@riocrypto/common-server 1.0.2321 → 1.0.2324

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.
@@ -0,0 +1,2 @@
1
+ import { Country, Fiat, Processor, User } from "@riocrypto/common";
2
+ export declare const getProcessor: (country: Country, fiat: Fiat, user: User, activeProcessors: Processor[]) => Processor;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getProcessor = void 0;
4
+ const common_1 = require("@riocrypto/common");
5
+ const getProcessor = (country, fiat, user, activeProcessors) => {
6
+ var _a;
7
+ if (fiat === common_1.Fiat.PEN) {
8
+ if (country === common_1.Country.Peru) {
9
+ return common_1.Processor.Interbank;
10
+ }
11
+ else {
12
+ throw new common_1.GenericInputError("PEN is not supported in your country");
13
+ }
14
+ }
15
+ else if (fiat === common_1.Fiat.MXN) {
16
+ if (country === common_1.Country.Mexico) {
17
+ if ((_a = user.attributes) === null || _a === void 0 ? void 0 : _a.includes(common_1.UserAttribute.useSTPForMXNWithdrawals)) {
18
+ if (activeProcessors.includes(common_1.Processor.SPEI_STP)) {
19
+ return common_1.Processor.SPEI_STP;
20
+ }
21
+ else if (activeProcessors.includes(common_1.Processor.SPEI_NVIO)) {
22
+ return common_1.Processor.SPEI_NVIO;
23
+ }
24
+ else {
25
+ return common_1.Processor.SPEI;
26
+ }
27
+ }
28
+ else {
29
+ if (activeProcessors.includes(common_1.Processor.SPEI_NVIO)) {
30
+ return common_1.Processor.SPEI_NVIO;
31
+ }
32
+ else {
33
+ return common_1.Processor.SPEI;
34
+ }
35
+ }
36
+ }
37
+ else {
38
+ throw new common_1.GenericInputError("MXN is not supported in your country");
39
+ }
40
+ }
41
+ else if (fiat === common_1.Fiat.USD) {
42
+ if (country === common_1.Country.UnitedStates) {
43
+ return common_1.Processor.Bridge;
44
+ }
45
+ else if (country === common_1.Country.Mexico) {
46
+ return common_1.Processor.SPID;
47
+ }
48
+ else if (country === common_1.Country.Peru) {
49
+ return common_1.Processor.Interbank;
50
+ }
51
+ else {
52
+ throw new common_1.GenericInputError("USD is not supported in your country");
53
+ }
54
+ }
55
+ else {
56
+ throw new common_1.GenericInputError("Fiat is not supported");
57
+ }
58
+ };
59
+ exports.getProcessor = getProcessor;
package/build/index.d.ts CHANGED
@@ -128,3 +128,4 @@ export * from "./helpers/send-with-xss-guard";
128
128
  export * from "./helpers/generate-idempotency-key-from-mongo-id";
129
129
  export * from "./helpers/generate-idempotency-key-from-order";
130
130
  export * from "./helpers/get-is-fireblocks-signature-valid";
131
+ export * from "./helpers/get-processor";
package/build/index.js CHANGED
@@ -144,3 +144,4 @@ __exportStar(require("./helpers/send-with-xss-guard"), exports);
144
144
  __exportStar(require("./helpers/generate-idempotency-key-from-mongo-id"), exports);
145
145
  __exportStar(require("./helpers/generate-idempotency-key-from-order"), exports);
146
146
  __exportStar(require("./helpers/get-is-fireblocks-signature-valid"), exports);
147
+ __exportStar(require("./helpers/get-processor"), exports);
@@ -1,4 +1,4 @@
1
- import { Country, Fiat, FXProvider, Side } from "@riocrypto/common";
1
+ import { Country, Fiat, FXProvider, Processor, Side } from "@riocrypto/common";
2
2
  import mongoose from "mongoose";
3
3
  interface RioSettingsAttrs {
4
4
  platformFee: number;
@@ -49,6 +49,9 @@ interface RioSettingsAttrs {
49
49
  };
50
50
  };
51
51
  fxExecutionThreshold: number;
52
+ activeFiatPaymentProcessors: {
53
+ [key in Side]: Processor[];
54
+ };
52
55
  }
53
56
  interface RioSettingsDoc extends mongoose.Document {
54
57
  platformFee: number;
@@ -99,6 +102,9 @@ interface RioSettingsDoc extends mongoose.Document {
99
102
  };
100
103
  };
101
104
  fxExecutionThreshold: number;
105
+ activeFiatPaymentProcessors: {
106
+ [key in Side]: Processor[];
107
+ };
102
108
  }
103
109
  interface RioSettingsModel extends mongoose.Model<RioSettingsDoc> {
104
110
  build(attrs: RioSettingsAttrs): RioSettingsDoc;
@@ -59,6 +59,9 @@ const buildRioSettings = (mongoose) => {
59
59
  defaultServiceFee: {
60
60
  type: Object,
61
61
  },
62
+ activeFiatPaymentProcessors: {
63
+ type: Object,
64
+ },
62
65
  }, {
63
66
  toJSON: {
64
67
  transform(doc, ret) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2321",
3
+ "version": "1.0.2324",
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.3.0",
29
29
  "@google-cloud/storage": "^6.9.5",
30
30
  "@hyperdx/node-opentelemetry": "^0.7.0",
31
- "@riocrypto/common": "^1.0.2034",
31
+ "@riocrypto/common": "^1.0.2036",
32
32
  "@types/express": "^4.17.13",
33
33
  "axios": "^1.7.4",
34
34
  "crypto-js": "^4.2.0",