@veramo/credential-ld 6.0.1-next.8 → 6.0.1
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 +461 -0
- package/build/action-handler.d.ts.map +1 -0
- package/build/{CredentialProviderLD.js → action-handler.js} +25 -38
- package/build/action-handler.js.map +1 -0
- package/build/index.d.ts +4 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -3
- package/build/index.js.map +1 -1
- package/build/ld-credential-module.d.ts +4 -4
- package/build/ld-credential-module.d.ts.map +1 -1
- package/build/ld-credential-module.js.map +1 -1
- package/build/ld-default-contexts.d.ts +1 -1
- package/build/ld-default-contexts.js +1 -1
- package/build/ld-suites.d.ts +0 -1
- package/build/ld-suites.d.ts.map +1 -1
- package/build/ld-suites.js.map +1 -1
- package/build/plugin.schema.d.ts +430 -0
- package/build/plugin.schema.d.ts.map +1 -0
- package/build/plugin.schema.js +477 -0
- package/build/plugin.schema.js.map +1 -0
- package/build/suites/EcdsaSecp256k1RecoverySignature2020.d.ts +0 -1
- package/build/suites/EcdsaSecp256k1RecoverySignature2020.d.ts.map +1 -1
- package/build/suites/EcdsaSecp256k1RecoverySignature2020.js +0 -3
- package/build/suites/EcdsaSecp256k1RecoverySignature2020.js.map +1 -1
- package/build/suites/Ed25519Signature2018.d.ts +0 -1
- package/build/suites/Ed25519Signature2018.d.ts.map +1 -1
- package/build/suites/Ed25519Signature2018.js +0 -3
- package/build/suites/Ed25519Signature2018.js.map +1 -1
- package/build/suites/Ed25519Signature2020.d.ts +0 -1
- package/build/suites/Ed25519Signature2020.d.ts.map +1 -1
- package/build/suites/Ed25519Signature2020.js +0 -3
- package/build/suites/Ed25519Signature2020.js.map +1 -1
- package/build/suites/JsonWebSignature2020.d.ts +0 -1
- package/build/suites/JsonWebSignature2020.d.ts.map +1 -1
- package/build/suites/JsonWebSignature2020.js +0 -3
- package/build/suites/JsonWebSignature2020.js.map +1 -1
- package/build/types.d.ts +220 -0
- package/build/types.d.ts.map +1 -1
- package/package.json +10 -6
- package/src/__tests__/issue-verify-ed25519-2020.test.ts +122 -122
- package/src/__tests__/{issue-verify-flow-ld.test.ts → issue-verify-flow.test.ts} +6 -7
- package/src/{CredentialProviderLD.ts → action-handler.ts} +40 -61
- package/src/index.ts +4 -3
- package/src/ld-credential-module.ts +3 -4
- package/src/ld-default-contexts.ts +1 -1
- package/src/ld-suites.ts +0 -2
- package/src/plugin.schema.ts +476 -0
- package/src/suites/EcdsaSecp256k1RecoverySignature2020.ts +1 -6
- package/src/suites/Ed25519Signature2018.ts +0 -5
- package/src/suites/Ed25519Signature2020.ts +1 -5
- package/src/suites/JsonWebSignature2020.ts +1 -5
- package/src/types.ts +265 -0
- package/build/CredentialProviderLD.d.ts +0 -42
- package/build/CredentialProviderLD.d.ts.map +0 -1
- package/build/CredentialProviderLD.js.map +0 -1
|
@@ -11,9 +11,6 @@ export class VeramoJsonWebSignature2020 extends VeramoLdSignature {
|
|
|
11
11
|
return 'JsonWebKey2020';
|
|
12
12
|
// TODO: add support for ['Ed25519VerificationKey2018', 'Ed25519VerificationKey2020', 'Multikey'] and others
|
|
13
13
|
}
|
|
14
|
-
getSupportedProofType() {
|
|
15
|
-
return 'JsonWebSignature2020';
|
|
16
|
-
}
|
|
17
14
|
getSupportedVeramoKeyType() {
|
|
18
15
|
return 'Ed25519';
|
|
19
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonWebSignature2020.js","sourceRoot":"","sources":["../../src/suites/JsonWebSignature2020.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACzE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAC5E,OAAO,EACL,OAAO,EACP,aAAa,EACb,gBAAgB,EAChB,MAAM,EACN,cAAc,EACd,UAAU,EACV,iBAAiB,GAClB,MAAM,eAAe,CAAA;AAEtB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{ CredentialPayload, IAgentContext, IDIDManager, IKey, IKeyManager, IPluginMethodMap, IResolver, PresentationPayload, UsingResolutionOptions, VerifiableCredential, VerifiablePresentation } from '@veramo/core-types';
|
|
2
|
+
/**
|
|
3
|
+
* The interface definition for a plugin that can issue and verify Verifiable Credentials and Presentations
|
|
4
|
+
* that use JSON-LD format (also called Data Integrity Proofs).
|
|
5
|
+
*
|
|
6
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model | W3C Verifiable Credentials data model}
|
|
7
|
+
* @see {@link https://www.w3.org/TR/vc-data-model/#data-integrity-proofs | Data Integrity proofs}
|
|
8
|
+
*
|
|
9
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
10
|
+
*/
|
|
11
|
+
export interface ICredentialIssuerLD extends IPluginMethodMap {
|
|
12
|
+
/**
|
|
13
|
+
* Creates a Verifiable Presentation.
|
|
14
|
+
* The payload, signer and format are chosen based on the `args` parameter.
|
|
15
|
+
*
|
|
16
|
+
* @param args - Arguments necessary to create the Presentation.
|
|
17
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
18
|
+
*
|
|
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
|
+
*
|
|
22
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#presentations | Verifiable Presentation data model
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
26
|
+
*/
|
|
27
|
+
createVerifiablePresentationLD(args: ICreateVerifiablePresentationLDArgs, context: IRequiredContext): Promise<VerifiablePresentation>;
|
|
28
|
+
/**
|
|
29
|
+
* Creates a Verifiable Credential.
|
|
30
|
+
* The payload, signer and format are chosen based on the `args` parameter.
|
|
31
|
+
*
|
|
32
|
+
* @param args - Arguments necessary to create the Presentation.
|
|
33
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
34
|
+
*
|
|
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
|
|
37
|
+
*
|
|
38
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#credentials | Verifiable Credential data model}
|
|
39
|
+
*
|
|
40
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
41
|
+
*/
|
|
42
|
+
createVerifiableCredentialLD(args: ICreateVerifiableCredentialLDArgs, context: IRequiredContext): Promise<VerifiableCredential>;
|
|
43
|
+
/**
|
|
44
|
+
* Verifies a Verifiable Credential JWT or LDS Format.
|
|
45
|
+
*
|
|
46
|
+
* @param args - Arguments necessary to verify a VerifiableCredential
|
|
47
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
48
|
+
*
|
|
49
|
+
* @returns - a promise that resolves to the boolean true on successful verification or rejects on error
|
|
50
|
+
*
|
|
51
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#credentials | Verifiable Credential data model}
|
|
52
|
+
*
|
|
53
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
54
|
+
*/
|
|
55
|
+
verifyCredentialLD(args: IVerifyCredentialLDArgs, context: IRequiredContext): Promise<boolean>;
|
|
56
|
+
/**
|
|
57
|
+
* Verifies a Verifiable Presentation JWT or LDS Format.
|
|
58
|
+
*
|
|
59
|
+
* @param args - Arguments necessary to verify a VerifiableCredential
|
|
60
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
61
|
+
*
|
|
62
|
+
* @returns - a promise that resolves to the boolean true on successful verification or rejects on error
|
|
63
|
+
*
|
|
64
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#presentations | Verifiable Credential data model}
|
|
65
|
+
*
|
|
66
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
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>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Encapsulates the parameters required to create a
|
|
80
|
+
* {@link https://www.w3.org/TR/vc-data-model/#presentations | W3C Verifiable Presentation}
|
|
81
|
+
*
|
|
82
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
83
|
+
*/
|
|
84
|
+
export interface ICreateVerifiablePresentationLDArgs extends UsingResolutionOptions {
|
|
85
|
+
/**
|
|
86
|
+
* The json payload of the Presentation according to the
|
|
87
|
+
* {@link https://www.w3.org/TR/vc-data-model/#presentations | canonical model}.
|
|
88
|
+
*
|
|
89
|
+
* The signer of the Presentation is chosen based on the `holder` property
|
|
90
|
+
* of the `presentation`
|
|
91
|
+
*
|
|
92
|
+
* `@context`, `type` and `issuanceDate` will be added automatically if omitted.
|
|
93
|
+
*/
|
|
94
|
+
presentation: PresentationPayload;
|
|
95
|
+
/**
|
|
96
|
+
* Optional (only JWT) string challenge parameter to add to the verifiable presentation.
|
|
97
|
+
*/
|
|
98
|
+
challenge?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Optional string domain parameter to add to the verifiable presentation.
|
|
101
|
+
*/
|
|
102
|
+
domain?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Optional. The key handle ({@link @veramo/core-types#IKey.kid | IKey.kid}) from the internal database.
|
|
105
|
+
*/
|
|
106
|
+
keyRef?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.
|
|
109
|
+
*
|
|
110
|
+
* Defaults to `false`
|
|
111
|
+
*/
|
|
112
|
+
fetchRemoteContexts?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Any other options that can be forwarded to the lower level libraries
|
|
115
|
+
*/
|
|
116
|
+
[x: string]: any;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Encapsulates the parameters required to create a
|
|
120
|
+
* {@link https://www.w3.org/TR/vc-data-model/#credentials | W3C Verifiable Credential}
|
|
121
|
+
*
|
|
122
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
123
|
+
*/
|
|
124
|
+
export interface ICreateVerifiableCredentialLDArgs extends UsingResolutionOptions {
|
|
125
|
+
/**
|
|
126
|
+
* The json payload of the Credential according to the
|
|
127
|
+
* {@link https://www.w3.org/TR/vc-data-model/#credentials | canonical model}
|
|
128
|
+
*
|
|
129
|
+
* The signer of the Credential is chosen based on the `issuer.id` property
|
|
130
|
+
* of the `credential`
|
|
131
|
+
*
|
|
132
|
+
* `@context`, `type` and `issuanceDate` will be added automatically if omitted
|
|
133
|
+
*/
|
|
134
|
+
credential: CredentialPayload;
|
|
135
|
+
/**
|
|
136
|
+
* Optional. The key handle ({@link @veramo/core-types#IKey.kid | IKey.kid}) from the internal database.
|
|
137
|
+
*/
|
|
138
|
+
keyRef?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.
|
|
141
|
+
*
|
|
142
|
+
* Defaults to `false`
|
|
143
|
+
*/
|
|
144
|
+
fetchRemoteContexts?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* Any other options that can be forwarded to the lower level libraries
|
|
147
|
+
*/
|
|
148
|
+
[x: string]: any;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Encapsulates the parameters required to verify a
|
|
152
|
+
* {@link https://www.w3.org/TR/vc-data-model/#credentials | W3C Verifiable Credential}
|
|
153
|
+
*
|
|
154
|
+
* @beta This API may change without a BREAKING CHANGE notice
|
|
155
|
+
*/
|
|
156
|
+
export interface IVerifyCredentialLDArgs extends UsingResolutionOptions {
|
|
157
|
+
/**
|
|
158
|
+
* The json payload of the Credential according to the
|
|
159
|
+
* {@link https://www.w3.org/TR/vc-data-model/#credentials | canonical model}
|
|
160
|
+
*
|
|
161
|
+
* The signer of the Credential is chosen based on the `issuer.id` property
|
|
162
|
+
* of the `credential`
|
|
163
|
+
*
|
|
164
|
+
*/
|
|
165
|
+
credential: VerifiableCredential;
|
|
166
|
+
/**
|
|
167
|
+
* Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.
|
|
168
|
+
*
|
|
169
|
+
* Defaults to `false`
|
|
170
|
+
*/
|
|
171
|
+
fetchRemoteContexts?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Any other options that can be forwarded to the lower level libraries
|
|
174
|
+
*/
|
|
175
|
+
[x: string]: any;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Encapsulates the parameters required to verify a
|
|
179
|
+
* {@link https://www.w3.org/TR/vc-data-model/#presentations | W3C Verifiable Presentation}
|
|
180
|
+
*
|
|
181
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
182
|
+
*/
|
|
183
|
+
export interface IVerifyPresentationLDArgs extends UsingResolutionOptions {
|
|
184
|
+
/**
|
|
185
|
+
* The json payload of the Credential according to the
|
|
186
|
+
* {@link https://www.w3.org/TR/vc-data-model/#credentials | canonical model}
|
|
187
|
+
*
|
|
188
|
+
* The signer of the Credential is chosen based on the `issuer.id` property
|
|
189
|
+
* of the `credential`
|
|
190
|
+
*
|
|
191
|
+
*/
|
|
192
|
+
presentation: VerifiablePresentation;
|
|
193
|
+
/**
|
|
194
|
+
* Optional (only for JWT) string challenge parameter to verify the verifiable presentation against
|
|
195
|
+
*/
|
|
196
|
+
challenge?: string;
|
|
197
|
+
/**
|
|
198
|
+
* Optional (only for JWT) string domain parameter to verify the verifiable presentation against
|
|
199
|
+
*/
|
|
200
|
+
domain?: string;
|
|
201
|
+
/**
|
|
202
|
+
* Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.
|
|
203
|
+
*
|
|
204
|
+
* Defaults to `false`
|
|
205
|
+
*/
|
|
206
|
+
fetchRemoteContexts?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* Any other options that can be forwarded to the lower level libraries
|
|
209
|
+
*/
|
|
210
|
+
[x: string]: any;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Represents the requirements that this plugin has.
|
|
214
|
+
* The agent that is using this plugin is expected to provide these methods.
|
|
215
|
+
*
|
|
216
|
+
* This interface can be used for static type checks, to make sure your application is properly initialized.
|
|
217
|
+
*
|
|
218
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
219
|
+
*/
|
|
220
|
+
export type IRequiredContext = IAgentContext<IResolver & Pick<IDIDManager, 'didManagerGet'> & Pick<IKeyManager, 'keyManagerGet' | 'keyManagerSign'>>;
|
|
1
221
|
/**
|
|
2
222
|
* Describes a document with a `@context` property.
|
|
3
223
|
*
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAChC,CAAA"}
|
|
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,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,oBAAoB,CAAA;AAE3B;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D;;;;;;;;;;;;;;OAcG;IACH,8BAA8B,CAC5B,IAAI,EAAE,mCAAmC,EACzC,OAAO,E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;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAwB,SAAQ,sBAAsB;IACrE;;;;;;;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,yBAA0B,SAAQ,sBAAsB;IACvE;;;;;;;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": "6.0.1
|
|
4
|
+
"version": "6.0.1",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./build/index.js"
|
|
@@ -9,7 +9,12 @@
|
|
|
9
9
|
"types": "build/index.d.ts",
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "tsc",
|
|
12
|
-
"
|
|
12
|
+
"generate-plugin-schema": "node ../cli/bin/veramo.js dev generate-plugin-schema"
|
|
13
|
+
},
|
|
14
|
+
"veramo": {
|
|
15
|
+
"pluginInterfaces": {
|
|
16
|
+
"ICredentialIssuerLD": "./src/action-handler.ts"
|
|
17
|
+
}
|
|
13
18
|
},
|
|
14
19
|
"dependencies": {
|
|
15
20
|
"@digitalcredentials/ed25519-signature-2020": "^4.0.0",
|
|
@@ -21,9 +26,8 @@
|
|
|
21
26
|
"@transmute/ed25519-signature-2018": "^0.7.0-unstable.81",
|
|
22
27
|
"@transmute/json-web-signature": "^0.7.0-unstable.81",
|
|
23
28
|
"@veramo-community/lds-ecdsa-secp256k1-recovery2020": "uport-project/EcdsaSecp256k1RecoverySignature2020",
|
|
24
|
-
"@veramo/core-types": "^6.0.1
|
|
25
|
-
"@veramo/
|
|
26
|
-
"@veramo/utils": "^6.0.1-next.8+018e189f3",
|
|
29
|
+
"@veramo/core-types": "^6.0.1",
|
|
30
|
+
"@veramo/utils": "^6.0.1",
|
|
27
31
|
"cross-fetch": "^4.0.0",
|
|
28
32
|
"debug": "^4.3.3",
|
|
29
33
|
"did-resolver": "^4.1.0"
|
|
@@ -77,5 +81,5 @@
|
|
|
77
81
|
"node_modules",
|
|
78
82
|
"src"
|
|
79
83
|
],
|
|
80
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "79ee5b2e7dd70ecd9c8431527052774c8521a64b"
|
|
81
85
|
}
|
|
@@ -1,143 +1,143 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
} from '../../../core/src'
|
|
11
|
-
import { CredentialPlugin } from '../../../credential-w3c/src'
|
|
12
|
-
import { DIDManager, MemoryDIDStore } from '../../../did-manager/src'
|
|
13
|
-
import { KeyManager, MemoryKeyStore, MemoryPrivateKeyStore } from '../../../key-manager/src'
|
|
14
|
-
import { KeyManagementSystem } from '../../../kms-local/src'
|
|
15
|
-
import { DIDResolverPlugin } from '../../../did-resolver/src'
|
|
16
|
-
import { ContextDoc } from '../types'
|
|
17
|
-
import {
|
|
18
|
-
import { LdDefaultContexts } from '../ld-default-contexts'
|
|
19
|
-
import { VeramoEd25519Signature2020 } from '../suites/Ed25519Signature2020'
|
|
20
|
-
import { Resolver } from 'did-resolver'
|
|
21
|
-
import { FakeDidProvider, FakeDidResolver } from '../../../test-utils/src/fake-did'
|
|
22
|
-
import { jest } from '@jest/globals'
|
|
2
|
+
createAgent,
|
|
3
|
+
CredentialPayload,
|
|
4
|
+
ICredentialPlugin,
|
|
5
|
+
IDIDManager,
|
|
6
|
+
IIdentifier,
|
|
7
|
+
IKeyManager,
|
|
8
|
+
IResolver,
|
|
9
|
+
TAgent,
|
|
10
|
+
} from '../../../core/src'
|
|
11
|
+
import { CredentialPlugin } from '../../../credential-w3c/src'
|
|
12
|
+
import { DIDManager, MemoryDIDStore } from '../../../did-manager/src'
|
|
13
|
+
import { KeyManager, MemoryKeyStore, MemoryPrivateKeyStore } from '../../../key-manager/src'
|
|
14
|
+
import { KeyManagementSystem } from '../../../kms-local/src'
|
|
15
|
+
import { DIDResolverPlugin } from '../../../did-resolver/src'
|
|
16
|
+
import { ContextDoc } from '../types'
|
|
17
|
+
import { CredentialIssuerLD } from '../action-handler'
|
|
18
|
+
import { LdDefaultContexts } from '../ld-default-contexts'
|
|
19
|
+
import { VeramoEd25519Signature2020 } from '../suites/Ed25519Signature2020'
|
|
20
|
+
import { Resolver } from 'did-resolver'
|
|
21
|
+
import { FakeDidProvider, FakeDidResolver } from '../../../test-utils/src/fake-did'
|
|
22
|
+
import { jest } from '@jest/globals'
|
|
23
23
|
|
|
24
|
-
jest.setTimeout(300000)
|
|
24
|
+
jest.setTimeout(300000)
|
|
25
25
|
|
|
26
|
-
const customContext: Record<string, ContextDoc> = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const customContext: Record<string, ContextDoc> = {
|
|
27
|
+
'custom:example.context': {
|
|
28
|
+
'@context': {
|
|
29
|
+
nothing: 'custom:example.context#blank',
|
|
30
|
+
},
|
|
30
31
|
},
|
|
31
|
-
}
|
|
32
|
-
}
|
|
32
|
+
}
|
|
33
33
|
|
|
34
|
-
describe('credential-LD full flow', () => {
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
describe('credential-LD full flow', () => {
|
|
35
|
+
let didFakeIdentifier: IIdentifier
|
|
36
|
+
let agent: TAgent<IResolver & IKeyManager & IDIDManager & ICredentialPlugin>
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
beforeAll(async () => {
|
|
39
|
+
agent = createAgent({
|
|
40
|
+
plugins: [
|
|
41
|
+
new KeyManager({
|
|
42
|
+
store: new MemoryKeyStore(),
|
|
43
|
+
kms: {
|
|
44
|
+
local: new KeyManagementSystem(new MemoryPrivateKeyStore()),
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
new DIDManager({
|
|
48
|
+
providers: {
|
|
49
|
+
'did:fake': new FakeDidProvider(),
|
|
50
|
+
},
|
|
51
|
+
store: new MemoryDIDStore(),
|
|
52
|
+
defaultProvider: 'did:fake',
|
|
53
|
+
}),
|
|
54
|
+
new DIDResolverPlugin({
|
|
55
|
+
resolver: new Resolver({
|
|
56
|
+
...new FakeDidResolver(() => agent, true).getDidFakeResolver(),
|
|
57
|
+
}),
|
|
58
|
+
}),
|
|
59
|
+
new CredentialPlugin(),
|
|
60
|
+
new CredentialIssuerLD({
|
|
61
|
+
contextMaps: [LdDefaultContexts, customContext],
|
|
62
|
+
suites: [new VeramoEd25519Signature2020()],
|
|
63
|
+
}),
|
|
64
|
+
],
|
|
65
|
+
})
|
|
66
|
+
didFakeIdentifier = await agent.didManagerImport({
|
|
67
|
+
did: 'did:fake:z6MkgbqNU4uF9NKSz5BqJQ4XKVHuQZYcUZP8pXGsJC8nTHwo',
|
|
68
|
+
keys: [
|
|
69
|
+
{
|
|
70
|
+
type: 'Ed25519',
|
|
71
|
+
kid: 'didcomm-senderKey-1',
|
|
72
|
+
publicKeyHex: '1fe9b397c196ab33549041b29cf93be29b9f2bdd27322f05844112fad97ff92a',
|
|
73
|
+
privateKeyHex:
|
|
74
|
+
'b57103882f7c66512dc96777cbafbeb2d48eca1e7a867f5a17a84e9a6740f7dc1fe9b397c196ab33549041b29cf93be29b9f2bdd27322f05844112fad97ff92a',
|
|
75
|
+
kms: 'local',
|
|
49
76
|
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
77
|
+
],
|
|
78
|
+
services: [
|
|
79
|
+
{
|
|
80
|
+
id: 'msg1',
|
|
81
|
+
type: 'DIDCommMessaging',
|
|
82
|
+
serviceEndpoint: 'http://localhost:3002/messaging',
|
|
54
83
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
resolver: new Resolver({
|
|
60
|
-
...new FakeDidResolver(() => agent, true).getDidFakeResolver(),
|
|
61
|
-
}),
|
|
62
|
-
}),
|
|
63
|
-
new CredentialPlugin({ issuers: [ld] }),
|
|
64
|
-
],
|
|
84
|
+
],
|
|
85
|
+
provider: 'did:fake',
|
|
86
|
+
alias: 'sender',
|
|
87
|
+
})
|
|
65
88
|
})
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
privateKeyHex:
|
|
74
|
-
'b57103882f7c66512dc96777cbafbeb2d48eca1e7a867f5a17a84e9a6740f7dc1fe9b397c196ab33549041b29cf93be29b9f2bdd27322f05844112fad97ff92a',
|
|
75
|
-
kms: 'local',
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
services: [
|
|
79
|
-
{
|
|
80
|
-
id: 'msg1',
|
|
81
|
-
type: 'DIDCommMessaging',
|
|
82
|
-
serviceEndpoint: 'http://localhost:3002/messaging',
|
|
89
|
+
|
|
90
|
+
it('works with Ed25519Signature2020 credential', async () => {
|
|
91
|
+
const credential: CredentialPayload = {
|
|
92
|
+
issuer: didFakeIdentifier.did,
|
|
93
|
+
'@context': ['custom:example.context'],
|
|
94
|
+
credentialSubject: {
|
|
95
|
+
nothing: 'else matters',
|
|
83
96
|
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
97
|
+
}
|
|
98
|
+
const verifiableCredential = await agent.createVerifiableCredential({
|
|
99
|
+
credential,
|
|
100
|
+
proofFormat: 'lds',
|
|
101
|
+
})
|
|
89
102
|
|
|
90
|
-
|
|
91
|
-
const credential: CredentialPayload = {
|
|
92
|
-
issuer: didFakeIdentifier.did,
|
|
93
|
-
'@context': ['custom:example.context'],
|
|
94
|
-
credentialSubject: {
|
|
95
|
-
nothing: 'else matters',
|
|
96
|
-
},
|
|
97
|
-
}
|
|
98
|
-
const verifiableCredential = await agent.createVerifiableCredential({
|
|
99
|
-
credential,
|
|
100
|
-
proofFormat: 'lds',
|
|
101
|
-
})
|
|
103
|
+
expect(verifiableCredential).toBeDefined()
|
|
102
104
|
|
|
103
|
-
|
|
105
|
+
const result = await agent.verifyCredential({
|
|
106
|
+
credential: verifiableCredential,
|
|
107
|
+
})
|
|
104
108
|
|
|
105
|
-
|
|
106
|
-
credential: verifiableCredential,
|
|
109
|
+
expect(result.verified).toBe(true)
|
|
107
110
|
})
|
|
108
111
|
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
it('works with Ed25519Signature2020 credential and presentation', async () => {
|
|
113
|
+
const credential: CredentialPayload = {
|
|
114
|
+
issuer: didFakeIdentifier.did,
|
|
115
|
+
'@context': ['custom:example.context'],
|
|
116
|
+
credentialSubject: {
|
|
117
|
+
nothing: 'else matters',
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
const verifiableCredential1 = await agent.createVerifiableCredential({
|
|
121
|
+
credential,
|
|
122
|
+
proofFormat: 'lds',
|
|
123
|
+
})
|
|
111
124
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const verifiableCredential1 = await agent.createVerifiableCredential({
|
|
121
|
-
credential,
|
|
122
|
-
proofFormat: 'lds',
|
|
123
|
-
})
|
|
125
|
+
const verifiablePresentation = await agent.createVerifiablePresentation({
|
|
126
|
+
presentation: {
|
|
127
|
+
verifiableCredential: [verifiableCredential1],
|
|
128
|
+
holder: didFakeIdentifier.did,
|
|
129
|
+
},
|
|
130
|
+
challenge: 'VERAMO',
|
|
131
|
+
proofFormat: 'lds',
|
|
132
|
+
})
|
|
124
133
|
|
|
125
|
-
|
|
126
|
-
presentation: {
|
|
127
|
-
verifiableCredential: [verifiableCredential1],
|
|
128
|
-
holder: didFakeIdentifier.did,
|
|
129
|
-
},
|
|
130
|
-
challenge: 'VERAMO',
|
|
131
|
-
proofFormat: 'lds',
|
|
132
|
-
})
|
|
134
|
+
expect(verifiablePresentation).toBeDefined()
|
|
133
135
|
|
|
134
|
-
|
|
136
|
+
const result = await agent.verifyPresentation({
|
|
137
|
+
presentation: verifiablePresentation,
|
|
138
|
+
challenge: 'VERAMO',
|
|
139
|
+
})
|
|
135
140
|
|
|
136
|
-
|
|
137
|
-
presentation: verifiablePresentation,
|
|
138
|
-
challenge: 'VERAMO',
|
|
141
|
+
expect(result.verified).toBe(true)
|
|
139
142
|
})
|
|
140
|
-
|
|
141
|
-
expect(result.verified).toBe(true)
|
|
142
143
|
})
|
|
143
|
-
})
|
|
@@ -16,7 +16,7 @@ import { getDidKeyResolver, KeyDIDProvider } from '../../../did-provider-key/src
|
|
|
16
16
|
import { DIDResolverPlugin } from '../../../did-resolver/src'
|
|
17
17
|
import { EthrDIDProvider } from '../../../did-provider-ethr/src'
|
|
18
18
|
import { ContextDoc } from '../types.js'
|
|
19
|
-
import {
|
|
19
|
+
import { CredentialIssuerLD } from '../action-handler.js'
|
|
20
20
|
import { LdDefaultContexts } from '../ld-default-contexts.js'
|
|
21
21
|
import { VeramoEd25519Signature2018 } from '../suites/Ed25519Signature2018.js'
|
|
22
22
|
import { Resolver } from 'did-resolver'
|
|
@@ -43,11 +43,6 @@ describe('credential-LD full flow', () => {
|
|
|
43
43
|
let didEthrIdentifier: IIdentifier
|
|
44
44
|
let agent: TAgent<IResolver & IKeyManager & IDIDManager & ICredentialPlugin>
|
|
45
45
|
|
|
46
|
-
const ld = new CredentialProviderLD({
|
|
47
|
-
contextMaps: [LdDefaultContexts, customContext],
|
|
48
|
-
suites: [new VeramoEd25519Signature2018(), new VeramoEcdsaSecp256k1RecoverySignature2020()],
|
|
49
|
-
})
|
|
50
|
-
|
|
51
46
|
beforeAll(async () => {
|
|
52
47
|
agent = createAgent<IResolver & IKeyManager & IDIDManager & ICredentialPlugin>({
|
|
53
48
|
plugins: [
|
|
@@ -74,7 +69,11 @@ describe('credential-LD full flow', () => {
|
|
|
74
69
|
...ethrDidResolver({ infuraProjectId }),
|
|
75
70
|
}),
|
|
76
71
|
}),
|
|
77
|
-
new CredentialPlugin(
|
|
72
|
+
new CredentialPlugin(),
|
|
73
|
+
new CredentialIssuerLD({
|
|
74
|
+
contextMaps: [LdDefaultContexts, customContext],
|
|
75
|
+
suites: [new VeramoEd25519Signature2018(), new VeramoEcdsaSecp256k1RecoverySignature2020()],
|
|
76
|
+
}),
|
|
78
77
|
],
|
|
79
78
|
})
|
|
80
79
|
didKeyIdentifier = await agent.didManagerCreate()
|