@sphereon/ssi-sdk.event-logger 0.33.1-feature.vcdm2.tsup.32 → 0.33.1-next.2

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 DELETED
@@ -1,886 +0,0 @@
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
- IEventLogger: {
29
- components: {
30
- schemas: {
31
- GetActivityEventsArgs: {
32
- type: "object",
33
- properties: {
34
- filter: {
35
- $ref: "#/components/schemas/FindActivityLoggingEventArgs"
36
- }
37
- }
38
- },
39
- FindActivityLoggingEventArgs: {
40
- type: "array",
41
- items: {
42
- $ref: "#/components/schemas/PartialActivityLoggingEvent"
43
- }
44
- },
45
- PartialActivityLoggingEvent: {
46
- type: "object",
47
- properties: {
48
- level: {
49
- type: "object",
50
- properties: {}
51
- },
52
- correlationId: {
53
- type: "string"
54
- },
55
- timestamp: {
56
- type: "object",
57
- properties: {},
58
- format: "date-time"
59
- },
60
- diagnosticData: {},
61
- id: {
62
- type: "string"
63
- },
64
- type: {
65
- type: "object",
66
- properties: {}
67
- },
68
- originalCredential: {
69
- type: "string"
70
- },
71
- credentialHash: {
72
- type: "string"
73
- },
74
- parentCredentialHash: {
75
- type: "string"
76
- },
77
- credentialType: {
78
- type: "object",
79
- properties: {}
80
- },
81
- sharePurpose: {
82
- type: "string"
83
- },
84
- system: {
85
- type: "object",
86
- properties: {}
87
- },
88
- subSystemType: {
89
- type: "object",
90
- properties: {}
91
- },
92
- actionType: {
93
- type: "object",
94
- properties: {}
95
- },
96
- actionSubType: {
97
- anyOf: [
98
- {
99
- type: "object",
100
- properties: {}
101
- },
102
- {
103
- type: "string"
104
- }
105
- ]
106
- },
107
- initiatorType: {
108
- type: "object",
109
- properties: {}
110
- },
111
- systemCorrelationIdType: {
112
- type: "object",
113
- properties: {}
114
- },
115
- systemCorrelationId: {
116
- type: "string"
117
- },
118
- systemAlias: {
119
- type: "string"
120
- },
121
- partyCorrelationType: {
122
- type: "object",
123
- properties: {}
124
- },
125
- partyCorrelationId: {
126
- type: "string"
127
- },
128
- partyAlias: {
129
- type: "string"
130
- },
131
- description: {
132
- type: "string"
133
- },
134
- data: {}
135
- }
136
- },
137
- ActivityLoggingEvent: {
138
- type: "object",
139
- properties: {
140
- id: {
141
- type: "string"
142
- },
143
- type: {
144
- type: "string",
145
- const: "activity"
146
- },
147
- originalCredential: {
148
- type: "string"
149
- },
150
- credentialHash: {
151
- type: "string"
152
- },
153
- parentCredentialHash: {
154
- type: "string"
155
- },
156
- credentialType: {
157
- $ref: "#/components/schemas/CredentialType"
158
- },
159
- sharePurpose: {
160
- type: "string"
161
- },
162
- correlationId: {
163
- type: "string"
164
- },
165
- system: {
166
- $ref: "#/components/schemas/System"
167
- },
168
- subSystemType: {
169
- $ref: "#/components/schemas/SubSystem"
170
- },
171
- actionType: {
172
- $ref: "#/components/schemas/ActionType"
173
- },
174
- actionSubType: {
175
- $ref: "#/components/schemas/ActionSubType"
176
- },
177
- initiatorType: {
178
- $ref: "#/components/schemas/InitiatorType"
179
- },
180
- systemCorrelationIdType: {
181
- $ref: "#/components/schemas/SystemCorrelationIdType"
182
- },
183
- systemCorrelationId: {
184
- type: "string"
185
- },
186
- systemAlias: {
187
- type: "string"
188
- },
189
- partyCorrelationType: {
190
- $ref: "#/components/schemas/PartyCorrelationType"
191
- },
192
- partyCorrelationId: {
193
- type: "string"
194
- },
195
- partyAlias: {
196
- type: "string"
197
- },
198
- description: {
199
- type: "string"
200
- },
201
- data: {},
202
- level: {
203
- $ref: "#/components/schemas/LogLevel"
204
- },
205
- timestamp: {
206
- type: "string",
207
- format: "date-time"
208
- },
209
- diagnosticData: {}
210
- },
211
- required: [
212
- "actionSubType",
213
- "actionType",
214
- "correlationId",
215
- "description",
216
- "id",
217
- "initiatorType",
218
- "level",
219
- "subSystemType",
220
- "system",
221
- "timestamp",
222
- "type"
223
- ]
224
- },
225
- CredentialType: {
226
- type: "string",
227
- enum: [
228
- "JSON_LD",
229
- "JWT",
230
- "SD_JWT",
231
- "MSO_MDOC"
232
- ]
233
- },
234
- System: {
235
- type: "string",
236
- enum: [
237
- "general",
238
- "kms",
239
- "identity",
240
- "oid4vci",
241
- "oid4vp",
242
- "siopv2",
243
- "PE",
244
- "credentials",
245
- "web3",
246
- "profile",
247
- "contact"
248
- ]
249
- },
250
- SubSystem: {
251
- type: "string",
252
- enum: [
253
- "key",
254
- "did_provider",
255
- "did_resolver",
256
- "oid4vp_op",
257
- "oid4vci_client",
258
- "siopv2_op",
259
- "contact_manager",
260
- "vc_issuer",
261
- "vc_verifier",
262
- "vc_persistence",
263
- "transport",
264
- "profile",
265
- "api"
266
- ]
267
- },
268
- ActionType: {
269
- type: "string",
270
- enum: [
271
- "create",
272
- "read",
273
- "update",
274
- "delete",
275
- "execute"
276
- ]
277
- },
278
- ActionSubType: {
279
- anyOf: [
280
- {
281
- $ref: "#/components/schemas/DefaultActionSubType"
282
- },
283
- {
284
- type: "string"
285
- }
286
- ]
287
- },
288
- DefaultActionSubType: {
289
- type: "string",
290
- enum: [
291
- "Key generation",
292
- "Key import",
293
- "Key persistence",
294
- "Key removal",
295
- "DID creation",
296
- "DID resolution",
297
- "DID service update",
298
- "VC issue",
299
- "VC verify",
300
- "VC share",
301
- "VC delete",
302
- "VC issue decline",
303
- "VC share decline"
304
- ]
305
- },
306
- InitiatorType: {
307
- type: "string",
308
- enum: [
309
- "user",
310
- "system",
311
- "external"
312
- ]
313
- },
314
- SystemCorrelationIdType: {
315
- type: "string",
316
- enum: [
317
- "did",
318
- "url",
319
- "email",
320
- "hostname",
321
- "phone",
322
- "user"
323
- ]
324
- },
325
- PartyCorrelationType: {
326
- type: "string",
327
- enum: [
328
- "did",
329
- "url",
330
- "email",
331
- "hostname",
332
- "phone"
333
- ]
334
- },
335
- LogLevel: {
336
- type: "number",
337
- enum: [
338
- 0,
339
- 1,
340
- 2,
341
- 3,
342
- 4
343
- ]
344
- },
345
- GetAuditEventsArgs: {
346
- type: "object",
347
- properties: {
348
- filter: {
349
- $ref: "#/components/schemas/FindAuditLoggingEventArgs"
350
- }
351
- }
352
- },
353
- FindAuditLoggingEventArgs: {
354
- type: "array",
355
- items: {
356
- $ref: "#/components/schemas/PartialAuditLoggingEvent"
357
- }
358
- },
359
- PartialAuditLoggingEvent: {
360
- type: "object",
361
- properties: {
362
- level: {
363
- type: "object",
364
- properties: {}
365
- },
366
- correlationId: {
367
- type: "string"
368
- },
369
- timestamp: {
370
- type: "object",
371
- properties: {},
372
- format: "date-time"
373
- },
374
- diagnosticData: {},
375
- id: {
376
- type: "string"
377
- },
378
- type: {
379
- type: "object",
380
- properties: {}
381
- },
382
- system: {
383
- type: "object",
384
- properties: {}
385
- },
386
- subSystemType: {
387
- type: "object",
388
- properties: {}
389
- },
390
- actionType: {
391
- type: "object",
392
- properties: {}
393
- },
394
- actionSubType: {
395
- anyOf: [
396
- {
397
- type: "object",
398
- properties: {}
399
- },
400
- {
401
- type: "string"
402
- }
403
- ]
404
- },
405
- initiatorType: {
406
- type: "object",
407
- properties: {}
408
- },
409
- systemCorrelationIdType: {
410
- type: "object",
411
- properties: {}
412
- },
413
- systemCorrelationId: {
414
- type: "string"
415
- },
416
- systemAlias: {
417
- type: "string"
418
- },
419
- partyCorrelationType: {
420
- type: "object",
421
- properties: {}
422
- },
423
- partyCorrelationId: {
424
- type: "string"
425
- },
426
- partyAlias: {
427
- type: "string"
428
- },
429
- description: {
430
- type: "string"
431
- },
432
- data: {}
433
- }
434
- },
435
- AuditLoggingEvent: {
436
- type: "object",
437
- properties: {
438
- id: {
439
- type: "string"
440
- },
441
- type: {
442
- type: "string",
443
- const: "audit"
444
- },
445
- correlationId: {
446
- type: "string"
447
- },
448
- system: {
449
- $ref: "#/components/schemas/System"
450
- },
451
- subSystemType: {
452
- $ref: "#/components/schemas/SubSystem"
453
- },
454
- actionType: {
455
- $ref: "#/components/schemas/ActionType"
456
- },
457
- actionSubType: {
458
- $ref: "#/components/schemas/ActionSubType"
459
- },
460
- initiatorType: {
461
- $ref: "#/components/schemas/InitiatorType"
462
- },
463
- systemCorrelationIdType: {
464
- $ref: "#/components/schemas/SystemCorrelationIdType"
465
- },
466
- systemCorrelationId: {
467
- type: "string"
468
- },
469
- systemAlias: {
470
- type: "string"
471
- },
472
- partyCorrelationType: {
473
- $ref: "#/components/schemas/PartyCorrelationType"
474
- },
475
- partyCorrelationId: {
476
- type: "string"
477
- },
478
- partyAlias: {
479
- type: "string"
480
- },
481
- description: {
482
- type: "string"
483
- },
484
- data: {},
485
- level: {
486
- $ref: "#/components/schemas/LogLevel"
487
- },
488
- timestamp: {
489
- type: "string",
490
- format: "date-time"
491
- },
492
- diagnosticData: {}
493
- },
494
- required: [
495
- "actionSubType",
496
- "actionType",
497
- "correlationId",
498
- "description",
499
- "id",
500
- "initiatorType",
501
- "level",
502
- "subSystemType",
503
- "system",
504
- "timestamp",
505
- "type"
506
- ]
507
- },
508
- LogEventArgs: {
509
- type: "object",
510
- properties: {
511
- event: {
512
- $ref: "#/components/schemas/LogEventType"
513
- }
514
- },
515
- required: [
516
- "event"
517
- ]
518
- },
519
- LogEventType: {
520
- anyOf: [
521
- {
522
- $ref: "#/components/schemas/NonPersistedAuditLoggingEvent"
523
- },
524
- {
525
- $ref: "#/components/schemas/NonPersistedActivityLoggingEvent"
526
- }
527
- ]
528
- },
529
- NonPersistedAuditLoggingEvent: {
530
- type: "object",
531
- properties: {
532
- system: {
533
- $ref: "#/components/schemas/System"
534
- },
535
- subSystemType: {
536
- $ref: "#/components/schemas/SubSystem"
537
- },
538
- initiatorType: {
539
- $ref: "#/components/schemas/InitiatorType"
540
- },
541
- diagnosticData: {},
542
- actionType: {
543
- type: "object",
544
- properties: {}
545
- },
546
- actionSubType: {
547
- anyOf: [
548
- {
549
- type: "object",
550
- properties: {}
551
- },
552
- {
553
- type: "string"
554
- }
555
- ]
556
- },
557
- systemCorrelationIdType: {
558
- type: "object",
559
- properties: {}
560
- },
561
- systemCorrelationId: {
562
- type: "string"
563
- },
564
- systemAlias: {
565
- type: "string"
566
- },
567
- partyCorrelationType: {
568
- type: "object",
569
- properties: {}
570
- },
571
- partyCorrelationId: {
572
- type: "string"
573
- },
574
- partyAlias: {
575
- type: "string"
576
- },
577
- description: {
578
- type: "string"
579
- },
580
- data: {},
581
- level: {
582
- type: "object",
583
- properties: {}
584
- },
585
- correlationId: {
586
- type: "string"
587
- }
588
- },
589
- required: [
590
- "actionSubType",
591
- "actionType",
592
- "description",
593
- "initiatorType",
594
- "subSystemType",
595
- "system"
596
- ]
597
- },
598
- NonPersistedActivityLoggingEvent: {
599
- type: "object",
600
- properties: {
601
- system: {
602
- $ref: "#/components/schemas/System"
603
- },
604
- subSystemType: {
605
- $ref: "#/components/schemas/SubSystem"
606
- },
607
- initiatorType: {
608
- $ref: "#/components/schemas/InitiatorType"
609
- },
610
- originalCredential: {
611
- type: "string"
612
- },
613
- credentialHash: {
614
- type: "string"
615
- },
616
- parentCredentialHash: {
617
- type: "string"
618
- },
619
- credentialType: {
620
- type: "object",
621
- properties: {}
622
- },
623
- sharePurpose: {
624
- type: "string"
625
- },
626
- data: {},
627
- diagnosticData: {},
628
- actionType: {
629
- type: "object",
630
- properties: {}
631
- },
632
- actionSubType: {
633
- anyOf: [
634
- {
635
- type: "object",
636
- properties: {}
637
- },
638
- {
639
- type: "string"
640
- }
641
- ]
642
- },
643
- systemCorrelationIdType: {
644
- type: "object",
645
- properties: {}
646
- },
647
- systemCorrelationId: {
648
- type: "string"
649
- },
650
- systemAlias: {
651
- type: "string"
652
- },
653
- partyCorrelationType: {
654
- type: "object",
655
- properties: {}
656
- },
657
- partyCorrelationId: {
658
- type: "string"
659
- },
660
- partyAlias: {
661
- type: "string"
662
- },
663
- description: {
664
- type: "string"
665
- },
666
- level: {
667
- type: "object",
668
- properties: {}
669
- },
670
- correlationId: {
671
- type: "string"
672
- }
673
- },
674
- required: [
675
- "actionSubType",
676
- "actionType",
677
- "description",
678
- "initiatorType",
679
- "subSystemType",
680
- "system"
681
- ]
682
- }
683
- },
684
- methods: {
685
- loggerGetActivityEvents: {
686
- description: "",
687
- arguments: {
688
- $ref: "#/components/schemas/GetActivityEventsArgs"
689
- },
690
- returnType: {
691
- type: "array",
692
- items: {
693
- $ref: "#/components/schemas/ActivityLoggingEvent"
694
- }
695
- }
696
- },
697
- loggerGetAuditEvents: {
698
- description: "",
699
- arguments: {
700
- $ref: "#/components/schemas/GetAuditEventsArgs"
701
- },
702
- returnType: {
703
- type: "array",
704
- items: {
705
- $ref: "#/components/schemas/AuditLoggingEvent"
706
- }
707
- }
708
- },
709
- loggerLogActivityEvent: {
710
- description: "",
711
- arguments: {
712
- $ref: "#/components/schemas/LogEventArgs"
713
- },
714
- returnType: {
715
- $ref: "#/components/schemas/ActivityLoggingEvent"
716
- }
717
- },
718
- loggerLogAuditEvent: {
719
- description: "",
720
- arguments: {
721
- $ref: "#/components/schemas/LogEventArgs"
722
- },
723
- returnType: {
724
- $ref: "#/components/schemas/AuditLoggingEvent"
725
- }
726
- },
727
- loggerLogGeneralEvent: {
728
- description: "",
729
- arguments: {
730
- $ref: "#/components/schemas/LogEventArgs"
731
- },
732
- returnType: {
733
- $ref: "#/components/schemas/LogEventType"
734
- }
735
- }
736
- }
737
- }
738
- }
739
- };
740
- }
741
- });
742
-
743
- // src/index.ts
744
- var index_exports = {};
745
- __export(index_exports, {
746
- EventLogger: () => EventLogger,
747
- eventLoggerAuditMethods: () => eventLoggerAuditMethods,
748
- eventLoggerMethods: () => eventLoggerMethods,
749
- schema: () => schema
750
- });
751
- module.exports = __toCommonJS(index_exports);
752
-
753
- // src/agent/EventLogger.ts
754
- var import_ssi_types = require("@sphereon/ssi-types");
755
- var import_uuid = require("uuid");
756
- var eventLoggerAuditMethods = [
757
- "loggerGetAuditEvents",
758
- "loggerLogAuditEvent",
759
- "loggerLogGeneralEvent",
760
- "loggerLogActivityEvent",
761
- "loggerGetActivityEvents"
762
- ];
763
- var eventLoggerMethods = [
764
- ...eventLoggerAuditMethods
765
- ];
766
- var EventLogger = class {
767
- static {
768
- __name(this, "EventLogger");
769
- }
770
- schema = schema.IEventLogger;
771
- eventTypes = [];
772
- store;
773
- simpleLoggers;
774
- methods = {
775
- loggerGetAuditEvents: this.loggerGetAuditEvents.bind(this),
776
- loggerLogAuditEvent: this.loggerLogAuditEvent.bind(this),
777
- loggerLogGeneralEvent: this.loggerLogGeneralEvent.bind(this),
778
- loggerLogActivityEvent: this.loggerLogActivityEvent.bind(this),
779
- loggerGetActivityEvents: this.loggerGetActivityEvents.bind(this)
780
- };
781
- constructor(options) {
782
- const { store, eventTypes } = options;
783
- const generalOpts = options.general ?? {
784
- debugPkg: true
785
- };
786
- this.store = store;
787
- this.eventTypes = eventTypes;
788
- const methods = [];
789
- if (generalOpts.debugPkg) {
790
- methods.push(import_ssi_types.LogMethod.DEBUG_PKG);
791
- }
792
- if (generalOpts.console) {
793
- methods.push(import_ssi_types.LogMethod.CONSOLE);
794
- }
795
- if (generalOpts.events) {
796
- methods.push(import_ssi_types.LogMethod.EVENT);
797
- }
798
- this.simpleLoggers = new import_ssi_types.Loggers({
799
- methods,
800
- eventName: generalOpts.eventName,
801
- defaultLogLevel: generalOpts.defaultLogLevel
802
- });
803
- }
804
- async onEvent(event, context) {
805
- switch (event.type) {
806
- case import_ssi_types.LoggingEventType.AUDIT:
807
- await context.agent.loggerLogAuditEvent({
808
- event: event.data
809
- });
810
- break;
811
- case import_ssi_types.LoggingEventType.GENERAL:
812
- await context.agent.loggerLogGeneralEvent({
813
- event: event.data
814
- });
815
- break;
816
- case import_ssi_types.LoggingEventType.ACTIVITY:
817
- await context.agent.loggerLogActivityEvent({
818
- event: event.data
819
- });
820
- break;
821
- default:
822
- return Promise.reject(Error(`Event type ${event.type} not supported`));
823
- }
824
- }
825
- async loggerGetAuditEvents(args) {
826
- const { filter } = args ?? {};
827
- if (!this.store) {
828
- return Promise.reject(Error("No store available in options"));
829
- }
830
- return this.store.getAuditEvents({
831
- filter
832
- });
833
- }
834
- async loggerGetActivityEvents(args) {
835
- const { filter } = args ?? {};
836
- if (!this.store) {
837
- return Promise.reject(Error("No store available in options"));
838
- }
839
- return this.store.getActivityEvents({
840
- filter
841
- });
842
- }
843
- async loggerLogGeneralEvent(args) {
844
- const { event } = args;
845
- this.simpleLoggers.get(event.data.system).logl(event.data.level ?? import_ssi_types.LogLevel.INFO, event.data.data, event.data);
846
- return args.event;
847
- }
848
- async loggerLogAuditEvent(args) {
849
- const { event } = args;
850
- if (!this.store) {
851
- return Promise.reject(Error("No store available in options"));
852
- }
853
- return this.store.storeAuditEvent({
854
- event: {
855
- ...event,
856
- system: event.system,
857
- subSystemType: event.subSystemType,
858
- initiatorType: event.initiatorType,
859
- level: event.level ?? import_ssi_types.LogLevel.INFO,
860
- correlationId: event.correlationId ?? (0, import_uuid.v4)(),
861
- timestamp: /* @__PURE__ */ new Date()
862
- }
863
- });
864
- }
865
- async loggerLogActivityEvent(args) {
866
- const { event } = args;
867
- if (!this.store) {
868
- return Promise.reject(Error("No store available in options"));
869
- }
870
- return this.store.storeActivityEvent({
871
- event: {
872
- ...event,
873
- system: event.system,
874
- subSystemType: event.subSystemType,
875
- initiatorType: event.initiatorType,
876
- level: event.level ?? import_ssi_types.LogLevel.INFO,
877
- correlationId: event.correlationId ?? (0, import_uuid.v4)(),
878
- timestamp: /* @__PURE__ */ new Date()
879
- }
880
- });
881
- }
882
- };
883
-
884
- // src/index.ts
885
- var schema = require_plugin_schema();
886
- //# sourceMappingURL=index.cjs.map