@riocrypto/common-server 1.0.1712 → 1.0.1713
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/build/services/logger.js
CHANGED
|
@@ -11,9 +11,49 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const common_1 = require("@riocrypto/common");
|
|
13
13
|
const winston_1 = require("winston");
|
|
14
|
-
const MAX_LEVEL = "info";
|
|
15
14
|
class LoggerService {
|
|
16
15
|
constructor() {
|
|
16
|
+
this.maskSensitiveData = (0, winston_1.format)((info) => {
|
|
17
|
+
// Mask sensitive headers
|
|
18
|
+
if (info.metadata && info.metadata.req && info.metadata.req.headers) {
|
|
19
|
+
const headers = info.metadata.req.headers;
|
|
20
|
+
const headerKeysToMask = [
|
|
21
|
+
"x-api-key",
|
|
22
|
+
"x-admin-api-key",
|
|
23
|
+
"x-cluster-api-key",
|
|
24
|
+
];
|
|
25
|
+
headerKeysToMask.forEach((key) => {
|
|
26
|
+
if (headers[key]) {
|
|
27
|
+
headers[key] = "***MASKED***"; // Replace with your masking preference
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
// Mask sensitive request body fields
|
|
32
|
+
if (info.metadata && info.metadata.req && info.metadata.req.body) {
|
|
33
|
+
const requestBodyFieldsToMask = [
|
|
34
|
+
"password",
|
|
35
|
+
"newPassword",
|
|
36
|
+
"securityAnswer",
|
|
37
|
+
"code",
|
|
38
|
+
"authenticatorCode",
|
|
39
|
+
];
|
|
40
|
+
requestBodyFieldsToMask.forEach((field) => {
|
|
41
|
+
if (info.metadata.req.body.hasOwnProperty(field)) {
|
|
42
|
+
info.metadata.req.body[field] = "***MASKED***"; // Replace with your masking preference
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// Mask sensitive response body fields
|
|
47
|
+
if (info.metadata && info.metadata.res && info.metadata.res.body) {
|
|
48
|
+
const responseBodyFieldsToMask = ["secret", "value"];
|
|
49
|
+
responseBodyFieldsToMask.forEach((field) => {
|
|
50
|
+
if (info.metadata.res.body.hasOwnProperty(field)) {
|
|
51
|
+
info.metadata.res.body[field] = "***MASKED***"; // Replace with your masking preference
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return info;
|
|
56
|
+
});
|
|
17
57
|
this.logger = null;
|
|
18
58
|
}
|
|
19
59
|
getLogger() {
|
|
@@ -25,14 +65,13 @@ class LoggerService {
|
|
|
25
65
|
initLogger() {
|
|
26
66
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
67
|
if (process.env.RIO_ENV === common_1.RioEnv.Production) {
|
|
28
|
-
|
|
29
|
-
const { getWinsonTransport } = yield require("@hyperdx/node-opentelemetry");
|
|
68
|
+
const { getWinstonTransport } = yield require("@hyperdx/node-opentelemetry");
|
|
30
69
|
this.logger = (0, winston_1.createLogger)({
|
|
31
|
-
level:
|
|
32
|
-
format: winston_1.format.combine(winston_1.format.timestamp(),
|
|
70
|
+
level: "info",
|
|
71
|
+
format: winston_1.format.combine(winston_1.format.timestamp(), this.maskSensitiveData(), winston_1.format.json(), winston_1.format.prettyPrint()),
|
|
33
72
|
transports: [
|
|
34
73
|
new winston_1.transports.Console(),
|
|
35
|
-
|
|
74
|
+
getWinstonTransport("info", {
|
|
36
75
|
apiKey: process.env.HYPERDX_API_KEY,
|
|
37
76
|
service: process.env.OTEL_SERVICE_NAME,
|
|
38
77
|
}),
|
|
@@ -40,10 +79,9 @@ class LoggerService {
|
|
|
40
79
|
});
|
|
41
80
|
}
|
|
42
81
|
else {
|
|
43
|
-
// Initialize logger for local environment with "error" level.
|
|
44
82
|
this.logger = (0, winston_1.createLogger)({
|
|
45
83
|
level: "error",
|
|
46
|
-
format: winston_1.format.combine(winston_1.format.timestamp(), winston_1.format.json(), winston_1.format.metadata(), winston_1.format.prettyPrint()),
|
|
84
|
+
format: winston_1.format.combine(winston_1.format.timestamp(), this.maskSensitiveData(), winston_1.format.json(), winston_1.format.metadata(), winston_1.format.prettyPrint()),
|
|
47
85
|
transports: [new winston_1.transports.Console()],
|
|
48
86
|
});
|
|
49
87
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1713",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@google-cloud/secret-manager": "^5.3.0",
|
|
27
27
|
"@google-cloud/storage": "^6.9.5",
|
|
28
28
|
"@hyperdx/node-opentelemetry": "^0.4.2",
|
|
29
|
-
"@riocrypto/common": "^1.0.
|
|
29
|
+
"@riocrypto/common": "^1.0.1505",
|
|
30
30
|
"@types/express": "^4.17.13",
|
|
31
31
|
"axios": "^1.6.0",
|
|
32
32
|
"crypto-js": "^4.2.0",
|