@alanszp/audit 4.0.10 → 6.0.5
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/audit.d.ts +1 -1
- package/dist/audit.js +2 -2
- package/dist/audit.js.map +1 -1
- package/dist/interfaces.d.ts +9 -9
- package/dist/interfaces.js +0 -5
- package/dist/interfaces.js.map +1 -1
- package/package.json +4 -4
- package/src/audit.ts +1 -1
- package/src/interfaces.ts +15 -22
package/dist/audit.d.ts
CHANGED
package/dist/audit.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Audit = void 0;
|
|
4
4
|
const logger_1 = require("@alanszp/logger");
|
|
5
|
+
const interfaces_1 = require("./interfaces");
|
|
5
6
|
const lodash_1 = require("lodash");
|
|
6
|
-
const _1 = require(".");
|
|
7
7
|
const auditWithState_1 = require("./auditWithState");
|
|
8
8
|
const MissingAuditFieldsError_1 = require("./errors/MissingAuditFieldsError");
|
|
9
9
|
class Audit {
|
|
@@ -11,7 +11,7 @@ class Audit {
|
|
|
11
11
|
this.logger = logger;
|
|
12
12
|
}
|
|
13
13
|
log(body) {
|
|
14
|
-
const missingFields = (0, lodash_1.difference)(
|
|
14
|
+
const missingFields = (0, lodash_1.difference)(interfaces_1.REQUIRED_FIELDS, Object.keys(body));
|
|
15
15
|
if (missingFields.length > 0) {
|
|
16
16
|
throw new MissingAuditFieldsError_1.MissingAuditFieldsError(missingFields);
|
|
17
17
|
}
|
package/dist/audit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":";;;AAAA,4CAAmD;AACnD,mCAAoC;AACpC,
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../src/audit.ts"],"names":[],"mappings":";;;AAAA,4CAAmD;AACnD,6CAA0D;AAC1D,mCAAoC;AACpC,qDAAkD;AAClD,8EAA2E;AAE3E,MAAa,KAAK;IAGhB,YAAY,MAAe;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,GAAG,CAAC,IAAe;QACxB,MAAM,aAAa,GAAG,IAAA,mBAAU,EAAC,4BAAe,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAErE,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;YAC5B,MAAM,IAAI,iDAAuB,CAAC,aAAa,CAAC,CAAC;SAClD;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,gCAC1B,QAAQ,EAAE,gBAAO,CAAC,KAAK,IACpB,IAAI,KACP,MAAM,EAAE,SAAS,IACjB,CAAC;IACL,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,+BAAc,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AAxBD,sBAwBC"}
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
export interface AuditBody {
|
|
2
|
+
actorRef: string;
|
|
3
|
+
orgRef: string;
|
|
4
|
+
ip: string | string[];
|
|
5
|
+
action: string;
|
|
6
|
+
succeed: boolean;
|
|
7
|
+
targetRef?: string;
|
|
8
|
+
metadata?: Metadata;
|
|
9
|
+
}
|
|
1
10
|
export declare enum CommonMetadataKeys {
|
|
2
11
|
EMPLOYEE_ID = "employee_id",
|
|
3
12
|
EMPLOYEE_IDS = "employee_ids",
|
|
@@ -8,12 +17,3 @@ export interface Metadata {
|
|
|
8
17
|
[key: string]: unknown;
|
|
9
18
|
}
|
|
10
19
|
export declare const REQUIRED_FIELDS: string[];
|
|
11
|
-
export interface AuditBody {
|
|
12
|
-
actorRef: string;
|
|
13
|
-
orgRef: string;
|
|
14
|
-
ip: string | string[];
|
|
15
|
-
action: string;
|
|
16
|
-
succeed: boolean;
|
|
17
|
-
targetRef?: string;
|
|
18
|
-
metadata?: Metadata;
|
|
19
|
-
}
|
package/dist/interfaces.js
CHANGED
|
@@ -15,9 +15,4 @@ exports.REQUIRED_FIELDS = [
|
|
|
15
15
|
"action",
|
|
16
16
|
"succeed",
|
|
17
17
|
];
|
|
18
|
-
// When will be set by logger (log time)
|
|
19
|
-
// Where will be set by logger (host name)
|
|
20
|
-
// Articles that we based to create this:
|
|
21
|
-
// https://workos.com/blog/the-developers-guide-to-audit-logs-siem
|
|
22
|
-
// https://www.strongdm.com/blog/audit-log-review-management
|
|
23
18
|
//# sourceMappingURL=interfaces.js.map
|
package/dist/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;AAeA,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,iDAA2B,CAAA;IAC3B,mDAA6B,CAAA;IAC7B,yCAAmB,CAAA;IACnB,qCAAe,CAAA;AACjB,CAAC,EALW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAK7B;AAMY,QAAA,eAAe,GAAG;IAC7B,UAAU;IACV,QAAQ;IACR,IAAI;IACJ,QAAQ;IACR,SAAS;CACV,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alanszp/audit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.5",
|
|
4
4
|
"description": "Alan's audit util.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"yalc-publish": "yarn run yalc publish"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@alanszp/errors": "^
|
|
23
|
-
"@alanszp/logger": "^
|
|
22
|
+
"@alanszp/errors": "^6.0.0",
|
|
23
|
+
"@alanszp/logger": "^6.0.5",
|
|
24
24
|
"lodash": "^4.17.21"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "2541f069637c6c6f019d20a4447b96270a3a299d"
|
|
27
27
|
}
|
package/src/audit.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ILogger, LogType } from "@alanszp/logger";
|
|
2
|
+
import { AuditBody, REQUIRED_FIELDS } from "./interfaces";
|
|
2
3
|
import { difference } from "lodash";
|
|
3
|
-
import { AuditBody, REQUIRED_FIELDS } from ".";
|
|
4
4
|
import { AuditWithState } from "./auditWithState";
|
|
5
5
|
import { MissingAuditFieldsError } from "./errors/MissingAuditFieldsError";
|
|
6
6
|
|
package/src/interfaces.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
export interface AuditBody {
|
|
2
|
+
// Who
|
|
3
|
+
actorRef: string;
|
|
4
|
+
orgRef: string;
|
|
5
|
+
|
|
6
|
+
// Where (it can be an array since the request can jump between nodes, and http keeps record of their IPs)
|
|
7
|
+
ip: string | string[];
|
|
8
|
+
|
|
9
|
+
// What
|
|
10
|
+
action: string;
|
|
11
|
+
succeed: boolean;
|
|
12
|
+
targetRef?: string;
|
|
13
|
+
metadata?: Metadata;
|
|
14
|
+
}
|
|
15
|
+
|
|
1
16
|
export enum CommonMetadataKeys {
|
|
2
17
|
EMPLOYEE_ID = "employee_id",
|
|
3
18
|
EMPLOYEE_IDS = "employee_ids",
|
|
@@ -16,25 +31,3 @@ export const REQUIRED_FIELDS = [
|
|
|
16
31
|
"action",
|
|
17
32
|
"succeed",
|
|
18
33
|
];
|
|
19
|
-
|
|
20
|
-
export interface AuditBody {
|
|
21
|
-
// Who
|
|
22
|
-
actorRef: string;
|
|
23
|
-
orgRef: string;
|
|
24
|
-
|
|
25
|
-
// Where (it can be an array since the request can jump between nodes, and http keeps record of their IPs)
|
|
26
|
-
ip: string | string[];
|
|
27
|
-
|
|
28
|
-
// What
|
|
29
|
-
action: string;
|
|
30
|
-
succeed: boolean;
|
|
31
|
-
targetRef?: string;
|
|
32
|
-
metadata?: Metadata;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// When will be set by logger (log time)
|
|
36
|
-
// Where will be set by logger (host name)
|
|
37
|
-
|
|
38
|
-
// Articles that we based to create this:
|
|
39
|
-
// https://workos.com/blog/the-developers-guide-to-audit-logs-siem
|
|
40
|
-
// https://www.strongdm.com/blog/audit-log-review-management
|