vesant-sdk 1.6.6 → 2.0.0-dev.40d1c39

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.
Files changed (86) hide show
  1. package/README.md +14 -4
  2. package/dist/client-BJ87_Vv5.d.ts +430 -0
  3. package/dist/{client-ePzhQKp9.d.mts → client-BolQlL5e.d.mts} +1 -1
  4. package/dist/{client-ePzhQKp9.d.ts → client-BolQlL5e.d.ts} +1 -1
  5. package/dist/{client-BlCxjbY2.d.mts → client-Bvp-f05-.d.ts} +7 -7
  6. package/dist/{client-C_A7QLcB.d.ts → client-CIEa7xYG.d.mts} +7 -7
  7. package/dist/client-IAOGCBfm.d.mts +430 -0
  8. package/dist/compliance/index.d.mts +25 -429
  9. package/dist/compliance/index.d.ts +25 -429
  10. package/dist/compliance/index.js +137 -58
  11. package/dist/compliance/index.js.map +1 -1
  12. package/dist/compliance/index.mjs +137 -59
  13. package/dist/compliance/index.mjs.map +1 -1
  14. package/dist/decisions/index.d.mts +2 -2
  15. package/dist/decisions/index.d.ts +2 -2
  16. package/dist/decisions/index.js +1 -1
  17. package/dist/decisions/index.js.map +1 -1
  18. package/dist/decisions/index.mjs +1 -1
  19. package/dist/decisions/index.mjs.map +1 -1
  20. package/dist/geolocation/index.d.mts +4 -4
  21. package/dist/geolocation/index.d.ts +4 -4
  22. package/dist/geolocation/index.js +6 -24
  23. package/dist/geolocation/index.js.map +1 -1
  24. package/dist/geolocation/index.mjs +6 -24
  25. package/dist/geolocation/index.mjs.map +1 -1
  26. package/dist/index.d.mts +14 -71
  27. package/dist/index.d.ts +14 -71
  28. package/dist/index.js +190 -237
  29. package/dist/index.js.map +1 -1
  30. package/dist/index.mjs +189 -236
  31. package/dist/index.mjs.map +1 -1
  32. package/dist/kyc/core.d.mts +4 -4
  33. package/dist/kyc/core.d.ts +4 -4
  34. package/dist/kyc/core.js +24 -13
  35. package/dist/kyc/core.js.map +1 -1
  36. package/dist/kyc/core.mjs +24 -14
  37. package/dist/kyc/core.mjs.map +1 -1
  38. package/dist/kyc/index.d.mts +20 -27
  39. package/dist/kyc/index.d.ts +20 -27
  40. package/dist/kyc/index.js +24 -13
  41. package/dist/kyc/index.js.map +1 -1
  42. package/dist/kyc/index.mjs +24 -14
  43. package/dist/kyc/index.mjs.map +1 -1
  44. package/dist/react.d.mts +6 -6
  45. package/dist/react.d.ts +6 -6
  46. package/dist/react.js +18 -5
  47. package/dist/react.js.map +1 -1
  48. package/dist/react.mjs +18 -5
  49. package/dist/react.mjs.map +1 -1
  50. package/dist/risk-profile/index.d.mts +4 -4
  51. package/dist/risk-profile/index.d.ts +4 -4
  52. package/dist/risk-profile/index.js +1 -1
  53. package/dist/risk-profile/index.js.map +1 -1
  54. package/dist/risk-profile/index.mjs +1 -1
  55. package/dist/risk-profile/index.mjs.map +1 -1
  56. package/dist/scores/index.d.mts +2 -2
  57. package/dist/scores/index.d.ts +2 -2
  58. package/dist/scores/index.js +1 -1
  59. package/dist/scores/index.js.map +1 -1
  60. package/dist/scores/index.mjs +1 -1
  61. package/dist/scores/index.mjs.map +1 -1
  62. package/dist/tax/index.d.mts +6 -41
  63. package/dist/tax/index.d.ts +6 -41
  64. package/dist/tax/index.js +1 -36
  65. package/dist/tax/index.js.map +1 -1
  66. package/dist/tax/index.mjs +1 -36
  67. package/dist/tax/index.mjs.map +1 -1
  68. package/dist/{types-X5Md_dD_.d.ts → types-2utj53GK.d.ts} +2 -2
  69. package/dist/{types-1RzYeSal.d.mts → types-C4Zx0d_u.d.mts} +2 -2
  70. package/dist/{types-B4Ezqo7V.d.mts → types-QUCWam16.d.mts} +7 -1
  71. package/dist/{types-B4Ezqo7V.d.ts → types-QUCWam16.d.ts} +7 -1
  72. package/dist/webhooks/index.d.mts +181 -2
  73. package/dist/webhooks/index.d.ts +181 -2
  74. package/dist/webhooks/index.js +49 -7
  75. package/dist/webhooks/index.js.map +1 -1
  76. package/dist/webhooks/index.mjs +49 -7
  77. package/dist/webhooks/index.mjs.map +1 -1
  78. package/package.json +16 -13
  79. package/dist/fraud/index.d.mts +0 -80
  80. package/dist/fraud/index.d.ts +0 -80
  81. package/dist/fraud/index.js +0 -606
  82. package/dist/fraud/index.js.map +0 -1
  83. package/dist/fraud/index.mjs +0 -604
  84. package/dist/fraud/index.mjs.map +0 -1
  85. package/dist/index-B04H4xfJ.d.mts +0 -320
  86. package/dist/index-CItMPmLL.d.ts +0 -320
@@ -1,4 +1,4 @@
1
- import { B as BaseClient, R as RequestOptions } from '../client-ePzhQKp9.js';
1
+ import { B as BaseClient, R as RequestOptions } from '../client-BolQlL5e.js';
2
2
 
3
3
  /**
4
4
  * TypeScript type definitions for Vesant Tax Service API
@@ -49,14 +49,6 @@ interface CustomerTaxProfileRecord {
49
49
  backup_withholding: boolean;
50
50
  b_notice_received: boolean;
51
51
  e_delivery_consent: boolean;
52
- /** B-Notice lifecycle stage. 'none' until IRS issues a CP2100. */
53
- b_notice_stage: 'none' | 'first' | 'second';
54
- b_notice_sent_at?: string;
55
- b_notice_second_sent_at?: string;
56
- /** ISO date the CP2100 notice was received from the IRS. */
57
- cp2100_received_at?: string;
58
- /** Set when the customer is flagged for fraud or tax non-compliance. */
59
- b_notice_flag_reason?: 'fraud' | 'tax_non_compliance';
60
52
  withholding_enabled_by?: string;
61
53
  withholding_enabled_at?: string;
62
54
  tin_due_date?: string;
