@riocrypto/common-server 1.0.2829 → 1.0.2831

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.
@@ -20,6 +20,8 @@ function buildAxiosWithLogging() {
20
20
  "passphrase",
21
21
  "signature",
22
22
  "csrf",
23
+ "hash",
24
+ "apgw",
23
25
  ];
24
26
  function maskHeaderValue(value) {
25
27
  return value.length > 2 ? "*".repeat(12) + value.slice(-2) : "************";
@@ -35,6 +37,30 @@ function buildAxiosWithLogging() {
35
37
  });
36
38
  return maskedHeaders;
37
39
  }
40
+ // Recursively masks any object field whose key contains a sensitive
41
+ // substring. Handles request/response bodies (e.g. passwords, session
42
+ // tokens) while leaving non-sensitive fields intact. String bodies and
43
+ // primitives are returned unchanged.
44
+ function maskData(data) {
45
+ if (Array.isArray(data)) {
46
+ return data.map((item) => maskData(item));
47
+ }
48
+ if (data && typeof data === "object") {
49
+ const maskedData = {};
50
+ for (const [key, value] of Object.entries(data)) {
51
+ const lower = key.toLowerCase();
52
+ if (sensitiveSubstrings.some((sub) => lower.includes(sub))) {
53
+ maskedData[key] =
54
+ typeof value === "string" ? maskHeaderValue(value) : "************";
55
+ }
56
+ else {
57
+ maskedData[key] = maskData(value);
58
+ }
59
+ }
60
+ return maskedData;
61
+ }
62
+ return data;
63
+ }
38
64
  function maskUrl(url) {
39
65
  if (!url)
40
66
  return "unknown";
@@ -63,7 +89,7 @@ function buildAxiosWithLogging() {
63
89
  // Mask sensitive headers in the configuration
64
90
  const maskedHeaders = maskHeaders(customConfig.headers);
65
91
  // Combine and log the full request configuration with masked headers
66
- const logMessage = `Request: method=${customConfig.method}, url=${maskUrl(customConfig.url)}, headers=${JSON.stringify(maskedHeaders)}, data=${JSON.stringify(customConfig.data)}`;
92
+ const logMessage = `Request: method=${customConfig.method}, url=${maskUrl(customConfig.url)}, headers=${JSON.stringify(maskedHeaders)}, data=${JSON.stringify(maskData(customConfig.data))}`;
67
93
  ((_a = logger_1.default.getLogger()) === null || _a === void 0 ? void 0 : _a.info(logMessage)) || console.log(logMessage);
68
94
  }
69
95
  return config;
@@ -81,7 +107,7 @@ function buildAxiosWithLogging() {
81
107
  // Check if logging is disabled for this request
82
108
  if (!customConfig.skipLogging) {
83
109
  // Combine and log the full response details
84
- const logMessage = `Response: url=${maskUrl(customConfig.url)}, status=${response.status}, data=${JSON.stringify(response.data)}`;
110
+ const logMessage = `Response: url=${maskUrl(customConfig.url)}, status=${response.status}, data=${JSON.stringify(maskData(response.data))}`;
85
111
  ((_a = logger_1.default.getLogger()) === null || _a === void 0 ? void 0 : _a.info(logMessage)) || console.log(logMessage);
86
112
  }
87
113
  return response;
@@ -90,7 +116,7 @@ function buildAxiosWithLogging() {
90
116
  // Combine and log the response error details without headers
91
117
  let logMessage = `Response Error: url=${maskUrl((_a = error.config) === null || _a === void 0 ? void 0 : _a.url)}, message=${error.message}`;
92
118
  if (error.response) {
93
- logMessage += `, status=${error.response.status}, data=${JSON.stringify(error.response.data)}`;
119
+ logMessage += `, status=${error.response.status}, data=${JSON.stringify(maskData(error.response.data))}`;
94
120
  }
95
121
  ((_b = logger_1.default.getLogger()) === null || _b === void 0 ? void 0 : _b.info(logMessage)) || console.log(logMessage);
96
122
  return Promise.reject({
@@ -195,6 +195,16 @@ declare class ClusterClient {
195
195
  generateSTPDepositCLABE(userId: string): Promise<{
196
196
  CLABE: string;
197
197
  }>;
198
+ generateAlfinVirtualCci(userId: string): Promise<{
199
+ CCIV: string;
200
+ codigoPagoCciv?: string;
201
+ }>;
202
+ createAlfinPENTreasuryWithdrawal(amount: number, cci: string, internalTransferId?: string): Promise<{
203
+ movimientoUId: number;
204
+ transferenciaId: string;
205
+ mpe001IDL: number;
206
+ beneficiaryName: string;
207
+ }>;
198
208
  getSTPMXNBalance(): Promise<number>;
199
209
  createSTPMXNWithdrawal(amount: number, CLABE: string, concepto: string, beneficiaryName: string, internalTransferId?: string): Promise<STPMXNWithdrawalDoc>;
200
210
  getSTPMXNWithdrawal(id: string): Promise<STPMXNWithdrawal>;
@@ -683,6 +683,18 @@ class ClusterClient {
683
683
  return response.data;
684
684
  });
685
685
  }
686
+ generateAlfinVirtualCci(userId) {
687
+ return __awaiter(this, void 0, void 0, function* () {
688
+ const response = yield this.axios.post(`${this.baseUrl}/api/bank/accounts/alfin/CCIV`, { userId }, { headers: { "x-cluster-api-key": this.clusterApiKey } });
689
+ return response.data;
690
+ });
691
+ }
692
+ createAlfinPENTreasuryWithdrawal(amount, cci, internalTransferId) {
693
+ return __awaiter(this, void 0, void 0, function* () {
694
+ const response = yield this.axios.post(`${this.baseUrl}/api/bank/accounts/alfin/PEN/treasury-withdrawal`, { amount, cci, internalTransferId }, { headers: { "x-cluster-api-key": this.clusterApiKey } });
695
+ return response.data;
696
+ });
697
+ }
686
698
  getSTPMXNBalance() {
687
699
  return __awaiter(this, void 0, void 0, function* () {
688
700
  const response = yield this.axios.get(`${this.baseUrl}/api/bank/accounts/STP/MXN/balance`, { headers: { "x-cluster-api-key": this.clusterApiKey } });
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getProcessor = void 0;
4
4
  const common_1 = require("@riocrypto/common");
5
5
  const getProcessor = ({ country, fiat, user, activeProcessors, side, isBinanceRFQ, }) => {
6
- var _a, _b;
6
+ var _a, _b, _c, _d;
7
7
  if (isBinanceRFQ === true) {
8
8
  return common_1.Processor.BinanceRFQ;
9
9
  }
@@ -17,6 +17,16 @@ const getProcessor = ({ country, fiat, user, activeProcessors, side, isBinanceRF
17
17
  }
18
18
  else if (fiat === common_1.Fiat.PEN) {
19
19
  if (country === common_1.Country.Peru) {
20
+ if (side === common_1.Side.Buy &&
21
+ ((_a = user.attributes) === null || _a === void 0 ? void 0 : _a.includes(common_1.UserAttribute.UseAlfinForPENDeposits)) &&
22
+ activeProcessors.includes(common_1.Processor.Alfin)) {
23
+ return common_1.Processor.Alfin;
24
+ }
25
+ if (side === common_1.Side.Sell &&
26
+ ((_b = user.attributes) === null || _b === void 0 ? void 0 : _b.includes(common_1.UserAttribute.UseAlfinForPENWithdrawals)) &&
27
+ activeProcessors.includes(common_1.Processor.Alfin)) {
28
+ return common_1.Processor.Alfin;
29
+ }
20
30
  return common_1.Processor.Interbank;
21
31
  }
22
32
  else {
@@ -26,9 +36,9 @@ const getProcessor = ({ country, fiat, user, activeProcessors, side, isBinanceRF
26
36
  else if (fiat === common_1.Fiat.MXN) {
27
37
  if (country === common_1.Country.Mexico) {
28
38
  if ((side === common_1.Side.Sell &&
29
- ((_a = user.attributes) === null || _a === void 0 ? void 0 : _a.includes(common_1.UserAttribute.UseSTPForMXNWithdrawals))) ||
39
+ ((_c = user.attributes) === null || _c === void 0 ? void 0 : _c.includes(common_1.UserAttribute.UseSTPForMXNWithdrawals))) ||
30
40
  (side === common_1.Side.Buy &&
31
- ((_b = user.attributes) === null || _b === void 0 ? void 0 : _b.includes(common_1.UserAttribute.UseSTPForMXNDeposits)))) {
41
+ ((_d = user.attributes) === null || _d === void 0 ? void 0 : _d.includes(common_1.UserAttribute.UseSTPForMXNDeposits)))) {
32
42
  if (activeProcessors.includes(common_1.Processor.SPEI_STP)) {
33
43
  return common_1.Processor.SPEI_STP;
34
44
  }
package/build/index.d.ts CHANGED
@@ -87,6 +87,9 @@ export * from "./models/admin-auth-dashboard-settings";
87
87
  export * from "./models/STP-mxn-withdrawal";
88
88
  export * from "./models/STP-deposit-CLABE";
89
89
  export * from "./models/STP-settings";
90
+ export * from "./models/alfin-virtual-cci";
91
+ export * from "./models/alfin-settings";
92
+ export * from "./models/alfin-pen-withdrawal";
90
93
  export * from "./models/dashboard-push-notification-subscription";
91
94
  export * from "./models/webauthn-credential";
92
95
  export * from "./models/admin-webauthn-credential";
package/build/index.js CHANGED
@@ -103,6 +103,9 @@ __exportStar(require("./models/admin-auth-dashboard-settings"), exports);
103
103
  __exportStar(require("./models/STP-mxn-withdrawal"), exports);
104
104
  __exportStar(require("./models/STP-deposit-CLABE"), exports);
105
105
  __exportStar(require("./models/STP-settings"), exports);
106
+ __exportStar(require("./models/alfin-virtual-cci"), exports);
107
+ __exportStar(require("./models/alfin-settings"), exports);
108
+ __exportStar(require("./models/alfin-pen-withdrawal"), exports);
106
109
  __exportStar(require("./models/dashboard-push-notification-subscription"), exports);
107
110
  __exportStar(require("./models/webauthn-credential"), exports);
108
111
  __exportStar(require("./models/admin-webauthn-credential"), exports);
@@ -0,0 +1,41 @@
1
+ import { AlfinPENWithdrawalStatus } from "@riocrypto/common";
2
+ import { Mongoose, Model, Document, HydratedDocument } from "mongoose";
3
+ interface AlfinPENWithdrawalPart {
4
+ uuid: string;
5
+ partNumber: number;
6
+ amount: number;
7
+ reference: string;
8
+ status: AlfinPENWithdrawalStatus;
9
+ cciBeneficiario?: string;
10
+ beneficiaryName?: string;
11
+ transferenciaId?: string;
12
+ mpe001IDL?: number;
13
+ movimientoUId?: number;
14
+ }
15
+ interface AlfinPENWithdrawalAttrs {
16
+ createdAt: Date;
17
+ type: "transaction" | "internalTransfer";
18
+ orderId?: string;
19
+ bulkBankPayoutId?: string;
20
+ internalTransferId?: string;
21
+ numberOfParts?: number;
22
+ partsCompleted?: number;
23
+ orderVersion?: number;
24
+ AlfinWithdrawals: AlfinPENWithdrawalPart[];
25
+ }
26
+ interface AlfinPENWithdrawalDoc extends Document {
27
+ createdAt: Date;
28
+ type: "transaction" | "internalTransfer";
29
+ orderId?: string;
30
+ bulkBankPayoutId?: string;
31
+ internalTransferId?: string;
32
+ numberOfParts?: number;
33
+ partsCompleted?: number;
34
+ orderVersion?: number;
35
+ AlfinWithdrawals: AlfinPENWithdrawalPart[];
36
+ }
37
+ interface AlfinPENWithdrawalModel extends Model<AlfinPENWithdrawalDoc> {
38
+ build(attrs: AlfinPENWithdrawalAttrs): HydratedDocument<AlfinPENWithdrawalDoc>;
39
+ }
40
+ declare const buildAlfinPENWithdrawal: (mongoose: Mongoose) => AlfinPENWithdrawalModel;
41
+ export { buildAlfinPENWithdrawal, AlfinPENWithdrawalDoc, AlfinPENWithdrawalAttrs, AlfinPENWithdrawalPart, };
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildAlfinPENWithdrawal = void 0;
4
+ const common_1 = require("@riocrypto/common");
5
+ const buildAlfinPENWithdrawal = (mongoose) => {
6
+ if (mongoose.models.AlfinPENWithdrawal) {
7
+ return mongoose.model("AlfinPENWithdrawal");
8
+ }
9
+ const AlfinPENWithdrawalSchema = new mongoose.Schema({
10
+ orderId: {
11
+ type: String,
12
+ },
13
+ bulkBankPayoutId: {
14
+ type: String,
15
+ },
16
+ internalTransferId: {
17
+ type: String,
18
+ },
19
+ numberOfParts: {
20
+ type: Number,
21
+ },
22
+ partsCompleted: {
23
+ type: Number,
24
+ },
25
+ type: {
26
+ type: String,
27
+ required: true,
28
+ },
29
+ createdAt: {
30
+ type: mongoose.Schema.Types.Date,
31
+ required: true,
32
+ },
33
+ AlfinWithdrawals: {
34
+ type: [
35
+ {
36
+ uuid: String,
37
+ amount: Number,
38
+ status: {
39
+ type: String,
40
+ enum: Object.values(common_1.AlfinPENWithdrawalStatus),
41
+ },
42
+ partNumber: Number,
43
+ reference: String,
44
+ cciBeneficiario: String,
45
+ beneficiaryName: String,
46
+ transferenciaId: String,
47
+ mpe001IDL: Number,
48
+ movimientoUId: Number,
49
+ },
50
+ ],
51
+ },
52
+ orderVersion: {
53
+ type: Number,
54
+ },
55
+ }, {
56
+ toJSON: {
57
+ transform(doc, ret) {
58
+ ret.id = ret._id.valueOf();
59
+ delete ret._id;
60
+ delete ret.__v;
61
+ if (ret.AlfinWithdrawals && Array.isArray(ret.AlfinWithdrawals)) {
62
+ ret.AlfinWithdrawals = ret.AlfinWithdrawals.map((withdrawal) => {
63
+ if (withdrawal._id) {
64
+ withdrawal.id = withdrawal._id.valueOf();
65
+ delete withdrawal._id;
66
+ }
67
+ return withdrawal;
68
+ });
69
+ }
70
+ },
71
+ },
72
+ });
73
+ AlfinPENWithdrawalSchema.statics.build = (attrs) => {
74
+ return new AlfinPENWithdrawal(attrs);
75
+ };
76
+ const AlfinPENWithdrawal = mongoose.model("AlfinPENWithdrawal", AlfinPENWithdrawalSchema);
77
+ return AlfinPENWithdrawal;
78
+ };
79
+ exports.buildAlfinPENWithdrawal = buildAlfinPENWithdrawal;
@@ -0,0 +1,12 @@
1
+ import mongoose, { HydratedDocument } from "mongoose";
2
+ interface AlfinSettingsAttrs {
3
+ payinCodeOffset: number;
4
+ }
5
+ interface AlfinSettingsDoc extends mongoose.Document {
6
+ payinCodeOffset: number;
7
+ }
8
+ interface AlfinSettingsModel extends mongoose.Model<AlfinSettingsDoc> {
9
+ build(attrs: AlfinSettingsAttrs): HydratedDocument<AlfinSettingsDoc>;
10
+ }
11
+ declare const buildAlfinSettings: (mongoose: typeof mongoose) => AlfinSettingsModel;
12
+ export { buildAlfinSettings, AlfinSettingsDoc, AlfinSettingsAttrs };
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildAlfinSettings = void 0;
4
+ const buildAlfinSettings = (mongoose) => {
5
+ if (mongoose.models.AlfinSettings) {
6
+ return mongoose.model("AlfinSettings");
7
+ }
8
+ const AlfinSettingsSchema = new mongoose.Schema({
9
+ payinCodeOffset: {
10
+ type: Number,
11
+ required: true,
12
+ },
13
+ }, {
14
+ toJSON: {
15
+ transform(doc, ret) {
16
+ ret.id = ret._id;
17
+ delete ret._id;
18
+ delete ret.__v;
19
+ },
20
+ },
21
+ });
22
+ AlfinSettingsSchema.statics.build = (attrs) => {
23
+ return new AlfinSettings(attrs);
24
+ };
25
+ const AlfinSettings = mongoose.model("AlfinSettings", AlfinSettingsSchema);
26
+ return AlfinSettings;
27
+ };
28
+ exports.buildAlfinSettings = buildAlfinSettings;
@@ -0,0 +1,26 @@
1
+ import { Mongoose, Model, Document, HydratedDocument } from "mongoose";
2
+ type AlfinVirtualCciType = "UNICO" | "RECURRENTE";
3
+ type AlfinVirtualCciStatus = "ACTIVO" | "BAJA" | "VENCIDO";
4
+ interface AlfinVirtualCciAttrs {
5
+ cci: string;
6
+ cciv: string;
7
+ codigoPagoCciv?: string;
8
+ userId: string;
9
+ type: AlfinVirtualCciType;
10
+ status?: AlfinVirtualCciStatus;
11
+ }
12
+ interface AlfinVirtualCciDoc extends Document {
13
+ cci: string;
14
+ cciv: string;
15
+ codigoPagoCciv?: string;
16
+ userId: string;
17
+ type: AlfinVirtualCciType;
18
+ status: AlfinVirtualCciStatus;
19
+ createdAt: Date;
20
+ updatedAt: Date;
21
+ }
22
+ interface AlfinVirtualCciModel extends Model<AlfinVirtualCciDoc> {
23
+ build(attrs: AlfinVirtualCciAttrs): HydratedDocument<AlfinVirtualCciDoc>;
24
+ }
25
+ declare const buildAlfinVirtualCci: (mongoose: Mongoose) => AlfinVirtualCciModel;
26
+ export { buildAlfinVirtualCci, AlfinVirtualCciDoc, AlfinVirtualCciAttrs, AlfinVirtualCciType, AlfinVirtualCciStatus, };
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildAlfinVirtualCci = void 0;
4
+ // Maps each virtual CCI (CCIV) we generate to the user it was issued to, so an
5
+ // inbound payin notification can be resolved to a single user and matched only
6
+ // against that user's orders / bulk payments.
7
+ const buildAlfinVirtualCci = (mongoose) => {
8
+ if (mongoose.models.AlfinVirtualCci) {
9
+ return mongoose.model("AlfinVirtualCci");
10
+ }
11
+ const AlfinVirtualCciSchema = new mongoose.Schema({
12
+ cci: {
13
+ type: String,
14
+ required: true,
15
+ },
16
+ cciv: {
17
+ type: String,
18
+ required: true,
19
+ unique: true,
20
+ },
21
+ codigoPagoCciv: {
22
+ type: String,
23
+ index: true,
24
+ },
25
+ userId: {
26
+ type: String,
27
+ required: true,
28
+ index: true,
29
+ },
30
+ type: {
31
+ type: String,
32
+ enum: ["UNICO", "RECURRENTE"],
33
+ required: true,
34
+ },
35
+ status: {
36
+ type: String,
37
+ enum: ["ACTIVO", "BAJA", "VENCIDO"],
38
+ default: "ACTIVO",
39
+ },
40
+ }, {
41
+ timestamps: true,
42
+ toJSON: {
43
+ transform(doc, ret) {
44
+ ret.id = ret._id.valueOf();
45
+ delete ret._id;
46
+ delete ret.__v;
47
+ },
48
+ },
49
+ });
50
+ AlfinVirtualCciSchema.statics.build = (attrs) => {
51
+ return new AlfinVirtualCci(attrs);
52
+ };
53
+ const AlfinVirtualCci = mongoose.model("AlfinVirtualCci", AlfinVirtualCciSchema);
54
+ return AlfinVirtualCci;
55
+ };
56
+ exports.buildAlfinVirtualCci = buildAlfinVirtualCci;
@@ -100,6 +100,10 @@ interface UserAttrs {
100
100
  taxId?: string;
101
101
  postalCode?: string;
102
102
  };
103
+ PE?: {
104
+ fiscalName?: string;
105
+ taxId?: string;
106
+ };
103
107
  };
104
108
  quotationTime?: number;
105
109
  referrerId?: string;
@@ -264,6 +268,10 @@ interface UserDoc extends Document {
264
268
  taxId?: string;
265
269
  postalCode?: string;
266
270
  };
271
+ PE?: {
272
+ fiscalName?: string;
273
+ taxId?: string;
274
+ };
267
275
  };
268
276
  quotationTime?: number;
269
277
  referrerId?: string;
@@ -337,6 +337,14 @@ const buildUser = (mongoose) => {
337
337
  type: String,
338
338
  },
339
339
  },
340
+ PE: {
341
+ fiscalName: {
342
+ type: String,
343
+ },
344
+ taxId: {
345
+ type: String,
346
+ },
347
+ },
340
348
  },
341
349
  businessData: {
342
350
  type: Object,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2829",
3
+ "version": "1.0.2831",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "@google-cloud/secret-manager": "^5.6.0",
29
29
  "@google-cloud/storage": "^7.19.0",
30
30
  "@hyperdx/node-opentelemetry": "^0.10.3",
31
- "@riocrypto/common": "1.0.2626",
31
+ "@riocrypto/common": "1.0.2629",
32
32
  "@slack/web-api": "^7.15.0",
33
33
  "@types/express": "^4.17.25",
34
34
  "axios": "1.16.0",