vesant-sdk 1.4.4 → 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 +55 -51
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +55 -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 +41 -33
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisions/index.mjs +41 -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 +42 -34
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +42 -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 +58 -52
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -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 +41 -33
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +41 -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 +41 -33
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +41 -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 +44 -36
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +44 -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 +41 -33
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/index.mjs +41 -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();
|
|
@@ -308,9 +308,20 @@ var BaseClient = class {
|
|
|
308
308
|
}
|
|
309
309
|
this.interceptors = config.interceptors || [];
|
|
310
310
|
this.logger = config.logger || createConsoleLogger();
|
|
311
|
+
let environment = config.environment;
|
|
312
|
+
const apiKey = config.apiKey || "";
|
|
313
|
+
if (apiKey.startsWith("pk_test_")) {
|
|
314
|
+
if (environment === "production") {
|
|
315
|
+
this.logger.warn('Sandbox API key (pk_test_*) used with environment: "production" \u2014 overriding to "sandbox"');
|
|
316
|
+
}
|
|
317
|
+
environment = "sandbox";
|
|
318
|
+
} else if (apiKey.startsWith("pk_live_") && environment === "sandbox") {
|
|
319
|
+
this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014 sandbox isolation will still be applied for backward compatibility');
|
|
320
|
+
}
|
|
311
321
|
this.config = {
|
|
312
322
|
...config,
|
|
313
|
-
apiKey
|
|
323
|
+
apiKey,
|
|
324
|
+
environment,
|
|
314
325
|
headers: config.headers || {},
|
|
315
326
|
timeout: config.timeout || 1e4,
|
|
316
327
|
retries: config.retries || 3,
|
|
@@ -377,10 +388,7 @@ var BaseClient = class {
|
|
|
377
388
|
}
|
|
378
389
|
}
|
|
379
390
|
if (this.config.debug) {
|
|
380
|
-
this.logger.debug(`${finalOptions.method || "GET"} ${
|
|
381
|
-
headers: finalOptions.headers,
|
|
382
|
-
body: finalOptions.body
|
|
383
|
-
});
|
|
391
|
+
this.logger.debug(`${finalOptions.method || "GET"} ${endpoint}`);
|
|
384
392
|
}
|
|
385
393
|
const response = await fetch(url, {
|
|
386
394
|
...finalOptions,
|
|
@@ -414,17 +422,17 @@ var BaseClient = class {
|
|
|
414
422
|
}
|
|
415
423
|
}
|
|
416
424
|
if (this.config.debug) {
|
|
417
|
-
this.logger.debug(
|
|
425
|
+
this.logger.debug(`Response: ${response.status}`);
|
|
418
426
|
}
|
|
419
427
|
return result;
|
|
420
428
|
} catch (error) {
|
|
421
429
|
clearTimeout(timeoutId);
|
|
422
|
-
if (error instanceof
|
|
430
|
+
if (error instanceof VesantError && error.statusCode && error.statusCode >= 500) {
|
|
423
431
|
this.circuitBreaker?.onFailure();
|
|
424
432
|
} else if (error instanceof NetworkError || error instanceof TimeoutError) {
|
|
425
433
|
this.circuitBreaker?.onFailure();
|
|
426
434
|
}
|
|
427
|
-
if (error instanceof
|
|
435
|
+
if (error instanceof VesantError && !error.requestId) {
|
|
428
436
|
error.requestId = requestId;
|
|
429
437
|
}
|
|
430
438
|
if (error instanceof Error) {
|
|
@@ -437,7 +445,7 @@ var BaseClient = class {
|
|
|
437
445
|
if (error instanceof Error) {
|
|
438
446
|
if (error.name === "AbortError") {
|
|
439
447
|
if (requestOptions?.signal?.aborted) {
|
|
440
|
-
const abortError = new
|
|
448
|
+
const abortError = new VesantError("Request aborted", "REQUEST_ABORTED");
|
|
441
449
|
abortError.requestId = requestId;
|
|
442
450
|
throw abortError;
|
|
443
451
|
}
|
|
@@ -446,7 +454,7 @@ var BaseClient = class {
|
|
|
446
454
|
timeoutError.requestId = requestId;
|
|
447
455
|
throw timeoutError;
|
|
448
456
|
}
|
|
449
|
-
if (error instanceof
|
|
457
|
+
if (error instanceof VesantError) {
|
|
450
458
|
throw error;
|
|
451
459
|
}
|
|
452
460
|
}
|
|
@@ -469,7 +477,7 @@ var BaseClient = class {
|
|
|
469
477
|
if (requestOptions?.signal?.aborted) {
|
|
470
478
|
throw lastError;
|
|
471
479
|
}
|
|
472
|
-
if (lastError instanceof
|
|
480
|
+
if (lastError instanceof VesantError && lastError.statusCode && lastError.statusCode >= 400 && lastError.statusCode < 500 && lastError.statusCode !== 429) {
|
|
473
481
|
throw lastError;
|
|
474
482
|
}
|
|
475
483
|
if (attempt === retries) {
|
|
@@ -497,13 +505,13 @@ var BaseClient = class {
|
|
|
497
505
|
const createError = () => {
|
|
498
506
|
switch (status) {
|
|
499
507
|
case 400:
|
|
500
|
-
return new
|
|
508
|
+
return new VesantError(message, "BAD_REQUEST", 400);
|
|
501
509
|
case 401:
|
|
502
510
|
return new AuthenticationError(message);
|
|
503
511
|
case 403:
|
|
504
|
-
return new
|
|
512
|
+
return new VesantError(message, "FORBIDDEN", 403);
|
|
505
513
|
case 404:
|
|
506
|
-
return new
|
|
514
|
+
return new VesantError(message, "NOT_FOUND", 404);
|
|
507
515
|
case 429: {
|
|
508
516
|
const retryAfter = data.retry_after || data.retryAfter;
|
|
509
517
|
return new RateLimitError(retryAfter);
|
|
@@ -514,7 +522,7 @@ var BaseClient = class {
|
|
|
514
522
|
case 504:
|
|
515
523
|
return new ServiceUnavailableError(message);
|
|
516
524
|
default:
|
|
517
|
-
return new
|
|
525
|
+
return new VesantError(message, "UNKNOWN_ERROR", status);
|
|
518
526
|
}
|
|
519
527
|
};
|
|
520
528
|
const error = createError();
|
|
@@ -1258,8 +1266,8 @@ var RiskProfileClient = class extends BaseClient {
|
|
|
1258
1266
|
requestOptions
|
|
1259
1267
|
);
|
|
1260
1268
|
} catch (error) {
|
|
1261
|
-
if (error instanceof
|
|
1262
|
-
throw new
|
|
1269
|
+
if (error instanceof VesantError && (error.statusCode === 404 || error.code === "NOT_FOUND")) {
|
|
1270
|
+
throw new VesantError("Profile not found", "NOT_FOUND", 404);
|
|
1263
1271
|
}
|
|
1264
1272
|
throw error;
|
|
1265
1273
|
}
|
|
@@ -1309,7 +1317,7 @@ var RiskProfileClient = class extends BaseClient {
|
|
|
1309
1317
|
try {
|
|
1310
1318
|
return await this.getProfile(customerId, requestOptions);
|
|
1311
1319
|
} catch (error) {
|
|
1312
|
-
if (error instanceof
|
|
1320
|
+
if (error instanceof VesantError && error.code === "NOT_FOUND") {
|
|
1313
1321
|
return await this.createProfile(createRequest, requestOptions);
|
|
1314
1322
|
}
|
|
1315
1323
|
throw error;
|
|
@@ -1476,8 +1484,6 @@ var ComplianceClient = class {
|
|
|
1476
1484
|
if (this.config.debug) {
|
|
1477
1485
|
this.logger.debug("Registration verification complete", {
|
|
1478
1486
|
allowed: true,
|
|
1479
|
-
riskScore: geoVerification.risk_score,
|
|
1480
|
-
profileId: profile.id,
|
|
1481
1487
|
requiresKYC,
|
|
1482
1488
|
requiresEDD
|
|
1483
1489
|
});
|
|
@@ -1493,16 +1499,14 @@ var ComplianceClient = class {
|
|
|
1493
1499
|
};
|
|
1494
1500
|
} catch (error) {
|
|
1495
1501
|
if (this.config.debug) {
|
|
1496
|
-
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
|
+
});
|
|
1497
1506
|
}
|
|
1498
1507
|
throw new ComplianceError(
|
|
1499
1508
|
"Registration verification failed",
|
|
1500
|
-
|
|
1501
|
-
stage: geoVerification ? "profile_creation" : "geo_verification",
|
|
1502
|
-
geoRecordId: geoVerification?.record_id,
|
|
1503
|
-
customerId: request.customerId,
|
|
1504
|
-
cause: error
|
|
1505
|
-
},
|
|
1509
|
+
error instanceof Error ? error.message : void 0,
|
|
1506
1510
|
geoVerification ? "PROFILE_CREATION_FAILED" : "GEO_VERIFICATION_FAILED"
|
|
1507
1511
|
);
|
|
1508
1512
|
}
|
|
@@ -1719,7 +1723,7 @@ var ComplianceClient = class {
|
|
|
1719
1723
|
processingTime: Date.now() - startTime
|
|
1720
1724
|
};
|
|
1721
1725
|
} catch (error) {
|
|
1722
|
-
throw new ComplianceError("Login verification failed", error);
|
|
1726
|
+
throw new ComplianceError("Login verification failed", error instanceof Error ? error.message : void 0);
|
|
1723
1727
|
}
|
|
1724
1728
|
}
|
|
1725
1729
|
/**
|
|
@@ -1798,7 +1802,7 @@ var ComplianceClient = class {
|
|
|
1798
1802
|
processingTime: Date.now() - startTime
|
|
1799
1803
|
};
|
|
1800
1804
|
} catch (error) {
|
|
1801
|
-
throw new ComplianceError("Transaction verification failed", error);
|
|
1805
|
+
throw new ComplianceError("Transaction verification failed", error instanceof Error ? error.message : void 0);
|
|
1802
1806
|
}
|
|
1803
1807
|
}
|
|
1804
1808
|
/**
|
|
@@ -1844,7 +1848,7 @@ var ComplianceClient = class {
|
|
|
1844
1848
|
async createProfileFromGeo(customerId, geoVerification, customerData) {
|
|
1845
1849
|
if (!customerData?.email || !customerData?.fullName) {
|
|
1846
1850
|
this.logger.warn(
|
|
1847
|
-
|
|
1851
|
+
"Creating profile with incomplete data. Profiles should be created during registration with complete customer information."
|
|
1848
1852
|
);
|
|
1849
1853
|
}
|
|
1850
1854
|
return this.riskClient.createProfile({
|