@sphereon/ssi-sdk.contact-manager 0.33.1-next.3 → 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.
package/dist/index.cjs ADDED
@@ -0,0 +1,961 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+
24
+ // plugin.schema.json
25
+ var require_plugin_schema = __commonJS({
26
+ "plugin.schema.json"(exports, module2) {
27
+ module2.exports = {
28
+ IContactManager: {
29
+ components: {
30
+ schemas: {
31
+ IGetContactArgs: {
32
+ type: "object",
33
+ properties: {
34
+ contactId: {
35
+ type: "string"
36
+ }
37
+ },
38
+ required: ["contactId"]
39
+ },
40
+ IGetContactsArgs: {
41
+ type: "object",
42
+ properties: {
43
+ filter: {
44
+ type: "array",
45
+ items: {
46
+ type: "object"
47
+ }
48
+ }
49
+ }
50
+ },
51
+ IAddContactArgs: {
52
+ type: "object",
53
+ properties: {
54
+ contact: {
55
+ $ref: "#/components/schemas/IBasicContact"
56
+ }
57
+ },
58
+ required: ["party"]
59
+ },
60
+ IRemoveContactArgs: {
61
+ type: "object",
62
+ properties: {
63
+ contactId: {
64
+ type: "string"
65
+ }
66
+ },
67
+ required: ["contactId"]
68
+ },
69
+ IUpdateContactArgs: {
70
+ type: "object",
71
+ properties: {
72
+ contact: {
73
+ $ref: "#/components/schemas/IBasicContact"
74
+ }
75
+ },
76
+ required: ["party"]
77
+ },
78
+ IGetIdentityArgs: {
79
+ type: "object",
80
+ properties: {
81
+ identityId: {
82
+ type: "string"
83
+ }
84
+ },
85
+ required: ["identityId"]
86
+ },
87
+ IGetIdentitiesArgs: {
88
+ type: "object",
89
+ properties: {
90
+ contactId: {
91
+ type: "string"
92
+ }
93
+ },
94
+ required: ["contactId"]
95
+ },
96
+ IAddIdentityArgs: {
97
+ type: "object",
98
+ properties: {
99
+ identity: {
100
+ $ref: "#/components/schemas/IIdentity"
101
+ }
102
+ },
103
+ required: ["identity"]
104
+ },
105
+ IRemoveIdentityArgs: {
106
+ type: "object",
107
+ properties: {
108
+ identityId: {
109
+ type: "string"
110
+ }
111
+ },
112
+ required: ["identityId"]
113
+ },
114
+ IUpdateIdentityArgs: {
115
+ type: "object",
116
+ properties: {
117
+ identity: {
118
+ $ref: "#/components/schemas/IIdentity"
119
+ }
120
+ },
121
+ required: ["identity"]
122
+ },
123
+ IBasicContact: {
124
+ type: "object",
125
+ properties: {
126
+ name: {
127
+ type: "string"
128
+ },
129
+ alias: {
130
+ type: "string"
131
+ },
132
+ uri: {
133
+ type: "string"
134
+ },
135
+ identities: {
136
+ type: "array",
137
+ items: {
138
+ $ref: "#/components/schemas/IBasicIdentity"
139
+ }
140
+ }
141
+ },
142
+ required: ["name", "alias"]
143
+ },
144
+ IContact: {
145
+ type: "object",
146
+ properties: {
147
+ id: {
148
+ type: "string"
149
+ },
150
+ name: {
151
+ type: "string"
152
+ },
153
+ alias: {
154
+ type: "string"
155
+ },
156
+ uri: {
157
+ type: "string"
158
+ },
159
+ identities: {
160
+ type: "array",
161
+ items: {
162
+ $ref: "#/components/schemas/IIdentity"
163
+ }
164
+ },
165
+ createdAt: {
166
+ type: "string",
167
+ format: "date-time"
168
+ },
169
+ lastUpdatedAt: {
170
+ type: "string",
171
+ format: "date-time"
172
+ }
173
+ },
174
+ required: ["id", "name", "alias", "createdAt", "lastUpdatedAt"]
175
+ },
176
+ IMetadataItem: {
177
+ type: "object",
178
+ properties: {
179
+ id: {
180
+ type: "string"
181
+ },
182
+ label: {
183
+ type: "string"
184
+ },
185
+ value: {
186
+ type: "string"
187
+ }
188
+ },
189
+ required: ["id", "label", "value"]
190
+ },
191
+ BasicMetadataItem: {
192
+ type: "object",
193
+ properties: {
194
+ label: {
195
+ type: "string"
196
+ },
197
+ value: {
198
+ type: "string"
199
+ }
200
+ },
201
+ required: ["label", "value"]
202
+ },
203
+ IBasicIdentity: {
204
+ type: "object",
205
+ properties: {
206
+ alias: {
207
+ type: "string"
208
+ },
209
+ identifier: {
210
+ $ref: "#/components/schemas/BasicCorrelationIdentifier"
211
+ },
212
+ connection: {
213
+ $ref: "#/components/schemas/IBasicConnection"
214
+ },
215
+ metadata: {
216
+ type: "array",
217
+ items: {
218
+ $ref: "#/components/schemas/IMetadataItem"
219
+ }
220
+ },
221
+ createdAt: {
222
+ type: "string",
223
+ format: "date-time"
224
+ },
225
+ lastUpdatedAt: {
226
+ type: "string",
227
+ format: "date-time"
228
+ }
229
+ },
230
+ required: ["id", "alias", "identifier", "createdAt", "lastUpdatedAt"]
231
+ },
232
+ IIdentity: {
233
+ type: "object",
234
+ properties: {
235
+ id: {
236
+ type: "string"
237
+ },
238
+ alias: {
239
+ type: "string"
240
+ },
241
+ identifier: {
242
+ $ref: "#/components/schemas/ICorrelationIdentifier"
243
+ },
244
+ connection: {
245
+ $ref: "#/components/schemas/IConnection"
246
+ },
247
+ metadata: {
248
+ type: "array",
249
+ items: {
250
+ $ref: "#/components/schemas/IMetadataItem"
251
+ }
252
+ },
253
+ createdAt: {
254
+ type: "string",
255
+ format: "date-time"
256
+ },
257
+ lastUpdatedAt: {
258
+ type: "string",
259
+ format: "date-time"
260
+ }
261
+ },
262
+ required: ["id", "alias", "identifier", "createdAt", "lastUpdatedAt"]
263
+ },
264
+ CorrelationIdentifierEnum: {
265
+ type: "string",
266
+ enum: ["did", "url"]
267
+ },
268
+ BasicCorrelationIdentifier: {
269
+ type: "object",
270
+ properties: {
271
+ type: {
272
+ $ref: "#/components/schemas/CorrelationIdentifierEnum"
273
+ },
274
+ correlationId: {
275
+ type: "string"
276
+ }
277
+ },
278
+ required: ["type", "correlationId"]
279
+ },
280
+ ICorrelationIdentifier: {
281
+ type: "object",
282
+ properties: {
283
+ id: {
284
+ type: "string"
285
+ },
286
+ type: {
287
+ $ref: "#/components/schemas/CorrelationIdentifierEnum"
288
+ },
289
+ correlationId: {
290
+ type: "string"
291
+ }
292
+ },
293
+ required: ["id", "type", "correlationId"]
294
+ },
295
+ ConnectionTypeEnum: {
296
+ type: "string",
297
+ enum: ["openid", "didauth", "siopv2+oidc4vp"]
298
+ },
299
+ IBasicConnection: {
300
+ type: "object",
301
+ properties: {
302
+ type: {
303
+ $ref: "#/components/schemas/ConnectionTypeEnum"
304
+ },
305
+ config: {
306
+ $ref: "#/components/schemas/BasicConnectionConfig"
307
+ }
308
+ },
309
+ required: ["type", "config"]
310
+ },
311
+ IConnection: {
312
+ type: "object",
313
+ properties: {
314
+ id: {
315
+ type: "string"
316
+ },
317
+ type: {
318
+ $ref: "#/components/schemas/ConnectionTypeEnum"
319
+ },
320
+ config: {
321
+ $ref: "#/components/schemas/ConnectionConfig"
322
+ }
323
+ },
324
+ required: ["id", "type", "config"]
325
+ },
326
+ BasicConnectionConfig: {
327
+ anyOf: [
328
+ {
329
+ $ref: "#/components/schemas/BasicDidAuthConfig"
330
+ },
331
+ {
332
+ $ref: "#/components/schemas/BasicOpenIdConfig"
333
+ }
334
+ ]
335
+ },
336
+ ConnectionConfig: {
337
+ anyOf: [
338
+ {
339
+ $ref: "#/components/schemas/IOpenIdConfig"
340
+ },
341
+ {
342
+ $ref: "#/components/schemas/IDidAuthConfig"
343
+ }
344
+ ]
345
+ },
346
+ BasicDidAuthConfig: {
347
+ type: "object",
348
+ properties: {
349
+ identifier: {
350
+ $ref: "#/components/schemas/IIdentifier"
351
+ },
352
+ stateId: {
353
+ type: "string"
354
+ },
355
+ redirectUrl: {
356
+ type: "string"
357
+ },
358
+ sessionId: {
359
+ type: "string"
360
+ }
361
+ },
362
+ required: ["identifier", "stateId", "redirectUrl", "sessionId"]
363
+ },
364
+ BasicOpenIdConfig: {
365
+ type: "object",
366
+ properties: {
367
+ clientId: {
368
+ type: "string"
369
+ },
370
+ clientSecret: {
371
+ type: "string"
372
+ },
373
+ scopes: {
374
+ type: "array",
375
+ items: {
376
+ type: "string"
377
+ }
378
+ },
379
+ issuer: {
380
+ type: "string"
381
+ },
382
+ redirectUrl: {
383
+ type: "string"
384
+ },
385
+ dangerouslyAllowInsecureHttpRequests: {
386
+ type: "boolean"
387
+ },
388
+ clientAuthMethod: {
389
+ type: "string",
390
+ enum: ["basic", "post"]
391
+ }
392
+ },
393
+ required: ["clientId", "clientSecret", "scopes", "issuer", "redirectUrl", "dangerouslyAllowInsecureHttpRequests"]
394
+ },
395
+ IOpenIdConfig: {
396
+ type: "object",
397
+ properties: {
398
+ id: {
399
+ type: "string"
400
+ },
401
+ clientId: {
402
+ type: "string"
403
+ },
404
+ clientSecret: {
405
+ type: "string"
406
+ },
407
+ scopes: {
408
+ type: "array",
409
+ items: {
410
+ type: "string"
411
+ }
412
+ },
413
+ issuer: {
414
+ type: "string"
415
+ },
416
+ redirectUrl: {
417
+ type: "string"
418
+ },
419
+ dangerouslyAllowInsecureHttpRequests: {
420
+ type: "boolean"
421
+ },
422
+ clientAuthMethod: {
423
+ type: "string",
424
+ enum: ["basic", "post"]
425
+ }
426
+ },
427
+ required: ["id", "clientId", "clientSecret", "scopes", "issuer", "redirectUrl", "dangerouslyAllowInsecureHttpRequests"]
428
+ },
429
+ IDidAuthConfig: {
430
+ type: "object",
431
+ properties: {
432
+ id: {
433
+ type: "string"
434
+ },
435
+ identifier: {
436
+ $ref: "#/components/schemas/IIdentifier"
437
+ },
438
+ stateId: {
439
+ type: "string"
440
+ },
441
+ redirectUrl: {
442
+ type: "string"
443
+ },
444
+ sessionId: {
445
+ type: "string"
446
+ }
447
+ },
448
+ required: ["id", "identifier", "stateId", "redirectUrl", "sessionId"]
449
+ },
450
+ IIdentifier: {
451
+ type: "object",
452
+ properties: {
453
+ did: {
454
+ type: "string",
455
+ description: "Decentralized identifier"
456
+ },
457
+ alias: {
458
+ type: "string",
459
+ description: "Optional. Identifier alias. Can be used to reference an object in an external system"
460
+ },
461
+ provider: {
462
+ type: "string",
463
+ description: "Identifier provider name"
464
+ },
465
+ controllerKeyId: {
466
+ type: "string",
467
+ description: "Controller key id"
468
+ },
469
+ keys: {
470
+ type: "array",
471
+ items: {
472
+ $ref: "#/components/schemas/IKey"
473
+ },
474
+ description: "Array of managed keys"
475
+ },
476
+ services: {
477
+ type: "array",
478
+ items: {
479
+ $ref: "#/components/schemas/IService"
480
+ },
481
+ description: "Array of services"
482
+ }
483
+ },
484
+ required: ["did", "provider", "keys", "services"],
485
+ description: "Identifier interface"
486
+ },
487
+ IKey: {
488
+ type: "object",
489
+ properties: {
490
+ kid: {
491
+ type: "string",
492
+ description: "Key ID"
493
+ },
494
+ kms: {
495
+ type: "string",
496
+ description: "Key Management System"
497
+ },
498
+ type: {
499
+ $ref: "#/components/schemas/TKeyType",
500
+ description: "Key type"
501
+ },
502
+ publicKeyHex: {
503
+ type: "string",
504
+ description: "Public key"
505
+ },
506
+ privateKeyHex: {
507
+ type: "string",
508
+ description: "Optional. Private key"
509
+ },
510
+ meta: {
511
+ anyOf: [
512
+ {
513
+ $ref: "#/components/schemas/KeyMetadata"
514
+ },
515
+ {
516
+ type: "null"
517
+ }
518
+ ],
519
+ description: "Optional. Key metadata. This should be used to determine which algorithms are supported."
520
+ }
521
+ },
522
+ required: ["kid", "kms", "type", "publicKeyHex"],
523
+ description: "Cryptographic key"
524
+ },
525
+ TKeyType: {
526
+ type: "string",
527
+ enum: ["Ed25519", "Secp256k1", "Secp256r1", "X25519", "Bls12381G1", "Bls12381G2", "RSA"],
528
+ description: "Cryptographic key type."
529
+ },
530
+ KeyMetadata: {
531
+ type: "object",
532
+ properties: {
533
+ algorithms: {
534
+ type: "array",
535
+ items: {
536
+ type: "string"
537
+ }
538
+ }
539
+ },
540
+ description: "This encapsulates data about a key.\n\nImplementations of {@link @veramo/key-manager#AbstractKeyManagementSystem | AbstractKeyManagementSystem } should populate this object, for each key, with the algorithms that can be performed using it.\n\nThis can also be used to add various tags to the keys under management."
541
+ },
542
+ IService: {
543
+ type: "object",
544
+ properties: {
545
+ id: {
546
+ type: "string",
547
+ description: "ID"
548
+ },
549
+ type: {
550
+ type: "string",
551
+ description: "Service type"
552
+ },
553
+ serviceEndpoint: {
554
+ anyOf: [
555
+ {
556
+ $ref: "#/components/schemas/IServiceEndpoint"
557
+ },
558
+ {
559
+ type: "array",
560
+ items: {
561
+ $ref: "#/components/schemas/IServiceEndpoint"
562
+ }
563
+ }
564
+ ],
565
+ description: "Endpoint URL"
566
+ },
567
+ description: {
568
+ type: "string",
569
+ description: "Optional. Description"
570
+ }
571
+ },
572
+ required: ["id", "type", "serviceEndpoint"],
573
+ description: "Identifier service"
574
+ },
575
+ IServiceEndpoint: {
576
+ anyOf: [
577
+ {
578
+ type: "string"
579
+ },
580
+ {
581
+ type: "object"
582
+ }
583
+ ],
584
+ description: "Represents a service endpoint URL or a map of URLs"
585
+ }
586
+ },
587
+ methods: {
588
+ cmGetContact: {
589
+ description: "",
590
+ arguments: {
591
+ $ref: "#/components/schemas/IGetContactArgs"
592
+ },
593
+ returnType: {
594
+ $ref: "#/components/schemas/IContact"
595
+ }
596
+ },
597
+ cmGetContacts: {
598
+ description: "",
599
+ arguments: {
600
+ $ref: "#/components/schemas/IGetContactsArgs"
601
+ },
602
+ returnType: {
603
+ type: "array",
604
+ items: {
605
+ $ref: "#/components/schemas/IContact"
606
+ }
607
+ }
608
+ },
609
+ cmAddContact: {
610
+ description: "",
611
+ arguments: {
612
+ $ref: "#/components/schemas/IAddContactArgs"
613
+ },
614
+ returnType: {
615
+ $ref: "#/components/schemas/IContact"
616
+ }
617
+ },
618
+ cmRemoveContact: {
619
+ description: "",
620
+ arguments: {
621
+ $ref: "#/components/schemas/IRemoveContactArgs"
622
+ },
623
+ returnType: {
624
+ type: "boolean"
625
+ }
626
+ },
627
+ cmUpdateContact: {
628
+ description: "",
629
+ arguments: {
630
+ $ref: "#/components/schemas/IUpdateContactArgs"
631
+ },
632
+ returnType: {
633
+ $ref: "#/components/schemas/IContact"
634
+ }
635
+ },
636
+ cmGetIdentity: {
637
+ description: "",
638
+ arguments: {
639
+ $ref: "#/components/schemas/IGetIdentityArgs"
640
+ },
641
+ returnType: {
642
+ $ref: "#/components/schemas/IIdentity"
643
+ }
644
+ },
645
+ cmGetIdentities: {
646
+ description: "",
647
+ arguments: {
648
+ $ref: "#/components/schemas/IGetIdentitiesArgs"
649
+ },
650
+ returnType: {
651
+ type: "array",
652
+ items: {
653
+ $ref: "#/components/schemas/IIdentity"
654
+ }
655
+ }
656
+ },
657
+ cmAddIdentity: {
658
+ description: "",
659
+ arguments: {
660
+ $ref: "#/components/schemas/IAddIdentityArgs"
661
+ },
662
+ returnType: {
663
+ $ref: "#/components/schemas/IIdentity"
664
+ }
665
+ },
666
+ cmRemoveIdentity: {
667
+ description: "",
668
+ arguments: {
669
+ $ref: "#/components/schemas/IRemoveIdentityArgs"
670
+ },
671
+ returnType: {
672
+ type: "boolean"
673
+ }
674
+ },
675
+ cmUpdateIdentity: {
676
+ description: "",
677
+ arguments: {
678
+ $ref: "#/components/schemas/IUpdateConnectionArgs"
679
+ },
680
+ returnType: {
681
+ $ref: "#/components/schemas/IIdentity"
682
+ }
683
+ }
684
+ }
685
+ }
686
+ }
687
+ };
688
+ }
689
+ });
690
+
691
+ // src/index.ts
692
+ var index_exports = {};
693
+ __export(index_exports, {
694
+ ContactManager: () => ContactManager,
695
+ contactManagerMethods: () => contactManagerMethods,
696
+ contextHasContactManager: () => contextHasContactManager,
697
+ schema: () => schema
698
+ });
699
+ module.exports = __toCommonJS(index_exports);
700
+
701
+ // src/agent/ContactManager.ts
702
+ var import_ssi_sdk = require("@sphereon/ssi-sdk.data-store");
703
+ var contactManagerMethods = [
704
+ "cmGetContact",
705
+ "cmGetContacts",
706
+ "cmAddContact",
707
+ "cmUpdateContact",
708
+ "cmRemoveContact",
709
+ "cmGetIdentity",
710
+ "cmGetIdentities",
711
+ "cmAddIdentity",
712
+ "cmUpdateIdentity",
713
+ "cmRemoveIdentity",
714
+ "cmAddRelationship",
715
+ "cmRemoveRelationship",
716
+ "cmGetRelationship",
717
+ "cmGetRelationships",
718
+ "cmUpdateRelationship",
719
+ "cmGetContactType",
720
+ "cmGetContactTypes",
721
+ "cmAddContactType",
722
+ "cmUpdateContactType",
723
+ "cmRemoveContactType",
724
+ "cmGetElectronicAddress",
725
+ "cmGetElectronicAddresses",
726
+ "cmAddElectronicAddress",
727
+ "cmUpdateElectronicAddress",
728
+ "cmRemoveElectronicAddress",
729
+ "cmGetPhysicalAddress",
730
+ "cmGetPhysicalAddresses",
731
+ "cmAddPhysicalAddress",
732
+ "cmUpdatePhysicalAddress",
733
+ "cmRemovePhysicalAddress"
734
+ ];
735
+ var ContactManager = class {
736
+ static {
737
+ __name(this, "ContactManager");
738
+ }
739
+ schema = schema.IContactManager;
740
+ methods = {
741
+ cmGetContact: this.cmGetContact.bind(this),
742
+ cmGetContacts: this.cmGetContacts.bind(this),
743
+ cmAddContact: this.cmAddContact.bind(this),
744
+ cmUpdateContact: this.cmUpdateContact.bind(this),
745
+ cmRemoveContact: this.cmRemoveContact.bind(this),
746
+ cmGetIdentity: this.cmGetIdentity.bind(this),
747
+ cmGetIdentities: this.cmGetIdentities.bind(this),
748
+ cmAddIdentity: this.cmAddIdentity.bind(this),
749
+ cmUpdateIdentity: this.cmUpdateIdentity.bind(this),
750
+ cmRemoveIdentity: this.cmRemoveIdentity.bind(this),
751
+ cmAddRelationship: this.cmAddRelationship.bind(this),
752
+ cmRemoveRelationship: this.cmRemoveRelationship.bind(this),
753
+ cmGetRelationship: this.cmGetRelationship.bind(this),
754
+ cmGetRelationships: this.cmGetRelationships.bind(this),
755
+ cmUpdateRelationship: this.cmUpdateRelationship.bind(this),
756
+ cmGetContactType: this.cmGetContactType.bind(this),
757
+ cmGetContactTypes: this.cmGetContactTypes.bind(this),
758
+ cmAddContactType: this.cmAddContactType.bind(this),
759
+ cmUpdateContactType: this.cmUpdateContactType.bind(this),
760
+ cmRemoveContactType: this.cmRemoveContactType.bind(this),
761
+ cmGetElectronicAddress: this.cmGetElectronicAddress.bind(this),
762
+ cmGetElectronicAddresses: this.cmGetElectronicAddresses.bind(this),
763
+ cmAddElectronicAddress: this.cmAddElectronicAddress.bind(this),
764
+ cmUpdateElectronicAddress: this.cmUpdateElectronicAddress.bind(this),
765
+ cmRemoveElectronicAddress: this.cmRemoveElectronicAddress.bind(this),
766
+ cmGetPhysicalAddress: this.cmGetPhysicalAddress.bind(this),
767
+ cmGetPhysicalAddresses: this.cmGetPhysicalAddresses.bind(this),
768
+ cmAddPhysicalAddress: this.cmAddPhysicalAddress.bind(this),
769
+ cmUpdatePhysicalAddress: this.cmUpdatePhysicalAddress.bind(this),
770
+ cmRemovePhysicalAddress: this.cmRemovePhysicalAddress.bind(this)
771
+ };
772
+ store;
773
+ constructor(options) {
774
+ this.store = options.store;
775
+ }
776
+ /** {@inheritDoc IContactManager.cmGetContact} */
777
+ async cmGetContact(args, context) {
778
+ const { contactId } = args;
779
+ return this.store.getParty({
780
+ partyId: contactId
781
+ });
782
+ }
783
+ /** {@inheritDoc IContactManager.cmGetContacts} */
784
+ async cmGetContacts(args) {
785
+ return this.store.getParties(args);
786
+ }
787
+ /** {@inheritDoc IContactManager.cmAddContact} */
788
+ async cmAddContact(args, context) {
789
+ const { uri, contactType, identities, electronicAddresses, physicalAddresses } = args;
790
+ return this.store.addParty({
791
+ uri,
792
+ partyType: contactType,
793
+ contact: this.getContactInformationFrom(args),
794
+ identities,
795
+ electronicAddresses,
796
+ physicalAddresses
797
+ });
798
+ }
799
+ /** {@inheritDoc IContactManager.cmUpdateContact} */
800
+ async cmUpdateContact(args, context) {
801
+ const { contact } = args;
802
+ return this.store.updateParty({
803
+ party: contact
804
+ });
805
+ }
806
+ /** {@inheritDoc IContactManager.cmRemoveContact} */
807
+ async cmRemoveContact(args, context) {
808
+ const { contactId } = args;
809
+ return this.store.removeParty({
810
+ partyId: contactId
811
+ }).then(() => true);
812
+ }
813
+ /** {@inheritDoc IContactManager.cmGetIdentity} */
814
+ async cmGetIdentity(args, context) {
815
+ return this.store.getIdentity(args);
816
+ }
817
+ /** {@inheritDoc IContactManager.cmGetIdentities} */
818
+ async cmGetIdentities(args) {
819
+ return this.store.getIdentities(args);
820
+ }
821
+ /** {@inheritDoc IContactManager.cmAddIdentity} */
822
+ async cmAddIdentity(args, context) {
823
+ const { contactId, identity } = args;
824
+ return this.store.addIdentity({
825
+ partyId: contactId,
826
+ identity
827
+ });
828
+ }
829
+ /** {@inheritDoc IContactManager.cmUpdateIdentity} */
830
+ async cmUpdateIdentity(args, context) {
831
+ return this.store.updateIdentity(args);
832
+ }
833
+ /** {@inheritDoc IContactManager.cmRemoveIdentity} */
834
+ async cmRemoveIdentity(args, context) {
835
+ return this.store.removeIdentity(args).then(() => true);
836
+ }
837
+ /** {@inheritDoc IContactManager.cmAddRelationship} */
838
+ async cmAddRelationship(args, context) {
839
+ return this.store.addRelationship(args);
840
+ }
841
+ /** {@inheritDoc IContactManager.cmRemoveRelationship} */
842
+ async cmRemoveRelationship(args, context) {
843
+ return this.store.removeRelationship(args).then(() => true);
844
+ }
845
+ /** {@inheritDoc IContactManager.cmGetRelationship} */
846
+ async cmGetRelationship(args, context) {
847
+ return this.store.getRelationship(args);
848
+ }
849
+ /** {@inheritDoc IContactManager.cmGetRelationships} */
850
+ async cmGetRelationships(args) {
851
+ return this.store.getRelationships(args);
852
+ }
853
+ /** {@inheritDoc IContactManager.cmUpdateRelationship} */
854
+ async cmUpdateRelationship(args, context) {
855
+ return this.store.updateRelationship(args);
856
+ }
857
+ /** {@inheritDoc IContactManager.cmGetContactType} */
858
+ async cmGetContactType(args, context) {
859
+ const { contactTypeId } = args;
860
+ return this.store.getPartyType({
861
+ partyTypeId: contactTypeId
862
+ });
863
+ }
864
+ /** {@inheritDoc IContactManager.cmGetContactTypes} */
865
+ async cmGetContactTypes(args) {
866
+ return this.store.getPartyTypes(args);
867
+ }
868
+ /** {@inheritDoc IContactManager.cmAddContactType} */
869
+ async cmAddContactType(args, context) {
870
+ return this.store.addPartyType(args);
871
+ }
872
+ /** {@inheritDoc IContactManager.cmUpdateContactType} */
873
+ async cmUpdateContactType(args, context) {
874
+ const { contactType } = args;
875
+ return this.store.updatePartyType({
876
+ partyType: contactType
877
+ });
878
+ }
879
+ /** {@inheritDoc IContactManager.cmRemoveContactType} */
880
+ async cmRemoveContactType(args, context) {
881
+ const { contactTypeId } = args;
882
+ return this.store.removePartyType({
883
+ partyTypeId: contactTypeId
884
+ }).then(() => true);
885
+ }
886
+ /** {@inheritDoc IContactManager.cmGetElectronicAddress} */
887
+ async cmGetElectronicAddress(args, context) {
888
+ return this.store.getElectronicAddress(args);
889
+ }
890
+ /** {@inheritDoc IContactManager.cmGetElectronicAddresses} */
891
+ async cmGetElectronicAddresses(args) {
892
+ return this.store.getElectronicAddresses(args);
893
+ }
894
+ /** {@inheritDoc IContactManager.cmAddElectronicAddress} */
895
+ async cmAddElectronicAddress(args) {
896
+ const { contactId, electronicAddress } = args;
897
+ return this.store.addElectronicAddress({
898
+ partyId: contactId,
899
+ electronicAddress
900
+ });
901
+ }
902
+ /** {@inheritDoc IContactManager.cmUpdateElectronicAddress} */
903
+ async cmUpdateElectronicAddress(args) {
904
+ return this.store.updateElectronicAddress(args);
905
+ }
906
+ /** {@inheritDoc IContactManager.cmRemoveElectronicAddress} */
907
+ async cmRemoveElectronicAddress(args) {
908
+ return this.store.removeElectronicAddress(args).then(() => true);
909
+ }
910
+ /** {@inheritDoc IContactManager.cmGetPhysicalAddress} */
911
+ async cmGetPhysicalAddress(args) {
912
+ return this.store.getPhysicalAddress(args);
913
+ }
914
+ /** {@inheritDoc IContactManager.cmGetPhysicalAddresses} */
915
+ async cmGetPhysicalAddresses(args) {
916
+ return this.store.getPhysicalAddresses(args);
917
+ }
918
+ /** {@inheritDoc IContactManager.cmAddPhysicalAddress} */
919
+ async cmAddPhysicalAddress(args) {
920
+ const { contactId, physicalAddress } = args;
921
+ return this.store.addPhysicalAddress({
922
+ partyId: contactId,
923
+ physicalAddress
924
+ });
925
+ }
926
+ /** {@inheritDoc IContactManager.cmUpdatePhysicalAddress} */
927
+ async cmUpdatePhysicalAddress(args) {
928
+ return this.store.updatePhysicalAddress(args);
929
+ }
930
+ /** {@inheritDoc IContactManager.cmRemovePhysicalAddress} */
931
+ async cmRemovePhysicalAddress(args) {
932
+ return this.store.removePhysicalAddress(args).then(() => true);
933
+ }
934
+ getContactInformationFrom(contact) {
935
+ if ((0, import_ssi_sdk.isNaturalPerson)(contact)) {
936
+ return {
937
+ firstName: contact.firstName,
938
+ middleName: contact.middleName,
939
+ lastName: contact.lastName,
940
+ displayName: contact.displayName
941
+ };
942
+ } else if ((0, import_ssi_sdk.isOrganization)(contact)) {
943
+ return {
944
+ legalName: contact.legalName,
945
+ displayName: contact.displayName
946
+ };
947
+ }
948
+ throw new Error("Contact not supported");
949
+ }
950
+ };
951
+
952
+ // src/types/IContactManager.ts
953
+ var import_ssi_sdk2 = require("@sphereon/ssi-sdk.agent-config");
954
+ function contextHasContactManager(context) {
955
+ return (0, import_ssi_sdk2.contextHasPlugin)(context, "cmGetContact");
956
+ }
957
+ __name(contextHasContactManager, "contextHasContactManager");
958
+
959
+ // src/index.ts
960
+ var schema = require_plugin_schema();
961
+ //# sourceMappingURL=index.cjs.map