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