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
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();
|
|
@@ -333,7 +334,7 @@ var BaseClient = class {
|
|
|
333
334
|
}
|
|
334
335
|
environment = "sandbox";
|
|
335
336
|
} else if (apiKey.startsWith("pk_live_") && environment === "sandbox") {
|
|
336
|
-
this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014
|
|
337
|
+
this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014 sandbox isolation will still be applied for backward compatibility');
|
|
337
338
|
}
|
|
338
339
|
this.config = {
|
|
339
340
|
...config,
|
|
@@ -405,10 +406,7 @@ var BaseClient = class {
|
|
|
405
406
|
}
|
|
406
407
|
}
|
|
407
408
|
if (this.config.debug) {
|
|
408
|
-
this.logger.debug(`${finalOptions.method || "GET"} ${
|
|
409
|
-
headers: finalOptions.headers,
|
|
410
|
-
body: finalOptions.body
|
|
411
|
-
});
|
|
409
|
+
this.logger.debug(`${finalOptions.method || "GET"} ${endpoint}`);
|
|
412
410
|
}
|
|
413
411
|
const response = await fetch(url, {
|
|
414
412
|
...finalOptions,
|
|
@@ -442,17 +440,17 @@ var BaseClient = class {
|
|
|
442
440
|
}
|
|
443
441
|
}
|
|
444
442
|
if (this.config.debug) {
|
|
445
|
-
this.logger.debug(
|
|
443
|
+
this.logger.debug(`Response: ${response.status}`);
|
|
446
444
|
}
|
|
447
445
|
return result;
|
|
448
446
|
} catch (error) {
|
|
449
447
|
clearTimeout(timeoutId);
|
|
450
|
-
if (error instanceof
|
|
448
|
+
if (error instanceof VesantError && error.statusCode && error.statusCode >= 500) {
|
|
451
449
|
this.circuitBreaker?.onFailure();
|
|
452
450
|
} else if (error instanceof NetworkError || error instanceof TimeoutError) {
|
|
453
451
|
this.circuitBreaker?.onFailure();
|
|
454
452
|
}
|
|
455
|
-
if (error instanceof
|
|
453
|
+
if (error instanceof VesantError && !error.requestId) {
|
|
456
454
|
error.requestId = requestId;
|
|
457
455
|
}
|
|
458
456
|
if (error instanceof Error) {
|
|
@@ -465,7 +463,7 @@ var BaseClient = class {
|
|
|
465
463
|
if (error instanceof Error) {
|
|
466
464
|
if (error.name === "AbortError") {
|
|
467
465
|
if (requestOptions?.signal?.aborted) {
|
|
468
|
-
const abortError = new
|
|
466
|
+
const abortError = new VesantError("Request aborted", "REQUEST_ABORTED");
|
|
469
467
|
abortError.requestId = requestId;
|
|
470
468
|
throw abortError;
|
|
471
469
|
}
|
|
@@ -474,7 +472,7 @@ var BaseClient = class {
|
|
|
474
472
|
timeoutError.requestId = requestId;
|
|
475
473
|
throw timeoutError;
|
|
476
474
|
}
|
|
477
|
-
if (error instanceof
|
|
475
|
+
if (error instanceof VesantError) {
|
|
478
476
|
throw error;
|
|
479
477
|
}
|
|
480
478
|
}
|
|
@@ -497,7 +495,7 @@ var BaseClient = class {
|
|
|
497
495
|
if (requestOptions?.signal?.aborted) {
|
|
498
496
|
throw lastError;
|
|
499
497
|
}
|
|
500
|
-
if (lastError instanceof
|
|
498
|
+
if (lastError instanceof VesantError && lastError.statusCode && lastError.statusCode >= 400 && lastError.statusCode < 500 && lastError.statusCode !== 429) {
|
|
501
499
|
throw lastError;
|
|
502
500
|
}
|
|
503
501
|
if (attempt === retries) {
|
|
@@ -525,13 +523,13 @@ var BaseClient = class {
|
|
|
525
523
|
const createError = () => {
|
|
526
524
|
switch (status) {
|
|
527
525
|
case 400:
|
|
528
|
-
return new
|
|
526
|
+
return new VesantError(message, "BAD_REQUEST", 400);
|
|
529
527
|
case 401:
|
|
530
528
|
return new AuthenticationError(message);
|
|
531
529
|
case 403:
|
|
532
|
-
return new
|
|
530
|
+
return new VesantError(message, "FORBIDDEN", 403);
|
|
533
531
|
case 404:
|
|
534
|
-
return new
|
|
532
|
+
return new VesantError(message, "NOT_FOUND", 404);
|
|
535
533
|
case 429: {
|
|
536
534
|
const retryAfter = data.retry_after || data.retryAfter;
|
|
537
535
|
return new RateLimitError(retryAfter);
|
|
@@ -542,7 +540,7 @@ var BaseClient = class {
|
|
|
542
540
|
case 504:
|
|
543
541
|
return new ServiceUnavailableError(message);
|
|
544
542
|
default:
|
|
545
|
-
return new
|
|
543
|
+
return new VesantError(message, "UNKNOWN_ERROR", status);
|
|
546
544
|
}
|
|
547
545
|
};
|
|
548
546
|
const error = createError();
|
|
@@ -1353,8 +1351,8 @@ var RiskProfileClient = class extends BaseClient {
|
|
|
1353
1351
|
requestOptions
|
|
1354
1352
|
);
|
|
1355
1353
|
} catch (error) {
|
|
1356
|
-
if (error instanceof
|
|
1357
|
-
throw new
|
|
1354
|
+
if (error instanceof VesantError && (error.statusCode === 404 || error.code === "NOT_FOUND")) {
|
|
1355
|
+
throw new VesantError("Profile not found", "NOT_FOUND", 404);
|
|
1358
1356
|
}
|
|
1359
1357
|
throw error;
|
|
1360
1358
|
}
|
|
@@ -1404,7 +1402,7 @@ var RiskProfileClient = class extends BaseClient {
|
|
|
1404
1402
|
try {
|
|
1405
1403
|
return await this.getProfile(customerId, requestOptions);
|
|
1406
1404
|
} catch (error) {
|
|
1407
|
-
if (error instanceof
|
|
1405
|
+
if (error instanceof VesantError && error.code === "NOT_FOUND") {
|
|
1408
1406
|
return await this.createProfile(createRequest, requestOptions);
|
|
1409
1407
|
}
|
|
1410
1408
|
throw error;
|
|
@@ -1571,8 +1569,6 @@ var ComplianceClient = class {
|
|
|
1571
1569
|
if (this.config.debug) {
|
|
1572
1570
|
this.logger.debug("Registration verification complete", {
|
|
1573
1571
|
allowed: true,
|
|
1574
|
-
riskScore: geoVerification.risk_score,
|
|
1575
|
-
profileId: profile.id,
|
|
1576
1572
|
requiresKYC,
|
|
1577
1573
|
requiresEDD
|
|
1578
1574
|
});
|
|
@@ -1588,16 +1584,14 @@ var ComplianceClient = class {
|
|
|
1588
1584
|
};
|
|
1589
1585
|
} catch (error) {
|
|
1590
1586
|
if (this.config.debug) {
|
|
1591
|
-
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
|
+
});
|
|
1592
1591
|
}
|
|
1593
1592
|
throw new ComplianceError(
|
|
1594
1593
|
"Registration verification failed",
|
|
1595
|
-
|
|
1596
|
-
stage: geoVerification ? "profile_creation" : "geo_verification",
|
|
1597
|
-
geoRecordId: geoVerification?.record_id,
|
|
1598
|
-
customerId: request.customerId,
|
|
1599
|
-
cause: error
|
|
1600
|
-
},
|
|
1594
|
+
error instanceof Error ? error.message : void 0,
|
|
1601
1595
|
geoVerification ? "PROFILE_CREATION_FAILED" : "GEO_VERIFICATION_FAILED"
|
|
1602
1596
|
);
|
|
1603
1597
|
}
|
|
@@ -1814,7 +1808,7 @@ var ComplianceClient = class {
|
|
|
1814
1808
|
processingTime: Date.now() - startTime
|
|
1815
1809
|
};
|
|
1816
1810
|
} catch (error) {
|
|
1817
|
-
throw new ComplianceError("Login verification failed", error);
|
|
1811
|
+
throw new ComplianceError("Login verification failed", error instanceof Error ? error.message : void 0);
|
|
1818
1812
|
}
|
|
1819
1813
|
}
|
|
1820
1814
|
/**
|
|
@@ -1893,7 +1887,7 @@ var ComplianceClient = class {
|
|
|
1893
1887
|
processingTime: Date.now() - startTime
|
|
1894
1888
|
};
|
|
1895
1889
|
} catch (error) {
|
|
1896
|
-
throw new ComplianceError("Transaction verification failed", error);
|
|
1890
|
+
throw new ComplianceError("Transaction verification failed", error instanceof Error ? error.message : void 0);
|
|
1897
1891
|
}
|
|
1898
1892
|
}
|
|
1899
1893
|
/**
|
|
@@ -1939,7 +1933,7 @@ var ComplianceClient = class {
|
|
|
1939
1933
|
async createProfileFromGeo(customerId, geoVerification, customerData) {
|
|
1940
1934
|
if (!customerData?.email || !customerData?.fullName) {
|
|
1941
1935
|
this.logger.warn(
|
|
1942
|
-
|
|
1936
|
+
"Creating profile with incomplete data. Profiles should be created during registration with complete customer information."
|
|
1943
1937
|
);
|
|
1944
1938
|
}
|
|
1945
1939
|
return this.riskClient.createProfile({
|
|
@@ -3156,6 +3150,7 @@ exports.ScoresClient = ScoresClient;
|
|
|
3156
3150
|
exports.ServiceUnavailableError = ServiceUnavailableError;
|
|
3157
3151
|
exports.TimeoutError = TimeoutError;
|
|
3158
3152
|
exports.ValidationError = ValidationError;
|
|
3153
|
+
exports.VesantError = VesantError;
|
|
3159
3154
|
exports.WebhookHandler = WebhookHandler;
|
|
3160
3155
|
exports.WorkflowClient = WorkflowClient;
|
|
3161
3156
|
exports.createConsoleLogger = createConsoleLogger;
|