From e00c48a24f710914250b10327ccdfac63122ac9f Mon Sep 17 00:00:00 2001 From: Phoebe Lew Date: Wed, 29 Nov 2023 10:34:32 +0000 Subject: [PATCH 1/6] Release new version --- packages/agent/package.json | 2 +- packages/api/package.json | 2 +- packages/credentials/package.json | 4 ++-- packages/dids/package.json | 2 +- packages/identity-agent/package.json | 2 +- packages/proxy-agent/package.json | 2 +- packages/user-agent/package.json | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/agent/package.json b/packages/agent/package.json index 3534fa1f9..79c9d67f3 100644 --- a/packages/agent/package.json +++ b/packages/agent/package.json @@ -69,7 +69,7 @@ "dependencies": { "@tbd54566975/dwn-sdk-js": "0.2.8", "@web5/common": "0.2.1", - "@web5/crypto": "0.2.2", + "@web5/crypto": "0.2.3", "@web5/dids": "0.2.2", "level": "8.0.0", "readable-stream": "4.4.2", diff --git a/packages/api/package.json b/packages/api/package.json index b64b2d2df..3d0c48fec 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -77,7 +77,7 @@ "dependencies": { "@tbd54566975/dwn-sdk-js": "0.2.8", "@web5/agent": "0.2.4", - "@web5/crypto": "0.2.2", + "@web5/crypto": "0.2.3", "@web5/dids": "0.2.2", "@web5/user-agent": "0.2.4", "level": "8.0.0", diff --git a/packages/credentials/package.json b/packages/credentials/package.json index 98bafcc3e..9c6edc9a7 100644 --- a/packages/credentials/package.json +++ b/packages/credentials/package.json @@ -1,6 +1,6 @@ { "name": "@web5/credentials", - "version": "0.3.1", + "version": "0.3.2", "description": "Verifiable Credentials", "type": "module", "main": "./dist/cjs/index.js", @@ -85,7 +85,7 @@ "@typescript-eslint/eslint-plugin": "6.4.0", "@typescript-eslint/parser": "6.4.0", "@web5/common": "0.2.1", - "@web5/crypto": "0.2.2", + "@web5/crypto": "0.2.3", "@web5/dids": "0.2.2", "c8": "8.0.1", "chai": "4.3.10", diff --git a/packages/dids/package.json b/packages/dids/package.json index 9feb2dae8..343234769 100644 --- a/packages/dids/package.json +++ b/packages/dids/package.json @@ -77,7 +77,7 @@ "@decentralized-identity/ion-pow-sdk": "1.0.17", "@decentralized-identity/ion-sdk": "1.0.1", "@web5/common": "0.2.1", - "@web5/crypto": "0.2.2", + "@web5/crypto": "0.2.3", "did-resolver": "4.1.0", "dns-packet": "5.6.1", "level": "8.0.0", diff --git a/packages/identity-agent/package.json b/packages/identity-agent/package.json index 142db6e71..74850dbd5 100644 --- a/packages/identity-agent/package.json +++ b/packages/identity-agent/package.json @@ -69,7 +69,7 @@ "dependencies": { "@web5/agent": "0.2.4", "@web5/common": "0.2.1", - "@web5/crypto": "0.2.2", + "@web5/crypto": "0.2.3", "@web5/dids": "0.2.2" }, "devDependencies": { diff --git a/packages/proxy-agent/package.json b/packages/proxy-agent/package.json index 71c3a6c09..2c56463c8 100644 --- a/packages/proxy-agent/package.json +++ b/packages/proxy-agent/package.json @@ -69,7 +69,7 @@ "dependencies": { "@web5/agent": "0.2.4", "@web5/common": "0.2.1", - "@web5/crypto": "0.2.2", + "@web5/crypto": "0.2.3", "@web5/dids": "0.2.2" }, "devDependencies": { diff --git a/packages/user-agent/package.json b/packages/user-agent/package.json index 1ee5bb9d0..a2b4a9ef5 100644 --- a/packages/user-agent/package.json +++ b/packages/user-agent/package.json @@ -69,7 +69,7 @@ "dependencies": { "@web5/agent": "0.2.4", "@web5/common": "0.2.1", - "@web5/crypto": "0.2.2", + "@web5/crypto": "0.2.3", "@web5/dids": "0.2.2" }, "devDependencies": { From 09a03e19ac4ed378b2b6970721b9f834361f8e99 Mon Sep 17 00:00:00 2001 From: Phoebe Lew Date: Wed, 29 Nov 2023 12:29:40 +0000 Subject: [PATCH 2/6] Add did:dht VC test --- .../tests/verifiable-credential.spec.ts | 169 +++++++++++++++++- 1 file changed, 168 insertions(+), 1 deletion(-) diff --git a/packages/credentials/tests/verifiable-credential.spec.ts b/packages/credentials/tests/verifiable-credential.spec.ts index 3142e9c5a..eef2ab216 100644 --- a/packages/credentials/tests/verifiable-credential.spec.ts +++ b/packages/credentials/tests/verifiable-credential.spec.ts @@ -1,7 +1,8 @@ import { expect } from 'chai'; import { VerifiableCredential, SignOptions } from '../src/verifiable-credential.js'; import { Ed25519, Jose } from '@web5/crypto'; -import { DidKeyMethod } from '@web5/dids'; +import { DidDhtMethod, DidKeyMethod, PortableDid } from '@web5/dids'; +import sinon from 'sinon'; type Signer = (data: Uint8Array) => Promise; @@ -180,6 +181,172 @@ describe('Verifiable Credential Tests', () => { await VerifiableCredential.verify(vcJwt); }); + + it('verify does not throw an exception with vaild vc signed by did:dht', async () => { + const mockDocument: PortableDid = { + keySet: { + identityKey: { + privateKeyJwk: { + d : '_8gihSI-m8aOCCM6jHg33d8kxdImPBN4C5_bZIu10XU', + alg : 'EdDSA', + crv : 'Ed25519', + kty : 'OKP', + ext : 'true', + key_ops : [ + 'sign' + ], + x : 'Qm88q6jAN9tfnrLt5V2zAiZs7wD_jnewHp7HIvM3dGo', + kid : '0' + }, + publicKeyJwk: { + alg : 'EdDSA', + crv : 'Ed25519', + kty : 'OKP', + ext : 'true', + key_ops : [ + 'verify' + ], + x : 'Qm88q6jAN9tfnrLt5V2zAiZs7wD_jnewHp7HIvM3dGo', + kid : '0' + } + }, + verificationMethodKeys: [ + { + privateKeyJwk: { + d : '_8gihSI-m8aOCCM6jHg33d8kxdImPBN4C5_bZIu10XU', + alg : 'EdDSA', + crv : 'Ed25519', + kty : 'OKP', + ext : 'true', + key_ops : [ + 'sign' + ], + x : 'Qm88q6jAN9tfnrLt5V2zAiZs7wD_jnewHp7HIvM3dGo', + kid : '0' + }, + publicKeyJwk: { + alg : 'EdDSA', + crv : 'Ed25519', + kty : 'OKP', + ext : 'true', + key_ops : [ + 'verify' + ], + x : 'Qm88q6jAN9tfnrLt5V2zAiZs7wD_jnewHp7HIvM3dGo', + kid : '0' + }, + relationships: [ + 'authentication', + 'assertionMethod', + 'capabilityInvocation', + 'capabilityDelegation' + ] + } + ] + + }, + did : 'did:dht:ejzu3k7eay57szh6sms6kzpuyeug35ay9688xcy6u5d1fh3zqtiy', + document : { + id : 'did:dht:ejzu3k7eay57szh6sms6kzpuyeug35ay9688xcy6u5d1fh3zqtiy', + verificationMethod : [ + { + id : 'did:dht:ejzu3k7eay57szh6sms6kzpuyeug35ay9688xcy6u5d1fh3zqtiy#0', + type : 'JsonWebKey2020', + controller : 'did:dht:ejzu3k7eay57szh6sms6kzpuyeug35ay9688xcy6u5d1fh3zqtiy', + publicKeyJwk : { + crv : 'Ed25519', + kty : 'OKP', + alg : 'EdDSA', + kid : '0', + x : 'Qm88q6jAN9tfnrLt5V2zAiZs7wD_jnewHp7HIvM3dGo' + } + } + ], + authentication: [ + '#0' + ], + assertionMethod: [ + '#0' + ], + capabilityInvocation: [ + '#0' + ], + capabilityDelegation: [ + '#0' + ] + } + }; + const didDhtCreateSpy = sinon.stub(DidDhtMethod, 'create').resolves(mockDocument); + + const alice = await DidDhtMethod.create({ publish: true }); + + const [signingKeyPair] = alice.keySet.verificationMethodKeys!; + const privateKey = (await Jose.jwkToKey({ key: signingKeyPair.privateKeyJwk!})).keyMaterial; + signer = EdDsaSigner(privateKey); + signOptions = { + issuerDid : alice.did, + subjectDid : alice.did, + kid : alice.did + '#' + alice.did.split(':')[2], + signer : signer + }; + + const vc = VerifiableCredential.create({ + type : 'StreetCred', + issuer : signOptions.issuerDid, + subject : signOptions.subjectDid, + data : new StreetCredibility('high', true), + }); + + const dhtDidResolutionSpy = sinon.stub(DidDhtMethod, 'resolve').resolves({ + '@context' : 'https://w3id.org/did-resolution/v1', + didDocument : { + id : 'did:dht:ejzu3k7eay57szh6sms6kzpuyeug35ay9688xcy6u5d1fh3zqtiy', + verificationMethod : [ + { + id : 'did:dht:ejzu3k7eay57szh6sms6kzpuyeug35ay9688xcy6u5d1fh3zqtiy#0', + type : 'JsonWebKey2020', + controller : 'did:dht:ejzu3k7eay57szh6sms6kzpuyeug35ay9688xcy6u5d1fh3zqtiy', + publicKeyJwk : { + crv : 'Ed25519', + kty : 'OKP', + alg : 'EdDSA', + kid : '0', + x : 'Qm88q6jAN9tfnrLt5V2zAiZs7wD_jnewHp7HIvM3dGo' + } + } + ], + authentication: [ + '#0' + ], + assertionMethod: [ + '#0' + ], + capabilityInvocation: [ + '#0' + ], + capabilityDelegation: [ + '#0' + ] + }, + didDocumentMetadata : {}, + didResolutionMetadata : { + contentType : 'application/did+ld+json', + did : { + didString : 'did:dht:ejzu3k7eay57szh6sms6kzpuyeug35ay9688xcy6u5d1fh3zqtiy', + methodSpecificId : 'ejzu3k7eay57szh6sms6kzpuyeug35ay9688xcy6u5d1fh3zqtiy', + method : 'dht' + } + } + }); + + const vcJwt = await vc.sign(signOptions); + + await VerifiableCredential.verify(vcJwt); + + sinon.assert.calledOnce(didDhtCreateSpy); + sinon.assert.calledOnce(dhtDidResolutionSpy); + sinon.restore(); + }); }); }); From ea2e611e0d20b282d1619fc4a85845685874aa17 Mon Sep 17 00:00:00 2001 From: phoebe-lew Date: Wed, 29 Nov 2023 12:53:42 +0000 Subject: [PATCH 3/6] Apply suggestions from code review Co-authored-by: Frank Hinek Co-authored-by: Gabe <7622243+decentralgabe@users.noreply.github.com> --- packages/agent/package.json | 2 +- packages/api/package.json | 2 +- packages/credentials/package.json | 2 +- packages/credentials/tests/verifiable-credential.spec.ts | 2 +- packages/dids/package.json | 2 +- packages/identity-agent/package.json | 2 +- packages/proxy-agent/package.json | 2 +- packages/user-agent/package.json | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/agent/package.json b/packages/agent/package.json index 79c9d67f3..3534fa1f9 100644 --- a/packages/agent/package.json +++ b/packages/agent/package.json @@ -69,7 +69,7 @@ "dependencies": { "@tbd54566975/dwn-sdk-js": "0.2.8", "@web5/common": "0.2.1", - "@web5/crypto": "0.2.3", + "@web5/crypto": "0.2.2", "@web5/dids": "0.2.2", "level": "8.0.0", "readable-stream": "4.4.2", diff --git a/packages/api/package.json b/packages/api/package.json index 3d0c48fec..b64b2d2df 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -77,7 +77,7 @@ "dependencies": { "@tbd54566975/dwn-sdk-js": "0.2.8", "@web5/agent": "0.2.4", - "@web5/crypto": "0.2.3", + "@web5/crypto": "0.2.2", "@web5/dids": "0.2.2", "@web5/user-agent": "0.2.4", "level": "8.0.0", diff --git a/packages/credentials/package.json b/packages/credentials/package.json index 9c6edc9a7..92920a558 100644 --- a/packages/credentials/package.json +++ b/packages/credentials/package.json @@ -85,7 +85,7 @@ "@typescript-eslint/eslint-plugin": "6.4.0", "@typescript-eslint/parser": "6.4.0", "@web5/common": "0.2.1", - "@web5/crypto": "0.2.3", + "@web5/crypto": "0.2.2", "@web5/dids": "0.2.2", "c8": "8.0.1", "chai": "4.3.10", diff --git a/packages/credentials/tests/verifiable-credential.spec.ts b/packages/credentials/tests/verifiable-credential.spec.ts index eef2ab216..5385122c8 100644 --- a/packages/credentials/tests/verifiable-credential.spec.ts +++ b/packages/credentials/tests/verifiable-credential.spec.ts @@ -281,7 +281,7 @@ describe('Verifiable Credential Tests', () => { const alice = await DidDhtMethod.create({ publish: true }); const [signingKeyPair] = alice.keySet.verificationMethodKeys!; - const privateKey = (await Jose.jwkToKey({ key: signingKeyPair.privateKeyJwk!})).keyMaterial; + const privateKey = (await Jose.jwkToKey({ key: signingKeyPair.privateKeyJwk! })).keyMaterial; signer = EdDsaSigner(privateKey); signOptions = { issuerDid : alice.did, diff --git a/packages/dids/package.json b/packages/dids/package.json index 343234769..9feb2dae8 100644 --- a/packages/dids/package.json +++ b/packages/dids/package.json @@ -77,7 +77,7 @@ "@decentralized-identity/ion-pow-sdk": "1.0.17", "@decentralized-identity/ion-sdk": "1.0.1", "@web5/common": "0.2.1", - "@web5/crypto": "0.2.3", + "@web5/crypto": "0.2.2", "did-resolver": "4.1.0", "dns-packet": "5.6.1", "level": "8.0.0", diff --git a/packages/identity-agent/package.json b/packages/identity-agent/package.json index 74850dbd5..142db6e71 100644 --- a/packages/identity-agent/package.json +++ b/packages/identity-agent/package.json @@ -69,7 +69,7 @@ "dependencies": { "@web5/agent": "0.2.4", "@web5/common": "0.2.1", - "@web5/crypto": "0.2.3", + "@web5/crypto": "0.2.2", "@web5/dids": "0.2.2" }, "devDependencies": { diff --git a/packages/proxy-agent/package.json b/packages/proxy-agent/package.json index 2c56463c8..71c3a6c09 100644 --- a/packages/proxy-agent/package.json +++ b/packages/proxy-agent/package.json @@ -69,7 +69,7 @@ "dependencies": { "@web5/agent": "0.2.4", "@web5/common": "0.2.1", - "@web5/crypto": "0.2.3", + "@web5/crypto": "0.2.2", "@web5/dids": "0.2.2" }, "devDependencies": { diff --git a/packages/user-agent/package.json b/packages/user-agent/package.json index a2b4a9ef5..1ee5bb9d0 100644 --- a/packages/user-agent/package.json +++ b/packages/user-agent/package.json @@ -69,7 +69,7 @@ "dependencies": { "@web5/agent": "0.2.4", "@web5/common": "0.2.1", - "@web5/crypto": "0.2.3", + "@web5/crypto": "0.2.2", "@web5/dids": "0.2.2" }, "devDependencies": { From 7da2096aa97a255e39436bc939a67973c25d7a8b Mon Sep 17 00:00:00 2001 From: Phoebe Lew Date: Wed, 29 Nov 2023 12:54:54 +0000 Subject: [PATCH 4/6] Fix kid --- packages/credentials/tests/verifiable-credential.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/credentials/tests/verifiable-credential.spec.ts b/packages/credentials/tests/verifiable-credential.spec.ts index 5385122c8..6cc2fe02a 100644 --- a/packages/credentials/tests/verifiable-credential.spec.ts +++ b/packages/credentials/tests/verifiable-credential.spec.ts @@ -286,7 +286,7 @@ describe('Verifiable Credential Tests', () => { signOptions = { issuerDid : alice.did, subjectDid : alice.did, - kid : alice.did + '#' + alice.did.split(':')[2], + kid : alice.did + '#0', signer : signer }; From 2e7f249ce88bc8c83f6e4cd5bb1d5149216c54f6 Mon Sep 17 00:00:00 2001 From: Phoebe Lew Date: Wed, 29 Nov 2023 13:01:13 +0000 Subject: [PATCH 5/6] set api version --- packages/api/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/api/package.json b/packages/api/package.json index b64b2d2df..ec1e14fc6 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@web5/api", - "version": "0.8.3", + "version": "0.8.2", "description": "SDK for accessing the features and capabilities of Web5", "type": "module", "main": "./dist/cjs/index.js", From 83702e2f2bbde4da55a428104a45008a435af556 Mon Sep 17 00:00:00 2001 From: Frank Hinek Date: Wed, 29 Nov 2023 09:34:55 -0500 Subject: [PATCH 6/6] Fix missing dev dependency Signed-off-by: Frank Hinek --- package-lock.json | 11 ++++++----- packages/identity-agent/package.json | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index c663b537f..1070b6998 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3419,9 +3419,9 @@ "dev": true }, "node_modules/electron-to-chromium": { - "version": "1.4.595", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.595.tgz", - "integrity": "sha512-+ozvXuamBhDOKvMNUQvecxfbyICmIAwS4GpLmR0bsiSBlGnLaOcs2Cj7J8XSbW+YEaN3Xl3ffgpm+srTUWFwFQ==", + "version": "1.4.596", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.596.tgz", + "integrity": "sha512-zW3zbZ40Icb2BCWjm47nxwcFGYlIgdXkAx85XDO7cyky9J4QQfq8t0W19/TLZqq3JPQXtlv8BPIGmfa9Jb4scg==", "dev": true, "peer": true }, @@ -9992,7 +9992,7 @@ }, "packages/api": { "name": "@web5/api", - "version": "0.8.3", + "version": "0.8.2", "license": "Apache-2.0", "dependencies": { "@tbd54566975/dwn-sdk-js": "0.2.8", @@ -10415,7 +10415,7 @@ }, "packages/credentials": { "name": "@web5/credentials", - "version": "0.3.1", + "version": "0.3.2", "license": "Apache-2.0", "dependencies": { "@sphereon/pex": "2.1.0", @@ -11093,6 +11093,7 @@ "@types/mocha": "10.0.1", "@typescript-eslint/eslint-plugin": "6.4.0", "@typescript-eslint/parser": "6.4.0", + "@web5/api": "0.8.2", "c8": "8.0.1", "chai": "4.3.10", "chai-as-promised": "7.1.1", diff --git a/packages/identity-agent/package.json b/packages/identity-agent/package.json index 142db6e71..65fe2606c 100644 --- a/packages/identity-agent/package.json +++ b/packages/identity-agent/package.json @@ -80,6 +80,7 @@ "@types/mocha": "10.0.1", "@typescript-eslint/eslint-plugin": "6.4.0", "@typescript-eslint/parser": "6.4.0", + "@web5/api": "0.8.2", "c8": "8.0.1", "chai": "4.3.10", "chai-as-promised": "7.1.1",