vesant-sdk 1.4.5 → 1.5.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.
- package/README.md +5 -3
- package/dist/{client-BlAt791q.d.ts → client-B8pFrXx_.d.ts} +11 -5
- package/dist/{client-oo_3-0YW.d.mts → client-BZxzOidG.d.mts} +11 -5
- package/dist/{client-CY41e2Z_.d.mts → client-CIon-bGS.d.mts} +9 -5
- package/dist/{client-CY41e2Z_.d.ts → client-CIon-bGS.d.ts} +9 -5
- package/dist/compliance/index.d.mts +7 -7
- package/dist/compliance/index.d.ts +7 -7
- package/dist/compliance/index.js +46 -51
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +46 -51
- package/dist/compliance/index.mjs.map +1 -1
- package/dist/decisions/index.d.mts +2 -2
- package/dist/decisions/index.d.ts +2 -2
- package/dist/decisions/index.js +32 -33
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisions/index.mjs +32 -33
- package/dist/decisions/index.mjs.map +1 -1
- package/dist/geolocation/index.d.mts +4 -4
- package/dist/geolocation/index.d.ts +4 -4
- package/dist/geolocation/index.js +33 -34
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +33 -34
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index.d.mts +553 -21
- package/dist/index.d.ts +553 -21
- package/dist/index.js +320 -161
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +318 -159
- package/dist/index.mjs.map +1 -1
- package/dist/kyc/core.d.mts +3 -3
- package/dist/kyc/core.d.ts +3 -3
- package/dist/kyc/core.js +32 -33
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +32 -33
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.d.mts +11 -7
- package/dist/kyc/index.d.ts +11 -7
- package/dist/kyc/index.js +32 -33
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +32 -33
- package/dist/kyc/index.mjs.map +1 -1
- package/dist/react.d.mts +6 -6
- package/dist/react.d.ts +6 -6
- package/dist/react.js +5 -5
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +5 -5
- package/dist/react.mjs.map +1 -1
- package/dist/risk-profile/index.d.mts +4 -4
- package/dist/risk-profile/index.d.ts +4 -4
- package/dist/risk-profile/index.js +35 -36
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +35 -36
- package/dist/risk-profile/index.mjs.map +1 -1
- package/dist/scores/index.d.mts +2 -2
- package/dist/scores/index.d.ts +2 -2
- package/dist/scores/index.js +32 -33
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/index.mjs +32 -33
- package/dist/scores/index.mjs.map +1 -1
- package/dist/{types-jaLuzruy.d.mts → types-1RzYeSal.d.mts} +2 -2
- package/dist/{types-DZHongaK.d.mts → types-B4Ezqo7V.d.mts} +2 -2
- package/dist/{types-DZHongaK.d.ts → types-B4Ezqo7V.d.ts} +2 -2
- package/dist/{types-DLC7Sfy5.d.ts → types-X5Md_dD_.d.ts} +2 -2
- package/dist/webhooks/index.d.mts +1 -1
- package/dist/webhooks/index.d.ts +1 -1
- package/package.json +6 -1
package/dist/kyc/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { e as ProfileFilters, f as ProfileListResponse, C as CustomerProfile, d as CreateProfileRequest } from '../types-
|
|
3
|
-
import { B as BaseClient } from '../client-
|
|
1
|
+
import { R as RiskLevel, P as PaginationParams } from '../types-B4Ezqo7V.mjs';
|
|
2
|
+
import { e as ProfileFilters, f as ProfileListResponse, C as CustomerProfile, d as CreateProfileRequest } from '../types-1RzYeSal.mjs';
|
|
3
|
+
import { B as BaseClient } from '../client-CIon-bGS.mjs';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* TypeScript type definitions for
|
|
6
|
+
* TypeScript type definitions for Vesant KYC Service API
|
|
7
7
|
*
|
|
8
8
|
* These types match the Go API structures in:
|
|
9
9
|
* - services/kyc-service/internal/domain/
|
|
@@ -232,6 +232,8 @@ interface CreateReuseKycSessionRequest {
|
|
|
232
232
|
reference: string;
|
|
233
233
|
/** customer ID to associate with the KYC session */
|
|
234
234
|
customer_id: string;
|
|
235
|
+
/** where the re-use-kyc using 'login' | 'transactions' */
|
|
236
|
+
path?: string;
|
|
235
237
|
/** URL to redirect user after validate the facial submission (optional) */
|
|
236
238
|
redirect_url?: string;
|
|
237
239
|
/** URL to receive callback notifications via POST request when reuse KYC status changes (optional) */
|
|
@@ -256,6 +258,8 @@ interface CreateReuseKycSessionResponse {
|
|
|
256
258
|
token: string;
|
|
257
259
|
/** reuse KYC session reference */
|
|
258
260
|
reference: string;
|
|
261
|
+
/** re-use-kyc required for the action or not */
|
|
262
|
+
is_required: boolean;
|
|
259
263
|
}
|
|
260
264
|
interface CheckKycStatusRequest {
|
|
261
265
|
/** User ID to check KYC status for */
|
|
@@ -266,7 +270,7 @@ interface CheckKycStatusRequest {
|
|
|
266
270
|
interface CheckKycStatusResponse {
|
|
267
271
|
/** User ID */
|
|
268
272
|
user_id?: string;
|
|
269
|
-
/** Token generated from
|
|
273
|
+
/** Token generated from the server */
|
|
270
274
|
kyc_id: string;
|
|
271
275
|
/** Current KYC status */
|
|
272
276
|
status: string;
|
|
@@ -394,7 +398,7 @@ interface UseKycPreferencesResult extends BaseHookState {
|
|
|
394
398
|
}
|
|
395
399
|
|
|
396
400
|
/**
|
|
397
|
-
* KycClient - TypeScript SDK for
|
|
401
|
+
* KycClient - TypeScript SDK for Vesant KYC (Know Your Customer) Service
|
|
398
402
|
*
|
|
399
403
|
* Provides type-safe methods to interact with the KYC service API.
|
|
400
404
|
* Extends BaseClient for consistent retry logic, timeout handling, and error management.
|
|
@@ -403,7 +407,7 @@ interface UseKycPreferencesResult extends BaseHookState {
|
|
|
403
407
|
/**
|
|
404
408
|
* KycClient extends BaseClient for:
|
|
405
409
|
* - Consistent retry logic with exponential backoff
|
|
406
|
-
* - Unified error handling (
|
|
410
|
+
* - Unified error handling (VesantError, NetworkError, TimeoutError, etc.)
|
|
407
411
|
* - Automatic timeout management
|
|
408
412
|
* - Debug logging
|
|
409
413
|
*
|
package/dist/kyc/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { e as ProfileFilters, f as ProfileListResponse, C as CustomerProfile, d as CreateProfileRequest } from '../types-
|
|
3
|
-
import { B as BaseClient } from '../client-
|
|
1
|
+
import { R as RiskLevel, P as PaginationParams } from '../types-B4Ezqo7V.js';
|
|
2
|
+
import { e as ProfileFilters, f as ProfileListResponse, C as CustomerProfile, d as CreateProfileRequest } from '../types-X5Md_dD_.js';
|
|
3
|
+
import { B as BaseClient } from '../client-CIon-bGS.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* TypeScript type definitions for
|
|
6
|
+
* TypeScript type definitions for Vesant KYC Service API
|
|
7
7
|
*
|
|
8
8
|
* These types match the Go API structures in:
|
|
9
9
|
* - services/kyc-service/internal/domain/
|
|
@@ -232,6 +232,8 @@ interface CreateReuseKycSessionRequest {
|
|
|
232
232
|
reference: string;
|
|
233
233
|
/** customer ID to associate with the KYC session */
|
|
234
234
|
customer_id: string;
|
|
235
|
+
/** where the re-use-kyc using 'login' | 'transactions' */
|
|
236
|
+
path?: string;
|
|
235
237
|
/** URL to redirect user after validate the facial submission (optional) */
|
|
236
238
|
redirect_url?: string;
|
|
237
239
|
/** URL to receive callback notifications via POST request when reuse KYC status changes (optional) */
|
|
@@ -256,6 +258,8 @@ interface CreateReuseKycSessionResponse {
|
|
|
256
258
|
token: string;
|
|
257
259
|
/** reuse KYC session reference */
|
|
258
260
|
reference: string;
|
|
261
|
+
/** re-use-kyc required for the action or not */
|
|
262
|
+
is_required: boolean;
|
|
259
263
|
}
|
|
260
264
|
interface CheckKycStatusRequest {
|
|
261
265
|
/** User ID to check KYC status for */
|
|
@@ -266,7 +270,7 @@ interface CheckKycStatusRequest {
|
|
|
266
270
|
interface CheckKycStatusResponse {
|
|
267
271
|
/** User ID */
|
|
268
272
|
user_id?: string;
|
|
269
|
-
/** Token generated from
|
|
273
|
+
/** Token generated from the server */
|
|
270
274
|
kyc_id: string;
|
|
271
275
|
/** Current KYC status */
|
|
272
276
|
status: string;
|
|
@@ -394,7 +398,7 @@ interface UseKycPreferencesResult extends BaseHookState {
|
|
|
394
398
|
}
|
|
395
399
|
|
|
396
400
|
/**
|
|
397
|
-
* KycClient - TypeScript SDK for
|
|
401
|
+
* KycClient - TypeScript SDK for Vesant KYC (Know Your Customer) Service
|
|
398
402
|
*
|
|
399
403
|
* Provides type-safe methods to interact with the KYC service API.
|
|
400
404
|
* Extends BaseClient for consistent retry logic, timeout handling, and error management.
|
|
@@ -403,7 +407,7 @@ interface UseKycPreferencesResult extends BaseHookState {
|
|
|
403
407
|
/**
|
|
404
408
|
* KycClient extends BaseClient for:
|
|
405
409
|
* - Consistent retry logic with exponential backoff
|
|
406
|
-
* - Unified error handling (
|
|
410
|
+
* - Unified error handling (VesantError, NetworkError, TimeoutError, etc.)
|
|
407
411
|
* - Automatic timeout management
|
|
408
412
|
* - Debug logging
|
|
409
413
|
*
|
package/dist/kyc/index.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/core/errors.ts
|
|
4
|
-
var
|
|
4
|
+
var VesantError = class _VesantError extends Error {
|
|
5
5
|
constructor(message, code, statusCode, details) {
|
|
6
6
|
super(message);
|
|
7
7
|
this.code = code;
|
|
8
8
|
this.statusCode = statusCode;
|
|
9
9
|
this.details = details;
|
|
10
|
-
this.name = "
|
|
11
|
-
Object.setPrototypeOf(this,
|
|
10
|
+
this.name = "VesantError";
|
|
11
|
+
Object.setPrototypeOf(this, _VesantError.prototype);
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
var NetworkError = class _NetworkError extends
|
|
14
|
+
var NetworkError = class _NetworkError extends VesantError {
|
|
15
15
|
constructor(message, originalError) {
|
|
16
|
-
super(message, "NETWORK_ERROR"
|
|
16
|
+
super(message, "NETWORK_ERROR");
|
|
17
17
|
this.originalError = originalError;
|
|
18
18
|
this.name = "NetworkError";
|
|
19
19
|
Object.setPrototypeOf(this, _NetworkError.prototype);
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
|
-
var ValidationError = class _ValidationError extends
|
|
22
|
+
var ValidationError = class _ValidationError extends VesantError {
|
|
23
23
|
constructor(message, fields) {
|
|
24
24
|
super(message, "VALIDATION_ERROR", 400, { fields });
|
|
25
25
|
this.name = "ValidationError";
|
|
26
26
|
Object.setPrototypeOf(this, _ValidationError.prototype);
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
|
-
var ServiceUnavailableError = class _ServiceUnavailableError extends
|
|
30
|
-
constructor(message) {
|
|
31
|
-
super(
|
|
29
|
+
var ServiceUnavailableError = class _ServiceUnavailableError extends VesantError {
|
|
30
|
+
constructor(message = "Service unavailable") {
|
|
31
|
+
super(message, "SERVICE_UNAVAILABLE", 503);
|
|
32
32
|
this.name = "ServiceUnavailableError";
|
|
33
33
|
Object.setPrototypeOf(this, _ServiceUnavailableError.prototype);
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
var AuthenticationError = class _AuthenticationError extends
|
|
36
|
+
var AuthenticationError = class _AuthenticationError extends VesantError {
|
|
37
37
|
constructor(message = "Authentication failed") {
|
|
38
38
|
super(message, "AUTHENTICATION_ERROR", 401);
|
|
39
39
|
this.name = "AuthenticationError";
|
|
40
40
|
Object.setPrototypeOf(this, _AuthenticationError.prototype);
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
var RateLimitError = class _RateLimitError extends
|
|
43
|
+
var RateLimitError = class _RateLimitError extends VesantError {
|
|
44
44
|
constructor(retryAfter) {
|
|
45
45
|
super("Rate limit exceeded", "RATE_LIMIT_EXCEEDED", 429, { retryAfter });
|
|
46
46
|
this.retryAfter = retryAfter;
|
|
@@ -48,7 +48,7 @@ var RateLimitError = class _RateLimitError extends CGSError {
|
|
|
48
48
|
Object.setPrototypeOf(this, _RateLimitError.prototype);
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
var TimeoutError = class _TimeoutError extends
|
|
51
|
+
var TimeoutError = class _TimeoutError extends VesantError {
|
|
52
52
|
constructor(timeout) {
|
|
53
53
|
super(`Request timeout after ${timeout}ms`, "TIMEOUT", 408, { timeout });
|
|
54
54
|
this.timeout = timeout;
|
|
@@ -56,7 +56,7 @@ var TimeoutError = class _TimeoutError extends CGSError {
|
|
|
56
56
|
Object.setPrototypeOf(this, _TimeoutError.prototype);
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
-
var CircuitBreakerOpenError = class _CircuitBreakerOpenError extends
|
|
59
|
+
var CircuitBreakerOpenError = class _CircuitBreakerOpenError extends VesantError {
|
|
60
60
|
constructor() {
|
|
61
61
|
super("Circuit breaker is open \u2014 requests are temporarily blocked", "CIRCUIT_BREAKER_OPEN", 503);
|
|
62
62
|
this.name = "CircuitBreakerOpenError";
|
|
@@ -201,22 +201,22 @@ var RateLimitTracker = class {
|
|
|
201
201
|
function createConsoleLogger() {
|
|
202
202
|
return {
|
|
203
203
|
debug(message, meta) {
|
|
204
|
-
console.log(`[
|
|
204
|
+
console.log(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
205
205
|
},
|
|
206
206
|
info(message, meta) {
|
|
207
|
-
console.info(`[
|
|
207
|
+
console.info(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
208
208
|
},
|
|
209
209
|
warn(message, meta) {
|
|
210
|
-
console.warn(`[
|
|
210
|
+
console.warn(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
211
211
|
},
|
|
212
212
|
error(message, meta) {
|
|
213
|
-
console.error(`[
|
|
213
|
+
console.error(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
214
214
|
}
|
|
215
215
|
};
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
// src/core/version.ts
|
|
219
|
-
var SDK_VERSION = "1.
|
|
219
|
+
var SDK_VERSION = "1.5.2";
|
|
220
220
|
|
|
221
221
|
// src/shared/browser-utils.ts
|
|
222
222
|
function generateUUID() {
|
|
@@ -251,7 +251,7 @@ var BaseClient = class {
|
|
|
251
251
|
}
|
|
252
252
|
environment = "sandbox";
|
|
253
253
|
} else if (apiKey.startsWith("pk_live_") && environment === "sandbox") {
|
|
254
|
-
this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014
|
|
254
|
+
this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014 sandbox isolation will still be applied for backward compatibility');
|
|
255
255
|
}
|
|
256
256
|
this.config = {
|
|
257
257
|
...config,
|
|
@@ -323,10 +323,7 @@ var BaseClient = class {
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
if (this.config.debug) {
|
|
326
|
-
this.logger.debug(`${finalOptions.method || "GET"} ${
|
|
327
|
-
headers: finalOptions.headers,
|
|
328
|
-
body: finalOptions.body
|
|
329
|
-
});
|
|
326
|
+
this.logger.debug(`${finalOptions.method || "GET"} ${endpoint}`);
|
|
330
327
|
}
|
|
331
328
|
const response = await fetch(url, {
|
|
332
329
|
...finalOptions,
|
|
@@ -360,17 +357,17 @@ var BaseClient = class {
|
|
|
360
357
|
}
|
|
361
358
|
}
|
|
362
359
|
if (this.config.debug) {
|
|
363
|
-
this.logger.debug(
|
|
360
|
+
this.logger.debug(`Response: ${response.status}`);
|
|
364
361
|
}
|
|
365
362
|
return result;
|
|
366
363
|
} catch (error) {
|
|
367
364
|
clearTimeout(timeoutId);
|
|
368
|
-
if (error instanceof
|
|
365
|
+
if (error instanceof VesantError && error.statusCode && error.statusCode >= 500) {
|
|
369
366
|
this.circuitBreaker?.onFailure();
|
|
370
367
|
} else if (error instanceof NetworkError || error instanceof TimeoutError) {
|
|
371
368
|
this.circuitBreaker?.onFailure();
|
|
372
369
|
}
|
|
373
|
-
if (error instanceof
|
|
370
|
+
if (error instanceof VesantError && !error.requestId) {
|
|
374
371
|
error.requestId = requestId;
|
|
375
372
|
}
|
|
376
373
|
if (error instanceof Error) {
|
|
@@ -383,7 +380,7 @@ var BaseClient = class {
|
|
|
383
380
|
if (error instanceof Error) {
|
|
384
381
|
if (error.name === "AbortError") {
|
|
385
382
|
if (requestOptions?.signal?.aborted) {
|
|
386
|
-
const abortError = new
|
|
383
|
+
const abortError = new VesantError("Request aborted", "REQUEST_ABORTED");
|
|
387
384
|
abortError.requestId = requestId;
|
|
388
385
|
throw abortError;
|
|
389
386
|
}
|
|
@@ -392,7 +389,7 @@ var BaseClient = class {
|
|
|
392
389
|
timeoutError.requestId = requestId;
|
|
393
390
|
throw timeoutError;
|
|
394
391
|
}
|
|
395
|
-
if (error instanceof
|
|
392
|
+
if (error instanceof VesantError) {
|
|
396
393
|
throw error;
|
|
397
394
|
}
|
|
398
395
|
}
|
|
@@ -415,7 +412,7 @@ var BaseClient = class {
|
|
|
415
412
|
if (requestOptions?.signal?.aborted) {
|
|
416
413
|
throw lastError;
|
|
417
414
|
}
|
|
418
|
-
if (lastError instanceof
|
|
415
|
+
if (lastError instanceof VesantError && lastError.statusCode && lastError.statusCode >= 400 && lastError.statusCode < 500 && lastError.statusCode !== 429) {
|
|
419
416
|
throw lastError;
|
|
420
417
|
}
|
|
421
418
|
if (attempt === retries) {
|
|
@@ -443,13 +440,15 @@ var BaseClient = class {
|
|
|
443
440
|
const createError = () => {
|
|
444
441
|
switch (status) {
|
|
445
442
|
case 400:
|
|
446
|
-
return new
|
|
443
|
+
return new VesantError(message, "BAD_REQUEST", 400);
|
|
447
444
|
case 401:
|
|
448
445
|
return new AuthenticationError(message);
|
|
449
446
|
case 403:
|
|
450
|
-
return new
|
|
447
|
+
return new VesantError(message, "FORBIDDEN", 403);
|
|
451
448
|
case 404:
|
|
452
|
-
return new
|
|
449
|
+
return new VesantError(message, "NOT_FOUND", 404);
|
|
450
|
+
case 409:
|
|
451
|
+
return new VesantError(message, "DUPLICATE_PROFILE", 409);
|
|
453
452
|
case 429: {
|
|
454
453
|
const retryAfter = data.retry_after || data.retryAfter;
|
|
455
454
|
return new RateLimitError(retryAfter);
|
|
@@ -460,7 +459,7 @@ var BaseClient = class {
|
|
|
460
459
|
case 504:
|
|
461
460
|
return new ServiceUnavailableError(message);
|
|
462
461
|
default:
|
|
463
|
-
return new
|
|
462
|
+
return new VesantError(message, "UNKNOWN_ERROR", status);
|
|
464
463
|
}
|
|
465
464
|
};
|
|
466
465
|
const error = createError();
|