vesant-sdk 1.6.0 → 1.6.2
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/dist/{client-C4g596fI.d.mts → client-BlCxjbY2.d.mts} +8 -2
- package/dist/{client-Bd9a5o0C.d.ts → client-C_A7QLcB.d.ts} +8 -2
- package/dist/{client-CIon-bGS.d.mts → client-ePzhQKp9.d.mts} +2 -0
- package/dist/{client-CIon-bGS.d.ts → client-ePzhQKp9.d.ts} +2 -0
- package/dist/compliance/index.d.mts +12 -5
- package/dist/compliance/index.d.ts +12 -5
- package/dist/compliance/index.js +201 -69
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +201 -69
- package/dist/compliance/index.mjs.map +1 -1
- package/dist/decisions/index.d.mts +1 -1
- package/dist/decisions/index.d.ts +1 -1
- package/dist/decisions/index.js +14 -1
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisions/index.mjs +14 -1
- package/dist/decisions/index.mjs.map +1 -1
- package/dist/geolocation/index.d.mts +3 -3
- package/dist/geolocation/index.d.ts +3 -3
- package/dist/geolocation/index.js +56 -14
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +56 -14
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index.d.mts +6 -376
- package/dist/index.d.ts +6 -376
- package/dist/index.js +268 -278
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +268 -278
- package/dist/index.mjs.map +1 -1
- package/dist/kyc/core.d.mts +1 -1
- package/dist/kyc/core.d.ts +1 -1
- package/dist/kyc/core.js +14 -1
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +14 -1
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.d.mts +1 -1
- package/dist/kyc/index.d.ts +1 -1
- package/dist/kyc/index.js +14 -1
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +14 -1
- package/dist/kyc/index.mjs.map +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +1 -1
- package/dist/react.mjs.map +1 -1
- package/dist/risk-profile/index.d.mts +1 -1
- package/dist/risk-profile/index.d.ts +1 -1
- package/dist/risk-profile/index.js +14 -1
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +14 -1
- package/dist/risk-profile/index.mjs.map +1 -1
- package/dist/scores/index.d.mts +1 -1
- package/dist/scores/index.d.ts +1 -1
- package/dist/scores/index.js +14 -1
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/index.mjs +14 -1
- package/dist/scores/index.mjs.map +1 -1
- package/dist/tax/index.d.mts +255 -0
- package/dist/tax/index.d.ts +255 -0
- package/dist/tax/index.js +652 -0
- package/dist/tax/index.js.map +1 -0
- package/dist/tax/index.mjs +650 -0
- package/dist/tax/index.mjs.map +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -242,7 +242,7 @@ var noopLogger = {
|
|
|
242
242
|
};
|
|
243
243
|
|
|
244
244
|
// src/core/version.ts
|
|
245
|
-
var SDK_VERSION = "1.6.
|
|
245
|
+
var SDK_VERSION = "1.6.2";
|
|
246
246
|
|
|
247
247
|
// src/shared/browser-utils.ts
|
|
248
248
|
function generateUUID() {
|
|
@@ -416,6 +416,19 @@ var BaseClient = class {
|
|
|
416
416
|
if (this.rateLimitTracker) {
|
|
417
417
|
this.rateLimitTracker.updateFromHeaders(response.headers);
|
|
418
418
|
}
|
|
419
|
+
if (requestOptions?.responseType === "arraybuffer") {
|
|
420
|
+
if (!response.ok) {
|
|
421
|
+
let errData = {};
|
|
422
|
+
try {
|
|
423
|
+
errData = await response.json();
|
|
424
|
+
} catch {
|
|
425
|
+
}
|
|
426
|
+
this.handleErrorResponse(response.status, errData, requestId);
|
|
427
|
+
}
|
|
428
|
+
this.circuitBreaker?.onSuccess();
|
|
429
|
+
const buffer = await response.arrayBuffer();
|
|
430
|
+
return buffer;
|
|
431
|
+
}
|
|
419
432
|
let data;
|
|
420
433
|
try {
|
|
421
434
|
data = await response.json();
|
|
@@ -1110,22 +1123,51 @@ var GeolocationClient = class extends BaseClient {
|
|
|
1110
1123
|
void 0,
|
|
1111
1124
|
requestOptions
|
|
1112
1125
|
);
|
|
1113
|
-
const
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1126
|
+
const loc = cipherTextResult.location;
|
|
1127
|
+
const risk = cipherTextResult.risk;
|
|
1128
|
+
if (!risk) {
|
|
1129
|
+
const locationResult = await this.verifyIP({
|
|
1130
|
+
ip_address: ipAddress,
|
|
1131
|
+
user_id: userId,
|
|
1132
|
+
event_type: eventType
|
|
1133
|
+
}, requestOptions);
|
|
1134
|
+
return {
|
|
1135
|
+
ciphertext_valid: cipherTextResult.valid,
|
|
1136
|
+
ciphertext_result: cipherTextResult,
|
|
1137
|
+
location: locationResult
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1140
|
+
const location = {
|
|
1141
|
+
ip_address: cipherTextResult.ip_address,
|
|
1142
|
+
location: {
|
|
1143
|
+
country: loc?.country ?? "",
|
|
1144
|
+
country_iso: loc?.country_iso ?? "",
|
|
1145
|
+
city: loc?.city ?? "",
|
|
1146
|
+
region: loc?.region ?? "",
|
|
1147
|
+
postal_code: "",
|
|
1148
|
+
latitude: loc?.latitude ?? 0,
|
|
1149
|
+
longitude: loc?.longitude ?? 0,
|
|
1150
|
+
timezone: "",
|
|
1151
|
+
is_vpn: risk.is_vpn ?? false,
|
|
1152
|
+
is_proxy: risk.is_proxy ?? false,
|
|
1153
|
+
is_tor: risk.is_tor ?? false,
|
|
1154
|
+
is_hosting: risk.is_hosting ?? false,
|
|
1155
|
+
is_anonymizer: risk.is_vpn || risk.is_proxy || risk.is_tor
|
|
1156
|
+
},
|
|
1157
|
+
is_compliant: cipherTextResult.is_compliant ?? !risk.is_blocked,
|
|
1158
|
+
is_blocked: risk.is_blocked ?? false,
|
|
1159
|
+
risk_level: risk.level ?? "low",
|
|
1160
|
+
risk_score: risk.score ?? 0,
|
|
1161
|
+
risk_reasons: risk.is_blocked && risk.block_reasons ? risk.block_reasons : risk.factors ?? [],
|
|
1162
|
+
jurisdiction: cipherTextResult.jurisdiction,
|
|
1163
|
+
geofence_evaluation: cipherTextResult.geofence_evaluation,
|
|
1164
|
+
record_id: cipherTextResult.record_id ?? "",
|
|
1165
|
+
gps_required: cipherTextResult.gps_required
|
|
1166
|
+
};
|
|
1125
1167
|
return {
|
|
1126
1168
|
ciphertext_valid: cipherTextResult.valid,
|
|
1127
1169
|
ciphertext_result: cipherTextResult,
|
|
1128
|
-
location
|
|
1170
|
+
location
|
|
1129
1171
|
};
|
|
1130
1172
|
}
|
|
1131
1173
|
// ============================================================================
|
|
@@ -1530,28 +1572,34 @@ var ComplianceClient = class {
|
|
|
1530
1572
|
if (this.config.debug) {
|
|
1531
1573
|
this.logger.debug("Starting registration verification", { customerId: request.customerId });
|
|
1532
1574
|
}
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
email: request.emailAddress,
|
|
1536
|
-
phone: request.phoneNumber,
|
|
1537
|
-
date_of_birth: request.dateOfBirth
|
|
1538
|
-
} : void 0;
|
|
1539
|
-
[cipherTextResult, geoVerification] = await Promise.all([
|
|
1540
|
-
this.executeCipherTextValidation(
|
|
1575
|
+
if (request.cipherText) {
|
|
1576
|
+
cipherTextResult = await this.executeCipherTextValidation(
|
|
1541
1577
|
request.cipherText,
|
|
1542
1578
|
request.customerId,
|
|
1543
1579
|
"registration",
|
|
1544
1580
|
request.ipAddress,
|
|
1545
|
-
|
|
1581
|
+
{
|
|
1582
|
+
full_name: request.fullName,
|
|
1583
|
+
email: request.emailAddress,
|
|
1584
|
+
phone: request.phoneNumber,
|
|
1585
|
+
date_of_birth: request.dateOfBirth
|
|
1586
|
+
},
|
|
1546
1587
|
requestOptions
|
|
1547
|
-
)
|
|
1548
|
-
this.geoClient.verifyIP({
|
|
1588
|
+
);
|
|
1589
|
+
geoVerification = (cipherTextResult && this.buildLocationFromCipherText(cipherTextResult, request.ipAddress)) ?? await this.geoClient.verifyIP({
|
|
1549
1590
|
ip_address: request.ipAddress,
|
|
1550
1591
|
user_id: request.customerId,
|
|
1551
1592
|
event_type: "registration",
|
|
1552
1593
|
device_fingerprint: request.deviceFingerprint
|
|
1553
|
-
}, requestOptions)
|
|
1554
|
-
|
|
1594
|
+
}, requestOptions);
|
|
1595
|
+
} else {
|
|
1596
|
+
geoVerification = await this.geoClient.verifyIP({
|
|
1597
|
+
ip_address: request.ipAddress,
|
|
1598
|
+
user_id: request.customerId,
|
|
1599
|
+
event_type: "registration",
|
|
1600
|
+
device_fingerprint: request.deviceFingerprint
|
|
1601
|
+
}, requestOptions);
|
|
1602
|
+
}
|
|
1555
1603
|
const blockReasons = this.evaluateRegistrationBlock(geoVerification, cipherTextResult);
|
|
1556
1604
|
if (blockReasons.length > 0) {
|
|
1557
1605
|
if (this.config.debug) {
|
|
@@ -1632,7 +1680,7 @@ var ComplianceClient = class {
|
|
|
1632
1680
|
evaluateRegistrationBlock(geoVerification, cipherTextResult) {
|
|
1633
1681
|
const blockReasons = [];
|
|
1634
1682
|
if (geoVerification.is_blocked) {
|
|
1635
|
-
blockReasons.push(...geoVerification.risk_reasons);
|
|
1683
|
+
blockReasons.push(...geoVerification.risk_reasons ?? []);
|
|
1636
1684
|
}
|
|
1637
1685
|
if (!geoVerification.is_compliant) {
|
|
1638
1686
|
if (!blockReasons.includes("non_compliant_jurisdiction")) {
|
|
@@ -1656,7 +1704,7 @@ var ComplianceClient = class {
|
|
|
1656
1704
|
}
|
|
1657
1705
|
}
|
|
1658
1706
|
if (geoVerification.geofence_evaluation?.blocked) {
|
|
1659
|
-
blockReasons.push(...geoVerification.geofence_evaluation.reasons);
|
|
1707
|
+
blockReasons.push(...geoVerification.geofence_evaluation.reasons ?? []);
|
|
1660
1708
|
}
|
|
1661
1709
|
if (geoVerification.risk_level === "critical") {
|
|
1662
1710
|
if (!blockReasons.includes("critical_risk_level")) {
|
|
@@ -1807,24 +1855,40 @@ var ComplianceClient = class {
|
|
|
1807
1855
|
if (this.config.debug) {
|
|
1808
1856
|
this.logger.debug("Starting login verification", { customerId: request.customerId });
|
|
1809
1857
|
}
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1858
|
+
let cipherTextResult;
|
|
1859
|
+
let geoVerification;
|
|
1860
|
+
let profileResult;
|
|
1861
|
+
if (request.cipherText) {
|
|
1862
|
+
[cipherTextResult, profileResult] = await Promise.all([
|
|
1863
|
+
this.executeCipherTextValidation(
|
|
1864
|
+
request.cipherText,
|
|
1865
|
+
request.customerId,
|
|
1866
|
+
"login",
|
|
1867
|
+
request.ipAddress,
|
|
1868
|
+
void 0,
|
|
1869
|
+
requestOptions
|
|
1870
|
+
),
|
|
1871
|
+
this.riskClient.getProfile(request.customerId, requestOptions).catch(() => null)
|
|
1872
|
+
]);
|
|
1873
|
+
geoVerification = (cipherTextResult && this.buildLocationFromCipherText(cipherTextResult, request.ipAddress)) ?? await this.geoClient.verifyIP({
|
|
1820
1874
|
ip_address: request.ipAddress,
|
|
1821
1875
|
user_id: request.customerId,
|
|
1822
1876
|
event_type: "login",
|
|
1823
1877
|
device_fingerprint: request.deviceFingerprint
|
|
1824
|
-
}, requestOptions)
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1878
|
+
}, requestOptions);
|
|
1879
|
+
} else {
|
|
1880
|
+
[, geoVerification, profileResult] = await Promise.all([
|
|
1881
|
+
Promise.resolve(void 0),
|
|
1882
|
+
this.geoClient.verifyIP({
|
|
1883
|
+
ip_address: request.ipAddress,
|
|
1884
|
+
user_id: request.customerId,
|
|
1885
|
+
event_type: "login",
|
|
1886
|
+
device_fingerprint: request.deviceFingerprint
|
|
1887
|
+
}, requestOptions),
|
|
1888
|
+
this.riskClient.getProfile(request.customerId, requestOptions).catch(() => null)
|
|
1889
|
+
]);
|
|
1890
|
+
}
|
|
1891
|
+
const loginBlockReasons = this.getBlockReasons(geoVerification, profileResult, cipherTextResult);
|
|
1828
1892
|
const isBlocked = !geoVerification.is_compliant || geoVerification.is_blocked || !!cipherTextResult?.risk?.is_blocked || cipherTextResult?.valid === false || geoVerification.gps_required && !cipherTextResult;
|
|
1829
1893
|
if (isBlocked && !profileResult) {
|
|
1830
1894
|
return {
|
|
@@ -1908,23 +1972,39 @@ var ComplianceClient = class {
|
|
|
1908
1972
|
currency: request.currency
|
|
1909
1973
|
});
|
|
1910
1974
|
}
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1975
|
+
let cipherTextResult;
|
|
1976
|
+
let geoVerification;
|
|
1977
|
+
let profileResult;
|
|
1978
|
+
if (request.cipherText) {
|
|
1979
|
+
[cipherTextResult, profileResult] = await Promise.all([
|
|
1980
|
+
this.executeCipherTextValidation(
|
|
1981
|
+
request.cipherText,
|
|
1982
|
+
request.customerId,
|
|
1983
|
+
"transaction",
|
|
1984
|
+
request.ipAddress,
|
|
1985
|
+
void 0,
|
|
1986
|
+
requestOptions
|
|
1987
|
+
),
|
|
1988
|
+
this.riskClient.getProfile(request.customerId, requestOptions).catch(() => null)
|
|
1989
|
+
]);
|
|
1990
|
+
geoVerification = (cipherTextResult && this.buildLocationFromCipherText(cipherTextResult, request.ipAddress)) ?? await this.geoClient.verifyIP({
|
|
1921
1991
|
ip_address: request.ipAddress,
|
|
1922
1992
|
user_id: request.customerId,
|
|
1923
1993
|
event_type: "transaction",
|
|
1924
1994
|
device_fingerprint: request.deviceFingerprint
|
|
1925
|
-
}, requestOptions)
|
|
1926
|
-
|
|
1927
|
-
|
|
1995
|
+
}, requestOptions);
|
|
1996
|
+
} else {
|
|
1997
|
+
[, geoVerification, profileResult] = await Promise.all([
|
|
1998
|
+
Promise.resolve(void 0),
|
|
1999
|
+
this.geoClient.verifyIP({
|
|
2000
|
+
ip_address: request.ipAddress,
|
|
2001
|
+
user_id: request.customerId,
|
|
2002
|
+
event_type: "transaction",
|
|
2003
|
+
device_fingerprint: request.deviceFingerprint
|
|
2004
|
+
}, requestOptions),
|
|
2005
|
+
this.riskClient.getProfile(request.customerId, requestOptions).catch(() => null)
|
|
2006
|
+
]);
|
|
2007
|
+
}
|
|
1928
2008
|
const geoBlocked = !geoVerification.is_compliant || geoVerification.is_blocked || !!cipherTextResult?.risk?.is_blocked || cipherTextResult?.valid === false || geoVerification.gps_required && !cipherTextResult;
|
|
1929
2009
|
if (geoBlocked && !profileResult) {
|
|
1930
2010
|
return {
|
|
@@ -1943,6 +2023,9 @@ var ComplianceClient = class {
|
|
|
1943
2023
|
cipherTextValidation: cipherTextResult
|
|
1944
2024
|
};
|
|
1945
2025
|
}
|
|
2026
|
+
if (!profileResult) {
|
|
2027
|
+
throw new ComplianceError("Customer profile not found", request.customerId);
|
|
2028
|
+
}
|
|
1946
2029
|
const profile = profileResult;
|
|
1947
2030
|
const transactionRisk = this.calculateTransactionRisk(
|
|
1948
2031
|
request.amount,
|
|
@@ -1985,22 +2068,31 @@ var ComplianceClient = class {
|
|
|
1985
2068
|
async verifyEvent(request, requestOptions) {
|
|
1986
2069
|
const startTime = Date.now();
|
|
1987
2070
|
this.validateEventRequest(request);
|
|
1988
|
-
|
|
1989
|
-
|
|
2071
|
+
let cipherTextResult;
|
|
2072
|
+
let geoVerification;
|
|
2073
|
+
if (request.cipherText) {
|
|
2074
|
+
cipherTextResult = await this.executeCipherTextValidation(
|
|
1990
2075
|
request.cipherText,
|
|
1991
2076
|
request.customerId,
|
|
1992
2077
|
request.eventType,
|
|
1993
2078
|
request.ipAddress,
|
|
1994
2079
|
void 0,
|
|
1995
2080
|
requestOptions
|
|
1996
|
-
)
|
|
1997
|
-
this.geoClient.verifyIP({
|
|
2081
|
+
);
|
|
2082
|
+
geoVerification = (cipherTextResult && this.buildLocationFromCipherText(cipherTextResult, request.ipAddress)) ?? await this.geoClient.verifyIP({
|
|
1998
2083
|
ip_address: request.ipAddress,
|
|
1999
2084
|
user_id: request.customerId,
|
|
2000
2085
|
event_type: request.eventType,
|
|
2001
2086
|
device_fingerprint: request.deviceFingerprint
|
|
2002
|
-
}, requestOptions)
|
|
2003
|
-
|
|
2087
|
+
}, requestOptions);
|
|
2088
|
+
} else {
|
|
2089
|
+
geoVerification = await this.geoClient.verifyIP({
|
|
2090
|
+
ip_address: request.ipAddress,
|
|
2091
|
+
user_id: request.customerId,
|
|
2092
|
+
event_type: request.eventType,
|
|
2093
|
+
device_fingerprint: request.deviceFingerprint
|
|
2094
|
+
}, requestOptions);
|
|
2095
|
+
}
|
|
2004
2096
|
if (this.config.autoCreateProfiles) {
|
|
2005
2097
|
try {
|
|
2006
2098
|
const profile = await this.riskClient.getProfile(request.customerId, requestOptions);
|
|
@@ -2014,7 +2106,7 @@ var ComplianceClient = class {
|
|
|
2014
2106
|
}
|
|
2015
2107
|
}
|
|
2016
2108
|
const cipherTextBlocked = cipherTextResult ? !cipherTextResult.valid || cipherTextResult.risk?.is_blocked === true : false;
|
|
2017
|
-
const blockReasons = [...geoVerification.risk_reasons];
|
|
2109
|
+
const blockReasons = [...geoVerification.risk_reasons ?? []];
|
|
2018
2110
|
if (cipherTextResult) {
|
|
2019
2111
|
if (!cipherTextResult.valid) {
|
|
2020
2112
|
blockReasons.push("ciphertext_validation_failed");
|
|
@@ -2083,6 +2175,44 @@ var ComplianceClient = class {
|
|
|
2083
2175
|
return void 0;
|
|
2084
2176
|
}
|
|
2085
2177
|
}
|
|
2178
|
+
/**
|
|
2179
|
+
* Build a LocationVerification from a ValidateCipherTextResponse.
|
|
2180
|
+
* The validate-ciphertext endpoint now returns the full geo-verification data
|
|
2181
|
+
* (is_compliant, jurisdiction, geofence_evaluation, record_id, gps_required),
|
|
2182
|
+
* so a separate verifyIP call is unnecessary.
|
|
2183
|
+
*/
|
|
2184
|
+
buildLocationFromCipherText(ct, ipAddress) {
|
|
2185
|
+
const loc = ct.location;
|
|
2186
|
+
const risk = ct.risk;
|
|
2187
|
+
if (!risk) return null;
|
|
2188
|
+
return {
|
|
2189
|
+
ip_address: ct.ip_address || ipAddress,
|
|
2190
|
+
location: {
|
|
2191
|
+
country: loc?.country ?? "",
|
|
2192
|
+
country_iso: loc?.country_iso ?? "",
|
|
2193
|
+
city: loc?.city ?? "",
|
|
2194
|
+
region: loc?.region ?? "",
|
|
2195
|
+
postal_code: "",
|
|
2196
|
+
latitude: loc?.latitude ?? 0,
|
|
2197
|
+
longitude: loc?.longitude ?? 0,
|
|
2198
|
+
timezone: "",
|
|
2199
|
+
is_vpn: risk.is_vpn,
|
|
2200
|
+
is_proxy: risk.is_proxy,
|
|
2201
|
+
is_tor: risk.is_tor,
|
|
2202
|
+
is_hosting: risk.is_hosting ?? false,
|
|
2203
|
+
is_anonymizer: risk.is_vpn || risk.is_proxy || risk.is_tor
|
|
2204
|
+
},
|
|
2205
|
+
is_compliant: ct.is_compliant ?? !risk.is_blocked,
|
|
2206
|
+
is_blocked: risk.is_blocked,
|
|
2207
|
+
risk_level: risk.level,
|
|
2208
|
+
risk_score: risk.score,
|
|
2209
|
+
risk_reasons: risk.is_blocked && risk.block_reasons ? risk.block_reasons : risk.factors ?? [],
|
|
2210
|
+
jurisdiction: ct.jurisdiction,
|
|
2211
|
+
geofence_evaluation: ct.geofence_evaluation,
|
|
2212
|
+
record_id: ct.record_id ?? "",
|
|
2213
|
+
gps_required: ct.gps_required
|
|
2214
|
+
};
|
|
2215
|
+
}
|
|
2086
2216
|
calculateTransactionRisk(amount, currency, geoVerification, profile, cipherTextResult) {
|
|
2087
2217
|
if (!this._currencyRatesCustomized && !this._currencyRatesWarned) {
|
|
2088
2218
|
this._currencyRatesWarned = true;
|
|
@@ -2153,13 +2283,15 @@ var ComplianceClient = class {
|
|
|
2153
2283
|
getBlockReasons(geoVerification, profile, cipherTextResult) {
|
|
2154
2284
|
const reasons = [];
|
|
2155
2285
|
if (geoVerification.is_blocked) {
|
|
2156
|
-
reasons.push(...geoVerification.risk_reasons);
|
|
2157
|
-
}
|
|
2158
|
-
if (profile.customer_status === "suspended") {
|
|
2159
|
-
reasons.push("account_suspended");
|
|
2286
|
+
reasons.push(...geoVerification.risk_reasons ?? []);
|
|
2160
2287
|
}
|
|
2161
|
-
if (profile
|
|
2162
|
-
|
|
2288
|
+
if (profile) {
|
|
2289
|
+
if (profile.customer_status === "suspended") {
|
|
2290
|
+
reasons.push("account_suspended");
|
|
2291
|
+
}
|
|
2292
|
+
if (profile.has_sanctions) {
|
|
2293
|
+
reasons.push("sanctions_match");
|
|
2294
|
+
}
|
|
2163
2295
|
}
|
|
2164
2296
|
if (cipherTextResult) {
|
|
2165
2297
|
if (!cipherTextResult.valid) {
|
|
@@ -3017,235 +3149,93 @@ var TaxClient = class extends BaseClient {
|
|
|
3017
3149
|
};
|
|
3018
3150
|
super(baseConfig);
|
|
3019
3151
|
}
|
|
3020
|
-
//
|
|
3021
|
-
// Tax
|
|
3022
|
-
//
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
*
|
|
3028
|
-
* @example
|
|
3029
|
-
* ```typescript
|
|
3030
|
-
* const config = await client.getTaxConfig();
|
|
3031
|
-
* console.log(`Tax enabled: ${config.tax_enabled}`);
|
|
3032
|
-
* ```
|
|
3033
|
-
*/
|
|
3034
|
-
async getTaxConfig() {
|
|
3035
|
-
const res = await this.request("/api/v1/tax/config");
|
|
3036
|
-
return res.tax_config;
|
|
3152
|
+
// ==========================================================================
|
|
3153
|
+
// P1 — Customer Tax Profile (core compliance flow)
|
|
3154
|
+
// ==========================================================================
|
|
3155
|
+
async getCustomerTaxProfileRecord(customerID) {
|
|
3156
|
+
return this.request(
|
|
3157
|
+
`/api/v1/tax/customer-tax-profiles/${customerID}`
|
|
3158
|
+
);
|
|
3037
3159
|
}
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
*
|
|
3044
|
-
* @example
|
|
3045
|
-
* ```typescript
|
|
3046
|
-
* // Enable tax
|
|
3047
|
-
* const config = await client.updateTaxConfig({ tax_enabled: true });
|
|
3048
|
-
*
|
|
3049
|
-
* // Disable tax
|
|
3050
|
-
* const config = await client.updateTaxConfig({ tax_enabled: false });
|
|
3051
|
-
* ```
|
|
3052
|
-
*/
|
|
3053
|
-
async updateTaxConfig(request) {
|
|
3054
|
-
const res = await this.request("/api/v1/tax/config", {
|
|
3055
|
-
method: "PUT",
|
|
3056
|
-
body: JSON.stringify({ tax_config: request })
|
|
3057
|
-
});
|
|
3058
|
-
return res.tax_config;
|
|
3160
|
+
async requestTaxForm(customerID) {
|
|
3161
|
+
return this.request(
|
|
3162
|
+
`/api/v1/tax/customer-tax-profiles/${customerID}/request-form`,
|
|
3163
|
+
{ method: "POST" }
|
|
3164
|
+
);
|
|
3059
3165
|
}
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
* Get solicitation triggers for the tenant
|
|
3065
|
-
*
|
|
3066
|
-
* @returns List of solicitation triggers with their enabled state
|
|
3067
|
-
*
|
|
3068
|
-
* @example
|
|
3069
|
-
* ```typescript
|
|
3070
|
-
* const triggers = await client.getSolicitationTriggers();
|
|
3071
|
-
* triggers.forEach(t => console.log(`${t.label}: ${t.enabled}`));
|
|
3072
|
-
* ```
|
|
3073
|
-
*/
|
|
3074
|
-
async getSolicitationTriggers() {
|
|
3075
|
-
const res = await this.request(
|
|
3076
|
-
"/api/v1/tax/solicitation/config"
|
|
3166
|
+
async checkTINStatus(customerID) {
|
|
3167
|
+
return this.requestWithRetry(
|
|
3168
|
+
`/api/v1/tax/customer-tax-profiles/${customerID}/check-tin`,
|
|
3169
|
+
{ method: "POST" }
|
|
3077
3170
|
);
|
|
3078
|
-
return res.solicitation_triggers;
|
|
3079
3171
|
}
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
* @param triggers - Array of triggers with updated enabled/threshold values
|
|
3084
|
-
* @returns Updated triggers
|
|
3085
|
-
*
|
|
3086
|
-
* @example
|
|
3087
|
-
* ```typescript
|
|
3088
|
-
* const triggers = await client.updateSolicitationTriggers([
|
|
3089
|
-
* { type: 'first_withdrawal', enabled: true, label: 'First Withdrawal', description: '...' },
|
|
3090
|
-
* { type: 'threshold_based', enabled: true, label: 'Threshold', description: '...', threshold_amount: 600 },
|
|
3091
|
-
* ]);
|
|
3092
|
-
* ```
|
|
3093
|
-
*/
|
|
3094
|
-
async updateSolicitationTriggers(triggers) {
|
|
3095
|
-
const res = await this.request(
|
|
3096
|
-
"/api/v1/tax/solicitation/config",
|
|
3172
|
+
async reRequestTaxForm(customerID, input) {
|
|
3173
|
+
return this.request(
|
|
3174
|
+
`/api/v1/tax/customer-tax-profiles/${customerID}/re-request-form`,
|
|
3097
3175
|
{
|
|
3098
|
-
method: "
|
|
3099
|
-
body: JSON.stringify(
|
|
3176
|
+
method: "POST",
|
|
3177
|
+
body: JSON.stringify(input)
|
|
3100
3178
|
}
|
|
3101
3179
|
);
|
|
3102
|
-
return res.solicitation_triggers;
|
|
3103
|
-
}
|
|
3104
|
-
// ============================================================================
|
|
3105
|
-
// Reminder Configuration
|
|
3106
|
-
// ============================================================================
|
|
3107
|
-
/**
|
|
3108
|
-
* Get the reminder configuration for the tenant
|
|
3109
|
-
*
|
|
3110
|
-
* @returns Reminder config (enabled, max_reminders, frequency_days)
|
|
3111
|
-
*
|
|
3112
|
-
* @example
|
|
3113
|
-
* ```typescript
|
|
3114
|
-
* const config = await client.getReminderConfig();
|
|
3115
|
-
* console.log(`Reminders enabled: ${config.enabled}, every ${config.frequency_days} days`);
|
|
3116
|
-
* ```
|
|
3117
|
-
*/
|
|
3118
|
-
async getReminderConfig() {
|
|
3119
|
-
const res = await this.request(
|
|
3120
|
-
"/api/v1/tax/solicitation/reminder-config"
|
|
3121
|
-
);
|
|
3122
|
-
return res.reminder_config;
|
|
3123
3180
|
}
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
* @param config - Reminder configuration to set
|
|
3128
|
-
* @returns Updated reminder config
|
|
3129
|
-
*
|
|
3130
|
-
* @example
|
|
3131
|
-
* ```typescript
|
|
3132
|
-
* const updated = await client.updateReminderConfig({
|
|
3133
|
-
* enabled: true,
|
|
3134
|
-
* max_reminders: 3,
|
|
3135
|
-
* frequency_days: 7,
|
|
3136
|
-
* });
|
|
3137
|
-
* ```
|
|
3138
|
-
*/
|
|
3139
|
-
async updateReminderConfig(config) {
|
|
3140
|
-
const res = await this.request(
|
|
3141
|
-
"/api/v1/tax/solicitation/reminder-config",
|
|
3181
|
+
async enableBackupWithholding(customerID, input) {
|
|
3182
|
+
return this.request(
|
|
3183
|
+
`/api/v1/tax/customer-tax-profiles/${customerID}/enable-withholding`,
|
|
3142
3184
|
{
|
|
3143
|
-
method: "
|
|
3144
|
-
body: JSON.stringify(
|
|
3185
|
+
method: "POST",
|
|
3186
|
+
body: JSON.stringify(input)
|
|
3145
3187
|
}
|
|
3146
3188
|
);
|
|
3147
|
-
return res.reminder_config;
|
|
3148
3189
|
}
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
* @param filters - Optional filters (customer_id, form_type, form_status, etc.)
|
|
3156
|
-
* @returns Paginated list of tax forms
|
|
3157
|
-
*
|
|
3158
|
-
* @example
|
|
3159
|
-
* ```typescript
|
|
3160
|
-
* const result = await client.listTaxForms({ form_type: 'W-9', form_status: 'Pending' });
|
|
3161
|
-
* console.log(`Found ${result.total} forms`);
|
|
3162
|
-
* ```
|
|
3163
|
-
*/
|
|
3164
|
-
async listTaxForms(filters) {
|
|
3165
|
-
const params = {};
|
|
3166
|
-
if (filters) {
|
|
3167
|
-
if (filters.customer_id) params.customer_id = filters.customer_id;
|
|
3168
|
-
if (filters.form_type) params.form_type = filters.form_type;
|
|
3169
|
-
if (filters.form_status) params.form_status = filters.form_status;
|
|
3170
|
-
if (filters.tin_status) params.tin_status = filters.tin_status;
|
|
3171
|
-
if (filters.avalara_company_id) params.avalara_company_id = filters.avalara_company_id;
|
|
3172
|
-
if (filters.search) params.search = filters.search;
|
|
3173
|
-
if (filters.start_date) params.start_date = filters.start_date;
|
|
3174
|
-
if (filters.end_date) params.end_date = filters.end_date;
|
|
3175
|
-
if (filters.page) params.page = filters.page;
|
|
3176
|
-
if (filters.page_size) params.limit = filters.page_size;
|
|
3177
|
-
}
|
|
3178
|
-
return this.request(`/api/v1/tax/forms${this.buildQueryString(params)}`);
|
|
3179
|
-
}
|
|
3180
|
-
/**
|
|
3181
|
-
* Get a tax form by ID
|
|
3182
|
-
*
|
|
3183
|
-
* @param formId - Tax form UUID
|
|
3184
|
-
* @returns Tax form details
|
|
3185
|
-
*/
|
|
3186
|
-
async getTaxForm(formId) {
|
|
3187
|
-
return this.request(`/api/v1/tax/forms/${formId}`);
|
|
3188
|
-
}
|
|
3189
|
-
/**
|
|
3190
|
-
* Get lifecycle events for a tax form
|
|
3191
|
-
*
|
|
3192
|
-
* @param formId - Tax form UUID
|
|
3193
|
-
* @returns List of lifecycle events
|
|
3194
|
-
*/
|
|
3195
|
-
async getTaxFormLifecycleEvents(formId) {
|
|
3196
|
-
const res = await this.request(
|
|
3197
|
-
`/api/v1/tax/forms/${formId}/lifecycle`
|
|
3190
|
+
async downloadTaxForm(customerID, requestOptions) {
|
|
3191
|
+
return this.request(
|
|
3192
|
+
`/api/v1/tax/customer-tax-profiles/${customerID}/download-form`,
|
|
3193
|
+
{ method: "GET" },
|
|
3194
|
+
void 0,
|
|
3195
|
+
{ ...requestOptions, responseType: "arraybuffer" }
|
|
3198
3196
|
);
|
|
3199
|
-
return res.lifecycle_events;
|
|
3200
3197
|
}
|
|
3201
|
-
//
|
|
3202
|
-
//
|
|
3203
|
-
//
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
* @param customerID - Customer ID
|
|
3208
|
-
* @returns Customer tax profile with all forms and events
|
|
3209
|
-
*
|
|
3210
|
-
* @example
|
|
3211
|
-
* ```typescript
|
|
3212
|
-
* const profile = await client.getCustomerTaxProfile('cust_123');
|
|
3213
|
-
* console.log(`Customer has ${profile.tax_forms.length} tax forms`);
|
|
3214
|
-
* ```
|
|
3215
|
-
*/
|
|
3216
|
-
async getCustomerTaxProfile(customerID) {
|
|
3217
|
-
return this.request(`/api/v1/tax/profile/${customerID}`);
|
|
3198
|
+
// ==========================================================================
|
|
3199
|
+
// P2 — Tenant Tax Rules
|
|
3200
|
+
// ==========================================================================
|
|
3201
|
+
async getTaxRules() {
|
|
3202
|
+
const res = await this.request("/api/v1/tax/rules");
|
|
3203
|
+
return res.rules;
|
|
3218
3204
|
}
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
* @returns Paginated list of tax companies
|
|
3228
|
-
*/
|
|
3229
|
-
async listTaxCompanies(page, pageSize) {
|
|
3205
|
+
async updateTaxRules(input) {
|
|
3206
|
+
const res = await this.request("/api/v1/tax/rules", {
|
|
3207
|
+
method: "PUT",
|
|
3208
|
+
body: JSON.stringify({ rules: input })
|
|
3209
|
+
});
|
|
3210
|
+
return res.version;
|
|
3211
|
+
}
|
|
3212
|
+
async getComplianceStats(filters) {
|
|
3230
3213
|
const params = {};
|
|
3231
|
-
if (
|
|
3232
|
-
if (
|
|
3214
|
+
if (filters?.time_range) params.time_range = filters.time_range;
|
|
3215
|
+
if (filters?.from_date) params.from_date = filters.from_date;
|
|
3216
|
+
if (filters?.to_date) params.to_date = filters.to_date;
|
|
3233
3217
|
return this.request(
|
|
3234
|
-
`/api/v1/tax/
|
|
3218
|
+
`/api/v1/tax/tenant/w-form-tenant-stats${this.buildQueryString(params)}`
|
|
3235
3219
|
);
|
|
3236
3220
|
}
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
return
|
|
3221
|
+
// ==========================================================================
|
|
3222
|
+
// P3 — Global Tax Rule & Treaty Countries
|
|
3223
|
+
// ==========================================================================
|
|
3224
|
+
async getCurrentGlobalTaxRule() {
|
|
3225
|
+
const res = await this.request(
|
|
3226
|
+
"/api/v1/tm/tenant/global-tax-rules/current"
|
|
3227
|
+
);
|
|
3228
|
+
return res.data;
|
|
3229
|
+
}
|
|
3230
|
+
async listTreatyCountries() {
|
|
3231
|
+
return this.request("/api/v1/tax/treaty-countries");
|
|
3232
|
+
}
|
|
3233
|
+
async getTreatyCountry(code) {
|
|
3234
|
+
const res = await this.request(
|
|
3235
|
+
`/api/v1/tax/treaty-countries/${encodeURIComponent(code)}`
|
|
3236
|
+
);
|
|
3237
|
+
return res.treaty_country;
|
|
3245
3238
|
}
|
|
3246
|
-
// ============================================================================
|
|
3247
|
-
// Utility Methods (inherited from BaseClient: healthCheck, updateConfig, getConfig, buildQueryString)
|
|
3248
|
-
// ============================================================================
|
|
3249
3239
|
};
|
|
3250
3240
|
|
|
3251
3241
|
// src/transaction/client.ts
|