diff --git a/__tests__/localAgent.test.ts b/__tests__/localAgent.test.ts index 2e74cc1fc8..b99b051e6d 100644 --- a/__tests__/localAgent.test.ts +++ b/__tests__/localAgent.test.ts @@ -123,15 +123,7 @@ const setup = async (options?: IAgentOptions): Promise => { }), new DIDResolverPlugin({ resolver: new Resolver({ - ...ethrDidResolver({ - networks: [ - { name: 'mainnet', rpcUrl: 'https://mainnet.infura.io/v3/' + infuraProjectId }, - { name: 'rinkeby', rpcUrl: 'https://rinkeby.infura.io/v3/' + infuraProjectId }, - { name: 'ropsten', rpcUrl: 'https://ropsten.infura.io/v3/' + infuraProjectId }, - { name: 'kovan', rpcUrl: 'https://kovan.infura.io/v3/' + infuraProjectId }, - { name: 'goerli', rpcUrl: 'https://goerli.infura.io/v3/' + infuraProjectId }, - ], - }), + ...ethrDidResolver({ infuraProjectId }), ...webDidResolver(), }), }), diff --git a/__tests__/restAgent.test.ts b/__tests__/restAgent.test.ts index 02cba9d3eb..9e95faa500 100644 --- a/__tests__/restAgent.test.ts +++ b/__tests__/restAgent.test.ts @@ -130,16 +130,8 @@ const setup = async (options?: IAgentOptions): Promise => { }), new DIDResolverPlugin({ resolver: new Resolver({ - ethr: ethrDidResolver({ - networks: [ - { name: 'mainnet', rpcUrl: 'https://mainnet.infura.io/v3/' + infuraProjectId }, - { name: 'rinkeby', rpcUrl: 'https://rinkeby.infura.io/v3/' + infuraProjectId }, - { name: 'ropsten', rpcUrl: 'https://ropsten.infura.io/v3/' + infuraProjectId }, - { name: 'kovan', rpcUrl: 'https://kovan.infura.io/v3/' + infuraProjectId }, - { name: 'goerli', rpcUrl: 'https://goerli.infura.io/v3/' + infuraProjectId }, - ], - }).ethr, - web: webDidResolver().web, + ...ethrDidResolver({ infuraProjectId }), + ...webDidResolver(), }), }), new DataStore(dbConnection), diff --git a/__tests__/shared/documentationExamples.ts b/__tests__/shared/documentationExamples.ts index 5e0215395c..ff1a1a58d3 100644 --- a/__tests__/shared/documentationExamples.ts +++ b/__tests__/shared/documentationExamples.ts @@ -27,24 +27,21 @@ export default (testContext: { const doc = await agent.resolveDid({ didUrl: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190', }) - - expect(doc).toEqual({ - '@context': 'https://w3id.org/did/v1', + expect(doc.didDocument).toEqual({ + '@context': [ + 'https://www.w3.org/ns/did/v1', + 'https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld', + ], id: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190', - publicKey: [ + verificationMethod: [ { id: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller', - type: 'Secp256k1VerificationKey2018', + type: 'EcdsaSecp256k1RecoveryMethod2020', controller: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190', - ethereumAddress: '0xb09b66026ba5909a7cfe99b76875431d2b8d5190', - }, - ], - authentication: [ - { - type: 'Secp256k1SignatureAuthentication2018', - publicKey: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller', + blockchainAccountId: '0xb09B66026bA5909A7CFE99b76875431D2b8D5190@eip155:4', }, ], + authentication: ['did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller'], }) }) diff --git a/__tests__/shared/keyManager.ts b/__tests__/shared/keyManager.ts index d6d48f6604..246f7fc183 100644 --- a/__tests__/shared/keyManager.ts +++ b/__tests__/shared/keyManager.ts @@ -165,9 +165,7 @@ export default (testContext: { data: 'test', }) - expect(signature).toHaveProperty('r') - expect(signature).toHaveProperty('s') - expect(signature).toHaveProperty('recoveryParam') + expect(signature).toBeDefined() }) it('should sign EthTX', async () => { diff --git a/__tests__/shared/resolveDid.ts b/__tests__/shared/resolveDid.ts index 6fedb6a8f0..e6782cf7fc 100644 --- a/__tests__/shared/resolveDid.ts +++ b/__tests__/shared/resolveDid.ts @@ -19,23 +19,38 @@ export default (testContext: { it('should resolve didUrl', async () => { const didUrl = 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190' - const didDoc = await agent.resolveDid({ didUrl }) - expect(didDoc.id).toEqual(didUrl) + const didDoc = (await agent.resolveDid({ didUrl })).didDocument + expect(didDoc?.id).toEqual(didUrl) }) - it('should throw an error for unsupported did methods', async () => { - await expect(agent.resolveDid({ didUrl: 'did:foo:bar' })).rejects.toThrow( - "Unsupported DID method: 'foo'", - ) + it('should return an error for unsupported did methods', async () => { + expect.assertions(1) + await expect(agent.resolveDid({ didUrl: 'did:foo:bar' })).resolves.toEqual({ + didDocument: null, + didResolutionMetadata: { error: 'unsupportedDidMethod' }, + didDocumentMetadata: {}, + }) }) it('should throw error when resolving garbage', async () => { //@ts-ignore - await expect(agent.resolveDid()).rejects.toHaveProperty('name', 'Error') + await expect(agent.resolveDid()).resolves.toEqual({ + didDocument: null, + didDocumentMetadata: {}, + didResolutionMetadata: { error: 'invalidDid' }, + }) //@ts-ignore - await expect(agent.resolveDid({})).rejects.toHaveProperty('name', 'Error') + await expect(agent.resolveDid({})).resolves.toEqual({ + didDocument: null, + didDocumentMetadata: {}, + didResolutionMetadata: { error: 'invalidDid' }, + }) //@ts-ignore - await expect(agent.resolveDid({ didUrl: 1 })).rejects.toThrow() + await expect(agent.resolveDid({ didUrl: "garbage" })).resolves.toEqual({ + didDocument: null, + didDocumentMetadata: {}, + didResolutionMetadata: { error: 'invalidDid' }, + }) }) }) diff --git a/package.json b/package.json index 3600ae75a7..7963ba8d1e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "@types/jest": "26.0.20", "codecov": "3.8.1", "cross-fetch": "3.0.6", - "husky": "5.0.9", + "husky": "5.1.3", "jest": "26.6.3", "jest-fetch-mock": "3.0.3", "json-schema": "0.3.0", diff --git a/packages/cli/default/default.yml b/packages/cli/default/default.yml index a7072df706..54a5588323 100644 --- a/packages/cli/default/default.yml +++ b/packages/cli/default/default.yml @@ -151,11 +151,11 @@ didResolver: $ref: /ethr-did-resolver web: $ref: /web-did-resolver - io: + key: $ref: /universal-resolver elem: $ref: /universal-resolver - key: + io: $ref: /universal-resolver ion: $ref: /universal-resolver diff --git a/packages/cli/package.json b/packages/cli/package.json index 89b878b83c..9595a7f36e 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -41,9 +41,9 @@ "cross-fetch": "^3.0.6", "date-fns": "^2.8.1", "debug": "^4.1.1", - "did-resolver": "^2.1.2", + "did-resolver": "3.1.0", "dotenv": "^8.2.0", - "ethr-did-resolver": "^3.0.2", + "ethr-did-resolver": "4.0.1", "express": "^4.17.1", "express-handlebars": "^5.2.0", "fuzzy": "^0.1.3", @@ -64,7 +64,7 @@ "ts-json-schema-generator": "^0.84.0", "typeorm": "0.2.30", "url-parse": "^1.4.7", - "web-did-resolver": "^1.3.5", + "web-did-resolver": "2.0.4", "ws": "^7.2.0", "yaml": "^1.10.0" }, diff --git a/packages/core/package.json b/packages/core/package.json index 6b07081d82..7724c46ae3 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -19,13 +19,13 @@ }, "dependencies": { "debug": "^4.1.1", - "did-jwt-vc": "^1.0.3", + "did-jwt-vc": "2.0.2", "events": "^3.0.0", "z-schema": "^5.0.0" }, "devDependencies": { "@types/debug": "4.1.5", - "did-resolver": "2.1.2", + "did-resolver": "3.1.0", "typescript": "4.1.3" }, "files": [ diff --git a/packages/core/plugin.schema.json b/packages/core/plugin.schema.json index b723299da2..c8b87c7949 100644 --- a/packages/core/plugin.schema.json +++ b/packages/core/plugin.schema.json @@ -8,6 +8,10 @@ "didUrl": { "type": "string", "description": "DID URL" + }, + "options": { + "$ref": "#/components/schemas/DIDResolutionOptions", + "description": "DID resolution options that will be passed to the method specific resolver. See: https://w3c.github.io/did-spec-registries/#did-resolution-input-metadata See: https://www.w3.org/TR/did-core/#did-resolution-options" } }, "required": [ @@ -15,6 +19,51 @@ ], "description": "Input arguments for {@link IResolver.resolveDid | resolveDid}" }, + "DIDResolutionOptions": { + "type": "object", + "properties": { + "accept": { + "type": "string" + } + } + }, + "DIDResolutionResult": { + "type": "object", + "properties": { + "didResolutionMetadata": { + "$ref": "#/components/schemas/DIDResolutionMetadata" + }, + "didDocument": { + "anyOf": [ + { + "$ref": "#/components/schemas/DIDDocument" + }, + { + "type": "null" + } + ] + }, + "didDocumentMetadata": { + "$ref": "#/components/schemas/DIDDocumentMetadata" + } + }, + "required": [ + "didResolutionMetadata", + "didDocument", + "didDocumentMetadata" + ] + }, + "DIDResolutionMetadata": { + "type": "object", + "properties": { + "contentType": { + "type": "string" + }, + "error": { + "type": "string" + } + } + }, "DIDDocument": { "type": "object", "properties": { @@ -22,7 +71,7 @@ "anyOf": [ { "type": "string", - "const": "https://w3id.org/did/v1" + "const": "https://www.w3.org/ns/did/v1" }, { "type": "string" @@ -38,10 +87,29 @@ "id": { "type": "string" }, - "publicKey": { + "alsoKnownAs": { "type": "array", "items": { - "$ref": "#/components/schemas/PublicKey" + "type": "string" + } + }, + "controller": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + }, + "verificationMethod": { + "type": "array", + "items": { + "$ref": "#/components/schemas/VerificationMethod" } }, "authentication": { @@ -52,31 +120,51 @@ "type": "string" }, { - "$ref": "#/components/schemas/PublicKey" + "$ref": "#/components/schemas/VerificationMethod" + } + ] + } + }, + "assertionMethod": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" }, { - "$ref": "#/components/schemas/Authentication" + "$ref": "#/components/schemas/VerificationMethod" } ] } }, - "uportProfile": {}, - "service": { + "keyAgreement": { "type": "array", "items": { - "$ref": "#/components/schemas/ServiceEndpoint" + "anyOf": [ + { + "type": "string" + }, + { + "$ref": "#/components/schemas/VerificationMethod" + } + ] } }, - "created": { - "type": "string" - }, - "updated": { - "type": "string" - }, - "proof": { - "$ref": "#/components/schemas/LinkedDataProof" + "capabilityInvocation": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "$ref": "#/components/schemas/VerificationMethod" + } + ] + } }, - "keyAgreement": { + "capabilityDelegation": { "type": "array", "items": { "anyOf": [ @@ -84,19 +172,29 @@ "type": "string" }, { - "$ref": "#/components/schemas/PublicKey" + "$ref": "#/components/schemas/VerificationMethod" } ] } + }, + "service": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ServiceEndpoint" + } + }, + "publicKey": { + "type": "array", + "items": { + "$ref": "#/components/schemas/VerificationMethod" + } } }, "required": [ - "@context", - "id", - "publicKey" + "id" ] }, - "PublicKey": { + "VerificationMethod": { "type": "object", "properties": { "id": { @@ -108,19 +206,60 @@ "controller": { "type": "string" }, - "ethereumAddress": { + "publicKeyBase58": { "type": "string" }, - "publicKeyBase64": { - "type": "string" + "publicKeyJwk": { + "type": "object", + "properties": { + "alg": { + "type": "string" + }, + "crv": { + "type": "string" + }, + "e": { + "type": "string" + }, + "ext": { + "type": "boolean" + }, + "key_ops": { + "type": "array", + "items": { + "type": "string" + } + }, + "kid": { + "type": "string" + }, + "kty": { + "type": "string" + }, + "n": { + "type": "string" + }, + "use": { + "type": "string" + }, + "x": { + "type": "string" + }, + "y": { + "type": "string" + } + }, + "required": [ + "kty" + ] }, - "publicKeyBase58": { + "publicKeyHex": { "type": "string" }, - "publicKeyHex": { + "blockchainAccountId": { "type": "string" }, - "publicKeyPem": { + "ethereumAddress": { "type": "string" } }, @@ -130,21 +269,6 @@ "controller" ] }, - "Authentication": { - "type": "object", - "properties": { - "type": { - "type": "string" - }, - "publicKey": { - "type": "string" - } - }, - "required": [ - "type", - "publicKey" - ] - }, "ServiceEndpoint": { "type": "object", "properties": { @@ -167,32 +291,34 @@ "serviceEndpoint" ] }, - "LinkedDataProof": { + "DIDDocumentMetadata": { "type": "object", "properties": { - "type": { + "created": { "type": "string" }, - "created": { + "updated": { + "type": "string" + }, + "deactivated": { + "type": "boolean" + }, + "versionId": { + "type": "string" + }, + "nextUpdate": { "type": "string" }, - "creator": { + "nextVersionId": { "type": "string" }, - "nonce": { + "equivalentId": { "type": "string" }, - "signatureValue": { + "canonicalId": { "type": "string" } - }, - "required": [ - "type", - "created", - "creator", - "nonce", - "signatureValue" - ] + } } }, "methods": { @@ -202,7 +328,7 @@ "$ref": "#/components/schemas/ResolveDidArgs" }, "returnType": { - "$ref": "#/components/schemas/DIDDocument" + "$ref": "#/components/schemas/DIDResolutionResult" } } } @@ -411,7 +537,54 @@ "description": "Key ID" }, "data": { - "type": "string", + "anyOf": [ + { + "type": "string" + }, + { + "type": "object", + "properties": { + "BYTES_PER_ELEMENT": { + "type": "number" + }, + "buffer": { + "anyOf": [ + { + "type": "object", + "properties": { + "byteLength": { + "type": "number" + } + }, + "required": [ + "byteLength" + ] + }, + {} + ] + }, + "byteLength": { + "type": "number" + }, + "byteOffset": { + "type": "number" + }, + "length": { + "type": "number" + } + }, + "required": [ + "BYTES_PER_ELEMENT", + "buffer", + "byteLength", + "byteOffset", + "length" + ], + "additionalProperties": { + "type": "number" + } + } + ], "description": "Data to sign" } }, @@ -420,26 +593,6 @@ "data" ], "description": "Input arguments for {@link IKeyManager.keyManagerSignJWT | keyManagerSignJWT}" - }, - "EcdsaSignature": { - "type": "object", - "properties": { - "r": { - "type": "string" - }, - "s": { - "type": "string" - }, - "recoveryParam": { - "type": "number", - "const": 1 - } - }, - "required": [ - "r", - "s", - "recoveryParam" - ] } }, "methods": { @@ -524,7 +677,7 @@ "$ref": "#/components/schemas/IKeyManagerSignJWTArgs" }, "returnType": { - "$ref": "#/components/schemas/EcdsaSignature" + "type": "string" } } } diff --git a/packages/core/src/types/IKeyManager.ts b/packages/core/src/types/IKeyManager.ts index 154e61fb4a..c412d8a0c2 100644 --- a/packages/core/src/types/IKeyManager.ts +++ b/packages/core/src/types/IKeyManager.ts @@ -94,13 +94,7 @@ export interface IKeyManagerSignJWTArgs { /** * Data to sign */ - data: string -} - -export interface EcdsaSignature { - r: string - s: string - recoveryParam: 1 + data: string | Uint8Array } /** @@ -164,7 +158,7 @@ export interface IKeyManager extends IPluginMethodMap { /** * Signs JWT */ - keyManagerSignJWT(args: IKeyManagerSignJWTArgs): Promise + keyManagerSignJWT(args: IKeyManagerSignJWTArgs): Promise /** Signs Ethereum transaction */ keyManagerSignEthTX(args: IKeyManagerSignEthTXArgs): Promise diff --git a/packages/core/src/types/IResolver.ts b/packages/core/src/types/IResolver.ts index 8f7ba19a89..d8ccc4ec95 100644 --- a/packages/core/src/types/IResolver.ts +++ b/packages/core/src/types/IResolver.ts @@ -1,5 +1,5 @@ -import { DIDDocument } from 'did-resolver' -export { DIDDocument } from 'did-resolver' +import { DIDResolutionOptions, DIDResolutionResult } from 'did-resolver' +export { DIDDocument, DIDResolutionOptions, DIDResolutionResult } from 'did-resolver' import { IPluginMethodMap } from './IAgent' /** @@ -14,6 +14,13 @@ export interface ResolveDidArgs { * `did:web:uport.me` */ didUrl: string + + /** + * DID resolution options that will be passed to the method specific resolver. + * See: https://w3c.github.io/did-spec-registries/#did-resolution-input-metadata + * See: https://www.w3.org/TR/did-core/#did-resolution-options + */ + options?: DIDResolutionOptions } /** @@ -29,29 +36,26 @@ export interface IResolver extends IPluginMethodMap { * const doc = await agent.resolveDid({ * didUrl: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190' * }) - * - * expect(doc).toEqual({ - * '@context': 'https://w3id.org/did/v1', + * expect(doc.didDocument).toEqual({ + * '@context': [ + * 'https://www.w3.org/ns/did/v1', + * 'https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld', + * ], * id: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190', - * publicKey: [ + * verificationMethod: [ * { - * id: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller', - * type: 'Secp256k1VerificationKey2018', - * controller: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190', - * ethereumAddress: '0xb09b66026ba5909a7cfe99b76875431d2b8d5190' - * } + * id: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller', + * type: 'EcdsaSecp256k1RecoveryMethod2020', + * controller: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190', + * blockchainAccountId: '0xb09B66026bA5909A7CFE99b76875431D2b8D5190@eip155:4', + * }, * ], - * authentication: [ - * { - * type: 'Secp256k1SignatureAuthentication2018', - * publicKey: 'did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller' - * } - * ] + * authentication: ['did:ethr:rinkeby:0xb09b66026ba5909a7cfe99b76875431d2b8d5190#controller'], * }) * ``` * * @param args - Input arguments for resolving a DID * @public */ - resolveDid(args: ResolveDidArgs): Promise + resolveDid(args: ResolveDidArgs): Promise } diff --git a/packages/credential-w3c/package.json b/packages/credential-w3c/package.json index 9f39496cfa..7f0062f81f 100644 --- a/packages/credential-w3c/package.json +++ b/packages/credential-w3c/package.json @@ -20,8 +20,8 @@ "@veramo/message-handler": "^1.1.0", "blakejs": "^1.1.0", "debug": "^4.1.1", - "did-jwt-vc": "^1.0.3", - "did-resolver": "2.1.2" + "did-jwt-vc": "2.0.2", + "did-resolver": "3.1.0" }, "devDependencies": { "@types/debug": "4.1.5", diff --git a/packages/credential-w3c/src/__tests__/credentialStatus.test.ts b/packages/credential-w3c/src/__tests__/credentialStatus.test.ts index 07ab488da8..5a57bf7b2c 100644 --- a/packages/credential-w3c/src/__tests__/credentialStatus.test.ts +++ b/packages/credential-w3c/src/__tests__/credentialStatus.test.ts @@ -36,7 +36,7 @@ describe('did-comm', () => { // publicKey: [ // { // id: 'did:ethr:rinkeby:0x42ba71c59a22a037e54f8d5b13d7b3721daa18c3#owner', -// type: 'Secp256k1VerificationKey2018', +// type: 'EcdsaSecp256k1VerificationKey2019', // owner: 'did:ethr:rinkeby:0x42ba71c59a22a037e54f8d5b13d7b3721daa18c3', // ethereumAddress: '0x42ba71c59a22a037e54f8d5b13d7b3721daa18c3', // }, diff --git a/packages/credential-w3c/src/__tests__/message-handler.test.ts b/packages/credential-w3c/src/__tests__/message-handler.test.ts index 1c89c062b4..f0a4eadd62 100644 --- a/packages/credential-w3c/src/__tests__/message-handler.test.ts +++ b/packages/credential-w3c/src/__tests__/message-handler.test.ts @@ -1,4 +1,4 @@ -import { DIDDocument } from '@veramo/core' +import { DIDDocument, DIDResolutionResult } from '@veramo/core' import { Message } from '@veramo/message-handler' import { W3cMessageHandler, MessageTypes } from '../index' import { IContext } from '../message-handler' @@ -63,26 +63,25 @@ describe('@veramo/credential-w3c', () => { execute: jest.fn(), availableMethods: jest.fn(), emit: jest.fn(), - resolveDid: async (args?): Promise => { + resolveDid: async (args?): Promise => { if (!args?.didUrl) throw Error('DID required') return { - '@context': 'https://w3id.org/did/v1', - id: args?.didUrl, - publicKey: [ - { - id: `${args?.didUrl}#owner`, - type: 'Secp256k1VerificationKey2018', - controller: args?.didUrl, - ethereumAddress: args?.didUrl.slice(-42), - }, - ], - authentication: [ - { - type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${args?.didUrl}#owner`, - }, - ], + didResolutionMetadata: {}, + didDocumentMetadata: {}, + didDocument: { + '@context': 'https://w3id.org/did/v1', + id: args?.didUrl, + verificationMethod: [ + { + id: `${args?.didUrl}#owner`, + type: 'EcdsaSecp256k1RecoveryMethod2020', + controller: args?.didUrl, + blockchainAccountId: `${args?.didUrl.slice(-42)}@eip155:1`, + }, + ], + authentication: [`${args?.didUrl}#owner`], + }, } }, }, diff --git a/packages/credential-w3c/src/action-handler.ts b/packages/credential-w3c/src/action-handler.ts index ef31a812a0..218811bb47 100644 --- a/packages/credential-w3c/src/action-handler.ts +++ b/packages/credential-w3c/src/action-handler.ts @@ -213,7 +213,7 @@ export class CredentialIssuer implements IAgentPlugin { const key = identifier.keys.find((k) => k.type === 'Secp256k1' || k.type === 'Ed25519') if (!key) throw Error('No signing key for ' + identifier.did) //FIXME: Throw an `unsupported_format` error if the `args.proofFormat` is not `jwt` - const signer = (data: string) => context.agent.keyManagerSignJWT({ kid: key.kid, data }) + const signer = (data: string | Uint8Array) => context.agent.keyManagerSignJWT({ kid: key.kid, data }) debug('Signing VP with', identifier.did) const jwt = await createVerifiablePresentationJwt(presentation, { did: identifier.did, signer }) //FIXME: flagging this as a potential privacy leak. @@ -249,7 +249,7 @@ export class CredentialIssuer implements IAgentPlugin { const key = identifier.keys.find((k) => k.type === 'Secp256k1' || k.type === 'Ed25519') if (!key) throw Error('No signing key for ' + identifier.did) //FIXME: Throw an `unsupported_format` error if the `args.proofFormat` is not `jwt` - const signer = (data: string) => context.agent.keyManagerSignJWT({ kid: key.kid, data }) + const signer = (data: string | Uint8Array) => context.agent.keyManagerSignJWT({ kid: key.kid, data }) debug('Signing VC with', identifier.did) let alg = 'ES256K' diff --git a/packages/did-comm/src/action-handler.ts b/packages/did-comm/src/action-handler.ts index f846aa323d..47438039df 100644 --- a/packages/did-comm/src/action-handler.ts +++ b/packages/did-comm/src/action-handler.ts @@ -79,7 +79,7 @@ export class DIDComm implements IAgentPlugin { const { data, url, headers, save = true } = args debug('Resolving didDoc') - const didDoc = await context.agent.resolveDid({ didUrl: data.to }) + const didDoc = (await context.agent.resolveDid({ didUrl: data.to })).didDocument let serviceEndpoint if (url) { serviceEndpoint = url @@ -96,7 +96,7 @@ export class DIDComm implements IAgentPlugin { const identifier = await context.agent.didManagerGet({ did: data.from }) const key = identifier.keys.find((k) => k.type === 'Ed25519') if (!key) throw Error('No encryption key') - const publicKey = didDoc?.publicKey.find((item) => item.type == 'Ed25519VerificationKey2018') + const publicKey = didDoc?.publicKey?.find((item) => item.type == 'Ed25519VerificationKey2018') if (!publicKey?.publicKeyHex) throw Error('Recipient does not have encryption publicKey') postPayload = await context.agent.keyManagerEncryptJWE({ diff --git a/packages/did-jwt/package.json b/packages/did-jwt/package.json index 1586d224eb..257f7c0e17 100644 --- a/packages/did-jwt/package.json +++ b/packages/did-jwt/package.json @@ -12,8 +12,8 @@ "@veramo/core": "^1.1.0", "@veramo/message-handler": "^1.1.0", "debug": "^4.1.1", - "did-jwt": "4.8.1", - "did-resolver": "2.1.2" + "did-jwt": "5.1.2", + "did-resolver": "3.1.0" }, "devDependencies": { "@types/debug": "4.1.5", diff --git a/packages/did-jwt/src/__tests__/didkey.test.ts b/packages/did-jwt/src/__tests__/didkey.test.ts index c082331bbf..be0aadc433 100644 --- a/packages/did-jwt/src/__tests__/didkey.test.ts +++ b/packages/did-jwt/src/__tests__/didkey.test.ts @@ -1,4 +1,4 @@ -import { DIDDocument } from '@veramo/core' +import { DIDResolutionResult } from '@veramo/core' import { Message } from '@veramo/message-handler' import { JwtMessageHandler, IContext } from '../message-handler' @@ -12,21 +12,25 @@ describe('@veramo/did-jwt', () => { execute: jest.fn(), availableMethods: jest.fn(), emit: jest.fn(), - resolveDid: async (args?): Promise => { + resolveDid: async (args?): Promise => { if (!args?.didUrl) throw Error('DID required') return { - '@context': 'https://w3id.org/did/v1', - id: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM', - publicKey: [ - { - id: - 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM#z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM', - type: 'Ed25519VerificationKey2018', - controller: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM', - publicKeyBase58: 'A12q688RGRdqshXhL9TW8QXQaX9H82ejU9DnqztLaAgy', - }, - ], + didDocumentMetadata: {}, + didResolutionMetadata: {}, + didDocument: { + '@context': 'https://w3id.org/did/v1', + id: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM', + publicKey: [ + { + id: + 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM#z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM', + type: 'Ed25519VerificationKey2018', + controller: 'did:key:z6MkoTHsgNNrby8JzCNQ1iRLyW5QQ6R8Xuu6AA8igGrMVPUM', + publicKeyBase58: 'A12q688RGRdqshXhL9TW8QXQaX9H82ejU9DnqztLaAgy', + }, + ], + }, } }, }, diff --git a/packages/did-jwt/src/__tests__/message-handler.test.ts b/packages/did-jwt/src/__tests__/message-handler.test.ts index 6dedfe763d..707c9ec598 100644 --- a/packages/did-jwt/src/__tests__/message-handler.test.ts +++ b/packages/did-jwt/src/__tests__/message-handler.test.ts @@ -1,4 +1,4 @@ -import { DIDDocument } from '@veramo/core' +import { DIDDocument, DIDResolutionResult } from '@veramo/core' import { Message } from '@veramo/message-handler' import { JwtMessageHandler, IContext } from '../message-handler' @@ -59,26 +59,25 @@ describe('@veramo/did-jwt', () => { execute: jest.fn(), availableMethods: jest.fn(), emit: jest.fn(), - resolveDid: async (args?): Promise => { + resolveDid: async (args?): Promise => { if (!args?.didUrl) throw Error('DID required') return { - '@context': 'https://w3id.org/did/v1', - id: args?.didUrl, - publicKey: [ - { - id: `${args?.didUrl}#owner`, - type: 'Secp256k1VerificationKey2018', - controller: args?.didUrl, - ethereumAddress: args?.didUrl.slice(-42), - }, - ], - authentication: [ - { - type: 'Secp256k1SignatureAuthentication2018', - publicKey: `${args?.didUrl}#owner`, - }, - ], + didResolutionMetadata: {}, + didDocumentMetadata: {}, + didDocument: { + '@context': 'https://w3id.org/did/v1', + id: args?.didUrl, + verificationMethod: [ + { + id: `${args?.didUrl}#owner`, + type: 'EcdsaSecp256k1RecoveryMethod2020', + controller: args?.didUrl, + blockchainAccountId: `${args?.didUrl.slice(-42)}@eip155:1`, + }, + ], + authentication: [`${args?.didUrl}#owner`], + }, } }, }, diff --git a/packages/did-jwt/src/message-handler.ts b/packages/did-jwt/src/message-handler.ts index 3a23974e7a..adb67dad2a 100644 --- a/packages/did-jwt/src/message-handler.ts +++ b/packages/did-jwt/src/message-handler.ts @@ -2,6 +2,7 @@ import { IAgentContext, IResolver } from '@veramo/core' import { AbstractMessageHandler, Message } from '@veramo/message-handler' import { verifyJWT, decodeJWT } from 'did-jwt' import Debug from 'debug' +import { Resolvable } from 'did-resolver' const debug = Debug('veramo:did-jwt:message-handler') export type IContext = IAgentContext @@ -16,7 +17,7 @@ export class JwtMessageHandler extends AbstractMessageHandler { try { const decoded = decodeJWT(message.raw) const audience = Array.isArray(decoded.payload.aud) ? decoded.payload.aud[0] : decoded.payload.aud - const resolver = { resolve: (didUrl: string) => context.agent.resolveDid({ didUrl }) } + const resolver = { resolve: (didUrl: string) => context.agent.resolveDid({ didUrl }) } as Resolvable const verified = await verifyJWT(message.raw, { resolver, audience }) debug('Message.raw is a valid JWT') message.addMetaData({ type: decoded.header.typ || 'JWT', value: decoded.header.alg }) diff --git a/packages/did-resolver/package.json b/packages/did-resolver/package.json index 74e69ddf37..23e2908e08 100644 --- a/packages/did-resolver/package.json +++ b/packages/did-resolver/package.json @@ -15,10 +15,10 @@ }, "devDependencies": { "@types/debug": "4.1.5", - "did-resolver": "2.1.2", - "ethr-did-resolver": "3.0.3", + "did-resolver": "3.1.0", + "ethr-did-resolver": "4.0.1", "typescript": "4.1.3", - "web-did-resolver": "1.3.5" + "web-did-resolver": "2.0.4" }, "files": [ "build/**/*", diff --git a/packages/did-resolver/src/__tests__/integration.test.ts b/packages/did-resolver/src/__tests__/integration.test.ts index 704293b0c9..cd11d867be 100644 --- a/packages/did-resolver/src/__tests__/integration.test.ts +++ b/packages/did-resolver/src/__tests__/integration.test.ts @@ -2,7 +2,7 @@ import { DIDResolverPlugin } from '../resolver' import { Resolver } from 'did-resolver' import { getResolver as getEthrResolver } from 'ethr-did-resolver' import { getResolver as getWebDidResolver } from 'web-did-resolver' -import { UniversalResolver } from '../universal-resolver' +import { getUniversalResolverFor } from '../universal-resolver' const providerConfig = { networks: [ @@ -13,8 +13,6 @@ const providerConfig = { ], } -const uniResolver = new UniversalResolver({ url: 'https://dev.uniresolver.io/1.0/identifiers/' }) - /** This creates a resolver that supports the [ethr, web, key, elem] DID methods */ let resolver: Resolver = new Resolver({ //resolve did:ethr using the embedded ethr-did-resolver @@ -22,8 +20,7 @@ let resolver: Resolver = new Resolver({ //resolve did:web using the embedded web-did-resolver ...getWebDidResolver(), //resolve some other DID methods using the centralized `uniresolver.io` service - key: uniResolver, - elem: uniResolver, + ...getUniversalResolverFor(['key', 'elem']), }) let resolverPlugin: DIDResolverPlugin = new DIDResolverPlugin({ resolver }) @@ -33,29 +30,33 @@ describe('@veramo/did-resolver', () => { it('should resolve web DID', async () => { expect.assertions(1) - await expect(resolverPlugin.resolveDid({ didUrl: 'did:web:did.actor:alice' })).resolves.toMatchObject({ - '@context': 'https://w3id.org/did/v0.11', - id: 'did:web:did.actor:alice', - publicKey: [ - { - id: 'did:web:did.actor:alice#z6MkrmNwty5ajKtFqc1U48oL2MMLjWjartwc5sf2AihZwXDN', - controller: 'did:web:did.actor:alice', - type: 'Ed25519VerificationKey2018', - publicKeyBase58: 'DK7uJiq9PnPnj7AmNZqVBFoLuwTjT1hFPrk6LSjZ2JRz', - }, - ], - authentication: ['did:web:did.actor:alice#z6MkrmNwty5ajKtFqc1U48oL2MMLjWjartwc5sf2AihZwXDN'], - assertionMethod: ['did:web:did.actor:alice#z6MkrmNwty5ajKtFqc1U48oL2MMLjWjartwc5sf2AihZwXDN'], - capabilityDelegation: ['did:web:did.actor:alice#z6MkrmNwty5ajKtFqc1U48oL2MMLjWjartwc5sf2AihZwXDN'], - capabilityInvocation: ['did:web:did.actor:alice#z6MkrmNwty5ajKtFqc1U48oL2MMLjWjartwc5sf2AihZwXDN'], - keyAgreement: [ - { - id: 'did:web:did.actor:alice#zC8GybikEfyNaausDA4mkT4egP7SNLx2T1d1kujLQbcP6h', - type: 'X25519KeyAgreementKey2019', - controller: 'did:web:did.actor:alice', - publicKeyBase58: 'CaSHXEvLKS6SfN9aBfkVGBpp15jSnaHazqHgLHp8KZ3Y', - }, - ], + await expect(resolverPlugin.resolveDid({ didUrl: 'did:web:did.actor:alice' })).resolves.toEqual({ + didDocument: { + '@context': 'https://w3id.org/did/v0.11', + id: 'did:web:did.actor:alice', + publicKey: [ + { + id: 'did:web:did.actor:alice#z6MkrmNwty5ajKtFqc1U48oL2MMLjWjartwc5sf2AihZwXDN', + controller: 'did:web:did.actor:alice', + type: 'Ed25519VerificationKey2018', + publicKeyBase58: 'DK7uJiq9PnPnj7AmNZqVBFoLuwTjT1hFPrk6LSjZ2JRz', + }, + ], + authentication: ['did:web:did.actor:alice#z6MkrmNwty5ajKtFqc1U48oL2MMLjWjartwc5sf2AihZwXDN'], + assertionMethod: ['did:web:did.actor:alice#z6MkrmNwty5ajKtFqc1U48oL2MMLjWjartwc5sf2AihZwXDN'], + capabilityDelegation: ['did:web:did.actor:alice#z6MkrmNwty5ajKtFqc1U48oL2MMLjWjartwc5sf2AihZwXDN'], + capabilityInvocation: ['did:web:did.actor:alice#z6MkrmNwty5ajKtFqc1U48oL2MMLjWjartwc5sf2AihZwXDN'], + keyAgreement: [ + { + id: 'did:web:did.actor:alice#zC8GybikEfyNaausDA4mkT4egP7SNLx2T1d1kujLQbcP6h', + type: 'X25519KeyAgreementKey2019', + controller: 'did:web:did.actor:alice', + publicKeyBase58: 'CaSHXEvLKS6SfN9aBfkVGBpp15jSnaHazqHgLHp8KZ3Y', + }, + ], + }, + didDocumentMetadata: {}, + didResolutionMetadata: { contentType: 'application/did+ld+json' }, }) }) @@ -63,31 +64,34 @@ describe('@veramo/did-resolver', () => { expect.assertions(1) await expect( resolverPlugin.resolveDid({ didUrl: 'did:ethr:rinkeby:0xE6Fe788d8ca214A080b0f6aC7F48480b2AEfa9a6' }), - ).resolves.toMatchObject({ - '@context': 'https://w3id.org/did/v1', - id: 'did:ethr:rinkeby:0xE6Fe788d8ca214A080b0f6aC7F48480b2AEfa9a6', - publicKey: [ - { - id: 'did:ethr:rinkeby:0xE6Fe788d8ca214A080b0f6aC7F48480b2AEfa9a6#controller', - type: 'Secp256k1VerificationKey2018', - controller: 'did:ethr:rinkeby:0xE6Fe788d8ca214A080b0f6aC7F48480b2AEfa9a6', - ethereumAddress: '0xe6fe788d8ca214a080b0f6ac7f48480b2aefa9a6', - }, - ], - authentication: [ - { - type: 'Secp256k1SignatureAuthentication2018', - publicKey: 'did:ethr:rinkeby:0xE6Fe788d8ca214A080b0f6aC7F48480b2AEfa9a6#controller', - }, - ], + ).resolves.toEqual({ + didDocument: { + '@context': [ + 'https://www.w3.org/ns/did/v1', + 'https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld', + ], + id: 'did:ethr:rinkeby:0xE6Fe788d8ca214A080b0f6aC7F48480b2AEfa9a6', + verificationMethod: [ + { + id: 'did:ethr:rinkeby:0xE6Fe788d8ca214A080b0f6aC7F48480b2AEfa9a6#controller', + type: 'EcdsaSecp256k1RecoveryMethod2020', + controller: 'did:ethr:rinkeby:0xE6Fe788d8ca214A080b0f6aC7F48480b2AEfa9a6', + blockchainAccountId: '0xE6Fe788d8ca214A080b0f6aC7F48480b2AEfa9a6@eip155:4', + }, + ], + authentication: ['did:ethr:rinkeby:0xE6Fe788d8ca214A080b0f6aC7F48480b2AEfa9a6#controller'], + }, + didDocumentMetadata: {}, + didResolutionMetadata: { contentType: 'application/did+ld+json' }, }) }) it('should resolve did:key using uniresolver', async () => { expect.assertions(1) - await expect( - resolverPlugin.resolveDid({ didUrl: 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6' }), - ).resolves.toMatchObject({ + const { didDocument } = await resolverPlugin.resolveDid({ + didUrl: 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6', + }) + expect(didDocument).toEqual({ '@context': ['https://w3id.org/did/v0.11'], id: 'did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6', publicKey: [ @@ -125,9 +129,11 @@ describe('@veramo/did-resolver', () => { it('should fail predictably when unsupported method is resolved', async () => { expect.assertions(1) - await expect(resolverPlugin.resolveDid({ didUrl: 'did:unsupported:lorem.ipsum' })).rejects.toThrowError( - "Unsupported DID method: 'unsupported'", - ) + await expect(resolverPlugin.resolveDid({ didUrl: 'did:unsupported:lorem.ipsum' })).resolves.toEqual({ + didDocument: null, + didDocumentMetadata: {}, + didResolutionMetadata: { error: 'unsupportedDidMethod' }, + }) }) it.todo('should resolve ethr-did with custom web3 provider') diff --git a/packages/did-resolver/src/resolver.ts b/packages/did-resolver/src/resolver.ts index 2142e00a6c..c742dda264 100644 --- a/packages/did-resolver/src/resolver.ts +++ b/packages/did-resolver/src/resolver.ts @@ -1,5 +1,5 @@ import { IAgentPlugin, IResolver, schema } from '@veramo/core' -import { Resolver, DIDDocument } from 'did-resolver' +import { Resolver, DIDDocument, DIDResolutionResult, DIDResolutionOptions } from 'did-resolver' export { DIDDocument } import Debug from 'debug' const debug = Debug('veramo:resolver') @@ -24,8 +24,8 @@ export class DIDResolverPlugin implements IAgentPlugin { } } - async resolveDid({ didUrl }: { didUrl: string }): Promise { + async resolveDid({ didUrl, options }: { didUrl: string, options?: DIDResolutionOptions }): Promise { debug('Resolving %s', didUrl) - return this.didResolver.resolve(didUrl) + return this.didResolver.resolve(didUrl, options) } } diff --git a/packages/did-resolver/src/universal-resolver.ts b/packages/did-resolver/src/universal-resolver.ts index 1085b24306..0dd5c70935 100644 --- a/packages/did-resolver/src/universal-resolver.ts +++ b/packages/did-resolver/src/universal-resolver.ts @@ -1,26 +1,79 @@ -import { DIDDocument, ParsedDID, Resolver } from 'did-resolver' +import { DIDResolutionResult, DIDResolver } from 'did-resolver' import fetch from 'cross-fetch' interface Options { url: string } +/** + * @deprecated please use `getUniresolver(url)` or `getUniresolverFor(methods, url)` instead + */ export class UniversalResolver { constructor(options: Options) { - if (!options.url) { - throw Error('[did-resolver] Universal: url required') - } + return getUniversalResolver(options.url) + } +} + +/** + * Creates a DIDResolver instance that can be used with `did-resolver` + * + * @example + * ```typescript + * const uniResolver = getUniversalResolver() + * const resolver = new Resolver({ + * web: uniResolver, + * key: uniResolver, + * elem: uniResolver + * }) + * ``` + * + * @param url the URL for the universal resolver instance (See https://uniresolver.io ) + * @returns `DIDResolver` + */ +export function getUniversalResolver( + url: string = 'https://dev.uniresolver.io/1.0/identifiers/', +): DIDResolver { + if (!url) { + throw Error('[did-resolver] Universal: url required') + } - const resolve = async (didUrl: string): Promise => { - try { - const result = await fetch(options.url + didUrl) - const ddo = await result.json() - return ddo.didDocument - } catch (e) { - return Promise.reject(e) - } + const resolve: DIDResolver = async (didUrl: string): Promise => { + try { + const result = await fetch(url + didUrl) + const ddo = await result.json() + return ddo + } catch (e) { + return Promise.reject(e) } + } + + return resolve +} - return resolve +/** + * Creates a mapping of DID methods to a DIDResolver instance that can be used with `did-resolver` + * + * @example + * ```typescript + * const uniResolver = getUniversalResolverFor(['web', 'key', 'elem']) + * const resolver = new Resolver({ + * ...uniResolver, + * // other resolvers + * }) + * ``` + * + * @param methods an array of DID methods that should be resolved by this universal resolver + * @param url the URL for the universal resolver instance (See https://uniresolver.io ) + * @returns `Record` a mapping of the given methods to an instance of `DIDResolver` + */ +export function getUniversalResolverFor( + methods: string[], + url: string = 'https://dev.uniresolver.io/1.0/identifiers/', +): Record { + const uniResolver = getUniversalResolver(url) + const mapping: Record = {} + for (const method of methods) { + mapping[method] = uniResolver } + return mapping } diff --git a/packages/key-manager/src/abstract-key-management-system.ts b/packages/key-manager/src/abstract-key-management-system.ts index 480085ee08..1f92fd86c1 100644 --- a/packages/key-manager/src/abstract-key-management-system.ts +++ b/packages/key-manager/src/abstract-key-management-system.ts @@ -1,10 +1,10 @@ -import { IKey, TKeyType, EcdsaSignature } from '@veramo/core' +import { IKey, TKeyType } from '@veramo/core' export abstract class AbstractKeyManagementSystem { abstract createKey(args: { type: TKeyType; meta?: any }): Promise> abstract deleteKey(args: { kid: string }): Promise abstract encryptJWE(args: { key: IKey; to: Omit; data: string }): Promise abstract decryptJWE(args: { key: IKey; data: string }): Promise - abstract signJWT(args: { key: IKey; data: string }): Promise + abstract signJWT(args: { key: IKey; data: string | Uint8Array }): Promise abstract signEthTX(args: { key: IKey; transaction: object }): Promise } diff --git a/packages/key-manager/src/key-manager.ts b/packages/key-manager/src/key-manager.ts index 1edf724d53..7a03b1f6cf 100644 --- a/packages/key-manager/src/key-manager.ts +++ b/packages/key-manager/src/key-manager.ts @@ -11,7 +11,6 @@ import { IKeyManagerDecryptJWEArgs, IKeyManagerSignJWTArgs, IKeyManagerSignEthTXArgs, - EcdsaSignature, schema, } from '@veramo/core' @@ -106,7 +105,7 @@ export class KeyManager implements IAgentPlugin { } /** {@inheritDoc @veramo/core#IKeyManager.keyManagerSignJWT} */ - async keyManagerSignJWT({ kid, data }: IKeyManagerSignJWTArgs): Promise { + async keyManagerSignJWT({ kid, data }: IKeyManagerSignJWTArgs): Promise< string> { const key = await this.store.get({ kid }) const kms = this.getKms(key.kms) return kms.signJWT({ key, data }) diff --git a/packages/kms-local-react-native/package.json b/packages/kms-local-react-native/package.json index 42badafdf0..8f498468b4 100644 --- a/packages/kms-local-react-native/package.json +++ b/packages/kms-local-react-native/package.json @@ -13,8 +13,8 @@ "@veramo/key-manager": "^1.1.0", "base-58": "^0.0.1", "debug": "^4.1.1", - "did-jwt": "4.8.1", - "elliptic": "^6.5.2", + "did-jwt": "5.1.2", + "elliptic": "6.5.4", "ethjs-signer": "^0.1.1" }, "peerDependencies": { diff --git a/packages/kms-local-react-native/src/key-management-system.ts b/packages/kms-local-react-native/src/key-management-system.ts index 840758b2d1..a83212401e 100644 --- a/packages/kms-local-react-native/src/key-management-system.ts +++ b/packages/kms-local-react-native/src/key-management-system.ts @@ -1,7 +1,7 @@ -import { TKeyType, IKey, EcdsaSignature } from '@veramo/core' +import { TKeyType, IKey } from '@veramo/core' import { AbstractKeyManagementSystem } from '@veramo/key-manager' import sodium from 'react-native-sodium' -import { NaclSigner, SimpleSigner } from 'did-jwt' +import { EdDSASigner, ES256KSigner, NaclSigner } from 'did-jwt' const EC = require('elliptic').ec const secp256k1 = new EC('secp256k1') import { DIDComm } from './didcomm' @@ -72,19 +72,15 @@ export class KeyManagementSystem extends AbstractKeyManagementSystem { return sign(transaction, '0x' + key.privateKeyHex) } - async signJWT({ key, data }: { key: IKey; data: string }): Promise { + async signJWT({ key, data }: { key: IKey; data: string }): Promise< string> { if (!key.privateKeyHex) throw Error('No private key for kid: ' + key.kid) if (key.type === 'Ed25519') { - const b64Key = sodium.to_base64( - Uint8Array.from(Buffer.from(key.privateKeyHex, 'hex')), - sodium.base64_variants.ORIGINAL, - ) - const signer = NaclSigner(b64Key) + const signer = EdDSASigner(key.privateKeyHex) return (signer(data) as any) as string } else if (key.type === 'Secp256k1') { - const signer = SimpleSigner(key.privateKeyHex) - return (signer(data) as any) as EcdsaSignature + const signer = ES256KSigner(key.privateKeyHex) + return signer(data) as unknown as string } else { throw Error('Cannot sign JWT with key of type ' + key.type) } diff --git a/packages/kms-local/package.json b/packages/kms-local/package.json index 842f7e37f9..28eea50e4a 100644 --- a/packages/kms-local/package.json +++ b/packages/kms-local/package.json @@ -13,8 +13,8 @@ "@veramo/key-manager": "^1.1.0", "base-58": "^0.0.1", "debug": "^4.1.1", - "did-jwt": "4.8.1", - "elliptic": "^6.5.2", + "did-jwt": "5.1.2", + "elliptic": "6.5.4", "ethjs-signer": "^0.1.1", "libsodium-wrappers": "^0.7.6" }, diff --git a/packages/kms-local/src/key-management-system.ts b/packages/kms-local/src/key-management-system.ts index a4f821d491..1ccbdfb489 100644 --- a/packages/kms-local/src/key-management-system.ts +++ b/packages/kms-local/src/key-management-system.ts @@ -1,7 +1,7 @@ -import { TKeyType, IKey, EcdsaSignature } from '@veramo/core' +import { TKeyType, IKey } from '@veramo/core' import { AbstractKeyManagementSystem } from '@veramo/key-manager' import sodium from 'libsodium-wrappers' -import { NaclSigner, SimpleSigner } from 'did-jwt' +import { EdDSASigner, ES256KSigner } from 'did-jwt' const EC = require('elliptic').ec const secp256k1 = new EC('secp256k1') import { DIDComm } from './didcomm' @@ -72,19 +72,15 @@ export class KeyManagementSystem extends AbstractKeyManagementSystem { return sign(transaction, '0x' + key.privateKeyHex) } - async signJWT({ key, data }: { key: IKey; data: string }): Promise { + async signJWT({ key, data }: { key: IKey; data: string | Uint8Array }): Promise { if (!key.privateKeyHex) throw Error('No private key for kid: ' + key.kid) if (key.type === 'Ed25519') { - const b64Key = sodium.to_base64( - Uint8Array.from(Buffer.from(key.privateKeyHex, 'hex')), - sodium.base64_variants.ORIGINAL, - ) - const signer = NaclSigner(b64Key) + const signer = EdDSASigner(key.privateKeyHex) return (signer(data) as any) as string } else if (key.type === 'Secp256k1') { - const signer = SimpleSigner(key.privateKeyHex) - return (signer(data) as any) as EcdsaSignature + const signer = ES256KSigner(key.privateKeyHex) + return (signer(data) as any) as string } else { throw Error('Cannot sign JWT with key of type ' + key.type) } diff --git a/packages/remote-server/src/web-did-doc-router.ts b/packages/remote-server/src/web-did-doc-router.ts index dcd652781a..ae2bf69f28 100644 --- a/packages/remote-server/src/web-did-doc-router.ts +++ b/packages/remote-server/src/web-did-doc-router.ts @@ -1,4 +1,4 @@ -import { IAgent, IIdentifier, IDIDManager, TAgent } from '@veramo/core' +import { IIdentifier, IDIDManager, TAgent } from '@veramo/core' import { Request, Router } from 'express' interface RequestWithAgentDIDManager extends Request { @@ -20,19 +20,13 @@ export const WebDidDocRouter = (): Router => { const didDoc = { '@context': 'https://w3id.org/did/v1', id: identifier.did, - publicKey: identifier.keys.map((key) => ({ + verificationMethod: identifier.keys.map((key) => ({ id: identifier.did + '#' + key.kid, - type: key.type === 'Secp256k1' ? 'Secp256k1VerificationKey2018' : 'Ed25519VerificationKey2018', + type: key.type === 'Secp256k1' ? 'EcdsaSecp256k1VerificationKey2019' : 'Ed25519VerificationKey2018', controller: identifier.did, publicKeyHex: key.publicKeyHex, })), - authentication: identifier.keys.map((key) => ({ - type: - key.type === 'Secp256k1' - ? 'Secp256k1SignatureAuthentication2018' - : 'Ed25519SignatureAuthentication2018', - publicKey: identifier.did + '#' + key.kid, - })), + authentication: identifier.keys.map((key) => `${identifier.did}#${key.kid}`), service: identifier.services, } diff --git a/packages/selective-disclosure/package.json b/packages/selective-disclosure/package.json index 700b57a8e9..3d01d3d6a3 100644 --- a/packages/selective-disclosure/package.json +++ b/packages/selective-disclosure/package.json @@ -21,7 +21,7 @@ "@veramo/message-handler": "^1.1.0", "blakejs": "^1.1.0", "debug": "^4.1.1", - "did-jwt": "4.8.1" + "did-jwt": "5.1.2" }, "devDependencies": { "@types/debug": "4.1.5", diff --git a/packages/selective-disclosure/src/action-handler.ts b/packages/selective-disclosure/src/action-handler.ts index 8dd0bd58cc..9e78bcb22f 100644 --- a/packages/selective-disclosure/src/action-handler.ts +++ b/packages/selective-disclosure/src/action-handler.ts @@ -4,7 +4,6 @@ import { IKeyManager, IAgentPlugin, VerifiablePresentation, - VerifiableCredential, } from '@veramo/core' import { IDataStoreORM, TClaimsColumns, FindArgs } from '@veramo/data-store' import { ICredentialIssuer } from '@veramo/credential-w3c' @@ -68,7 +67,7 @@ export class SelectiveDisclosure implements IAgentPlugin { const key = identifier.keys.find((k) => k.type === 'Secp256k1') if (!key) throw Error('Signing key not found') - const signer = (data: string) => context.agent.keyManagerSignJWT({ kid: key.kid, data }) + const signer = (data: string | Uint8Array) => context.agent.keyManagerSignJWT({ kid: key.kid, data }) const jwt = await createJWT( { type: 'sdr', @@ -76,7 +75,7 @@ export class SelectiveDisclosure implements IAgentPlugin { }, { signer, - alg: 'ES256K-R', + alg: 'ES256K', issuer: identifier.did, }, ) diff --git a/packages/selective-disclosure/src/message-handler.ts b/packages/selective-disclosure/src/message-handler.ts index 792ecbe453..c50e2f1dec 100644 --- a/packages/selective-disclosure/src/message-handler.ts +++ b/packages/selective-disclosure/src/message-handler.ts @@ -26,12 +26,10 @@ export class SdrMessageHandler extends AbstractMessageHandler { const meta = message.getLastMetaData() if ( - meta?.type === 'JWT' && - meta?.value === 'ES256K-R' && message.data.type == MessageTypes.sdr && message.data.claims ) { - debug('JWT type is', MessageTypes.sdr) + debug('Message type is', MessageTypes.sdr) message.id = blake2bHex(message.raw) message.type = MessageTypes.sdr diff --git a/yarn.lock b/yarn.lock index f5487ceae6..af73ae2311 100644 --- a/yarn.lock +++ b/yarn.lock @@ -423,6 +423,245 @@ dependencies: chalk "^4.0.0" +"@ethersproject/abi@^5.0.10", "@ethersproject/abi@^5.0.13": + version "5.0.13" + resolved "https://registry.yarnpkg.com/@ethersproject/abi/-/abi-5.0.13.tgz#600a559c3730467716595658beaa2894b4352bcc" + integrity sha512-2coOH3D7ra1lwamKEH0HVc+Jbcsw5yfeCgmY8ekhCDualEiyyovD2qDcMBBcY3+kjoLHVTmo7ost6MNClxdOrg== + dependencies: + "@ethersproject/address" "^5.0.9" + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/constants" "^5.0.8" + "@ethersproject/hash" "^5.0.10" + "@ethersproject/keccak256" "^5.0.7" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/strings" "^5.0.8" + +"@ethersproject/abstract-provider@^5.0.8": + version "5.0.10" + resolved "https://registry.yarnpkg.com/@ethersproject/abstract-provider/-/abstract-provider-5.0.10.tgz#a533aed39a5f27312745c8c4c40fa25fc884831c" + integrity sha512-OSReY5iz94iIaPlRvLiJP8YVIvQLx4aUvMMnHWSaA/vTU8QHZmgNlt4OBdYV1+aFY8Xl+VRYiWBHq72ZDKXXCQ== + dependencies: + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/networks" "^5.0.7" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/transactions" "^5.0.9" + "@ethersproject/web" "^5.0.12" + +"@ethersproject/abstract-signer@^5.0.10", "@ethersproject/abstract-signer@^5.0.14": + version "5.0.14" + resolved "https://registry.yarnpkg.com/@ethersproject/abstract-signer/-/abstract-signer-5.0.14.tgz#30ef912b0f86599d90fdffc65c110452e7b55cf1" + integrity sha512-JztBwVO7o5OHLh2vyjordlS4/1EjRyaECtc8vPdXTF1i4dXN+J0coeRoPN6ZFbBvi/YbaB6br2fvqhst1VQD/g== + dependencies: + "@ethersproject/abstract-provider" "^5.0.8" + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + +"@ethersproject/address@^5.0.11", "@ethersproject/address@^5.0.9": + version "5.0.11" + resolved "https://registry.yarnpkg.com/@ethersproject/address/-/address-5.0.11.tgz#12022e8c590c33939beb5ab18b401ecf585eac59" + integrity sha512-Et4GBdD8/tsBGjCEOKee9upN29qjL5kbRcmJifb4Penmiuh9GARXL2/xpXvEp5EW+EIW/rfCHFJrkYBgoQFQBw== + dependencies: + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/keccak256" "^5.0.7" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/rlp" "^5.0.7" + +"@ethersproject/base64@^5.0.7": + version "5.0.9" + resolved "https://registry.yarnpkg.com/@ethersproject/base64/-/base64-5.0.9.tgz#bb1f35d3dba92082a574d5e2418f9202a0a1a7e6" + integrity sha512-37RBz5LEZ9SlTNGiWCYFttnIN9J7qVs9Xo2EbqGqDH5LfW9EIji66S+YDMpXVo1zWDax1FkEldAoatxHK2gfgA== + dependencies: + "@ethersproject/bytes" "^5.0.9" + +"@ethersproject/basex@^5.0.7", "@ethersproject/basex@^5.0.9": + version "5.0.9" + resolved "https://registry.yarnpkg.com/@ethersproject/basex/-/basex-5.0.9.tgz#00d727a031bac563cb8bb900955206f1bf3cf1fc" + integrity sha512-FANswl1IN3PS0eltQxH2aM2+utPrkLUVG4XVFi6SafRG9EpAqXCgycxC8PU90mPGhigYTpg9cnTB5mCZ6ejQjw== + dependencies: + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/properties" "^5.0.7" + +"@ethersproject/bignumber@^5.0.13", "@ethersproject/bignumber@^5.0.15": + version "5.0.15" + resolved "https://registry.yarnpkg.com/@ethersproject/bignumber/-/bignumber-5.0.15.tgz#b089b3f1e0381338d764ac1c10512f0c93b184ed" + integrity sha512-MTADqnyacvdRwtKh7o9ujwNDSM1SDJjYDMYAzjIgjoi9rh6TY4suMbhCa3i2vh3SUXiXSICyTI8ui+NPdrZ9Lw== + dependencies: + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + bn.js "^4.4.0" + +"@ethersproject/bytes@^5.0.9": + version "5.0.11" + resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.0.11.tgz#21118e75b1d00db068984c15530e316021101276" + integrity sha512-D51plLYY5qF05AsoVQwIZVLqlBkaTPVHVP/1WmmBIWyHB0cRW0C9kh0kx5Exo51rB63Hk8PfHxc7SmpoaQFEyg== + dependencies: + "@ethersproject/logger" "^5.0.8" + +"@ethersproject/constants@^5.0.8": + version "5.0.10" + resolved "https://registry.yarnpkg.com/@ethersproject/constants/-/constants-5.0.10.tgz#eb0c604fbc44c53ba9641eed31a1d0c9e1ebcadc" + integrity sha512-OSo8jxkHLDXieCy8bgOFR7lMfgPxEzKvSDdP+WAWHCDM8+orwch0B6wzkTmiQFgryAtIctrBt5glAdJikZ3hGw== + dependencies: + "@ethersproject/bignumber" "^5.0.13" + +"@ethersproject/contracts@^5.0.12": + version "5.0.12" + resolved "https://registry.yarnpkg.com/@ethersproject/contracts/-/contracts-5.0.12.tgz#6d488db46221258399dfe80b89bf849b3afd7897" + integrity sha512-srijy31idjz8bE+gL1I6IRj2H4I9dUwfQ+QroLrIgNdGArqY8y2iFUKa3QTy+JBX26fJsdYiCQi1kKkaNpnMpQ== + dependencies: + "@ethersproject/abi" "^5.0.10" + "@ethersproject/abstract-provider" "^5.0.8" + "@ethersproject/abstract-signer" "^5.0.10" + "@ethersproject/address" "^5.0.9" + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/constants" "^5.0.8" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + +"@ethersproject/hash@^5.0.10": + version "5.0.12" + resolved "https://registry.yarnpkg.com/@ethersproject/hash/-/hash-5.0.12.tgz#1074599f7509e2ca2bb7a3d4f4e39ab3a796da42" + integrity sha512-kn4QN+fhNFbUgX3XZTZUaQixi0oyfIEY+hfW+KtkHu+rq7dV76oAIvaLEEynu1/4npOL38E4X4YI42gGZk+C0Q== + dependencies: + "@ethersproject/abstract-signer" "^5.0.10" + "@ethersproject/address" "^5.0.9" + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/keccak256" "^5.0.7" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/strings" "^5.0.8" + +"@ethersproject/keccak256@^5.0.7": + version "5.0.9" + resolved "https://registry.yarnpkg.com/@ethersproject/keccak256/-/keccak256-5.0.9.tgz#ca0d86e4af56c13b1ef25e533bde3e96d28f647d" + integrity sha512-zhdUTj6RGtCJSgU+bDrWF6cGbvW453LoIC1DSNWrTlXzC7WuH4a+EiPrgc7/kNoRxerKuA/cxYlI8GwNtVtDlw== + dependencies: + "@ethersproject/bytes" "^5.0.9" + js-sha3 "0.5.7" + +"@ethersproject/logger@^5.0.8": + version "5.0.10" + resolved "https://registry.yarnpkg.com/@ethersproject/logger/-/logger-5.0.10.tgz#fd884688b3143253e0356ef92d5f22d109d2e026" + integrity sha512-0y2T2NqykDrbPM3Zw9RSbPkDOxwChAL8detXaom76CfYoGxsOnRP/zTX8OUAV+x9LdwzgbWvWmeXrc0M7SuDZw== + +"@ethersproject/networks@^5.0.7": + version "5.0.9" + resolved "https://registry.yarnpkg.com/@ethersproject/networks/-/networks-5.0.9.tgz#ec5da11e4d4bfd69bec4eaebc9ace33eb9569279" + integrity sha512-L8+VCQwArBLGkxZb/5Ns/OH/OxP38AcaveXIxhUTq+VWpXYjrObG3E7RDQIKkUx1S1IcQl/UWTz5w4DK0UitJg== + dependencies: + "@ethersproject/logger" "^5.0.8" + +"@ethersproject/properties@^5.0.7": + version "5.0.9" + resolved "https://registry.yarnpkg.com/@ethersproject/properties/-/properties-5.0.9.tgz#d7aae634680760136ea522e25c3ef043ec15b5c2" + integrity sha512-ZCjzbHYTw+rF1Pn8FDCEmx3gQttwIHcm/6Xee8g/M3Ga3SfW4tccNMbs5zqnBH0E4RoOPaeNgyg1O68TaF0tlg== + dependencies: + "@ethersproject/logger" "^5.0.8" + +"@ethersproject/providers@^5.0.24": + version "5.0.24" + resolved "https://registry.yarnpkg.com/@ethersproject/providers/-/providers-5.0.24.tgz#4c638a029482d052faa18364b5e0e2d3ddd9c0cb" + integrity sha512-M4Iw1r4gGJkt7ZUa++iREuviKL/DIpmIMsaUlVlXtV+ZrUXeN8xQ3zOTrbz7R4h9W9oljBZM7i4D3Kn1krJ30A== + dependencies: + "@ethersproject/abstract-provider" "^5.0.8" + "@ethersproject/abstract-signer" "^5.0.10" + "@ethersproject/address" "^5.0.9" + "@ethersproject/basex" "^5.0.7" + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/constants" "^5.0.8" + "@ethersproject/hash" "^5.0.10" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/networks" "^5.0.7" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/random" "^5.0.7" + "@ethersproject/rlp" "^5.0.7" + "@ethersproject/sha2" "^5.0.7" + "@ethersproject/strings" "^5.0.8" + "@ethersproject/transactions" "^5.0.9" + "@ethersproject/web" "^5.0.12" + bech32 "1.1.4" + ws "7.2.3" + +"@ethersproject/random@^5.0.7": + version "5.0.9" + resolved "https://registry.yarnpkg.com/@ethersproject/random/-/random-5.0.9.tgz#1903d4436ba66e4c8ac77968b16f756abea3a0d0" + integrity sha512-DANG8THsKqFbJOantrxumtG6gyETNE54VfbsWa+SQAT8WKpDo9W/X5Zhh73KuhClaey1UI32uVmISZeq/Zxn1A== + dependencies: + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + +"@ethersproject/rlp@^5.0.7": + version "5.0.9" + resolved "https://registry.yarnpkg.com/@ethersproject/rlp/-/rlp-5.0.9.tgz#da205bf8a34d3c3409eb73ddd237130a4b376aff" + integrity sha512-ns1U7ZMVeruUW6JXc4om+1w3w4ynHN/0fpwmeNTsAjwGKoF8SAUgue6ylKpHKWSti2idx7jDxbn8hNNFHk67CA== + dependencies: + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + +"@ethersproject/sha2@^5.0.7": + version "5.0.9" + resolved "https://registry.yarnpkg.com/@ethersproject/sha2/-/sha2-5.0.9.tgz#41275ee03e6e1660b3c997754005e089e936adc6" + integrity sha512-5FH4s47gM7N1fFAYQ1+m7aX0SbLg0Xr+6tvqndmNqc382/qBIbzXiGlUookrsjlPb6gLNurnTssCXjNM72J6lQ== + dependencies: + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + hash.js "1.1.3" + +"@ethersproject/signing-key@^5.0.8": + version "5.0.11" + resolved "https://registry.yarnpkg.com/@ethersproject/signing-key/-/signing-key-5.0.11.tgz#19fc5c4597e18ad0a5efc6417ba5b74069fdd2af" + integrity sha512-Jfcru/BGwdkXhLxT+8WCZtFy7LL0TPFZw05FAb5asxB/MyVsEfNdNxGDtjVE9zXfmRSPe/EusXYY4K7wcygOyQ== + dependencies: + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + elliptic "6.5.4" + +"@ethersproject/strings@^5.0.8": + version "5.0.10" + resolved "https://registry.yarnpkg.com/@ethersproject/strings/-/strings-5.0.10.tgz#ddce1e9724f4ac4f3f67e0cac0b48748e964bfdb" + integrity sha512-KAeoS1tZ9/5ECXiIZA6S6hywbD0so2VmuW+Wfyo5EDXeyZ6Na1nxTPhTnW7voQmjbeYJffCrOc0qLFJeylyg7w== + dependencies: + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/constants" "^5.0.8" + "@ethersproject/logger" "^5.0.8" + +"@ethersproject/transactions@^5.0.11", "@ethersproject/transactions@^5.0.9": + version "5.0.11" + resolved "https://registry.yarnpkg.com/@ethersproject/transactions/-/transactions-5.0.11.tgz#b31df5292f47937136a45885d6ee6112477c13df" + integrity sha512-ftsRvR9+gQp7L63F6+XmstvsZ4w8GtWvQB08e/zB+oB86Fnhq8+i/tkgpJplSHC8I/qgiCisva+M3u2GVhDFPA== + dependencies: + "@ethersproject/address" "^5.0.9" + "@ethersproject/bignumber" "^5.0.13" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/constants" "^5.0.8" + "@ethersproject/keccak256" "^5.0.7" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/rlp" "^5.0.7" + "@ethersproject/signing-key" "^5.0.8" + +"@ethersproject/web@^5.0.12": + version "5.0.14" + resolved "https://registry.yarnpkg.com/@ethersproject/web/-/web-5.0.14.tgz#6e7bebdd9fb967cb25ee60f44d9218dc0803bac4" + integrity sha512-QpTgplslwZ0Sp9oKNLoRuS6TKxnkwfaEk3gr7zd7XLF8XBsYejsrQO/03fNfnMx/TAT/RR6WEw/mbOwpRSeVRA== + dependencies: + "@ethersproject/base64" "^5.0.7" + "@ethersproject/bytes" "^5.0.9" + "@ethersproject/logger" "^5.0.8" + "@ethersproject/properties" "^5.0.7" + "@ethersproject/strings" "^5.0.8" + "@evocateur/libnpmaccess@^3.1.2": version "3.1.2" resolved "https://registry.yarnpkg.com/@evocateur/libnpmaccess/-/libnpmaccess-3.1.2.tgz#ecf7f6ce6b004e9f942b098d92200be4a4b1c845" @@ -2296,6 +2535,11 @@ mkdirp-promise "^5.0.1" mz "^2.5.0" +"@zxing/text-encoding@0.9.0": + version "0.9.0" + resolved "https://registry.yarnpkg.com/@zxing/text-encoding/-/text-encoding-0.9.0.tgz#fb50ffabc6c7c66a0c96b4c03e3d9be74864b70b" + integrity sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA== + JSONStream@^1.0.4, JSONStream@^1.3.4, JSONStream@^1.3.5: version "1.3.5" resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0" @@ -2767,6 +3011,11 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" +bech32@1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" + integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ== + before-after-hook@^2.0.0, before-after-hook@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.1.0.tgz#b6c03487f44e24200dd30ca5e6a1979c5d2fb635" @@ -2819,6 +3068,11 @@ bn.js@4.11.6: resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.6.tgz#53344adb14617a13f6e8dd2ce28905d1c0ba3215" integrity sha1-UzRK2xRhehP26N0s4okF0cC6MhU= +bn.js@^4.11.9: + version "4.12.0" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" + integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== + bn.js@^4.4.0: version "4.11.9" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.9.tgz#26d556829458f9d1e81fc48952493d0ba3507828" @@ -2889,7 +3143,7 @@ braces@^3.0.1: dependencies: fill-range "^7.0.1" -brorand@^1.0.1: +brorand@^1.0.1, brorand@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" integrity sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8= @@ -2928,7 +3182,7 @@ buffer-writer@2.0.0: resolved "https://registry.yarnpkg.com/buffer-writer/-/buffer-writer-2.0.0.tgz#ce7eb81a38f7829db09c873f2fbb792c0c98ec04" integrity sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw== -buffer@^5.1.0, buffer@^5.5.0: +buffer@^5.5.0: version "5.7.1" resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== @@ -3736,6 +3990,13 @@ cross-fetch@3.0.6, cross-fetch@^3.0.4, cross-fetch@^3.0.5, cross-fetch@^3.0.6: dependencies: node-fetch "2.6.1" +cross-fetch@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.2.tgz#ee0c2f18844c4fde36150c2a4ddc068d20c1bc41" + integrity sha512-+JhD65rDNqLbGmB3Gzs3HrEKC0aQnD+XA3SY6RjgkF88jV2q5cTc5+CwxlS3sdmLk98gpPt5CF9XRnPdlxZe6w== + dependencies: + node-fetch "2.6.1" + cross-spawn@^5.0.1: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" @@ -4034,30 +4295,30 @@ dezalgo@^1.0.0, dezalgo@~1.0.3: asap "^2.0.0" wrappy "1" -did-jwt-vc@^1.0.3: - version "1.0.6" - resolved "https://registry.yarnpkg.com/did-jwt-vc/-/did-jwt-vc-1.0.6.tgz#92a86ff2ce20e8aeb6e7ec044c75ae89c82f37b1" - integrity sha512-k0pYUfT9ivn8yBBayuSeHm0tRG7pRGRnYwrCSVWciFcxnfQK94QUoax9g7HQtvgyxqAWP0DQUTDK75zp1/wZ0g== +did-jwt-vc@2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/did-jwt-vc/-/did-jwt-vc-2.0.2.tgz#5a26213359bcae679371eb0c7a1d2e662adf9602" + integrity sha512-4+iZ6DYMAJVqZdWvBGjRMQRat1OnlBrADG9GBD9Rqh4FrgUNTBIaB3UD2Iogkx0xZTKsD4XM9ugRQIWUfXJWEg== dependencies: - did-jwt "^4.4.2" + did-jwt "^5.1.2" + did-resolver "^3.1.0" -did-jwt@4.8.1: - version "4.8.1" - resolved "https://registry.yarnpkg.com/did-jwt/-/did-jwt-4.8.1.tgz#fae7d680c6d12c13cdce92530540d9f4b5d007f0" - integrity sha512-TRfk6He4MSUe3mN+YBqX4wC8N4ns3jan0Ckwal6fPsexKYRwo20ns8w0IGt7J4oHOF3IxXNAkH07OBdEpMnEdA== +did-jwt@5.1.2, did-jwt@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/did-jwt/-/did-jwt-5.1.2.tgz#a71519ef5a9bd88e6174550e918a1e48e42d3c37" + integrity sha512-7FayCI0qLsWXgCvquoeh764W/waXC0ryfSMtjROIc7DKKUFAnOAy7MmOKD0XjdHVjjjZeXnXe8FFHNTK5vBMaQ== dependencies: - "@babel/runtime" "^7.11.2" "@stablelib/ed25519" "^1.0.1" "@stablelib/random" "^1.0.0" "@stablelib/sha256" "^1.0.0" "@stablelib/x25519" "^1.0.0" "@stablelib/xchacha20poly1305" "^1.0.0" - did-resolver "^2.1.2" - elliptic "^6.5.3" + did-resolver "^3.1.0" + elliptic "^6.5.4" js-sha3 "^0.8.0" - uint8arrays "^2.0.0" + uint8arrays "^2.1.3" -did-jwt@^4.4.2, did-jwt@^4.8.0: +did-jwt@^4.8.0: version "4.8.0" resolved "https://registry.yarnpkg.com/did-jwt/-/did-jwt-4.8.0.tgz#b5d7727d264be52f5d576c6da38bee2cdc282199" integrity sha512-7Vwv+E6st0lETniq8ygr3BFv0Af7YOATw31aIiHP3TxIJf79DHLeplI5aHQI36leh7S+cusdWlNxTxTdAPr9/A== @@ -4073,16 +4334,16 @@ did-jwt@^4.4.2, did-jwt@^4.8.0: js-sha3 "^0.8.0" uint8arrays "^1.1.0" -did-resolver@2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/did-resolver/-/did-resolver-2.1.1.tgz#43796f8a3e921644e5fb15a8147684ca87019cfd" - integrity sha512-FYLTkNWofjYNDGV1HTQlyVu1OqZiFxR4I8KM+oxGVOkbXva15NfWzbzciqdXUDqOhe6so5aroAdrVip6gSAYSA== - did-resolver@2.1.2, did-resolver@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/did-resolver/-/did-resolver-2.1.2.tgz#f1194fdbc087161809ce545e13c11a596f4a3928" integrity sha512-n4YGS1CzbX48U/ChLRY3SdgiV5N3B/+yh0ToS5t+Sx4QjhVZN6ZyijUSSYbFGvz+I4qImeSZOdo6RX8JaieN7A== +did-resolver@3.1.0, did-resolver@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/did-resolver/-/did-resolver-3.1.0.tgz#84f0e3d16abe9711dc04c34a5a0e2f63868c9611" + integrity sha512-uf3/4LfHoDn3Ek8bFegO72OemHMytBhAkud6CA1HlB5I0iVwrCpG4oh+DA6DXUuBdhrA0cY4cGz1D0VNDTlgnw== + diff-sequences@^26.6.2: version "26.6.2" resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-26.6.2.tgz#48ba99157de1923412eed41db6b6d4aa9ca7c0b1" @@ -4193,7 +4454,20 @@ elliptic@6.3.2: hash.js "^1.0.0" inherits "^2.0.1" -elliptic@^6.5.2, elliptic@^6.5.3: +elliptic@6.5.4, elliptic@^6.5.4: + version "6.5.4" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" + integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== + dependencies: + bn.js "^4.11.9" + brorand "^1.1.0" + hash.js "^1.0.0" + hmac-drbg "^1.0.1" + inherits "^2.0.4" + minimalistic-assert "^1.0.1" + minimalistic-crypto-utils "^1.0.1" + +elliptic@^6.5.3: version "6.5.3" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.3.tgz#cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6" integrity sha512-IMqzv5wNQf+E6aHeIqATs0tOLeOTwj1QKbRcS3jBbYkl5oLAserA8yJTT7/VyHUYG91PRmPyeQDObKLPpeS4dw== @@ -4499,7 +4773,23 @@ ethr-did-registry@0.0.3, ethr-did-registry@^0.0.3: resolved "https://registry.yarnpkg.com/ethr-did-registry/-/ethr-did-registry-0.0.3.tgz#f363d2c73cb9572b57bd7a5c9c90c88485feceb5" integrity sha512-4BPvMGkxAK9vTduCq6D5b8ZqjteD2cvDIPPriXP6nnmPhWKFSxypo+AFvyQ0omJGa0cGTR+dkdI/8jiF7U/qaw== -ethr-did-resolver@3.0.3, ethr-did-resolver@^3.0.3: +ethr-did-resolver@4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/ethr-did-resolver/-/ethr-did-resolver-4.0.1.tgz#d500f33fef8effbc704ba3c2452fac5aa434c395" + integrity sha512-/a1WgU1OZBChSYKI/wVaYfwkwG7UDUqqKxZDSYoRkfpPb3xWTJ0HHmhTjJsi2ocVIiqGONns5TKHgfRga7Eyog== + dependencies: + "@ethersproject/abi" "^5.0.13" + "@ethersproject/abstract-signer" "^5.0.14" + "@ethersproject/address" "^5.0.11" + "@ethersproject/basex" "^5.0.9" + "@ethersproject/bignumber" "^5.0.15" + "@ethersproject/contracts" "^5.0.12" + "@ethersproject/providers" "^5.0.24" + "@ethersproject/transactions" "^5.0.11" + did-resolver "^3.1.0" + ethr-did-registry "^0.0.3" + +ethr-did-resolver@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/ethr-did-resolver/-/ethr-did-resolver-3.0.3.tgz#71a7ca6f7e550efae0b6b1c42e6722f538482e8a" integrity sha512-bqpA8Cs4701v0ag4w9cksdNTaCwDItNmNuHwfKgZkDhnPOEJfxvhQO75kr0RiCxM6cr9URiD9/6+FQ53+tSbvw== @@ -4514,21 +4804,6 @@ ethr-did-resolver@3.0.3, ethr-did-resolver@^3.0.3: ethr-did-registry "^0.0.3" js-sha3 "^0.8.0" -ethr-did-resolver@^3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/ethr-did-resolver/-/ethr-did-resolver-3.0.2.tgz#9fd39f73d7ecf62781cd8eec0b2397f8ad68981d" - integrity sha512-dCsK5RWhnpDuV0TM8VL9LxY+RxdN9LxTud2sdaY4oT9WULP74uO/pQO8eWn9IQFz2c796ckzaKwDbeaOo+sogw== - dependencies: - buffer "^5.1.0" - did-resolver "2.1.2" - elliptic "^6.5.3" - ethjs-abi "^0.2.1" - ethjs-contract "^0.2.0" - ethjs-provider-http "^0.1.6" - ethjs-query "^0.3.5" - ethr-did-registry "^0.0.3" - js-sha3 "^0.8.0" - ethr-did@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/ethr-did/-/ethr-did-1.3.0.tgz#84d3c7c9551d7fb8fa3c966ac7bc5dd40cb255e8" @@ -5464,6 +5739,14 @@ has@^1.0.3: dependencies: function-bind "^1.1.1" +hash.js@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.3.tgz#340dedbe6290187151c1ea1d777a3448935df846" + integrity sha512-/UETyP0W22QILqS+6HowevwhEFJ3MBJnwTf75Qob9Wz9t0DPuisL8kW8YZMK62dHAKE1c1p+gY1TtOLY+USEHA== + dependencies: + inherits "^2.0.3" + minimalistic-assert "^1.0.0" + hash.js@^1.0.0, hash.js@^1.0.3: version "1.1.7" resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" @@ -5477,7 +5760,7 @@ highlight.js@^10.0.0: resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-10.4.1.tgz#d48fbcf4a9971c4361b3f95f302747afe19dbad0" integrity sha512-yR5lWvNz7c85OhVAEAeFhVCc/GV4C30Fjzc/rCP0aCWzc1UUOPUk55dK/qdwTZHBvMZo+eZ2jpk62ndX/xMFlg== -hmac-drbg@^1.0.0: +hmac-drbg@^1.0.0, hmac-drbg@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" integrity sha1-0nRXAQJabHdabFRXk+1QL8DGSaE= @@ -5627,10 +5910,10 @@ humanize-ms@^1.2.1: dependencies: ms "^2.0.0" -husky@5.0.9: - version "5.0.9" - resolved "https://registry.yarnpkg.com/husky/-/husky-5.0.9.tgz#6d38706643d66ed395bcd4ee952d02e3f15eb3a3" - integrity sha512-0SjcaY21a+IRdx7p7r/X33Vc09UR2m8SbP8yfkhUX2/jAmwcz+GR7i9jXkp2pP3GfX23JhMkVP6SWwXB18uXtg== +husky@5.1.3: + version "5.1.3" + resolved "https://registry.yarnpkg.com/husky/-/husky-5.1.3.tgz#1a0645a4fe3ffc006c4d0d8bd0bcb4c98787cc9d" + integrity sha512-fbNJ+Gz5wx2LIBtMweJNY1D7Uc8p1XERi5KNRMccwfQA+rXlxWNSdUxswo0gT8XqxywTIw7Ywm/F4v/O35RdMg== iconv-lite@0.4.24, iconv-lite@^0.4.24, iconv-lite@^0.4.4: version "0.4.24" @@ -6674,6 +6957,11 @@ js-sha3@0.5.5: resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.5.5.tgz#baf0c0e8c54ad5903447df96ade7a4a1bca79a4a" integrity sha1-uvDA6MVK1ZA0R9+Wreekobynmko= +js-sha3@0.5.7: + version "0.5.7" + resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.5.7.tgz#0d4ffd8002d5333aabaf4a23eed2f6374c9f28e7" + integrity sha1-DU/9gALVMzqrr0oj7tL2N0yfKOc= + js-sha3@^0.8.0: version "0.8.0" resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" @@ -7810,6 +8098,14 @@ multibase@^3.1.1: "@multiformats/base-x" "^4.0.1" web-encoding "^1.0.6" +multibase@^4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/multibase/-/multibase-4.0.2.tgz#8250a0f50d0ed49765146bf0e3431e3df9b249ac" + integrity sha512-l0XMK4O5I9cCfxC0/UMDX/UxlIlrqkjEZQNG+ZUUrsGhnXWgFXgatYOQSONiR/lQGfBO463UyZkh3SiQBpjRIQ== + dependencies: + "@multiformats/base-x" "^4.0.1" + web-encoding "^1.1.0" + multicodec@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/multicodec/-/multicodec-2.1.0.tgz#b66dff2184e91e74ac68981e0deba2591bbf1f87" @@ -11084,13 +11380,13 @@ uint8arrays@1.1.0, uint8arrays@^1.1.0: multibase "^3.0.0" web-encoding "^1.0.2" -uint8arrays@^2.0.0: - version "2.0.5" - resolved "https://registry.yarnpkg.com/uint8arrays/-/uint8arrays-2.0.5.tgz#763d0c3dd8e1d05b656d2e60c8a9a53096a47d9e" - integrity sha512-1HSktgwqtYIwVn1mg3GcnqKhHH9oC4kVgdD/43cxMWwhP8rihKcFPmToDzS1XtbvVvlR8XxTk/DUBf0C83qNIg== +uint8arrays@^2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/uint8arrays/-/uint8arrays-2.1.3.tgz#6e09ed40687042ed7b0047b498c0e876efe5a49a" + integrity sha512-2h2Z2OIqzrhHmZTv9ViJVyZZreFkHRHeihh7SxLVY/nLUVJhU4ey/u74tWsgMR6hhMSO2g5rhKmdLQIg3lKiUQ== dependencies: - multibase "^3.0.0" - web-encoding "^1.0.5" + multibase "^4.0.1" + web-encoding "^1.1.0" umask@^1.1.0, umask@~1.1.0: version "1.1.0" @@ -11356,24 +11652,31 @@ wcwidth@^1.0.0: dependencies: defaults "^1.0.3" -web-did-resolver@1.3.5, web-did-resolver@^1.3.5: - version "1.3.5" - resolved "https://registry.yarnpkg.com/web-did-resolver/-/web-did-resolver-1.3.5.tgz#1240a94530fa5194827856b8ff7957d00d11a7d7" - integrity sha512-k+32CvrguvAwgvppYH0geMsmKJL1akuyWa3p5ArVON5swYvMb72e1yayM7XuPMwUW/6aZ2Z0HL14QkfvcIJRQw== +web-did-resolver@2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/web-did-resolver/-/web-did-resolver-2.0.4.tgz#5a26cc96b1c6924191687ecc8cdb2ce5ef66805b" + integrity sha512-PORpoA4P0I3m0cLJX2IIDZ0gMKgC1PjS8DuDeg9/JCdIlFiXrZCyTG1hxvw4a4vhDKr0sZKSZL1pQDXTgqLm8w== dependencies: - cross-fetch "^3.0.4" - did-resolver "2.1.1" + cross-fetch "^3.1.2" + did-resolver "^3.1.0" web-encoding@^1.0.2, web-encoding@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/web-encoding/-/web-encoding-1.0.4.tgz#0398d39ce2cbef5ed2617080750ed874e6153aea" integrity sha512-DcXs2lbVPzuJmn2kuDEwul2oZg7p4YMa5J2f0YzsOBHaAnBYGPNUB/rJ74DTjTKpw7F0+lSsVM8sFHE2UyBixg== -web-encoding@^1.0.5, web-encoding@^1.0.6: +web-encoding@^1.0.6: version "1.0.6" resolved "https://registry.yarnpkg.com/web-encoding/-/web-encoding-1.0.6.tgz#ec631356ee523b4474ecbcae680440bd1e79416a" integrity sha512-26wEnRPEFAc5d5lmH1Q/DuvWEYsRF1D2alX2jlKpdmqv7cj+BbANL7Xlcl9r4s72Eg9kItZa9RWVbBMC9dMv4w== +web-encoding@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/web-encoding/-/web-encoding-1.1.0.tgz#b8ed50f0e23ba239542ba11ebe885b75a0b95bea" + integrity sha512-KzYonGdJnZB3qvhK8hKca5qXk/wp+hgwGNTY1TnqtF2CzDzpN8szOC3ejhX9+wbhCq3vQs/TjM8BykS1kor0lQ== + optionalDependencies: + "@zxing/text-encoding" "0.9.0" + webidl-conversions@^4.0.2: version "4.0.2" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" @@ -11567,6 +11870,11 @@ write-pkg@^3.1.0: sort-keys "^2.0.0" write-json-file "^2.2.0" +ws@7.2.3: + version "7.2.3" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.2.3.tgz#a5411e1fb04d5ed0efee76d26d5c46d830c39b46" + integrity sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ== + ws@^7.2.0, ws@^7.2.3: version "7.4.1" resolved "https://registry.yarnpkg.com/ws/-/ws-7.4.1.tgz#a333be02696bd0e54cea0434e21dcc8a9ac294bb"