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
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.6.6";
243
+ var SDK_VERSION = "2.0.0";
244
244
 
245
245
  // src/shared/browser-utils.ts
246
246
  function generateUUID() {
@@ -1454,6 +1454,81 @@ var RiskProfileClient = class extends BaseClient {
1454
1454
  }
1455
1455
  };
1456
1456
 
1457
+ // src/compliance/block-reasons.ts
1458
+ var sdkReasons = {
1459
+ // Jurisdiction
1460
+ jurisdictionBlocked: (country, countryISO) => ({
1461
+ code: "JURISDICTION_BLOCKED",
1462
+ message: "Access from a blocked jurisdiction",
1463
+ metadata: { country, country_iso: countryISO }
1464
+ }),
1465
+ jurisdictionNonCompliant: () => ({
1466
+ code: "JURISDICTION_NON_COMPLIANT",
1467
+ message: "Location does not meet compliance requirements"
1468
+ }),
1469
+ jurisdictionRegistrationDenied: () => ({
1470
+ code: "JURISDICTION_REGISTRATION_DENIED",
1471
+ message: "Registration is not permitted in this jurisdiction"
1472
+ }),
1473
+ jurisdictionRestricted: () => ({
1474
+ code: "JURISDICTION_RESTRICTED",
1475
+ message: "Access from a restricted jurisdiction"
1476
+ }),
1477
+ // Risk
1478
+ riskCriticalLevel: () => ({
1479
+ code: "RISK_CRITICAL_LEVEL",
1480
+ message: "Risk assessment reached critical threshold"
1481
+ }),
1482
+ accountSuspended: () => ({
1483
+ code: "RISK_ACCOUNT_SUSPENDED",
1484
+ message: "Customer account is suspended"
1485
+ }),
1486
+ sanctionsMatch: () => ({
1487
+ code: "RISK_SANCTIONS_MATCH",
1488
+ message: "Customer profile matched against sanctions list"
1489
+ }),
1490
+ riskHighLocation: () => ({
1491
+ code: "RISK_HIGH_LOCATION",
1492
+ message: "High-risk geographic location"
1493
+ }),
1494
+ riskHighCustomer: () => ({
1495
+ code: "RISK_HIGH_CUSTOMER",
1496
+ message: "Customer flagged as high risk"
1497
+ }),
1498
+ // Device
1499
+ ciphertextInvalid: () => ({
1500
+ code: "DEVICE_CIPHERTEXT_INVALID",
1501
+ message: "Device verification payload failed validation"
1502
+ }),
1503
+ gpsIPMismatch: () => ({
1504
+ code: "DEVICE_GPS_IP_MISMATCH",
1505
+ message: "GPS location does not match IP-derived location"
1506
+ }),
1507
+ gpsRequired: () => ({
1508
+ code: "DEVICE_GPS_REQUIRED",
1509
+ message: "GPS verification is required but was not provided"
1510
+ }),
1511
+ // Transaction
1512
+ transactionHighAmount: (amount, currency, threshold) => ({
1513
+ code: "TRANSACTION_HIGH_AMOUNT",
1514
+ message: "Transaction amount exceeds high-value threshold",
1515
+ metadata: { amount, currency, threshold }
1516
+ }),
1517
+ transactionElevatedAmount: (amount, currency, threshold) => ({
1518
+ code: "TRANSACTION_ELEVATED_AMOUNT",
1519
+ message: "Transaction amount exceeds elevated-value threshold",
1520
+ metadata: { amount, currency, threshold }
1521
+ }),
1522
+ transactionJurisdictionLimit: () => ({
1523
+ code: "TRANSACTION_JURISDICTION_LIMIT",
1524
+ message: "Transaction amount exceeds jurisdiction limit"
1525
+ }),
1526
+ anonymizationDetected: () => ({
1527
+ code: "NETWORK_ANONYMIZER_DETECTED",
1528
+ message: "Anonymization tool detected"
1529
+ })
1530
+ };
1531
+
1457
1532
  // src/compliance/types.ts
