diff --git a/.gitignore b/.gitignore index fdaf6278..3c7567d3 100644 --- a/.gitignore +++ b/.gitignore @@ -36,5 +36,5 @@ cover.out fairos.aar fairos-sources.jar -fairos.wasm +fairos.wasm* fairos.wasm.gz \ No newline at end of file diff --git a/cmd/common/request.go b/cmd/common/request.go index 1d70f451..7c7c764f 100644 --- a/cmd/common/request.go +++ b/cmd/common/request.go @@ -29,6 +29,12 @@ type UserLoginRequest struct { Password string `json:"password,omitempty"` } +// UserSignatureLoginRequest is the request body for user login with signature +type UserSignatureLoginRequest struct { + Signature string `json:"signature,omitempty"` + Password string `json:"password,omitempty"` +} + // PodRequest is the request body for pod creation type PodRequest struct { PodName string `json:"podName,omitempty"` diff --git a/cmd/dfs-cli/cmd/prompt.go b/cmd/dfs-cli/cmd/prompt.go index c06d0caa..c7c5f258 100644 --- a/cmd/dfs-cli/cmd/prompt.go +++ b/cmd/dfs-cli/cmd/prompt.go @@ -96,10 +96,11 @@ const ( apiDocLoadJson = apiVersion + "/doc/loadjson" apiDocIndexJson = apiVersion + "/doc/indexjson" - apiUserSignupV2 = apiVersionV2 + "/user/signup" - apiUserLoginV2 = apiVersionV2 + "/user/login" - apiUserPresentV2 = apiVersionV2 + "/user/present" - apiUserDeleteV2 = apiVersionV2 + "/user/delete" + apiUserSignupV2 = apiVersionV2 + "/user/signup" + apiUserLoginV2 = apiVersionV2 + "/user/login" + apiUserSignatureLogin = apiVersionV2 + "/user/login-with-signature" + apiUserPresentV2 = apiVersionV2 + "/user/present" + apiUserDeleteV2 = apiVersionV2 + "/user/delete" ) func newPrompt() { @@ -144,6 +145,7 @@ var userSuggestions = []prompt.Suggest{ {Text: "new", Description: "create a new user (v2)"}, {Text: "del", Description: "delete a existing user (v2)"}, {Text: "login", Description: "login to a existing user (v2)"}, + {Text: "signatureLogin", Description: "login with signature"}, {Text: "logout", Description: "logout from a logged-in user"}, {Text: "present", Description: "is user present (v2)"}, {Text: "stat", Description: "shows information about a user"}, @@ -308,6 +310,17 @@ func executor(in string) { currentPod = "" currentDirectory = "" currentPrompt = getCurrentPrompt() + case "signatureLogin": + if len(blocks) < 3 { + fmt.Println("invalid command. Missing \"signature\" argument") + return + } + signature := blocks[2] + fmt.Println("signatureLogin", signature) + signatureLogin(signature, apiUserSignatureLogin) + currentPod = "" + currentDirectory = "" + currentPrompt = getCurrentPrompt() case "present": if len(blocks) < 3 { fmt.Println("invalid command. Missing \"userName\" argument") @@ -1023,6 +1036,7 @@ func help() { fmt.Println(" - user (user-name) (mnemonic) - create a new user and login as that user") fmt.Println(" - user - deletes a logged-in user") fmt.Println(" - user (user-name) - login as a given user") + fmt.Println(" - user (signature) - login with signature") fmt.Println(" - user - logout a logged-in user") fmt.Println(" - user (user-name) - returns true if the user is present, false otherwise") fmt.Println(" - user - shows information about a user") diff --git a/cmd/dfs-cli/cmd/user.go b/cmd/dfs-cli/cmd/user.go index 3301baf8..66f3e81e 100644 --- a/cmd/dfs-cli/cmd/user.go +++ b/cmd/dfs-cli/cmd/user.go @@ -102,6 +102,36 @@ func userLogin(userName, apiEndpoint string) { fmt.Println(message) } +func signatureLogin(signature, apiEndpoint string) { + password := getPassword() + loginUser := common.UserSignatureLoginRequest{ + Signature: signature, + Password: password, + } + jsonData, err := json.Marshal(loginUser) + if err != nil { + fmt.Println("login user: error marshalling request") + return + } + data, err := fdfsAPI.postReq(http.MethodPost, apiEndpoint, jsonData) + if err != nil { + fmt.Println("login user: ", err) + return + } + var resp api.UserSignupResponse + err = json.Unmarshal(data, &resp) + if err != nil { + fmt.Println("create user: ", err) + return + } + + currentUser = resp.Address + message := strings.ReplaceAll(string(data), "\n", "") + fdfsAPI.setAccessToken(resp.AccessToken) + + fmt.Println(message) +} + func deleteUser(apiEndpoint string) { password := getPassword() delUser := common.UserSignupRequest{ diff --git a/cmd/dfs/cmd/dev.go b/cmd/dfs/cmd/dev.go index 48e56d98..e1c92faa 100644 --- a/cmd/dfs/cmd/dev.go +++ b/cmd/dfs/cmd/dev.go @@ -2,6 +2,8 @@ package cmd import ( "context" + "crypto/rand" + "encoding/hex" "fmt" "os" "os/signal" @@ -60,7 +62,7 @@ func startDevServer() { dfsApi := dfs.NewMockDfsAPI(mockClient, users, logger) handler = api.NewMockHandler(dfsApi, logger, []string{"http://localhost:3000"}) defer handler.Close() - httpPort = ":9093" + httpPort = ":9090" pprofPort = ":9091" srv := startHttpService(logger) fmt.Printf("Server running at:http://127.0.0.1%s\n", httpPort) @@ -72,6 +74,8 @@ func startDevServer() { }() done := make(chan os.Signal, 1) signal.Notify(done, syscall.SIGINT, syscall.SIGTERM) - + batchOk := make([]byte, 32) + _, _ = rand.Read(batchOk) + fmt.Println(hex.EncodeToString(batchOk)) <-done } diff --git a/cmd/dfs/cmd/server.go b/cmd/dfs/cmd/server.go index c0404667..7e6c02a9 100644 --- a/cmd/dfs/cmd/server.go +++ b/cmd/dfs/cmd/server.go @@ -297,6 +297,7 @@ func startHttpService(logger logging.Logger) *http.Server { router.HandleFunc("/public-file", handler.PublicPodGetFileHandler) router.HandleFunc("/public-dir", handler.PublicPodGetDirHandler) router.HandleFunc("/public-kv", handler.PublicPodKVEntryGetHandler) + router.HandleFunc("/public-pod-snapshot", handler.PodReceiveSnapshotHandler).Methods("GET") redirectHandler := func(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, r.URL.Path+"/", http.StatusMovedPermanently) @@ -333,6 +334,7 @@ func startHttpService(logger logging.Logger) *http.Server { baseRouterV2.Use(handler.LogMiddleware) baseRouterV2.HandleFunc("/user/signup", handler.UserSignupV2Handler).Methods("POST") baseRouterV2.HandleFunc("/user/login", handler.UserLoginV2Handler).Methods("POST") + baseRouterV2.HandleFunc("/user/login-with-signature", handler.UserLoginWithSignature).Methods("POST") baseRouterV2.HandleFunc("/user/present", handler.UserPresentV2Handler).Methods("GET") userRouterV2 := baseRouterV2.PathPrefix("/user/").Subrouter() userRouterV2.Use(handler.LoginMiddleware) diff --git a/cmd/dfs/cmd/server_test.go b/cmd/dfs/cmd/server_test.go index 8757683c..f333c9ea 100644 --- a/cmd/dfs/cmd/server_test.go +++ b/cmd/dfs/cmd/server_test.go @@ -17,6 +17,8 @@ import ( "testing" "time" + "github.com/fairdatasociety/fairOS-dfs/pkg/pod" + "github.com/fairdatasociety/fairOS-dfs/pkg/acl/acl" "github.com/stretchr/testify/assert" @@ -60,7 +62,7 @@ func TestApis(t *testing.T) { mockClient := bee.NewBeeClient(beeUrl, mock.BatchOkStr, true, 0, logger) ens := mock2.NewMockNamespaceManager() - users := user.NewUsers(mockClient, ens, 500, 0, logger) + users := user.NewUsers(mockClient, ens, -1, 0, logger) dfsApi := dfs.NewMockDfsAPI(mockClient, users, logger) handler = api.NewMockHandler(dfsApi, logger, []string{"http://localhost:3000"}) defer handler.Close() @@ -1084,6 +1086,309 @@ func TestApis(t *testing.T) { } }) + t.Run("signup-login-pod-dir-file-snapshot", func(t *testing.T) { + c := http.Client{Timeout: time.Duration(1) * time.Minute} + userRequest := &common.UserSignupRequest{ + UserName: randStringRunes(16), + Password: randStringRunes(12), + } + + userTwoRequest := &common.UserSignupRequest{ + UserName: randStringRunes(16), + Password: randStringRunes(12), + } + + userBytes, err := json.Marshal(userRequest) + if err != nil { + t.Fatal(err) + } + + userTwoBytes, err := json.Marshal(userTwoRequest) + if err != nil { + t.Fatal(err) + } + + cookies := [][]string{} + + for _, user := range [][]byte{userBytes, userTwoBytes} { + signupRequestDataHttpReq, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s%s", basev2, string(common.UserSignup)), bytes.NewBuffer(user)) + if err != nil { + t.Fatal(err) + } + signupRequestDataHttpReq.Header.Add("Content-Type", "application/json") + signupRequestDataHttpReq.Header.Add("Content-Length", strconv.Itoa(len(user))) + signupRequestResp, err := c.Do(signupRequestDataHttpReq) + if err != nil { + t.Fatal(err) + } + + err = signupRequestResp.Body.Close() + if err != nil { + t.Fatal(err) + } + if signupRequestResp.StatusCode != http.StatusCreated { + t.Fatal("Signup failed", signupRequestResp.StatusCode) + } + + userLoginHttpReq, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s%s", basev2, string(common.UserLogin)), bytes.NewBuffer(user)) + if err != nil { + t.Fatal(err) + + } + userLoginHttpReq.Header.Add("Content-Type", "application/json") + userLoginHttpReq.Header.Add("Content-Length", strconv.Itoa(len(user))) + userLoginResp, err := c.Do(userLoginHttpReq) + if err != nil { + t.Fatal(err) + } + err = userLoginResp.Body.Close() + if err != nil { + t.Fatal(err) + } + if userLoginResp.StatusCode != http.StatusOK { + t.Fatal("user should be able to login") + } + cookie := userLoginResp.Header["Set-Cookie"] + cookies = append(cookies, cookie) + } + + // pod new + podRequest := &common.PodRequest{ + PodName: randStringRunes(16), + } + podBytes, err := json.Marshal(podRequest) + if err != nil { + t.Fatal(err) + } + podNewHttpReq, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s%s", basev1, string(common.PodNew)), bytes.NewBuffer(podBytes)) + if err != nil { + t.Fatal(err) + } + podNewHttpReq.Header.Set("Cookie", cookies[0][0]) + podNewHttpReq.Header.Add("Content-Type", "application/json") + podNewHttpReq.Header.Add("Content-Length", strconv.Itoa(len(podBytes))) + podNewResp, err := c.Do(podNewHttpReq) + if err != nil { + t.Fatal(err) + } + + err = podNewResp.Body.Close() + if err != nil { + t.Fatal(err) + } + if podNewResp.StatusCode != 201 { + t.Fatal("pod creation failed") + } + + entries := []struct { + path string + isDir bool + size int64 + content []byte + }{ + { + path: "/dir1", + isDir: true, + }, + { + path: "/dir2", + isDir: true, + }, + { + path: "/dir3", + isDir: true, + }, + { + path: "/file1", + size: 1024 * 1024, + }, + { + path: "/dir1/file11", + size: 1024 * 512, + }, + { + path: "/dir1/file12", + size: 1024 * 1024, + }, + { + path: "/dir3/file31", + size: 1024 * 1024, + }, + { + path: "/dir3/file32", + size: 1024 * 1024, + }, + { + path: "/dir3/file33", + size: 1024, + }, + { + path: "/dir2/dir4", + isDir: true, + }, + { + path: "/dir2/dir4/dir5", + isDir: true, + }, + { + path: "/dir2/dir4/file241", + size: 5 * 1024 * 1024, + }, + { + path: "/dir2/dir4/dir5/file2451", + size: 10 * 1024 * 1024, + }, + } + + for _, v := range entries { + if v.isDir { + mkdirRqst := common.FileSystemRequest{ + PodName: podRequest.PodName, + DirectoryPath: v.path, + } + mkDirBytes, err := json.Marshal(mkdirRqst) + if err != nil { + t.Fatal(err) + } + mkDirHttpReq, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s%s", basev1, string(common.DirMkdir)), bytes.NewBuffer(mkDirBytes)) + if err != nil { + t.Fatal(err) + + } + mkDirHttpReq.Header.Set("Cookie", cookies[0][0]) + mkDirHttpReq.Header.Add("Content-Type", "application/json") + mkDirHttpReq.Header.Add("Content-Length", strconv.Itoa(len(mkDirBytes))) + mkDirResp, err := c.Do(mkDirHttpReq) + if err != nil { + t.Fatal(err) + } + err = mkDirResp.Body.Close() + if err != nil { + t.Fatal(err) + } + if mkDirResp.StatusCode != 201 { + t.Fatal("mkdir failed") + } + } else { + body := new(bytes.Buffer) + writer := multipart.NewWriter(body) + contentLength := fmt.Sprintf("%d", v.size) + + err = writer.WriteField("podName", podRequest.PodName) + if err != nil { + t.Fatal(err) + } + err = writer.WriteField("contentLength", contentLength) + if err != nil { + t.Fatal(err) + } + err = writer.WriteField("dirPath", filepath.Dir(v.path)) + if err != nil { + t.Fatal(err) + } + err = writer.WriteField("blockSize", "1Mb") + if err != nil { + t.Fatal(err) + } + part, err := writer.CreateFormFile("files", filepath.Base(v.path)) + if err != nil { + t.Fatal(err) + } + reader := &io.LimitedReader{R: rand.Reader, N: v.size} + _, err = io.Copy(part, reader) + if err != nil { + t.Fatal(err) + } + + err = writer.Close() + if err != nil { + t.Fatal(err) + } + + uploadReq, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s%s", basev1, string(common.FileUpload)), body) + if err != nil { + t.Fatal(err) + + } + uploadReq.Header.Set("Cookie", cookies[0][0]) + contentType := fmt.Sprintf("multipart/form-data;boundary=%v", writer.Boundary()) + uploadReq.Header.Add("Content-Type", contentType) + uploadResp, err := c.Do(uploadReq) + if err != nil { + t.Fatal(err) + } + err = uploadResp.Body.Close() + if err != nil { + t.Fatal(err) + } + if uploadResp.StatusCode != 200 { + t.Fatal("upload failed") + } + } + } + <-time.After(time.Second * 2) + podShareRequest := &common.PodShareRequest{ + PodName: podRequest.PodName, + SharedPodName: "sharedPod", + } + podShareBytes, err := json.Marshal(podShareRequest) + if err != nil { + t.Fatal(err) + } + podShareHttpReq, err := http.NewRequest(http.MethodPost, fmt.Sprintf("%s%s", basev1, "/pod/share"), bytes.NewBuffer(podShareBytes)) + if err != nil { + t.Fatal(err) + } + podShareHttpReq.Header.Set("Cookie", cookies[0][0]) + podShareHttpReq.Header.Add("Content-Type", "application/json") + podShareHttpReq.Header.Add("Content-Length", strconv.Itoa(len(podShareBytes))) + podShareResp, err := c.Do(podShareHttpReq) + if err != nil { + t.Fatal(err) + } + + podShareData := &api.PodSharingReference{} + podShareRespBytes, err := io.ReadAll(podShareResp.Body) + if err != nil { + t.Fatal(err) + } + + err = json.Unmarshal(podShareRespBytes, podShareData) + if err != nil { + t.Fatal(err) + } + err = podShareResp.Body.Close() + if err != nil { + t.Fatal(err) + } + if podShareResp.StatusCode != 200 { + t.Fatal("pod share failed") + } + podSnapHttpReq, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s%s%s", "http://localhost:9090", "/public-pod-snapshot?sharingRef=", podShareData.Reference), http.NoBody) + if err != nil { + t.Fatal(err) + } + podSnapHttpReq.Header.Add("Content-Type", "application/json") + podSnapResp, err := c.Do(podSnapHttpReq) + if err != nil { + t.Fatal(err) + } + + data, err := io.ReadAll(podSnapResp.Body) + if err != nil { + t.Fatal(err) + } + snap := &pod.DirSnapShot{} + err = json.Unmarshal(data, snap) + if err != nil { + t.Fatal(err) + } + err = podSnapResp.Body.Close() + if err != nil { + t.Fatal(err) + } + }) + t.Run("group-test", func(t *testing.T) { c := http.Client{Timeout: time.Duration(1) * time.Minute} userRequest := &common.UserSignupRequest{ diff --git a/go.mod b/go.mod index c4031737..c21a152e 100644 --- a/go.mod +++ b/go.mod @@ -1,15 +1,16 @@ module github.com/fairdatasociety/fairOS-dfs -go 1.21 +go 1.22 + +toolchain go1.22.0 require ( github.com/btcsuite/btcd/btcec/v2 v2.3.3 github.com/c-bata/go-prompt v0.2.6 github.com/dustin/go-humanize v1.0.1 - github.com/ethereum/go-ethereum v1.14.0 - github.com/ethersphere/bee/v2 v2.0.0 + github.com/ethereum/go-ethereum v1.14.7 + github.com/ethersphere/bee/v2 v2.1.1-0.20240611213428-4b04c086d8db github.com/ethersphere/bmt v0.1.4 - github.com/fairdatasociety/fairOS-dfs-utils v0.0.0-20221230123929-aec4ed8b854d github.com/golang-jwt/jwt/v5 v5.2.1 github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 @@ -21,7 +22,7 @@ require ( github.com/miguelmota/go-ethereum-hdwallet v0.1.2 github.com/mitchellh/go-homedir v1.1.0 github.com/plexsysio/taskmanager v0.0.0-20211220123746-de5ebdd49ae2 - github.com/rs/cors v1.10.1 + github.com/rs/cors v1.11.0 github.com/sirupsen/logrus v1.9.3 github.com/spf13/cobra v1.8.0 github.com/spf13/viper v1.18.2 @@ -32,34 +33,31 @@ require ( github.com/tyler-smith/go-bip39 v1.1.0 github.com/wealdtech/go-ens/v3 v3.6.0 go.uber.org/goleak v1.3.0 - golang.org/x/crypto v0.22.0 - golang.org/x/term v0.19.0 + golang.org/x/crypto v0.25.0 + golang.org/x/term v0.22.0 gopkg.in/yaml.v2 v2.4.0 resenje.org/jsonhttp v0.2.3 ) require ( - github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect github.com/KyleBanks/depth v1.2.1 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/Microsoft/go-winio v0.6.2 // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bits-and-blooms/bitset v1.10.0 // indirect github.com/btcsuite/btcd v0.22.3 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce // indirect - github.com/casbin/casbin/v2 v2.35.0 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/deckarep/golang-set/v2 v2.1.0 // indirect + github.com/deckarep/golang-set/v2 v2.6.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/ethereum/c-kzg-4844 v1.0.0 // indirect - github.com/ethersphere/bee v1.10.0 // indirect github.com/ethersphere/go-price-oracle-abi v0.2.0 // indirect - github.com/ethersphere/go-storage-incentives-abi v0.6.2 // indirect + github.com/ethersphere/go-storage-incentives-abi v0.8.6 // indirect github.com/ethersphere/go-sw3-abi v0.6.5 // indirect github.com/ethersphere/langos v1.0.0 // indirect github.com/felixge/httpsnoop v1.0.3 // indirect @@ -73,54 +71,52 @@ require ( github.com/go-playground/universal-translator v0.18.0 // indirect github.com/go-playground/validator/v10 v10.11.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.4 // indirect - github.com/google/go-cmp v0.6.0 // indirect github.com/google/uuid v1.4.0 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/holiman/uint256 v1.2.4 // indirect + github.com/holiman/uint256 v1.3.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/klauspost/compress v1.17.0 // indirect - github.com/klauspost/cpuid/v2 v2.2.6 // indirect + github.com/klauspost/compress v1.17.6 // indirect + github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/klauspost/reedsolomon v1.11.8 // indirect github.com/leodido/go-urn v1.2.1 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect - github.com/libp2p/go-libp2p v0.30.0 // indirect + github.com/libp2p/go-libp2p v0.33.2 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.13 // indirect github.com/mattn/go-tty v0.0.3 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/miekg/dns v1.1.55 // indirect + github.com/miekg/dns v1.1.58 // indirect github.com/minio/sha256-simd v1.0.1 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mmcloughlin/addchain v0.4.0 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/multiformats/go-base32 v0.1.0 // indirect github.com/multiformats/go-base36 v0.2.0 // indirect - github.com/multiformats/go-multiaddr v0.11.0 // indirect + github.com/multiformats/go-multiaddr v0.12.3 // indirect github.com/multiformats/go-multiaddr-dns v0.3.1 // indirect github.com/multiformats/go-multibase v0.2.0 // indirect github.com/multiformats/go-multicodec v0.9.0 // indirect github.com/multiformats/go-multihash v0.2.3 // indirect - github.com/multiformats/go-multistream v0.4.1 // indirect + github.com/multiformats/go-multistream v0.5.0 // indirect github.com/multiformats/go-varint v0.0.7 // indirect + github.com/onsi/ginkgo v1.16.4 // indirect github.com/onsi/gomega v1.27.10 // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pkg/term v1.2.0-beta.2 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus/client_golang v1.14.0 // indirect - github.com/prometheus/client_model v0.4.0 // indirect - github.com/prometheus/common v0.42.0 // indirect - github.com/prometheus/procfs v0.9.0 // indirect + github.com/prometheus/client_golang v1.18.0 // indirect + github.com/prometheus/client_model v0.6.0 // indirect + github.com/prometheus/common v0.47.0 // indirect + github.com/prometheus/procfs v0.12.0 // indirect github.com/rivo/uniseg v0.2.0 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect @@ -145,13 +141,13 @@ require ( github.com/yusufpapurcu/wmi v1.2.2 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect + golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect golang.org/x/mod v0.17.0 // indirect - golang.org/x/net v0.24.0 // indirect + golang.org/x/net v0.25.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.19.0 // indirect - golang.org/x/text v0.14.0 // indirect - golang.org/x/tools v0.20.0 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/text v0.16.0 // indirect + golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect @@ -162,4 +158,6 @@ require ( rsc.io/tmplfunc v0.0.3 // indirect ) +//replace github.com/ethersphere/bee/v2 => ../../ethersphere/bee + replace github.com/codahale/hdrhistogram => github.com/HdrHistogram/hdrhistogram-go v0.0.0-20200919145931-8dac23c8dac1 diff --git a/go.sum b/go.sum index b40b03e4..cfae0b2a 100644 --- a/go.sum +++ b/go.sum @@ -1,22 +1,16 @@ -contrib.go.opencensus.io/exporter/prometheus v0.4.2 h1:sqfsYl5GIY/L570iT+l93ehxaWJs2/OwXtiWwew3oAg= -contrib.go.opencensus.io/exporter/prometheus v0.4.2/go.mod h1:dvEHbiKmgvbr5pjaF9fpw1KeYcjrnC1J8B+JKjsZyRQ= github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/HdrHistogram/hdrhistogram-go v0.0.0-20200919145931-8dac23c8dac1 h1:nEjGZtKHMK92888VT6XkzKwyiW14v5FFRGeWq2uV7N0= github.com/HdrHistogram/hdrhistogram-go v0.0.0-20200919145931-8dac23c8dac1/go.mod h1:nxrse8/Tzg2tg3DZcZjm6qEclQKK70g0KxO61gFFZD4= -github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw= -github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= -github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow= -github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= -github.com/VictoriaMetrics/fastcache v1.12.1 h1:i0mICQuojGDL3KblA7wUNlY5lOK6a4bwt3uRKnkZU40= -github.com/VictoriaMetrics/fastcache v1.12.1/go.mod h1:tX04vaqcNoQeGLD+ra5pU5sWkuxnzWhEzLwhP9w653o= +github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= +github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= +github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= +github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= -github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= @@ -39,18 +33,18 @@ github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtE github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/c-bata/go-prompt v0.2.6 h1:POP+nrHE+DfLYx370bedwNhsqmpCUynWPxuHi0C5vZI= github.com/c-bata/go-prompt v0.2.6/go.mod h1:/LMAke8wD2FsNu9EXNdHxNLbd9MedkPnCdfpU9wwHfY= -github.com/casbin/casbin/v2 v2.35.0 h1:f0prVg9LgTJTihjAxWEZhfJptXvah1GpZh12sb5KXNA= -github.com/casbin/casbin/v2 v2.35.0/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg= github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cockroachdb/errors v1.11.1 h1:xSEW75zKaKCWzR3OfxXUxgrk/NtT4G1MiOv5lWZazG8= -github.com/cockroachdb/errors v1.11.1/go.mod h1:8MUxA3Gi6b25tYlFEBGLf+D8aISL+M4MIpiWMSNRfxw= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cockroachdb/errors v1.11.3 h1:5bA+k2Y6r+oz/6Z/RFlNeVCesGARKuC6YymtcDrbC/I= +github.com/cockroachdb/errors v1.11.3/go.mod h1:m4UIW4CDjx+R5cybPsNrRbreomiFqt8o1h1wUVazSd8= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce h1:giXvy4KSc/6g/esnpM7Geqxka4WSqI1SZc7sMJFd3y4= +github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce/go.mod h1:9/y3cnZ5GKakj/H4y9r9GTjCvAFta7KLgSHPJJYc52M= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= -github.com/cockroachdb/pebble v1.1.0 h1:pcFh8CdCIt2kmEpK0OIatq67Ln9uGDYY3d5XnE0LJG4= -github.com/cockroachdb/pebble v1.1.0/go.mod h1:sEHm5NOXxyiAoKWhoFxT8xMgd/f3RA6qUqQ1BXKrh2E= +github.com/cockroachdb/pebble v1.1.1 h1:XnKU22oiCLy2Xn8vp1re67cXg4SAasg/WDt1NtcRFaw= +github.com/cockroachdb/pebble v1.1.1/go.mod h1:4exszw1r40423ZsmkG/09AFEG83I0uDgfujJdbL6kYU= github.com/cockroachdb/redact v1.1.5 h1:u1PMllDkdFfPWaNGMyLD1+so+aq3uUItthCFqzwPJ30= github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo= @@ -59,16 +53,10 @@ github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/Yj github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M= github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY= -github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= -github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw= -github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= -github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= -github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 h1:d28BXYi+wUpz1KBmiF9bWrjEMacUEREV6MBi2ODnrfQ= -github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c h1:uQYC5Z1mdLRPrZhHjHxufI8+2UG/i25QG92j0Er9p6I= +github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= github.com/crate-crypto/go-kzg-4844 v1.0.0 h1:TsSgHwrkTKecKJ4kadtHi4b3xHW5dCFUDFnUp1TsawI= github.com/crate-crypto/go-kzg-4844 v1.0.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -77,49 +65,37 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c h1:pFUpOrbxDR6AkioZ1ySsx5yxlDQZ8stG2b88gTPxgJU= -github.com/davidlazar/go-crypto v0.0.0-20200604182044-b73af7476f6c/go.mod h1:6UhI8N9EjYm1c2odKpFpAYeR8dsBeM7PtzQhRgxRr9U= -github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= -github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/deckarep/golang-set/v2 v2.6.0 h1:XfcQbWM1LlMB8BsJ8N9vW5ehnnPVIw0je80NsVHagjM= +github.com/deckarep/golang-set/v2 v2.6.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= -github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= -github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= -github.com/elastic/gosigar v0.14.2 h1:Dg80n8cr90OZ7x+bAax/QjoW/XqTI11RmA79ZwIm9/4= -github.com/elastic/gosigar v0.14.2/go.mod h1:iXRIGg2tLnu7LBdpqzyQfGDEidKCfWcCMS0WKyPWoMs= github.com/ethereum/c-kzg-4844 v1.0.0 h1:0X1LBXxaEtYD9xsyj9B9ctQEZIpnvVDeoBx8aHEwTNA= github.com/ethereum/c-kzg-4844 v1.0.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= -github.com/ethereum/go-ethereum v1.14.0 h1:xRWC5NlB6g1x7vNy4HDBLuqVNbtLrc7v8S6+Uxim1LU= -github.com/ethereum/go-ethereum v1.14.0/go.mod h1:1STrq471D0BQbCX9He0hUj4bHxX2k6mt5nOQJhDNOJ8= -github.com/ethersphere/bee v1.10.0 h1:GVMO/aTgxNFX6IZyBYJKoR8OFnEjJjQnuQPuY/M75zs= -github.com/ethersphere/bee v1.10.0/go.mod h1:zy0U2o4EvOKiRKb67TdZnSOP8tTnrc62+bsJCgqeEPs= -github.com/ethersphere/bee/v2 v2.0.0 h1:hGSSIKpXRa/uP9lYW7tecAoEWFEDzGO/dJo5UhkRllc= -github.com/ethersphere/bee/v2 v2.0.0/go.mod h1:5pP4lvNuEdvar6NlKjqVWM8y9ArNGblleTF+2lhx8EA= +github.com/ethereum/go-ethereum v1.14.7 h1:EHpv3dE8evQmpVEQ/Ne2ahB06n2mQptdwqaMNhAT29g= +github.com/ethereum/go-ethereum v1.14.7/go.mod h1:Mq0biU2jbdmKSZoqOj29017ygFrMnB5/Rifwp980W4o= +github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 h1:KrE8I4reeVvf7C1tm8elRjj4BdscTYzz/WAbYyf/JI4= +github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0/go.mod h1:D9AJLVXSyZQXJQVk8oh1EwjISE+sJTn2duYIZC0dy3w= +github.com/ethersphere/bee/v2 v2.1.1-0.20240611213428-4b04c086d8db h1:+CWPPQnOQDCUTAODgbhNT7e3UcF7ZsFBCHD3ExobeI8= +github.com/ethersphere/bee/v2 v2.1.1-0.20240611213428-4b04c086d8db/go.mod h1:2XYm5T9MbERw7caUg/iC38kwwpr8ZjMhokW0khdr3H4= github.com/ethersphere/bmt v0.1.4 h1:+rkWYNtMgDx6bkNqGdWu+U9DgGI1rRZplpSW3YhBr1Q= github.com/ethersphere/bmt v0.1.4/go.mod h1:Yd8ft1U69WDuHevZc/rwPxUv1rzPSMpMnS6xbU53aY8= github.com/ethersphere/go-price-oracle-abi v0.2.0 h1:wtIcYLgNZHY4BjYwJCnu93SvJdVAZVvBaKinspyyHvQ= github.com/ethersphere/go-price-oracle-abi v0.2.0/go.mod h1:sI/Qj4/zJ23/b1enzwMMv0/hLTpPNVNacEwCWjo6yBk= -github.com/ethersphere/go-storage-incentives-abi v0.6.2 h1:lcVylu+KRUEOUvytP6ofcyTwTE7UmfE2oJPC4jpVjSo= -github.com/ethersphere/go-storage-incentives-abi v0.6.2/go.mod h1:SXvJVtM4sEsaSKD0jc1ClpDLw8ErPoROZDme4Wrc/Nc= +github.com/ethersphere/go-storage-incentives-abi v0.8.6 h1:M9WwEtWoxVHKehBAoPMzQhXlzlBetuXsrGgoFvM5I8Y= +github.com/ethersphere/go-storage-incentives-abi v0.8.6/go.mod h1:SXvJVtM4sEsaSKD0jc1ClpDLw8ErPoROZDme4Wrc/Nc= github.com/ethersphere/go-sw3-abi v0.6.5 h1:M5dcIe1zQYvGpY2K07UNkNU9Obc4U+A1fz68Ho/Q+XE= github.com/ethersphere/go-sw3-abi v0.6.5/go.mod h1:BmpsvJ8idQZdYEtWnvxA8POYQ8Rl/NhyCdF0zLMOOJU= github.com/ethersphere/langos v1.0.0 h1:NBtNKzXTTRSue95uOlzPN4py7Aofs0xWPzyj4AI1Vcc= github.com/ethersphere/langos v1.0.0/go.mod h1:dlcN2j4O8sQ+BlCaxeBu43bgr4RQ+inJ+pHwLeZg5Tw= -github.com/fairdatasociety/fairOS-dfs-utils v0.0.0-20221230123929-aec4ed8b854d h1:4QgyFcv+J02YdPZ92oiCjjQ8QtGl/UbLTAypKb+WfZc= -github.com/fairdatasociety/fairOS-dfs-utils v0.0.0-20221230123929-aec4ed8b854d/go.mod h1:f4lfxKoK1n4S+2II4lyVmuvWISAMThqH+uc/XL62tzU= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk= github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/fjl/memsize v0.0.2 h1:27txuSD9or+NZlnOWdKUxeBzTAUkWCVh+4Gf2dWFOzA= github.com/fjl/memsize v0.0.2/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= -github.com/flynn/noise v1.0.0 h1:DlTHqmzmvcEiKj+4RYo/imoswx/4r6iBlCMfVtrMXpQ= -github.com/flynn/noise v1.0.0/go.mod h1:xbMo+0i6+IGbYdJhF31t2eR1BIU0CYc12+BNAKwUTag= -github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= -github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -128,14 +104,8 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= -github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46 h1:BAIP2GihuqhwdILrV+7GJel5lyPV3u1+PgzrWLc0TkE= -github.com/gballet/go-verkle v0.1.1-0.20231031103413-a67434b50f46/go.mod h1:QNpY22eby74jVhqH4WhDLDwxc/vqsern6pW+u2kbkpc= -github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= -github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ= -github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= -github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= -github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= +github.com/getsentry/sentry-go v0.27.0 h1:Pv98CIbtB3LkMWmXi4Joa5OOcwbmnX88sF5qbK3r3Ps= +github.com/getsentry/sentry-go v0.27.0/go.mod h1:lc76E2QywIyW8WuBnwl8Lc4bkmQH4+w1gwTf25trprY= github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE= github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78= @@ -158,10 +128,7 @@ github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/j github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ= github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= -github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= -github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= -github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= @@ -170,11 +137,6 @@ github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOW github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= @@ -182,8 +144,6 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -194,10 +154,6 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gopacket v1.1.19 h1:ves8RnFZPGiFnTS0uPQStjwru6uO6h+nlr9j6fL7kF8= -github.com/google/gopacket v1.1.19/go.mod h1:iJ8V8n6KS+z2U1A8pUwu8bW5SyEMkXJB8Yo/Vo+TKTo= -github.com/google/pprof v0.0.0-20230817174616-7a8ec2ada47b h1:h9U78+dx9a4BKdQkBBos92HalKpaGKHrp+3Uo6yTodo= -github.com/google/pprof v0.0.0-20230817174616-7a8ec2ada47b/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= @@ -225,8 +181,8 @@ github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6w github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= -github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= -github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= +github.com/holiman/uint256 v1.3.0 h1:4wdcm/tnd0xXdu7iS3ruNvxkWwrb4aeBQv19ayYn8F4= +github.com/holiman/uint256 v1.3.0/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= @@ -234,13 +190,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= -github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8= -github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY= -github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= -github.com/jbenet/go-temp-err-catcher v0.1.0 h1:zpb3ZH6wIE8Shj2sKS+khgRvf7T7RABoLk/+KKHggpk= -github.com/jbenet/go-temp-err-catcher v0.1.0/go.mod h1:0kJRvmDZXNMIiJirNPEYfhpPwbGVtZVWC34vc5WLsDk= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= @@ -248,16 +199,14 @@ github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlT github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= -github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJwgrqM= -github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc= -github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/klauspost/compress v1.17.6 h1:60eq2E/jlfwQXtvZEeBUYADs+BwKBWURIY+Gj2eRGjI= +github.com/klauspost/compress v1.17.6/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM= +github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= +github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU= github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/klauspost/reedsolomon v1.11.8 h1:s8RpUW5TK4hjr+djiOpbZJB4ksx+TdYbRH7vHQpwPOY= github.com/klauspost/reedsolomon v1.11.8/go.mod h1:4bXRN+cVzMdml6ti7qLouuYi32KHJ5MGv0Qd8a47h6A= -github.com/koron/go-ssdp v0.0.4 h1:1IDwrghSKYM7yLf7XCzbByg2sJ/JcNOZRXS2jczTwz0= -github.com/koron/go-ssdp v0.0.4/go.mod h1:oDXq+E5IL5q0U8uSBcoAXzTzInwy5lEgC91HoKtbmZk= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= @@ -275,24 +224,8 @@ github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= -github.com/libp2p/go-cidranger v1.1.0 h1:ewPN8EZ0dd1LSnrtuwd4709PXVcITVeuwbag38yPW7c= -github.com/libp2p/go-cidranger v1.1.0/go.mod h1:KWZTfSr+r9qEo9OkI9/SIEeAtw+NNoU0dXIXt15Okic= -github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM= -github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro= -github.com/libp2p/go-libp2p v0.30.0 h1:9EZwFtJPFBcs/yJTnP90TpN1hgrT/EsFfM+OZuwV87U= -github.com/libp2p/go-libp2p v0.30.0/go.mod h1:nr2g5V7lfftwgiJ78/HrID+pwvayLyqKCEirT2Y3Byg= -github.com/libp2p/go-libp2p-asn-util v0.3.0 h1:gMDcMyYiZKkocGXDQ5nsUQyquC9+H+iLEQHwOCZ7s8s= -github.com/libp2p/go-libp2p-asn-util v0.3.0/go.mod h1:B1mcOrKUE35Xq/ASTmQ4tN3LNzVVaMNmq2NACuqyB9w= -github.com/libp2p/go-msgio v0.3.0 h1:mf3Z8B1xcFN314sWX+2vOTShIE0Mmn2TXn3YCUQGNj0= -github.com/libp2p/go-msgio v0.3.0/go.mod h1:nyRM819GmVaF9LX3l03RMh10QdOroF++NBbxAb0mmDM= -github.com/libp2p/go-nat v0.2.0 h1:Tyz+bUFAYqGyJ/ppPPymMGbIgNRH+WqC5QrT5fKrrGk= -github.com/libp2p/go-nat v0.2.0/go.mod h1:3MJr+GRpRkyT65EpVPBstXLvOlAPzUVlG6Pwg9ohLJk= -github.com/libp2p/go-netroute v0.2.1 h1:V8kVrpD8GK0Riv15/7VN6RbUQ3URNZVosw7H2v9tksU= -github.com/libp2p/go-netroute v0.2.1/go.mod h1:hraioZr0fhBjG0ZRXJJ6Zj2IVEVNx6tDTFQfSmcq7mQ= -github.com/libp2p/go-reuseport v0.4.0 h1:nR5KU7hD0WxXCJbmw7r2rhRYruNRl2koHw8fQscQm2s= -github.com/libp2p/go-reuseport v0.4.0/go.mod h1:ZtI03j/wO5hZVDFo2jKywN6bYKWLOy8Se6DrI2E1cLU= -github.com/libp2p/go-yamux/v4 v4.0.1 h1:FfDR4S1wj6Bw2Pqbc8Uz7pCxeRBPbwsBbEdfwiCypkQ= -github.com/libp2p/go-yamux/v4 v4.0.1/go.mod h1:NWjl8ZTLOGlozrXSOZ/HlfG++39iKNnM5wwmtQP1YB4= +github.com/libp2p/go-libp2p v0.33.2 h1:vCdwnFxoGOXMKmaGHlDSnL4bM3fQeW8pgIa9DECnb40= +github.com/libp2p/go-libp2p v0.33.2/go.mod h1:zTeppLuCvUIkT118pFVzA8xzP/p2dJYOMApCkFh0Yww= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -300,8 +233,6 @@ github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd h1:br0buuQ854V8u83wA0rVZ8ttrq5CpaPZdvrK0LP2lOk= -github.com/marten-seemann/tcp v0.0.0-20210406111302-dfbc87cc63fd/go.mod h1:QuCEs1Nt24+FYQEqAAncTDPJIuGs+LxK1MCiFL25pMU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -310,25 +241,19 @@ github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hd github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-tty v0.0.3 h1:5OfyWorkyO7xP52Mq7tB36ajHDG5OHrmBGIS/DtakQI= github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0= -github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= -github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= -github.com/miekg/dns v1.1.55 h1:GoQ4hpsj0nFLYe+bWiCToyrBEJXkQfOOIvFGFy0lEgo= -github.com/miekg/dns v1.1.55/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= +github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4= +github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY= github.com/miguelmota/go-ethereum-hdwallet v0.1.2 h1:mz9LO6V7QCRkLYb0AH17t5R8KeqCe3E+hx9YXpmZeXA= github.com/miguelmota/go-ethereum-hdwallet v0.1.2/go.mod h1:fdNwFSoBFVBPnU0xpOd6l2ueqsPSH/Gch5kIvSvTGk8= -github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b h1:z78hV3sbSMAUoyUMM0I83AUIT6Hu17AWfgjzIbtrYFc= -github.com/mikioh/tcpinfo v0.0.0-20190314235526-30a79bb1804b/go.mod h1:lxPUiZwKoFL8DUUmalo2yJJUCxbPKtm8OKfqr2/FTNU= -github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc h1:PTfri+PuQmWDqERdnNMiD9ZejrlswWrCpBEZgWOiTrc= -github.com/mikioh/tcpopt v0.0.0-20190314235656-172688c1accc/go.mod h1:cGKTAVKx4SxOuR/czcZ/E2RSJ3sfHs8FpHhQ5CWMf9s= github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ= github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= @@ -350,12 +275,10 @@ github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYg github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0= github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4= github.com/multiformats/go-multiaddr v0.2.0/go.mod h1:0nO36NvPpyV4QzvTLi/lafl2y95ncPj0vFwVF6k6wJ4= -github.com/multiformats/go-multiaddr v0.11.0 h1:XqGyJ8ufbCE0HmTDwx2kPdsrQ36AGPZNZX6s6xfJH10= -github.com/multiformats/go-multiaddr v0.11.0/go.mod h1:gWUm0QLR4thQ6+ZF6SXUw8YjtwQSPapICM+NmCkxHSM= +github.com/multiformats/go-multiaddr v0.12.3 h1:hVBXvPRcKG0w80VinQ23P5t7czWgg65BmIvQKjDydU8= +github.com/multiformats/go-multiaddr v0.12.3/go.mod h1:sBXrNzucqkFJhvKOiwwLyqamGa/P5EIXNPLovyhQCII= github.com/multiformats/go-multiaddr-dns v0.3.1 h1:QgQgR+LQVt3NPTjbrLLpsaT2ufAA2y0Mkk+QRVJbW3A= github.com/multiformats/go-multiaddr-dns v0.3.1/go.mod h1:G/245BRQ6FJGmryJCrOuTdB37AMA5AMOVuO6NY3JwTk= -github.com/multiformats/go-multiaddr-fmt v0.1.0 h1:WLEFClPycPkp4fnIzoFoV9FVd49/eQsuaL3/CWe167E= -github.com/multiformats/go-multiaddr-fmt v0.1.0/go.mod h1:hGtDIW4PU4BqJ50gW2quDuPVjyWNZxToGUh/HwTZYJo= github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g= github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk= github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3IbPKOXWJkmg= @@ -363,8 +286,8 @@ github.com/multiformats/go-multicodec v0.9.0/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI1 github.com/multiformats/go-multihash v0.0.8/go.mod h1:YSLudS+Pi8NHE7o6tb3D8vrpKa63epEDmG8nTduyAew= github.com/multiformats/go-multihash v0.2.3 h1:7Lyc8XfX/IY2jWb/gI7JP+o7JEq9hOa7BFvVU9RSh+U= github.com/multiformats/go-multihash v0.2.3/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM= -github.com/multiformats/go-multistream v0.4.1 h1:rFy0Iiyn3YT0asivDUIR05leAdwZq3de4741sbiSdfo= -github.com/multiformats/go-multistream v0.4.1/go.mod h1:Mz5eykRVAjJWckE2U78c6xqdtyNUEhKSM0Lwar2p77Q= +github.com/multiformats/go-multistream v0.5.0 h1:5htLSLl7lvJk3xx3qT/8Zm9J4K8vEOf/QGkvOGQAyiE= +github.com/multiformats/go-multistream v0.5.0/go.mod h1:n6tMZiwiP2wUsR8DgfDWw1dydlEqV3l6N3/GBsX6ILA= github.com/multiformats/go-varint v0.0.1/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE= github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= @@ -378,21 +301,15 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= -github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU= -github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= -github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= +github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= -github.com/opencontainers/runtime-spec v1.1.0 h1:HHUyrt9mwHUjtasSbXSMvs4cyFxh+Bll4AjJ9odEGpg= -github.com/opencontainers/runtime-spec v1.1.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs= github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= -github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0= -github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= @@ -405,34 +322,22 @@ github.com/plexsysio/taskmanager v0.0.0-20211220123746-de5ebdd49ae2/go.mod h1:mr github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= -github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= -github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= -github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= -github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM= -github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc= -github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= -github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= -github.com/prometheus/statsd_exporter v0.22.7 h1:7Pji/i2GuhK6Lu7DHrtTkFmNBCudCPT1pX2CziuyQR0= -github.com/prometheus/statsd_exporter v0.22.7/go.mod h1:N/TevpjkIh9ccs6nuzY3jQn9dFqnUakOjnEuMPJJJnI= -github.com/quic-go/qpack v0.4.0 h1:Cr9BXA1sQS2SmDUWjSofMPNKmvF6IiIfDRmgU0w1ZCo= -github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A= -github.com/quic-go/qtls-go1-20 v0.3.3 h1:17/glZSLI9P9fDAeyCHBFSWSqJcwx1byhLwP5eUIDCM= -github.com/quic-go/qtls-go1-20 v0.3.3/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k= -github.com/quic-go/quic-go v0.38.2 h1:VWv/6gxIoB8hROQJhx1JEyiegsUQ+zMN3em3kynTGdg= -github.com/quic-go/quic-go v0.38.2/go.mod h1:ijnZM7JsFIkp4cRyjxJNIzdSfCLmUMg9wdyhGmg+SN4= -github.com/quic-go/webtransport-go v0.5.3 h1:5XMlzemqB4qmOlgIus5zB45AcZ2kCgCy2EptUrfOPWU= -github.com/quic-go/webtransport-go v0.5.3/go.mod h1:OhmmgJIzTTqXK5xvtuX0oBpLV2GkLWNDA+UeTGJXErU= -github.com/raulk/go-watchdog v1.3.0 h1:oUmdlHxdkXRJlwfG0O9omj8ukerm8MEQavSiDTEtBsk= -github.com/raulk/go-watchdog v1.3.0/go.mod h1:fIvOnLbF0b0ZwkB9YU4mOW9Did//4vPZtDqv66NfsMU= +github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+FoDDqP5Tbk= +github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= +github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= +github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= +github.com/prometheus/common v0.47.0 h1:p5Cz0FNHo7SnWOmWmoRozVcjEp0bIVU8cV7OShpjL1k= +github.com/prometheus/common v0.47.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5EC6ILDTlAPc= +github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= +github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= -github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo= -github.com/rs/cors v1.10.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/rs/cors v1.11.0 h1:0B9GE/r9Bc2UxRMMtymBkHTenPkHDv0CW4Y98GBY+po= +github.com/rs/cors v1.11.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= @@ -464,6 +369,7 @@ github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSS github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -515,21 +421,13 @@ github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPR github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= gitlab.com/nolash/go-mockbytes v0.0.7 h1:9XVFpEfY67kGBVJve3uV19kzqORdlo7V+q09OE6Yo54= gitlab.com/nolash/go-mockbytes v0.0.7/go.mod h1:KKOpNTT39j2Eo+P6uUTOncntfeKY6AFh/2CxuD5MpgE= -go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= -go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/dig v1.17.0 h1:5Chju+tUvcC+N7N6EV08BJz41UZuO3BmHcN4A287ZLI= -go.uber.org/dig v1.17.0/go.mod h1:rTxpf7l5I0eBTlE6/9RL+lDybC7WFwY2QH55ZSjy1mU= -go.uber.org/fx v1.20.0 h1:ZMC/pnRvhsthOZh9MZjMq5U8Or3mA9zBSPaLnzs3ihQ= -go.uber.org/fx v1.20.0/go.mod h1:qCUj0btiR3/JnanEr1TYEePfSw6o/4qYJscgvzQ5Ub0= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= -go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= @@ -538,16 +436,15 @@ golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= -golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= -golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= -golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= +golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= +golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/exp v0.0.0-20240213143201-ec583247a57a h1:HinSgX1tJRX3KsL//Gxynpw5CTOAIPhgL4W8PNiIpVE= +golang.org/x/exp v0.0.0-20240213143201-ec583247a57a/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -557,10 +454,9 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= -golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -585,6 +481,7 @@ golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200918174421-af09f7315aff/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -596,27 +493,27 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= -golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.19.0 h1:+ThwsDv+tYfnJFhF4L8jITxu1tdTWRTZpdsWgEgjL6Q= -golang.org/x/term v0.19.0/go.mod h1:2CuTdWZ7KHSQwUzKva0cbMg6q2DMI3Mmxp+gKJbskEk= +golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= +golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.20.0 h1:hz/CVckiOxybQvFw6h7b/q80NTr9IUQb4s1IIzW7KNY= -golang.org/x/tools v0.20.0/go.mod h1:WvitBU7JJf6A4jOdg4S1tviW9bhUxkgeCui/0JHctQg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -638,8 +535,8 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= -gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/pkg/account/account.go b/pkg/account/account.go index 6aa457f7..e6db5857 100644 --- a/pkg/account/account.go +++ b/pkg/account/account.go @@ -26,7 +26,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2" "github.com/ethereum/go-ethereum/accounts" - "github.com/fairdatasociety/fairOS-dfs-utils/crypto" + "github.com/ethersphere/bee/v2/pkg/crypto" "github.com/fairdatasociety/fairOS-dfs/pkg/logging" "github.com/fairdatasociety/fairOS-dfs/pkg/utils" hdwallet "github.com/miguelmota/go-ethereum-hdwallet" @@ -117,6 +117,43 @@ func (a *Account) CreateUserAccount(mnemonic string) (string, []byte, error) { return mnemonic, seed, nil } +// GenerateUserAccountFromSignature create a new master account for a user. +func (a *Account) GenerateUserAccountFromSignature(signature, password string) (string, []byte, error) { + wal := newWallet(nil) + a.wallet = wal + acc, mnemonic, err := wal.GenerateWalletFromSignature(signature, password) + if err != nil { + return "", nil, err + } + + hdw, err := hdwallet.NewFromMnemonic(mnemonic) + if err != nil { // skipcq: TCV-001 + return "", nil, err + } + + // store publicKey, private key and user + a.userAccount.privateKey, err = hdw.PrivateKey(acc) + if err != nil { // skipcq: TCV-001 + return "", nil, err + } + a.userAccount.publicKey, err = hdw.PublicKey(acc) + if err != nil { // skipcq: TCV-001 + return "", nil, err + } + addrBytes, err := crypto.NewEthereumAddress(a.userAccount.privateKey.PublicKey) + if err != nil { // skipcq: TCV-001 + return "", nil, err + } + a.userAccount.address.SetBytes(addrBytes) + + seed, err := hdwallet.NewSeedFromMnemonic(mnemonic) + if err != nil { // skipcq: TCV-001 + return "", nil, err + } + + return mnemonic, seed, nil +} + // LoadUserAccountFromSeed loads the user account given the bip39 seed func (a *Account) LoadUserAccountFromSeed(seed []byte) error { acc, err := a.wallet.CreateAccountFromSeed(rootPath, seed) diff --git a/pkg/account/wallet.go b/pkg/account/wallet.go index 1bace280..2ce35b6e 100644 --- a/pkg/account/wallet.go +++ b/pkg/account/wallet.go @@ -17,10 +17,13 @@ limitations under the License. package account import ( + "crypto/sha256" + "encoding/hex" "fmt" "strings" "github.com/ethereum/go-ethereum/accounts" + "github.com/ethersphere/bee/v2/pkg/crypto" hdwallet "github.com/miguelmota/go-ethereum-hdwallet" "github.com/tyler-smith/go-bip39" ) @@ -28,6 +31,8 @@ import ( const ( rootPath = "m/44'/60'/0'/0/0" genericPath = "m/44'/60'/0'/0/" + + MaxEntropyLength = 32 ) // Wallet is used to create root and pod accounts of user @@ -122,3 +127,63 @@ func (*Wallet) IsValidMnemonic(mnemonic string) error { } return nil } + +// GenerateWalletFromSignature is used to create an account from a given signature +func (w *Wallet) GenerateWalletFromSignature(signature, password string) (accounts.Account, string, error) { + if signature == "" { + return accounts.Account{}, "", fmt.Errorf("signature is empty") + } + signatureBytes, err := hex.DecodeString(signature) + if err != nil { + return accounts.Account{}, "", err + } + wallet, acc, mnemonic, err := signatureToWallet(signatureBytes) + if err != nil { // skipcq: TCV-001 + return accounts.Account{}, "", err + } + if password != "" { + pk, err := wallet.PrivateKey(acc) + if err != nil { // skipcq: TCV-001 + return accounts.Account{}, "", err + } + signer := crypto.NewDefaultSigner(pk) + passBytes := sha256.Sum256([]byte(password)) + signatureBytes, err = signer.Sign([]byte("0x" + hex.EncodeToString(passBytes[:]))) + if err != nil { + return accounts.Account{}, "", err + } + + wallet, acc, mnemonic, err = signatureToWallet(signatureBytes) + if err != nil { // skipcq: TCV-001 + return accounts.Account{}, "", err + } + _ = wallet + } + + seed, err := hdwallet.NewSeedFromMnemonic(mnemonic) + if err != nil { // skipcq: TCV-001 + return accounts.Account{}, "", err + } + w.seed = seed + return acc, mnemonic, nil +} + +func signatureToWallet(signatureBytes []byte) (*hdwallet.Wallet, accounts.Account, string, error) { + slicedSignature := signatureBytes[0:MaxEntropyLength] + + mnemonic, err := bip39.NewMnemonic(slicedSignature) + if err != nil { // skipcq: TCV-001 + return nil, accounts.Account{}, "", err + } + wallet, err := hdwallet.NewFromMnemonic(mnemonic) + if err != nil { // skipcq: TCV-001 + return nil, accounts.Account{}, "", err + } + + path := hdwallet.MustParseDerivationPath(rootPath) + acc, err := wallet.Derive(path, false) + if err != nil { // skipcq: TCV-001 + return nil, accounts.Account{}, "", err + } + return wallet, acc, mnemonic, nil +} diff --git a/pkg/account/wallet_test.go b/pkg/account/wallet_test.go index a1e710bf..514c5994 100644 --- a/pkg/account/wallet_test.go +++ b/pkg/account/wallet_test.go @@ -4,6 +4,8 @@ import ( "os" "testing" + "github.com/stretchr/testify/assert" + hdwallet "github.com/miguelmota/go-ethereum-hdwallet" "github.com/tyler-smith/go-bip39" @@ -38,3 +40,19 @@ func TestWallet(t *testing.T) { t.Fatal("invalid mnemonic") } } + +func TestSignatureToWallet(t *testing.T) { + signature := "b7f4346174a6ff79983bdb10348523de3a4bd2b4772b9f7217b997c6ca1f6abd3de015eab01818e459fad3c067e00969d9f02b808df027574da2f7fd50170a911c" + addrs := []string{"0x61E18Ac267f4d5af06D421DeA020818255678649", "0x13543e7BA5ff28AD8B203BB8e93b47D76ee2aE05"} + w := newWallet(nil) + acc, _, err := w.GenerateWalletFromSignature(signature, "") + if err != nil { + t.Fatal(err) + } + assert.Equal(t, addrs[0], acc.Address.String()) + acc, _, err = w.GenerateWalletFromSignature(signature, "111111111111") + if err != nil { + t.Fatal(err) + } + assert.Equal(t, addrs[1], acc.Address.String()) +} diff --git a/pkg/api/pod_share.go b/pkg/api/pod_share.go index c423181b..5e480f81 100644 --- a/pkg/api/pod_share.go +++ b/pkg/api/pod_share.go @@ -21,10 +21,8 @@ import ( "fmt" "net/http" - "github.com/fairdatasociety/fairOS-dfs/pkg/auth" - "github.com/fairdatasociety/fairOS-dfs/cmd/common" - + "github.com/fairdatasociety/fairOS-dfs/pkg/auth" "github.com/fairdatasociety/fairOS-dfs/pkg/dfs" p "github.com/fairdatasociety/fairOS-dfs/pkg/pod" "github.com/fairdatasociety/fairOS-dfs/pkg/utils" @@ -172,6 +170,58 @@ func (h *Handler) PodReceiveInfoHandler(w http.ResponseWriter, r *http.Request) jsonhttp.OK(w, shareInfo) } +// PodReceiveSnapshotHandler godoc +// +// @Summary Receive shared pod snapshot +// @Description PodReceiveSnapshotHandler is the api handler to receive shared pod snapshot from shared reference +// @ID pod-receive-snapshot-handler +// @Tags pod +// @Accept json +// @Produce json +// @Param sharingRef query string true "pod sharing reference" +// @Param Cookie header string true "cookie parameter" +// @Success 200 {object} pod.DirSnapShot +// @Failure 400 {object} response +// @Failure 500 {object} response +// @Router /v1/pod/snapshot [get] +func (h *Handler) PodReceiveSnapshotHandler(w http.ResponseWriter, r *http.Request) { + + sharingRefString := r.URL.Query().Get("sharingRef") + if sharingRefString == "" { + h.logger.Errorf("pod receive snapshot: \"sharingRef\" argument missing") + jsonhttp.BadRequest(w, "pod receive snapshot: \"sharingRef\" argument missing") + return + } + + path := r.URL.Query().Get("path") + if path == "" { + path = "/" + } + + ref, err := utils.ParseHexReference(sharingRefString) + if err != nil { + h.logger.Errorf("pod receive snapshot: invalid reference: %s", err) + jsonhttp.BadRequest(w, "pod receive snapshot: invalid reference:"+err.Error()) + return + } + + shareInfo, err := h.dfsAPI.PublicPodReceiveInfo(ref) + if err != nil { + h.logger.Errorf("pod receive snapshot: %v", err) + jsonhttp.InternalServerError(w, "pod receive snapshot: "+err.Error()) + return + } + snapshot, err := h.dfsAPI.PublicPodSnapshot(shareInfo, path) + if err != nil { + h.logger.Errorf("pod receive snapshot: %v", err) + jsonhttp.InternalServerError(w, "pod receive snapshot: "+err.Error()) + return + } + + w.Header().Set("Content-Type", " application/json") + jsonhttp.OK(w, snapshot) +} + // PodReceiveHandler godoc // // @Summary Receive shared pod diff --git a/pkg/api/user_login.go b/pkg/api/user_login.go index 36a09eac..29cb81bf 100644 --- a/pkg/api/user_login.go +++ b/pkg/api/user_login.go @@ -88,9 +88,9 @@ func (h *Handler) UserLoginV2Handler(w http.ResponseWriter, r *http.Request) { jsonhttp.NotFound(w, &response{Message: "user login: " + err.Error()}) return } - if err == u.ErrUserAlreadyLoggedIn || - err == u.ErrInvalidUserName || - err == u.ErrInvalidPassword { + if errors.Is(err, u.ErrUserAlreadyLoggedIn) || + errors.Is(err, u.ErrInvalidUserName) || + errors.Is(err, u.ErrInvalidPassword) { h.logger.Errorf("user login: %v", err) jsonhttp.BadRequest(w, &response{Message: "user login: " + err.Error()}) return @@ -114,3 +114,76 @@ func (h *Handler) UserLoginV2Handler(w http.ResponseWriter, r *http.Request) { AccessToken: loginResp.AccessToken, }) } + +// UserLoginWithSignature godoc +// +// @Summary Login User with signature +// @Description login user with signature described in https://github.com/fairDataSociety/FIPs/blob/master/text/0063-external-account-generator.md +// @ID user-login-signature +// @Tags user +// @Accept json +// @Produce json +// @Param user_request body common.UserSignatureLoginRequest true "signature and password" +// @Success 200 {object} UserLoginResponse +// @Failure 400 {object} response +// @Failure 500 {object} response +// @Header 200 {string} Set-Cookie "fairos-dfs session" +// @Router /v2/user/login-with-signature [post] +func (h *Handler) UserLoginWithSignature(w http.ResponseWriter, r *http.Request) { + contentType := r.Header.Get("Content-Type") + if contentType != jsonContentType { + h.logger.Errorf("user login: invalid request body type") + jsonhttp.BadRequest(w, &response{Message: "user login: invalid request body type"}) + return + } + + decoder := json.NewDecoder(r.Body) + var userReq common.UserSignatureLoginRequest + err := decoder.Decode(&userReq) + if err != nil { + h.logger.Errorf("user login: could not decode arguments") + jsonhttp.BadRequest(w, &response{Message: "user login: could not decode arguments"}) + return + } + + signature := userReq.Signature + password := userReq.Password + if signature == "" { + h.logger.Errorf("user login: \"signature\" argument missing") + jsonhttp.BadRequest(w, &response{Message: "user login: \"signature\" argument missing"}) + return + } + + // login user + loginResp, err := h.dfsAPI.LoginUserWithSignature(signature, password, "") + if err != nil { + if errors.Is(err, u.ErrUserNameNotFound) { + h.logger.Errorf("user login: %v", err) + jsonhttp.NotFound(w, &response{Message: "user login: " + err.Error()}) + return + } + if errors.Is(err, u.ErrUserAlreadyLoggedIn) || + errors.Is(err, u.ErrInvalidUserName) || + errors.Is(err, u.ErrInvalidPassword) { + h.logger.Errorf("user login: %v", err) + jsonhttp.BadRequest(w, &response{Message: "user login: " + err.Error()}) + return + } + h.logger.Errorf("user login: %v", err) + jsonhttp.InternalServerError(w, &response{Message: "user login: " + err.Error()}) + return + } + err = cookie.SetSession(loginResp.UserInfo.GetSessionId(), w, h.cookieDomain) + if err != nil { + h.logger.Errorf("user login: %v", err) + jsonhttp.InternalServerError(w, &response{Message: "user login: " + err.Error()}) + return + } + addr := loginResp.UserInfo.GetAccount().GetUserAccountInfo().GetAddress() + jsonhttp.OK(w, &UserSignupResponse{ + Address: addr.Hex(), + PublicKey: loginResp.PublicKey, + Message: "user logged-in successfully", + AccessToken: loginResp.AccessToken, + }) +} diff --git a/pkg/blockstore/bee/client.go b/pkg/blockstore/bee/client.go index b32b247c..95ef7d71 100644 --- a/pkg/blockstore/bee/client.go +++ b/pkg/blockstore/bee/client.go @@ -49,6 +49,7 @@ const ( bzzUrl = "/bzz" tagsUrl = "/tags" pinsUrl = "/pins/" + feedsUrl = "/feeds/" swarmPinHeader = "Swarm-Pin" swarmEncryptHeader = "Swarm-Encrypt" swarmPostageBatchId = "Swarm-Postage-Batch-Id" @@ -114,6 +115,7 @@ func NewBeeClient(apiUrl, postageBlockId string, shouldPin bool, redundancyLevel postageBlockId: postageBlockId, logger: logger, shouldPin: shouldPin, + redundancyLevel: redundancyLevel, } } @@ -189,7 +191,7 @@ func (s *Client) UploadSOC(owner, id, signature string, data []byte) (address [] // the postage block id to store the SOC chunk req.Header.Set(swarmPostageBatchId, s.postageBlockId) req.Header.Set(contentTypeHeader, "application/octet-stream") - req.Header.Set(swarmDeferredUploadHeader, "true") + req.Header.Set(swarmDeferredUploadHeader, "false") // TODO change this in the future when we have some alternative to pin SOC // This is a temporary fix to force soc pinning @@ -661,6 +663,102 @@ func (s *Client) CreateTag(address []byte) (uint32, error) { return resp.UID, nil } +func (s *Client) CreateFeedManifest(owner, topic string) (swarm.Address, error) { + to := time.Now() + + fullUrl := s.url + feedsUrl + owner + "/" + topic + fmt.Println("fullUrl: ", fullUrl) + req, err := http.NewRequest(http.MethodPost, fullUrl, nil) + if err != nil { + return swarm.ZeroAddress, err + } + req.Close = true + + req.Header.Set(swarmPostageBatchId, s.postageBlockId) + + response, err := s.Do(req) + if err != nil { + return swarm.ZeroAddress, err + } + // skipcq: GO-S2307 + defer response.Body.Close() + + respData, err := io.ReadAll(response.Body) + if err != nil { + return swarm.ZeroAddress, errors.New("error create feed manifest") + } + + if response.StatusCode != http.StatusOK && response.StatusCode != http.StatusCreated { + var beeErr *beeError + err = json.Unmarshal(respData, &beeErr) + if err != nil { + return swarm.ZeroAddress, errors.New(string(respData)) + } + return swarm.ZeroAddress, errors.New(beeErr.Message) + } + + var resp bytesPostResponse + err = json.Unmarshal(respData, &resp) + if err != nil { + return swarm.ZeroAddress, fmt.Errorf("error unmarshalling response") + } + fields := logrus.Fields{ + "owner": owner, + "topic": topic, + "duration": time.Since(to).String(), + } + s.logger.WithFields(fields).Log(logrus.DebugLevel, "create feed manifest: ") + return resp.Reference, nil +} + +func (s *Client) GetLatestFeedManifest(owner, topic string) ([]byte, string, string, error) { + to := time.Now() + + fullUrl := s.url + feedsUrl + owner + "/" + topic + fmt.Println("get ullUrl: ", fullUrl) + + req, err := http.NewRequest(http.MethodGet, fullUrl, nil) + if err != nil { + return nil, "", "", err + } + req.Close = true + + response, err := s.Do(req) + if err != nil { + return nil, "", "", err + } + // skipcq: GO-S2307 + defer response.Body.Close() + + respData, err := io.ReadAll(response.Body) + if err != nil { + return nil, "", "", errors.New("error getting latest feed manifest") + } + + if response.StatusCode != http.StatusOK && response.StatusCode != http.StatusCreated { + var beeErr *beeError + err = json.Unmarshal(respData, &beeErr) + if err != nil { + return nil, "", "", errors.New(string(respData)) + } + return nil, "", "", errors.New(beeErr.Message) + } + + var resp bytesPostResponse + err = json.Unmarshal(respData, &resp) + if err != nil { + return nil, "", "", fmt.Errorf("error unmarshalling response") + } + fields := logrus.Fields{ + "owner": owner, + "topic": topic, + "duration": time.Since(to).String(), + } + s.logger.WithFields(fields).Log(logrus.DebugLevel, "get latest feed manifest: ") + + return resp.Reference.Bytes(), response.Header.Get("swarm-feed-index"), response.Header.Get("swarm-feed-index-next"), nil +} + // GetTag gets sync status of a given tag func (s *Client) GetTag(tag uint32) (int64, int64, int64, error) { // gateway proxy does not have tags api exposed diff --git a/pkg/blockstore/bee/mock/client.go b/pkg/blockstore/bee/mock/client.go index bcc4b8f3..bcd92483 100644 --- a/pkg/blockstore/bee/mock/client.go +++ b/pkg/blockstore/bee/mock/client.go @@ -17,8 +17,7 @@ import ( "github.com/ethereum/go-ethereum/common" accountingmock "github.com/ethersphere/bee/v2/pkg/accounting/mock" "github.com/ethersphere/bee/v2/pkg/api" - "github.com/ethersphere/bee/v2/pkg/auth" - mockauth "github.com/ethersphere/bee/v2/pkg/auth/mock" + "github.com/ethersphere/bee/v2/pkg/crypto" "github.com/ethersphere/bee/v2/pkg/feeds" "github.com/ethersphere/bee/v2/pkg/log" @@ -84,9 +83,6 @@ type TestServerOptions struct { Post postage.Service Steward steward.Interface WsHeaders http.Header - Authenticator auth.Authenticator - DebugAPI bool - Restricted bool DirectUpload bool Probe *api.Probe @@ -136,13 +132,6 @@ func NewTestBeeServer(t *testing.T, o TestServerOptions) string { if o.SyncStatus == nil { o.SyncStatus = func() (bool, error) { return true, nil } } - if o.Authenticator == nil { - o.Authenticator = &mockauth.Auth{ - EnforceFunc: func(_, _, _ string) (bool, error) { - return true, nil - }, - } - } topologyDriver := topologymock.NewTopologyDriver(o.TopologyOpts...) acc := accountingmock.NewAccounting(o.AccountingOpts...) @@ -206,18 +195,14 @@ func NewTestBeeServer(t *testing.T, o TestServerOptions) string { }) testutil.CleanupCloser(t, tracerCloser) - s.Configure(signer, o.Authenticator, noOpTracer, api.Options{ + s.Configure(signer, noOpTracer, api.Options{ CORSAllowedOrigins: o.CORSAllowedOrigins, WsPingPeriod: o.WsPingPeriod, - Restricted: o.Restricted, }, extraOpts, 1, erc20) - if o.DebugAPI { - s.MountTechnicalDebug() - s.MountDebug(false) - } else { - s.MountAPI() - } + s.MountTechnicalDebug() + s.MountDebug() + s.MountAPI() ts := httptest.NewServer(s) t.Cleanup(ts.Close) diff --git a/pkg/blockstore/client.go b/pkg/blockstore/client.go index db0bd1b9..a6dd3521 100644 --- a/pkg/blockstore/client.go +++ b/pkg/blockstore/client.go @@ -35,4 +35,6 @@ type Client interface { DeleteReference(address []byte) error CreateTag(address []byte) (uint32, error) GetTag(tag uint32) (int64, int64, int64, error) + CreateFeedManifest(owner, topic string) (address swarm.Address, err error) + GetLatestFeedManifest(owner, topic string) (address []byte, index, nextIndex string, err error) } diff --git a/pkg/blockstore/putergetter/bzzUpdate.go b/pkg/blockstore/putergetter/bzzUpdate.go new file mode 100644 index 00000000..df3064a0 --- /dev/null +++ b/pkg/blockstore/putergetter/bzzUpdate.go @@ -0,0 +1 @@ +package putergetter diff --git a/pkg/dfs/pod_api.go b/pkg/dfs/pod_api.go index 1fad4715..57fce41f 100644 --- a/pkg/dfs/pod_api.go +++ b/pkg/dfs/pod_api.go @@ -27,6 +27,8 @@ import ( "path/filepath" "strconv" "strings" + "sync" + "time" "github.com/fairdatasociety/fairOS-dfs/pkg/account" c "github.com/fairdatasociety/fairOS-dfs/pkg/collection" @@ -305,6 +307,24 @@ func (a *API) PublicPodFileDownload(pod *pod.ShareInfo, filePath string) (io.Rea return reader, meta.Size, nil } +// PublicPodFileDownloadFromMetadata downloads a file from a public pod +func (a *API) PublicPodFileDownloadFromMetadata(meta *file.MetaData) (io.ReadCloser, uint64, error) { + + fileInodeBytes, _, err := a.client.DownloadBlob(meta.InodeAddress) + if err != nil { // skipcq: TCV-001 + return nil, 0, err + } + + var fileInode file.INode + err = json.Unmarshal(fileInodeBytes, &fileInode) + if err != nil { // skipcq: TCV-001 + return nil, 0, err + } + + reader := file.NewReader(fileInode, a.client, meta.Size, meta.BlockSize, meta.Compression, false) + return reader, meta.Size, nil +} + // PublicPodKVEntryGet gets a kv entry from a public pod func (a *API) PublicPodKVEntryGet(pod *pod.ShareInfo, name, key string) ([]string, []byte, error) { @@ -335,7 +355,6 @@ func (a *API) PublicPodKVGetter(pod *pod.ShareInfo) KVGetter { // PublicPodDisLs lists a directory from a public pod func (a *API) PublicPodDisLs(pod *pod.ShareInfo, dirPathToLs string) ([]dir.Entry, []file.Entry, error) { - accountInfo := &account.Info{} address := utils.HexToAddress(pod.Address) accountInfo.SetAddress(address) @@ -343,85 +362,429 @@ func (a *API) PublicPodDisLs(pod *pod.ShareInfo, dirPathToLs string) ([]dir.Entr fd := feed.New(accountInfo, a.client, a.feedCacheSize, a.feedCacheTTL, a.logger) dirNameWithPath := filepath.ToSlash(dirPathToLs) - topic := utils.HashString(dirNameWithPath) - _, data, err := fd.GetFeedData(topic, accountInfo.GetAddress(), []byte(pod.Password), false) + var ( + inode dir.Inode + data []byte + ) + + topic := utils.HashString(utils.CombinePathAndFile(dirNameWithPath, dir.IndexFileName)) + _, metaBytes, err := fd.GetFeedData(topic, accountInfo.GetAddress(), []byte(pod.Password), false) if err != nil { // skipcq: TCV-001 - if dirNameWithPath == utils.PathSeparator { - return nil, nil, nil + topic = utils.HashString(dirNameWithPath) + _, data, err = fd.GetFeedData(topic, accountInfo.GetAddress(), []byte(pod.Password), false) + if err != nil { + return nil, nil, fmt.Errorf("list dir : %v", err) // skipcq: TCV-001 + } + err = inode.Unmarshal(data) + if err != nil { // skipcq: TCV-001 + return nil, nil, err + } + } else { + if string(metaBytes) == utils.DeletedFeedMagicWord { + a.logger.Errorf("found deleted feed for %s\n", dirNameWithPath) + return nil, nil, file.ErrDeletedFeed + } + + var meta *file.MetaData + err = json.Unmarshal(metaBytes, &meta) + if err != nil { // skipcq: TCV-001 + return nil, nil, err + } + fileInodeBytes, _, err := a.client.DownloadBlob(meta.InodeAddress) + if err != nil { // skipcq: TCV-001 + return nil, nil, err + } + + var fileInode file.INode + err = json.Unmarshal(fileInodeBytes, &fileInode) + if err != nil { // skipcq: TCV-001 + return nil, nil, err + } + r := file.NewReader(fileInode, a.client, meta.Size, meta.BlockSize, meta.Compression, false) + data, err = io.ReadAll(r) + if err != nil { // skipcq: TCV-001 + return nil, nil, err + } + err = inode.Unmarshal(data) + if err != nil { // skipcq: TCV-001 + return nil, nil, err } - return nil, nil, fmt.Errorf("list dir : %v", err) // skipcq: TCV-001 } - dirInode := &dir.Inode{} - err = dirInode.Unmarshal(data) - if err != nil { - return nil, nil, fmt.Errorf("list dir : %v", err) + var wg sync.WaitGroup + dirChan := make(chan dir.Entry, len(inode.FileOrDirNames)) + fileChan := make(chan file.Entry, len(inode.FileOrDirNames)) + errChan := make(chan error, len(inode.FileOrDirNames)) + semaphore := make(chan struct{}, 4) + missingCount := 0 + for _, fileOrDirName := range inode.FileOrDirNames { + wg.Add(1) + semaphore <- struct{}{} // Acquire a semaphore slot + + go func(fileOrDirName string) { + defer wg.Done() + defer func() { <-semaphore }() // Release the semaphore slot + if strings.HasPrefix(fileOrDirName, "_D_") { + + dirName := strings.TrimPrefix(fileOrDirName, "_D_") + dirPath := utils.CombinePathAndFile(dirNameWithPath, dirName) + var ( + inode dir.Inode + data []byte + ) + + dirTopic := utils.HashString(utils.CombinePathAndFile(dirPath, dir.IndexFileName)) + _, indexBytes, err := fd.GetFeedData(dirTopic, accountInfo.GetAddress(), []byte(pod.Password), false) + if err != nil { // skipcq: TCV-001 + topic = utils.HashString(dirName) + _, data, err = fd.GetFeedData(topic, accountInfo.GetAddress(), []byte(pod.Password), false) + if err != nil { + errChan <- fmt.Errorf("list dir : %v", err) + return + } + err = inode.Unmarshal(data) + if err != nil { + errChan <- err + return + } + } else { + if string(indexBytes) == utils.DeletedFeedMagicWord { + a.logger.Errorf("found deleted feed for %s\n", dirNameWithPath) + errChan <- file.ErrDeletedFeed + return + } + + var meta *file.MetaData + err = json.Unmarshal(indexBytes, &meta) + if err != nil { + errChan <- err + return + } + fileInodeBytes, _, err := a.client.DownloadBlob(meta.InodeAddress) + if err != nil { + errChan <- err + return + } + + var fileInode file.INode + err = json.Unmarshal(fileInodeBytes, &fileInode) + if err != nil { + errChan <- err + return + } + r := file.NewReader(fileInode, a.client, meta.Size, meta.BlockSize, meta.Compression, false) + data, err = io.ReadAll(r) + if err != nil { + errChan <- err + return + } + err = inode.Unmarshal(data) + if err != nil { + errChan <- err + return + } + } + entry := dir.Entry{ + Name: inode.Meta.Name, + ContentType: dir.MimeTypeDirectory, // per RFC2425 + CreationTime: strconv.FormatInt(inode.Meta.CreationTime, 10), + AccessTime: strconv.FormatInt(inode.Meta.AccessTime, 10), + ModificationTime: strconv.FormatInt(inode.Meta.ModificationTime, 10), + Mode: inode.Meta.Mode, + } + dirChan <- entry + } else if strings.HasPrefix(fileOrDirName, "_F_") { + fileName := strings.TrimPrefix(fileOrDirName, "_F_") + filePath := utils.CombinePathAndFile(dirNameWithPath, fileName) + + fileTopic := utils.HashString(utils.CombinePathAndFile(filePath, "")) + + _, data, err := fd.GetFeedData(fileTopic, accountInfo.GetAddress(), []byte(pod.Password), false) + if err != nil { // skipcq: TCV-001 + errChan <- fmt.Errorf("file mtdt : %s : %v", filePath, err) + return + } + if string(data) == utils.DeletedFeedMagicWord { // skipcq: TCV-001 + return + } + var meta *file.MetaData + err = json.Unmarshal(data, &meta) + if err != nil { // skipcq: TCV-001 + errChan <- fmt.Errorf("file mtdt : %v", err) + return + } + entry := file.Entry{ + Name: meta.Name, + ContentType: meta.ContentType, + Size: strconv.FormatUint(meta.Size, 10), + BlockSize: strconv.FormatInt(int64(meta.BlockSize), 10), + CreationTime: strconv.FormatInt(meta.CreationTime, 10), + AccessTime: strconv.FormatInt(meta.AccessTime, 10), + ModificationTime: strconv.FormatInt(meta.ModificationTime, 10), + Mode: meta.Mode, + } + + fileChan <- entry + } + }(fileOrDirName) } + // Close channels in a goroutine after all goroutines are done + go func() { + wg.Wait() + close(dirChan) + close(fileChan) + close(errChan) + }() + var listEntries []dir.Entry - var files []string - for _, fileOrDirName := range dirInode.FileOrDirNames { - if strings.HasPrefix(fileOrDirName, "_D_") { - dirName := strings.TrimPrefix(fileOrDirName, "_D_") - dirPath := utils.CombinePathAndFile(dirNameWithPath, dirName) - dirTopic := utils.HashString(dirPath) - - _, data, err := fd.GetFeedData(dirTopic, accountInfo.GetAddress(), []byte(pod.Password), false) - if err != nil { // skipcq: TCV-001 - return nil, nil, fmt.Errorf("list dir : %v", err) + var fileEntries []file.Entry + + for { + select { + case dirEntry, ok := <-dirChan: + if ok { + listEntries = append(listEntries, dirEntry) } - var dirInode *dir.Inode - err = json.Unmarshal(data, &dirInode) - if err != nil { // skipcq: TCV-001 - return nil, nil, fmt.Errorf("list dir : %v", err) + case fileEntry, ok := <-fileChan: + if ok { + fileEntries = append(fileEntries, fileEntry) } - entry := dir.Entry{ - Name: dirInode.Meta.Name, - ContentType: dir.MimeTypeDirectory, // per RFC2425 - CreationTime: strconv.FormatInt(dirInode.Meta.CreationTime, 10), - AccessTime: strconv.FormatInt(dirInode.Meta.AccessTime, 10), - ModificationTime: strconv.FormatInt(dirInode.Meta.ModificationTime, 10), - Mode: dirInode.Meta.Mode, + case err := <-errChan: + if err != nil { + return nil, nil, err } - listEntries = append(listEntries, entry) - } else if strings.HasPrefix(fileOrDirName, "_F_") { - fileName := strings.TrimPrefix(fileOrDirName, "_F_") - filePath := utils.CombinePathAndFile(dirNameWithPath, fileName) - files = append(files, filePath) + case <-time.After(time.Hour): + return nil, nil, fmt.Errorf("timeout while listing directory") + } + if len(listEntries)+len(fileEntries)+missingCount == len(inode.FileOrDirNames) { + break } } - var fileEntries []file.Entry - for _, filePath := range files { - fileTopic := utils.HashString(utils.CombinePathAndFile(filePath, "")) + return listEntries, fileEntries, nil +} - _, data, err := fd.GetFeedData(fileTopic, accountInfo.GetAddress(), []byte(pod.Password), false) +// PublicPodSnapshot Gets the current snapshot from a public pod +func (a *API) PublicPodSnapshot(p *pod.ShareInfo, dirPathToLs string) (*pod.DirSnapShot, error) { + accountInfo := &account.Info{} + address := utils.HexToAddress(p.Address) + accountInfo.SetAddress(address) + dirSnapShot := &pod.DirSnapShot{ + FileList: make([]file.MetaData, 0), + DirList: make([]*pod.DirSnapShot, 0), + } + fd := feed.New(accountInfo, a.client, a.feedCacheSize, a.feedCacheTTL, a.logger) + + dirNameWithPath := filepath.ToSlash(dirPathToLs) + var ( + inode dir.Inode + data []byte + ) + fmt.Println("dirNameWithPath", dirNameWithPath) + + topic := utils.HashString(utils.CombinePathAndFile(dirNameWithPath, dir.IndexFileName)) + _, metaBytes, err := fd.GetFeedData(topic, accountInfo.GetAddress(), []byte(p.Password), false) + if err != nil { // skipcq: TCV-001 + fmt.Println("err", err) + topic = utils.HashString(dirNameWithPath) + _, data, err = fd.GetFeedData(topic, accountInfo.GetAddress(), []byte(p.Password), false) + if err != nil { + return nil, fmt.Errorf("list dir : %v for %s", err, dirNameWithPath) // skipcq: TCV-001 + } + err = inode.Unmarshal(data) if err != nil { // skipcq: TCV-001 - return nil, nil, fmt.Errorf("file mtdt : %v", err) + return nil, err } - if string(data) == utils.DeletedFeedMagicWord { // skipcq: TCV-001 - continue + } else { + if string(metaBytes) == utils.DeletedFeedMagicWord { + a.logger.Errorf("found deleted feed for %s\n", dirNameWithPath) + return nil, file.ErrDeletedFeed } + var meta *file.MetaData - err = json.Unmarshal(data, &meta) + err = json.Unmarshal(metaBytes, &meta) if err != nil { // skipcq: TCV-001 - return nil, nil, fmt.Errorf("file mtdt : %v", err) + return nil, err } - entry := file.Entry{ - Name: meta.Name, - ContentType: meta.ContentType, - Size: strconv.FormatUint(meta.Size, 10), - BlockSize: strconv.FormatInt(int64(meta.BlockSize), 10), - CreationTime: strconv.FormatInt(meta.CreationTime, 10), - AccessTime: strconv.FormatInt(meta.AccessTime, 10), - ModificationTime: strconv.FormatInt(meta.ModificationTime, 10), - Mode: meta.Mode, + fileInodeBytes, _, err := a.client.DownloadBlob(meta.InodeAddress) + if err != nil { // skipcq: TCV-001 + return nil, err } - fileEntries = append(fileEntries, entry) + var fileInode file.INode + err = json.Unmarshal(fileInodeBytes, &fileInode) + if err != nil { // skipcq: TCV-001 + return nil, err + } + r := file.NewReader(fileInode, a.client, meta.Size, meta.BlockSize, meta.Compression, false) + data, err = io.ReadAll(r) + if err != nil { // skipcq: TCV-001 + return nil, err + } + err = inode.Unmarshal(data) + if err != nil { // skipcq: TCV-001 + return nil, err + } } + dirSnapShot.Name = inode.Meta.Name + dirSnapShot.ContentType = dir.MimeTypeDirectory + dirSnapShot.CreationTime = strconv.FormatInt(inode.Meta.CreationTime, 10) + dirSnapShot.AccessTime = strconv.FormatInt(inode.Meta.AccessTime, 10) + dirSnapShot.ModificationTime = strconv.FormatInt(inode.Meta.ModificationTime, 10) + dirSnapShot.Mode = inode.Meta.Mode + err = a.getSnapShotForDir(dirSnapShot, fd, accountInfo, inode.FileOrDirNames, dirNameWithPath, p.Password) + if err != nil { + return nil, err + } + return dirSnapShot, nil +} - return listEntries, fileEntries, nil +func (a *API) getSnapShotForDir(dirL *pod.DirSnapShot, fd *feed.API, accountInfo *account.Info, fileOrDirNames []string, dirNameWithPath, password string) error { + var wg sync.WaitGroup + dirChan := make(chan dir.Inode, len(fileOrDirNames)) + fileChan := make(chan file.MetaData, len(fileOrDirNames)) + errChan := make(chan error, len(fileOrDirNames)) + semaphore := make(chan struct{}, 4) + missingCount := 0 + for _, fileOrDirName := range fileOrDirNames { + wg.Add(1) + semaphore <- struct{}{} // Acquire a semaphore slot + + go func(fileOrDirName string) { + defer wg.Done() + defer func() { <-semaphore }() // Release the semaphore slot + if strings.HasPrefix(fileOrDirName, "_D_") { + + dirName := strings.TrimPrefix(fileOrDirName, "_D_") + dirPath := utils.CombinePathAndFile(dirNameWithPath, dirName) + var ( + inode dir.Inode + data []byte + ) + + dirTopic := utils.HashString(utils.CombinePathAndFile(dirPath, dir.IndexFileName)) + _, indexBytes, err := fd.GetFeedData(dirTopic, accountInfo.GetAddress(), []byte(password), false) + if err != nil { // skipcq: TCV-001 + topic := utils.HashString(dirName) + _, data, err = fd.GetFeedData(topic, accountInfo.GetAddress(), []byte(password), false) + if err != nil { + errChan <- fmt.Errorf("list dir : %v", err) + return + } + err = inode.Unmarshal(data) + if err != nil { + errChan <- err + return + } + } else { + if string(indexBytes) == utils.DeletedFeedMagicWord { + errChan <- file.ErrDeletedFeed + return + } + + var meta *file.MetaData + err = json.Unmarshal(indexBytes, &meta) + if err != nil { + errChan <- err + return + } + fileInodeBytes, _, err := a.client.DownloadBlob(meta.InodeAddress) + if err != nil { + errChan <- err + return + } + + var fileInode file.INode + err = json.Unmarshal(fileInodeBytes, &fileInode) + if err != nil { + errChan <- err + return + } + r := file.NewReader(fileInode, a.client, meta.Size, meta.BlockSize, meta.Compression, false) + data, err = io.ReadAll(r) + if err != nil { + errChan <- err + return + } + err = inode.Unmarshal(data) + if err != nil { + errChan <- err + return + } + } + dirChan <- inode + } else if strings.HasPrefix(fileOrDirName, "_F_") { + fileName := strings.TrimPrefix(fileOrDirName, "_F_") + filePath := utils.CombinePathAndFile(dirNameWithPath, fileName) + + fileTopic := utils.HashString(utils.CombinePathAndFile(filePath, "")) + + _, data, err := fd.GetFeedData(fileTopic, accountInfo.GetAddress(), []byte(password), false) + if err != nil { // skipcq: TCV-001 + errChan <- fmt.Errorf("file mtdt : %s : %v", filePath, err) + return + } + if string(data) == utils.DeletedFeedMagicWord { // skipcq: TCV-001 + return + } + var meta *file.MetaData + err = json.Unmarshal(data, &meta) + if err != nil { // skipcq: TCV-001 + errChan <- fmt.Errorf("file mtdt : %v", err) + return + } + + fileChan <- *meta + } + }(fileOrDirName) + } + + // Close channels in a goroutine after all goroutines are done + go func() { + wg.Wait() + close(dirChan) + close(fileChan) + close(errChan) + }() + + for { + select { + case inode, ok := <-dirChan: + if ok { + + dirItem := &pod.DirSnapShot{ + Name: inode.Meta.Name, + ContentType: dir.MimeTypeDirectory, + CreationTime: strconv.FormatInt(inode.Meta.CreationTime, 10), + AccessTime: strconv.FormatInt(inode.Meta.AccessTime, 10), + ModificationTime: strconv.FormatInt(inode.Meta.ModificationTime, 10), + Mode: inode.Meta.Mode, + DirList: make([]*pod.DirSnapShot, 0), + FileList: make([]file.MetaData, 0), + } + dirL.DirList = append(dirL.DirList, dirItem) + err := a.getSnapShotForDir(dirItem, fd, accountInfo, inode.FileOrDirNames, utils.CombinePathAndFile(dirNameWithPath, inode.Meta.Name), password) + if err != nil { + return err + } + } + case fileEntry, ok := <-fileChan: + if ok { + dirL.FileList = append(dirL.FileList, fileEntry) + } + case err := <-errChan: + if err != nil { + return err + } + case <-time.After(time.Hour): + return fmt.Errorf("timeout while listing directory") + } + if len(dirL.FileList)+len(dirL.DirList)+missingCount == len(fileOrDirNames) { + break + } + } + return nil } // PodReceive - receive a pod from a sharingReference diff --git a/pkg/dfs/user_api.go b/pkg/dfs/user_api.go index 37578cc2..2257f131 100644 --- a/pkg/dfs/user_api.go +++ b/pkg/dfs/user_api.go @@ -30,6 +30,11 @@ func (a *API) LoginUserV2(userName, passPhrase, sessionId string) (*user.LoginRe return a.users.LoginUserV2(userName, passPhrase, a.client, a.tm, a.sm, sessionId) } +// LoginUserWithSignature is a controller function which calls the users login with signature function. +func (a *API) LoginUserWithSignature(signature, passPhrase, sessionId string) (*user.LoginResponse, error) { + return a.users.LoginUserWithSignature(signature, passPhrase, a.client, a.tm, a.sm, sessionId) +} + // LoadLiteUser is a controller function which loads user from mnemonic and doesn't store any user info on chain func (a *API) LoadLiteUser(userName, passPhrase, mnemonic, sessionId string) (string, string, *user.Info, error) { return a.users.LoadLiteUser(userName, passPhrase, mnemonic, sessionId, a.tm, a.sm) diff --git a/pkg/dir/inode.go b/pkg/dir/inode.go index d60d81cd..215a622a 100644 --- a/pkg/dir/inode.go +++ b/pkg/dir/inode.go @@ -73,7 +73,7 @@ func (d *Directory) GetInode(podPassword, dirNameWithPath string) (*Inode, error } var inode Inode var data []byte - r, _, err := d.file.Download(utils.CombinePathAndFile(dirNameWithPath, indexFileName), podPassword) + r, _, err := d.file.Download(utils.CombinePathAndFile(dirNameWithPath, IndexFileName), podPassword) if err != nil { // skipcq: TCV-001 topic := utils.HashString(dirNameWithPath) _, data, err = d.fd.GetFeedData(topic, d.getAddress(), []byte(podPassword), false) @@ -113,7 +113,7 @@ func (d *Directory) SetInode(podPassword string, iNode *Inode) error { return err } - err = d.file.Upload(bufio.NewReader(bytes.NewBuffer(data)), indexFileName, int64(len(data)), file.MinBlockSize, 0, totalPath, "gzip", podPassword) + err = d.file.Upload(bufio.NewReader(bytes.NewBuffer(data)), IndexFileName, int64(len(data)), file.MinBlockSize, 0, totalPath, "gzip", podPassword) if err != nil { return err } @@ -131,7 +131,7 @@ func (d *Directory) RemoveInode(podPassword, dirNameWithPath string) error { } else { totalPath = utils.CombinePathAndFile(parentPath, dirToDelete) } - err := d.file.RmFile(utils.CombinePathAndFile(totalPath, indexFileName), podPassword) + err := d.file.RmFile(utils.CombinePathAndFile(totalPath, IndexFileName), podPassword) if err != nil { return err } diff --git a/pkg/dir/modify_dir_entry.go b/pkg/dir/modify_dir_entry.go index 4f47e38b..4dec4b7b 100644 --- a/pkg/dir/modify_dir_entry.go +++ b/pkg/dir/modify_dir_entry.go @@ -22,7 +22,7 @@ import ( ) const ( - indexFileName = "index.dfs" + IndexFileName = "index.dfs" ) // AddEntryToDir adds a new entry (directory/file) to a given directory. diff --git a/pkg/dir/rename.go b/pkg/dir/rename.go index d9b136dc..c4159f47 100644 --- a/pkg/dir/rename.go +++ b/pkg/dir/rename.go @@ -72,12 +72,12 @@ func (d *Directory) RenameDir(dirNameWithPath, newDirNameWithPath, podPassword s return err } - err = d.file.Upload(bufio.NewReader(strings.NewReader(string(fileMetaBytes))), indexFileName, int64(len(fileMetaBytes)), file.MinBlockSize, 0, newDirNameWithPath, "gzip", podPassword) + err = d.file.Upload(bufio.NewReader(strings.NewReader(string(fileMetaBytes))), IndexFileName, int64(len(fileMetaBytes)), file.MinBlockSize, 0, newDirNameWithPath, "gzip", podPassword) if err != nil { // skipcq: TCV-001 return err } - err = d.file.RmFile(utils.CombinePathAndFile(dirNameWithPath, indexFileName), podPassword) + err = d.file.RmFile(utils.CombinePathAndFile(dirNameWithPath, IndexFileName), podPassword) if err != nil { // skipcq: TCV-001 return err } diff --git a/pkg/feed/handler.go b/pkg/feed/handler.go index d42ed07d..7a22c7f1 100644 --- a/pkg/feed/handler.go +++ b/pkg/feed/handler.go @@ -24,7 +24,6 @@ import ( "encoding/hex" "errors" "fmt" - "github.com/fairdatasociety/fairOS-dfs/pkg/logging" "hash" "strings" "sync" @@ -35,10 +34,10 @@ import ( "github.com/ethersphere/bee/v2/pkg/soc" "github.com/ethersphere/bee/v2/pkg/swarm" bmtlegacy "github.com/ethersphere/bmt/legacy" - utilsSigner "github.com/fairdatasociety/fairOS-dfs-utils/signer" "github.com/fairdatasociety/fairOS-dfs/pkg/account" "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore" "github.com/fairdatasociety/fairOS-dfs/pkg/feed/lookup" + "github.com/fairdatasociety/fairOS-dfs/pkg/logging" "github.com/fairdatasociety/fairOS-dfs/pkg/utils" "github.com/hashicorp/golang-lru/v2/expirable" "golang.org/x/crypto/sha3" @@ -615,7 +614,7 @@ func (h *Handler) getSignature(id, payloadId []byte) ([]byte, []byte, error) { if err != nil { return nil, nil, err } - signer := utilsSigner.NewDefaultSigner(h.accountInfo.GetPrivateKey()) + signer := bCrypto.NewDefaultSigner(h.accountInfo.GetPrivateKey()) signature, err := signer.Sign(toSignBytes) if err != nil { return nil, nil, err diff --git a/pkg/pod/ls.go b/pkg/pod/ls.go index 3531d5c9..4e97f42f 100644 --- a/pkg/pod/ls.go +++ b/pkg/pod/ls.go @@ -26,9 +26,11 @@ func (p *Pod) ListPods() ([]string, []string, error) { if err != nil { // skipcq: TCV-001 return nil, nil, err } - err := p.storeUserPodsV2(podList) - if err != nil { - fmt.Println("error storing podsV2", err) + if len(podList.Pods) != 0 || len(podList.SharedPods) != 0 { + err := p.storeUserPodsV2(podList) + if err != nil { + fmt.Println("error storing podsV2", err) + } } } diff --git a/pkg/pod/pod.go b/pkg/pod/pod.go index 1eb69813..2cede24f 100644 --- a/pkg/pod/pod.go +++ b/pkg/pod/pod.go @@ -21,6 +21,8 @@ import ( "sync" "time" + "github.com/fairdatasociety/fairOS-dfs/pkg/file" + "github.com/fairdatasociety/fairOS-dfs/pkg/subscriptionManager" "github.com/fairdatasociety/fairOS-dfs/pkg/account" @@ -71,6 +73,19 @@ type List struct { SharedPods []SharedListItem `json:"sharedPods"` } +type DirSnapShot struct { + Name string `json:"name"` + ContentType string `json:"contentType"` + Size string `json:"size,omitempty"` + Mode uint32 `json:"mode"` + BlockSize string `json:"blockSize,omitempty"` + CreationTime string `json:"creationTime"` + ModificationTime string `json:"modificationTime"` + AccessTime string `json:"accessTime"` + FileList []file.MetaData `json:"fileList"` + DirList []*DirSnapShot `json:"dirList"` +} + // NewPod creates the main pod object which has all the methods related to the pods. func NewPod(client blockstore.Client, feed *feed.API, account *account.Account, m taskmanager.TaskManagerGO, sm subscriptionManager.SubscriptionManager, feedCacheSize int, feedCacheTTL time.Duration, logger logging.Logger) *Pod { return &Pod{ diff --git a/pkg/swarm-feed/swarmFeed.go b/pkg/swarm-feed/swarmFeed.go new file mode 100644 index 00000000..3b80568c --- /dev/null +++ b/pkg/swarm-feed/swarmFeed.go @@ -0,0 +1,153 @@ +package swarm_feed + +import ( + "bytes" + "encoding/binary" + "encoding/hex" + "errors" + "fmt" + "reflect" + "strings" + "time" + + "github.com/ethersphere/bee/v2/pkg/cac" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/ethersphere/bee/v2/pkg/soc" + "github.com/ethersphere/bee/v2/pkg/swarm" + "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore" + "github.com/fairdatasociety/fairOS-dfs/pkg/utils" + "golang.org/x/crypto/sha3" +) + +const ( + FEED_INDEX_HEX_LENGTH = 16 + TOPIC_HEX_LENGTH = 64 +) + +type Topic string + +type Index interface{} +type Identifier []byte +type IndexBytes []byte + +type Feed struct { + bClient blockstore.Client +} + +func NewFeed(bClient blockstore.Client) *Feed { + return &Feed{bClient: bClient} +} + +func (f *Feed) Upload(owner, topic string, signer crypto.Signer, payload swarm.Address) (swarm.Address, error) { + topicHash := keccak256Hash([]byte(topic)) + _, _, nextIndex, _ := f.bClient.GetLatestFeedManifest(owner, utils.Encode(topicHash)) + if nextIndex == "" { + nextIndex = strings.Repeat("0", FEED_INDEX_HEX_LENGTH) + } + id, err := makeFeedIdentifier(topicHash, nextIndex) + if err != nil { + return swarm.ZeroAddress, err + } + timestamp := numberToUint64BE(time.Now().Unix()) + payloadBytes := concatBytes(timestamp, payload.Bytes()) + + ch, err := cac.New(payloadBytes) + if err != nil { + return swarm.ZeroAddress, err + } + s := soc.New(soc.ID(id), ch) + _, err = s.Sign(signer) + if err != nil { + return swarm.ZeroAddress, err + } + _, err = f.bClient.UploadSOC(owner, utils.Encode(id), utils.Encode(s.Signature()), ch.Data()) + if err != nil { + return swarm.ZeroAddress, err + } + return f.bClient.CreateFeedManifest(owner, utils.Encode(topicHash)) +} + +func concatBytes(byteSlices ...[]byte) []byte { + var buffer bytes.Buffer + for _, b := range byteSlices { + buffer.Write(b) + } + return buffer.Bytes() +} + +func isEpoch(epoch interface{}) bool { + v := reflect.ValueOf(epoch) + if v.Kind() != reflect.Struct { + return false + } + + if v.FieldByName("time").IsValid() && v.FieldByName("level").IsValid() { + return true + } + + return false +} + +func keccak256Hash(data ...[]byte) Identifier { + hash := sha3.NewLegacyKeccak256() + for _, d := range data { + hash.Write(d) + } + return hash.Sum(nil) +} + +func hexToBytes(hexStr string) ([]byte, error) { + return hex.DecodeString(hexStr) +} + +func hashFeedIdentifier(topic []byte, index IndexBytes) (Identifier, error) { + return keccak256Hash(topic, index), nil +} + +func numberToUint64BE(num int64) IndexBytes { + indexBytes := make([]byte, 8) + binary.BigEndian.PutUint64(indexBytes, uint64(num)) + return indexBytes +} + +func makeSequentialFeedIdentifier(topic []byte, index int64) (Identifier, error) { + indexBytes := numberToUint64BE(index) + return hashFeedIdentifier(topic, indexBytes) +} + +func makeFeedIndexBytes(s string) (IndexBytes, error) { + hex, err := makeHexString(s, FEED_INDEX_HEX_LENGTH) + if err != nil { + return nil, err + } + return hexToBytes(hex) +} + +func makeHexString(s string, length int) (string, error) { + if len(s) > length { + return "", errors.New("string length exceeds the required length") + } + return fmt.Sprintf("%0*s", length, s), nil +} + +func makeFeedIdentifier(topic []byte, index Index) (Identifier, error) { + switch idx := index.(type) { + case int: + return makeSequentialFeedIdentifier(topic, int64(idx)) + case string: + indexBytes, err := makeFeedIndexBytes(idx) + if err != nil { + return nil, err + } + return hashFeedIdentifier(topic, indexBytes) + default: + if isEpoch(index) { + return nil, errors.New("epoch is not yet implemented") + } + indexBytes, ok := index.(IndexBytes) + if !ok { + return nil, errors.New("invalid index type") + } + return hashFeedIdentifier(topic, indexBytes) + } +} diff --git a/pkg/swarm-feed/swarm_feed_test.go b/pkg/swarm-feed/swarm_feed_test.go new file mode 100644 index 00000000..6858996b --- /dev/null +++ b/pkg/swarm-feed/swarm_feed_test.go @@ -0,0 +1,49 @@ +package swarm_feed + +import ( + "crypto/ecdsa" + "fmt" + "io" + "testing" + + "github.com/ethersphere/bee/v2/pkg/swarm" + + "github.com/fairdatasociety/fairOS-dfs/pkg/logging" + "github.com/sirupsen/logrus" + + "github.com/fairdatasociety/fairOS-dfs/pkg/blockstore/bee" + + eCrypto "github.com/ethereum/go-ethereum/crypto" + "github.com/ethersphere/bee/v2/pkg/crypto" + "github.com/fairdatasociety/fairOS-dfs/pkg/utils" +) + +func TestFeed(t *testing.T) { + t.Skip() + logger := logging.New(io.Discard, logrus.DebugLevel) + mockClient := bee.NewBeeClient("http://localhost:1633", "1ba87c174b66150dacde56df0b914661cff548afcd96957d46f8201694f4a983", true, 0, logger) + bzzAddr := "ea615d35603a3606426f97822b03020761b2e496568424c0b309103a7f66fb9f" + bzzRef, err := swarm.ParseHexAddress(bzzAddr) + pk, err := eCrypto.HexToECDSA("31b0713ac15ac3082180963d288975131a1f63658400fa88f00cf00adedf2609") + if err != nil { + t.Fatal(err) + + } + + // get Address from private key + publicKey := pk.Public().(*ecdsa.PublicKey) + addr, err := crypto.NewEthereumAddress(*publicKey) + if err != nil { + t.Fatal(err) + } + topic := "bzzUpdate js 105" + signer := crypto.NewDefaultSigner(pk) + + f := NewFeed(mockClient) + + manifest, err := f.Upload(utils.Encode(addr), topic, signer, bzzRef) + if err != nil { + t.Fatal(err) + } + fmt.Println("manifest: ", manifest) +} diff --git a/pkg/user/login.go b/pkg/user/login.go index 59584136..ea9772a1 100644 --- a/pkg/user/login.go +++ b/pkg/user/login.go @@ -135,6 +135,66 @@ func (u *Users) LoginUserV2(userName, passPhrase string, client blockstore.Clien }, nil } +// LoginUserWithSignature logs an user with a provided signature +func (u *Users) LoginUserWithSignature(signature, password string, client blockstore.Client, tm taskmanager.TaskManagerGO, sm subscriptionManager.SubscriptionManager, sessionId string) (*LoginResponse, error) { + // check if sessionId is still active + if u.IsUserLoggedIn(sessionId) { // skipcq: TCV-001 + return nil, ErrUserAlreadyLoggedIn + } + + // create account + acc := account.New(u.logger) + accountInfo := acc.GetUserAccountInfo() + // load encrypted private key + fd := feed.New(accountInfo, client, u.feedCacheSize, u.feedCacheTTL, u.logger) + + _, _, err := acc.GenerateUserAccountFromSignature(signature, password) + if err != nil { // skipcq: TCV-001 + return nil, err + } + addr := accountInfo.GetAddress() + // Instantiate pod, dir & file objects + file := f.NewFile(addr.String(), u.client, fd, addr, tm, u.logger) + dir := d.NewDirectory(addr.String(), u.client, fd, addr, file, tm, u.logger) + pod := p.NewPod(u.client, fd, acc, tm, sm, u.feedCacheSize, u.feedCacheTTL, u.logger) + acl := acl2.NewACL(u.client, fd, u.logger) + group := p.NewGroup(u.client, fd, acc, acl, u.logger) + if sessionId == "" { + sessionId = auth.GetUniqueSessionId() + } + + ui := &Info{ + name: addr.String(), + sessionId: sessionId, + feedApi: fd, + account: acc, + file: file, + dir: dir, + pod: pod, + group: group, + openPods: make(map[string]*p.Info), + openPodsMu: &sync.RWMutex{}, + } + + // set cookie and add user to map + err = u.addUserAndSessionToMap(ui) + if err != nil { + return nil, err + } + + token, err := jwt.GenerateToken(sessionId) + if err != nil { + u.logger.Errorf("error generating token: %v\n", err) + } + + return &LoginResponse{ + Address: addr.Hex(), + PublicKey: utils.Encode(crypto.FromECDSAPub(accountInfo.GetPublicKey())), + UserInfo: ui, + AccessToken: token, + }, nil +} + func (u *Users) addUserAndSessionToMap(ui *Info) error { u.addUserToMap(ui) return nil diff --git a/swagger/docs.go b/swagger/docs.go index 4777addc..e4b32007 100644 --- a/swagger/docs.go +++ b/swagger/docs.go @@ -1816,6 +1816,13 @@ const docTemplate = `{ "in": "query", "required": true }, + { + "type": "string", + "description": "group name", + "name": "groupName", + "in": "query", + "required": true + }, { "type": "string", "description": "file path", @@ -4129,6 +4136,58 @@ const docTemplate = `{ } } }, + "/v1/pod/snapshot": { + "get": { + "description": "PodReceiveSnapshotHandler is the api handler to receive shared pod snapshot from shared reference", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pod" + ], + "summary": "Receive shared pod snapshot", + "operationId": "pod-receive-snapshot-handler", + "parameters": [ + { + "type": "string", + "description": "pod sharing reference", + "name": "sharingRef", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "cookie parameter", + "name": "Cookie", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/pod.DirSnapShot" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, "/v1/pod/stat": { "get": { "description": "PodStatHandler is the api handler get information about a pod", @@ -4567,6 +4626,59 @@ const docTemplate = `{ } } }, + "/v2/user/login-with-signature": { + "post": { + "description": "login user with signature described in https://github.com/fairDataSociety/FIPs/blob/master/text/0063-external-account-generator.md", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Login User with signature", + "operationId": "user-login-signature", + "parameters": [ + { + "description": "signature and password", + "name": "user_request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/common.UserSignatureLoginRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api.UserLoginResponse" + }, + "headers": { + "Set-Cookie": { + "type": "string", + "description": "fairos-dfs session" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, "/v2/user/present": { "get": { "description": "checks if the new user is present in the new ENS based authentication", @@ -4692,6 +4804,9 @@ const docTemplate = `{ "dirPath": { "type": "string" }, + "groupName": { + "type": "string" + }, "mode": { "type": "string" }, @@ -4717,6 +4832,9 @@ const docTemplate = `{ "dirPath": { "type": "string" }, + "groupName": { + "type": "string" + }, "podName": { "type": "string" } @@ -4809,6 +4927,9 @@ const docTemplate = `{ "filePath": { "type": "string" }, + "groupName": { + "type": "string" + }, "podName": { "type": "string" } @@ -4820,6 +4941,9 @@ const docTemplate = `{ "filePath": { "type": "string" }, + "groupName": { + "type": "string" + }, "mode": { "type": "string" }, @@ -4837,6 +4961,9 @@ const docTemplate = `{ "filePath": { "type": "string" }, + "groupName": { + "type": "string" + }, "podName": { "type": "string" } @@ -5264,6 +5391,9 @@ const docTemplate = `{ "common.RenameRequest": { "type": "object", "properties": { + "groupName": { + "type": "string" + }, "newPath": { "type": "string" }, @@ -5286,6 +5416,17 @@ const docTemplate = `{ } } }, + "common.UserSignatureLoginRequest": { + "type": "object", + "properties": { + "password": { + "type": "string" + }, + "signature": { + "type": "string" + } + } + }, "common.UserSignupRequest": { "type": "object", "properties": { @@ -5390,6 +5531,50 @@ const docTemplate = `{ } } }, + "file.MetaData": { + "type": "object", + "properties": { + "accessTime": { + "type": "integer" + }, + "blockSize": { + "type": "integer" + }, + "compression": { + "type": "string" + }, + "contentType": { + "type": "string" + }, + "creationTime": { + "type": "integer" + }, + "fileInodeReference": { + "type": "array", + "items": { + "type": "integer" + } + }, + "fileName": { + "type": "string" + }, + "filePath": { + "type": "string" + }, + "fileSize": { + "type": "integer" + }, + "mode": { + "type": "integer" + }, + "modificationTime": { + "type": "integer" + }, + "version": { + "type": "integer" + } + } + }, "file.Stats": { "type": "object", "properties": { @@ -5428,6 +5613,47 @@ const docTemplate = `{ } } }, + "pod.DirSnapShot": { + "type": "object", + "properties": { + "accessTime": { + "type": "string" + }, + "blockSize": { + "type": "string" + }, + "contentType": { + "type": "string" + }, + "creationTime": { + "type": "string" + }, + "dirList": { + "type": "array", + "items": { + "$ref": "#/definitions/pod.DirSnapShot" + } + }, + "fileList": { + "type": "array", + "items": { + "$ref": "#/definitions/file.MetaData" + } + }, + "mode": { + "type": "integer" + }, + "modificationTime": { + "type": "string" + }, + "name": { + "type": "string" + }, + "size": { + "type": "string" + } + } + }, "pod.GroupItem": { "type": "object", "properties": { diff --git a/swagger/swagger.json b/swagger/swagger.json index cfd8e3fe..1356cf46 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -1807,6 +1807,13 @@ "in": "query", "required": true }, + { + "type": "string", + "description": "group name", + "name": "groupName", + "in": "query", + "required": true + }, { "type": "string", "description": "file path", @@ -4120,6 +4127,58 @@ } } }, + "/v1/pod/snapshot": { + "get": { + "description": "PodReceiveSnapshotHandler is the api handler to receive shared pod snapshot from shared reference", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pod" + ], + "summary": "Receive shared pod snapshot", + "operationId": "pod-receive-snapshot-handler", + "parameters": [ + { + "type": "string", + "description": "pod sharing reference", + "name": "sharingRef", + "in": "query", + "required": true + }, + { + "type": "string", + "description": "cookie parameter", + "name": "Cookie", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/pod.DirSnapShot" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, "/v1/pod/stat": { "get": { "description": "PodStatHandler is the api handler get information about a pod", @@ -4558,6 +4617,59 @@ } } }, + "/v2/user/login-with-signature": { + "post": { + "description": "login user with signature described in https://github.com/fairDataSociety/FIPs/blob/master/text/0063-external-account-generator.md", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "Login User with signature", + "operationId": "user-login-signature", + "parameters": [ + { + "description": "signature and password", + "name": "user_request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/common.UserSignatureLoginRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/api.UserLoginResponse" + }, + "headers": { + "Set-Cookie": { + "type": "string", + "description": "fairos-dfs session" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "$ref": "#/definitions/api.response" + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "$ref": "#/definitions/api.response" + } + } + } + } + }, "/v2/user/present": { "get": { "description": "checks if the new user is present in the new ENS based authentication", @@ -4683,6 +4795,9 @@ "dirPath": { "type": "string" }, + "groupName": { + "type": "string" + }, "mode": { "type": "string" }, @@ -4708,6 +4823,9 @@ "dirPath": { "type": "string" }, + "groupName": { + "type": "string" + }, "podName": { "type": "string" } @@ -4800,6 +4918,9 @@ "filePath": { "type": "string" }, + "groupName": { + "type": "string" + }, "podName": { "type": "string" } @@ -4811,6 +4932,9 @@ "filePath": { "type": "string" }, + "groupName": { + "type": "string" + }, "mode": { "type": "string" }, @@ -4828,6 +4952,9 @@ "filePath": { "type": "string" }, + "groupName": { + "type": "string" + }, "podName": { "type": "string" } @@ -5255,6 +5382,9 @@ "common.RenameRequest": { "type": "object", "properties": { + "groupName": { + "type": "string" + }, "newPath": { "type": "string" }, @@ -5277,6 +5407,17 @@ } } }, + "common.UserSignatureLoginRequest": { + "type": "object", + "properties": { + "password": { + "type": "string" + }, + "signature": { + "type": "string" + } + } + }, "common.UserSignupRequest": { "type": "object", "properties": { @@ -5381,6 +5522,50 @@ } } }, + "file.MetaData": { + "type": "object", + "properties": { + "accessTime": { + "type": "integer" + }, + "blockSize": { + "type": "integer" + }, + "compression": { + "type": "string" + }, + "contentType": { + "type": "string" + }, + "creationTime": { + "type": "integer" + }, + "fileInodeReference": { + "type": "array", + "items": { + "type": "integer" + } + }, + "fileName": { + "type": "string" + }, + "filePath": { + "type": "string" + }, + "fileSize": { + "type": "integer" + }, + "mode": { + "type": "integer" + }, + "modificationTime": { + "type": "integer" + }, + "version": { + "type": "integer" + } + } + }, "file.Stats": { "type": "object", "properties": { @@ -5419,6 +5604,47 @@ } } }, + "pod.DirSnapShot": { + "type": "object", + "properties": { + "accessTime": { + "type": "string" + }, + "blockSize": { + "type": "string" + }, + "contentType": { + "type": "string" + }, + "creationTime": { + "type": "string" + }, + "dirList": { + "type": "array", + "items": { + "$ref": "#/definitions/pod.DirSnapShot" + } + }, + "fileList": { + "type": "array", + "items": { + "$ref": "#/definitions/file.MetaData" + } + }, + "mode": { + "type": "integer" + }, + "modificationTime": { + "type": "string" + }, + "name": { + "type": "string" + }, + "size": { + "type": "string" + } + } + }, "pod.GroupItem": { "type": "object", "properties": { diff --git a/swagger/swagger.yaml b/swagger/swagger.yaml index 49e38142..5c7b77dc 100644 --- a/swagger/swagger.yaml +++ b/swagger/swagger.yaml @@ -21,6 +21,8 @@ definitions: properties: dirPath: type: string + groupName: + type: string mode: type: string podName: @@ -37,6 +39,8 @@ definitions: properties: dirPath: type: string + groupName: + type: string podName: type: string type: object @@ -96,6 +100,8 @@ definitions: properties: filePath: type: string + groupName: + type: string podName: type: string type: object @@ -103,6 +109,8 @@ definitions: properties: filePath: type: string + groupName: + type: string mode: type: string podName: @@ -114,6 +122,8 @@ definitions: type: string filePath: type: string + groupName: + type: string podName: type: string type: object @@ -387,6 +397,8 @@ definitions: type: object common.RenameRequest: properties: + groupName: + type: string newPath: type: string oldPath: @@ -401,6 +413,13 @@ definitions: userName: type: string type: object + common.UserSignatureLoginRequest: + properties: + password: + type: string + signature: + type: string + type: object common.UserSignupRequest: properties: mnemonic: @@ -469,6 +488,35 @@ definitions: size: type: string type: object + file.MetaData: + properties: + accessTime: + type: integer + blockSize: + type: integer + compression: + type: string + contentType: + type: string + creationTime: + type: integer + fileInodeReference: + items: + type: integer + type: array + fileName: + type: string + filePath: + type: string + fileSize: + type: integer + mode: + type: integer + modificationTime: + type: integer + version: + type: integer + type: object file.Stats: properties: accessTime: @@ -494,6 +542,33 @@ definitions: podName: type: string type: object + pod.DirSnapShot: + properties: + accessTime: + type: string + blockSize: + type: string + contentType: + type: string + creationTime: + type: string + dirList: + items: + $ref: '#/definitions/pod.DirSnapShot' + type: array + fileList: + items: + $ref: '#/definitions/file.MetaData' + type: array + mode: + type: integer + modificationTime: + type: string + name: + type: string + size: + type: string + type: object pod.GroupItem: properties: name: @@ -1794,6 +1869,11 @@ paths: name: podName required: true type: string + - description: group name + in: query + name: groupName + required: true + type: string - description: file path in: query name: filePath @@ -3367,6 +3447,42 @@ paths: summary: Share pod tags: - pod + /v1/pod/snapshot: + get: + consumes: + - application/json + description: PodReceiveSnapshotHandler is the api handler to receive shared + pod snapshot from shared reference + operationId: pod-receive-snapshot-handler + parameters: + - description: pod sharing reference + in: query + name: sharingRef + required: true + type: string + - description: cookie parameter + in: header + name: Cookie + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/pod.DirSnapShot' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api.response' + summary: Receive shared pod snapshot + tags: + - pod /v1/pod/stat: get: consumes: @@ -3659,6 +3775,41 @@ paths: summary: Login User tags: - user + /v2/user/login-with-signature: + post: + consumes: + - application/json + description: login user with signature described in https://github.com/fairDataSociety/FIPs/blob/master/text/0063-external-account-generator.md + operationId: user-login-signature + parameters: + - description: signature and password + in: body + name: user_request + required: true + schema: + $ref: '#/definitions/common.UserSignatureLoginRequest' + produces: + - application/json + responses: + "200": + description: OK + headers: + Set-Cookie: + description: fairos-dfs session + type: string + schema: + $ref: '#/definitions/api.UserLoginResponse' + "400": + description: Bad Request + schema: + $ref: '#/definitions/api.response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/api.response' + summary: Login User with signature + tags: + - user /v2/user/present: get: description: checks if the new user is present in the new ENS based authentication diff --git a/wasm/main.go b/wasm/main.go index 445865e8..de1a27cf 100644 --- a/wasm/main.go +++ b/wasm/main.go @@ -11,6 +11,7 @@ import ( "fmt" "io" "os" + "path/filepath" "strings" "syscall/js" @@ -18,6 +19,7 @@ import ( "github.com/fairdatasociety/fairOS-dfs/pkg/collection" "github.com/fairdatasociety/fairOS-dfs/pkg/contracts" "github.com/fairdatasociety/fairOS-dfs/pkg/dfs" + "github.com/fairdatasociety/fairOS-dfs/pkg/file" "github.com/fairdatasociety/fairOS-dfs/pkg/logging" "github.com/fairdatasociety/fairOS-dfs/pkg/utils" "github.com/sirupsen/logrus" @@ -45,6 +47,7 @@ func registerWasmFunctions() { js.Global().Set("connectWallet", js.FuncOf(connectWallet)) js.Global().Set("login", js.FuncOf(login)) js.Global().Set("walletLogin", js.FuncOf(walletLogin)) + js.Global().Set("signatureLogin", js.FuncOf(signatureLogin)) js.Global().Set("userPresent", js.FuncOf(userPresent)) js.Global().Set("userIsLoggedIn", js.FuncOf(userIsLoggedIn)) js.Global().Set("userLogout", js.FuncOf(userLogout)) @@ -133,6 +136,11 @@ func registerWasmFunctions() { js.Global().Set("docEntryDelete", js.FuncOf(docEntryDelete)) js.Global().Set("docLoadJson", js.FuncOf(docLoadJson)) js.Global().Set("docIndexJson", js.FuncOf(docIndexJson)) + + js.Global().Set("publicPodFile", js.FuncOf(publicPodFile)) + js.Global().Set("publicPodFileMeta", js.FuncOf(publicPodFileMeta)) + js.Global().Set("publicPodDir", js.FuncOf(publicPodDir)) + js.Global().Set("publicPodReceiveInfo", js.FuncOf(publicPodReceiveInfo)) } func connect(_ js.Value, funcArgs []js.Value) interface{} { @@ -170,7 +178,7 @@ func connect(_ js.Value, funcArgs []js.Value) interface{} { if subContractAddress != "" { subConfig.DataHubAddress = subContractAddress } - logger := logging.New(os.Stdout, logrus.DebugLevel) + logger := logging.New(os.Stdout, logrus.ErrorLevel) go func() { var err error @@ -188,6 +196,7 @@ func connect(_ js.Value, funcArgs []js.Value) interface{} { if err != nil { reject.Invoke(fmt.Sprintf("failed to connect to fairOS: %s", err.Error())) } + fmt.Println("******** FairOS connected ********") resolve.Invoke("connected") }() @@ -207,7 +216,10 @@ func publicKvEntryGet(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] - + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"publicKvEntryGet(sharingRef, tableName, key)\"") return nil @@ -254,6 +266,10 @@ func login(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"login(username, password)\"") @@ -290,6 +306,10 @@ func walletLogin(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"walletLogin(addressHex, signature)\"") @@ -321,10 +341,51 @@ func walletLogin(_ js.Value, funcArgs []js.Value) interface{} { return promiseConstructor.New(handler) } +func signatureLogin(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } + + if len(funcArgs) != 2 { + reject.Invoke("not enough arguments. \"signatureLogin(signature, password)\"") + return nil + } + signature := funcArgs[0].String() + password := funcArgs[1].String() + + go func() { + lr, err := api.LoginUserWithSignature(signature, password, "") + if err != nil { + reject.Invoke(fmt.Sprintf("Failed to login user : %s", err.Error())) + return + } + ui := lr.UserInfo + object := js.Global().Get("Object").New() + object.Set("user", ui.GetUserName()) + object.Set("address", lr.Address) + object.Set("sessionId", ui.GetSessionId()) + resolve.Invoke(object) + }() + + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + func connectWallet(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 4 { reject.Invoke("not enough arguments. \"connectWallet(username, password, walletAddress, signature)\"") @@ -355,6 +416,10 @@ func userPresent(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 1 { reject.Invoke("not enough arguments. \"userPresent(username)\"") @@ -380,6 +445,10 @@ func userIsLoggedIn(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 1 { reject.Invoke("not enough arguments. \"userIsLoggedIn(username)\"") @@ -406,6 +475,10 @@ func userLogout(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 1 { reject.Invoke("not enough arguments. \"userLogout(sessionId)\"") @@ -432,6 +505,10 @@ func userDelete(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"userDelete(sessionId, password)\"") @@ -459,6 +536,10 @@ func userStat(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 1 { reject.Invoke("not enough arguments. \"userStat(sessionId)\"") @@ -490,6 +571,10 @@ func podNew(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"podNew(sessionId, podName)\"") @@ -517,6 +602,10 @@ func podOpen(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"podOpen(sessionId, podName)\"") @@ -544,6 +633,10 @@ func podClose(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"podClose(sessionId, podName)\"") @@ -571,6 +664,10 @@ func podSync(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"podSync(sessionId, podName)\"") @@ -598,6 +695,10 @@ func podDelete(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"podDelete(sessionId, podName)\"") @@ -625,6 +726,10 @@ func podList(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 1 { reject.Invoke("not enough arguments. \"podList(sessionId)\"") @@ -666,6 +771,10 @@ func podStat(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"podStat(sessionId, podName)\"") @@ -697,6 +806,10 @@ func podShare(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"podShare(sessionId, podName, shareAs)\"") @@ -728,6 +841,10 @@ func podReceive(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"podReceive(sessionId, newPodName, podSharingReference)\"") @@ -757,10 +874,182 @@ func podReceive(_ js.Value, funcArgs []js.Value) interface{} { return promiseConstructor.New(handler) } +func publicPodFile(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } + + if len(funcArgs) != 2 { + reject.Invoke("not enough arguments. \"publicPod(podSharingReference, filepath)\"") + return nil + } + podSharingReference := funcArgs[0].String() + fp := funcArgs[1].String() + + go func() { + ref, err := utils.ParseHexReference(podSharingReference) + if err != nil { + reject.Invoke(fmt.Sprintf("public pod downlod failed : %s", err.Error())) + return + } + shareInfo, err := api.PublicPodReceiveInfo(ref) + if err != nil { + reject.Invoke(fmt.Sprintf("public pod downlod failed : %s", err.Error())) + return + } + r, _, err := api.PublicPodFileDownload(shareInfo, fp) + if err != nil { + reject.Invoke(fmt.Sprintf("public pod fileDownload failed : %s", err.Error())) + return + } + defer r.Close() + + buf := new(bytes.Buffer) + _, err = buf.ReadFrom(r) + if err != nil { + reject.Invoke(fmt.Sprintf("public pod fileDownload failed : %s", err.Error())) + return + } + a := js.Global().Get("Uint8Array").New(buf.Len()) + js.CopyBytesToJS(a, buf.Bytes()) + resolve.Invoke(a) + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + +func publicPodFileMeta(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } + + if len(funcArgs) != 1 { + reject.Invoke("not enough arguments. \"publicPodFileMeta(metadata)\"") + return nil + } + metadata := funcArgs[0].String() + meta := &file.MetaData{} + err := json.Unmarshal([]byte(metadata), meta) + if err != nil { + reject.Invoke(fmt.Sprintf("public pod file meta failed : %s", err.Error())) + return nil + } + go func() { + + r, _, err := api.PublicPodFileDownloadFromMetadata(meta) + if err != nil { + reject.Invoke(fmt.Sprintf("public pod fileDownload failed : %s", err.Error())) + return + } + defer r.Close() + buf := new(bytes.Buffer) + _, err = buf.ReadFrom(r) + if err != nil { + reject.Invoke(fmt.Sprintf("public pod fileDownload failed : %s", err.Error())) + return + } + a := js.Global().Get("Uint8Array").New(buf.Len()) + js.CopyBytesToJS(a, buf.Bytes()) + resolve.Invoke(a) + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + +func publicPodDir(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } + + if len(funcArgs) != 2 { + reject.Invoke("not enough arguments. \"publicPodDir(podSharingReference, filepath)\"") + return nil + } + podSharingReference := funcArgs[0].String() + fp := funcArgs[1].String() + + go func() { + ref, err := utils.ParseHexReference(podSharingReference) + if err != nil { + reject.Invoke(fmt.Sprintf("public pod downlod failed : %s", err.Error())) + return + } + shareInfo, err := api.PublicPodReceiveInfo(ref) + if err != nil { + reject.Invoke(fmt.Sprintf("public pod downlod failed : %s", err.Error())) + return + } + filePath := filepath.ToSlash(fp) + dirs, files, err := api.PublicPodDisLs(shareInfo, filePath) + if err != nil { + reject.Invoke(fmt.Sprintf("public pod fileDownload failed : %s", err.Error())) + return + } + filesList := js.Global().Get("Array").New(len(files)) + for i, v := range files { + file := js.Global().Get("Object").New() + file.Set("name", v.Name) + file.Set("contentType", v.ContentType) + file.Set("size", v.Size) + file.Set("blockSize", v.BlockSize) + file.Set("creationTime", v.CreationTime) + file.Set("modificationTime", v.ModificationTime) + file.Set("accessTime", v.AccessTime) + file.Set("mode", v.Mode) + filesList.SetIndex(i, file) + } + dirsList := js.Global().Get("Array").New(len(dirs)) + for i, v := range dirs { + dir := js.Global().Get("Object").New() + dir.Set("name", v.Name) + dir.Set("contentType", v.ContentType) + dir.Set("size", v.Size) + dir.Set("mode", v.Mode) + dir.Set("blockSize", v.BlockSize) + dir.Set("creationTime", v.CreationTime) + dir.Set("modificationTime", v.ModificationTime) + dir.Set("accessTime", v.AccessTime) + dirsList.SetIndex(i, dir) + } + object := js.Global().Get("Object").New() + object.Set("files", filesList) + object.Set("dirs", dirsList) + + resolve.Invoke(object) + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + func podReceiveInfo(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"podReceiveInfo(sessionId, pod_sharing_reference)\"") @@ -796,10 +1085,56 @@ func podReceiveInfo(_ js.Value, funcArgs []js.Value) interface{} { return promiseConstructor.New(handler) } +func publicPodReceiveInfo(_ js.Value, funcArgs []js.Value) interface{} { + handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { + resolve := args[0] + reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } + + if len(funcArgs) != 1 { + reject.Invoke("not enough arguments. \"publicPodReceiveInfo(pod_sharing_reference)\"") + return nil + } + podSharingReference := funcArgs[0].String() + + go func() { + ref, err := utils.ParseHexReference(podSharingReference) + if err != nil { + reject.Invoke(fmt.Sprintf("publicPodReceiveInfo failed : %s", err.Error())) + return + } + shareInfo, err := api.PublicPodReceiveInfo(ref) + if err != nil { + reject.Invoke(fmt.Sprintf("publicPodReceiveInfo failed : %s", err.Error())) + return + } + + object := js.Global().Get("Object").New() + object.Set("podName", shareInfo.PodName) + object.Set("podAddress", shareInfo.Address) + object.Set("password", shareInfo.Password) + object.Set("userAddress", shareInfo.UserAddress) + + resolve.Invoke(object) + }() + return nil + }) + + promiseConstructor := js.Global().Get("Promise") + return promiseConstructor.New(handler) +} + func groupNew(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"groupNew(sessionId, groupName)\"") @@ -827,6 +1162,10 @@ func groupOpen(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"groupOpen(sessionId, groupName)\"") @@ -854,6 +1193,10 @@ func groupClose(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"groupClose(sessionId, groupName)\"") @@ -881,6 +1224,10 @@ func groupDelete(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"groupDelete(sessionId, groupName)\"") @@ -908,6 +1255,10 @@ func groupDeleteShared(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"groupDeleteShared(sessionId, groupName)\"") @@ -935,6 +1286,10 @@ func groupList(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 1 { reject.Invoke("not enough arguments. \"groupList(sessionId)\"") @@ -976,6 +1331,10 @@ func groupInvite(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 4 { reject.Invoke("not enough arguments. \"groupInvite(sessionId, groupName, member, permission)\"") @@ -1008,6 +1367,10 @@ func groupAccept(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"groupInvite(sessionId, groupInviteReference)\"") @@ -1035,6 +1398,10 @@ func groupRemoveMember(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"groupRemoveMember(sessionId, groupName, member)\"") @@ -1063,6 +1430,10 @@ func groupUpdatePermission(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 4 { reject.Invoke("not enough arguments. \"groupUpdatePermission(sessionId, groupName, member, permission)\"") @@ -1093,6 +1464,10 @@ func groupMembers(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"groupMembers(sessionId, groupName)\"") @@ -1125,6 +1500,10 @@ func groupPermission(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"groupPermission(sessionId, groupName)\"") @@ -1155,6 +1534,10 @@ func dirPresent(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"dirPresent(sessionId, podName, dirPath)\"") @@ -1187,6 +1570,10 @@ func dirMake(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"dirMake(sessionId, podName, dirPath)\"") @@ -1215,6 +1602,10 @@ func dirRemove(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"dirRemove(sessionId, podName, dirPath)\"") @@ -1243,6 +1634,10 @@ func dirList(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"dirList(sessionId, podName, dirPath)\"") @@ -1301,6 +1696,10 @@ func dirStat(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"dirStat(sessionId, podName, dirPath)\"") @@ -1340,6 +1739,10 @@ func fileDownload(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"fileDownload(sessionId, podName, filePath)\"") return nil @@ -1376,6 +1779,10 @@ func fileUpload(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 8 { reject.Invoke("not enough arguments. \"fileUpload(sessionId, podName, dirPath, file, name, size, blockSize, compression)\"") return nil @@ -1422,6 +1829,10 @@ func fileShare(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 4 { reject.Invoke("not enough arguments. \"fileShare(sessionId, podName, dirPath, destinationUser)\"") @@ -1455,6 +1866,10 @@ func fileReceive(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 4 { reject.Invoke("not enough arguments. \"fileReceive(sessionId, podName, directory, file_sharing_reference)\"") @@ -1487,6 +1902,10 @@ func fileReceiveInfo(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"fileReceiveInfo(sessionId, fileSharingReference)\"") @@ -1525,6 +1944,10 @@ func fileDelete(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"fileDelete(sessionId, podName, podFileWithPath)\"") @@ -1553,6 +1976,10 @@ func fileStat(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"fileStat(sessionId, podName, podFileWithPath)\"") @@ -1594,6 +2021,10 @@ func groupDirPresent(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"groupDirPresent(sessionId, groupName, dirPath)\"") @@ -1626,6 +2057,10 @@ func groupDirMake(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"groupDirMake(sessionId, groupName, dirPath)\"") @@ -1654,6 +2089,10 @@ func groupDirRemove(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"groupDirRemove(sessionId, groupName, dirPath)\"") @@ -1682,6 +2121,10 @@ func groupDirList(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"groupDirList(sessionId, groupName, dirPath)\"") @@ -1740,6 +2183,10 @@ func groupDirStat(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"groupDirStat(sessionId, groupName, dirPath)\"") @@ -1779,6 +2226,10 @@ func groupFileDownload(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"groupFileDownload(sessionId, groupName, filePath)\"") return nil @@ -1798,7 +2249,7 @@ func groupFileDownload(_ js.Value, funcArgs []js.Value) interface{} { buf := new(bytes.Buffer) _, err = buf.ReadFrom(r) if err != nil { - reject.Invoke(fmt.Sprintf("groupFileDownload failed : %s", err.Error())) + reject.Invoke(fmt.Sprintf("fileDownload failed : %s", err.Error())) return } a := js.Global().Get("Uint8Array").New(buf.Len()) @@ -1815,6 +2266,10 @@ func groupFileUpload(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 8 { reject.Invoke("not enough arguments. \"groupFileUpload(sessionId, groupName, dirPath, file, name, size, blockSize, compression)\"") return nil @@ -1861,6 +2316,10 @@ func groupFileShare(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 4 { reject.Invoke("not enough arguments. \"groupFileShare(sessionId, groupName, dirPath, destinationUser)\"") @@ -1894,6 +2353,10 @@ func groupFileDelete(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"groupFileDelete(sessionId, groupName, podFileWithPath)\"") @@ -1922,6 +2385,10 @@ func groupFileStat(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"groupFileStat(sessionId, groupName, podFileWithPath)\"") @@ -1963,6 +2430,10 @@ func kvNewStore(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 4 { reject.Invoke("not enough arguments. \"kvNewStore(sessionId, podName, tableName, indexType)\"") @@ -2007,6 +2478,10 @@ func kvList(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"kvList(sessionId, podName)\"") @@ -2043,6 +2518,10 @@ func kvOpen(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"kvOpen(sessionId, podName, tableName)\"") @@ -2071,6 +2550,10 @@ func kvDelete(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"kvDelete(sessionId, podName, tableName)\"") @@ -2099,6 +2582,10 @@ func kvCount(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"kvCount(sessionId, podName, tableName)\"") @@ -2130,6 +2617,10 @@ func kvEntryPut(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 5 { reject.Invoke("not enough arguments. \"kvEntryPut(sessionId, podName, tableName, key, value)\"") @@ -2165,6 +2656,10 @@ func kvEntryGet(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 4 { reject.Invoke("not enough arguments. \"kvEntryGet(sessionId, podName, tableName, key)\"") @@ -2198,6 +2693,10 @@ func kvEntryDelete(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 4 { reject.Invoke("not enough arguments. \"kvEntryDelete(sessionId, podName, tableName, key)\"") @@ -2227,6 +2726,10 @@ func kvLoadCSV(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 4 { reject.Invoke("not enough arguments. \"kvLoadCSV(sessionId, podName, tableName, file)\"") return nil @@ -2304,6 +2807,10 @@ func kvSeek(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 6 { reject.Invoke("not enough arguments. \"kvSeek(sessionId, podName, tableName, start, end, limit)\"") @@ -2338,6 +2845,10 @@ func kvSeekNext(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"kvSeekNext(sessionId, podName, tableName)\"") @@ -2371,6 +2882,10 @@ func docNewStore(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 5 { reject.Invoke("not enough arguments. \"docNewStore(sessionId, podName, tableName, simpleIndexes, mutable)\"") @@ -2426,6 +2941,10 @@ func docList(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"docList(sessionId, podName)\"") @@ -2454,6 +2973,10 @@ func docOpen(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"docOpen(sessionId, podName, tableName)\"") @@ -2482,6 +3005,10 @@ func docCount(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 4 { reject.Invoke("not enough arguments. \"docCount(sessionId, podName, tableName, expression)\"") @@ -2512,6 +3039,10 @@ func docDelete(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"docDelete(sessionId, podName, tableName)\"") @@ -2540,6 +3071,10 @@ func docFind(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 5 { reject.Invoke("not enough arguments. \"docFind(sessionId, podName, tableName, expression, limit)\"") @@ -2571,6 +3106,10 @@ func docEntryPut(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 4 { reject.Invoke("not enough arguments. \"docEntryPut(sessionId, podName, tableName, value)\"") @@ -2604,6 +3143,10 @@ func docEntryGet(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 4 { reject.Invoke("not enough arguments. \"docEntryGet(sessionId, podName, tableName, id)\"") @@ -2637,6 +3180,10 @@ func docEntryDelete(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 4 { reject.Invoke("not enough arguments. \"docEntryDelete(sessionId, podName, tableName, id)\"") @@ -2666,6 +3213,10 @@ func docLoadJson(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 4 { reject.Invoke("not enough arguments. \"docLoadJson(sessionId, podName, tableName, file)\"") return nil @@ -2724,6 +3275,10 @@ func docIndexJson(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 4 { reject.Invoke("not enough arguments. \"docIndexJson(sessionId, podName, tableName, filePath)\"") @@ -2753,6 +3308,10 @@ func encryptSubscription(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"encryptSubscription(sessionId, podName, subscriberNameHash)\"") @@ -2792,6 +3351,10 @@ func getSubscriptions(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"getSubscriptions(sessionId)\"") @@ -2831,6 +3394,10 @@ func openSubscribedPod(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"openSubscribedPod(sessionId, subHash, keyLocation)\"") @@ -2869,6 +3436,10 @@ func openSubscribedPodFromReference(_ js.Value, funcArgs []js.Value) interface{} handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 3 { reject.Invoke("not enough arguments. \"openSubscribedPodFromReference(sessionId, reference, sellerNameHash)\"") @@ -2907,6 +3478,10 @@ func getSubscribablePods(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 1 { reject.Invoke("not enough arguments. \"getSubscribablePods(sessionId)\"") @@ -2950,6 +3525,10 @@ func getSubRequests(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 1 { reject.Invoke("not enough arguments. \"getSubRequests(sessionId)\"") @@ -2987,6 +3566,10 @@ func getSubscribablePodInfo(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"getSubscribablePodInfo(sessionId, subHash)\"") @@ -3033,6 +3616,10 @@ func getNameHash(_ js.Value, funcArgs []js.Value) interface{} { handler := js.FuncOf(func(_ js.Value, args []js.Value) interface{} { resolve := args[0] reject := args[1] + if api == nil { + reject.Invoke("not connected to fairOS") + return nil + } if len(funcArgs) != 2 { reject.Invoke("not enough arguments. \"getNameHash(sessionId, username)\"")