@riocrypto/common-server 1.0.1711 → 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.
@@ -1,9 +1,9 @@
1
1
  import { Mongoose, Model, Document } from "mongoose";
2
2
  interface BridgeCustomerAttrs {
3
3
  userId: string;
4
- kycLinkId: string;
5
- kycLink: string;
6
- tosLink: string;
4
+ kycLinkId?: string;
5
+ kycLink?: string;
6
+ tosLink?: string;
7
7
  bridgeCustomerId?: string;
8
8
  }
9
9
  interface BridgeCustomerModel extends Model<BridgeCustomerDoc> {
@@ -12,9 +12,9 @@ interface BridgeCustomerModel extends Model<BridgeCustomerDoc> {
12
12
  interface BridgeCustomerDoc extends Document {
13
13
  _id: string;
14
14
  userId: string;
15
- kycLinkId: string;
16
- kycLink: string;
17
- tosLink: string;
15
+ kycLinkId?: string;
16
+ kycLink?: string;
17
+ tosLink?: string;
18
18
  bridgeCustomerId?: string;
19
19
  }
20
20
  declare const buildBridgeCustomer: (mongoose: Mongoose) => BridgeCustomerModel;
@@ -13,15 +13,12 @@ const buildBridgeCustomer = (mongoose) => {
13
13
  },
14
14
  kycLinkId: {
15
15
  type: String,
16
- required: true,
17
16
  },
18
17
  kycLink: {
19
18
  type: String,
20
- required: true,
21
19
  },
22
20
  tosLink: {
23
21
  type: String,
24
- required: true,
25
22
  },
26
23
  bridgeCustomerId: {
27
24
  type: String,
@@ -2,6 +2,7 @@ import { Logger } from "winston";
2
2
  declare class LoggerService {
3
3
  private logger;
4
4
  constructor();
5
+ private maskSensitiveData;
5
6
  getLogger(): Logger;
6
7
  initLogger(): Promise<void>;
7
8
  }
@@ -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
- // Initialize logger for production environment with "info" level.
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: MAX_LEVEL,
32
- format: winston_1.format.combine(winston_1.format.timestamp(), winston_1.format.json(), winston_1.format.metadata(), winston_1.format.prettyPrint()),
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
- getWinsonTransport(MAX_LEVEL, {
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.1711",
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.1502",
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",