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