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
|
@@ -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() {
|
|
@@ -233,7 +233,7 @@ function generateDeviceId() {
|
|
|
233
233
|
if (typeof window === "undefined" || typeof localStorage === "undefined") {
|
|
234
234
|
return generateUUID();
|
|
235
235
|
}
|
|
236
|
-
const storageKey = "
|
|
236
|
+
const storageKey = "vesant_device_id";
|
|
237
237
|
let deviceId = localStorage.getItem(storageKey);
|
|
238
238
|
if (!deviceId) {
|
|
239
239
|
deviceId = generateUUID();
|
|
@@ -308,7 +308,7 @@ var BaseClient = class {
|
|
|
308
308
|
}
|
|
309
309
|
environment = "sandbox";
|
|
310
310
|
} else if (apiKey.startsWith("pk_live_") && environment === "sandbox") {
|
|
311
|
-
this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014
|
|
311
|
+
this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014 sandbox isolation will still be applied for backward compatibility');
|
|
312
312
|
}
|
|
313
313
|
this.config = {
|
|
314
314
|
...config,
|
|
@@ -380,10 +380,7 @@ var BaseClient = class {
|
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
382
|
if (this.config.debug) {
|
|
383
|
-
this.logger.debug(`${finalOptions.method || "GET"} ${
|
|
384
|
-
headers: finalOptions.headers,
|
|
385
|
-
body: finalOptions.body
|
|
386
|
-
});
|
|
383
|
+
this.logger.debug(`${finalOptions.method || "GET"} ${endpoint}`);
|
|
387
384
|
}
|
|
388
385
|
const response = await fetch(url, {
|
|
389
386
|
...finalOptions,
|
|
@@ -417,17 +414,17 @@ var BaseClient = class {
|
|
|
417
414
|
}
|
|
418
415
|
}
|
|
419
416
|
if (this.config.debug) {
|
|
420
|
-
this.logger.debug(
|
|
417
|
+
this.logger.debug(`Response: ${response.status}`);
|
|
421
418
|
}
|
|
422
419
|
return result;
|
|
423
420
|
} catch (error) {
|
|
424
421
|
clearTimeout(timeoutId);
|
|
425
|
-
if (error instanceof
|
|
422
|
+
if (error instanceof VesantError && error.statusCode && error.statusCode >= 500) {
|
|
426
423
|
this.circuitBreaker?.onFailure();
|
|
427
424
|
} else if (error instanceof NetworkError || error instanceof TimeoutError) {
|
|
428
425
|
this.circuitBreaker?.onFailure();
|
|
429
426
|
}
|
|
430
|
-
if (error instanceof
|
|
427
|
+
if (error instanceof VesantError && !error.requestId) {
|
|
431
428
|
error.requestId = requestId;
|
|
432
429
|
}
|
|
433
430
|
if (error instanceof Error) {
|
|
@@ -440,7 +437,7 @@ var BaseClient = class {
|
|
|
440
437
|
if (error instanceof Error) {
|
|
441
438
|
if (error.name === "AbortError") {
|
|
442
439
|
if (requestOptions?.signal?.aborted) {
|
|
443
|
-
const abortError = new
|
|
440
|
+
const abortError = new VesantError("Request aborted", "REQUEST_ABORTED");
|
|
444
441
|
abortError.requestId = requestId;
|
|
445
442
|
throw abortError;
|
|
446
443
|
}
|
|
@@ -449,7 +446,7 @@ var BaseClient = class {
|
|
|
449
446
|
timeoutError.requestId = requestId;
|
|
450
447
|
throw timeoutError;
|
|
451
448
|
}
|
|
452
|
-
if (error instanceof
|
|
449
|
+
if (error instanceof VesantError) {
|
|
453
450
|
throw error;
|
|
454
451
|
}
|
|
455
452
|
}
|
|
@@ -472,7 +469,7 @@ var BaseClient = class {
|
|
|
472
469
|
if (requestOptions?.signal?.aborted) {
|
|
473
470
|
throw lastError;
|
|
474
471
|
}
|
|
475
|
-
if (lastError instanceof
|
|
472
|
+
if (lastError instanceof VesantError && lastError.statusCode && lastError.statusCode >= 400 && lastError.statusCode < 500 && lastError.statusCode !== 429) {
|
|
476
473
|
throw lastError;
|
|
477
474
|
}
|
|
478
475
|
if (attempt === retries) {
|
|
@@ -500,13 +497,15 @@ var BaseClient = class {
|
|
|
500
497
|
const createError = () => {
|
|
501
498
|
switch (status) {
|
|
502
499
|
case 400:
|
|
503
|
-
return new
|
|
500
|
+
return new VesantError(message, "BAD_REQUEST", 400);
|
|
504
501
|
case 401:
|
|
505
502
|
return new AuthenticationError(message);
|
|
506
503
|
case 403:
|
|
507
|
-
return new
|
|
504
|
+
return new VesantError(message, "FORBIDDEN", 403);
|
|
508
505
|
case 404:
|
|
509
|
-
return new
|
|
506
|
+
return new VesantError(message, "NOT_FOUND", 404);
|
|
507
|
+
case 409:
|
|
508
|
+
return new VesantError(message, "DUPLICATE_PROFILE", 409);
|
|
510
509
|
case 429: {
|
|
511
510
|
const retryAfter = data.retry_after || data.retryAfter;
|
|
512
511
|
return new RateLimitError(retryAfter);
|
|
@@ -517,7 +516,7 @@ var BaseClient = class {
|
|
|
517
516
|
case 504:
|
|
518
517
|
return new ServiceUnavailableError(message);
|
|
519
518
|
default:
|
|
520
|
-
return new
|
|
519
|
+
return new VesantError(message, "UNKNOWN_ERROR", status);
|
|
521
520
|
}
|
|
522
521
|
};
|
|
523
522
|
const error = createError();
|