From b41daa03ab0479a8774f522991ab9d2f2e37df61 Mon Sep 17 00:00:00 2001 From: Andres Uribe Gonzalez Date: Fri, 28 Jul 2023 17:47:31 -0400 Subject: [PATCH] Update ssi-sdk version --- go.mod | 4 ++-- go.sum | 8 ++++---- pkg/server/router/did_test.go | 6 +++--- pkg/server/server_did_test.go | 6 +++--- pkg/service/did/service.go | 4 ++-- pkg/service/did/web.go | 3 +++ 6 files changed, 17 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index d09fe3170..eea37fd16 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/BurntSushi/toml v1.3.2 - github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230711190054-bce640c9bf25 + github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230728184551-8db407fb064a github.com/alicebob/miniredis/v2 v2.30.4 github.com/ardanlabs/conf v1.5.0 github.com/benbjohnson/clock v1.3.5 @@ -143,7 +143,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pquerna/cachecontrol v0.2.0 // indirect github.com/redis/go-redis/extra/rediscmd/v9 v9.0.5 // indirect - github.com/santhosh-tekuri/jsonschema/v5 v5.3.0 // indirect + github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect github.com/segmentio/asm v1.2.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/afero v1.9.5 // indirect diff --git a/go.sum b/go.sum index cb1362cfe..e72f67d64 100644 --- a/go.sum +++ b/go.sum @@ -46,8 +46,8 @@ github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= -github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230711190054-bce640c9bf25 h1:wW+49kQxN/BYcMkbDjQA9mkrUC9cYUV6HOFLP+JIx+E= -github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230711190054-bce640c9bf25/go.mod h1:lup1EqGAT730/c7dRF9Q8OvgsjWJewq4K2dFAyBV1vk= +github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230728184551-8db407fb064a h1:dyR/yGhyLl+GuwafcrbaaeGYYOaVzJpyUnxqy9CPZNE= +github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230728184551-8db407fb064a/go.mod h1:mVKRjfdpgmCxPwnfQluXGkgzsFyrPsjrCvHXCJ41avQ= github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc= github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 h1:uvdUDbHQHO85qeSydJtItA4T55Pw6BtAejd0APRJOCE= github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc= @@ -437,8 +437,8 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/santhosh-tekuri/jsonschema/v5 v5.3.0 h1:uIkTLo0AGRc8l7h5l9r+GcYi9qfVPt6lD4/bhmzfiKo= -github.com/santhosh-tekuri/jsonschema/v5 v5.3.0/go.mod h1:FKdcjfQW6rpZSnxxUvEA5H/cDPdvJ/SZJQLWWXWGrZ0= +github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4= +github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= diff --git a/pkg/server/router/did_test.go b/pkg/server/router/did_test.go index 97d25c89d..d77328393 100644 --- a/pkg/server/router/did_test.go +++ b/pkg/server/router/did_test.go @@ -199,13 +199,13 @@ func TestDIDRouter(t *testing.T) { createOpts := did.CreateWebDIDOptions{DIDWebID: "did:web:example.com"} _, err = didService.CreateDIDByMethod(context.Background(), did.CreateDIDRequest{Method: didsdk.WebMethod, KeyType: "bad", Options: createOpts}) assert.Error(tt, err) - assert.Contains(tt, err.Error(), "could not generate key for did:web") + assert.Contains(tt, err.Error(), "key type not supported") gock.Off() gock.New("https://example.com"). Get("/.well-known/did.json"). Reply(200). - BodyString("") + JSON("{}") // good key type createDIDResponse, err := didService.CreateDIDByMethod(context.Background(), did.CreateDIDRequest{Method: didsdk.WebMethod, KeyType: crypto.Ed25519, Options: createOpts}) assert.NoError(tt, err) @@ -226,7 +226,7 @@ func TestDIDRouter(t *testing.T) { gock.New("https://tbd.website"). Get("/.well-known/did.json"). Reply(200). - BodyString("") + JSON("{}") // create a second DID createOpts = did.CreateWebDIDOptions{DIDWebID: "did:web:tbd.website"} createDIDResponse2, err := didService.CreateDIDByMethod(context.Background(), did.CreateDIDRequest{Method: didsdk.WebMethod, KeyType: crypto.Ed25519, Options: createOpts}) diff --git a/pkg/server/server_did_test.go b/pkg/server/server_did_test.go index b2815aaa6..c231df6b7 100644 --- a/pkg/server/server_did_test.go +++ b/pkg/server/server_did_test.go @@ -160,7 +160,7 @@ func TestDIDAPI(t *testing.T) { gock.New("https://example.com"). Get("/.well-known/did.json"). Reply(200). - BodyString(`{"didDocument": {"id": "did:web:example.com"}}`) + JSON(`{"didDocument": {"id": "did:web:example.com"}}`) defer gock.Off() c = newRequestContextWithParams(w, req, params) @@ -280,7 +280,7 @@ func TestDIDAPI(t *testing.T) { gock.New("https://example.com"). Get("/.well-known/did.json"). Reply(200). - BodyString(`{"didDocument": {"id": "did:web:example.com"}}`) + JSON(`{"didDocument": {"id": "did:web:example.com"}}`) defer gock.Off() c := newRequestContextWithParams(w, req, params) @@ -300,7 +300,7 @@ func TestDIDAPI(t *testing.T) { gock.New("https://example.com"). Get("/.well-known/did.json"). Reply(200). - BodyString(`{"didDocument": {"id": "did:web:example.com"}}`) + JSON(`{"didDocument": {"id": "did:web:example.com"}}`) defer gock.Off() // Make sure it can't make another did:web of the same DIDWebID diff --git a/pkg/service/did/service.go b/pkg/service/did/service.go index 44af368e1..84bc0fec6 100644 --- a/pkg/service/did/service.go +++ b/pkg/service/did/service.go @@ -142,9 +142,9 @@ func (s *Service) ResolveDID(request ResolveDIDRequest) (*ResolveDIDResponse, er return nil, err } return &ResolveDIDResponse{ - ResolutionMetadata: &resolved.Metadata, + ResolutionMetadata: resolved.Metadata, DIDDocument: &resolved.Document, - DIDDocumentMetadata: &resolved.DocumentMetadata, + DIDDocumentMetadata: resolved.DocumentMetadata, }, nil } diff --git a/pkg/service/did/web.go b/pkg/service/did/web.go index 158b207e8..b91108537 100644 --- a/pkg/service/did/web.go +++ b/pkg/service/did/web.go @@ -49,6 +49,9 @@ func (h *webHandler) GetMethod() did.Method { func (h *webHandler) CreateDID(ctx context.Context, request CreateDIDRequest) (*CreateDIDResponse, error) { logrus.Debugf("creating DID: %+v", request) + if !crypto.IsSupportedKeyType(request.KeyType) { + return nil, errors.Errorf("key type <%s> not supported", request.KeyType) + } // process options if request.Options == nil { return nil, errors.New("options cannot be empty")