@riocrypto/common-server 1.0.2877 → 1.0.2879

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.
Files changed (39) hide show
  1. package/build/clients/cluster-client.d.ts +36 -0
  2. package/build/clients/cluster-client.js +31 -1
  3. package/build/helpers/get-custom-rio-bank-account.d.ts +10 -0
  4. package/build/helpers/get-custom-rio-bank-account.js +37 -0
  5. package/build/helpers/get-processor.d.ts +7 -4
  6. package/build/helpers/get-processor.js +72 -55
  7. package/build/helpers/get-tax-rate.js +1 -0
  8. package/build/helpers/payin-destinations.d.ts +37 -0
  9. package/build/helpers/payin-destinations.js +286 -0
  10. package/build/helpers/payin-verification.d.ts +30 -0
  11. package/build/helpers/payin-verification.js +162 -0
  12. package/build/helpers/processor-enablement.d.ts +19 -0
  13. package/build/helpers/processor-enablement.js +87 -0
  14. package/build/helpers/record-observed-processor-readiness.d.ts +10 -0
  15. package/build/helpers/record-observed-processor-readiness.js +65 -0
  16. package/build/helpers/resolve-processor.d.ts +18 -0
  17. package/build/helpers/resolve-processor.js +122 -0
  18. package/build/index.d.ts +10 -0
  19. package/build/index.js +10 -0
  20. package/build/middlewares/get-order.js +1 -0
  21. package/build/models/bank-account-verification.d.ts +2 -2
  22. package/build/models/bulk-bank-payment.js +3 -0
  23. package/build/models/fintoc-deposit-CLABE.d.ts +28 -0
  24. package/build/models/fintoc-deposit-CLABE.js +56 -0
  25. package/build/models/fintoc-mxn-withdrawal.d.ts +51 -0
  26. package/build/models/fintoc-mxn-withdrawal.js +88 -0
  27. package/build/models/fireblocks-vault.d.ts +8 -0
  28. package/build/models/fireblocks-vault.js +8 -0
  29. package/build/models/internal-balances.d.ts +3 -0
  30. package/build/models/internal-balances.js +3 -0
  31. package/build/models/payment-address-verification.d.ts +49 -0
  32. package/build/models/payment-address-verification.js +77 -0
  33. package/build/models/processor-readiness.d.ts +44 -0
  34. package/build/models/processor-readiness.js +90 -0
  35. package/build/models/rio-bank-account.d.ts +3 -1
  36. package/build/models/rio-bank-account.js +3 -0
  37. package/build/models/rio-settings.d.ts +3 -11
  38. package/build/models/rio-settings.js +1 -2
  39. package/package.json +2 -2
