@veramo/credential-ld 5.5.2-next.9 → 5.5.3-next.17
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/action-handler.d.ts +8 -1
- package/build/action-handler.d.ts.map +1 -1
- package/build/action-handler.js +26 -1
- package/build/action-handler.js.map +1 -1
- package/build/types.d.ts +15 -6
- package/build/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/action-handler.ts +26 -1
- package/src/types.ts +16 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAgentPlugin, VerifiableCredential, VerifiablePresentation } from '@veramo/core-types';
|
|
1
|
+
import { IAgentPlugin, IKey, VerifiableCredential, VerifiablePresentation } from '@veramo/core-types';
|
|
2
2
|
import { VeramoLdSignature } from './index.js';
|
|
3
3
|
import { OrPromise, RecordLike } from '@veramo/utils';
|
|
4
4
|
import { ContextDoc, ICreateVerifiableCredentialLDArgs, ICreateVerifiablePresentationLDArgs, ICredentialIssuerLD, IRequiredContext, IVerifyCredentialLDArgs, IVerifyPresentationLDArgs } from './types.js';
|
|
@@ -402,5 +402,12 @@ export declare class CredentialIssuerLD implements IAgentPlugin {
|
|
|
402
402
|
/** {@inheritdoc ICredentialIssuerLD.verifyPresentationLD} */
|
|
403
403
|
verifyPresentationLD(args: IVerifyPresentationLDArgs, context: IRequiredContext): Promise<boolean>;
|
|
404
404
|
private findSigningKeyWithId;
|
|
405
|
+
/**
|
|
406
|
+
* Returns true if the key is supported by any of the installed LD Signature suites
|
|
407
|
+
* @param k - the key to verify
|
|
408
|
+
*
|
|
409
|
+
* @internal
|
|
410
|
+
*/
|
|
411
|
+
matchKeyForLDSuite(k: IKey): Promise<boolean>;
|
|
405
412
|
}
|
|
406
413
|
//# sourceMappingURL=action-handler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-handler.d.ts","sourceRoot":"","sources":["../src/action-handler.ts"],"names":[],"mappings":"AAAA,OAAO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mCAAmC,EACzC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,sBAAsB,CAAC;IAmElC,qEAAqE;IACxD,4BAA4B,CACvC,IAAI,EAAE,iCAAiC,EACvC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,oBAAoB,CAAC;IAiDhC,2DAA2D;IAC9C,kBAAkB,CAC7B,IAAI,EAAE,uBAAuB,EAC7B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,OAAO,CAAC;IAgBnB,6DAA6D;IAChD,oBAAoB,CAC/B,IAAI,EAAE,yBAAyB,EAC/B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,OAAO,CAAC;YAgBL,oBAAoB;IAgClC;;;;;OAKG;IACG,kBAAkB,CAAC,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;CAiBpD"}
|
package/build/action-handler.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import schema from './plugin.schema.json' assert { type: 'json' };
|
|
2
2
|
import Debug from 'debug';
|
|
3
3
|
import { LdContextLoader } from './ld-context-loader.js';
|
|
4
|
-
import { extractIssuer, isDefined, MANDATORY_CREDENTIAL_CONTEXT, mapIdentifierKeysToDoc, processEntryToArray, removeDIDParameters, } from '@veramo/utils';
|
|
4
|
+
import { extractIssuer, intersect, isDefined, MANDATORY_CREDENTIAL_CONTEXT, mapIdentifierKeysToDoc, processEntryToArray, removeDIDParameters, } from '@veramo/utils';
|
|
5
5
|
import { LdCredentialModule } from './ld-credential-module.js';
|
|
6
6
|
import { LdSuiteLoader } from './ld-suite-loader.js';
|
|
7
7
|
const debug = Debug('veramo:credential-ld:action-handler');
|
|
@@ -24,6 +24,7 @@ export class CredentialIssuerLD {
|
|
|
24
24
|
createVerifiableCredentialLD: this.createVerifiableCredentialLD.bind(this),
|
|
25
25
|
verifyCredentialLD: this.verifyCredentialLD.bind(this),
|
|
26
26
|
verifyPresentationLD: this.verifyPresentationLD.bind(this),
|
|
27
|
+
matchKeyForLDSuite: this.matchKeyForLDSuite.bind(this),
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
/** {@inheritdoc ICredentialIssuerLD.createVerifiablePresentationLD} */
|
|
@@ -146,5 +147,29 @@ export class CredentialIssuerLD {
|
|
|
146
147
|
verificationMethodId = signingKey.meta.verificationMethod.id;
|
|
147
148
|
return { signingKey, verificationMethodId };
|
|
148
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Returns true if the key is supported by any of the installed LD Signature suites
|
|
152
|
+
* @param k - the key to verify
|
|
153
|
+
*
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
156
|
+
async matchKeyForLDSuite(k) {
|
|
157
|
+
// prefilter based on key algorithms
|
|
158
|
+
switch (k.type) {
|
|
159
|
+
case 'Ed25519':
|
|
160
|
+
if (!k.meta?.algorithms?.includes('EdDSA'))
|
|
161
|
+
return false;
|
|
162
|
+
break;
|
|
163
|
+
case 'Secp256k1':
|
|
164
|
+
if (intersect(k.meta?.algorithms ?? [], ['ES256K-R', 'ES256K']).length == 0)
|
|
165
|
+
return false;
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
// TODO: this should return a list of supported suites, not just a boolean
|
|
169
|
+
const suites = this.ldCredentialModule.ldSuiteLoader.getAllSignatureSuites();
|
|
170
|
+
return suites
|
|
171
|
+
.map((suite) => suite.getSupportedVeramoKeyType().includes(k.type))
|
|
172
|
+
.some((supportsThisKey) => supportsThisKey);
|
|
173
|
+
}
|
|
149
174
|
}
|
|
150
175
|
//# sourceMappingURL=action-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-handler.js","sourceRoot":"","sources":["../src/action-handler.ts"],"names":[],"mappings":"AAYA,OAAO,MAAM,MAAM,sBAAsB,CAAC,SAAS,IAAI,EAAE,MAAM,EAAE,CAAA;AACjE,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;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
|
|
1
|
-
import { CredentialPayload, IAgentContext, IDIDManager, IKeyManager, IPluginMethodMap, IResolver, PresentationPayload, VerifiableCredential, VerifiablePresentation } from '@veramo/core-types';
|
|
1
|
+
import { CredentialPayload, IAgentContext, IDIDManager, IKey, IKeyManager, IPluginMethodMap, IResolver, PresentationPayload, VerifiableCredential, VerifiablePresentation } from '@veramo/core-types';
|
|
2
2
|
/**
|
|
3
3
|
* The interface definition for a plugin that can issue and verify Verifiable Credentials and Presentations
|
|
4
4
|
* that use JSON-LD format (also called Data Integrity Proofs).
|
|
@@ -16,10 +16,11 @@ export interface ICredentialIssuerLD extends IPluginMethodMap {
|
|
|
16
16
|
* @param args - Arguments necessary to create the Presentation.
|
|
17
17
|
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
18
18
|
*
|
|
19
|
-
* @returns - a promise that resolves to the {@link @veramo/core-types#VerifiablePresentation} that was requested or
|
|
20
|
-
* if there was a problem with the input or while getting the key to sign
|
|
19
|
+
* @returns - a promise that resolves to the {@link @veramo/core-types#VerifiablePresentation} that was requested or
|
|
20
|
+
* rejects with an error if there was a problem with the input or while getting the key to sign
|
|
21
21
|
*
|
|
22
|
-
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#presentations | Verifiable Presentation data model
|
|
22
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#presentations | Verifiable Presentation data model
|
|
23
|
+
* }
|
|
23
24
|
*
|
|
24
25
|
* @beta This API may change without a BREAKING CHANGE notice.
|
|
25
26
|
*/
|
|
@@ -31,8 +32,8 @@ export interface ICredentialIssuerLD extends IPluginMethodMap {
|
|
|
31
32
|
* @param args - Arguments necessary to create the Presentation.
|
|
32
33
|
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
33
34
|
*
|
|
34
|
-
* @returns - a promise that resolves to the {@link @veramo/core-types#VerifiableCredential} that was requested or
|
|
35
|
-
* if there was a problem with the input or while getting the key to sign
|
|
35
|
+
* @returns - a promise that resolves to the {@link @veramo/core-types#VerifiableCredential} that was requested or
|
|
36
|
+
* rejects with an error if there was a problem with the input or while getting the key to sign
|
|
36
37
|
*
|
|
37
38
|
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#credentials | Verifiable Credential data model}
|
|
38
39
|
*
|
|
@@ -65,6 +66,14 @@ export interface ICredentialIssuerLD extends IPluginMethodMap {
|
|
|
65
66
|
* @beta This API may change without a BREAKING CHANGE notice.
|
|
66
67
|
*/
|
|
67
68
|
verifyPresentationLD(args: IVerifyPresentationLDArgs, context: IRequiredContext): Promise<boolean>;
|
|
69
|
+
/**
|
|
70
|
+
* Returns true if the key is supported by any of the installed LD Signature suites
|
|
71
|
+
* @param key - the key to verify
|
|
72
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
73
|
+
*
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
matchKeyForLDSuite(key: IKey, context: IAgentContext<{}>): Promise<boolean>;
|
|
68
77
|
}
|
|
69
78
|
/**
|
|
70
79
|
* Encapsulates the parameters required to create a
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,oBAAoB,CAAA;AAE3B;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,IAAI,EACJ,WAAW,EACX,gBAAgB,EAChB,SAAS,EACT,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,oBAAoB,CAAA;A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;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAE7B;;OAEG;IACH,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;;;;OAOG;IACH,UAAU,EAAE,oBAAoB,CAAA;IAEhC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAE7B;;OAEG;IACH,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CACjB;AAED;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;;;;OAOG;IACH,YAAY,EAAE,sBAAsB,CAAA;IAEpC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAE7B;;OAEG;IACH,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CACjB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAC1C,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,GAAG,IAAI,CAAC,WAAW,EAAE,eAAe,GAAG,gBAAgB,CAAC,CACvG,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAChC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veramo/credential-ld",
|
|
3
3
|
"description": "Veramo plugin for working with W3C JSON-LD Verifiable Credentials & Presentations.",
|
|
4
|
-
"version": "5.5.
|
|
4
|
+
"version": "5.5.3-next.17+c1d603295",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./build/index.js",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"@transmute/ed25519-signature-2018": "^0.7.0-unstable.81",
|
|
28
28
|
"@transmute/json-web-signature": "^0.7.0-unstable.81",
|
|
29
29
|
"@veramo-community/lds-ecdsa-secp256k1-recovery2020": "uport-project/EcdsaSecp256k1RecoverySignature2020",
|
|
30
|
-
"@veramo/core-types": "^5.5.
|
|
31
|
-
"@veramo/utils": "^5.5.
|
|
30
|
+
"@veramo/core-types": "^5.5.3-next.17+c1d603295",
|
|
31
|
+
"@veramo/utils": "^5.5.3-next.17+c1d603295",
|
|
32
32
|
"cross-fetch": "^4.0.0",
|
|
33
33
|
"debug": "^4.3.3",
|
|
34
34
|
"did-resolver": "^4.1.0"
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"node_modules",
|
|
63
63
|
"src"
|
|
64
64
|
],
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "c1d6032952dccb8dd53ec8fb56e817e5413273ce"
|
|
66
66
|
}
|
package/src/action-handler.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { LdContextLoader } from './ld-context-loader.js'
|
|
|
16
16
|
import {
|
|
17
17
|
_ExtendedIKey,
|
|
18
18
|
extractIssuer,
|
|
19
|
+
intersect,
|
|
19
20
|
isDefined,
|
|
20
21
|
MANDATORY_CREDENTIAL_CONTEXT,
|
|
21
22
|
mapIdentifierKeysToDoc,
|
|
@@ -61,6 +62,7 @@ export class CredentialIssuerLD implements IAgentPlugin {
|
|
|
61
62
|
createVerifiableCredentialLD: this.createVerifiableCredentialLD.bind(this),
|
|
62
63
|
verifyCredentialLD: this.verifyCredentialLD.bind(this),
|
|
63
64
|
verifyPresentationLD: this.verifyPresentationLD.bind(this),
|
|
65
|
+
matchKeyForLDSuite: this.matchKeyForLDSuite.bind(this),
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
|
|
@@ -255,9 +257,32 @@ export class CredentialIssuerLD implements IAgentPlugin {
|
|
|
255
257
|
signingKey = extendedKeys.find((k) => supportedTypes.includes(k.meta.verificationMethod.type))
|
|
256
258
|
}
|
|
257
259
|
|
|
258
|
-
|
|
259
260
|
if (!signingKey) throw Error(`key_not_found: No suitable signing key found for ${identifier.did}`)
|
|
260
261
|
verificationMethodId = signingKey.meta.verificationMethod.id
|
|
261
262
|
return { signingKey, verificationMethodId }
|
|
262
263
|
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Returns true if the key is supported by any of the installed LD Signature suites
|
|
267
|
+
* @param k - the key to verify
|
|
268
|
+
*
|
|
269
|
+
* @internal
|
|
270
|
+
*/
|
|
271
|
+
async matchKeyForLDSuite(k: IKey): Promise<boolean> {
|
|
272
|
+
// prefilter based on key algorithms
|
|
273
|
+
switch (k.type) {
|
|
274
|
+
case 'Ed25519':
|
|
275
|
+
if (!k.meta?.algorithms?.includes('EdDSA')) return false
|
|
276
|
+
break
|
|
277
|
+
case 'Secp256k1':
|
|
278
|
+
if (intersect(k.meta?.algorithms ?? [], ['ES256K-R', 'ES256K']).length == 0) return false
|
|
279
|
+
break
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// TODO: this should return a list of supported suites, not just a boolean
|
|
283
|
+
const suites = this.ldCredentialModule.ldSuiteLoader.getAllSignatureSuites()
|
|
284
|
+
return suites
|
|
285
|
+
.map((suite: VeramoLdSignature) => suite.getSupportedVeramoKeyType().includes(k.type))
|
|
286
|
+
.some((supportsThisKey: boolean) => supportsThisKey)
|
|
287
|
+
}
|
|
263
288
|
}
|
package/src/types.ts
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
CredentialPayload,
|
|
3
3
|
IAgentContext,
|
|
4
4
|
IDIDManager,
|
|
5
|
+
IKey,
|
|
5
6
|
IKeyManager,
|
|
6
7
|
IPluginMethodMap,
|
|
7
8
|
IResolver,
|
|
@@ -27,10 +28,11 @@ export interface ICredentialIssuerLD extends IPluginMethodMap {
|
|
|
27
28
|
* @param args - Arguments necessary to create the Presentation.
|
|
28
29
|
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
29
30
|
*
|
|
30
|
-
* @returns - a promise that resolves to the {@link @veramo/core-types#VerifiablePresentation} that was requested or
|
|
31
|
-
* if there was a problem with the input or while getting the key to sign
|
|
31
|
+
* @returns - a promise that resolves to the {@link @veramo/core-types#VerifiablePresentation} that was requested or
|
|
32
|
+
* rejects with an error if there was a problem with the input or while getting the key to sign
|
|
32
33
|
*
|
|
33
|
-
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#presentations | Verifiable Presentation data model
|
|
34
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#presentations | Verifiable Presentation data model
|
|
35
|
+
* }
|
|
34
36
|
*
|
|
35
37
|
* @beta This API may change without a BREAKING CHANGE notice.
|
|
36
38
|
*/
|
|
@@ -46,8 +48,8 @@ export interface ICredentialIssuerLD extends IPluginMethodMap {
|
|
|
46
48
|
* @param args - Arguments necessary to create the Presentation.
|
|
47
49
|
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
48
50
|
*
|
|
49
|
-
* @returns - a promise that resolves to the {@link @veramo/core-types#VerifiableCredential} that was requested or
|
|
50
|
-
* if there was a problem with the input or while getting the key to sign
|
|
51
|
+
* @returns - a promise that resolves to the {@link @veramo/core-types#VerifiableCredential} that was requested or
|
|
52
|
+
* rejects with an error if there was a problem with the input or while getting the key to sign
|
|
51
53
|
*
|
|
52
54
|
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#credentials | Verifiable Credential data model}
|
|
53
55
|
*
|
|
@@ -85,6 +87,15 @@ export interface ICredentialIssuerLD extends IPluginMethodMap {
|
|
|
85
87
|
* @beta This API may change without a BREAKING CHANGE notice.
|
|
86
88
|
*/
|
|
87
89
|
verifyPresentationLD(args: IVerifyPresentationLDArgs, context: IRequiredContext): Promise<boolean>
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Returns true if the key is supported by any of the installed LD Signature suites
|
|
93
|
+
* @param key - the key to verify
|
|
94
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
95
|
+
*
|
|
96
|
+
* @internal
|
|
97
|
+
*/
|
|
98
|
+
matchKeyForLDSuite(key: IKey, context: IAgentContext<{}>): Promise<boolean>
|
|
88
99
|
}
|
|
89
100
|
|
|
90
101
|
/**
|