vesant-sdk 1.6.0 → 1.6.2

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 (65) hide show
  1. package/dist/{client-C4g596fI.d.mts → client-BlCxjbY2.d.mts} +8 -2
  2. package/dist/{client-Bd9a5o0C.d.ts → client-C_A7QLcB.d.ts} +8 -2
  3. package/dist/{client-CIon-bGS.d.mts → client-ePzhQKp9.d.mts} +2 -0
  4. package/dist/{client-CIon-bGS.d.ts → client-ePzhQKp9.d.ts} +2 -0
  5. package/dist/compliance/index.d.mts +12 -5
  6. package/dist/compliance/index.d.ts +12 -5
  7. package/dist/compliance/index.js +201 -69
  8. package/dist/compliance/index.js.map +1 -1
  9. package/dist/compliance/index.mjs +201 -69
  10. package/dist/compliance/index.mjs.map +1 -1
  11. package/dist/decisions/index.d.mts +1 -1
  12. package/dist/decisions/index.d.ts +1 -1
  13. package/dist/decisions/index.js +14 -1
  14. package/dist/decisions/index.js.map +1 -1
  15. package/dist/decisions/index.mjs +14 -1
  16. package/dist/decisions/index.mjs.map +1 -1
  17. package/dist/geolocation/index.d.mts +3 -3
  18. package/dist/geolocation/index.d.ts +3 -3
  19. package/dist/geolocation/index.js +56 -14
  20. package/dist/geolocation/index.js.map +1 -1
  21. package/dist/geolocation/index.mjs +56 -14
  22. package/dist/geolocation/index.mjs.map +1 -1
  23. package/dist/index.d.mts +6 -376
  24. package/dist/index.d.ts +6 -376
  25. package/dist/index.js +268 -278
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.mjs +268 -278
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/kyc/core.d.mts +1 -1
  30. package/dist/kyc/core.d.ts +1 -1
  31. package/dist/kyc/core.js +14 -1
  32. package/dist/kyc/core.js.map +1 -1
  33. package/dist/kyc/core.mjs +14 -1
  34. package/dist/kyc/core.mjs.map +1 -1
  35. package/dist/kyc/index.d.mts +1 -1
  36. package/dist/kyc/index.d.ts +1 -1
  37. package/dist/kyc/index.js +14 -1
  38. package/dist/kyc/index.js.map +1 -1
  39. package/dist/kyc/index.mjs +14 -1
  40. package/dist/kyc/index.mjs.map +1 -1
  41. package/dist/react.d.mts +2 -2
  42. package/dist/react.d.ts +2 -2
  43. package/dist/react.js +1 -1
  44. package/dist/react.js.map +1 -1
  45. package/dist/react.mjs +1 -1
  46. package/dist/react.mjs.map +1 -1
  47. package/dist/risk-profile/index.d.mts +1 -1
  48. package/dist/risk-profile/index.d.ts +1 -1
  49. package/dist/risk-profile/index.js +14 -1
  50. package/dist/risk-profile/index.js.map +1 -1
  51. package/dist/risk-profile/index.mjs +14 -1
  52. package/dist/risk-profile/index.mjs.map +1 -1
  53. package/dist/scores/index.d.mts +1 -1
  54. package/dist/scores/index.d.ts +1 -1
  55. package/dist/scores/index.js +14 -1
  56. package/dist/scores/index.js.map +1 -1
  57. package/dist/scores/index.mjs +14 -1
  58. package/dist/scores/index.mjs.map +1 -1
  59. package/dist/tax/index.d.mts +255 -0
  60. package/dist/tax/index.d.ts +255 -0
  61. package/dist/tax/index.js +652 -0
  62. package/dist/tax/index.js.map +1 -0
  63. package/dist/tax/index.mjs +650 -0
  64. package/dist/tax/index.mjs.map +1 -0
  65. package/package.json +1 -1
@@ -222,7 +222,7 @@ function createConsoleLogger() {
222
222
  }
223
223
 
224
224
  // src/core/version.ts
225
- var SDK_VERSION = "1.6.0";
225
+ var SDK_VERSION = "1.6.2";
226
226
 
227
227
  // src/shared/browser-utils.ts