@@ -0,0 +1,44 @@
1
+ import { Country, Fiat, Processor, ProcessorReadiness, ProcessorReadinessStatus, ProcessorReadinessVerificationMethod } from "@riocrypto/common";
2
+ import { Mongoose, Model, Document, HydratedDocument } from "mongoose";
3
+ type ProcessorEnablement = ProcessorReadiness["enablement"];
4
+ interface ProcessorReadinessAttrs {
5
+ createdAt: Date;
6
+ userId: string;
7
+ country: Country;
8
+ fiat: Fiat;
9
+ processor: Processor;
10
+ enablement?: ProcessorEnablement;
11
+ status: ProcessorReadinessStatus;
12
+ CLABE?: string;
13
+ testReference?: string;
14
+ testAmount?: number;
15
+ observedOriginCLABE?: string;
16
+ observedOriginAccountHolderName?: string;
17
+ verifiedAt?: Date;
18
+ verifiedVia?: ProcessorReadinessVerificationMethod;
19
+ verifiedByAdminId?: string;
20
+ verificationNote?: string;
21
+ }
22
+ interface ProcessorReadinessDoc extends Document {
23
+ createdAt: Date;
24
+ userId: string;
25
+ country: Country;
26
+ fiat: Fiat;
27
+ processor: Processor;
28
+ enablement?: ProcessorEnablement;
29
+ status: ProcessorReadinessStatus;
30
+ CLABE?: string;
31
+ testReference?: string;
32
+ testAmount?: number;
33
+ observedOriginCLABE?: string;
34
+ observedOriginAccountHolderName?: string;
35
+ verifiedAt?: Date;
36
+ verifiedVia?: ProcessorReadinessVerificationMethod;
37
+ verifiedByAdminId?: string;
38
+ verificationNote?: string;
39
+ }
40
+ interface ProcessorReadinessModel extends Model<ProcessorReadinessDoc> {
41
+ build(attrs: ProcessorReadinessAttrs): HydratedDocument<ProcessorReadinessDoc>;
42
+ }
43
+ declare const buildProcessorReadiness: (mongoose: Mongoose) => ProcessorReadinessModel;
44
+ export { buildProcessorReadiness, ProcessorReadinessDoc, ProcessorReadinessAttrs, };
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildProcessorReadiness = void 0;
4
+ // One user's relationship with one rail, along two independent axes: what they
5
+ // accept (enablement, per side, which order routing gates on) and what we have
6
+ // proven (status, from a penny test or a real payment). They are separate because
7
+ // a customer can be willing to use a rail nobody has tested, and a rail proven to
8
+ // work last year can stop working when their bank changes its whitelist.
9
+ const buildProcessorReadiness = (mongoose) => {
10
+ if (mongoose.models.ProcessorReadiness) {
11
+ return mongoose.model("ProcessorReadiness");
12
+ }
13
+ const ProcessorReadinessSchema = new mongoose.Schema({
14
+ userId: {
15
+ type: String,
16
+ required: true,
17
+ },
18
+ country: {
19
+ type: String,
20
+ required: true,
21
+ },
22
+ fiat: {
23
+ type: String,
24
+ required: true,
25
+ },
26
+ processor: {
27
+ type: String,
28
+ required: true,
29
+ },
30
+ status: {
31
+ type: String,
32
+ required: true,
33
+ },
34
+ // Keyed by side, with no default: an absent side means enabled, so a
35
+ // record written before a customer touched their settings keeps working.
36
+ // Free-form so a side can be added without a schema migration.
37
+ enablement: {
38
+ type: Object,
39
+ },
40
+ CLABE: {
41
+ type: String,
42
+ },
43
+ testReference: {
44
+ type: String,
45
+ index: { unique: true, sparse: true },
46
+ },
47
+ testAmount: {
48
+ type: Number,
49
+ },
50
+ observedOriginCLABE: {
51
+ type: String,
52
+ },
53
+ observedOriginAccountHolderName: {
54
+ type: String,
55
+ },
56
+ verifiedAt: {
57
+ type: mongoose.Schema.Types.Date,
58
+ },
59
+ verifiedVia: {
60
+ type: String,
61
+ },
62
+ verifiedByAdminId: {
63
+ type: String,
64
+ },
65
+ verificationNote: {
66
+ type: String,
67
+ },
68
+ createdAt: {
69
+ type: mongoose.Schema.Types.Date,
70
+ required: true,
71
+ },
72
+ }, {
73
+ toJSON: {
74
+ transform(doc, ret) {
75
+ ret.id = ret._id.valueOf();
76
+ delete ret._id;
77
+ delete ret.__v;
78
+ },
79
+ },
80
+ });
81
+ // One record per user per rail. Unique so concurrent provisioning attempts
82
+ // cannot create duplicates that disagree about status.
83
+ ProcessorReadinessSchema.index({ userId: 1, country: 1, fiat: 1, processor: 1 }, { unique: true });
84
+ ProcessorReadinessSchema.statics.build = (attrs) => {
85
+ return new ProcessorReadiness(attrs);
86
+ };
87
+ const ProcessorReadiness = mongoose.model("ProcessorReadiness", ProcessorReadinessSchema);
88
+ return ProcessorReadiness;
89
+ };
90
+ exports.buildProcessorReadiness = buildProcessorReadiness;
@@ -1,9 +1,10 @@
1
- import { Country, Fiat } from "@riocrypto/common";
1
+ import { Country, Fiat, Processor } from "@riocrypto/common";
2
2
  import { Mongoose, Model, Document, HydratedDocument } from "mongoose";
