@sphereon/ssi-sdk.credential-vcdm 0.33.1-feature.jose.vcdm.55
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/LICENSE +201 -0
- package/README.md +6 -0
- package/dist/index.cjs +406 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +547 -0
- package/dist/index.d.ts +547 -0
- package/dist/index.js +375 -0
- package/dist/index.js.map +1 -0
- package/package.json +93 -0
- package/src/__tests__/action-handler.test.ts +130 -0
- package/src/__tests__/issue-verify-flow-w3c.test.ts +250 -0
- package/src/__tests__/message-handler.test.ts +281 -0
- package/src/action-handler.ts +209 -0
- package/src/functions.ts +96 -0
- package/src/index.ts +25 -0
- package/src/message-handler.ts +167 -0
- package/src/types.ts +546 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
import { IPluginMethodMap, PresentationPayload, IAgentContext, IResolver, IDIDManager, CredentialPayload, VerifiableCredential, VerificationPolicies, IVerifyResult, VerifiablePresentation, IKey, ICredentialVerifier, IAgentPlugin, IIdentifier, W3CVerifiableCredential as W3CVerifiableCredential$1, W3CVerifiablePresentation as W3CVerifiablePresentation$1, ICredentialStatusVerifier } from '@veramo/core';
|
|
2
|
+
export { ICredentialIssuer, ICredentialVerifier } from '@veramo/core';
|
|
3
|
+
import { VerifiablePresentationSP, VerifiableCredentialSP } from '@sphereon/ssi-sdk.core';
|
|
4
|
+
import { ISphereonKeyManager } from '@sphereon/ssi-sdk-ext.key-manager';
|
|
5
|
+
import { IIssueCredentialStatusOpts } from '@sphereon/ssi-sdk.vc-status-list';
|
|
6
|
+
import { W3CVerifiableCredential, W3CVerifiablePresentation } from '@sphereon/ssi-types';
|
|
7
|
+
import { AbstractMessageHandler, Message } from '@veramo/message-handler';
|
|
8
|
+
|
|
9
|
+
type IVcdmCredentialPlugin = IVcdmCredentialIssuer & IVcdmCredentialVerifier;
|
|
10
|
+
/**
|
|
11
|
+
* Encapsulates the parameters required to check if a credential type can be issued
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
interface ICanIssueCredentialTypeArgs {
|
|
16
|
+
proofFormat: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Encapsulates the parameters required to check if a document can be verified
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
interface ICanVerifyDocumentTypeArgs {
|
|
24
|
+
/**
|
|
25
|
+
* The document to check against the verifier
|
|
26
|
+
*/
|
|
27
|
+
document: W3CVerifiableCredential | W3CVerifiablePresentation;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Encapsulates the parameters required to create a
|
|
31
|
+
* {@link https://www.w3.org/TR/vc-data-model/#presentations | W3C Verifiable Presentation}
|
|
32
|
+
*
|
|
33
|
+
* @beta This API is likely to change without a BREAKING CHANGE notice
|
|
34
|
+
*/
|
|
35
|
+
interface ICreateVerifiablePresentationLDArgs {
|
|
36
|
+
/**
|
|
37
|
+
* The json payload of the Presentation according to the
|
|
38
|
+
* {@link https://www.w3.org/TR/vc-data-model/#presentations | canonical model}.
|
|
39
|
+
*
|
|
40
|
+
* The signer of the Presentation is chosen based on the `holderDID` property
|
|
41
|
+
* of the `presentation`
|
|
42
|
+
*
|
|
43
|
+
* '@context', 'type' and 'issuanceDate' will be added automatically if omitted
|
|
44
|
+
*/
|
|
45
|
+
presentation: PresentationPayload;
|
|
46
|
+
/**
|
|
47
|
+
* Optional (only JWT) string challenge parameter to add to the verifiable presentation.
|
|
48
|
+
*/
|
|
49
|
+
challenge?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Optional string domain parameter to add to the verifiable presentation.
|
|
52
|
+
*/
|
|
53
|
+
domain?: string;
|
|
54
|
+
purpose?: IAuthenticationProofPurpose | IControllerProofPurpose | IAssertionProofPurpose | IProofPurpose;
|
|
55
|
+
/**
|
|
56
|
+
* The desired format for the VerifiableCredential to be created.
|
|
57
|
+
*/
|
|
58
|
+
proofFormat: string;
|
|
59
|
+
/**
|
|
60
|
+
* Remove payload members during JWT-JSON transformation. Defaults to `true`.
|
|
61
|
+
* See https://www.w3.org/TR/vc-data-model/#jwt-encoding
|
|
62
|
+
*/
|
|
63
|
+
removeOriginalFields?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* [Optional] The ID of the key that should sign this presentation.
|
|
66
|
+
* If this is not specified, the first matching key will be used.
|
|
67
|
+
*/
|
|
68
|
+
keyRef?: string;
|
|
69
|
+
/**
|
|
70
|
+
* When dealing with JSON-LD you also MUST provide the proper contexts.
|
|
71
|
+
* Set this to `true` ONLY if you want the `@context` URLs to be fetched in case they are not preloaded.
|
|
72
|
+
* The context definitions SHOULD rather be provided at startup instead of being fetched.
|
|
73
|
+
*
|
|
74
|
+
* Defaults to `false`
|
|
75
|
+
*/
|
|
76
|
+
fetchRemoteContexts?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Optional date to use for the `issuanceDate` or `validFrom` property depending on VCDM version being used.
|
|
79
|
+
* If not specified, the current date will be used.
|
|
80
|
+
*
|
|
81
|
+
*/
|
|
82
|
+
now?: Date | number;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Encapsulates the parameters required to create a
|
|
86
|
+
* {@link https://www.w3.org/TR/vc-data-model/#credentials | W3C Verifiable Credential}
|
|
87
|
+
*
|
|
88
|
+
* @beta This API is likely to change without a BREAKING CHANGE notice
|
|
89
|
+
*/
|
|
90
|
+
interface ICreateVerifiableCredentialLDArgs {
|
|
91
|
+
/**
|
|
92
|
+
* The JSON payload of the Credential according to the
|
|
93
|
+
* {@link https://www.w3.org/TR/vc-data-model/#credentials | canonical model}
|
|
94
|
+
*
|
|
95
|
+
* The signer of the Credential is chosen based on the `issuer.id` property
|
|
96
|
+
* of the `credential`
|
|
97
|
+
*
|
|
98
|
+
* `@context`, `type` and `issuanceDate` will be added automatically if omitted
|
|
99
|
+
*/
|
|
100
|
+
credential: CredentialPayload;
|
|
101
|
+
/**
|
|
102
|
+
* Optional date to use for the `issuanceDate` or `validFrom` property depending on VCDM version being used.
|
|
103
|
+
* If not specified, the current date will be used.
|
|
104
|
+
*
|
|
105
|
+
*/
|
|
106
|
+
now?: Date | number;
|
|
107
|
+
/**
|
|
108
|
+
* The desired format for the VerifiableCredential to be created.
|
|
109
|
+
*/
|
|
110
|
+
proofFormat: string;
|
|
111
|
+
/**
|
|
112
|
+
* Remove payload members during JWT-JSON transformation. Defaults to `true`.
|
|
113
|
+
* See https://www.w3.org/TR/vc-data-model/#jwt-encoding
|
|
114
|
+
*/
|
|
115
|
+
removeOriginalFields?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* [Optional] The ID of the key that should sign this credential.
|
|
118
|
+
* If this is not specified, the first matching key will be used.
|
|
119
|
+
*/
|
|
120
|
+
keyRef?: string;
|
|
121
|
+
/**
|
|
122
|
+
* When dealing with JSON-LD you also MUST provide the proper contexts.
|
|
123
|
+
* Set this to `true` ONLY if you want the `@context` URLs to be fetched in case they are not preloaded.
|
|
124
|
+
* The context definitions SHOULD rather be provided at startup instead of being fetched.
|
|
125
|
+
*
|
|
126
|
+
* Defaults to `false`
|
|
127
|
+
*/
|
|
128
|
+
fetchRemoteContexts?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Use this purpose for the verification method in the DID when doing a check (defaults to CredentialIssuancePurpose)
|
|
131
|
+
*/
|
|
132
|
+
purpose?: IAuthenticationProofPurpose | IControllerProofPurpose | IAssertionProofPurpose | IProofPurpose;
|
|
133
|
+
credentialStatusOpts?: IIssueCredentialStatusOpts;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Encapsulates the parameters required to verify a
|
|
137
|
+
* {@link https://www.w3.org/TR/vc-data-model/#credentials | W3C Verifiable Credential}
|
|
138
|
+
*
|
|
139
|
+
* @beta This API is likely to change without a BREAKING CHANGE notice
|
|
140
|
+
*/
|
|
141
|
+
interface IVerifyCredentialLDArgs {
|
|
142
|
+
/**
|
|
143
|
+
* The json payload of the Credential according to the
|
|
144
|
+
* {@link https://www.w3.org/TR/vc-data-model/#credentials | canonical model}
|
|
145
|
+
*
|
|
146
|
+
* The signer of the Credential is chosen based on the `issuer.id` property
|
|
147
|
+
* of the `credential`
|
|
148
|
+
*
|
|
149
|
+
*/
|
|
150
|
+
credential: VerifiableCredential;
|
|
151
|
+
/**
|
|
152
|
+
* Set this to true if you want the '@context' URLs to be fetched in case they are not pre-loaded.
|
|
153
|
+
*
|
|
154
|
+
* @default false
|
|
155
|
+
*/
|
|
156
|
+
fetchRemoteContexts?: boolean;
|
|
157
|
+
/**
|
|
158
|
+
* Overrides specific aspects of credential verification, where possible.
|
|
159
|
+
*/
|
|
160
|
+
policies?: VerificationPolicies;
|
|
161
|
+
/**
|
|
162
|
+
* Use this presentation purpose for the verification method in the DID when doing a check (defaults to CredentialIssuancePurpose)
|
|
163
|
+
*/
|
|
164
|
+
purpose?: IAuthenticationProofPurpose | IControllerProofPurpose | IAssertionProofPurpose | IProofPurpose;
|
|
165
|
+
/**
|
|
166
|
+
* Check status function, to check verifiableCredentials that have a credentialStatus property
|
|
167
|
+
*/
|
|
168
|
+
checkStatus?: Function;
|
|
169
|
+
/**
|
|
170
|
+
* Allows you to use the default integrated statusList 2021 support. If a checkStatus function is provided, this will be ignored
|
|
171
|
+
*/
|
|
172
|
+
statusList?: StatusListCheck;
|
|
173
|
+
}
|
|
174
|
+
interface StatusListCheck {
|
|
175
|
+
/**
|
|
176
|
+
* If no checkStatus function is given we default to a StatusList2021 check in case the VC has a credentialStatus. This boolean allows to disable this fallback check
|
|
177
|
+
*/
|
|
178
|
+
disableCheckStatusList2021?: boolean;
|
|
179
|
+
mandatoryCredentialStatus: boolean;
|
|
180
|
+
verifyStatusListCredential: boolean;
|
|
181
|
+
verifyMatchingIssuers: boolean;
|
|
182
|
+
errorUnknownListType?: boolean;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Encapsulates the parameters required to verify a
|
|
186
|
+
* {@link https://www.w3.org/TR/vc-data-model/#presentations | W3C Verifiable Presentation}
|
|
187
|
+
*
|
|
188
|
+
* @beta This API is likely to change without a BREAKING CHANGE notice
|
|
189
|
+
*/
|
|
190
|
+
interface IVerifyPresentationLDArgs {
|
|
191
|
+
/**
|
|
192
|
+
* The json payload of the Credential according to the
|
|
193
|
+
* {@link https://www.w3.org/TR/vc-data-model/#credentials | canonical model}
|
|
194
|
+
*
|
|
195
|
+
* The signer of the Credential is chosen based on the `issuer.id` property
|
|
196
|
+
* of the `credential`
|
|
197
|
+
*
|
|
198
|
+
*/
|
|
199
|
+
presentation: VerifiablePresentation;
|
|
200
|
+
/**
|
|
201
|
+
* Optional (only for JWT) string challenge parameter to verify the verifiable presentation against
|
|
202
|
+
*/
|
|
203
|
+
challenge?: string;
|
|
204
|
+
/**
|
|
205
|
+
* Optional (only for JWT) string domain parameter to verify the verifiable presentation against
|
|
206
|
+
*/
|
|
207
|
+
domain?: string;
|
|
208
|
+
/**
|
|
209
|
+
* Set this to true if you want the '@context' URLs to be fetched in case they are not pre-loaded.
|
|
210
|
+
*
|
|
211
|
+
* @default false
|
|
212
|
+
*/
|
|
213
|
+
fetchRemoteContexts?: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Overrides specific aspects of credential verification, where possible.
|
|
216
|
+
*/
|
|
217
|
+
policies?: VerificationPolicies;
|
|
218
|
+
/**
|
|
219
|
+
* Use this presentation purpose for the verification method in the DID when doing a check (defaualts to assertionMethod)
|
|
220
|
+
*/
|
|
221
|
+
presentationPurpose?: IAuthenticationProofPurpose | IControllerProofPurpose | IAssertionProofPurpose | IProofPurpose;
|
|
222
|
+
/**
|
|
223
|
+
* Check status function, to check verifiableCredentials that have a credentialStatus property
|
|
224
|
+
*/
|
|
225
|
+
checkStatus?: Function;
|
|
226
|
+
/**
|
|
227
|
+
* Allows you to use the default integrated statusList 2021 support. If a checkStatus function is provided, this will be ignored
|
|
228
|
+
*/
|
|
229
|
+
statusList?: StatusListCheck;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Represents the requirements that this plugin has.
|
|
233
|
+
* The agent that is using this plugin is expected to provide these methods.
|
|
234
|
+
*
|
|
235
|
+
* This interface can be used for static type checks, to make sure your application is properly initialized.
|
|
236
|
+
*
|
|
237
|
+
* @beta This API is likely to change without a BREAKING CHANGE notice
|
|
238
|
+
*/
|
|
239
|
+
/**
|
|
240
|
+
* Represents the requirements that this plugin has.
|
|
241
|
+
* The agent that is using this plugin is expected to provide these methods.
|
|
242
|
+
*
|
|
243
|
+
* This interface can be used for static type checks, to make sure your application is properly initialized.
|
|
244
|
+
*
|
|
245
|
+
* @beta
|
|
246
|
+
*/
|
|
247
|
+
type IVcdmIssuerAgentContext = IAgentContext<IResolver & IDIDManager & Pick<ISphereonKeyManager, 'keyManagerGet' | 'keyManagerSign' | 'keyManagerVerify'>>;
|
|
248
|
+
type ContextDoc = {
|
|
249
|
+
'@context': string | Record<string, any>;
|
|
250
|
+
};
|
|
251
|
+
interface IProofPurpose {
|
|
252
|
+
term?: string;
|
|
253
|
+
date?: string | Date | number;
|
|
254
|
+
maxTimestampDelta?: number;
|
|
255
|
+
}
|
|
256
|
+
interface IControllerProofPurpose extends IProofPurpose {
|
|
257
|
+
controller?: object;
|
|
258
|
+
}
|
|
259
|
+
interface IAuthenticationProofPurpose extends IControllerProofPurpose {
|
|
260
|
+
challenge?: string;
|
|
261
|
+
domain?: string;
|
|
262
|
+
}
|
|
263
|
+
interface IAssertionProofPurpose extends IControllerProofPurpose {
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* The interface definition for a plugin that can generate Verifiable Credentials and Presentations
|
|
267
|
+
*
|
|
268
|
+
* @see {@link @veramo/credential-w3c#CredentialPlugin} for an implementation.
|
|
269
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model | W3C Verifiable Credentials data model}
|
|
270
|
+
*
|
|
271
|
+
* @public
|
|
272
|
+
*/
|
|
273
|
+
interface IVcdmCredentialProvider {
|
|
274
|
+
/**
|
|
275
|
+
* Creates a Verifiable Presentation.
|
|
276
|
+
* The payload, signer and format are chosen based on the `args` parameter.
|
|
277
|
+
*
|
|
278
|
+
* @param args - Arguments necessary to create the Presentation.
|
|
279
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
280
|
+
*
|
|
281
|
+
* @returns - a promise that resolves to the {@link @veramo/core#VerifiablePresentation} that was requested or
|
|
282
|
+
* rejects with an error if there was a problem with the input or while getting the key to sign
|
|
283
|
+
*
|
|
284
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#presentations | Verifiable Presentation data model
|
|
285
|
+
* }
|
|
286
|
+
*/
|
|
287
|
+
createVerifiablePresentation(args: ICreateVerifiablePresentationLDArgs, context: IVcdmIssuerAgentContext): Promise<VerifiablePresentationSP>;
|
|
288
|
+
/**
|
|
289
|
+
* Creates a Verifiable Presentation.
|
|
290
|
+
* The payload, signer and format are chosen based on the `args` parameter.
|
|
291
|
+
*
|
|
292
|
+
* @param args - Arguments necessary to create the Presentation.
|
|
293
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
294
|
+
*
|
|
295
|
+
* @returns - a promise that resolves to the {@link @veramo/core#VerifiablePresentation} that was requested or
|
|
296
|
+
* rejects with an error if there was a problem with the input or while getting the key to sign
|
|
297
|
+
*
|
|
298
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#presentations | Verifiable Presentation data model
|
|
299
|
+
* }
|
|
300
|
+
*/
|
|
301
|
+
canIssueCredentialType(args: ICanIssueCredentialTypeArgs): boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Matches a key against the type of proof supported by this issuer
|
|
304
|
+
*
|
|
305
|
+
* @param key - The key to match against the proof type(s) supported by this issuer
|
|
306
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
307
|
+
*
|
|
308
|
+
* @returns - a promise that resolves to a boolean indicating if the key can be used to sign a credential with this issuer
|
|
309
|
+
*/
|
|
310
|
+
matchKeyForType(key: IKey): boolean;
|
|
311
|
+
/**
|
|
312
|
+
* Gets the proof type supported by this issuer
|
|
313
|
+
*
|
|
314
|
+
* @returns - a promise that resolves to a string of the proof format supported by this issuer
|
|
315
|
+
*/
|
|
316
|
+
getTypeProofFormat(): string;
|
|
317
|
+
/**
|
|
318
|
+
* Creates a Verifiable Credential.
|
|
319
|
+
* The payload, signer and format are chosen based on the `args` parameter.
|
|
320
|
+
*
|
|
321
|
+
* @param args - Arguments necessary to create the Presentation.
|
|
322
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
323
|
+
*
|
|
324
|
+
* @returns - a promise that resolves to the {@link @veramo/core#VerifiableCredential} that was requested or
|
|
325
|
+
* rejects with an error if there was a problem with the input or while getting the key to sign
|
|
326
|
+
*
|
|
327
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#credentials | Verifiable Credential data model}
|
|
328
|
+
*/
|
|
329
|
+
createVerifiableCredential(args: ICreateVerifiableCredentialLDArgs, context: IVcdmIssuerAgentContext): Promise<VerifiableCredentialSP>;
|
|
330
|
+
/**
|
|
331
|
+
* Verifies a Verifiable Credential
|
|
332
|
+
*
|
|
333
|
+
* @param args - Arguments necessary to verify a VerifiableCredential
|
|
334
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
335
|
+
*
|
|
336
|
+
* @returns - a promise that resolves to an object containing a `verified` boolean property and an optional `error`
|
|
337
|
+
* for details
|
|
338
|
+
*
|
|
339
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#credentials | Verifiable Credential data model}
|
|
340
|
+
*/
|
|
341
|
+
verifyCredential(args: IVerifyCredentialLDArgs, context: IVcdmVerifierAgentContext): Promise<IVerifyResult>;
|
|
342
|
+
/**
|
|
343
|
+
*
|
|
344
|
+
* @param args - Arguments necessary to verify a document
|
|
345
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
346
|
+
*
|
|
347
|
+
* @returns a promise that resolves to a boolean indicating if the document can be verified
|
|
348
|
+
*/
|
|
349
|
+
canVerifyDocumentType(args: ICanVerifyDocumentTypeArgs): boolean;
|
|
350
|
+
/**
|
|
351
|
+
* Verifies a Verifiable Presentation JWT or LDS Format.
|
|
352
|
+
*
|
|
353
|
+
* @param args - Arguments necessary to verify a VerifiableCredential
|
|
354
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
355
|
+
*
|
|
356
|
+
* @returns - a promise that resolves to an object containing a `verified` boolean property and an optional `error`
|
|
357
|
+
* for details
|
|
358
|
+
*
|
|
359
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#presentations | Verifiable Credential data model}
|
|
360
|
+
*/
|
|
361
|
+
verifyPresentation(args: IVerifyPresentationLDArgs, context: IVcdmVerifierAgentContext): Promise<IVerifyResult>;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* The interface definition for a plugin that can generate Verifiable Credentials and Presentations
|
|
365
|
+
*
|
|
366
|
+
* @see {@link @veramo/credential-w3c#CredentialPlugin} for an implementation.
|
|
367
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model | W3C Verifiable Credentials data model}
|
|
368
|
+
*
|
|
369
|
+
* @public
|
|
370
|
+
*/
|
|
371
|
+
interface IVcdmCredentialIssuer extends IPluginMethodMap {
|
|
372
|
+
/**
|
|
373
|
+
* Creates a Verifiable Presentation.
|
|
374
|
+
* The payload, signer and format are chosen based on the `args` parameter.
|
|
375
|
+
*
|
|
376
|
+
* @param args - Arguments necessary to create the Presentation.
|
|
377
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
378
|
+
*
|
|
379
|
+
* @returns - a promise that resolves to the {@link @veramo/core#VerifiablePresentation} that was requested or
|
|
380
|
+
* rejects with an error if there was a problem with the input or while getting the key to sign
|
|
381
|
+
*
|
|
382
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#presentations | Verifiable Presentation data model
|
|
383
|
+
* }
|
|
384
|
+
*/
|
|
385
|
+
createVerifiablePresentation(args: ICreateVerifiablePresentationLDArgs, context: IVcdmIssuerAgentContext): Promise<VerifiablePresentationSP>;
|
|
386
|
+
/**
|
|
387
|
+
* Creates a Verifiable Credential.
|
|
388
|
+
* The payload, signer and format are chosen based on the `args` parameter.
|
|
389
|
+
*
|
|
390
|
+
* @param args - Arguments necessary to create the Presentation.
|
|
391
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
392
|
+
*
|
|
393
|
+
* @returns - a promise that resolves to the {@link @veramo/core#VerifiableCredential} that was requested or rejects
|
|
394
|
+
* with an error if there was a problem with the input or while getting the key to sign
|
|
395
|
+
*
|
|
396
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#credentials | Verifiable Credential data model}
|
|
397
|
+
*/
|
|
398
|
+
createVerifiableCredential(args: ICreateVerifiableCredentialLDArgs, context: IVcdmIssuerAgentContext): Promise<VerifiableCredentialSP>;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* The interface definition for a plugin that can generate Verifiable Credentials and Presentations
|
|
402
|
+
*
|
|
403
|
+
* @see {@link @veramo/credential-w3c#CredentialPlugin} for an implementation.
|
|
404
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model | W3C Verifiable Credentials data model}
|
|
405
|
+
*
|
|
406
|
+
* @public
|
|
407
|
+
*/
|
|
408
|
+
interface IVcdmCredentialVerifier extends IPluginMethodMap {
|
|
409
|
+
/**
|
|
410
|
+
* Verifies a Verifiable Credential
|
|
411
|
+
*
|
|
412
|
+
* @param args - Arguments necessary to verify a VerifiableCredential
|
|
413
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
414
|
+
*
|
|
415
|
+
* @returns - a promise that resolves to an object containing a `verified` boolean property and an optional `error`
|
|
416
|
+
* for details
|
|
417
|
+
*
|
|
418
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#credentials | Verifiable Credential data model}
|
|
419
|
+
*/
|
|
420
|
+
verifyCredential(args: IVerifyCredentialLDArgs, context: IVcdmVerifierAgentContext): Promise<IVerifyResult>;
|
|
421
|
+
/**
|
|
422
|
+
* Verifies a Verifiable Presentation JWT or LDS Format.
|
|
423
|
+
*
|
|
424
|
+
* @param args - Arguments necessary to verify a VerifiableCredential
|
|
425
|
+
* @param context - This reserved param is automatically added and handled by the framework, *do not override*
|
|
426
|
+
*
|
|
427
|
+
* @returns - a promise that resolves to an object containing a `verified` boolean property and an optional `error`
|
|
428
|
+
* for details
|
|
429
|
+
*
|
|
430
|
+
* @remarks Please see {@link https://www.w3.org/TR/vc-data-model/#presentations | Verifiable Credential data model}
|
|
431
|
+
*/
|
|
432
|
+
verifyPresentation(args: IVerifyPresentationLDArgs, context: IVcdmVerifierAgentContext): Promise<IVerifyResult>;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Represents the requirements that this plugin has.
|
|
436
|
+
* The agent that is using this plugin is expected to provide these methods.
|
|
437
|
+
*
|
|
438
|
+
* This interface can be used for static type checks, to make sure your application is properly initialized.
|
|
439
|
+
*
|
|
440
|
+
* @beta
|
|
441
|
+
*/
|
|
442
|
+
type IVcdmVerifierAgentContext = IAgentContext<IResolver & Pick<IDIDManager, 'didManagerGet' | 'didManagerFind'>>;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* These types are used by `@veramo/data-store` when storing Verifiable Credentials and Presentations
|
|
446
|
+
*
|
|
447
|
+
* @internal
|
|
448
|
+
*/
|
|
449
|
+
declare const MessageTypes: {
|
|
450
|
+
/** Represents a Verifiable Credential */
|
|
451
|
+
vc: string;
|
|
452
|
+
/** Represents a Verifiable Presentation */
|
|
453
|
+
vp: string;
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* Represents the requirements that this plugin has.
|
|
457
|
+
* The agent that is using this plugin is expected to provide these methods.
|
|
458
|
+
*
|
|
459
|
+
* This interface can be used for static type checks, to make sure your application is properly initialized.
|
|
460
|
+
*/
|
|
461
|
+
type IContext = IAgentContext<IResolver & ICredentialVerifier>;
|
|
462
|
+
/**
|
|
463
|
+
* An implementation of the {@link @veramo/message-handler#AbstractMessageHandler}.
|
|
464
|
+
*
|
|
465
|
+
* This plugin can handle incoming W3C Verifiable Credentials and Presentations and prepare them
|
|
466
|
+
* for internal storage as {@link @veramo/message-handler#Message} types.
|
|
467
|
+
*
|
|
468
|
+
* The current version can only handle `JWT` encoded
|
|
469
|
+
*
|
|
470
|
+
* @remarks {@link @veramo/core#IDataStore | IDataStore }
|
|
471
|
+
*
|
|
472
|
+
* @public
|
|
473
|
+
*/
|
|
474
|
+
declare class W3cMessageHandler extends AbstractMessageHandler {
|
|
475
|
+
handle(message: Message, context: IContext): Promise<Message>;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* A plugin that implements the {@link @sphereon/ssi-sdk.credential-vcdm#IVcdmCredentialPlugin} methods.
|
|
480
|
+
*
|
|
481
|
+
* @public
|
|
482
|
+
*/
|
|
483
|
+
declare class VcdmCredentialPlugin implements IAgentPlugin {
|
|
484
|
+
readonly methods: IVcdmCredentialPlugin;
|
|
485
|
+
readonly schema: {
|
|
486
|
+
components: {
|
|
487
|
+
schemas: any;
|
|
488
|
+
methods: any;
|
|
489
|
+
};
|
|
490
|
+
};
|
|
491
|
+
private issuers;
|
|
492
|
+
constructor(options: {
|
|
493
|
+
issuers: IVcdmCredentialProvider[];
|
|
494
|
+
});
|
|
495
|
+
listUsableProofFormats(did: IIdentifier, context: IVcdmIssuerAgentContext): Promise<string[]>;
|
|
496
|
+
/** {@inheritdoc @veramo/core#ICredentialIssuer.createVerifiableCredential} */
|
|
497
|
+
createVerifiableCredential(args: ICreateVerifiableCredentialLDArgs, context: IVcdmIssuerAgentContext): Promise<VerifiableCredentialSP>;
|
|
498
|
+
/** {@inheritdoc @veramo/core#ICredentialVerifier.verifyCredential} */
|
|
499
|
+
verifyCredential(args: IVerifyCredentialLDArgs, context: IVcdmVerifierAgentContext): Promise<IVerifyResult>;
|
|
500
|
+
/** {@inheritdoc @veramo/core#ICredentialIssuer.createVerifiablePresentation} */
|
|
501
|
+
createVerifiablePresentation(args: ICreateVerifiablePresentationLDArgs, context: IVcdmIssuerAgentContext): Promise<VerifiablePresentationSP>;
|
|
502
|
+
/** {@inheritdoc @veramo/core#ICredentialVerifier.verifyPresentation} */
|
|
503
|
+
verifyPresentation(args: IVerifyPresentationLDArgs, context: IVcdmVerifierAgentContext): Promise<IVerifyResult>;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Decodes a credential or presentation and returns the issuer ID
|
|
508
|
+
* `iss` from a JWT or `issuer`/`issuer.id` from a VC or `holder` from a VP
|
|
509
|
+
*
|
|
510
|
+
* @param input - the credential or presentation whose issuer/holder needs to be extracted.
|
|
511
|
+
* @param options - options for the extraction
|
|
512
|
+
* removeParameters - Remove all DID parameters from the issuer ID
|
|
513
|
+
*
|
|
514
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
515
|
+
*/
|
|
516
|
+
declare function extractIssuer(input?: W3CVerifiableCredential$1 | W3CVerifiablePresentation$1 | CredentialPayload | PresentationPayload | null, options?: {
|
|
517
|
+
removeParameters?: boolean;
|
|
518
|
+
}): string;
|
|
519
|
+
/**
|
|
520
|
+
* Remove all DID parameters from a DID url after the query part (?)
|
|
521
|
+
*
|
|
522
|
+
* @param did - the DID URL
|
|
523
|
+
*
|
|
524
|
+
* @beta This API may change without a BREAKING CHANGE notice.
|
|
525
|
+
*/
|
|
526
|
+
declare function removeDIDParameters(did: string): string;
|
|
527
|
+
declare function pickSigningKey(identifier: IIdentifier, keyRef?: string): IKey;
|
|
528
|
+
declare function isRevoked(credential: VerifiableCredential, context: IAgentContext<ICredentialStatusVerifier>): Promise<boolean>;
|
|
529
|
+
|
|
530
|
+
/**
|
|
531
|
+
* Provides a {@link @veramo/credential-w3c#CredentialPlugin | plugin} for the {@link @veramo/core#Agent} that
|
|
532
|
+
* implements
|
|
533
|
+
* {@link @veramo/core#ICredentialIssuer} interface.
|
|
534
|
+
*
|
|
535
|
+
* Provides a {@link @veramo/credential-w3c#W3cMessageHandler | plugin} for the
|
|
536
|
+
* {@link @veramo/message-handler#MessageHandler} that verifies Credentials and Presentations in a message.
|
|
537
|
+
*
|
|
538
|
+
* @packageDocumentation
|
|
539
|
+
*/
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* @deprecated please use {@link VcdmCredentialPlugin} instead
|
|
543
|
+
* @public
|
|
544
|
+
*/
|
|
545
|
+
declare const CredentialIssuer: typeof VcdmCredentialPlugin;
|
|
546
|
+
|
|
547
|
+
export { type ContextDoc, CredentialIssuer, type IAssertionProofPurpose, type IAuthenticationProofPurpose, type ICanIssueCredentialTypeArgs, type ICanVerifyDocumentTypeArgs, type IControllerProofPurpose, type ICreateVerifiableCredentialLDArgs, type ICreateVerifiablePresentationLDArgs, type IProofPurpose, type IVcdmCredentialIssuer, type IVcdmCredentialPlugin, type IVcdmCredentialProvider, type IVcdmCredentialVerifier, type IVcdmIssuerAgentContext, type IVcdmVerifierAgentContext, type IVerifyCredentialLDArgs, type IVerifyPresentationLDArgs, MessageTypes, type StatusListCheck, VcdmCredentialPlugin, W3cMessageHandler, extractIssuer, isRevoked, pickSigningKey, removeDIDParameters };
|