Repository: TBD54566975/ssi-service
Pull request #614 (2023-07-28 21:48:28)

Update ssi-sdk version
This includes fixes from the SDK, which is always nice. 


codecov-commenter: ## [Codecov](https://app.codecov.io/gh/TBD54566975/ssi-service/pull/614?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TBD54566975) Report
> Merging [#614](https://app.codecov.io/gh/TBD54566975/ssi-service/pull/614?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TBD54566975) (6e5a779) into [main](https://app.codecov.io/gh/TBD54566975/ssi-service/commit/b43f45c7c1d4163692ca4aa74649fb92d7789803?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TBD54566975) (b43f45c) will **decrease** coverage by `0.01%`.
> Report is 2 commits behind head on main.
> The diff coverage is `0.00%`.

```diff
@@            Coverage Diff             @@
##             main     #614      +/-   ##
==========================================
- Coverage   27.03%   27.02%   -0.01%     
==========================================
  Files          48       48              
  Lines        5830     5832       +2     
==========================================
  Hits         1576     1576              
- Misses       3971     3973       +2     
  Partials      283      283              
```


| [Files Changed](https://app.codecov.io/gh/TBD54566975/ssi-service/pull/614?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TBD54566975) | Coverage Δ | |
|---|---|---|
| [pkg/service/did/service.go](https://app.codecov.io/gh/TBD54566975/ssi-service/pull/614?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TBD54566975#diff-cGtnL3NlcnZpY2UvZGlkL3NlcnZpY2UuZ28=) | `0.00% <0.00%> (ø)` | |
| [pkg/service/did/web.go](https://app.codecov.io/gh/TBD54566975/ssi-service/pull/614?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=TBD54566975#diff-cGtnL3NlcnZpY2UvZGlkL3dlYi5nbw==) | `0.00% <0.00%> (ø)` | |



Patch:
diff --git a/doc/swagger.yaml b/doc/swagger.yaml
index c4f4282..a93a630 100644
--- a/doc/swagger.yaml
+++ b/doc/swagger.yaml
@@ -2128,20 +2128,36 @@ definitions:
   resolution.DocumentMetadata:
     properties:
       canonicalId:
+        description: See `canonicalId` in https://www.w3.org/TR/did-core/#did-document-metadata
         type: string
       created:
+        description: See `created` in https://www.w3.org/TR/did-core/#did-document-metadata
         type: string
       deactivated:
+        description: See `deactivated` in https://www.w3.org/TR/did-core/#did-document-metadata
         type: boolean
       equivalentId:
-        type: string
+        description: See `equivalentId` in https://www.w3.org/TR/did-core/#did-document-metadata
+        items:
+          type: string
+        type: array
+      method:
+        allOf:
+        - $ref: '#/definitions/resolution.Method'
+        description: |-
+          Optional information that is specific to the DID Method of the DID Document resolved. Populated only
+          for sidetree based did methods (e.g. ION), as described in https://identity.foundation/sidetree/spec/#did-resolver-output
       nextUpdate:
+        description: See `nextUpdate` in https://www.w3.org/TR/did-core/#did-document-metadata
         type: string
       nextVersionId:
+        description: See `nextVersionId` in https://www.w3.org/TR/did-core/#did-document-metadata
         type: string
       updated:
+        description: See `updated` in https://www.w3.org/TR/did-core/#did-document-metadata
         type: string
       versionId:
+        description: See `versionId` in https://www.w3.org/TR/did-core/#did-document-metadata
         type: string
     type: object
   resolution.Error:
@@ -2162,6 +2178,18 @@ definitions:
       error:
         $ref: '#/definitions/resolution.Error'
     type: object
+  resolution.Method:
+    properties:
+      published:
+        description: The `method` property in https://identity.foundation/sidetree/spec/#did-resolver-output
+        type: boolean
+      recoveryCommitment:
+        description: The `recoveryCommitment` property in https://identity.foundation/sidetree/spec/#did-resolver-output
+        type: string
+      updateCommitment:
+        description: The `updateCommitment` property in https://identity.foundation/sidetree/spec/#did-resolver-output
+        type: string
+    type: object
   schema.JSONSchema:
     additionalProperties: {}
     type: object
diff --git a/go.mod b/go.mod
index dd702fa..a10a782 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.20230731175253-d5c302a1d9b9
 	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 f6974d4..50cd64d 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.20230731175253-d5c302a1d9b9 h1:Ig2o+eOTFTaa9agWiz+Vz/7N4zoTJ2Na9PiRaYaAbXY=
+github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20230731175253-d5c302a1d9b9/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/service/did/service.go b/pkg/service/did/service.go
index 44af368..ccd0295 100644
--- a/pkg/service/did/service.go
+++ b/pkg/service/did/service.go
@@ -144,7 +144,7 @@ func (s *Service) ResolveDID(request ResolveDIDRequest) (*ResolveDIDResponse, er
 	return &ResolveDIDResponse{
 		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 158b207..381f36b 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")
@@ -64,8 +67,8 @@ func (h *webHandler) CreateDID(ctx context.Context, request CreateDIDRequest) (*
 	didWeb := web.DIDWeb(opts.DIDWebID)
 
 	err := didWeb.Validate(ctx)
-	if err != nil {
-		return nil, errors.Wrap(err, "could not validate if did:web exists externally")
+	if err == nil {
+		return nil, fmt.Errorf("%s exists externally", didWeb.String())
 	}
 
 	exists, err := h.storage.DIDExists(ctx, opts.DIDWebID)


Test patch:
diff --git a/integration/didweb_resolver_integration_test.go b/integration/didweb_resolver_integration_test.go
index e5b8fed..823a40d 100644
--- a/integration/didweb_resolver_integration_test.go
+++ b/integration/didweb_resolver_integration_test.go
@@ -12,7 +12,7 @@ func TestResolveDIDWebIntegration(t *testing.T) {
 	}
 
 	// A .well-known file exists at https://tbd.website/.well-known/did.json
-	didWebOutput, err := put(endpoint+version+"dids/web", `{ "keyType":"Ed25519", "options": {"didWebId":"did:web:tbd.website"}}`)
+	didWebOutput, err := put(endpoint+version+"dids/web", `{ "keyType":"Ed25519", "options": {"didWebId":"did:web:i-made-up-this.website"}}`)
 	assert.NoError(t, err)
 
 	did, err := getJSONElement(didWebOutput, "$.did.id")
@@ -20,12 +20,11 @@ func TestResolveDIDWebIntegration(t *testing.T) {
 	resolvedOutput, err := ResolveDID(did)
 	assert.NoError(t, err)
 
-	didError, err := getJSONElement(resolvedOutput, "$.didResolutionMetadata.Error")
-	assert.NoError(t, err)
-	assert.Equal(t, "<nil>", didError)
+	_, err = getJSONElement(resolvedOutput, "$.didResolutionMetadata.Error")
+	assert.ErrorContains(t, err, "key error: Error not found in object")
 
 	didDocumentID, err := getJSONElement(resolvedOutput, "$.didDocument.id")
 	assert.NoError(t, err)
-	assert.Equal(t, "did:web:tbd.website", didDocumentID)
+	assert.Equal(t, "did:web:i-made-up-this.website", didDocumentID)
 
 }
diff --git a/pkg/server/router/did_test.go b/pkg/server/router/did_test.go
index 97d25c8..6a2c0d2 100644
--- a/pkg/server/router/did_test.go
+++ b/pkg/server/router/did_test.go
@@ -199,13 +199,12 @@ 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 <bad> not supported")
 
 				gock.Off()
 				gock.New("https://example.com").
 					Get("/.well-known/did.json").
-					Reply(200).
-					BodyString("")
+					Reply(404)
 				// good key type
 				createDIDResponse, err := didService.CreateDIDByMethod(context.Background(), did.CreateDIDRequest{Method: didsdk.WebMethod, KeyType: crypto.Ed25519, Options: createOpts})
 				assert.NoError(tt, err)
@@ -225,8 +224,7 @@ func TestDIDRouter(t *testing.T) {
 				gock.Off()
 				gock.New("https://tbd.website").
 					Get("/.well-known/did.json").
-					Reply(200).
-					BodyString("")
+					Reply(404)
 				// 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 bfc15ee..7cfce51 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"}}`)
+					BodyString(`Something here that's not a DID'`)
 				defer gock.Off()
 
 				c = newRequestContextWithParams(w, req, params)
@@ -279,8 +279,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"}}`)
+					Reply(404)
 				defer gock.Off()
 
 				c := newRequestContextWithParams(w, req, params)
@@ -299,8 +298,7 @@ func TestDIDAPI(t *testing.T) {
 				req2 := httptest.NewRequest(http.MethodPut, "https://ssi-service.com/v1/dids/web", requestReader2)
 				gock.New("https://example.com").
 					Get("/.well-known/did.json").
-					Reply(200).
-					BodyString(`{"didDocument": {"id": "did:web:example.com"}}`)
+					Reply(404)
 				defer gock.Off()
 
 				// Make sure it can't make another did:web of the same DIDWebID