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,5 +1,5 @@
|
|
|
1
|
-
import { L as Logger, B as BaseClient, R as RequestOptions } from './client-
|
|
2
|
-
import { P as PaginationParams } from './types-
|
|
1
|
+
import { L as Logger, B as BaseClient, R as RequestOptions } from './client-BQRONu8q.js';
|
|
2
|
+
import { P as PaginationParams } from './types-B1OzEQR3.js';
|
|
3
3
|
|
|
4
4
|
interface DeviceFingerprintRequest {
|
|
5
5
|
device_id: string;
|
|
@@ -728,7 +728,7 @@ interface UseLocationCaptureResult {
|
|
|
728
728
|
}
|
|
729
729
|
|
|
730
730
|
/**
|
|
731
|
-
* GeolocationClient - TypeScript SDK for
|
|
731
|
+
* GeolocationClient - TypeScript SDK for Vesant Geolocation & Compliance Service
|
|
732
732
|
*
|
|
733
733
|
* Provides type-safe methods to interact with the geolocation service API.
|
|
734
734
|
* Extends BaseClient for consistent retry logic, timeout handling, and error management.
|
|
@@ -737,7 +737,7 @@ interface UseLocationCaptureResult {
|
|
|
737
737
|
/**
|
|
738
738
|
* GeolocationClient extends BaseClient for:
|
|
739
739
|
* - Consistent retry logic with exponential backoff
|
|
740
|
-
* - Unified error handling (
|
|
740
|
+
* - Unified error handling (VesantError, NetworkError, TimeoutError, etc.)
|
|
741
741
|
* - Automatic timeout management
|
|
742
742
|
* - Debug logging
|
|
743
743
|
*
|
|
@@ -99,7 +99,7 @@ interface BaseClientConfig {
|
|
|
99
99
|
/** Enable rate limit header tracking (default: false) */
|
|
100
100
|
enableRateLimitTracking?: boolean;
|
|
101
101
|
}
|
|
102
|
-
interface
|
|
102
|
+
interface VesantConfig {
|
|
103
103
|
/** Base URL for the Vesant API */
|
|
104
104
|
baseURL: string;
|
|
105
105
|
/** Tenant ID for multi-tenancy */
|
|
@@ -129,8 +129,12 @@ interface CGSConfig {
|
|
|
129
129
|
/** Enable rate limit header tracking (default: false) */
|
|
130
130
|
enableRateLimitTracking?: boolean;
|
|
131
131
|
}
|
|
132
|
-
/**
|
|
133
|
-
type
|
|
132
|
+
/** VesantConfig with core fields required, enterprise features remain optional */
|
|
133
|
+
type RequiredVesantConfig = Required<Pick<VesantConfig, 'baseURL' | 'tenantId' | 'apiKey' | 'headers' | 'timeout' | 'retries' | 'debug' | 'autoCreateProfiles' | 'syncMode' | 'interceptors' | 'logger'>> & Pick<VesantConfig, 'environment' | 'circuitBreaker' | 'enableRateLimitTracking'>;
|
|
134
|
+
/** @deprecated Use VesantConfig instead */
|
|
135
|
+
type CGSConfig = VesantConfig;
|
|
136
|
+
/** @deprecated Use RequiredVesantConfig instead */
|
|
137
|
+
type RequiredCGSConfig = RequiredVesantConfig;
|
|
134
138
|
/** BaseClientConfig with core fields required, enterprise features remain optional */
|
|
135
139
|
type RequiredBaseClientConfig = Required<Pick<BaseClientConfig, 'baseURL' | 'tenantId' | 'apiKey' | 'headers' | 'timeout' | 'retries' | 'debug' | 'interceptors' | 'logger'>> & Pick<BaseClientConfig, 'environment' | 'circuitBreaker' | 'enableRateLimitTracking'>;
|
|
136
140
|
|
|
@@ -170,7 +174,7 @@ declare class RateLimitTracker {
|
|
|
170
174
|
}
|
|
171
175
|
|
|
172
176
|
/**
|
|
173
|
-
* Base HTTP client for all
|
|
177
|
+
* Base HTTP client for all Vesant SDK clients
|
|
174
178
|
*
|
|
175
179
|
* Provides common functionality:
|
|
176
180
|
* - Request/response handling
|
|
@@ -231,4 +235,4 @@ declare abstract class BaseClient {
|
|
|
231
235
|
}>;
|
|
232
236
|
}
|
|
233
237
|
|
|
234
|
-
export { BaseClient as B, type CircuitBreakerConfig as C, type Logger as L, type RequestOptions as R, type RequestInterceptor as a, type BaseClientConfig as b, type
|
|
238
|
+
export { BaseClient as B, type CircuitBreakerConfig as C, type Logger as L, type RequestOptions as R, type VesantConfig as V, type RequestInterceptor as a, type BaseClientConfig as b, type RequiredVesantConfig as c, type CGSConfig as d, type RequiredCGSConfig as e, type RequiredBaseClientConfig as f, type CircuitBreakerState as g, type CircuitBreakerStatus as h, CircuitBreaker as i, type RateLimitStatus as j, RateLimitTracker as k };
|
|
@@ -99,7 +99,7 @@ interface BaseClientConfig {
|
|
|
99
99
|
/** Enable rate limit header tracking (default: false) */
|
|
100
100
|
enableRateLimitTracking?: boolean;
|
|
101
101
|
}
|
|
102
|
-
interface
|
|
102
|
+
interface VesantConfig {
|
|
103
103
|
/** Base URL for the Vesant API */
|
|
104
104
|
baseURL: string;
|
|
105
105
|
/** Tenant ID for multi-tenancy */
|
|
@@ -129,8 +129,12 @@ interface CGSConfig {
|
|
|
129
129
|
/** Enable rate limit header tracking (default: false) */
|
|
130
130
|
enableRateLimitTracking?: boolean;
|
|
131
131
|
}
|
|
132
|
-
/**
|
|
133
|
-
type
|
|
132
|
+
/** VesantConfig with core fields required, enterprise features remain optional */
|
|
133
|
+
type RequiredVesantConfig = Required<Pick<VesantConfig, 'baseURL' | 'tenantId' | 'apiKey' | 'headers' | 'timeout' | 'retries' | 'debug' | 'autoCreateProfiles' | 'syncMode' | 'interceptors' | 'logger'>> & Pick<VesantConfig, 'environment' | 'circuitBreaker' | 'enableRateLimitTracking'>;
|
|
134
|
+
/** @deprecated Use VesantConfig instead */
|
|
135
|
+
type CGSConfig = VesantConfig;
|
|
136
|
+
/** @deprecated Use RequiredVesantConfig instead */
|
|
137
|
+
type RequiredCGSConfig = RequiredVesantConfig;
|
|
134
138
|
/** BaseClientConfig with core fields required, enterprise features remain optional */
|
|
135
139
|
type RequiredBaseClientConfig = Required<Pick<BaseClientConfig, 'baseURL' | 'tenantId' | 'apiKey' | 'headers' | 'timeout' | 'retries' | 'debug' | 'interceptors' | 'logger'>> & Pick<BaseClientConfig, 'environment' | 'circuitBreaker' | 'enableRateLimitTracking'>;
|
|
136
140
|
|
|
@@ -170,7 +174,7 @@ declare class RateLimitTracker {
|
|
|
170
174
|
}
|
|
171
175
|
|
|
172
176
|
/**
|
|
173
|
-
* Base HTTP client for all
|
|
177
|
+
* Base HTTP client for all Vesant SDK clients
|
|
174
178
|
*
|
|
175
179
|
* Provides common functionality:
|
|
176
180
|
* - Request/response handling
|
|
@@ -231,4 +235,4 @@ declare abstract class BaseClient {
|
|
|
231
235
|
}>;
|
|
232
236
|
}
|
|
233
237
|
|
|
234
|
-
export { BaseClient as B, type CircuitBreakerConfig as C, type Logger as L, type RequestOptions as R, type RequestInterceptor as a, type BaseClientConfig as b, type
|
|
238
|
+
export { BaseClient as B, type CircuitBreakerConfig as C, type Logger as L, type RequestOptions as R, type VesantConfig as V, type RequestInterceptor as a, type BaseClientConfig as b, type RequiredVesantConfig as c, type CGSConfig as d, type RequiredCGSConfig as e, type RequiredBaseClientConfig as f, type CircuitBreakerState as g, type CircuitBreakerStatus as h, CircuitBreaker as i, type RateLimitStatus as j, RateLimitTracker as k };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as Logger, B as BaseClient, R as RequestOptions } from './client-
|
|
2
|
-
import { P as PaginationParams } from './types-
|
|
1
|
+
import { L as Logger, B as BaseClient, R as RequestOptions } from './client-BQRONu8q.mjs';
|
|
2
|
+
import { P as PaginationParams } from './types-B1OzEQR3.mjs';
|
|
3
3
|
|
|
4
4
|
interface DeviceFingerprintRequest {
|
|
5
5
|
device_id: string;
|
|
@@ -728,7 +728,7 @@ interface UseLocationCaptureResult {
|
|
|
728
728
|
}
|
|
729
729
|
|
|
730
730
|
/**
|
|
731
|
-
* GeolocationClient - TypeScript SDK for
|
|
731
|
+
* GeolocationClient - TypeScript SDK for Vesant Geolocation & Compliance Service
|
|
732
732
|
*
|
|
733
733
|
* Provides type-safe methods to interact with the geolocation service API.
|
|
734
734
|
* Extends BaseClient for consistent retry logic, timeout handling, and error management.
|
|
@@ -737,7 +737,7 @@ interface UseLocationCaptureResult {
|
|
|
737
737
|
/**
|
|
738
738
|
* GeolocationClient extends BaseClient for:
|
|
739
739
|
* - Consistent retry logic with exponential backoff
|
|
740
|
-
* - Unified error handling (
|
|
740
|
+
* - Unified error handling (VesantError, NetworkError, TimeoutError, etc.)
|
|
741
741
|
* - Automatic timeout management
|
|
742
742
|
* - Debug logging
|
|
743
743
|
*
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { D as DeviceFingerprintRequest, L as LocationVerification, P as LocationRequest, G as GeolocationClient, S as LocationRequestFilters, T as LocationRequestListResponse } from '../client-
|
|
2
|
-
export { Q as CreateLocationRequestRequest, Y as LocationCaptureRequest, _ as LocationCaptureResponse, O as LocationRequestChannel, R as LocationRequestResult, N as LocationRequestStatus, Z as LocationShareInfo, W as ResendLocationRequestRequest } from '../client-
|
|
1
|
+
import { D as DeviceFingerprintRequest, L as LocationVerification, P as LocationRequest, G as GeolocationClient, S as LocationRequestFilters, T as LocationRequestListResponse } from '../client-DKqyESgT.mjs';
|
|
2
|
+
export { Q as CreateLocationRequestRequest, Y as LocationCaptureRequest, _ as LocationCaptureResponse, O as LocationRequestChannel, R as LocationRequestResult, N as LocationRequestStatus, Z as LocationShareInfo, W as ResendLocationRequestRequest } from '../client-DKqyESgT.mjs';
|
|
3
3
|
import { RiskProfileClient } from '../risk-profile/index.mjs';
|
|
4
|
-
import {
|
|
5
|
-
import { C as CustomerProfile } from '../types-
|
|
6
|
-
import { E as EntityType, P as PaginationParams } from '../types-
|
|
4
|
+
import { V as VesantConfig, R as RequestOptions } from '../client-BQRONu8q.mjs';
|
|
5
|
+
import { C as CustomerProfile } from '../types-_hsTA3Ez.mjs';
|
|
6
|
+
import { E as EntityType, P as PaginationParams } from '../types-B1OzEQR3.mjs';
|
|
7
7
|
|
|
8
8
|
interface RegistrationVerificationRequest {
|
|
9
9
|
customerId: string;
|
|
@@ -114,7 +114,7 @@ interface ComplianceLocationRequestResult {
|
|
|
114
114
|
* Main integration point for casino platforms. Orchestrates geolocation
|
|
115
115
|
* verification with customer risk profiling for complete compliance coverage.
|
|
116
116
|
*
|
|
117
|
-
*
|
|
117
|
+
* SDK is the primary data injection point for compliance verification.
|
|
118
118
|
*/
|
|
119
119
|
|
|
120
120
|
declare class ComplianceClient {
|
|
@@ -125,7 +125,7 @@ declare class ComplianceClient {
|
|
|
125
125
|
private currencyRates;
|
|
126
126
|
private _currencyRatesCustomized;
|
|
127
127
|
private _currencyRatesWarned;
|
|
128
|
-
constructor(config:
|
|
128
|
+
constructor(config: VesantConfig);
|
|
129
129
|
/** Get the underlying GeolocationClient for direct geolocation API access */
|
|
130
130
|
getGeolocationClient(): GeolocationClient;
|
|
131
131
|
/** Get the underlying RiskProfileClient for direct risk profile API access */
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { D as DeviceFingerprintRequest, L as LocationVerification, P as LocationRequest, G as GeolocationClient, S as LocationRequestFilters, T as LocationRequestListResponse } from '../client-
|
|
2
|
-
export { Q as CreateLocationRequestRequest, Y as LocationCaptureRequest, _ as LocationCaptureResponse, O as LocationRequestChannel, R as LocationRequestResult, N as LocationRequestStatus, Z as LocationShareInfo, W as ResendLocationRequestRequest } from '../client-
|
|
1
|
+
import { D as DeviceFingerprintRequest, L as LocationVerification, P as LocationRequest, G as GeolocationClient, S as LocationRequestFilters, T as LocationRequestListResponse } from '../client-3cBb_Pp-.js';
|
|
2
|
+
export { Q as CreateLocationRequestRequest, Y as LocationCaptureRequest, _ as LocationCaptureResponse, O as LocationRequestChannel, R as LocationRequestResult, N as LocationRequestStatus, Z as LocationShareInfo, W as ResendLocationRequestRequest } from '../client-3cBb_Pp-.js';
|
|
3
3
|
import { RiskProfileClient } from '../risk-profile/index.js';
|
|
4
|
-
import {
|
|
5
|
-
import { C as CustomerProfile } from '../types-
|
|
6
|
-
import { E as EntityType, P as PaginationParams } from '../types-
|
|
4
|
+
import { V as VesantConfig, R as RequestOptions } from '../client-BQRONu8q.js';
|
|
5
|
+
import { C as CustomerProfile } from '../types-BnL66DB3.js';
|
|
6
|
+
import { E as EntityType, P as PaginationParams } from '../types-B1OzEQR3.js';
|
|
7
7
|
|
|
8
8
|
interface RegistrationVerificationRequest {
|
|
9
9
|
customerId: string;
|
|
@@ -114,7 +114,7 @@ interface ComplianceLocationRequestResult {
|
|
|
114
114
|
* Main integration point for casino platforms. Orchestrates geolocation
|
|
115
115
|
* verification with customer risk profiling for complete compliance coverage.
|
|
116
116
|
*
|
|
117
|
-
*
|
|
117
|
+
* SDK is the primary data injection point for compliance verification.
|
|
118
118
|
*/
|
|
119
119
|
|
|
120
120
|
declare class ComplianceClient {
|
|
@@ -125,7 +125,7 @@ declare class ComplianceClient {
|
|
|
125
125
|
private currencyRates;
|
|
126
126
|
private _currencyRatesCustomized;
|
|
127
127
|
private _currencyRatesWarned;
|
|
128
|
-
constructor(config:
|
|
128
|
+
constructor(config: VesantConfig);
|
|
129
129
|
/** Get the underlying GeolocationClient for direct geolocation API access */
|
|
130
130
|
getGeolocationClient(): GeolocationClient;
|
|
131
131
|
/** Get the underlying RiskProfileClient for direct risk profile API access */
|
package/dist/compliance/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,15 +56,15 @@ var TimeoutError = class _TimeoutError extends CGSError {
|
|
|
56
56
|
Object.setPrototypeOf(this, _TimeoutError.prototype);
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
-
var ComplianceError = class _ComplianceError extends
|
|
59
|
+
var ComplianceError = class _ComplianceError extends VesantError {
|
|
60
60
|
constructor(message, originalError, code = "COMPLIANCE_ERROR") {
|
|
61
|
-
super(message, code
|
|
61
|
+
super(message, code);
|
|
62
62
|
this.originalError = originalError;
|
|
63
63
|
this.name = "ComplianceError";
|
|
64
64
|
Object.setPrototypeOf(this, _ComplianceError.prototype);
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
var CircuitBreakerOpenError = class _CircuitBreakerOpenError extends
|
|
67
|
+
var CircuitBreakerOpenError = class _CircuitBreakerOpenError extends VesantError {
|
|
68
68
|
constructor() {
|
|
69
69
|
super("Circuit breaker is open \u2014 requests are temporarily blocked", "CIRCUIT_BREAKER_OPEN", 503);
|
|
70
70
|
this.name = "CircuitBreakerOpenError";
|
|
@@ -209,22 +209,22 @@ var RateLimitTracker = class {
|
|
|
209
209
|
function createConsoleLogger() {
|
|
210
210
|
return {
|
|
211
211
|
debug(message, meta) {
|
|
212
|
-
console.log(`[
|
|
212
|
+
console.log(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
213
213
|
},
|
|
214
214
|
info(message, meta) {
|
|
215
|
-
console.info(`[
|
|
215
|
+
console.info(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
216
216
|
},
|
|
217
217
|
warn(message, meta) {
|
|
218
|
-
console.warn(`[
|
|
218
|
+
console.warn(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
219
219
|
},
|
|
220
220
|
error(message, meta) {
|
|
221
|
-
console.error(`[
|
|
221
|
+
console.error(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
// src/core/version.ts
|
|
227
|
-
var SDK_VERSION = "1.
|
|
227
|
+
var SDK_VERSION = "1.5.0";
|
|
228
228
|
|
|
229
229
|
// src/shared/browser-utils.ts
|
|
230
230
|
function generateUUID() {
|
|
@@ -241,7 +241,7 @@ function generateDeviceId() {
|
|
|
241
241
|
if (typeof window === "undefined" || typeof localStorage === "undefined") {
|
|
242
242
|
return generateUUID();
|
|
243
243
|
}
|
|
244
|
-
const storageKey = "
|
|
244
|
+
const storageKey = "vesant_device_id";
|
|
245
245
|
let deviceId = localStorage.getItem(storageKey);
|
|
246
246
|
if (!deviceId) {
|
|
247
247
|
deviceId = generateUUID();
|
|
@@ -316,7 +316,7 @@ var BaseClient = class {
|
|
|
316
316
|
}
|
|
317
317
|
environment = "sandbox";
|
|
318
318
|
} else if (apiKey.startsWith("pk_live_") && environment === "sandbox") {
|
|
319
|
-
this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014
|
|
319
|
+
this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014 sandbox isolation will still be applied for backward compatibility');
|
|
320
320
|
}
|
|
321
321
|
this.config = {
|
|
322
322
|
...config,
|
|
@@ -388,10 +388,7 @@ var BaseClient = class {
|
|
|
388
388
|
}
|
|
389
389
|
}
|
|
390
390
|
if (this.config.debug) {
|
|
391
|
-
this.logger.debug(`${finalOptions.method || "GET"} ${
|
|
392
|
-
headers: finalOptions.headers,
|
|
393
|
-
body: finalOptions.body
|
|
394
|
-
});
|
|
391
|
+
this.logger.debug(`${finalOptions.method || "GET"} ${endpoint}`);
|
|
395
392
|
}
|
|
396
393
|
const response = await fetch(url, {
|
|
397
394
|
...finalOptions,
|
|
@@ -425,17 +422,17 @@ var BaseClient = class {
|
|
|
425
422
|
}
|
|
426
423
|
}
|
|
427
424
|
if (this.config.debug) {
|
|
428
|
-
this.logger.debug(
|
|
425
|
+
this.logger.debug(`Response: ${response.status}`);
|
|
429
426
|
}
|
|
430
427
|
return result;
|
|
431
428
|
} catch (error) {
|
|
432
429
|
clearTimeout(timeoutId);
|
|
433
|
-
if (error instanceof
|
|
430
|
+
if (error instanceof VesantError && error.statusCode && error.statusCode >= 500) {
|
|
434
431
|
this.circuitBreaker?.onFailure();
|
|
435
432
|
} else if (error instanceof NetworkError || error instanceof TimeoutError) {
|
|
436
433
|
this.circuitBreaker?.onFailure();
|
|
437
434
|
}
|
|
438
|
-
if (error instanceof
|
|
435
|
+
if (error instanceof VesantError && !error.requestId) {
|
|
439
436
|
error.requestId = requestId;
|
|
440
437
|
}
|
|
441
438
|
if (error instanceof Error) {
|
|
@@ -448,7 +445,7 @@ var BaseClient = class {
|
|
|
448
445
|
if (error instanceof Error) {
|
|
449
446
|
if (error.name === "AbortError") {
|
|
450
447
|
if (requestOptions?.signal?.aborted) {
|
|
451
|
-
const abortError = new
|
|
448
|
+
const abortError = new VesantError("Request aborted", "REQUEST_ABORTED");
|
|
452
449
|
abortError.requestId = requestId;
|
|
453
450
|
throw abortError;
|
|
454
451
|
}
|
|
@@ -457,7 +454,7 @@ var BaseClient = class {
|
|
|
457
454
|
timeoutError.requestId = requestId;
|
|
458
455
|
throw timeoutError;
|
|
459
456
|
}
|
|
460
|
-
if (error instanceof
|
|
457
|
+
if (error instanceof VesantError) {
|
|
461
458
|
throw error;
|
|
462
459
|
}
|
|
463
460
|
}
|
|
@@ -480,7 +477,7 @@ var BaseClient = class {
|
|
|
480
477
|
if (requestOptions?.signal?.aborted) {
|
|
481
478
|
throw lastError;
|
|
482
479
|
}
|
|
483
|
-
if (lastError instanceof
|
|
480
|
+
if (lastError instanceof VesantError && lastError.statusCode && lastError.statusCode >= 400 && lastError.statusCode < 500 && lastError.statusCode !== 429) {
|
|
484
481
|
throw lastError;
|
|
485
482
|
}
|
|
486
483
|
if (attempt === retries) {
|
|
@@ -508,13 +505,13 @@ var BaseClient = class {
|
|
|
508
505
|
const createError = () => {
|
|
509
506
|
switch (status) {
|
|
510
507
|
case 400:
|
|
511
|
-
return new
|
|
508
|
+
return new VesantError(message, "BAD_REQUEST", 400);
|
|
512
509
|
case 401:
|
|
513
510
|
return new AuthenticationError(message);
|
|
514
511
|
case 403:
|
|
515
|
-
return new
|
|
512
|
+
return new VesantError(message, "FORBIDDEN", 403);
|
|
516
513
|
case 404:
|
|
517
|
-
return new
|
|
514
|
+
return new VesantError(message, "NOT_FOUND", 404);
|
|
518
515
|
case 429: {
|
|
519
516
|
const retryAfter = data.retry_after || data.retryAfter;
|
|
520
517
|
return new RateLimitError(retryAfter);
|
|
@@ -525,7 +522,7 @@ var BaseClient = class {
|
|
|
525
522
|
case 504:
|
|
526
523
|
return new ServiceUnavailableError(message);
|
|
527
524
|
default:
|
|
528
|
-
return new
|
|
525
|
+
return new VesantError(message, "UNKNOWN_ERROR", status);
|
|
529
526
|
}
|
|
530
527
|
};
|
|
531
528
|
const error = createError();
|
|
@@ -1269,8 +1266,8 @@ var RiskProfileClient = class extends BaseClient {
|
|
|
1269
1266
|
requestOptions
|
|
1270
1267
|
);
|
|
1271
1268
|
} catch (error) {
|
|
1272
|
-
if (error instanceof
|
|
1273
|
-
throw new
|
|
1269
|
+
if (error instanceof VesantError && (error.statusCode === 404 || error.code === "NOT_FOUND")) {
|
|
1270
|
+
throw new VesantError("Profile not found", "NOT_FOUND", 404);
|
|
1274
1271
|
}
|
|
1275
1272
|
throw error;
|
|
1276
1273
|
}
|
|
@@ -1320,7 +1317,7 @@ var RiskProfileClient = class extends BaseClient {
|
|
|
1320
1317
|
try {
|
|
1321
1318
|
return await this.getProfile(customerId, requestOptions);
|
|
1322
1319
|
} catch (error) {
|
|
1323
|
-
if (error instanceof
|
|
1320
|
+
if (error instanceof VesantError && error.code === "NOT_FOUND") {
|
|
1324
1321
|
return await this.createProfile(createRequest, requestOptions);
|
|
1325
1322
|
}
|
|
1326
1323
|
throw error;
|
|
@@ -1487,8 +1484,6 @@ var ComplianceClient = class {
|
|
|
1487
1484
|
if (this.config.debug) {
|
|
1488
1485
|
this.logger.debug("Registration verification complete", {
|
|
1489
1486
|
allowed: true,
|
|
1490
|
-
riskScore: geoVerification.risk_score,
|
|
1491
|
-
profileId: profile.id,
|
|
1492
1487
|
requiresKYC,
|
|
1493
1488
|
requiresEDD
|
|
1494
1489
|
});
|
|
@@ -1504,16 +1499,14 @@ var ComplianceClient = class {
|
|
|
1504
1499
|
};
|
|
1505
1500
|
} catch (error) {
|
|
1506
1501
|
if (this.config.debug) {
|
|
1507
|
-
this.logger.error("Registration verification failed", {
|
|
1502
|
+
this.logger.error("Registration verification failed", {
|
|
1503
|
+
code: error instanceof Error ? error.code : void 0,
|
|
1504
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
1505
|
+
});
|
|
1508
1506
|
}
|
|
1509
1507
|
throw new ComplianceError(
|
|
1510
1508
|
"Registration verification failed",
|
|
1511
|
-
|
|
1512
|
-
stage: geoVerification ? "profile_creation" : "geo_verification",
|
|
1513
|
-
geoRecordId: geoVerification?.record_id,
|
|
1514
|
-
customerId: request.customerId,
|
|
1515
|
-
cause: error
|
|
1516
|
-
},
|
|
1509
|
+
error instanceof Error ? error.message : void 0,
|
|
1517
1510
|
geoVerification ? "PROFILE_CREATION_FAILED" : "GEO_VERIFICATION_FAILED"
|
|
1518
1511
|
);
|
|
1519
1512
|
}
|
|
@@ -1730,7 +1723,7 @@ var ComplianceClient = class {
|
|
|
1730
1723
|
processingTime: Date.now() - startTime
|
|
1731
1724
|
};
|
|
1732
1725
|
} catch (error) {
|
|
1733
|
-
throw new ComplianceError("Login verification failed", error);
|
|
1726
|
+
throw new ComplianceError("Login verification failed", error instanceof Error ? error.message : void 0);
|
|
1734
1727
|
}
|
|
1735
1728
|
}
|
|
1736
1729
|
/**
|
|
@@ -1809,7 +1802,7 @@ var ComplianceClient = class {
|
|
|
1809
1802
|
processingTime: Date.now() - startTime
|
|
1810
1803
|
};
|
|
1811
1804
|
} catch (error) {
|
|
1812
|
-
throw new ComplianceError("Transaction verification failed", error);
|
|
1805
|
+
throw new ComplianceError("Transaction verification failed", error instanceof Error ? error.message : void 0);
|
|
1813
1806
|
}
|
|
1814
1807
|
}
|
|
1815
1808
|
/**
|
|
@@ -1855,7 +1848,7 @@ var ComplianceClient = class {
|
|
|
1855
1848
|
async createProfileFromGeo(customerId, geoVerification, customerData) {
|
|
1856
1849
|
if (!customerData?.email || !customerData?.fullName) {
|
|
1857
1850
|
this.logger.warn(
|
|
1858
|
-
|
|
1851
|
+
"Creating profile with incomplete data. Profiles should be created during registration with complete customer information."
|
|
1859
1852
|
);
|
|
1860
1853
|
}
|
|
1861
1854
|
return this.riskClient.createProfile({
|