@payfit/audit-log 1.0.0-alpha7 → 1.0.0-alpha8

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.d.ts CHANGED
@@ -12,11 +12,6 @@ export interface IAuditLogData {
12
12
  * e.g documents, authentication, ...
13
13
  */
14
14
  namespace: string;
15
- /**
16
- * The service name (tech).
17
- * e.g files, payroll-api-v2, auth, ...
18
- */
19
- service: string;
20
15
  /**
21
16
  * The name of the event.
22
17
  * e.g. signIn, passwordUpdated, bonusAdded, ...
@@ -36,9 +31,9 @@ export interface IAuditLogData {
36
31
  */
37
32
  export declare type IAuditLogAuthData = {
38
33
  /**
39
- * Tells if the action has been made during a siginAs
34
+ * The id of the payfiter that did the action if it has been made during a siginAs
40
35
  */
41
- isImpersonated?: boolean;
36
+ internalId?: string;
42
37
  holdingId?: string;
43
38
  companyId?: string;
44
39
  employeeId?: string;
@@ -75,10 +70,11 @@ export interface IAuditLogger {
75
70
  export interface IAuditLoggerInitialization {
76
71
  apiUrl: string;
77
72
  environment: string;
73
+ service: string;
78
74
  }
79
75
  export declare class AuditLogger implements IAuditLogger {
80
76
  protected params: IAuditLoggerInitialization;
81
77
  private transport;
82
78
  constructor(params: IAuditLoggerInitialization);
83
- log(params: IAuditLogData): Promise<void>;
79
+ log(data: IAuditLogData): Promise<void>;
84
80
  }
package/dist/index.js CHANGED
@@ -15,12 +15,12 @@ class AuditLogger {
15
15
  this.params = params;
16
16
  this.transport = new implementation_1.Transport(params.apiUrl);
17
17
  }
18
- log(params) {
18
+ log(data) {
19
19
  return __awaiter(this, void 0, void 0, function* () {
20
20
  const uuid = uuid_1.v4();
21
- const environment = this.params.environment;
21
+ const { environment, service } = this.params;
22
22
  const timestamp = new Date().getTime();
23
- const log = Object.assign({}, params, { id: uuid, environment,
23
+ const log = Object.assign({}, data, { service, id: uuid, environment,
24
24
  timestamp });
25
25
  yield this.transport.create(log);
26
26
  });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,+BAAmC;AAEnC,+DAAsD;AAoGtD,MAAa,WAAW;IAGtB,YAAsB,MAAkC;QAAlC,WAAM,GAAN,MAAM,CAA4B;QACtD,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC/C,CAAC;IAEK,GAAG,CAAC,MAAqB;;YAC7B,MAAM,IAAI,GAAG,SAAM,EAAE,CAAA;YACrB,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAA;YAC3C,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;YAEtC,MAAM,GAAG,qBACJ,MAAM,IACT,EAAE,EAAE,IAAI,EACR,WAAW;gBACX,SAAS,GACV,CAAA;YAED,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAClC,CAAC;KAAA;CACF;AArBD,kCAqBC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,+BAAmC;AAEnC,+DAAsD;AA+FtD,MAAa,WAAW;IAGtB,YAAsB,MAAkC;QAAlC,WAAM,GAAN,MAAM,CAA4B;QACtD,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC/C,CAAC;IAEK,GAAG,CAAC,IAAmB;;YAC3B,MAAM,IAAI,GAAG,SAAM,EAAE,CAAA;YACrB,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;YAC5C,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;YAEtC,MAAM,GAAG,qBACJ,IAAI,IACP,OAAO,EACP,EAAE,EAAE,IAAI,EACR,WAAW;gBACX,SAAS,GACV,CAAA;YAED,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAClC,CAAC;KAAA;CACF;AAtBD,kCAsBC"}
@@ -34,13 +34,13 @@ export interface InlineObject {
34
34
  */
35
35
  payload?: object;
36
36
  /**
37
- *
38
- * @type {boolean}
37
+ * id of the payfiter who performed the audit log action, if signed as.
38
+ * @type {string}
39
39
  * @memberof InlineObject
40
40
  */
41
- isImpersonated?: boolean;
41
+ internalId?: string;
42
42
  /**
43
- *
43
+ * Tells whether the logged action has been made by the system
44
44
  * @type {boolean}
45
45
  * @memberof InlineObject
46
46
  */
@@ -70,49 +70,49 @@ export interface InlineObject {
70
70
  */
71
71
  environment?: string;
72
72
  /**
73
- * Audit log event holdingId
73
+ * holdingId of the account performing the event
74
74
  * @type {string}
75
75
  * @memberof InlineObject
76
76
  */
77
77
  holdingId?: string;
78
78
  /**
79
- * Audit log event companyId
79
+ * companyId of the account performing the event
80
80
  * @type {string}
81
81
  * @memberof InlineObject
82
82
  */
83
83
  companyId?: string;
84
84
  /**
85
- * Audit log event employeeId
85
+ * employeeId of the account performing the event
86
86
  * @type {string}
87
87
  * @memberof InlineObject
88
88
  */
89
89
  employeeId?: string;
90
90
  /**
91
- * Audit log event individualId
91
+ * individualId of the account performing the event
92
92
  * @type {string}
93
93
  * @memberof InlineObject
94
94
  */
95
95
  individualId?: string;
96
96
  /**
97
- * Audit log event roleId
97
+ * roleId of the account performing the event
98
98
  * @type {string}
99
99
  * @memberof InlineObject
100
100
  */
101
101
  roleId?: string;
102
102
  /**
103
- * Audit log event userIp
103
+ * userIp of the account performing the event
104
104
  * @type {string}
105
105
  * @memberof InlineObject
106
106
  */
107
107
  userIp?: string;
108
108
  /**
109
- * Audit log event specialRole
109
+ * specialRole of the account performing the event
110
110
  * @type {string}
111
111
  * @memberof InlineObject
112
112
  */
113
113
  specialRole?: string;
114
114
  /**
115
- * Audit log event email
115
+ * email of the account performing the event
116
116
  * @type {string}
117
117
  * @memberof InlineObject
118
118
  */
@@ -31,7 +31,6 @@ class Transport {
31
31
  return __awaiter(this, void 0, void 0, function* () {
32
32
  const { account } = auditLogData, logDataWithoutAccount = __rest(auditLogData, ["account"]);
33
33
  const dataToSend = Object.assign({}, logDataWithoutAccount, account);
34
- console.log(dataToSend);
35
34
  yield this.api.v1LogPost(dataToSend);
36
35
  });
37
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../src/transport/implementation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,2CAAwC;AAGxC,MAAa,SAAS;IAGpB,YAAsB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAClC,IAAI,CAAC,GAAG,GAAG,IAAI,sBAAU,CAAC;YACxB,QAAQ,EAAE,IAAI,CAAC,MAAM;SACtB,CAAC,CAAA;IACJ,CAAC;IAEK,MAAM,CAAC,YAAmC;;YAC9C,MAAM,EAAE,OAAO,KAA+B,YAAY,EAAzC,yDAAyC,CAAA;YAE1D,MAAM,UAAU,qBACX,qBAAqB,EACrB,OAAO,CACX,CAAA;YAED,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;YAEvB,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QACtC,CAAC;KAAA;CACF;AArBD,8BAqBC"}
1
+ {"version":3,"file":"implementation.js","sourceRoot":"","sources":["../../src/transport/implementation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,2CAAwC;AAGxC,MAAa,SAAS;IAGpB,YAAsB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAClC,IAAI,CAAC,GAAG,GAAG,IAAI,sBAAU,CAAC;YACxB,QAAQ,EAAE,IAAI,CAAC,MAAM;SACtB,CAAC,CAAA;IACJ,CAAC;IAEK,MAAM,CAAC,YAAmC;;YAC9C,MAAM,EAAE,OAAO,KAA+B,YAAY,EAAzC,yDAAyC,CAAA;YAE1D,MAAM,UAAU,qBACX,qBAAqB,EACrB,OAAO,CACX,CAAA;YAED,MAAM,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QACtC,CAAC;KAAA;CACF;AAnBD,8BAmBC"}
@@ -3,6 +3,7 @@ export declare type IAuditLogCreationData = IAuditLogData & {
3
3
  id: string;
4
4
  timestamp: number;
5
5
  environment: string;
6
+ service: string;
6
7
  };
7
8
  export interface IAuditLogTransport {
8
9
  create: (data: IAuditLogCreationData) => Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payfit/audit-log",
3
- "version": "1.0.0-alpha7",
3
+ "version": "1.0.0-alpha8",
4
4
  "description": "Library to handle audit logs at Payfit",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -3,18 +3,19 @@ import { AuditLogger } from '../src'
3
3
  const logger = new AuditLogger({
4
4
  apiUrl: 'http://localhost:8090',
5
5
  environment: 'TEST-env',
6
+ service: 'auth',
6
7
  })
7
8
 
8
9
  async function main() {
9
10
  await logger.log({
10
11
  event: 'signin',
11
12
  namespace: 'auth',
12
- service: 'auth',
13
13
  payload: {
14
14
  isTest: true,
15
15
  },
16
16
  account: {
17
- isSystem: true,
17
+ internalId: 'an internal id',
18
+ individualId: 'an invidiaul id',
18
19
  },
19
20
  scope: null,
20
21
  })
package/src/index.ts CHANGED
@@ -18,12 +18,6 @@ export interface IAuditLogData {
18
18
  */
19
19
  namespace: string
20
20
 
21
- /**
22
- * The service name (tech).
23
- * e.g files, payroll-api-v2, auth, ...
24
- */
25
- service: string
26
-
27
21
  /**
28
22
  * The name of the event.
29
23
  * e.g. signIn, passwordUpdated, bonusAdded, ...
@@ -47,9 +41,9 @@ export interface IAuditLogData {
47
41
  export type IAuditLogAuthData =
48
42
  | {
49
43
  /**
50
- * Tells if the action has been made during a siginAs
44
+ * The id of the payfiter that did the action if it has been made during a siginAs
51
45
  */
52
- isImpersonated?: boolean
46
+ internalId?: string
53
47
 
54
48
  // the "account" infos
55
49
  holdingId?: string
@@ -98,6 +92,7 @@ export interface IAuditLogger {
98
92
  export interface IAuditLoggerInitialization {
99
93
  apiUrl: string
100
94
  environment: string
95
+ service: string
101
96
  }
102
97
 
103
98
  export class AuditLogger implements IAuditLogger {
@@ -107,13 +102,14 @@ export class AuditLogger implements IAuditLogger {
107
102
  this.transport = new Transport(params.apiUrl)
108
103
  }
109
104
 
110
- async log(params: IAuditLogData) {
105
+ async log(data: IAuditLogData) {
111
106
  const uuid = uuidV4()
112
- const environment = this.params.environment
107
+ const { environment, service } = this.params
113
108
  const timestamp = new Date().getTime()
114
109
 
115
110
  const log = {
116
- ...params,
111
+ ...data,
112
+ service,
117
113
  id: uuid,
118
114
  environment,
119
115
  timestamp,
@@ -38,13 +38,13 @@ export interface InlineObject {
38
38
  */
39
39
  payload?: object;
40
40
  /**
41
- *
42
- * @type {boolean}
41
+ * id of the payfiter who performed the audit log action, if signed as.
42
+ * @type {string}
43
43
  * @memberof InlineObject
44
44
  */
45
- isImpersonated?: boolean;
45
+ internalId?: string;
46
46
  /**
47
- *
47
+ * Tells whether the logged action has been made by the system
48
48
  * @type {boolean}
49
49
  * @memberof InlineObject
50
50
  */
@@ -74,49 +74,49 @@ export interface InlineObject {
74
74
  */
75
75
  environment?: string;
76
76
  /**
77
- * Audit log event holdingId
77
+ * holdingId of the account performing the event
78
78
  * @type {string}
79
79
  * @memberof InlineObject
80
80
  */
81
81
  holdingId?: string;
82
82
  /**
83
- * Audit log event companyId
83
+ * companyId of the account performing the event
84
84
  * @type {string}
85
85
  * @memberof InlineObject
86
86
  */
87
87
  companyId?: string;
88
88
  /**
89
- * Audit log event employeeId
89
+ * employeeId of the account performing the event
90
90
  * @type {string}
91
91
  * @memberof InlineObject
92
92
  */
93
93
  employeeId?: string;
94
94
  /**
95
- * Audit log event individualId
95
+ * individualId of the account performing the event
96
96
  * @type {string}
97
97
  * @memberof InlineObject
98
98
  */
99
99
  individualId?: string;
100
100
  /**
101
- * Audit log event roleId
101
+ * roleId of the account performing the event
102
102
  * @type {string}
103
103
  * @memberof InlineObject
104
104
  */
105
105
  roleId?: string;
106
106
  /**
107
- * Audit log event userIp
107
+ * userIp of the account performing the event
108
108
  * @type {string}
109
109
  * @memberof InlineObject
110
110
  */
111
111
  userIp?: string;
112
112
  /**
113
- * Audit log event specialRole
113
+ * specialRole of the account performing the event
114
114
  * @type {string}
115
115
  * @memberof InlineObject
116
116
  */
117
117
  specialRole?: string;
118
118
  /**
119
- * Audit log event email
119
+ * email of the account performing the event
120
120
  * @type {string}
121
121
  * @memberof InlineObject
122
122
  */
@@ -18,8 +18,6 @@ export class Transport implements IAuditLogTransport {
18
18
  ...account,
19
19
  }
20
20
 
21
- console.log(dataToSend)
22
-
23
21
  await this.api.v1LogPost(dataToSend)
24
22
  }
25
23
  }
@@ -4,6 +4,7 @@ export type IAuditLogCreationData = IAuditLogData & {
4
4
  id: string
5
5
  timestamp: number
6
6
  environment: string
7
+ service: string
7
8
  }
8
9
 
9
10
  export interface IAuditLogTransport {