vesant-sdk 1.6.6-next.ac58d2b → 2.0.0-dev.40d1c39

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.
Files changed (72) hide show
  1. package/README.md +4 -4
  2. package/dist/client-BJ87_Vv5.d.ts +430 -0
  3. package/dist/{client-DPtiuQvW.d.ts → client-Bvp-f05-.d.ts} +6 -6
  4. package/dist/{client-D6PE3pcB.d.mts → client-CIEa7xYG.d.mts} +6 -6
  5. package/dist/client-IAOGCBfm.d.mts +430 -0
  6. package/dist/compliance/index.d.mts +25 -429
  7. package/dist/compliance/index.d.ts +25 -429
  8. package/dist/compliance/index.js +131 -34
  9. package/dist/compliance/index.js.map +1 -1
  10. package/dist/compliance/index.mjs +131 -35
  11. package/dist/compliance/index.mjs.map +1 -1
  12. package/dist/decisions/index.d.mts +1 -1
  13. package/dist/decisions/index.d.ts +1 -1
  14. package/dist/decisions/index.js +1 -1
  15. package/dist/decisions/index.js.map +1 -1
  16. package/dist/decisions/index.mjs +1 -1
  17. package/dist/decisions/index.mjs.map +1 -1
  18. package/dist/geolocation/index.d.mts +3 -3
  19. package/dist/geolocation/index.d.ts +3 -3
  20. package/dist/geolocation/index.js +1 -1
  21. package/dist/geolocation/index.js.map +1 -1
  22. package/dist/geolocation/index.mjs +1 -1
  23. package/dist/geolocation/index.mjs.map +1 -1
  24. package/dist/index.d.mts +10 -8
  25. package/dist/index.d.ts +10 -8
  26. package/dist/index.js +145 -34
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +144 -35
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/kyc/core.d.mts +3 -3
  31. package/dist/kyc/core.d.ts +3 -3
  32. package/dist/kyc/core.js +15 -1
  33. package/dist/kyc/core.js.map +1 -1
  34. package/dist/kyc/core.mjs +15 -2
  35. package/dist/kyc/core.mjs.map +1 -1
  36. package/dist/kyc/index.d.mts +7 -3
  37. package/dist/kyc/index.d.ts +7 -3
  38. package/dist/kyc/index.js +15 -1
  39. package/dist/kyc/index.js.map +1 -1
  40. package/dist/kyc/index.mjs +15 -2
  41. package/dist/kyc/index.mjs.map +1 -1
  42. package/dist/react.d.mts +4 -4
  43. package/dist/react.d.ts +4 -4
  44. package/dist/react.js +1 -1
  45. package/dist/react.js.map +1 -1
  46. package/dist/react.mjs +1 -1
  47. package/dist/react.mjs.map +1 -1
  48. package/dist/risk-profile/index.d.mts +3 -3
  49. package/dist/risk-profile/index.d.ts +3 -3
  50. package/dist/risk-profile/index.js +1 -1
  51. package/dist/risk-profile/index.js.map +1 -1
  52. package/dist/risk-profile/index.mjs +1 -1
  53. package/dist/risk-profile/index.mjs.map +1 -1
  54. package/dist/scores/index.d.mts +1 -1
  55. package/dist/scores/index.d.ts +1 -1
  56. package/dist/scores/index.js +1 -1
  57. package/dist/scores/index.js.map +1 -1
  58. package/dist/scores/index.mjs +1 -1
  59. package/dist/scores/index.mjs.map +1 -1
  60. package/dist/tax/index.js +1 -1
  61. package/dist/tax/index.js.map +1 -1
  62. package/dist/tax/index.mjs +1 -1
  63. package/dist/tax/index.mjs.map +1 -1
  64. package/dist/{types-_YQdS3Ax.d.ts → types-2utj53GK.d.ts} +2 -2
  65. package/dist/{types-DGDVnogO.d.mts → types-C4Zx0d_u.d.mts} +2 -2
  66. package/dist/{types-B4Ezqo7V.d.mts → types-QUCWam16.d.mts} +7 -1
  67. package/dist/{types-B4Ezqo7V.d.ts → types-QUCWam16.d.ts} +7 -1
  68. package/dist/webhooks/index.d.mts +1 -1
  69. package/dist/webhooks/index.d.ts +1 -1
  70. package/dist/webhooks/index.js.map +1 -1
  71. package/dist/webhooks/index.mjs.map +1 -1
  72. package/package.json +1 -1
