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,44 +1,44 @@
|
|
|
1
1
|
// src/core/errors.ts
|
|
2
|
-
var
|
|
2
|
+
var VesantError = class _VesantError extends Error {
|
|
3
3
|
constructor(message, code, statusCode, details) {
|
|
4
4
|
super(message);
|
|
5
5
|
this.code = code;
|
|
6
6
|
this.statusCode = statusCode;
|
|
7
7
|
this.details = details;
|
|
8
|
-
this.name = "
|
|
9
|
-
Object.setPrototypeOf(this,
|
|
8
|
+
this.name = "VesantError";
|
|
9
|
+
Object.setPrototypeOf(this, _VesantError.prototype);
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
-
var NetworkError = class _NetworkError extends
|
|
12
|
+
var NetworkError = class _NetworkError extends VesantError {
|
|
13
13
|
constructor(message, originalError) {
|
|
14
|
-
super(message, "NETWORK_ERROR"
|
|
14
|
+
super(message, "NETWORK_ERROR");
|
|
15
15
|
this.originalError = originalError;
|
|
16
16
|
this.name = "NetworkError";
|
|
17
17
|
Object.setPrototypeOf(this, _NetworkError.prototype);
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
|
-
var ValidationError = class _ValidationError extends
|
|
20
|
+
var ValidationError = class _ValidationError extends VesantError {
|
|
21
21
|
constructor(message, fields) {
|
|
22
22
|
super(message, "VALIDATION_ERROR", 400, { fields });
|
|
23
23
|
this.name = "ValidationError";
|
|
24
24
|
Object.setPrototypeOf(this, _ValidationError.prototype);
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
-
var ServiceUnavailableError = class _ServiceUnavailableError extends
|
|
28
|
-
constructor(message) {
|
|
29
|
-
super(
|
|
27
|
+
var ServiceUnavailableError = class _ServiceUnavailableError extends VesantError {
|
|
28
|
+
constructor(message = "Service unavailable") {
|
|
29
|
+
super(message, "SERVICE_UNAVAILABLE", 503);
|
|
30
30
|
this.name = "ServiceUnavailableError";
|
|
31
31
|
Object.setPrototypeOf(this, _ServiceUnavailableError.prototype);
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
|
-
var AuthenticationError = class _AuthenticationError extends
|
|
34
|
+
var AuthenticationError = class _AuthenticationError extends VesantError {
|
|
35
35
|
constructor(message = "Authentication failed") {
|
|
36
36
|
super(message, "AUTHENTICATION_ERROR", 401);
|
|
37
37
|
this.name = "AuthenticationError";
|
|
38
38
|
Object.setPrototypeOf(this, _AuthenticationError.prototype);
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
var RateLimitError = class _RateLimitError extends
|
|
41
|
+
var RateLimitError = class _RateLimitError extends VesantError {
|
|
42
42
|
constructor(retryAfter) {
|
|
43
43
|
super("Rate limit exceeded", "RATE_LIMIT_EXCEEDED", 429, { retryAfter });
|
|
44
44
|
this.retryAfter = retryAfter;
|
|
@@ -46,7 +46,7 @@ var RateLimitError = class _RateLimitError extends CGSError {
|
|
|
46
46
|
Object.setPrototypeOf(this, _RateLimitError.prototype);
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
var TimeoutError = class _TimeoutError extends
|
|
49
|
+
var TimeoutError = class _TimeoutError extends VesantError {
|
|
50
50
|
constructor(timeout) {
|
|
51
51
|
super(`Request timeout after ${timeout}ms`, "TIMEOUT", 408, { timeout });
|
|
52
52
|
this.timeout = timeout;
|
|
@@ -54,7 +54,7 @@ var TimeoutError = class _TimeoutError extends CGSError {
|
|
|
54
54
|
Object.setPrototypeOf(this, _TimeoutError.prototype);
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
-
var CircuitBreakerOpenError = class _CircuitBreakerOpenError extends
|
|
57
|
+
var CircuitBreakerOpenError = class _CircuitBreakerOpenError extends VesantError {
|
|
58
58
|
constructor() {
|
|
59
59
|
super("Circuit breaker is open \u2014 requests are temporarily blocked", "CIRCUIT_BREAKER_OPEN", 503);
|
|
60
60
|
this.name = "CircuitBreakerOpenError";
|
|
@@ -199,22 +199,22 @@ var RateLimitTracker = class {
|
|
|
199
199
|
function createConsoleLogger() {
|
|
200
200
|
return {
|
|
201
201
|
debug(message, meta) {
|
|
202
|
-
console.log(`[
|
|
202
|
+
console.log(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
203
203
|
},
|
|
204
204
|
info(message, meta) {
|
|
205
|
-
console.info(`[
|
|
205
|
+
console.info(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
206
206
|
},
|
|
207
207
|
warn(message, meta) {
|
|
208
|
-
console.warn(`[
|
|
208
|
+
console.warn(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
209
209
|
},
|
|
210
210
|
error(message, meta) {
|
|
211
|
-
console.error(`[
|
|
211
|
+
console.error(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
212
212
|
}
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
// src/core/version.ts
|
|
217
|
-
var SDK_VERSION = "1.
|
|
217
|
+
var SDK_VERSION = "1.5.2";
|
|
218
218
|
|
|
219
219
|
// src/shared/browser-utils.ts
|
|
220
220
|
function generateUUID() {
|
|
@@ -231,7 +231,7 @@ function generateDeviceId() {
|
|
|
231
231
|
if (typeof window === "undefined" || typeof localStorage === "undefined") {
|
|
232
232
|
return generateUUID();
|
|
233
233
|
}
|
|
234
|
-
const storageKey = "
|
|
234
|
+
const storageKey = "vesant_device_id";
|
|
235
235
|
let deviceId = localStorage.getItem(storageKey);
|
|
236
236
|
if (!deviceId) {
|
|
237
237
|
deviceId = generateUUID();
|
|
@@ -306,7 +306,7 @@ var BaseClient = class {
|
|
|
306
306
|
}
|
|
307
307
|
environment = "sandbox";
|
|
308
308
|
} else if (apiKey.startsWith("pk_live_") && environment === "sandbox") {
|
|
309
|
-
this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014
|
|
309
|
+
this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014 sandbox isolation will still be applied for backward compatibility');
|
|
310
310
|
}
|
|
311
311
|
this.config = {
|
|
312
312
|
...config,
|
|
@@ -378,10 +378,7 @@ var BaseClient = class {
|
|
|
378
378
|
}
|
|
379
379
|
}
|
|
380
380
|
if (this.config.debug) {
|
|
381
|
-
this.logger.debug(`${finalOptions.method || "GET"} ${
|
|
382
|
-
headers: finalOptions.headers,
|
|
383
|
-
body: finalOptions.body
|
|
384
|
-
});
|
|
381
|
+
this.logger.debug(`${finalOptions.method || "GET"} ${endpoint}`);
|
|
385
382
|
}
|
|
386
383
|
const response = await fetch(url, {
|
|
387
384
|
...finalOptions,
|
|
@@ -415,17 +412,17 @@ var BaseClient = class {
|
|
|
415
412
|
}
|
|
416
413
|
}
|
|
417
414
|
if (this.config.debug) {
|
|
418
|
-
this.logger.debug(
|
|
415
|
+
this.logger.debug(`Response: ${response.status}`);
|
|
419
416
|
}
|
|
420
417
|
return result;
|
|
421
418
|
} catch (error) {
|
|
422
419
|
clearTimeout(timeoutId);
|
|
423
|
-
if (error instanceof
|
|
420
|
+
if (error instanceof VesantError && error.statusCode && error.statusCode >= 500) {
|
|
424
421
|
this.circuitBreaker?.onFailure();
|
|
425
422
|
} else if (error instanceof NetworkError || error instanceof TimeoutError) {
|
|
426
423
|
this.circuitBreaker?.onFailure();
|
|
427
424
|
}
|
|
428
|
-
if (error instanceof
|
|
425
|
+
if (error instanceof VesantError && !error.requestId) {
|
|
429
426
|
error.requestId = requestId;
|
|
430
427
|
}
|
|
431
428
|
if (error instanceof Error) {
|
|
@@ -438,7 +435,7 @@ var BaseClient = class {
|
|
|
438
435
|
if (error instanceof Error) {
|
|
439
436
|
if (error.name === "AbortError") {
|
|
440
437
|
if (requestOptions?.signal?.aborted) {
|
|
441
|
-
const abortError = new
|
|
438
|
+
const abortError = new VesantError("Request aborted", "REQUEST_ABORTED");
|
|
442
439
|
abortError.requestId = requestId;
|
|
443
440
|
throw abortError;
|
|
444
441
|
}
|
|
@@ -447,7 +444,7 @@ var BaseClient = class {
|
|
|
447
444
|
timeoutError.requestId = requestId;
|
|
448
445
|
throw timeoutError;
|
|
449
446
|
}
|
|
450
|
-
if (error instanceof
|
|
447
|
+
if (error instanceof VesantError) {
|
|
451
448
|
throw error;
|
|
452
449
|
}
|
|
453
450
|
}
|
|
@@ -470,7 +467,7 @@ var BaseClient = class {
|
|
|
470
467
|
if (requestOptions?.signal?.aborted) {
|
|
471
468
|
throw lastError;
|
|
472
469
|
}
|
|
473
|
-
if (lastError instanceof
|
|
470
|
+
if (lastError instanceof VesantError && lastError.statusCode && lastError.statusCode >= 400 && lastError.statusCode < 500 && lastError.statusCode !== 429) {
|
|
474
471
|
throw lastError;
|
|
475
472
|
}
|
|
476
473
|
if (attempt === retries) {
|
|
@@ -498,13 +495,15 @@ var BaseClient = class {
|
|
|
498
495
|
const createError = () => {
|
|
499
496
|
switch (status) {
|
|
500
497
|
case 400:
|
|
501
|
-
return new
|
|
498
|
+
return new VesantError(message, "BAD_REQUEST", 400);
|
|
502
499
|
case 401:
|
|
503
500
|
return new AuthenticationError(message);
|
|
504
501
|
case 403:
|
|
505
|
-
return new
|
|
502
|
+
return new VesantError(message, "FORBIDDEN", 403);
|
|
506
503
|
case 404:
|
|
507
|
-
return new
|
|
504
|
+
return new VesantError(message, "NOT_FOUND", 404);
|
|
505
|
+
case 409:
|
|
506
|
+
return new VesantError(message, "DUPLICATE_PROFILE", 409);
|
|
508
507
|
case 429: {
|
|
509
508
|
const retryAfter = data.retry_after || data.retryAfter;
|
|
510
509
|
return new RateLimitError(retryAfter);
|
|
@@ -515,7 +514,7 @@ var BaseClient = class {
|
|
|
515
514
|
case 504:
|
|
516
515
|
return new ServiceUnavailableError(message);
|
|
517
516
|
default:
|
|
518
|
-
return new
|
|
517
|
+
return new VesantError(message, "UNKNOWN_ERROR", status);
|
|
519
518
|
}
|
|
520
519
|
};
|
|
521
520
|
const error = createError();
|