vesant-sdk 1.7.2 → 1.8.0-dev.00f6233

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 +3 -3
  2. package/dist/{client-B3DCAHlg.d.ts → client-BPALLldd.d.ts} +2 -2
  3. package/dist/{client-fy3trF2K.d.ts → client-BaUekQT8.d.ts} +32 -10
  4. package/dist/{client-BwXMQA2a.d.mts → client-XDEhh9VN.d.mts} +32 -10
  5. package/dist/{client-D23KhWeh.d.mts → client-_OhkfnyJ.d.mts} +2 -2
  6. package/dist/compliance/index.d.mts +3 -3
  7. package/dist/compliance/index.d.ts +3 -3
  8. package/dist/compliance/index.js +66 -11
  9. package/dist/compliance/index.js.map +1 -1
  10. package/dist/compliance/index.mjs +66 -11
  11. package/dist/compliance/index.mjs.map +1 -1
  12. package/dist/decisions/index.js +8 -7
  13. package/dist/decisions/index.js.map +1 -1
  14. package/dist/decisions/index.mjs +8 -7
  15. package/dist/decisions/index.mjs.map +1 -1
  16. package/dist/geolocation/index.d.mts +2 -2
  17. package/dist/geolocation/index.d.ts +2 -2
  18. package/dist/geolocation/index.js +47 -8
  19. package/dist/geolocation/index.js.map +1 -1
  20. package/dist/geolocation/index.mjs +47 -8
  21. package/dist/geolocation/index.mjs.map +1 -1
  22. package/dist/{index-DSDgS09k.d.ts → index-BosFSGan.d.ts} +57 -2
  23. package/dist/{index-C3zUKydT.d.mts → index-C49a7fg2.d.mts} +57 -2
  24. package/dist/index.d.mts +6 -6
  25. package/dist/index.d.ts +6 -6
  26. package/dist/index.js +104 -169
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +101 -170
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/kyc/core.d.mts +2 -2
  31. package/dist/kyc/core.d.ts +2 -2
  32. package/dist/kyc/core.js +39 -165
  33. package/dist/kyc/core.js.map +1 -1
  34. package/dist/kyc/core.mjs +38 -166
  35. package/dist/kyc/core.mjs.map +1 -1
  36. package/dist/kyc/index.d.mts +219 -218
  37. package/dist/kyc/index.d.ts +219 -218
  38. package/dist/kyc/index.js +39 -165
  39. package/dist/kyc/index.js.map +1 -1
  40. package/dist/kyc/index.mjs +38 -166
  41. package/dist/kyc/index.mjs.map +1 -1
  42. package/dist/react.d.mts +24 -115
  43. package/dist/react.d.ts +24 -115
  44. package/dist/react.js +23 -196
  45. package/dist/react.js.map +1 -1
  46. package/dist/react.mjs +24 -194
  47. package/dist/react.mjs.map +1 -1
  48. package/dist/risk-profile/index.d.mts +16 -6
  49. package/dist/risk-profile/index.d.ts +16 -6
  50. package/dist/risk-profile/index.js +26 -9
  51. package/dist/risk-profile/index.js.map +1 -1
  52. package/dist/risk-profile/index.mjs +26 -10
  53. package/dist/risk-profile/index.mjs.map +1 -1
  54. package/dist/scores/index.js +8 -7
  55. package/dist/scores/index.js.map +1 -1
  56. package/dist/scores/index.mjs +8 -7
  57. package/dist/scores/index.mjs.map +1 -1
  58. package/dist/tax/index.d.mts +1 -1
  59. package/dist/tax/index.d.ts +1 -1
  60. package/dist/tax/index.js +8 -7
  61. package/dist/tax/index.js.map +1 -1
  62. package/dist/tax/index.mjs +8 -7
  63. package/dist/tax/index.mjs.map +1 -1
  64. package/dist/{types-BOFaMQxI.d.mts → types-DbvVph_0.d.mts} +45 -2
  65. package/dist/{types-UGyDl1fd.d.ts → types-qXamJr2q.d.ts} +45 -2
  66. package/dist/webhooks/index.d.mts +1 -1
  67. package/dist/webhooks/index.d.ts +1 -1
  68. package/dist/webhooks/index.js +6 -0
  69. package/dist/webhooks/index.js.map +1 -1
  70. package/dist/webhooks/index.mjs +6 -1
  71. package/dist/webhooks/index.mjs.map +1 -1
  72. package/package.json +1 -1