@@ -1,3 +1,78 @@
1
+ // src/compliance/block-reasons.ts
2
+ var sdkReasons = {
3
+ // Jurisdiction
4
+ jurisdictionBlocked: (country, countryISO) => ({
5
+ code: "JURISDICTION_BLOCKED",
6
+ message: "Access from a blocked jurisdiction",
7
+ metadata: { country, country_iso: countryISO }
8
+ }),
9
+ jurisdictionNonCompliant: () => ({
10
+ code: "JURISDICTION_NON_COMPLIANT",
11
+ message: "Location does not meet compliance requirements"
12
+ }),
13
+ jurisdictionRegistrationDenied: () => ({
14
+ code: "JURISDICTION_REGISTRATION_DENIED",
15
+ message: "Registration is not permitted in this jurisdiction"
16
+ }),
17
+ jurisdictionRestricted: () => ({
18
+ code: "JURISDICTION_RESTRICTED",
19
+ message: "Access from a restricted jurisdiction"
20
+ }),
21
+ // Risk
22
+ riskCriticalLevel: () => ({
23
+ code: "RISK_CRITICAL_LEVEL",
24
+ message: "Risk assessment reached critical threshold"
25
+ }),
26
+ accountSuspended: () => ({
27
+ code: "RISK_ACCOUNT_SUSPENDED",
28
+ message: "Customer account is suspended"
29
+ }),
30
+ sanctionsMatch: () => ({
31
+ code: "RISK_SANCTIONS_MATCH",
32
+ message: "Customer profile matched against sanctions list"
33
+ }),
34
+ riskHighLocation: () => ({
35
+ code: "RISK_HIGH_LOCATION",
36
+ message: "High-risk geographic location"
37
+ }),
38
+ riskHighCustomer: () => ({
39
+ code: "RISK_HIGH_CUSTOMER",
40
+ message: "Customer flagged as high risk"
41
+ }),
42
+ // Device
43
+ ciphertextInvalid: () => ({
44
+ code: "DEVICE_CIPHERTEXT_INVALID",
45
+ message: "Device verification payload failed validation"
46
+ }),
47
+ gpsIPMismatch: () => ({
48
+ code: "DEVICE_GPS_IP_MISMATCH",
49
+ message: "GPS location does not match IP-derived location"
50
+ }),
51
+ gpsRequired: () => ({
52
+ code: "DEVICE_GPS_REQUIRED",
53
+ message: "GPS verification is required but was not provided"
54
+ }),
55
+ // Transaction
56
+ transactionHighAmount: (amount, currency, threshold) => ({
57
+ code: "TRANSACTION_HIGH_AMOUNT",
58
+ message: "Transaction amount exceeds high-value threshold",
59
+ metadata: { amount, currency, threshold }
60
+ }),
61
+ transactionElevatedAmount: (amount, currency, threshold) => ({
62
+ code: "TRANSACTION_ELEVATED_AMOUNT",
63
+ message: "Transaction amount exceeds elevated-value threshold",
64
+ metadata: { amount, currency, threshold }
65
+ }),
66
+ transactionJurisdictionLimit: () => ({
67
+ code: "TRANSACTION_JURISDICTION_LIMIT",
68
+ message: "Transaction amount exceeds jurisdiction limit"
69
+ }),
70
+ anonymizationDetected: () => ({
71
+ code: "NETWORK_ANONYMIZER_DETECTED",
72
+ message: "Anonymization tool detected"
73
+ })
74
+ };
75
+
1
76
  // src/core/errors.ts
