@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.
Files changed (55) hide show
  1. package/build/action-handler.d.ts +461 -0
  2. package/build/action-handler.d.ts.map +1 -0
  3. package/build/{CredentialProviderLD.js → action-handler.js} +25 -38
  4. package/build/action-handler.js.map +1 -0
  5. package/build/index.d.ts +4 -3
  6. package/build/index.d.ts.map +1 -1
  7. package/build/index.js +4 -3
  8. package/build/index.js.map +1 -1
  9. package/build/ld-credential-module.d.ts +4 -4
  10. package/build/ld-credential-module.d.ts.map +1 -1
  11. package/build/ld-credential-module.js.map +1 -1
  12. package/build/ld-default-contexts.d.ts +1 -1
  13. package/build/ld-default-contexts.js +1 -1
  14. package/build/ld-suites.d.ts +0 -1
  15. package/build/ld-suites.d.ts.map +1 -1
  16. package/build/ld-suites.js.map +1 -1
  17. package/build/plugin.schema.d.ts +430 -0
  18. package/build/plugin.schema.d.ts.map +1 -0
  19. package/build/plugin.schema.js +477 -0
  20. package/build/plugin.schema.js.map +1 -0
  21. package/build/suites/EcdsaSecp256k1RecoverySignature2020.d.ts +0 -1
  22. package/build/suites/EcdsaSecp256k1RecoverySignature2020.d.ts.map +1 -1
  23. package/build/suites/EcdsaSecp256k1RecoverySignature2020.js +0 -3
  24. package/build/suites/EcdsaSecp256k1RecoverySignature2020.js.map +1 -1
  25. package/build/suites/Ed25519Signature2018.d.ts +0 -1
  26. package/build/suites/Ed25519Signature2018.d.ts.map +1 -1
  27. package/build/suites/Ed25519Signature2018.js +0 -3
  28. package/build/suites/Ed25519Signature2018.js.map +1 -1
  29. package/build/suites/Ed25519Signature2020.d.ts +0 -1
  30. package/build/suites/Ed25519Signature2020.d.ts.map +1 -1
  31. package/build/suites/Ed25519Signature2020.js +0 -3
  32. package/build/suites/Ed25519Signature2020.js.map +1 -1
  33. package/build/suites/JsonWebSignature2020.d.ts +0 -1
  34. package/build/suites/JsonWebSignature2020.d.ts.map +1 -1
  35. package/build/suites/JsonWebSignature2020.js +0 -3
  36. package/build/suites/JsonWebSignature2020.js.map +1 -1
  37. package/build/types.d.ts +220 -0
  38. package/build/types.d.ts.map +1 -1
  39. package/package.json +10 -6
  40. package/src/__tests__/issue-verify-ed25519-2020.test.ts +122 -122
  41. package/src/__tests__/{issue-verify-flow-ld.test.ts → issue-verify-flow.test.ts} +6 -7
  42. package/src/{CredentialProviderLD.ts → action-handler.ts} +40 -61
  43. package/src/index.ts +4 -3
  44. package/src/ld-credential-module.ts +3 -4
  45. package/src/ld-default-contexts.ts +1 -1
  46. package/src/ld-suites.ts +0 -2
  47. package/src/plugin.schema.ts +476 -0
  48. package/src/suites/EcdsaSecp256k1RecoverySignature2020.ts +1 -6
  49. package/src/suites/Ed25519Signature2018.ts +0 -5
  50. package/src/suites/Ed25519Signature2020.ts +1 -5
  51. package/src/suites/JsonWebSignature2020.ts +1 -5
  52. package/src/types.ts +265 -0
  53. package/build/CredentialProviderLD.d.ts +0 -42
  54. package/build/CredentialProviderLD.d.ts.map +0 -1
  55. package/build/CredentialProviderLD.js.map +0 -1
