vesant-sdk 1.8.0-dev.2b9e28d → 1.8.0-dev.2d679f1

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 (60) hide show
  1. package/README.md +2 -2
  2. package/dist/{client-DUHC-68_.d.ts → client-BPALLldd.d.ts} +1 -1
  3. package/dist/{client-5q4whhGu.d.mts → client-_OhkfnyJ.d.mts} +1 -1
  4. package/dist/compliance/index.d.mts +2 -2
  5. package/dist/compliance/index.d.ts +2 -2
  6. package/dist/compliance/index.js +26 -9
  7. package/dist/compliance/index.js.map +1 -1
  8. package/dist/compliance/index.mjs +26 -9
  9. package/dist/compliance/index.mjs.map +1 -1
  10. package/dist/decisions/index.js +7 -6
  11. package/dist/decisions/index.js.map +1 -1
  12. package/dist/decisions/index.mjs +7 -6
  13. package/dist/decisions/index.mjs.map +1 -1
  14. package/dist/geolocation/index.js +7 -6
  15. package/dist/geolocation/index.js.map +1 -1
  16. package/dist/geolocation/index.mjs +7 -6
  17. package/dist/geolocation/index.mjs.map +1 -1
  18. package/dist/index.d.mts +3 -3
  19. package/dist/index.d.ts +3 -3
  20. package/dist/index.js +57 -167
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +55 -168
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/kyc/core.d.mts +2 -2
  25. package/dist/kyc/core.d.ts +2 -2
  26. package/dist/kyc/core.js +37 -164
  27. package/dist/kyc/core.js.map +1 -1
  28. package/dist/kyc/core.mjs +36 -165
  29. package/dist/kyc/core.mjs.map +1 -1
  30. package/dist/kyc/index.d.mts +218 -218
  31. package/dist/kyc/index.d.ts +218 -218
  32. package/dist/kyc/index.js +37 -164
  33. package/dist/kyc/index.js.map +1 -1
  34. package/dist/kyc/index.mjs +36 -165
  35. package/dist/kyc/index.mjs.map +1 -1
  36. package/dist/react.d.mts +16 -114
  37. package/dist/react.d.ts +16 -114
  38. package/dist/react.js +8 -186
  39. package/dist/react.js.map +1 -1
  40. package/dist/react.mjs +9 -184
  41. package/dist/react.mjs.map +1 -1
  42. package/dist/risk-profile/index.d.mts +16 -6
  43. package/dist/risk-profile/index.d.ts +16 -6
  44. package/dist/risk-profile/index.js +25 -8
  45. package/dist/risk-profile/index.js.map +1 -1
  46. package/dist/risk-profile/index.mjs +25 -9
  47. package/dist/risk-profile/index.mjs.map +1 -1
  48. package/dist/scores/index.js +7 -6
  49. package/dist/scores/index.js.map +1 -1
  50. package/dist/scores/index.mjs +7 -6
  51. package/dist/scores/index.mjs.map +1 -1
  52. package/dist/tax/index.d.mts +1 -1
  53. package/dist/tax/index.d.ts +1 -1
  54. package/dist/tax/index.js +7 -6
  55. package/dist/tax/index.js.map +1 -1
  56. package/dist/tax/index.mjs +7 -6
  57. package/dist/tax/index.mjs.map +1 -1
  58. package/dist/{types-BOFaMQxI.d.mts → types-DbvVph_0.d.mts} +45 -2
  59. package/dist/{types-UGyDl1fd.d.ts → types-qXamJr2q.d.ts} +45 -2
  60. package/package.json +1 -1
