vesant-sdk 1.8.0-dev.d4d3b0d → 1.8.0-dev.d8b25c5

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 (50) hide show
  1. package/README.md +1 -3
  2. package/dist/compliance/index.js +7 -6
  3. package/dist/compliance/index.js.map +1 -1
  4. package/dist/compliance/index.mjs +7 -6
  5. package/dist/compliance/index.mjs.map +1 -1
  6. package/dist/decisions/index.js +7 -6
  7. package/dist/decisions/index.js.map +1 -1
  8. package/dist/decisions/index.mjs +7 -6
  9. package/dist/decisions/index.mjs.map +1 -1
  10. package/dist/geolocation/index.js +7 -6
  11. package/dist/geolocation/index.js.map +1 -1
  12. package/dist/geolocation/index.mjs +7 -6
  13. package/dist/geolocation/index.mjs.map +1 -1
  14. package/dist/index.d.mts +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.js +10 -182
  17. package/dist/index.js.map +1 -1
  18. package/dist/index.mjs +10 -182
  19. package/dist/index.mjs.map +1 -1
  20. package/dist/kyc/core.d.mts +1 -1
  21. package/dist/kyc/core.d.ts +1 -1
  22. package/dist/kyc/core.js +10 -182
  23. package/dist/kyc/core.js.map +1 -1
  24. package/dist/kyc/core.mjs +10 -182
  25. package/dist/kyc/core.mjs.map +1 -1
  26. package/dist/kyc/index.d.mts +4 -204
  27. package/dist/kyc/index.d.ts +4 -204
  28. package/dist/kyc/index.js +10 -182
  29. package/dist/kyc/index.js.map +1 -1
  30. package/dist/kyc/index.mjs +10 -182
  31. package/dist/kyc/index.mjs.map +1 -1
  32. package/dist/react.d.mts +4 -120
  33. package/dist/react.d.ts +4 -120
  34. package/dist/react.js +0 -185
  35. package/dist/react.js.map +1 -1
  36. package/dist/react.mjs +1 -183
  37. package/dist/react.mjs.map +1 -1
  38. package/dist/risk-profile/index.js +7 -6
  39. package/dist/risk-profile/index.js.map +1 -1
  40. package/dist/risk-profile/index.mjs +7 -6
  41. package/dist/risk-profile/index.mjs.map +1 -1
  42. package/dist/scores/index.js +7 -6
  43. package/dist/scores/index.js.map +1 -1
  44. package/dist/scores/index.mjs +7 -6
  45. package/dist/scores/index.mjs.map +1 -1
  46. package/dist/tax/index.js +7 -6
  47. package/dist/tax/index.js.map +1 -1
  48. package/dist/tax/index.mjs +7 -6
  49. package/dist/tax/index.mjs.map +1 -1
  50. package/package.json +1 -1
package/dist/kyc/index.js CHANGED
@@ -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();
@@ -913,74 +914,6 @@ var KycClient = class extends BaseClient {
913
914
  headers: this.getUserHeaders()
914
915
  });
915
916
  }