1458
1533
  var DEFAULT_CURRENCY_RATES = {
1459
1534
  USD: 1,
@@ -1686,23 +1761,23 @@ var ComplianceClient = class {
1686
1761
  blockReasons.push(...geoVerification.risk_reasons ?? []);
1687
1762
  }
1688
1763
  if (!geoVerification.is_compliant) {
1689
- if (!blockReasons.includes("non_compliant_jurisdiction")) {
1690
- blockReasons.push("non_compliant_jurisdiction");
1764
+ if (!blockReasons.some((r) => r.code === "JURISDICTION_NON_COMPLIANT")) {
1765
+ blockReasons.push(sdkReasons.jurisdictionNonCompliant());
1691
1766
  }
1692
1767
  }
1693
1768
  const jurisdiction = geoVerification.jurisdiction;
1694
1769
  if (jurisdiction) {
1695
1770
  if (jurisdiction.allow_registration === false) {
1696
- blockReasons.push("registration_not_allowed_in_jurisdiction");
1771
+ blockReasons.push(sdkReasons.jurisdictionRegistrationDenied());
1697
1772
  }
1698
1773
  if (jurisdiction.status === "blocked" || jurisdiction.status === "sanctioned") {
1699
- if (!blockReasons.includes("blocked_jurisdiction")) {
1700
- blockReasons.push("blocked_jurisdiction");
1774
+ if (!blockReasons.some((r) => r.code === "JURISDICTION_BLOCKED")) {
1775
+ blockReasons.push(sdkReasons.jurisdictionBlocked(jurisdiction.country_name ?? "", jurisdiction.country_iso ?? ""));
1701
1776
  }
1702
1777
  }
1703
1778
  if (jurisdiction.status === "restricted" && jurisdiction.allow_registration === false) {
1704
- if (!blockReasons.includes("restricted_jurisdiction_no_registration")) {
1705
- blockReasons.push("restricted_jurisdiction_no_registration");
1779
+ if (!blockReasons.some((r) => r.code === "JURISDICTION_RESTRICTED")) {
1780
+ blockReasons.push(sdkReasons.jurisdictionRestricted());
1706
1781
  }
1707
1782
  }
1708
1783
  }
@@ -1710,25 +1785,30 @@ var ComplianceClient = class {
1710
1785
  blockReasons.push(...geoVerification.geofence_evaluation.reasons ?? []);
1711
1786
  }
1712
1787
  if (geoVerification.risk_level === "critical") {
1713
- if (!blockReasons.includes("critical_risk_level")) {
1714
- blockReasons.push("critical_risk_level");
1788
+ if (!blockReasons.some((r) => r.code === "RISK_CRITICAL_LEVEL")) {
1789
+ blockReasons.push(sdkReasons.riskCriticalLevel());
1715
1790
  }
1716
1791
  }
1717
1792
  if (cipherTextResult) {
1718
1793
  if (!cipherTextResult.valid) {
1719
- blockReasons.push("ciphertext_validation_failed");
1794
+ blockReasons.push(sdkReasons.ciphertextInvalid());
1720
1795
  }
1721
1796
  if (cipherTextResult.risk?.is_blocked) {
1722
1797
  blockReasons.push(...cipherTextResult.risk.block_reasons || []);
1723
1798
  }
1724
1799
  if (cipherTextResult.risk?.location_mismatch) {
1725
- blockReasons.push("gps_ip_location_mismatch");
1800
+ blockReasons.push(sdkReasons.gpsIPMismatch());
1726
1801
  }
1727
1802
  }
1728
1803
  if (geoVerification.gps_required && !cipherTextResult) {
1729
- blockReasons.push("gps_verification_required");
1804
+ blockReasons.push(sdkReasons.gpsRequired());
1730
1805
  }
1731
- return [...new Set(blockReasons)];
1806
+ const seen = /* @__PURE__ */ new Set();
1807
+ return blockReasons.filter((r) => {
1808
+ if (seen.has(r.code)) return false;
1809
+ seen.add(r.code);
1810
+ return true;
1811
+ });
1732
1812
  }
1733
1813
  /**
1734
1814
  * Validate registration request has all required fields
@@ -2112,7 +2192,7 @@ var ComplianceClient = class {
2112
2192
  const blockReasons = [...geoVerification.risk_reasons ?? []];
2113
2193
  if (cipherTextResult) {
2114
2194
  if (!cipherTextResult.valid) {
2115
- blockReasons.push("ciphertext_validation_failed");
2195
+ blockReasons.push(sdkReasons.ciphertextInvalid());
2116
2196
  }
2117
2197
  if (cipherTextResult.risk?.is_blocked) {
2118
2198
  blockReasons.push(...cipherTextResult.risk.block_reasons || []);
@@ -2120,12 +2200,18 @@ var ComplianceClient = class {
2120
2200
  }
2121
2201
  const gpsBlocked = geoVerification.gps_required && !cipherTextResult;
2122
2202
  if (gpsBlocked) {
2123
- blockReasons.push("gps_verification_required");
2203
+ blockReasons.push(sdkReasons.gpsRequired());
2124
2204
  }
2205
+ const seen = /* @__PURE__ */ new Set();
2206
+ const dedupedBlockReasons = blockReasons.filter((r) => {
2207
+ if (seen.has(r.code)) return false;
2208
+ seen.add(r.code);
2209
+ return true;
2210
+ });
2125
2211
  return {
2126
2212
  allowed: geoVerification.is_compliant && !geoVerification.is_blocked && !cipherTextBlocked && !gpsBlocked,
2127
2213
  geolocation: geoVerification,
2128
- blockReasons: [...new Set(blockReasons)],
2214
+ blockReasons: dedupedBlockReasons,
2129
2215
  processingTime: Date.now() - startTime,
2130
2216
  cipherTextValidation: cipherTextResult
2131
2217
  };
@@ -2228,31 +2314,31 @@ var ComplianceClient = class {
2228
2314
  const normalizedAmount = this.normalizeToUSD(amount, currency);
2229
2315
  if (normalizedAmount > 1e4) {
2230
2316
  riskScore += 30;
2231
- factors.push("high_transaction_amount");
2317
+ factors.push(sdkReasons.transactionHighAmount(normalizedAmount, currency, 1e4));
2232
2318
  } else if (normalizedAmount > 5e3) {
2233
2319
  riskScore += 15;
2234
- factors.push("elevated_transaction_amount");
2320
+ factors.push(sdkReasons.transactionElevatedAmount(normalizedAmount, currency, 5e3));
2235
2321
  }
2236
2322
  riskScore += geoVerification.risk_score * 0.4;
2237
2323
  if (geoVerification.risk_level === "high" || geoVerification.risk_level === "critical") {
2238
- factors.push("high_risk_location");
2324
+ factors.push(sdkReasons.riskHighLocation());
2239
2325
  }
2240
2326
  riskScore += profile.risk_score * 0.3;
2241
2327
  if (profile.risk_category === "high" || profile.risk_category === "critical") {
2242
- factors.push("high_risk_customer");
2328
+ factors.push(sdkReasons.riskHighCustomer());
2243
2329
  }
2244
2330
  if (geoVerification.location.is_vpn || geoVerification.location.is_proxy) {
2245
2331
  riskScore += 20;
2246
- factors.push("anonymization_detected");
2332
+ factors.push(sdkReasons.anonymizationDetected());
2247
2333
  }
2248
2334
  if (profile.customer_status === "suspended") {
2249
2335
  riskScore += 50;
2250
- factors.push("account_suspended");
2336
+ factors.push(sdkReasons.accountSuspended());
2251
2337
  }
2252
2338
  if (cipherTextResult) {
2253
2339
  if (cipherTextResult.risk?.location_mismatch) {
2254
2340
  riskScore += 20;
2255
- factors.push("gps_ip_location_mismatch");
2341
+ factors.push(sdkReasons.gpsIPMismatch());
2256
2342
  }
2257
2343
  if (cipherTextResult.risk?.score) {
2258
2344
  riskScore += cipherTextResult.risk.score * 0.2;
@@ -2290,48 +2376,58 @@ var ComplianceClient = class {
2290
2376
  }
2291
2377
  if (profile) {
2292
2378
  if (profile.customer_status === "suspended") {
2293
- reasons.push("account_suspended");
2379
+ reasons.push(sdkReasons.accountSuspended());
2294
2380
  }
2295
2381
  if (profile.has_sanctions) {
2296
- reasons.push("sanctions_match");
2382
+ reasons.push(sdkReasons.sanctionsMatch());
2297
2383
  }
2298
2384
  }
2299
2385
  if (cipherTextResult) {
2300
2386
  if (!cipherTextResult.valid) {
2301
- reasons.push("ciphertext_validation_failed");
2387
+ reasons.push(sdkReasons.ciphertextInvalid());
2302
2388
  }
2303
2389
  if (cipherTextResult.risk?.is_blocked) {
2304
2390
  reasons.push(...cipherTextResult.risk.block_reasons || []);
2305
2391
  }
2306
2392
  }
2307
2393
  if (geoVerification.gps_required && !cipherTextResult) {
2308
- reasons.push("gps_verification_required");
2394
+ reasons.push(sdkReasons.gpsRequired());
2309
2395
  }
2310
- return [...new Set(reasons)];
2396
+ const seen = /* @__PURE__ */ new Set();
2397
+ return reasons.filter((r) => {
2398
+ if (seen.has(r.code)) return false;
2399
+ seen.add(r.code);
2400
+ return true;
2401
+ });
2311
2402
  }
2312
2403
  getTransactionBlockReasons(geoVerification, transactionRisk, jurisdictionAllowed, cipherTextResult) {
2313
2404
  const reasons = [];
2314
2405
  if (!geoVerification.is_compliant) {
2315
- reasons.push("non_compliant_jurisdiction");
2406
+ reasons.push(sdkReasons.jurisdictionNonCompliant());
2316
2407
  }
2317
2408
  if (!jurisdictionAllowed) {
2318
- reasons.push("exceeds_jurisdiction_limit");
2409
+ reasons.push(sdkReasons.transactionJurisdictionLimit());
2319
2410
  }
2320
2411
  if (!transactionRisk.allowed) {
2321
2412
  reasons.push(...transactionRisk.factors);
2322
2413
  }
2323
2414
  if (cipherTextResult) {
2324
2415
  if (!cipherTextResult.valid) {
2325
- reasons.push("ciphertext_validation_failed");
2416
+ reasons.push(sdkReasons.ciphertextInvalid());
2326
2417
  }
2327
2418
  if (cipherTextResult.risk?.is_blocked) {
2328
2419
  reasons.push(...cipherTextResult.risk.block_reasons || []);
2329
2420
  }
2330
2421
  }
2331
2422
  if (geoVerification.gps_required && !cipherTextResult) {
2332
- reasons.push("gps_verification_required");
2423
+ reasons.push(sdkReasons.gpsRequired());
2333
2424
  }
2334
- return [...new Set(reasons)];
2425
+ const seen = /* @__PURE__ */ new Set();
2426
+ return reasons.filter((r) => {
2427
+ if (seen.has(r.code)) return false;
2428
+ seen.add(r.code);
2429
+ return true;
2430
+ });
2335
2431
  }
2336
2432
  // ============================================================================
2337
2433
  // Location Request Methods
@@ -3138,6 +3234,19 @@ var KycClient = class extends BaseClient {
3138
3234
  // ============================================================================
3139
3235
  };
3140
3236
 
3237
+ // src/kyc/types.ts
3238
+ var KYC_DECLINED_DESCRIPTIONS = {
3239
+ KYC_DOCUMENT_EXPIRED: "The submitted document has expired",
3240
+ KYC_DOCUMENT_INVALID: "The submitted document could not be verified",
3241
+ KYC_FACE_MISMATCH: "Face verification did not match the identity document",
3242
+ KYC_AGE_REQUIREMENT: "Age requirement not met",
3243
+ KYC_DUPLICATE_IDENTITY: "This identity has already been verified under another account",
3244
+ KYC_ADDRESS_MISMATCH: "Address verification failed",
3245
+ KYC_NAME_MISMATCH: "Name on document does not match the registered name",
3246
+ KYC_PROVIDER_REJECTED: "Identity verification was rejected by the verification provider",
3247
+ KYC_DECLINED: "Identity verification was declined"
3248
+ };
3249
+
3141
3250
  // src/tax/client.ts
3142
3251
  var TaxClient = class extends BaseClient {
3143
3252
  constructor(config) {
@@ -3412,6 +3521,6 @@ function buildHandler(options) {
3412
3521
  return handler;
3413
3522
  }
3414
3523
 
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 };
3524
+ 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
3525
  //# sourceMappingURL=index.mjs.map
3417
3526
  //# sourceMappingURL=index.mjs.map