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