916
- /**
917
- * List KYC requests with filters and pagination
918
- *
919
- * @param filters - Optional filters (status, search, date range)
920
- * @param pagination - Optional pagination (page, page_size)
921
- * @returns Paginated list of KYC requests
922
- *
923
- * @example
924
- * ```typescript
925
- * const requests = await client.listKycRequests(
926
- * { status: "pending", search: "john" },
927
- * { page: 1, page_size: 20 }
928
- * );
929
- * console.log(`Found ${requests.total} pending requests`);
930
- * ```
931
- *
932
- * @remarks Console session only. This endpoint accepts a Vesant console
933
- * (dashboard login) token, not a tenant API key; called with an API key it
934
- * fails with `AuthenticationError` or a permission error.
935
- */
936
- async listKycRequests(filters, pagination) {
937
- const params = {};
938
- if (filters) {
939
- addFilterParam(params, "status", filters.status);
940
- addSimpleParams(params, filters, ["search", "fromDate", "toDate", "sortBy", "order"]);
941
- }
942
- if (pagination) {
943
- if (pagination.page) params.page = pagination.page;
944
- if (pagination.page_size) params.limit = pagination.page_size;
945
- }
946
- return this.request(
947
- `/api/v1/kyc/requests${this.buildQueryString(params)}`,
948
- { headers: this.getUserHeaders() }
949
- );
950
- }
951
- /**
952
- * Update KYC request status (accept/decline)
953
- *
954
- * @param request - Status update request with reference, status, and reason
955
- *
956
- * @example
957
- * ```typescript
958
- * // Accept a KYC request
959
- * await client.updateKycStatus({
960
- * reference: "kyc-ref-123",
961
- * status: "accepted",
962
- * reason: "All documents verified successfully"
963
- * });
964
- *
965
- * // Decline a KYC request
966
- * await client.updateKycStatus({
967
- * reference: "kyc-ref-456",
968
- * status: "declined",
969
- * reason: "Document expired"
970
- * });
971
- * ```
972
- *
973
- * @remarks Console session only. This endpoint accepts a Vesant console
974
- * (dashboard login) token, not a tenant API key; called with an API key it
975
- * fails with `AuthenticationError` or a permission error.
976
- */
977
- async updateKycStatus(request) {
978
- await this.request("/api/v1/kyc/status", {
979
- method: "PUT",
980
- body: JSON.stringify(request),
981
- headers: this.getUserHeaders()
982
- });
983
- }
984
917
  /**
985
918
  * Request additional documents from customer
986
919
  *
@@ -1029,53 +962,8 @@ var KycClient = class extends BaseClient {
1029
962
  return (kyc.proofs ?? []).filter((proof) => typeof proof.link === "string" && proof.link !== "").map((proof) => ({ id: proof.id, type: proof.type, url: proof.link }));
1030
963
  }
1031
964
  // ============================================================================
1032
- // KYC Overview & Statistics
1033
- // ============================================================================
1034
- /**
1035
- * Get KYC overview statistics
1036
- *
1037
- * @param fromDate - Optional start date (ISO 8601)
1038
- * @param toDate - Optional end date (ISO 8601)
1039
- * @returns KYC statistics including counts by status
1040
- *
1041
- * @example
1042
- * ```typescript
1043
- * const overview = await client.getOverview(
1044
- * "2024-01-01T00:00:00Z",
1045
- * "2024-12-31T23:59:59Z"
1046
- * );
1047
- * console.log(`Total: ${overview.total}, Pending: ${overview.pending}`);
1048
- * console.log(`Approved: ${overview.approved}, Rejected: ${overview.rejected}`);
1049
- * ```
1050
- *
1051
- * @remarks Console session only. This endpoint accepts a Vesant console
1052
- * (dashboard login) token, not a tenant API key; called with an API key it
1053
- * fails with `AuthenticationError` or a permission error.
1054
- */
1055
- async getOverview(fromDate, toDate) {
1056
- const params = {};
1057
- if (fromDate) params.fromDate = fromDate;
1058
- if (toDate) params.toDate = toDate;
1059
- return this.request(
1060
- `/api/v1/kyc/overview${this.buildQueryString(params)}`
1061
- );
1062
- }
1063
- // ============================================================================
1064
965
  // Alert Management
1065
966
  // ============================================================================
