@veramo/credential-ld 4.2.1-next.6 → 4.2.1-unstable.9

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 (60) hide show
  1. package/build/action-handler.d.ts +389 -3
  2. package/build/action-handler.d.ts.map +1 -1
  3. package/build/action-handler.js +118 -136
  4. package/build/action-handler.js.map +1 -1
  5. package/build/index.d.ts +8 -16
  6. package/build/index.d.ts.map +1 -1
  7. package/build/index.js +8 -36
  8. package/build/index.js.map +1 -1
  9. package/build/ld-context-loader.d.ts +1 -1
  10. package/build/ld-context-loader.d.ts.map +1 -1
  11. package/build/ld-context-loader.js +6 -20
  12. package/build/ld-context-loader.js.map +1 -1
  13. package/build/ld-credential-module.d.ts +3 -3
  14. package/build/ld-credential-module.d.ts.map +1 -1
  15. package/build/ld-credential-module.js +72 -85
  16. package/build/ld-credential-module.js.map +1 -1
  17. package/build/ld-default-contexts.d.ts +315 -1
  18. package/build/ld-default-contexts.d.ts.map +1 -1
  19. package/build/ld-default-contexts.js +28 -17
  20. package/build/ld-default-contexts.js.map +1 -1
  21. package/build/ld-suite-loader.d.ts +1 -1
  22. package/build/ld-suite-loader.d.ts.map +1 -1
  23. package/build/ld-suite-loader.js +4 -9
  24. package/build/ld-suite-loader.js.map +1 -1
  25. package/build/ld-suites.js +2 -7
  26. package/build/ld-suites.js.map +1 -1
  27. package/build/plugin.schema.json +430 -0
  28. package/build/suites/EcdsaSecp256k1RecoverySignature2020.d.ts +1 -1
  29. package/build/suites/EcdsaSecp256k1RecoverySignature2020.d.ts.map +1 -1
  30. package/build/suites/EcdsaSecp256k1RecoverySignature2020.js +16 -52
  31. package/build/suites/EcdsaSecp256k1RecoverySignature2020.js.map +1 -1
  32. package/build/suites/Ed25519Signature2018.d.ts +1 -1
  33. package/build/suites/Ed25519Signature2018.d.ts.map +1 -1
  34. package/build/suites/Ed25519Signature2018.js +12 -48
  35. package/build/suites/Ed25519Signature2018.js.map +1 -1
  36. package/build/suites/Ed25519Signature2020.d.ts +1 -1
  37. package/build/suites/Ed25519Signature2020.d.ts.map +1 -1
  38. package/build/suites/Ed25519Signature2020.js +16 -54
  39. package/build/suites/Ed25519Signature2020.js.map +1 -1
  40. package/build/suites/JsonWebSignature2020.d.ts +1 -1
  41. package/build/suites/JsonWebSignature2020.d.ts.map +1 -1
  42. package/build/suites/JsonWebSignature2020.js +44 -82
  43. package/build/suites/JsonWebSignature2020.js.map +1 -1
  44. package/build/tsdoc-metadata.json +1 -1
  45. package/build/types.js +1 -2
  46. package/package.json +20 -9
  47. package/src/__tests__/context.loader.test.ts +3 -3
  48. package/src/__tests__/issue-verify-flow.test.ts +7 -5
  49. package/src/action-handler.ts +8 -7
  50. package/src/index.ts +8 -17
  51. package/src/ld-context-loader.ts +1 -1
  52. package/src/ld-credential-module.ts +5 -4
  53. package/src/ld-default-contexts.ts +27 -14
  54. package/src/ld-suite-loader.ts +1 -1
  55. package/src/module-types/jsonld/index.d.ts +0 -1
  56. package/{plugin.schema.json → src/plugin.schema.json} +0 -0
  57. package/src/suites/EcdsaSecp256k1RecoverySignature2020.ts +4 -4
  58. package/src/suites/Ed25519Signature2018.ts +1 -1
  59. package/src/suites/Ed25519Signature2020.ts +4 -3
  60. package/src/suites/JsonWebSignature2020.ts +1 -1
@@ -1,21 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LdSuiteLoader = void 0;
4
1
  /**
5
2
  * Initializes a list of Veramo-wrapped LD Signature suites and exposes those to the Agent Module
6
3
  */
