@sphereon/ssi-sdk.credential-store 0.33.1-feature.vcdm2.tsup.32 → 0.33.1-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2212 +1,37 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropNames = Object.getOwnPropertyNames;
3
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
- var __commonJS = (cb, mod) => function __require() {
5
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
6
- };
7
-
8
- // plugin.schema.json
9
- var require_plugin_schema = __commonJS({
10
- "plugin.schema.json"(exports, module) {
11
- module.exports = {
12
- ICredentialStore: {
13
- components: {
14
- schemas: {
15
- AddCredentialArgs: {
16
- type: "object",
17
- properties: {
18
- credential: {
19
- $ref: "#/components/schemas/AddDigitalCredential"
20
- },
21
- opts: {
22
- type: "object",
23
- properties: {
24
- maxTimeSkewInMS: {
25
- type: "number"
26
- },
27
- hasher: {
28
- $ref: "#/components/schemas/HasherSync"
29
- }
30
- }
31
- }
32
- },
33
- required: [
34
- "credential"
35
- ]
36
- },
37
- AddDigitalCredential: {
38
- type: "object",
39
- properties: {
40
- parentId: {
41
- type: "string"
42
- },
43
- credentialRole: {
44
- type: "object",
45
- properties: {}
46
- },
47
- rawDocument: {
48
- type: "string"
49
- },
50
- credentialId: {
51
- type: "string"
52
- },
53
- kmsKeyRef: {
54
- type: "string"
55
- },
56
- identifierMethod: {
57
- type: "string"
58
- },
59
- issuerCorrelationType: {
60
- type: "object",
61
- properties: {}
62
- },
63
- subjectCorrelationType: {
64
- type: "object",
65
- properties: {}
66
- },
67
- rpCorrelationType: {
68
- type: "object",
69
- properties: {}
70
- },
71
- isIssuerSigned: {
72
- type: "boolean"
73
- },
74
- issuerCorrelationId: {
75
- type: "string"
76
- },
77
- subjectCorrelationId: {
78
- type: "string"
79
- },
80
- rpCorrelationId: {
81
- type: "string"
82
- },
83
- verifiedState: {
84
- type: "object",
85
- properties: {}
86
- },
87
- tenantId: {
88
- type: "string"
89
- },
90
- presentedAt: {
91
- type: "string",
92
- format: "date-time"
93
- },
94
- verifiedAt: {
95
- type: "string",
96
- format: "date-time"
97
- },
98
- revokedAt: {
99
- type: "string",
100
- format: "date-time"
101
- },
102
- regulationType: {
103
- type: "object",
104
- properties: {}
105
- }
106
- },
107
- required: [
108
- "credentialRole",
109
- "rawDocument",
110
- "issuerCorrelationType",
111
- "issuerCorrelationId"
112
- ]
113
- },
114
- HasherSync: {
115
- $comment: "(data: string | ArrayBuffer, alg: string) => Uint8Array",
116
- type: "object",
117
- properties: {
118
- namedArgs: {
119
- type: "object",
120
- properties: {
121
- data: {
122
- anyOf: [
123
- {
124
- type: "string"
125
- },
126
- {
127
- type: "object",
128
- properties: {
129
- byteLength: {
130
- type: "number"
131
- }
132
- },
133
- required: [
134
- "byteLength"
135
- ]
136
- }
137
- ]
138
- },
139
- alg: {
140
- type: "string"
141
- }
142
- },
143
- required: [
144
- "data",
145
- "alg"
146
- ],
147
- additionalProperties: false
148
- }
149
- }
150
- },
151
- DigitalCredential: {
152
- type: "object",
153
- properties: {
154
- id: {
155
- type: "string"
156
- },
157
- parentId: {
158
- type: "string"
159
- },
160
- documentType: {
161
- $ref: "#/components/schemas/DocumentType"
162
- },
163
- documentFormat: {
164
- $ref: "#/components/schemas/CredentialDocumentFormat"
165
- },
166
- credentialRole: {
167
- $ref: "#/components/schemas/CredentialRole"
168
- },
169
- regulationType: {
170
- $ref: "#/components/schemas/RegulationType"
171
- },
172
- rawDocument: {
173
- type: "string"
174
- },
175
- uniformDocument: {
176
- type: "string"
177
- },
178
- credentialId: {
179
- type: "string"
180
- },
181
- hash: {
182
- type: "string"
183
- },
184
- kmsKeyRef: {
185
- type: "string"
186
- },
187
- identifierMethod: {
188
- type: "string"
189
- },
190
- issuerCorrelationType: {
191
- $ref: "#/components/schemas/CredentialCorrelationType"
192
- },
193
- subjectCorrelationType: {
194
- $ref: "#/components/schemas/CredentialCorrelationType"
195
- },
196
- rpCorrelationType: {
197
- $ref: "#/components/schemas/CredentialCorrelationType"
198
- },
199
- isIssuerSigned: {
200
- type: "boolean"
201
- },
202
- issuerCorrelationId: {
203
- type: "string"
204
- },
205
- subjectCorrelationId: {
206
- type: "string"
207
- },
208
- rpCorrelationId: {
209
- type: "string"
210
- },
211
- verifiedState: {
212
- $ref: "#/components/schemas/CredentialStateType"
213
- },
214
- tenantId: {
215
- type: "string"
216
- },
217
- createdAt: {
218
- type: "string",
219
- format: "date-time"
220
- },
221
- presentedAt: {
222
- type: "string",
223
- format: "date-time"
224
- },
225
- lastUpdatedAt: {
226
- type: "string",
227
- format: "date-time"
228
- },
229
- validUntil: {
230
- type: "string",
231
- format: "date-time"
232
- },
233
- validFrom: {
234
- type: "string",
235
- format: "date-time"
236
- },
237
- verifiedAt: {
238
- type: "string",
239
- format: "date-time"
240
- },
241
- revokedAt: {
242
- type: "string",
243
- format: "date-time"
244
- }
245
- },
246
- required: [
247
- "id",
248
- "documentType",
249
- "documentFormat",
250
- "credentialRole",
251
- "regulationType",
252
- "rawDocument",
253
- "uniformDocument",
254
- "hash",
255
- "issuerCorrelationType",
256
- "issuerCorrelationId",
257
- "createdAt",
258
- "lastUpdatedAt"
259
- ]
260
- },
261
- DocumentType: {
262
- type: "string",
263
- enum: [
264
- "VC",
265
- "VP",
266
- "P",
267
- "C"
268
- ]
269
- },
270
- CredentialDocumentFormat: {
271
- type: "string",
272
- enum: [
273
- "JSON_LD",
274
- "JWT",
275
- "SD_JWT",
276
- "MSO_MDOC"
277
- ]
278
- },
279
- CredentialRole: {
280
- type: "string",
281
- enum: [
282
- "ISSUER",
283
- "VERIFIER",
284
- "HOLDER",
285
- "FEDERATION_TRUST_ANCHOR"
286
- ]
287
- },
288
- RegulationType: {
289
- type: "string",
290
- enum: [
291
- "PID",
292
- "QEAA",
293
- "EAA",
294
- "NON_REGULATED"
295
- ]
296
- },
297
- CredentialCorrelationType: {
298
- type: "string",
299
- enum: [
300
- "DID",
301
- "X509_SAN",
302
- "KID",
303
- "URL"
304
- ]
305
- },
306
- CredentialStateType: {
307
- type: "string",
308
- enum: [
309
- "REVOKED",
310
- "VERIFIED",
311
- "EXPIRED"
312
- ]
313
- },
314
- DeleteCredentialArgs: {
315
- anyOf: [
316
- {
317
- type: "object",
318
- properties: {
319
- id: {
320
- type: "string"
321
- }
322
- },
323
- required: [
324
- "id"
325
- ]
326
- },
327
- {
328
- type: "object",
329
- properties: {
330
- hash: {
331
- type: "string"
332
- }
333
- },
334
- required: [
335
- "hash"
336
- ]
337
- }
338
- ]
339
- },
340
- DeleteCredentialsArgs: {
341
- $ref: "#/components/schemas/GetCredentialsArgs"
342
- },
343
- GetCredentialsArgs: {
344
- type: "object",
345
- properties: {
346
- filter: {
347
- $ref: "#/components/schemas/FindDigitalCredentialArgs"
348
- }
349
- },
350
- required: [
351
- "filter"
352
- ]
353
- },
354
- FindDigitalCredentialArgs: {
355
- type: "array",
356
- items: {
357
- type: "object",
358
- properties: {
359
- id: {
360
- type: "string"
361
- },
362
- parentId: {
363
- type: "string"
364
- },
365
- documentType: {
366
- $ref: "#/components/schemas/DocumentType"
367
- },
368
- documentFormat: {
369
- $ref: "#/components/schemas/CredentialDocumentFormat"
370
- },
371
- credentialRole: {
372
- $ref: "#/components/schemas/CredentialRole"
373
- },
374
- regulationType: {
375
- $ref: "#/components/schemas/RegulationType"
376
- },
377
- rawDocument: {
378
- type: "string"
379
- },
380
- uniformDocument: {
381
- type: "string"
382
- },
383
- credentialId: {
384
- type: "string"
385
- },
386
- hash: {
387
- type: "string"
388
- },
389
- kmsKeyRef: {
390
- type: "string"
391
- },
392
- identifierMethod: {
393
- type: "string"
394
- },
395
- issuerCorrelationType: {
396
- $ref: "#/components/schemas/CredentialCorrelationType"
397
- },
398
- subjectCorrelationType: {
399
- $ref: "#/components/schemas/CredentialCorrelationType"
400
- },
401
- rpCorrelationType: {
402
- $ref: "#/components/schemas/CredentialCorrelationType"
403
- },
404
- isIssuerSigned: {
405
- type: "boolean"
406
- },
407
- issuerCorrelationId: {
408
- type: "string"
409
- },
410
- subjectCorrelationId: {
411
- type: "string"
412
- },
413
- rpCorrelationId: {
414
- type: "string"
415
- },
416
- verifiedState: {
417
- $ref: "#/components/schemas/CredentialStateType"
418
- },
419
- tenantId: {
420
- type: "string"
421
- },
422
- createdAt: {
423
- type: "string",
424
- format: "date-time"
425
- },
426
- presentedAt: {
427
- type: "string",
428
- format: "date-time"
429
- },
430
- lastUpdatedAt: {
431
- type: "string",
432
- format: "date-time"
433
- },
434
- validUntil: {
435
- type: "string",
436
- format: "date-time"
437
- },
438
- validFrom: {
439
- type: "string",
440
- format: "date-time"
441
- },
442
- verifiedAt: {
443
- type: "string",
444
- format: "date-time"
445
- },
446
- revokedAt: {
447
- type: "string",
448
- format: "date-time"
449
- }
450
- }
451
- }
452
- },
453
- GetCredentialArgs: {
454
- type: "object",
455
- properties: {
456
- id: {
457
- type: "string"
458
- }
459
- },
460
- required: [
461
- "id"
462
- ]
463
- },
464
- GetCredentialsByClaimsArgs: {
465
- type: "object",
466
- properties: {
467
- filter: {
468
- $ref: "#/components/schemas/FindClaimsArgs"
469
- },
470
- credentialRole: {
471
- $ref: "#/components/schemas/CredentialRole"
472
- },
473
- tenantId: {
474
- type: "string"
475
- }
476
- },
477
- required: [
478
- "filter"
479
- ]
480
- },
481
- FindClaimsArgs: {
482
- $ref: "#/components/schemas/FindArgs-TClaimsColumns"
483
- },
484
- "FindArgs-TClaimsColumns": {
485
- type: "object",
486
- properties: {
487
- where: {
488
- type: "array",
489
- items: {
490
- $ref: "#/components/schemas/Where-TClaimsColumns"
491
- },
492
- description: "Imposes constraints on the values of the given columns. WHERE clauses are combined using AND."
493
- },
494
- order: {
495
- type: "array",
496
- items: {
497
- $ref: "#/components/schemas/Order-TClaimsColumns"
498
- },
499
- description: "Sorts the results according to the given array of column priorities."
500
- },
501
- skip: {
502
- type: "number",
503
- description: "Ignores the first number of entries in a {@link IDataStoreORM } query result."
504
- },
505
- take: {
506
- type: "number",
507
- description: "Returns at most this number of results from a {@link IDataStoreORM } query."
508
- }
509
- }
510
- },
511
- "Where-TClaimsColumns": {
512
- type: "object",
513
- properties: {
514
- column: {
515
- $ref: "#/components/schemas/TClaimsColumns"
516
- },
517
- value: {
518
- type: "array",
519
- items: {
520
- type: "string"
521
- }
522
- },
523
- not: {
524
- type: "boolean"
525
- },
526
- op: {
527
- type: "string",
528
- enum: [
529
- "LessThan",
530
- "LessThanOrEqual",
531
- "MoreThan",
532
- "MoreThanOrEqual",
533
- "Equal",
534
- "Like",
535
- "Between",
536
- "In",
537
- "Any",
538
- "IsNull"
539
- ]
540
- }
541
- },
542
- required: [
543
- "column"
544
- ],
545
- description: "Represents a WHERE predicate for a {@link FindArgs } query. In situations where multiple WHERE predicates are present, they are combined with AND."
546
- },
547
- TClaimsColumns: {
548
- type: "string",
549
- enum: [
550
- "context",
551
- "credentialType",
552
- "type",
553
- "value",
554
- "isObj",
555
- "id",
556
- "issuer",
557
- "subject",
558
- "expirationDate",
559
- "issuanceDate"
560
- ]
561
- },
562
- "Order-TClaimsColumns": {
563
- type: "object",
564
- properties: {
565
- column: {
566
- $ref: "#/components/schemas/TClaimsColumns"
567
- },
568
- direction: {
569
- type: "string",
570
- enum: [
571
- "ASC",
572
- "DESC"
573
- ]
574
- }
575
- },
576
- required: [
577
- "column",
578
- "direction"
579
- ],
580
- description: "Represents the sort order of results from a {@link FindArgs } query."
581
- },
582
- UniqueDigitalCredential: {
583
- type: "object",
584
- properties: {
585
- hash: {
586
- type: "string"
587
- },
588
- id: {
589
- type: "string"
590
- },
591
- digitalCredential: {
592
- $ref: "#/components/schemas/DigitalCredential"
593
- },
594
- originalVerifiableCredential: {
595
- $ref: "#/components/schemas/OriginalVerifiableCredential"
596
- },
597
- originalVerifiablePresentation: {
598
- $ref: "#/components/schemas/OriginalVerifiablePresentation"
599
- },
600
- originalCredential: {
601
- $ref: "#/components/schemas/ICredential"
602
- },
603
- originalPresentation: {
604
- $ref: "#/components/schemas/IPresentation"
605
- },
606
- uniformVerifiableCredential: {
607
- $ref: "#/components/schemas/IVerifiableCredential"
608
- },
609
- uniformVerifiablePresentation: {
610
- $ref: "#/components/schemas/IVerifiablePresentation"
611
- }
612
- },
613
- required: [
614
- "hash",
615
- "digitalCredential"
616
- ]
617
- },
618
- OriginalVerifiableCredential: {
619
- anyOf: [
620
- {
621
- $ref: "#/components/schemas/W3CVerifiableCredential"
622
- },
623
- {
624
- $ref: "#/components/schemas/JwtDecodedVerifiableCredential"
625
- },
626
- {
627
- $ref: "#/components/schemas/SdJwtDecodedVerifiableCredential"
628
- },
629
- {
630
- $ref: "#/components/schemas/MdocOid4vpIssuerSigned"
631
- },
632
- {
633
- $ref: "#/components/schemas/MdocDocument"
634
- }
635
- ]
636
- },
637
- W3CVerifiableCredential: {
638
- anyOf: [
639
- {
640
- $ref: "#/components/schemas/IVerifiableCredential"
641
- },
642
- {
643
- $ref: "#/components/schemas/CompactJWT"
644
- }
645
- ],
646
- description: "Represents a signed Verifiable Credential (includes proof), in either JSON, compact JWT or compact SD-JWT VC format. See {@link https://www.w3.org/TR/vc-data-model/#credentials | VC data model } See {@link https://www.w3.org/TR/vc-data-model/#proof-formats | proof formats }"
647
- },
648
- IVerifiableCredential: {
649
- type: "object",
650
- properties: {
651
- proof: {
652
- anyOf: [
653
- {
654
- $ref: "#/components/schemas/IProof"
655
- },
656
- {
657
- type: "array",
658
- items: {
659
- $ref: "#/components/schemas/IProof"
660
- }
661
- }
662
- ]
663
- },
664
- "@context": {
665
- anyOf: [
666
- {
667
- $ref: "#/components/schemas/ICredentialContextType"
668
- },
669
- {
670
- type: "array",
671
- items: {
672
- $ref: "#/components/schemas/ICredentialContextType"
673
- }
674
- }
675
- ]
676
- },
677
- type: {
678
- type: "array",
679
- items: {
680
- type: "string"
681
- }
682
- },
683
- credentialSchema: {
684
- anyOf: [
685
- {
686
- $ref: "#/components/schemas/ICredentialSchemaType"
687
- },
688
- {
689
- type: "array",
690
- items: {
691
- $ref: "#/components/schemas/ICredentialSchemaType"
692
- }
693
- }
694
- ]
695
- },
696
- issuer: {
697
- anyOf: [
698
- {
699
- $ref: "#/components/schemas/IIssuerId"
700
- },
701
- {
702
- $ref: "#/components/schemas/IIssuer"
703
- }
704
- ]
705
- },
706
- issuanceDate: {
707
- type: "string"
708
- },
709
- credentialSubject: {
710
- anyOf: [
711
- {
712
- type: "object",
713
- properties: {
714
- id: {
715
- type: "string"
716
- }
717
- }
718
- },
719
- {
720
- type: "array",
721
- items: {
722
- type: "object",
723
- properties: {
724
- id: {
725
- type: "string"
726
- }
727
- }
728
- }
729
- }
730
- ]
731
- },
732
- expirationDate: {
733
- type: "string"
734
- },
735
- id: {
736
- type: "string"
737
- },
738
- credentialStatus: {
739
- $ref: "#/components/schemas/ICredentialStatus"
740
- },
741
- description: {
742
- type: "string"
743
- },
744
- name: {
745
- type: "string"
746
- }
747
- },
748
- required: [
749
- "@context",
750
- "credentialSubject",
751
- "issuanceDate",
752
- "issuer",
753
- "proof",
754
- "type"
755
- ]
756
- },
757
- IProof: {
758
- type: "object",
759
- properties: {
760
- type: {
761
- anyOf: [
762
- {
763
- $ref: "#/components/schemas/IProofType"
764
- },
765
- {
766
- type: "string"
767
- }
768
- ]
769
- },
770
- created: {
771
- type: "string"
772
- },
773
- proofPurpose: {
774
- anyOf: [
775
- {
776
- $ref: "#/components/schemas/IProofPurpose"
777
- },
778
- {
779
- type: "string"
780
- }
781
- ]
782
- },
783
- verificationMethod: {
784
- type: "string"
785
- },
786
- challenge: {
787
- type: "string"
788
- },
789
- domain: {
790
- type: "string"
791
- },
792
- proofValue: {
793
- type: "string"
794
- },
795
- jws: {
796
- type: "string"
797
- },
798
- jwt: {
799
- type: "string"
800
- },
801
- mso_mdoc: {
802
- type: "string"
803
- },
804
- nonce: {
805
- type: "string"
806
- },
807
- requiredRevealStatements: {
808
- type: "array",
809
- items: {
810
- type: "string"
811
- }
812
- }
813
- },
814
- required: [
815
- "type",
816
- "created",
817
- "proofPurpose",
818
- "verificationMethod"
819
- ]
820
- },
821
- IProofType: {
822
- type: "string",
823
- enum: [
824
- "Ed25519Signature2018",
825
- "Ed25519Signature2020",
826
- "EcdsaSecp256k1Signature2019",
827
- "EcdsaSecp256k1RecoverySignature2020",
828
- "JsonWebSignature2020",
829
- "RsaSignature2018",
830
- "GpgSignature2020",
831
- "JcsEd25519Signature2020",
832
- "BbsBlsSignatureProof2020",
833
- "BbsBlsBoundSignatureProof2020",
834
- "JwtProof2020",
835
- "SdJwtProof2024",
836
- "MsoMdocProof2024"
837
- ]
838
- },
839
- IProofPurpose: {
840
- type: "string",
841
- enum: [
842
- "verificationMethod",
843
- "assertionMethod",
844
- "authentication",
845
- "keyAgreement",
846
- "contactAgreement",
847
- "capabilityInvocation",
848
- "capabilityDelegation"
849
- ]
850
- },
851
- ICredentialContextType: {
852
- anyOf: [
853
- {
854
- type: "object",
855
- properties: {
856
- name: {
857
- type: "string"
858
- },
859
- did: {
860
- type: "string"
861
- }
862
- }
863
- },
864
- {
865
- type: "string"
866
- }
867
- ]
868
- },
869
- ICredentialSchemaType: {
870
- anyOf: [
871
- {
872
- $ref: "#/components/schemas/ICredentialSchema"
873
- },
874
- {
875
- type: "string"
876
- }
877
- ]
878
- },
879
- ICredentialSchema: {
880
- type: "object",
881
- properties: {
882
- id: {
883
- type: "string"
884
- },
885
- type: {
886
- type: "string"
887
- }
888
- },
889
- required: [
890
- "id"
891
- ]
892
- },
893
- IIssuerId: {
894
- type: "string"
895
- },
896
- IIssuer: {
897
- type: "object",
898
- properties: {
899
- id: {
900
- type: "string"
901
- }
902
- },
903
- required: [
904
- "id"
905
- ]
906
- },
907
- ICredentialStatus: {
908
- type: "object",
909
- properties: {
910
- id: {
911
- type: "string"
912
- },
913
- type: {
914
- type: "string"
915
- }
916
- },
917
- required: [
918
- "id",
919
- "type"
920
- ]
921
- },
922
- CompactJWT: {
923
- type: "string",
924
- description: "Represents a Json Web Token in compact form."
925
- },
926
- JwtDecodedVerifiableCredential: {
927
- type: "object",
928
- properties: {
929
- vc: {
930
- $ref: "#/components/schemas/IVerifiableCredential"
931
- },
932
- exp: {
933
- type: "string"
934
- },
935
- iss: {
936
- type: "string"
937
- },
938
- nbf: {
939
- type: "string"
940
- },
941
- sub: {
942
- type: "string"
943
- },
944
- jti: {
945
- type: "string"
946
- }
947
- },
948
- required: [
949
- "vc",
950
- "exp",
951
- "iss",
952
- "nbf",
953
- "sub",
954
- "jti"
955
- ]
956
- },
957
- SdJwtDecodedVerifiableCredential: {
958
- type: "object",
959
- properties: {
960
- compactSdJwtVc: {
961
- type: "string",
962
- description: "The compact sd jwt is the sd-jwt encoded as string. It is a normal JWT, with the disclosures and kb-jwt appended separated by ~"
963
- },
964
- disclosures: {
965
- type: "array",
966
- items: {
967
- $ref: "#/components/schemas/SdJwtDisclosure"
968
- },
969
- description: "The disclosures included within the SD-JWT in both encoded and decoded format. The digests are also included, and allows the disclosures to be linked against the digests in the signed payload."
970
- },
971
- signedPayload: {
972
- type: "object",
973
- properties: {
974
- vct: {
975
- type: "string"
976
- },
977
- iss: {
978
- type: "string"
979
- },
980
- iat: {
981
- type: "number"
982
- },
983
- nbf: {
984
- type: "number"
985
- },
986
- exp: {
987
- type: "number"
988
- },
989
- cnf: {
990
- type: "object",
991
- properties: {
992
- jwk: {},
993
- kid: {
994
- type: "string"
995
- }
996
- }
997
- },
998
- status: {
999
- type: "object",
1000
- properties: {
1001
- idx: {
1002
- type: "number"
1003
- },
1004
- uri: {
1005
- type: "string"
1006
- }
1007
- },
1008
- required: [
1009
- "idx",
1010
- "uri"
1011
- ]
1012
- },
1013
- sub: {
1014
- type: "string"
1015
- },
1016
- _sd: {
1017
- type: "array",
1018
- items: {
1019
- type: "string"
1020
- }
1021
- },
1022
- _sd_alg: {
1023
- type: "string"
1024
- }
1025
- },
1026
- additionalProperties: {
1027
- anyOf: [
1028
- {
1029
- not: {}
1030
- },
1031
- {
1032
- not: {}
1033
- },
1034
- {
1035
- type: [
1036
- "string",
1037
- "number",
1038
- "boolean",
1039
- "object",
1040
- "array"
1041
- ]
1042
- }
1043
- ]
1044
- },
1045
- required: [
1046
- "iat",
1047
- "iss",
1048
- "vct"
1049
- ],
1050
- description: "The signed payload is the payload of the sd-jwt that is actually signed, and that includes the `_sd` and `...` digests."
1051
- },
1052
- decodedPayload: {
1053
- $ref: "#/components/schemas/SdJwtDecodedVerifiableCredentialPayload",
1054
- description: "The decoded payload is the payload when all `_sd` and `...` digests have been replaced by the actual values from the disclosures. This format could also be seen as the 'pretty` version of the SD JWT payload.\n\nThis is useful for displaying the contents of the SD JWT VC to the user, or for example for querying the contents of the SD JWT VC using a PEX presentation definition path."
1055
- },
1056
- kbJwt: {
1057
- type: "object",
1058
- properties: {
1059
- header: {
1060
- $ref: "#/components/schemas/SdJwtVcKbJwtHeader"
1061
- },
1062
- payload: {
1063
- $ref: "#/components/schemas/SdJwtVcKbJwtPayload"
1064
- },
1065
- compact: {
1066
- $ref: "#/components/schemas/CompactJWT"
1067
- }
1068
- },
1069
- required: [
1070
- "header",
1071
- "payload"
1072
- ],
1073
- description: "Key binding JWT"
1074
- }
1075
- },
1076
- required: [
1077
- "compactSdJwtVc",
1078
- "disclosures",
1079
- "signedPayload",
1080
- "decodedPayload"
1081
- ],
1082
- description: "The decoded SD JWT Verifiable Credential. This representation includes multiple representations of the same SD-JWT, and allows to fully process an SD-JWT, as well as create a presentation SD-JWT (minus the KB-JWT) by removing certain disclosures from the compact SD-JWT.\n\nThis representation is useful as it doesn't require a hasher implementation to match the different digests in the signed SD-JWT payload, with the different disclosures."
1083
- },
1084
- SdJwtDisclosure: {
1085
- type: "object",
1086
- properties: {
1087
- encoded: {
1088
- type: "string"
1089
- },
1090
- decoded: {
1091
- $ref: "#/components/schemas/SdJwtDecodedDisclosure"
1092
- },
1093
- digest: {
1094
- type: "string"
1095
- }
1096
- },
1097
- required: [
1098
- "encoded",
1099
- "decoded",
1100
- "digest"
1101
- ]
1102
- },
1103
- SdJwtDecodedDisclosure: {
1104
- anyOf: [
1105
- {
1106
- type: "array",
1107
- minItems: 3,
1108
- items: [
1109
- {
1110
- type: "string"
1111
- },
1112
- {
1113
- type: "string"
1114
- },
1115
- {
1116
- anyOf: [
1117
- {
1118
- type: "string"
1119
- },
1120
- {
1121
- type: "number"
1122
- },
1123
- {
1124
- type: "boolean"
1125
- },
1126
- {
1127
- type: "object",
1128
- additionalProperties: {
1129
- anyOf: [
1130
- {
1131
- $ref: "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-197-306-pes_sd-jwt-vc.d.ts-0-8006"
1132
- },
1133
- {
1134
- not: {}
1135
- }
1136
- ]
1137
- }
1138
- },
1139
- {
1140
- type: "array",
1141
- items: {
1142
- $ref: "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-197-306-pes_sd-jwt-vc.d.ts-0-8006"
1143
- }
1144
- }
1145
- ]
1146
- }
1147
- ],
1148
- maxItems: 3
1149
- },
1150
- {
1151
- type: "array",
1152
- minItems: 2,
1153
- items: [
1154
- {
1155
- type: "string"
1156
- },
1157
- {
1158
- anyOf: [
1159
- {
1160
- type: "string"
1161
- },
1162
- {
1163
- type: "number"
1164
- },
1165
- {
1166
- type: "boolean"
1167
- },
1168
- {
1169
- type: "object",
1170
- additionalProperties: {
1171
- anyOf: [
1172
- {
1173
- $ref: "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-197-306-pes_sd-jwt-vc.d.ts-0-8006"
1174
- },
1175
- {
1176
- not: {}
1177
- }
1178
- ]
1179
- }
1180
- },
1181
- {
1182
- type: "array",
1183
- items: {
1184
- $ref: "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-197-306-pes_sd-jwt-vc.d.ts-0-8006"
1185
- }
1186
- }
1187
- ]
1188
- }
1189
- ],
1190
- maxItems: 2
1191
- }
1192
- ]
1193
- },
1194
- "alias-pes_sd-jwt-vc.d.ts-197-306-pes_sd-jwt-vc.d.ts-0-8006": {
1195
- anyOf: [
1196
- {
1197
- type: "string"
1198
- },
1199
- {
1200
- type: "number"
1201
- },
1202
- {
1203
- type: "boolean"
1204
- },
1205
- {
1206
- type: "object",
1207
- additionalProperties: {
1208
- anyOf: [
1209
- {
1210
- $ref: "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-197-306-pes_sd-jwt-vc.d.ts-0-8006"
1211
- },
1212
- {
1213
- not: {}
1214
- }
1215
- ]
1216
- }
1217
- },
1218
- {
1219
- type: "array",
1220
- items: {
1221
- $ref: "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-197-306-pes_sd-jwt-vc.d.ts-0-8006"
1222
- }
1223
- }
1224
- ]
1225
- },
1226
- SdJwtDecodedVerifiableCredentialPayload: {
1227
- type: "object",
1228
- properties: {
1229
- vct: {
1230
- type: "string"
1231
- },
1232
- iss: {
1233
- type: "string"
1234
- },
1235
- iat: {
1236
- type: "number"
1237
- },
1238
- nbf: {
1239
- type: "number"
1240
- },
1241
- exp: {
1242
- type: "number"
1243
- },
1244
- cnf: {
1245
- type: "object",
1246
- properties: {
1247
- jwk: {},
1248
- kid: {
1249
- type: "string"
1250
- }
1251
- }
1252
- },
1253
- status: {
1254
- type: "object",
1255
- properties: {
1256
- idx: {
1257
- type: "number"
1258
- },
1259
- uri: {
1260
- type: "string"
1261
- }
1262
- },
1263
- required: [
1264
- "idx",
1265
- "uri"
1266
- ]
1267
- },
1268
- sub: {
1269
- type: "string"
1270
- }
1271
- },
1272
- required: [
1273
- "vct",
1274
- "iss",
1275
- "iat"
1276
- ],
1277
- additionalProperties: {
1278
- anyOf: [
1279
- {
1280
- type: "string"
1281
- },
1282
- {
1283
- type: "number"
1284
- },
1285
- {
1286
- type: "boolean"
1287
- },
1288
- {
1289
- type: "object",
1290
- additionalProperties: {
1291
- anyOf: [
1292
- {
1293
- $ref: "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-197-306-pes_sd-jwt-vc.d.ts-0-8006"
1294
- },
1295
- {
1296
- not: {}
1297
- }
1298
- ]
1299
- }
1300
- },
1301
- {
1302
- type: "array",
1303
- items: {
1304
- $ref: "#/components/schemas/alias-pes_sd-jwt-vc.d.ts-197-306-pes_sd-jwt-vc.d.ts-0-8006"
1305
- }
1306
- },
1307
- {
1308
- not: {}
1309
- }
1310
- ]
1311
- },
1312
- description: "Decoded 'pretty' SD JWT Verifiable Credential. This representation has all the `_sd` properties removed, and includes the disclosures directly within the payload."
1313
- },
1314
- SdJwtVcKbJwtHeader: {
1315
- type: "object",
1316
- properties: {
1317
- typ: {
1318
- type: "string",
1319
- const: "kb+jwt"
1320
- },
1321
- alg: {
1322
- type: "string"
1323
- }
1324
- },
1325
- required: [
1326
- "typ",
1327
- "alg"
1328
- ]
1329
- },
1330
- SdJwtVcKbJwtPayload: {
1331
- type: "object",
1332
- properties: {
1333
- iat: {
1334
- type: "number"
1335
- },
1336
- aud: {
1337
- type: "string"
1338
- },
1339
- nonce: {
1340
- type: "string"
1341
- },
1342
- sd_hash: {
1343
- type: "string"
1344
- }
1345
- },
1346
- required: [
1347
- "iat",
1348
- "aud",
1349
- "nonce",
1350
- "sd_hash"
1351
- ],
1352
- additionalProperties: {}
1353
- },
1354
- MdocOid4vpIssuerSigned: {
1355
- type: "string",
1356
- description: "Represents a selective disclosure JWT vc in compact form."
1357
- },
1358
- MdocDocument: {
1359
- $ref: "#/components/schemas/com.sphereon.mdoc.data.device.DocumentCbor"
1360
- },
1361
- "com.sphereon.mdoc.data.device.DocumentCbor": {
1362
- type: "object",
1363
- properties: {}
1364
- },
1365
- OriginalVerifiablePresentation: {
1366
- anyOf: [
1367
- {
1368
- $ref: "#/components/schemas/W3CVerifiablePresentation"
1369
- },
1370
- {
1371
- $ref: "#/components/schemas/JwtDecodedVerifiablePresentation"
1372
- },
1373
- {
1374
- $ref: "#/components/schemas/SdJwtDecodedVerifiableCredential"
1375
- },
1376
- {
1377
- $ref: "#/components/schemas/MdocOid4vpMdocVpToken"
1378
- },
1379
- {
1380
- $ref: "#/components/schemas/MdocDeviceResponse"
1381
- }
1382
- ]
1383
- },
1384
- W3CVerifiablePresentation: {
1385
- anyOf: [
1386
- {
1387
- $ref: "#/components/schemas/IVerifiablePresentation"
1388
- },
1389
- {
1390
- $ref: "#/components/schemas/CompactJWT"
1391
- }
1392
- ],
1393
- description: "Represents a signed Verifiable Presentation (includes proof), in either JSON or compact JWT format. See {@link https://www.w3.org/TR/vc-data-model/#presentations | VC data model } See {@link https://www.w3.org/TR/vc-data-model/#proof-formats | proof formats }"
1394
- },
1395
- IVerifiablePresentation: {
1396
- type: "object",
1397
- properties: {
1398
- proof: {
1399
- anyOf: [
1400
- {
1401
- $ref: "#/components/schemas/IProof"
1402
- },
1403
- {
1404
- type: "array",
1405
- items: {
1406
- $ref: "#/components/schemas/IProof"
1407
- }
1408
- }
1409
- ]
1410
- },
1411
- id: {
1412
- type: "string"
1413
- },
1414
- "@context": {
1415
- anyOf: [
1416
- {
1417
- $ref: "#/components/schemas/ICredentialContextType"
1418
- },
1419
- {
1420
- type: "array",
1421
- items: {
1422
- $ref: "#/components/schemas/ICredentialContextType"
1423
- }
1424
- }
1425
- ]
1426
- },
1427
- type: {
1428
- anyOf: [
1429
- {
1430
- type: "string"
1431
- },
1432
- {
1433
- type: "array",
1434
- items: {
1435
- type: "string"
1436
- }
1437
- }
1438
- ]
1439
- },
1440
- verifiableCredential: {
1441
- type: "array",
1442
- items: {
1443
- $ref: "#/components/schemas/W3CVerifiableCredential"
1444
- }
1445
- },
1446
- presentation_submission: {
1447
- $ref: "#/components/schemas/PresentationSubmission"
1448
- },
1449
- holder: {
1450
- type: "string"
1451
- },
1452
- verifier: {
1453
- type: "string"
1454
- }
1455
- },
1456
- required: [
1457
- "@context",
1458
- "proof"
1459
- ]
1460
- },
1461
- PresentationSubmission: {
1462
- type: "object",
1463
- properties: {
1464
- id: {
1465
- type: "string",
1466
- description: "A UUID or some other unique ID to identify this Presentation Submission"
1467
- },
1468
- definition_id: {
1469
- type: "string",
1470
- description: "A UUID or some other unique ID to identify this Presentation Definition"
1471
- },
1472
- descriptor_map: {
1473
- type: "array",
1474
- items: {
1475
- $ref: "#/components/schemas/Descriptor"
1476
- },
1477
- description: "List of descriptors of how the claims are being mapped to presentation definition"
1478
- }
1479
- },
1480
- required: [
1481
- "id",
1482
- "definition_id",
1483
- "descriptor_map"
1484
- ],
1485
- description: "It expresses how the inputs are presented as proofs to a Verifier."
1486
- },
1487
- Descriptor: {
1488
- type: "object",
1489
- properties: {
1490
- id: {
1491
- type: "string",
1492
- description: "ID to identify the descriptor from Presentation Definition Input Descriptor it coresponds to."
1493
- },
1494
- path: {
1495
- type: "string",
1496
- description: "The path where the verifiable credential is located in the presentation submission json"
1497
- },
1498
- path_nested: {
1499
- $ref: "#/components/schemas/Descriptor"
1500
- },
1501
- format: {
1502
- type: "string",
1503
- description: "The Proof or JWT algorith that the proof is in"
1504
- }
1505
- },
1506
- required: [
1507
- "id",
1508
- "path",
1509
- "format"
1510
- ],
1511
- description: "descriptor map laying out the structure of the presentation submission."
1512
- },
1513
- JwtDecodedVerifiablePresentation: {
1514
- type: "object",
1515
- properties: {
1516
- vp: {
1517
- $ref: "#/components/schemas/IVerifiablePresentation"
1518
- },
1519
- exp: {
1520
- type: "string"
1521
- },
1522
- iss: {
1523
- type: "string"
1524
- },
1525
- nbf: {
1526
- type: "string"
1527
- },
1528
- sub: {
1529
- type: "string"
1530
- },
1531
- jti: {
1532
- type: "string"
1533
- },
1534
- aud: {
1535
- type: "string"
1536
- },
1537
- iat: {
1538
- type: "string"
1539
- }
1540
- },
1541
- required: [
1542
- "vp",
1543
- "exp",
1544
- "iss",
1545
- "nbf",
1546
- "sub",
1547
- "jti",
1548
- "aud",
1549
- "iat"
1550
- ]
1551
- },
1552
- MdocOid4vpMdocVpToken: {
1553
- type: "string"
1554
- },
1555
- MdocDeviceResponse: {
1556
- $ref: "#/components/schemas/com.sphereon.mdoc.data.device.DeviceResponseCbor"
1557
- },
1558
- "com.sphereon.mdoc.data.device.DeviceResponseCbor": {
1559
- type: "object",
1560
- properties: {}
1561
- },
1562
- ICredential: {
1563
- type: "object",
1564
- properties: {
1565
- "@context": {
1566
- anyOf: [
1567
- {
1568
- $ref: "#/components/schemas/ICredentialContextType"
1569
- },
1570
- {
1571
- type: "array",
1572
- items: {
1573
- $ref: "#/components/schemas/ICredentialContextType"
1574
- }
1575
- }
1576
- ]
1577
- },
1578
- type: {
1579
- type: "array",
1580
- items: {
1581
- type: "string"
1582
- }
1583
- },
1584
- credentialSchema: {
1585
- anyOf: [
1586
- {
1587
- $ref: "#/components/schemas/ICredentialSchemaType"
1588
- },
1589
- {
1590
- type: "array",
1591
- items: {
1592
- $ref: "#/components/schemas/ICredentialSchemaType"
1593
- }
1594
- }
1595
- ]
1596
- },
1597
- issuer: {
1598
- anyOf: [
1599
- {
1600
- $ref: "#/components/schemas/IIssuerId"
1601
- },
1602
- {
1603
- $ref: "#/components/schemas/IIssuer"
1604
- }
1605
- ]
1606
- },
1607
- issuanceDate: {
1608
- type: "string"
1609
- },
1610
- credentialSubject: {
1611
- anyOf: [
1612
- {
1613
- type: "object",
1614
- properties: {
1615
- id: {
1616
- type: "string"
1617
- }
1618
- }
1619
- },
1620
- {
1621
- type: "array",
1622
- items: {
1623
- type: "object",
1624
- properties: {
1625
- id: {
1626
- type: "string"
1627
- }
1628
- }
1629
- }
1630
- }
1631
- ]
1632
- },
1633
- expirationDate: {
1634
- type: "string"
1635
- },
1636
- id: {
1637
- type: "string"
1638
- },
1639
- credentialStatus: {
1640
- $ref: "#/components/schemas/ICredentialStatus"
1641
- },
1642
- description: {
1643
- type: "string"
1644
- },
1645
- name: {
1646
- type: "string"
1647
- }
1648
- },
1649
- required: [
1650
- "@context",
1651
- "type",
1652
- "issuer",
1653
- "issuanceDate",
1654
- "credentialSubject"
1655
- ]
1656
- },
1657
- IPresentation: {
1658
- type: "object",
1659
- properties: {
1660
- id: {
1661
- type: "string"
1662
- },
1663
- "@context": {
1664
- anyOf: [
1665
- {
1666
- $ref: "#/components/schemas/ICredentialContextType"
1667
- },
1668
- {
1669
- type: "array",
1670
- items: {
1671
- $ref: "#/components/schemas/ICredentialContextType"
1672
- }
1673
- }
1674
- ]
1675
- },
1676
- type: {
1677
- anyOf: [
1678
- {
1679
- type: "string"
1680
- },
1681
- {
1682
- type: "array",
1683
- items: {
1684
- type: "string"
1685
- }
1686
- }
1687
- ]
1688
- },
1689
- verifiableCredential: {
1690
- type: "array",
1691
- items: {
1692
- $ref: "#/components/schemas/W3CVerifiableCredential"
1693
- }
1694
- },
1695
- presentation_submission: {
1696
- $ref: "#/components/schemas/PresentationSubmission"
1697
- },
1698
- holder: {
1699
- type: "string"
1700
- },
1701
- verifier: {
1702
- type: "string"
1703
- }
1704
- },
1705
- required: [
1706
- "@context"
1707
- ]
1708
- },
1709
- GetCredentialsByIdOrHashArgs: {
1710
- type: "object",
1711
- properties: {
1712
- credentialRole: {
1713
- $ref: "#/components/schemas/CredentialRole"
1714
- },
1715
- idOrHash: {
1716
- type: "string"
1717
- }
1718
- },
1719
- required: [
1720
- "credentialRole",
1721
- "idOrHash"
1722
- ]
1723
- },
1724
- OptionalUniqueDigitalCredential: {
1725
- anyOf: [
1726
- {
1727
- $ref: "#/components/schemas/UniqueDigitalCredential"
1728
- },
1729
- {
1730
- not: {}
1731
- }
1732
- ]
1733
- },
1734
- UpdateCredentialStateArgs: {
1735
- anyOf: [
1736
- {
1737
- type: "object",
1738
- properties: {
1739
- verifiedState: {
1740
- $ref: "#/components/schemas/CredentialStateType"
1741
- },
1742
- verifiedAt: {
1743
- type: "string",
1744
- format: "date-time"
1745
- },
1746
- revokedAt: {
1747
- type: "string",
1748
- format: "date-time"
1749
- },
1750
- id: {
1751
- type: "string"
1752
- }
1753
- },
1754
- required: [
1755
- "id",
1756
- "verifiedState"
1757
- ]
1758
- },
1759
- {
1760
- type: "object",
1761
- properties: {
1762
- verifiedState: {
1763
- $ref: "#/components/schemas/CredentialStateType"
1764
- },
1765
- verifiedAt: {
1766
- type: "string",
1767
- format: "date-time"
1768
- },
1769
- revokedAt: {
1770
- type: "string",
1771
- format: "date-time"
1772
- },
1773
- hash: {
1774
- type: "string"
1775
- }
1776
- },
1777
- required: [
1778
- "hash",
1779
- "verifiedState"
1780
- ]
1781
- }
1782
- ]
1783
- }
1784
- },
1785
- methods: {
1786
- crsAddCredential: {
1787
- description: "Add a new credential.",
1788
- arguments: {
1789
- $ref: "#/components/schemas/AddCredentialArgs"
1790
- },
1791
- returnType: {
1792
- $ref: "#/components/schemas/DigitalCredential"
1793
- }
1794
- },
1795
- crsDeleteCredential: {
1796
- description: "Delete a single credentials by primary key",
1797
- arguments: {
1798
- $ref: "#/components/schemas/DeleteCredentialArgs"
1799
- },
1800
- returnType: {
1801
- type: "boolean"
1802
- }
1803
- },
1804
- crsDeleteCredentials: {
1805
- description: "Delete multiple credentials records using filters",
1806
- arguments: {
1807
- $ref: "#/components/schemas/DeleteCredentialsArgs"
1808
- },
1809
- returnType: {
1810
- type: "number"
1811
- }
1812
- },
1813
- crsGetCredential: {
1814
- description: "Get a single credentials by primary key",
1815
- arguments: {
1816
- $ref: "#/components/schemas/GetCredentialArgs"
1817
- },
1818
- returnType: {
1819
- $ref: "#/components/schemas/DigitalCredential"
1820
- }
1821
- },
1822
- crsGetCredentials: {
1823
- description: "Find one or more credentials using filters",
1824
- arguments: {
1825
- $ref: "#/components/schemas/GetCredentialsArgs"
1826
- },
1827
- returnType: {
1828
- type: "array",
1829
- items: {
1830
- $ref: "#/components/schemas/DigitalCredential"
1831
- }
1832
- }
1833
- },
1834
- crsGetCredentialsByClaims: {
1835
- description: "Returns a list of UniqueDigitalCredentials that match the given filter based on the claims they contain.",
1836
- arguments: {
1837
- $ref: "#/components/schemas/GetCredentialsByClaimsArgs"
1838
- },
1839
- returnType: {
1840
- type: "array",
1841
- items: {
1842
- $ref: "#/components/schemas/UniqueDigitalCredential"
1843
- }
1844
- }
1845
- },
1846
- crsGetCredentialsByClaimsCount: {
1847
- description: "Returns a count of UniqueDigitalCredentials that match the given filter based on the claims they contain.",
1848
- arguments: {
1849
- $ref: "#/components/schemas/GetCredentialsByClaimsArgs"
1850
- },
1851
- returnType: {
1852
- type: "number"
1853
- }
1854
- },
1855
- crsGetUniqueCredentialByIdOrHash: {
1856
- description: "Find one credential by id or hash",
1857
- arguments: {
1858
- $ref: "#/components/schemas/GetCredentialsByIdOrHashArgs"
1859
- },
1860
- returnType: {
1861
- $ref: "#/components/schemas/OptionalUniqueDigitalCredential"
1862
- }
1863
- },
1864
- crsGetUniqueCredentials: {
1865
- description: "Find one or more credentials using filters",
1866
- arguments: {
1867
- $ref: "#/components/schemas/GetCredentialsArgs"
1868
- },
1869
- returnType: {
1870
- type: "array",
1871
- items: {
1872
- $ref: "#/components/schemas/UniqueDigitalCredential"
1873
- }
1874
- }
1875
- },
1876
- crsUpdateCredentialState: {
1877
- description: "Update credential the state of an existing credential.",
1878
- arguments: {
1879
- $ref: "#/components/schemas/UpdateCredentialStateArgs"
1880
- },
1881
- returnType: {
1882
- $ref: "#/components/schemas/DigitalCredential"
1883
- }
1884
- }
1885
- }
1886
- }
1887
- }
1888
- };
1889
- }
1890
- });
1891
-
1892
- // src/index.ts
1893
- import { Loggers } from "@sphereon/ssi-types";
1894
-
1895
- // src/agent/CredentialStore.ts
1896
- import { DocumentType as DocumentType2, parseRawDocument } from "@sphereon/ssi-sdk.data-store";
1897
- import { shaHasher as defaultHasher } from "@sphereon/ssi-sdk.core";
1898
-
1899
- // src/utils/filters.ts
1900
- import { DocumentType } from "@sphereon/ssi-sdk.data-store";
1901
- import { validate as uuidValidate } from "uuid";
1902
- var credentialIdOrHashFilter = /* @__PURE__ */ __name((credentialRole, idOrHash) => {
1903
- const filter = [
1904
- {
1905
- hash: idOrHash,
1906
- credentialRole
1907
- },
1908
- {
1909
- credentialId: idOrHash,
1910
- credentialRole
1911
- }
1912
- ];
1913
- if (uuidValidate(idOrHash)) {
1914
- filter.push({
1915
- id: idOrHash,
1916
- credentialRole
1917
- });
1918
- }
1919
- return filter;
1920
- }, "credentialIdOrHashFilter");
1921
- var verifiableCredentialForRoleFilter = /* @__PURE__ */ __name((credentialRole, withFilter) => {
1922
- const filter = [
1923
- {
1924
- documentType: DocumentType.VC,
1925
- credentialRole
1926
- }
1927
- ];
1928
- if (withFilter !== void 0) {
1929
- return mergeFilter(withFilter, filter);
1930
- }
1931
- return filter;
1932
- }, "verifiableCredentialForRoleFilter");
1933
- var mergeFilter = /* @__PURE__ */ __name((filter1, filter2) => {
1934
- const mergedFilter = [];
1935
- const mergedMap = /* @__PURE__ */ new Map();
1936
- filter1.forEach((obj, index) => {
1937
- mergedMap.set(index, {
1938
- ...obj
1939
- });
1940
- });
1941
- filter2.forEach((obj, index) => {
1942
- if (mergedMap.has(index)) {
1943
- mergedMap.set(index, {
1944
- ...mergedMap.get(index),
1945
- ...obj
1946
- });
1947
- } else {
1948
- mergedMap.set(index, {
1949
- ...obj
1950
- });
1951
- }
1952
- });
1953
- mergedMap.forEach((value) => {
1954
- mergedFilter.push(value);
1955
- });
1956
- return mergedFilter;
1957
- }, "mergeFilter");
1958
-
1959
- // src/agent/CredentialStore.ts
1960
- var credentialStoreMethods = [
1961
- "crsAddCredential",
1962
- "crsUpdateCredentialState",
1963
- "crsGetCredential",
1964
- "crsGetCredentials",
1965
- "crsDeleteCredential",
1966
- "crsDeleteCredentials",
1967
- "crsGetUniqueCredentials",
1968
- "crsGetUniqueCredentialByIdOrHash",
1969
- "crsGetCredentialsByClaims",
1970
- "crsGetCredentialsByClaimsCount"
1971
- ];
1972
- var CredentialStore = class {
1973
- static {
1974
- __name(this, "CredentialStore");
1975
- }
1976
- schema = schema.ICredentialStore;
1977
- methods = {
1978
- crsAddCredential: this.crsAddCredential.bind(this),
1979
- crsUpdateCredentialState: this.crsUpdateCredentialState.bind(this),
1980
- crsGetCredential: this.crsGetCredential.bind(this),
1981
- crsGetCredentials: this.crsGetCredentials.bind(this),
1982
- crsGetUniqueCredentialByIdOrHash: this.crsGetUniqueCredentialByIdOrHash.bind(this),
1983
- crsGetUniqueCredentials: this.crsGetUniqueCredentials.bind(this),
1984
- crsDeleteCredential: this.crsDeleteCredential.bind(this),
1985
- crsDeleteCredentials: this.crsDeleteCredentials.bind(this),
1986
- crsGetCredentialsByClaims: this.crsGetCredentialsByClaims.bind(this),
1987
- crsGetCredentialsByClaimsCount: this.crsGetCredentialsByClaimsCount.bind(this)
1988
- };
1989
- store;
1990
- constructor(options) {
1991
- this.store = options.store;
1992
- }
1993
- /** {@inheritDoc ICredentialStore.crsAddCredential} */
1994
- async crsAddCredential(args) {
1995
- return await this.store.addCredential({
1996
- ...args.credential,
1997
- opts: {
1998
- ...args.opts,
1999
- hasher: args.opts?.hasher ?? defaultHasher
2000
- }
2001
- });
2002
- }
2003
- /** {@inheritDoc ICredentialStore.crsUpdateCredentialState} */
2004
- async crsUpdateCredentialState(args) {
2005
- return await this.store.updateCredentialState(args);
2006
- }
2007
- /** {@inheritDoc ICredentialStore.crsGetCredential} */
2008
- async crsGetCredential(args) {
2009
- const { id } = args;
2010
- return this.store.getCredential({
2011
- id
2012
- });
2013
- }
2014
- /** {@inheritDoc ICredentialStore.crsGetCredentials} */
2015
- async crsGetCredentials(args) {
2016
- const { filter } = args;
2017
- const credentials = await this.store.getCredentials({
2018
- filter
2019
- });
2020
- return credentials.data;
2021
- }
2022
- /** {@inheritDoc ICredentialStore.crsGetUniqueCredentialByIdOrHash} */
2023
- async crsGetUniqueCredentialByIdOrHash(args) {
2024
- const credentials = await this.crsGetCredentials({
2025
- filter: credentialIdOrHashFilter(args.credentialRole, args.idOrHash)
2026
- });
2027
- if (credentials.length === 0) {
2028
- return void 0;
2029
- } else if (credentials.length > 1) {
2030
- logger.warning("Duplicate credentials detected in crsGetUniqueCredentialByIdOrHash", args);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
2031
7
  }
2032
- return this.toUniqueCredentials(credentials)[0];
2033
- }
2034
- /** {@inheritDoc ICredentialStore.crsGetUniqueCredentials} */
2035
- async crsGetUniqueCredentials(args) {
2036
- const credentials = await this.crsGetCredentials(args);
2037
- return this.toUniqueCredentials(credentials);
2038
- }
2039
- /** {@inheritDoc ICredentialStore.crsDeleteCredential} */
2040
- async crsDeleteCredential(args) {
2041
- return this.store.removeCredential(args);
2042
- }
2043
- /** {@inheritDoc ICredentialStore.crsDeleteCredentials} */
2044
- async crsDeleteCredentials(args) {
2045
- const credentials = await this.crsGetCredentials(args);
2046
- let count = 0;
2047
- for (const credential of credentials) {
2048
- const result = await this.store.removeCredential({
2049
- id: credential.id
2050
- });
2051
- if (result) {
2052
- count++;
2053
- }
2054
- }
2055
- return count;
2056
- }
2057
- /**
2058
- * Returns a list of UniqueDigitalCredentials that match the given filter based on the claims they contain.
2059
- * @param args
2060
- */
2061
- async crsGetCredentialsByClaims(args) {
2062
- const digitalCredentials = await this.crsGetUniqueCredentials({
2063
- filter: [
2064
- // TODO SDK-25 Implement param for documentType & support VP filtering below
2065
- {
2066
- documentType: DocumentType2.VC,
2067
- credentialRole: args.credentialRole,
2068
- tenantId: args.tenantId
2069
- },
2070
- {
2071
- documentType: DocumentType2.C,
2072
- credentialRole: args.credentialRole,
2073
- tenantId: args.tenantId
2074
- }
2075
- ]
2076
- });
2077
- return digitalCredentials.filter((uniqueVC) => {
2078
- if (!uniqueVC.uniformVerifiableCredential) {
2079
- return false;
2080
- }
2081
- const credential = uniqueVC.uniformVerifiableCredential;
2082
- return args.filter.where?.every((whereClause) => {
2083
- const value = this.getValueFromCredential(credential, whereClause.column);
2084
- if (value === void 0) {
2085
- return whereClause.op === "IsNull";
2086
- }
2087
- switch (whereClause.op) {
2088
- case "In":
2089
- return whereClause.value?.includes(value);
2090
- case "Like":
2091
- return typeof value === "string" && value.includes(whereClause.value?.[0] || "");
2092
- case "Between":
2093
- return value >= (whereClause.value?.[0] || "") && value <= (whereClause.value?.[1] || "");
2094
- case "LessThan":
2095
- return value < (whereClause.value?.[0] || "");
2096
- case "LessThanOrEqual":
2097
- return value <= (whereClause.value?.[0] || "");
2098
- case "MoreThan":
2099
- return value > (whereClause.value?.[0] || "");
2100
- case "MoreThanOrEqual":
2101
- return value >= (whereClause.value?.[0] || "");
2102
- case "Any":
2103
- return Array.isArray(value) && value.some((v) => whereClause.value?.includes(v));
2104
- case "IsNull":
2105
- return value === null || value === void 0;
2106
- case "Equal":
2107
- default:
2108
- return value === whereClause.value?.[0];
2109
- }
2110
- }) ?? true;
2111
- });
2112
- }
2113
- getValueFromCredential(credential, column) {
2114
- switch (column) {
2115
- case "context":
2116
- return credential["@context"];
2117
- case "credentialType":
2118
- return credential.type;
2119
- case "type":
2120
- return Array.isArray(credential.credentialSubject) ? credential.credentialSubject[0]?.type : credential.credentialSubject?.type;
2121
- case "value":
2122
- return JSON.stringify(credential.credentialSubject);
2123
- case "isObj":
2124
- return typeof credential.credentialSubject === "object";
2125
- case "id":
2126
- return credential.id;
2127
- case "issuer":
2128
- return typeof credential.issuer === "string" ? credential.issuer : credential.issuer.id;
2129
- case "subject":
2130
- return Array.isArray(credential.credentialSubject) ? credential.credentialSubject[0]?.id : credential.credentialSubject?.id;
2131
- case "expirationDate":
2132
- return credential.expirationDate;
2133
- case "issuanceDate":
2134
- return credential.issuanceDate;
2135
- default:
2136
- return void 0;
2137
- }
2138
- }
2139
- /**
2140
- * Returns a count of UniqueDigitalCredentials that match the given filter based on the claims they contain.
2141
- * @param args
2142
- */
2143
- async crsGetCredentialsByClaimsCount(args) {
2144
- const credentialsByClaims = await this.crsGetCredentialsByClaims(args);
2145
- return credentialsByClaims.length;
2146
- }
2147
- secureParse(original) {
2148
- return parseRawDocument(original);
2149
- }
2150
- toUniqueCredentials(credentials) {
2151
- return Object.values(credentials.reduce((accumulator, credential) => {
2152
- const uniqueCredential = {
2153
- hash: credential.hash,
2154
- digitalCredential: credential
2155
- };
2156
- switch (credential.documentType) {
2157
- case DocumentType2.VC:
2158
- uniqueCredential.originalVerifiableCredential = this.secureParse(credential.rawDocument);
2159
- uniqueCredential.uniformVerifiableCredential = this.secureParse(credential.uniformDocument);
2160
- uniqueCredential.id = uniqueCredential.uniformVerifiableCredential?.id;
2161
- break;
2162
- case DocumentType2.VP:
2163
- uniqueCredential.originalVerifiablePresentation = this.secureParse(credential.rawDocument);
2164
- uniqueCredential.uniformVerifiablePresentation = this.secureParse(credential.uniformDocument);
2165
- uniqueCredential.id = uniqueCredential.uniformVerifiablePresentation?.id;
2166
- break;
2167
- case DocumentType2.P:
2168
- uniqueCredential.originalPresentation = this.secureParse(credential.rawDocument);
2169
- uniqueCredential.id = uniqueCredential.originalPresentation?.id;
2170
- break;
2171
- case DocumentType2.C:
2172
- uniqueCredential.originalCredential = this.secureParse(credential.rawDocument);
2173
- uniqueCredential.id = uniqueCredential.originalCredential?.id;
2174
- break;
2175
- }
2176
- accumulator[credential.hash] = uniqueCredential;
2177
- return accumulator;
2178
- }, {}));
2179
- }
2180
- };
2181
-
2182
- // src/index.ts
2183
- import { CredentialRole, CredentialStateType, CredentialCorrelationType, CredentialDocumentFormat, DocumentType as DocumentType3, DigitalCredential, FindDigitalCredentialArgs } from "@sphereon/ssi-sdk.data-store";
2184
-
2185
- // src/types/ICredentialStore.ts
2186
- import { contextHasPlugin } from "@sphereon/ssi-sdk.agent-config";
2187
- function contextHasCredentialStore(context) {
2188
- return contextHasPlugin(context, "crsGetCredential");
2189
- }
2190
- __name(contextHasCredentialStore, "contextHasCredentialStore");
2191
-
2192
- // src/index.ts
2193
- var schema = require_plugin_schema();
2194
- var logger = Loggers.DEFAULT.get("sphereon:credential-store");
2195
- export {
2196
- CredentialCorrelationType,
2197
- CredentialDocumentFormat,
2198
- CredentialRole,
2199
- CredentialStateType,
2200
- CredentialStore,
2201
- DigitalCredential,
2202
- DocumentType3 as DocumentType,
2203
- FindDigitalCredentialArgs,
2204
- contextHasCredentialStore,
2205
- credentialIdOrHashFilter,
2206
- credentialStoreMethods,
2207
- logger,
2208
- mergeFilter,
2209
- schema,
2210
- verifiableCredentialForRoleFilter
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2211
15
  };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.DocumentType = exports.CredentialDocumentFormat = exports.CredentialCorrelationType = exports.CredentialStateType = exports.CredentialRole = exports.credentialStoreMethods = exports.CredentialStore = exports.logger = exports.schema = void 0;
