@riocrypto/common-server 1.0.1914 → 1.0.1918
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 +20 -10
- package/package.json +1 -1
package/build/services/logger.js
CHANGED
|
@@ -38,7 +38,7 @@ class LoggerService {
|
|
|
38
38
|
key === "refreshToken" ||
|
|
39
39
|
key === "adminRefreshToken" ||
|
|
40
40
|
key === "phoneVerifiedJWT") {
|
|
41
|
-
return `${key}=${this.maskValue(value)}`; // Mask the sensitive cookie
|
|
41
|
+
return `${key}=${this.maskValue(value, true)}`; // Mask the sensitive cookie
|
|
42
42
|
}
|
|
43
43
|
return cookie; // Return unmodified if not sensitive
|
|
44
44
|
})
|
|
@@ -47,18 +47,25 @@ class LoggerService {
|
|
|
47
47
|
}
|
|
48
48
|
// Mask sensitive request body fields
|
|
49
49
|
if (info.meta && info.meta.req && info.meta.req.body) {
|
|
50
|
-
const
|
|
50
|
+
const requestBodyFieldsToMaskWithLastFour = [
|
|
51
|
+
"accountNumber",
|
|
52
|
+
"routingNumber",
|
|
53
|
+
];
|
|
54
|
+
requestBodyFieldsToMaskWithLastFour.forEach((field) => {
|
|
55
|
+
if (info.meta.req.body.hasOwnProperty(field)) {
|
|
56
|
+
info.meta.req.body[field] = this.maskValue(info.meta.req.body[field], true);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
const requestBodyFieldsToMaskWithoutLastFour = [
|
|
51
60
|
"password",
|
|
52
61
|
"newPassword",
|
|
53
62
|
"securityAnswer",
|
|
54
|
-
"accountNumber",
|
|
55
|
-
"routingNumber",
|
|
56
63
|
"code",
|
|
57
64
|
"authenticatorCode",
|
|
58
65
|
];
|
|
59
|
-
|
|
66
|
+
requestBodyFieldsToMaskWithoutLastFour.forEach((field) => {
|
|
60
67
|
if (info.meta.req.body.hasOwnProperty(field)) {
|
|
61
|
-
info.meta.req.body[field] = this.maskValue(info.meta.req.body[field]);
|
|
68
|
+
info.meta.req.body[field] = this.maskValue(info.meta.req.body[field]);
|
|
62
69
|
}
|
|
63
70
|
});
|
|
64
71
|
}
|
|
@@ -89,10 +96,13 @@ class LoggerService {
|
|
|
89
96
|
});
|
|
90
97
|
this.logger = null;
|
|
91
98
|
}
|
|
92
|
-
maskValue(value) {
|
|
93
|
-
|
|
94
|
-
? "*".repeat(
|
|
95
|
-
|
|
99
|
+
maskValue(value, showLastFour = false) {
|
|
100
|
+
if (showLastFour) {
|
|
101
|
+
return value.length > 4 ? "*".repeat(12) + value.slice(-4) : value;
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return "************";
|
|
105
|
+
}
|
|
96
106
|
}
|
|
97
107
|
getLogger() {
|
|
98
108
|
if (!this.logger) {
|