7
- class LdSuiteLoader {
4
+ export class LdSuiteLoader {
8
5
  constructor(options) {
9
- this.signatureMap = {};
10
6
  options.veramoLdSignatures.forEach((obj) => {
11
7
  const keyType = obj.getSupportedVeramoKeyType();
12
8
  const verificationType = obj.getSupportedVerificationType();
13
- return this.signatureMap[keyType] = Object.assign(Object.assign({}, this.signatureMap[keyType]), { [verificationType]: obj });
9
+ return this.signatureMap[keyType] = { ...this.signatureMap[keyType], [verificationType]: obj };
14
10
  });
15
11
  }
12
+ signatureMap = {};
16
13
  getSignatureSuiteForKeyType(type, verificationType) {
17
- var _a;
18
- const suite = (_a = this.signatureMap[type]) === null || _a === void 0 ? void 0 : _a[verificationType];
14
+ const suite = this.signatureMap[type]?.[verificationType];
19
15
  if (suite)
20
16
  return suite;
21
17
  throw new Error('No Veramo LD Signature Suite for ' + type);
@@ -27,5 +23,4 @@ class LdSuiteLoader {
27
23
  return Object.values(this.signatureMap).map((x) => Object.keys(x)).flat();
28
24
  }
29
25
  }
30
- exports.LdSuiteLoader = LdSuiteLoader;
31
26
  //# sourceMappingURL=ld-suite-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ld-suite-loader.js","sourceRoot":"","sources":["../src/ld-suite-loader.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,MAAa,aAAa;IACxB,YAAY,OAAoD;QAOxD,iBAAY,GAAsD,EAAE,CAAA;QAN1E,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACzC,MAAM,OAAO,GAAG,GAAG,CAAC,yBAAyB,EAAE,CAAA;YAC/C,MAAM,gBAAgB,GAAG,GAAG,CAAC,4BAA4B,EAAE,CAAA;YAC3D,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,mCAAQ,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,KAAE,CAAC,gBAAgB,CAAC,EAAE,GAAG,GAAE,CAAA;QAChG,CAAC,CAAC,CAAA;IACJ,CAAC;IAGD,2BAA2B,CAAC,IAAc,EAAE,gBAAwB;;QAClE,MAAM,KAAK,GAAG,MAAA,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,0CAAG,gBAAgB,CAAC,CAAA;QACzD,IAAI,KAAK;YAAE,OAAO,KAAK,CAAA;QAEvB,MAAM,IAAI,KAAK,CAAC,mCAAmC,GAAG,IAAI,CAAC,CAAA;IAC7D,CAAC;IAED,qBAAqB;QACnB,O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AC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IAC7E,CAAC;IAED,yBAAyB;QACvB,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;IAC3E,CAAC;CACF"}
@@ -1,21 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VeramoLdSignature = void 0;
4
1
  /**
5
2
  * Base class for Veramo adapters of LinkedDataSignature suites.
6
3
  *
7
4
  * @alpha This API is experimental and is very likely to change or disappear in future releases without notice.
8
5
  */
9
- class VeramoLdSignature {
6
+ export class VeramoLdSignature {
10
7
  preSigningPresModification(presentation) {
11
- var _a;
12
8
  // TODO: Remove invalid field 'verifiers' from Presentation. Needs to be adapted for LD credentials
13
9
  // Only remove empty array (vc.signPresentation will throw then)
14
10
  const sanitizedPresentation = presentation;
15
- if (((_a = sanitizedPresentation === null || sanitizedPresentation === void 0 ? void 0 : sanitizedPresentation.verifier) === null || _a === void 0 ? void 0 : _a.length) == 0) {
11
+ if (sanitizedPresentation?.verifier?.length == 0) {
16
12
  delete sanitizedPresentation.verifier;
17
13
  }
18
14
  }
19
15
  }
20
- exports.VeramoLdSignature = VeramoLdSignature;
21
16
  //# sourceMappingURL=ld-suites.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ld-suites.js","sourceRoot":"","sources":["../src/ld-suites.ts"],"names":[],"mappings":";;;AAaA;;;;GAIG;AACH,MAAsB,iBAAiB;IAuBrC,0BAA0B,CAAC,YAAiC;;QAC1D,mGAAmG;QACnG,gEAAgE;QAChE,MAAM,qBAAqB,GAAG,YAAmB,CAAA;QACjD,IAAI,CAAA,MAAA,qBAAqB,aAArB,qBAAqB,uBAArB,qBAAqB,CAAE,QAAQ,0CAAE,MAAM,KAAI,CAAC,EAAE;YAChD,OAAO,qBAAqB,CAAC,QAAQ,CAAA;SACtC;IACH,CAAC;CACF;AA/BD,8CA+BC"}
1
+ {"version":3,"file":"ld-suites.js","sourceRoot":"","sources":["../src/ld-suites.ts"],"names":[],"mappings":"AAaA;;;;GAIG;AACH,MAAM,OAAgB,iBAAiB;IAuBrC,0BAA0B,CAAC,YAAiC;QAC1D,mGAAmG;QACnG,gEAAgE;QAChE,MAAM,qBAAqB,GAAG,YAAmB,CAAA;QACjD,IAAI,qBAAqB,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC,EAAE;YAChD,OAAO,qBAAqB,CAAC,QAAQ,CAAA;SACtC;IACH,CAAC;CACF"}
@@ -0,0 +1,430 @@
1
+ {
2
+ "ICredentialIssuerLD": {
3
+ "components": {
4
+ "schemas": {
5
+ "ICreateVerifiableCredentialLDArgs": {
6
+ "type": "object",
7
+ "properties": {
8
+ "credential": {
9
+ "$ref": "#/components/schemas/CredentialPayload",
10
+ "description": "The json payload of the Credential according to the\n {@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"
11
+ },
12
+ "keyRef": {
13
+ "type": "string",
14
+ "description": "Optional. The key handle ( {@link @veramo/core#IKey.kid | IKey.kid } ) from the internal database."
15
+ },
16
+ "fetchRemoteContexts": {
17
+ "type": "boolean",
18
+ "description": "Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.\n\nDefaults to `false`"
19
+ }
20
+ },
21
+ "required": [
22
+ "credential"
23
+ ],
24
+ "additionalProperties": {
25
+ "description": "Any other options that can be forwarded to the lower level libraries"
26
+ },
27
+ "description": "Encapsulates the parameters required to create a\n {@link https://www.w3.org/TR/vc-data-model/#credentials | W3C Verifiable Credential }"
28
+ },
29
+ "CredentialPayload": {
30
+ "type": "object",
31
+ "properties": {
32
+ "issuer": {
33
+ "$ref": "#/components/schemas/IssuerType"
34
+ },
35
+ "credentialSubject": {
36
+ "$ref": "#/components/schemas/CredentialSubject"
37
+ },
38
+ "type": {
39
+ "type": "array",
40
+ "items": {
41
+ "type": "string"
42
+ }
43
+ },
44
+ "@context": {
45
+ "type": "array",
46
+ "items": {
47
+ "type": "string"
48
+ }
49
+ },
50
+ "issuanceDate": {
51
+ "$ref": "#/components/schemas/DateType"
52
+ },
53
+ "expirationDate": {
54
+ "$ref": "#/components/schemas/DateType"
55
+ },
56
+ "credentialStatus": {
57
+ "$ref": "#/components/schemas/CredentialStatusReference"
58
+ },
59
+ "id": {
60
+ "type": "string"
61
+ }
62
+ },
63
+ "required": [
64
+ "issuer"
65
+ ],
66
+ "description": "Used as input when creating Verifiable Credentials"
67
+ },
68
+ "IssuerType": {
69
+ "anyOf": [
70
+ {
71
+ "type": "object",
72
+ "properties": {
73
+ "id": {
74
+ "type": "string"
75
+ }
76
+ },
77
+ "required": [
78
+ "id"
79
+ ]
80
+ },
81
+ {
82
+ "type": "string"
83
+ }
84
+ ],
85
+ "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 }"
86
+ },
87
+ "CredentialSubject": {
88
+ "type": "object",
89
+ "properties": {
90
+ "id": {
91
+ "type": "string"
92
+ }
93
+ },
94
+ "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 }"
95
+ },
96
+ "DateType": {
97
+ "type": "string",
98
+ "description": "Represents an issuance or expiration date for Credentials / Presentations. This is used as input when creating them."
99
+ },
100
+ "CredentialStatusReference": {
101
+ "type": "object",
102
+ "properties": {
103
+ "id": {
104
+ "type": "string"
105
+ },
106
+ "type": {
107
+ "type": "string"
108
+ }
109
+ },
110
+ "required": [
111
+ "id",
112
+ "type"
113
+ ],
114
+ "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 }"
115
+ },
116
+ "VerifiableCredential": {
117
+ "type": "object",
118
+ "properties": {
119
+ "proof": {
120
+ "$ref": "#/components/schemas/ProofType"
121
+ },
122
+ "issuer": {
123
+ "$ref": "#/components/schemas/IssuerType"
124
+ },
125
+ "credentialSubject": {
126
+ "$ref": "#/components/schemas/CredentialSubject"
127
+ },
128
+ "type": {
129
+ "anyOf": [
130
+ {
131
+ "type": "array",
132
+ "items": {
133
+ "type": "string"
134
+ }
135
+ },
136
+ {
137
+ "type": "string"
138
+ }
139
+ ]
140
+ },
141
+ "@context": {
142
+ "anyOf": [
143
+ {
144
+ "type": "array",
145
+ "items": {
146
+ "type": "string"
147
+ }
148
+ },
149
+ {
150
+ "type": "string"
151
+ }
152
+ ]
153
+ },
154
+ "issuanceDate": {
155
+ "type": "string"
156
+ },
157
+ "expirationDate": {
158
+ "type": "string"
159
+ },
160
+ "credentialStatus": {
161
+ "$ref": "#/components/schemas/CredentialStatusReference"
162
+ },
163
+ "id": {
164
+ "type": "string"
165
+ }
166
+ },
167
+ "required": [
168
+ "@context",
169
+ "credentialSubject",
170
+ "issuanceDate",
171
+ "issuer",
172
+ "proof"
173
+ ],
174
+ "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 }"
175
+ },
176
+ "ProofType": {
177
+ "type": "object",
178
+ "properties": {
179
+ "type": {
180
+ "type": "string"
181
+ }
182
+ },
183
+ "description": "A proof property of a {@link VerifiableCredential } or {@link VerifiablePresentation }"
184
+ },
185
+ "ICreateVerifiablePresentationLDArgs": {
186
+ "type": "object",
187
+ "properties": {
188
+ "presentation": {
189
+ "$ref": "#/components/schemas/PresentationPayload",
190
+ "description": "The json payload of the Presentation according to the\n {@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."
191
+ },
192
+ "challenge": {
193
+ "type": "string",
194
+ "description": "Optional (only JWT) string challenge parameter to add to the verifiable presentation."
195
+ },
196
+ "domain": {
197
+ "type": "string",
198
+ "description": "Optional string domain parameter to add to the verifiable presentation."
199
+ },
200
+ "keyRef": {
201
+ "type": "string",
202
+ "description": "Optional. The key handle ( {@link @veramo/core#IKey.kid | IKey.kid } ) from the internal database."
203
+ },
204
+ "fetchRemoteContexts": {
205
+ "type": "boolean",
206
+ "description": "Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.\n\nDefaults to `false`"
207
+ }
208
+ },
209
+ "required": [
210
+ "presentation"
211
+ ],
212
+ "additionalProperties": {
213
+ "description": "Any other options that can be forwarded to the lower level libraries"
214
+ },
215
+ "description": "Encapsulates the parameters required to create a\n {@link https://www.w3.org/TR/vc-data-model/#presentations | W3C Verifiable Presentation }"
216
+ },
217
+ "PresentationPayload": {
218
+ "type": "object",
219
+ "properties": {
220
+ "holder": {
221
+ "type": "string"
222
+ },
223
+ "verifiableCredential": {
224
+ "type": "array",
225
+ "items": {
226
+ "$ref": "#/components/schemas/W3CVerifiableCredential"
227
+ }
228
+ },
229
+ "type": {
230
+ "type": "array",
231
+ "items": {
232
+ "type": "string"
233
+ }
234
+ },
235
+ "@context": {
236
+ "type": "array",
237
+ "items": {
238
+ "type": "string"
239
+ }
240
+ },
241
+ "verifier": {
242
+ "type": "array",
243
+ "items": {
244
+ "type": "string"
245
+ }
246
+ },
247
+ "issuanceDate": {
248
+ "$ref": "#/components/schemas/DateType"
249
+ },
250
+ "expirationDate": {
251
+ "$ref": "#/components/schemas/DateType"
252
+ },
253
+ "id": {
254
+ "type": "string"
255
+ }
256
+ },
257
+ "required": [
258
+ "holder"
259
+ ],
260
+ "description": "Used as input when creating Verifiable Presentations"
261
+ },
262
+ "W3CVerifiableCredential": {
263
+ "anyOf": [
264
+ {
265
+ "$ref": "#/components/schemas/VerifiableCredential"
266
+ },
267
+ {
268
+ "$ref": "#/components/schemas/CompactJWT"
269
+ }
270
+ ],
271
+ "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 } \nSee {@link https://www.w3.org/TR/vc-data-model/#proof-formats | proof formats }"
272
+ },
273
+ "CompactJWT": {
274
+ "type": "string",
275
+ "description": "Represents a Json Web Token in compact form. \"header.payload.signature\""
276
+ },
277
+ "VerifiablePresentation": {
278
+ "type": "object",
279
+ "properties": {
280
+ "proof": {
281
+ "$ref": "#/components/schemas/ProofType"
282
+ },
283
+ "holder": {
284
+ "type": "string"
285
+ },
286
+ "verifiableCredential": {
287
+ "type": "array",
288
+ "items": {
289
+ "$ref": "#/components/schemas/W3CVerifiableCredential"
290
+ }
291
+ },
292
+ "type": {
293
+ "anyOf": [
294
+ {
295
+ "type": "array",
296
+ "items": {
297
+ "type": "string"
298
+ }
299
+ },
300
+ {
301
+ "type": "string"
302
+ }
303
+ ]
304
+ },
305
+ "@context": {
306
+ "anyOf": [
307
+ {
308
+ "type": "array",
309
+ "items": {
310
+ "type": "string"
311
+ }
312
+ },
313
+ {
314
+ "type": "string"
315
+ }
316
+ ]
317
+ },
318
+ "verifier": {
319
+ "type": "array",
320
+ "items": {
321
+ "type": "string"
322
+ }
323
+ },
324
+ "issuanceDate": {
325
+ "type": "string"
326
+ },
327
+ "expirationDate": {
328
+ "type": "string"
329
+ },
330
+ "id": {
331
+ "type": "string"
332
+ }
333
+ },
334
+ "required": [
335
+ "@context",
336
+ "holder",
337
+ "proof"
338
+ ],
339
+ "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 }"
340
+ },
341
+ "IVerifyCredentialLDArgs": {
342
+ "type": "object",
343
+ "properties": {
344
+ "credential": {
345
+ "$ref": "#/components/schemas/VerifiableCredential",
346
+ "description": "The json payload of the Credential according to the\n {@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`"
347
+ },
348
+ "fetchRemoteContexts": {
349
+ "type": "boolean",
350
+ "description": "Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.\n\nDefaults to `false`"
351
+ }
352
+ },
353
+ "required": [
354
+ "credential"
355
+ ],
356
+ "additionalProperties": {
357
+ "description": "Any other options that can be forwarded to the lower level libraries"
358
+ },
359
+ "description": "Encapsulates the parameters required to verify a\n {@link https://www.w3.org/TR/vc-data-model/#credentials | W3C Verifiable Credential }"
360
+ },
361
+ "IVerifyPresentationLDArgs": {
362
+ "type": "object",
363
+ "properties": {
364
+ "presentation": {
365
+ "$ref": "#/components/schemas/VerifiablePresentation",
366
+ "description": "The json payload of the Credential according to the\n {@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`"
367
+ },
368
+ "challenge": {
369
+ "type": "string",
370
+ "description": "Optional (only for JWT) string challenge parameter to verify the verifiable presentation against"
371
+ },
372
+ "domain": {
373
+ "type": "string",
374
+ "description": "Optional (only for JWT) string domain parameter to verify the verifiable presentation against"
375
+ },
376
+ "fetchRemoteContexts": {
377
+ "type": "boolean",
378
+ "description": "Set this to true if you want the `@context` URLs to be fetched in case they are not preloaded.\n\nDefaults to `false`"
379
+ }
380
+ },
381
+ "required": [
382
+ "presentation"
383
+ ],
384
+ "additionalProperties": {
385
+ "description": "Any other options that can be forwarded to the lower level libraries"
386
+ },
387
+ "description": "Encapsulates the parameters required to verify a\n {@link https://www.w3.org/TR/vc-data-model/#presentations | W3C Verifiable Presentation }"
388
+ }
389
+ },
390
+ "methods": {
391
+ "createVerifiableCredentialLD": {
392
+ "description": "Creates a Verifiable Credential. The payload, signer and format are chosen based on the ",
393
+ "arguments": {
394
+ "$ref": "#/components/schemas/ICreateVerifiableCredentialLDArgs"
395
+ },
396
+ "returnType": {
397
+ "$ref": "#/components/schemas/VerifiableCredential"
398
+ }
399
+ },
400
+ "createVerifiablePresentationLD": {
401
+ "description": "Creates a Verifiable Presentation. The payload, signer and format are chosen based on the ",
402
+ "arguments": {
403
+ "$ref": "#/components/schemas/ICreateVerifiablePresentationLDArgs"
404
+ },
405
+ "returnType": {
406
+ "$ref": "#/components/schemas/VerifiablePresentation"
407
+ }
408
+ },
409
+ "verifyCredentialLD": {
410
+ "description": "Verifies a Verifiable Credential JWT or LDS Format.",
411
+ "arguments": {
412
+ "$ref": "#/components/schemas/IVerifyCredentialLDArgs"
413
+ },
414
+ "returnType": {
415
+ "type": "boolean"
416
+ }
417
+ },
418
+ "verifyPresentationLD": {
419
+ "description": "Verifies a Verifiable Presentation JWT or LDS Format.",
420
+ "arguments": {
421
+ "$ref": "#/components/schemas/IVerifyPresentationLDArgs"
422
+ },
423
+ "returnType": {
424
+ "type": "boolean"
425
+ }
426
+ }
427
+ }
428
+ }
429
+ }
430
+ }
@@ -1,4 +1,4 @@
1
- import { RequiredAgentMethods, VeramoLdSignature } from '../ld-suites';
1
+ import { RequiredAgentMethods, VeramoLdSignature } from '../ld-suites.js';
2
2
  import { CredentialPayload, DIDDocument, IAgentContext, IKey, TKeyType } from '@veramo/core';
3
3
  /**
4
4
  * Veramo wrapper for the EcdsaSecp256k1RecoverySignature2020 suite by Transmute Industries
@@ -1 +1 @@
1
- {"version":3,"file":"EcdsaSecp256k1RecoverySignature2020.d.ts","sourceRoot":"","sources":["../../src/suites/EcdsaSecp256k1RecoverySignature2020.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,IAAI;IAmBvE,UAAU,IAAI,MAAM;CAGrB"}
@@ -1,48 +1,14 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.VeramoEcdsaSecp256k1RecoverySignature2020 = void 0;
36
- const ld_suites_1 = require("../ld-suites");
37
- const lds_ecdsa_secp256k1_recovery2020_1 = require("@veramo-community/lds-ecdsa-secp256k1-recovery2020");
38
- const u8a = __importStar(require("uint8arrays"));
39
- const utils_1 = require("@veramo/utils");
1
+ import { VeramoLdSignature } from '../ld-suites.js';
2
+ import ldsEcdsa from '@veramo-community/lds-ecdsa-secp256k1-recovery2020';
3
+ const { EcdsaSecp256k1RecoveryMethod2020, EcdsaSecp256k1RecoverySignature2020, } = ldsEcdsa;
4
+ import * as u8a from 'uint8arrays';
5
+ import { asArray, encodeJoseBlob } from '@veramo/utils';
40
6
  /**
41
7
  * Veramo wrapper for the EcdsaSecp256k1RecoverySignature2020 suite by Transmute Industries
42
8
  *
43
9
  * @alpha This API is experimental and is very likely to change or disappear in future releases without notice.
44
10
  */
45
- class VeramoEcdsaSecp256k1RecoverySignature2020 extends ld_suites_1.VeramoLdSignature {
11
+ export class VeramoEcdsaSecp256k1RecoverySignature2020 extends VeramoLdSignature {
46
12
  getSupportedVerificationType() {
47
13
  return 'EcdsaSecp256k1RecoveryMethod2020';
48
14
  }
@@ -53,27 +19,27 @@ class VeramoEcdsaSecp256k1RecoverySignature2020 extends ld_suites_1.VeramoLdSign
53
19
  const controller = did;
54
20
  const signer = {
55
21
  //returns a JWS detached
56
- sign: (args) => __awaiter(this, void 0, void 0, function* () {
22
+ sign: async (args) => {
57
23
  const header = {
58
24
  alg: 'ES256K-R',
59
25
  b64: false,
60
26
  crit: ['b64'],
61
27
  };
62
- const headerString = (0, utils_1.encodeJoseBlob)(header);
28
+ const headerString = encodeJoseBlob(header);
63
29
  const messageBuffer = u8a.concat([u8a.fromString(`${headerString}.`, 'utf-8'), args.data]);
64
30
  const messageString = u8a.toString(messageBuffer, 'base64');
65
- const signature = yield context.agent.keyManagerSign({
31
+ const signature = await context.agent.keyManagerSign({
66
32
  keyRef: key.kid,
67
33
  algorithm: 'ES256K-R',
68
34
  data: messageString,
69
35
  encoding: 'base64',
70
36
  });
71
37
  return `${headerString}..${signature}`;
72
- }),
38
+ },
73
39
  };
74
- const suite = new lds_ecdsa_secp256k1_recovery2020_1.EcdsaSecp256k1RecoverySignature2020({
40
+ const suite = new EcdsaSecp256k1RecoverySignature2020({
75
41
  // signer,
76
- key: new lds_ecdsa_secp256k1_recovery2020_1.EcdsaSecp256k1RecoveryMethod2020({
42
+ key: new EcdsaSecp256k1RecoveryMethod2020({
77
43
  publicKeyHex: key.publicKeyHex,
78
44
  signer: () => signer,
79
45
  type: this.getSupportedVerificationType(),
@@ -82,25 +48,24 @@ class VeramoEcdsaSecp256k1RecoverySignature2020 extends ld_suites_1.VeramoLdSign
82
48
  }),
83
49
  });
84
50
  suite.ensureSuiteContext = ({ document }) => {
85
- document['@context'] = [...(0, utils_1.asArray)(document['@context'] || []), this.getContext()];
51
+ document['@context'] = [...asArray(document['@context'] || []), this.getContext()];
86
52
  };
87
53
  return suite;
88
54
  }
89
55
  getSuiteForVerification() {
90
- return new lds_ecdsa_secp256k1_recovery2020_1.EcdsaSecp256k1RecoverySignature2020();
56
+ return new EcdsaSecp256k1RecoverySignature2020();
91
57
  }
92
58
  preSigningCredModification(credential) {
93
59
  }
94
60
  preDidResolutionModification(didUrl, didDoc) {
95
- var _a, _b;
96
61
  // did:ethr
97
- const idx = ((_a = didDoc['@context']) === null || _a === void 0 ? void 0 : _a.indexOf('https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld')) || -1;
62
+ const idx = didDoc['@context']?.indexOf('https://identity.foundation/EcdsaSecp256k1RecoverySignature2020/lds-ecdsa-secp256k1-recovery2020-0.0.jsonld') || -1;
98
63
  if (Array.isArray(didDoc['@context']) && idx !== -1) {
99
64
  didDoc['@context'][idx] = this.getContext();
100
65
  }
101
66
  if (didUrl.toLowerCase().startsWith('did:ethr')) {
102
67
  //EcdsaSecp256k1RecoveryMethod2020 does not support older format blockchainAccountId
103
- (_b = didDoc.verificationMethod) === null || _b === void 0 ? void 0 : _b.forEach((x) => {
68
+ didDoc.verificationMethod?.forEach((x) => {
104
69
  if (x.blockchainAccountId) {
105
70
  if (x.blockchainAccountId.lastIndexOf('@eip155:') !== -1) {
106
71
  const [address, chain] = x.blockchainAccountId.split("@eip155:");
@@ -114,5 +79,4 @@ class VeramoEcdsaSecp256k1RecoverySignature2020 extends ld_suites_1.VeramoLdSign
114
79
  return 'https://w3id.org/security/suites/secp256k1recovery-2020/v2';
115
80
  }
116
81
  }
117
- exports.VeramoEcdsaSecp256k1RecoverySignature2020 = VeramoEcdsaSecp256k1RecoverySignature2020;
118
82
  //# sourceMappingURL=EcdsaSecp256k1RecoverySignature2020.js.map