1066
- /**
1067
- * Get a KYC alert by ID
1068
- *
1069
- * @param alertId - Alert ID
1070
- * @returns Alert details
1071
- *
1072
- * @remarks Console session only. This endpoint accepts a Vesant console
1073
- * (dashboard login) token, not a tenant API key; called with an API key it
1074
- * fails with `AuthenticationError` or a permission error.
1075
- */
1076
- async getAlert(alertId) {
1077
- return this.request(`/api/v1/kyc/alerts/${alertId}`);
1078
- }
1079
967
  /**
1080
968
  * List KYC alerts with filters and pagination
1081
969
  *
@@ -1096,9 +984,8 @@ var KycClient = class extends BaseClient {
1096
984
  * console.log(`Found ${alerts.total} alerts`);
1097
985
  * ```
1098
986
  *
1099
- * @remarks Console session only. This endpoint accepts a Vesant console
1100
- * (dashboard login) token, not a tenant API key; called with an API key it
1101
- * fails with `AuthenticationError` or a permission error.
987
+ * @remarks Works with a tenant API key and returns the alerts raised for
988
+ * your tenant's customers.
1102
989
  */
1103
990
  async listAlerts(filters, pagination) {
1104
991
  const params = {};
@@ -1118,74 +1005,15 @@ var KycClient = class extends BaseClient {
1118
1005
  `/api/v1/kyc/alerts${this.buildQueryString(params)}`
1119
1006
  );
1120
1007
  }
1121
- /**
1122
- * Update a KYC alert
1123
- *
1124
- * @param alertId - Alert ID
1125
- * @param update - Fields to update (status, assigned_for, reason, alert_type)
1126
- *
1127
- * @example
1128
- * ```typescript
1129
- * // Assign an alert
1130
- * await client.updateAlert("alert_123", {
1131
- * assigned_for: "analyst_user_id",
1132
- * status: "in_progress"
1133
- * });
1134
- *
1135
- * // Resolve an alert
1136
- * await client.updateAlert("alert_123", {
1137
- * status: "resolved",
1138
- * reason: "Customer verified via phone call"
1139
- * });
1140
- *
1141
- * // Escalate an alert
1142
- * await client.updateAlert("alert_123", {
1143
- * status: "escalated",
1144
- * assigned_for: "manager_user_id",
1145
- * reason: "Requires senior review - suspicious documents"
1146
- * });
1147
- * ```
1148
- *
1149
- * @remarks Console session only. This endpoint accepts a Vesant console
1150
- * (dashboard login) token, not a tenant API key; called with an API key it
1151
- * fails with `AuthenticationError` or a permission error.
1152
- */
1153
- async updateAlert(alertId, update) {
1154
- await this.request(`/api/v1/kyc/alerts/${alertId}`, {
1155
- method: "PUT",
1156
- body: JSON.stringify(update),
1157
- headers: this.getUserHeaders()
1158
- });
1159
- }
1160
1008
  // ============================================================================
1161
1009
  // KYC Preferences
1162
1010
  // ============================================================================
1163
- /**
1164
- * Get KYC preferences for the tenant
1165
- *
1166
- * @returns KYC preferences configuration
1167
- *
1168
- * @example
1169
- * ```typescript
1170
- * const prefs = await client.getPreferences();
1171
- * console.log(`Face verification required: ${prefs.is_face_verification_required}`);
1172
- * console.log(`Required documents: ${prefs.required_document_count}`);
1173
- * ```
1174
- *
1175
- * @remarks Console session only. This endpoint accepts a Vesant console
1176
- * (dashboard login) token, not a tenant API key; called with an API key it
1177
- * fails with `AuthenticationError` or a permission error.
1178
- */
1179
- async getPreferences() {
1180
- return this.request("/api/v1/kyc/preferences");
1181
- }
1182
1011
  /**
1183
1012
  * Update KYC preferences for the tenant
1184
1013
  *
1185
1014
  * @deprecated KYC preferences are managed in the Vesant console; the
1186
1015
  * platform exposes no update operation to the SDK, so this call always
1187
- * fails. Use `getPreferences()` to read them. This method will be removed
1188
- * in a future release.
1016
+ * fails. This method will be removed in a future release.
1189
1017
  *
1190
1018
  * @param update - Fields to update
1191
1019
  * @returns Updated preferences