From 99c53e52d3e5f5f9c50d7fc20775e519c2e75589 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 8 Dec 2023 18:20:33 +0100 Subject: [PATCH] fix(deps): update dependency ethr-did-resolver to v10 (#1291) fixes #1295 --- __tests__/localAgent.test.ts | 2 +- __tests__/shared/documentationExamples.ts | 5 +- package.json | 2 +- packages/cli/package.json | 2 +- packages/core-types/src/plugin.schema.json | 25 +++++++-- packages/core-types/src/types/IResolver.ts | 12 +--- .../EcdsaSecp256k1RecoverySignature2020.ts | 27 ++++++--- packages/did-resolver/package.json | 2 +- .../src/__tests__/integration.test.ts | 5 +- .../browserAgent.browser-test.ts | 5 +- packages/test-react-app/package.json | 2 +- packages/utils/package.json | 1 + pnpm-lock.yaml | 56 ++++++++++++++++--- 13 files changed, 100 insertions(+), 46 deletions(-) diff --git a/__tests__/localAgent.test.ts b/__tests__/localAgent.test.ts index db58647f5..efad96309 100644 --- a/__tests__/localAgent.test.ts +++ b/__tests__/localAgent.test.ts @@ -218,7 +218,7 @@ const setup = async (options?: IAgentOptions): Promise => { { name: 'ganache', chainId: 1337, - provider, + provider: provider as any, registry, }, ], diff --git a/__tests__/shared/documentationExamples.ts b/__tests__/shared/documentationExamples.ts index 8997bbc48..b42cacbb6 100644 --- a/__tests__/shared/documentationExamples.ts +++ b/__tests__/shared/documentationExamples.ts @@ -59,10 +59,7 @@ export default (testContext: { didUrl: 'did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190', }) expect(doc.didDocument).toEqual({ - '@context': [ - 'https://www.w3.org/ns/did/v1', - 'https://w3id.org/security/suites/secp256k1recovery-2020/v2', - ], + '@context': expect.anything(), id: 'did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190', verificationMethod: [ { diff --git a/package.json b/package.json index be4717a84..52e8d9a68 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "did-jwt-vc": "3.2.11", "did-resolver": "4.1.0", "ethers": "6.7.1", - "ethr-did-resolver": "9.0.0", + "ethr-did-resolver": "10.1.0", "express": "4.18.2", "ganache": "7.9.0", "jest": "29.7.0", diff --git a/packages/cli/package.json b/packages/cli/package.json index a2b5a666c..b5cc09b07 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -73,7 +73,7 @@ "debug": "^4.3.4", "did-resolver": "^4.1.0", "dotenv": "^16.3.1", - "ethr-did-resolver": "^9.0.0", + "ethr-did-resolver": "^10.1.0", "express": "^4.18.2", "express-handlebars": "^7.1.1", "fuzzy": "^0.1.3", diff --git a/packages/core-types/src/plugin.schema.json b/packages/core-types/src/plugin.schema.json index eab6c794d..81b0be3dd 100644 --- a/packages/core-types/src/plugin.schema.json +++ b/packages/core-types/src/plugin.schema.json @@ -347,18 +347,35 @@ "description": "Represents an endpoint of a Service entry in a DID document." }, "DIDDocumentSection": { + "anyOf": [ + { + "$ref": "#/components/schemas/KeyCapabilitySection" + }, + { + "type": "string", + "const": "verificationMethod" + }, + { + "type": "string", + "const": "publicKey" + }, + { + "type": "string", + "const": "service" + } + ], + "description": "Refers to a section of a DID document. Either the list of verification methods or services or one of the verification relationships.\n\nSee {@link https://www.w3.org/TR/did-core/#verification-relationships | verification relationships }" + }, + "KeyCapabilitySection": { "type": "string", "enum": [ - "verificationMethod", - "publicKey", - "service", "authentication", "assertionMethod", "keyAgreement", "capabilityInvocation", "capabilityDelegation" ], - "description": "Refers to a section of a DID document. Either the list of verification methods or services or one of the verification relationships.\n\nSee {@link https://www.w3.org/TR/did-core/#verification-relationships | verification relationships }" + "description": "Represents the Verification Relationship between a DID subject and a Verification Method." }, "DIDDocComponent": { "anyOf": [ diff --git a/packages/core-types/src/types/IResolver.ts b/packages/core-types/src/types/IResolver.ts index f273956b2..5be9c7daa 100644 --- a/packages/core-types/src/types/IResolver.ts +++ b/packages/core-types/src/types/IResolver.ts @@ -2,6 +2,7 @@ import { DIDDocument, DIDResolutionOptions, DIDResolutionResult, + KeyCapabilitySection, ServiceEndpoint, VerificationMethod, } from 'did-resolver' @@ -78,10 +79,7 @@ export interface IResolver extends IPluginMethodMap { * didUrl: 'did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190' * }) * expect(doc.didDocument).toEqual({ - * '@context': [ - * 'https://www.w3.org/ns/did/v1', - * 'https://w3id.org/security/suites/secp256k1recovery-2020/v2', - * ], + * '@context': expect.anything(), * id: 'did:ethr:0xb09b66026ba5909a7cfe99b76875431d2b8d5190', * verificationMethod: [ * { @@ -142,11 +140,7 @@ export interface IResolver extends IPluginMethodMap { * @public */ export type DIDDocumentSection = + | KeyCapabilitySection | 'verificationMethod' | 'publicKey' //used for backward compatibility | 'service' - | 'authentication' - | 'assertionMethod' - | 'keyAgreement' - | 'capabilityInvocation' - | 'capabilityDelegation' diff --git a/packages/credential-ld/src/suites/EcdsaSecp256k1RecoverySignature2020.ts b/packages/credential-ld/src/suites/EcdsaSecp256k1RecoverySignature2020.ts index 7d9679df0..7a8e8b764 100644 --- a/packages/credential-ld/src/suites/EcdsaSecp256k1RecoverySignature2020.ts +++ b/packages/credential-ld/src/suites/EcdsaSecp256k1RecoverySignature2020.ts @@ -1,7 +1,7 @@ import { RequiredAgentMethods, VeramoLdSignature } from '../ld-suites.js' import { CredentialPayload, DIDDocument, IAgentContext, IKey, TKeyType } from '@veramo/core-types' import ldsEcdsa from '@veramo-community/lds-ecdsa-secp256k1-recovery2020' -import { asArray, bytesToBase64, concat, encodeJoseBlob, stringToUtf8Bytes } from '@veramo/utils' +import { asArray, bytesToBase64, concat, encodeJoseBlob, intersect, stringToUtf8Bytes } from '@veramo/utils' const { EcdsaSecp256k1RecoveryMethod2020, EcdsaSecp256k1RecoverySignature2020 } = ldsEcdsa @@ -72,14 +72,24 @@ export class VeramoEcdsaSecp256k1RecoverySignature2020 extends VeramoLdSignature preSigningCredModification(credential: CredentialPayload): void {} async preDidResolutionModification(didUrl: string, didDoc: DIDDocument): Promise { - // did:ethr - const idx = - didDoc['@context']?.indexOf( - 'https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld', - ) || -1 - if (Array.isArray(didDoc['@context']) && idx !== -1) { - didDoc['@context'][idx] = this.getContext() + const ctx = asArray(didDoc['@context']) + const legacyContext = + 'https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld' + const unstableContext = 'https://w3id.org/security/v3-unstable' + + // Old did:ethr resolvers would return a broken context link + const idx = ctx.indexOf(legacyContext) + if (idx !== -1) { + ctx[idx] = this.getContext() + } + + // this verification suite does not support both https://w3id.org/security/suites/secp256k1recovery-2020/v2 and + // https://w3id.org/security/v3-unstable as DID document @context, complaining that the `blockchainAccountId` is + // being redefined. + if (intersect(ctx, [unstableContext, this.getContext()]).length == 2) { + ctx.splice(ctx.indexOf(unstableContext), 1) } + didDoc['@context'] = ctx if (didUrl.toLowerCase().startsWith('did:ethr')) { //EcdsaSecp256k1RecoveryMethod2020 does not support older format blockchainAccountId @@ -94,6 +104,7 @@ export class VeramoEcdsaSecp256k1RecoverySignature2020 extends VeramoLdSignature } return didDoc } + getContext(): string { return 'https://w3id.org/security/suites/secp256k1recovery-2020/v2' } diff --git a/packages/did-resolver/package.json b/packages/did-resolver/package.json index 4ab7fbc8c..7f6ac4ccb 100644 --- a/packages/did-resolver/package.json +++ b/packages/did-resolver/package.json @@ -17,7 +17,7 @@ "did-resolver": "^4.1.0" }, "devDependencies": { - "ethr-did-resolver": "9.0.0", + "ethr-did-resolver": "10.1.0", "@types/debug": "4.1.8", "typescript": "5.2.2", "web-did-resolver": "2.0.27" diff --git a/packages/did-resolver/src/__tests__/integration.test.ts b/packages/did-resolver/src/__tests__/integration.test.ts index adc51f8fe..89b96f6e8 100644 --- a/packages/did-resolver/src/__tests__/integration.test.ts +++ b/packages/did-resolver/src/__tests__/integration.test.ts @@ -71,10 +71,7 @@ describe('@veramo/did-resolver', () => { resolverPlugin.resolveDid({ didUrl: 'did:ethr:mainnet:0xaafe788d8ca214a080b0f6ac7f48480b2aefa9bb' }), ).resolves.toEqual({ didDocument: { - '@context': [ - 'https://www.w3.org/ns/did/v1', - 'https://w3id.org/security/suites/secp256k1recovery-2020/v2', - ], + '@context': expect.anything(), id: 'did:ethr:mainnet:0xaafe788d8ca214a080b0f6ac7f48480b2aefa9bb', verificationMethod: [ { diff --git a/packages/test-react-app/headless-tests/browserAgent.browser-test.ts b/packages/test-react-app/headless-tests/browserAgent.browser-test.ts index 7558b91dc..6d90a91b5 100644 --- a/packages/test-react-app/headless-tests/browserAgent.browser-test.ts +++ b/packages/test-react-app/headless-tests/browserAgent.browser-test.ts @@ -52,10 +52,7 @@ describe('Browser integration tests', () => { contentType: 'application/did+ld+json', }, didDocument: { - '@context': [ - 'https://www.w3.org/ns/did/v1', - 'https://w3id.org/security/suites/secp256k1recovery-2020/v2', - ], + '@context': expect.anything(), id: 'did:ethr:0x6acf3bb1ef0ee84559de2bc2bd9d91532062a730', verificationMethod: [ { diff --git a/packages/test-react-app/package.json b/packages/test-react-app/package.json index 229bb81a7..45c1c0c61 100644 --- a/packages/test-react-app/package.json +++ b/packages/test-react-app/package.json @@ -31,7 +31,7 @@ "buffer": "npm:buffer", "crypto": "npm:crypto-browserify", "did-resolver": "^4.1.0", - "ethr-did-resolver": "^9.0.0", + "ethr-did-resolver": "^10.1.0", "path": "npm:path-browserify", "process": "npm:process", "react": "18.2.0", diff --git a/packages/utils/package.json b/packages/utils/package.json index ff3e32f77..0f9edfaaf 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -16,6 +16,7 @@ "credential-status": "^2.0.5", "cross-fetch": "^4.0.0", "debug": "^4.3.3", + "ethers": "^6.7.1", "did-jwt": "^7.4.1", "did-jwt-vc": "^3.2.10", "did-resolver": "^4.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c9c9db0ea..d41e94267 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -76,8 +76,8 @@ importers: specifier: 6.7.1 version: 6.7.1 ethr-did-resolver: - specifier: 9.0.0 - version: 9.0.0 + specifier: 10.1.0 + version: 10.1.0 express: specifier: 4.18.2 version: 4.18.2 @@ -268,8 +268,8 @@ importers: specifier: ^16.3.1 version: 16.3.1 ethr-did-resolver: - specifier: ^9.0.0 - version: 9.0.0 + specifier: ^10.1.0 + version: 10.1.0 express: specifier: ^4.18.2 version: 4.18.2 @@ -1013,8 +1013,8 @@ importers: specifier: 4.1.8 version: 4.1.8 ethr-did-resolver: - specifier: 9.0.0 - version: 9.0.0 + specifier: 10.1.0 + version: 10.1.0 typescript: specifier: 5.2.2 version: 5.2.2 @@ -1406,8 +1406,8 @@ importers: specifier: ^4.1.0 version: 4.1.0 ethr-did-resolver: - specifier: ^9.0.0 - version: 9.0.0 + specifier: ^10.1.0 + version: 10.1.0 path: specifier: npm:path-browserify version: /path-browserify@1.0.1 @@ -1591,6 +1591,9 @@ importers: did-resolver: specifier: ^4.1.0 version: 4.1.0 + ethers: + specifier: ^6.7.1 + version: 6.7.1 ipfs-unixfs: specifier: ^11.1.0 version: 11.1.0 @@ -1615,6 +1618,9 @@ packages: engines: {node: '>=0.10.0'} dev: true + /@adraffy/ens-normalize@1.10.0: + resolution: {integrity: sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==} + /@adraffy/ens-normalize@1.9.2: resolution: {integrity: sha512-0h+FrQDqe2Wn+IIGFkTCd4aAwTJ+7834Ek1COohCyV26AXhwQ7WQaz+4F/nLOeVl/3BtWHOHLPsq46V8YB46Eg==} @@ -7321,6 +7327,11 @@ packages: dependencies: '@noble/hashes': 1.3.1 + /@noble/curves@1.2.0: + resolution: {integrity: sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==} + dependencies: + '@noble/hashes': 1.3.2 + /@noble/ed25519@1.7.1: resolution: {integrity: sha512-Rk4SkJFaXZiznFyC/t77Q0NKS4FL7TLJJsVG2V2oiEq3kJVeTdxysEe/yRWSpnWMe808XRDJ+VFh5pt/FN5plw==} dev: false @@ -7336,6 +7347,10 @@ packages: resolution: {integrity: sha512-EbqwksQwz9xDRGfDST86whPBgM65E0OH/pCgqW0GBVzO22bNE+NuIbeTb714+IfSjU3aRk47EUvXIb5bTsenKA==} engines: {node: '>= 16'} + /@noble/hashes@1.3.2: + resolution: {integrity: sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==} + engines: {node: '>= 16'} + /@noble/secp256k1@1.7.1: resolution: {integrity: sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==} @@ -13940,6 +13955,21 @@ packages: - bufferutil - utf-8-validate + /ethers@6.9.0: + resolution: {integrity: sha512-pmfNyQzc2mseLe91FnT2vmNaTt8dDzhxZ/xItAV7uGsF4dI4ek2ufMu3rAkgQETL/TIs0GS5A+U05g9QyWnv3Q==} + engines: {node: '>=14.0.0'} + dependencies: + '@adraffy/ens-normalize': 1.10.0 + '@noble/curves': 1.2.0 + '@noble/hashes': 1.3.2 + '@types/node': 18.15.13 + aes-js: 4.0.0-beta.5 + tslib: 2.4.0 + ws: 8.5.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + /ethjs-util@0.1.6: resolution: {integrity: sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w==} engines: {node: '>=6.5.0', npm: '>=3'} @@ -13947,6 +13977,15 @@ packages: is-hex-prefixed: 1.0.0 strip-hex-prefix: 1.0.0 + /ethr-did-resolver@10.1.0: + resolution: {integrity: sha512-PH3R8UQGpJGWXaVVSWPppPiEzb7eHrzG6yTCGtk23Fw8Et2totj+7V1id+zxCQvToM9cW+CHA/+k64F8xpk/Mw==} + dependencies: + did-resolver: 4.1.0 + ethers: 6.9.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + /ethr-did-resolver@9.0.0: resolution: {integrity: sha512-L+c3NZk4fEC+jB1WWPtlUVPZk0r1XItxP54oRLhYpRMRwpG7lPnCzKV6XjuiCTDI7bJEfzrAYYn9sbxbIwEtLA==} dependencies: @@ -13955,6 +13994,7 @@ packages: transitivePeerDependencies: - bufferutil - utf-8-validate + dev: false /ethr-did@3.0.1: resolution: {integrity: sha512-EuxsA8nMDQcIkOh98vmjjXPRqRHw7ObfZ9nwAryVar/oIejp77oWtpn0dQwlM6RAi9B14z4b8iVXK5KQzMnrnw==}