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.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.2";
|
|
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,15 @@ 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);
|
|
533
|
+
case 409:
|
|
534
|
+
return new VesantError(message, "DUPLICATE_PROFILE", 409);
|
|
535
535
|
case 429: {
|
|
536
536
|
const retryAfter = data.retry_after || data.retryAfter;
|
|
537
537
|
return new RateLimitError(retryAfter);
|
|
@@ -542,7 +542,7 @@ var BaseClient = class {
|
|
|
542
542
|
case 504:
|
|
543
543
|
return new ServiceUnavailableError(message);
|
|
544
544
|
default:
|
|
545
|
-
return new
|
|
545
|
+
return new VesantError(message, "UNKNOWN_ERROR", status);
|
|
546
546
|
}
|
|
547
547
|
};
|
|
548
548
|
const error = createError();
|
|
@@ -1353,8 +1353,8 @@ var RiskProfileClient = class extends BaseClient {
|
|
|
1353
1353
|
requestOptions
|
|
1354
1354
|
);
|
|
1355
1355
|
} catch (error) {
|
|
1356
|
-
if (error instanceof
|
|
1357
|
-
throw new
|
|
1356
|
+
if (error instanceof VesantError && (error.statusCode === 404 || error.code === "NOT_FOUND")) {
|
|
1357
|
+
throw new VesantError("Profile not found", "NOT_FOUND", 404);
|
|
1358
1358
|
}
|
|
1359
1359
|
throw error;
|
|
1360
1360
|
}
|
|
@@ -1404,7 +1404,7 @@ var RiskProfileClient = class extends BaseClient {
|
|
|
1404
1404
|
try {
|
|
1405
1405
|
return await this.getProfile(customerId, requestOptions);
|
|
1406
1406
|
} catch (error) {
|
|
1407
|
-
if (error instanceof
|
|
1407
|
+
if (error instanceof VesantError && error.code === "NOT_FOUND") {
|
|
1408
1408
|
return await this.createProfile(createRequest, requestOptions);
|
|
1409
1409
|
}
|
|
1410
1410
|
throw error;
|
|
@@ -1571,8 +1571,6 @@ var ComplianceClient = class {
|
|
|
1571
1571
|
if (this.config.debug) {
|
|
1572
1572
|
this.logger.debug("Registration verification complete", {
|
|
1573
1573
|
allowed: true,
|
|
1574
|
-
riskScore: geoVerification.risk_score,
|
|
1575
|
-
profileId: profile.id,
|
|
1576
1574
|
requiresKYC,
|
|
1577
1575
|
requiresEDD
|
|
1578
1576
|
});
|
|
@@ -1588,16 +1586,14 @@ var ComplianceClient = class {
|
|
|
1588
1586
|
};
|
|
1589
1587
|
} catch (error) {
|
|
1590
1588
|
if (this.config.debug) {
|
|
1591
|
-
this.logger.error("Registration verification failed", {
|
|
1589
|
+
this.logger.error("Registration verification failed", {
|
|
1590
|
+
code: error instanceof Error ? error.code : void 0,
|
|
1591
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
1592
|
+
});
|
|
1592
1593
|
}
|
|
1593
1594
|
throw new ComplianceError(
|
|
1594
1595
|
"Registration verification failed",
|
|
1595
|
-
|
|
1596
|
-
stage: geoVerification ? "profile_creation" : "geo_verification",
|
|
1597
|
-
geoRecordId: geoVerification?.record_id,
|
|
1598
|
-
customerId: request.customerId,
|
|
1599
|
-
cause: error
|
|
1600
|
-
},
|
|
1596
|
+
error instanceof Error ? error.message : void 0,
|
|
1601
1597
|
geoVerification ? "PROFILE_CREATION_FAILED" : "GEO_VERIFICATION_FAILED"
|
|
1602
1598
|
);
|
|
1603
1599
|
}
|
|
@@ -1814,7 +1810,7 @@ var ComplianceClient = class {
|
|
|
1814
1810
|
processingTime: Date.now() - startTime
|
|
1815
1811
|
};
|
|
1816
1812
|
} catch (error) {
|
|
1817
|
-
throw new ComplianceError("Login verification failed", error);
|
|
1813
|
+
throw new ComplianceError("Login verification failed", error instanceof Error ? error.message : void 0);
|
|
1818
1814
|
}
|
|
1819
1815
|
}
|
|
1820
1816
|
/**
|
|
@@ -1893,7 +1889,7 @@ var ComplianceClient = class {
|
|
|
1893
1889
|
processingTime: Date.now() - startTime
|
|
1894
1890
|
};
|
|
1895
1891
|
} catch (error) {
|
|
1896
|
-
throw new ComplianceError("Transaction verification failed", error);
|
|
1892
|
+
throw new ComplianceError("Transaction verification failed", error instanceof Error ? error.message : void 0);
|
|
1897
1893
|
}
|
|
1898
1894
|
}
|
|
1899
1895
|
/**
|
|
@@ -1939,7 +1935,7 @@ var ComplianceClient = class {
|
|
|
1939
1935
|
async createProfileFromGeo(customerId, geoVerification, customerData) {
|
|
1940
1936
|
if (!customerData?.email || !customerData?.fullName) {
|
|
1941
1937
|
this.logger.warn(
|
|
1942
|
-
|
|
1938
|
+
"Creating profile with incomplete data. Profiles should be created during registration with complete customer information."
|
|
1943
1939
|
);
|
|
1944
1940
|
}
|
|
1945
1941
|
return this.riskClient.createProfile({
|
|
@@ -2844,152 +2840,315 @@ var KycClient = class extends BaseClient {
|
|
|
2844
2840
|
// ============================================================================
|
|
2845
2841
|
};
|
|
2846
2842
|
|
|
2847
|
-
// src/
|
|
2848
|
-
var
|
|
2843
|
+
// src/tax/client.ts
|
|
2844
|
+
var TaxClient = class extends BaseClient {
|
|
2845
|
+
constructor(config) {
|
|
2846
|
+
const baseConfig = {
|
|
2847
|
+
baseURL: config.baseURL,
|
|
2848
|
+
tenantId: config.tenantId,
|
|
2849
|
+
apiKey: config.apiKey,
|
|
2850
|
+
headers: config.headers,
|
|
2851
|
+
timeout: config.timeout,
|
|
2852
|
+
retries: 3,
|
|
2853
|
+
debug: config.debug,
|
|
2854
|
+
environment: config.environment
|
|
2855
|
+
};
|
|
2856
|
+
super(baseConfig);
|
|
2857
|
+
}
|
|
2858
|
+
// ============================================================================
|
|
2859
|
+
// Tax Enable / Disable Configuration
|
|
2860
|
+
// ============================================================================
|
|
2849
2861
|
/**
|
|
2850
|
-
*
|
|
2862
|
+
* Get the tax enabled/disabled state for the tenant
|
|
2863
|
+
*
|
|
2864
|
+
* @returns The current tax config (tax_enabled flag)
|
|
2865
|
+
*
|
|
2866
|
+
* @example
|
|
2867
|
+
* ```typescript
|
|
2868
|
+
* const config = await client.getTaxConfig();
|
|
2869
|
+
* console.log(`Tax enabled: ${config.tax_enabled}`);
|
|
2870
|
+
* ```
|
|
2851
2871
|
*/
|
|
2852
|
-
async
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
{ method: "POST", body: JSON.stringify(request) },
|
|
2856
|
-
void 0,
|
|
2857
|
-
void 0,
|
|
2858
|
-
requestOptions
|
|
2859
|
-
);
|
|
2872
|
+
async getTaxConfig() {
|
|
2873
|
+
const res = await this.request("/api/v1/tax/config");
|
|
2874
|
+
return res.tax_config;
|
|
2860
2875
|
}
|
|
2861
2876
|
/**
|
|
2862
|
-
*
|
|
2877
|
+
* Enable or disable tax compliance features for the tenant
|
|
2878
|
+
*
|
|
2879
|
+
* @param request - Object with tax_enabled boolean
|
|
2880
|
+
* @returns Updated tax config
|
|
2881
|
+
*
|
|
2882
|
+
* @example
|
|
2883
|
+
* ```typescript
|
|
2884
|
+
* // Enable tax
|
|
2885
|
+
* const config = await client.updateTaxConfig({ tax_enabled: true });
|
|
2886
|
+
*
|
|
2887
|
+
* // Disable tax
|
|
2888
|
+
* const config = await client.updateTaxConfig({ tax_enabled: false });
|
|
2889
|
+
* ```
|
|
2863
2890
|
*/
|
|
2864
|
-
async
|
|
2865
|
-
const
|
|
2866
|
-
|
|
2867
|
-
|
|
2891
|
+
async updateTaxConfig(request) {
|
|
2892
|
+
const res = await this.request("/api/v1/tax/config", {
|
|
2893
|
+
method: "PUT",
|
|
2894
|
+
body: JSON.stringify({ tax_config: request })
|
|
2868
2895
|
});
|
|
2869
|
-
return
|
|
2870
|
-
`/api/v1/decisions${queryString}`,
|
|
2871
|
-
{ method: "GET" },
|
|
2872
|
-
void 0,
|
|
2873
|
-
void 0,
|
|
2874
|
-
requestOptions
|
|
2875
|
-
);
|
|
2896
|
+
return res.tax_config;
|
|
2876
2897
|
}
|
|
2898
|
+
// ============================================================================
|
|
2899
|
+
// Solicitation Trigger Configuration
|
|
2900
|
+
// ============================================================================
|
|
2877
2901
|
/**
|
|
2878
|
-
* Get
|
|
2902
|
+
* Get solicitation triggers for the tenant
|
|
2903
|
+
*
|
|
2904
|
+
* @returns List of solicitation triggers with their enabled state
|
|
2905
|
+
*
|
|
2906
|
+
* @example
|
|
2907
|
+
* ```typescript
|
|
2908
|
+
* const triggers = await client.getSolicitationTriggers();
|
|
2909
|
+
* triggers.forEach(t => console.log(`${t.label}: ${t.enabled}`));
|
|
2910
|
+
* ```
|
|
2879
2911
|
*/
|
|
2880
|
-
async
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
{ method: "GET" },
|
|
2884
|
-
void 0,
|
|
2885
|
-
void 0,
|
|
2886
|
-
requestOptions
|
|
2912
|
+
async getSolicitationTriggers() {
|
|
2913
|
+
const res = await this.request(
|
|
2914
|
+
"/api/v1/tax/solicitation/config"
|
|
2887
2915
|
);
|
|
2916
|
+
return res.solicitation_triggers;
|
|
2888
2917
|
}
|
|
2889
2918
|
/**
|
|
2890
|
-
*
|
|
2919
|
+
* Update solicitation triggers for the tenant
|
|
2920
|
+
*
|
|
2921
|
+
* @param triggers - Array of triggers with updated enabled/threshold values
|
|
2922
|
+
* @returns Updated triggers
|
|
2923
|
+
*
|
|
2924
|
+
* @example
|
|
2925
|
+
* ```typescript
|
|
2926
|
+
* const triggers = await client.updateSolicitationTriggers([
|
|
2927
|
+
* { type: 'first_withdrawal', enabled: true, label: 'First Withdrawal', description: '...' },
|
|
2928
|
+
* { type: 'threshold_based', enabled: true, label: 'Threshold', description: '...', threshold_amount: 600 },
|
|
2929
|
+
* ]);
|
|
2930
|
+
* ```
|
|
2891
2931
|
*/
|
|
2892
|
-
async
|
|
2893
|
-
|
|
2894
|
-
"/api/v1/
|
|
2895
|
-
{
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2932
|
+
async updateSolicitationTriggers(triggers) {
|
|
2933
|
+
const res = await this.request(
|
|
2934
|
+
"/api/v1/tax/solicitation/config",
|
|
2935
|
+
{
|
|
2936
|
+
method: "PUT",
|
|
2937
|
+
body: JSON.stringify({ solicitation_triggers: triggers })
|
|
2938
|
+
}
|
|
2899
2939
|
);
|
|
2940
|
+
return res.solicitation_triggers;
|
|
2900
2941
|
}
|
|
2942
|
+
// ============================================================================
|
|
2943
|
+
// Reminder Configuration
|
|
2944
|
+
// ============================================================================
|
|
2901
2945
|
/**
|
|
2902
|
-
*
|
|
2946
|
+
* Get the reminder configuration for the tenant
|
|
2947
|
+
*
|
|
2948
|
+
* @returns Reminder config (enabled, max_reminders, frequency_days)
|
|
2949
|
+
*
|
|
2950
|
+
* @example
|
|
2951
|
+
* ```typescript
|
|
2952
|
+
* const config = await client.getReminderConfig();
|
|
2953
|
+
* console.log(`Reminders enabled: ${config.enabled}, every ${config.frequency_days} days`);
|
|
2954
|
+
* ```
|
|
2903
2955
|
*/
|
|
2904
|
-
async
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
{ method: "DELETE" },
|
|
2908
|
-
void 0,
|
|
2909
|
-
void 0,
|
|
2910
|
-
requestOptions
|
|
2956
|
+
async getReminderConfig() {
|
|
2957
|
+
const res = await this.request(
|
|
2958
|
+
"/api/v1/tax/solicitation/reminder-config"
|
|
2911
2959
|
);
|
|
2960
|
+
return res.reminder_config;
|
|
2912
2961
|
}
|
|
2913
2962
|
/**
|
|
2914
|
-
*
|
|
2963
|
+
* Update the reminder configuration for the tenant
|
|
2964
|
+
*
|
|
2965
|
+
* @param config - Reminder configuration to set
|
|
2966
|
+
* @returns Updated reminder config
|
|
2967
|
+
*
|
|
2968
|
+
* @example
|
|
2969
|
+
* ```typescript
|
|
2970
|
+
* const updated = await client.updateReminderConfig({
|
|
2971
|
+
* enabled: true,
|
|
2972
|
+
* max_reminders: 3,
|
|
2973
|
+
* frequency_days: 7,
|
|
2974
|
+
* });
|
|
2975
|
+
* ```
|
|
2915
2976
|
*/
|
|
2916
|
-
async
|
|
2917
|
-
const
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
requestOptions
|
|
2977
|
+
async updateReminderConfig(config) {
|
|
2978
|
+
const res = await this.request(
|
|
2979
|
+
"/api/v1/tax/solicitation/reminder-config",
|
|
2980
|
+
{
|
|
2981
|
+
method: "PUT",
|
|
2982
|
+
body: JSON.stringify({ reminder_config: config })
|
|
2983
|
+
}
|
|
2924
2984
|
);
|
|
2985
|
+
return res.reminder_config;
|
|
2925
2986
|
}
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
//
|
|
2929
|
-
var ScoresClient = class extends BaseClient {
|
|
2987
|
+
// ============================================================================
|
|
2988
|
+
// Tax Forms
|
|
2989
|
+
// ============================================================================
|
|
2930
2990
|
/**
|
|
2931
|
-
*
|
|
2991
|
+
* List tax forms with optional filters and pagination
|
|
2992
|
+
*
|
|
2993
|
+
* @param filters - Optional filters (customer_id, form_type, form_status, etc.)
|
|
2994
|
+
* @returns Paginated list of tax forms
|
|
2995
|
+
*
|
|
2996
|
+
* @example
|
|
2997
|
+
* ```typescript
|
|
2998
|
+
* const result = await client.listTaxForms({ form_type: 'W-9', form_status: 'Pending' });
|
|
2999
|
+
* console.log(`Found ${result.total} forms`);
|
|
3000
|
+
* ```
|
|
2932
3001
|
*/
|
|
2933
|
-
async
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
3002
|
+
async listTaxForms(filters) {
|
|
3003
|
+
const params = {};
|
|
3004
|
+
if (filters) {
|
|
3005
|
+
if (filters.customer_id) params.customer_id = filters.customer_id;
|
|
3006
|
+
if (filters.form_type) params.form_type = filters.form_type;
|
|
3007
|
+
if (filters.form_status) params.form_status = filters.form_status;
|
|
3008
|
+
if (filters.tin_status) params.tin_status = filters.tin_status;
|
|
3009
|
+
if (filters.avalara_company_id) params.avalara_company_id = filters.avalara_company_id;
|
|
3010
|
+
if (filters.search) params.search = filters.search;
|
|
3011
|
+
if (filters.start_date) params.start_date = filters.start_date;
|
|
3012
|
+
if (filters.end_date) params.end_date = filters.end_date;
|
|
3013
|
+
if (filters.page) params.page = filters.page;
|
|
3014
|
+
if (filters.page_size) params.limit = filters.page_size;
|
|
3015
|
+
}
|
|
3016
|
+
return this.request(`/api/v1/tax/forms${this.buildQueryString(params)}`);
|
|
2941
3017
|
}
|
|
2942
3018
|
/**
|
|
2943
|
-
* Get a
|
|
3019
|
+
* Get a tax form by ID
|
|
3020
|
+
*
|
|
3021
|
+
* @param formId - Tax form UUID
|
|
3022
|
+
* @returns Tax form details
|
|
2944
3023
|
*/
|
|
2945
|
-
async
|
|
2946
|
-
return this.
|
|
2947
|
-
`/api/v1/scores/${encodeURIComponent(customerId)}/breakdown`,
|
|
2948
|
-
{ method: "GET" },
|
|
2949
|
-
void 0,
|
|
2950
|
-
void 0,
|
|
2951
|
-
requestOptions
|
|
2952
|
-
);
|
|
3024
|
+
async getTaxForm(formId) {
|
|
3025
|
+
return this.request(`/api/v1/tax/forms/${formId}`);
|
|
2953
3026
|
}
|
|
2954
|
-
};
|
|
2955
|
-
var WorkflowClient = class extends BaseClient {
|
|
2956
3027
|
/**
|
|
2957
|
-
* Get
|
|
3028
|
+
* Get lifecycle events for a tax form
|
|
3029
|
+
*
|
|
3030
|
+
* @param formId - Tax form UUID
|
|
3031
|
+
* @returns List of lifecycle events
|
|
2958
3032
|
*/
|
|
2959
|
-
async
|
|
2960
|
-
|
|
2961
|
-
`/api/v1/
|
|
2962
|
-
{ method: "GET" },
|
|
2963
|
-
void 0,
|
|
2964
|
-
void 0,
|
|
2965
|
-
requestOptions
|
|
3033
|
+
async getTaxFormLifecycleEvents(formId) {
|
|
3034
|
+
const res = await this.request(
|
|
3035
|
+
`/api/v1/tax/forms/${formId}/lifecycle`
|
|
2966
3036
|
);
|
|
3037
|
+
return res.lifecycle_events;
|
|
2967
3038
|
}
|
|
3039
|
+
// ============================================================================
|
|
3040
|
+
// Customer Tax Profile
|
|
3041
|
+
// ============================================================================
|
|
2968
3042
|
/**
|
|
2969
|
-
*
|
|
3043
|
+
* Get the full tax profile for a customer (all forms + lifecycle events)
|
|
3044
|
+
*
|
|
3045
|
+
* @param customerID - Customer ID
|
|
3046
|
+
* @returns Customer tax profile with all forms and events
|
|
3047
|
+
*
|
|
3048
|
+
* @example
|
|
3049
|
+
* ```typescript
|
|
3050
|
+
* const profile = await client.getCustomerTaxProfile('cust_123');
|
|
3051
|
+
* console.log(`Customer has ${profile.tax_forms.length} tax forms`);
|
|
3052
|
+
* ```
|
|
2970
3053
|
*/
|
|
2971
|
-
async
|
|
2972
|
-
|
|
2973
|
-
return this.requestWithRetry(
|
|
2974
|
-
`/api/v1/workflows${queryString}`,
|
|
2975
|
-
{ method: "GET" },
|
|
2976
|
-
void 0,
|
|
2977
|
-
void 0,
|
|
2978
|
-
requestOptions
|
|
2979
|
-
);
|
|
3054
|
+
async getCustomerTaxProfile(customerID) {
|
|
3055
|
+
return this.request(`/api/v1/tax/profile/${customerID}`);
|
|
2980
3056
|
}
|
|
3057
|
+
// ============================================================================
|
|
3058
|
+
// Tax Companies
|
|
3059
|
+
// ============================================================================
|
|
2981
3060
|
/**
|
|
2982
|
-
*
|
|
3061
|
+
* List Avalara tax companies for the tenant
|
|
3062
|
+
*
|
|
3063
|
+
* @param page - Page number (default: 1)
|
|
3064
|
+
* @param pageSize - Items per page (default: 20)
|
|
3065
|
+
* @returns Paginated list of tax companies
|
|
2983
3066
|
*/
|
|
2984
|
-
async
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
requestOptions
|
|
3067
|
+
async listTaxCompanies(page, pageSize) {
|
|
3068
|
+
const params = {};
|
|
3069
|
+
if (page) params.page = page;
|
|
3070
|
+
if (pageSize) params.limit = pageSize;
|
|
3071
|
+
return this.request(
|
|
3072
|
+
`/api/v1/tax/companies${this.buildQueryString(params)}`
|
|
2991
3073
|
);
|
|
2992
3074
|
}
|
|
3075
|
+
/**
|
|
3076
|
+
* Get a tax company by ID
|
|
3077
|
+
*
|
|
3078
|
+
* @param companyId - Tax company UUID
|
|
3079
|
+
* @returns Tax company details
|
|
3080
|
+
*/
|
|
3081
|
+
async getTaxCompany(companyId) {
|
|
3082
|
+
return this.request(`/api/v1/tax/companies/${companyId}`);
|
|
3083
|
+
}
|
|
3084
|
+
// ============================================================================
|
|
3085
|
+
// Utility Methods (inherited from BaseClient: healthCheck, updateConfig, getConfig, buildQueryString)
|
|
3086
|
+
// ============================================================================
|
|
3087
|
+
};
|
|
3088
|
+
|
|
3089
|
+
// src/transaction/client.ts
|
|
3090
|
+
var TransactionClient = class extends BaseClient {
|
|
3091
|
+
constructor(config) {
|
|
3092
|
+
super(config);
|
|
3093
|
+
}
|
|
3094
|
+
// ==========================================================================
|
|
3095
|
+
// Transaction creation
|
|
3096
|
+
// ==========================================================================
|
|
3097
|
+
/**
|
|
3098
|
+
* Submit a new transaction record to the monitoring service.
|
|
3099
|
+
*
|
|
3100
|
+
* The gateway endpoint is `POST /api/v1/tm/transactions` and returns 201
|
|
3101
|
+
* with no body on success. The SDK method resolves to `void` to reflect
|
|
3102
|
+
* that behaviour.
|
|
3103
|
+
*
|
|
3104
|
+
* @param request - Data required to create the transaction
|
|
3105
|
+
* @param requestOptions - Optional request options (e.g. AbortSignal)
|
|
3106
|
+
*
|
|
3107
|
+
* @example
|
|
3108
|
+
* ```ts
|
|
3109
|
+
* const client = new TransactionClient({
|
|
3110
|
+
* baseURL: process.env.API_GATEWAY_URL!,
|
|
3111
|
+
* tenantId: 'tenant-123',
|
|
3112
|
+
* apiKey: 'pk_test_...',
|
|
3113
|
+
* });
|
|
3114
|
+
*
|
|
3115
|
+
* await client.createTransaction({
|
|
3116
|
+
* tx_id: 'tx-1',
|
|
3117
|
+
* reference: 'ref-1',
|
|
3118
|
+
* tenant_id: 'tenant-123',
|
|
3119
|
+
* customer_id: 'cust-1',
|
|
3120
|
+
* transaction_type: 'deposit',
|
|
3121
|
+
* transaction_mode: 'ach',
|
|
3122
|
+
* amount: '100.00',
|
|
3123
|
+
* currency: 'USD',
|
|
3124
|
+
* status: 'pending',
|
|
3125
|
+
* source_account: 'acct-1',
|
|
3126
|
+
* destination_account: 'acct-2',
|
|
3127
|
+
* country: 'US',
|
|
3128
|
+
* ip_address: '10.0.0.1',
|
|
3129
|
+
* metadata: {},
|
|
3130
|
+
* benificiary_comment: '',
|
|
3131
|
+
* transaction_date: new Date().toISOString(),
|
|
3132
|
+
* });
|
|
3133
|
+
* ```
|
|
3134
|
+
*/
|
|
3135
|
+
async createTransaction(request, requestOptions) {
|
|
3136
|
+
const data = await this.requestWithRetry("/api/v1/tm/transactions", {
|
|
3137
|
+
method: "POST",
|
|
3138
|
+
body: JSON.stringify(request)
|
|
3139
|
+
}, void 0, void 0, requestOptions);
|
|
3140
|
+
return data;
|
|
3141
|
+
}
|
|
3142
|
+
/**
|
|
3143
|
+
*
|
|
3144
|
+
* @param transactionId tx_id of the transaction
|
|
3145
|
+
* @param requestOptions optional request options (e.g. AbortSignal)
|
|
3146
|
+
*/
|
|
3147
|
+
async getTransaction(transactionId, requestOptions) {
|
|
3148
|
+
await this.requestWithRetry(`/api/v1/tm/transactions/status/${transactionId}`, {
|
|
3149
|
+
method: "GET"
|
|
3150
|
+
}, void 0, void 0, requestOptions);
|
|
3151
|
+
}
|
|
2993
3152
|
};
|
|
2994
3153
|
|
|
2995
3154
|
// src/webhooks/handler.ts
|
|
@@ -3144,7 +3303,6 @@ exports.ComplianceBlockedError = ComplianceBlockedError;
|
|
|
3144
3303
|
exports.ComplianceClient = ComplianceClient;
|
|
3145
3304
|
exports.ComplianceError = ComplianceError;
|
|
3146
3305
|
exports.DEFAULT_CURRENCY_RATES = DEFAULT_CURRENCY_RATES;
|
|
3147
|
-
exports.DecisionsClient = DecisionsClient;
|
|
3148
3306
|
exports.GeolocationClient = GeolocationClient;
|
|
3149
3307
|
exports.KycClient = KycClient;
|
|
3150
3308
|
exports.NetworkError = NetworkError;
|
|
@@ -3152,12 +3310,13 @@ exports.RateLimitError = RateLimitError;
|
|
|
3152
3310
|
exports.RateLimitTracker = RateLimitTracker;
|
|
3153
3311
|
exports.RiskProfileClient = RiskProfileClient;
|
|
3154
3312
|
exports.SDK_VERSION = SDK_VERSION;
|
|
3155
|
-
exports.ScoresClient = ScoresClient;
|
|
3156
3313
|
exports.ServiceUnavailableError = ServiceUnavailableError;
|
|
3314
|
+
exports.TaxClient = TaxClient;
|
|
3157
3315
|
exports.TimeoutError = TimeoutError;
|
|
3316
|
+
exports.TransactionClient = TransactionClient;
|
|
3158
3317
|
exports.ValidationError = ValidationError;
|
|
3318
|
+
exports.VesantError = VesantError;
|
|
3159
3319
|
exports.WebhookHandler = WebhookHandler;
|
|
3160
|
-
exports.WorkflowClient = WorkflowClient;
|
|
3161
3320
|
exports.createConsoleLogger = createConsoleLogger;
|
|
3162
3321
|
exports.createNextWebhookHandler = createNextWebhookHandler;
|
|
3163
3322
|
exports.createWebhookMiddleware = createWebhookMiddleware;
|