@@ -70,16 +62,16 @@ interface CustomerTaxProfileRecord {
70
62
  /**
71
63
  * Input for POST /api/v1/tax/customer-tax-profiles/{id}/re-request-form
72
64
  */
73
- interface CustomerTaxProfileDocuments {
74
- w_form: string;
75
- '1099_form': string;
76
- }
77
65
  interface ReRequestTaxFormInput {
78
66
  /** Customer email address — required */
79
67
  email: string;
80
68
  /** Customer full name — optional */
81
69
  name?: string;
82
70
  }
71
+ interface CustomerTaxProfileDocuments {
72
+ w_form: string;
73
+ '1099_form': string;
74
+ }
83
75
  /**
84
76
  * Input for POST /api/v1/tax/customer-tax-profiles/{id}/enable-withholding
85
77
  */
@@ -247,23 +239,6 @@ interface TaxClientConfig {
247
239
  debug?: boolean;
248
240
  environment?: 'production' | 'sandbox';
249
241
  }
250
- interface RunRemindersResponse {
251
- tenant_id: string;
252
- sent_count: number;
253
- skipped_count: number;
254
- error_count: number;
255
- }
256
- /**
257
- * Input for TaxClient.updateReminderConfig().
258
- * Only updates reminder-specific fields; all other tax rule settings are preserved.
259
- * Caller must be authenticated as a Tenant Super Admin.
260
- */
261
- interface UpdateReminderConfigInput {
262
- /** Days between reminders. Must be >= 7. */
263
- reminder_frequency_days: number;
264
- /** Max reminders per customer before stopping. Must be > 0. */
265
- reminder_max_count: number;
266
- }
267
242
 
268
243
  declare class TaxClient extends BaseClient {
269
244
  constructor(config: TaxClientConfig);
@@ -274,16 +249,6 @@ declare class TaxClient extends BaseClient {
274
249
  enableBackupWithholding(customerID: string, input: EnableWithholdingInput): Promise<EnableWithholdingResponse>;
275
250
  getCustomerDocuments(customerID: string): Promise<CustomerTaxProfileDocuments>;
276
251
  downloadTaxForm(customerID: string, requestOptions?: RequestOptions): Promise<ArrayBuffer>;
277
- runReminders(): Promise<RunRemindersResponse>;
278
- /**
279
- * Update only the reminder configuration (frequency + max count) without
280
- * touching any other tax rule settings. Fetches current rules first and
281
- * merges the reminder fields before sending the update.
282
- *
283
- * Requires the caller to be authenticated as a Tenant Super Admin.
284
- * Throws VesantError with status 403 if the role requirement is not met.
285
- */
286
- updateReminderConfig(input: UpdateReminderConfigInput): Promise<TaxRuleVersion>;
287
252
  getTaxRules(): Promise<TaxRules>;
288
253
  updateTaxRules(input: UpdateTaxRulesInput): Promise<TaxRuleVersion>;
289
254
  getComplianceStats(filters?: ComplianceStatsFilters): Promise<ComplianceStats>;
@@ -292,4 +257,4 @@ declare class TaxClient extends BaseClient {
292
257
  getTreatyCountry(code: string): Promise<TreatyCountry>;
293
258
  }
294
259
 
295
- export { type CTPFormStatus, type CTPTINStatus, type ComplianceStats, type ComplianceStatsFilters, type CustomerTaxProfileDocuments, type CustomerTaxProfileRecord, type CustomerType, type DocumentRequestBreakdown, type EmailSendingMethod, type EnableWithholdingInput, type EnableWithholdingResponse, type GlobalTaxRule, type ReRequestTaxFormInput, type RunRemindersResponse, type TINCheckResult, type TINStatusBreakdown, TaxClient, type TaxClientConfig, type TaxRuleApprovalStatus, type TaxRuleVersion, type TaxRules, type TransactionAction, type TreatyCountry, type TreatyCountryListResponse, type UpdateReminderConfigInput, type UpdateTaxRulesInput, type WFormCountBreakdown, type WFormStatusBreakdown };
260
+ export { type CTPFormStatus, type CTPTINStatus, type ComplianceStats, type ComplianceStatsFilters, type CustomerTaxProfileDocuments, type CustomerTaxProfileRecord, type CustomerType, type DocumentRequestBreakdown, type EmailSendingMethod, type EnableWithholdingInput, type EnableWithholdingResponse, type GlobalTaxRule, type ReRequestTaxFormInput, type TINCheckResult, type TINStatusBreakdown, TaxClient, type TaxClientConfig, type TaxRuleApprovalStatus, type TaxRuleVersion, type TaxRules, type TransactionAction, type TreatyCountry, type TreatyCountryListResponse, type UpdateTaxRulesInput, type WFormCountBreakdown, type WFormStatusBreakdown };
package/dist/tax/index.js CHANGED
@@ -216,7 +216,7 @@ function createConsoleLogger() {
216
216
  }
217
217
 
218
218
  // src/core/version.ts
219
- var SDK_VERSION = "1.6.6";
219
+ var SDK_VERSION = "2.0.0";
220
220
 
221
221
  // src/shared/browser-utils.ts
222
222
  function generateUUID() {
@@ -609,41 +609,6 @@ var TaxClient = class extends BaseClient {
609
609
  { ...requestOptions, responseType: "arraybuffer" }
610
610
  );
611
611
  }
612
- async runReminders() {
613
- return this.request("/api/v1/tax/reminders/run", {
614
- method: "POST"
615
- });
616
- }
617
- /**
618
- * Update only the reminder configuration (frequency + max count) without
619
- * touching any other tax rule settings. Fetches current rules first and
620
- * merges the reminder fields before sending the update.
621
- *
622
- * Requires the caller to be authenticated as a Tenant Super Admin.
623
- * Throws VesantError with status 403 if the role requirement is not met.
624
- */
625
- async updateReminderConfig(input) {
626
- const current = await this.getTaxRules();
627
- return this.updateTaxRules({
628
- trigger_account_creation: current.trigger_account_creation,
629
- trigger_first_withdrawal: current.trigger_first_withdrawal,
630
- trigger_threshold: current.trigger_threshold,
631
- trigger_manual: current.trigger_manual,
632
- trigger_tin_invalid: current.trigger_tin_invalid,
633
- trigger_w8ben_expiry: current.trigger_w8ben_expiry,
634
- trigger_tin_expired: current.trigger_tin_expired,
635
- us_withholding_enabled: current.us_withholding_enabled,
636
- non_us_withholding_enabled: current.non_us_withholding_enabled,
637
- transaction_action: current.transaction_action,
638
- w8ben_expiry_warning_days: current.w8ben_expiry_warning_days,
639
- tin_verification_due_date: current.tin_verification_due_date,
640
- email_sending_method: current.email_sending_method,
641
- display_tin_links_on_platform: current.display_tin_links_on_platform,
642
- tax_treaty_support: current.tax_treaty_support,
643
- reminder_frequency_days: input.reminder_frequency_days,
644
- reminder_max_count: input.reminder_max_count
645
- });
646
- }
647
612
  // ==========================================================================
648
613
  // P2 — Tenant Tax Rules
649
614
  // ==========================================================================
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/errors.ts","../../src/core/circuit-breaker.ts","../../src/core/rate-limiter.ts","../../src/core/logger.ts","../../src/core/version.ts","../../src/shared/browser-utils.ts","../../src/core/client.ts","../../src/tax/client.ts"],"names":[],"mappings":";;;AAOO,IAAM,WAAA,GAAN,MAAM,YAAA,SAAoB,KAAA,CAAM;AAAA,EAGrC,WAAA,CACE,OAAA,EACO,IAAA,EACA,UAAA,EACA,OAAA,EACP;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAJN,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAAA,CAAA,UAAA,GAAA,UAAA;AACA,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAGP,IAAA,IAAA,CAAK,IAAA,GAAO,aAAA;AACZ,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,YAAA,CAAY,SAAS,CAAA;AAAA,EACnD;AACF,CAAA;AAOO,IAAM,YAAA,GAAN,MA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D,IAAA,IAAI,OAAA,EAAS,OAAA,EAAS,MAAA,CAAO,OAAA,GAAU,OAAA,CAAQ,OAAA;AAC/C,IAAA,OAAO,IAAA,CAAK,OAAA;AAAA,MACV,CAAA,sCAAA,EAAyC,IAAA,CAAK,gBAAA,CAAiB,MAAM,CAAC,CAAA;AAAA,KACxE;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,uBAAA,GAAkD;AACtD,IAAA,MAAM,GAAA,GAAM,MAAM,IAAA,CAAK,OAAA;AAAA,MACrB;AAAA,KACF;AACA,IAAA,OAAO,GAAA,CAAI,IAAA;AAAA,EACb;AAAA,EAEA,MAAM,mBAAA,GAA0D;AAC9D,IAAA,OAAO,IAAA,CAAK,QAAmC,8BAA8B,CAAA;AAAA,EAC/E;AAAA,EAEA,MAAM,iBAAiB,IAAA,EAAsC;AAC3D,IAAA,MAAM,GAAA,GAAM,MAAM,IAAA,CAAK,OAAA;AAAA,MACrB,CAAA,6BAAA,EAAgC,kBAAA,CAAmB,IAAI,CAAC,CAAA;AAAA,KAC1D;AACA,IAAA,OAAO,GAAA,CAAI,cAAA;AAAA,EACb;AACF","file":"index.js","sourcesContent":["/**\n * Error hierarchy for Vesant SDK\n *\n * Provides structured error handling with specific error types\n * for different failure scenarios.\n */\n\nexport class VesantError extends Error {\n public requestId?: string;\n\n constructor(\n message: string,\n public code: string,\n public statusCode?: number,\n public details?: Record<string, unknown>\n ) {\n super(message);\n this.name = 'VesantError';\n Object.setPrototypeOf(this, VesantError.prototype);\n }\n}\n\n/** @deprecated Use VesantError instead */\nexport const CGSError = VesantError;\n/** @deprecated Use VesantError instead */\nexport type CGSError = VesantError;\n\nexport class NetworkError extends VesantError {\n constructor(message: string, public originalError?: unknown) {\n super(message, 'NETWORK_ERROR');\n this.name = 'NetworkError';\n Object.setPrototypeOf(this, NetworkError.prototype);\n }\n}\n\nexport class ValidationError extends VesantError {\n constructor(message: string, fields?: string[]) {\n super(message, 'VALIDATION_ERROR', 400, { fields });\n this.name = 'ValidationError';\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\nexport class ServiceUnavailableError extends VesantError {\n constructor(message: string = 'Service unavailable') {\n super(message, 'SERVICE_UNAVAILABLE', 503);\n this.name = 'ServiceUnavailableError';\n Object.setPrototypeOf(this, ServiceUnavailableError.prototype);\n }\n}\n\nexport class ComplianceBlockedError extends VesantError {\n constructor(reasons: string[]) {\n super('Access blocked due to compliance rules', 'COMPLIANCE_BLOCKED', 403, { reasons });\n this.name = 'ComplianceBlockedError';\n Object.setPrototypeOf(this, ComplianceBlockedError.prototype);\n }\n}\n\nexport class AuthenticationError extends VesantError {\n constructor(message: string = 'Authentication failed') {\n super(message, 'AUTHENTICATION_ERROR', 401);\n this.name = 'AuthenticationError';\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\nexport class RateLimitError extends VesantError {\n constructor(public retryAfter?: number) {\n super('Rate limit exceeded', 'RATE_LIMIT_EXCEEDED', 429, { retryAfter });\n this.name = 'RateLimitError';\n Object.setPrototypeOf(this, RateLimitError.prototype);\n }\n}\n\nexport class TimeoutError extends VesantError {\n constructor(public timeout: number) {\n super(`Request timeout after ${timeout}ms`, 'TIMEOUT', 408, { timeout });\n this.name = 'TimeoutError';\n Object.setPrototypeOf(this, TimeoutError.prototype);\n }\n}\n\nexport class ComplianceError extends VesantError {\n constructor(\n message: string,\n public originalError?: unknown,\n code: string = 'COMPLIANCE_ERROR'\n ) {\n super(message, code);\n this.name = 'ComplianceError';\n Object.setPrototypeOf(this, ComplianceError.prototype);\n }\n}\n\nexport class CircuitBreakerOpenError extends VesantError {\n constructor() {\n super('Circuit breaker is open — requests are temporarily blocked', 'CIRCUIT_BREAKER_OPEN', 503);\n this.name = 'CircuitBreakerOpenError';\n Object.setPrototypeOf(this, CircuitBreakerOpenError.prototype);\n }\n}\n","/**\n * Circuit breaker pattern for resilient HTTP requests.\n *\n * States: closed (normal) -> open (failing) -> half-open (testing) -> closed\n */\n\nexport type CircuitBreakerState = 'closed' | 'open' | 'half-open';\n\nexport interface CircuitBreakerConfig {\n /** Number of consecutive failures before opening the circuit (default: 5) */\n failureThreshold?: number;\n /** Time in ms to wait before transitioning from open to half-open (default: 30000) */\n resetTimeout?: number;\n /** Number of successes in half-open state before closing (default: 1) */\n successThreshold?: number;\n}\n\nexport interface CircuitBreakerStatus {\n state: CircuitBreakerState;\n failures: number;\n successes: number;\n lastFailureTime: number | null;\n nextRetryTime: number | null;\n}\n\nexport class CircuitBreaker {\n private state: CircuitBreakerState = 'closed';\n private failures = 0;\n private successes = 0;\n private lastFailureTime: number | null = null;\n\n private readonly failureThreshold: number;\n private readonly resetTimeout: number;\n private readonly successThreshold: number;\n\n constructor(config: CircuitBreakerConfig = {}) {\n this.failureThreshold = config.failureThreshold ?? 5;\n this.resetTimeout = config.resetTimeout ?? 30000;\n this.successThreshold = config.successThreshold ?? 1;\n }\n\n /**\n * Check if a request can proceed through the circuit breaker.\n */\n canExecute(): boolean {\n if (this.state === 'closed') {\n return true;\n }\n\n if (this.state === 'open') {\n const now = Date.now();\n if (this.lastFailureTime && now - this.lastFailureTime >= this.resetTimeout) {\n this.state = 'half-open';\n this.successes = 0;\n return true;\n }\n return false;\n }\n\n // half-open: allow requests through for testing\n return true;\n }\n\n /**\n * Record a successful request.\n */\n onSuccess(): void {\n if (this.state === 'half-open') {\n this.successes++;\n if (this.successes >= this.successThreshold) {\n this.state = 'closed';\n this.failures = 0;\n this.successes = 0;\n this.lastFailureTime = null;\n }\n } else if (this.state === 'closed') {\n this.failures = 0;\n }\n }\n\n /**\n * Record a failed request.\n */\n onFailure(): void {\n this.failures++;\n this.lastFailureTime = Date.now();\n\n if (this.state === 'half-open') {\n this.state = 'open';\n this.successes = 0;\n } else if (this.state === 'closed' && this.failures >= this.failureThreshold) {\n this.state = 'open';\n }\n }\n\n /**\n * Get current circuit breaker status.\n */\n getStatus(): CircuitBreakerStatus {\n return {\n state: this.state,\n failures: this.failures,\n successes: this.successes,\n lastFailureTime: this.lastFailureTime,\n nextRetryTime:\n this.state === 'open' && this.lastFailureTime\n ? this.lastFailureTime + this.resetTimeout\n : null,\n };\n }\n\n /**\n * Reset the circuit breaker to its initial closed state.\n */\n reset(): void {\n this.state = 'closed';\n this.failures = 0;\n this.successes = 0;\n this.lastFailureTime = null;\n }\n}\n","/**\n * Rate limit tracking from API response headers.\n *\n * Tracks X-RateLimit-* headers to enable pre-flight checks\n * before making requests.\n */\n\nexport interface RateLimitStatus {\n /** Maximum requests allowed in the window */\n limit: number | null;\n /** Remaining requests in the current window */\n remaining: number | null;\n /** Unix timestamp (seconds) when the rate limit resets */\n reset: number | null;\n /** Seconds until the rate limit resets */\n retryAfter: number | null;\n}\n\nexport class RateLimitTracker {\n private limit: number | null = null;\n private remaining: number | null = null;\n private reset: number | null = null;\n private retryAfter: number | null = null;\n\n /**\n * Extract rate limit information from response headers.\n */\n updateFromHeaders(headers: Headers): void {\n const limit = headers.get('x-ratelimit-limit');\n const remaining = headers.get('x-ratelimit-remaining');\n const reset = headers.get('x-ratelimit-reset');\n const retryAfter = headers.get('retry-after');\n\n if (limit !== null) this.limit = parseInt(limit, 10);\n if (remaining !== null) this.remaining = parseInt(remaining, 10);\n if (reset !== null) this.reset = parseInt(reset, 10);\n if (retryAfter !== null) this.retryAfter = parseInt(retryAfter, 10);\n }\n\n /**\n * Check if the rate limit has been exceeded based on tracked headers.\n */\n isLimitExceeded(): boolean {\n if (this.remaining !== null && this.remaining <= 0) {\n // Check if the reset time has passed\n if (this.reset !== null) {\n const now = Math.floor(Date.now() / 1000);\n if (now >= this.reset) {\n // Reset window has passed, allow requests\n this.remaining = null;\n this.reset = null;\n this.retryAfter = null;\n return false;\n }\n }\n return true;\n }\n return false;\n }\n\n /**\n * Get current rate limit status.\n */\n getStatus(): RateLimitStatus {\n return {\n limit: this.limit,\n remaining: this.remaining,\n reset: this.reset,\n retryAfter: this.retryAfter,\n };\n }\n}\n","import type { Logger } from './config';\n\nexport function createConsoleLogger(): Logger {\n return {\n debug(message: string, meta?: Record<string, unknown>) {\n console.log(`[Vesant SDK] ${message}`, meta !== undefined ? meta : '');\n },\n info(message: string, meta?: Record<string, unknown>) {\n console.info(`[Vesant SDK] ${message}`, meta !== undefined ? meta : '');\n },\n warn(message: string, meta?: Record<string, unknown>) {\n console.warn(`[Vesant SDK] ${message}`, meta !== undefined ? meta : '');\n },\n error(message: string, meta?: Record<string, unknown>) {\n console.error(`[Vesant SDK] ${message}`, meta !== undefined ? meta : '');\n },\n };\n}\n\nexport const noopLogger: Logger = {\n debug() {},\n info() {},\n warn() {},\n error() {},\n};\n","/**\n * Single source of truth for the SDK version.\n */\nexport const SDK_VERSION = '1.6.6';\n","/**\n * Shared browser utility functions.\n *\n * Extracted from ciphertext.ts and hooks.ts to avoid duplication.\n * All functions include SSR guards for safe server-side rendering.\n */\n\n/**\n * Generate a UUID v4\n */\nexport function generateUUID(): string {\n if (typeof crypto !== 'undefined' && crypto.randomUUID) {\n return crypto.randomUUID();\n }\n\n // Fallback for older browsers\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n\n/**\n * Generate a unique device ID that persists across sessions.\n * Falls back to a random UUID when localStorage is unavailable (SSR).\n */\nexport function generateDeviceId(): string {\n if (typeof window === 'undefined' || typeof localStorage === 'undefined') {\n return generateUUID();\n }\n\n const storageKey = 'vesant_device_id';\n let deviceId = localStorage.getItem(storageKey);\n\n if (!deviceId) {\n deviceId = generateUUID();\n localStorage.setItem(storageKey, deviceId);\n }\n\n return deviceId;\n}\n\n/**\n * Detect browser information from user agent.\n * Returns safe defaults when running server-side.\n */\nexport function getBrowserInfo(): {\n browser: string;\n browser_version: string;\n os: string;\n os_version: string;\n} {\n if (typeof navigator === 'undefined') {\n return { browser: 'unknown', browser_version: '', os: 'unknown', os_version: '' };\n }\n\n const ua = navigator.userAgent;\n let browser = 'unknown';\n let browserVersion = '';\n let os = 'unknown';\n let osVersion = '';\n\n // Detect browser\n if (ua.includes('Firefox/')) {\n browser = 'Firefox';\n browserVersion = ua.match(/Firefox\\/([\\d.]+)/)?.[1] || '';\n } else if (ua.includes('Edg/')) {\n browser = 'Edge';\n browserVersion = ua.match(/Edg\\/([\\d.]+)/)?.[1] || '';\n } else if (ua.includes('Chrome/')) {\n browser = 'Chrome';\n browserVersion = ua.match(/Chrome\\/([\\d.]+)/)?.[1] || '';\n } else if (ua.includes('Safari/') && !ua.includes('Chrome')) {\n browser = 'Safari';\n browserVersion = ua.match(/Version\\/([\\d.]+)/)?.[1] || '';\n } else if (ua.includes('Opera') || ua.includes('OPR/')) {\n browser = 'Opera';\n browserVersion = ua.match(/(?:Opera|OPR)\\/([\\d.]+)/)?.[1] || '';\n }\n\n // Detect OS\n if (ua.includes('Windows')) {\n os = 'Windows';\n if (ua.includes('Windows NT 10.0')) osVersion = '10';\n else if (ua.includes('Windows NT 6.3')) osVersion = '8.1';\n else if (ua.includes('Windows NT 6.2')) osVersion = '8';\n else if (ua.includes('Windows NT 6.1')) osVersion = '7';\n } else if (ua.includes('Mac OS X')) {\n os = 'macOS';\n osVersion = ua.match(/Mac OS X ([\\d_]+)/)?.[1]?.replace(/_/g, '.') || '';\n } else if (ua.includes('Linux')) {\n os = 'Linux';\n } else if (ua.includes('Android')) {\n os = 'Android';\n osVersion = ua.match(/Android ([\\d.]+)/)?.[1] || '';\n } else if (ua.includes('iOS') || ua.includes('iPhone') || ua.includes('iPad')) {\n os = 'iOS';\n osVersion = ua.match(/OS ([\\d_]+)/)?.[1]?.replace(/_/g, '.') || '';\n }\n\n return { browser, browser_version: browserVersion, os, os_version: osVersion };\n}\n","/**\n * Base HTTP client for all Vesant SDK clients\n *\n * Provides common functionality:\n * - Request/response handling\n * - Error handling\n * - Retry logic with exponential backoff\n * - Timeout management\n * - Debug logging\n */\n\nimport type { BaseClientConfig, Logger, RequestInterceptor, RequestOptions } from './config';\nimport {\n VesantError,\n NetworkError,\n TimeoutError,\n AuthenticationError,\n RateLimitError,\n ServiceUnavailableError,\n ValidationError,\n CircuitBreakerOpenError,\n} from './errors';\nimport { CircuitBreaker, type CircuitBreakerStatus } from './circuit-breaker';\nimport { RateLimitTracker, type RateLimitStatus } from './rate-limiter';\nimport { createConsoleLogger } from './logger';\nimport { SDK_VERSION } from './version';\nimport { generateUUID } from '../shared/browser-utils';\n\nexport abstract class BaseClient {\n protected config: BaseClientConfig & { timeout: number; retries: number };\n protected logger: Logger;\n private interceptors: RequestInterceptor[];\n private circuitBreaker: CircuitBreaker | null = null;\n private rateLimitTracker: RateLimitTracker | null = null;\n\n constructor(config: BaseClientConfig) {\n if (!config.baseURL?.trim()) {\n throw new ValidationError('baseURL is required and must be a non-empty string', ['baseURL']);\n }\n if (!config.tenantId?.trim()) {\n throw new ValidationError('tenantId is required and must be a non-empty string', ['tenantId']);\n }\n\n this.interceptors = config.interceptors || [];\n this.logger = config.logger || createConsoleLogger();\n\n // Auto-detect environment from API key prefix\n let environment = config.environment;\n const apiKey = config.apiKey || '';\n if (apiKey.startsWith('pk_test_')) {\n if (environment === 'production') {\n this.logger.warn('Sandbox API key (pk_test_*) used with environment: \"production\" — overriding to \"sandbox\"');\n }\n environment = 'sandbox';\n } else if (apiKey.startsWith('pk_live_') && environment === 'sandbox') {\n this.logger.warn('Production API key (pk_live_*) used with environment: \"sandbox\" — sandbox isolation will still be applied for backward compatibility');\n }\n\n this.config = {\n ...config,\n apiKey,\n environment,\n headers: config.headers || {},\n timeout: config.timeout || 10000,\n retries: config.retries || 3,\n debug: config.debug || false,\n interceptors: this.interceptors,\n logger: this.logger,\n };\n\n if (config.circuitBreaker) {\n this.circuitBreaker = new CircuitBreaker(config.circuitBreaker);\n }\n if (config.enableRateLimitTracking) {\n this.rateLimitTracker = new RateLimitTracker();\n }\n }\n\n /**\n * Make an HTTP request with timeout and error handling\n */\n protected async request<T>(\n endpoint: string,\n options: RequestInit = {},\n serviceURL?: string,\n requestOptions?: RequestOptions\n ): Promise<T> {\n const requestId = generateUUID();\n\n // Circuit breaker check\n if (this.circuitBreaker && !this.circuitBreaker.canExecute()) {\n const error = new CircuitBreakerOpenError();\n error.requestId = requestId;\n throw error;\n }\n\n // Rate limit pre-check\n if (this.rateLimitTracker && this.rateLimitTracker.isLimitExceeded()) {\n const status = this.rateLimitTracker.getStatus();\n const error = new RateLimitError(status.retryAfter ?? undefined);\n error.requestId = requestId;\n throw error;\n }\n\n const url = `${serviceURL || this.config.baseURL}${endpoint}`;\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-Tenant-ID': this.config.tenantId,\n 'X-SDK-Version': `vesant-sdk-ts/${SDK_VERSION}`,\n 'X-Request-ID': requestId,\n ...this.config.headers,\n ...((options.headers as Record<string, string>) || {}),\n };\n\n if (this.config.apiKey) {\n headers['Authorization'] = `Bearer ${this.config.apiKey}`;\n }\n\n // Sandbox header\n if (this.config.environment === 'sandbox') {\n headers['X-Sandbox'] = 'true';\n }\n\n // Idempotency key for mutating methods\n const method = (options.method || 'GET').toUpperCase();\n if (['POST', 'PUT', 'PATCH'].includes(method)) {\n headers['Idempotency-Key'] = requestOptions?.idempotencyKey || generateUUID();\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n // Link consumer AbortSignal to internal controller\n if (requestOptions?.signal) {\n if (requestOptions.signal.aborted) {\n controller.abort();\n } else {\n requestOptions.signal.addEventListener('abort', () => controller.abort(), { once: true });\n }\n }\n\n try {\n // Run onRequest interceptors\n let finalOptions: RequestInit = { ...options, headers };\n for (const interceptor of this.interceptors) {\n if (interceptor.onRequest) {\n finalOptions = await interceptor.onRequest(url, finalOptions);\n }\n }\n\n if (this.config.debug) {\n this.logger.debug(`${finalOptions.method || 'GET'} ${endpoint}`);\n }\n\n const response = await fetch(url, {\n ...finalOptions,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n // Track rate limit headers\n if (this.rateLimitTracker) {\n this.rateLimitTracker.updateFromHeaders(response.headers);\n }\n\n // Binary download path\n if (requestOptions?.responseType === 'arraybuffer') {\n if (!response.ok) {\n let errData: Record<string, unknown> = {};\n try { errData = await response.json(); } catch { /* ignore */ }\n this.handleErrorResponse(response.status, errData, requestId);\n }\n this.circuitBreaker?.onSuccess();\n const buffer = await response.arrayBuffer();\n return buffer as unknown as T;\n }\n\n let data: Record<string, unknown> | undefined;\n try {\n data = await response.json();\n } catch {\n // Non-JSON response (HTML error pages, 204 No Content, etc.)\n if (!response.ok) {\n this.handleErrorResponse(response.status, {\n error: `HTTP ${response.status}`,\n message: response.statusText,\n }, requestId);\n }\n // OK response but no JSON body (e.g., 204)\n this.circuitBreaker?.onSuccess();\n return undefined as unknown as T;\n }\n\n if (!response.ok) {\n this.handleErrorResponse(response.status, data || {}, requestId);\n }\n\n // Record success for circuit breaker\n this.circuitBreaker?.onSuccess();\n\n // Run onResponse interceptors\n let result: unknown = data;\n for (const interceptor of this.interceptors) {\n if (interceptor.onResponse) {\n result = await interceptor.onResponse(url, result);\n }\n }\n\n if (this.config.debug) {\n this.logger.debug(`Response: ${response.status}`);\n }\n\n return result as T;\n } catch (error) {\n clearTimeout(timeoutId);\n\n // Record failure for circuit breaker (skip for client errors)\n if (\n error instanceof VesantError &&\n error.statusCode &&\n error.statusCode >= 500\n ) {\n this.circuitBreaker?.onFailure();\n } else if (error instanceof NetworkError || error instanceof TimeoutError) {\n this.circuitBreaker?.onFailure();\n }\n\n // Attach requestId to VesantError instances\n if (error instanceof VesantError && !error.requestId) {\n error.requestId = requestId;\n }\n\n // Run onError interceptors\n if (error instanceof Error) {\n for (const interceptor of this.interceptors) {\n if (interceptor.onError) {\n await interceptor.onError(url, error);\n }\n }\n }\n\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n // Distinguish consumer abort from timeout\n if (requestOptions?.signal?.aborted) {\n const abortError = new VesantError('Request aborted', 'REQUEST_ABORTED');\n abortError.requestId = requestId;\n throw abortError;\n }\n this.circuitBreaker?.onFailure();\n const timeoutError = new TimeoutError(this.config.timeout);\n timeoutError.requestId = requestId;\n throw timeoutError;\n }\n if (error instanceof VesantError) {\n throw error;\n }\n }\n\n const networkError = new NetworkError('Network request failed', error);\n networkError.requestId = requestId;\n this.circuitBreaker?.onFailure();\n throw networkError;\n }\n }\n\n /**\n * Make an HTTP request with retry logic\n */\n protected async requestWithRetry<T>(\n endpoint: string,\n options: RequestInit = {},\n serviceURL?: string,\n retries: number = this.config.retries,\n requestOptions?: RequestOptions\n ): Promise<T> {\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n return await this.request<T>(endpoint, options, serviceURL, requestOptions);\n } catch (error) {\n lastError = error instanceof Error ? error : new Error('Unknown error');\n\n // Don't retry on consumer abort\n if (requestOptions?.signal?.aborted) {\n throw lastError;\n }\n\n // Don't retry on client errors (4xx), except 429 (rate limit)\n if (\n lastError instanceof VesantError &&\n lastError.statusCode &&\n lastError.statusCode >= 400 &&\n lastError.statusCode < 500 &&\n lastError.statusCode !== 429\n ) {\n throw lastError;\n }\n\n // Don't retry on last attempt\n if (attempt === retries) {\n break;\n }\n\n // Use Retry-After for 429, otherwise exponential backoff with jitter\n let delay: number;\n if (lastError instanceof RateLimitError && lastError.retryAfter) {\n delay = lastError.retryAfter * 1000;\n } else {\n delay = Math.min(1000 * Math.pow(2, attempt) + Math.random() * 1000, 10000);\n }\n await new Promise((resolve) => setTimeout(resolve, delay));\n\n if (this.config.debug) {\n this.logger.debug(`Retry attempt ${attempt + 1}/${retries} after ${delay.toFixed(0)}ms`);\n }\n }\n }\n\n throw new NetworkError(`Request failed after ${retries} retries`, lastError);\n }\n\n /**\n * Handle error responses from API\n */\n protected handleErrorResponse(status: number, data: Record<string, unknown>, requestId?: string): never {\n const message = (data.error as string) || (data.message as string) || `HTTP ${status}`;\n\n const createError = (): VesantError => {\n switch (status) {\n case 400:\n return new VesantError(message, 'BAD_REQUEST', 400);\n case 401:\n return new AuthenticationError(message);\n case 403:\n return new VesantError(message, 'FORBIDDEN', 403);\n case 404:\n return new VesantError(message, 'NOT_FOUND', 404);\n case 409:\n return new VesantError(message, 'DUPLICATE_PROFILE', 409);\n case 429: {\n const retryAfter = (data.retry_after as number | undefined) || (data.retryAfter as number | undefined);\n return new RateLimitError(retryAfter);\n }\n case 500:\n case 502:\n case 503:\n case 504:\n return new ServiceUnavailableError(message);\n default:\n return new VesantError(message, 'UNKNOWN_ERROR', status);\n }\n };\n\n const error = createError();\n if (requestId) {\n error.requestId = requestId;\n }\n throw error;\n }\n\n /**\n * Build query string from parameters\n */\n protected buildQueryString(params: Record<string, unknown>): string {\n const query = new URLSearchParams();\n\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n if (Array.isArray(value)) {\n value.forEach((item) => query.append(key, String(item)));\n } else {\n query.append(key, String(value));\n }\n }\n });\n\n const queryString = query.toString();\n return queryString ? `?${queryString}` : '';\n }\n\n /**\n * Update client configuration\n */\n updateConfig(config: Partial<BaseClientConfig>): void {\n this.config = {\n ...this.config,\n ...config,\n headers: {\n ...this.config.headers,\n ...(config.headers || {}),\n },\n };\n if (config.logger) {\n this.logger = config.logger;\n }\n if (config.interceptors) {\n this.interceptors = config.interceptors;\n }\n }\n\n /**\n * Get current configuration (readonly)\n */\n getConfig(): Readonly<BaseClientConfig> {\n return { ...this.config };\n }\n\n /**\n * Get rate limit status from tracked response headers.\n */\n getRateLimitStatus(): RateLimitStatus | null {\n return this.rateLimitTracker?.getStatus() ?? null;\n }\n\n /**\n * Get circuit breaker status.\n */\n getCircuitBreakerStatus(): CircuitBreakerStatus | null {\n return this.circuitBreaker?.getStatus() ?? null;\n }\n\n /**\n * Health check endpoint\n */\n async healthCheck(): Promise<{ status: string; timestamp: string }> {\n return this.request('/api/v1/health');\n }\n}\n","import { BaseClient } from '../core/client';\nimport type { BaseClientConfig, RequestOptions } from '../core/config';\nimport type {\n TaxClientConfig,\n CustomerTaxProfileRecord,\n CustomerTaxProfileDocuments,\n ReRequestTaxFormInput,\n EnableWithholdingInput,\n EnableWithholdingResponse,\n TINCheckResult,\n TaxRules,\n UpdateTaxRulesInput,\n UpdateReminderConfigInput,\n TaxRuleVersion,\n ComplianceStats,\n ComplianceStatsFilters,\n GlobalTaxRule,\n TreatyCountry,\n TreatyCountryListResponse,\n RunRemindersResponse,\n} from './types';\n\nexport class TaxClient extends BaseClient {\n constructor(config: TaxClientConfig) {\n const baseConfig: BaseClientConfig = {\n baseURL: config.baseURL,\n tenantId: config.tenantId,\n apiKey: config.apiKey,\n headers: config.headers,\n timeout: config.timeout,\n retries: 3,\n debug: config.debug,\n environment: config.environment,\n };\n super(baseConfig);\n }\n\n // ==========================================================================\n // P1 — Customer Tax Profile (core compliance flow)\n // ==========================================================================\n\n async getCustomerTaxProfileRecord(customerID: string): Promise<CustomerTaxProfileRecord> {\n return this.request<CustomerTaxProfileRecord>(\n `/api/v1/tax/customer-tax-profiles/${customerID}`\n );\n }\n\n async requestTaxForm(customerID: string): Promise<CustomerTaxProfileRecord> {\n return this.request<CustomerTaxProfileRecord>(\n `/api/v1/tax/customer-tax-profiles/${customerID}/request-form`,\n { method: 'POST' }\n );\n }\n\n async checkTINStatus(customerID: string): Promise<TINCheckResult> {\n return this.requestWithRetry<TINCheckResult>(\n `/api/v1/tax/customer-tax-profiles/${customerID}/check-tin`,\n { method: 'POST' }\n );\n }\n\n async reRequestTaxForm(\n customerID: string,\n input: ReRequestTaxFormInput\n ): Promise<CustomerTaxProfileRecord> {\n return this.request<CustomerTaxProfileRecord>(\n `/api/v1/tax/customer-tax-profiles/${customerID}/re-request-form`,\n {\n method: 'POST',\n body: JSON.stringify(input),\n }\n );\n }\n\n async enableBackupWithholding(\n customerID: string,\n input: EnableWithholdingInput\n ): Promise<EnableWithholdingResponse> {\n return this.request<EnableWithholdingResponse>(\n `/api/v1/tax/customer-tax-profiles/${customerID}/enable-withholding`,\n {\n method: 'POST',\n body: JSON.stringify(input),\n }\n );\n }\n\n async getCustomerDocuments(customerID: string): Promise<CustomerTaxProfileDocuments> {\n return this.request<CustomerTaxProfileDocuments>(\n `/api/v1/tax/customer-tax-profiles/${customerID}/documents`\n );\n }\n\n async downloadTaxForm(\n customerID: string,\n requestOptions?: RequestOptions\n ): Promise<ArrayBuffer> {\n return this.request<ArrayBuffer>(\n `/api/v1/tax/customer-tax-profiles/${customerID}/download-form`,\n { method: 'GET' },\n undefined,\n { ...requestOptions, responseType: 'arraybuffer' }\n );\n }\n\n async runReminders(): Promise<RunRemindersResponse> {\n return this.request<RunRemindersResponse>('/api/v1/tax/reminders/run', {\n method: 'POST',\n });\n }\n\n /**\n * Update only the reminder configuration (frequency + max count) without\n * touching any other tax rule settings. Fetches current rules first and\n * merges the reminder fields before sending the update.\n *\n * Requires the caller to be authenticated as a Tenant Super Admin.\n * Throws VesantError with status 403 if the role requirement is not met.\n */\n async updateReminderConfig(input: UpdateReminderConfigInput): Promise<TaxRuleVersion> {\n const current = await this.getTaxRules();\n return this.updateTaxRules({\n trigger_account_creation: current.trigger_account_creation,\n trigger_first_withdrawal: current.trigger_first_withdrawal,\n trigger_threshold: current.trigger_threshold,\n trigger_manual: current.trigger_manual,\n trigger_tin_invalid: current.trigger_tin_invalid,\n trigger_w8ben_expiry: current.trigger_w8ben_expiry,\n trigger_tin_expired: current.trigger_tin_expired,\n us_withholding_enabled: current.us_withholding_enabled,\n non_us_withholding_enabled: current.non_us_withholding_enabled,\n transaction_action: current.transaction_action,\n w8ben_expiry_warning_days: current.w8ben_expiry_warning_days,\n tin_verification_due_date: current.tin_verification_due_date,\n email_sending_method: current.email_sending_method,\n display_tin_links_on_platform: current.display_tin_links_on_platform,\n tax_treaty_support: current.tax_treaty_support,\n reminder_frequency_days: input.reminder_frequency_days,\n reminder_max_count: input.reminder_max_count,\n });\n }\n\n // ==========================================================================\n // P2 — Tenant Tax Rules\n // ==========================================================================\n\n async getTaxRules(): Promise<TaxRules> {\n const res = await this.request<{ rules: TaxRules }>('/api/v1/tax/rules');\n return res.rules;\n }\n\n async updateTaxRules(input: UpdateTaxRulesInput): Promise<TaxRuleVersion> {\n const res = await this.request<{ version: TaxRuleVersion }>('/api/v1/tax/rules', {\n method: 'PUT',\n body: JSON.stringify({ rules: input }),\n });\n return res.version;\n }\n\n async getComplianceStats(filters?: ComplianceStatsFilters): Promise<ComplianceStats> {\n const params: Record<string, unknown> = {};\n if (filters?.time_range) params.time_range = filters.time_range;\n if (filters?.from_date) params.from_date = filters.from_date;\n if (filters?.to_date) params.to_date = filters.to_date;\n return this.request<ComplianceStats>(\n `/api/v1/tax/tenant/w-form-tenant-stats${this.buildQueryString(params)}`\n );\n }\n\n // ==========================================================================\n // P3 — Global Tax Rule & Treaty Countries\n // ==========================================================================\n\n async getCurrentGlobalTaxRule(): Promise<GlobalTaxRule> {\n const res = await this.request<{ success: boolean; message: string; data: GlobalTaxRule }>(\n '/api/v1/tm/tenant/global-tax-rules/current'\n );\n return res.data;\n }\n\n async listTreatyCountries(): Promise<TreatyCountryListResponse> {\n return this.request<TreatyCountryListResponse>('/api/v1/tax/treaty-countries');\n }\n\n async getTreatyCountry(code: string): Promise<TreatyCountry> {\n const res = await this.request<{ treaty_country: TreatyCountry }>(\n `/api/v1/tax/treaty-countries/${encodeURIComponent(code)}`\n );\n return res.treaty_country;\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/core/errors.ts","../../src/core/circuit-breaker.ts","../../src/core/rate-limiter.ts","../../src/core/logger.ts","../../src/core/version.ts","../../src/shared/browser-utils.ts","../../src/core/client.ts","../../src/tax/client.ts"],"names":[],"mappings":";;;AAOO,IAAM,WAAA,GAAN,MAAM,YAAA,SAAoB,KAAA,CAAM;AAAA,EAGrC,WAAA,CACE,OAAA,EACO,IAAA,EACA,UAAA,EACA,OAAA,EACP;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AAJN,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA;AACA,IAAA,IAA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BAAA,EAAqB;AAAA,MAC/E,MAAA,EAAQ,KAAA;AAAA,MACR,MAAM,IAAA,CAAK,SAAA,CAAU,EAAE,KAAA,EAAO,OAAO;AAAA,KACtC,CAAA;AACD,IAAA,OAAO,GAAA,CAAI,OAAA;AAAA,EACb;AAAA,EAEA,MAAM,mBAAmB,OAAA,EAA4D;AACnF,IAAA,MAAM,SAAkC,EAAC;AACzC,IAAA,IAAI,OAAA,EAAS,UAAA,EAAY,MAAA,CAAO,UAAA,GAAa,OAAA,CAAQ,UAAA;AACrD,IAAA,IAAI,OAAA,EAAS,SAAA,EAAW,MAAA,CAAO,SAAA,GAAY,OAAA,CAAQ,SAAA;AACnD,IAAA,IAAI,OAAA,EAAS,OAAA,EAAS,MAAA,CAAO,OAAA,GAAU,OAAA,CAAQ,OAAA;AAC/C,IAAA,OAAO,IAAA,CAAK,OAAA;AAAA,MACV,CAAA,sCAAA,EAAyC,IAAA,CAAK,gBAAA,CAAiB,MAAM,CAAC,CAAA;AAAA,KACxE;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,uBAAA,GAAkD;AACtD,IAAA,MAAM,GAAA,GAAM,MAAM,IAAA,CAAK,OAAA;AAAA,MACrB;AAAA,KACF;AACA,IAAA,OAAO,GAAA,CAAI,IAAA;AAAA,EACb;AAAA,EAEA,MAAM,mBAAA,GAA0D;AAC9D,IAAA,OAAO,IAAA,CAAK,QAAmC,8BAA8B,CAAA;AAAA,EAC/E;AAAA,EAEA,MAAM,iBAAiB,IAAA,EAAsC;AAC3D,IAAA,MAAM,GAAA,GAAM,MAAM,IAAA,CAAK,OAAA;AAAA,MACrB,CAAA,6BAAA,EAAgC,kBAAA,CAAmB,IAAI,CAAC,CAAA;AAAA,KAC1D;AACA,IAAA,OAAO,GAAA,CAAI,cAAA;AAAA,EACb;AACF","file":"index.js","sourcesContent":["/**\n * Error hierarchy for Vesant SDK\n *\n * Provides structured error handling with specific error types\n * for different failure scenarios.\n */\n\nexport class VesantError extends Error {\n public requestId?: string;\n\n constructor(\n message: string,\n public code: string,\n public statusCode?: number,\n public details?: Record<string, unknown>\n ) {\n super(message);\n this.name = 'VesantError';\n Object.setPrototypeOf(this, VesantError.prototype);\n }\n}\n\n/** @deprecated Use VesantError instead */\nexport const CGSError = VesantError;\n/** @deprecated Use VesantError instead */\nexport type CGSError = VesantError;\n\nexport class NetworkError extends VesantError {\n constructor(message: string, public originalError?: unknown) {\n super(message, 'NETWORK_ERROR');\n this.name = 'NetworkError';\n Object.setPrototypeOf(this, NetworkError.prototype);\n }\n}\n\nexport class ValidationError extends VesantError {\n constructor(message: string, fields?: string[]) {\n super(message, 'VALIDATION_ERROR', 400, { fields });\n this.name = 'ValidationError';\n Object.setPrototypeOf(this, ValidationError.prototype);\n }\n}\n\nexport class ServiceUnavailableError extends VesantError {\n constructor(message: string = 'Service unavailable') {\n super(message, 'SERVICE_UNAVAILABLE', 503);\n this.name = 'ServiceUnavailableError';\n Object.setPrototypeOf(this, ServiceUnavailableError.prototype);\n }\n}\n\nexport class ComplianceBlockedError extends VesantError {\n constructor(reasons: import('./types').BlockReason[]) {\n super('Access blocked due to compliance rules', 'COMPLIANCE_BLOCKED', 403, { reasons });\n this.name = 'ComplianceBlockedError';\n Object.setPrototypeOf(this, ComplianceBlockedError.prototype);\n }\n}\n\nexport class AuthenticationError extends VesantError {\n constructor(message: string = 'Authentication failed') {\n super(message, 'AUTHENTICATION_ERROR', 401);\n this.name = 'AuthenticationError';\n Object.setPrototypeOf(this, AuthenticationError.prototype);\n }\n}\n\nexport class RateLimitError extends VesantError {\n constructor(public retryAfter?: number) {\n super('Rate limit exceeded', 'RATE_LIMIT_EXCEEDED', 429, { retryAfter });\n this.name = 'RateLimitError';\n Object.setPrototypeOf(this, RateLimitError.prototype);\n }\n}\n\nexport class TimeoutError extends VesantError {\n constructor(public timeout: number) {\n super(`Request timeout after ${timeout}ms`, 'TIMEOUT', 408, { timeout });\n this.name = 'TimeoutError';\n Object.setPrototypeOf(this, TimeoutError.prototype);\n }\n}\n\nexport class ComplianceError extends VesantError {\n constructor(\n message: string,\n public originalError?: unknown,\n code: string = 'COMPLIANCE_ERROR'\n ) {\n super(message, code);\n this.name = 'ComplianceError';\n Object.setPrototypeOf(this, ComplianceError.prototype);\n }\n}\n\nexport class CircuitBreakerOpenError extends VesantError {\n constructor() {\n super('Circuit breaker is open — requests are temporarily blocked', 'CIRCUIT_BREAKER_OPEN', 503);\n this.name = 'CircuitBreakerOpenError';\n Object.setPrototypeOf(this, CircuitBreakerOpenError.prototype);\n }\n}\n","/**\n * Circuit breaker pattern for resilient HTTP requests.\n *\n * States: closed (normal) -> open (failing) -> half-open (testing) -> closed\n */\n\nexport type CircuitBreakerState = 'closed' | 'open' | 'half-open';\n\nexport interface CircuitBreakerConfig {\n /** Number of consecutive failures before opening the circuit (default: 5) */\n failureThreshold?: number;\n /** Time in ms to wait before transitioning from open to half-open (default: 30000) */\n resetTimeout?: number;\n /** Number of successes in half-open state before closing (default: 1) */\n successThreshold?: number;\n}\n\nexport interface CircuitBreakerStatus {\n state: CircuitBreakerState;\n failures: number;\n successes: number;\n lastFailureTime: number | null;\n nextRetryTime: number | null;\n}\n\nexport class CircuitBreaker {\n private state: CircuitBreakerState = 'closed';\n private failures = 0;\n private successes = 0;\n private lastFailureTime: number | null = null;\n\n private readonly failureThreshold: number;\n private readonly resetTimeout: number;\n private readonly successThreshold: number;\n\n constructor(config: CircuitBreakerConfig = {}) {\n this.failureThreshold = config.failureThreshold ?? 5;\n this.resetTimeout = config.resetTimeout ?? 30000;\n this.successThreshold = config.successThreshold ?? 1;\n }\n\n /**\n * Check if a request can proceed through the circuit breaker.\n */\n canExecute(): boolean {\n if (this.state === 'closed') {\n return true;\n }\n\n if (this.state === 'open') {\n const now = Date.now();\n if (this.lastFailureTime && now - this.lastFailureTime >= this.resetTimeout) {\n this.state = 'half-open';\n this.successes = 0;\n return true;\n }\n return false;\n }\n\n // half-open: allow requests through for testing\n return true;\n }\n\n /**\n * Record a successful request.\n */\n onSuccess(): void {\n if (this.state === 'half-open') {\n this.successes++;\n if (this.successes >= this.successThreshold) {\n this.state = 'closed';\n this.failures = 0;\n this.successes = 0;\n this.lastFailureTime = null;\n }\n } else if (this.state === 'closed') {\n this.failures = 0;\n }\n }\n\n /**\n * Record a failed request.\n */\n onFailure(): void {\n this.failures++;\n this.lastFailureTime = Date.now();\n\n if (this.state === 'half-open') {\n this.state = 'open';\n this.successes = 0;\n } else if (this.state === 'closed' && this.failures >= this.failureThreshold) {\n this.state = 'open';\n }\n }\n\n /**\n * Get current circuit breaker status.\n */\n getStatus(): CircuitBreakerStatus {\n return {\n state: this.state,\n failures: this.failures,\n successes: this.successes,\n lastFailureTime: this.lastFailureTime,\n nextRetryTime:\n this.state === 'open' && this.lastFailureTime\n ? this.lastFailureTime + this.resetTimeout\n : null,\n };\n }\n\n /**\n * Reset the circuit breaker to its initial closed state.\n */\n reset(): void {\n this.state = 'closed';\n this.failures = 0;\n this.successes = 0;\n this.lastFailureTime = null;\n }\n}\n","/**\n * Rate limit tracking from API response headers.\n *\n * Tracks X-RateLimit-* headers to enable pre-flight checks\n * before making requests.\n */\n\nexport interface RateLimitStatus {\n /** Maximum requests allowed in the window */\n limit: number | null;\n /** Remaining requests in the current window */\n remaining: number | null;\n /** Unix timestamp (seconds) when the rate limit resets */\n reset: number | null;\n /** Seconds until the rate limit resets */\n retryAfter: number | null;\n}\n\nexport class RateLimitTracker {\n private limit: number | null = null;\n private remaining: number | null = null;\n private reset: number | null = null;\n private retryAfter: number | null = null;\n\n /**\n * Extract rate limit information from response headers.\n */\n updateFromHeaders(headers: Headers): void {\n const limit = headers.get('x-ratelimit-limit');\n const remaining = headers.get('x-ratelimit-remaining');\n const reset = headers.get('x-ratelimit-reset');\n const retryAfter = headers.get('retry-after');\n\n if (limit !== null) this.limit = parseInt(limit, 10);\n if (remaining !== null) this.remaining = parseInt(remaining, 10);\n if (reset !== null) this.reset = parseInt(reset, 10);\n if (retryAfter !== null) this.retryAfter = parseInt(retryAfter, 10);\n }\n\n /**\n * Check if the rate limit has been exceeded based on tracked headers.\n */\n isLimitExceeded(): boolean {\n if (this.remaining !== null && this.remaining <= 0) {\n // Check if the reset time has passed\n if (this.reset !== null) {\n const now = Math.floor(Date.now() / 1000);\n if (now >= this.reset) {\n // Reset window has passed, allow requests\n this.remaining = null;\n this.reset = null;\n this.retryAfter = null;\n return false;\n }\n }\n return true;\n }\n return false;\n }\n\n /**\n * Get current rate limit status.\n */\n getStatus(): RateLimitStatus {\n return {\n limit: this.limit,\n remaining: this.remaining,\n reset: this.reset,\n retryAfter: this.retryAfter,\n };\n }\n}\n","import type { Logger } from './config';\n\nexport function createConsoleLogger(): Logger {\n return {\n debug(message: string, meta?: Record<string, unknown>) {\n console.log(`[Vesant SDK] ${message}`, meta !== undefined ? meta : '');\n },\n info(message: string, meta?: Record<string, unknown>) {\n console.info(`[Vesant SDK] ${message}`, meta !== undefined ? meta : '');\n },\n warn(message: string, meta?: Record<string, unknown>) {\n console.warn(`[Vesant SDK] ${message}`, meta !== undefined ? meta : '');\n },\n error(message: string, meta?: Record<string, unknown>) {\n console.error(`[Vesant SDK] ${message}`, meta !== undefined ? meta : '');\n },\n };\n}\n\nexport const noopLogger: Logger = {\n debug() {},\n info() {},\n warn() {},\n error() {},\n};\n","/**\n * Single source of truth for the SDK version.\n */\nexport const SDK_VERSION = '2.0.0';\n","/**\n * Shared browser utility functions.\n *\n * Extracted from ciphertext.ts and hooks.ts to avoid duplication.\n * All functions include SSR guards for safe server-side rendering.\n */\n\n/**\n * Generate a UUID v4\n */\nexport function generateUUID(): string {\n if (typeof crypto !== 'undefined' && crypto.randomUUID) {\n return crypto.randomUUID();\n }\n\n // Fallback for older browsers\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n\n/**\n * Generate a unique device ID that persists across sessions.\n * Falls back to a random UUID when localStorage is unavailable (SSR).\n */\nexport function generateDeviceId(): string {\n if (typeof window === 'undefined' || typeof localStorage === 'undefined') {\n return generateUUID();\n }\n\n const storageKey = 'vesant_device_id';\n let deviceId = localStorage.getItem(storageKey);\n\n if (!deviceId) {\n deviceId = generateUUID();\n localStorage.setItem(storageKey, deviceId);\n }\n\n return deviceId;\n}\n\n/**\n * Detect browser information from user agent.\n * Returns safe defaults when running server-side.\n */\nexport function getBrowserInfo(): {\n browser: string;\n browser_version: string;\n os: string;\n os_version: string;\n} {\n if (typeof navigator === 'undefined') {\n return { browser: 'unknown', browser_version: '', os: 'unknown', os_version: '' };\n }\n\n const ua = navigator.userAgent;\n let browser = 'unknown';\n let browserVersion = '';\n let os = 'unknown';\n let osVersion = '';\n\n // Detect browser\n if (ua.includes('Firefox/')) {\n browser = 'Firefox';\n browserVersion = ua.match(/Firefox\\/([\\d.]+)/)?.[1] || '';\n } else if (ua.includes('Edg/')) {\n browser = 'Edge';\n browserVersion = ua.match(/Edg\\/([\\d.]+)/)?.[1] || '';\n } else if (ua.includes('Chrome/')) {\n browser = 'Chrome';\n browserVersion = ua.match(/Chrome\\/([\\d.]+)/)?.[1] || '';\n } else if (ua.includes('Safari/') && !ua.includes('Chrome')) {\n browser = 'Safari';\n browserVersion = ua.match(/Version\\/([\\d.]+)/)?.[1] || '';\n } else if (ua.includes('Opera') || ua.includes('OPR/')) {\n browser = 'Opera';\n browserVersion = ua.match(/(?:Opera|OPR)\\/([\\d.]+)/)?.[1] || '';\n }\n\n // Detect OS\n if (ua.includes('Windows')) {\n os = 'Windows';\n if (ua.includes('Windows NT 10.0')) osVersion = '10';\n else if (ua.includes('Windows NT 6.3')) osVersion = '8.1';\n else if (ua.includes('Windows NT 6.2')) osVersion = '8';\n else if (ua.includes('Windows NT 6.1')) osVersion = '7';\n } else if (ua.includes('Mac OS X')) {\n os = 'macOS';\n osVersion = ua.match(/Mac OS X ([\\d_]+)/)?.[1]?.replace(/_/g, '.') || '';\n } else if (ua.includes('Linux')) {\n os = 'Linux';\n } else if (ua.includes('Android')) {\n os = 'Android';\n osVersion = ua.match(/Android ([\\d.]+)/)?.[1] || '';\n } else if (ua.includes('iOS') || ua.includes('iPhone') || ua.includes('iPad')) {\n os = 'iOS';\n osVersion = ua.match(/OS ([\\d_]+)/)?.[1]?.replace(/_/g, '.') || '';\n }\n\n return { browser, browser_version: browserVersion, os, os_version: osVersion };\n}\n","/**\n * Base HTTP client for all Vesant SDK clients\n *\n * Provides common functionality:\n * - Request/response handling\n * - Error handling\n * - Retry logic with exponential backoff\n * - Timeout management\n * - Debug logging\n */\n\nimport type { BaseClientConfig, Logger, RequestInterceptor, RequestOptions } from './config';\nimport {\n VesantError,\n NetworkError,\n TimeoutError,\n AuthenticationError,\n RateLimitError,\n ServiceUnavailableError,\n ValidationError,\n CircuitBreakerOpenError,\n} from './errors';\nimport { CircuitBreaker, type CircuitBreakerStatus } from './circuit-breaker';\nimport { RateLimitTracker, type RateLimitStatus } from './rate-limiter';\nimport { createConsoleLogger } from './logger';\nimport { SDK_VERSION } from './version';\nimport { generateUUID } from '../shared/browser-utils';\n\nexport abstract class BaseClient {\n protected config: BaseClientConfig & { timeout: number; retries: number };\n protected logger: Logger;\n private interceptors: RequestInterceptor[];\n private circuitBreaker: CircuitBreaker | null = null;\n private rateLimitTracker: RateLimitTracker | null = null;\n\n constructor(config: BaseClientConfig) {\n if (!config.baseURL?.trim()) {\n throw new ValidationError('baseURL is required and must be a non-empty string', ['baseURL']);\n }\n if (!config.tenantId?.trim()) {\n throw new ValidationError('tenantId is required and must be a non-empty string', ['tenantId']);\n }\n\n this.interceptors = config.interceptors || [];\n this.logger = config.logger || createConsoleLogger();\n\n // Auto-detect environment from API key prefix\n let environment = config.environment;\n const apiKey = config.apiKey || '';\n if (apiKey.startsWith('pk_test_')) {\n if (environment === 'production') {\n this.logger.warn('Sandbox API key (pk_test_*) used with environment: \"production\" — overriding to \"sandbox\"');\n }\n environment = 'sandbox';\n } else if (apiKey.startsWith('pk_live_') && environment === 'sandbox') {\n this.logger.warn('Production API key (pk_live_*) used with environment: \"sandbox\" — sandbox isolation will still be applied for backward compatibility');\n }\n\n this.config = {\n ...config,\n apiKey,\n environment,\n headers: config.headers || {},\n timeout: config.timeout || 10000,\n retries: config.retries || 3,\n debug: config.debug || false,\n interceptors: this.interceptors,\n logger: this.logger,\n };\n\n if (config.circuitBreaker) {\n this.circuitBreaker = new CircuitBreaker(config.circuitBreaker);\n }\n if (config.enableRateLimitTracking) {\n this.rateLimitTracker = new RateLimitTracker();\n }\n }\n\n /**\n * Make an HTTP request with timeout and error handling\n */\n protected async request<T>(\n endpoint: string,\n options: RequestInit = {},\n serviceURL?: string,\n requestOptions?: RequestOptions\n ): Promise<T> {\n const requestId = generateUUID();\n\n // Circuit breaker check\n if (this.circuitBreaker && !this.circuitBreaker.canExecute()) {\n const error = new CircuitBreakerOpenError();\n error.requestId = requestId;\n throw error;\n }\n\n // Rate limit pre-check\n if (this.rateLimitTracker && this.rateLimitTracker.isLimitExceeded()) {\n const status = this.rateLimitTracker.getStatus();\n const error = new RateLimitError(status.retryAfter ?? undefined);\n error.requestId = requestId;\n throw error;\n }\n\n const url = `${serviceURL || this.config.baseURL}${endpoint}`;\n\n const headers: Record<string, string> = {\n 'Content-Type': 'application/json',\n 'X-Tenant-ID': this.config.tenantId,\n 'X-SDK-Version': `vesant-sdk-ts/${SDK_VERSION}`,\n 'X-Request-ID': requestId,\n ...this.config.headers,\n ...((options.headers as Record<string, string>) || {}),\n };\n\n if (this.config.apiKey) {\n headers['Authorization'] = `Bearer ${this.config.apiKey}`;\n }\n\n // Sandbox header\n if (this.config.environment === 'sandbox') {\n headers['X-Sandbox'] = 'true';\n }\n\n // Idempotency key for mutating methods\n const method = (options.method || 'GET').toUpperCase();\n if (['POST', 'PUT', 'PATCH'].includes(method)) {\n headers['Idempotency-Key'] = requestOptions?.idempotencyKey || generateUUID();\n }\n\n const controller = new AbortController();\n const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);\n\n // Link consumer AbortSignal to internal controller\n if (requestOptions?.signal) {\n if (requestOptions.signal.aborted) {\n controller.abort();\n } else {\n requestOptions.signal.addEventListener('abort', () => controller.abort(), { once: true });\n }\n }\n\n try {\n // Run onRequest interceptors\n let finalOptions: RequestInit = { ...options, headers };\n for (const interceptor of this.interceptors) {\n if (interceptor.onRequest) {\n finalOptions = await interceptor.onRequest(url, finalOptions);\n }\n }\n\n if (this.config.debug) {\n this.logger.debug(`${finalOptions.method || 'GET'} ${endpoint}`);\n }\n\n const response = await fetch(url, {\n ...finalOptions,\n signal: controller.signal,\n });\n\n clearTimeout(timeoutId);\n\n // Track rate limit headers\n if (this.rateLimitTracker) {\n this.rateLimitTracker.updateFromHeaders(response.headers);\n }\n\n // Binary download path\n if (requestOptions?.responseType === 'arraybuffer') {\n if (!response.ok) {\n let errData: Record<string, unknown> = {};\n try { errData = await response.json(); } catch { /* ignore */ }\n this.handleErrorResponse(response.status, errData, requestId);\n }\n this.circuitBreaker?.onSuccess();\n const buffer = await response.arrayBuffer();\n return buffer as unknown as T;\n }\n\n let data: Record<string, unknown> | undefined;\n try {\n data = await response.json();\n } catch {\n // Non-JSON response (HTML error pages, 204 No Content, etc.)\n if (!response.ok) {\n this.handleErrorResponse(response.status, {\n error: `HTTP ${response.status}`,\n message: response.statusText,\n }, requestId);\n }\n // OK response but no JSON body (e.g., 204)\n this.circuitBreaker?.onSuccess();\n return undefined as unknown as T;\n }\n\n if (!response.ok) {\n this.handleErrorResponse(response.status, data || {}, requestId);\n }\n\n // Record success for circuit breaker\n this.circuitBreaker?.onSuccess();\n\n // Run onResponse interceptors\n let result: unknown = data;\n for (const interceptor of this.interceptors) {\n if (interceptor.onResponse) {\n result = await interceptor.onResponse(url, result);\n }\n }\n\n if (this.config.debug) {\n this.logger.debug(`Response: ${response.status}`);\n }\n\n return result as T;\n } catch (error) {\n clearTimeout(timeoutId);\n\n // Record failure for circuit breaker (skip for client errors)\n if (\n error instanceof VesantError &&\n error.statusCode &&\n error.statusCode >= 500\n ) {\n this.circuitBreaker?.onFailure();\n } else if (error instanceof NetworkError || error instanceof TimeoutError) {\n this.circuitBreaker?.onFailure();\n }\n\n // Attach requestId to VesantError instances\n if (error instanceof VesantError && !error.requestId) {\n error.requestId = requestId;\n }\n\n // Run onError interceptors\n if (error instanceof Error) {\n for (const interceptor of this.interceptors) {\n if (interceptor.onError) {\n await interceptor.onError(url, error);\n }\n }\n }\n\n if (error instanceof Error) {\n if (error.name === 'AbortError') {\n // Distinguish consumer abort from timeout\n if (requestOptions?.signal?.aborted) {\n const abortError = new VesantError('Request aborted', 'REQUEST_ABORTED');\n abortError.requestId = requestId;\n throw abortError;\n }\n this.circuitBreaker?.onFailure();\n const timeoutError = new TimeoutError(this.config.timeout);\n timeoutError.requestId = requestId;\n throw timeoutError;\n }\n if (error instanceof VesantError) {\n throw error;\n }\n }\n\n const networkError = new NetworkError('Network request failed', error);\n networkError.requestId = requestId;\n this.circuitBreaker?.onFailure();\n throw networkError;\n }\n }\n\n /**\n * Make an HTTP request with retry logic\n */\n protected async requestWithRetry<T>(\n endpoint: string,\n options: RequestInit = {},\n serviceURL?: string,\n retries: number = this.config.retries,\n requestOptions?: RequestOptions\n ): Promise<T> {\n let lastError: Error | undefined;\n\n for (let attempt = 0; attempt <= retries; attempt++) {\n try {\n return await this.request<T>(endpoint, options, serviceURL, requestOptions);\n } catch (error) {\n lastError = error instanceof Error ? error : new Error('Unknown error');\n\n // Don't retry on consumer abort\n if (requestOptions?.signal?.aborted) {\n throw lastError;\n }\n\n // Don't retry on client errors (4xx), except 429 (rate limit)\n if (\n lastError instanceof VesantError &&\n lastError.statusCode &&\n lastError.statusCode >= 400 &&\n lastError.statusCode < 500 &&\n lastError.statusCode !== 429\n ) {\n throw lastError;\n }\n\n // Don't retry on last attempt\n if (attempt === retries) {\n break;\n }\n\n // Use Retry-After for 429, otherwise exponential backoff with jitter\n let delay: number;\n if (lastError instanceof RateLimitError && lastError.retryAfter) {\n delay = lastError.retryAfter * 1000;\n } else {\n delay = Math.min(1000 * Math.pow(2, attempt) + Math.random() * 1000, 10000);\n }\n await new Promise((resolve) => setTimeout(resolve, delay));\n\n if (this.config.debug) {\n this.logger.debug(`Retry attempt ${attempt + 1}/${retries} after ${delay.toFixed(0)}ms`);\n }\n }\n }\n\n throw new NetworkError(`Request failed after ${retries} retries`, lastError);\n }\n\n /**\n * Handle error responses from API\n */\n protected handleErrorResponse(status: number, data: Record<string, unknown>, requestId?: string): never {\n const message = (data.error as string) || (data.message as string) || `HTTP ${status}`;\n\n const createError = (): VesantError => {\n switch (status) {\n case 400:\n return new VesantError(message, 'BAD_REQUEST', 400);\n case 401:\n return new AuthenticationError(message);\n case 403:\n return new VesantError(message, 'FORBIDDEN', 403);\n case 404:\n return new VesantError(message, 'NOT_FOUND', 404);\n case 409:\n return new VesantError(message, 'DUPLICATE_PROFILE', 409);\n case 429: {\n const retryAfter = (data.retry_after as number | undefined) || (data.retryAfter as number | undefined);\n return new RateLimitError(retryAfter);\n }\n case 500:\n case 502:\n case 503:\n case 504:\n return new ServiceUnavailableError(message);\n default:\n return new VesantError(message, 'UNKNOWN_ERROR', status);\n }\n };\n\n const error = createError();\n if (requestId) {\n error.requestId = requestId;\n }\n throw error;\n }\n\n /**\n * Build query string from parameters\n */\n protected buildQueryString(params: Record<string, unknown>): string {\n const query = new URLSearchParams();\n\n Object.entries(params).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n if (Array.isArray(value)) {\n value.forEach((item) => query.append(key, String(item)));\n } else {\n query.append(key, String(value));\n }\n }\n });\n\n const queryString = query.toString();\n return queryString ? `?${queryString}` : '';\n }\n\n /**\n * Update client configuration\n */\n updateConfig(config: Partial<BaseClientConfig>): void {\n this.config = {\n ...this.config,\n ...config,\n headers: {\n ...this.config.headers,\n ...(config.headers || {}),\n },\n };\n if (config.logger) {\n this.logger = config.logger;\n }\n if (config.interceptors) {\n this.interceptors = config.interceptors;\n }\n }\n\n /**\n * Get current configuration (readonly)\n */\n getConfig(): Readonly<BaseClientConfig> {\n return { ...this.config };\n }\n\n /**\n * Get rate limit status from tracked response headers.\n */\n getRateLimitStatus(): RateLimitStatus | null {\n return this.rateLimitTracker?.getStatus() ?? null;\n }\n\n /**\n * Get circuit breaker status.\n */\n getCircuitBreakerStatus(): CircuitBreakerStatus | null {\n return this.circuitBreaker?.getStatus() ?? null;\n }\n\n /**\n * Health check endpoint\n */\n async healthCheck(): Promise<{ status: string; timestamp: string }> {\n return this.request('/api/v1/health');\n }\n}\n","import { BaseClient } from '../core/client';\nimport type { BaseClientConfig, RequestOptions } from '../core/config';\nimport type {\n TaxClientConfig,\n CustomerTaxProfileRecord,\n CustomerTaxProfileDocuments,\n ReRequestTaxFormInput,\n EnableWithholdingInput,\n EnableWithholdingResponse,\n TINCheckResult,\n TaxRules,\n UpdateTaxRulesInput,\n TaxRuleVersion,\n ComplianceStats,\n ComplianceStatsFilters,\n GlobalTaxRule,\n TreatyCountry,\n TreatyCountryListResponse,\n} from './types';\n\nexport class TaxClient extends BaseClient {\n constructor(config: TaxClientConfig) {\n const baseConfig: BaseClientConfig = {\n baseURL: config.baseURL,\n tenantId: config.tenantId,\n apiKey: config.apiKey,\n headers: config.headers,\n timeout: config.timeout,\n retries: 3,\n debug: config.debug,\n environment: config.environment,\n };\n super(baseConfig);\n }\n\n // ==========================================================================\n // P1 — Customer Tax Profile (core compliance flow)\n // ==========================================================================\n\n async getCustomerTaxProfileRecord(customerID: string): Promise<CustomerTaxProfileRecord> {\n return this.request<CustomerTaxProfileRecord>(\n `/api/v1/tax/customer-tax-profiles/${customerID}`\n );\n }\n\n async requestTaxForm(customerID: string): Promise<CustomerTaxProfileRecord> {\n return this.request<CustomerTaxProfileRecord>(\n `/api/v1/tax/customer-tax-profiles/${customerID}/request-form`,\n { method: 'POST' }\n );\n }\n\n async checkTINStatus(customerID: string): Promise<TINCheckResult> {\n return this.requestWithRetry<TINCheckResult>(\n `/api/v1/tax/customer-tax-profiles/${customerID}/check-tin`,\n { method: 'POST' }\n );\n }\n\n async reRequestTaxForm(\n customerID: string,\n input: ReRequestTaxFormInput\n ): Promise<CustomerTaxProfileRecord> {\n return this.request<CustomerTaxProfileRecord>(\n `/api/v1/tax/customer-tax-profiles/${customerID}/re-request-form`,\n {\n method: 'POST',\n body: JSON.stringify(input),\n }\n );\n }\n\n async enableBackupWithholding(\n customerID: string,\n input: EnableWithholdingInput\n ): Promise<EnableWithholdingResponse> {\n return this.request<EnableWithholdingResponse>(\n `/api/v1/tax/customer-tax-profiles/${customerID}/enable-withholding`,\n {\n method: 'POST',\n body: JSON.stringify(input),\n }\n );\n }\n\n async getCustomerDocuments(customerID: string): Promise<CustomerTaxProfileDocuments> {\n return this.request<CustomerTaxProfileDocuments>(\n `/api/v1/tax/customer-tax-profiles/${customerID}/documents`\n );\n }\n\n async downloadTaxForm(\n customerID: string,\n requestOptions?: RequestOptions\n ): Promise<ArrayBuffer> {\n return this.request<ArrayBuffer>(\n `/api/v1/tax/customer-tax-profiles/${customerID}/download-form`,\n { method: 'GET' },\n undefined,\n { ...requestOptions, responseType: 'arraybuffer' }\n );\n }\n\n // ==========================================================================\n // P2 — Tenant Tax Rules\n // ==========================================================================\n\n async getTaxRules(): Promise<TaxRules> {\n const res = await this.request<{ rules: TaxRules }>('/api/v1/tax/rules');\n return res.rules;\n }\n\n async updateTaxRules(input: UpdateTaxRulesInput): Promise<TaxRuleVersion> {\n const res = await this.request<{ version: TaxRuleVersion }>('/api/v1/tax/rules', {\n method: 'PUT',\n body: JSON.stringify({ rules: input }),\n });\n return res.version;\n }\n\n async getComplianceStats(filters?: ComplianceStatsFilters): Promise<ComplianceStats> {\n const params: Record<string, unknown> = {};\n if (filters?.time_range) params.time_range = filters.time_range;\n if (filters?.from_date) params.from_date = filters.from_date;\n if (filters?.to_date) params.to_date = filters.to_date;\n return this.request<ComplianceStats>(\n `/api/v1/tax/tenant/w-form-tenant-stats${this.buildQueryString(params)}`\n );\n }\n\n // ==========================================================================\n // P3 — Global Tax Rule & Treaty Countries\n // ==========================================================================\n\n async getCurrentGlobalTaxRule(): Promise<GlobalTaxRule> {\n const res = await this.request<{ success: boolean; message: string; data: GlobalTaxRule }>(\n '/api/v1/tm/tenant/global-tax-rules/current'\n );\n return res.data;\n }\n\n async listTreatyCountries(): Promise<TreatyCountryListResponse> {\n return this.request<TreatyCountryListResponse>('/api/v1/tax/treaty-countries');\n }\n\n async getTreatyCountry(code: string): Promise<TreatyCountry> {\n const res = await this.request<{ treaty_country: TreatyCountry }>(\n `/api/v1/tax/treaty-countries/${encodeURIComponent(code)}`\n );\n return res.treaty_country;\n }\n}\n"]}
@@ -214,7 +214,7 @@ function createConsoleLogger() {
214
214
  }
215
215
 
216
216
  // src/core/version.ts
217
- var SDK_VERSION = "1.6.6";
217
+ var SDK_VERSION = "2.0.0";
218
218
 
219
219
  // src/shared/browser-utils.ts
220
220
  function generateUUID() {
@@ -607,41 +607,6 @@ var TaxClient = class extends BaseClient {
607
607
  { ...requestOptions, responseType: "arraybuffer" }
608
608
  );
609
609
  }
610
- async runReminders() {
611
- return this.request("/api/v1/tax/reminders/run", {
612
- method: "POST"
613
- });
614
- }
615
- /**
616
- * Update only the reminder configuration (frequency + max count) without
617
- * touching any other tax rule settings. Fetches current rules first and
618
- * merges the reminder fields before sending the update.
619
- *
620
- * Requires the caller to be authenticated as a Tenant Super Admin.
621
- * Throws VesantError with status 403 if the role requirement is not met.
622
- */
623
- async updateReminderConfig(input) {
624
- const current = await this.getTaxRules();
625
- return this.updateTaxRules({
626
- trigger_account_creation: current.trigger_account_creation,
627
- trigger_first_withdrawal: current.trigger_first_withdrawal,
628
- trigger_threshold: current.trigger_threshold,
629
- trigger_manual: current.trigger_manual,
630
- trigger_tin_invalid: current.trigger_tin_invalid,
631
- trigger_w8ben_expiry: current.trigger_w8ben_expiry,
632
- trigger_tin_expired: current.trigger_tin_expired,
633
- us_withholding_enabled: current.us_withholding_enabled,
634
- non_us_withholding_enabled: current.non_us_withholding_enabled,
635
- transaction_action: current.transaction_action,
636
- w8ben_expiry_warning_days: current.w8ben_expiry_warning_days,
637
- tin_verification_due_date: current.tin_verification_due_date,
638
- email_sending_method: current.email_sending_method,
639
- display_tin_links_on_platform: current.display_tin_links_on_platform,
640
- tax_treaty_support: current.tax_treaty_support,
641
- reminder_frequency_days: input.reminder_frequency_days,
642
- reminder_max_count: input.reminder_max_count
643
- });
644
- }
645
610
  // ==========================================================================
646
611
  // P2 — Tenant Tax Rules
647
612
  // ==========================================================================