Skip to content

Commit

Permalink
fix(deps): update dependency ethr-did-resolver to v10 (#1291)
Browse files Browse the repository at this point in the history
fixes #1295
  • Loading branch information
renovate[bot] authored Dec 8, 2023
1 parent 5aa97a2 commit 99c53e5
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 46 deletions.
2 changes: 1 addition & 1 deletion __tests__/localAgent.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ const setup = async (options?: IAgentOptions): Promise<boolean> => {
{
name: 'ganache',
chainId: 1337,
provider,
provider: provider as any,
registry,
},
],
Expand Down
5 changes: 1 addition & 4 deletions __tests__/shared/documentationExamples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
25 changes: 21 additions & 4 deletions packages/core-types/src/plugin.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
12 changes: 3 additions & 9 deletions packages/core-types/src/types/IResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
DIDDocument,
DIDResolutionOptions,
DIDResolutionResult,
KeyCapabilitySection,
ServiceEndpoint,
VerificationMethod,
} from 'did-resolver'
Expand Down Expand Up @@ -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: [
* {
Expand Down Expand Up @@ -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'
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -72,14 +72,24 @@ export class VeramoEcdsaSecp256k1RecoverySignature2020 extends VeramoLdSignature
preSigningCredModification(credential: CredentialPayload): void {}

async preDidResolutionModification(didUrl: string, didDoc: DIDDocument): Promise<DIDDocument> {
// 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
Expand All @@ -94,6 +104,7 @@ export class VeramoEcdsaSecp256k1RecoverySignature2020 extends VeramoLdSignature
}
return didDoc
}

getContext(): string {
return 'https://w3id.org/security/suites/secp256k1recovery-2020/v2'
}
Expand Down
2 changes: 1 addition & 1 deletion packages/did-resolver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 1 addition & 4 deletions packages/did-resolver/src/__tests__/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
{
Expand Down
2 changes: 1 addition & 1 deletion packages/test-react-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
56 changes: 48 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 99c53e5

Please sign in to comment.