@@ -645,19 +645,20 @@ var BaseClient = class {
645
645
  * Handle error responses from API
646
646
  */
647
647
  handleErrorResponse(status, data, requestId) {
648
- const message = data.error || data.message || `HTTP ${status}`;
648
+ const structured = data.error && typeof data.error === "object" && !Array.isArray(data.error) ? data.error : void 0;
649
+ const message = typeof data.error === "string" && data.error || typeof structured?.message === "string" && structured.message || typeof data.message === "string" && data.message || `HTTP ${status}`;
649
650
  const createError = () => {
650
651
  switch (status) {
651
652
  case 400:
652
- return new VesantError(message, "BAD_REQUEST", 400);
653
+ return new VesantError(message, "BAD_REQUEST", 400, structured);
653
654
  case 401:
654
655
  return new AuthenticationError(message);
655
656
  case 403:
656
- return new VesantError(message, "FORBIDDEN", 403);
657
+ return new VesantError(message, "FORBIDDEN", 403, structured);
657
658
  case 404:
658
- return new VesantError(message, "NOT_FOUND", 404);
659
+ return new VesantError(message, "NOT_FOUND", 404, structured);
659
660
  case 409:
660
- return new VesantError(message, "DUPLICATE_PROFILE", 409);
661
+ return new VesantError(message, "DUPLICATE_PROFILE", 409, structured);
661
662
  case 429: {
662
663
  const retryAfter = data.retry_after || data.retryAfter;
663
664
  return new RateLimitError(retryAfter);
@@ -668,7 +669,7 @@ var BaseClient = class {
668
669
  case 504:
669
670
  return new ServiceUnavailableError(message);
670
671
  default:
671
- return new VesantError(message, "UNKNOWN_ERROR", status);
672
+ return new VesantError(message, "UNKNOWN_ERROR", status, structured);
672
673
  }
673
674
  };
674
675
  const error = createError();
@@ -1522,17 +1523,27 @@ var RiskProfileClient = class extends BaseClient {
1522
1523
  /**
1523
1524
  * Update customer profile
1524
1525
  *
1526
+ * Omitted fields keep their stored values. When the tenant has the
1527
+ * **On Account Sensitive Action** KYC trigger enabled and the update changes
1528
+ * the customer's name, date of birth or residential address, Vesant applies
1529
+ * the other fields, holds the sensitive ones and answers `202` with a
1530
+ * {@link ProfileUpdateHeldResponse} instead of the profile. Narrow with
1531
+ * {@link isProfileUpdateHeld}, then request a `profile_change` submit link.
1532
+ *
1525
1533
  * @param profileId - Profile UUID
1526
1534
  * @param updates - Fields to update
1527
- * @returns Updated customer profile
1535
+ * @returns Updated customer profile, or the held change
1528
1536
  *
1529
1537
  * @example
1530
1538
  * ```typescript
1531
- * const updated = await client.updateProfile(profileId, {
1539
+ * const result = await client.updateProfile(profileId, {
1532
1540
  * location: 'New York, USA',
1533
1541
  * location_compliance: 'compliant',
1534
1542
  * last_recorded_activity: new Date().toISOString()
1535
1543
  * });
1544
+ * if (isProfileUpdateHeld(result)) {
1545
+ * // name / DOB / address held: start KYC with trigger_event 'profile_change'
1546
+ * }
1536
1547
  * ```
1537
1548
  */
1538
1549
  async updateProfile(profileId, updates, requestOptions) {
@@ -1572,6 +1583,11 @@ var RiskProfileClient = class extends BaseClient {
1572
1583
  }
1573
1584
  };
1574
1585
 
1586
+ // src/risk-profile/types.ts
1587
+ function isProfileUpdateHeld(result) {
1588
+ return typeof result === "object" && result !== null && result.status === "kyc_required" && result.kyc_required === true;
1589
+ }
1590
+
1575
1591
  // src/compliance/types.ts
1576
1592
  var DEFAULT_CURRENCY_RATES = {
1577
1593
  USD: 1,
@@ -2027,11 +2043,12 @@ var ComplianceClient = class {
2027
2043
  if (profileResult) {
2028
2044
  profile = profileResult;
2029
2045
  if (!isBlocked && this.shouldUpdateProfile(profile, geoVerification.location.city)) {
2030
- profile = await this.riskClient.updateProfile(profile.id, {
2046
+ const updated = await this.riskClient.updateProfile(profile.id, {
2031
2047
  last_recorded_activity: (/* @__PURE__ */ new Date()).toISOString(),
2032
2048
  location: `${geoVerification.location.city}, ${geoVerification.location.country}`,
2033
2049
  location_compliance: geoVerification.is_compliant ? "compliant" : "non-compliant"
2034
2050
  }, requestOptions);
2051
+ profile = isProfileUpdateHeld(updated) ? updated.profile : updated;
2035
2052
  }
2036
2053
  } else {
2037
2054
  if (this.config.autoCreateProfiles && this.config.debug) {