b2b-platform-utils 1.1.99 → 1.1.101
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/errorsMap.js +24 -0
- package/financialAdmissionPlan.js +4 -2
- package/package.json +1 -1
package/errorsMap.js
CHANGED
|
@@ -1842,6 +1842,30 @@ const STATIC_ERRORS = [
|
|
|
1842
1842
|
httpCode: 422,
|
|
1843
1843
|
description: "Risk permission conditions contain an unsupported permission or condition.",
|
|
1844
1844
|
},
|
|
1845
|
+
{
|
|
1846
|
+
errorCode: 1300,
|
|
1847
|
+
errorKey: "withdrawalTwoFaChallengeRequired",
|
|
1848
|
+
httpCode: 422,
|
|
1849
|
+
description: "Withdrawal requires a valid authenticator code. No withdrawal was created.",
|
|
1850
|
+
},
|
|
1851
|
+
{
|
|
1852
|
+
errorCode: 1301,
|
|
1853
|
+
errorKey: "withdrawalTwoFaSetupRequired",
|
|
1854
|
+
httpCode: 422,
|
|
1855
|
+
description: "Withdrawal requires authenticator enrollment. No withdrawal was created.",
|
|
1856
|
+
},
|
|
1857
|
+
{
|
|
1858
|
+
errorCode: 1302,
|
|
1859
|
+
errorKey: "withdrawalTwoFaInvalidOtp",
|
|
1860
|
+
httpCode: 422,
|
|
1861
|
+
description: "Withdrawal authenticator code is incorrect. Another attempt is allowed.",
|
|
1862
|
+
},
|
|
1863
|
+
{
|
|
1864
|
+
errorCode: 1303,
|
|
1865
|
+
errorKey: "withdrawalTwoFaChallengeExpired",
|
|
1866
|
+
httpCode: 422,
|
|
1867
|
+
description: "Withdrawal authenticator challenge expired or was invalidated.",
|
|
1868
|
+
},
|
|
1845
1869
|
];
|
|
1846
1870
|
|
|
1847
1871
|
const STATIC_BY_KEY = Object.fromEntries(
|
|
@@ -4,6 +4,8 @@ const { createHash } = require('node:crypto');
|
|
|
4
4
|
const A = require('./financialAdmissionMath');
|
|
5
5
|
const failure = (code) => Object.assign(new TypeError(code), { code });
|
|
6
6
|
const sequence = (v) => typeof v === 'string' && /^(0|[1-9]\d{0,35})$/.test(v);
|
|
7
|
+
// AccountPrecisionState/Entry.precision_version is an existing signed SQL BIGINT.
|
|
8
|
+
const precisionVersion = (v) => sequence(v) && BigInt(v) <= 9223372036854775807n;
|
|
7
9
|
const minor = (v) => typeof v === 'string' && v !== '-0' && /^-?(0|[1-9]\d{0,35})$/.test(v);
|
|
8
10
|
const id = (v) => typeof v === 'string' && v.length > 0 && v.length <= 200 && !/[\x00-\x1f\x7f]/.test(v);
|
|
9
11
|
const fingerprint = (v) => typeof v === 'string' && /^[a-f0-9]{64}$/.test(v);
|
|
@@ -50,7 +52,7 @@ function state(value) {
|
|
|
50
52
|
throw failure('financial_admission_state_invalid');
|
|
51
53
|
for (const prefix of ['cash', 'bonus']) {
|
|
52
54
|
const r = fraction(value[`${prefix}RemainderNumerator`], value[`${prefix}RemainderDenominator`]);
|
|
53
|
-
if (!
|
|
55
|
+
if (!precisionVersion(value[`${prefix}PrecisionVersion`]) || (prefix === 'cash' && (r.n < 0n || r.n >= r.d)))
|
|
54
56
|
throw failure('financial_admission_state_invalid');
|
|
55
57
|
}
|
|
56
58
|
return Object.fromEntries(STATE_FIELDS.map((field) => [field, value[field]]));
|
|
@@ -117,7 +119,7 @@ function preparePlan(input) {
|
|
|
117
119
|
after[`${bucket}RemainderNumerator`] = String(next.remainder.n);
|
|
118
120
|
after[`${bucket}RemainderDenominator`] = String(next.remainder.d);
|
|
119
121
|
after[`${bucket}PrecisionVersion`] = String(BigInt(after[`${bucket}PrecisionVersion`]) + (dr.n === 0n ? 0n : 1n));
|
|
120
|
-
if (!
|
|
122
|
+
if (!precisionVersion(after[`${bucket}PrecisionVersion`])) throw failure('financial_admission_version_exhausted');
|
|
121
123
|
// Existing RG eligibility is based on actual real-wallet debit, not bonus.
|
|
122
124
|
// Freespin/free-bet/session eligibility still belongs to the caller's
|
|
123
125
|
// established policy checks, independently verified by Payment.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "b2b-platform-utils",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.101",
|
|
4
4
|
"description": "Shared utilities for Node.js microservices: errors map, local cache, logger, numbers, dates, filesystem, media optimization, paginator, slugger, crypto wrapper, sanitize HTML, sorting.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"license": "KingSizer",
|