@sphereon/ssi-sdk.event-logger 0.30.2-next.103 → 0.30.2-next.129
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/README.md +4 -0
- package/dist/agent/EventLogger.d.ts +4 -2
- package/dist/agent/EventLogger.d.ts.map +1 -1
- package/dist/agent/EventLogger.js +34 -1
- package/dist/agent/EventLogger.js.map +1 -1
- package/dist/ssi-sdk.event-logger.d.ts +37 -3
- package/dist/types/IEventLogger.d.ts +28 -5
- package/dist/types/IEventLogger.d.ts.map +1 -1
- package/package.json +6 -6
- package/plugin.schema.json +344 -13
- package/src/agent/EventLogger.ts +60 -6
- package/src/types/IEventLogger.ts +46 -6
package/README.md
CHANGED
|
@@ -17,11 +17,15 @@ There are also functions that can be manually called to persist events. Current,
|
|
|
17
17
|
|
|
18
18
|
Ideally this plugin should be used in combination with the event logger from our core package. This event logger will also default debug the events.
|
|
19
19
|
This is mainly as a fallback for when no listener is present within the agent.
|
|
20
|
+
You can also store (credential) activity logs. which gets information related to a credential and the action that has performed on it.
|
|
20
21
|
|
|
21
22
|
## Available functions
|
|
22
23
|
|
|
23
24
|
- loggerGetAuditEvents
|
|
24
25
|
- loggerStoreAuditEvent
|
|
26
|
+
- loggerLogGeneralEvent
|
|
27
|
+
- loggerLogActivityEvent
|
|
28
|
+
- loggerGetActivityEvents
|
|
25
29
|
|
|
26
30
|
## Usage
|
|
27
31
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IAgentPlugin } from '@veramo/core';
|
|
2
1
|
import { Loggers, LoggingEventType } from '@sphereon/ssi-types';
|
|
3
|
-
import {
|
|
2
|
+
import { IAgentPlugin } from '@veramo/core';
|
|
3
|
+
import { EventLoggerOptions, IEventLogger, LoggingEvent, RequiredContext } from '../types/IEventLogger';
|
|
4
4
|
/**
|
|
5
5
|
* {@inheritDoc IEventLogger}
|
|
6
6
|
*/
|
|
@@ -15,7 +15,9 @@ export declare class EventLogger implements IAgentPlugin {
|
|
|
15
15
|
constructor(options: EventLoggerOptions);
|
|
16
16
|
onEvent(event: LoggingEvent, context: RequiredContext): Promise<void>;
|
|
17
17
|
private loggerGetAuditEvents;
|
|
18
|
+
private loggerGetActivityEvents;
|
|
18
19
|
private loggerLogGeneralEvent;
|
|
19
20
|
private loggerLogAuditEvent;
|
|
21
|
+
private loggerLogActivityEvent;
|
|
20
22
|
}
|
|
21
23
|
//# sourceMappingURL=EventLogger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventLogger.d.ts","sourceRoot":"","sources":["../../src/agent/EventLogger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"EventLogger.d.ts","sourceRoot":"","sources":["../../src/agent/EventLogger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAuB,MAAM,qBAAqB,CAAA;AAEpF,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C,OAAO,EACL,kBAAkB,EAGlB,YAAY,EAIZ,YAAY,EAEZ,eAAe,EAChB,MAAM,uBAAuB,CAAA;AAE9B;;GAEG;AAGH,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,MAAM,CAMjD,CAAA;AACD,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,MAAM,CAAgC,CAAA;AAE7E,qBAAa,WAAY,YAAW,YAAY;IAC9C,QAAQ,CAAC,MAAM,MAAsB;IACrC,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAK;IACjD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,CAA0B;IACjD,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAA;IAE/B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAM7B;gBAEW,OAAO,EAAE,kBAAkB;IAuB1B,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;YAoBpE,oBAAoB;YAUpB,uBAAuB;YAUvB,qBAAqB;YAOrB,mBAAmB;YAoBnB,sBAAsB;CAmBrC"}
|
|
@@ -17,7 +17,13 @@ const index_1 = require("../index");
|
|
|
17
17
|
* {@inheritDoc IEventLogger}
|
|
18
18
|
*/
|
|
19
19
|
// Exposing the methods here for any REST implementation
|
|
20
|
-
exports.eventLoggerAuditMethods = [
|
|
20
|
+
exports.eventLoggerAuditMethods = [
|
|
21
|
+
'loggerGetAuditEvents',
|
|
22
|
+
'loggerLogAuditEvent',
|
|
23
|
+
'loggerLogGeneralEvent',
|
|
24
|
+
'loggerLogActivityEvent',
|
|
25
|
+
'loggerGetActivityEvents',
|
|
26
|
+
];
|
|
21
27
|
exports.eventLoggerMethods = [...exports.eventLoggerAuditMethods];
|
|
22
28
|
class EventLogger {
|
|
23
29
|
constructor(options) {
|
|
@@ -28,6 +34,8 @@ class EventLogger {
|
|
|
28
34
|
loggerGetAuditEvents: this.loggerGetAuditEvents.bind(this),
|
|
29
35
|
loggerLogAuditEvent: this.loggerLogAuditEvent.bind(this),
|
|
30
36
|
loggerLogGeneralEvent: this.loggerLogGeneralEvent.bind(this),
|
|
37
|
+
loggerLogActivityEvent: this.loggerLogActivityEvent.bind(this),
|
|
38
|
+
loggerGetActivityEvents: this.loggerGetActivityEvents.bind(this),
|
|
31
39
|
};
|
|
32
40
|
const { store, eventTypes } = options;
|
|
33
41
|
const generalOpts = (_a = options.general) !== null && _a !== void 0 ? _a : { debugPkg: true };
|
|
@@ -61,6 +69,10 @@ class EventLogger {
|
|
|
61
69
|
// TODO: We might also want to do this locally though, as these logs are not persisted typically
|
|
62
70
|
yield context.agent.loggerLogGeneralEvent({ event: event.data });
|
|
63
71
|
break;
|
|
72
|
+
case ssi_types_1.LoggingEventType.ACTIVITY:
|
|
73
|
+
// Calling the context of the agent to make sure the REST client is called when configured
|
|
74
|
+
yield context.agent.loggerLogActivityEvent({ event: event.data });
|
|
75
|
+
break;
|
|
64
76
|
default:
|
|
65
77
|
return Promise.reject(Error(`Event type ${event.type} not supported`));
|
|
66
78
|
}
|
|
@@ -75,6 +87,15 @@ class EventLogger {
|
|
|
75
87
|
return this.store.getAuditEvents({ filter });
|
|
76
88
|
});
|
|
77
89
|
}
|
|
90
|
+
loggerGetActivityEvents(args) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const { filter } = args !== null && args !== void 0 ? args : {};
|
|
93
|
+
if (!this.store) {
|
|
94
|
+
return Promise.reject(Error('No store available in options'));
|
|
95
|
+
}
|
|
96
|
+
return this.store.getActivityEvents({ filter });
|
|
97
|
+
});
|
|
98
|
+
}
|
|
78
99
|
loggerLogGeneralEvent(args) {
|
|
79
100
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
101
|
var _a;
|
|
@@ -95,6 +116,18 @@ class EventLogger {
|
|
|
95
116
|
});
|
|
96
117
|
});
|
|
97
118
|
}
|
|
119
|
+
loggerLogActivityEvent(args) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
var _a, _b;
|
|
122
|
+
const { event } = args;
|
|
123
|
+
if (!this.store) {
|
|
124
|
+
return Promise.reject(Error('No store available in options'));
|
|
125
|
+
}
|
|
126
|
+
return this.store.storeActivityEvent({
|
|
127
|
+
event: Object.assign(Object.assign({}, event), { system: event.system, subSystemType: event.subSystemType, initiatorType: event.initiatorType, level: (_a = event.level) !== null && _a !== void 0 ? _a : ssi_types_1.LogLevel.INFO, correlationId: (_b = event.correlationId) !== null && _b !== void 0 ? _b : (0, uuid_1.v4)(), timestamp: new Date() }),
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
}
|
|
98
131
|
}
|
|
99
132
|
exports.EventLogger = EventLogger;
|
|
100
133
|
//# sourceMappingURL=EventLogger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventLogger.js","sourceRoot":"","sources":["../../src/agent/EventLogger.ts"],"names":[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,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC;gBAChC,KAAK,kCACA,KAAK,KACR,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,aAAa,EAAE,KAAK,CAAC,aAAa,EAClC,aAAa,EAAE,KAAK,CAAC,aAAa,EAClC,KAAK,EAAE,MAAA,KAAK,CAAC,KAAK,mCAAI,oBAAQ,CAAC,IAAI,EACnC,aAAa,EAAE,MAAA,KAAK,CAAC,aAAa,mCAAI,IAAA,SAAM,GAAE,EAC9C,SAAS,EAAE,IAAI,IAAI,EAAE,GACtB;aACF,CAAC,CAAA;QACJ,CAAC;KAAA;IAEa,sBAAsB,CAAC,IAA0B;;;YAC7D,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;YAEtB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;gBAChB,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC,CAAA;YAC/D,CAAC;YAED,OAAO,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC;gBACnC,KAAK,kCACA,KAAK,KACR,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,aAAa,EAAE,KAAK,CAAC,aAAa,EAClC,aAAa,EAAE,KAAK,CAAC,aAAa,EAClC,KAAK,EAAE,MAAA,KAAK,CAAC,KAAK,mCAAI,oBAAQ,CAAC,IAAI,EACnC,aAAa,EAAE,MAAA,KAAK,CAAC,aAAa,mCAAI,IAAA,SAAM,GAAE,EAC9C,SAAS,EAAE,IAAI,IAAI,EAAE,GACtB;aACF,CAAC,CAAA;QACJ,CAAC;KAAA;CACF;AA3HD,kCA2HC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { AbstractEventLoggerStore } from '@sphereon/ssi-sdk.data-store';
|
|
2
|
+
import { ActivityLoggingEvent } from '@sphereon/ssi-sdk.core';
|
|
2
3
|
import { AuditLoggingEvent } from '@sphereon/ssi-sdk.core';
|
|
4
|
+
import { CredentialType } from '@sphereon/ssi-sdk.core';
|
|
5
|
+
import { FindActivityLoggingEventArgs } from '@sphereon/ssi-sdk.data-store';
|
|
3
6
|
import { FindAuditLoggingEventArgs } from '@sphereon/ssi-sdk.data-store';
|
|
4
7
|
import { IAgentContext } from '@veramo/core';
|
|
5
8
|
import { IAgentPlugin } from '@veramo/core';
|
|
@@ -8,6 +11,7 @@ import { IPluginMethodMap } from '@veramo/core';
|
|
|
8
11
|
import { Loggers } from '@sphereon/ssi-types';
|
|
9
12
|
import { LoggingEventType } from '@sphereon/ssi-types';
|
|
10
13
|
import { LogLevel } from '@sphereon/ssi-types';
|
|
14
|
+
import { NonPersistedActivityLoggingEvent as NonPersistedActivityLoggingEvent_2 } from '@sphereon/ssi-sdk.core';
|
|
11
15
|
import { NonPersistedAuditLoggingEvent as NonPersistedAuditLoggingEvent_2 } from '@sphereon/ssi-sdk.core';
|
|
12
16
|
import { SubSystem } from '@sphereon/ssi-types';
|
|
13
17
|
import { System } from '@sphereon/ssi-types';
|
|
@@ -21,8 +25,10 @@ export declare class EventLogger implements IAgentPlugin {
|
|
|
21
25
|
constructor(options: EventLoggerOptions);
|
|
22
26
|
onEvent(event: LoggingEvent, context: RequiredContext): Promise<void>;
|
|
23
27
|
private loggerGetAuditEvents;
|
|
28
|
+
private loggerGetActivityEvents;
|
|
24
29
|
private loggerLogGeneralEvent;
|
|
25
30
|
private loggerLogAuditEvent;
|
|
31
|
+
private loggerLogActivityEvent;
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
/**
|
|
@@ -46,23 +52,51 @@ export declare type EventLoggerOptions = {
|
|
|
46
52
|
general?: EventLoggerGeneralLogOpts;
|
|
47
53
|
};
|
|
48
54
|
|
|
55
|
+
export declare type GetActivityEventsArgs = {
|
|
56
|
+
filter?: FindActivityLoggingEventArgs;
|
|
57
|
+
};
|
|
58
|
+
|
|
49
59
|
export declare type GetAuditEventsArgs = {
|
|
50
60
|
filter?: FindAuditLoggingEventArgs;
|
|
51
61
|
};
|
|
52
62
|
|
|
53
63
|
export declare interface IEventLogger extends IPluginMethodMap {
|
|
54
64
|
loggerGetAuditEvents(args?: GetAuditEventsArgs): Promise<Array<AuditLoggingEvent>>;
|
|
55
|
-
loggerLogAuditEvent(args:
|
|
56
|
-
loggerLogGeneralEvent(args:
|
|
65
|
+
loggerLogAuditEvent(args: LogEventArgs, context: RequiredContext): Promise<AuditLoggingEvent>;
|
|
66
|
+
loggerLogGeneralEvent(args: LogEventArgs, context: RequiredContext): Promise<LogEventType>;
|
|
67
|
+
loggerLogActivityEvent(args: LogEventArgs, context: RequiredContext): Promise<ActivityLoggingEvent>;
|
|
68
|
+
loggerGetActivityEvents(args?: GetActivityEventsArgs): Promise<Array<ActivityLoggingEvent>>;
|
|
57
69
|
}
|
|
58
70
|
|
|
71
|
+
export declare type LogActivityEventArgs = {
|
|
72
|
+
event: NonPersistedActivityLoggingEvent;
|
|
73
|
+
};
|
|
74
|
+
|
|
59
75
|
export declare type LogAuditEventArgs = {
|
|
60
76
|
event: NonPersistedAuditLoggingEvent;
|
|
61
77
|
};
|
|
62
78
|
|
|
79
|
+
export declare type LogEventArgs = {
|
|
80
|
+
event: LogEventType;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export declare type LogEventType = NonPersistedAuditLoggingEvent | NonPersistedActivityLoggingEvent;
|
|
84
|
+
|
|
63
85
|
export declare type LoggingEvent = {
|
|
64
86
|
type: LoggingEventType;
|
|
65
|
-
data:
|
|
87
|
+
data: LogEventType;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export declare type NonPersistedActivityLoggingEvent = Omit<NonPersistedActivityLoggingEvent_2, 'system' | 'subSystemType' | 'initiatorType'> & {
|
|
91
|
+
system: System;
|
|
92
|
+
subSystemType: SubSystem;
|
|
93
|
+
initiatorType: InitiatorType;
|
|
94
|
+
originalCredential?: string;
|
|
95
|
+
credentialHash?: string;
|
|
96
|
+
parentCredentialHash?: string;
|
|
97
|
+
credentialType?: CredentialType;
|
|
98
|
+
sharePurpose?: string;
|
|
99
|
+
data?: any;
|
|
66
100
|
};
|
|
67
101
|
|
|
68
102
|
export declare type NonPersistedAuditLoggingEvent = Omit<NonPersistedAuditLoggingEvent_2, 'system' | 'subSystemType' | 'initiatorType'> & {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { InitiatorType, LoggingEventType, LogLevel, SubSystem, System } from '@sphereon/ssi-types';
|
|
2
|
+
import { AuditLoggingEvent, CredentialType, NonPersistedAuditLoggingEvent as NPAuditLoggingEvent, NonPersistedActivityLoggingEvent as NPActivityLoggingEvent, ActivityLoggingEvent } from '@sphereon/ssi-sdk.core';
|
|
3
|
+
import { AbstractEventLoggerStore, FindActivityLoggingEventArgs, FindAuditLoggingEventArgs } from '@sphereon/ssi-sdk.data-store';
|
|
2
4
|
import { IAgentContext, IPluginMethodMap } from '@veramo/core';
|
|
3
|
-
import { AuditLoggingEvent, NonPersistedAuditLoggingEvent as NPAuditLoggingEvent } from '@sphereon/ssi-sdk.core';
|
|
4
|
-
import { AbstractEventLoggerStore, FindAuditLoggingEventArgs } from '@sphereon/ssi-sdk.data-store';
|
|
5
5
|
export interface IEventLogger extends IPluginMethodMap {
|
|
6
6
|
loggerGetAuditEvents(args?: GetAuditEventsArgs): Promise<Array<AuditLoggingEvent>>;
|
|
7
|
-
loggerLogAuditEvent(args:
|
|
8
|
-
loggerLogGeneralEvent(args:
|
|
7
|
+
loggerLogAuditEvent(args: LogEventArgs, context: RequiredContext): Promise<AuditLoggingEvent>;
|
|
8
|
+
loggerLogGeneralEvent(args: LogEventArgs, context: RequiredContext): Promise<LogEventType>;
|
|
9
|
+
loggerLogActivityEvent(args: LogEventArgs, context: RequiredContext): Promise<ActivityLoggingEvent>;
|
|
10
|
+
loggerGetActivityEvents(args?: GetActivityEventsArgs): Promise<Array<ActivityLoggingEvent>>;
|
|
9
11
|
}
|
|
10
12
|
export interface EventLoggerGeneralLogOpts {
|
|
11
13
|
debugPkg?: boolean;
|
|
@@ -22,17 +24,38 @@ export type EventLoggerOptions = {
|
|
|
22
24
|
export type GetAuditEventsArgs = {
|
|
23
25
|
filter?: FindAuditLoggingEventArgs;
|
|
24
26
|
};
|
|
27
|
+
export type GetActivityEventsArgs = {
|
|
28
|
+
filter?: FindActivityLoggingEventArgs;
|
|
29
|
+
};
|
|
30
|
+
export type LogEventArgs = {
|
|
31
|
+
event: LogEventType;
|
|
32
|
+
};
|
|
33
|
+
export type LogEventType = NonPersistedAuditLoggingEvent | NonPersistedActivityLoggingEvent;
|
|
25
34
|
export type LogAuditEventArgs = {
|
|
26
35
|
event: NonPersistedAuditLoggingEvent;
|
|
27
36
|
};
|
|
37
|
+
export type LogActivityEventArgs = {
|
|
38
|
+
event: NonPersistedActivityLoggingEvent;
|
|
39
|
+
};
|
|
28
40
|
export type NonPersistedAuditLoggingEvent = Omit<NPAuditLoggingEvent, 'system' | 'subSystemType' | 'initiatorType'> & {
|
|
29
41
|
system: System;
|
|
30
42
|
subSystemType: SubSystem;
|
|
31
43
|
initiatorType: InitiatorType;
|
|
32
44
|
};
|
|
45
|
+
export type NonPersistedActivityLoggingEvent = Omit<NPActivityLoggingEvent, 'system' | 'subSystemType' | 'initiatorType'> & {
|
|
46
|
+
system: System;
|
|
47
|
+
subSystemType: SubSystem;
|
|
48
|
+
initiatorType: InitiatorType;
|
|
49
|
+
originalCredential?: string;
|
|
50
|
+
credentialHash?: string;
|
|
51
|
+
parentCredentialHash?: string;
|
|
52
|
+
credentialType?: CredentialType;
|
|
53
|
+
sharePurpose?: string;
|
|
54
|
+
data?: any;
|
|
55
|
+
};
|
|
33
56
|
export type LoggingEvent = {
|
|
34
57
|
type: LoggingEventType;
|
|
35
|
-
data:
|
|
58
|
+
data: LogEventType;
|
|
36
59
|
};
|
|
37
60
|
export type RequiredContext = IAgentContext<IEventLogger>;
|
|
38
61
|
//# sourceMappingURL=IEventLogger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IEventLogger.d.ts","sourceRoot":"","sources":["../../src/types/IEventLogger.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"IEventLogger.d.ts","sourceRoot":"","sources":["../../src/types/IEventLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,MAAM,EACP,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,6BAA6B,IAAI,mBAAmB,EACpD,gCAAgC,IAAI,sBAAsB,EAC1D,oBAAoB,EACrB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,wBAAwB,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AAChI,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAE9D,MAAM,WAAW,YAAa,SAAQ,gBAAgB;IACpD,oBAAoB,CAAC,IAAI,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAA;IAClF,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAC7F,qBAAqB,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;IAC1F,sBAAsB,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;IACnG,uBAAuB,CAAC,IAAI,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAA;CAC5F;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,SAA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,CAAA;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,IAAI,CAAC,EAAE,GAAG,CAAA;CACX,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,gBAAgB,CAAA;IACtB,IAAI,EAAE,YAAY,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,aAAa,CAAC,YAAY,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.event-logger",
|
|
3
|
-
"version": "0.30.2-next.
|
|
3
|
+
"version": "0.30.2-next.129+85479f8a",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"generate-plugin-schema": "ts-node ../../packages/dev/bin/sphereon.js dev generate-plugin-schema"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@sphereon/ssi-sdk.data-store": "0.30.2-next.
|
|
19
|
-
"@sphereon/ssi-types": "0.30.2-next.
|
|
18
|
+
"@sphereon/ssi-sdk.data-store": "0.30.2-next.129+85479f8a",
|
|
19
|
+
"@sphereon/ssi-types": "0.30.2-next.129+85479f8a",
|
|
20
20
|
"uuid": "^9.0.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@sphereon/ssi-sdk.agent-config": "0.30.2-next.
|
|
24
|
-
"@sphereon/ssi-sdk.core": "0.30.2-next.
|
|
23
|
+
"@sphereon/ssi-sdk.agent-config": "0.30.2-next.129+85479f8a",
|
|
24
|
+
"@sphereon/ssi-sdk.core": "0.30.2-next.129+85479f8a",
|
|
25
25
|
"@sphereon/ssi-sdk.data-store": "workspace:*",
|
|
26
26
|
"@types/jest": "^27.5.2",
|
|
27
27
|
"@types/uuid": "^9.0.8",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"Audit"
|
|
55
55
|
],
|
|
56
56
|
"nx": {},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "85479f8ad18e6eef981de750c81cd9be5b6d9c53"
|
|
58
58
|
}
|
package/plugin.schema.json
CHANGED
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
"IEventLogger": {
|
|
3
3
|
"components": {
|
|
4
4
|
"schemas": {
|
|
5
|
-
"
|
|
5
|
+
"GetActivityEventsArgs": {
|
|
6
6
|
"type": "object",
|
|
7
7
|
"properties": {
|
|
8
8
|
"filter": {
|
|
9
|
-
"$ref": "#/components/schemas/
|
|
9
|
+
"$ref": "#/components/schemas/FindActivityLoggingEventArgs"
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
},
|
|
13
|
-
"
|
|
13
|
+
"FindActivityLoggingEventArgs": {
|
|
14
14
|
"type": "array",
|
|
15
15
|
"items": {
|
|
16
|
-
"$ref": "#/components/schemas/
|
|
16
|
+
"$ref": "#/components/schemas/PartialActivityLoggingEvent"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
-
"
|
|
19
|
+
"PartialActivityLoggingEvent": {
|
|
20
20
|
"type": "object",
|
|
21
21
|
"properties": {
|
|
22
22
|
"level": {
|
|
@@ -35,6 +35,26 @@
|
|
|
35
35
|
"id": {
|
|
36
36
|
"type": "string"
|
|
37
37
|
},
|
|
38
|
+
"type": {
|
|
39
|
+
"type": "object",
|
|
40
|
+
"properties": {}
|
|
41
|
+
},
|
|
42
|
+
"originalCredential": {
|
|
43
|
+
"type": "string"
|
|
44
|
+
},
|
|
45
|
+
"credentialHash": {
|
|
46
|
+
"type": "string"
|
|
47
|
+
},
|
|
48
|
+
"parentCredentialHash": {
|
|
49
|
+
"type": "string"
|
|
50
|
+
},
|
|
51
|
+
"credentialType": {
|
|
52
|
+
"type": "object",
|
|
53
|
+
"properties": {}
|
|
54
|
+
},
|
|
55
|
+
"sharePurpose": {
|
|
56
|
+
"type": "string"
|
|
57
|
+
},
|
|
38
58
|
"system": {
|
|
39
59
|
"type": "object",
|
|
40
60
|
"properties": {}
|
|
@@ -88,12 +108,31 @@
|
|
|
88
108
|
"data": {}
|
|
89
109
|
}
|
|
90
110
|
},
|
|
91
|
-
"
|
|
111
|
+
"ActivityLoggingEvent": {
|
|
92
112
|
"type": "object",
|
|
93
113
|
"properties": {
|
|
94
114
|
"id": {
|
|
95
115
|
"type": "string"
|
|
96
116
|
},
|
|
117
|
+
"type": {
|
|
118
|
+
"type": "string",
|
|
119
|
+
"const": "activity"
|
|
120
|
+
},
|
|
121
|
+
"originalCredential": {
|
|
122
|
+
"type": "string"
|
|
123
|
+
},
|
|
124
|
+
"credentialHash": {
|
|
125
|
+
"type": "string"
|
|
126
|
+
},
|
|
127
|
+
"parentCredentialHash": {
|
|
128
|
+
"type": "string"
|
|
129
|
+
},
|
|
130
|
+
"credentialType": {
|
|
131
|
+
"$ref": "#/components/schemas/CredentialType"
|
|
132
|
+
},
|
|
133
|
+
"sharePurpose": {
|
|
134
|
+
"type": "string"
|
|
135
|
+
},
|
|
97
136
|
"correlationId": {
|
|
98
137
|
"type": "string"
|
|
99
138
|
},
|
|
@@ -153,7 +192,17 @@
|
|
|
153
192
|
"level",
|
|
154
193
|
"subSystemType",
|
|
155
194
|
"system",
|
|
156
|
-
"timestamp"
|
|
195
|
+
"timestamp",
|
|
196
|
+
"type"
|
|
197
|
+
]
|
|
198
|
+
},
|
|
199
|
+
"CredentialType": {
|
|
200
|
+
"type": "string",
|
|
201
|
+
"enum": [
|
|
202
|
+
"JSON_LD",
|
|
203
|
+
"JWT",
|
|
204
|
+
"SD_JWT",
|
|
205
|
+
"MSO_MDOC"
|
|
157
206
|
]
|
|
158
207
|
},
|
|
159
208
|
"System": {
|
|
@@ -221,7 +270,10 @@
|
|
|
221
270
|
"DID resolution",
|
|
222
271
|
"DID service update",
|
|
223
272
|
"VC issue",
|
|
224
|
-
"VC verify"
|
|
273
|
+
"VC verify",
|
|
274
|
+
"VC share",
|
|
275
|
+
"VC delete",
|
|
276
|
+
"VC decline"
|
|
225
277
|
]
|
|
226
278
|
},
|
|
227
279
|
"InitiatorType": {
|
|
@@ -263,17 +315,190 @@
|
|
|
263
315
|
4
|
|
264
316
|
]
|
|
265
317
|
},
|
|
266
|
-
"
|
|
318
|
+
"GetAuditEventsArgs": {
|
|
319
|
+
"type": "object",
|
|
320
|
+
"properties": {
|
|
321
|
+
"filter": {
|
|
322
|
+
"$ref": "#/components/schemas/FindAuditLoggingEventArgs"
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
"FindAuditLoggingEventArgs": {
|
|
327
|
+
"type": "array",
|
|
328
|
+
"items": {
|
|
329
|
+
"$ref": "#/components/schemas/PartialAuditLoggingEvent"
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
"PartialAuditLoggingEvent": {
|
|
333
|
+
"type": "object",
|
|
334
|
+
"properties": {
|
|
335
|
+
"level": {
|
|
336
|
+
"type": "object",
|
|
337
|
+
"properties": {}
|
|
338
|
+
},
|
|
339
|
+
"correlationId": {
|
|
340
|
+
"type": "string"
|
|
341
|
+
},
|
|
342
|
+
"timestamp": {
|
|
343
|
+
"type": "object",
|
|
344
|
+
"properties": {},
|
|
345
|
+
"format": "date-time"
|
|
346
|
+
},
|
|
347
|
+
"diagnosticData": {},
|
|
348
|
+
"id": {
|
|
349
|
+
"type": "string"
|
|
350
|
+
},
|
|
351
|
+
"type": {
|
|
352
|
+
"type": "object",
|
|
353
|
+
"properties": {}
|
|
354
|
+
},
|
|
355
|
+
"system": {
|
|
356
|
+
"type": "object",
|
|
357
|
+
"properties": {}
|
|
358
|
+
},
|
|
359
|
+
"subSystemType": {
|
|
360
|
+
"type": "object",
|
|
361
|
+
"properties": {}
|
|
362
|
+
},
|
|
363
|
+
"actionType": {
|
|
364
|
+
"type": "object",
|
|
365
|
+
"properties": {}
|
|
366
|
+
},
|
|
367
|
+
"actionSubType": {
|
|
368
|
+
"anyOf": [
|
|
369
|
+
{
|
|
370
|
+
"type": "object",
|
|
371
|
+
"properties": {}
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
"type": "string"
|
|
375
|
+
}
|
|
376
|
+
]
|
|
377
|
+
},
|
|
378
|
+
"initiatorType": {
|
|
379
|
+
"type": "object",
|
|
380
|
+
"properties": {}
|
|
381
|
+
},
|
|
382
|
+
"systemCorrelationIdType": {
|
|
383
|
+
"type": "object",
|
|
384
|
+
"properties": {}
|
|
385
|
+
},
|
|
386
|
+
"systemCorrelationId": {
|
|
387
|
+
"type": "string"
|
|
388
|
+
},
|
|
389
|
+
"systemAlias": {
|
|
390
|
+
"type": "string"
|
|
391
|
+
},
|
|
392
|
+
"partyCorrelationType": {
|
|
393
|
+
"type": "object",
|
|
394
|
+
"properties": {}
|
|
395
|
+
},
|
|
396
|
+
"partyCorrelationId": {
|
|
397
|
+
"type": "string"
|
|
398
|
+
},
|
|
399
|
+
"partyAlias": {
|
|
400
|
+
"type": "string"
|
|
401
|
+
},
|
|
402
|
+
"description": {
|
|
403
|
+
"type": "string"
|
|
404
|
+
},
|
|
405
|
+
"data": {}
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
"AuditLoggingEvent": {
|
|
409
|
+
"type": "object",
|
|
410
|
+
"properties": {
|
|
411
|
+
"id": {
|
|
412
|
+
"type": "string"
|
|
413
|
+
},
|
|
414
|
+
"type": {
|
|
415
|
+
"type": "string",
|
|
416
|
+
"const": "audit"
|
|
417
|
+
},
|
|
418
|
+
"correlationId": {
|
|
419
|
+
"type": "string"
|
|
420
|
+
},
|
|
421
|
+
"system": {
|
|
422
|
+
"$ref": "#/components/schemas/System"
|
|
423
|
+
},
|
|
424
|
+
"subSystemType": {
|
|
425
|
+
"$ref": "#/components/schemas/SubSystem"
|
|
426
|
+
},
|
|
427
|
+
"actionType": {
|
|
428
|
+
"$ref": "#/components/schemas/ActionType"
|
|
429
|
+
},
|
|
430
|
+
"actionSubType": {
|
|
431
|
+
"$ref": "#/components/schemas/ActionSubType"
|
|
432
|
+
},
|
|
433
|
+
"initiatorType": {
|
|
434
|
+
"$ref": "#/components/schemas/InitiatorType"
|
|
435
|
+
},
|
|
436
|
+
"systemCorrelationIdType": {
|
|
437
|
+
"$ref": "#/components/schemas/SystemCorrelationIdType"
|
|
438
|
+
},
|
|
439
|
+
"systemCorrelationId": {
|
|
440
|
+
"type": "string"
|
|
441
|
+
},
|
|
442
|
+
"systemAlias": {
|
|
443
|
+
"type": "string"
|
|
444
|
+
},
|
|
445
|
+
"partyCorrelationType": {
|
|
446
|
+
"$ref": "#/components/schemas/PartyCorrelationType"
|
|
447
|
+
},
|
|
448
|
+
"partyCorrelationId": {
|
|
449
|
+
"type": "string"
|
|
450
|
+
},
|
|
451
|
+
"partyAlias": {
|
|
452
|
+
"type": "string"
|
|
453
|
+
},
|
|
454
|
+
"description": {
|
|
455
|
+
"type": "string"
|
|
456
|
+
},
|
|
457
|
+
"data": {},
|
|
458
|
+
"level": {
|
|
459
|
+
"$ref": "#/components/schemas/LogLevel"
|
|
460
|
+
},
|
|
461
|
+
"timestamp": {
|
|
462
|
+
"type": "string",
|
|
463
|
+
"format": "date-time"
|
|
464
|
+
},
|
|
465
|
+
"diagnosticData": {}
|
|
466
|
+
},
|
|
467
|
+
"required": [
|
|
468
|
+
"actionSubType",
|
|
469
|
+
"actionType",
|
|
470
|
+
"correlationId",
|
|
471
|
+
"description",
|
|
472
|
+
"id",
|
|
473
|
+
"initiatorType",
|
|
474
|
+
"level",
|
|
475
|
+
"subSystemType",
|
|
476
|
+
"system",
|
|
477
|
+
"timestamp",
|
|
478
|
+
"type"
|
|
479
|
+
]
|
|
480
|
+
},
|
|
481
|
+
"LogEventArgs": {
|
|
267
482
|
"type": "object",
|
|
268
483
|
"properties": {
|
|
269
484
|
"event": {
|
|
270
|
-
"$ref": "#/components/schemas/
|
|
485
|
+
"$ref": "#/components/schemas/LogEventType"
|
|
271
486
|
}
|
|
272
487
|
},
|
|
273
488
|
"required": [
|
|
274
489
|
"event"
|
|
275
490
|
]
|
|
276
491
|
},
|
|
492
|
+
"LogEventType": {
|
|
493
|
+
"anyOf": [
|
|
494
|
+
{
|
|
495
|
+
"$ref": "#/components/schemas/NonPersistedAuditLoggingEvent"
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
"$ref": "#/components/schemas/NonPersistedActivityLoggingEvent"
|
|
499
|
+
}
|
|
500
|
+
]
|
|
501
|
+
},
|
|
277
502
|
"NonPersistedAuditLoggingEvent": {
|
|
278
503
|
"type": "object",
|
|
279
504
|
"properties": {
|
|
@@ -342,9 +567,106 @@
|
|
|
342
567
|
"subSystemType",
|
|
343
568
|
"system"
|
|
344
569
|
]
|
|
570
|
+
},
|
|
571
|
+
"NonPersistedActivityLoggingEvent": {
|
|
572
|
+
"type": "object",
|
|
573
|
+
"properties": {
|
|
574
|
+
"system": {
|
|
575
|
+
"$ref": "#/components/schemas/System"
|
|
576
|
+
},
|
|
577
|
+
"subSystemType": {
|
|
578
|
+
"$ref": "#/components/schemas/SubSystem"
|
|
579
|
+
},
|
|
580
|
+
"initiatorType": {
|
|
581
|
+
"$ref": "#/components/schemas/InitiatorType"
|
|
582
|
+
},
|
|
583
|
+
"originalCredential": {
|
|
584
|
+
"type": "string"
|
|
585
|
+
},
|
|
586
|
+
"credentialHash": {
|
|
587
|
+
"type": "string"
|
|
588
|
+
},
|
|
589
|
+
"parentCredentialHash": {
|
|
590
|
+
"type": "string"
|
|
591
|
+
},
|
|
592
|
+
"credentialType": {
|
|
593
|
+
"type": "object",
|
|
594
|
+
"properties": {}
|
|
595
|
+
},
|
|
596
|
+
"sharePurpose": {
|
|
597
|
+
"type": "string"
|
|
598
|
+
},
|
|
599
|
+
"data": {},
|
|
600
|
+
"diagnosticData": {},
|
|
601
|
+
"actionType": {
|
|
602
|
+
"type": "object",
|
|
603
|
+
"properties": {}
|
|
604
|
+
},
|
|
605
|
+
"actionSubType": {
|
|
606
|
+
"anyOf": [
|
|
607
|
+
{
|
|
608
|
+
"type": "object",
|
|
609
|
+
"properties": {}
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
"type": "string"
|
|
613
|
+
}
|
|
614
|
+
]
|
|
615
|
+
},
|
|
616
|
+
"systemCorrelationIdType": {
|
|
617
|
+
"type": "object",
|
|
618
|
+
"properties": {}
|
|
619
|
+
},
|
|
620
|
+
"systemCorrelationId": {
|
|
621
|
+
"type": "string"
|
|
622
|
+
},
|
|
623
|
+
"systemAlias": {
|
|
624
|
+
"type": "string"
|
|
625
|
+
},
|
|
626
|
+
"partyCorrelationType": {
|
|
627
|
+
"type": "object",
|
|
628
|
+
"properties": {}
|
|
629
|
+
},
|
|
630
|
+
"partyCorrelationId": {
|
|
631
|
+
"type": "string"
|
|
632
|
+
},
|
|
633
|
+
"partyAlias": {
|
|
634
|
+
"type": "string"
|
|
635
|
+
},
|
|
636
|
+
"description": {
|
|
637
|
+
"type": "string"
|
|
638
|
+
},
|
|
639
|
+
"level": {
|
|
640
|
+
"type": "object",
|
|
641
|
+
"properties": {}
|
|
642
|
+
},
|
|
643
|
+
"correlationId": {
|
|
644
|
+
"type": "string"
|
|
645
|
+
}
|
|
646
|
+
},
|
|
647
|
+
"required": [
|
|
648
|
+
"actionSubType",
|
|
649
|
+
"actionType",
|
|
650
|
+
"description",
|
|
651
|
+
"initiatorType",
|
|
652
|
+
"subSystemType",
|
|
653
|
+
"system"
|
|
654
|
+
]
|
|
345
655
|
}
|
|
346
656
|
},
|
|
347
657
|
"methods": {
|
|
658
|
+
"loggerGetActivityEvents": {
|
|
659
|
+
"description": "",
|
|
660
|
+
"arguments": {
|
|
661
|
+
"$ref": "#/components/schemas/GetActivityEventsArgs"
|
|
662
|
+
},
|
|
663
|
+
"returnType": {
|
|
664
|
+
"type": "array",
|
|
665
|
+
"items": {
|
|
666
|
+
"$ref": "#/components/schemas/ActivityLoggingEvent"
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
},
|
|
348
670
|
"loggerGetAuditEvents": {
|
|
349
671
|
"description": "",
|
|
350
672
|
"arguments": {
|
|
@@ -357,10 +679,19 @@
|
|
|
357
679
|
}
|
|
358
680
|
}
|
|
359
681
|
},
|
|
682
|
+
"loggerLogActivityEvent": {
|
|
683
|
+
"description": "",
|
|
684
|
+
"arguments": {
|
|
685
|
+
"$ref": "#/components/schemas/LogEventArgs"
|
|
686
|
+
},
|
|
687
|
+
"returnType": {
|
|
688
|
+
"$ref": "#/components/schemas/ActivityLoggingEvent"
|
|
689
|
+
}
|
|
690
|
+
},
|
|
360
691
|
"loggerLogAuditEvent": {
|
|
361
692
|
"description": "",
|
|
362
693
|
"arguments": {
|
|
363
|
-
"$ref": "#/components/schemas/
|
|
694
|
+
"$ref": "#/components/schemas/LogEventArgs"
|
|
364
695
|
},
|
|
365
696
|
"returnType": {
|
|
366
697
|
"$ref": "#/components/schemas/AuditLoggingEvent"
|
|
@@ -369,10 +700,10 @@
|
|
|
369
700
|
"loggerLogGeneralEvent": {
|
|
370
701
|
"description": "",
|
|
371
702
|
"arguments": {
|
|
372
|
-
"$ref": "#/components/schemas/
|
|
703
|
+
"$ref": "#/components/schemas/LogEventArgs"
|
|
373
704
|
},
|
|
374
705
|
"returnType": {
|
|
375
|
-
"$ref": "#/components/schemas/
|
|
706
|
+
"$ref": "#/components/schemas/LogEventType"
|
|
376
707
|
}
|
|
377
708
|
}
|
|
378
709
|
}
|
package/src/agent/EventLogger.ts
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
import { AbstractEventLoggerStore } from '@sphereon/ssi-sdk.data-store'
|
|
2
|
-
import { IAgentPlugin } from '@veramo/core'
|
|
3
2
|
import { Loggers, LoggingEventType, LogLevel, LogMethod } from '@sphereon/ssi-types'
|
|
4
|
-
import { AuditLoggingEvent } from '@sphereon/ssi-sdk.core'
|
|
3
|
+
import { ActivityLoggingEvent, AuditLoggingEvent } from '@sphereon/ssi-sdk.core'
|
|
4
|
+
import { IAgentPlugin } from '@veramo/core'
|
|
5
5
|
import { v4 as uuidv4 } from 'uuid'
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { schema } from '../index'
|
|
7
|
+
import {
|
|
8
|
+
EventLoggerOptions,
|
|
9
|
+
GetActivityEventsArgs,
|
|
10
|
+
GetAuditEventsArgs,
|
|
11
|
+
IEventLogger,
|
|
12
|
+
LogActivityEventArgs,
|
|
13
|
+
LogAuditEventArgs,
|
|
14
|
+
LogEventArgs,
|
|
15
|
+
LoggingEvent,
|
|
16
|
+
LogEventType,
|
|
17
|
+
RequiredContext,
|
|
18
|
+
} from '../types/IEventLogger'
|
|
8
19
|
|
|
9
20
|
/**
|
|
10
21
|
* {@inheritDoc IEventLogger}
|
|
11
22
|
*/
|
|
12
23
|
|
|
13
24
|
// Exposing the methods here for any REST implementation
|
|
14
|
-
export const eventLoggerAuditMethods: Array<string> = [
|
|
25
|
+
export const eventLoggerAuditMethods: Array<string> = [
|
|
26
|
+
'loggerGetAuditEvents',
|
|
27
|
+
'loggerLogAuditEvent',
|
|
28
|
+
'loggerLogGeneralEvent',
|
|
29
|
+
'loggerLogActivityEvent',
|
|
30
|
+
'loggerGetActivityEvents',
|
|
31
|
+
]
|
|
15
32
|
export const eventLoggerMethods: Array<string> = [...eventLoggerAuditMethods]
|
|
16
33
|
|
|
17
34
|
export class EventLogger implements IAgentPlugin {
|
|
@@ -24,6 +41,8 @@ export class EventLogger implements IAgentPlugin {
|
|
|
24
41
|
loggerGetAuditEvents: this.loggerGetAuditEvents.bind(this),
|
|
25
42
|
loggerLogAuditEvent: this.loggerLogAuditEvent.bind(this),
|
|
26
43
|
loggerLogGeneralEvent: this.loggerLogGeneralEvent.bind(this),
|
|
44
|
+
loggerLogActivityEvent: this.loggerLogActivityEvent.bind(this),
|
|
45
|
+
loggerGetActivityEvents: this.loggerGetActivityEvents.bind(this),
|
|
27
46
|
}
|
|
28
47
|
|
|
29
48
|
constructor(options: EventLoggerOptions) {
|
|
@@ -60,6 +79,10 @@ export class EventLogger implements IAgentPlugin {
|
|
|
60
79
|
// TODO: We might also want to do this locally though, as these logs are not persisted typically
|
|
61
80
|
await context.agent.loggerLogGeneralEvent({ event: event.data })
|
|
62
81
|
break
|
|
82
|
+
case LoggingEventType.ACTIVITY:
|
|
83
|
+
// Calling the context of the agent to make sure the REST client is called when configured
|
|
84
|
+
await context.agent.loggerLogActivityEvent({ event: event.data })
|
|
85
|
+
break
|
|
63
86
|
default:
|
|
64
87
|
return Promise.reject(Error(`Event type ${event.type} not supported`))
|
|
65
88
|
}
|
|
@@ -75,9 +98,20 @@ export class EventLogger implements IAgentPlugin {
|
|
|
75
98
|
return this.store.getAuditEvents({ filter })
|
|
76
99
|
}
|
|
77
100
|
|
|
78
|
-
private async
|
|
101
|
+
private async loggerGetActivityEvents(args?: GetActivityEventsArgs): Promise<Array<ActivityLoggingEvent>> {
|
|
102
|
+
const { filter } = args ?? {}
|
|
103
|
+
|
|
104
|
+
if (!this.store) {
|
|
105
|
+
return Promise.reject(Error('No store available in options'))
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return this.store.getActivityEvents({ filter })
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
private async loggerLogGeneralEvent(args: LogEventArgs): Promise<LogEventType> {
|
|
79
112
|
const { event } = args
|
|
80
113
|
this.simpleLoggers.get(event.data.system).logl(event.data.level ?? LogLevel.INFO, event.data.data, event.data)
|
|
114
|
+
|
|
81
115
|
return args.event
|
|
82
116
|
}
|
|
83
117
|
|
|
@@ -100,4 +134,24 @@ export class EventLogger implements IAgentPlugin {
|
|
|
100
134
|
},
|
|
101
135
|
})
|
|
102
136
|
}
|
|
137
|
+
|
|
138
|
+
private async loggerLogActivityEvent(args: LogActivityEventArgs): Promise<ActivityLoggingEvent> {
|
|
139
|
+
const { event } = args
|
|
140
|
+
|
|
141
|
+
if (!this.store) {
|
|
142
|
+
return Promise.reject(Error('No store available in options'))
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return this.store.storeActivityEvent({
|
|
146
|
+
event: {
|
|
147
|
+
...event,
|
|
148
|
+
system: event.system,
|
|
149
|
+
subSystemType: event.subSystemType,
|
|
150
|
+
initiatorType: event.initiatorType,
|
|
151
|
+
level: event.level ?? LogLevel.INFO,
|
|
152
|
+
correlationId: event.correlationId ?? uuidv4(),
|
|
153
|
+
timestamp: new Date(),
|
|
154
|
+
},
|
|
155
|
+
})
|
|
156
|
+
}
|
|
103
157
|
}
|
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
InitiatorType,
|
|
3
|
+
LoggingEventType,
|
|
4
|
+
LogLevel,
|
|
5
|
+
SubSystem,
|
|
6
|
+
System
|
|
7
|
+
} from '@sphereon/ssi-types'
|
|
8
|
+
import {
|
|
9
|
+
AuditLoggingEvent,
|
|
10
|
+
CredentialType,
|
|
11
|
+
NonPersistedAuditLoggingEvent as NPAuditLoggingEvent,
|
|
12
|
+
NonPersistedActivityLoggingEvent as NPActivityLoggingEvent,
|
|
13
|
+
ActivityLoggingEvent,
|
|
14
|
+
} from '@sphereon/ssi-sdk.core'
|
|
15
|
+
import { AbstractEventLoggerStore, FindActivityLoggingEventArgs, FindAuditLoggingEventArgs } from '@sphereon/ssi-sdk.data-store'
|
|
2
16
|
import { IAgentContext, IPluginMethodMap } from '@veramo/core'
|
|
3
|
-
import { AuditLoggingEvent, NonPersistedAuditLoggingEvent as NPAuditLoggingEvent } from '@sphereon/ssi-sdk.core'
|
|
4
|
-
import { AbstractEventLoggerStore, FindAuditLoggingEventArgs } from '@sphereon/ssi-sdk.data-store'
|
|
5
17
|
|
|
6
18
|
export interface IEventLogger extends IPluginMethodMap {
|
|
7
19
|
loggerGetAuditEvents(args?: GetAuditEventsArgs): Promise<Array<AuditLoggingEvent>>
|
|
8
|
-
loggerLogAuditEvent(args:
|
|
9
|
-
loggerLogGeneralEvent(args:
|
|
20
|
+
loggerLogAuditEvent(args: LogEventArgs, context: RequiredContext): Promise<AuditLoggingEvent>
|
|
21
|
+
loggerLogGeneralEvent(args: LogEventArgs, context: RequiredContext): Promise<LogEventType>
|
|
22
|
+
loggerLogActivityEvent(args: LogEventArgs, context: RequiredContext): Promise<ActivityLoggingEvent>
|
|
23
|
+
loggerGetActivityEvents(args?: GetActivityEventsArgs): Promise<Array<ActivityLoggingEvent>>
|
|
10
24
|
}
|
|
11
25
|
|
|
12
26
|
export interface EventLoggerGeneralLogOpts {
|
|
@@ -27,19 +41,45 @@ export type GetAuditEventsArgs = {
|
|
|
27
41
|
filter?: FindAuditLoggingEventArgs
|
|
28
42
|
}
|
|
29
43
|
|
|
44
|
+
export type GetActivityEventsArgs = {
|
|
45
|
+
filter?: FindActivityLoggingEventArgs
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type LogEventArgs = {
|
|
49
|
+
event: LogEventType
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type LogEventType = NonPersistedAuditLoggingEvent | NonPersistedActivityLoggingEvent
|
|
53
|
+
|
|
30
54
|
export type LogAuditEventArgs = {
|
|
31
55
|
event: NonPersistedAuditLoggingEvent
|
|
32
56
|
}
|
|
33
57
|
|
|
58
|
+
export type LogActivityEventArgs = {
|
|
59
|
+
event: NonPersistedActivityLoggingEvent
|
|
60
|
+
}
|
|
61
|
+
|
|
34
62
|
export type NonPersistedAuditLoggingEvent = Omit<NPAuditLoggingEvent, 'system' | 'subSystemType' | 'initiatorType'> & {
|
|
35
63
|
system: System
|
|
36
64
|
subSystemType: SubSystem
|
|
37
65
|
initiatorType: InitiatorType
|
|
38
66
|
}
|
|
39
67
|
|
|
68
|
+
export type NonPersistedActivityLoggingEvent = Omit<NPActivityLoggingEvent, 'system' | 'subSystemType' | 'initiatorType'> & {
|
|
69
|
+
system: System
|
|
70
|
+
subSystemType: SubSystem
|
|
71
|
+
initiatorType: InitiatorType
|
|
72
|
+
originalCredential?: string
|
|
73
|
+
credentialHash?: string
|
|
74
|
+
parentCredentialHash?: string
|
|
75
|
+
credentialType?: CredentialType
|
|
76
|
+
sharePurpose?: string
|
|
77
|
+
data?: any
|
|
78
|
+
}
|
|
79
|
+
|
|
40
80
|
export type LoggingEvent = {
|
|
41
81
|
type: LoggingEventType
|
|
42
|
-
data:
|
|
82
|
+
data: LogEventType
|
|
43
83
|
}
|
|
44
84
|
|
|
45
85
|
export type RequiredContext = IAgentContext<IEventLogger>
|