18
+ const ssi_types_1 = require("@sphereon/ssi-types");
19
+ /**
20
+ * @public
21
+ */
22
+ const schema = require('../plugin.schema.json');
23
+ exports.schema = schema;
24
+ exports.logger = ssi_types_1.Loggers.DEFAULT.get('sphereon:credential-store');
25
+ var CredentialStore_1 = require("./agent/CredentialStore");
26
+ Object.defineProperty(exports, "CredentialStore", { enumerable: true, get: function () { return CredentialStore_1.CredentialStore; } });
27
+ Object.defineProperty(exports, "credentialStoreMethods", { enumerable: true, get: function () { return CredentialStore_1.credentialStoreMethods; } });
28
+ var ssi_sdk_data_store_1 = require("@sphereon/ssi-sdk.data-store");
29
+ Object.defineProperty(exports, "CredentialRole", { enumerable: true, get: function () { return ssi_sdk_data_store_1.CredentialRole; } });
30
+ Object.defineProperty(exports, "CredentialStateType", { enumerable: true, get: function () { return ssi_sdk_data_store_1.CredentialStateType; } });
31
+ Object.defineProperty(exports, "CredentialCorrelationType", { enumerable: true, get: function () { return ssi_sdk_data_store_1.CredentialCorrelationType; } });
32
+ Object.defineProperty(exports, "CredentialDocumentFormat", { enumerable: true, get: function () { return ssi_sdk_data_store_1.CredentialDocumentFormat; } });
33
+ Object.defineProperty(exports, "DocumentType", { enumerable: true, get: function () { return ssi_sdk_data_store_1.DocumentType; } });
34
+ __exportStar(require("./types/ICredentialStore"), exports);
35
+ __exportStar(require("./types/claims"), exports);
36
+ __exportStar(require("./utils/filters"), exports);
2212
37
  //# sourceMappingURL=index.js.map