@veramo/credential-ld 6.0.3-next.59 → 6.0.3-next.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/CredentialProviderLD.d.ts +20 -19
- package/build/CredentialProviderLD.d.ts.map +1 -1
- package/build/CredentialProviderLD.js +46 -44
- package/build/CredentialProviderLD.js.map +1 -1
- package/package.json +5 -5
- package/src/CredentialProviderLD.ts +51 -55
- package/src/__tests__/issue-verify-ed25519-2020.test.ts +1 -1
- package/src/__tests__/issue-verify-flow-ld.test.ts +7 -3
|
@@ -1,42 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ICreateVerifiableCredentialArgs, ICreateVerifiablePresentationArgs, IKey, IssuerAgentContext, IVerifyCredentialArgs, IVerifyPresentationArgs, IVerifyResult, ProofFormat, VerifiableCredential, VerifiablePresentation, VerifierAgentContext } from '@veramo/core-types';
|
|
2
2
|
import { VeramoLdSignature } from './index.js';
|
|
3
3
|
import { OrPromise, RecordLike } from '@veramo/utils';
|
|
4
4
|
import { ContextDoc } from './types.js';
|
|
5
|
-
import {
|
|
5
|
+
import { ICredentialProvider, ProofFormatQuery, TentativeVerificationQuery } from '@veramo/credential-w3c';
|
|
6
6
|
/**
|
|
7
|
-
* A
|
|
7
|
+
* A Veramo Credential sub-plugin that implements
|
|
8
|
+
* a {@link @veramo/credential-w3c#ICredentialProvider | ICredentialProvider} with support for
|
|
9
|
+
* Verifiable Credentials and Presentations using JSON-LD proofs.
|
|
8
10
|
*
|
|
9
|
-
* @
|
|
11
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
12
|
+
* @see {@link https://www.w3.org/TR/vc-data-model-1.1/ | VC 1.1 data model}.
|
|
10
13
|
*/
|
|
11
|
-
export declare class CredentialProviderLD implements
|
|
14
|
+
export declare class CredentialProviderLD implements ICredentialProvider {
|
|
12
15
|
private ldCredentialModule;
|
|
13
16
|
constructor(options: {
|
|
14
17
|
contextMaps: RecordLike<OrPromise<ContextDoc>>[];
|
|
15
18
|
suites: VeramoLdSignature[];
|
|
16
19
|
});
|
|
17
|
-
/** {@inheritdoc @veramo/credential-w3c#
|
|
18
|
-
|
|
19
|
-
/** {@inheritdoc @veramo/credential-w3c#
|
|
20
|
-
|
|
21
|
-
/** {@inheritdoc @veramo/credential-w3c#
|
|
22
|
-
|
|
23
|
-
/** {@inheritdoc @veramo/credential-w3c#
|
|
24
|
-
canVerifyDocumentType(args: ICanVerifyDocumentTypeArgs): boolean;
|
|
25
|
-
/** {@inheritdoc ICredentialIssuer.createVerifiablePresentationLD} */
|
|
20
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.getProofFormatsSupportedForKey} */
|
|
21
|
+
getProofFormatsSupportedForKey(key: IKey): ProofFormat[];
|
|
22
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.canIssueCredentialType} */
|
|
23
|
+
canIssueProofFormat(query: ProofFormatQuery): boolean;
|
|
24
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.canVerifyDocumentType} */
|
|
25
|
+
canVerifyDocumentType(query: TentativeVerificationQuery): boolean;
|
|
26
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.createVerifiablePresentation} */
|
|
26
27
|
createVerifiablePresentation(args: ICreateVerifiablePresentationArgs, context: IssuerAgentContext): Promise<VerifiablePresentation>;
|
|
27
|
-
/** {@inheritdoc
|
|
28
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.createVerifiableCredential} */
|
|
28
29
|
createVerifiableCredential(args: ICreateVerifiableCredentialArgs, context: IssuerAgentContext): Promise<VerifiableCredential>;
|
|
29
|
-
/** {@inheritdoc
|
|
30
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.verifyCredential} */
|
|
30
31
|
verifyCredential(args: IVerifyCredentialArgs, context: VerifierAgentContext): Promise<IVerifyResult>;
|
|
31
|
-
/** {@inheritdoc
|
|
32
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.verifyPresentation} */
|
|
32
33
|
verifyPresentation(args: IVerifyPresentationArgs, context: VerifierAgentContext): Promise<IVerifyResult>;
|
|
33
|
-
private findSigningKeyWithId;
|
|
34
34
|
/**
|
|
35
35
|
* Returns true if the key is supported by any of the installed LD Signature suites
|
|
36
36
|
* @param k - the key to match
|
|
37
37
|
*
|
|
38
38
|
* @internal
|
|
39
39
|
*/
|
|
40
|
-
matchKeyForLDSuite
|
|
40
|
+
private matchKeyForLDSuite;
|
|
41
|
+
private findSigningKeyWithId;
|
|
41
42
|
}
|
|
42
43
|
//# sourceMappingURL=CredentialProviderLD.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialProviderLD.d.ts","sourceRoot":"","sources":["../src/CredentialProviderLD.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CredentialProviderLD.d.ts","sourceRoot":"","sources":["../src/CredentialProviderLD.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,+BAA+B,EAC/B,iCAAiC,EAEjC,IAAI,EAEJ,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,aAAa,EAGb,WAAW,EACX,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAG9C,OAAO,EAOL,SAAS,EAET,UAAU,EAEX,MAAM,eAAe,CAAA;AAItB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvC,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAA;AAI1G;;;;;;;GAOG;AACH,qBAAa,oBAAqB,YAAW,mBAAmB;IAC9D,OAAO,CAAC,kBAAkB,CAAoB;gBAElC,OAAO,EAAE;QAAE,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;QAAC,MAAM,EAAE,iBAAiB,EAAE,CAAA;KAAE;IAOtG,8FAA8F;IAC9F,8BAA8B,CAAC,GAAG,EAAE,IAAI,GAAG,WAAW,EAAE;IAOxD,sFAAsF;IACtF,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO;IAIrD,qFAAqF;IACrF,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,GAAG,OAAO;IAYjE,4FAA4F;IACtF,4BAA4B,CAChC,IAAI,EAAE,iCAAiC,EACvC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,sBAAsB,CAAC;IAmElC,0FAA0F;IACpF,0BAA0B,CAC9B,IAAI,EAAE,+BAA+B,EACrC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,oBAAoB,CAAC;IAkDhC,gFAAgF;IAC1E,gBAAgB,CAAC,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC;IAa1G,kFAAkF;IAC5E,kBAAkB,CACtB,IAAI,EAAE,uBAAuB,EAC7B,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,aAAa,CAAC;IAezB;;;;;OAKG;IACH,OAAO,CAAC,kBAAkB;YAkBZ,oBAAoB;CAqCnC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PROOF_FORMAT, } from '@veramo/core-types';
|
|
1
2
|
import Debug from 'debug';
|
|
2
3
|
import { LdContextLoader } from './ld-context-loader.js';
|
|
3
4
|
import { extractIssuer, intersect, isDefined, MANDATORY_CREDENTIAL_CONTEXT, mapIdentifierKeysToDoc, processEntryToArray, removeDIDParameters, } from '@veramo/utils';
|
|
@@ -5,9 +6,12 @@ import { LdCredentialModule } from './ld-credential-module.js';
|
|
|
5
6
|
import { LdSuiteLoader } from './ld-suite-loader.js';
|
|
6
7
|
const debug = Debug('veramo:credential-ld:action-handler');
|
|
7
8
|
/**
|
|
8
|
-
* A
|
|
9
|
+
* A Veramo Credential sub-plugin that implements
|
|
10
|
+
* a {@link @veramo/credential-w3c#ICredentialProvider | ICredentialProvider} with support for
|
|
11
|
+
* Verifiable Credentials and Presentations using JSON-LD proofs.
|
|
9
12
|
*
|
|
10
|
-
* @
|
|
13
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
14
|
+
* @see {@link https://www.w3.org/TR/vc-data-model-1.1/ | VC 1.1 data model}.
|
|
11
15
|
*/
|
|
12
16
|
export class CredentialProviderLD {
|
|
13
17
|
ldCredentialModule;
|
|
@@ -17,21 +21,20 @@ export class CredentialProviderLD {
|
|
|
17
21
|
ldSuiteLoader: new LdSuiteLoader({ veramoLdSignatures: options.suites }),
|
|
18
22
|
});
|
|
19
23
|
}
|
|
20
|
-
/** {@inheritdoc @veramo/credential-w3c#
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return 'lds';
|
|
24
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.getProofFormatsSupportedForKey} */
|
|
25
|
+
getProofFormatsSupportedForKey(key) {
|
|
26
|
+
if (this.matchKeyForLDSuite(key)) {
|
|
27
|
+
return [PROOF_FORMAT.LD_SIGNATURE];
|
|
28
|
+
}
|
|
29
|
+
return [];
|
|
27
30
|
}
|
|
28
|
-
/** {@inheritdoc @veramo/credential-w3c#
|
|
29
|
-
|
|
30
|
-
return
|
|
31
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.canIssueCredentialType} */
|
|
32
|
+
canIssueProofFormat(query) {
|
|
33
|
+
return query.proofFormat === PROOF_FORMAT.LD_SIGNATURE;
|
|
31
34
|
}
|
|
32
|
-
/** {@inheritdoc @veramo/credential-w3c#
|
|
33
|
-
canVerifyDocumentType(
|
|
34
|
-
const { document } =
|
|
35
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.canVerifyDocumentType} */
|
|
36
|
+
canVerifyDocumentType(query) {
|
|
37
|
+
const { document } = query;
|
|
35
38
|
for (const suite of this.ldCredentialModule.ldSuiteLoader.getAllSignatureSuites()) {
|
|
36
39
|
if (suite.getSupportedProofType() === document?.proof?.type || '') {
|
|
37
40
|
return true;
|
|
@@ -39,7 +42,7 @@ export class CredentialProviderLD {
|
|
|
39
42
|
}
|
|
40
43
|
return false;
|
|
41
44
|
}
|
|
42
|
-
/** {@inheritdoc
|
|
45
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.createVerifiablePresentation} */
|
|
43
46
|
async createVerifiablePresentation(args, context) {
|
|
44
47
|
const presentationContext = processEntryToArray(args?.presentation?.['@context'], MANDATORY_CREDENTIAL_CONTEXT);
|
|
45
48
|
const presentationType = processEntryToArray(args?.presentation?.type, 'VerifiablePresentation');
|
|
@@ -52,7 +55,7 @@ export class CredentialProviderLD {
|
|
|
52
55
|
throw new Error('invalid_argument: args.presentation.holder must not be empty');
|
|
53
56
|
}
|
|
54
57
|
if (args.presentation.verifiableCredential) {
|
|
55
|
-
|
|
58
|
+
presentation.verifiableCredential = args.presentation.verifiableCredential.map((cred) => {
|
|
56
59
|
if (typeof cred !== 'string' && cred.proof.jwt) {
|
|
57
60
|
return cred.proof.jwt;
|
|
58
61
|
}
|
|
@@ -60,7 +63,6 @@ export class CredentialProviderLD {
|
|
|
60
63
|
return cred;
|
|
61
64
|
}
|
|
62
65
|
});
|
|
63
|
-
presentation.verifiableCredential = credentials;
|
|
64
66
|
}
|
|
65
67
|
//issuanceDate must not be present for presentations because it is not defined in a @context
|
|
66
68
|
delete presentation.issuanceDate;
|
|
@@ -85,7 +87,7 @@ export class CredentialProviderLD {
|
|
|
85
87
|
return Promise.reject(error);
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
|
-
/** {@inheritdoc
|
|
90
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.createVerifiableCredential} */
|
|
89
91
|
async createVerifiableCredential(args, context) {
|
|
90
92
|
const credentialContext = processEntryToArray(args?.credential?.['@context'], MANDATORY_CREDENTIAL_CONTEXT);
|
|
91
93
|
const credentialType = processEntryToArray(args?.credential?.type, 'VerifiableCredential');
|
|
@@ -118,7 +120,7 @@ export class CredentialProviderLD {
|
|
|
118
120
|
return Promise.reject(error);
|
|
119
121
|
}
|
|
120
122
|
}
|
|
121
|
-
/** {@inheritdoc
|
|
123
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.verifyCredential} */
|
|
122
124
|
async verifyCredential(args, context) {
|
|
123
125
|
args.credential = args.credential;
|
|
124
126
|
const credential = args.credential;
|
|
@@ -128,7 +130,7 @@ export class CredentialProviderLD {
|
|
|
128
130
|
}
|
|
129
131
|
return this.ldCredentialModule.verifyCredential(credential, { ...args, now }, context);
|
|
130
132
|
}
|
|
131
|
-
/** {@inheritdoc
|
|
133
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.verifyPresentation} */
|
|
132
134
|
async verifyPresentation(args, context) {
|
|
133
135
|
const presentation = args.presentation;
|
|
134
136
|
let { now } = args;
|
|
@@ -137,29 +139,6 @@ export class CredentialProviderLD {
|
|
|
137
139
|
}
|
|
138
140
|
return this.ldCredentialModule.verifyPresentation(presentation, args.challenge, args.domain, { ...args, now }, context);
|
|
139
141
|
}
|
|
140
|
-
async findSigningKeyWithId(context, identifier, keyRef, resolutionOptions) {
|
|
141
|
-
const extendedKeys = await mapIdentifierKeysToDoc(identifier, 'assertionMethod', context, resolutionOptions);
|
|
142
|
-
let supportedTypes = this.ldCredentialModule.ldSuiteLoader.getAllSignatureSuiteTypes();
|
|
143
|
-
let signingKey;
|
|
144
|
-
let verificationMethodId;
|
|
145
|
-
if (keyRef) {
|
|
146
|
-
signingKey = extendedKeys.find((k) => k.kid === keyRef);
|
|
147
|
-
}
|
|
148
|
-
if (signingKey && !supportedTypes.includes(signingKey.meta.verificationMethod.type)) {
|
|
149
|
-
debug('WARNING: requested signing key DOES NOT correspond to a supported Signature suite type. Looking for the next best key.');
|
|
150
|
-
signingKey = undefined;
|
|
151
|
-
}
|
|
152
|
-
if (!signingKey) {
|
|
153
|
-
if (keyRef) {
|
|
154
|
-
debug('WARNING: no signing key was found that matches the reference provided. Searching for the first available signing key.');
|
|
155
|
-
}
|
|
156
|
-
signingKey = extendedKeys.find((k) => supportedTypes.includes(k.meta.verificationMethod.type));
|
|
157
|
-
}
|
|
158
|
-
if (!signingKey)
|
|
159
|
-
throw Error(`key_not_found: No suitable signing key found for ${identifier.did}`);
|
|
160
|
-
verificationMethodId = signingKey.meta.verificationMethod.id;
|
|
161
|
-
return { signingKey, verificationMethodId };
|
|
162
|
-
}
|
|
163
142
|
/**
|
|
164
143
|
* Returns true if the key is supported by any of the installed LD Signature suites
|
|
165
144
|
* @param k - the key to match
|
|
@@ -184,5 +163,28 @@ export class CredentialProviderLD {
|
|
|
184
163
|
.map((suite) => suite.getSupportedVeramoKeyType().includes(k.type))
|
|
185
164
|
.some((supportsThisKey) => supportsThisKey);
|
|
186
165
|
}
|
|
166
|
+
async findSigningKeyWithId(context, identifier, keyRef, resolutionOptions) {
|
|
167
|
+
const extendedKeys = await mapIdentifierKeysToDoc(identifier, 'assertionMethod', context, resolutionOptions);
|
|
168
|
+
let supportedTypes = this.ldCredentialModule.ldSuiteLoader.getAllSignatureSuiteTypes();
|
|
169
|
+
let signingKey;
|
|
170
|
+
let verificationMethodId;
|
|
171
|
+
if (keyRef) {
|
|
172
|
+
signingKey = extendedKeys.find((k) => k.kid === keyRef);
|
|
173
|
+
}
|
|
174
|
+
if (signingKey && !supportedTypes.includes(signingKey.meta.verificationMethod.type)) {
|
|
175
|
+
debug('WARNING: requested signing key DOES NOT correspond to a supported Signature suite type. Looking for the next best key.');
|
|
176
|
+
signingKey = undefined;
|
|
177
|
+
}
|
|
178
|
+
if (!signingKey) {
|
|
179
|
+
if (keyRef) {
|
|
180
|
+
debug('WARNING: no signing key was found that matches the reference provided. Searching for the first available signing key.');
|
|
181
|
+
}
|
|
182
|
+
signingKey = extendedKeys.find((k) => supportedTypes.includes(k.meta.verificationMethod.type));
|
|
183
|
+
}
|
|
184
|
+
if (!signingKey)
|
|
185
|
+
throw Error(`key_not_found: No suitable signing key found for ${identifier.did}`);
|
|
186
|
+
verificationMethodId = signingKey.meta.verificationMethod.id;
|
|
187
|
+
return { signingKey, verificationMethodId };
|
|
188
|
+
}
|
|
187
189
|
}
|
|
188
190
|
//# sourceMappingURL=CredentialProviderLD.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CredentialProviderLD.js","sourceRoot":"","sources":["../src/CredentialProviderLD.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CredentialProviderLD.js","sourceRoot":"","sources":["../src/CredentialProviderLD.ts"],"names":[],"mappings":"AAAA,OAAO,EAaL,YAAY,GAKb,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,EAEL,aAAa,EACb,SAAS,EACT,SAAS,EACT,4BAA4B,EAC5B,sBAAsB,EAEtB,mBAAmB,EAEnB,mBAAmB,GACpB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAMpD,MAAM,KAAK,GAAG,KAAK,CAAC,qCAAqC,CAAC,CAAA;AAE1D;;;;;;;GAOG;AACH,MAAM,OAAO,oBAAoB;IACvB,kBAAkB,CAAoB;IAE9C,YAAY,OAA0F;QACpG,IAAI,CAAC,kBAAkB,GAAG,IAAI,kBAAkB,CAAC;YAC/C,eAAe,EAAE,IAAI,eAAe,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;YAC5E,aAAa,EAAE,IAAI,aAAa,CAAC,EAAE,kBAAkB,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;SACzE,CAAC,CAAA;IACJ,CAAC;IAED,8FAA8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C JSON-LD Verifiable Credentials & Presentations.",
|
|
4
|
-
"version": "6.0.3-next.
|
|
4
|
+
"version": "6.0.3-next.62+cbd848d4c",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./build/index.js"
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"@transmute/ed25519-signature-2018": "^0.7.0-unstable.81",
|
|
22
22
|
"@transmute/json-web-signature": "^0.7.0-unstable.81",
|
|
23
23
|
"@veramo-community/lds-ecdsa-secp256k1-recovery2020": "uport-project/EcdsaSecp256k1RecoverySignature2020",
|
|
24
|
-
"@veramo/core-types": "^6.0.3-next.
|
|
25
|
-
"@veramo/credential-w3c": "^6.0.3-next.
|
|
26
|
-
"@veramo/utils": "^6.0.3-next.
|
|
24
|
+
"@veramo/core-types": "^6.0.3-next.62+cbd848d4c",
|
|
25
|
+
"@veramo/credential-w3c": "^6.0.3-next.62+cbd848d4c",
|
|
26
|
+
"@veramo/utils": "^6.0.3-next.62+cbd848d4c",
|
|
27
27
|
"cross-fetch": "^4.0.0",
|
|
28
28
|
"debug": "^4.3.3",
|
|
29
29
|
"did-resolver": "^4.1.0"
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"node_modules",
|
|
78
78
|
"src"
|
|
79
79
|
],
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "cbd848d4ce2b52497d99d335f1c93bd8b005cdb2"
|
|
81
81
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CredentialPayload,
|
|
3
3
|
IAgentContext,
|
|
4
|
-
IAgentPlugin,
|
|
5
|
-
ICanIssueCredentialTypeArgs,
|
|
6
4
|
ICreateVerifiableCredentialArgs,
|
|
7
5
|
ICreateVerifiablePresentationArgs,
|
|
8
6
|
IIdentifier,
|
|
@@ -13,10 +11,11 @@ import {
|
|
|
13
11
|
IVerifyPresentationArgs,
|
|
14
12
|
IVerifyResult,
|
|
15
13
|
PresentationPayload,
|
|
14
|
+
PROOF_FORMAT,
|
|
15
|
+
ProofFormat,
|
|
16
16
|
VerifiableCredential,
|
|
17
17
|
VerifiablePresentation,
|
|
18
18
|
VerifierAgentContext,
|
|
19
|
-
ICanVerifyDocumentTypeArgs,
|
|
20
19
|
} from '@veramo/core-types'
|
|
21
20
|
import { VeramoLdSignature } from './index.js'
|
|
22
21
|
import Debug from 'debug'
|
|
@@ -36,22 +35,22 @@ import {
|
|
|
36
35
|
|
|
37
36
|
import { LdCredentialModule } from './ld-credential-module.js'
|
|
38
37
|
import { LdSuiteLoader } from './ld-suite-loader.js'
|
|
39
|
-
import {
|
|
40
|
-
ContextDoc,
|
|
41
|
-
} from './types.js'
|
|
38
|
+
import { ContextDoc } from './types.js'
|
|
42
39
|
import { DIDResolutionOptions } from 'did-resolver'
|
|
43
40
|
|
|
44
|
-
import {
|
|
41
|
+
import { ICredentialProvider, ProofFormatQuery, TentativeVerificationQuery } from '@veramo/credential-w3c'
|
|
45
42
|
|
|
46
43
|
const debug = Debug('veramo:credential-ld:action-handler')
|
|
47
44
|
|
|
48
45
|
/**
|
|
49
|
-
* A
|
|
46
|
+
* A Veramo Credential sub-plugin that implements
|
|
47
|
+
* a {@link @veramo/credential-w3c#ICredentialProvider | ICredentialProvider} with support for
|
|
48
|
+
* Verifiable Credentials and Presentations using JSON-LD proofs.
|
|
50
49
|
*
|
|
51
|
-
* @
|
|
50
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
51
|
+
* @see {@link https://www.w3.org/TR/vc-data-model-1.1/ | VC 1.1 data model}.
|
|
52
52
|
*/
|
|
53
|
-
export class CredentialProviderLD implements
|
|
54
|
-
|
|
53
|
+
export class CredentialProviderLD implements ICredentialProvider {
|
|
55
54
|
private ldCredentialModule: LdCredentialModule
|
|
56
55
|
|
|
57
56
|
constructor(options: { contextMaps: RecordLike<OrPromise<ContextDoc>>[]; suites: VeramoLdSignature[] }) {
|
|
@@ -61,24 +60,22 @@ export class CredentialProviderLD implements AbstractCredentialProvider {
|
|
|
61
60
|
})
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
/** {@inheritdoc @veramo/credential-w3c#
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
getTypeProofFormat(): string {
|
|
71
|
-
return 'lds'
|
|
63
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.getProofFormatsSupportedForKey} */
|
|
64
|
+
getProofFormatsSupportedForKey(key: IKey): ProofFormat[] {
|
|
65
|
+
if (this.matchKeyForLDSuite(key)) {
|
|
66
|
+
return [PROOF_FORMAT.LD_SIGNATURE]
|
|
67
|
+
}
|
|
68
|
+
return []
|
|
72
69
|
}
|
|
73
70
|
|
|
74
|
-
/** {@inheritdoc @veramo/credential-w3c#
|
|
75
|
-
|
|
76
|
-
return
|
|
71
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.canIssueCredentialType} */
|
|
72
|
+
canIssueProofFormat(query: ProofFormatQuery): boolean {
|
|
73
|
+
return query.proofFormat === PROOF_FORMAT.LD_SIGNATURE
|
|
77
74
|
}
|
|
78
75
|
|
|
79
|
-
/** {@inheritdoc @veramo/credential-w3c#
|
|
80
|
-
canVerifyDocumentType(
|
|
81
|
-
const { document } =
|
|
76
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.canVerifyDocumentType} */
|
|
77
|
+
canVerifyDocumentType(query: TentativeVerificationQuery): boolean {
|
|
78
|
+
const { document } = query
|
|
82
79
|
|
|
83
80
|
for (const suite of this.ldCredentialModule.ldSuiteLoader.getAllSignatureSuites()) {
|
|
84
81
|
if (suite.getSupportedProofType() === (<VerifiableCredential>document)?.proof?.type || '') {
|
|
@@ -89,7 +86,7 @@ export class CredentialProviderLD implements AbstractCredentialProvider {
|
|
|
89
86
|
return false
|
|
90
87
|
}
|
|
91
88
|
|
|
92
|
-
/** {@inheritdoc
|
|
89
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.createVerifiablePresentation} */
|
|
93
90
|
async createVerifiablePresentation(
|
|
94
91
|
args: ICreateVerifiablePresentationArgs,
|
|
95
92
|
context: IssuerAgentContext,
|
|
@@ -111,14 +108,13 @@ export class CredentialProviderLD implements AbstractCredentialProvider {
|
|
|
111
108
|
}
|
|
112
109
|
|
|
113
110
|
if (args.presentation.verifiableCredential) {
|
|
114
|
-
|
|
111
|
+
presentation.verifiableCredential = args.presentation.verifiableCredential.map((cred) => {
|
|
115
112
|
if (typeof cred !== 'string' && cred.proof.jwt) {
|
|
116
113
|
return cred.proof.jwt
|
|
117
114
|
} else {
|
|
118
115
|
return cred
|
|
119
116
|
}
|
|
120
117
|
})
|
|
121
|
-
presentation.verifiableCredential = credentials
|
|
122
118
|
}
|
|
123
119
|
|
|
124
120
|
//issuanceDate must not be present for presentations because it is not defined in a @context
|
|
@@ -161,7 +157,7 @@ export class CredentialProviderLD implements AbstractCredentialProvider {
|
|
|
161
157
|
}
|
|
162
158
|
}
|
|
163
159
|
|
|
164
|
-
/** {@inheritdoc
|
|
160
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.createVerifiableCredential} */
|
|
165
161
|
async createVerifiableCredential(
|
|
166
162
|
args: ICreateVerifiableCredentialArgs,
|
|
167
163
|
context: IssuerAgentContext,
|
|
@@ -215,7 +211,7 @@ export class CredentialProviderLD implements AbstractCredentialProvider {
|
|
|
215
211
|
}
|
|
216
212
|
}
|
|
217
213
|
|
|
218
|
-
/** {@inheritdoc
|
|
214
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.verifyCredential} */
|
|
219
215
|
async verifyCredential(args: IVerifyCredentialArgs, context: VerifierAgentContext): Promise<IVerifyResult> {
|
|
220
216
|
args.credential = args.credential as VerifiableCredential
|
|
221
217
|
const credential = args.credential
|
|
@@ -229,7 +225,7 @@ export class CredentialProviderLD implements AbstractCredentialProvider {
|
|
|
229
225
|
return this.ldCredentialModule.verifyCredential(credential, { ...args, now }, context)
|
|
230
226
|
}
|
|
231
227
|
|
|
232
|
-
/** {@inheritdoc
|
|
228
|
+
/** {@inheritdoc @veramo/credential-w3c#ICredentialProvider.verifyPresentation} */
|
|
233
229
|
async verifyPresentation(
|
|
234
230
|
args: IVerifyPresentationArgs,
|
|
235
231
|
context: VerifierAgentContext,
|
|
@@ -248,6 +244,30 @@ export class CredentialProviderLD implements AbstractCredentialProvider {
|
|
|
248
244
|
)
|
|
249
245
|
}
|
|
250
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Returns true if the key is supported by any of the installed LD Signature suites
|
|
249
|
+
* @param k - the key to match
|
|
250
|
+
*
|
|
251
|
+
* @internal
|
|
252
|
+
*/
|
|
253
|
+
private matchKeyForLDSuite(k: IKey): boolean {
|
|
254
|
+
// prefilter based on key algorithms
|
|
255
|
+
switch (k.type) {
|
|
256
|
+
case 'Ed25519':
|
|
257
|
+
if (!k.meta?.algorithms?.includes('EdDSA')) return false
|
|
258
|
+
break
|
|
259
|
+
case 'Secp256k1':
|
|
260
|
+
if (intersect(k.meta?.algorithms ?? [], ['ES256K-R', 'ES256K']).length == 0) return false
|
|
261
|
+
break
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// TODO: this should return a list of supported suites, not just a boolean
|
|
265
|
+
const suites = this.ldCredentialModule.ldSuiteLoader.getAllSignatureSuites()
|
|
266
|
+
return suites
|
|
267
|
+
.map((suite: VeramoLdSignature) => suite.getSupportedVeramoKeyType().includes(k.type))
|
|
268
|
+
.some((supportsThisKey: boolean) => supportsThisKey)
|
|
269
|
+
}
|
|
270
|
+
|
|
251
271
|
private async findSigningKeyWithId(
|
|
252
272
|
context: IAgentContext<IResolver>,
|
|
253
273
|
identifier: IIdentifier,
|
|
@@ -285,28 +305,4 @@ export class CredentialProviderLD implements AbstractCredentialProvider {
|
|
|
285
305
|
verificationMethodId = signingKey.meta.verificationMethod.id
|
|
286
306
|
return { signingKey, verificationMethodId }
|
|
287
307
|
}
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Returns true if the key is supported by any of the installed LD Signature suites
|
|
291
|
-
* @param k - the key to match
|
|
292
|
-
*
|
|
293
|
-
* @internal
|
|
294
|
-
*/
|
|
295
|
-
matchKeyForLDSuite(k: IKey): boolean {
|
|
296
|
-
// prefilter based on key algorithms
|
|
297
|
-
switch (k.type) {
|
|
298
|
-
case 'Ed25519':
|
|
299
|
-
if (!k.meta?.algorithms?.includes('EdDSA')) return false
|
|
300
|
-
break
|
|
301
|
-
case 'Secp256k1':
|
|
302
|
-
if (intersect(k.meta?.algorithms ?? [], ['ES256K-R', 'ES256K']).length == 0) return false
|
|
303
|
-
break
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// TODO: this should return a list of supported suites, not just a boolean
|
|
307
|
-
const suites = this.ldCredentialModule.ldSuiteLoader.getAllSignatureSuites()
|
|
308
|
-
return suites
|
|
309
|
-
.map((suite: VeramoLdSignature) => suite.getSupportedVeramoKeyType().includes(k.type))
|
|
310
|
-
.some((supportsThisKey: boolean) => supportsThisKey)
|
|
311
|
-
}
|
|
312
308
|
}
|
|
@@ -60,7 +60,7 @@ describe('credential-LD full flow', () => {
|
|
|
60
60
|
...new FakeDidResolver(() => agent, true).getDidFakeResolver(),
|
|
61
61
|
}),
|
|
62
62
|
}),
|
|
63
|
-
new CredentialPlugin(
|
|
63
|
+
new CredentialPlugin([ld]),
|
|
64
64
|
],
|
|
65
65
|
})
|
|
66
66
|
didFakeIdentifier = await agent.didManagerImport({
|
|
@@ -78,17 +78,19 @@ describe('credential-LD full flow', () => {
|
|
|
78
78
|
new DIDResolverPlugin({
|
|
79
79
|
resolver: new Resolver({
|
|
80
80
|
...getDidKeyResolver(),
|
|
81
|
-
...ethrDidResolver({
|
|
81
|
+
...ethrDidResolver({
|
|
82
|
+
networks: [
|
|
82
83
|
{
|
|
83
84
|
chainId: 1337,
|
|
84
85
|
name: 'ganache',
|
|
85
86
|
provider,
|
|
86
87
|
registry,
|
|
87
88
|
},
|
|
88
|
-
],
|
|
89
|
+
],
|
|
90
|
+
}),
|
|
89
91
|
}),
|
|
90
92
|
}),
|
|
91
|
-
new CredentialPlugin(
|
|
93
|
+
new CredentialPlugin([ld]),
|
|
92
94
|
],
|
|
93
95
|
})
|
|
94
96
|
didKeyIdentifier = await agent.didManagerCreate()
|
|
@@ -147,6 +149,7 @@ describe('credential-LD full flow', () => {
|
|
|
147
149
|
|
|
148
150
|
it('works with EcdsaSecp256k1RecoveryMethod2020 credentials', async () => {
|
|
149
151
|
const credential: CredentialPayload = {
|
|
152
|
+
// use did:ethr issuer to have a EcdsaSecp256k1RecoveryMethod2020 as a verification method in the DID document
|
|
150
153
|
issuer: didEthrIdentifier.did,
|
|
151
154
|
'@context': ['custom:example.context'],
|
|
152
155
|
credentialSubject: {
|
|
@@ -159,6 +162,7 @@ describe('credential-LD full flow', () => {
|
|
|
159
162
|
})
|
|
160
163
|
|
|
161
164
|
expect(verifiableCredential).toBeDefined()
|
|
165
|
+
expect((verifiableCredential as any).proof.type).toBe('EcdsaSecp256k1RecoverySignature2020')
|
|
162
166
|
|
|
163
167
|
const result = await agent.verifyCredential({
|
|
164
168
|
credential: verifiableCredential,
|