228
228
  function generateUUID() {
@@ -396,6 +396,19 @@ var BaseClient = class {
396
396
  if (this.rateLimitTracker) {
397
397
  this.rateLimitTracker.updateFromHeaders(response.headers);
398
398
  }
399
+ if (requestOptions?.responseType === "arraybuffer") {
400
+ if (!response.ok) {
401
+ let errData = {};
402
+ try {
403
+ errData = await response.json();
404
+ } catch {
405
+ }
406
+ this.handleErrorResponse(response.status, errData, requestId);
407
+ }
408
+ this.circuitBreaker?.onSuccess();
409
+ const buffer = await response.arrayBuffer();
410
+ return buffer;
411
+ }
399
412
  let data;
400
413
  try {
401
414
  data = await response.json();
@@ -1023,22 +1036,51 @@ var GeolocationClient = class extends BaseClient {
1023
1036
  void 0,
1024
1037
  requestOptions
1025
1038
  );
1026
- const locationResult = await this.verifyIP({
1027
- ip_address: ipAddress,
1028
- user_id: userId,
1029
- event_type: eventType,
1030
- device_fingerprint: cipherTextResult.valid && cipherTextResult.device ? {
1031
- device_id: cipherTextResult.device_uuid,
1032
- user_agent: "",
1033
- platform: cipherTextResult.device.platform,
1034
- browser: cipherTextResult.device.browser,
1035
- os: cipherTextResult.device.os
1036
- } : void 0
1037
- }, requestOptions);
1039
+ const loc = cipherTextResult.location;
1040
+ const risk = cipherTextResult.risk;
1041
+ if (!risk) {
1042
+ const locationResult = await this.verifyIP({
1043
+ ip_address: ipAddress,
1044
+ user_id: userId,
1045
+ event_type: eventType
1046
+ }, requestOptions);
1047
+ return {
1048
+ ciphertext_valid: cipherTextResult.valid,
1049
+ ciphertext_result: cipherTextResult,
1050
+ location: locationResult
1051
+ };
1052
+ }
1053
+ const location = {
1054
+ ip_address: cipherTextResult.ip_address,
1055
+ location: {
1056
+ country: loc?.country ?? "",
1057
+ country_iso: loc?.country_iso ?? "",
1058
+ city: loc?.city ?? "",
1059
+ region: loc?.region ?? "",
1060
+ postal_code: "",
1061
+ latitude: loc?.latitude ?? 0,
1062
+ longitude: loc?.longitude ?? 0,
1063
+ timezone: "",
1064
+ is_vpn: risk.is_vpn ?? false,
1065
+ is_proxy: risk.is_proxy ?? false,
1066
+ is_tor: risk.is_tor ?? false,
1067
+ is_hosting: risk.is_hosting ?? false,
1068
+ is_anonymizer: risk.is_vpn || risk.is_proxy || risk.is_tor
1069
+ },
1070
+ is_compliant: cipherTextResult.is_compliant ?? !risk.is_blocked,
1071
+ is_blocked: risk.is_blocked ?? false,
1072
+ risk_level: risk.level ?? "low",
1073
+ risk_score: risk.score ?? 0,
1074
+ risk_reasons: risk.is_blocked && risk.block_reasons ? risk.block_reasons : risk.factors ?? [],
1075
+ jurisdiction: cipherTextResult.jurisdiction,
1076
+ geofence_evaluation: cipherTextResult.geofence_evaluation,
1077
+ record_id: cipherTextResult.record_id ?? "",
1078
+ gps_required: cipherTextResult.gps_required
1079
+ };
1038
1080
  return {
1039
1081
  ciphertext_valid: cipherTextResult.valid,
1040
1082
  ciphertext_result: cipherTextResult,
1041
- location: locationResult
1083
+ location
1042
1084
  };
1043
1085
  }
1044
1086
  // ============================================================================
@@ -1443,28 +1485,34 @@ var ComplianceClient = class {
1443
1485
  if (this.config.debug) {
1444
1486
  this.logger.debug("Starting registration verification", { customerId: request.customerId });
1445
1487
  }
1446
- const customerData = request.cipherText ? {
1447
- full_name: request.fullName,
1448
- email: request.emailAddress,
1449
- phone: request.phoneNumber,
1450
- date_of_birth: request.dateOfBirth
1451
- } : void 0;
1452
- [cipherTextResult, geoVerification] = await Promise.all([
1453
- this.executeCipherTextValidation(
1488
+ if (request.cipherText) {
1489
+ cipherTextResult = await this.executeCipherTextValidation(
1454
1490
  request.cipherText,
1455
1491
  request.customerId,
1456
1492
  "registration",
1457
1493
  request.ipAddress,
1458
- customerData,
1494
+ {
1495
+ full_name: request.fullName,
1496
+ email: request.emailAddress,
1497
+ phone: request.phoneNumber,
1498
+ date_of_birth: request.dateOfBirth
1499
+ },
1459
1500
  requestOptions
1460
- ),
1461
- this.geoClient.verifyIP({
1501
+ );
1502
+ geoVerification = (cipherTextResult && this.buildLocationFromCipherText(cipherTextResult, request.ipAddress)) ?? await this.geoClient.verifyIP({
1462
1503
  ip_address: request.ipAddress,
1463
1504
  user_id: request.customerId,
1464
1505
  event_type: "registration",
1465
1506
  device_fingerprint: request.deviceFingerprint
1466
- }, requestOptions)
1467
- ]);
1507
+ }, requestOptions);
1508
+ } else {
1509
+ geoVerification = await this.geoClient.verifyIP({
1510
+ ip_address: request.ipAddress,
1511
+ user_id: request.customerId,
1512
+ event_type: "registration",
1513
+ device_fingerprint: request.deviceFingerprint
1514
+ }, requestOptions);
1515
+ }
1468
1516
  const blockReasons = this.evaluateRegistrationBlock(geoVerification, cipherTextResult);
1469
1517
  if (blockReasons.length > 0) {
1470
1518
  if (this.config.debug) {
@@ -1545,7 +1593,7 @@ var ComplianceClient = class {
1545
1593
  evaluateRegistrationBlock(geoVerification, cipherTextResult) {
1546
1594
  const blockReasons = [];
1547
1595
  if (geoVerification.is_blocked) {
1548
- blockReasons.push(...geoVerification.risk_reasons);
1596
+ blockReasons.push(...geoVerification.risk_reasons ?? []);
1549
1597
  }
1550
1598
  if (!geoVerification.is_compliant) {
1551
1599
  if (!blockReasons.includes("non_compliant_jurisdiction")) {
@@ -1569,7 +1617,7 @@ var ComplianceClient = class {
1569
1617
  }
1570
1618
  }
1571
1619
  if (geoVerification.geofence_evaluation?.blocked) {
1572
- blockReasons.push(...geoVerification.geofence_evaluation.reasons);
1620
+ blockReasons.push(...geoVerification.geofence_evaluation.reasons ?? []);
1573
1621
  }
1574
1622
  if (geoVerification.risk_level === "critical") {
1575
1623
  if (!blockReasons.includes("critical_risk_level")) {
@@ -1720,24 +1768,40 @@ var ComplianceClient = class {
1720
1768
  if (this.config.debug) {
1721
1769
  this.logger.debug("Starting login verification", { customerId: request.customerId });
1722
1770
  }
1723
- const [cipherTextResult, geoVerification, profileResult] = await Promise.all([
1724
- this.executeCipherTextValidation(
1725
- request.cipherText,
1726
- request.customerId,
1727
- "login",
1728
- request.ipAddress,
1729
- void 0,
1730
- requestOptions
1731
- ),
1732
- this.geoClient.verifyIP({
1771
+ let cipherTextResult;
1772
+ let geoVerification;
1773
+ let profileResult;
1774
+ if (request.cipherText) {
1775
+ [cipherTextResult, profileResult] = await Promise.all([
1776
+ this.executeCipherTextValidation(
1777
+ request.cipherText,
1778
+ request.customerId,
1779
+ "login",
1780
+ request.ipAddress,
1781
+ void 0,
1782
+ requestOptions
1783
+ ),
1784
+ this.riskClient.getProfile(request.customerId, requestOptions).catch(() => null)
1785
+ ]);
1786
+ geoVerification = (cipherTextResult && this.buildLocationFromCipherText(cipherTextResult, request.ipAddress)) ?? await this.geoClient.verifyIP({
1733
1787
  ip_address: request.ipAddress,
1734
1788
  user_id: request.customerId,
1735
1789
  event_type: "login",
1736
1790
  device_fingerprint: request.deviceFingerprint
1737
- }, requestOptions),
1738
- this.riskClient.getProfile(request.customerId, requestOptions).catch(() => null)
1739
- ]);
1740
- const loginBlockReasons = this.getBlockReasons(geoVerification, profileResult || {}, cipherTextResult);
1791
+ }, requestOptions);
1792
+ } else {
1793
+ [, geoVerification, profileResult] = await Promise.all([
1794
+ Promise.resolve(void 0),
1795
+ this.geoClient.verifyIP({
1796
+ ip_address: request.ipAddress,
1797
+ user_id: request.customerId,
1798
+ event_type: "login",
1799
+ device_fingerprint: request.deviceFingerprint
1800
+ }, requestOptions),
1801
+ this.riskClient.getProfile(request.customerId, requestOptions).catch(() => null)
1802
+ ]);
1803
+ }
1804
+ const loginBlockReasons = this.getBlockReasons(geoVerification, profileResult, cipherTextResult);
1741
1805
  const isBlocked = !geoVerification.is_compliant || geoVerification.is_blocked || !!cipherTextResult?.risk?.is_blocked || cipherTextResult?.valid === false || geoVerification.gps_required && !cipherTextResult;
1742
1806
  if (isBlocked && !profileResult) {
1743
1807
  return {
@@ -1821,23 +1885,39 @@ var ComplianceClient = class {
1821
1885
  currency: request.currency
1822
1886
  });
1823
1887
  }
1824
- const [cipherTextResult, geoVerification, profileResult] = await Promise.all([
1825
- this.executeCipherTextValidation(
1826
- request.cipherText,
1827
- request.customerId,
1828
- "transaction",
1829
- request.ipAddress,
1830
- void 0,
1831
- requestOptions
1832
- ),
1833
- this.geoClient.verifyIP({
1888
+ let cipherTextResult;
1889
+ let geoVerification;
1890
+ let profileResult;
1891
+ if (request.cipherText) {
1892
+ [cipherTextResult, profileResult] = await Promise.all([
1893
+ this.executeCipherTextValidation(
1894
+ request.cipherText,
1895
+ request.customerId,
1896
+ "transaction",
1897
+ request.ipAddress,
1898
+ void 0,
1899
+ requestOptions
1900
+ ),
1901
+ this.riskClient.getProfile(request.customerId, requestOptions).catch(() => null)
1902
+ ]);
1903
+ geoVerification = (cipherTextResult && this.buildLocationFromCipherText(cipherTextResult, request.ipAddress)) ?? await this.geoClient.verifyIP({
1834
1904
  ip_address: request.ipAddress,
1835
1905
  user_id: request.customerId,
1836
1906
  event_type: "transaction",
1837
1907
  device_fingerprint: request.deviceFingerprint
1838
- }, requestOptions),
1839
- this.riskClient.getProfile(request.customerId, requestOptions).catch(() => null)
1840
- ]);
1908
+ }, requestOptions);
1909
+ } else {
1910
+ [, geoVerification, profileResult] = await Promise.all([
1911
+ Promise.resolve(void 0),
1912
+ this.geoClient.verifyIP({
1913
+ ip_address: request.ipAddress,
1914
+ user_id: request.customerId,
1915
+ event_type: "transaction",
1916
+ device_fingerprint: request.deviceFingerprint
1917
+ }, requestOptions),
1918
+ this.riskClient.getProfile(request.customerId, requestOptions).catch(() => null)
1919
+ ]);
1920
+ }
1841
1921
  const geoBlocked = !geoVerification.is_compliant || geoVerification.is_blocked || !!cipherTextResult?.risk?.is_blocked || cipherTextResult?.valid === false || geoVerification.gps_required && !cipherTextResult;
1842
1922
  if (geoBlocked && !profileResult) {
1843
1923
  return {
@@ -1856,6 +1936,9 @@ var ComplianceClient = class {
1856
1936
  cipherTextValidation: cipherTextResult
1857
1937
  };
1858
1938
  }
1939
+ if (!profileResult) {
1940
+ throw new ComplianceError("Customer profile not found", request.customerId);
1941
+ }
1859
1942
  const profile = profileResult;
1860
1943
  const transactionRisk = this.calculateTransactionRisk(
1861
1944
  request.amount,
@@ -1898,22 +1981,31 @@ var ComplianceClient = class {
1898
1981
  async verifyEvent(request, requestOptions) {
1899
1982
  const startTime = Date.now();
1900
1983
  this.validateEventRequest(request);
1901
- const [cipherTextResult, geoVerification] = await Promise.all([
1902
- this.executeCipherTextValidation(
1984
+ let cipherTextResult;
1985
+ let geoVerification;
1986
+ if (request.cipherText) {
1987
+ cipherTextResult = await this.executeCipherTextValidation(
1903
1988
  request.cipherText,
1904
1989
  request.customerId,
1905
1990
  request.eventType,
1906
1991
  request.ipAddress,
1907
1992
  void 0,
1908
1993
  requestOptions
1909
- ),
1910
- this.geoClient.verifyIP({
1994
+ );
1995
+ geoVerification = (cipherTextResult && this.buildLocationFromCipherText(cipherTextResult, request.ipAddress)) ?? await this.geoClient.verifyIP({
1911
1996
  ip_address: request.ipAddress,
1912
1997
  user_id: request.customerId,
1913
1998
  event_type: request.eventType,
1914
1999
  device_fingerprint: request.deviceFingerprint
1915
- }, requestOptions)
1916
- ]);
2000
+ }, requestOptions);
2001
+ } else {
2002
+ geoVerification = await this.geoClient.verifyIP({
2003
+ ip_address: request.ipAddress,
2004
+ user_id: request.customerId,
2005
+ event_type: request.eventType,
2006
+ device_fingerprint: request.deviceFingerprint
2007
+ }, requestOptions);
2008
+ }
1917
2009
  if (this.config.autoCreateProfiles) {
1918
2010
  try {
1919
2011
  const profile = await this.riskClient.getProfile(request.customerId, requestOptions);
@@ -1927,7 +2019,7 @@ var ComplianceClient = class {
1927
2019
  }
1928
2020
  }
1929
2021
  const cipherTextBlocked = cipherTextResult ? !cipherTextResult.valid || cipherTextResult.risk?.is_blocked === true : false;
1930
- const blockReasons = [...geoVerification.risk_reasons];
2022
+ const blockReasons = [...geoVerification.risk_reasons ?? []];
1931
2023
  if (cipherTextResult) {
1932
2024
  if (!cipherTextResult.valid) {
1933
2025
  blockReasons.push("ciphertext_validation_failed");
@@ -1996,6 +2088,44 @@ var ComplianceClient = class {
1996
2088
  return void 0;
1997
2089
  }
1998
2090
  }
2091
+ /**
2092
+ * Build a LocationVerification from a ValidateCipherTextResponse.
2093
+ * The validate-ciphertext endpoint now returns the full geo-verification data
2094
+ * (is_compliant, jurisdiction, geofence_evaluation, record_id, gps_required),
2095
+ * so a separate verifyIP call is unnecessary.
2096
+ */
2097
+ buildLocationFromCipherText(ct, ipAddress) {
2098
+ const loc = ct.location;
2099
+ const risk = ct.risk;
2100
+ if (!risk) return null;
2101
+ return {
2102
+ ip_address: ct.ip_address || ipAddress,
2103
+ location: {
2104
+ country: loc?.country ?? "",
2105
+ country_iso: loc?.country_iso ?? "",
2106
+ city: loc?.city ?? "",
2107
+ region: loc?.region ?? "",
2108
+ postal_code: "",
2109
+ latitude: loc?.latitude ?? 0,
2110
+ longitude: loc?.longitude ?? 0,
2111
+ timezone: "",
2112
+ is_vpn: risk.is_vpn,
2113
+ is_proxy: risk.is_proxy,
2114
+ is_tor: risk.is_tor,
2115
+ is_hosting: risk.is_hosting ?? false,
2116
+ is_anonymizer: risk.is_vpn || risk.is_proxy || risk.is_tor
2117
+ },
2118
+ is_compliant: ct.is_compliant ?? !risk.is_blocked,
2119
+ is_blocked: risk.is_blocked,
2120
+ risk_level: risk.level,
2121
+ risk_score: risk.score,
2122
+ risk_reasons: risk.is_blocked && risk.block_reasons ? risk.block_reasons : risk.factors ?? [],
2123
+ jurisdiction: ct.jurisdiction,
2124
+ geofence_evaluation: ct.geofence_evaluation,
2125
+ record_id: ct.record_id ?? "",
2126
+ gps_required: ct.gps_required
2127
+ };
2128
+ }
1999
2129
  calculateTransactionRisk(amount, currency, geoVerification, profile, cipherTextResult) {
2000
2130
  if (!this._currencyRatesCustomized && !this._currencyRatesWarned) {
2001
2131
  this._currencyRatesWarned = true;
@@ -2066,13 +2196,15 @@ var ComplianceClient = class {
2066
2196
  getBlockReasons(geoVerification, profile, cipherTextResult) {
2067
2197
  const reasons = [];
2068
2198
  if (geoVerification.is_blocked) {
2069
- reasons.push(...geoVerification.risk_reasons);
2199
+ reasons.push(...geoVerification.risk_reasons ?? []);
2070
2200
  }
2071
- if (profile.customer_status === "suspended") {
2072
- reasons.push("account_suspended");
2073
- }
2074
- if (profile.has_sanctions) {
2075
- reasons.push("sanctions_match");
2201
+ if (profile) {
2202
+ if (profile.customer_status === "suspended") {
2203
+ reasons.push("account_suspended");
2204
+ }
2205
+ if (profile.has_sanctions) {
2206
+ reasons.push("sanctions_match");
2207
+ }
2076
2208
  }
2077
2209
  if (cipherTextResult) {
2078
2210
  if (!cipherTextResult.valid) {