@sphereon/ssi-sdk.ebsi-support 0.33.1-next.2 → 0.33.1-next.68

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 (57) hide show
  1. package/dist/index.cjs +3610 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +446 -0
  4. package/dist/index.d.ts +445 -6
  5. package/dist/index.js +3580 -29
  6. package/dist/index.js.map +1 -1
  7. package/package.json +42 -31
  8. package/src/did/functions.ts +10 -5
  9. package/dist/agent/EbsiSupport.d.ts +0 -14
  10. package/dist/agent/EbsiSupport.d.ts.map +0 -1
  11. package/dist/agent/EbsiSupport.js +0 -237
  12. package/dist/agent/EbsiSupport.js.map +0 -1
  13. package/dist/did/EbsiDidProvider.d.ts +0 -47
  14. package/dist/did/EbsiDidProvider.d.ts.map +0 -1
  15. package/dist/did/EbsiDidProvider.js +0 -210
  16. package/dist/did/EbsiDidProvider.js.map +0 -1
  17. package/dist/did/EbsiDidResolver.d.ts +0 -5
  18. package/dist/did/EbsiDidResolver.d.ts.map +0 -1
  19. package/dist/did/EbsiDidResolver.js +0 -22
  20. package/dist/did/EbsiDidResolver.js.map +0 -1
  21. package/dist/did/functions.d.ts +0 -60
  22. package/dist/did/functions.d.ts.map +0 -1
  23. package/dist/did/functions.js +0 -458
  24. package/dist/did/functions.js.map +0 -1
  25. package/dist/did/index.d.ts +0 -6
  26. package/dist/did/index.d.ts.map +0 -1
  27. package/dist/did/index.js +0 -29
  28. package/dist/did/index.js.map +0 -1
  29. package/dist/did/services/EbsiRPCService.d.ts +0 -13
  30. package/dist/did/services/EbsiRPCService.d.ts.map +0 -1
  31. package/dist/did/services/EbsiRPCService.js +0 -80
  32. package/dist/did/services/EbsiRPCService.js.map +0 -1
  33. package/dist/did/services/EbsiRestService.d.ts +0 -37
  34. package/dist/did/services/EbsiRestService.d.ts.map +0 -1
  35. package/dist/did/services/EbsiRestService.js +0 -108
  36. package/dist/did/services/EbsiRestService.js.map +0 -1
  37. package/dist/did/types.d.ts +0 -397
  38. package/dist/did/types.d.ts.map +0 -1
  39. package/dist/did/types.js +0 -50
  40. package/dist/did/types.js.map +0 -1
  41. package/dist/functions/Attestation.d.ts +0 -32
  42. package/dist/functions/Attestation.d.ts.map +0 -1
  43. package/dist/functions/Attestation.js +0 -212
  44. package/dist/functions/Attestation.js.map +0 -1
  45. package/dist/functions/AttestationHeadlessCallbacks.d.ts +0 -16
  46. package/dist/functions/AttestationHeadlessCallbacks.d.ts.map +0 -1
  47. package/dist/functions/AttestationHeadlessCallbacks.js +0 -229
  48. package/dist/functions/AttestationHeadlessCallbacks.js.map +0 -1
  49. package/dist/functions/index.d.ts +0 -7
  50. package/dist/functions/index.d.ts.map +0 -1
  51. package/dist/functions/index.js +0 -36
  52. package/dist/functions/index.js.map +0 -1
  53. package/dist/index.d.ts.map +0 -1
  54. package/dist/types/IEbsiSupport.d.ts +0 -215
  55. package/dist/types/IEbsiSupport.d.ts.map +0 -1
  56. package/dist/types/IEbsiSupport.js +0 -8
  57. package/dist/types/IEbsiSupport.js.map +0 -1