@@ -0,0 +1,476 @@
1
+ export const schema = {
2
+ "ICredentialIssuerLD": {
3
+ "components": {
4
+ "schemas": {
5
+ "ICreateVerifiableCredentialLDArgs": {
6
+ "type": "object",
7
+ "properties": {
8
+ "resolutionOptions": {
9
+ "type": "object",
10
+ "properties": {
11
+ "publicKeyFormat": {
12
+ "type": "string"
13
+ },
14
+ "accept": {
15
+ "type": "string"
16
+ }
17
+ },
18
+ "description": "Options to be passed to the DID resolver."
19
+ },
20
+ "credential": {
21
+ "$ref": "#/components/schemas/CredentialPayload",
22
+ "description": "The json payload of the Credential according to the {@link https://www.w3.org/TR/vc-data-model/#credentials | canonical model } \n\nThe signer of the Credential is chosen based on the `issuer.id` property of the `credential`\n\n`@context`, `type` and `issuanceDate` will be added automatically if omitted"
23
+ },
24
+ "keyRef": {
25
+ "type": "string",
26
+ "description": "Optional. The key handle ( {@link @veramo/core-types#IKey.kid | IKey.kid } ) from the internal database."
27
+ },
28
+ "fetchRemoteContexts": {
29
+ "type": "boolean",
30
+ "description": "Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.\n\nDefaults to `false`"
31
+ }
32
+ },
33
+ "required": [
34
+ "credential"
35
+ ],
36
+ "additionalProperties": {
37
+ "description": "Any other options that can be forwarded to the lower level libraries"
38
+ },
39
+ "description": "Encapsulates the parameters required to create a {@link https://www.w3.org/TR/vc-data-model/#credentials | W3C Verifiable Credential }"
40
+ },
41
+ "CredentialPayload": {
42
+ "type": "object",
43
+ "properties": {
44
+ "issuer": {
45
+ "$ref": "#/components/schemas/IssuerType"
46
+ },
47
+ "credentialSubject": {
48
+ "$ref": "#/components/schemas/CredentialSubject"
49
+ },
50
+ "type": {
51
+ "type": "array",
52
+ "items": {
53
+ "type": "string"
54
+ }
55
+ },
56
+ "@context": {
57
+ "$ref": "#/components/schemas/ContextType"
58
+ },
59
+ "issuanceDate": {
60
+ "$ref": "#/components/schemas/DateType"
61
+ },
62
+ "expirationDate": {
63
+ "$ref": "#/components/schemas/DateType"
64
+ },
65
+ "credentialStatus": {
66
+ "$ref": "#/components/schemas/CredentialStatusReference"
67
+ },
68
+ "id": {
69
+ "type": "string"
70
+ }
71
+ },
72
+ "required": [
73
+ "issuer"
74
+ ],
75
+ "description": "Used as input when creating Verifiable Credentials"
76
+ },
77
+ "IssuerType": {
78
+ "anyOf": [
79
+ {
80
+ "type": "object",
81
+ "properties": {
82
+ "id": {
83
+ "type": "string"
84
+ }
85
+ },
86
+ "required": [
87
+ "id"
88
+ ]
89
+ },
90
+ {
91
+ "type": "string"
92
+ }
93
+ ],
94
+ "description": "The issuer of a {@link VerifiableCredential } or the holder of a {@link VerifiablePresentation } .\n\nThe value of the issuer property MUST be either a URI or an object containing an id property. It is RECOMMENDED that the URI in the issuer or its id be one which, if de-referenced, results in a document containing machine-readable information about the issuer that can be used to verify the information expressed in the credential.\n\nSee {@link https://www.w3.org/TR/vc-data-model/#issuer | Issuer data model }"
95
+ },
96
+ "CredentialSubject": {
97
+ "type": "object",
98
+ "properties": {
99
+ "id": {
100
+ "type": "string"
101
+ }
102
+ },
103
+ "description": "The value of the credentialSubject property is defined as a set of objects that contain one or more properties that are each related to a subject of the verifiable credential. Each object MAY contain an id.\n\nSee {@link https://www.w3.org/TR/vc-data-model/#credential-subject | Credential Subject }"
104
+ },
105
+ "ContextType": {
106
+ "anyOf": [
107
+ {
108
+ "type": "string"
109
+ },
110
+ {
111
+ "type": "object"
112
+ },
113
+ {
114
+ "type": "array",
115
+ "items": {
116
+ "anyOf": [
117
+ {
118
+ "type": "string"
119
+ },
120
+ {
121
+ "type": "object"
122
+ }
123
+ ]
124
+ }
125
+ }
126
+ ],
127
+ "description": "The data type for `@context` properties of credentials, presentations, etc."
128
+ },
129
+ "DateType": {
130
+ "type": "string",
131
+ "description": "Represents an issuance or expiration date for Credentials / Presentations. This is used as input when creating them."
132
+ },
133
+ "CredentialStatusReference": {
134
+ "type": "object",
135
+ "properties": {
136
+ "id": {
137
+ "type": "string"
138
+ },
139
+ "type": {
140
+ "type": "string"
141
+ }
142
+ },
143
+ "required": [
144
+ "id",
145
+ "type"
146
+ ],
147
+ "description": "Used for the discovery of information about the current status of a verifiable credential, such as whether it is suspended or revoked. The precise contents of the credential status information is determined by the specific `credentialStatus` type definition, and varies depending on factors such as whether it is simple to implement or if it is privacy-enhancing.\n\nSee {@link https://www.w3.org/TR/vc-data-model/#status | Credential Status }"
148
+ },
149
+ "VerifiableCredential": {
150
+ "type": "object",
151
+ "properties": {
152
+ "proof": {
153
+ "$ref": "#/components/schemas/ProofType"
154
+ },
155
+ "issuer": {
156
+ "$ref": "#/components/schemas/IssuerType"
157
+ },
158
+ "credentialSubject": {
159
+ "$ref": "#/components/schemas/CredentialSubject"
160
+ },
161
+ "type": {
162
+ "anyOf": [
163
+ {
164
+ "type": "array",
165
+ "items": {
166
+ "type": "string"
167
+ }
168
+ },
169
+ {
170
+ "type": "string"
171
+ }
172
+ ]
173
+ },
174
+ "@context": {
175
+ "$ref": "#/components/schemas/ContextType"
176
+ },
177
+ "issuanceDate": {
178
+ "type": "string"
179
+ },
180
+ "expirationDate": {
181
+ "type": "string"
182
+ },
183
+ "credentialStatus": {
184
+ "$ref": "#/components/schemas/CredentialStatusReference"
185
+ },
186
+ "id": {
187
+ "type": "string"
188
+ }
189
+ },
190
+ "required": [
191
+ "@context",
192
+ "credentialSubject",
193
+ "issuanceDate",
194
+ "issuer",
195
+ "proof"
196
+ ],
197
+ "description": "Represents a signed Verifiable Credential payload (includes proof), using a JSON representation. See {@link https://www.w3.org/TR/vc-data-model/#credentials | VC data model }"
198
+ },
199
+ "ProofType": {
200
+ "type": "object",
201
+ "properties": {
202
+ "type": {
203
+ "type": "string"
204
+ }
205
+ },
206
+ "description": "A proof property of a {@link VerifiableCredential } or {@link VerifiablePresentation }"
207
+ },
208
+ "ICreateVerifiablePresentationLDArgs": {
209
+ "type": "object",
210
+ "properties": {
211
+ "resolutionOptions": {
212
+ "type": "object",
213
+ "properties": {
214
+ "publicKeyFormat": {
215
+ "type": "string"
216
+ },
217
+ "accept": {
218
+ "type": "string"
219
+ }
220
+ },
221
+ "description": "Options to be passed to the DID resolver."
222
+ },
223
+ "presentation": {
224
+ "$ref": "#/components/schemas/PresentationPayload",
225
+ "description": "The json payload of the Presentation according to the {@link https://www.w3.org/TR/vc-data-model/#presentations | canonical model } .\n\nThe signer of the Presentation is chosen based on the `holder` property of the `presentation`\n\n`@context`, `type` and `issuanceDate` will be added automatically if omitted."
226
+ },
227
+ "challenge": {
228
+ "type": "string",
229
+ "description": "Optional (only JWT) string challenge parameter to add to the verifiable presentation."
230
+ },
231
+ "domain": {
232
+ "type": "string",
233
+ "description": "Optional string domain parameter to add to the verifiable presentation."
234
+ },
235
+ "keyRef": {
236
+ "type": "string",
237
+ "description": "Optional. The key handle ( {@link @veramo/core-types#IKey.kid | IKey.kid } ) from the internal database."
238
+ },
239
+ "fetchRemoteContexts": {
240
+ "type": "boolean",
241
+ "description": "Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.\n\nDefaults to `false`"
242
+ }
243
+ },
244
+ "required": [
245
+ "presentation"
246
+ ],
247
+ "additionalProperties": {
248
+ "description": "Any other options that can be forwarded to the lower level libraries"
249
+ },
250
+ "description": "Encapsulates the parameters required to create a {@link https://www.w3.org/TR/vc-data-model/#presentations | W3C Verifiable Presentation }"
251
+ },
252
+ "PresentationPayload": {
253
+ "type": "object",
254
+ "properties": {
255
+ "holder": {
256
+ "type": "string"
257
+ },
258
+ "verifiableCredential": {
259
+ "type": "array",
260
+ "items": {
261
+ "$ref": "#/components/schemas/W3CVerifiableCredential"
262
+ }
263
+ },
264
+ "type": {
265
+ "type": "array",
266
+ "items": {
267
+ "type": "string"
268
+ }
269
+ },
270
+ "@context": {
271
+ "$ref": "#/components/schemas/ContextType"
272
+ },
273
+ "verifier": {
274
+ "type": "array",
275
+ "items": {
276
+ "type": "string"
277
+ }
278
+ },
279
+ "issuanceDate": {
280
+ "$ref": "#/components/schemas/DateType"
281
+ },
282
+ "expirationDate": {
283
+ "$ref": "#/components/schemas/DateType"
284
+ },
285
+ "id": {
286
+ "type": "string"
287
+ }
288
+ },
289
+ "required": [
290
+ "holder"
291
+ ],
292
+ "description": "Used as input when creating Verifiable Presentations"
293
+ },
294
+ "W3CVerifiableCredential": {
295
+ "anyOf": [
296
+ {
297
+ "$ref": "#/components/schemas/VerifiableCredential"
298
+ },
299
+ {
300
+ "$ref": "#/components/schemas/CompactJWT"
301
+ }
302
+ ],
303
+ "description": "Represents a signed Verifiable Credential (includes proof), in either JSON or compact JWT format. See {@link https://www.w3.org/TR/vc-data-model/#credentials | VC data model } See {@link https://www.w3.org/TR/vc-data-model/#proof-formats | proof formats }"
304
+ },
305
+ "CompactJWT": {
306
+ "type": "string",
307
+ "description": "Represents a Json Web Token in compact form. \"header.payload.signature\""
308
+ },
309
+ "VerifiablePresentation": {
310
+ "type": "object",
311
+ "properties": {
312
+ "proof": {
313
+ "$ref": "#/components/schemas/ProofType"
314
+ },
315
+ "holder": {
316
+ "type": "string"
317
+ },
318
+ "verifiableCredential": {
319
+ "type": "array",
320
+ "items": {
321
+ "$ref": "#/components/schemas/W3CVerifiableCredential"
322
+ }
323
+ },
324
+ "type": {
325
+ "anyOf": [
326
+ {
327
+ "type": "array",
328
+ "items": {
329
+ "type": "string"
330
+ }
331
+ },
332
+ {
333
+ "type": "string"
334
+ }
335
+ ]
336
+ },
337
+ "@context": {
338
+ "$ref": "#/components/schemas/ContextType"
339
+ },
340
+ "verifier": {
341
+ "type": "array",
342
+ "items": {
343
+ "type": "string"
344
+ }
345
+ },
346
+ "issuanceDate": {
347
+ "type": "string"
348
+ },
349
+ "expirationDate": {
350
+ "type": "string"
351
+ },
352
+ "id": {
353
+ "type": "string"
354
+ }
355
+ },
356
+ "required": [
357
+ "@context",
358
+ "holder",
359
+ "proof"
360
+ ],
361
+ "description": "Represents a signed Verifiable Presentation (includes proof), using a JSON representation. See {@link https://www.w3.org/TR/vc-data-model/#presentations | VP data model }"
362
+ },
363
+ "IVerifyCredentialLDArgs": {
364
+ "type": "object",
365
+ "properties": {
366
+ "resolutionOptions": {
367
+ "type": "object",
368
+ "properties": {
369
+ "publicKeyFormat": {
370
+ "type": "string"
371
+ },
372
+ "accept": {
373
+ "type": "string"
374
+ }
375
+ },
376
+ "description": "Options to be passed to the DID resolver."
377
+ },
378
+ "credential": {
379
+ "$ref": "#/components/schemas/VerifiableCredential",
380
+ "description": "The json payload of the Credential according to the {@link https://www.w3.org/TR/vc-data-model/#credentials | canonical model } \n\nThe signer of the Credential is chosen based on the `issuer.id` property of the `credential`"
381
+ },
382
+ "fetchRemoteContexts": {
383
+ "type": "boolean",
384
+ "description": "Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.\n\nDefaults to `false`"
385
+ }
386
+ },
387
+ "required": [
388
+ "credential"
389
+ ],
390
+ "additionalProperties": {
391
+ "description": "Any other options that can be forwarded to the lower level libraries"
392
+ },
393
+ "description": "Encapsulates the parameters required to verify a {@link https://www.w3.org/TR/vc-data-model/#credentials | W3C Verifiable Credential }"
394
+ },
395
+ "IVerifyPresentationLDArgs": {
396
+ "type": "object",
397
+ "properties": {
398
+ "resolutionOptions": {
399
+ "type": "object",
400
+ "properties": {
401
+ "publicKeyFormat": {
402
+ "type": "string"
403
+ },
404
+ "accept": {
405
+ "type": "string"
406
+ }
407
+ },
408
+ "description": "Options to be passed to the DID resolver."
409
+ },
410
+ "presentation": {
411
+ "$ref": "#/components/schemas/VerifiablePresentation",
412
+ "description": "The json payload of the Credential according to the {@link https://www.w3.org/TR/vc-data-model/#credentials | canonical model } \n\nThe signer of the Credential is chosen based on the `issuer.id` property of the `credential`"
413
+ },
414
+ "challenge": {
415
+ "type": "string",
416
+ "description": "Optional (only for JWT) string challenge parameter to verify the verifiable presentation against"
417
+ },
418
+ "domain": {
419
+ "type": "string",
420
+ "description": "Optional (only for JWT) string domain parameter to verify the verifiable presentation against"
421
+ },
422
+ "fetchRemoteContexts": {
423
+ "type": "boolean",
424
+ "description": "Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.\n\nDefaults to `false`"
425
+ }
426
+ },
427
+ "required": [
428
+ "presentation"
429
+ ],
430
+ "additionalProperties": {
431
+ "description": "Any other options that can be forwarded to the lower level libraries"
432
+ },
433
+ "description": "Encapsulates the parameters required to verify a {@link https://www.w3.org/TR/vc-data-model/#presentations | W3C Verifiable Presentation }"
434
+ }
435
+ },
436
+ "methods": {
437
+ "createVerifiableCredentialLD": {
438
+ "description": "Creates a Verifiable Credential. The payload, signer and format are chosen based on the ",
439
+ "arguments": {
440
+ "$ref": "#/components/schemas/ICreateVerifiableCredentialLDArgs"
441
+ },
442
+ "returnType": {
443
+ "$ref": "#/components/schemas/VerifiableCredential"
444
+ }
445
+ },
446
+ "createVerifiablePresentationLD": {
447
+ "description": "Creates a Verifiable Presentation. The payload, signer and format are chosen based on the ",
448
+ "arguments": {
449
+ "$ref": "#/components/schemas/ICreateVerifiablePresentationLDArgs"
450
+ },
451
+ "returnType": {
452
+ "$ref": "#/components/schemas/VerifiablePresentation"
453
+ }
454
+ },
455
+ "verifyCredentialLD": {
456
+ "description": "Verifies a Verifiable Credential JWT or LDS Format.",
457
+ "arguments": {
458
+ "$ref": "#/components/schemas/IVerifyCredentialLDArgs"
459
+ },
460
+ "returnType": {
461
+ "type": "boolean"
462
+ }
463
+ },
464
+ "verifyPresentationLD": {
465
+ "description": "Verifies a Verifiable Presentation JWT or LDS Format.",
466
+ "arguments": {
467
+ "$ref": "#/components/schemas/IVerifyPresentationLDArgs"
468
+ },
469
+ "returnType": {
470
+ "type": "boolean"
471
+ }
472
+ }
473
+ }
474
+ }
475
+ }
476
+ }
@@ -17,11 +17,6 @@ export class VeramoEcdsaSecp256k1RecoverySignature2020 extends VeramoLdSignature
17
17
  // 'JsonWebKey2020', 'Multikey']
