From e3183fd6fc798c96175ba3e657850fcf71ee140d Mon Sep 17 00:00:00 2001 From: Javi Date: Thu, 18 Apr 2024 12:45:24 +0200 Subject: [PATCH 1/6] feat: add custom package manager in order to support custom networks (#70) * feat: adding custom-networks verifications * chore: removing unneeded packagemanager * chore: adding new deploy settings --- .env-sample | 5 -- .github/workflows/deploy_new_account.yml | 31 +++++++- .github/workflows/dev_deploy.yml | 31 +++++++- .github/workflows/prod_deploy.yml | 31 +++++++- .github/workflows/testing_deploy.yml | 31 +++++++- cmd/main.go | 69 ++++++++++++++++- go.mod | 6 +- internal/api/main_test.go | 10 +-- internal/api/server.go | 98 ++++++++---------------- internal/api/server_test.go | 25 +++--- internal/config/config.go | 11 ++- resolvers_settings_sample.yaml | 20 +++-- 12 files changed, 251 insertions(+), 117 deletions(-) diff --git a/.env-sample b/.env-sample index c7a026a..fa0d05a 100644 --- a/.env-sample +++ b/.env-sample @@ -1,11 +1,6 @@ VERIFIER_BACKEND_HOST=http://localhost:3010 VERIFIER_BACKEND_PORT=3010 VERIFIER_BACKEND_KEY_DIR=./keys - - VERIFIER_IPFS_URL=https://gateway.pinata.cloud -VERIFIER_BACKEND_MUMBAI_SENDER_DID=did:polygonid:polygon:mumbai:2qH7TstpRRJHXNN4o49Fu9H2Qismku8hQeUxDVrjqT -VERIFIER_BACKEND_MAIN_SENDER_DID=did:polygonid:polygon:main:2q4Q7F7tM1xpwUTgWivb6TgKX3vWirsE3mqymuYjVv -VERIFIER_BACKEND_AMOY_SENDER_DID=did:polygonid:polygon:amoy:2qV9QXdhXXmN5sKjN1YueMjxgRbnJcEGK2kGpvk3cq VERIFIER_BACKEND_RESOLVER_SETTINGS_PATH=./resolvers_settings.yaml VERIFIER_BACKEND_CACHE_EXPIRATION=60m \ No newline at end of file diff --git a/.github/workflows/deploy_new_account.yml b/.github/workflows/deploy_new_account.yml index 21e9cca..f6d5c36 100644 --- a/.github/workflows/deploy_new_account.yml +++ b/.github/workflows/deploy_new_account.yml @@ -10,9 +10,22 @@ on: env: AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} ECR_REPOSITORY: verifier_backend - POLYGON_MUMBAI_CONTRACT_ADDRESS: "0x134B1BE34911E39A8397ec6289782989729807a4" + POLYGON_AMOY_CONTRACT_ADDRESS: "0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124" + POLYGON_AMOY_SENDER_DID: "did:polygonid:polygon:amoy:2qV9QXdhXXmN5sKjN1YueMjxgRbnJcEGK2kGpvk3cq" + POLYGON_AMOY_NETWORK_FLAG: "0b0001_0011" + POLYGON_AMOY_CHAIN_ID: "80002" + POLYGON_MAIN_CONTRACT_ADDRESS: "0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D" + POLYGON_MAIN_SENDER_DID: "did:polygonid:polygon:main:2q4Q7F7tM1xpwUTgWivb6TgKX3vWirsE3mqymuYjVv" + POLYGON_MAIN_NETWORK_FLAG: "0b0001_0001" + POLYGON_MAIN_CHAIN_ID: "137" + + CAMINO_COLUMBUS_CONTRACT_ADDRESS: "0x34eCe5eCe59B978C95147bBa6db8fb62F127e601" + CAMINO_COLUMBUS_NODE_URL: "https://columbus.camino.network/ext/bc/C/rpc" + CAMINO_COLUMBUS_SENDER_DID: "did:polygonid:camino:columbus:3E1DZ5qrNCJctmUS3nphEkfsvqYs1kL5oGTtEpYiov" + CAMINO_COLUMBUS_NETWORK_FLAG: "0b10000011" + CAMINO_COLUMBUS_CHAIN_ID: "501" jobs: build-backend: @@ -48,12 +61,22 @@ jobs: echo -e " amoy:" >> resolvers_settings.yaml echo -e " contractAddress: ${{ env.POLYGON_AMOY_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml echo -e " networkURL: ${{ secrets.POLYGON_AMOY_NODE_URL }}" >> resolvers_settings.yaml - echo -e " mumbai:" >> resolvers_settings.yaml - echo -e " contractAddress: ${{ env.POLYGON_MUMBAI_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml - echo -e " networkURL: ${{ secrets.POLYGON_NODE_URL }}" >> resolvers_settings.yaml + echo -e " chainID: ${{ env.POLYGON_AMOY_CHAIN_ID }}" >> resolvers_settings.yaml + echo -e " networkFlag: ${{ env.POLYGON_AMOY_NETWORK_FLAG }}" >> resolvers_settings.yaml + echo -e " did: ${{ env.POLYGON_AMOY_SENDER_DID }}" >> resolvers_settings.yaml echo -e " main:" >> resolvers_settings.yaml echo -e " contractAddress: ${{ env.POLYGON_MAIN_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml echo -e " networkURL: ${{ secrets.POLYGON_MAINET_NODE_URL }}" >> resolvers_settings.yaml + echo -e " chainID: ${{ env.POLYGON_MAIN_CHAIN_ID }}" >> resolvers_settings.yaml + echo -e " networkFlag: ${{ env.POLYGON_MAIN_NETWORK_FLAG }}" >> resolvers_settings.yaml + echo -e " did: ${{ env.POLYGON_MAIN_SENDER_DID }}" >> resolvers_settings.yaml + echo -e "camino:" > resolvers_settings.yaml + echo -e " columbus:" >> resolvers_settings.yaml + echo -e " contractAddress: ${{ env.CAMINO_COLUMBUS_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml + echo -e " networkURL: ${{ env.CAMINO_COLUMBUS_NODE_URL }}" >> resolvers_settings.yaml + echo -e " chainID: ${{ env.CAMINO_COLUMBUS_CHAIN_ID }}" >> resolvers_settings.yaml + echo -e " networkFlag: ${{ env.CAMINO_COLUMBUS_NETWORK_FLAG }}" >> resolvers_settings.yaml + echo -e " did: ${{ env.CAMINO_COLUMBUS_SENDER_DID }}" >> resolvers_settings.yaml cat resolvers_settings.yaml - run: make build/docker diff --git a/.github/workflows/dev_deploy.yml b/.github/workflows/dev_deploy.yml index 6ae2187..20f75ca 100644 --- a/.github/workflows/dev_deploy.yml +++ b/.github/workflows/dev_deploy.yml @@ -12,9 +12,22 @@ env: AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} ENVIRONMENT: dev ECR_REPOSITORY: verifier_backend - POLYGON_MUMBAI_CONTRACT_ADDRESS: "0x134B1BE34911E39A8397ec6289782989729807a4" + POLYGON_AMOY_CONTRACT_ADDRESS: "0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124" + POLYGON_AMOY_SENDER_DID: "did:polygonid:polygon:amoy:2qV9QXdhXXmN5sKjN1YueMjxgRbnJcEGK2kGpvk3cq" + POLYGON_AMOY_NETWORK_FLAG: "0b0001_0011" + POLYGON_AMOY_CHAIN_ID: "80002" + POLYGON_MAIN_CONTRACT_ADDRESS: "0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D" + POLYGON_MAIN_SENDER_DID: "did:polygonid:polygon:main:2q4Q7F7tM1xpwUTgWivb6TgKX3vWirsE3mqymuYjVv" + POLYGON_MAIN_NETWORK_FLAG: "0b0001_0001" + POLYGON_MAIN_CHAIN_ID: "137" + + CAMINO_COLUMBUS_CONTRACT_ADDRESS: "0x34eCe5eCe59B978C95147bBa6db8fb62F127e601" + CAMINO_COLUMBUS_NODE_URL: "https://columbus.camino.network/ext/bc/C/rpc" + CAMINO_COLUMBUS_SENDER_DID: "did:polygonid:camino:columbus:3E1DZ5qrNCJctmUS3nphEkfsvqYs1kL5oGTtEpYiov" + CAMINO_COLUMBUS_NETWORK_FLAG: "0b10000011" + CAMINO_COLUMBUS_CHAIN_ID: "501" jobs: build-backend: @@ -48,12 +61,22 @@ jobs: echo -e " amoy:" >> resolvers_settings.yaml echo -e " contractAddress: ${{ env.POLYGON_AMOY_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml echo -e " networkURL: ${{ secrets.POLYGON_AMOY_NODE_URL }}" >> resolvers_settings.yaml - echo -e " mumbai:" >> resolvers_settings.yaml - echo -e " contractAddress: ${{ env.POLYGON_MUMBAI_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml - echo -e " networkURL: ${{ secrets.POLYGON_NODE_URL }}" >> resolvers_settings.yaml + echo -e " chainID: ${{ env.POLYGON_AMOY_CHAIN_ID }}" >> resolvers_settings.yaml + echo -e " networkFlag: ${{ env.POLYGON_AMOY_NETWORK_FLAG }}" >> resolvers_settings.yaml + echo -e " did: ${{ env.POLYGON_AMOY_SENDER_DID }}" >> resolvers_settings.yaml echo -e " main:" >> resolvers_settings.yaml echo -e " contractAddress: ${{ env.POLYGON_MAIN_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml echo -e " networkURL: ${{ secrets.POLYGON_MAINET_NODE_URL }}" >> resolvers_settings.yaml + echo -e " chainID: ${{ env.POLYGON_MAIN_CHAIN_ID }}" >> resolvers_settings.yaml + echo -e " networkFlag: ${{ env.POLYGON_MAIN_NETWORK_FLAG }}" >> resolvers_settings.yaml + echo -e " did: ${{ env.POLYGON_MAIN_SENDER_DID }}" >> resolvers_settings.yaml + echo -e "camino:" > resolvers_settings.yaml + echo -e " columbus:" >> resolvers_settings.yaml + echo -e " contractAddress: ${{ env.CAMINO_COLUMBUS_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml + echo -e " networkURL: ${{ env.CAMINO_COLUMBUS_NODE_URL }}" >> resolvers_settings.yaml + echo -e " chainID: ${{ env.CAMINO_COLUMBUS_CHAIN_ID }}" >> resolvers_settings.yaml + echo -e " networkFlag: ${{ env.CAMINO_COLUMBUS_NETWORK_FLAG }}" >> resolvers_settings.yaml + echo -e " did: ${{ env.CAMINO_COLUMBUS_SENDER_DID }}" >> resolvers_settings.yaml cat resolvers_settings.yaml - run: make build/docker diff --git a/.github/workflows/prod_deploy.yml b/.github/workflows/prod_deploy.yml index 4da4c52..0f65206 100644 --- a/.github/workflows/prod_deploy.yml +++ b/.github/workflows/prod_deploy.yml @@ -12,9 +12,22 @@ env: AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} ENVIRONMENT: production ECR_REPOSITORY: verifier_backend - POLYGON_MUMBAI_CONTRACT_ADDRESS: "0x134B1BE34911E39A8397ec6289782989729807a4" + POLYGON_AMOY_CONTRACT_ADDRESS: "0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124" + POLYGON_AMOY_SENDER_DID: "did:polygonid:polygon:amoy:2qV9QXdhXXmN5sKjN1YueMjxgRbnJcEGK2kGpvk3cq" + POLYGON_AMOY_NETWORK_FLAG: "0b0001_0011" + POLYGON_AMOY_CHAIN_ID: "80002" + POLYGON_MAIN_CONTRACT_ADDRESS: "0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D" + POLYGON_MAIN_SENDER_DID: "did:polygonid:polygon:main:2q4Q7F7tM1xpwUTgWivb6TgKX3vWirsE3mqymuYjVv" + POLYGON_MAIN_NETWORK_FLAG: "0b0001_0001" + POLYGON_MAIN_CHAIN_ID: "137" + + CAMINO_COLUMBUS_CONTRACT_ADDRESS: "0x34eCe5eCe59B978C95147bBa6db8fb62F127e601" + CAMINO_COLUMBUS_NODE_URL: "https://columbus.camino.network/ext/bc/C/rpc" + CAMINO_COLUMBUS_SENDER_DID: "did:polygonid:camino:columbus:3E1DZ5qrNCJctmUS3nphEkfsvqYs1kL5oGTtEpYiov" + CAMINO_COLUMBUS_NETWORK_FLAG: "0b10000011" + CAMINO_COLUMBUS_CHAIN_ID: "501" jobs: build-backend: @@ -48,12 +61,22 @@ jobs: echo -e " amoy:" >> resolvers_settings.yaml echo -e " contractAddress: ${{ env.POLYGON_AMOY_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml echo -e " networkURL: ${{ secrets.POLYGON_AMOY_NODE_URL }}" >> resolvers_settings.yaml - echo -e " mumbai:" >> resolvers_settings.yaml - echo -e " contractAddress: ${{ env.POLYGON_MUMBAI_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml - echo -e " networkURL: ${{ secrets.POLYGON_NODE_URL }}" >> resolvers_settings.yaml + echo -e " chainID: ${{ env.POLYGON_AMOY_CHAIN_ID }}" >> resolvers_settings.yaml + echo -e " networkFlag: ${{ env.POLYGON_AMOY_NETWORK_FLAG }}" >> resolvers_settings.yaml + echo -e " did: ${{ env.POLYGON_AMOY_SENDER_DID }}" >> resolvers_settings.yaml echo -e " main:" >> resolvers_settings.yaml echo -e " contractAddress: ${{ env.POLYGON_MAIN_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml echo -e " networkURL: ${{ secrets.POLYGON_MAINET_NODE_URL }}" >> resolvers_settings.yaml + echo -e " chainID: ${{ env.POLYGON_MAIN_CHAIN_ID }}" >> resolvers_settings.yaml + echo -e " networkFlag: ${{ env.POLYGON_MAIN_NETWORK_FLAG }}" >> resolvers_settings.yaml + echo -e " did: ${{ env.POLYGON_MAIN_SENDER_DID }}" >> resolvers_settings.yaml + echo -e "camino:" > resolvers_settings.yaml + echo -e " columbus:" >> resolvers_settings.yaml + echo -e " contractAddress: ${{ env.CAMINO_COLUMBUS_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml + echo -e " networkURL: ${{ env.CAMINO_COLUMBUS_NODE_URL }}" >> resolvers_settings.yaml + echo -e " chainID: ${{ env.CAMINO_COLUMBUS_CHAIN_ID }}" >> resolvers_settings.yaml + echo -e " networkFlag: ${{ env.CAMINO_COLUMBUS_NETWORK_FLAG }}" >> resolvers_settings.yaml + echo -e " did: ${{ env.CAMINO_COLUMBUS_SENDER_DID }}" >> resolvers_settings.yaml cat resolvers_settings.yaml - run: make build/docker diff --git a/.github/workflows/testing_deploy.yml b/.github/workflows/testing_deploy.yml index 4da4b82..20097f1 100644 --- a/.github/workflows/testing_deploy.yml +++ b/.github/workflows/testing_deploy.yml @@ -12,9 +12,22 @@ env: AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} ENVIRONMENT: testing ECR_REPOSITORY: verifier_backend - POLYGON_MUMBAI_CONTRACT_ADDRESS: "0x134B1BE34911E39A8397ec6289782989729807a4" + POLYGON_AMOY_CONTRACT_ADDRESS: "0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124" + POLYGON_AMOY_SENDER_DID: "did:polygonid:polygon:amoy:2qV9QXdhXXmN5sKjN1YueMjxgRbnJcEGK2kGpvk3cq" + POLYGON_AMOY_NETWORK_FLAG: "0b0001_0011" + POLYGON_AMOY_CHAIN_ID: "80002" + POLYGON_MAIN_CONTRACT_ADDRESS: "0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D" + POLYGON_MAIN_SENDER_DID: "did:polygonid:polygon:main:2q4Q7F7tM1xpwUTgWivb6TgKX3vWirsE3mqymuYjVv" + POLYGON_MAIN_NETWORK_FLAG: "0b0001_0001" + POLYGON_MAIN_CHAIN_ID: "137" + + CAMINO_COLUMBUS_CONTRACT_ADDRESS: "0x34eCe5eCe59B978C95147bBa6db8fb62F127e601" + CAMINO_COLUMBUS_NODE_URL: "https://columbus.camino.network/ext/bc/C/rpc" + CAMINO_COLUMBUS_SENDER_DID: "did:polygonid:camino:columbus:3E1DZ5qrNCJctmUS3nphEkfsvqYs1kL5oGTtEpYiov" + CAMINO_COLUMBUS_NETWORK_FLAG: "0b10000011" + CAMINO_COLUMBUS_CHAIN_ID: "501" jobs: build-backend: @@ -48,12 +61,22 @@ jobs: echo -e " amoy:" >> resolvers_settings.yaml echo -e " contractAddress: ${{ env.POLYGON_AMOY_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml echo -e " networkURL: ${{ secrets.POLYGON_AMOY_NODE_URL }}" >> resolvers_settings.yaml - echo -e " mumbai:" >> resolvers_settings.yaml - echo -e " contractAddress: ${{ env.POLYGON_MUMBAI_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml - echo -e " networkURL: ${{ secrets.POLYGON_NODE_URL }}" >> resolvers_settings.yaml + echo -e " chainID: ${{ env.POLYGON_AMOY_CHAIN_ID }}" >> resolvers_settings.yaml + echo -e " networkFlag: ${{ env.POLYGON_AMOY_NETWORK_FLAG }}" >> resolvers_settings.yaml + echo -e " did: ${{ env.POLYGON_AMOY_SENDER_DID }}" >> resolvers_settings.yaml echo -e " main:" >> resolvers_settings.yaml echo -e " contractAddress: ${{ env.POLYGON_MAIN_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml echo -e " networkURL: ${{ secrets.POLYGON_MAINET_NODE_URL }}" >> resolvers_settings.yaml + echo -e " chainID: ${{ env.POLYGON_MAIN_CHAIN_ID }}" >> resolvers_settings.yaml + echo -e " networkFlag: ${{ env.POLYGON_MAIN_NETWORK_FLAG }}" >> resolvers_settings.yaml + echo -e " did: ${{ env.POLYGON_MAIN_SENDER_DID }}" >> resolvers_settings.yaml + echo -e "camino:" > resolvers_settings.yaml + echo -e " columbus:" >> resolvers_settings.yaml + echo -e " contractAddress: ${{ env.CAMINO_COLUMBUS_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml + echo -e " networkURL: ${{ env.CAMINO_COLUMBUS_NODE_URL }}" >> resolvers_settings.yaml + echo -e " chainID: ${{ env.CAMINO_COLUMBUS_CHAIN_ID }}" >> resolvers_settings.yaml + echo -e " networkFlag: ${{ env.CAMINO_COLUMBUS_NETWORK_FLAG }}" >> resolvers_settings.yaml + echo -e " did: ${{ env.CAMINO_COLUMBUS_SENDER_DID }}" >> resolvers_settings.yaml cat resolvers_settings.yaml - run: make build/docker diff --git a/cmd/main.go b/cmd/main.go index 6430866..f66c2ab 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -1,32 +1,38 @@ package main import ( + "context" "fmt" "net/http" "os" "os/signal" + "strconv" "syscall" "github.com/go-chi/chi/v5" chiMiddleware "github.com/go-chi/chi/v5/middleware" "github.com/go-chi/cors" + auth "github.com/iden3/go-iden3-auth/v2" "github.com/iden3/go-iden3-auth/v2/loaders" + "github.com/iden3/go-iden3-auth/v2/pubsignals" + "github.com/iden3/go-iden3-auth/v2/state" + core "github.com/iden3/go-iden3-core/v2" log "github.com/sirupsen/logrus" "github.com/0xPolygonID/verifier-backend/internal/api" "github.com/0xPolygonID/verifier-backend/internal/config" "github.com/0xPolygonID/verifier-backend/internal/errors" + "github.com/0xPolygonID/verifier-backend/internal/loader" ) func main() { + ctx := context.Background() cfg, err := config.Load() if err != nil { log.WithField("error", err).Error("cannot load config") return } - keysLoader := &loaders.FSKeyLoader{Dir: cfg.KeyDIR} - mux := chi.NewRouter() mux.Use( @@ -36,7 +42,21 @@ func main() { chiMiddleware.NoCache, ) - apiServer := api.New(*cfg, keysLoader) + keysLoader := &loaders.FSKeyLoader{Dir: cfg.KeyDIR} + w3cLoader := loader.NewW3CDocumentLoader(nil, cfg.IPFSURL) + resolvers, senderDIDs, err := parseResolverSettings(ctx, cfg.ResolverSettings) + if err != nil { + log.WithField("error", err).Error("cannot parse resolver settings") + return + } + + verifier, err := auth.NewVerifier(keysLoader, resolvers, auth.WithDocumentLoader(w3cLoader)) + if err != nil { + log.WithFields(log.Fields{"err": err}).Error("failed to create verifier") + return + } + + apiServer := api.New(*cfg, verifier, senderDIDs) api.HandlerFromMux(api.NewStrictHandlerWithOptions(apiServer, nil, api.StrictHTTPServerOptions{RequestErrorHandlerFunc: errors.RequestErrorHandlerFunc}), mux) api.RegisterStatic(mux) @@ -58,3 +78,46 @@ func main() { <-quit log.Info("Shutting down") } + +// parseResolverSettings parses the resolver settings from the config file +func parseResolverSettings(ctx context.Context, rs config.ResolverSettings) (map[string]pubsignals.StateResolver, map[string]string, error) { + var ( + resolvers = make(map[string]pubsignals.StateResolver) + verifiersDIDs = make(map[string]string) + ) + + for chainName, chainSettings := range rs { + for networkName, networkSettings := range chainSettings { + prefix := fmt.Sprintf("%s:%s", chainName, networkName) + resolver := state.NewETHResolver(networkSettings.NetworkURL, networkSettings.ContractAddress) + resolvers[prefix] = resolver + + if err := registerCustomDIDMethod(ctx, chainName, networkName, networkSettings); err != nil { + log.Error(ctx, "cannot register custom DID method", "err", err) + return nil, nil, err + } + + verifiersDIDs[networkSettings.ChainID] = networkSettings.DID + } + } + + return resolvers, verifiersDIDs, nil +} + +func registerCustomDIDMethod(ctx context.Context, blockchain string, network string, resolverAttrs config.ResolverSettingsAttrs) error { + chainID, err := strconv.Atoi(resolverAttrs.ChainID) + if err != nil { + return fmt.Errorf("cannot convert chainID to int: %w", err) + } + params := core.DIDMethodNetworkParams{ + Method: core.DIDMethodPolygonID, + Blockchain: core.Blockchain(blockchain), + Network: core.NetworkID(network), + NetworkFlag: resolverAttrs.NetworkFlag, + } + if err := core.RegisterDIDMethodNetwork(params, core.WithChainID(chainID)); err != nil { + log.Error(ctx, "cannot register custom DID method", "err", err, "customDID", chainID) + return err + } + return nil +} diff --git a/go.mod b/go.mod index 0fe9927..d4ab462 100644 --- a/go.mod +++ b/go.mod @@ -9,9 +9,11 @@ require ( github.com/go-chi/cors v1.2.1 github.com/golangci/golangci-lint v1.55.1 github.com/google/uuid v1.6.0 + github.com/iden3/contracts-abi/state/go/abi v1.0.1 github.com/iden3/go-circuits/v2 v2.2.0 github.com/iden3/go-iden3-auth/v2 v2.2.2 github.com/iden3/go-iden3-core/v2 v2.1.0 + github.com/iden3/go-jwz/v2 v2.0.2 github.com/iden3/go-schema-processor/v2 v2.3.3 github.com/iden3/iden3comm/v2 v2.3.2 github.com/ipfs/go-ipfs-api v0.7.0 @@ -20,6 +22,7 @@ require ( github.com/oapi-codegen/runtime v1.1.1 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/piprate/json-gold v0.5.1-0.20230111113000-6ddbe6e6f19f + github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.9.3 github.com/stretchr/testify v1.9.0 gopkg.in/yaml.v3 v3.0.1 @@ -122,9 +125,7 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/hexops/gotextdiff v1.0.3 // indirect github.com/holiman/uint256 v1.2.4 // indirect - github.com/iden3/contracts-abi/state/go/abi v1.0.1 // indirect github.com/iden3/go-iden3-crypto v0.0.16 // indirect - github.com/iden3/go-jwz/v2 v2.0.2 // indirect github.com/iden3/go-merkletree-sql/v2 v2.0.6 // indirect github.com/iden3/go-rapidsnark/prover v0.0.10 // indirect github.com/iden3/go-rapidsnark/types v0.0.3 // indirect @@ -194,7 +195,6 @@ require ( github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.9 // indirect github.com/perimeterx/marshmallow v1.1.4 // indirect - github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/polyfloyd/go-errorlint v1.4.5 // indirect github.com/pquerna/cachecontrol v0.2.0 // indirect diff --git a/internal/api/main_test.go b/internal/api/main_test.go index afee1d0..2e4f66c 100644 --- a/internal/api/main_test.go +++ b/internal/api/main_test.go @@ -17,12 +17,10 @@ var ( func TestMain(m *testing.M) { cfg = config.Config{ - Host: "http://localhost", - ApiPort: "3000", - KeyDIR: "./keys", - MumbaiSenderDID: "did:polygonid:polygon:mumbai:2qH7TstpRRJHXNN4o49Fu9H2Qismku8hQeUxDVrjqT", - MainSenderDID: "did:polygonid:polygon:main:2qH7TstpRRJHXNN4o49Fu9H2Qismku8hQeUxDVrjqT", - IPFSURL: "https://gateway.pinata.cloud", + Host: "http://localhost", + ApiPort: "3000", + KeyDIR: "./keys", + IPFSURL: "https://gateway.pinata.cloud", ResolverSettings: config.ResolverSettings{ "polygon": { "mumbai": { diff --git a/internal/api/server.go b/internal/api/server.go index 04bbb2b..4b139bc 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -16,9 +16,7 @@ import ( "github.com/google/uuid" "github.com/iden3/go-circuits/v2" auth "github.com/iden3/go-iden3-auth/v2" - "github.com/iden3/go-iden3-auth/v2/loaders" "github.com/iden3/go-iden3-auth/v2/pubsignals" - "github.com/iden3/go-iden3-auth/v2/state" core "github.com/iden3/go-iden3-core/v2" "github.com/iden3/go-iden3-core/v2/w3c" "github.com/iden3/iden3comm/v2/protocol" @@ -27,7 +25,6 @@ import ( "github.com/0xPolygonID/verifier-backend/internal/common" "github.com/0xPolygonID/verifier-backend/internal/config" - "github.com/0xPolygonID/verifier-backend/internal/loader" "github.com/0xPolygonID/verifier-backend/internal/models" ) @@ -45,20 +42,22 @@ const ( // Server represents the API server type Server struct { - keyLoader *loaders.FSKeyLoader - cfg config.Config - qrStore *QRcodeStore - cache *cache.Cache + cfg config.Config + qrStore *QRcodeStore + cache *cache.Cache + verifier *auth.Verifier + senderDIDs map[string]string } // New creates a new API server -func New(cfg config.Config, keyLoader *loaders.FSKeyLoader) *Server { +func New(cfg config.Config, verifier *auth.Verifier, senderDIDs map[string]string) *Server { c := cache.New(cfg.CacheExpiration.AsDuration(), cfg.CacheExpiration.AsDuration()) return &Server{ - cfg: cfg, - keyLoader: keyLoader, - qrStore: NewQRCodeStore(c), - cache: c, + cfg: cfg, + qrStore: NewQRCodeStore(c), + cache: c, + verifier: verifier, + senderDIDs: senderDIDs, } } @@ -106,19 +105,7 @@ func (s *Server) Callback(ctx context.Context, request CallbackRequestObject) (C }, nil } - w3cLoader := loader.NewW3CDocumentLoader(nil, s.cfg.IPFSURL) - - resolvers := s.parseResolverSettings() - verifier, err := auth.NewVerifier(s.keyLoader, resolvers, auth.WithDocumentLoader(w3cLoader)) - if err != nil { - log.WithFields(log.Fields{ - "sessionID": sessionID, - "err": err, - }).Error("failed to create verifier") - return nil, err - } - - authRespMsg, err := verifier.FullVerify(ctx, *request.Body, + authRespMsg, err := s.verifier.FullVerify(ctx, *request.Body, authRequest.(protocol.AuthorizationRequestMessage), pubsignals.WithAcceptedStateTransitionDelay(stateTransitionDelay)) if err != nil { @@ -172,7 +159,7 @@ func (s *Server) SignIn(_ context.Context, request SignInRequestObject) (SignInR switch circuits.CircuitID(request.Body.Scope[0].CircuitId) { case circuits.AtomicQuerySigV2CircuitID, circuits.AtomicQueryMTPV2CircuitID, circuits.AtomicQueryV3CircuitID: - authReq, err := getAuthRequestOffChain(request, s.cfg, sessionID) + authReq, err := s.getAuthRequestOffChain(request, sessionID) if err != nil { log.Error(err) return SignIn400JSONResponse{N400JSONResponse{err.Error()}}, nil @@ -188,7 +175,7 @@ func (s *Server) SignIn(_ context.Context, request SignInRequestObject) (SignInR SessionID: sessionID, }, nil case circuits.AtomicQuerySigV2OnChainCircuitID, circuits.AtomicQueryMTPV2OnChainCircuitID, circuits.AtomicQueryV3OnChainCircuitID: - invokeReq, err := getContractInvokeRequestOnChain(request, s.cfg) + invokeReq, err := s.getContractInvokeRequestOnChain(request) if err != nil { log.Error(err) return SignIn400JSONResponse{N400JSONResponse{err.Error()}}, nil @@ -263,19 +250,6 @@ func writeFile(path string, mimeType string, w http.ResponseWriter) { _, _ = w.Write(f) } -// parseResolverSettings parses the resolver settings from the config file -func (s *Server) parseResolverSettings() map[string]pubsignals.StateResolver { - resolvers := map[string]pubsignals.StateResolver{} - for chainName, chainSettings := range s.cfg.ResolverSettings { - for networkName, networkSettings := range chainSettings { - prefix := fmt.Sprintf("%s:%s", chainName, networkName) - resolver := state.NewETHResolver(networkSettings.NetworkURL, networkSettings.ContractAddress) - resolvers[prefix] = resolver - } - } - return resolvers -} - func getAuthReqQRCode(request protocol.AuthorizationRequestMessage) QRCode { scopes := make([]Scope, 0, len(request.Body.Scope)) for _, scope := range request.Body.Scope { @@ -352,10 +326,6 @@ func validateOffChainRequest(request SignInRequestObject) error { return fmt.Errorf("field chainId is empty expected %s or %s or %s", mumbaiNetwork, mainnetNetwork, amoyNetwork) } - if err := validateNetWork(*request.Body.ChainID); err != nil { - return err - } - if err := validateRequestQuery(true, request.Body.Scope); err != nil { return err } @@ -363,14 +333,6 @@ func validateOffChainRequest(request SignInRequestObject) error { return nil } -func validateNetWork(chainID string) error { - if chainID != mumbaiNetwork && chainID != mainnetNetwork && chainID != amoyNetwork { - return fmt.Errorf("field chainID value is wrong, got %s, expected %s or %s or %s", chainID, mumbaiNetwork, mainnetNetwork, amoyNetwork) - } - - return nil -} - func validateRequestQuery(offChainRequest bool, scope []ScopeRequest) error { reqIds := make(map[uint32]bool, 0) for _, scope := range scope { @@ -420,13 +382,18 @@ func validateRequestQuery(offChainRequest bool, scope []ScopeRequest) error { return nil } -func getAuthRequestOffChain(req SignInRequestObject, cfg config.Config, sessionID uuid.UUID) (protocol.AuthorizationRequestMessage, error) { +func (s *Server) getAuthRequestOffChain(req SignInRequestObject, sessionID uuid.UUID) (protocol.AuthorizationRequestMessage, error) { if err := validateOffChainRequest(req); err != nil { return protocol.AuthorizationRequestMessage{}, err } + senderDID, err := s.getSenderDID(*req.Body.ChainID) + if err != nil { + return protocol.AuthorizationRequestMessage{}, err + } + id := uuid.NewString() - authReq := auth.CreateAuthorizationRequest(getReason(req.Body.Reason), getSenderID(*req.Body.ChainID, cfg), getUri(cfg, sessionID)) + authReq := auth.CreateAuthorizationRequest(getReason(req.Body.Reason), senderDID, getUri(s.cfg, sessionID)) authReq.ID = id authReq.ThreadID = id authReq.To = "" @@ -481,7 +448,7 @@ func checkOnChainRequest(req SignInRequestObject) error { return nil } -func getContractInvokeRequestOnChain(req SignInRequestObject, cfg config.Config) (protocol.ContractInvokeRequestMessage, error) { +func (s *Server) getContractInvokeRequestOnChain(req SignInRequestObject) (protocol.ContractInvokeRequestMessage, error) { if err := checkOnChainRequest(req); err != nil { return protocol.ContractInvokeRequestMessage{}, err } @@ -509,8 +476,13 @@ func getContractInvokeRequestOnChain(req SignInRequestObject, cfg config.Config) ChainID: req.Body.TransactionData.ChainID, Network: req.Body.TransactionData.Network, } + senderDID, err := s.getSenderDID(strconv.Itoa(transactionData.ChainID)) + if err != nil { + return protocol.ContractInvokeRequestMessage{}, err + } + + authReq := auth.CreateContractInvokeRequest(getReason(req.Body.Reason), senderDID, transactionData, mtpProofRequests...) id := uuid.NewString() - authReq := auth.CreateContractInvokeRequest(getReason(req.Body.Reason), getSenderID(strconv.Itoa(transactionData.ChainID), cfg), transactionData, mtpProofRequests...) authReq.ID = id authReq.ThreadID = id authReq.To = "" @@ -565,15 +537,13 @@ func getParams(params ScopeParams) (map[string]interface{}, error) { return map[string]interface{}{"nullifierSessionId": nullifierSessionID.String()}, nil } -func getSenderID(chainID string, cfg config.Config) string { - switch chainID { - case mumbaiNetwork: - return cfg.MumbaiSenderDID - case mainnetNetwork: - return cfg.MainSenderDID - default: - return cfg.AmoySenderDID +func (s *Server) getSenderDID(chainID string) (string, error) { + val, ok := s.senderDIDs[chainID] + if !ok { + return "", fmt.Errorf("sender not found for chainID %s", chainID) } + + return val, nil } func getUri(cfg config.Config, sessionID uuid.UUID) string { diff --git a/internal/api/server_test.go b/internal/api/server_test.go index 54c63bb..4b89a63 100644 --- a/internal/api/server_test.go +++ b/internal/api/server_test.go @@ -17,9 +17,11 @@ import ( "github.com/0xPolygonID/verifier-backend/internal/common" ) +const mumbaiSenderDID = "did:polygonid:polygon:mumbai:2qCU58EJgrELdThzMyykDwT5kWff6XSbpSWtTQ7oS8" + func TestSignIn(t *testing.T) { ctx := context.Background() - server := New(cfg, keysLoader) + server := New(cfg, nil, map[string]string{"80001": mumbaiSenderDID}) type expected struct { httpCode int @@ -78,7 +80,7 @@ func TestSignIn(t *testing.T) { }, }, }, - From: cfg.MumbaiSenderDID, + From: mumbaiSenderDID, To: nil, Typ: string(packers.MediaTypePlainMessage), Type: string(protocol.AuthorizationRequestMessageType), @@ -130,7 +132,7 @@ func TestSignIn(t *testing.T) { }, }, }, - From: cfg.MumbaiSenderDID, + From: mumbaiSenderDID, To: common.ToPointer("did:polygonid:polygon:mumbai:2qEATqfECVbCBzq9EhJpPSiv1xtJRpbMBKDaNM68Ci"), Typ: string(packers.MediaTypePlainMessage), Type: string(protocol.AuthorizationRequestMessageType), @@ -181,7 +183,7 @@ func TestSignIn(t *testing.T) { }, }, }, - From: cfg.MumbaiSenderDID, + From: mumbaiSenderDID, To: nil, Typ: string(packers.MediaTypePlainMessage), Type: string(protocol.AuthorizationRequestMessageType), @@ -234,7 +236,7 @@ func TestSignIn(t *testing.T) { }, }, }, - From: cfg.MumbaiSenderDID, + From: mumbaiSenderDID, To: nil, Typ: string(packers.MediaTypePlainMessage), Type: string(protocol.AuthorizationRequestMessageType), @@ -293,7 +295,7 @@ func TestSignIn(t *testing.T) { }, }, }, - From: cfg.MumbaiSenderDID, + From: mumbaiSenderDID, To: nil, Typ: string(packers.MediaTypePlainMessage), Type: string(protocol.AuthorizationRequestMessageType), @@ -420,7 +422,7 @@ func TestSignIn(t *testing.T) { }, }, }, - From: cfg.MumbaiSenderDID, + From: mumbaiSenderDID, To: nil, Typ: "application/iden3comm-plain-json", Type: "https://iden3-communication.io/authorization/1.0/request", @@ -611,12 +613,13 @@ func TestSignIn(t *testing.T) { }, }, { - name: "invalid request - invalid ChainID", + name: "sender not found for chainID invalid", body: SignInRequestObject{ Body: &SignInJSONRequestBody{ - ChainID: common.ToPointer("invalid"), + ChainID: common.ToPointer("12345"), Scope: []ScopeRequest{ { + Id: uint32(12), CircuitId: string(circuits.AtomicQueryV3CircuitID), Query: jsonToMap(t, `{ "context": "https://raw.githubusercontent.com/iden3/claim-schema-vocab/main/schemas/json-ld/kyc-v3.json-ld", @@ -635,7 +638,7 @@ func TestSignIn(t *testing.T) { }, expected: expected{ httpCode: http.StatusBadRequest, - ErrorMessage: "field chainID value is wrong, got invalid, expected 80001 or 137 or 80002", + ErrorMessage: "sender not found for chainID 12345", }, }, { @@ -920,7 +923,7 @@ func TestSignIn(t *testing.T) { }, }, }, - From: cfg.MumbaiSenderDID, + From: mumbaiSenderDID, To: nil, Typ: "application/iden3comm-plain-json", Type: "https://iden3-communication.io/authorization/1.0/request", diff --git a/internal/config/config.go b/internal/config/config.go index aa99afd..83eea35 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -22,9 +22,6 @@ type Config struct { Host string `envconfig:"host" default:"http://localhost"` ApiPort string `envconfig:"port" default:"3009"` KeyDIR string `envconfig:"keydir" default:"./keys"` - MumbaiSenderDID string `envconfig:"mumbai_sender_did" default:"0x2C1DdDc4C8b6BdAaE831eF04bF4FfDfA575d8bA7"` - MainSenderDID string `envconfig:"main_sender_did" default:"0x2C1DdDc4C8b6BdAaE831eF04bF4FfDfA575d8bA7"` - AmoySenderDID string `envconfig:"amoy_sender_did" default:"did:polygonid:polygon:amoy:2qV9QXdhXXmN5sKjN1YueMjxgRbnJcEGK2kGpvk3cq"` IPFSURL string `envconfig:"ipfs_url" default:"https://gateway.pinata.cloud"` ResolverSettingsPath string `envconfig:"resolver_settings_path" default:"./resolvers_settings.yaml"` CacheExpiration CacheTTL `envconfig:"cache_expiration" default:"48h"` @@ -32,9 +29,15 @@ type Config struct { } // ResolverSettings holds the resolver settings -type ResolverSettings map[string]map[string]struct { +type ResolverSettings map[string]map[string]ResolverSettingsAttrs + +// ResolverSettingsAttrs holds the resolver settings attributes +type ResolverSettingsAttrs struct { ContractAddress string `yaml:"contractAddress"` NetworkURL string `yaml:"networkURL"` + ChainID string `yaml:"chainID"` + NetworkFlag byte `yaml:"networkFlag"` + DID string `yaml:"did"` } // Load loads the configuration from the environment diff --git a/resolvers_settings_sample.yaml b/resolvers_settings_sample.yaml index de45bbc..69f0785 100644 --- a/resolvers_settings_sample.yaml +++ b/resolvers_settings_sample.yaml @@ -1,10 +1,20 @@ polygon: amoy: contractAddress: 0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124 - networkURL: https://polygon-amoy.g.alchemy.com/v2/xaP2XXXX - mumbai: - contractAddress: 0x134B1BE34911E39A8397ec6289782989729807a4 - networkURL: https://polygon-mumbai.g.alchemy.com/v2/xaP2XXXX + networkURL: https://polygon-amoy.g.alchemy.com/v2/XXXXX + chainID: 80002 + networkFlag: 0b0001_0011 + did: did:polygonid:polygon:amoy:2qV9QXdhXXmN5sKjN1YueMjxgRbnJcEGK2kGpvk3cq main: contractAddress: 0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D - networkURL: https://polygon-mainnet.g.alchemy.com/v2/X2HIXXX \ No newline at end of file + networkURL: https://polygon-mainnet.g.alchemy.com/v2/XXXXX + chainID: 137 + networkFlag: 0b0001_0001 + did: did:polygonid:polygon:main:2q4Q7F7tM1xpwUTgWivb6TgKX3vWirsE3mqymuYjVv +#customBlockchain: +# customNetwork: +# contractAddress: { replace with state contract } +# networkURL: { replace with custom RPC } +# chainID: { replace with chain ID } +# networkFlag: { replace with network flag, e.g 0b0011_0001 } +# did: { replace with verifier's did } \ No newline at end of file From 83d863c3ac0e6c77f71964ce3bfe77730fe7bc83 Mon Sep 17 00:00:00 2001 From: Martin Saporiti Date: Thu, 18 Apr 2024 08:27:38 -0300 Subject: [PATCH 2/6] chore: update aws region --- .github/workflows/deploy_new_account.yml | 2 +- .github/workflows/dev_deploy.yml | 2 +- .github/workflows/prod_deploy.yml | 2 +- .github/workflows/testing_deploy.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy_new_account.yml b/.github/workflows/deploy_new_account.yml index f6d5c36..a8f02e6 100644 --- a/.github/workflows/deploy_new_account.yml +++ b/.github/workflows/deploy_new_account.yml @@ -8,7 +8,7 @@ on: - completed env: - AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} ECR_REPOSITORY: verifier_backend POLYGON_AMOY_CONTRACT_ADDRESS: "0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124" diff --git a/.github/workflows/dev_deploy.yml b/.github/workflows/dev_deploy.yml index 20f75ca..2309f7a 100644 --- a/.github/workflows/dev_deploy.yml +++ b/.github/workflows/dev_deploy.yml @@ -9,7 +9,7 @@ on: env: AWS_ACCOUNT_ID: ${{ secrets.DEV_AWS_ACCOUNT_ID }} - AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} ENVIRONMENT: dev ECR_REPOSITORY: verifier_backend diff --git a/.github/workflows/prod_deploy.yml b/.github/workflows/prod_deploy.yml index 0f65206..dd9cf1a 100644 --- a/.github/workflows/prod_deploy.yml +++ b/.github/workflows/prod_deploy.yml @@ -9,7 +9,7 @@ on: env: AWS_ACCOUNT_ID: ${{ secrets.PROD_AWS_ACCOUNT_ID }} - AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} ENVIRONMENT: production ECR_REPOSITORY: verifier_backend diff --git a/.github/workflows/testing_deploy.yml b/.github/workflows/testing_deploy.yml index 20097f1..b0ba079 100644 --- a/.github/workflows/testing_deploy.yml +++ b/.github/workflows/testing_deploy.yml @@ -9,7 +9,7 @@ on: env: AWS_ACCOUNT_ID: ${{ secrets.TESTING_AWS_ACCOUNT_ID }} - AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }} ENVIRONMENT: testing ECR_REPOSITORY: verifier_backend From 15554cbf9c87351c32bc4decac98d16d805dbfff Mon Sep 17 00:00:00 2001 From: Javi Date: Thu, 18 Apr 2024 13:41:39 +0200 Subject: [PATCH 3/6] chore: adding dynamic server in open-api (#72) --- api/api.yaml | 6 ------ api/spec.html | 11 +++++++++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/api/api.yaml b/api/api.yaml index 824f7cf..9a5550b 100644 --- a/api/api.yaml +++ b/api/api.yaml @@ -5,12 +5,6 @@ info: Documentation for the Backend Verifier API version: "1" -servers: - - description: Local - url: http://localhost:3010 - - description: Dev - url: https://verifier-backend-dev.polygonid.me - tags: - name: Public description: Public endpoints for integrators diff --git a/api/spec.html b/api/spec.html index 2d7e25d..db87aa3 100644 --- a/api/spec.html +++ b/api/spec.html @@ -8,6 +8,7 @@ + \ No newline at end of file From 2a42400d80f75b3b598006db7611ddff6b419a54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jordi=20Gim=C3=A9nez?= Date: Thu, 18 Apr 2024 14:18:12 +0200 Subject: [PATCH 4/6] feat: Add verifiable presentations (#73) --- api/api.yaml | 32 +++++++++++++++++++ internal/api/api.gen.go | 16 ++++++++-- internal/api/server.go | 63 +++++++++++++++++++++++++++---------- internal/api/server_test.go | 5 ++- internal/models/payload.go | 50 +++++++++++++++++++++++++++++ 5 files changed, 147 insertions(+), 19 deletions(-) create mode 100644 internal/models/payload.go diff --git a/api/api.yaml b/api/api.yaml index 9a5550b..71ca835 100644 --- a/api/api.yaml +++ b/api/api.yaml @@ -480,6 +480,7 @@ components: type: object required: - userDID + - verifiablePresentations properties: userDID: type: string @@ -489,6 +490,8 @@ components: x-omitempty: false items: $ref: '#/components/schemas/JWZProofs' + verifiablePresentations: + $ref: '#/components/schemas/VerifiablePresentations' @@ -726,6 +729,35 @@ components: type: string example: '1234' + VerifiablePresentations: + type: array + items: + $ref: '#/components/schemas/VerifiablePresentation' + + VerifiablePresentation: + type: object + required: + - proofType + - schemaContext + - schemaType + - credentialSubject + properties: + proofType: + type: string + example: 'VerifiablePresentation' + schemaContext: + type: array + items: + type: string + example: 'https://www.w3.org/2018/credentials/v1' + schemaType: + type: array + items: + type: string + example: 'KYCAgeCredential' + credentialSubject: + type: object + UUID: type: string x-go-type: uuid.UUID diff --git a/internal/api/api.gen.go b/internal/api/api.gen.go index cc70023..8b19867 100644 --- a/internal/api/api.gen.go +++ b/internal/api/api.gen.go @@ -39,8 +39,9 @@ type Health = map[string]interface{} // JWZMetadata defines model for JWZMetadata. type JWZMetadata struct { - Nullifiers *[]JWZProofs `json:"nullifiers"` - UserDID string `json:"userDID"` + Nullifiers *[]JWZProofs `json:"nullifiers"` + UserDID string `json:"userDID"` + VerifiablePresentations VerifiablePresentations `json:"verifiablePresentations"` } // JWZProofs defines model for JWZProofs. @@ -138,6 +139,17 @@ type TransactionDataResponse struct { // UUID defines model for UUID. type UUID = uuid.UUID +// VerifiablePresentation defines model for VerifiablePresentation. +type VerifiablePresentation struct { + CredentialSubject map[string]interface{} `json:"credentialSubject"` + ProofType string `json:"proofType"` + SchemaContext []string `json:"schemaContext"` + SchemaType []string `json:"schemaType"` +} + +// VerifiablePresentations defines model for VerifiablePresentations. +type VerifiablePresentations = []VerifiablePresentation + // Id defines model for id. type Id = uuid.UUID diff --git a/internal/api/server.go b/internal/api/server.go index 4b139bc..66fd15f 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -19,6 +19,7 @@ import ( "github.com/iden3/go-iden3-auth/v2/pubsignals" core "github.com/iden3/go-iden3-core/v2" "github.com/iden3/go-iden3-core/v2/w3c" + "github.com/iden3/go-jwz/v2" "github.com/iden3/iden3comm/v2/protocol" "github.com/patrickmn/go-cache" log "github.com/sirupsen/logrus" @@ -33,9 +34,6 @@ const ( statusPending = "pending" statusSuccess = "success" statusError = "error" - mumbaiNetwork = "80001" - mainnetNetwork = "137" - amoyNetwork = "80002" defaultReason = "for testing purposes" defaultBigIntBase = 10 ) @@ -201,14 +199,8 @@ func (s *Server) Status(_ context.Context, request StatusRequestObject) (StatusR id := request.Params.SessionID item, ok := s.cache.Get(id.String()) if !ok { - log.WithFields(log.Fields{ - "sessionID": id, - }).Error("sessionID not found") - return Status404JSONResponse{ - N404JSONResponse: N404JSONResponse{ - Message: "sessionID not found", - }, - }, nil + log.WithFields(log.Fields{"sessionID": id}).Error("sessionID not found") + return Status404JSONResponse{N404JSONResponse: N404JSONResponse{Message: "sessionID not found"}}, nil } switch value := item.(type) { @@ -222,11 +214,45 @@ func (s *Server) Status(_ context.Context, request StatusRequestObject) (StatusR Message: common.ToPointer(value.Error()), }, nil case models.VerificationResponse: - return getStatusVerificationResponse(value), nil + vps, err := getVerifiablePresentations(value.Jwz) + if err != nil { + log.WithFields(log.Fields{"err": err}).Error("failed to get verifiable presentations") + return Status200JSONResponse{ + Status: statusError, + Message: common.ToPointer(err.Error()), + }, nil + } + return getStatusVerificationResponse(value, vps), nil } return nil, nil } +func getVerifiablePresentations(jwzToken string) (VerifiablePresentations, error) { + token, err := jwz.Parse(jwzToken) + if err != nil { + return nil, err + } + + var payload models.JWZPayload + if err := json.Unmarshal(token.GetPayload(), &payload); err != nil { + return nil, err + } + + resp := make(VerifiablePresentations, 0, len(payload.Body.Scope)) + for _, scope := range payload.Body.Scope { + if scope.Vp.VerifiableCredential.CredentialSubject == nil { + continue + } + resp = append(resp, VerifiablePresentation{ + CredentialSubject: scope.Vp.VerifiableCredential.CredentialSubject, + ProofType: scope.Vp.Type, + SchemaContext: scope.Vp.VerifiableCredential.Context, + SchemaType: scope.Vp.VerifiableCredential.Type, + }) + } + return resp, nil +} + func documentation(w http.ResponseWriter, _ *http.Request) { writeFile("api/spec.html", "text/html; charset=UTF-8", w) } @@ -323,7 +349,7 @@ func getInvokeContractQRCode(request protocol.ContractInvokeRequestMessage) QRCo func validateOffChainRequest(request SignInRequestObject) error { if request.Body.ChainID == nil { - return fmt.Errorf("field chainId is empty expected %s or %s or %s", mumbaiNetwork, mainnetNetwork, amoyNetwork) + return errors.New("field chainId is empty") } if err := validateRequestQuery(true, request.Body.Scope); err != nil { @@ -592,8 +618,13 @@ func getVerificationResponseScopes(scopes []protocol.ZeroKnowledgeProofResponse) return resp, nil } -func getStatusVerificationResponse(verification models.VerificationResponse) Status200JSONResponse { - jwzMetadata := &JWZMetadata{UserDID: verification.UserDID} +func getStatusVerificationResponse(verification models.VerificationResponse, vcs VerifiablePresentations) Status200JSONResponse { + jwzMetadata := &JWZMetadata{ + UserDID: verification.UserDID, + } + if len(vcs) > 0 { + jwzMetadata.VerifiablePresentations = vcs + } if len(verification.Scopes) > 0 { nullifiers := make([]JWZProofs, 0, len(verification.Scopes)) @@ -608,8 +639,8 @@ func getStatusVerificationResponse(verification models.VerificationResponse) Sta } return Status200JSONResponse{ - Status: statusSuccess, Jwz: common.ToPointer(verification.Jwz), JwzMetadata: jwzMetadata, + Status: statusSuccess, } } diff --git a/internal/api/server_test.go b/internal/api/server_test.go index 4b89a63..4015332 100644 --- a/internal/api/server_test.go +++ b/internal/api/server_test.go @@ -17,7 +17,10 @@ import ( "github.com/0xPolygonID/verifier-backend/internal/common" ) -const mumbaiSenderDID = "did:polygonid:polygon:mumbai:2qCU58EJgrELdThzMyykDwT5kWff6XSbpSWtTQ7oS8" +const ( + mumbaiSenderDID = "did:polygonid:polygon:mumbai:2qCU58EJgrELdThzMyykDwT5kWff6XSbpSWtTQ7oS8" + mumbaiNetwork = "80001" +) func TestSignIn(t *testing.T) { ctx := context.Background() diff --git a/internal/models/payload.go b/internal/models/payload.go new file mode 100644 index 0000000..b38dec9 --- /dev/null +++ b/internal/models/payload.go @@ -0,0 +1,50 @@ +package models + +// JWZPayload is the struct that represents the payload of the message +type JWZPayload struct { + Id string `json:"id"` + Typ string `json:"typ"` + Type string `json:"type"` + Thid string `json:"thid"` + Body struct { + DidDoc struct { + Context []string `json:"context"` + Id string `json:"id"` + Service []struct { + Id string `json:"id"` + Type string `json:"type"` + ServiceEndpoint string `json:"serviceEndpoint"` + Metadata struct { + Devices []struct { + Ciphertext string `json:"ciphertext"` + Alg string `json:"alg"` + } `json:"devices"` + } `json:"metadata"` + } `json:"service"` + } `json:"did_doc"` + Message interface{} `json:"message"` + Scope []struct { + Proof struct { + PiA []string `json:"pi_a"` + PiB [][]string `json:"pi_b"` + PiC []string `json:"pi_c"` + Protocol string `json:"protocol"` + Curve string `json:"curve"` + } `json:"proof"` + PubSignals []string `json:"pub_signals"` + Id int `json:"id"` + CircuitId string `json:"circuitId"` + Vp struct { + Context []string `json:"@context"` + Type string `json:"@type"` + VerifiableCredential struct { + Context []string `json:"@context"` + Type []string `json:"@type"` + CredentialSubject map[string]any `json:"credentialSubject"` + } `json:"verifiableCredential"` + } `json:"vp,omitempty"` + } `json:"scope"` + } `json:"body"` + From string `json:"from"` + To string `json:"to"` +} From 83ffc438e939aedce40989944d4363ce0209c5c5 Mon Sep 17 00:00:00 2001 From: Javi Date: Fri, 19 Apr 2024 09:05:34 +0200 Subject: [PATCH 5/6] chore: updating protocol libraries (#75) --- go.mod | 22 +++++++++++----------- go.sum | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index d4ab462..d99c553 100644 --- a/go.mod +++ b/go.mod @@ -4,18 +4,18 @@ go 1.21 require ( github.com/deepmap/oapi-codegen v1.16.2 - github.com/ethereum/go-ethereum v1.13.14 + github.com/ethereum/go-ethereum v1.13.15 github.com/go-chi/chi/v5 v5.0.11 github.com/go-chi/cors v1.2.1 github.com/golangci/golangci-lint v1.55.1 github.com/google/uuid v1.6.0 github.com/iden3/contracts-abi/state/go/abi v1.0.1 - github.com/iden3/go-circuits/v2 v2.2.0 - github.com/iden3/go-iden3-auth/v2 v2.2.2 - github.com/iden3/go-iden3-core/v2 v2.1.0 - github.com/iden3/go-jwz/v2 v2.0.2 - github.com/iden3/go-schema-processor/v2 v2.3.3 - github.com/iden3/iden3comm/v2 v2.3.2 + github.com/iden3/go-circuits/v2 v2.2.1 + github.com/iden3/go-iden3-auth/v2 v2.3.3 + github.com/iden3/go-iden3-core/v2 v2.1.1 + github.com/iden3/go-jwz/v2 v2.0.3 + github.com/iden3/go-schema-processor/v2 v2.3.4 + github.com/iden3/iden3comm/v2 v2.3.3 github.com/ipfs/go-ipfs-api v0.7.0 github.com/joho/godotenv v1.5.1 github.com/kelseyhightower/envconfig v1.4.0 @@ -58,7 +58,7 @@ require ( github.com/bombsimon/wsl/v3 v3.4.0 // indirect github.com/breml/bidichk v0.2.7 // indirect github.com/breml/errchkjson v0.3.6 // indirect - github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect + github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect github.com/butuzov/ireturn v0.2.2 // indirect github.com/butuzov/mirror v1.1.0 // indirect github.com/catenacyber/perfsprint v0.2.0 // indirect @@ -134,7 +134,7 @@ require ( github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/invopop/yaml v0.1.0 // indirect - github.com/ipfs/boxo v0.18.0 // indirect + github.com/ipfs/boxo v0.19.0 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/jgautheron/goconst v1.6.0 // indirect github.com/jingyugao/rowserrcheck v1.1.1 // indirect @@ -237,7 +237,7 @@ require ( github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect github.com/tdakkota/asciicheck v0.2.0 // indirect github.com/tetafro/godot v1.4.15 // indirect - github.com/tetratelabs/wazero v1.7.0 // indirect + github.com/tetratelabs/wazero v1.7.1 // indirect github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 // indirect github.com/timonwong/loggercheck v0.9.4 // indirect github.com/tklauser/go-sysconf v0.3.13 // indirect @@ -258,7 +258,7 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect golang.org/x/crypto v0.22.0 // indirect - golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect + golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f // indirect golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 // indirect golang.org/x/mod v0.17.0 // indirect golang.org/x/net v0.24.0 // indirect diff --git a/go.sum b/go.sum index 0dbc5d4..9120c39 100644 --- a/go.sum +++ b/go.sum @@ -117,6 +117,8 @@ github.com/btcsuite/btcd v0.23.3 h1:4KH/JKy9WiCd+iUS9Mu0Zp7Dnj17TGdKrg9xc/FGj24= github.com/btcsuite/btcd v0.23.3/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/btcsuite/btcd/btcec/v2 v2.3.3 h1:6+iXlDKE8RMtKsvK0gshlXIuPbyWM/h84Ensb7o3sC0= +github.com/btcsuite/btcd/btcec/v2 v2.3.3/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipusjXSohQ= github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= @@ -173,6 +175,8 @@ github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233 h1:d28BXYi+wUp github.com/crate-crypto/go-ipa v0.0.0-20231025140028-3c0104f4b233/go.mod h1:geZJZH3SzKCqnz5VT0q/DyIG/tvu/dZk+VIfXicupJs= github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA= github.com/crate-crypto/go-kzg-4844 v0.7.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc= +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/curioswitch/go-reassign v0.2.0 h1:G9UZyOcpk/d7Gd6mqYgd8XYWFMw/znxwGDUstnC9DIo= github.com/curioswitch/go-reassign v0.2.0/go.mod h1:x6OpXuWvgfQaMGks2BZybTngWjT84hqJfKoO8Tt/Roc= github.com/daixiang0/gci v0.11.2 h1:Oji+oPsp3bQ6bNNgX30NBAVT18P4uBH4sRZnlOlTj7Y= @@ -206,6 +210,8 @@ github.com/ethereum/c-kzg-4844 v1.0.1 h1:pGixCbGizcVKSwoV70ge48+PrbB+iSKs2rjgfE4 github.com/ethereum/c-kzg-4844 v1.0.1/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0= github.com/ethereum/go-ethereum v1.13.14 h1:EwiY3FZP94derMCIam1iW4HFVrSgIcpsu0HwTQtm6CQ= github.com/ethereum/go-ethereum v1.13.14/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU= +github.com/ethereum/go-ethereum v1.13.15 h1:U7sSGYGo4SPjP6iNIifNoyIAiNjrmQkz6EwQG+/EZWo= +github.com/ethereum/go-ethereum v1.13.15/go.mod h1:TN8ZiHrdJwSe8Cb6x+p0hs5CxhJZPbqB7hHkaUXcmIU= github.com/ettle/strcase v0.1.1 h1:htFueZyVeE1XNnMEfbqp5r67qAN/4r6ya1ysq8Q+Zcw= github.com/ettle/strcase v0.1.1/go.mod h1:hzDLsPC7/lwKyBOywSHEP89nt2pDgdy+No1NBA9o9VY= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= @@ -431,14 +437,22 @@ github.com/iden3/contracts-abi/state/go/abi v1.0.1 h1:FsaLJSy3NSyJl5k1yfDxc5DhUH github.com/iden3/contracts-abi/state/go/abi v1.0.1/go.mod h1:TxgIrXCvxms3sbOdsy8kTvffUCIpEEifNy0fSXdkU4w= github.com/iden3/go-circuits/v2 v2.2.0 h1:qJeySVPG9vxZwJyL/CsvXdUhccWOctXQUYGnyX5p2Kc= github.com/iden3/go-circuits/v2 v2.2.0/go.mod h1:1LET+T8i9Rkfx+RNj2BBHKAPGDODEWWwSEFjR6g3h6c= +github.com/iden3/go-circuits/v2 v2.2.1 h1:ww+qOmEZJjL3bolLlnZv2SuukiVolgdcSaL3vonXoxI= +github.com/iden3/go-circuits/v2 v2.2.1/go.mod h1:Q6IFYauDdWo0hES4XzHXxz7hUYpmNsVmtP36Lxkjc/0= github.com/iden3/go-iden3-auth/v2 v2.2.2 h1:4uA+m5H2OvhfOsMJaeXaCjciV2sHypvHgGHewZfXB58= github.com/iden3/go-iden3-auth/v2 v2.2.2/go.mod h1:1ytFvnSnuNK2m9BoVrgYJoLNH919Bg2pt68pFelcJcM= +github.com/iden3/go-iden3-auth/v2 v2.3.3 h1:lbm/Gf8NzE6AaIM9ZtL4AzAJd3piG2RAMTqBwf344Zo= +github.com/iden3/go-iden3-auth/v2 v2.3.3/go.mod h1:TkEaleplXaiyyW5DAmL7wN1XkSIOMtcRJwqPtmtLWfA= github.com/iden3/go-iden3-core/v2 v2.1.0 h1:R1s7Tj3tIx5lDy8S7OJrSNuxXIFeRzWRmTBaQoQHJps= github.com/iden3/go-iden3-core/v2 v2.1.0/go.mod h1:L9PxhWPvoS9qTb3inEkZBm1RpjHBt+VTwvxssdzbAdw= +github.com/iden3/go-iden3-core/v2 v2.1.1 h1:WD14iWKZmnfHTl9Em/PfGssrFYXz8YNQPjPs/cn+eHc= +github.com/iden3/go-iden3-core/v2 v2.1.1/go.mod h1:L9PxhWPvoS9qTb3inEkZBm1RpjHBt+VTwvxssdzbAdw= github.com/iden3/go-iden3-crypto v0.0.16 h1:zN867xiz6HgErXVIV/6WyteGcOukE9gybYTorBMEdsk= github.com/iden3/go-iden3-crypto v0.0.16/go.mod h1:dLpM4vEPJ3nDHzhWFXDjzkn1qHoBeOT/3UEhXsEsP3E= github.com/iden3/go-jwz/v2 v2.0.2 h1:yx56x1TZcObeuj6cvX715Jd7QTxnCpHwbETKWCPJmhw= github.com/iden3/go-jwz/v2 v2.0.2/go.mod h1:B1r6wJpPhIiuZTmgicNoogr7XD/VS3jZu9U519GwWz4= +github.com/iden3/go-jwz/v2 v2.0.3 h1:pf4tVDDbNP9zm6VS3uBFBcoHceLFmhu9A8lAr1sDvN4= +github.com/iden3/go-jwz/v2 v2.0.3/go.mod h1:rojFWvIXqjCRvXBvlgRjw20s8fnYDBnpCZ/IPVfe5KY= github.com/iden3/go-merkletree-sql/v2 v2.0.6 h1:vsVDImnvnHf7Ggr45ptFOXJyWNA/8IwVQO1jzRLUlY8= github.com/iden3/go-merkletree-sql/v2 v2.0.6/go.mod h1:kRhHKYpui5DUsry5RpveP6IC4XMe6iApdV9VChRYuEk= github.com/iden3/go-rapidsnark/prover v0.0.10 h1:NvOfRPpex/k646UsqOcUy7a7uVl17t4ok9kWvpQg4+k= @@ -453,14 +467,20 @@ github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e github.com/iden3/go-rapidsnark/witness/wazero v0.0.0-20230524142950-0986cf057d4e/go.mod h1:UEBifEzw62T6VzIHJeHuUgeLg2U/J9ttf7hOwQEqnYk= github.com/iden3/go-schema-processor/v2 v2.3.3 h1:GfChxMZHG4miA3p/5rLIrM7TGmKu/oAAXgLloYTBHSI= github.com/iden3/go-schema-processor/v2 v2.3.3/go.mod h1:8y/R0iQpYhyhRQ3sL4F5Aja3+1T68M6uwGQdC4pQ4X0= +github.com/iden3/go-schema-processor/v2 v2.3.4 h1:zWE9NrY7dm9Il8c0u3XcJfenptmxbvIaNDOqkq5uQ0A= +github.com/iden3/go-schema-processor/v2 v2.3.4/go.mod h1:tuz/iuqU13NdpCY1Ovsh7n6KTZnJnfhqjB0MUgxbcA4= github.com/iden3/iden3comm/v2 v2.3.2 h1:ulD0oI/+qsEmnHVELWrxdLNvQOOWr/JLVMFXzEVbr5E= github.com/iden3/iden3comm/v2 v2.3.2/go.mod h1:HVdSjre4og+kdJ5Cqe2b3Dt2ccOogOdfyWwKaUSAelw= +github.com/iden3/iden3comm/v2 v2.3.3 h1:lH2v/hZeZYvKQAgfpi/hyzugDjvCTxJo/Y0pyMVWHFQ= +github.com/iden3/iden3comm/v2 v2.3.3/go.mod h1:14aZgYjCi0XIZ/wkQrWIhLkQT20nwQMyWEIeLXY0Klg= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/invopop/yaml v0.1.0 h1:YW3WGUoJEXYfzWBjn00zIlrw7brGVD0fUKRYDPAPhrc= github.com/invopop/yaml v0.1.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= github.com/ipfs/boxo v0.18.0 h1:MOL9/AgoV3e7jlVMInicaSdbgralfqSsbkc31dZ9tmw= github.com/ipfs/boxo v0.18.0/go.mod h1:pIZgTWdm3k3pLF9Uq6MB8JEcW07UDwNJjlXW1HELW80= +github.com/ipfs/boxo v0.19.0 h1:UbX9FBJQF19ACLqRZOgdEla6jR/sC4H1O+iGE0NToXA= +github.com/ipfs/boxo v0.19.0/go.mod h1:V5gJzbIMwKEXrg3IdvAxIdF7UPgU4RsXmNGS8MQ/0D4= 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-ipfs-api v0.7.0 h1:CMBNCUl0b45coC+lQCXEVpMhwoqjiaCwUIrM+coYW2Q= @@ -798,6 +818,8 @@ github.com/tetafro/godot v1.4.15 h1:QzdIs+XB8q+U1WmQEWKHQbKmCw06QuQM7gLx/dky2RM= github.com/tetafro/godot v1.4.15/go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio= github.com/tetratelabs/wazero v1.7.0 h1:jg5qPydno59wqjpGrHph81lbtHzTrWzwwtD4cD88+hQ= github.com/tetratelabs/wazero v1.7.0/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= +github.com/tetratelabs/wazero v1.7.1 h1:QtSfd6KLc41DIMpDYlJdoMc6k7QTN246DM2+n2Y/Dx8= +github.com/tetratelabs/wazero v1.7.1/go.mod h1:ytl6Zuh20R/eROuyDaGPkp82O9C/DJfXAwJfQ3X6/7Y= github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 h1:quvGphlmUVU+nhpFa4gg4yJyTRJ13reZMDHrKwYw53M= github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966/go.mod h1:27bSVNWSBOHm+qRp1T9qzaIpsWEP6TbUnei/43HK+PQ= github.com/timonwong/loggercheck v0.9.4 h1:HKKhqrjcVj8sxL7K77beXh0adEm6DLjV/QOGeMXEVi4= @@ -888,6 +910,8 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 h1:985EYyeCOxTpcgOTJpflJUwOeEz0CQOdPt73OzpE9F8= golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= +golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY= +golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 h1:jWGQJV4niP+CCmFW9ekjA9Zx8vYORzOUH2/Nl5WPuLQ= From eb6b4e9d4dbd213b6d917c1574534485fce4edc5 Mon Sep 17 00:00:00 2001 From: Javi Date: Fri, 19 Apr 2024 11:09:37 +0200 Subject: [PATCH 6/6] fix: overriding resolver settings (#77) --- .github/workflows/deploy_new_account.yml | 2 +- .github/workflows/dev_deploy.yml | 2 +- .github/workflows/prod_deploy.yml | 2 +- .github/workflows/testing_deploy.yml | 2 +- api/spec.html | 1 - 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy_new_account.yml b/.github/workflows/deploy_new_account.yml index a8f02e6..b526d36 100644 --- a/.github/workflows/deploy_new_account.yml +++ b/.github/workflows/deploy_new_account.yml @@ -70,7 +70,7 @@ jobs: echo -e " chainID: ${{ env.POLYGON_MAIN_CHAIN_ID }}" >> resolvers_settings.yaml echo -e " networkFlag: ${{ env.POLYGON_MAIN_NETWORK_FLAG }}" >> resolvers_settings.yaml echo -e " did: ${{ env.POLYGON_MAIN_SENDER_DID }}" >> resolvers_settings.yaml - echo -e "camino:" > resolvers_settings.yaml + echo -e "camino:" >> resolvers_settings.yaml echo -e " columbus:" >> resolvers_settings.yaml echo -e " contractAddress: ${{ env.CAMINO_COLUMBUS_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml echo -e " networkURL: ${{ env.CAMINO_COLUMBUS_NODE_URL }}" >> resolvers_settings.yaml diff --git a/.github/workflows/dev_deploy.yml b/.github/workflows/dev_deploy.yml index 2309f7a..e12ee9d 100644 --- a/.github/workflows/dev_deploy.yml +++ b/.github/workflows/dev_deploy.yml @@ -70,7 +70,7 @@ jobs: echo -e " chainID: ${{ env.POLYGON_MAIN_CHAIN_ID }}" >> resolvers_settings.yaml echo -e " networkFlag: ${{ env.POLYGON_MAIN_NETWORK_FLAG }}" >> resolvers_settings.yaml echo -e " did: ${{ env.POLYGON_MAIN_SENDER_DID }}" >> resolvers_settings.yaml - echo -e "camino:" > resolvers_settings.yaml + echo -e "camino:" >> resolvers_settings.yaml echo -e " columbus:" >> resolvers_settings.yaml echo -e " contractAddress: ${{ env.CAMINO_COLUMBUS_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml echo -e " networkURL: ${{ env.CAMINO_COLUMBUS_NODE_URL }}" >> resolvers_settings.yaml diff --git a/.github/workflows/prod_deploy.yml b/.github/workflows/prod_deploy.yml index dd9cf1a..15a7ae3 100644 --- a/.github/workflows/prod_deploy.yml +++ b/.github/workflows/prod_deploy.yml @@ -70,7 +70,7 @@ jobs: echo -e " chainID: ${{ env.POLYGON_MAIN_CHAIN_ID }}" >> resolvers_settings.yaml echo -e " networkFlag: ${{ env.POLYGON_MAIN_NETWORK_FLAG }}" >> resolvers_settings.yaml echo -e " did: ${{ env.POLYGON_MAIN_SENDER_DID }}" >> resolvers_settings.yaml - echo -e "camino:" > resolvers_settings.yaml + echo -e "camino:" >> resolvers_settings.yaml echo -e " columbus:" >> resolvers_settings.yaml echo -e " contractAddress: ${{ env.CAMINO_COLUMBUS_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml echo -e " networkURL: ${{ env.CAMINO_COLUMBUS_NODE_URL }}" >> resolvers_settings.yaml diff --git a/.github/workflows/testing_deploy.yml b/.github/workflows/testing_deploy.yml index b0ba079..e1c6020 100644 --- a/.github/workflows/testing_deploy.yml +++ b/.github/workflows/testing_deploy.yml @@ -70,7 +70,7 @@ jobs: echo -e " chainID: ${{ env.POLYGON_MAIN_CHAIN_ID }}" >> resolvers_settings.yaml echo -e " networkFlag: ${{ env.POLYGON_MAIN_NETWORK_FLAG }}" >> resolvers_settings.yaml echo -e " did: ${{ env.POLYGON_MAIN_SENDER_DID }}" >> resolvers_settings.yaml - echo -e "camino:" > resolvers_settings.yaml + echo -e "camino:" >> resolvers_settings.yaml echo -e " columbus:" >> resolvers_settings.yaml echo -e " contractAddress: ${{ env.CAMINO_COLUMBUS_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml echo -e " networkURL: ${{ env.CAMINO_COLUMBUS_NODE_URL }}" >> resolvers_settings.yaml diff --git a/api/spec.html b/api/spec.html index db87aa3..0cc85e4 100644 --- a/api/spec.html +++ b/api/spec.html @@ -21,7 +21,6 @@ navigation-item-text = path allow-authentication = true sort-endpoints-by="summary" - server-url = "http://localhost:3010" >