3
3
  interface RioBankAccountAttrs {
4
4
  createdAt: Date;
5
5
  country: Country;
6
6
  fiat: Fiat;
7
+ processor?: Processor;
7
8
  bankName?: string;
8
9
  companyName?: string;
9
10
  companyAddress?: string;
@@ -19,6 +20,7 @@ interface RioBankAccountDoc extends Document {
19
20
  createdAt: Date;
20
21
  country: Country;
21
22
  fiat: Fiat;
23
+ processor?: Processor;
22
24
  bankName?: string;
23
25
  companyName?: string;
24
26
  companyAddress?: string;
@@ -19,6 +19,9 @@ const buildRioBankAccount = (mongoose) => {
19
19
  type: String,
20
20
  required: true,
21
21
  },
22
+ processor: {
23
+ type: String,
24
+ },
22
25
  bankName: {
23
26
  type: String,
24
27
  },
@@ -1,4 +1,4 @@
1
- import { Country, Crypto, DeferredPaymentType, Fiat, FXProvider, FXTradingPolicies, Processor, Side } from "@riocrypto/common";
1
+ import { Country, Crypto, DeferredPaymentType, Fiat, FXProvider, FXTradingPolicies, ProcessorRoutingConfig, Side } from "@riocrypto/common";
2
2
  import { TVFXDataProvider } from "@riocrypto/common";
3
3
  import mongoose, { HydratedDocument } from "mongoose";
4
4
  interface RioSettingsAttrs {
@@ -54,11 +54,7 @@ interface RioSettingsAttrs {
54
54
  };
55
55
  };
56
56
  fxTradingPolicies?: FXTradingPolicies;
57
- activeFiatPaymentProcessors: {
58
- [Side.Buy]: Processor[];
59
- [Side.Sell]: Processor[];
60
- bankAccountVerifications: Processor[];
61
- };
57
+ processorRouting?: ProcessorRoutingConfig;
62
58
  TVFXDataProvider: {
63
59
  [key in Fiat]: TVFXDataProvider;
64
60
  };
@@ -152,11 +148,7 @@ interface RioSettingsDoc extends mongoose.Document {
152
148
  };
153
149
  };
154
150
  fxTradingPolicies?: FXTradingPolicies;
155
- activeFiatPaymentProcessors: {
156
- [Side.Buy]: Processor[];
157
- [Side.Sell]: Processor[];
158
- bankAccountVerifications: Processor[];
159
- };
151
+ processorRouting?: ProcessorRoutingConfig;
160
152
  TVFXDataProvider: {
161
153
  [key in Fiat]: TVFXDataProvider;
162
154
  };
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildRioSettings = void 0;
4
- const common_1 = require("@riocrypto/common");
5
4
  const buildRioSettings = (mongoose) => {
6
5
  // if model is already defined, return it
7
6
  if (mongoose.models.RioSettings) {
@@ -57,7 +56,7 @@ const buildRioSettings = (mongoose) => {
57
56
  defaultServiceFee: {
58
57
  type: Object,
59
58
  },
60
- activeFiatPaymentProcessors: {
59
+ processorRouting: {
61
60
  type: Object,
62
61
  },
63
62
  TVFXDataProvider: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2877",
3
+ "version": "1.0.2879",
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.2693",
31
+ "@riocrypto/common": "1.0.2699",
32
32
  "@slack/web-api": "^7.15.0",
33
33
  "@types/express": "^4.17.25",
34
34
  "axios": "1.18.1",