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
package/dist/index.d.ts
CHANGED
|
@@ -1,58 +1,62 @@
|
|
|
1
|
-
import { L as Logger } from './client-
|
|
2
|
-
export { B as BaseClient, b as BaseClientConfig,
|
|
3
|
-
export { A as APIResponse, C as CustomerStatus, E as EntityType, b as ErrorResponse, L as LocationCompliance, a as PaginatedResponse, P as PaginationParams, R as Result, c as RiskLevel, S as SuccessResponse, T as Timestamp, U as UUID, V as VerificationEventType } from './types-
|
|
1
|
+
import { L as Logger } from './client-BQRONu8q.js';
|
|
2
|
+
export { B as BaseClient, b as BaseClientConfig, d as CGSConfig, i as CircuitBreaker, C as CircuitBreakerConfig, g as CircuitBreakerState, h as CircuitBreakerStatus, j as RateLimitStatus, k as RateLimitTracker, a as RequestInterceptor, R as RequestOptions, f as RequiredBaseClientConfig, e as RequiredCGSConfig, c as RequiredVesantConfig, V as VesantConfig } from './client-BQRONu8q.js';
|
|
3
|
+
export { A as APIResponse, C as CustomerStatus, E as EntityType, b as ErrorResponse, L as LocationCompliance, a as PaginatedResponse, P as PaginationParams, R as Result, c as RiskLevel, S as SuccessResponse, T as Timestamp, U as UUID, V as VerificationEventType } from './types-B1OzEQR3.js';
|
|
4
4
|
export { BaseWebhookEvent, ComplianceCheckFailedPayload, DecisionRecordedPayload, GeolocationBlockedPayload, GeolocationVerifiedPayload, KycStatusChangedPayload, LabelAppliedPayload, LocationRequestCompletedPayload, ProfileCreatedPayload, ProfileUpdatedPayload, RiskCategoryChangedPayload, RiskScoreChangedPayload, WebhookAnyHandler, WebhookEvent, WebhookEventHandler, WebhookEventType, WebhookHandler, WebhookHandlerConfig, WebhookMiddlewareOptions, createNextWebhookHandler, createWebhookMiddleware, verifyWebhookSignature } from './webhooks/index.js';
|
|
5
|
-
export { B as APIError, p as AlertFilters, q as AlertListResponse, m as AlertSeverity, A as AlertStatus, n as AlertType, e as CipherTextCustomerData, b as CipherTextOptions, C as CipherTextPayload, a as CipherTextReason, c as CipherTextResult, l as ComplianceCheckResponse, w as CreateGeofenceRuleRequest, s as CreateJurisdictionRequest, Q as CreateLocationRequestRequest, r as DashboardMetrics, d as DecryptedCipherText, j as DeviceFingerprint, D as DeviceFingerprintRequest, k as DeviceTrustResult, h as GeoIPResult, u as GeofenceAction, i as GeofenceEvaluation, v as GeofenceRule, t as GeofenceRuleType, o as GeolocationAlert, G as GeolocationClient, F as GeolocationClientConfig, E as GeolocationConfigResponse, z as GeolocationRecord, J as JurisdictionConfig, Y as LocationCaptureRequest, _ as LocationCaptureResponse, P as LocationRequest, O as LocationRequestChannel, S as LocationRequestFilters, T as LocationRequestListResponse, R as LocationRequestResult, N as LocationRequestStatus, Z as LocationShareInfo, L as LocationVerification, W as ResendLocationRequestRequest, y as UpdateDeviceTrustRequest, x as UpdateGeofenceRuleRequest, U as UpdateJurisdictionRequest, K as UseAlertsOptions, M as UseAlertsResult, H as UseGeolocationOptions, I as UseGeolocationResult, a1 as UseLocationCaptureOptions, a2 as UseLocationCaptureResult, $ as UseLocationRequestsOptions, a0 as UseLocationRequestsResult, V as ValidateCipherTextRequest, f as ValidateCipherTextResponse, g as VerifyIPRequest, X as WiFiNetwork } from './client-
|
|
5
|
+
export { B as APIError, p as AlertFilters, q as AlertListResponse, m as AlertSeverity, A as AlertStatus, n as AlertType, e as CipherTextCustomerData, b as CipherTextOptions, C as CipherTextPayload, a as CipherTextReason, c as CipherTextResult, l as ComplianceCheckResponse, w as CreateGeofenceRuleRequest, s as CreateJurisdictionRequest, Q as CreateLocationRequestRequest, r as DashboardMetrics, d as DecryptedCipherText, j as DeviceFingerprint, D as DeviceFingerprintRequest, k as DeviceTrustResult, h as GeoIPResult, u as GeofenceAction, i as GeofenceEvaluation, v as GeofenceRule, t as GeofenceRuleType, o as GeolocationAlert, G as GeolocationClient, F as GeolocationClientConfig, E as GeolocationConfigResponse, z as GeolocationRecord, J as JurisdictionConfig, Y as LocationCaptureRequest, _ as LocationCaptureResponse, P as LocationRequest, O as LocationRequestChannel, S as LocationRequestFilters, T as LocationRequestListResponse, R as LocationRequestResult, N as LocationRequestStatus, Z as LocationShareInfo, L as LocationVerification, W as ResendLocationRequestRequest, y as UpdateDeviceTrustRequest, x as UpdateGeofenceRuleRequest, U as UpdateJurisdictionRequest, K as UseAlertsOptions, M as UseAlertsResult, H as UseGeolocationOptions, I as UseGeolocationResult, a1 as UseLocationCaptureOptions, a2 as UseLocationCaptureResult, $ as UseLocationRequestsOptions, a0 as UseLocationRequestsResult, V as ValidateCipherTextRequest, f as ValidateCipherTextResponse, g as VerifyIPRequest, X as WiFiNetwork } from './client-3cBb_Pp-.js';
|
|
6
6
|
export { decodeCipherText, generateCipherText, isCipherTextExpired } from './geolocation/index.js';
|
|
7
7
|
export { RiskProfileClient } from './risk-profile/index.js';
|
|
8
|
-
export { d as CreateCustomerProfileRequest, d as CreateProfileRequest, C as CustomerProfile, e as CustomerProfileFilters, f as CustomerProfileListResponse, E as EmploymentType, L as LegalForm, P as ProfileDetailsResponse, e as ProfileFilters, f as ProfileListResponse, R as RiskCategory, h as RiskConfiguration, g as RiskDashboardMetrics, a as RiskFactor, b as RiskFactorType, c as RiskHistory, S as ScreeningStatus, U as UpdateProfileRequest } from './types-
|
|
8
|
+
export { d as CreateCustomerProfileRequest, d as CreateProfileRequest, C as CustomerProfile, e as CustomerProfileFilters, f as CustomerProfileListResponse, E as EmploymentType, L as LegalForm, P as ProfileDetailsResponse, e as ProfileFilters, f as ProfileListResponse, R as RiskCategory, h as RiskConfiguration, g as RiskDashboardMetrics, a as RiskFactor, b as RiskFactorType, c as RiskHistory, S as ScreeningStatus, U as UpdateProfileRequest } from './types-BnL66DB3.js';
|
|
9
9
|
export { ComplianceClient, ComplianceLocationRequestInput, ComplianceLocationRequestResult, CurrencyRates, DEFAULT_CURRENCY_RATES, EventVerificationRequest, EventVerificationResponse, LoginVerificationRequest, LoginVerificationResponse, RegistrationVerificationRequest, RegistrationVerificationResponse, TransactionRiskResult, TransactionVerificationRequest, TransactionVerificationResponse } from './compliance/index.js';
|
|
10
10
|
export { CheckKycStatusRequest, CheckKycStatusResponse, CreateReuseKycSessionRequest, CreateReuseKycSessionResponse, DocumentType, DocumentVerificationRequest, DocumentVerificationResponse, FaceProof, KycAlert, KycAlertFilters, KycAlertListResponse, KycAlertStatus, KycAlertType, KycClient, KycClientConfig, KycCustomerProfile, KycOverview, KycPagination, KycPreferences, KycRequest, KycRequestFilters, KycRequestListResponse, KycStatus, Name, Proof, ProofDownloadURL, ProofType, RequestAdditionalDocumentsRequest, RequestKycSubmitLinkRequest, RequestKycSubmitLinkResponse, SubmitReuseKycSessionRequest, SubmittedDocument, SupportedDocumentType, UpdateKycAlertRequest, UpdateKycPreferencesRequest, UpdateKycStatusRequest, UseKycAlertsOptions, UseKycAlertsResult, UseKycOverviewOptions, UseKycOverviewResult, UseKycPreferencesResult, UseKycRequestsOptions, UseKycRequestsResult, UseKycSubmissionOptions, UseKycSubmissionResult } from './kyc/index.js';
|
|
11
11
|
export { ApplyLabelRequest, Decision, DecisionCategory, DecisionFilters, DecisionListResponse, DecisionSource, DecisionType, DecisionsClient, Label, LabelListResponse, LabelType, RecordDecisionRequest } from './decisions/index.js';
|
|
12
12
|
export { CustomerScore, ScoreBreakdown, ScoreFactor, ScoreHistoryEntry, ScoresClient, Workflow, WorkflowClient, WorkflowFilters, WorkflowListResponse, WorkflowStatus, WorkflowStep, WorkflowStepType } from './scores/index.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Error hierarchy for
|
|
15
|
+
* Error hierarchy for Vesant SDK
|
|
16
16
|
*
|
|
17
17
|
* Provides structured error handling with specific error types
|
|
18
18
|
* for different failure scenarios.
|
|
19
19
|
*/
|
|
20
|
-
declare class
|
|
20
|
+
declare class VesantError extends Error {
|
|
21
21
|
code: string;
|
|
22
22
|
statusCode?: number | undefined;
|
|
23
23
|
details?: Record<string, unknown> | undefined;
|
|
24
24
|
requestId?: string;
|
|
25
25
|
constructor(message: string, code: string, statusCode?: number | undefined, details?: Record<string, unknown> | undefined);
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
/** @deprecated Use VesantError instead */
|
|
28
|
+
declare const CGSError: typeof VesantError;
|
|
29
|
+
/** @deprecated Use VesantError instead */
|
|
30
|
+
type CGSError = VesantError;
|
|
31
|
+
declare class NetworkError extends VesantError {
|
|
28
32
|
originalError?: unknown | undefined;
|
|
29
33
|
constructor(message: string, originalError?: unknown | undefined);
|
|
30
34
|
}
|
|
31
|
-
declare class ValidationError extends
|
|
35
|
+
declare class ValidationError extends VesantError {
|
|
32
36
|
constructor(message: string, fields?: string[]);
|
|
33
37
|
}
|
|
34
|
-
declare class ServiceUnavailableError extends
|
|
35
|
-
constructor(message
|
|
38
|
+
declare class ServiceUnavailableError extends VesantError {
|
|
39
|
+
constructor(message?: string);
|
|
36
40
|
}
|
|
37
|
-
declare class ComplianceBlockedError extends
|
|
41
|
+
declare class ComplianceBlockedError extends VesantError {
|
|
38
42
|
constructor(reasons: string[]);
|
|
39
43
|
}
|
|
40
|
-
declare class AuthenticationError extends
|
|
44
|
+
declare class AuthenticationError extends VesantError {
|
|
41
45
|
constructor(message?: string);
|
|
42
46
|
}
|
|
43
|
-
declare class RateLimitError extends
|
|
47
|
+
declare class RateLimitError extends VesantError {
|
|
44
48
|
retryAfter?: number | undefined;
|
|
45
49
|
constructor(retryAfter?: number | undefined);
|
|
46
50
|
}
|
|
47
|
-
declare class TimeoutError extends
|
|
51
|
+
declare class TimeoutError extends VesantError {
|
|
48
52
|
timeout: number;
|
|
49
53
|
constructor(timeout: number);
|
|
50
54
|
}
|
|
51
|
-
declare class ComplianceError extends
|
|
55
|
+
declare class ComplianceError extends VesantError {
|
|
52
56
|
originalError?: unknown | undefined;
|
|
53
57
|
constructor(message: string, originalError?: unknown | undefined, code?: string);
|
|
54
58
|
}
|
|
55
|
-
declare class CircuitBreakerOpenError extends
|
|
59
|
+
declare class CircuitBreakerOpenError extends VesantError {
|
|
56
60
|
constructor();
|
|
57
61
|
}
|
|
58
62
|
|
|
@@ -62,6 +66,6 @@ declare const noopLogger: Logger;
|
|
|
62
66
|
/**
|
|
63
67
|
* Single source of truth for the SDK version.
|
|
64
68
|
*/
|
|
65
|
-
declare const SDK_VERSION = "1.
|
|
69
|
+
declare const SDK_VERSION = "1.5.0";
|
|
66
70
|
|
|
67
|
-
export { AuthenticationError, CGSError, CircuitBreakerOpenError, ComplianceBlockedError, ComplianceError, Logger, NetworkError, RateLimitError, SDK_VERSION, ServiceUnavailableError, TimeoutError, ValidationError, createConsoleLogger, noopLogger };
|
|
71
|
+
export { AuthenticationError, CGSError, CircuitBreakerOpenError, ComplianceBlockedError, ComplianceError, Logger, NetworkError, RateLimitError, SDK_VERSION, ServiceUnavailableError, TimeoutError, ValidationError, VesantError, createConsoleLogger, noopLogger };
|
package/dist/index.js
CHANGED
|
@@ -1,53 +1,54 @@
|
|
|
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
|
|
14
|
+
var CGSError = VesantError;
|
|
15
|
+
var NetworkError = class _NetworkError extends VesantError {
|
|
15
16
|
constructor(message, originalError) {
|
|
16
|
-
super(message, "NETWORK_ERROR"
|
|
17
|
+
super(message, "NETWORK_ERROR");
|
|
17
18
|
this.originalError = originalError;
|
|
18
19
|
this.name = "NetworkError";
|
|
19
20
|
Object.setPrototypeOf(this, _NetworkError.prototype);
|
|
20
21
|
}
|
|
21
22
|
};
|
|
22
|
-
var ValidationError = class _ValidationError extends
|
|
23
|
+
var ValidationError = class _ValidationError extends VesantError {
|
|
23
24
|
constructor(message, fields) {
|
|
24
25
|
super(message, "VALIDATION_ERROR", 400, { fields });
|
|
25
26
|
this.name = "ValidationError";
|
|
26
27
|
Object.setPrototypeOf(this, _ValidationError.prototype);
|
|
27
28
|
}
|
|
28
29
|
};
|
|
29
|
-
var ServiceUnavailableError = class _ServiceUnavailableError extends
|
|
30
|
-
constructor(message) {
|
|
31
|
-
super(
|
|
30
|
+
var ServiceUnavailableError = class _ServiceUnavailableError extends VesantError {
|
|
31
|
+
constructor(message = "Service unavailable") {
|
|
32
|
+
super(message, "SERVICE_UNAVAILABLE", 503);
|
|
32
33
|
this.name = "ServiceUnavailableError";
|
|
33
34
|
Object.setPrototypeOf(this, _ServiceUnavailableError.prototype);
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
|
-
var ComplianceBlockedError = class _ComplianceBlockedError extends
|
|
37
|
+
var ComplianceBlockedError = class _ComplianceBlockedError extends VesantError {
|
|
37
38
|
constructor(reasons) {
|
|
38
39
|
super("Access blocked due to compliance rules", "COMPLIANCE_BLOCKED", 403, { reasons });
|
|
39
40
|
this.name = "ComplianceBlockedError";
|
|
40
41
|
Object.setPrototypeOf(this, _ComplianceBlockedError.prototype);
|
|
41
42
|
}
|
|
42
43
|
};
|
|
43
|
-
var AuthenticationError = class _AuthenticationError extends
|
|
44
|
+
var AuthenticationError = class _AuthenticationError extends VesantError {
|
|
44
45
|
constructor(message = "Authentication failed") {
|
|
45
46
|
super(message, "AUTHENTICATION_ERROR", 401);
|
|
46
47
|
this.name = "AuthenticationError";
|
|
47
48
|
Object.setPrototypeOf(this, _AuthenticationError.prototype);
|
|
48
49
|
}
|
|
49
50
|
};
|
|
50
|
-
var RateLimitError = class _RateLimitError extends
|
|
51
|
+
var RateLimitError = class _RateLimitError extends VesantError {
|
|
51
52
|
constructor(retryAfter) {
|
|
52
53
|
super("Rate limit exceeded", "RATE_LIMIT_EXCEEDED", 429, { retryAfter });
|
|
53
54
|
this.retryAfter = retryAfter;
|
|
@@ -55,7 +56,7 @@ var RateLimitError = class _RateLimitError extends CGSError {
|
|
|
55
56
|
Object.setPrototypeOf(this, _RateLimitError.prototype);
|
|
56
57
|
}
|
|
57
58
|
};
|
|
58
|
-
var TimeoutError = class _TimeoutError extends
|
|
59
|
+
var TimeoutError = class _TimeoutError extends VesantError {
|
|
59
60
|
constructor(timeout) {
|
|
60
61
|
super(`Request timeout after ${timeout}ms`, "TIMEOUT", 408, { timeout });
|
|
61
62
|
this.timeout = timeout;
|
|
@@ -63,15 +64,15 @@ var TimeoutError = class _TimeoutError extends CGSError {
|
|
|
63
64
|
Object.setPrototypeOf(this, _TimeoutError.prototype);
|
|
64
65
|
}
|
|
65
66
|
};
|
|
66
|
-
var ComplianceError = class _ComplianceError extends
|
|
67
|
+
var ComplianceError = class _ComplianceError extends VesantError {
|
|
67
68
|
constructor(message, originalError, code = "COMPLIANCE_ERROR") {
|
|
68
|
-
super(message, code
|
|
69
|
+
super(message, code);
|
|
69
70
|
this.originalError = originalError;
|
|
70
71
|
this.name = "ComplianceError";
|
|
71
72
|
Object.setPrototypeOf(this, _ComplianceError.prototype);
|
|
72
73
|
}
|
|
73
74
|
};
|
|
74
|
-
var CircuitBreakerOpenError = class _CircuitBreakerOpenError extends
|
|
75
|
+
var CircuitBreakerOpenError = class _CircuitBreakerOpenError extends VesantError {
|
|
75
76
|
constructor() {
|
|
76
77
|
super("Circuit breaker is open \u2014 requests are temporarily blocked", "CIRCUIT_BREAKER_OPEN", 503);
|
|
77
78
|
this.name = "CircuitBreakerOpenError";
|
|
@@ -216,16 +217,16 @@ var RateLimitTracker = class {
|
|
|
216
217
|
function createConsoleLogger() {
|
|
217
218
|
return {
|
|
218
219
|
debug(message, meta) {
|
|
219
|
-
console.log(`[
|
|
220
|
+
console.log(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
220
221
|
},
|
|
221
222
|
info(message, meta) {
|
|
222
|
-
console.info(`[
|
|
223
|
+
console.info(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
223
224
|
},
|
|
224
225
|
warn(message, meta) {
|
|
225
|
-
console.warn(`[
|
|
226
|
+
console.warn(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
226
227
|
},
|
|
227
228
|
error(message, meta) {
|
|
228
|
-
console.error(`[
|
|
229
|
+
console.error(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
229
230
|
}
|
|
230
231
|
};
|
|
231
232
|
}
|
|
@@ -241,7 +242,7 @@ var noopLogger = {
|
|
|
241
242
|
};
|
|
242
243
|
|
|
243
244
|
// src/core/version.ts
|
|
244
|
-
var SDK_VERSION = "1.
|
|
245
|
+
var SDK_VERSION = "1.5.0";
|
|
245
246
|
|
|
246
247
|
// src/shared/browser-utils.ts
|
|
247
248
|
function generateUUID() {
|
|
@@ -258,7 +259,7 @@ function generateDeviceId() {
|
|
|
258
259
|
if (typeof window === "undefined" || typeof localStorage === "undefined") {
|
|
259
260
|
return generateUUID();
|
|
260
261
|
}
|
|
261
|
-
const storageKey = "
|
|
262
|
+
const storageKey = "vesant_device_id";
|
|
262
263
|
let deviceId = localStorage.getItem(storageKey);
|
|
263
264
|
if (!deviceId) {
|
|
264
265
|
deviceId = generateUUID();
|
|
@@ -325,9 +326,20 @@ var BaseClient = class {
|
|
|
325
326
|
}
|
|
326
327
|
this.interceptors = config.interceptors || [];
|
|
327
328
|
this.logger = config.logger || createConsoleLogger();
|
|
329
|
+
let environment = config.environment;
|
|
330
|
+
const apiKey = config.apiKey || "";
|
|
331
|
+
if (apiKey.startsWith("pk_test_")) {
|
|
332
|
+
if (environment === "production") {
|
|
333
|
+
this.logger.warn('Sandbox API key (pk_test_*) used with environment: "production" \u2014 overriding to "sandbox"');
|
|
334
|
+
}
|
|
335
|
+
environment = "sandbox";
|
|
336
|
+
} else if (apiKey.startsWith("pk_live_") && environment === "sandbox") {
|
|
337
|
+
this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014 sandbox isolation will still be applied for backward compatibility');
|
|
338
|
+
}
|
|
328
339
|
this.config = {
|
|
329
340
|
...config,
|
|
330
|
-
apiKey
|
|
341
|
+
apiKey,
|
|
342
|
+
environment,
|
|
331
343
|
headers: config.headers || {},
|
|
332
344
|
timeout: config.timeout || 1e4,
|
|
333
345
|
retries: config.retries || 3,
|
|
@@ -394,10 +406,7 @@ var BaseClient = class {
|
|
|
394
406
|
}
|
|
395
407
|
}
|
|
396
408
|
if (this.config.debug) {
|
|
397
|
-
this.logger.debug(`${finalOptions.method || "GET"} ${
|
|
398
|
-
headers: finalOptions.headers,
|
|
399
|
-
body: finalOptions.body
|
|
400
|
-
});
|
|
409
|
+
this.logger.debug(`${finalOptions.method || "GET"} ${endpoint}`);
|
|
401
410
|
}
|
|
402
411
|
const response = await fetch(url, {
|
|
403
412
|
...finalOptions,
|
|
@@ -431,17 +440,17 @@ var BaseClient = class {
|
|
|
431
440
|
}
|
|
432
441
|
}
|
|
433
442
|
if (this.config.debug) {
|
|
434
|
-
this.logger.debug(
|
|
443
|
+
this.logger.debug(`Response: ${response.status}`);
|
|
435
444
|
}
|
|
436
445
|
return result;
|
|
437
446
|
} catch (error) {
|
|
438
447
|
clearTimeout(timeoutId);
|
|
439
|
-
if (error instanceof
|
|
448
|
+
if (error instanceof VesantError && error.statusCode && error.statusCode >= 500) {
|
|
440
449
|
this.circuitBreaker?.onFailure();
|
|
441
450
|
} else if (error instanceof NetworkError || error instanceof TimeoutError) {
|
|
442
451
|
this.circuitBreaker?.onFailure();
|
|
443
452
|
}
|
|
444
|
-
if (error instanceof
|
|
453
|
+
if (error instanceof VesantError && !error.requestId) {
|
|
445
454
|
error.requestId = requestId;
|
|
446
455
|
}
|
|
447
456
|
if (error instanceof Error) {
|
|
@@ -454,7 +463,7 @@ var BaseClient = class {
|
|
|
454
463
|
if (error instanceof Error) {
|
|
455
464
|
if (error.name === "AbortError") {
|
|
456
465
|
if (requestOptions?.signal?.aborted) {
|
|
457
|
-
const abortError = new
|
|
466
|
+
const abortError = new VesantError("Request aborted", "REQUEST_ABORTED");
|
|
458
467
|
abortError.requestId = requestId;
|
|
459
468
|
throw abortError;
|
|
460
469
|
}
|
|
@@ -463,7 +472,7 @@ var BaseClient = class {
|
|
|
463
472
|
timeoutError.requestId = requestId;
|
|
464
473
|
throw timeoutError;
|
|
465
474
|
}
|
|
466
|
-
if (error instanceof
|
|
475
|
+
if (error instanceof VesantError) {
|
|
467
476
|
throw error;
|
|
468
477
|
}
|
|
469
478
|
}
|
|
@@ -486,7 +495,7 @@ var BaseClient = class {
|
|
|
486
495
|
if (requestOptions?.signal?.aborted) {
|
|
487
496
|
throw lastError;
|
|
488
497
|
}
|
|
489
|
-
if (lastError instanceof
|
|
498
|
+
if (lastError instanceof VesantError && lastError.statusCode && lastError.statusCode >= 400 && lastError.statusCode < 500 && lastError.statusCode !== 429) {
|
|
490
499
|
throw lastError;
|
|
491
500
|
}
|
|
492
501
|
if (attempt === retries) {
|
|
@@ -514,13 +523,13 @@ var BaseClient = class {
|
|
|
514
523
|
const createError = () => {
|
|
515
524
|
switch (status) {
|
|
516
525
|
case 400:
|
|
517
|
-
return new
|
|
526
|
+
return new VesantError(message, "BAD_REQUEST", 400);
|
|
518
527
|
case 401:
|
|
519
528
|
return new AuthenticationError(message);
|
|
520
529
|
case 403:
|
|
521
|
-
return new
|
|
530
|
+
return new VesantError(message, "FORBIDDEN", 403);
|
|
522
531
|
case 404:
|
|
523
|
-
return new
|
|
532
|
+
return new VesantError(message, "NOT_FOUND", 404);
|
|
524
533
|
case 429: {
|
|
525
534
|
const retryAfter = data.retry_after || data.retryAfter;
|
|
526
535
|
return new RateLimitError(retryAfter);
|
|
@@ -531,7 +540,7 @@ var BaseClient = class {
|
|
|
531
540
|
case 504:
|
|
532
541
|
return new ServiceUnavailableError(message);
|
|
533
542
|
default:
|
|
534
|
-
return new
|
|
543
|
+
return new VesantError(message, "UNKNOWN_ERROR", status);
|
|
535
544
|
}
|
|
536
545
|
};
|
|
537
546
|
const error = createError();
|
|
@@ -1342,8 +1351,8 @@ var RiskProfileClient = class extends BaseClient {
|
|
|
1342
1351
|
requestOptions
|
|
1343
1352
|
);
|
|
1344
1353
|
} catch (error) {
|
|
1345
|
-
if (error instanceof
|
|
1346
|
-
throw new
|
|
1354
|
+
if (error instanceof VesantError && (error.statusCode === 404 || error.code === "NOT_FOUND")) {
|
|
1355
|
+
throw new VesantError("Profile not found", "NOT_FOUND", 404);
|
|
1347
1356
|
}
|
|
1348
1357
|
throw error;
|
|
1349
1358
|
}
|
|
@@ -1393,7 +1402,7 @@ var RiskProfileClient = class extends BaseClient {
|
|
|
1393
1402
|
try {
|
|
1394
1403
|
return await this.getProfile(customerId, requestOptions);
|
|
1395
1404
|
} catch (error) {
|
|
1396
|
-
if (error instanceof
|
|
1405
|
+
if (error instanceof VesantError && error.code === "NOT_FOUND") {
|
|
1397
1406
|
return await this.createProfile(createRequest, requestOptions);
|
|
1398
1407
|
}
|
|
1399
1408
|
throw error;
|
|
@@ -1560,8 +1569,6 @@ var ComplianceClient = class {
|
|
|
1560
1569
|
if (this.config.debug) {
|
|
1561
1570
|
this.logger.debug("Registration verification complete", {
|
|
1562
1571
|
allowed: true,
|
|
1563
|
-
riskScore: geoVerification.risk_score,
|
|
1564
|
-
profileId: profile.id,
|
|
1565
1572
|
requiresKYC,
|
|
1566
1573
|
requiresEDD
|
|
1567
1574
|
});
|
|
@@ -1577,16 +1584,14 @@ var ComplianceClient = class {
|
|
|
1577
1584
|
};
|
|
1578
1585
|
} catch (error) {
|
|
1579
1586
|
if (this.config.debug) {
|
|
1580
|
-
this.logger.error("Registration verification failed", {
|
|
1587
|
+
this.logger.error("Registration verification failed", {
|
|
1588
|
+
code: error instanceof Error ? error.code : void 0,
|
|
1589
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
1590
|
+
});
|
|
1581
1591
|
}
|
|
1582
1592
|
throw new ComplianceError(
|
|
1583
1593
|
"Registration verification failed",
|
|
1584
|
-
|
|
1585
|
-
stage: geoVerification ? "profile_creation" : "geo_verification",
|
|
1586
|
-
geoRecordId: geoVerification?.record_id,
|
|
1587
|
-
customerId: request.customerId,
|
|
1588
|
-
cause: error
|
|
1589
|
-
},
|
|
1594
|
+
error instanceof Error ? error.message : void 0,
|
|
1590
1595
|
geoVerification ? "PROFILE_CREATION_FAILED" : "GEO_VERIFICATION_FAILED"
|
|
1591
1596
|
);
|
|
1592
1597
|
}
|
|
@@ -1803,7 +1808,7 @@ var ComplianceClient = class {
|
|
|
1803
1808
|
processingTime: Date.now() - startTime
|
|
1804
1809
|
};
|
|
1805
1810
|
} catch (error) {
|
|
1806
|
-
throw new ComplianceError("Login verification failed", error);
|
|
1811
|
+
throw new ComplianceError("Login verification failed", error instanceof Error ? error.message : void 0);
|
|
1807
1812
|
}
|
|
1808
1813
|
}
|
|
1809
1814
|
/**
|
|
@@ -1882,7 +1887,7 @@ var ComplianceClient = class {
|
|
|
1882
1887
|
processingTime: Date.now() - startTime
|
|
1883
1888
|
};
|
|
1884
1889
|
} catch (error) {
|
|
1885
|
-
throw new ComplianceError("Transaction verification failed", error);
|
|
1890
|
+
throw new ComplianceError("Transaction verification failed", error instanceof Error ? error.message : void 0);
|
|
1886
1891
|
}
|
|
1887
1892
|
}
|
|
1888
1893
|
/**
|
|
@@ -1928,7 +1933,7 @@ var ComplianceClient = class {
|
|
|
1928
1933
|
async createProfileFromGeo(customerId, geoVerification, customerData) {
|
|
1929
1934
|
if (!customerData?.email || !customerData?.fullName) {
|
|
1930
1935
|
this.logger.warn(
|
|
1931
|
-
|
|
1936
|
+
"Creating profile with incomplete data. Profiles should be created during registration with complete customer information."
|
|
1932
1937
|
);
|
|
1933
1938
|
}
|
|
1934
1939
|
return this.riskClient.createProfile({
|
|
@@ -3145,6 +3150,7 @@ exports.ScoresClient = ScoresClient;
|
|
|
3145
3150
|
exports.ServiceUnavailableError = ServiceUnavailableError;
|
|
3146
3151
|
exports.TimeoutError = TimeoutError;
|
|
3147
3152
|
exports.ValidationError = ValidationError;
|
|
3153
|
+
exports.VesantError = VesantError;
|
|
3148
3154
|
exports.WebhookHandler = WebhookHandler;
|
|
3149
3155
|
exports.WorkflowClient = WorkflowClient;
|
|
3150
3156
|
exports.createConsoleLogger = createConsoleLogger;
|