vesant-sdk 1.4.5 → 1.5.2
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/README.md +5 -3
- package/dist/{client-BlAt791q.d.ts → client-B8pFrXx_.d.ts} +11 -5
- package/dist/{client-oo_3-0YW.d.mts → client-BZxzOidG.d.mts} +11 -5
- package/dist/{client-CY41e2Z_.d.mts → client-CIon-bGS.d.mts} +9 -5
- package/dist/{client-CY41e2Z_.d.ts → client-CIon-bGS.d.ts} +9 -5
- package/dist/compliance/index.d.mts +7 -7
- package/dist/compliance/index.d.ts +7 -7
- package/dist/compliance/index.js +46 -51
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +46 -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 +32 -33
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisions/index.mjs +32 -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 +33 -34
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +33 -34
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index.d.mts +553 -21
- package/dist/index.d.ts +553 -21
- package/dist/index.js +320 -161
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +318 -159
- 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 +32 -33
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +32 -33
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.d.mts +11 -7
- package/dist/kyc/index.d.ts +11 -7
- package/dist/kyc/index.js +32 -33
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +32 -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 +35 -36
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +35 -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 +32 -33
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/index.mjs +32 -33
- package/dist/scores/index.mjs.map +1 -1
- package/dist/{types-jaLuzruy.d.mts → types-1RzYeSal.d.mts} +2 -2
- package/dist/{types-DZHongaK.d.mts → types-B4Ezqo7V.d.mts} +2 -2
- package/dist/{types-DZHongaK.d.ts → types-B4Ezqo7V.d.ts} +2 -2
- package/dist/{types-DLC7Sfy5.d.ts → types-X5Md_dD_.d.ts} +2 -2
- package/dist/webhooks/index.d.mts +1 -1
- package/dist/webhooks/index.d.ts +1 -1
- package/package.json +6 -1
package/dist/index.mjs
CHANGED
|
@@ -1,51 +1,52 @@
|
|
|
1
1
|
// src/core/errors.ts
|
|
2
|
-
var
|
|
2
|
+
var VesantError = class _VesantError extends Error {
|
|
3
3
|
constructor(message, code, statusCode, details) {
|
|
4
4
|
super(message);
|
|
5
5
|
this.code = code;
|
|
6
6
|
this.statusCode = statusCode;
|
|
7
7
|
this.details = details;
|
|
8
|
-
this.name = "
|
|
9
|
-
Object.setPrototypeOf(this,
|
|
8
|
+
this.name = "VesantError";
|
|
9
|
+
Object.setPrototypeOf(this, _VesantError.prototype);
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
-
var
|
|
12
|
+
var CGSError = VesantError;
|
|
13
|
+
var NetworkError = class _NetworkError extends VesantError {
|
|
13
14
|
constructor(message, originalError) {
|
|
14
|
-
super(message, "NETWORK_ERROR"
|
|
15
|
+
super(message, "NETWORK_ERROR");
|
|
15
16
|
this.originalError = originalError;
|
|
16
17
|
this.name = "NetworkError";
|
|
17
18
|
Object.setPrototypeOf(this, _NetworkError.prototype);
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
|
-
var ValidationError = class _ValidationError extends
|
|
21
|
+
var ValidationError = class _ValidationError extends VesantError {
|
|
21
22
|
constructor(message, fields) {
|
|
22
23
|
super(message, "VALIDATION_ERROR", 400, { fields });
|
|
23
24
|
this.name = "ValidationError";
|
|
24
25
|
Object.setPrototypeOf(this, _ValidationError.prototype);
|
|
25
26
|
}
|
|
26
27
|
};
|
|
27
|
-
var ServiceUnavailableError = class _ServiceUnavailableError extends
|
|
28
|
-
constructor(message) {
|
|
29
|
-
super(
|
|
28
|
+
var ServiceUnavailableError = class _ServiceUnavailableError extends VesantError {
|
|
29
|
+
constructor(message = "Service unavailable") {
|
|
30
|
+
super(message, "SERVICE_UNAVAILABLE", 503);
|
|
30
31
|
this.name = "ServiceUnavailableError";
|
|
31
32
|
Object.setPrototypeOf(this, _ServiceUnavailableError.prototype);
|
|
32
33
|
}
|
|
33
34
|
};
|
|
34
|
-
var ComplianceBlockedError = class _ComplianceBlockedError extends
|
|
35
|
+
var ComplianceBlockedError = class _ComplianceBlockedError extends VesantError {
|
|
35
36
|
constructor(reasons) {
|
|
36
37
|
super("Access blocked due to compliance rules", "COMPLIANCE_BLOCKED", 403, { reasons });
|
|
37
38
|
this.name = "ComplianceBlockedError";
|
|
38
39
|
Object.setPrototypeOf(this, _ComplianceBlockedError.prototype);
|
|
39
40
|
}
|
|
40
41
|
};
|
|
41
|
-
var AuthenticationError = class _AuthenticationError extends
|
|
42
|
+
var AuthenticationError = class _AuthenticationError extends VesantError {
|
|
42
43
|
constructor(message = "Authentication failed") {
|
|
43
44
|
super(message, "AUTHENTICATION_ERROR", 401);
|
|
44
45
|
this.name = "AuthenticationError";
|
|
45
46
|
Object.setPrototypeOf(this, _AuthenticationError.prototype);
|
|
46
47
|
}
|
|
47
48
|
};
|
|
48
|
-
var RateLimitError = class _RateLimitError extends
|
|
49
|
+
var RateLimitError = class _RateLimitError extends VesantError {
|
|
49
50
|
constructor(retryAfter) {
|
|
50
51
|
super("Rate limit exceeded", "RATE_LIMIT_EXCEEDED", 429, { retryAfter });
|
|
51
52
|
this.retryAfter = retryAfter;
|
|
@@ -53,7 +54,7 @@ var RateLimitError = class _RateLimitError extends CGSError {
|
|
|
53
54
|
Object.setPrototypeOf(this, _RateLimitError.prototype);
|
|
54
55
|
}
|
|
55
56
|
};
|
|
56
|
-
var TimeoutError = class _TimeoutError extends
|
|
57
|
+
var TimeoutError = class _TimeoutError extends VesantError {
|
|
57
58
|
constructor(timeout) {
|
|
58
59
|
super(`Request timeout after ${timeout}ms`, "TIMEOUT", 408, { timeout });
|
|
59
60
|
this.timeout = timeout;
|
|
@@ -61,15 +62,15 @@ var TimeoutError = class _TimeoutError extends CGSError {
|
|
|
61
62
|
Object.setPrototypeOf(this, _TimeoutError.prototype);
|
|
62
63
|
}
|
|
63
64
|
};
|
|
64
|
-
var ComplianceError = class _ComplianceError extends
|
|
65
|
+
var ComplianceError = class _ComplianceError extends VesantError {
|
|
65
66
|
constructor(message, originalError, code = "COMPLIANCE_ERROR") {
|
|
66
|
-
super(message, code
|
|
67
|
+
super(message, code);
|
|
67
68
|
this.originalError = originalError;
|
|
68
69
|
this.name = "ComplianceError";
|
|
69
70
|
Object.setPrototypeOf(this, _ComplianceError.prototype);
|
|
70
71
|
}
|
|
71
72
|
};
|
|
72
|
-
var CircuitBreakerOpenError = class _CircuitBreakerOpenError extends
|
|
73
|
+
var CircuitBreakerOpenError = class _CircuitBreakerOpenError extends VesantError {
|
|
73
74
|
constructor() {
|
|
74
75
|
super("Circuit breaker is open \u2014 requests are temporarily blocked", "CIRCUIT_BREAKER_OPEN", 503);
|
|
75
76
|
this.name = "CircuitBreakerOpenError";
|
|
@@ -214,16 +215,16 @@ var RateLimitTracker = class {
|
|
|
214
215
|
function createConsoleLogger() {
|
|
215
216
|
return {
|
|
216
217
|
debug(message, meta) {
|
|
217
|
-
console.log(`[
|
|
218
|
+
console.log(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
218
219
|
},
|
|
219
220
|
info(message, meta) {
|
|
220
|
-
console.info(`[
|
|
221
|
+
console.info(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
221
222
|
},
|
|
222
223
|
warn(message, meta) {
|
|
223
|
-
console.warn(`[
|
|
224
|
+
console.warn(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
224
225
|
},
|
|
225
226
|
error(message, meta) {
|
|
226
|
-
console.error(`[
|
|
227
|
+
console.error(`[Vesant SDK] ${message}`, meta !== void 0 ? meta : "");
|
|
227
228
|
}
|
|
228
229
|
};
|
|
229
230
|
}
|
|
@@ -239,7 +240,7 @@ var noopLogger = {
|
|
|
239
240
|
};
|
|
240
241
|
|
|
241
242
|
// src/core/version.ts
|
|
242
|
-
var SDK_VERSION = "1.
|
|
243
|
+
var SDK_VERSION = "1.5.2";
|
|
243
244
|
|
|
244
245
|
// src/shared/browser-utils.ts
|
|
245
246
|
function generateUUID() {
|
|
@@ -256,7 +257,7 @@ function generateDeviceId() {
|
|
|
256
257
|
if (typeof window === "undefined" || typeof localStorage === "undefined") {
|
|
257
258
|
return generateUUID();
|
|
258
259
|
}
|
|
259
|
-
const storageKey = "
|
|
260
|
+
const storageKey = "vesant_device_id";
|
|
260
261
|
let deviceId = localStorage.getItem(storageKey);
|
|
261
262
|
if (!deviceId) {
|
|
262
263
|
deviceId = generateUUID();
|
|
@@ -331,7 +332,7 @@ var BaseClient = class {
|
|
|
331
332
|
}
|
|
332
333
|
environment = "sandbox";
|
|
333
334
|
} else if (apiKey.startsWith("pk_live_") && environment === "sandbox") {
|
|
334
|
-
this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014
|
|
335
|
+
this.logger.warn('Production API key (pk_live_*) used with environment: "sandbox" \u2014 sandbox isolation will still be applied for backward compatibility');
|
|
335
336
|
}
|
|
336
337
|
this.config = {
|
|
337
338
|
...config,
|
|
@@ -403,10 +404,7 @@ var BaseClient = class {
|
|
|
403
404
|
}
|
|
404
405
|
}
|
|
405
406
|
if (this.config.debug) {
|
|
406
|
-
this.logger.debug(`${finalOptions.method || "GET"} ${
|
|
407
|
-
headers: finalOptions.headers,
|
|
408
|
-
body: finalOptions.body
|
|
409
|
-
});
|
|
407
|
+
this.logger.debug(`${finalOptions.method || "GET"} ${endpoint}`);
|
|
410
408
|
}
|
|
411
409
|
const response = await fetch(url, {
|
|
412
410
|
...finalOptions,
|
|
@@ -440,17 +438,17 @@ var BaseClient = class {
|
|
|
440
438
|
}
|
|
441
439
|
}
|
|
442
440
|
if (this.config.debug) {
|
|
443
|
-
this.logger.debug(
|
|
441
|
+
this.logger.debug(`Response: ${response.status}`);
|
|
444
442
|
}
|
|
445
443
|
return result;
|
|
446
444
|
} catch (error) {
|
|
447
445
|
clearTimeout(timeoutId);
|
|
448
|
-
if (error instanceof
|
|
446
|
+
if (error instanceof VesantError && error.statusCode && error.statusCode >= 500) {
|
|
449
447
|
this.circuitBreaker?.onFailure();
|
|
450
448
|
} else if (error instanceof NetworkError || error instanceof TimeoutError) {
|
|
451
449
|
this.circuitBreaker?.onFailure();
|
|
452
450
|
}
|
|
453
|
-
if (error instanceof
|
|
451
|
+
if (error instanceof VesantError && !error.requestId) {
|
|
454
452
|
error.requestId = requestId;
|
|
455
453
|
}
|
|
456
454
|
if (error instanceof Error) {
|
|
@@ -463,7 +461,7 @@ var BaseClient = class {
|
|
|
463
461
|
if (error instanceof Error) {
|
|
464
462
|
if (error.name === "AbortError") {
|
|
465
463
|
if (requestOptions?.signal?.aborted) {
|
|
466
|
-
const abortError = new
|
|
464
|
+
const abortError = new VesantError("Request aborted", "REQUEST_ABORTED");
|
|
467
465
|
abortError.requestId = requestId;
|
|
468
466
|
throw abortError;
|
|
469
467
|
}
|
|
@@ -472,7 +470,7 @@ var BaseClient = class {
|
|
|
472
470
|
timeoutError.requestId = requestId;
|
|
473
471
|
throw timeoutError;
|
|
474
472
|
}
|
|
475
|
-
if (error instanceof
|
|
473
|
+
if (error instanceof VesantError) {
|
|
476
474
|
throw error;
|
|
477
475
|
}
|
|
478
476
|
}
|
|
@@ -495,7 +493,7 @@ var BaseClient = class {
|
|
|
495
493
|
if (requestOptions?.signal?.aborted) {
|
|
496
494
|
throw lastError;
|
|
497
495
|
}
|
|
498
|
-
if (lastError instanceof
|
|
496
|
+
if (lastError instanceof VesantError && lastError.statusCode && lastError.statusCode >= 400 && lastError.statusCode < 500 && lastError.statusCode !== 429) {
|
|
499
497
|
throw lastError;
|
|
500
498
|
}
|
|
501
499
|
if (attempt === retries) {
|
|
@@ -523,13 +521,15 @@ var BaseClient = class {
|
|
|
523
521
|
const createError = () => {
|
|
524
522
|
switch (status) {
|
|
525
523
|
case 400:
|
|
526
|
-
return new
|
|
524
|
+
return new VesantError(message, "BAD_REQUEST", 400);
|
|
527
525
|
case 401:
|
|
528
526
|
return new AuthenticationError(message);
|
|
529
527
|
case 403:
|
|
530
|
-
return new
|
|
528
|
+
return new VesantError(message, "FORBIDDEN", 403);
|
|
531
529
|
case 404:
|
|
532
|
-
return new
|
|
530
|
+
return new VesantError(message, "NOT_FOUND", 404);
|
|
531
|
+
case 409:
|
|
532
|
+
return new VesantError(message, "DUPLICATE_PROFILE", 409);
|
|
533
533
|
case 429: {
|
|
534
534
|
const retryAfter = data.retry_after || data.retryAfter;
|
|
535
535
|
return new RateLimitError(retryAfter);
|
|
@@ -540,7 +540,7 @@ var BaseClient = class {
|
|
|
540
540
|
case 504:
|
|
541
541
|
return new ServiceUnavailableError(message);
|
|
542
542
|
default:
|
|
543
|
-
return new
|
|
543
|
+
return new VesantError(message, "UNKNOWN_ERROR", status);
|
|
544
544
|
}
|
|
545
545
|
};
|
|
546
546
|
const error = createError();
|
|
@@ -1351,8 +1351,8 @@ var RiskProfileClient = class extends BaseClient {
|
|
|
1351
1351
|
requestOptions
|
|
1352
1352
|
);
|
|
1353
1353
|
} catch (error) {
|
|
1354
|
-
if (error instanceof
|
|
1355
|
-
throw new
|
|
1354
|
+
if (error instanceof VesantError && (error.statusCode === 404 || error.code === "NOT_FOUND")) {
|
|
1355
|
+
throw new VesantError("Profile not found", "NOT_FOUND", 404);
|
|
1356
1356
|
}
|
|
1357
1357
|
throw error;
|
|
1358
1358
|
}
|
|
@@ -1402,7 +1402,7 @@ var RiskProfileClient = class extends BaseClient {
|
|
|
1402
1402
|
try {
|
|
1403
1403
|
return await this.getProfile(customerId, requestOptions);
|
|
1404
1404
|
} catch (error) {
|
|
1405
|
-
if (error instanceof
|
|
1405
|
+
if (error instanceof VesantError && error.code === "NOT_FOUND") {
|
|
1406
1406
|
return await this.createProfile(createRequest, requestOptions);
|
|
1407
1407
|
}
|
|
1408
1408
|
throw error;
|
|
@@ -1569,8 +1569,6 @@ var ComplianceClient = class {
|
|
|
1569
1569
|
if (this.config.debug) {
|
|
1570
1570
|
this.logger.debug("Registration verification complete", {
|
|
1571
1571
|
allowed: true,
|
|
1572
|
-
riskScore: geoVerification.risk_score,
|
|
1573
|
-
profileId: profile.id,
|
|
1574
1572
|
requiresKYC,
|
|
1575
1573
|
requiresEDD
|
|
1576
1574
|
});
|
|
@@ -1586,16 +1584,14 @@ var ComplianceClient = class {
|
|
|
1586
1584
|
};
|
|
1587
1585
|
} catch (error) {
|
|
1588
1586
|
if (this.config.debug) {
|
|
1589
|
-
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
|
+
});
|
|
1590
1591
|
}
|
|
1591
1592
|
throw new ComplianceError(
|
|
1592
1593
|
"Registration verification failed",
|
|
1593
|
-
|
|
1594
|
-
stage: geoVerification ? "profile_creation" : "geo_verification",
|
|
1595
|
-
geoRecordId: geoVerification?.record_id,
|
|
1596
|
-
customerId: request.customerId,
|
|
1597
|
-
cause: error
|
|
1598
|
-
},
|
|
1594
|
+
error instanceof Error ? error.message : void 0,
|
|
1599
1595
|
geoVerification ? "PROFILE_CREATION_FAILED" : "GEO_VERIFICATION_FAILED"
|
|
1600
1596
|
);
|
|
1601
1597
|
}
|
|
@@ -1812,7 +1808,7 @@ var ComplianceClient = class {
|
|
|
1812
1808
|
processingTime: Date.now() - startTime
|
|
1813
1809
|
};
|
|
1814
1810
|
} catch (error) {
|
|
1815
|
-
throw new ComplianceError("Login verification failed", error);
|
|
1811
|
+
throw new ComplianceError("Login verification failed", error instanceof Error ? error.message : void 0);
|
|
1816
1812
|
}
|
|
1817
1813
|
}
|
|
1818
1814
|
/**
|
|
@@ -1891,7 +1887,7 @@ var ComplianceClient = class {
|
|
|
1891
1887
|
processingTime: Date.now() - startTime
|
|
1892
1888
|
};
|
|
1893
1889
|
} catch (error) {
|
|
1894
|
-
throw new ComplianceError("Transaction verification failed", error);
|
|
1890
|
+
throw new ComplianceError("Transaction verification failed", error instanceof Error ? error.message : void 0);
|
|
1895
1891
|
}
|
|
1896
1892
|
}
|
|
1897
1893
|
/**
|
|
@@ -1937,7 +1933,7 @@ var ComplianceClient = class {
|
|
|
1937
1933
|
async createProfileFromGeo(customerId, geoVerification, customerData) {
|
|
1938
1934
|
if (!customerData?.email || !customerData?.fullName) {
|
|
1939
1935
|
this.logger.warn(
|
|
1940
|
-
|
|
1936
|
+
"Creating profile with incomplete data. Profiles should be created during registration with complete customer information."
|
|
1941
1937
|
);
|
|
1942
1938
|
}
|
|
1943
1939
|
return this.riskClient.createProfile({
|
|
@@ -2842,152 +2838,315 @@ var KycClient = class extends BaseClient {
|
|
|
2842
2838
|
// ============================================================================
|
|
2843
2839
|
};
|
|
2844
2840
|
|
|
2845
|
-
// src/
|
|
2846
|
-
var
|
|
2841
|
+
// src/tax/client.ts
|
|
2842
|
+
var TaxClient = class extends BaseClient {
|
|
2843
|
+
constructor(config) {
|
|
2844
|
+
const baseConfig = {
|
|
2845
|
+
baseURL: config.baseURL,
|
|
2846
|
+
tenantId: config.tenantId,
|
|
2847
|
+
apiKey: config.apiKey,
|
|
2848
|
+
headers: config.headers,
|
|
2849
|
+
timeout: config.timeout,
|
|
2850
|
+
retries: 3,
|
|
2851
|
+
debug: config.debug,
|
|
2852
|
+
environment: config.environment
|
|
2853
|
+
};
|
|
2854
|
+
super(baseConfig);
|
|
2855
|
+
}
|
|
2856
|
+
// ============================================================================
|
|
2857
|
+
// Tax Enable / Disable Configuration
|
|
2858
|
+
// ============================================================================
|
|
2847
2859
|
/**
|
|
2848
|
-
*
|
|
2860
|
+
* Get the tax enabled/disabled state for the tenant
|
|
2861
|
+
*
|
|
2862
|
+
* @returns The current tax config (tax_enabled flag)
|
|
2863
|
+
*
|
|
2864
|
+
* @example
|
|
2865
|
+
* ```typescript
|
|
2866
|
+
* const config = await client.getTaxConfig();
|
|
2867
|
+
* console.log(`Tax enabled: ${config.tax_enabled}`);
|
|
2868
|
+
* ```
|
|
2849
2869
|
*/
|
|
2850
|
-
async
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
{ method: "POST", body: JSON.stringify(request) },
|
|
2854
|
-
void 0,
|
|
2855
|
-
void 0,
|
|
2856
|
-
requestOptions
|
|
2857
|
-
);
|
|
2870
|
+
async getTaxConfig() {
|
|
2871
|
+
const res = await this.request("/api/v1/tax/config");
|
|
2872
|
+
return res.tax_config;
|
|
2858
2873
|
}
|
|
2859
2874
|
/**
|
|
2860
|
-
*
|
|
2875
|
+
* Enable or disable tax compliance features for the tenant
|
|
2876
|
+
*
|
|
2877
|
+
* @param request - Object with tax_enabled boolean
|
|
2878
|
+
* @returns Updated tax config
|
|
2879
|
+
*
|
|
2880
|
+
* @example
|
|
2881
|
+
* ```typescript
|
|
2882
|
+
* // Enable tax
|
|
2883
|
+
* const config = await client.updateTaxConfig({ tax_enabled: true });
|
|
2884
|
+
*
|
|
2885
|
+
* // Disable tax
|
|
2886
|
+
* const config = await client.updateTaxConfig({ tax_enabled: false });
|
|
2887
|
+
* ```
|
|
2861
2888
|
*/
|
|
2862
|
-
async
|
|
2863
|
-
const
|
|
2864
|
-
|
|
2865
|
-
|
|
2889
|
+
async updateTaxConfig(request) {
|
|
2890
|
+
const res = await this.request("/api/v1/tax/config", {
|
|
2891
|
+
method: "PUT",
|
|
2892
|
+
body: JSON.stringify({ tax_config: request })
|
|
2866
2893
|
});
|
|
2867
|
-
return
|
|
2868
|
-
`/api/v1/decisions${queryString}`,
|
|
2869
|
-
{ method: "GET" },
|
|
2870
|
-
void 0,
|
|
2871
|
-
void 0,
|
|
2872
|
-
requestOptions
|
|
2873
|
-
);
|
|
2894
|
+
return res.tax_config;
|
|
2874
2895
|
}
|
|
2896
|
+
// ============================================================================
|
|
2897
|
+
// Solicitation Trigger Configuration
|
|
2898
|
+
// ============================================================================
|
|
2875
2899
|
/**
|
|
2876
|
-
* Get
|
|
2900
|
+
* Get solicitation triggers for the tenant
|
|
2901
|
+
*
|
|
2902
|
+
* @returns List of solicitation triggers with their enabled state
|
|
2903
|
+
*
|
|
2904
|
+
* @example
|
|
2905
|
+
* ```typescript
|
|
2906
|
+
* const triggers = await client.getSolicitationTriggers();
|
|
2907
|
+
* triggers.forEach(t => console.log(`${t.label}: ${t.enabled}`));
|
|
2908
|
+
* ```
|
|
2877
2909
|
*/
|
|
2878
|
-
async
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
{ method: "GET" },
|
|
2882
|
-
void 0,
|
|
2883
|
-
void 0,
|
|
2884
|
-
requestOptions
|
|
2910
|
+
async getSolicitationTriggers() {
|
|
2911
|
+
const res = await this.request(
|
|
2912
|
+
"/api/v1/tax/solicitation/config"
|
|
2885
2913
|
);
|
|
2914
|
+
return res.solicitation_triggers;
|
|
2886
2915
|
}
|
|
2887
2916
|
/**
|
|
2888
|
-
*
|
|
2917
|
+
* Update solicitation triggers for the tenant
|
|
2918
|
+
*
|
|
2919
|
+
* @param triggers - Array of triggers with updated enabled/threshold values
|
|
2920
|
+
* @returns Updated triggers
|
|
2921
|
+
*
|
|
2922
|
+
* @example
|
|
2923
|
+
* ```typescript
|
|
2924
|
+
* const triggers = await client.updateSolicitationTriggers([
|
|
2925
|
+
* { type: 'first_withdrawal', enabled: true, label: 'First Withdrawal', description: '...' },
|
|
2926
|
+
* { type: 'threshold_based', enabled: true, label: 'Threshold', description: '...', threshold_amount: 600 },
|
|
2927
|
+
* ]);
|
|
2928
|
+
* ```
|
|
2889
2929
|
*/
|
|
2890
|
-
async
|
|
2891
|
-
|
|
2892
|
-
"/api/v1/
|
|
2893
|
-
{
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2930
|
+
async updateSolicitationTriggers(triggers) {
|
|
2931
|
+
const res = await this.request(
|
|
2932
|
+
"/api/v1/tax/solicitation/config",
|
|
2933
|
+
{
|
|
2934
|
+
method: "PUT",
|
|
2935
|
+
body: JSON.stringify({ solicitation_triggers: triggers })
|
|
2936
|
+
}
|
|
2897
2937
|
);
|
|
2938
|
+
return res.solicitation_triggers;
|
|
2898
2939
|
}
|
|
2940
|
+
// ============================================================================
|
|
2941
|
+
// Reminder Configuration
|
|
2942
|
+
// ============================================================================
|
|
2899
2943
|
/**
|
|
2900
|
-
*
|
|
2944
|
+
* Get the reminder configuration for the tenant
|
|
2945
|
+
*
|
|
2946
|
+
* @returns Reminder config (enabled, max_reminders, frequency_days)
|
|
2947
|
+
*
|
|
2948
|
+
* @example
|
|
2949
|
+
* ```typescript
|
|
2950
|
+
* const config = await client.getReminderConfig();
|
|
2951
|
+
* console.log(`Reminders enabled: ${config.enabled}, every ${config.frequency_days} days`);
|
|
2952
|
+
* ```
|
|
2901
2953
|
*/
|
|
2902
|
-
async
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
{ method: "DELETE" },
|
|
2906
|
-
void 0,
|
|
2907
|
-
void 0,
|
|
2908
|
-
requestOptions
|
|
2954
|
+
async getReminderConfig() {
|
|
2955
|
+
const res = await this.request(
|
|
2956
|
+
"/api/v1/tax/solicitation/reminder-config"
|
|
2909
2957
|
);
|
|
2958
|
+
return res.reminder_config;
|
|
2910
2959
|
}
|
|
2911
2960
|
/**
|
|
2912
|
-
*
|
|
2961
|
+
* Update the reminder configuration for the tenant
|
|
2962
|
+
*
|
|
2963
|
+
* @param config - Reminder configuration to set
|
|
2964
|
+
* @returns Updated reminder config
|
|
2965
|
+
*
|
|
2966
|
+
* @example
|
|
2967
|
+
* ```typescript
|
|
2968
|
+
* const updated = await client.updateReminderConfig({
|
|
2969
|
+
* enabled: true,
|
|
2970
|
+
* max_reminders: 3,
|
|
2971
|
+
* frequency_days: 7,
|
|
2972
|
+
* });
|
|
2973
|
+
* ```
|
|
2913
2974
|
*/
|
|
2914
|
-
async
|
|
2915
|
-
const
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
requestOptions
|
|
2975
|
+
async updateReminderConfig(config) {
|
|
2976
|
+
const res = await this.request(
|
|
2977
|
+
"/api/v1/tax/solicitation/reminder-config",
|
|
2978
|
+
{
|
|
2979
|
+
method: "PUT",
|
|
2980
|
+
body: JSON.stringify({ reminder_config: config })
|
|
2981
|
+
}
|
|
2922
2982
|
);
|
|
2983
|
+
return res.reminder_config;
|
|
2923
2984
|
}
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
//
|
|
2927
|
-
var ScoresClient = class extends BaseClient {
|
|
2985
|
+
// ============================================================================
|
|
2986
|
+
// Tax Forms
|
|
2987
|
+
// ============================================================================
|
|
2928
2988
|
/**
|
|
2929
|
-
*
|
|
2989
|
+
* List tax forms with optional filters and pagination
|
|
2990
|
+
*
|
|
2991
|
+
* @param filters - Optional filters (customer_id, form_type, form_status, etc.)
|
|
2992
|
+
* @returns Paginated list of tax forms
|
|
2993
|
+
*
|
|
2994
|
+
* @example
|
|
2995
|
+
* ```typescript
|
|
2996
|
+
* const result = await client.listTaxForms({ form_type: 'W-9', form_status: 'Pending' });
|
|
2997
|
+
* console.log(`Found ${result.total} forms`);
|
|
2998
|
+
* ```
|
|
2930
2999
|
*/
|
|
2931
|
-
async
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
3000
|
+
async listTaxForms(filters) {
|
|
3001
|
+
const params = {};
|
|
3002
|
+
if (filters) {
|
|
3003
|
+
if (filters.customer_id) params.customer_id = filters.customer_id;
|
|
3004
|
+
if (filters.form_type) params.form_type = filters.form_type;
|
|
3005
|
+
if (filters.form_status) params.form_status = filters.form_status;
|
|
3006
|
+
if (filters.tin_status) params.tin_status = filters.tin_status;
|
|
3007
|
+
if (filters.avalara_company_id) params.avalara_company_id = filters.avalara_company_id;
|
|
3008
|
+
if (filters.search) params.search = filters.search;
|
|
3009
|
+
if (filters.start_date) params.start_date = filters.start_date;
|
|
3010
|
+
if (filters.end_date) params.end_date = filters.end_date;
|
|
3011
|
+
if (filters.page) params.page = filters.page;
|
|
3012
|
+
if (filters.page_size) params.limit = filters.page_size;
|
|
3013
|
+
}
|
|
3014
|
+
return this.request(`/api/v1/tax/forms${this.buildQueryString(params)}`);
|
|
2939
3015
|
}
|
|
2940
3016
|
/**
|
|
2941
|
-
* Get a
|
|
3017
|
+
* Get a tax form by ID
|
|
3018
|
+
*
|
|
3019
|
+
* @param formId - Tax form UUID
|
|
3020
|
+
* @returns Tax form details
|
|
2942
3021
|
*/
|
|
2943
|
-
async
|
|
2944
|
-
return this.
|
|
2945
|
-
`/api/v1/scores/${encodeURIComponent(customerId)}/breakdown`,
|
|
2946
|
-
{ method: "GET" },
|
|
2947
|
-
void 0,
|
|
2948
|
-
void 0,
|
|
2949
|
-
requestOptions
|
|
2950
|
-
);
|
|
3022
|
+
async getTaxForm(formId) {
|
|
3023
|
+
return this.request(`/api/v1/tax/forms/${formId}`);
|
|
2951
3024
|
}
|
|
2952
|
-
};
|
|
2953
|
-
var WorkflowClient = class extends BaseClient {
|
|
2954
3025
|
/**
|
|
2955
|
-
* Get
|
|
3026
|
+
* Get lifecycle events for a tax form
|
|
3027
|
+
*
|
|
3028
|
+
* @param formId - Tax form UUID
|
|
3029
|
+
* @returns List of lifecycle events
|
|
2956
3030
|
*/
|
|
2957
|
-
async
|
|
2958
|
-
|
|
2959
|
-
`/api/v1/
|
|
2960
|
-
{ method: "GET" },
|
|
2961
|
-
void 0,
|
|
2962
|
-
void 0,
|
|
2963
|
-
requestOptions
|
|
3031
|
+
async getTaxFormLifecycleEvents(formId) {
|
|
3032
|
+
const res = await this.request(
|
|
3033
|
+
`/api/v1/tax/forms/${formId}/lifecycle`
|
|
2964
3034
|
);
|
|
3035
|
+
return res.lifecycle_events;
|
|
2965
3036
|
}
|
|
3037
|
+
// ============================================================================
|
|
3038
|
+
// Customer Tax Profile
|
|
3039
|
+
// ============================================================================
|
|
2966
3040
|
/**
|
|
2967
|
-
*
|
|
3041
|
+
* Get the full tax profile for a customer (all forms + lifecycle events)
|
|
3042
|
+
*
|
|
3043
|
+
* @param customerID - Customer ID
|
|
3044
|
+
* @returns Customer tax profile with all forms and events
|
|
3045
|
+
*
|
|
3046
|
+
* @example
|
|
3047
|
+
* ```typescript
|
|
3048
|
+
* const profile = await client.getCustomerTaxProfile('cust_123');
|
|
3049
|
+
* console.log(`Customer has ${profile.tax_forms.length} tax forms`);
|
|
3050
|
+
* ```
|
|
2968
3051
|
*/
|
|
2969
|
-
async
|
|
2970
|
-
|
|
2971
|
-
return this.requestWithRetry(
|
|
2972
|
-
`/api/v1/workflows${queryString}`,
|
|
2973
|
-
{ method: "GET" },
|
|
2974
|
-
void 0,
|
|
2975
|
-
void 0,
|
|
2976
|
-
requestOptions
|
|
2977
|
-
);
|
|
3052
|
+
async getCustomerTaxProfile(customerID) {
|
|
3053
|
+
return this.request(`/api/v1/tax/profile/${customerID}`);
|
|
2978
3054
|
}
|
|
3055
|
+
// ============================================================================
|
|
3056
|
+
// Tax Companies
|
|
3057
|
+
// ============================================================================
|
|
2979
3058
|
/**
|
|
2980
|
-
*
|
|
3059
|
+
* List Avalara tax companies for the tenant
|
|
3060
|
+
*
|
|
3061
|
+
* @param page - Page number (default: 1)
|
|
3062
|
+
* @param pageSize - Items per page (default: 20)
|
|
3063
|
+
* @returns Paginated list of tax companies
|
|
2981
3064
|
*/
|
|
2982
|
-
async
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
requestOptions
|
|
3065
|
+
async listTaxCompanies(page, pageSize) {
|
|
3066
|
+
const params = {};
|
|
3067
|
+
if (page) params.page = page;
|
|
3068
|
+
if (pageSize) params.limit = pageSize;
|
|
3069
|
+
return this.request(
|
|
3070
|
+
`/api/v1/tax/companies${this.buildQueryString(params)}`
|
|
2989
3071
|
);
|
|
2990
3072
|
}
|
|
3073
|
+
/**
|
|
3074
|
+
* Get a tax company by ID
|
|
3075
|
+
*
|
|
3076
|
+
* @param companyId - Tax company UUID
|
|
3077
|
+
* @returns Tax company details
|
|
3078
|
+
*/
|
|
3079
|
+
async getTaxCompany(companyId) {
|
|
3080
|
+
return this.request(`/api/v1/tax/companies/${companyId}`);
|
|
3081
|
+
}
|
|
3082
|
+
// ============================================================================
|
|
3083
|
+
// Utility Methods (inherited from BaseClient: healthCheck, updateConfig, getConfig, buildQueryString)
|
|
3084
|
+
// ============================================================================
|
|
3085
|
+
};
|
|
3086
|
+
|
|
3087
|
+
// src/transaction/client.ts
|
|
3088
|
+
var TransactionClient = class extends BaseClient {
|
|
3089
|
+
constructor(config) {
|
|
3090
|
+
super(config);
|
|
3091
|
+
}
|
|
3092
|
+
// ==========================================================================
|
|
3093
|
+
// Transaction creation
|
|
3094
|
+
// ==========================================================================
|
|
3095
|
+
/**
|
|
3096
|
+
* Submit a new transaction record to the monitoring service.
|
|
3097
|
+
*
|
|
3098
|
+
* The gateway endpoint is `POST /api/v1/tm/transactions` and returns 201
|
|
3099
|
+
* with no body on success. The SDK method resolves to `void` to reflect
|
|
3100
|
+
* that behaviour.
|
|
3101
|
+
*
|
|
3102
|
+
* @param request - Data required to create the transaction
|
|
3103
|
+
* @param requestOptions - Optional request options (e.g. AbortSignal)
|
|
3104
|
+
*
|
|
3105
|
+
* @example
|
|
3106
|
+
* ```ts
|
|
3107
|
+
* const client = new TransactionClient({
|
|
3108
|
+
* baseURL: process.env.API_GATEWAY_URL!,
|
|
3109
|
+
* tenantId: 'tenant-123',
|
|
3110
|
+
* apiKey: 'pk_test_...',
|
|
3111
|
+
* });
|
|
3112
|
+
*
|
|
3113
|
+
* await client.createTransaction({
|
|
3114
|
+
* tx_id: 'tx-1',
|
|
3115
|
+
* reference: 'ref-1',
|
|
3116
|
+
* tenant_id: 'tenant-123',
|
|
3117
|
+
* customer_id: 'cust-1',
|
|
3118
|
+
* transaction_type: 'deposit',
|
|
3119
|
+
* transaction_mode: 'ach',
|
|
3120
|
+
* amount: '100.00',
|
|
3121
|
+
* currency: 'USD',
|
|
3122
|
+
* status: 'pending',
|
|
3123
|
+
* source_account: 'acct-1',
|
|
3124
|
+
* destination_account: 'acct-2',
|
|
3125
|
+
* country: 'US',
|
|
3126
|
+
* ip_address: '10.0.0.1',
|
|
3127
|
+
* metadata: {},
|
|
3128
|
+
* benificiary_comment: '',
|
|
3129
|
+
* transaction_date: new Date().toISOString(),
|
|
3130
|
+
* });
|
|
3131
|
+
* ```
|
|
3132
|
+
*/
|
|
3133
|
+
async createTransaction(request, requestOptions) {
|
|
3134
|
+
const data = await this.requestWithRetry("/api/v1/tm/transactions", {
|
|
3135
|
+
method: "POST",
|
|
3136
|
+
body: JSON.stringify(request)
|
|
3137
|
+
}, void 0, void 0, requestOptions);
|
|
3138
|
+
return data;
|
|
3139
|
+
}
|
|
3140
|
+
/**
|
|
3141
|
+
*
|
|
3142
|
+
* @param transactionId tx_id of the transaction
|
|
3143
|
+
* @param requestOptions optional request options (e.g. AbortSignal)
|
|
3144
|
+
*/
|
|
3145
|
+
async getTransaction(transactionId, requestOptions) {
|
|
3146
|
+
await this.requestWithRetry(`/api/v1/tm/transactions/status/${transactionId}`, {
|
|
3147
|
+
method: "GET"
|
|
3148
|
+
}, void 0, void 0, requestOptions);
|
|
3149
|
+
}
|
|
2991
3150
|
};
|
|
2992
3151
|
|
|
2993
3152
|
// src/webhooks/handler.ts
|
|
@@ -3133,6 +3292,6 @@ function buildHandler(options) {
|
|
|
3133
3292
|
return handler;
|
|
3134
3293
|
}
|
|
3135
3294
|
|
|
3136
|
-
export { AuthenticationError, BaseClient, CGSError, CircuitBreaker, CircuitBreakerOpenError, ComplianceBlockedError, ComplianceClient, ComplianceError, DEFAULT_CURRENCY_RATES,
|
|
3295
|
+
export { AuthenticationError, BaseClient, CGSError, CircuitBreaker, CircuitBreakerOpenError, ComplianceBlockedError, ComplianceClient, ComplianceError, DEFAULT_CURRENCY_RATES, GeolocationClient, KycClient, NetworkError, RateLimitError, RateLimitTracker, RiskProfileClient, SDK_VERSION, ServiceUnavailableError, TaxClient, TimeoutError, TransactionClient, ValidationError, VesantError, WebhookHandler, createConsoleLogger, createNextWebhookHandler, createWebhookMiddleware, decodeCipherText, generateCipherText, isCipherTextExpired, noopLogger, verifyWebhookSignature };
|
|
3137
3296
|
//# sourceMappingURL=index.mjs.map
|
|
3138
3297
|
//# sourceMappingURL=index.mjs.map
|