vesant-sdk 1.6.6-next.ac58d2b → 1.7.0-dev.059da4f
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/README.md +4 -4
- package/dist/client-C3DCmGe9.d.ts +436 -0
- package/dist/{client-D6PE3pcB.d.mts → client-DMIRx7Tu.d.mts} +4 -2
- package/dist/{client-DPtiuQvW.d.ts → client-DoMSYMMR.d.ts} +4 -2
- package/dist/client-ZNdnpWe7.d.mts +436 -0
- package/dist/compliance/index.d.mts +25 -429
- package/dist/compliance/index.d.ts +25 -429
- package/dist/compliance/index.js +181 -79
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +181 -80
- 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 +1 -1
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisions/index.mjs +1 -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 +2 -1
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +2 -1
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index.d.mts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +269 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +268 -94
- package/dist/index.mjs.map +1 -1
- package/dist/kyc/core.d.mts +3 -3
- package/dist/kyc/core.d.ts +3 -3
- package/dist/kyc/core.js +77 -15
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +77 -16
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.d.mts +267 -26
- package/dist/kyc/index.d.ts +267 -26
- package/dist/kyc/index.js +77 -15
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +77 -16
- package/dist/kyc/index.mjs.map +1 -1
- package/dist/react.d.mts +45 -8
- package/dist/react.d.ts +45 -8
- package/dist/react.js +874 -272
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +873 -271
- package/dist/react.mjs.map +1 -1
- package/dist/risk-profile/index.d.mts +3 -3
- package/dist/risk-profile/index.d.ts +3 -3
- package/dist/risk-profile/index.js +1 -1
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +1 -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 +1 -1
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/index.mjs +1 -1
- package/dist/scores/index.mjs.map +1 -1
- package/dist/tax/index.d.mts +41 -1
- package/dist/tax/index.d.ts +41 -1
- package/dist/tax/index.js +13 -1
- package/dist/tax/index.js.map +1 -1
- package/dist/tax/index.mjs +13 -1
- package/dist/tax/index.mjs.map +1 -1
- package/dist/{types-DGDVnogO.d.mts → types-BOFaMQxI.d.mts} +2 -2
- package/dist/{types-B4Ezqo7V.d.mts → types-CBQRNL-l.d.mts} +14 -1
- package/dist/{types-B4Ezqo7V.d.ts → types-CBQRNL-l.d.ts} +14 -1
- package/dist/{types-_YQdS3Ax.d.ts → types-UGyDl1fd.d.ts} +2 -2
- package/dist/webhooks/index.d.mts +12 -4
- package/dist/webhooks/index.d.ts +12 -4
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -240,7 +240,7 @@ var noopLogger = {
|
|
|
240
240
|
};
|
|
241
241
|
|
|
242
242
|
// src/core/version.ts
|
|
243
|
-
var SDK_VERSION = "1.
|
|
243
|
+
var SDK_VERSION = "1.7.0";
|
|
244
244
|
|
|
245
245
|
// src/shared/browser-utils.ts
|
|
246
246
|
function generateUUID() {
|
|
@@ -1159,6 +1159,7 @@ var GeolocationClient = class extends BaseClient {
|
|
|
1159
1159
|
risk_level: risk.level ?? "low",
|
|
1160
1160
|
risk_score: risk.score ?? 0,
|
|
1161
1161
|
risk_reasons: risk.is_blocked && risk.block_reasons ? risk.block_reasons : risk.factors ?? [],
|
|
1162
|
+
risk_reasons_structured: risk.block_reasons_structured ?? [],
|
|
1162
1163
|
jurisdiction: cipherTextResult.jurisdiction,
|
|
1163
1164
|
geofence_evaluation: cipherTextResult.geofence_evaluation,
|
|
1164
1165
|
record_id: cipherTextResult.record_id ?? "",
|
|
@@ -1454,6 +1455,81 @@ var RiskProfileClient = class extends BaseClient {
|
|
|
1454
1455
|
}
|
|
1455
1456
|
};
|
|
1456
1457
|
|
|
1458
|
+
// src/compliance/block-reasons.ts
|
|
1459
|
+
var sdkReasons = {
|
|
1460
|
+
// Jurisdiction
|
|
1461
|
+
jurisdictionBlocked: (country, countryISO) => ({
|
|
1462
|
+
code: "JURISDICTION_BLOCKED",
|
|
1463
|
+
message: "Access from a blocked jurisdiction",
|
|
1464
|
+
metadata: { country, country_iso: countryISO }
|
|
1465
|
+
}),
|
|
1466
|
+
jurisdictionNonCompliant: () => ({
|
|
1467
|
+
code: "JURISDICTION_NON_COMPLIANT",
|
|
1468
|
+
message: "Location does not meet compliance requirements"
|
|
1469
|
+
}),
|
|
1470
|
+
jurisdictionRegistrationDenied: () => ({
|
|
1471
|
+
code: "JURISDICTION_REGISTRATION_DENIED",
|
|
1472
|
+
message: "Registration is not permitted in this jurisdiction"
|
|
1473
|
+
}),
|
|
1474
|
+
jurisdictionRestricted: () => ({
|
|
1475
|
+
code: "JURISDICTION_RESTRICTED",
|
|
1476
|
+
message: "Access from a restricted jurisdiction"
|
|
1477
|
+
}),
|
|
1478
|
+
// Risk
|
|
1479
|
+
riskCriticalLevel: () => ({
|
|
1480
|
+
code: "RISK_CRITICAL_LEVEL",
|
|
1481
|
+
message: "Risk assessment reached critical threshold"
|
|
1482
|
+
}),
|
|
1483
|
+
accountSuspended: () => ({
|
|
1484
|
+
code: "RISK_ACCOUNT_SUSPENDED",
|
|
1485
|
+
message: "Customer account is suspended"
|
|
1486
|
+
}),
|
|
1487
|
+
sanctionsMatch: () => ({
|
|
1488
|
+
code: "RISK_SANCTIONS_MATCH",
|
|
1489
|
+
message: "Customer profile matched against sanctions list"
|
|
1490
|
+
}),
|
|
1491
|
+
riskHighLocation: () => ({
|
|
1492
|
+
code: "RISK_HIGH_LOCATION",
|
|
1493
|
+
message: "High-risk geographic location"
|
|
1494
|
+
}),
|
|
1495
|
+
riskHighCustomer: () => ({
|
|
1496
|
+
code: "RISK_HIGH_CUSTOMER",
|
|
1497
|
+
message: "Customer flagged as high risk"
|
|
1498
|
+
}),
|
|
1499
|
+
// Device
|
|
1500
|
+
ciphertextInvalid: () => ({
|
|
1501
|
+
code: "DEVICE_CIPHERTEXT_INVALID",
|
|
1502
|
+
message: "Device verification payload failed validation"
|
|
1503
|
+
}),
|
|
1504
|
+
gpsIPMismatch: () => ({
|
|
1505
|
+
code: "DEVICE_GPS_IP_MISMATCH",
|
|
1506
|
+
message: "GPS location does not match IP-derived location"
|
|
1507
|
+
}),
|
|
1508
|
+
gpsRequired: () => ({
|
|
1509
|
+
code: "DEVICE_GPS_REQUIRED",
|
|
1510
|
+
message: "GPS verification is required but was not provided"
|
|
1511
|
+
}),
|
|
1512
|
+
// Transaction
|
|
1513
|
+
transactionHighAmount: (amount, currency, threshold) => ({
|
|
1514
|
+
code: "TRANSACTION_HIGH_AMOUNT",
|
|
1515
|
+
message: "Transaction amount exceeds high-value threshold",
|
|
1516
|
+
metadata: { amount, currency, threshold }
|
|
1517
|
+
}),
|
|
1518
|
+
transactionElevatedAmount: (amount, currency, threshold) => ({
|
|
1519
|
+
code: "TRANSACTION_ELEVATED_AMOUNT",
|
|
1520
|
+
message: "Transaction amount exceeds elevated-value threshold",
|
|
1521
|
+
metadata: { amount, currency, threshold }
|
|
1522
|
+
}),
|
|
1523
|
+
transactionJurisdictionLimit: () => ({
|
|
1524
|
+
code: "TRANSACTION_JURISDICTION_LIMIT",
|
|
1525
|
+
message: "Transaction amount exceeds jurisdiction limit"
|
|
1526
|
+
}),
|
|
1527
|
+
anonymizationDetected: () => ({
|
|
1528
|
+
code: "NETWORK_ANONYMIZER_DETECTED",
|
|
1529
|
+
message: "Anonymization tool detected"
|
|
1530
|
+
})
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1457
1533
|
// src/compliance/types.ts
|
|
1458
1534
|
var DEFAULT_CURRENCY_RATES = {
|
|
1459
1535
|
USD: 1,
|
|
@@ -1600,10 +1676,10 @@ var ComplianceClient = class {
|
|
|
1600
1676
|
device_fingerprint: request.deviceFingerprint
|
|
1601
1677
|
}, requestOptions);
|
|
1602
1678
|
}
|
|
1603
|
-
const
|
|
1604
|
-
if (
|
|
1679
|
+
const structuredBlockReasons = this.evaluateRegistrationBlock(geoVerification, cipherTextResult);
|
|
1680
|
+
if (structuredBlockReasons.length > 0) {
|
|
1605
1681
|
if (this.config.debug) {
|
|
1606
|
-
this.logger.debug("Registration blocked at geo stage", { blockReasons });
|
|
1682
|
+
this.logger.debug("Registration blocked at geo stage", { blockReasons: structuredBlockReasons });
|
|
1607
1683
|
}
|
|
1608
1684
|
return {
|
|
1609
1685
|
allowed: false,
|
|
@@ -1611,9 +1687,7 @@ var ComplianceClient = class {
|
|
|
1611
1687
|
profile: null,
|
|
1612
1688
|
requiresKYC: false,
|
|
1613
1689
|
requiresEDD: false,
|
|
1614
|
-
|
|
1615
|
-
processingTime: Date.now() - startTime,
|
|
1616
|
-
cipherTextValidation: cipherTextResult
|
|
1690
|
+
...this.buildReasonTail(structuredBlockReasons, startTime, cipherTextResult)
|
|
1617
1691
|
};
|
|
1618
1692
|
}
|
|
1619
1693
|
const profile = await this.riskClient.createProfile({
|
|
@@ -1647,9 +1721,7 @@ var ComplianceClient = class {
|
|
|
1647
1721
|
profile,
|
|
1648
1722
|
requiresKYC,
|
|
1649
1723
|
requiresEDD,
|
|
1650
|
-
|
|
1651
|
-
processingTime: Date.now() - startTime,
|
|
1652
|
-
cipherTextValidation: cipherTextResult
|
|
1724
|
+
...this.buildReasonTail([], startTime, cipherTextResult)
|
|
1653
1725
|
};
|
|
1654
1726
|
} catch (error) {
|
|
1655
1727
|
if (this.config.debug) {
|
|
@@ -1683,52 +1755,62 @@ var ComplianceClient = class {
|
|
|
1683
1755
|
evaluateRegistrationBlock(geoVerification, cipherTextResult) {
|
|
1684
1756
|
const blockReasons = [];
|
|
1685
1757
|
if (geoVerification.is_blocked) {
|
|
1686
|
-
blockReasons.push(...geoVerification.
|
|
1758
|
+
blockReasons.push(...geoVerification.risk_reasons_structured ?? []);
|
|
1687
1759
|
}
|
|
1688
1760
|
if (!geoVerification.is_compliant) {
|
|
1689
|
-
if (!blockReasons.
|
|
1690
|
-
blockReasons.push(
|
|
1761
|
+
if (!blockReasons.some((r) => r.code === "JURISDICTION_NON_COMPLIANT")) {
|
|
1762
|
+
blockReasons.push(sdkReasons.jurisdictionNonCompliant());
|
|
1691
1763
|
}
|
|
1692
1764
|
}
|
|
1693
1765
|
const jurisdiction = geoVerification.jurisdiction;
|
|
1694
1766
|
if (jurisdiction) {
|
|
1695
1767
|
if (jurisdiction.allow_registration === false) {
|
|
1696
|
-
blockReasons.push(
|
|
1768
|
+
blockReasons.push(sdkReasons.jurisdictionRegistrationDenied());
|
|
1697
1769
|
}
|
|
1698
1770
|
if (jurisdiction.status === "blocked" || jurisdiction.status === "sanctioned") {
|
|
1699
|
-
if (!blockReasons.
|
|
1700
|
-
blockReasons.push("
|
|
1771
|
+
if (!blockReasons.some((r) => r.code === "JURISDICTION_BLOCKED")) {
|
|
1772
|
+
blockReasons.push(sdkReasons.jurisdictionBlocked(jurisdiction.country_name ?? "", jurisdiction.country_iso ?? ""));
|
|
1701
1773
|
}
|
|
1702
1774
|
}
|
|
1703
1775
|
if (jurisdiction.status === "restricted" && jurisdiction.allow_registration === false) {
|
|
1704
|
-
if (!blockReasons.
|
|
1705
|
-
blockReasons.push(
|
|
1776
|
+
if (!blockReasons.some((r) => r.code === "JURISDICTION_RESTRICTED")) {
|
|
1777
|
+
blockReasons.push(sdkReasons.jurisdictionRestricted());
|
|
1706
1778
|
}
|
|
1707
1779
|
}
|
|
1708
1780
|
}
|
|
1709
1781
|
if (geoVerification.geofence_evaluation?.blocked) {
|
|
1710
|
-
blockReasons.push(
|
|
1782
|
+
blockReasons.push(
|
|
1783
|
+
...(geoVerification.geofence_evaluation.reasons ?? []).map((m) => ({
|
|
1784
|
+
code: "JURISDICTION_GEOFENCE_VIOLATION",
|
|
1785
|
+
message: m
|
|
1786
|
+
}))
|
|
1787
|
+
);
|
|
1711
1788
|
}
|
|
1712
1789
|
if (geoVerification.risk_level === "critical") {
|
|
1713
|
-
if (!blockReasons.
|
|
1714
|
-
blockReasons.push(
|
|
1790
|
+
if (!blockReasons.some((r) => r.code === "RISK_CRITICAL_LEVEL")) {
|
|
1791
|
+
blockReasons.push(sdkReasons.riskCriticalLevel());
|
|
1715
1792
|
}
|
|
1716
1793
|
}
|
|
1717
1794
|
if (cipherTextResult) {
|
|
1718
1795
|
if (!cipherTextResult.valid) {
|
|
1719
|
-
blockReasons.push(
|
|
1796
|
+
blockReasons.push(sdkReasons.ciphertextInvalid());
|
|
1720
1797
|
}
|
|
1721
1798
|
if (cipherTextResult.risk?.is_blocked) {
|
|
1722
|
-
blockReasons.push(...cipherTextResult.risk.
|
|
1799
|
+
blockReasons.push(...cipherTextResult.risk.block_reasons_structured ?? []);
|
|
1723
1800
|
}
|
|
1724
1801
|
if (cipherTextResult.risk?.location_mismatch) {
|
|
1725
|
-
blockReasons.push(
|
|
1802
|
+
blockReasons.push(sdkReasons.gpsIPMismatch());
|
|
1726
1803
|
}
|
|
1727
1804
|
}
|
|
1728
1805
|
if (geoVerification.gps_required && !cipherTextResult) {
|
|
1729
|
-
blockReasons.push(
|
|
1806
|
+
blockReasons.push(sdkReasons.gpsRequired());
|
|
1730
1807
|
}
|
|
1731
|
-
|
|
1808
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1809
|
+
return blockReasons.filter((r) => {
|
|
1810
|
+
if (seen.has(r.code)) return false;
|
|
1811
|
+
seen.add(r.code);
|
|
1812
|
+
return true;
|
|
1813
|
+
});
|
|
1732
1814
|
}
|
|
1733
1815
|
/**
|
|
1734
1816
|
* Validate registration request has all required fields
|
|
@@ -1899,9 +1981,7 @@ var ComplianceClient = class {
|
|
|
1899
1981
|
geolocation: geoVerification,
|
|
1900
1982
|
profile: null,
|
|
1901
1983
|
requiresStepUp: false,
|
|
1902
|
-
|
|
1903
|
-
processingTime: Date.now() - startTime,
|
|
1904
|
-
cipherTextValidation: cipherTextResult
|
|
1984
|
+
...this.buildReasonTail(loginBlockReasons, startTime, cipherTextResult)
|
|
1905
1985
|
};
|
|
1906
1986
|
}
|
|
1907
1987
|
let profile;
|
|
@@ -1921,14 +2001,13 @@ var ComplianceClient = class {
|
|
|
1921
2001
|
profile = await this.createProfileFromGeo(request.customerId, geoVerification);
|
|
1922
2002
|
}
|
|
1923
2003
|
const requiresStepUp = geoVerification.risk_level === "high" || geoVerification.risk_level === "critical" || cipherTextResult?.risk?.location_mismatch === true;
|
|
2004
|
+
const loginFinalStructured = isBlocked || profile.customer_status === "suspended" ? this.getBlockReasons(geoVerification, profile, cipherTextResult) : [];
|
|
1924
2005
|
return {
|
|
1925
2006
|
allowed: !isBlocked && profile.customer_status !== "suspended",
|
|
1926
2007
|
geolocation: geoVerification,
|
|
1927
2008
|
profile,
|
|
1928
2009
|
requiresStepUp,
|
|
1929
|
-
|
|
1930
|
-
processingTime: Date.now() - startTime,
|
|
1931
|
-
cipherTextValidation: cipherTextResult
|
|
2010
|
+
...this.buildReasonTail(loginFinalStructured, startTime, cipherTextResult)
|
|
1932
2011
|
};
|
|
1933
2012
|
} catch (error) {
|
|
1934
2013
|
throw new ComplianceError("Login verification failed", error instanceof Error ? error.message : void 0);
|
|
@@ -2010,20 +2089,19 @@ var ComplianceClient = class {
|
|
|
2010
2089
|
}
|
|
2011
2090
|
const geoBlocked = !geoVerification.is_compliant || geoVerification.is_blocked || !!cipherTextResult?.risk?.is_blocked || cipherTextResult?.valid === false || geoVerification.gps_required && !cipherTextResult;
|
|
2012
2091
|
if (geoBlocked && !profileResult) {
|
|
2092
|
+
const earlyStructured = this.getTransactionBlockReasons(
|
|
2093
|
+
geoVerification,
|
|
2094
|
+
{ score: 0, level: "low", factors: [], allowed: false, requiresManualReview: false },
|
|
2095
|
+
true,
|
|
2096
|
+
cipherTextResult
|
|
2097
|
+
);
|
|
2013
2098
|
return {
|
|
2014
2099
|
allowed: false,
|
|
2015
2100
|
geolocation: geoVerification,
|
|
2016
2101
|
profile: null,
|
|
2017
2102
|
transactionRisk: { score: 0, level: "low", factors: [], allowed: false, requiresManualReview: false },
|
|
2018
2103
|
requiresApproval: false,
|
|
2019
|
-
|
|
2020
|
-
geoVerification,
|
|
2021
|
-
{ score: 0, level: "low", factors: [], allowed: false, requiresManualReview: false },
|
|
2022
|
-
true,
|
|
2023
|
-
cipherTextResult
|
|
2024
|
-
),
|
|
2025
|
-
processingTime: Date.now() - startTime,
|
|
2026
|
-
cipherTextValidation: cipherTextResult
|
|
2104
|
+
...this.buildReasonTail(earlyStructured, startTime, cipherTextResult)
|
|
2027
2105
|
};
|
|
2028
2106
|
}
|
|
2029
2107
|
if (!profileResult) {
|
|
@@ -2043,20 +2121,19 @@ var ComplianceClient = class {
|
|
|
2043
2121
|
geoVerification.jurisdiction
|
|
2044
2122
|
);
|
|
2045
2123
|
const isAllowed = !geoBlocked && jurisdictionAllowed && transactionRisk.allowed && profile.customer_status !== "suspended";
|
|
2124
|
+
const txStructured = this.getTransactionBlockReasons(
|
|
2125
|
+
geoVerification,
|
|
2126
|
+
transactionRisk,
|
|
2127
|
+
jurisdictionAllowed,
|
|
2128
|
+
cipherTextResult
|
|
2129
|
+
);
|
|
2046
2130
|
return {
|
|
2047
2131
|
allowed: isAllowed,
|
|
2048
2132
|
geolocation: geoVerification,
|
|
2049
2133
|
profile,
|
|
2050
2134
|
transactionRisk,
|
|
2051
2135
|
requiresApproval: transactionRisk.requiresManualReview,
|
|
2052
|
-
|
|
2053
|
-
geoVerification,
|
|
2054
|
-
transactionRisk,
|
|
2055
|
-
jurisdictionAllowed,
|
|
2056
|
-
cipherTextResult
|
|
2057
|
-
),
|
|
2058
|
-
processingTime: Date.now() - startTime,
|
|
2059
|
-
cipherTextValidation: cipherTextResult
|
|
2136
|
+
...this.buildReasonTail(txStructured, startTime, cipherTextResult)
|
|
2060
2137
|
};
|
|
2061
2138
|
} catch (error) {
|
|
2062
2139
|
throw new ComplianceError("Transaction verification failed", error instanceof Error ? error.message : void 0);
|
|
@@ -2109,30 +2186,42 @@ var ComplianceClient = class {
|
|
|
2109
2186
|
}
|
|
2110
2187
|
}
|
|
2111
2188
|
const cipherTextBlocked = cipherTextResult ? !cipherTextResult.valid || cipherTextResult.risk?.is_blocked === true : false;
|
|
2112
|
-
const
|
|
2189
|
+
const structuredEventReasons = [...geoVerification.risk_reasons_structured ?? []];
|
|
2113
2190
|
if (cipherTextResult) {
|
|
2114
2191
|
if (!cipherTextResult.valid) {
|
|
2115
|
-
|
|
2192
|
+
structuredEventReasons.push(sdkReasons.ciphertextInvalid());
|
|
2116
2193
|
}
|
|
2117
2194
|
if (cipherTextResult.risk?.is_blocked) {
|
|
2118
|
-
|
|
2195
|
+
structuredEventReasons.push(...cipherTextResult.risk.block_reasons_structured ?? []);
|
|
2119
2196
|
}
|
|
2120
2197
|
}
|
|
2121
2198
|
const gpsBlocked = geoVerification.gps_required && !cipherTextResult;
|
|
2122
2199
|
if (gpsBlocked) {
|
|
2123
|
-
|
|
2200
|
+
structuredEventReasons.push(sdkReasons.gpsRequired());
|
|
2124
2201
|
}
|
|
2202
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2203
|
+
const dedupedStructured = structuredEventReasons.filter((r) => {
|
|
2204
|
+
if (seen.has(r.code)) return false;
|
|
2205
|
+
seen.add(r.code);
|
|
2206
|
+
return true;
|
|
2207
|
+
});
|
|
2125
2208
|
return {
|
|
2126
2209
|
allowed: geoVerification.is_compliant && !geoVerification.is_blocked && !cipherTextBlocked && !gpsBlocked,
|
|
2127
2210
|
geolocation: geoVerification,
|
|
2128
|
-
|
|
2129
|
-
processingTime: Date.now() - startTime,
|
|
2130
|
-
cipherTextValidation: cipherTextResult
|
|
2211
|
+
...this.buildReasonTail(dedupedStructured, startTime, cipherTextResult)
|
|
2131
2212
|
};
|
|
2132
2213
|
}
|
|
2133
2214
|
// ============================================================================
|
|
2134
2215
|
// Helper Methods
|
|
2135
2216
|
// ============================================================================
|
|
2217
|
+
buildReasonTail(structured, startTime, cipherTextResult) {
|
|
2218
|
+
return {
|
|
2219
|
+
blockReasons: structured.map((r) => r.message),
|
|
2220
|
+
blockReasonsStructured: structured,
|
|
2221
|
+
processingTime: Date.now() - startTime,
|
|
2222
|
+
cipherTextValidation: cipherTextResult
|
|
2223
|
+
};
|
|
2224
|
+
}
|
|
2136
2225
|
shouldUpdateProfile(profile, newCity) {
|
|
2137
2226
|
return !profile.location || !profile.location.includes(newCity);
|
|
2138
2227
|
}
|
|
@@ -2209,7 +2298,8 @@ var ComplianceClient = class {
|
|
|
2209
2298
|
is_blocked: risk.is_blocked,
|
|
2210
2299
|
risk_level: risk.level,
|
|
2211
2300
|
risk_score: risk.score,
|
|
2212
|
-
risk_reasons:
|
|
2301
|
+
risk_reasons: [],
|
|
2302
|
+
risk_reasons_structured: risk.is_blocked && risk.block_reasons_structured ? risk.block_reasons_structured : [],
|
|
2213
2303
|
jurisdiction: ct.jurisdiction,
|
|
2214
2304
|
geofence_evaluation: ct.geofence_evaluation,
|
|
2215
2305
|
record_id: ct.record_id ?? "",
|
|
@@ -2224,35 +2314,35 @@ var ComplianceClient = class {
|
|
|
2224
2314
|
);
|
|
2225
2315
|
}
|
|
2226
2316
|
let riskScore = 0;
|
|
2227
|
-
const
|
|
2317
|
+
const structuredFactors = [];
|
|
2228
2318
|
const normalizedAmount = this.normalizeToUSD(amount, currency);
|
|
2229
2319
|
if (normalizedAmount > 1e4) {
|
|
2230
2320
|
riskScore += 30;
|
|
2231
|
-
|
|
2321
|
+
structuredFactors.push(sdkReasons.transactionHighAmount(normalizedAmount, currency, 1e4));
|
|
2232
2322
|
} else if (normalizedAmount > 5e3) {
|
|
2233
2323
|
riskScore += 15;
|
|
2234
|
-
|
|
2324
|
+
structuredFactors.push(sdkReasons.transactionElevatedAmount(normalizedAmount, currency, 5e3));
|
|
2235
2325
|
}
|
|
2236
2326
|
riskScore += geoVerification.risk_score * 0.4;
|
|
2237
2327
|
if (geoVerification.risk_level === "high" || geoVerification.risk_level === "critical") {
|
|
2238
|
-
|
|
2328
|
+
structuredFactors.push(sdkReasons.riskHighLocation());
|
|
2239
2329
|
}
|
|
2240
2330
|
riskScore += profile.risk_score * 0.3;
|
|
2241
2331
|
if (profile.risk_category === "high" || profile.risk_category === "critical") {
|
|
2242
|
-
|
|
2332
|
+
structuredFactors.push(sdkReasons.riskHighCustomer());
|
|
2243
2333
|
}
|
|
2244
2334
|
if (geoVerification.location.is_vpn || geoVerification.location.is_proxy) {
|
|
2245
2335
|
riskScore += 20;
|
|
2246
|
-
|
|
2336
|
+
structuredFactors.push(sdkReasons.anonymizationDetected());
|
|
2247
2337
|
}
|
|
2248
2338
|
if (profile.customer_status === "suspended") {
|
|
2249
2339
|
riskScore += 50;
|
|
2250
|
-
|
|
2340
|
+
structuredFactors.push(sdkReasons.accountSuspended());
|
|
2251
2341
|
}
|
|
2252
2342
|
if (cipherTextResult) {
|
|
2253
2343
|
if (cipherTextResult.risk?.location_mismatch) {
|
|
2254
2344
|
riskScore += 20;
|
|
2255
|
-
|
|
2345
|
+
structuredFactors.push(sdkReasons.gpsIPMismatch());
|
|
2256
2346
|
}
|
|
2257
2347
|
if (cipherTextResult.risk?.score) {
|
|
2258
2348
|
riskScore += cipherTextResult.risk.score * 0.2;
|
|
@@ -2261,7 +2351,8 @@ var ComplianceClient = class {
|
|
|
2261
2351
|
return {
|
|
2262
2352
|
score: Math.min(riskScore, 100),
|
|
2263
2353
|
level: this.getRiskLevel(riskScore),
|
|
2264
|
-
factors,
|
|
2354
|
+
factors: structuredFactors.map((r) => r.message),
|
|
2355
|
+
factorsStructured: structuredFactors,
|
|
2265
2356
|
allowed: riskScore < 70,
|
|
2266
2357
|
requiresManualReview: riskScore >= 60 && riskScore < 70
|
|
2267
2358
|
};
|
|
@@ -2286,52 +2377,62 @@ var ComplianceClient = class {
|
|
|
2286
2377
|
getBlockReasons(geoVerification, profile, cipherTextResult) {
|
|
2287
2378
|
const reasons = [];
|
|
2288
2379
|
if (geoVerification.is_blocked) {
|
|
2289
|
-
reasons.push(...geoVerification.
|
|
2380
|
+
reasons.push(...geoVerification.risk_reasons_structured ?? []);
|
|
2290
2381
|
}
|
|
2291
2382
|
if (profile) {
|
|
2292
2383
|
if (profile.customer_status === "suspended") {
|
|
2293
|
-
reasons.push(
|
|
2384
|
+
reasons.push(sdkReasons.accountSuspended());
|
|
2294
2385
|
}
|
|
2295
2386
|
if (profile.has_sanctions) {
|
|
2296
|
-
reasons.push(
|
|
2387
|
+
reasons.push(sdkReasons.sanctionsMatch());
|
|
2297
2388
|
}
|
|
2298
2389
|
}
|
|
2299
2390
|
if (cipherTextResult) {
|
|
2300
2391
|
if (!cipherTextResult.valid) {
|
|
2301
|
-
reasons.push(
|
|
2392
|
+
reasons.push(sdkReasons.ciphertextInvalid());
|
|
2302
2393
|
}
|
|
2303
2394
|
if (cipherTextResult.risk?.is_blocked) {
|
|
2304
|
-
reasons.push(...cipherTextResult.risk.
|
|
2395
|
+
reasons.push(...cipherTextResult.risk.block_reasons_structured ?? []);
|
|
2305
2396
|
}
|
|
2306
2397
|
}
|
|
2307
2398
|
if (geoVerification.gps_required && !cipherTextResult) {
|
|
2308
|
-
reasons.push(
|
|
2399
|
+
reasons.push(sdkReasons.gpsRequired());
|
|
2309
2400
|
}
|
|
2310
|
-
|
|
2401
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2402
|
+
return reasons.filter((r) => {
|
|
2403
|
+
if (seen.has(r.code)) return false;
|
|
2404
|
+
seen.add(r.code);
|
|
2405
|
+
return true;
|
|
2406
|
+
});
|
|
2311
2407
|
}
|
|
2312
2408
|
getTransactionBlockReasons(geoVerification, transactionRisk, jurisdictionAllowed, cipherTextResult) {
|
|
2313
2409
|
const reasons = [];
|
|
2314
2410
|
if (!geoVerification.is_compliant) {
|
|
2315
|
-
reasons.push(
|
|
2411
|
+
reasons.push(sdkReasons.jurisdictionNonCompliant());
|
|
2316
2412
|
}
|
|
2317
2413
|
if (!jurisdictionAllowed) {
|
|
2318
|
-
reasons.push(
|
|
2414
|
+
reasons.push(sdkReasons.transactionJurisdictionLimit());
|
|
2319
2415
|
}
|
|
2320
2416
|
if (!transactionRisk.allowed) {
|
|
2321
|
-
reasons.push(...transactionRisk.
|
|
2417
|
+
reasons.push(...transactionRisk.factorsStructured ?? []);
|
|
2322
2418
|
}
|
|
2323
2419
|
if (cipherTextResult) {
|
|
2324
2420
|
if (!cipherTextResult.valid) {
|
|
2325
|
-
reasons.push(
|
|
2421
|
+
reasons.push(sdkReasons.ciphertextInvalid());
|
|
2326
2422
|
}
|
|
2327
2423
|
if (cipherTextResult.risk?.is_blocked) {
|
|
2328
|
-
reasons.push(...cipherTextResult.risk.
|
|
2424
|
+
reasons.push(...cipherTextResult.risk.block_reasons_structured ?? []);
|
|
2329
2425
|
}
|
|
2330
2426
|
}
|
|
2331
2427
|
if (geoVerification.gps_required && !cipherTextResult) {
|
|
2332
|
-
reasons.push(
|
|
2428
|
+
reasons.push(sdkReasons.gpsRequired());
|
|
2333
2429
|
}
|
|
2334
|
-
|
|
2430
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2431
|
+
return reasons.filter((r) => {
|
|
2432
|
+
if (seen.has(r.code)) return false;
|
|
2433
|
+
seen.add(r.code);
|
|
2434
|
+
return true;
|
|
2435
|
+
});
|
|
2335
2436
|
}
|
|
2336
2437
|
// ============================================================================
|
|
2337
2438
|
// Location Request Methods
|
|
@@ -2632,40 +2733,88 @@ var KycClient = class extends BaseClient {
|
|
|
2632
2733
|
});
|
|
2633
2734
|
}
|
|
2634
2735
|
/**
|
|
2635
|
-
* Create a
|
|
2736
|
+
* Create a Event-Based Face Verification session.
|
|
2737
|
+
*
|
|
2738
|
+
* Inspect the response before showing UI:
|
|
2739
|
+
* - `is_required === false` → skip face capture; `reason` explains why.
|
|
2740
|
+
* - `device_type === 'desktop'` → render `qr_payload` as a QR; the
|
|
2741
|
+
* mobile device picks up the session via the connect endpoint.
|
|
2742
|
+
* - `device_type === 'mobile'` → open the face capture modal directly.
|
|
2636
2743
|
*
|
|
2637
|
-
* @param request -
|
|
2744
|
+
* @param request - Reference, customer_id, event, amount (for threshold events), optional URLs.
|
|
2638
2745
|
*/
|
|
2639
|
-
async
|
|
2640
|
-
return this.
|
|
2746
|
+
async createEventBasedFaceVerificationSession(request) {
|
|
2747
|
+
return this.request("/api/v1/kyc/face/session", {
|
|
2641
2748
|
method: "POST",
|
|
2642
2749
|
body: JSON.stringify(request),
|
|
2643
2750
|
headers: this.getUserHeaders()
|
|
2644
2751
|
});
|
|
2645
2752
|
}
|
|
2646
2753
|
/**
|
|
2647
|
-
* Submit a
|
|
2754
|
+
* Submit a real-time face capture for an active Event-Based Face Verification session.
|
|
2648
2755
|
*
|
|
2649
|
-
*
|
|
2756
|
+
* **Mobile-only.** The server rejects desktop User-Agents with HTTP
|
|
2757
|
+
* 400 (`face capture must be completed on a mobile device`). Use the
|
|
2758
|
+
* QR handoff from `createEventBasedFaceVerificationSession` for desktop callers.
|
|
2759
|
+
*
|
|
2760
|
+
* The `data` field on the response carries `retries_remaining`,
|
|
2761
|
+
* `retry_limit_exceeded`, and the reaction flags (`enforce_logout`,
|
|
2762
|
+
* `freeze_account`, etc.) so the tenant app can act on a final failure.
|
|
2763
|
+
*
|
|
2764
|
+
* @param request - Token from `createEventBasedFaceVerificationSession`, plus the base64 selfie.
|
|
2650
2765
|
*/
|
|
2651
|
-
async
|
|
2652
|
-
return this.
|
|
2766
|
+
async submitEventBasedFaceVerificationSession(request) {
|
|
2767
|
+
return this.request("/api/v1/kyc/face/submit", {
|
|
2653
2768
|
method: "POST",
|
|
2654
2769
|
body: JSON.stringify(request),
|
|
2655
2770
|
headers: this.getUserHeaders()
|
|
2656
2771
|
});
|
|
2657
2772
|
}
|
|
2658
2773
|
/**
|
|
2659
|
-
*
|
|
2660
|
-
*
|
|
2661
|
-
*
|
|
2662
|
-
*
|
|
2663
|
-
|
|
2664
|
-
|
|
2774
|
+
* Look up the current state of a Event-Based Face Verification session by its
|
|
2775
|
+
* session token. Useful for desktop pollers waiting on the mobile handoff.
|
|
2776
|
+
*
|
|
2777
|
+
* The lookup is scoped by the unguessable, server-issued session token (not
|
|
2778
|
+
* the enumerable forward reference): the endpoint is public/unauthenticated,
|
|
2779
|
+
* and scoping by the token is what prevents cross-tenant status reads.
|
|
2780
|
+
*
|
|
2781
|
+
* @param token - The session token returned by `createEventBasedFaceVerificationSession`.
|
|
2782
|
+
*/
|
|
2783
|
+
async getEventBasedFaceVerificationSessionStatus(token) {
|
|
2784
|
+
return this.requestWithRetry(`/api/v1/kyc/face/verify/${encodeURIComponent(token)}`, {
|
|
2665
2785
|
method: "GET",
|
|
2666
2786
|
headers: this.getUserHeaders()
|
|
2667
2787
|
});
|
|
2668
2788
|
}
|
|
2789
|
+
/**
|
|
2790
|
+
* Fetch the Redis-backed handoff session for a token. Same backing
|
|
2791
|
+
* store as normal KYC (`kyc:session:<token>`, 15-minute TTL). Desktop
|
|
2792
|
+
* callers poll `mobile_connected` to detect when a mobile device has
|
|
2793
|
+
* scanned the QR and attached.
|
|
2794
|
+
*
|
|
2795
|
+
* @param token - The session token returned by `createEventBasedFaceVerificationSession`.
|
|
2796
|
+
*/
|
|
2797
|
+
async getHandoffSession(token) {
|
|
2798
|
+
return this.request(
|
|
2799
|
+
`/api/v1/kyc/session${this.buildQueryString({ token })}`,
|
|
2800
|
+
{ headers: this.getUserHeaders() }
|
|
2801
|
+
);
|
|
2802
|
+
}
|
|
2803
|
+
/**
|
|
2804
|
+
* Attach a mobile device to a desktop-initiated session. The mobile
|
|
2805
|
+
* client calls this after scanning the QR code. The desktop poller
|
|
2806
|
+
* sees `mobile_connected: true` on the next `getHandoffSession`.
|
|
2807
|
+
*
|
|
2808
|
+
* @param token - The session token transferred via the QR payload.
|
|
2809
|
+
* @param isDisconnect - Pass true to release the session (default false).
|
|
2810
|
+
*/
|
|
2811
|
+
async connectMobileSession(token, isDisconnect = false) {
|
|
2812
|
+
return this.request("/api/v1/kyc/session/connect", {
|
|
2813
|
+
method: "PUT",
|
|
2814
|
+
body: JSON.stringify({ token, is_disconnect: isDisconnect }),
|
|
2815
|
+
headers: this.getUserHeaders()
|
|
2816
|
+
});
|
|
2817
|
+
}
|
|
2669
2818
|
/**
|
|
2670
2819
|
* Check KYC status for a user
|
|
2671
2820
|
*
|
|
@@ -3138,6 +3287,19 @@ var KycClient = class extends BaseClient {
|
|
|
3138
3287
|
// ============================================================================
|
|
3139
3288
|
};
|
|
3140
3289
|
|
|
3290
|
+
// src/kyc/types.ts
|
|
3291
|
+
var KYC_DECLINED_DESCRIPTIONS = {
|
|
3292
|
+
KYC_DOCUMENT_EXPIRED: "The submitted document has expired",
|
|
3293
|
+
KYC_DOCUMENT_INVALID: "The submitted document could not be verified",
|
|
3294
|
+
KYC_FACE_MISMATCH: "Face verification did not match the identity document",
|
|
3295
|
+
KYC_AGE_REQUIREMENT: "Age requirement not met",
|
|
3296
|
+
KYC_DUPLICATE_IDENTITY: "This identity has already been verified under another account",
|
|
3297
|
+
KYC_ADDRESS_MISMATCH: "Address verification failed",
|
|
3298
|
+
KYC_NAME_MISMATCH: "Name on document does not match the registered name",
|
|
3299
|
+
KYC_PROVIDER_REJECTED: "Identity verification was rejected by the verification provider",
|
|
3300
|
+
KYC_DECLINED: "Identity verification was declined"
|
|
3301
|
+
};
|
|
3302
|
+
|
|
3141
3303
|
// src/tax/client.ts
|
|
3142
3304
|
var TaxClient = class extends BaseClient {
|
|
3143
3305
|
constructor(config) {
|
|
@@ -3167,6 +3329,15 @@ var TaxClient = class extends BaseClient {
|
|
|
3167
3329
|
{ method: "POST" }
|
|
3168
3330
|
);
|
|
3169
3331
|
}
|
|
3332
|
+
async requestTaxFormWithProfile(input) {
|
|
3333
|
+
return this.request(
|
|
3334
|
+
"/api/v1/tax/customer-tax-profiles/request-form-with-profile",
|
|
3335
|
+
{
|
|
3336
|
+
method: "POST",
|
|
3337
|
+
body: JSON.stringify(input)
|
|
3338
|
+
}
|
|
3339
|
+
);
|
|
3340
|
+
}
|
|
3170
3341
|
async checkTINStatus(customerID) {
|
|
3171
3342
|
return this.requestWithRetry(
|
|
3172
3343
|
`/api/v1/tax/customer-tax-profiles/${customerID}/check-tin`,
|
|
@@ -3218,6 +3389,9 @@ var TaxClient = class extends BaseClient {
|
|
|
3218
3389
|
});
|
|
3219
3390
|
return res.version;
|
|
3220
3391
|
}
|
|
3392
|
+
async runReminders() {
|
|
3393
|
+
return this.request("/api/v1/tax/reminders/run", { method: "POST" });
|
|
3394
|
+
}
|
|
3221
3395
|
async getComplianceStats(filters) {
|
|
3222
3396
|
const params = {};
|
|
3223
3397
|
if (filters?.time_range) params.time_range = filters.time_range;
|
|
@@ -3412,6 +3586,6 @@ function buildHandler(options) {
|
|
|
3412
3586
|
return handler;
|
|
3413
3587
|
}
|
|
3414
3588
|
|
|
3415
|
-
export { AuthenticationError, BaseClient, CGSError, CircuitBreaker, CircuitBreakerOpenError, ComplianceBlockedError, ComplianceClient, ComplianceError, DEFAULT_CURRENCY_RATES, GeolocationClient, KycClient, NetworkError, RateLimitError, RateLimitTracker, RiskProfileClient, SDK_VERSION, ServiceUnavailableError, TaxClient, TimeoutError, ValidationError, VesantError, WebhookHandler, createConsoleLogger, createNextWebhookHandler, createWebhookMiddleware, decodeCipherText, generateCipherText, isCipherTextExpired, noopLogger, verifyWebhookSignature };
|
|
3589
|
+
export { AuthenticationError, BaseClient, CGSError, CircuitBreaker, CircuitBreakerOpenError, ComplianceBlockedError, ComplianceClient, ComplianceError, DEFAULT_CURRENCY_RATES, GeolocationClient, KYC_DECLINED_DESCRIPTIONS, KycClient, NetworkError, RateLimitError, RateLimitTracker, RiskProfileClient, SDK_VERSION, ServiceUnavailableError, TaxClient, TimeoutError, ValidationError, VesantError, WebhookHandler, createConsoleLogger, createNextWebhookHandler, createWebhookMiddleware, decodeCipherText, generateCipherText, isCipherTextExpired, noopLogger, sdkReasons, verifyWebhookSignature };
|
|
3416
3590
|
//# sourceMappingURL=index.mjs.map
|
|
3417
3591
|
//# sourceMappingURL=index.mjs.map
|