@cap-js/audit-logging 1.0.0 → 1.0.1

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/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/).
6
6
 
7
+ ## Version 1.0.1 - 2025-08-05
8
+
9
+ ### Fixed
10
+
11
+ - `audit-log-to-alsng`: EventDataPayload to Support Multi-Key Object and DataSubject IDs
12
+
7
13
  ## Version 1.0.0 - 2025-07-11
8
14
 
9
15
  ### Added
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cap-js/audit-logging",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "CDS plugin providing integration to the SAP Audit Log service as well as out-of-the-box personal data-related audit logging based on annotations.",
5
5
  "repository": "cap-js/audit-logging",
6
6
  "author": "SAP SE (https://www.sap.com)",
package/srv/log2alsng.js CHANGED
@@ -32,15 +32,23 @@ module.exports = class AuditLog2ALSNG extends AuditLogService {
32
32
  }[event]()
33
33
  }
34
34
 
35
+ flattenAndSortIdObject(id) {
36
+ if (!id || !Object.keys(id).length) return 'not provided'
37
+
38
+ let s = ''
39
+ for (const k of Object.keys(id).sort()) s += `${k}:${id[k]} `
40
+ return s.trim()
41
+ }
42
+
35
43
  eventDataPayload(event, data) {
36
44
  const object = data['object'] || { type: 'not provided', id: { ID: 'not provided' } }
37
45
  const channel = data['channel'] || { type: 'not specified', id: 'not specified' }
38
46
  const subject = data['data_subject'] || { type: 'not provided', id: { ID: 'not provided' } }
39
47
  const attributes = data['attributes'] || [{ name: 'not provided', old: 'not provided', new: 'not provided' }]
40
- const objectId = object['id']?.['ID'] || 'not provided'
48
+ const objectId = this.flattenAndSortIdObject(object['id'])
41
49
  const oldValue = attributes[0]['old'] ?? ''
42
50
  const newValue = attributes[0]['new'] ?? ''
43
- const dataSubjectId = subject['id']?.['ID'] || 'not provided'
51
+ const dataSubjectId = this.flattenAndSortIdObject(subject['id'])
44
52
  return {
45
53
  dppDataModification: {
46
54
  objectType: object['type'],
@@ -113,22 +121,25 @@ module.exports = class AuditLog2ALSNG extends AuditLogService {
113
121
  return eventData
114
122
  }
115
123
 
124
+ formatEventData(event, data) {
125
+ if (event === 'legacySecurityWrapper') {
126
+ return JSON.stringify([this.eventPayload(event, data)])
127
+ }
128
+
129
+ const eventData = data['attributes']?.map(attr => {
130
+ return this.eventPayload(event, {
131
+ ...data,
132
+ attributes: [attr]
133
+ })
134
+ })
135
+
136
+ return JSON.stringify(eventData || [])
137
+ }
138
+
116
139
  logEvent(event, data) {
117
140
  const passphrase = this._userProvided.credentials?.keyPassphrase
118
141
  const url = new URL(`${this._userProvided.credentials?.url}/ingestion/v1/events`)
119
- let eventData = []
120
-
121
- if (event === 'legacySecurityWrapper') {
122
- eventData = JSON.stringify([this.eventPayload(event, data)])
123
- } else {
124
- eventData = data['attributes'].map(attr => {
125
- return this.eventPayload(event, {
126
- ...data,
127
- attributes: [attr]
128
- })
129
- })
130
- eventData = JSON.stringify(eventData)
131
- }
142
+ const eventData = this.formatEventData(event, data)
132
143
 
133
144
  const options = {
134
145
  method: 'POST',