@sphereon/ssi-sdk.event-logger 0.17.6-next.52
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/LICENSE +201 -0
- package/README.md +193 -0
- package/dist/agent/EventLogger.d.ts +17 -0
- package/dist/agent/EventLogger.d.ts.map +1 -0
- package/dist/agent/EventLogger.js +58 -0
- package/dist/agent/EventLogger.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/ssi-sdk.event-logger.d.ts +61 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/types/IEventLogger.d.ts +27 -0
- package/dist/types/IEventLogger.d.ts.map +1 -0
- package/dist/types/IEventLogger.js +3 -0
- package/dist/types/IEventLogger.js.map +1 -0
- package/package.json +56 -0
- package/plugin.schema.json +350 -0
- package/src/agent/EventLogger.ts +66 -0
- package/src/index.ts +7 -0
- package/src/types/IEventLogger.ts +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [2023] [Sphereon BV]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
<!--suppress HtmlDeprecatedAttribute -->
|
|
2
|
+
<h1 align="center">
|
|
3
|
+
<br>
|
|
4
|
+
<a href="https://www.sphereon.com"><img src="https://sphereon.com/content/themes/sphereon/assets/img/logo.svg" alt="Sphereon" width="400"></a>
|
|
5
|
+
<br>Event Logger (Typescript)
|
|
6
|
+
<br>
|
|
7
|
+
</h1>
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
**Warning: This package still is in very early development. Breaking changes without notice will happen at this point!**
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
A Veramo event logger plugin. This plugin allows for listening to events and to persist them into a database.
|
|
16
|
+
There are also functions that can be manually called to persist events. Current, only audit events are supported that can be used to create an audit log.
|
|
17
|
+
|
|
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
|
+
This is mainly as a fallback for when no listener is present within the agent.
|
|
20
|
+
|
|
21
|
+
## Available functions
|
|
22
|
+
- loggerGetAuditEvents
|
|
23
|
+
- loggerStoreAuditEvent
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Adding the plugin to an agent:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { migrations, Entities } from '@veramo/data-store'
|
|
31
|
+
import { EventLogger, IEventLogger } from '@sphereon/ssi-sdk.event-logger'
|
|
32
|
+
import {
|
|
33
|
+
EventLoggerStore,
|
|
34
|
+
DataStoreMigrations,
|
|
35
|
+
DataStoreEventLoggerEntities,
|
|
36
|
+
LoggingEventType
|
|
37
|
+
} from '@sphereon/ssi-sdk.data-store'
|
|
38
|
+
|
|
39
|
+
const dbConnection = createConnection({
|
|
40
|
+
type: 'react-native',
|
|
41
|
+
database: 'app.sqlite',
|
|
42
|
+
location: 'default',
|
|
43
|
+
logging: false,
|
|
44
|
+
synchronize: false,
|
|
45
|
+
migrationsRun: true,
|
|
46
|
+
migrations: [...DataStoreMigrations, ...migrations],
|
|
47
|
+
entities: [...DataStoreEventLoggerEntities, ...Entities],
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
const agent = createAgent<IEventLogger>({
|
|
51
|
+
plugins: [
|
|
52
|
+
new EventLogger({
|
|
53
|
+
eventTypes: [LoggingEventType.AUDIT],
|
|
54
|
+
store: new EventLoggerStore(dbConnection),
|
|
55
|
+
}),
|
|
56
|
+
],
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Log event using event listener:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import {
|
|
64
|
+
EventLogger,
|
|
65
|
+
EventLoggerBuilder,
|
|
66
|
+
LoggingEventType ,
|
|
67
|
+
LogLevel,
|
|
68
|
+
System,
|
|
69
|
+
SubSystem,
|
|
70
|
+
ActionType,
|
|
71
|
+
InitiatorType,
|
|
72
|
+
SystemCorrelationIdType,
|
|
73
|
+
PartyCorrelationType
|
|
74
|
+
} from '@sphereon/ssi-sdk.core';
|
|
75
|
+
|
|
76
|
+
const agentContext = { agent }
|
|
77
|
+
const logger: EventLogger = new EventLoggerBuilder()
|
|
78
|
+
.withContext(agentContext)
|
|
79
|
+
.withNamespace('custom_namespace')
|
|
80
|
+
.build()
|
|
81
|
+
|
|
82
|
+
await logger.logEvent({
|
|
83
|
+
type: LoggingEventType.AUDIT,
|
|
84
|
+
data: {
|
|
85
|
+
level: LogLevel.DEBUG,
|
|
86
|
+
correlationId: 'b40b8474-58a2-4b23-9fde-bd6ee1902cdb',
|
|
87
|
+
system: System.GENERAL,
|
|
88
|
+
subSystemType: SubSystem.DID_PROVIDER,
|
|
89
|
+
actionType: ActionType.CREATE,
|
|
90
|
+
actionSubType: 'Key generation',
|
|
91
|
+
initiatorType: InitiatorType.EXTERNAL,
|
|
92
|
+
systemCorrelationIdType: SystemCorrelationIdType.DID,
|
|
93
|
+
systemCorrelationId: 'did:example:123456789abcdefghi',
|
|
94
|
+
systemAlias: 'test_alias',
|
|
95
|
+
partyCorrelationType: PartyCorrelationType.DID,
|
|
96
|
+
partyCorrelationId: 'did:example:123456789abcdefghi',
|
|
97
|
+
partyAlias: 'test_alias',
|
|
98
|
+
description: 'test_description',
|
|
99
|
+
data: 'test_data_string',
|
|
100
|
+
diagnosticData: { data: 'test_data_string'}
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Log event manually:
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
import {
|
|
109
|
+
AuditLoggingEvent,
|
|
110
|
+
LogLevel,
|
|
111
|
+
System,
|
|
112
|
+
SubSystem,
|
|
113
|
+
ActionType,
|
|
114
|
+
InitiatorType,
|
|
115
|
+
SystemCorrelationIdType,
|
|
116
|
+
PartyCorrelationType
|
|
117
|
+
} from '@sphereon/ssi-sdk.core'
|
|
118
|
+
import { GetAuditEventsArgs, NonPersistedAuditLoggingEvent } from '@sphereon/ssi-sdk.event-logger'
|
|
119
|
+
|
|
120
|
+
const auditEvent: NonPersistedAuditLoggingEvent = {
|
|
121
|
+
level: LogLevel.DEBUG,
|
|
122
|
+
correlationId: 'b40b8474-58a2-4b23-9fde-bd6ee1902cdb',
|
|
123
|
+
system: System.GENERAL,
|
|
124
|
+
subSystemType: SubSystem.DID_PROVIDER,
|
|
125
|
+
actionType: ActionType.CREATE,
|
|
126
|
+
actionSubType: 'Key generation',
|
|
127
|
+
initiatorType: InitiatorType.EXTERNAL,
|
|
128
|
+
systemCorrelationIdType: SystemCorrelationIdType.DID,
|
|
129
|
+
systemCorrelationId: 'did:example:123456789abcdefghi',
|
|
130
|
+
systemAlias: 'test_alias',
|
|
131
|
+
partyCorrelationType: PartyCorrelationType.DID,
|
|
132
|
+
partyCorrelationId: 'did:example:123456789abcdefghi',
|
|
133
|
+
partyAlias: 'test_alias',
|
|
134
|
+
description: 'test_description',
|
|
135
|
+
data: 'test_data_string',
|
|
136
|
+
diagnosticData: { data: 'test_data_string'}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const result: AuditLoggingEvent = await agent.loggerLogAuditEvent({event: auditEvent})
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Retrieve audit events:
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
import {
|
|
146
|
+
AuditLoggingEvent,
|
|
147
|
+
LogLevel,
|
|
148
|
+
System,
|
|
149
|
+
SubSystem,
|
|
150
|
+
ActionType,
|
|
151
|
+
InitiatorType,
|
|
152
|
+
SystemCorrelationIdType,
|
|
153
|
+
PartyCorrelationType
|
|
154
|
+
} from '@sphereon/ssi-sdk.core'
|
|
155
|
+
import { GetAuditEventsArgs, NonPersistedAuditLoggingEvent } from '@sphereon/ssi-sdk.event-logger'
|
|
156
|
+
|
|
157
|
+
const auditEvent: NonPersistedAuditLoggingEvent = {
|
|
158
|
+
level: LogLevel.DEBUG,
|
|
159
|
+
correlationId: 'b40b8474-58a2-4b23-9fde-bd6ee1902cdb',
|
|
160
|
+
system: System.GENERAL,
|
|
161
|
+
subSystemType: SubSystem.DID_PROVIDER,
|
|
162
|
+
actionType: ActionType.CREATE,
|
|
163
|
+
actionSubType: 'Key generation',
|
|
164
|
+
initiatorType: InitiatorType.EXTERNAL,
|
|
165
|
+
systemCorrelationIdType: SystemCorrelationIdType.DID,
|
|
166
|
+
systemCorrelationId: 'did:example:123456789abcdefghi',
|
|
167
|
+
systemAlias: 'test_alias',
|
|
168
|
+
partyCorrelationType: PartyCorrelationType.DID,
|
|
169
|
+
partyCorrelationId: 'did:example:123456789abcdefghi',
|
|
170
|
+
partyAlias: 'test_alias',
|
|
171
|
+
description: 'test_description',
|
|
172
|
+
data: 'test_data_string',
|
|
173
|
+
diagnosticData: { data: 'test_data_string'}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
await agent.loggerLogAuditEvent({event: auditEvent})
|
|
177
|
+
const getAuditEventArgs: GetAuditEventsArgs = {
|
|
178
|
+
filter: [{ correlationId: auditEvent.correlationId }],
|
|
179
|
+
}
|
|
180
|
+
const result: Array<AuditLoggingEvent> = await agent.loggerGetAuditEvents(getAuditEventArgs)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Installation
|
|
184
|
+
|
|
185
|
+
```shell
|
|
186
|
+
yarn add @sphereon/ssi-sdk.event-logger
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## Build
|
|
190
|
+
|
|
191
|
+
```shell
|
|
192
|
+
yarn build
|
|
193
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IAgentPlugin } from '@veramo/core';
|
|
2
|
+
import { LoggingEventType } from '@sphereon/ssi-sdk.core';
|
|
3
|
+
import { EventLoggerOptions, IEventLogger, RequiredContext, LoggingEvent } from '../types/IEventLogger';
|
|
4
|
+
/**
|
|
5
|
+
* {@inheritDoc IEventLogger}
|
|
6
|
+
*/
|
|
7
|
+
export declare class EventLogger implements IAgentPlugin {
|
|
8
|
+
readonly schema: any;
|
|
9
|
+
readonly eventTypes: Array<LoggingEventType>;
|
|
10
|
+
readonly methods: IEventLogger;
|
|
11
|
+
private readonly store;
|
|
12
|
+
constructor(options: EventLoggerOptions);
|
|
13
|
+
onEvent(event: LoggingEvent, context: RequiredContext): Promise<void>;
|
|
14
|
+
private loggerGetAuditEvents;
|
|
15
|
+
private loggerLogAuditEvent;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=EventLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventLogger.d.ts","sourceRoot":"","sources":["../../src/agent/EventLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAAqB,gBAAgB,EAAY,MAAM,wBAAwB,CAAA;AAGtF,OAAO,EACL,kBAAkB,EAElB,YAAY,EACZ,eAAe,EAEf,YAAY,EACb,MAAM,uBAAuB,CAAA;AAE9B;;GAEG;AAEH,qBAAa,WAAY,YAAW,YAAY;IAC9C,QAAQ,CAAC,MAAM,MAAsB;IACrC,QAAQ,CAAC,UAAU,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAK;IAEjD,QAAQ,CAAC,OAAO,EAAE,YAAY,CAG7B;IAED,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA0B;gBAEpC,OAAO,EAAE,kBAAkB;IAM1B,OAAO,CAAC,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;YAUpE,oBAAoB;YAMpB,mBAAmB;CAclC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.EventLogger = void 0;
|
|
13
|
+
const ssi_sdk_core_1 = require("@sphereon/ssi-sdk.core");
|
|
14
|
+
const uuid_1 = require("uuid");
|
|
15
|
+
const index_1 = require("../index");
|
|
16
|
+
/**
|
|
17
|
+
* {@inheritDoc IEventLogger}
|
|
18
|
+
*/
|
|
19
|
+
class EventLogger {
|
|
20
|
+
constructor(options) {
|
|
21
|
+
this.schema = index_1.schema.IEventLogger;
|
|
22
|
+
this.eventTypes = [];
|
|
23
|
+
this.methods = {
|
|
24
|
+
loggerGetAuditEvents: this.loggerGetAuditEvents.bind(this),
|
|
25
|
+
loggerLogAuditEvent: this.loggerLogAuditEvent.bind(this),
|
|
26
|
+
};
|
|
27
|
+
const { store, eventTypes } = options;
|
|
28
|
+
this.store = store;
|
|
29
|
+
this.eventTypes = eventTypes;
|
|
30
|
+
}
|
|
31
|
+
onEvent(event, context) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
switch (event.type) {
|
|
34
|
+
case ssi_sdk_core_1.LoggingEventType.AUDIT:
|
|
35
|
+
yield this.loggerLogAuditEvent({ event: event.data }, context);
|
|
36
|
+
break;
|
|
37
|
+
default:
|
|
38
|
+
return Promise.reject(Error('Event type not supported'));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
loggerGetAuditEvents(args) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const { filter } = args !== null && args !== void 0 ? args : {};
|
|
45
|
+
return this.store.getAuditEvents({ filter });
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
loggerLogAuditEvent(args, context) {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const { event } = args;
|
|
52
|
+
return this.store.storeAuditEvent({ event: Object.assign(Object.assign({}, event), { system: event.system, subSystemType: event.subSystemType, level: (_a = event.level) !== null && _a !== void 0 ? _a : ssi_sdk_core_1.LogLevel.INFO, correlationId: (_b = event.correlationId) !== null && _b !== void 0 ? _b : (0, uuid_1.v4)(), timestamp: new Date() })
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.EventLogger = EventLogger;
|
|
58
|
+
//# sourceMappingURL=EventLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventLogger.js","sourceRoot":"","sources":["../../src/agent/EventLogger.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,yDAAsF;AACtF,+BAAmC;AACnC,oCAAiC;AAUjC;;GAEG;AAEH,MAAa,WAAW;IAWtB,YAAY,OAA2B;QAV9B,WAAM,GAAG,cAAM,CAAC,YAAY,CAAA;QAC5B,eAAU,GAA4B,EAAE,CAAA;QAExC,YAAO,GAAiB;YAC/B,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC;YAC1D,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC;SACzD,CAAA;QAKC,MAAM,EAAC,KAAK,EAAE,UAAU,EAAC,GAAG,OAAO,CAAA;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAEY,OAAO,CAAC,KAAmB,EAAE,OAAwB;;YAChE,QAAO,KAAK,CAAC,IAAI,EAAE;gBACjB,KAAK,+BAAgB,CAAC,KAAK;oBACzB,MAAM,IAAI,CAAC,mBAAmB,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAA;oBAC9D,MAAM;gBACR;oBACE,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC,CAAA;aAC3D;QACH,CAAC;KAAA;IAEa,oBAAoB,CAAC,IAAyB;;YAC1D,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAA;YAE7B,OAAO,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;QAC9C,CAAC;KAAA;IAEa,mBAAmB,CAAC,IAAuB,EAAE,OAAwB;;;YACjF,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;YAEtB,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,EAAE,KAAK,kCAClC,KAAK,KACR,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,aAAa,EAAE,KAAK,CAAC,aAAa,EAClC,KAAK,EAAE,MAAA,KAAK,CAAC,KAAK,mCAAI,uBAAQ,CAAC,IAAI,EACnC,aAAa,EAAE,MAAA,KAAK,CAAC,aAAa,mCAAI,IAAA,SAAM,GAAE,EAC9C,SAAS,EAAE,IAAI,IAAI,EAAE,GACtB;aACF,CAAC,CAAA;;KACH;CAEF;AA/CD,kCA+CC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,QAAA,MAAM,MAAM,KAAmC,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,cAAc,sBAAsB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
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
|
+
__exportStar(require("./types/IEventLogger"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,MAAM,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;AACtC,wBAAM;AACf,mDAAiD;AAAxC,0GAAA,WAAW,OAAA;AACpB,uDAAoC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { AbstractEventLoggerStore } from '@sphereon/ssi-sdk.data-store';
|
|
2
|
+
import { AuditLoggingEvent } from '@sphereon/ssi-sdk.core';
|
|
3
|
+
import { FindAuditLoggingEventArgs } from '@sphereon/ssi-sdk.data-store';
|
|
4
|
+
import { IAgentContext } from '@veramo/core';
|
|
5
|
+
import { IAgentPlugin } from '@veramo/core';
|
|
6
|
+
import { IPluginMethodMap } from '@veramo/core';
|
|
7
|
+
import { LoggingEventType } from '@sphereon/ssi-sdk.core';
|
|
8
|
+
import { NonPersistedAuditLoggingEvent as NonPersistedAuditLoggingEvent_2 } from '@sphereon/ssi-sdk.core';
|
|
9
|
+
import { SubSystem } from '@sphereon/ssi-sdk.core';
|
|
10
|
+
import { System } from '@sphereon/ssi-sdk.core';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* {@inheritDoc IEventLogger}
|
|
14
|
+
*/
|
|
15
|
+
export declare class EventLogger implements IAgentPlugin {
|
|
16
|
+
readonly schema: any;
|
|
17
|
+
readonly eventTypes: Array<LoggingEventType>;
|
|
18
|
+
readonly methods: IEventLogger;
|
|
19
|
+
private readonly store;
|
|
20
|
+
constructor(options: EventLoggerOptions);
|
|
21
|
+
onEvent(event: LoggingEvent, context: RequiredContext): Promise<void>;
|
|
22
|
+
private loggerGetAuditEvents;
|
|
23
|
+
private loggerLogAuditEvent;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export declare type EventLoggerOptions = {
|
|
27
|
+
store: AbstractEventLoggerStore;
|
|
28
|
+
eventTypes: Array<LoggingEventType>;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export declare type GetAuditEventsArgs = {
|
|
32
|
+
filter?: FindAuditLoggingEventArgs;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export declare interface IEventLogger extends IPluginMethodMap {
|
|
36
|
+
loggerGetAuditEvents(args?: GetAuditEventsArgs): Promise<Array<AuditLoggingEvent>>;
|
|
37
|
+
loggerLogAuditEvent(args: LogAuditEventArgs, context: RequiredContext): Promise<AuditLoggingEvent>;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export declare type LogAuditEventArgs = {
|
|
41
|
+
event: NonPersistedAuditLoggingEvent;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export declare type LoggingEvent = {
|
|
45
|
+
type: LoggingEventType;
|
|
46
|
+
data: NonPersistedAuditLoggingEvent;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export declare type NonPersistedAuditLoggingEvent = Omit<NonPersistedAuditLoggingEvent_2, 'system' | 'subSystemType'> & {
|
|
50
|
+
system: System;
|
|
51
|
+
subSystemType: SubSystem;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export declare type RequiredContext = IAgentContext<never>;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
export declare const schema: any;
|
|
60
|
+
|
|
61
|
+
export { }
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.37.1"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { IAgentContext, IPluginMethodMap } from '@veramo/core';
|
|
2
|
+
import { AuditLoggingEvent, NonPersistedAuditLoggingEvent as NPAuditLoggingEvent, LoggingEventType, SubSystem, System } from '@sphereon/ssi-sdk.core';
|
|
3
|
+
import { AbstractEventLoggerStore, FindAuditLoggingEventArgs } from '@sphereon/ssi-sdk.data-store';
|
|
4
|
+
export interface IEventLogger extends IPluginMethodMap {
|
|
5
|
+
loggerGetAuditEvents(args?: GetAuditEventsArgs): Promise<Array<AuditLoggingEvent>>;
|
|
6
|
+
loggerLogAuditEvent(args: LogAuditEventArgs, context: RequiredContext): Promise<AuditLoggingEvent>;
|
|
7
|
+
}
|
|
8
|
+
export type EventLoggerOptions = {
|
|
9
|
+
store: AbstractEventLoggerStore;
|
|
10
|
+
eventTypes: Array<LoggingEventType>;
|
|
11
|
+
};
|
|
12
|
+
export type GetAuditEventsArgs = {
|
|
13
|
+
filter?: FindAuditLoggingEventArgs;
|
|
14
|
+
};
|
|
15
|
+
export type LogAuditEventArgs = {
|
|
16
|
+
event: NonPersistedAuditLoggingEvent;
|
|
17
|
+
};
|
|
18
|
+
export type NonPersistedAuditLoggingEvent = Omit<NPAuditLoggingEvent, 'system' | 'subSystemType'> & {
|
|
19
|
+
system: System;
|
|
20
|
+
subSystemType: SubSystem;
|
|
21
|
+
};
|
|
22
|
+
export type LoggingEvent = {
|
|
23
|
+
type: LoggingEventType;
|
|
24
|
+
data: NonPersistedAuditLoggingEvent;
|
|
25
|
+
};
|
|
26
|
+
export type RequiredContext = IAgentContext<never>;
|
|
27
|
+
//# sourceMappingURL=IEventLogger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEventLogger.d.ts","sourceRoot":"","sources":["../../src/types/IEventLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,EACL,iBAAiB,EACjB,6BAA6B,IAAI,mBAAmB,EACpD,gBAAgB,EAChB,SAAS,EACT,MAAM,EACP,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AAElG,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,iBAAiB,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;CACnG;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,wBAAwB,CAAA;IAC/B,UAAU,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAA;CACpC,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,CAAC,EAAE,yBAAyB,CAAA;CACnC,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,6BAA6B,CAAA;CACrC,CAAA;AAED,MAAM,MAAM,6BAA6B,GAAG,IAAI,CAAC,mBAAmB,EAAE,QAAQ,GAAG,eAAe,CAAC,GAAG;IAClG,MAAM,EAAE,MAAM,CAAA;IACd,aAAa,EAAE,SAAS,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,gBAAgB,CAAC;IACvB,IAAI,EAAE,6BAA6B,CAAA;CACpC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,aAAa,CAAC,KAAK,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEventLogger.js","sourceRoot":"","sources":["../../src/types/IEventLogger.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sphereon/ssi-sdk.event-logger",
|
|
3
|
+
"version": "0.17.6-next.52+967da967",
|
|
4
|
+
"source": "src/index.ts",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"veramo": {
|
|
8
|
+
"pluginInterfaces": {
|
|
9
|
+
"IEventLogger": "./src/types/IEventLogger.ts"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"build:clean": "tsc --build --clean && tsc --build",
|
|
15
|
+
"generate-plugin-schema": "ts-node ../../packages/dev/bin/sphereon.js dev generate-plugin-schema"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@sphereon/ssi-sdk.data-store": "0.17.6-next.52+967da967",
|
|
19
|
+
"uuid": "^8.3.2"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@sphereon/ssi-sdk.agent-config": "0.17.6-next.52+967da967",
|
|
23
|
+
"@sphereon/ssi-sdk.core": "0.17.6-next.52+967da967",
|
|
24
|
+
"@sphereon/ssi-sdk.data-store": "workspace:*",
|
|
25
|
+
"@types/jest": "^27.5.2",
|
|
26
|
+
"@types/uuid": "^8.3.4",
|
|
27
|
+
"@veramo/remote-client": "4.2.0",
|
|
28
|
+
"@veramo/remote-server": "4.2.0",
|
|
29
|
+
"jest": "^27.5.1",
|
|
30
|
+
"typeorm": "0.3.17",
|
|
31
|
+
"typescript": "^4.9.5"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist/**/*",
|
|
35
|
+
"src/**/*",
|
|
36
|
+
"README.md",
|
|
37
|
+
"plugin.schema.json",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"private": false,
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"repository": "git@github.com:Sphereon-Opensource/SSI-SDK.git",
|
|
45
|
+
"author": "Sphereon <dev@sphereon.com>",
|
|
46
|
+
"license": "Apache-2.0",
|
|
47
|
+
"keywords": [
|
|
48
|
+
"Sphereon",
|
|
49
|
+
"SSI",
|
|
50
|
+
"Veramo",
|
|
51
|
+
"Events",
|
|
52
|
+
"Logger",
|
|
53
|
+
"Audit"
|
|
54
|
+
],
|
|
55
|
+
"gitHead": "967da9671a941f39637dcf163156c1a9f56c739b"
|
|
56
|
+
}
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
{
|
|
2
|
+
"IEventLogger": {
|
|
3
|
+
"components": {
|
|
4
|
+
"schemas": {
|
|
5
|
+
"GetAuditEventsArgs": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"filter": {
|
|
9
|
+
"$ref": "#/components/schemas/FindAuditLoggingEventArgs"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"FindAuditLoggingEventArgs": {
|
|
14
|
+
"type": "array",
|
|
15
|
+
"items": {
|
|
16
|
+
"$ref": "#/components/schemas/PartialAuditLoggingEvent"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"PartialAuditLoggingEvent": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"properties": {
|
|
22
|
+
"id": {
|
|
23
|
+
"type": "string"
|
|
24
|
+
},
|
|
25
|
+
"timestamp": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"format": "date-time"
|
|
28
|
+
},
|
|
29
|
+
"level": {
|
|
30
|
+
"$ref": "#/components/schemas/LogLevel"
|
|
31
|
+
},
|
|
32
|
+
"correlationId": {
|
|
33
|
+
"type": "string"
|
|
34
|
+
},
|
|
35
|
+
"system": {
|
|
36
|
+
"$ref": "#/components/schemas/System"
|
|
37
|
+
},
|
|
38
|
+
"subSystemType": {
|
|
39
|
+
"$ref": "#/components/schemas/SubSystem"
|
|
40
|
+
},
|
|
41
|
+
"actionType": {
|
|
42
|
+
"$ref": "#/components/schemas/ActionType"
|
|
43
|
+
},
|
|
44
|
+
"actionSubType": {
|
|
45
|
+
"$ref": "#/components/schemas/ActionSubType"
|
|
46
|
+
},
|
|
47
|
+
"initiatorType": {
|
|
48
|
+
"$ref": "#/components/schemas/InitiatorType"
|
|
49
|
+
},
|
|
50
|
+
"systemCorrelationIdType": {
|
|
51
|
+
"$ref": "#/components/schemas/SystemCorrelationIdType"
|
|
52
|
+
},
|
|
53
|
+
"systemCorrelationId": {
|
|
54
|
+
"type": "string"
|
|
55
|
+
},
|
|
56
|
+
"systemAlias": {
|
|
57
|
+
"type": "string"
|
|
58
|
+
},
|
|
59
|
+
"partyCorrelationType": {
|
|
60
|
+
"$ref": "#/components/schemas/PartyCorrelationType"
|
|
61
|
+
},
|
|
62
|
+
"partyCorrelationId": {
|
|
63
|
+
"type": "string"
|
|
64
|
+
},
|
|
65
|
+
"partyAlias": {
|
|
66
|
+
"type": "string"
|
|
67
|
+
},
|
|
68
|
+
"description": {
|
|
69
|
+
"type": "string"
|
|
70
|
+
},
|
|
71
|
+
"data": {},
|
|
72
|
+
"diagnosticData": {}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"LogLevel": {
|
|
76
|
+
"type": "number",
|
|
77
|
+
"enum": [
|
|
78
|
+
0,
|
|
79
|
+
1,
|
|
80
|
+
2,
|
|
81
|
+
3
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
"System": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"enum": [
|
|
87
|
+
"general",
|
|
88
|
+
"kms",
|
|
89
|
+
"identity",
|
|
90
|
+
"oid4vci",
|
|
91
|
+
"credentials",
|
|
92
|
+
"web3",
|
|
93
|
+
"profile",
|
|
94
|
+
"contact"
|
|
95
|
+
]
|
|
96
|
+
},
|
|
97
|
+
"SubSystem": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"enum": [
|
|
100
|
+
"key",
|
|
101
|
+
"did_provider",
|
|
102
|
+
"did_resolver",
|
|
103
|
+
"oid4vp_op",
|
|
104
|
+
"oid4vci_client",
|
|
105
|
+
"siopv2_op",
|
|
106
|
+
"contact_manager",
|
|
107
|
+
"vc_issuer",
|
|
108
|
+
"vc_verifier",
|
|
109
|
+
"vc_persistence",
|
|
110
|
+
"transport",
|
|
111
|
+
"profile"
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
"ActionType": {
|
|
115
|
+
"type": "string",
|
|
116
|
+
"enum": [
|
|
117
|
+
"create",
|
|
118
|
+
"read",
|
|
119
|
+
"update",
|
|
120
|
+
"delete",
|
|
121
|
+
"execute"
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
"ActionSubType": {
|
|
125
|
+
"anyOf": [
|
|
126
|
+
{
|
|
127
|
+
"$ref": "#/components/schemas/DefaultActionSubType"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"type": "string"
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
"DefaultActionSubType": {
|
|
135
|
+
"type": "string",
|
|
136
|
+
"enum": [
|
|
137
|
+
"Key generation",
|
|
138
|
+
"Key import",
|
|
139
|
+
"Key persistence",
|
|
140
|
+
"Key removal",
|
|
141
|
+
"DID creation",
|
|
142
|
+
"DID resolution",
|
|
143
|
+
"DID service update",
|
|
144
|
+
"VC issue",
|
|
145
|
+
"VC verify"
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
"InitiatorType": {
|
|
149
|
+
"type": "string",
|
|
150
|
+
"enum": [
|
|
151
|
+
"user",
|
|
152
|
+
"system",
|
|
153
|
+
"external"
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
"SystemCorrelationIdType": {
|
|
157
|
+
"type": "string",
|
|
158
|
+
"enum": [
|
|
159
|
+
"did",
|
|
160
|
+
"email",
|
|
161
|
+
"hostname",
|
|
162
|
+
"phone",
|
|
163
|
+
"user"
|
|
164
|
+
]
|
|
165
|
+
},
|
|
166
|
+
"PartyCorrelationType": {
|
|
167
|
+
"type": "string",
|
|
168
|
+
"enum": [
|
|
169
|
+
"did",
|
|
170
|
+
"email",
|
|
171
|
+
"hostname",
|
|
172
|
+
"phone"
|
|
173
|
+
]
|
|
174
|
+
},
|
|
175
|
+
"AuditLoggingEvent": {
|
|
176
|
+
"type": "object",
|
|
177
|
+
"properties": {
|
|
178
|
+
"id": {
|
|
179
|
+
"type": "string"
|
|
180
|
+
},
|
|
181
|
+
"timestamp": {
|
|
182
|
+
"type": "string",
|
|
183
|
+
"format": "date-time"
|
|
184
|
+
},
|
|
185
|
+
"level": {
|
|
186
|
+
"$ref": "#/components/schemas/LogLevel"
|
|
187
|
+
},
|
|
188
|
+
"correlationId": {
|
|
189
|
+
"type": "string"
|
|
190
|
+
},
|
|
191
|
+
"system": {
|
|
192
|
+
"$ref": "#/components/schemas/System"
|
|
193
|
+
},
|
|
194
|
+
"subSystemType": {
|
|
195
|
+
"$ref": "#/components/schemas/SubSystem"
|
|
196
|
+
},
|
|
197
|
+
"actionType": {
|
|
198
|
+
"$ref": "#/components/schemas/ActionType"
|
|
199
|
+
},
|
|
200
|
+
"actionSubType": {
|
|
201
|
+
"$ref": "#/components/schemas/ActionSubType"
|
|
202
|
+
},
|
|
203
|
+
"initiatorType": {
|
|
204
|
+
"$ref": "#/components/schemas/InitiatorType"
|
|
205
|
+
},
|
|
206
|
+
"systemCorrelationIdType": {
|
|
207
|
+
"$ref": "#/components/schemas/SystemCorrelationIdType"
|
|
208
|
+
},
|
|
209
|
+
"systemCorrelationId": {
|
|
210
|
+
"type": "string"
|
|
211
|
+
},
|
|
212
|
+
"systemAlias": {
|
|
213
|
+
"type": "string"
|
|
214
|
+
},
|
|
215
|
+
"partyCorrelationType": {
|
|
216
|
+
"$ref": "#/components/schemas/PartyCorrelationType"
|
|
217
|
+
},
|
|
218
|
+
"partyCorrelationId": {
|
|
219
|
+
"type": "string"
|
|
220
|
+
},
|
|
221
|
+
"partyAlias": {
|
|
222
|
+
"type": "string"
|
|
223
|
+
},
|
|
224
|
+
"description": {
|
|
225
|
+
"type": "string"
|
|
226
|
+
},
|
|
227
|
+
"data": {},
|
|
228
|
+
"diagnosticData": {}
|
|
229
|
+
},
|
|
230
|
+
"required": [
|
|
231
|
+
"id",
|
|
232
|
+
"timestamp",
|
|
233
|
+
"level",
|
|
234
|
+
"correlationId",
|
|
235
|
+
"system",
|
|
236
|
+
"subSystemType",
|
|
237
|
+
"actionType",
|
|
238
|
+
"actionSubType",
|
|
239
|
+
"initiatorType",
|
|
240
|
+
"description"
|
|
241
|
+
]
|
|
242
|
+
},
|
|
243
|
+
"LogAuditEventArgs": {
|
|
244
|
+
"type": "object",
|
|
245
|
+
"properties": {
|
|
246
|
+
"event": {
|
|
247
|
+
"$ref": "#/components/schemas/NonPersistedAuditLoggingEvent"
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
"required": [
|
|
251
|
+
"event"
|
|
252
|
+
]
|
|
253
|
+
},
|
|
254
|
+
"NonPersistedAuditLoggingEvent": {
|
|
255
|
+
"type": "object",
|
|
256
|
+
"properties": {
|
|
257
|
+
"system": {
|
|
258
|
+
"$ref": "#/components/schemas/System"
|
|
259
|
+
},
|
|
260
|
+
"subSystemType": {
|
|
261
|
+
"$ref": "#/components/schemas/SubSystem"
|
|
262
|
+
},
|
|
263
|
+
"actionType": {
|
|
264
|
+
"type": "object",
|
|
265
|
+
"properties": {}
|
|
266
|
+
},
|
|
267
|
+
"actionSubType": {
|
|
268
|
+
"anyOf": [
|
|
269
|
+
{
|
|
270
|
+
"type": "object",
|
|
271
|
+
"properties": {}
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"type": "string"
|
|
275
|
+
}
|
|
276
|
+
]
|
|
277
|
+
},
|
|
278
|
+
"initiatorType": {
|
|
279
|
+
"type": "object",
|
|
280
|
+
"properties": {}
|
|
281
|
+
},
|
|
282
|
+
"systemCorrelationIdType": {
|
|
283
|
+
"type": "object",
|
|
284
|
+
"properties": {}
|
|
285
|
+
},
|
|
286
|
+
"systemCorrelationId": {
|
|
287
|
+
"type": "string"
|
|
288
|
+
},
|
|
289
|
+
"systemAlias": {
|
|
290
|
+
"type": "string"
|
|
291
|
+
},
|
|
292
|
+
"partyCorrelationType": {
|
|
293
|
+
"type": "object",
|
|
294
|
+
"properties": {}
|
|
295
|
+
},
|
|
296
|
+
"partyCorrelationId": {
|
|
297
|
+
"type": "string"
|
|
298
|
+
},
|
|
299
|
+
"partyAlias": {
|
|
300
|
+
"type": "string"
|
|
301
|
+
},
|
|
302
|
+
"description": {
|
|
303
|
+
"type": "string"
|
|
304
|
+
},
|
|
305
|
+
"data": {},
|
|
306
|
+
"diagnosticData": {},
|
|
307
|
+
"level": {
|
|
308
|
+
"type": "object",
|
|
309
|
+
"properties": {}
|
|
310
|
+
},
|
|
311
|
+
"correlationId": {
|
|
312
|
+
"type": "string"
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
"required": [
|
|
316
|
+
"actionSubType",
|
|
317
|
+
"actionType",
|
|
318
|
+
"description",
|
|
319
|
+
"initiatorType",
|
|
320
|
+
"subSystemType",
|
|
321
|
+
"system"
|
|
322
|
+
]
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
"methods": {
|
|
326
|
+
"loggerGetAuditEvents": {
|
|
327
|
+
"description": "",
|
|
328
|
+
"arguments": {
|
|
329
|
+
"$ref": "#/components/schemas/GetAuditEventsArgs"
|
|
330
|
+
},
|
|
331
|
+
"returnType": {
|
|
332
|
+
"type": "array",
|
|
333
|
+
"items": {
|
|
334
|
+
"$ref": "#/components/schemas/AuditLoggingEvent"
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
"loggerLogAuditEvent": {
|
|
339
|
+
"description": "",
|
|
340
|
+
"arguments": {
|
|
341
|
+
"$ref": "#/components/schemas/LogAuditEventArgs"
|
|
342
|
+
},
|
|
343
|
+
"returnType": {
|
|
344
|
+
"$ref": "#/components/schemas/AuditLoggingEvent"
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { IAgentPlugin } from '@veramo/core'
|
|
2
|
+
import { AbstractEventLoggerStore } from '@sphereon/ssi-sdk.data-store'
|
|
3
|
+
import { AuditLoggingEvent, LoggingEventType, LogLevel } from '@sphereon/ssi-sdk.core'
|
|
4
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
5
|
+
import { schema } from '../index'
|
|
6
|
+
import {
|
|
7
|
+
EventLoggerOptions,
|
|
8
|
+
GetAuditEventsArgs,
|
|
9
|
+
IEventLogger,
|
|
10
|
+
RequiredContext,
|
|
11
|
+
LogAuditEventArgs,
|
|
12
|
+
LoggingEvent
|
|
13
|
+
} from '../types/IEventLogger'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* {@inheritDoc IEventLogger}
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export class EventLogger implements IAgentPlugin {
|
|
20
|
+
readonly schema = schema.IEventLogger
|
|
21
|
+
readonly eventTypes: Array<LoggingEventType> = []
|
|
22
|
+
|
|
23
|
+
readonly methods: IEventLogger = {
|
|
24
|
+
loggerGetAuditEvents: this.loggerGetAuditEvents.bind(this),
|
|
25
|
+
loggerLogAuditEvent: this.loggerLogAuditEvent.bind(this),
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
private readonly store: AbstractEventLoggerStore
|
|
29
|
+
|
|
30
|
+
constructor(options: EventLoggerOptions) {
|
|
31
|
+
const {store, eventTypes} = options
|
|
32
|
+
this.store = store
|
|
33
|
+
this.eventTypes = eventTypes
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public async onEvent(event: LoggingEvent, context: RequiredContext): Promise<void> {
|
|
37
|
+
switch(event.type) {
|
|
38
|
+
case LoggingEventType.AUDIT:
|
|
39
|
+
await this.loggerLogAuditEvent({ event: event.data }, context)
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
return Promise.reject(Error('Event type not supported'))
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private async loggerGetAuditEvents(args?: GetAuditEventsArgs): Promise<Array<AuditLoggingEvent>> {
|
|
47
|
+
const { filter } = args ?? {}
|
|
48
|
+
|
|
49
|
+
return this.store.getAuditEvents({ filter })
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private async loggerLogAuditEvent(args: LogAuditEventArgs, context: RequiredContext): Promise<AuditLoggingEvent> {
|
|
53
|
+
const { event } = args
|
|
54
|
+
|
|
55
|
+
return this.store.storeAuditEvent({ event: {
|
|
56
|
+
...event,
|
|
57
|
+
system: event.system,
|
|
58
|
+
subSystemType: event.subSystemType,
|
|
59
|
+
level: event.level ?? LogLevel.INFO,
|
|
60
|
+
correlationId: event.correlationId ?? uuidv4(),
|
|
61
|
+
timestamp: new Date()
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { IAgentContext, IPluginMethodMap } from '@veramo/core'
|
|
2
|
+
import {
|
|
3
|
+
AuditLoggingEvent,
|
|
4
|
+
NonPersistedAuditLoggingEvent as NPAuditLoggingEvent,
|
|
5
|
+
LoggingEventType,
|
|
6
|
+
SubSystem,
|
|
7
|
+
System
|
|
8
|
+
} from '@sphereon/ssi-sdk.core'
|
|
9
|
+
import { AbstractEventLoggerStore, FindAuditLoggingEventArgs } from '@sphereon/ssi-sdk.data-store'
|
|
10
|
+
|
|
11
|
+
export interface IEventLogger extends IPluginMethodMap {
|
|
12
|
+
loggerGetAuditEvents(args?: GetAuditEventsArgs): Promise<Array<AuditLoggingEvent>>
|
|
13
|
+
loggerLogAuditEvent(args: LogAuditEventArgs, context: RequiredContext): Promise<AuditLoggingEvent>
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type EventLoggerOptions = {
|
|
17
|
+
store: AbstractEventLoggerStore
|
|
18
|
+
eventTypes: Array<LoggingEventType>
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type GetAuditEventsArgs = {
|
|
22
|
+
filter?: FindAuditLoggingEventArgs
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type LogAuditEventArgs = {
|
|
26
|
+
event: NonPersistedAuditLoggingEvent
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type NonPersistedAuditLoggingEvent = Omit<NPAuditLoggingEvent, 'system' | 'subSystemType'> & {
|
|
30
|
+
system: System
|
|
31
|
+
subSystemType: SubSystem
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type LoggingEvent = {
|
|
35
|
+
type: LoggingEventType,
|
|
36
|
+
data: NonPersistedAuditLoggingEvent
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type RequiredContext = IAgentContext<never>
|