package/dist/index.cjs ADDED
@@ -0,0 +1,3610 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __commonJS = (cb, mod) => function __require() {
10
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
+ };
12
+ var __export = (target, all) => {
13
+ for (var name in all)
14
+ __defProp(target, name, { get: all[name], enumerable: true });
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
32
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
33
+
34
+ // plugin.schema.json
35
+ var require_plugin_schema = __commonJS({
36
+ "plugin.schema.json"(exports, module2) {
37
+ module2.exports = {
38
+ IEBSIAuthorizationClient: {
39
+ components: {
40
+ schemas: {
41
+ EBSIAuthAccessTokenGetArgs: {
42
+ type: "object",
43
+ properties: {
44
+ vc: {
45
+ type: "string"
46
+ },
47
+ definitionId: {
48
+ $ref: "#/components/schemas/ScopeByDefinition"
49
+ },
50
+ did: {
51
+ type: "string"
52
+ },
53
+ kid: {
54
+ type: "string"
55
+ },
56
+ scope: {
57
+ $ref: "#/components/schemas/EBSIScope"
58
+ },
59
+ apiOpts: {
60
+ $ref: '#/components/schemas/Optional<ApiOpts,"version">'
61
+ }
62
+ },
63
+ required: ["vc", "definitionId", "did", "kid", "scope", "apiOpts"]
64
+ },
65
+ ScopeByDefinition: {
66
+ type: "string",
67
+ enum: ["didr_invite", "didr_write", "tir_invite", "tir_write", "timestamp_write", "tnt_authorise", "tnt_create", "tnt_write"]
68
+ },
69
+ EBSIScope: {
70
+ type: "string",
71
+ enum: [
72
+ "didr_write",
73
+ "didr_invite",
74
+ "tir_write",
75
+ "tir_invite",
76
+ "timestamp_write",
77
+ "tnt_authorise",
78
+ "tnt_create",
79
+ "tnt_write",
80
+ "did_authn"
81
+ ],
82
+ description: "The OpenID scope"
83
+ },
84
+ 'Optional<ApiOpts,"version">': {
85
+ type: "object",
86
+ properties: {
87
+ environment: {
88
+ $ref: "#/components/schemas/EbsiEnvironment"
89
+ },
90
+ version: {
91
+ $ref: "#/components/schemas/EbsiApiVersion"
92
+ }
93
+ }
94
+ },
95
+ EbsiEnvironment: {
96
+ type: "string",
97
+ enum: ["pilot", "conformance", "conformance-test"]
98
+ },
99
+ EbsiApiVersion: {
100
+ type: "string",
101
+ enum: ["v3", "v4", "v5"]
102
+ },
103
+ GetAccessTokenResponse: {
104
+ anyOf: [
105
+ {
106
+ $ref: "#/components/schemas/GetAccessTokenSuccessResponse"
107
+ },
108
+ {
109
+ $ref: "#/components/schemas/ExceptionResponse"
110
+ }
111
+ ]
112
+ },
113
+ GetAccessTokenSuccessResponse: {
114
+ type: "object",
115
+ properties: {
116
+ access_token: {
117
+ type: "string"
118
+ },
119
+ token_type: {
120
+ $ref: "#/components/schemas/TokenType"
121
+ },
122
+ expires_in: {
123
+ type: "number"
124
+ },
125
+ scope: {
126
+ $ref: "#/components/schemas/EBSIScope"
127
+ },
128
+ id_token: {
129
+ type: "string"
130
+ },
131
+ apiOpts: {
132
+ $ref: "#/components/schemas/ApiOpts"
133
+ }
134
+ },
135
+ required: ["access_token", "token_type", "scope", "id_token", "apiOpts"]
136
+ },
137
+ TokenType: {
138
+ type: "string",
139
+ const: "Bearer"
140
+ },
141
+ ApiOpts: {
142
+ type: "object",
143
+ properties: {
144
+ environment: {
145
+ $ref: "#/components/schemas/EbsiEnvironment"
146
+ },
147
+ version: {
148
+ $ref: "#/components/schemas/EbsiApiVersion"
149
+ }
150
+ },
151
+ required: ["version"]
152
+ },
153
+ ExceptionResponse: {
154
+ type: "object",
155
+ properties: {
156
+ type: {
157
+ type: "string"
158
+ },
159
+ title: {
160
+ type: "string"
161
+ },
162
+ status: {
163
+ type: "number"
164
+ },
165
+ detail: {
166
+ type: "string"
167
+ },
168
+ instance: {
169
+ type: "string"
170
+ }
171
+ }
172
+ },
173
+ GetOIDProviderJwksResponse: {
174
+ anyOf: [
175
+ {
176
+ $ref: "#/components/schemas/GetOIDProviderJwksSuccessResponse"
177
+ },
178
+ {
179
+ $ref: "#/components/schemas/ExceptionResponse"
180
+ }
181
+ ]
182
+ },
183
+ GetOIDProviderJwksSuccessResponse: {
184
+ type: "object",
185
+ properties: {
186
+ keys: {
187
+ type: "array",
188
+ items: {
189
+ $ref: "#/components/schemas/JWK"
190
+ }
191
+ }
192
+ },
193
+ required: ["keys"]
194
+ },
195
+ JWK: {
196
+ type: "object",
197
+ properties: {
198
+ alg: {
199
+ type: "string",
200
+ description: 'JWK "alg" (Algorithm) Parameter.'
201
+ },
202
+ crv: {
203
+ type: "string"
204
+ },
205
+ d: {
206
+ type: "string"
207
+ },
208
+ dp: {
209
+ type: "string"
210
+ },
211
+ dq: {
212
+ type: "string"
213
+ },
214
+ e: {
215
+ type: "string"
216
+ },
217
+ ext: {
218
+ type: "boolean",
219
+ description: 'JWK "ext" (Extractable) Parameter.'
220
+ },
221
+ k: {
222
+ type: "string"
223
+ },
224
+ key_ops: {
225
+ type: "array",
226
+ items: {
227
+ type: "string"
228
+ },
229
+ description: 'JWK "key_ops" (Key Operations) Parameter.'
230
+ },
231
+ kid: {
232
+ type: "string",
233
+ description: 'JWK "kid" (Key ID) Parameter.'
234
+ },
235
+ kty: {
236
+ type: "string",
237
+ description: 'JWK "kty" (Key Type) Parameter.'
238
+ },
239
+ n: {
240
+ type: "string"
241
+ },
242
+ oth: {
243
+ type: "array",
244
+ items: {
245
+ type: "object",
246
+ properties: {
247
+ d: {
248
+ type: "string"
249
+ },
250
+ r: {
251
+ type: "string"
252
+ },
253
+ t: {
254
+ type: "string"
255
+ }
256
+ }
257
+ }
258
+ },
259
+ p: {
260
+ type: "string"
261
+ },
262
+ q: {
263
+ type: "string"
264
+ },
265
+ qi: {
266
+ type: "string"
267
+ },
268
+ use: {
269
+ type: "string",
270
+ description: 'JWK "use" (Public Key Use) Parameter.'
271
+ },
272
+ x: {
273
+ type: "string"
274
+ },
275
+ y: {
276
+ type: "string"
277
+ },
278
+ x5c: {
279
+ type: "array",
280
+ items: {
281
+ type: "string"
282
+ },
283
+ description: 'JWK "x5c" (X.509 Certificate Chain) Parameter.'
284
+ },
285
+ x5t: {
286
+ type: "string",
287
+ description: 'JWK "x5t" (X.509 Certificate SHA-1 Thumbprint) Parameter.'
288
+ },
289
+ "x5t#S256": {
290
+ type: "string",
291
+ description: '"x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Parameter.'
292
+ },
293
+ x5u: {
294
+ type: "string",
295
+ description: 'JWK "x5u" (X.509 URL) Parameter.'
296
+ }
297
+ },
298
+ additionalProperties: {},
299
+ description: 'JSON Web Key ( {@link https://www.rfc-editor.org/rfc/rfc7517 | JWK } ). "RSA", "EC", "OKP", and "oct" key types are supported.'
300
+ },
301
+ GetPresentationDefinitionArgs: {
302
+ type: "object",
303
+ properties: {
304
+ scope: {
305
+ $ref: "#/components/schemas/EBSIScope"
306
+ },
307
+ apiOpts: {
308
+ $ref: "#/components/schemas/ApiOpts"
309
+ }
310
+ },
311
+ required: ["scope"]
312
+ },
313
+ GetPresentationDefinitionResponse: {
314
+ $ref: "#/components/schemas/GetPresentationDefinitionSuccessResponse"
315
+ },
316
+ GetPresentationDefinitionSuccessResponse: {
317
+ type: "object",
318
+ properties: {
319
+ format: {
320
+ $ref: "#/components/schemas/Format"
321
+ },
322
+ id: {
323
+ type: "string"
324
+ },
325
+ name: {
326
+ type: "string"
327
+ },
328
+ purpose: {
329
+ type: "string"
330
+ },
331
+ submission_requirements: {
332
+ type: "array",
333
+ items: {
334
+ $ref: "#/components/schemas/SubmissionRequirement"
335
+ }
336
+ },
337
+ input_descriptors: {
338
+ type: "array",
339
+ items: {
340
+ $ref: "#/components/schemas/InputDescriptorV2"
341
+ }
342
+ },
343
+ frame: {
344
+ type: "object"
345
+ }
346
+ },
347
+ required: ["id", "input_descriptors"]
348
+ },
349
+ Format: {
350
+ type: "object",
351
+ properties: {
352
+ jwt: {
353
+ $ref: "#/components/schemas/JwtObject"
354
+ },
355
+ jwt_vc: {
356
+ $ref: "#/components/schemas/JwtObject"
357
+ },
358
+ jwt_vc_json: {
359
+ $ref: "#/components/schemas/JwtObject"
360
+ },
361
+ jwt_vp: {
362
+ $ref: "#/components/schemas/JwtObject"
363
+ },
364
+ jwt_vp_json: {
365
+ $ref: "#/components/schemas/JwtObject"
366
+ },
367
+ ldp: {
368
+ $ref: "#/components/schemas/LdpObject"
369
+ },
370
+ ldp_vc: {
371
+ $ref: "#/components/schemas/LdpObject"
372
+ },
373
+ ldp_vp: {
374
+ $ref: "#/components/schemas/LdpObject"
375
+ },
376
+ di: {
377
+ $ref: "#/components/schemas/DiObject"
378
+ },
379
+ di_vc: {
380
+ $ref: "#/components/schemas/DiObject"
381
+ },
382
+ di_vp: {
383
+ $ref: "#/components/schemas/DiObject"
384
+ },
385
+ "vc+sd-jwt": {
386
+ $ref: "#/components/schemas/SdJwtObject"
387
+ }
388
+ }
389
+ },
390
+ JwtObject: {
391
+ type: "object",
392
+ properties: {
393
+ alg: {
394
+ type: "array",
395
+ items: {
396
+ type: "string"
397
+ }
398
+ }
399
+ },
400
+ required: ["alg"]
401
+ },
402
+ LdpObject: {
403
+ type: "object",
404
+ properties: {
405
+ proof_type: {
406
+ type: "array",
407
+ items: {
408
+ type: "string"
409
+ }
410
+ }
411
+ },
412
+ required: ["proof_type"]
413
+ },
414
+ DiObject: {
415
+ type: "object",
416
+ properties: {
417
+ proof_type: {
418
+ type: "array",
419
+ items: {
420
+ type: "string"
421
+ }
422
+ },
423
+ cryptosuite: {
424
+ type: "array",
425
+ items: {
426
+ type: "string"
427
+ }
428
+ }
429
+ },
430
+ required: ["proof_type", "cryptosuite"]
431
+ },
432
+ SdJwtObject: {
433
+ type: "object",
434
+ properties: {
435
+ "sd-jwt_alg_values": {
436
+ type: "array",
437
+ items: {
438
+ type: "string"
439
+ }
440
+ },
441
+ "kb-jwt_alg_values": {
442
+ type: "array",
443
+ items: {
444
+ type: "string"
445
+ }
446
+ }
447
+ }
448
+ },
449
+ SubmissionRequirement: {
450
+ type: "object",
451
+ properties: {
452
+ name: {
453
+ type: "string"
454
+ },
455
+ purpose: {
456
+ type: "string"
457
+ },
458
+ rule: {
459
+ $ref: "#/components/schemas/Rules"
460
+ },
461
+ count: {
462
+ type: "number"
463
+ },
464
+ min: {
465
+ type: "number"
466
+ },
467
+ max: {
468
+ type: "number"
469
+ },
470
+ from: {
471
+ type: "string"
472
+ },
473
+ from_nested: {
474
+ type: "array",
475
+ items: {
476
+ $ref: "#/components/schemas/SubmissionRequirement"
477
+ }
478
+ }
479
+ },
480
+ required: ["rule"]
481
+ },
482
+ Rules: {
483
+ type: "string",
484
+ enum: ["all", "pick"]
485
+ },
486
+ InputDescriptorV2: {
487
+ type: "object",
488
+ properties: {
489
+ id: {
490
+ type: "string"
491
+ },
492
+ name: {
493
+ type: "string"
494
+ },
495
+ purpose: {
496
+ type: "string"
497
+ },
498
+ format: {
499
+ $ref: "#/components/schemas/Format"
500
+ },
501
+ group: {
502
+ type: "array",
503
+ items: {
504
+ type: "string"
505
+ }
506
+ },
507
+ issuance: {
508
+ type: "array",
509
+ items: {
510
+ $ref: "#/components/schemas/Issuance"
511
+ }
512
+ },
513
+ constraints: {
514
+ $ref: "#/components/schemas/ConstraintsV2"
515
+ }
516
+ },
517
+ required: ["id", "constraints"]
518
+ },
519
+ Issuance: {
520
+ type: "object",
521
+ properties: {
522
+ manifest: {
523
+ type: "string"
524
+ }
525
+ },
526
+ additionalProperties: {}
527
+ },
528
+ ConstraintsV2: {
529
+ type: "object",
530
+ properties: {
531
+ limit_disclosure: {
532
+ $ref: "#/components/schemas/Optionality"
533
+ },
534
+ statuses: {
535
+ $ref: "#/components/schemas/Statuses"
536
+ },
537
+ fields: {
538
+ type: "array",
539
+ items: {
540
+ $ref: "#/components/schemas/FieldV2"
541
+ }
542
+ },
543
+ subject_is_issuer: {
544
+ $ref: "#/components/schemas/Optionality"
545
+ },
546
+ is_holder: {
547
+ type: "array",
548
+ items: {
549
+ $ref: "#/components/schemas/HolderSubject"
550
+ }
551
+ },
552
+ same_subject: {
553
+ type: "array",
554
+ items: {
555
+ $ref: "#/components/schemas/HolderSubject"
556
+ }
557
+ }
558
+ }
559
+ },
560
+ Optionality: {
561
+ type: "string",
562
+ enum: ["required", "preferred"]
563
+ },
564
+ Statuses: {
565
+ type: "object",
566
+ properties: {
567
+ active: {
568
+ $ref: "#/components/schemas/PdStatus"
569
+ },
570
+ suspended: {
571
+ $ref: "#/components/schemas/PdStatus"
572
+ },
573
+ revoked: {
574
+ $ref: "#/components/schemas/PdStatus"
575
+ }
576
+ }
577
+ },
578
+ PdStatus: {
579
+ type: "object",
580
+ properties: {
581
+ directive: {
582
+ $ref: "#/components/schemas/Directives"
583
+ }
584
+ }
585
+ },
586
+ Directives: {
587
+ type: "string",
588
+ enum: ["required", "allowed", "disallowed"]
589
+ },
590
+ FieldV2: {
591
+ type: "object",
592
+ properties: {
593
+ id: {
594
+ type: "string"
595
+ },
596
+ path: {
597
+ type: "array",
598
+ items: {
599
+ type: "string"
600
+ }
601
+ },
602
+ purpose: {
603
+ type: "string"
604
+ },
605
+ filter: {
606
+ $ref: "#/components/schemas/FilterV2"
607
+ },
608
+ predicate: {
609
+ $ref: "#/components/schemas/Optionality"
610
+ },
611
+ name: {
612
+ type: "string"
613
+ },
614
+ optional: {
615
+ type: "boolean"
616
+ }
617
+ },
618
+ required: ["path"]
619
+ },
620
+ FilterV2: {
621
+ type: "object",
622
+ properties: {
623
+ const: {
624
+ $ref: "#/components/schemas/OneOfNumberStringBoolean"
625
+ },
626
+ enum: {
627
+ type: "array",
628
+ items: {
629
+ $ref: "#/components/schemas/OneOfNumberStringBoolean"
630
+ }
631
+ },
632
+ exclusiveMinimum: {
633
+ $ref: "#/components/schemas/OneOfNumberString"
634
+ },
635
+ exclusiveMaximum: {
636
+ $ref: "#/components/schemas/OneOfNumberString"
637
+ },
638
+ format: {
639
+ type: "string"
640
+ },
641
+ formatMaximum: {
642
+ type: "string"
643
+ },
644
+ formatMinimum: {
645
+ type: "string"
646
+ },
647
+ formatExclusiveMaximum: {
648
+ type: "string"
649
+ },
650
+ formatExclusiveMinimum: {
651
+ type: "string"
652
+ },
653
+ minLength: {
654
+ type: "number"
655
+ },
656
+ maxLength: {
657
+ type: "number"
658
+ },
659
+ minimum: {
660
+ $ref: "#/components/schemas/OneOfNumberString"
661
+ },
662
+ maximum: {
663
+ $ref: "#/components/schemas/OneOfNumberString"
664
+ },
665
+ not: {
666
+ type: "object"
667
+ },
668
+ pattern: {
669
+ type: "string"
670
+ },
671
+ type: {
672
+ type: "string"
673
+ },
674
+ contains: {
675
+ $ref: "#/components/schemas/FilterV2Base"
676
+ },
677
+ items: {
678
+ $ref: "#/components/schemas/FilterV2BaseItems"
679
+ }
680
+ },
681
+ required: ["type"]
682
+ },
683
+ OneOfNumberStringBoolean: {
684
+ type: ["boolean", "number", "string"]
685
+ },
686
+ OneOfNumberString: {
687
+ type: ["number", "string"]
688
+ },
689
+ FilterV2Base: {
690
+ type: "object",
691
+ properties: {
692
+ const: {
693
+ $ref: "#/components/schemas/OneOfNumberStringBoolean"
694
+ },
695
+ enum: {
696
+ type: "array",
697
+ items: {
698
+ $ref: "#/components/schemas/OneOfNumberStringBoolean"
699
+ }
700
+ },
701
+ exclusiveMinimum: {
702
+ $ref: "#/components/schemas/OneOfNumberString"
703
+ },
704
+ exclusiveMaximum: {
705
+ $ref: "#/components/schemas/OneOfNumberString"
706
+ },
707
+ format: {
708
+ type: "string"
709
+ },
710
+ formatMaximum: {
711
+ type: "string"
712
+ },
713
+ formatMinimum: {
714
+ type: "string"
715
+ },
716
+ formatExclusiveMaximum: {
717
+ type: "string"
718
+ },
719
+ formatExclusiveMinimum: {
720
+ type: "string"
721
+ },
722
+ minLength: {
723
+ type: "number"
724
+ },
725
+ maxLength: {
726
+ type: "number"
727
+ },
728
+ minimum: {
729
+ $ref: "#/components/schemas/OneOfNumberString"
730
+ },
731
+ maximum: {
732
+ $ref: "#/components/schemas/OneOfNumberString"
733
+ },
734
+ not: {
735
+ type: "object"
736
+ },
737
+ pattern: {
738
+ type: "string"
739
+ },
740
+ type: {
741
+ type: "string"
742
+ },
743
+ contains: {
744
+ $ref: "#/components/schemas/FilterV2Base"
745
+ },
746
+ items: {
747
+ $ref: "#/components/schemas/FilterV2BaseItems"
748
+ }
749
+ }
750
+ },
751
+ FilterV2BaseItems: {
752
+ type: "object",
753
+ properties: {
754
+ const: {
755
+ $ref: "#/components/schemas/OneOfNumberStringBoolean"
756
+ },
757
+ enum: {
758
+ type: "array",
759
+ items: {
760
+ $ref: "#/components/schemas/OneOfNumberStringBoolean"
761
+ }
762
+ },
763
+ exclusiveMinimum: {
764
+ $ref: "#/components/schemas/OneOfNumberString"
765
+ },
766
+ exclusiveMaximum: {
767
+ $ref: "#/components/schemas/OneOfNumberString"
768
+ },
769
+ format: {
770
+ type: "string"
771
+ },
772
+ formatMaximum: {
773
+ type: "string"
774
+ },
775
+ formatMinimum: {
776
+ type: "string"
777
+ },
778
+ formatExclusiveMaximum: {
779
+ type: "string"
780
+ },
781
+ formatExclusiveMinimum: {
782
+ type: "string"
783
+ },
784
+ minLength: {
785
+ type: "number"
786
+ },
787
+ maxLength: {
788
+ type: "number"
789
+ },
790
+ minimum: {
791
+ $ref: "#/components/schemas/OneOfNumberString"
792
+ },
793
+ maximum: {
794
+ $ref: "#/components/schemas/OneOfNumberString"
795
+ },
796
+ not: {
797
+ type: "object"
798
+ },
799
+ pattern: {
800
+ type: "string"
801
+ },
802
+ type: {
803
+ type: "string"
804
+ },
805
+ contains: {
806
+ $ref: "#/components/schemas/FilterV2Base"
807
+ },
808
+ items: {
809
+ $ref: "#/components/schemas/FilterV2BaseItems"
810
+ }
811
+ },
812
+ required: ["type"]
813
+ },
814
+ HolderSubject: {
815
+ type: "object",
816
+ properties: {
817
+ field_id: {
818
+ type: "array",
819
+ items: {
820
+ type: "string"
821
+ }
822
+ },
823
+ directive: {
824
+ $ref: "#/components/schemas/Optionality"
825
+ }
826
+ },
827
+ required: ["field_id", "directive"]
828
+ },
829
+ GetOIDProviderMetadataResponse: {
830
+ $ref: "#/components/schemas/EbsiOpenIDMetadata"
831
+ },
832
+ EbsiOpenIDMetadata: {
833
+ anyOf: [
834
+ {
835
+ type: "object",
836
+ properties: {
837
+ presentation_definition_endpoint: {
838
+ type: "string"
839
+ },
840
+ authorization_endpoint: {
841
+ anyOf: [
842
+ {
843
+ $ref: "#/components/schemas/Schema"
844
+ },
845
+ {
846
+ type: "string"
847
+ }
848
+ ]
849
+ },
850
+ issuer: {
851
+ anyOf: [
852
+ {
853
+ $ref: "#/components/schemas/ResponseIss"
854
+ },
855
+ {
856
+ type: "string"
857
+ }
858
+ ]
859
+ },
860
+ response_types_supported: {
861
+ anyOf: [
862
+ {
863
+ type: "array",
864
+ items: {
865
+ $ref: "#/components/schemas/ResponseType"
866
+ }
867
+ },
868
+ {
869
+ $ref: "#/components/schemas/ResponseType"
870
+ }
871
+ ]
872
+ },
873
+ scopes_supported: {
874
+ anyOf: [
875
+ {
876
+ type: "array",
877
+ items: {
878
+ $ref: "#/components/schemas/Scope"
879
+ }
880
+ },
881
+ {
882
+ $ref: "#/components/schemas/Scope"
883
+ }
884
+ ]
885
+ },
886
+ subject_types_supported: {
887
+ anyOf: [
888
+ {
889
+ type: "array",
890
+ items: {
891
+ $ref: "#/components/schemas/SubjectType"
892
+ }
893
+ },
894
+ {
895
+ $ref: "#/components/schemas/SubjectType"
896
+ }
897
+ ]
898
+ },
899
+ id_token_signing_alg_values_supported: {
900
+ anyOf: [
901
+ {
902
+ type: "array",
903
+ items: {
904
+ $ref: "#/components/schemas/SigningAlgo"
905
+ }
906
+ },
907
+ {
908
+ $ref: "#/components/schemas/SigningAlgo"
909
+ }
910
+ ]
911
+ },
912
+ request_object_signing_alg_values_supported: {
913
+ anyOf: [
914
+ {
915
+ type: "array",
916
+ items: {
917
+ $ref: "#/components/schemas/SigningAlgo"
918
+ }
919
+ },
920
+ {
921
+ $ref: "#/components/schemas/SigningAlgo"
922
+ }
923
+ ]
924
+ },
925
+ subject_syntax_types_supported: {
926
+ type: "array",
927
+ items: {
928
+ type: "string"
929
+ }
930
+ },
931
+ token_endpoint: {
932
+ type: "string"
933
+ },
934
+ userinfo_endpoint: {
935
+ type: "string"
936
+ },
937
+ jwks_uri: {
938
+ type: "string"
939
+ },
940
+ registration_endpoint: {
941
+ type: "string"
942
+ },
943
+ response_modes_supported: {
944
+ anyOf: [
945
+ {
946
+ type: "array",
947
+ items: {
948
+ $ref: "#/components/schemas/ResponseMode"
949
+ }
950
+ },
951
+ {
952
+ $ref: "#/components/schemas/ResponseMode"
953
+ }
954
+ ]
955
+ },
956
+ grant_types_supported: {
957
+ anyOf: [
958
+ {
959
+ type: "array",
960
+ items: {
961
+ $ref: "#/components/schemas/GrantType"
962
+ }
963
+ },
964
+ {
965
+ $ref: "#/components/schemas/GrantType"
966
+ }
967
+ ]
968
+ },
969
+ acr_values_supported: {
970
+ anyOf: [
971
+ {
972
+ type: "array",
973
+ items: {
974
+ $ref: "#/components/schemas/AuthenticationContextReferences"
975
+ }
976
+ },
977
+ {
978
+ $ref: "#/components/schemas/AuthenticationContextReferences"
979
+ }
980
+ ]
981
+ },
982
+ id_token_encryption_alg_values_supported: {
983
+ anyOf: [
984
+ {
985
+ type: "array",
986
+ items: {
987
+ $ref: "#/components/schemas/SigningAlgo"
988
+ }
989
+ },
990
+ {
991
+ $ref: "#/components/schemas/SigningAlgo"
992
+ }
993
+ ]
994
+ },
995
+ id_token_encryption_enc_values_supported: {
996
+ anyOf: [
997
+ {
998
+ type: "array",
999
+ items: {
1000
+ type: "string"
1001
+ }
1002
+ },
1003
+ {
1004
+ type: "string"
1005
+ }
1006
+ ],
1007
+ description: "OPTIONAL. JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for the ID Token to encode the Claims in a JWT [JWT]."
1008
+ },
1009
+ userinfo_signing_alg_values_supported: {
1010
+ anyOf: [
1011
+ {
1012
+ type: "array",
1013
+ items: {
1014
+ $ref: "#/components/schemas/SigningAlgo"
1015
+ }
1016
+ },
1017
+ {
1018
+ $ref: "#/components/schemas/SigningAlgo"
1019
+ }
1020
+ ]
1021
+ },
1022
+ userinfo_encryption_alg_values_supported: {
1023
+ anyOf: [
1024
+ {
1025
+ type: "array",
1026
+ items: {
1027
+ $ref: "#/components/schemas/SigningAlgo"
1028
+ }
1029
+ },
1030
+ {
1031
+ $ref: "#/components/schemas/SigningAlgo"
1032
+ }
1033
+ ]
1034
+ },
1035
+ userinfo_encryption_enc_values_supported: {
1036
+ anyOf: [
1037
+ {
1038
+ type: "array",
1039
+ items: {
1040
+ type: "string"
1041
+ }
1042
+ },
1043
+ {
1044
+ type: "string"
1045
+ }
1046
+ ],
1047
+ description: "OPTIONAL. JSON array containing a list of the JWE encryption algorithms (enc values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]."
1048
+ },
1049
+ request_object_encryption_alg_values_supported: {
1050
+ anyOf: [
1051
+ {
1052
+ type: "array",
1053
+ items: {
1054
+ $ref: "#/components/schemas/SigningAlgo"
1055
+ }
1056
+ },
1057
+ {
1058
+ $ref: "#/components/schemas/SigningAlgo"
1059
+ }
1060
+ ]
1061
+ },
1062
+ request_object_encryption_enc_values_supported: {
1063
+ anyOf: [
1064
+ {
1065
+ type: "array",
1066
+ items: {
1067
+ type: "string"
1068
+ }
1069
+ },
1070
+ {
1071
+ type: "string"
1072
+ }
1073
+ ],
1074
+ description: "OPTIONAL. JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference."
1075
+ },
1076
+ token_endpoint_auth_methods_supported: {
1077
+ anyOf: [
1078
+ {
1079
+ type: "array",
1080
+ items: {
1081
+ $ref: "#/components/schemas/TokenEndpointAuthMethod"
1082
+ }
1083
+ },
1084
+ {
1085
+ $ref: "#/components/schemas/TokenEndpointAuthMethod"
1086
+ }
1087
+ ]
1088
+ },
1089
+ token_endpoint_auth_signing_alg_values_supported: {
1090
+ anyOf: [
1091
+ {
1092
+ type: "array",
1093
+ items: {
1094
+ $ref: "#/components/schemas/SigningAlgo"
1095
+ }
1096
+ },
1097
+ {
1098
+ $ref: "#/components/schemas/SigningAlgo"
1099
+ }
1100
+ ]
1101
+ },
1102
+ display_values_supported: {
1103
+ anyOf: [
1104
+ {
1105
+ type: "array",
1106
+ items: {}
1107
+ },
1108
+ {}
1109
+ ],
1110
+ description: "OPTIONAL. JSON array containing a list of the display parameter values that the OpenID Provider supports. These values are described in Section 3.1.2.1 of OpenID Connect Core 1.0 [OpenID.Core]."
1111
+ },
1112
+ claim_types_supported: {
1113
+ anyOf: [
1114
+ {
1115
+ type: "array",
1116
+ items: {
1117
+ $ref: "#/components/schemas/ClaimType"
1118
+ }
1119
+ },
1120
+ {
1121
+ $ref: "#/components/schemas/ClaimType"
1122
+ }
1123
+ ],
1124
+ description: "OPTIONAL. JSON array containing a list of the Claim Types that the OpenID Provider supports. These Claim Types are described in Section 5.6 of OpenID Connect Core 1.0 [OpenID.Core]. Values defined by this specification are normal, aggregated, and distributed. If omitted, the implementation supports only normal Claims."
1125
+ },
1126
+ claims_supported: {
1127
+ anyOf: [
1128
+ {
1129
+ type: "array",
1130
+ items: {
1131
+ type: "string"
1132
+ }
1133
+ },
1134
+ {
1135
+ type: "string"
1136
+ }
1137
+ ],
1138
+ description: "RECOMMENDED. JSON array containing a list of the Claim Names of the Claims that the OpenID Provider MAY be able to supply values for. Note that for privacy or other reasons, this might not be an exhaustive list."
1139
+ },
1140
+ service_documentation: {
1141
+ type: "string"
1142
+ },
1143
+ claims_locales_supported: {
1144
+ anyOf: [
1145
+ {
1146
+ type: "array",
1147
+ items: {
1148
+ type: "string"
1149
+ }
1150
+ },
1151
+ {
1152
+ type: "string"
1153
+ }
1154
+ ]
1155
+ },
1156
+ ui_locales_supported: {
1157
+ anyOf: [
1158
+ {
1159
+ type: "array",
1160
+ items: {
1161
+ type: "string"
1162
+ }
1163
+ },
1164
+ {
1165
+ type: "string"
1166
+ }
1167
+ ]
1168
+ },
1169
+ claims_parameter_supported: {
1170
+ type: "boolean"
1171
+ },
1172
+ request_parameter_supported: {
1173
+ type: "boolean"
1174
+ },
1175
+ request_uri_parameter_supported: {
1176
+ type: "boolean"
1177
+ },
1178
+ require_request_uri_registration: {
1179
+ type: "boolean"
1180
+ },
1181
+ op_policy_uri: {
1182
+ type: "string"
1183
+ },
1184
+ op_tos_uri: {
1185
+ type: "string"
1186
+ },
1187
+ client_id: {
1188
+ type: "string"
1189
+ },
1190
+ redirect_uris: {
1191
+ type: "array",
1192
+ items: {
1193
+ type: "string"
1194
+ }
1195
+ },
1196
+ client_name: {
1197
+ type: "string"
1198
+ },
1199
+ token_endpoint_auth_method: {
1200
+ type: "string"
1201
+ },
1202
+ application_type: {
1203
+ type: "string"
1204
+ },
1205
+ response_types: {
1206
+ type: "string"
1207
+ },
1208
+ grant_types: {
1209
+ type: "string"
1210
+ },
1211
+ vp_formats: {
1212
+ $ref: "#/components/schemas/Format"
1213
+ }
1214
+ }
1215
+ },
1216
+ {
1217
+ type: "object",
1218
+ properties: {
1219
+ presentation_definition_endpoint: {
1220
+ type: "string"
1221
+ },
1222
+ authorization_endpoint: {
1223
+ anyOf: [
1224
+ {
1225
+ $ref: "#/components/schemas/Schema"
1226
+ },
1227
+ {
1228
+ type: "string"
1229
+ }
1230
+ ]
1231
+ },
1232
+ issuer: {
1233
+ anyOf: [
1234
+ {
1235
+ $ref: "#/components/schemas/ResponseIss"
1236
+ },
1237
+ {
1238
+ type: "string"
1239
+ }
1240
+ ]
1241
+ },
1242
+ response_types_supported: {
1243
+ anyOf: [
1244
+ {
1245
+ type: "array",
1246
+ items: {
1247
+ $ref: "#/components/schemas/ResponseType"
1248
+ }
1249
+ },
1250
+ {
1251
+ $ref: "#/components/schemas/ResponseType"
1252
+ }
1253
+ ]
1254
+ },
1255
+ scopes_supported: {
1256
+ anyOf: [
1257
+ {
1258
+ type: "array",
1259
+ items: {
1260
+ $ref: "#/components/schemas/Scope"
1261
+ }
1262
+ },
1263
+ {
1264
+ $ref: "#/components/schemas/Scope"
1265
+ }
1266
+ ]
1267
+ },
1268
+ subject_types_supported: {
1269
+ anyOf: [
1270
+ {
1271
+ type: "array",
1272
+ items: {
1273
+ $ref: "#/components/schemas/SubjectType"
1274
+ }
1275
+ },
1276
+ {
1277
+ $ref: "#/components/schemas/SubjectType"
1278
+ }
1279
+ ]
1280
+ },
1281
+ id_token_signing_alg_values_supported: {
1282
+ anyOf: [
1283
+ {
1284
+ type: "array",
1285
+ items: {
1286
+ $ref: "#/components/schemas/SigningAlgo"
1287
+ }
1288
+ },
1289
+ {
1290
+ $ref: "#/components/schemas/SigningAlgo"
1291
+ }
1292
+ ]
1293
+ },
1294
+ request_object_signing_alg_values_supported: {
1295
+ anyOf: [
1296
+ {
1297
+ type: "array",
1298
+ items: {
1299
+ $ref: "#/components/schemas/SigningAlgo"
1300
+ }
1301
+ },
1302
+ {
1303
+ $ref: "#/components/schemas/SigningAlgo"
1304
+ }
1305
+ ]
1306
+ },
1307
+ subject_syntax_types_supported: {
1308
+ type: "array",
1309
+ items: {
1310
+ type: "string"
1311
+ }
1312
+ },
1313
+ token_endpoint: {
1314
+ type: "string"
1315
+ },
1316
+ userinfo_endpoint: {
1317
+ type: "string"
1318
+ },
1319
+ jwks_uri: {
1320
+ type: "string"
1321
+ },
1322
+ registration_endpoint: {
1323
+ type: "string"
1324
+ },
1325
+ response_modes_supported: {
1326
+ anyOf: [
1327
+ {
1328
+ type: "array",
1329
+ items: {
1330
+ $ref: "#/components/schemas/ResponseMode"
1331
+ }
1332
+ },
1333
+ {
1334
+ $ref: "#/components/schemas/ResponseMode"
1335
+ }
1336
+ ]
1337
+ },
1338
+ grant_types_supported: {
1339
+ anyOf: [
1340
+ {
1341
+ type: "array",
1342
+ items: {
1343
+ $ref: "#/components/schemas/GrantType"
1344
+ }
1345
+ },
1346
+ {
1347
+ $ref: "#/components/schemas/GrantType"
1348
+ }
1349
+ ]
1350
+ },
1351
+ acr_values_supported: {
1352
+ anyOf: [
1353
+ {
1354
+ type: "array",
1355
+ items: {
1356
+ $ref: "#/components/schemas/AuthenticationContextReferences"
1357
+ }
1358
+ },
1359
+ {
1360
+ $ref: "#/components/schemas/AuthenticationContextReferences"
1361
+ }
1362
+ ]
1363
+ },
1364
+ id_token_encryption_alg_values_supported: {
1365
+ anyOf: [
1366
+ {
1367
+ type: "array",
1368
+ items: {
1369
+ $ref: "#/components/schemas/SigningAlgo"
1370
+ }
1371
+ },
1372
+ {
1373
+ $ref: "#/components/schemas/SigningAlgo"
1374
+ }
1375
+ ]
1376
+ },
1377
+ id_token_encryption_enc_values_supported: {
1378
+ anyOf: [
1379
+ {
1380
+ type: "array",
1381
+ items: {
1382
+ type: "string"
1383
+ }
1384
+ },
1385
+ {
1386
+ type: "string"
1387
+ }
1388
+ ],
1389
+ description: "OPTIONAL. JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for the ID Token to encode the Claims in a JWT [JWT]."
1390
+ },
1391
+ userinfo_signing_alg_values_supported: {
1392
+ anyOf: [
1393
+ {
1394
+ type: "array",
1395
+ items: {
1396
+ $ref: "#/components/schemas/SigningAlgo"
1397
+ }
1398
+ },
1399
+ {
1400
+ $ref: "#/components/schemas/SigningAlgo"
1401
+ }
1402
+ ]
1403
+ },
1404
+ userinfo_encryption_alg_values_supported: {
1405
+ anyOf: [
1406
+ {
1407
+ type: "array",
1408
+ items: {
1409
+ $ref: "#/components/schemas/SigningAlgo"
1410
+ }
1411
+ },
1412
+ {
1413
+ $ref: "#/components/schemas/SigningAlgo"
1414
+ }
1415
+ ]
1416
+ },
1417
+ userinfo_encryption_enc_values_supported: {
1418
+ anyOf: [
1419
+ {
1420
+ type: "array",
1421
+ items: {
1422
+ type: "string"
1423
+ }
1424
+ },
1425
+ {
1426
+ type: "string"
1427
+ }
1428
+ ],
1429
+ description: "OPTIONAL. JSON array containing a list of the JWE encryption algorithms (enc values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]."
1430
+ },
1431
+ request_object_encryption_alg_values_supported: {
1432
+ anyOf: [
1433
+ {
1434
+ type: "array",
1435
+ items: {
1436
+ $ref: "#/components/schemas/SigningAlgo"
1437
+ }
1438
+ },
1439
+ {
1440
+ $ref: "#/components/schemas/SigningAlgo"
1441
+ }
1442
+ ]
1443
+ },
1444
+ request_object_encryption_enc_values_supported: {
1445
+ anyOf: [
1446
+ {
1447
+ type: "array",
1448
+ items: {
1449
+ type: "string"
1450
+ }
1451
+ },
1452
+ {
1453
+ type: "string"
1454
+ }
1455
+ ],
1456
+ description: "OPTIONAL. JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference."
1457
+ },
1458
+ token_endpoint_auth_methods_supported: {
1459
+ anyOf: [
1460
+ {
1461
+ type: "array",
1462
+ items: {
1463
+ $ref: "#/components/schemas/TokenEndpointAuthMethod"
1464
+ }
1465
+ },
1466
+ {
1467
+ $ref: "#/components/schemas/TokenEndpointAuthMethod"
1468
+ }
1469
+ ]
1470
+ },
1471
+ token_endpoint_auth_signing_alg_values_supported: {
1472
+ anyOf: [
1473
+ {
1474
+ type: "array",
1475
+ items: {
1476
+ $ref: "#/components/schemas/SigningAlgo"
1477
+ }
1478
+ },
1479
+ {
1480
+ $ref: "#/components/schemas/SigningAlgo"
1481
+ }
1482
+ ]
1483
+ },
1484
+ display_values_supported: {
1485
+ anyOf: [
1486
+ {
1487
+ type: "array",
1488
+ items: {}
1489
+ },
1490
+ {}
1491
+ ],
1492
+ description: "OPTIONAL. JSON array containing a list of the display parameter values that the OpenID Provider supports. These values are described in Section 3.1.2.1 of OpenID Connect Core 1.0 [OpenID.Core]."
1493
+ },
1494
+ claim_types_supported: {
1495
+ anyOf: [
1496
+ {
1497
+ type: "array",
1498
+ items: {
1499
+ $ref: "#/components/schemas/ClaimType"
1500
+ }
1501
+ },
1502
+ {
1503
+ $ref: "#/components/schemas/ClaimType"
1504
+ }
1505
+ ],
1506
+ description: "OPTIONAL. JSON array containing a list of the Claim Types that the OpenID Provider supports. These Claim Types are described in Section 5.6 of OpenID Connect Core 1.0 [OpenID.Core]. Values defined by this specification are normal, aggregated, and distributed. If omitted, the implementation supports only normal Claims."
1507
+ },
1508
+ claims_supported: {
1509
+ anyOf: [
1510
+ {
1511
+ type: "array",
1512
+ items: {
1513
+ type: "string"
1514
+ }
1515
+ },
1516
+ {
1517
+ type: "string"
1518
+ }
1519
+ ],
1520
+ description: "RECOMMENDED. JSON array containing a list of the Claim Names of the Claims that the OpenID Provider MAY be able to supply values for. Note that for privacy or other reasons, this might not be an exhaustive list."
1521
+ },
1522
+ service_documentation: {
1523
+ type: "string"
1524
+ },
1525
+ claims_locales_supported: {
1526
+ anyOf: [
1527
+ {
1528
+ type: "array",
1529
+ items: {
1530
+ type: "string"
1531
+ }
1532
+ },
1533
+ {
1534
+ type: "string"
1535
+ }
1536
+ ]
1537
+ },
1538
+ ui_locales_supported: {
1539
+ anyOf: [
1540
+ {
1541
+ type: "array",
1542
+ items: {
1543
+ type: "string"
1544
+ }
1545
+ },
1546
+ {
1547
+ type: "string"
1548
+ }
1549
+ ]
1550
+ },
1551
+ claims_parameter_supported: {
1552
+ type: "boolean"
1553
+ },
1554
+ request_parameter_supported: {
1555
+ type: "boolean"
1556
+ },
1557
+ request_uri_parameter_supported: {
1558
+ type: "boolean"
1559
+ },
1560
+ require_request_uri_registration: {
1561
+ type: "boolean"
1562
+ },
1563
+ op_policy_uri: {
1564
+ type: "string"
1565
+ },
1566
+ op_tos_uri: {
1567
+ type: "string"
1568
+ },
1569
+ client_id: {
1570
+ type: "string"
1571
+ },
1572
+ redirect_uris: {
1573
+ type: "array",
1574
+ items: {
1575
+ type: "string"
1576
+ }
1577
+ },
1578
+ client_name: {
1579
+ type: "string"
1580
+ },
1581
+ token_endpoint_auth_method: {
1582
+ type: "string"
1583
+ },
1584
+ application_type: {
1585
+ type: "string"
1586
+ },
1587
+ response_types: {
1588
+ type: "string"
1589
+ },
1590
+ grant_types: {
1591
+ type: "string"
1592
+ },
1593
+ vp_formats: {
1594
+ $ref: "#/components/schemas/Format"
1595
+ },
1596
+ logo_uri: {
1597
+ type: "string"
1598
+ },
1599
+ client_purpose: {
1600
+ type: "string"
1601
+ }
1602
+ }
1603
+ },
1604
+ {
1605
+ type: "object",
1606
+ properties: {
1607
+ presentation_definition_endpoint: {
1608
+ type: "string"
1609
+ },
1610
+ authorization_endpoint: {
1611
+ anyOf: [
1612
+ {
1613
+ $ref: "#/components/schemas/Schema"
1614
+ },
1615
+ {
1616
+ type: "string"
1617
+ }
1618
+ ]
1619
+ },
1620
+ issuer: {
1621
+ anyOf: [
1622
+ {
1623
+ $ref: "#/components/schemas/ResponseIss"
1624
+ },
1625
+ {
1626
+ type: "string"
1627
+ }
1628
+ ]
1629
+ },
1630
+ response_types_supported: {
1631
+ anyOf: [
1632
+ {
1633
+ type: "array",
1634
+ items: {
1635
+ $ref: "#/components/schemas/ResponseType"
1636
+ }
1637
+ },
1638
+ {
1639
+ $ref: "#/components/schemas/ResponseType"
1640
+ }
1641
+ ]
1642
+ },
1643
+ scopes_supported: {
1644
+ anyOf: [
1645
+ {
1646
+ type: "array",
1647
+ items: {
1648
+ $ref: "#/components/schemas/Scope"
1649
+ }
1650
+ },
1651
+ {
1652
+ $ref: "#/components/schemas/Scope"
1653
+ }
1654
+ ]
1655
+ },
1656
+ subject_types_supported: {
1657
+ anyOf: [
1658
+ {
1659
+ type: "array",
1660
+ items: {
1661
+ $ref: "#/components/schemas/SubjectType"
1662
+ }
1663
+ },
1664
+ {
1665
+ $ref: "#/components/schemas/SubjectType"
1666
+ }
1667
+ ]
1668
+ },
1669
+ id_token_signing_alg_values_supported: {
1670
+ anyOf: [
1671
+ {
1672
+ type: "array",
1673
+ items: {
1674
+ $ref: "#/components/schemas/SigningAlgo"
1675
+ }
1676
+ },
1677
+ {
1678
+ $ref: "#/components/schemas/SigningAlgo"
1679
+ }
1680
+ ]
1681
+ },
1682
+ request_object_signing_alg_values_supported: {
1683
+ anyOf: [
1684
+ {
1685
+ type: "array",
1686
+ items: {
1687
+ $ref: "#/components/schemas/SigningAlgo"
1688
+ }
1689
+ },
1690
+ {
1691
+ $ref: "#/components/schemas/SigningAlgo"
1692
+ }
1693
+ ]
1694
+ },
1695
+ subject_syntax_types_supported: {
1696
+ type: "array",
1697
+ items: {
1698
+ type: "string"
1699
+ }
1700
+ },
1701
+ token_endpoint: {
1702
+ type: "string"
1703
+ },
1704
+ userinfo_endpoint: {
1705
+ type: "string"
1706
+ },
1707
+ jwks_uri: {
1708
+ type: "string"
1709
+ },
1710
+ registration_endpoint: {
1711
+ type: "string"
1712
+ },
1713
+ response_modes_supported: {
1714
+ anyOf: [
1715
+ {
1716
+ type: "array",
1717
+ items: {
1718
+ $ref: "#/components/schemas/ResponseMode"
1719
+ }
1720
+ },
1721
+ {
1722
+ $ref: "#/components/schemas/ResponseMode"
1723
+ }
1724
+ ]
1725
+ },
1726
+ grant_types_supported: {
1727
+ anyOf: [
1728
+ {
1729
+ type: "array",
1730
+ items: {
1731
+ $ref: "#/components/schemas/GrantType"
1732
+ }
1733
+ },
1734
+ {
1735
+ $ref: "#/components/schemas/GrantType"
1736
+ }
1737
+ ]
1738
+ },
1739
+ acr_values_supported: {
1740
+ anyOf: [
1741
+ {
1742
+ type: "array",
1743
+ items: {
1744
+ $ref: "#/components/schemas/AuthenticationContextReferences"
1745
+ }
1746
+ },
1747
+ {
1748
+ $ref: "#/components/schemas/AuthenticationContextReferences"
1749
+ }
1750
+ ]
1751
+ },
1752
+ id_token_encryption_alg_values_supported: {
1753
+ anyOf: [
1754
+ {
1755
+ type: "array",
1756
+ items: {
1757
+ $ref: "#/components/schemas/SigningAlgo"
1758
+ }
1759
+ },
1760
+ {
1761
+ $ref: "#/components/schemas/SigningAlgo"
1762
+ }
1763
+ ]
1764
+ },
1765
+ id_token_encryption_enc_values_supported: {
1766
+ anyOf: [
1767
+ {
1768
+ type: "array",
1769
+ items: {
1770
+ type: "string"
1771
+ }
1772
+ },
1773
+ {
1774
+ type: "string"
1775
+ }
1776
+ ],
1777
+ description: "OPTIONAL. JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for the ID Token to encode the Claims in a JWT [JWT]."
1778
+ },
1779
+ userinfo_signing_alg_values_supported: {
1780
+ anyOf: [
1781
+ {
1782
+ type: "array",
1783
+ items: {
1784
+ $ref: "#/components/schemas/SigningAlgo"
1785
+ }
1786
+ },
1787
+ {
1788
+ $ref: "#/components/schemas/SigningAlgo"
1789
+ }
1790
+ ]
1791
+ },
1792
+ userinfo_encryption_alg_values_supported: {
1793
+ anyOf: [
1794
+ {
1795
+ type: "array",
1796
+ items: {
1797
+ $ref: "#/components/schemas/SigningAlgo"
1798
+ }
1799
+ },
1800
+ {
1801
+ $ref: "#/components/schemas/SigningAlgo"
1802
+ }
1803
+ ]
1804
+ },
1805
+ userinfo_encryption_enc_values_supported: {
1806
+ anyOf: [
1807
+ {
1808
+ type: "array",
1809
+ items: {
1810
+ type: "string"
1811
+ }
1812
+ },
1813
+ {
1814
+ type: "string"
1815
+ }
1816
+ ],
1817
+ description: "OPTIONAL. JSON array containing a list of the JWE encryption algorithms (enc values) [JWA] supported by the UserInfo Endpoint to encode the Claims in a JWT [JWT]."
1818
+ },
1819
+ request_object_encryption_alg_values_supported: {
1820
+ anyOf: [
1821
+ {
1822
+ type: "array",
1823
+ items: {
1824
+ $ref: "#/components/schemas/SigningAlgo"
1825
+ }
1826
+ },
1827
+ {
1828
+ $ref: "#/components/schemas/SigningAlgo"
1829
+ }
1830
+ ]
1831
+ },
1832
+ request_object_encryption_enc_values_supported: {
1833
+ anyOf: [
1834
+ {
1835
+ type: "array",
1836
+ items: {
1837
+ type: "string"
1838
+ }
1839
+ },
1840
+ {
1841
+ type: "string"
1842
+ }
1843
+ ],
1844
+ description: "OPTIONAL. JSON array containing a list of the JWE encryption algorithms (enc values) supported by the OP for Request Objects. These algorithms are used both when the Request Object is passed by value and when it is passed by reference."
1845
+ },
1846
+ token_endpoint_auth_methods_supported: {
1847
+ anyOf: [
1848
+ {
1849
+ type: "array",
1850
+ items: {
1851
+ $ref: "#/components/schemas/TokenEndpointAuthMethod"
1852
+ }
1853
+ },
1854
+ {
1855
+ $ref: "#/components/schemas/TokenEndpointAuthMethod"
1856
+ }
1857
+ ]
1858
+ },
1859
+ token_endpoint_auth_signing_alg_values_supported: {
1860
+ anyOf: [
1861
+ {
1862
+ type: "array",
1863
+ items: {
1864
+ $ref: "#/components/schemas/SigningAlgo"
1865
+ }
1866
+ },
1867
+ {
1868
+ $ref: "#/components/schemas/SigningAlgo"
1869
+ }
1870
+ ]
1871
+ },
1872
+ display_values_supported: {
1873
+ anyOf: [
1874
+ {
1875
+ type: "array",
1876
+ items: {}
1877
+ },
1878
+ {}
1879
+ ],
1880
+ description: "OPTIONAL. JSON array containing a list of the display parameter values that the OpenID Provider supports. These values are described in Section 3.1.2.1 of OpenID Connect Core 1.0 [OpenID.Core]."
1881
+ },
1882
+ claim_types_supported: {
1883
+ anyOf: [
1884
+ {
1885
+ type: "array",
1886
+ items: {
1887
+ $ref: "#/components/schemas/ClaimType"
1888
+ }
1889
+ },
1890
+ {
1891
+ $ref: "#/components/schemas/ClaimType"
1892
+ }
1893
+ ],
1894
+ description: "OPTIONAL. JSON array containing a list of the Claim Types that the OpenID Provider supports. These Claim Types are described in Section 5.6 of OpenID Connect Core 1.0 [OpenID.Core]. Values defined by this specification are normal, aggregated, and distributed. If omitted, the implementation supports only normal Claims."
1895
+ },
1896
+ claims_supported: {
1897
+ anyOf: [
1898
+ {
1899
+ type: "array",
1900
+ items: {
1901
+ type: "string"
1902
+ }
1903
+ },
1904
+ {
1905
+ type: "string"
1906
+ }
1907
+ ],
1908
+ description: "RECOMMENDED. JSON array containing a list of the Claim Names of the Claims that the OpenID Provider MAY be able to supply values for. Note that for privacy or other reasons, this might not be an exhaustive list."
1909
+ },
1910
+ service_documentation: {
1911
+ type: "string"
1912
+ },
1913
+ claims_locales_supported: {
1914
+ anyOf: [
1915
+ {
1916
+ type: "array",
1917
+ items: {
1918
+ type: "string"
1919
+ }
1920
+ },
1921
+ {
1922
+ type: "string"
1923
+ }
1924
+ ]
1925
+ },
1926
+ ui_locales_supported: {
1927
+ anyOf: [
1928
+ {
1929
+ type: "array",
1930
+ items: {
1931
+ type: "string"
1932
+ }
1933
+ },
1934
+ {
1935
+ type: "string"
1936
+ }
1937
+ ]
1938
+ },
1939
+ claims_parameter_supported: {
1940
+ type: "boolean"
1941
+ },
1942
+ request_parameter_supported: {
1943
+ type: "boolean"
1944
+ },
1945
+ request_uri_parameter_supported: {
1946
+ type: "boolean"
1947
+ },
1948
+ require_request_uri_registration: {
1949
+ type: "boolean"
1950
+ },
1951
+ op_policy_uri: {
1952
+ type: "string"
1953
+ },
1954
+ op_tos_uri: {
1955
+ type: "string"
1956
+ },
1957
+ id_token_types_supported: {
1958
+ anyOf: [
1959
+ {
1960
+ type: "array",
1961
+ items: {
1962
+ $ref: "#/components/schemas/IdTokenType"
1963
+ }
1964
+ },
1965
+ {
1966
+ $ref: "#/components/schemas/IdTokenType"
1967
+ }
1968
+ ]
1969
+ },
1970
+ vp_formats_supported: {
1971
+ $ref: "#/components/schemas/Format"
1972
+ }
1973
+ }
1974
+ }
1975
+ ]
1976
+ },
1977
+ Schema: {
1978
+ type: "string",
1979
+ enum: ["openid:", "openid-vc:"]
1980
+ },
1981
+ ResponseIss: {
1982
+ type: "string",
1983
+ enum: ["https://self-issued.me", "https://self-issued.me/v2", "https://self-issued.me/v2/openid-vc"]
1984
+ },
1985
+ ResponseType: {
1986
+ type: "string",
1987
+ enum: ["id_token", "vp_token"]
1988
+ },
1989
+ Scope: {
1990
+ type: "string",
1991
+ enum: ["openid", "openid did_authn", "profile", "email", "address", "phone"]
1992
+ },
1993
+ SubjectType: {
1994
+ type: "string",
1995
+ enum: ["public", "pairwise"]
1996
+ },
1997
+ SigningAlgo: {
1998
+ type: "string",
1999
+ enum: ["EdDSA", "RS256", "PS256", "ES256", "ES256K"]
2000
+ },
2001
+ ResponseMode: {
2002
+ type: "string",
2003
+ enum: ["fragment", "form_post", "post", "direct_post", "query"]
2004
+ },
2005
+ GrantType: {
2006
+ type: "string",
2007
+ enum: ["authorization_code", "implicit"]
2008
+ },
2009
+ AuthenticationContextReferences: {
2010
+ type: "string",
2011
+ enum: ["phr", "phrh"]
2012
+ },
2013
+ TokenEndpointAuthMethod: {
2014
+ type: "string",
2015
+ enum: ["client_secret_post", "client_secret_basic", "client_secret_jwt", "private_key_jwt"]
2016
+ },
2017
+ ClaimType: {
2018
+ type: "string",
2019
+ enum: ["normal", "aggregated", "distributed"]
2020
+ },
2021
+ IdTokenType: {
2022
+ type: "string",
2023
+ enum: ["subject_signed", "attester_signed"]
2024
+ }
2025
+ },
2026
+ methods: {
2027
+ ebsiAccessTokenGet: {
2028
+ description: "",
2029
+ arguments: {
2030
+ $ref: "#/components/schemas/EBSIAuthAccessTokenGetArgs"
2031
+ },
2032
+ returnType: {
2033
+ $ref: "#/components/schemas/GetAccessTokenResponse"
2034
+ }
2035
+ },
2036
+ ebsiAuthorizationServerJwks: {
2037
+ description: "",
2038
+ arguments: {
2039
+ $ref: "#/components/schemas/ApiOpts"
2040
+ },
2041
+ returnType: {
2042
+ $ref: "#/components/schemas/GetOIDProviderJwksResponse"
2043
+ }
2044
+ },
2045
+ ebsiPresentationDefinitionGet: {
2046
+ description: "",
2047
+ arguments: {
2048
+ $ref: "#/components/schemas/GetPresentationDefinitionArgs"
2049
+ },
2050
+ returnType: {
2051
+ $ref: "#/components/schemas/GetPresentationDefinitionResponse"
2052
+ }
2053
+ },
2054
+ ebsiWellknownMetadata: {
2055
+ description: "",
2056
+ arguments: {
2057
+ $ref: "#/components/schemas/ApiOpts"
2058
+ },
2059
+ returnType: {
2060
+ $ref: "#/components/schemas/GetOIDProviderMetadataResponse"
2061
+ }
2062
+ }
2063
+ }
2064
+ }
2065
+ }
2066
+ };
2067
+ }
2068
+ });
2069
+
2070
+ // src/index.ts
2071
+ var index_exports = {};
2072
+ __export(index_exports, {
2073
+ EbsiDidProvider: () => EbsiDidProvider,
2074
+ EbsiSupport: () => EbsiSupport,
2075
+ TokenType: () => TokenType,
2076
+ ebsiSupportMethods: () => ebsiSupportMethods,
2077
+ logger: () => logger,
2078
+ schema: () => schema
2079
+ });
2080
+ module.exports = __toCommonJS(index_exports);
2081
+ var import_ssi_types2 = require("@sphereon/ssi-types");
2082
+
2083
+ // src/agent/EbsiSupport.ts
2084
+ var import_did_auth_siop2 = require("@sphereon/did-auth-siop");
2085
+ var import_oid4vci_common4 = require("@sphereon/oid4vci-common");
2086
+ var import_ssi_types = require("@sphereon/ssi-types");
2087
+ var import_cross_fetch4 = __toESM(require("cross-fetch"), 1);
2088
+
2089
+ // src/did/functions.ts
2090
+ var import_random = require("@ethersproject/random");
2091
+ var import_oid4vci_common3 = require("@sphereon/oid4vci-common");
2092
+ var import_ssi_sdk_ext3 = require("@sphereon/ssi-sdk-ext.did-utils");
2093
+ var import_ssi_sdk_ext4 = require("@sphereon/ssi-sdk-ext.key-utils");
2094
+ var import_ethers = require("ethers");
2095
+ var import_base58 = require("multiformats/bases/base58");
2096
+ var import_from_string = require("uint8arrays/from-string");
2097
+ var import_to_string = require("uint8arrays/to-string");
2098
+
2099
+ // src/functions/Attestation.ts
2100
+ var import_oid4vci_client = require("@sphereon/oid4vci-client");
2101
+ var import_oid4vci_common2 = require("@sphereon/oid4vci-common");
2102
+ var import_ssi_sdk_ext = require("@sphereon/ssi-sdk-ext.did-utils");
2103
+ var import_ssi_sdk_ext2 = require("@sphereon/ssi-sdk-ext.key-utils");
2104
+ var import_ssi_sdk3 = require("@sphereon/ssi-sdk.oid4vci-holder");
2105
+ var import_ssi_sdk4 = require("@sphereon/ssi-sdk.siopv2-oid4vp-op-auth");
2106
+ var import_waitFor = require("xstate/lib/waitFor");
2107
+
2108
+ // src/functions/AttestationHeadlessCallbacks.ts
2109
+ var import_did_auth_siop = require("@sphereon/did-auth-siop");
2110
+ var import_oid4vci_common = require("@sphereon/oid4vci-common");
2111
+ var import_ssi_sdk = require("@sphereon/ssi-sdk.data-store");
2112
+ var import_ssi_sdk2 = require("@sphereon/ssi-sdk.oid4vci-holder");
2113
+ var import_cross_fetch = __toESM(require("cross-fetch"), 1);
2114
+ var addContactCallback = /* @__PURE__ */ __name((context) => {
2115
+ return async (oid4vciMachine, state) => {
2116
+ const { serverMetadata, hasContactConsent, contactAlias } = state.context;
2117
+ if (!serverMetadata) {
2118
+ return Promise.reject(Error("Missing serverMetadata in context"));
2119
+ }
2120
+ const issuerUrl = new URL(serverMetadata.issuer);
2121
+ const correlationId = `${issuerUrl.protocol}//${issuerUrl.hostname}`;
2122
+ let issuerName = (0, import_oid4vci_common.getIssuerName)(correlationId, serverMetadata.credentialIssuerMetadata);
2123
+ const party = {
2124
+ contact: {
2125
+ displayName: issuerName,
2126
+ legalName: issuerName
2127
+ },
2128
+ // FIXME maybe its nicer if we can also just use the id only
2129
+ // TODO using the predefined party type from the contact migrations here
2130
+ // TODO this is not used as the screen itself adds one, look at the params of the screen, this is not being passed in
2131
+ partyType: {
2132
+ id: "3875c12e-fdaa-4ef6-a340-c936e054b627",
2133
+ origin: import_ssi_sdk.PartyOrigin.EXTERNAL,
2134
+ type: import_ssi_sdk.PartyTypeType.ORGANIZATION,
2135
+ name: "Sphereon_default_type",
2136
+ tenantId: "95e09cfc-c974-4174-86aa-7bf1d5251fb4"
2137
+ },
2138
+ uri: correlationId,
2139
+ identities: [
2140
+ {
2141
+ alias: correlationId,
2142
+ roles: [
2143
+ import_ssi_sdk.CredentialRole.ISSUER
2144
+ ],
2145
+ origin: import_ssi_sdk.IdentityOrigin.EXTERNAL,
2146
+ identifier: {
2147
+ type: import_ssi_sdk.CorrelationIdentifierType.URL,
2148
+ correlationId: issuerUrl.hostname
2149
+ },
2150
+ // TODO WAL-476 add support for correct connection
2151
+ connection: {
2152
+ type: import_ssi_sdk.ConnectionType.OPENID_CONNECT,
2153
+ config: {
2154
+ clientId: "138d7bf8-c930-4c6e-b928-97d3a4928b01",
2155
+ clientSecret: "03b3955f-d020-4f2a-8a27-4e452d4e27a0",
2156
+ scopes: [
2157
+ "auth"
2158
+ ],
2159
+ issuer: "https://example.com/app-test",
2160
+ redirectUrl: "app:/callback",
2161
+ dangerouslyAllowInsecureHttpRequests: true,
2162
+ clientAuthMethod: "post"
2163
+ }
2164
+ }
2165
+ }
2166
+ ]
2167
+ };
2168
+ const onCreate = /* @__PURE__ */ __name(async ({ party: party2, issuerUrl: issuerUrl2, issuerName: issuerName2, correlationId: correlationId2 }) => {
2169
+ const displayName = party2.contact.displayName ?? issuerName2;
2170
+ const contacts = await context.agent.cmGetContacts({
2171
+ filter: [
2172
+ {
2173
+ contact: {
2174
+ // Searching on legalName as displayName is not unique, and we only support organizations for now
2175
+ legalName: displayName
2176
+ }
2177
+ }
2178
+ ]
2179
+ });
2180
+ if (contacts.length === 0 || !contacts[0]?.contact) {
2181
+ const contact = await context.agent.cmAddContact({
2182
+ ...party2,
2183
+ displayName,
2184
+ legalName: displayName,
2185
+ contactType: {
2186
+ type: import_ssi_sdk.PartyTypeType.ORGANIZATION,
2187
+ name: displayName,
2188
+ origin: import_ssi_sdk.PartyOrigin.EXTERNAL,
2189
+ tenantId: party2.tenantId ?? "1"
2190
+ }
2191
+ });
2192
+ oid4vciMachine.send({
2193
+ type: import_ssi_sdk2.OID4VCIMachineEvents.CREATE_CONTACT,
2194
+ data: contact
2195
+ });
2196
+ }
2197
+ }, "onCreate");
2198
+ const onConsentChange = /* @__PURE__ */ __name(async (hasConsent) => {
2199
+ oid4vciMachine.send({
2200
+ type: import_ssi_sdk2.OID4VCIMachineEvents.SET_CONTACT_CONSENT,
2201
+ data: hasConsent
2202
+ });
2203
+ }, "onConsentChange");
2204
+ const onAliasChange = /* @__PURE__ */ __name(async (alias) => {
2205
+ oid4vciMachine.send({
2206
+ type: import_ssi_sdk2.OID4VCIMachineEvents.SET_CONTACT_ALIAS,
2207
+ data: alias
2208
+ });
2209
+ }, "onAliasChange");
2210
+ if (!issuerName) {
2211
+ issuerName = `EBSI unknown (${issuerUrl})`;
2212
+ } else if (issuerName.startsWith("http")) {
2213
+ issuerName = `EBSI ${issuerName.replace(/https?:\/\//, "")}`;
2214
+ }
2215
+ if (!contactAlias) {
2216
+ return await onAliasChange(issuerName);
2217
+ }
2218
+ issuerName = contactAlias;
2219
+ if (!hasContactConsent) {
2220
+ return await onConsentChange(true);
2221
+ }
2222
+ await onCreate({
2223
+ party,
2224
+ issuerName,
2225
+ issuerUrl: issuerUrl.toString(),
2226
+ correlationId
2227
+ });
2228
+ };
2229
+ }, "addContactCallback");
2230
+ var handleErrorCallback = /* @__PURE__ */ __name((context) => {
2231
+ return async (oid4vciMachine, state) => {
2232
+ console.error(`error callback event: ${state.event}`, state.context.error);
2233
+ logger.trace(state.event);
2234
+ };
2235
+ }, "handleErrorCallback");
2236
+ var selectCredentialsCallback = /* @__PURE__ */ __name((context) => {
2237
+ return async (oid4vciMachine, state) => {
2238
+ const { contact, credentialToSelectFrom, selectedCredentials } = state.context;
2239
+ if (selectedCredentials && selectedCredentials.length > 0) {
2240
+ logger.info(`selected: ${selectedCredentials.join(", ")}`);
2241
+ oid4vciMachine.send({
2242
+ type: import_ssi_sdk2.OID4VCIMachineEvents.NEXT
2243
+ });
2244
+ return;
2245
+ } else if (!contact) {
2246
+ return Promise.reject(Error("Missing contact in context"));
2247
+ }
2248
+ const onSelectType = /* @__PURE__ */ __name(async (selectedCredentials2) => {
2249
+ console.log(`Selected credentials: ${selectedCredentials2.join(", ")}`);
2250
+ oid4vciMachine.send({
2251
+ type: import_ssi_sdk2.OID4VCIMachineEvents.SET_SELECTED_CREDENTIALS,
2252
+ data: selectedCredentials2
2253
+ });
2254
+ }, "onSelectType");
2255
+ await onSelectType(credentialToSelectFrom.map((sel) => sel.credentialId));
2256
+ };
2257
+ }, "selectCredentialsCallback");
2258
+ var authorizationCodeUrlCallback = /* @__PURE__ */ __name(({ authReqResult, vpLinkHandler }, context) => {
2259
+ return async (oid4vciMachine, state) => {
2260
+ const url = state.context.authorizationCodeURL;
2261
+ console.log("navigateAuthorizationCodeURL: ", url);
2262
+ if (!url) {
2263
+ return Promise.reject(Error("Missing authorization URL in context"));
2264
+ }
2265
+ const onOpenAuthorizationUrl = /* @__PURE__ */ __name(async (url2) => {
2266
+ console.log("onOpenAuthorizationUrl being invoked: ", url2);
2267
+ oid4vciMachine.send({
2268
+ type: import_ssi_sdk2.OID4VCIMachineEvents.INVOKED_AUTHORIZATION_CODE_REQUEST,
2269
+ data: url2
2270
+ });
2271
+ const response = await (0, import_cross_fetch.default)(url2, {
2272
+ redirect: "manual"
2273
+ });
2274
+ if (response.status < 301 || response.status > 302) {
2275
+ throw Error(`When doing a headless auth, we expect to be redirected on getting the authz URL`);
2276
+ }
2277
+ const openidUri = response.headers.get("location");
2278
+ if (!openidUri || !openidUri.startsWith("openid://")) {
2279
+ let error = void 0;
2280
+ if (openidUri) {
2281
+ if (openidUri.includes("error")) {
2282
+ error = "Authorization server error: ";
2283
+ const decoded = (0, import_did_auth_siop.decodeUriAsJson)(openidUri);
2284
+ if ("error" in decoded && decoded.error) {
2285
+ error += decoded.error + ", ";
2286
+ }
2287
+ if ("error_description" in decoded && decoded.error_description) {
2288
+ error += decoded.error_description;
2289
+ }
2290
+ }
2291
+ }
2292
+ throw Error(error ?? `Expected a openid:// URI to be returned from EBSI in headless mode. Returned: ${openidUri}, ${JSON.stringify(await response.text())}`);
2293
+ }
2294
+ console.log(`onOpenAuthorizationUrl after openUrl: ${url2}`);
2295
+ const kid = authReqResult.authKey.meta?.jwkThumbprint ? `${authReqResult.identifier.did}#${authReqResult.authKey.meta.jwkThumbprint}` : authReqResult.identifier.kid;
2296
+ await vpLinkHandler.handle(openidUri, {
2297
+ idOpts: {
2298
+ ...authReqResult.identifier,
2299
+ kmsKeyRef: kid
2300
+ }
2301
+ });
2302
+ }, "onOpenAuthorizationUrl");
2303
+ await onOpenAuthorizationUrl(url);
2304
+ };
2305
+ }, "authorizationCodeUrlCallback");
2306
+ var reviewCredentialsCallback = /* @__PURE__ */ __name((context) => {
2307
+ return async (oid4vciMachine, state) => {
2308
+ console.log(`# REVIEW CREDENTIALS:`);
2309
+ console.log(JSON.stringify(state.context.credentialsToAccept, null, 2));
2310
+ oid4vciMachine.send({
2311
+ type: import_ssi_sdk2.OID4VCIMachineEvents.NEXT
2312
+ });
2313
+ };
2314
+ }, "reviewCredentialsCallback");
2315
+ var siopDoneCallback = /* @__PURE__ */ __name(({ oid4vciMachine }, context) => {
2316
+ return async (oid4vpMachine, state) => {
2317
+ if (!state.context.authorizationResponseData?.queryParams?.code) {
2318
+ throw Error(`No code was returned from the authorization step`);
2319
+ }
2320
+ oid4vciMachine.interpreter.send({
2321
+ type: import_ssi_sdk2.OID4VCIMachineEvents.PROVIDE_AUTHORIZATION_CODE_RESPONSE,
2322
+ data: state.context.authorizationResponseData.url
2323
+ });
2324
+ console.log(`SIOP DONE!`);
2325
+ };
2326
+ }, "siopDoneCallback");
2327
+
2328
+ // src/functions/Attestation.ts
2329
+ var ebsiCreateAttestationAuthRequestURL = /* @__PURE__ */ __name(async ({ clientId: clientIdArg, credentialIssuer, credentialType, idOpts, redirectUri, requestObjectOpts, formats = [
2330
+ "jwt_vc",
2331
+ "jwt_vc_json"
2332
+ ] }, context) => {
2333
+ logger.info(`create attestation ${credentialType} auth req URL for ${clientIdArg} and issuer ${credentialIssuer}`);
2334
+ const resolution = await context.agent.identifierManagedGetByDid(idOpts);
2335
+ const identifier = resolution.identifier;
2336
+ if (identifier.provider !== "did:ebsi" && identifier.provider !== "did:key") {
2337
+ throw Error(`EBSI only supports did:key for natural persons and did:ebsi for legal persons. Provider: ${identifier.provider}, did: ${identifier.did}`);
2338
+ }
2339
+ const authKey = await (0, import_ssi_sdk_ext.getAuthenticationKey)({
2340
+ identifier,
2341
+ offlineWhenNoDIDRegistered: credentialType === "VerifiableAuthorisationToOnboard",
2342
+ noVerificationMethodFallback: true,
2343
+ keyType: "Secp256r1"
2344
+ }, context);
2345
+ const kid = authKey.meta?.jwkThumbprint ?? (0, import_ssi_sdk_ext2.calculateJwkThumbprintForKey)({
2346
+ key: authKey
2347
+ });
2348
+ const clientId = clientIdArg ?? identifier.did;
2349
+ const vciClient = await import_oid4vci_client.OpenID4VCIClient.fromCredentialIssuer({
2350
+ credentialIssuer,
2351
+ kid,
2352
+ clientId,
2353
+ createAuthorizationRequestURL: false,
2354
+ retrieveServerMetadata: true
2355
+ });
2356
+ const allMatches = vciClient.getCredentialsSupported(false);
2357
+ let arrayMatches;
2358
+ if (Array.isArray(allMatches)) {
2359
+ arrayMatches = allMatches;
2360
+ } else {
2361
+ arrayMatches = Object.entries(allMatches).map(([id, supported]) => {
2362
+ supported.id = id;
2363
+ return supported;
2364
+ });
2365
+ }
2366
+ const supportedConfigurations = arrayMatches.filter((supported) => (0, import_oid4vci_common2.getTypesFromCredentialSupported)(supported, {
2367
+ filterVerifiableCredential: false
2368
+ }).includes(credentialType)).filter((supported) => (supported.format === "jwt_vc" || supported.format === "jwt_vc_json") && formats.includes(supported.format));
2369
+ if (supportedConfigurations.length === 0) {
2370
+ throw Error(`Could not find '${credentialType}' with format(s) '${formats.join(",")}' in list of supported types for issuer: ${credentialIssuer}`);
2371
+ }
2372
+ const authorizationDetails = supportedConfigurations.map((supported) => {
2373
+ return {
2374
+ type: "openid_credential",
2375
+ format: supported.format,
2376
+ types: (0, import_oid4vci_common2.getTypesFromCredentialSupported)(supported)
2377
+ };
2378
+ });
2379
+ const signCallbacks = requestObjectOpts.signCallbacks ?? {
2380
+ signCallback: (0, import_ssi_sdk3.signCallback)(idOpts, context)
2381
+ };
2382
+ const authorizationRequestOpts = {
2383
+ redirectUri,
2384
+ clientId,
2385
+ authorizationDetails,
2386
+ requestObjectOpts: {
2387
+ ...requestObjectOpts,
2388
+ signCallbacks,
2389
+ kid: requestObjectOpts.kid ?? kid
2390
+ }
2391
+ };
2392
+ const authorizationCodeURL = await vciClient.createAuthorizationRequestUrl({
2393
+ authorizationRequest: authorizationRequestOpts
2394
+ });
2395
+ logger.info(`create attestation ${credentialType} auth req URL for ${clientIdArg} and issuer ${credentialIssuer}, result: ${authorizationCodeURL}`);
2396
+ const jwaAlg = await (0, import_ssi_sdk_ext2.signatureAlgorithmFromKey)({
2397
+ key: authKey
2398
+ });
2399
+ if (!(jwaAlg in import_oid4vci_common2.Alg)) {
2400
+ return Promise.reject(Error(`${jwaAlg} is not supported`));
2401
+ }
2402
+ const alg = import_oid4vci_common2.Alg[jwaAlg];
2403
+ return {
2404
+ requestData: {
2405
+ createAuthorizationRequestURL: false,
2406
+ flowType: import_oid4vci_common2.AuthzFlowType.AUTHORIZATION_CODE_FLOW,
2407
+ uri: credentialIssuer,
2408
+ existingClientState: JSON.parse(await vciClient.exportState())
2409
+ },
2410
+ accessTokenOpts: {
2411
+ clientOpts: {
2412
+ alg,
2413
+ clientId,
2414
+ kid,
2415
+ signCallbacks,
2416
+ clientAssertionType: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer"
2417
+ }
2418
+ },
2419
+ authorizationRequestOpts,
2420
+ authorizationCodeURL,
2421
+ identifier: resolution,
2422
+ authKey,
2423
+ didMethodPreferences: [
2424
+ import_ssi_sdk_ext.SupportedDidMethodEnum.DID_EBSI,
2425
+ import_ssi_sdk_ext.SupportedDidMethodEnum.DID_KEY
2426
+ ]
2427
+ };
2428
+ }, "ebsiCreateAttestationAuthRequestURL");
2429
+ var ebsiGetAttestationInterpreter = /* @__PURE__ */ __name(async ({ clientId, authReqResult }, context) => {
2430
+ const identifier = authReqResult.identifier;
2431
+ const vciStateCallbacks = /* @__PURE__ */ new Map();
2432
+ const vpStateCallbacks = /* @__PURE__ */ new Map();
2433
+ const oid4vciMachine = await context.agent.oid4vciHolderGetMachineInterpreter({
2434
+ ...authReqResult,
2435
+ issuanceOpt: {
2436
+ identifier,
2437
+ supportedPreferredDidMethod: import_ssi_sdk_ext.SupportedDidMethodEnum.DID_EBSI,
2438
+ kid: authReqResult.authKey.meta?.jwkThumbprint ?? authReqResult.authKey.kid
2439
+ },
2440
+ clientOpts: {
2441
+ clientAssertionType: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
2442
+ kid: authReqResult.authKey.meta?.jwkThumbprint ?? authReqResult.authKey.kid,
2443
+ clientId
2444
+ },
2445
+ didMethodPreferences: [
2446
+ import_ssi_sdk_ext.SupportedDidMethodEnum.DID_EBSI,
2447
+ import_ssi_sdk_ext.SupportedDidMethodEnum.DID_KEY
2448
+ ],
2449
+ stateNavigationListener: (0, import_ssi_sdk3.OID4VCICallbackStateListener)(vciStateCallbacks)
2450
+ });
2451
+ const vpLinkHandler = new import_ssi_sdk4.Siopv2OID4VPLinkHandler({
2452
+ protocols: [
2453
+ "openid:"
2454
+ ],
2455
+ // @ts-ignore
2456
+ context,
2457
+ noStateMachinePersistence: true,
2458
+ stateNavigationListener: (0, import_ssi_sdk4.OID4VPCallbackStateListener)(vpStateCallbacks)
2459
+ });
2460
+ vpStateCallbacks.set(import_ssi_sdk4.Siopv2MachineStates.done, siopDoneCallback({
2461
+ oid4vciMachine
2462
+ }, context)).set(import_ssi_sdk4.Siopv2MachineStates.handleError, handleErrorCallback(context)).set(import_ssi_sdk4.Siopv2MachineStates.error, handleErrorCallback(context));
2463
+ vciStateCallbacks.set(import_ssi_sdk3.OID4VCIMachineStates.handleError, handleErrorCallback(context)).set(import_ssi_sdk3.OID4VCIMachineStates.addContact, addContactCallback(context)).set(import_ssi_sdk3.OID4VCIMachineStates.selectCredentials, selectCredentialsCallback(context)).set(import_ssi_sdk3.OID4VCIMachineStates.initiateAuthorizationRequest, authorizationCodeUrlCallback({
2464
+ authReqResult,
2465
+ vpLinkHandler
2466
+ }, context)).set(import_ssi_sdk3.OID4VCIMachineStates.reviewCredentials, reviewCredentialsCallback(context));
2467
+ return oid4vciMachine.interpreter;
2468
+ }, "ebsiGetAttestationInterpreter");
2469
+ var ebsiGetAttestation = /* @__PURE__ */ __name(async ({ clientId, authReqResult, opts = {
2470
+ timeout: 3e4
2471
+ } }, agentContext) => {
2472
+ logger.info(`Getting EBSI attestation for ${authReqResult.identifier.did} and ${clientId}`);
2473
+ const interpreter = await ebsiGetAttestationInterpreter({
2474
+ clientId,
2475
+ authReqResult
2476
+ }, agentContext);
2477
+ const state = await (0, import_waitFor.waitFor)(interpreter.start(), (state2) => state2.matches("done") || state2.matches("handleError") || state2.matches("error"), {
2478
+ timeout: opts.timeout ?? 3e4
2479
+ });
2480
+ const { contactAlias, contact, credentialBranding, issuanceOpt, error, credentialsToAccept } = state.context;
2481
+ if (state.matches("handleError") || state.matches("error")) {
2482
+ logger.error(JSON.stringify(state.context.error));
2483
+ throw Error(JSON.stringify(state.context.error));
2484
+ }
2485
+ const result = {
2486
+ contactAlias,
2487
+ contact,
2488
+ credentialBranding,
2489
+ identifier: issuanceOpt?.identifier ? await agentContext.agent.identifierManagedGet(issuanceOpt.identifier) : authReqResult.identifier,
2490
+ error,
2491
+ credentials: credentialsToAccept
2492
+ };
2493
+ logger.info(`EBSI attestation for ${authReqResult.identifier.did} and ${clientId}`, result);
2494
+ return result;
2495
+ }, "ebsiGetAttestation");
2496
+
2497
+ // src/functions/index.ts
2498
+ var getEbsiApiBaseUrl = /* @__PURE__ */ __name(({ environment = "pilot", version, system = "pilot" }) => {
2499
+ return `https://api-${environment}.ebsi.eu/${system}/${version}`;
2500
+ }, "getEbsiApiBaseUrl");
2501
+ var wait = /* @__PURE__ */ __name(async (timeoutInMS) => {
2502
+ return new Promise((resolve) => setTimeout(resolve, timeoutInMS));
2503
+ }, "wait");
2504
+
2505
+ // src/did/services/EbsiRestService.ts
2506
+ var import_cross_fetch2 = __toESM(require("cross-fetch"), 1);
2507
+ var ebsiGetDidDocument = /* @__PURE__ */ __name(async (args) => {
2508
+ const { params, apiOpts } = args;
2509
+ const { did, validAt } = params;
2510
+ if (!did) {
2511
+ throw new Error("did parameter is required");
2512
+ }
2513
+ const query = validAt ? `?valid_at=${validAt}` : "";
2514
+ const response = await (0, import_cross_fetch2.default)(`${ebsiGetRegistryAPIUrls({
2515
+ ...apiOpts
2516
+ }).query}/${did}${query}`);
2517
+ const textBody = await response.text();
2518
+ const json = textBody.startsWith("{") ? JSON.parse(textBody) : void 0;
2519
+ if (response.status >= 300 || !json) {
2520
+ return Promise.reject(new Error(json ?? textBody));
2521
+ }
2522
+ return json;
2523
+ }, "ebsiGetDidDocument");
2524
+ var ebsiWaitTillDocumentAnchored = /* @__PURE__ */ __name(async (args) => {
2525
+ const { did, startIntervalMS = 2e3, minIntervalMS = 500, decreaseIntervalMSPerStep = 250, maxWaitTime = 6e4, version = "v5", environment = "pilot", searchForObject } = args;
2526
+ if (startIntervalMS < minIntervalMS) {
2527
+ return Promise.reject(Error(`min interval ${minIntervalMS} needs to be smaller or equal to the start interval ${startIntervalMS}`));
2528
+ } else if (decreaseIntervalMSPerStep < 0) {
2529
+ return Promise.reject(Error(`decrease interval per step ${decreaseIntervalMSPerStep} needs to be bigger than zero`));
2530
+ }
2531
+ let interval = startIntervalMS;
2532
+ let totalWaitTime = 0;
2533
+ let didDocument;
2534
+ let count = 0;
2535
+ function logCalback() {
2536
+ logger.debug(`Get DID Document; count ${count}: wait time: ${totalWaitTime}, ${did}`);
2537
+ }
2538
+ __name(logCalback, "logCalback");
2539
+ while (!didDocument && totalWaitTime <= maxWaitTime) {
2540
+ ++count;
2541
+ try {
2542
+ logCalback();
2543
+ didDocument = await ebsiGetDidDocument({
2544
+ params: {
2545
+ did
2546
+ },
2547
+ apiOpts: {
2548
+ environment,
2549
+ version
2550
+ }
2551
+ });
2552
+ if (searchForObject && didDocument) {
2553
+ const didDocAsStr = JSON.stringify(didDocument);
2554
+ const search = JSON.stringify(searchForObject);
2555
+ const found = didDocAsStr.includes(search.substring(1, search.length - 1));
2556
+ if (!found) {
2557
+ logger.debug(`We did not find VM relationship or key ${JSON.stringify(searchForObject)} in DID document ${did}`);
2558
+ didDocument = void 0;
2559
+ }
2560
+ }
2561
+ } catch (e) {
2562
+ }
2563
+ if (!didDocument) {
2564
+ await wait(interval);
2565
+ totalWaitTime += interval;
2566
+ interval = Math.max(interval - decreaseIntervalMSPerStep, minIntervalMS);
2567
+ }
2568
+ }
2569
+ logCalback();
2570
+ return {
2571
+ didDocument,
2572
+ totalWaitTime,
2573
+ count
2574
+ };
2575
+ }, "ebsiWaitTillDocumentAnchored");
2576
+
2577
+ // src/did/services/EbsiRPCService.ts
2578
+ var import_cross_fetch3 = __toESM(require("cross-fetch"), 1);
2579
+
2580
+ // src/did/types.ts
2581
+ var EBSI_DID_SPEC_INFOS = {
2582
+ V1: {
2583
+ type: "LEGAL_ENTITY",
2584
+ method: "did:ebsi:",
2585
+ version: 1,
2586
+ didLength: 16,
2587
+ privateKeyLength: 32
2588
+ },
2589
+ KEY: {
2590
+ type: "NATURAL_PERSON",
2591
+ method: "did:key:"
2592
+ }
2593
+ };
2594
+ var EbsiPublicKeyPurpose = /* @__PURE__ */ function(EbsiPublicKeyPurpose2) {
2595
+ EbsiPublicKeyPurpose2["Authentication"] = "authentication";
2596
+ EbsiPublicKeyPurpose2["AssertionMethod"] = "assertionMethod";
2597
+ EbsiPublicKeyPurpose2["CapabilityInvocation"] = "capabilityInvocation";
2598
+ return EbsiPublicKeyPurpose2;
2599
+ }({});
2600
+ var JSON_RPC_VERSION = "2.0";
2601
+ var BASE_CONTEXT_DOC = JSON.stringify({
2602
+ "@context": [
2603
+ "https://www.w3.org/ns/did/v1",
2604
+ "https://w3id.org/security/suites/jws-2020/v1"
2605
+ ]
2606
+ });
2607
+ var EbsiRpcMethod = /* @__PURE__ */ function(EbsiRpcMethod2) {
2608
+ EbsiRpcMethod2["INSERT_DID_DOCUMENT"] = "insertDidDocument";
2609
+ EbsiRpcMethod2["UPDATE_DID_DOCUMENT"] = "updateBaseDocument";
2610
+ EbsiRpcMethod2["ADD_VERIFICATION_METHOD"] = "addVerificationMethod";
2611
+ EbsiRpcMethod2["ADD_VERIFICATION_RELATIONSHIP"] = "addVerificationRelationship";
2612
+ EbsiRpcMethod2["ADD_SERVICE"] = "addService";
2613
+ EbsiRpcMethod2["SEND_SIGNED_TRANSACTION"] = "sendSignedTransaction";
2614
+ return EbsiRpcMethod2;
2615
+ }({});
2616
+
2617
+ // src/did/services/EbsiRPCService.ts
2618
+ var callRpcMethod = /* @__PURE__ */ __name(async (args) => {
2619
+ return callRpcMethodImpl({
2620
+ ...args,
2621
+ retries: 10
2622
+ });
2623
+ }, "callRpcMethod");
2624
+ var callRpcMethodImpl = /* @__PURE__ */ __name(async (args) => {
2625
+ const { params, rpcId, accessToken, rpcMethod, apiOpts, doNotThrowErrors = false, retries } = args;
2626
+ const options = buildFetchOptions({
2627
+ accessToken,
2628
+ params,
2629
+ rpcId,
2630
+ rpcMethod
2631
+ });
2632
+ logger.debug(`RPC call:\r
2633
+ ${JSON.stringify(options, null, 2)}`);
2634
+ const rpcResponse = await (await (0, import_cross_fetch3.default)(ebsiGetRegistryAPIUrls({
2635
+ ...apiOpts
2636
+ }).mutate, options)).json();
2637
+ let result = rpcResponse.result;
2638
+ logger.debug(`RPC RESPONSE:\r
2639
+ ${JSON.stringify(result ?? rpcResponse.error)}`);
2640
+ if (rpcResponse.error !== void 0 && !doNotThrowErrors) {
2641
+ logger.error(`RPC ERROR RESPONSE:`, rpcResponse);
2642
+ if (rpcResponse.error.message.includes(`replacement fee too low`)) {
2643
+ args.rpcId = randomRpcId();
2644
+ if (retries <= 0) {
2645
+ throw Error(rpcResponse.error.message);
2646
+ }
2647
+ logger.warning(`Replacement fee too low error. Waiting 1 sec. Retries: ${retries}`);
2648
+ await wait(1e3);
2649
+ return callRpcMethodImpl({
2650
+ ...args,
2651
+ retries: retries - 1
2652
+ });
2653
+ }
2654
+ throw Error(rpcResponse.error.message);
2655
+ }
2656
+ return rpcResponse;
2657
+ }, "callRpcMethodImpl");
2658
+ var buildFetchOptions = /* @__PURE__ */ __name((args) => {
2659
+ const { params, rpcId, accessToken, rpcMethod } = args;
2660
+ const fetchReq = {
2661
+ method: "POST",
2662
+ headers: {
2663
+ "Content-Type": "application/json",
2664
+ Authorization: `Bearer ${accessToken}`
2665
+ },
2666
+ body: JSON.stringify({
2667
+ jsonrpc: JSON_RPC_VERSION,
2668
+ method: rpcMethod,
2669
+ params,
2670
+ id: rpcId
2671
+ })
2672
+ };
2673
+ logger.debug(fetchReq);
2674
+ return fetchReq;
2675
+ }, "buildFetchOptions");
2676
+
2677
+ // src/did/functions.ts
2678
+ function generateEbsiMethodSpecificId(specInfo) {
2679
+ const spec = specInfo ?? EBSI_DID_SPEC_INFOS.V1;
2680
+ const length = spec.didLength ?? 16;
2681
+ const result = new Uint8Array(length + (spec.version ? 1 : 0));
2682
+ if (spec.version) {
2683
+ result.set([
2684
+ spec.version
2685
+ ]);
2686
+ }
2687
+ result.set((0, import_random.randomBytes)(length), spec.version ? 1 : 0);
2688
+ return import_base58.base58btc.encode(result);
2689
+ }
2690
+ __name(generateEbsiMethodSpecificId, "generateEbsiMethodSpecificId");
2691
+ function generateOrUseProvidedEbsiPrivateKeyHex(specInfo, privateKeyBytes) {
2692
+ const spec = specInfo ?? EBSI_DID_SPEC_INFOS.V1;
2693
+ const length = spec.didLength ? 2 * spec.didLength : 32;
2694
+ if (privateKeyBytes) {
2695
+ if (privateKeyBytes.length !== length) {
2696
+ throw Error(`Invalid private key length supplied (${privateKeyBytes.length}. Expected ${length} for ${spec.type}`);
2697
+ }
2698
+ return (0, import_to_string.toString)(privateKeyBytes, "base16");
2699
+ }
2700
+ return (0, import_to_string.toString)((0, import_random.randomBytes)(length), "base16");
2701
+ }
2702
+ __name(generateOrUseProvidedEbsiPrivateKeyHex, "generateOrUseProvidedEbsiPrivateKeyHex");
2703
+ var formatEbsiPublicKey = /* @__PURE__ */ __name((args) => {
2704
+ const { key, type } = args;
2705
+ switch (type) {
2706
+ case "Secp256k1": {
2707
+ const bytes = (0, import_ethers.getBytes)("0x" + key.publicKeyHex, "key");
2708
+ return import_ethers.SigningKey.computePublicKey(bytes, false);
2709
+ }
2710
+ case "Secp256r1": {
2711
+ const jwk = (0, import_ssi_sdk_ext4.toJwk)(key.publicKeyHex, type, {
2712
+ use: import_ssi_sdk_ext4.JwkKeyUse.Signature,
2713
+ key
2714
+ });
2715
+ const jwkString = JSON.stringify(jwk, null, 2);
2716
+ return `0x${(0, import_to_string.toString)((0, import_from_string.fromString)(jwkString), "base16")}`;
2717
+ }
2718
+ default:
2719
+ throw new Error(`Unsupported EBSI key type: ${type}`);
2720
+ }
2721
+ }, "formatEbsiPublicKey");
2722
+ var ebsiGetIssuerMock = /* @__PURE__ */ __name((args) => {
2723
+ const { environment = "conformance", version = "v3" } = args;
2724
+ if (environment === "pilot") {
2725
+ throw Error(`EBSI Pilot network does not have a issuer mock server`);
2726
+ }
2727
+ return `${getEbsiApiBaseUrl({
2728
+ environment,
2729
+ version,
2730
+ system: environment
2731
+ })}/issuer-mock`;
2732
+ }, "ebsiGetIssuerMock");
2733
+ var ebsiGetRegistryAPIUrls = /* @__PURE__ */ __name((args) => {
2734
+ const { environment = "pilot", version = "v5" } = args;
2735
+ const baseUrl = `${getEbsiApiBaseUrl({
2736
+ environment,
2737
+ version,
2738
+ system: "did-registry"
2739
+ })}`;
2740
+ return {
2741
+ mutate: `${baseUrl}/jsonrpc`,
2742
+ query: `${baseUrl}/identifiers`
2743
+ };
2744
+ }, "ebsiGetRegistryAPIUrls");
2745
+ var determineWellknownEndpoint = /* @__PURE__ */ __name(({ environment, version, type, system = environment, mock }) => {
2746
+ const url = `${getEbsiApiBaseUrl({
2747
+ environment,
2748
+ version,
2749
+ system
2750
+ })}${mock ? `/${mock}` : ""}/.well-known/${type}`;
2751
+ logger.debug(`wellknown url: ${url}`);
2752
+ return url;
2753
+ }, "determineWellknownEndpoint");
2754
+ var ebsiSignAndSendTransaction = /* @__PURE__ */ __name(async (args, context) => {
2755
+ const { rpcRequest, accessToken, kid, apiOpts, previousTxResponse } = args;
2756
+ const unsignedTxResponse = await callRpcMethod(rpcRequest);
2757
+ const nonce = "result" in unsignedTxResponse ? unsignedTxResponse.result.nonce : void 0;
2758
+ if (previousTxResponse && "result" in unsignedTxResponse && "nonce" in previousTxResponse && "nonce" in unsignedTxResponse.result && typeof unsignedTxResponse.result === "object" && previousTxResponse.nonce === unsignedTxResponse.result.nonce) {
2759
+ await wait(1e3);
2760
+ return await ebsiSignAndSendTransaction({
2761
+ ...args,
2762
+ previousTxResponse
2763
+ }, context);
2764
+ }
2765
+ if ("error" in unsignedTxResponse && !!unsignedTxResponse.error) {
2766
+ logger.error(JSON.stringify(unsignedTxResponse));
2767
+ throw new Error(unsignedTxResponse.error.message ?? "Unknown error occurred");
2768
+ }
2769
+ const unsignedTx = unsignedTxResponse.result;
2770
+ const agentUnsignedTx = JSON.parse(JSON.stringify(unsignedTx));
2771
+ if (unsignedTx && "chainId" in unsignedTx && typeof unsignedTx.chainId === "string" && unsignedTx.chainId.toLowerCase().startsWith("0x")) {
2772
+ agentUnsignedTx.chainId = Number.parseInt(unsignedTx.chainId, 16);
2773
+ }
2774
+ const signedRawTx = await context.agent.keyManagerSignEthTX({
2775
+ kid,
2776
+ transaction: agentUnsignedTx
2777
+ });
2778
+ const sig = import_ethers.Transaction.from(signedRawTx).signature;
2779
+ const { r, s, v } = sig;
2780
+ const sTResponse = await callRpcMethod({
2781
+ params: [
2782
+ {
2783
+ protocol: "eth",
2784
+ unsignedTransaction: unsignedTx,
2785
+ r,
2786
+ s,
2787
+ v: `0x${v.toString(16)}`,
2788
+ signedRawTransaction: signedRawTx
2789
+ }
2790
+ ],
2791
+ rpcMethod: EbsiRpcMethod.SEND_SIGNED_TRANSACTION,
2792
+ rpcId: unsignedTxResponse.id,
2793
+ apiOpts,
2794
+ accessToken
2795
+ });
2796
+ if ("status" in sTResponse) {
2797
+ throw new Error(JSON.stringify(sTResponse, null, 2));
2798
+ }
2799
+ return {
2800
+ ...sTResponse,
2801
+ nonce
2802
+ };
2803
+ }, "ebsiSignAndSendTransaction");
2804
+ var ebsiGenerateOrUseKeyPair = /* @__PURE__ */ __name(async (args, context) => {
2805
+ const { keyOpts, keyType, kms, controllerKey = false } = args;
2806
+ let privateKeyHex = generateOrUseProvidedEbsiPrivateKeyHex(EBSI_DID_SPEC_INFOS.V1, keyOpts?.privateKeyHex ? (0, import_from_string.fromString)(keyOpts.privateKeyHex, "base16") : void 0);
2807
+ if (privateKeyHex.startsWith("0x")) {
2808
+ privateKeyHex = privateKeyHex.substring(2);
2809
+ }
2810
+ if (!privateKeyHex || privateKeyHex.length !== 64) {
2811
+ throw new Error("Private key should be 32 bytes / 64 chars hex");
2812
+ }
2813
+ const importableKey = await toMinimalImportableKey({
2814
+ key: {
2815
+ ...keyOpts,
2816
+ privateKeyHex
2817
+ },
2818
+ type: keyType,
2819
+ kms
2820
+ });
2821
+ if (keyType === "Secp256k1") {
2822
+ importableKey.meta = {
2823
+ ...importableKey.meta,
2824
+ ebsi: {
2825
+ anchored: false,
2826
+ controllerKey
2827
+ }
2828
+ };
2829
+ }
2830
+ return importableKey;
2831
+ }, "ebsiGenerateOrUseKeyPair");
2832
+ var toMinimalImportableKey = /* @__PURE__ */ __name(async (args) => {
2833
+ const { key, kms } = args;
2834
+ const minimalImportableKey = {
2835
+ ...key
2836
+ };
2837
+ const type = args.key?.type ?? args.type;
2838
+ minimalImportableKey.kms = kms;
2839
+ minimalImportableKey.type = type;
2840
+ if (!minimalImportableKey.privateKeyHex) {
2841
+ throw Error(`Minimal importable key needs a private key`);
2842
+ }
2843
+ minimalImportableKey.meta = {
2844
+ purposes: assertedPurposes({
2845
+ key
2846
+ }) ?? setDefaultPurposes({
2847
+ key,
2848
+ type
2849
+ }),
2850
+ jwkThumbprint: (0, import_ssi_sdk_ext4.calculateJwkThumbprintForKey)({
2851
+ key: minimalImportableKey,
2852
+ digestAlgorithm: "sha256"
2853
+ })
2854
+ };
2855
+ return minimalImportableKey;
2856
+ }, "toMinimalImportableKey");
2857
+ var assertedPurposes = /* @__PURE__ */ __name((args) => {
2858
+ const { key } = args;
2859
+ if (key?.purposes && key.purposes.length > 0) {
2860
+ switch (key.type) {
2861
+ case "Secp256k1": {
2862
+ if (key?.purposes && key.purposes.length > 0 && key.purposes?.includes(EbsiPublicKeyPurpose.CapabilityInvocation)) {
2863
+ return key.purposes;
2864
+ }
2865
+ throw new Error(`Secp256k1/ES256K key requires ${EbsiPublicKeyPurpose.CapabilityInvocation} purpose`);
2866
+ }
2867
+ case "Secp256r1": {
2868
+ if (key?.purposes && key.purposes.length > 0 && key.purposes.includes(EbsiPublicKeyPurpose.AssertionMethod) && key.purposes.includes(EbsiPublicKeyPurpose.Authentication)) {
2869
+ return key.purposes;
2870
+ }
2871
+ throw new Error(`Secp256r1/ES256 key requires ${[
2872
+ EbsiPublicKeyPurpose.AssertionMethod,
2873
+ EbsiPublicKeyPurpose.Authentication
2874
+ ].join(", ")} purposes`);
2875
+ }
2876
+ default:
2877
+ throw new Error(`Unsupported key type: ${key.type}`);
2878
+ }
2879
+ }
2880
+ return key?.purposes;
2881
+ }, "assertedPurposes");
2882
+ var setDefaultPurposes = /* @__PURE__ */ __name((args) => {
2883
+ const { key, type } = args;
2884
+ if (!key?.purposes || key.purposes.length === 0) {
2885
+ switch (type) {
2886
+ case "Secp256k1":
2887
+ return [
2888
+ EbsiPublicKeyPurpose.CapabilityInvocation
2889
+ ];
2890
+ case "Secp256r1":
2891
+ return [
2892
+ EbsiPublicKeyPurpose.AssertionMethod,
2893
+ EbsiPublicKeyPurpose.Authentication
2894
+ ];
2895
+ default:
2896
+ throw new Error(`Unsupported key type: ${key?.type}`);
2897
+ }
2898
+ }
2899
+ return key.purposes;
2900
+ }, "setDefaultPurposes");
2901
+ var randomRpcId = /* @__PURE__ */ __name(() => {
2902
+ return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
2903
+ }, "randomRpcId");
2904
+ var ebsiCreateDidOnLedger = /* @__PURE__ */ __name(async (args, context) => {
2905
+ const { accessTokenOpts, notBefore = Math.floor(Date.now() / 1e3 - 60), notAfter = Math.floor(Date.now() / 1e3 + 10 * 365 * 24 * 60 * 60), baseDocument, identifier } = args;
2906
+ const { clientId, redirectUri, environment, credentialIssuer } = accessTokenOpts;
2907
+ const controllerKey = (0, import_ssi_sdk_ext3.getControllerKey)({
2908
+ identifier
2909
+ });
2910
+ const secp256r1 = (0, import_ssi_sdk_ext3.getKeys)({
2911
+ identifier,
2912
+ keyType: "Secp256r1"
2913
+ })?.[0];
2914
+ let { attestationToOnboard, attestationToOnboardCredentialRole } = accessTokenOpts;
2915
+ if (!controllerKey || !secp256r1) {
2916
+ return Promise.reject(`No secp256k1 controller key and/or secp2561r key found for identifier ${identifier}`);
2917
+ }
2918
+ const from = (0, import_ssi_sdk_ext3.getEthereumAddressFromKey)({
2919
+ key: controllerKey
2920
+ });
2921
+ if (!from) {
2922
+ return Promise.reject(Error(`EBSI 'from' address expected for key ${controllerKey.publicKeyHex}`));
2923
+ }
2924
+ const did = identifier.did;
2925
+ const kid = controllerKey.kid;
2926
+ const idOpts = {
2927
+ identifier,
2928
+ kid
2929
+ };
2930
+ let rpcId = args.rpcId ?? randomRpcId();
2931
+ const apiOpts = {
2932
+ environment,
2933
+ version: "v5"
2934
+ };
2935
+ const jwksUri = args.accessTokenOpts.jwksUri ?? `${clientId}/.well-known/jwks/dids/${encodeURIComponent(identifier.did)}.json`;
2936
+ if (!attestationToOnboard) {
2937
+ console.log(`No attestation to onboard present. Will get one`);
2938
+ const authReqResult = await context.agent.ebsiCreateAttestationAuthRequestURL({
2939
+ credentialIssuer,
2940
+ idOpts,
2941
+ formats: [
2942
+ "jwt_vc"
2943
+ ],
2944
+ clientId,
2945
+ redirectUri,
2946
+ credentialType: "VerifiableAuthorisationToOnboard",
2947
+ requestObjectOpts: {
2948
+ iss: clientId,
2949
+ requestObjectMode: import_oid4vci_common3.CreateRequestObjectMode.REQUEST_OBJECT,
2950
+ jwksUri
2951
+ }
2952
+ });
2953
+ const attestationResult = await context.agent.ebsiGetAttestation({
2954
+ clientId,
2955
+ authReqResult,
2956
+ opts: {
2957
+ timeout: 12e4
2958
+ }
2959
+ });
2960
+ attestationToOnboard = attestationResult.credentials[0].rawVerifiableCredential;
2961
+ console.log(`Attestation to onboard received`, attestationToOnboard);
2962
+ }
2963
+ const insertDidAccessTokenResponse = await context.agent.ebsiAccessTokenGet({
2964
+ credentialRole: attestationToOnboardCredentialRole,
2965
+ attestationCredential: attestationToOnboard,
2966
+ jwksUri,
2967
+ scope: "didr_invite",
2968
+ idOpts,
2969
+ redirectUri,
2970
+ credentialIssuer,
2971
+ clientId,
2972
+ environment,
2973
+ skipDidResolution: true
2974
+ });
2975
+ const insertDidDocRequest = {
2976
+ params: [
2977
+ {
2978
+ from,
2979
+ did,
2980
+ baseDocument: baseDocument ?? BASE_CONTEXT_DOC,
2981
+ vMethodId: (0, import_ssi_sdk_ext4.calculateJwkThumbprint)({
2982
+ jwk: (0, import_ssi_sdk_ext4.toJwk)(controllerKey.publicKeyHex, "Secp256k1")
2983
+ }),
2984
+ isSecp256k1: true,
2985
+ publicKey: formatEbsiPublicKey({
2986
+ key: controllerKey,
2987
+ type: "Secp256k1"
2988
+ }),
2989
+ notBefore,
2990
+ notAfter
2991
+ }
2992
+ ],
2993
+ rpcMethod: EbsiRpcMethod.INSERT_DID_DOCUMENT,
2994
+ rpcId,
2995
+ apiOpts,
2996
+ accessToken: insertDidAccessTokenResponse.accessTokenResponse.access_token
2997
+ };
2998
+ const insertDidDocResponse = await ebsiSignAndSendTransaction({
2999
+ rpcRequest: insertDidDocRequest,
3000
+ kid,
3001
+ accessToken: insertDidAccessTokenResponse.accessTokenResponse.access_token,
3002
+ apiOpts
3003
+ }, context);
3004
+ let anchorTime = await ebsiWaitTillDocumentAnchored({
3005
+ did,
3006
+ ...apiOpts,
3007
+ maxWaitTime: 3e4,
3008
+ startIntervalMS: 2e3,
3009
+ minIntervalMS: 500,
3010
+ decreaseIntervalMSPerStep: 750
3011
+ });
3012
+ if (!anchorTime.didDocument) {
3013
+ throw Error(`did ${did} was not registered on EBSI network ${apiOpts.environment} in 45 seconds`);
3014
+ }
3015
+ logger.debug(`Anchoring did ${did} on network ${apiOpts.environment} took ${anchorTime.totalWaitTime / 1e3} seconds in ${anchorTime.count} tries`);
3016
+ idOpts.kid = (0, import_ssi_sdk_ext4.calculateJwkThumbprintForKey)({
3017
+ key: controllerKey
3018
+ });
3019
+ const addVMAccessTokenResponse = await context.agent.ebsiAccessTokenGet({
3020
+ credentialRole: attestationToOnboardCredentialRole,
3021
+ // attestationCredential: attestationToOnboard,
3022
+ jwksUri,
3023
+ scope: "didr_write",
3024
+ idOpts,
3025
+ redirectUri,
3026
+ credentialIssuer: void 0,
3027
+ clientId,
3028
+ environment,
3029
+ skipDidResolution: true
3030
+ });
3031
+ const vMethodId = (0, import_ssi_sdk_ext4.calculateJwkThumbprint)({
3032
+ jwk: (0, import_ssi_sdk_ext4.toJwk)(secp256r1.publicKeyHex, "Secp256r1")
3033
+ });
3034
+ const publicKey = formatEbsiPublicKey({
3035
+ key: secp256r1,
3036
+ type: "Secp256r1"
3037
+ });
3038
+ const addVerificationMethodRequest = {
3039
+ params: [
3040
+ {
3041
+ from,
3042
+ did,
3043
+ isSecp256k1: false,
3044
+ vMethodId,
3045
+ publicKey
3046
+ }
3047
+ ],
3048
+ rpcMethod: EbsiRpcMethod.ADD_VERIFICATION_METHOD,
3049
+ rpcId,
3050
+ apiOpts,
3051
+ accessToken: addVMAccessTokenResponse.accessTokenResponse.access_token
3052
+ };
3053
+ const addVerificationMethodResponse = await ebsiSignAndSendTransaction({
3054
+ rpcRequest: addVerificationMethodRequest,
3055
+ previousTxResponse: insertDidDocResponse,
3056
+ kid,
3057
+ accessToken: addVMAccessTokenResponse.accessTokenResponse.access_token,
3058
+ apiOpts
3059
+ }, context);
3060
+ await wait(2e3);
3061
+ const addAssertionMethodRelationshipRequest = {
3062
+ params: [
3063
+ {
3064
+ from,
3065
+ did,
3066
+ vMethodId,
3067
+ name: "assertionMethod",
3068
+ notAfter,
3069
+ notBefore
3070
+ }
3071
+ ],
3072
+ rpcMethod: EbsiRpcMethod.ADD_VERIFICATION_RELATIONSHIP,
3073
+ rpcId,
3074
+ apiOpts,
3075
+ accessToken: addVMAccessTokenResponse.accessTokenResponse.access_token
3076
+ };
3077
+ const addAssertionMethodRelationshipResponse = await ebsiSignAndSendTransaction({
3078
+ rpcRequest: addAssertionMethodRelationshipRequest,
3079
+ previousTxResponse: addVerificationMethodResponse,
3080
+ kid,
3081
+ accessToken: addVMAccessTokenResponse.accessTokenResponse.access_token,
3082
+ apiOpts
3083
+ }, context);
3084
+ anchorTime = await ebsiWaitTillDocumentAnchored({
3085
+ did,
3086
+ ...apiOpts,
3087
+ maxWaitTime: 2e4,
3088
+ minIntervalMS: 500,
3089
+ decreaseIntervalMSPerStep: 500,
3090
+ searchForObject: {
3091
+ assertionMethod: [
3092
+ `${did}#${vMethodId}`
3093
+ ]
3094
+ }
3095
+ });
3096
+ if (!anchorTime.didDocument) {
3097
+ throw Error(`did ${did} assertionMethod id ${vMethodId} was not registered on EBSI network ${apiOpts.environment} in 20 seconds`);
3098
+ }
3099
+ logger.debug(`Anchoring assertionMethod ${vMethodId} for DID ${did} on network ${apiOpts.environment} took ${anchorTime.totalWaitTime / 1e3} seconds in ${anchorTime.count} tries`);
3100
+ const addAuthenticationRelationshipRequest = {
3101
+ params: [
3102
+ {
3103
+ from,
3104
+ did,
3105
+ vMethodId,
3106
+ name: "authentication",
3107
+ notAfter,
3108
+ notBefore
3109
+ }
3110
+ ],
3111
+ rpcMethod: EbsiRpcMethod.ADD_VERIFICATION_RELATIONSHIP,
3112
+ rpcId,
3113
+ apiOpts,
3114
+ accessToken: addVMAccessTokenResponse.accessTokenResponse.access_token
3115
+ };
3116
+ const addAuthenticationRelationshipResponse = await ebsiSignAndSendTransaction({
3117
+ rpcRequest: addAuthenticationRelationshipRequest,
3118
+ previousTxResponse: addAssertionMethodRelationshipResponse,
3119
+ kid,
3120
+ accessToken: addVMAccessTokenResponse.accessTokenResponse.access_token,
3121
+ apiOpts
3122
+ }, context);
3123
+ return {
3124
+ identifier,
3125
+ insertDidDoc: insertDidDocResponse,
3126
+ addVerificationMethod: addVerificationMethodResponse,
3127
+ addAuthenticationRelationship: addAuthenticationRelationshipResponse,
3128
+ addAssertionMethodRelationship: addAssertionMethodRelationshipResponse
3129
+ };
3130
+ }, "ebsiCreateDidOnLedger");
3131
+
3132
+ // src/agent/EbsiSupport.ts
3133
+ var import_uuid = require("uuid");
3134
+ var import_did_auth_siop_adapter = require("@sphereon/did-auth-siop-adapter");
3135
+ var import_ssi_sdk5 = require("@sphereon/ssi-sdk.core");
3136
+ var ebsiSupportMethods = [
3137
+ "ebsiCreateDidOnLedger",
3138
+ "ebsiWellknownMetadata",
3139
+ "ebsiAuthorizationServerJwks",
3140
+ "ebsiPresentationDefinitionGet",
3141
+ "ebsiAccessTokenGet",
3142
+ "ebsiCreateAttestationAuthRequestURL",
3143
+ "ebsiGetAttestation"
3144
+ ];
3145
+ var EbsiSupport = class {
3146
+ static {
3147
+ __name(this, "EbsiSupport");
3148
+ }
3149
+ schema = schema.IEbsiSupport;
3150
+ methods = {
3151
+ ebsiCreateDidOnLedger: this.ebsiCreateDidOnLedger.bind(this),
3152
+ ebsiWellknownMetadata: this.ebsiWellknownMetadata.bind(this),
3153
+ ebsiAuthorizationServerJwks: this.ebsiAuthorizationServerJwks.bind(this),
3154
+ ebsiPresentationDefinitionGet: this.ebsiPresentationDefinitionGet.bind(this),
3155
+ ebsiAccessTokenGet: this.ebsiAccessTokenGet.bind(this),
3156
+ ebsiCreateAttestationAuthRequestURL: ebsiCreateAttestationAuthRequestURL.bind(this),
3157
+ ebsiGetAttestation: ebsiGetAttestation.bind(this)
3158
+ };
3159
+ async ebsiCreateDidOnLedger(args, context) {
3160
+ return await ebsiCreateDidOnLedger(args, context);
3161
+ }
3162
+ async ebsiWellknownMetadata(args) {
3163
+ const url = determineWellknownEndpoint(args);
3164
+ return await (await (0, import_cross_fetch4.default)(url, {
3165
+ method: "GET",
3166
+ headers: {
3167
+ Accept: "application/json"
3168
+ }
3169
+ })).json();
3170
+ }
3171
+ async ebsiAuthorizationServerJwks(args) {
3172
+ const discoveryMetadata = await this.ebsiWellknownMetadata({
3173
+ ...args,
3174
+ type: "openid-configuration"
3175
+ });
3176
+ return await (await (0, import_cross_fetch4.default)(`${discoveryMetadata.jwks_uri}`, {
3177
+ method: "GET",
3178
+ headers: {
3179
+ Accept: "application/jwk-set+json"
3180
+ }
3181
+ })).json();
3182
+ }
3183
+ async ebsiPresentationDefinitionGet(args) {
3184
+ const { scope, apiOpts, openIDMetadata } = args;
3185
+ const discoveryMetadata = openIDMetadata ?? await this.ebsiWellknownMetadata({
3186
+ ...apiOpts,
3187
+ type: "openid-configuration",
3188
+ system: apiOpts?.mock ? "authorisation" : apiOpts?.system,
3189
+ version: apiOpts?.version ?? "v4"
3190
+ });
3191
+ return await (await (0, import_cross_fetch4.default)(`${discoveryMetadata.presentation_definition_endpoint}?scope=openid%20${scope}`, {
3192
+ method: "GET",
3193
+ headers: {
3194
+ Accept: "application/json"
3195
+ }
3196
+ })).json();
3197
+ }
3198
+ async ebsiAccessTokenGet(args, context) {
3199
+ const { scope, idOpts, jwksUri, clientId, allVerifiableCredentials, redirectUri, environment, skipDidResolution = false } = args;
3200
+ const identifier = await context.agent.identifierManagedGetByDid(idOpts);
3201
+ console.log(`Getting access token for ${identifier.did}, scope ${scope} and clientId=${clientId}, skipDidResolution=${skipDidResolution}...`);
3202
+ const openIDMetadata = await this.ebsiWellknownMetadata({
3203
+ environment,
3204
+ version: "v4",
3205
+ mock: void 0,
3206
+ system: "authorisation",
3207
+ type: "openid-configuration"
3208
+ });
3209
+ const definitionResponse = await this.ebsiPresentationDefinitionGet({
3210
+ ...args,
3211
+ openIDMetadata,
3212
+ apiOpts: {
3213
+ environment,
3214
+ version: "v4",
3215
+ type: "openid-configuration"
3216
+ }
3217
+ });
3218
+ const hasInputDescriptors = definitionResponse.input_descriptors.length > 0;
3219
+ console.log(`PD response`, definitionResponse);
3220
+ if (!hasInputDescriptors) {
3221
+ console.warn(`No INPUT descriptor returned for scope ${scope}`);
3222
+ }
3223
+ let attestationCredential = args.attestationCredential;
3224
+ if (hasInputDescriptors && !attestationCredential) {
3225
+ if (allVerifiableCredentials && allVerifiableCredentials.length > 0) {
3226
+ const pexResult2 = await context.agent.pexDefinitionFilterCredentials({
3227
+ presentationDefinition: definitionResponse,
3228
+ credentialFilterOpts: {
3229
+ credentialRole: args.credentialRole,
3230
+ verifiableCredentials: allVerifiableCredentials
3231
+ }
3232
+ });
3233
+ if (pexResult2.filteredCredentials.length > 0) {
3234
+ const filtered = pexResult2.filteredCredentials.map((cred) => import_ssi_types.CredentialMapper.toUniformCredential(cred, {
3235
+ hasher: import_ssi_sdk5.defaultHasher
3236
+ })).filter((cred) => {
3237
+ if (!cred.expirationDate) {
3238
+ return cred;
3239
+ } else if (new Date(cred.expirationDate).getDate() >= Date.now()) {
3240
+ return cred;
3241
+ }
3242
+ return void 0;
3243
+ }).filter((cred) => !!cred);
3244
+ if (filtered.length > 0) {
3245
+ attestationCredential = filtered[0];
3246
+ }
3247
+ }
3248
+ }
3249
+ if (!attestationCredential) {
3250
+ console.log(`No attestation credential present. Will get one from within access token method!`);
3251
+ const credentialIssuer = args.credentialIssuer ?? ebsiGetIssuerMock({
3252
+ environment
3253
+ });
3254
+ const authReqResult = await context.agent.ebsiCreateAttestationAuthRequestURL({
3255
+ credentialIssuer,
3256
+ idOpts,
3257
+ formats: [
3258
+ "jwt_vc"
3259
+ ],
3260
+ clientId,
3261
+ redirectUri,
3262
+ requestObjectOpts: {
3263
+ iss: clientId,
3264
+ requestObjectMode: import_oid4vci_common4.CreateRequestObjectMode.REQUEST_OBJECT,
3265
+ jwksUri
3266
+ },
3267
+ credentialType: "VerifiableAuthorisationToOnboard"
3268
+ });
3269
+ const attestationResult = await context.agent.ebsiGetAttestation({
3270
+ authReqResult,
3271
+ clientId,
3272
+ opts: {
3273
+ timeout: 3e4
3274
+ }
3275
+ });
3276
+ attestationCredential = attestationResult.credentials[0].rawVerifiableCredential;
3277
+ }
3278
+ }
3279
+ const definition = {
3280
+ definition: definitionResponse,
3281
+ location: import_did_auth_siop2.PresentationDefinitionLocation.TOPLEVEL_PRESENTATION_DEF,
3282
+ version: import_did_auth_siop2.SupportedVersion.SIOPv2_D11
3283
+ };
3284
+ const pexResult = hasInputDescriptors ? await context.agent.pexDefinitionFilterCredentials({
3285
+ presentationDefinition: definitionResponse,
3286
+ credentialFilterOpts: {
3287
+ credentialRole: args.credentialRole,
3288
+ verifiableCredentials: [
3289
+ attestationCredential
3290
+ ]
3291
+ }
3292
+ }) : {
3293
+ // LOL, let's see whether we can trick PEX to create a VP without VCs
3294
+ filteredCredentials: [],
3295
+ id: definitionResponse.id,
3296
+ selectResults: {
3297
+ verifiableCredential: [],
3298
+ areRequiredCredentialsPresent: "info"
3299
+ }
3300
+ };
3301
+ const opSession = await context.agent.siopRegisterOPSession({
3302
+ requestJwtOrUri: "",
3303
+ op: {
3304
+ checkLinkedDomains: import_did_auth_siop_adapter.CheckLinkedDomain.NEVER
3305
+ },
3306
+ providedPresentationDefinitions: [
3307
+ definition
3308
+ ]
3309
+ });
3310
+ const oid4vp = await opSession.getOID4VP({
3311
+ allIdentifiers: [
3312
+ identifier.did
3313
+ ]
3314
+ });
3315
+ const vp = await oid4vp.createVerifiablePresentation(args.credentialRole, {
3316
+ definition,
3317
+ credentials: pexResult.filteredCredentials
3318
+ }, {
3319
+ proofOpts: {
3320
+ domain: openIDMetadata.issuer,
3321
+ nonce: (0, import_uuid.v4)(),
3322
+ created: new Date(Date.now() - 12e4).toString()
3323
+ },
3324
+ holder: identifier.did,
3325
+ idOpts,
3326
+ skipDidResolution,
3327
+ forceNoCredentialsInVP: !hasInputDescriptors
3328
+ });
3329
+ const presentationSubmission = hasInputDescriptors ? vp.presentationSubmission : {
3330
+ id: (0, import_uuid.v4)(),
3331
+ definition_id: definitionResponse.id,
3332
+ descriptor_map: []
3333
+ };
3334
+ console.log(`Presentation submission`, presentationSubmission);
3335
+ const tokenRequestArgs = {
3336
+ grant_type: "vp_token",
3337
+ vp_token: import_ssi_types.CredentialMapper.toCompactJWT(vp.verifiablePresentations[0]),
3338
+ scope,
3339
+ presentation_submission: presentationSubmission,
3340
+ apiOpts: {
3341
+ environment,
3342
+ version: "v4"
3343
+ },
3344
+ openIDMetadata
3345
+ };
3346
+ console.log(`Access token request:\r
3347
+ ${JSON.stringify(tokenRequestArgs)}`);
3348
+ const accessTokenResponse = await this.getAccessToken(tokenRequestArgs);
3349
+ console.log(`Access token response:\r
3350
+ ${JSON.stringify(accessTokenResponse)}`);
3351
+ if (!("access_token" in accessTokenResponse)) {
3352
+ throw Error(`Error response: ${JSON.stringify(accessTokenResponse)}`);
3353
+ }
3354
+ return {
3355
+ accessTokenResponse,
3356
+ // vp,
3357
+ scope,
3358
+ // definition,
3359
+ identifier
3360
+ };
3361
+ }
3362
+ async getAccessToken(args) {
3363
+ const { grant_type = "vp_token", scope, vp_token, presentation_submission, apiOpts, openIDMetadata } = args;
3364
+ const discoveryMetadata = openIDMetadata ?? await this.ebsiWellknownMetadata({
3365
+ ...apiOpts,
3366
+ type: "openid-configuration"
3367
+ });
3368
+ const request = {
3369
+ grant_type,
3370
+ scope: `openid ${scope}`,
3371
+ vp_token,
3372
+ presentation_submission: JSON.stringify(presentation_submission)
3373
+ };
3374
+ return await (await (0, import_cross_fetch4.default)(`${discoveryMetadata.token_endpoint}`, {
3375
+ method: "POST",
3376
+ headers: {
3377
+ ContentType: "application/x-www-form-urlencoded",
3378
+ Accept: "application/json"
3379
+ },
3380
+ body: new URLSearchParams(request)
3381
+ })).json();
3382
+ }
3383
+ };
3384
+
3385
+ // src/types/IEbsiSupport.ts
3386
+ var TokenType = /* @__PURE__ */ function(TokenType2) {
3387
+ TokenType2["BEARER"] = "Bearer";
3388
+ return TokenType2;
3389
+ }({});
3390
+
3391
+ // src/did/EbsiDidProvider.ts
3392
+ var import_ssi_sdk_ext5 = require("@sphereon/ssi-sdk-ext.did-utils");
3393
+ var import_ssi_sdk_ext6 = require("@sphereon/ssi-sdk-ext.key-utils");
3394
+ var import_did_manager = require("@veramo/did-manager");
3395
+ var import_debug = __toESM(require("debug"), 1);
3396
+ var debug = (0, import_debug.default)("sphereon:did-provider-ebsi");
3397
+ var EbsiDidProvider = class _EbsiDidProvider extends import_did_manager.AbstractIdentifierProvider {
3398
+ static {
3399
+ __name(this, "EbsiDidProvider");
3400
+ }
3401
+ static PROVIDER = "did:ebsi";
3402
+ defaultKms;
3403
+ apiOpts;
3404
+ constructor(options) {
3405
+ super();
3406
+ this.defaultKms = options.defaultKms;
3407
+ this.apiOpts = options.apiOpts;
3408
+ }
3409
+ async createIdentifier(args, context) {
3410
+ const { type, options, kms = this.defaultKms, alias } = args;
3411
+ const { notBefore, notAfter, secp256k1Key, secp256r1Key, keys, accessTokenOpts, executeLedgerOperation = !!args.options?.accessTokenOpts, methodSpecificId = generateEbsiMethodSpecificId(EBSI_DID_SPEC_INFOS.V1), baseDocument, services } = {
3412
+ ...options
3413
+ };
3414
+ if (executeLedgerOperation && !accessTokenOpts) {
3415
+ throw new Error("Access token options must be provided to execute ledger operation");
3416
+ }
3417
+ const rpcId = options?.rpcId ?? randomRpcId();
3418
+ if (type === EBSI_DID_SPEC_INFOS.KEY) {
3419
+ return Promise.reject(Error(`Type ${type} not supported. Please use @sphereon/ssi-sdk-ext.did-provider-key for Natural Person EBSI DIDs`));
3420
+ } else if (!kms) {
3421
+ return Promise.reject(Error(`No KMS value provided`));
3422
+ } else if (keys && keys.length > 0 && !executeLedgerOperation) {
3423
+ return Promise.reject(Error(`Cannot add additional keys if ledger operation is not enabled at creation. Please add the keys later yourself`));
3424
+ }
3425
+ const secp256k1ImportKey = await ebsiGenerateOrUseKeyPair({
3426
+ keyOpts: secp256k1Key,
3427
+ keyType: "Secp256k1",
3428
+ kms,
3429
+ controllerKey: true
3430
+ }, context);
3431
+ const secp256k1ManagedKeyInfo = await context.agent.keyManagerImport(secp256k1ImportKey);
3432
+ const secp256r1ImportKey = await ebsiGenerateOrUseKeyPair({
3433
+ keyOpts: secp256r1Key,
3434
+ keyType: "Secp256r1",
3435
+ kms
3436
+ }, context);
3437
+ const secp256r1ManagedKeyInfo = await context.agent.keyManagerImport(secp256r1ImportKey);
3438
+ const identifier = {
3439
+ did: options.did && options.did.startsWith("did:ebsi:") ? options.did : `${EBSI_DID_SPEC_INFOS.V1.method}${methodSpecificId}`,
3440
+ controllerKeyId: secp256k1ManagedKeyInfo.kid,
3441
+ keys: [
3442
+ secp256k1ManagedKeyInfo,
3443
+ secp256r1ManagedKeyInfo
3444
+ ],
3445
+ alias,
3446
+ services: services ?? [],
3447
+ provider: _EbsiDidProvider.PROVIDER
3448
+ };
3449
+ const apiOpts = {
3450
+ ...this.apiOpts
3451
+ };
3452
+ if (!apiOpts.environment) {
3453
+ apiOpts.environment = accessTokenOpts?.environment ?? "pilot";
3454
+ }
3455
+ if (!apiOpts.version) {
3456
+ apiOpts.version = "v5";
3457
+ }
3458
+ if (executeLedgerOperation) {
3459
+ await ebsiCreateDidOnLedger({
3460
+ identifier,
3461
+ baseDocument,
3462
+ accessTokenOpts,
3463
+ rpcId,
3464
+ notBefore,
3465
+ notAfter
3466
+ }, context);
3467
+ if (keys && keys.length > 0) {
3468
+ for (const keyOpts of keys) {
3469
+ const key = await ebsiGenerateOrUseKeyPair({
3470
+ keyOpts,
3471
+ keyType: keyOpts.type ?? "Secp256r1",
3472
+ kms
3473
+ }, context);
3474
+ const managedKeyInfo = await context.agent.keyManagerImport(key);
3475
+ console.warn(`FIXME: Anchor additional key on EBSI`, managedKeyInfo);
3476
+ }
3477
+ }
3478
+ }
3479
+ debug("Created", identifier.did);
3480
+ return identifier;
3481
+ }
3482
+ async addKey(args, context) {
3483
+ const { identifier, key, options } = args;
3484
+ const { accessToken, vmRelationships, apiOpts, rpcId = randomRpcId() } = options;
3485
+ if (vmRelationships.length === 0) {
3486
+ return Promise.reject(Error(`No verification method relationship provided`));
3487
+ }
3488
+ const controllerKey = (0, import_ssi_sdk_ext5.getControllerKey)({
3489
+ identifier
3490
+ });
3491
+ const from = (0, import_ssi_sdk_ext5.getEthereumAddressFromKey)({
3492
+ key: controllerKey
3493
+ });
3494
+ const kid = controllerKey.kid;
3495
+ const did = identifier.did;
3496
+ const addVerificationMethodRequest = {
3497
+ params: [
3498
+ {
3499
+ from,
3500
+ did,
3501
+ isSecp256k1: true,
3502
+ vMethodId: (0, import_ssi_sdk_ext6.calculateJwkThumbprint)({
3503
+ jwk: (0, import_ssi_sdk_ext6.toJwk)(key.publicKeyHex, key.type)
3504
+ }),
3505
+ publicKey: formatEbsiPublicKey({
3506
+ key,
3507
+ type: key.type
3508
+ })
3509
+ }
3510
+ ],
3511
+ rpcMethod: EbsiRpcMethod.ADD_VERIFICATION_METHOD,
3512
+ rpcId,
3513
+ apiOpts,
3514
+ accessToken
3515
+ };
3516
+ let rpcResponse = await ebsiSignAndSendTransaction({
3517
+ rpcRequest: addVerificationMethodRequest,
3518
+ kid,
3519
+ accessToken,
3520
+ apiOpts
3521
+ }, context);
3522
+ const vMethodId = (0, import_ssi_sdk_ext6.calculateJwkThumbprintForKey)({
3523
+ key
3524
+ });
3525
+ for (const vmRelationshipsKey in vmRelationships) {
3526
+ const addVerificationMethodRelationshipRequest = {
3527
+ params: [
3528
+ {
3529
+ from,
3530
+ did,
3531
+ vMethodId,
3532
+ name: vmRelationshipsKey,
3533
+ notAfter: Date.now() / 1e3 - 6e4,
3534
+ notBefore: Date.now() / 1e3 + 5 * 365 * 24 * 60 * 60
3535
+ }
3536
+ ],
3537
+ rpcMethod: EbsiRpcMethod.ADD_VERIFICATION_RELATIONSHIP,
3538
+ rpcId,
3539
+ apiOpts,
3540
+ accessToken
3541
+ };
3542
+ rpcResponse = await ebsiSignAndSendTransaction({
3543
+ rpcRequest: addVerificationMethodRelationshipRequest,
3544
+ previousTxResponse: rpcResponse,
3545
+ kid,
3546
+ accessToken,
3547
+ apiOpts
3548
+ }, context);
3549
+ }
3550
+ }
3551
+ async addService(args, context) {
3552
+ const { identifier, service, options } = args;
3553
+ const { accessToken, apiOpts, rpcId = randomRpcId() } = options;
3554
+ const controllerKey = (0, import_ssi_sdk_ext5.getControllerKey)({
3555
+ identifier
3556
+ });
3557
+ const from = (0, import_ssi_sdk_ext5.getEthereumAddressFromKey)({
3558
+ key: controllerKey
3559
+ });
3560
+ const did = identifier.did;
3561
+ const kid = controllerKey.kid;
3562
+ const addServiceRequest = {
3563
+ params: [
3564
+ {
3565
+ from,
3566
+ did,
3567
+ service
3568
+ }
3569
+ ],
3570
+ rpcMethod: EbsiRpcMethod.ADD_SERVICE,
3571
+ rpcId,
3572
+ apiOpts,
3573
+ accessToken
3574
+ };
3575
+ return await ebsiSignAndSendTransaction({
3576
+ rpcRequest: addServiceRequest,
3577
+ kid,
3578
+ accessToken,
3579
+ apiOpts
3580
+ }, context);
3581
+ }
3582
+ deleteIdentifier(args, context) {
3583
+ return Promise.resolve(true);
3584
+ }
3585
+ removeKey(args, context) {
3586
+ throw new Error(`Not (yet) implemented for the EBSI did provider`);
3587
+ }
3588
+ removeService(args, context) {
3589
+ throw new Error(`Not (yet) implemented for the EBSI did provider`);
3590
+ }
3591
+ // TODO How does it work? Not inferable from the api: https://hub.ebsi.eu/apis/pilot/did-registry/v5/post-jsonrpc#updatebasedocument
3592
+ async updateIdentifier(args, context) {
3593
+ throw new Error(`Not (yet) implemented for the EBSI did provider`);
3594
+ }
3595
+ };
3596
+
3597
+ // src/did/EbsiDidResolver.ts
3598
+ var import_did_resolver = require("did-resolver");
3599
+ var import_ssi_sdk_ext7 = require("@sphereon/ssi-sdk-ext.did-resolver-ebsi");
3600
+
3601
+ // src/index.ts
3602
+ var logger = import_ssi_types2.Loggers.DEFAULT.options("sphereon:ebsi-support", {
3603
+ defaultLogLevel: import_ssi_types2.LogLevel.DEBUG,
3604
+ methods: [
3605
+ import_ssi_types2.LogMethod.CONSOLE,
3606
+ import_ssi_types2.LogMethod.DEBUG_PKG
3607
+ ]
3608
+ }).get("sphereon:ebsi-support");
3609
+ var schema = require_plugin_schema();
3610
+ //# sourceMappingURL=index.cjs.map