vesant-sdk 1.4.5 → 1.5.0
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/dist/{client-BlAt791q.d.ts → client-3cBb_Pp-.d.ts} +4 -4
- package/dist/{client-CY41e2Z_.d.mts → client-BQRONu8q.d.mts} +9 -5
- package/dist/{client-CY41e2Z_.d.ts → client-BQRONu8q.d.ts} +9 -5
- package/dist/{client-oo_3-0YW.d.mts → client-DKqyESgT.d.mts} +4 -4
- package/dist/compliance/index.d.mts +7 -7
- package/dist/compliance/index.d.ts +7 -7
- package/dist/compliance/index.js +44 -51
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +44 -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 +30 -33
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisions/index.mjs +30 -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 +31 -34
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +31 -34
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index.d.mts +23 -19
- package/dist/index.d.ts +23 -19
- package/dist/index.js +47 -52
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -53
- 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 +30 -33
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +30 -33
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.d.mts +7 -7
- package/dist/kyc/index.d.ts +7 -7
- package/dist/kyc/index.js +30 -33
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +30 -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 +33 -36
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +33 -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 +30 -33
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/index.mjs +30 -33
- package/dist/scores/index.mjs.map +1 -1
- package/dist/{types-DZHongaK.d.mts → types-B1OzEQR3.d.mts} +1 -1
- package/dist/{types-DZHongaK.d.ts → types-B1OzEQR3.d.ts} +1 -1
- package/dist/{types-DLC7Sfy5.d.ts → types-BnL66DB3.d.ts} +2 -2
- package/dist/{types-jaLuzruy.d.mts → types-_hsTA3Ez.d.mts} +2 -2
- package/dist/webhooks/index.d.mts +1 -1
- package/dist/webhooks/index.d.ts +1 -1
- package/package.json +1 -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,15 +54,15 @@ var TimeoutError = class _TimeoutError extends CGSError {
|
|
|
54
54
|
Object.setPrototypeOf(this, _TimeoutError.prototype);
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
-
var ComplianceError = class _ComplianceError extends
|
|
57
|
+
var ComplianceError = class _ComplianceError extends VesantError {
|
|
58
58
|
constructor(message, originalError, code = "COMPLIANCE_ERROR") {
|
|
59
|
-
super(message, code
|
|
59
|
+
super(message, code);
|
|
60
60
|
this.originalError = originalError;
|
|
61
61
|
this.name = "ComplianceError";
|
|
62
62
|
Object.setPrototypeOf(this, _ComplianceError.prototype);
|
|
63
63
|
}
|
|
64
64
|
};
|
|
65
|
-
var CircuitBreakerOpenError = class _CircuitBreakerOpenError extends
|
|
65
|
+
var CircuitBreakerOpenError = class _CircuitBreakerOpenError extends VesantError {
|
|
66
66
|
constructor() {
|
|
67
67
|
super("Circuit breaker is open \u2014 requests are temporarily blocked", "CIRCUIT_BREAKER_OPEN", 503);
|
|
68
68
|
this.name = "CircuitBreakerOpenError";
|
|
@@ -207,22 +207,22 @@ var RateLimitTracker = class {
|
|
|
207
207
|
function createConsoleLogger() {
|
|
208
208
|
return {
|
|
209
209
|
debug(message, meta) {
|
|
210
|
-
console.log(`[
|
|
210
|
+
console.log(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
211
211
|
},
|
|
212
212
|
info(message, meta) {
|
|
213
|
-
console.info(`[
|
|
213
|
+
console.info(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
214
214
|
},
|
|
215
215
|
warn(message, meta) {
|
|
216
|
-
console.warn(`[
|
|
216
|
+
console.warn(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
217
217
|
},
|
|
218
218
|
error(message, meta) {
|
|
219
|
-
console.error(`[
|
|
219
|
+
console.error(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
// src/core/version.ts
|
|
225
|
-
var SDK_VERSION = "1.
|
|
225
|
+
var SDK_VERSION = "1.5.0";
|
|
226
226
|
|
|
227
227
|
// src/shared/browser-utils.ts
|
|
228
228
|
function generateUUID() {
|
|
@@ -239,7 +239,7 @@ function generateDeviceId() {
|
|
|
239
239
|
if (typeof window === "undefined" || typeof localStorage === "undefined") {
|
|
240
240
|
return generateUUID();
|
|
241
241
|
}
|
|
242
|
-
const storageKey = "
|
|
242
|
+
const storageKey = "vesant_device_id";
|
|
243
243
|
let deviceId = localStorage.getItem(storageKey);
|
|
244
244
|
if (!deviceId) {
|
|
245
245
|
deviceId = generateUUID();
|
|
@@ -314,7 +314,7 @@ var BaseClient = class {
|
|
|
314
314
|
}
|
|
315
315
|
environment = "sandbox";
|
|
316
316
|
} else if (apiKey.startsWith("pk_live_") && environment === "sandbox") {
|
|
317
|
-
this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014
|
|
317
|
+
this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014 sandbox isolation will still be applied for backward compatibility');
|
|
318
318
|
}
|
|
319
319
|
this.config = {
|
|
320
320
|
...config,
|
|
@@ -386,10 +386,7 @@ var BaseClient = class {
|
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
if (this.config.debug) {
|
|
389
|
-
this.logger.debug(`${finalOptions.method || "GET"} ${
|
|
390
|
-
headers: finalOptions.headers,
|
|
391
|
-
body: finalOptions.body
|
|
392
|
-
});
|
|
389
|
+
this.logger.debug(`${finalOptions.method || "GET"} ${endpoint}`);
|
|
393
390
|
}
|
|
394
391
|
const response = await fetch(url, {
|
|
395
392
|
...finalOptions,
|
|
@@ -423,17 +420,17 @@ var BaseClient = class {
|
|
|
423
420
|
}
|
|
424
421
|
}
|
|
425
422
|
if (this.config.debug) {
|
|
426
|
-
this.logger.debug(
|
|
423
|
+
this.logger.debug(`Response: ${response.status}`);
|
|
427
424
|
}
|
|
428
425
|
return result;
|
|
429
426
|
} catch (error) {
|
|
430
427
|
clearTimeout(timeoutId);
|
|
431
|
-
if (error instanceof
|
|
428
|
+
if (error instanceof VesantError && error.statusCode && error.statusCode >= 500) {
|
|
432
429
|
this.circuitBreaker?.onFailure();
|
|
433
430
|
} else if (error instanceof NetworkError || error instanceof TimeoutError) {
|
|
434
431
|
this.circuitBreaker?.onFailure();
|
|
435
432
|
}
|
|
436
|
-
if (error instanceof
|
|
433
|
+
if (error instanceof VesantError && !error.requestId) {
|
|
437
434
|
error.requestId = requestId;
|
|
438
435
|
}
|
|
439
436
|
if (error instanceof Error) {
|
|
@@ -446,7 +443,7 @@ var BaseClient = class {
|
|
|
446
443
|
if (error instanceof Error) {
|
|
447
444
|
if (error.name === "AbortError") {
|
|
448
445
|
if (requestOptions?.signal?.aborted) {
|
|
449
|
-
const abortError = new
|
|
446
|
+
const abortError = new VesantError("Request aborted", "REQUEST_ABORTED");
|
|
450
447
|
abortError.requestId = requestId;
|
|
451
448
|
throw abortError;
|
|
452
449
|
}
|
|
@@ -455,7 +452,7 @@ var BaseClient = class {
|
|
|
455
452
|
timeoutError.requestId = requestId;
|
|
456
453
|
throw timeoutError;
|
|
457
454
|
}
|
|
458
|
-
if (error instanceof
|
|
455
|
+
if (error instanceof VesantError) {
|
|
459
456
|
throw error;
|
|
460
457
|
}
|
|
461
458
|
}
|
|
@@ -478,7 +475,7 @@ var BaseClient = class {
|
|
|
478
475
|
if (requestOptions?.signal?.aborted) {
|
|
479
476
|
throw lastError;
|
|
480
477
|
}
|
|
481
|
-
if (lastError instanceof
|
|
478
|
+
if (lastError instanceof VesantError && lastError.statusCode && lastError.statusCode >= 400 && lastError.statusCode < 500 && lastError.statusCode !== 429) {
|
|
482
479
|
throw lastError;
|
|
483
480
|
}
|
|
484
481
|
if (attempt === retries) {
|
|
@@ -506,13 +503,13 @@ var BaseClient = class {
|
|
|
506
503
|
const createError = () => {
|
|
507
504
|
switch (status) {
|
|
508
505
|
case 400:
|
|
509
|
-
return new
|
|
506
|
+
return new VesantError(message, "BAD_REQUEST", 400);
|
|
510
507
|
case 401:
|
|
511
508
|
return new AuthenticationError(message);
|
|
512
509
|
case 403:
|
|
513
|
-
return new
|
|
510
|
+
return new VesantError(message, "FORBIDDEN", 403);
|
|
514
511
|
case 404:
|
|
515
|
-
return new
|
|
512
|
+
return new VesantError(message, "NOT_FOUND", 404);
|
|
516
513
|
case 429: {
|
|
517
514
|
const retryAfter = data.retry_after || data.retryAfter;
|
|
518
515
|
return new RateLimitError(retryAfter);
|
|
@@ -523,7 +520,7 @@ var BaseClient = class {
|
|
|
523
520
|
case 504:
|
|
524
521
|
return new ServiceUnavailableError(message);
|
|
525
522
|
default:
|
|
526
|
-
return new
|
|
523
|
+
return new VesantError(message, "UNKNOWN_ERROR", status);
|
|
527
524
|
}
|
|
528
525
|
};
|
|
529
526
|
const error = createError();
|
|
@@ -1267,8 +1264,8 @@ var RiskProfileClient = class extends BaseClient {
|
|
|
1267
1264
|
requestOptions
|
|
1268
1265
|
);
|
|
1269
1266
|
} catch (error) {
|
|
1270
|
-
if (error instanceof
|
|
1271
|
-
throw new
|
|
1267
|
+
if (error instanceof VesantError && (error.statusCode === 404 || error.code === "NOT_FOUND")) {
|
|
1268
|
+
throw new VesantError("Profile not found", "NOT_FOUND", 404);
|
|
1272
1269
|
}
|
|
1273
1270
|
throw error;
|
|
1274
1271
|
}
|
|
@@ -1318,7 +1315,7 @@ var RiskProfileClient = class extends BaseClient {
|
|
|
1318
1315
|
try {
|
|
1319
1316
|
return await this.getProfile(customerId, requestOptions);
|
|
1320
1317
|
} catch (error) {
|
|
1321
|
-
if (error instanceof
|
|
1318
|
+
if (error instanceof VesantError && error.code === "NOT_FOUND") {
|
|
1322
1319
|
return await this.createProfile(createRequest, requestOptions);
|
|
1323
1320
|
}
|
|
1324
1321
|
throw error;
|
|
@@ -1485,8 +1482,6 @@ var ComplianceClient = class {
|
|
|
1485
1482
|
if (this.config.debug) {
|
|
1486
1483
|
this.logger.debug("Registration verification complete", {
|
|
1487
1484
|
allowed: true,
|
|
1488
|
-
riskScore: geoVerification.risk_score,
|
|
1489
|
-
profileId: profile.id,
|
|
1490
1485
|
requiresKYC,
|
|
1491
1486
|
requiresEDD
|
|
1492
1487
|
});
|
|
@@ -1502,16 +1497,14 @@ var ComplianceClient = class {
|
|
|
1502
1497
|
};
|
|
1503
1498
|
} catch (error) {
|
|
1504
1499
|
if (this.config.debug) {
|
|
1505
|
-
this.logger.error("Registration verification failed", {
|
|
1500
|
+
this.logger.error("Registration verification failed", {
|
|
1501
|
+
code: error instanceof Error ? error.code : void 0,
|
|
1502
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
1503
|
+
});
|
|
1506
1504
|
}
|
|
1507
1505
|
throw new ComplianceError(
|
|
1508
1506
|
"Registration verification failed",
|
|
1509
|
-
|
|
1510
|
-
stage: geoVerification ? "profile_creation" : "geo_verification",
|
|
1511
|
-
geoRecordId: geoVerification?.record_id,
|
|
1512
|
-
customerId: request.customerId,
|
|
1513
|
-
cause: error
|
|
1514
|
-
},
|
|
1507
|
+
error instanceof Error ? error.message : void 0,
|
|
1515
1508
|
geoVerification ? "PROFILE_CREATION_FAILED" : "GEO_VERIFICATION_FAILED"
|
|
1516
1509
|
);
|
|
1517
1510
|
}
|
|
@@ -1728,7 +1721,7 @@ var ComplianceClient = class {
|
|
|
1728
1721
|
processingTime: Date.now() - startTime
|
|
1729
1722
|
};
|
|
1730
1723
|
} catch (error) {
|
|
1731
|
-
throw new ComplianceError("Login verification failed", error);
|
|
1724
|
+
throw new ComplianceError("Login verification failed", error instanceof Error ? error.message : void 0);
|
|
1732
1725
|
}
|
|
1733
1726
|
}
|
|
1734
1727
|
/**
|
|
@@ -1807,7 +1800,7 @@ var ComplianceClient = class {
|
|
|
1807
1800
|
processingTime: Date.now() - startTime
|
|
1808
1801
|
};
|
|
1809
1802
|
} catch (error) {
|
|
1810
|
-
throw new ComplianceError("Transaction verification failed", error);
|
|
1803
|
+
throw new ComplianceError("Transaction verification failed", error instanceof Error ? error.message : void 0);
|
|
1811
1804
|
}
|
|
1812
1805
|
}
|
|
1813
1806
|
/**
|
|
@@ -1853,7 +1846,7 @@ var ComplianceClient = class {
|
|
|
1853
1846
|
async createProfileFromGeo(customerId, geoVerification, customerData) {
|
|
1854
1847
|
if (!customerData?.email || !customerData?.fullName) {
|
|
1855
1848
|
this.logger.warn(
|
|
1856
|
-
|
|
1849
|
+
"Creating profile with incomplete data. Profiles should be created during registration with complete customer information."
|
|
1857
1850
|
);
|
|
1858
1851
|
}
|
|
1859
1852
|
return this.riskClient.createProfile({
|