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