2
77
  var VesantError = class _VesantError extends Error {
3
78
  constructor(message, code, statusCode, details) {
@@ -222,7 +297,7 @@ function createConsoleLogger() {
222
297
  }
223
298
 
224
299
  // src/core/version.ts
225
- var SDK_VERSION = "1.6.6";
300
+ var SDK_VERSION = "2.0.0";
226
301
 
227
302
  // src/shared/browser-utils.ts
228
303
  function generateUUID() {
@@ -1600,23 +1675,23 @@ var ComplianceClient = class {
1600
1675
  blockReasons.push(...geoVerification.risk_reasons ?? []);
1601
1676
  }
1602
1677
  if (!geoVerification.is_compliant) {
1603
- if (!blockReasons.includes("non_compliant_jurisdiction")) {
1604
- blockReasons.push("non_compliant_jurisdiction");
1678
+ if (!blockReasons.some((r) => r.code === "JURISDICTION_NON_COMPLIANT")) {
1679
+ blockReasons.push(sdkReasons.jurisdictionNonCompliant());
1605
1680
  }
1606
1681
  }
1607
1682
  const jurisdiction = geoVerification.jurisdiction;
1608
1683
  if (jurisdiction) {
1609
1684
  if (jurisdiction.allow_registration === false) {
1610
- blockReasons.push("registration_not_allowed_in_jurisdiction");
1685
+ blockReasons.push(sdkReasons.jurisdictionRegistrationDenied());
1611
1686
  }
1612
1687
  if (jurisdiction.status === "blocked" || jurisdiction.status === "sanctioned") {
1613
- if (!blockReasons.includes("blocked_jurisdiction")) {
1614
- blockReasons.push("blocked_jurisdiction");
1688
+ if (!blockReasons.some((r) => r.code === "JURISDICTION_BLOCKED")) {
1689
+ blockReasons.push(sdkReasons.jurisdictionBlocked(jurisdiction.country_name ?? "", jurisdiction.country_iso ?? ""));
1615
1690
  }
1616
1691
  }
1617
1692
  if (jurisdiction.status === "restricted" && jurisdiction.allow_registration === false) {
1618
- if (!blockReasons.includes("restricted_jurisdiction_no_registration")) {
1619
- blockReasons.push("restricted_jurisdiction_no_registration");
1693
+ if (!blockReasons.some((r) => r.code === "JURISDICTION_RESTRICTED")) {
1694
+ blockReasons.push(sdkReasons.jurisdictionRestricted());
1620
1695
  }
1621
1696
  }
1622
1697
  }
@@ -1624,25 +1699,30 @@ var ComplianceClient = class {
1624
1699
  blockReasons.push(...geoVerification.geofence_evaluation.reasons ?? []);
1625
1700
  }
1626
1701
  if (geoVerification.risk_level === "critical") {
1627
- if (!blockReasons.includes("critical_risk_level")) {
1628
- blockReasons.push("critical_risk_level");
1702
+ if (!blockReasons.some((r) => r.code === "RISK_CRITICAL_LEVEL")) {
1703
+ blockReasons.push(sdkReasons.riskCriticalLevel());
1629
1704
  }
1630
1705
  }
1631
1706
  if (cipherTextResult) {
1632
1707
  if (!cipherTextResult.valid) {
1633
- blockReasons.push("ciphertext_validation_failed");
1708
+ blockReasons.push(sdkReasons.ciphertextInvalid());
1634
1709
  }
1635
1710
  if (cipherTextResult.risk?.is_blocked) {
1636
1711
  blockReasons.push(...cipherTextResult.risk.block_reasons || []);
1637
1712
  }
1638
1713
  if (cipherTextResult.risk?.location_mismatch) {
1639
- blockReasons.push("gps_ip_location_mismatch");
1714
+ blockReasons.push(sdkReasons.gpsIPMismatch());
1640
1715
  }
1641
1716
  }
1642
1717
  if (geoVerification.gps_required && !cipherTextResult) {
1643
- blockReasons.push("gps_verification_required");
1718
+ blockReasons.push(sdkReasons.gpsRequired());
1644
1719
  }
1645
- return [...new Set(blockReasons)];
1720
+ const seen = /* @__PURE__ */ new Set();
1721
+ return blockReasons.filter((r) => {
1722
+ if (seen.has(r.code)) return false;
1723
+ seen.add(r.code);
1724
+ return true;
1725
+ });
1646
1726
  }
1647
1727
  /**
1648
1728
  * Validate registration request has all required fields
@@ -2026,7 +2106,7 @@ var ComplianceClient = class {
2026
2106
  const blockReasons = [...geoVerification.risk_reasons ?? []];
2027
2107
  if (cipherTextResult) {
2028
2108
  if (!cipherTextResult.valid) {
2029
- blockReasons.push("ciphertext_validation_failed");
2109
+ blockReasons.push(sdkReasons.ciphertextInvalid());
2030
2110
  }
2031
2111
  if (cipherTextResult.risk?.is_blocked) {
2032
2112
  blockReasons.push(...cipherTextResult.risk.block_reasons || []);
@@ -2034,12 +2114,18 @@ var ComplianceClient = class {
2034
2114
  }
2035
2115
  const gpsBlocked = geoVerification.gps_required && !cipherTextResult;
2036
2116
  if (gpsBlocked) {
2037
- blockReasons.push("gps_verification_required");
2117
+ blockReasons.push(sdkReasons.gpsRequired());
2038
2118
  }
2119
+ const seen = /* @__PURE__ */ new Set();
2120
+ const dedupedBlockReasons = blockReasons.filter((r) => {
2121
+ if (seen.has(r.code)) return false;
2122
+ seen.add(r.code);
2123
+ return true;
2124
+ });
2039
2125
  return {
2040
2126
  allowed: geoVerification.is_compliant && !geoVerification.is_blocked && !cipherTextBlocked && !gpsBlocked,
2041
2127
  geolocation: geoVerification,
2042
- blockReasons: [...new Set(blockReasons)],
2128
+ blockReasons: dedupedBlockReasons,
2043
2129
  processingTime: Date.now() - startTime,
2044
2130
  cipherTextValidation: cipherTextResult
2045
2131
  };
@@ -2142,31 +2228,31 @@ var ComplianceClient = class {
2142
2228
  const normalizedAmount = this.normalizeToUSD(amount, currency);
2143
2229
  if (normalizedAmount > 1e4) {
2144
2230
  riskScore += 30;
2145
- factors.push("high_transaction_amount");
2231
+ factors.push(sdkReasons.transactionHighAmount(normalizedAmount, currency, 1e4));
2146
2232
  } else if (normalizedAmount > 5e3) {
2147
2233
  riskScore += 15;
2148
- factors.push("elevated_transaction_amount");
2234
+ factors.push(sdkReasons.transactionElevatedAmount(normalizedAmount, currency, 5e3));
2149
2235
  }
2150
2236
  riskScore += geoVerification.risk_score * 0.4;
2151
2237
  if (geoVerification.risk_level === "high" || geoVerification.risk_level === "critical") {
2152
- factors.push("high_risk_location");
2238
+ factors.push(sdkReasons.riskHighLocation());
2153
2239
  }
2154
2240
  riskScore += profile.risk_score * 0.3;
2155
2241
  if (profile.risk_category === "high" || profile.risk_category === "critical") {
2156
- factors.push("high_risk_customer");
2242
+ factors.push(sdkReasons.riskHighCustomer());
2157
2243
  }
2158
2244
  if (geoVerification.location.is_vpn || geoVerification.location.is_proxy) {
2159
2245
  riskScore += 20;
2160
- factors.push("anonymization_detected");
2246
+ factors.push(sdkReasons.anonymizationDetected());
2161
2247
  }
2162
2248
  if (profile.customer_status === "suspended") {
2163
2249
  riskScore += 50;
2164
- factors.push("account_suspended");
2250
+ factors.push(sdkReasons.accountSuspended());
2165
2251
  }
2166
2252
  if (cipherTextResult) {
2167
2253
  if (cipherTextResult.risk?.location_mismatch) {
2168
2254
  riskScore += 20;
2169
- factors.push("gps_ip_location_mismatch");
2255
+ factors.push(sdkReasons.gpsIPMismatch());
2170
2256
  }
2171
2257
  if (cipherTextResult.risk?.score) {
2172
2258
  riskScore += cipherTextResult.risk.score * 0.2;
@@ -2204,48 +2290,58 @@ var ComplianceClient = class {
2204
2290
  }
2205
2291
  if (profile) {
2206
2292
  if (profile.customer_status === "suspended") {
2207
- reasons.push("account_suspended");
2293
+ reasons.push(sdkReasons.accountSuspended());
2208
2294
  }
2209
2295
  if (profile.has_sanctions) {
2210
- reasons.push("sanctions_match");
2296
+ reasons.push(sdkReasons.sanctionsMatch());
2211
2297
  }
2212
2298
  }
2213
2299
  if (cipherTextResult) {
2214
2300
  if (!cipherTextResult.valid) {
2215
- reasons.push("ciphertext_validation_failed");
2301
+ reasons.push(sdkReasons.ciphertextInvalid());
2216
2302
  }
2217
2303
  if (cipherTextResult.risk?.is_blocked) {
2218
2304
  reasons.push(...cipherTextResult.risk.block_reasons || []);
2219
2305
  }
2220
2306
  }
2221
2307
  if (geoVerification.gps_required && !cipherTextResult) {
2222
- reasons.push("gps_verification_required");
2308
+ reasons.push(sdkReasons.gpsRequired());
2223
2309
  }
2224
- return [...new Set(reasons)];
2310
+ const seen = /* @__PURE__ */ new Set();
2311
+ return reasons.filter((r) => {
2312
+ if (seen.has(r.code)) return false;
2313
+ seen.add(r.code);
2314
+ return true;
2315
+ });
2225
2316
  }
2226
2317
  getTransactionBlockReasons(geoVerification, transactionRisk, jurisdictionAllowed, cipherTextResult) {
2227
2318
  const reasons = [];
2228
2319
  if (!geoVerification.is_compliant) {
2229
- reasons.push("non_compliant_jurisdiction");
2320
+ reasons.push(sdkReasons.jurisdictionNonCompliant());
2230
2321
  }
2231
2322
  if (!jurisdictionAllowed) {
2232
- reasons.push("exceeds_jurisdiction_limit");
2323
+ reasons.push(sdkReasons.transactionJurisdictionLimit());
2233
2324
  }
2234
2325
  if (!transactionRisk.allowed) {
2235
2326
  reasons.push(...transactionRisk.factors);
2236
2327
  }
2237
2328
  if (cipherTextResult) {
2238
2329
  if (!cipherTextResult.valid) {
2239
- reasons.push("ciphertext_validation_failed");
2330
+ reasons.push(sdkReasons.ciphertextInvalid());
2240
2331
  }
2241
2332
  if (cipherTextResult.risk?.is_blocked) {
2242
2333
  reasons.push(...cipherTextResult.risk.block_reasons || []);
2243
2334
  }
2244
2335
  }
2245
2336
  if (geoVerification.gps_required && !cipherTextResult) {
2246
- reasons.push("gps_verification_required");
2337
+ reasons.push(sdkReasons.gpsRequired());
2247
2338
  }
2248
- return [...new Set(reasons)];
2339
+ const seen = /* @__PURE__ */ new Set();
2340
+ return reasons.filter((r) => {
2341
+ if (seen.has(r.code)) return false;
2342
+ seen.add(r.code);
2343
+ return true;
2344
+ });
2249
2345
  }
2250
2346
  // ============================================================================
2251
2347
  // Location Request Methods
@@ -2463,6 +2559,6 @@ var ComplianceClient = class {
2463
2559
  }
2464
2560
  };
2465
2561
 
2466
- export { ComplianceClient, DEFAULT_CURRENCY_RATES };
2562
+ export { ComplianceClient, DEFAULT_CURRENCY_RATES, sdkReasons };
2467
2563
  //# sourceMappingURL=index.mjs.map
2468
2564
  //# sourceMappingURL=index.mjs.map