18
18
  }
19
19
 
20
- getSupportedProofType(): string {
21
- return 'EcdsaSecp256k1RecoverySignature2020'
22
- }
23
-
24
-
25
20
  getSupportedVeramoKeyType(): TKeyType {
26
21
  return 'Secp256k1'
27
22
  }
@@ -76,7 +71,7 @@ export class VeramoEcdsaSecp256k1RecoverySignature2020 extends VeramoLdSignature
76
71
  return new EcdsaSecp256k1RecoverySignature2020()
77
72
  }
78
73
 
79
- preSigningCredModification(credential: CredentialPayload): void { }
74
+ preSigningCredModification(credential: CredentialPayload): void {}
80
75
 
81
76
  async preDidResolutionModification(didUrl: string, didDoc: DIDDocument): Promise<DIDDocument> {
82
77
  const ctx = asArray(didDoc['@context'])
@@ -14,11 +14,6 @@ export class VeramoEd25519Signature2018 extends VeramoLdSignature {
14
14
  // TODO: add support for ['Ed25519VerificationKey2020', 'Multikey']
15
15
  }
16
16
 
17
- getSupportedProofType(): string {
18
- return 'Ed25519Signature2018'
19
- }
20
-
21
-
22
17
  getSupportedVeramoKeyType(): TKeyType {
23
18
  return 'Ed25519'
24
19
  }
@@ -35,10 +35,6 @@ export class VeramoEd25519Signature2020 extends VeramoLdSignature {
35
35
  // TODO: add support for ['JsonWebKey2020', 'Multikey']
36
36
  }
37
37
 
38
- getSupportedProofType(): string {
39
- return 'Ed25519Signature2020'
40
- }
41
-
42
38
  getSupportedVeramoKeyType(): TKeyType {
43
39
  return 'Ed25519'
44
40
  }
@@ -140,7 +136,7 @@ export class VeramoEd25519Signature2020 extends VeramoLdSignature {
140
136
 
141
137
  private transformVerificationMethod(vm: VerificationMethod): VerificationMethod {
142
138
  if (vm.type === 'Ed25519VerificationKey2020') {
143
- ; (vm as any)['@context'] = 'https://w3id.org/security/suites/ed25519-2020/v1'
139
+ ;(vm as any)['@context'] = 'https://w3id.org/security/suites/ed25519-2020/v1'
144
140
  // publicKeyMultibase is required by this suite
145
141
  if (!vm.publicKeyMultibase) {
146
142
  const { publicKeyHex } = extractPublicKeyHex(vm)
@@ -19,11 +19,7 @@ import {
19
19
  export class VeramoJsonWebSignature2020 extends VeramoLdSignature {
20
20
  getSupportedVerificationType(): string {
21
21
  return 'JsonWebKey2020'
22
- // TODO: add support for ['Ed25519VerificationKey2018', 'Ed25519VerificationKey2020', 'Multikey'] and others
23
- }
24
-
25
- getSupportedProofType(): string {
26
- return 'JsonWebSignature2020'
22
+ // TODO: add support for ['Ed25519VerificationKey2018', 'Ed25519VerificationKey2020', 'Multikey'] and others
27
23
  }
28
24
 
29
25
  getSupportedVeramoKeyType(): TKeyType {