package/dist/kyc/index.js CHANGED
@@ -229,7 +229,7 @@ function createConsoleLogger() {
229
229
  }
230
230
 
231
231
  // src/core/version.ts
232
- var SDK_VERSION = "1.7.2";
232
+ var SDK_VERSION = "1.8.0";
233
233
 
234
234
  // src/shared/browser-utils.ts
235
235
  function generateUUID() {
@@ -507,19 +507,20 @@ var BaseClient = class {
507
507
  * Handle error responses from API
508
508
  */
509
509
  handleErrorResponse(status, data, requestId) {
510
- const message = data.error || data.message || `HTTP ${status}`;
510
+ const structured = data.error && typeof data.error === "object" && !Array.isArray(data.error) ? data.error : void 0;
511
+ const message = typeof data.error === "string" && data.error || typeof structured?.message === "string" && structured.message || typeof data.message === "string" && data.message || `HTTP ${status}`;
511
512
  const createError = () => {
512
513
  switch (status) {
513
514
  case 400:
514
- return new VesantError(message, "BAD_REQUEST", 400);
515
+ return new VesantError(message, "BAD_REQUEST", 400, structured);
515
516
  case 401:
516
517
  return new AuthenticationError(message);
517
518
  case 403:
518
- return new VesantError(message, "FORBIDDEN", 403);
519
+ return new VesantError(message, "FORBIDDEN", 403, structured);
519
520
  case 404:
520
- return new VesantError(message, "NOT_FOUND", 404);
521
+ return new VesantError(message, "NOT_FOUND", 404, structured);
521
522
  case 409:
522
- return new VesantError(message, "DUPLICATE_PROFILE", 409);
523
+ return new VesantError(message, "DUPLICATE_PROFILE", 409, structured);
523
524
  case 429: {
524
525
  const retryAfter = data.retry_after || data.retryAfter;
525
526
  return new RateLimitError(retryAfter);
@@ -530,7 +531,7 @@ var BaseClient = class {
530
531
  case 504:
531
532
  return new ServiceUnavailableError(message);
532
533
  default:
533
- return new VesantError(message, "UNKNOWN_ERROR", status);
534
+ return new VesantError(message, "UNKNOWN_ERROR", status, structured);
534
535
  }
535
536
  };
536
537
  const error = createError();
@@ -892,77 +893,24 @@ var KycClient = class extends BaseClient {
892
893
  }, void 0, requestOptions);
893
894
  }
894
895
  /**
895
- * Get a KYC request by ID
896
+ * Get a KYC record by ID
896
897
  *
897
- * @param id - KYC request ID
898
- * @returns KYC request details including proofs and alerts
898
+ * Works with your tenant API key. Each entry in `proofs` carries a
899
+ * short-lived `link` for downloading that document, and `reference` holds
900
+ * your own customer reference (the `forward_reference`).
901
+ *
902
+ * @param id - KYC record ID (the `kyc_id` returned by `requestKycSubmitLink`)
903
+ * @returns KYC record including proofs (with download links) and alerts
899
904
  *
900
905
  * @example
901
906
  * ```typescript
902
907
  * const kyc = await client.getKycRequest("550e8400-e29b-41d4-a716-446655440000");
903
908
  * console.log(`Status: ${kyc.status}, ID Verified: ${kyc.id_verified}`);
909
+ * kyc.proofs?.forEach(proof => console.log(`${proof.type}: ${proof.link}`));
904
910
  * ```
905
911
  */
906
912
  async getKycRequest(id) {
907
- return this.request(`/api/v1/kyc/requests/${id}`);
908
- }
909
- /**
910
- * List KYC requests with filters and pagination
911
- *
912
- * @param filters - Optional filters (status, search, date range)
913
- * @param pagination - Optional pagination (page, page_size)
914
- * @returns Paginated list of KYC requests
915
- *
916
- * @example
917
- * ```typescript
918
- * const requests = await client.listKycRequests(
919
- * { status: "pending", search: "john" },
920
- * { page: 1, page_size: 20 }
921
- * );
922
- * console.log(`Found ${requests.total} pending requests`);
923
- * ```
924
- */
925
- async listKycRequests(filters, pagination) {
926
- const params = {};
927
- if (filters) {
928
- addFilterParam(params, "status", filters.status);
929
- addSimpleParams(params, filters, ["search", "fromDate", "toDate", "sortBy", "order"]);
930
- }
931
- if (pagination) {
932
- if (pagination.page) params.page = pagination.page;
933
- if (pagination.page_size) params.limit = pagination.page_size;
934
- }
935
- return this.request(
936
- `/api/v1/kyc/requests${this.buildQueryString(params)}`,
937
- { headers: this.getUserHeaders() }
938
- );
939
- }
940
- /**
941
- * Update KYC request status (accept/decline)
942
- *
943
- * @param request - Status update request with reference, status, and reason
944
- *
945
- * @example
946
- * ```typescript
947
- * // Accept a KYC request
948
- * await client.updateKycStatus({
949
- * reference: "kyc-ref-123",
950
- * status: "accepted",
951
- * reason: "All documents verified successfully"
952
- * });
953
- *
954
- * // Decline a KYC request
955
- * await client.updateKycStatus({
956
- * reference: "kyc-ref-456",
957
- * status: "declined",
958
- * reason: "Document expired"
959
- * });
960
- * ```
961
- */
962
- async updateKycStatus(request) {
963
- await this.request("/api/v1/kyc/status", {
964
- method: "PUT",
965
- body: JSON.stringify(request),
913
+ return this.request(`/api/v1/kyc/${encodeURIComponent(id)}`, {
966
914
  headers: this.getUserHeaders()
967
915
  });
968
916
  }
@@ -994,63 +942,28 @@ var KycClient = class extends BaseClient {
994
942
  /**
995
943
  * Get downloadable URLs for KYC proofs/documents
996
944
  *
997
- * @param kycId - KYC request ID
998
- * @returns Array of proof download URLs with expiration
945
+ * Derived from the `proofs` of `getKycRequest`: the platform attaches a
946
+ * short-lived download link to every proof on the KYC record, so no
947
+ * separate endpoint is needed. Proofs without a link are omitted.
948
+ *
949
+ * @param kycId - KYC record ID
950
+ * @returns Array of proof download URLs
999
951
  *
1000
952
  * @example
1001
953
  * ```typescript
1002
954
  * const proofs = await client.getProofDownloadURLs("550e8400-e29b-41d4-a716-446655440000");
1003
955
  * proofs.forEach(proof => {
1004
- * console.log(`${proof.type}: ${proof.url} (expires: ${proof.expires_at})`);
956
+ * console.log(`${proof.type}: ${proof.url}`);
1005
957
  * });
1006
958
  * ```
1007
959
  */
1008
960
  async getProofDownloadURLs(kycId) {
1009
- return this.request(
1010
- `/api/v1/kyc/proofs/${kycId}`,
1011
- { headers: this.getUserHeaders() }
1012
- );
1013
- }
1014
- // ============================================================================
1015
- // KYC Overview & Statistics
1016
- // ============================================================================
1017
- /**
1018
- * Get KYC overview statistics
1019
- *
1020
- * @param fromDate - Optional start date (ISO 8601)
1021
- * @param toDate - Optional end date (ISO 8601)
1022
- * @returns KYC statistics including counts by status
1023
- *
1024
- * @example
1025
- * ```typescript
1026
- * const overview = await client.getOverview(
1027
- * "2024-01-01T00:00:00Z",
1028
- * "2024-12-31T23:59:59Z"
1029
- * );
1030
- * console.log(`Total: ${overview.total}, Pending: ${overview.pending}`);
1031
- * console.log(`Approved: ${overview.approved}, Rejected: ${overview.rejected}`);
1032
- * ```
1033
- */
1034
- async getOverview(fromDate, toDate) {
1035
- const params = {};
1036
- if (fromDate) params.fromDate = fromDate;
1037
- if (toDate) params.toDate = toDate;
1038
- return this.request(
1039
- `/api/v1/kyc/overview${this.buildQueryString(params)}`
1040
- );
961
+ const kyc = await this.getKycRequest(kycId);
962
+ return (kyc.proofs ?? []).filter((proof) => typeof proof.link === "string" && proof.link !== "").map((proof) => ({ id: proof.id, type: proof.type, url: proof.link }));
1041
963
  }
1042
964
  // ============================================================================
1043
965
  // Alert Management
1044
966
  // ============================================================================
1045
- /**
1046
- * Get a KYC alert by ID
1047
- *
1048
- * @param alertId - Alert ID
1049
- * @returns Alert details
1050
- */
1051
- async getAlert(alertId) {
1052
- return this.request(`/api/v1/kyc/alerts/${alertId}`);
1053
- }
1054
967
  /**
1055
968
  * List KYC alerts with filters and pagination
1056
969
  *
@@ -1070,6 +983,10 @@ var KycClient = class extends BaseClient {
1070
983
  * );
1071
984
  * console.log(`Found ${alerts.total} alerts`);
1072
985
  * ```
986
+ *
987
+ * @remarks Console session only. This endpoint accepts a Vesant console
988
+ * (dashboard login) token, not a tenant API key; called with an API key it
989
+ * fails with `AuthenticationError` or a permission error.
1073
990
  */
1074
991
  async listAlerts(filters, pagination) {
1075
992
  const params = {};
@@ -1089,66 +1006,15 @@ var KycClient = class extends BaseClient {
1089
1006
  `/api/v1/kyc/alerts${this.buildQueryString(params)}`
1090
1007
  );
1091
1008
  }
1092
- /**
1093
- * Update a KYC alert
1094
- *
1095
- * @param alertId - Alert ID
1096
- * @param update - Fields to update (status, assigned_for, reason, alert_type)
1097
- *
1098
- * @example
1099
- * ```typescript
1100
- * // Assign an alert
1101
- * await client.updateAlert("alert_123", {
1102
- * assigned_for: "analyst_user_id",
1103
- * status: "in_progress"
1104
- * });
1105
- *
1106
- * // Resolve an alert
1107
- * await client.updateAlert("alert_123", {
1108
- * status: "resolved",
1109
- * reason: "Customer verified via phone call"
1110
- * });
1111
- *
1112
- * // Escalate an alert
1113
- * await client.updateAlert("alert_123", {
1114
- * status: "escalated",
1115
- * assigned_for: "manager_user_id",
1116
- * reason: "Requires senior review - suspicious documents"
1117
- * });
1118
- * ```
1119
- */
1120
- async updateAlert(alertId, update) {
1121
- await this.request(`/api/v1/kyc/alerts/${alertId}`, {
1122
- method: "PUT",
1123
- body: JSON.stringify(update),
1124
- headers: this.getUserHeaders()
1125
- });
1126
- }
1127
1009
  // ============================================================================
1128
1010
  // KYC Preferences
1129
1011
  // ============================================================================
1130
- /**
1131
- * Get KYC preferences for the tenant
1132
- *
1133
- * @returns KYC preferences configuration
1134
- *
1135
- * @example
1136
- * ```typescript
1137
- * const prefs = await client.getPreferences();
1138
- * console.log(`Face verification required: ${prefs.is_face_verification_required}`);
1139
- * console.log(`Required documents: ${prefs.required_document_count}`);
1140
- * ```
1141
- */
1142
- async getPreferences() {
1143
- return this.request("/api/v1/kyc/preferences");
1144
- }
1145
1012
  /**
1146
1013
  * Update KYC preferences for the tenant
1147
1014
  *
1148
1015
  * @deprecated KYC preferences are managed in the Vesant console; the
1149
1016
  * platform exposes no update operation to the SDK, so this call always
1150
- * fails. Use `getPreferences()` to read them. This method will be removed
1151
- * in a future release.
1017
+ * fails. This method will be removed in a future release.
1152
1018
  *
1153
1019
  * @param update - Fields to update
1154
1020
  * @returns Updated preferences
@@ -1311,9 +1177,17 @@ var KYC_DECLINED_DESCRIPTIONS = {
1311
1177
  function isKycDocumentExpiredCallbackEvent(value) {
1312
1178
  return typeof value === "object" && value !== null && value.event === "kyc_document_expired";
1313
1179
  }
1180
+ function isKycStatusCallbackEvent(value) {
1181
+ return typeof value === "object" && value !== null && value.event === "kyc";
1182
+ }
1183
+ function isProfileChangeCallbackEvent(value) {
1184
+ return typeof value === "object" && value !== null && value.event === "profile_change";
1185
+ }
1314
1186
 
1315
1187
  exports.KYC_DECLINED_DESCRIPTIONS = KYC_DECLINED_DESCRIPTIONS;
1316
1188
  exports.KycClient = KycClient;
1317
1189
  exports.isKycDocumentExpiredCallbackEvent = isKycDocumentExpiredCallbackEvent;
1190
+ exports.isKycStatusCallbackEvent = isKycStatusCallbackEvent;
1191
+ exports.isProfileChangeCallbackEvent = isProfileChangeCallbackEvent;
1318
1192
  //# sourceMappingURL=index.js.map
1319
1193
  //# sourceMappingURL=index.js.map