@riocrypto/common 1.0.2656 → 1.0.2658
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/errors/us-operations-disabled-error.d.ts +10 -0
- package/build/errors/us-operations-disabled-error.js +21 -0
- package/build/helpers/is-us-operations-enabled.d.ts +17 -0
- package/build/helpers/is-us-operations-enabled.js +26 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsOperationsDisabledError = void 0;
|
|
4
|
+
const custom_error_1 = require("./custom-error");
|
|
5
|
+
class UsOperationsDisabledError extends custom_error_1.CustomError {
|
|
6
|
+
constructor() {
|
|
7
|
+
super("US operations are temporarily unavailable");
|
|
8
|
+
this.statusCode = 403;
|
|
9
|
+
this.internalCode = 44;
|
|
10
|
+
Object.setPrototypeOf(this, UsOperationsDisabledError.prototype);
|
|
11
|
+
}
|
|
12
|
+
serializeErrors() {
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
code: this.internalCode,
|
|
16
|
+
message: "US operations are temporarily unavailable",
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.UsOperationsDisabledError = UsOperationsDisabledError;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Country } from "../types/country";
|
|
2
|
+
import { CountryOfOrigin } from "../types/country-of-origin";
|
|
3
|
+
/**
|
|
4
|
+
* Temporary kill switch for US operations while the commercial agreement with
|
|
5
|
+
* our US partner (Bridge) is paused. When this is `false`, users cannot create
|
|
6
|
+
* new US business (users, quotes, orders, bank accounts, transfers) and the US
|
|
7
|
+
* is hidden from country selectors in the UI. Read operations are unaffected.
|
|
8
|
+
*
|
|
9
|
+
* Set back to `true` to restore US support across the platform.
|
|
10
|
+
*/
|
|
11
|
+
export declare const US_OPERATIONS_ENABLED = false;
|
|
12
|
+
export declare const isUsCountry: (country?: Country | CountryOfOrigin | string | null) => boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Throws when a write operation targets the US while US operations are disabled.
|
|
15
|
+
* No-op for non-US countries and when US operations are enabled.
|
|
16
|
+
*/
|
|
17
|
+
export declare const assertUsOperationsEnabled: (country?: Country | CountryOfOrigin | string | null) => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertUsOperationsEnabled = exports.isUsCountry = exports.US_OPERATIONS_ENABLED = void 0;
|
|
4
|
+
const country_1 = require("../types/country");
|
|
5
|
+
const us_operations_disabled_error_1 = require("../errors/us-operations-disabled-error");
|
|
6
|
+
/**
|
|
7
|
+
* Temporary kill switch for US operations while the commercial agreement with
|
|
8
|
+
* our US partner (Bridge) is paused. When this is `false`, users cannot create
|
|
9
|
+
* new US business (users, quotes, orders, bank accounts, transfers) and the US
|
|
10
|
+
* is hidden from country selectors in the UI. Read operations are unaffected.
|
|
11
|
+
*
|
|
12
|
+
* Set back to `true` to restore US support across the platform.
|
|
13
|
+
*/
|
|
14
|
+
exports.US_OPERATIONS_ENABLED = false;
|
|
15
|
+
const isUsCountry = (country) => country === country_1.Country.UnitedStates;
|
|
16
|
+
exports.isUsCountry = isUsCountry;
|
|
17
|
+
/**
|
|
18
|
+
* Throws when a write operation targets the US while US operations are disabled.
|
|
19
|
+
* No-op for non-US countries and when US operations are enabled.
|
|
20
|
+
*/
|
|
21
|
+
const assertUsOperationsEnabled = (country) => {
|
|
22
|
+
if (!exports.US_OPERATIONS_ENABLED && (0, exports.isUsCountry)(country)) {
|
|
23
|
+
throw new us_operations_disabled_error_1.UsOperationsDisabledError();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
exports.assertUsOperationsEnabled = assertUsOperationsEnabled;
|
package/build/index.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export * from "./errors/expired-quote-error";
|
|
|
40
40
|
export * from "./errors/user-not-enabled-in-us-error";
|
|
41
41
|
export * from "./errors/above-limit-error";
|
|
42
42
|
export * from "./errors/onboarding-not-approved-error";
|
|
43
|
+
export * from "./errors/us-operations-disabled-error";
|
|
43
44
|
export * from "./events/base-listener";
|
|
44
45
|
export * from "./events/base-publisher";
|
|
45
46
|
export * from "./events/subjects";
|
|
@@ -561,5 +562,6 @@ export * from "./helpers/get-two-way-settlement-date-offset-from-date";
|
|
|
561
562
|
export * from "./helpers/get-two-way-settlement-date";
|
|
562
563
|
export * from "./helpers/get-order-status-rankings";
|
|
563
564
|
export * from "./helpers/get-lower-order-statuses";
|
|
565
|
+
export * from "./helpers/is-us-operations-enabled";
|
|
564
566
|
export * from "./constants/mexico-fiscal-regimens";
|
|
565
567
|
export * from "./constants/mexican-banks";
|
package/build/index.js
CHANGED
|
@@ -56,6 +56,7 @@ __exportStar(require("./errors/expired-quote-error"), exports);
|
|
|
56
56
|
__exportStar(require("./errors/user-not-enabled-in-us-error"), exports);
|
|
57
57
|
__exportStar(require("./errors/above-limit-error"), exports);
|
|
58
58
|
__exportStar(require("./errors/onboarding-not-approved-error"), exports);
|
|
59
|
+
__exportStar(require("./errors/us-operations-disabled-error"), exports);
|
|
59
60
|
__exportStar(require("./events/base-listener"), exports);
|
|
60
61
|
__exportStar(require("./events/base-publisher"), exports);
|
|
61
62
|
__exportStar(require("./events/subjects"), exports);
|
|
@@ -577,5 +578,6 @@ __exportStar(require("./helpers/get-two-way-settlement-date-offset-from-date"),
|
|
|
577
578
|
__exportStar(require("./helpers/get-two-way-settlement-date"), exports);
|
|
578
579
|
__exportStar(require("./helpers/get-order-status-rankings"), exports);
|
|
579
580
|
__exportStar(require("./helpers/get-lower-order-statuses"), exports);
|
|
581
|
+
__exportStar(require("./helpers/is-us-operations-enabled"), exports);
|
|
580
582
|
__exportStar(require("./constants/mexico-fiscal-regimens"), exports);
|
|
581
583
|
__exportStar(require("./constants/mexican-banks"), exports);
|