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,320 +0,0 @@
1
- import { T as Timestamp, U as UUID, R as RiskLevel } from './types-B4Ezqo7V.js';
2
-
3
- /**
4
- * Webhook signature verification utilities.
5
- *
6
- * Supports both Web Crypto API (browsers, Deno, Cloudflare Workers)
7
- * and Node.js crypto module with automatic runtime detection.
8
- * Uses constant-time comparison to prevent timing attacks.
9
- */
10
- /**
11
- * Verify an HMAC-SHA256 webhook signature.
12
- *
13
- * @param payload - The raw request body string
14
- * @param signature - The signature from the webhook header
15
- * @param secret - The webhook signing secret
16
- * @returns true if the signature is valid
17
- */
18
- declare function verifyWebhookSignature(payload: string, signature: string, secret: string): Promise<boolean>;
19
-
20
- /**
21
- * TypeScript types for the Transaction Monitoring (TM) Service
22
- *
23
- * These definitions mirror the Go structs used in
24
- * services/transaction-monitoring-service/internal/domain/
25
- *
26
- * Only a subset of fields is included; additional helpers may be
27
- * added as the SDK grows.
28
- */
29
-
30
- /**
31
- * Supported transaction types.
32
- * See domain/transaction.go TransactionType constants.
33
- */
34
- type TransactionType = "deposit" | "withdrawal" | "transfer" | "bet" | "payout";
35
- /**
36
- * Modes or channels by which the transaction was carried out.
37
- * See domain/transaction.go TransactionMode constants.
38
- */
39
- type TransactionMode = "wire_transfer" | "crypto" | "swift" | "ach" | "card";
40
- /**
41
- * Current status of the transaction record.
42
- * See domain/transaction.go TransactionStatus constants.
43
- */
44
- type TransactionStatus = "pending" | "completed" | "failed" | "blocked" | "flagged" | "hold";
45
- /**
46
- * Payload sent when creating a new transaction via the TM API.
47
- *
48
- * Numeric decimal types in Go are represented as strings in the SDK to avoid
49
- * precision loss in JavaScript. Dates are ISO strings.
50
- */
51
- interface TransactionCreateDTO {
52
- tx_id: string;
53
- reference: string;
54
- tenant_id: string;
55
- customer_id: string;
56
- transaction_type: TransactionType;
57
- transaction_mode: TransactionMode;
58
- amount: string;
59
- amount_usd?: number;
60
- currency: string;
61
- source_account?: string;
62
- destination_account?: string;
63
- country?: string;
64
- ip_address?: string;
65
- metadata?: Record<string, any>;
66
- benificiary_comment?: string;
67
- transaction_date: Timestamp;
68
- }
69
- /**
70
- * Representation of a transaction record returned from the TM service.
71
- */
72
- type WithholdingType = "none" | "backup_us" | "backup_non_us" | "treaty";
73
- type WithholdingReason = "customer_tax_form_not_verified" | "tin_not_verified" | "b_notice_backup_withholding";
74
- type JSONB = Record<string, any>;
75
- type Transaction = {
76
- id: string;
77
- tx_id: string;
78
- reference: string;
79
- tenant_id: string;
80
- customer_id: string;
81
- transaction_type: TransactionType;
82
- transaction_mode: TransactionMode;
83
- amount: string;
84
- withheld_amount: string;
85
- released_amount: string;
86
- withholding_rate: number;
87
- withholding_reason?: WithholdingReason;
88
- withholding_type?: WithholdingType;
89
- amount_usd: number;
90
- withheld_usd: number;
91
- released_usd: number;
92
- tax_year: number;
93
- currency: string;
94
- status: TransactionStatus;
95
- source_account?: string;
96
- destination_account?: string;
97
- country?: string;
98
- ip_address?: string;
99
- is_first_withdrawal: boolean;
100
- risk_score: number;
101
- metadata?: JSONB;
102
- benificiary_comment?: string;
103
- transaction_date: string;
104
- created_at: string;
105
- updated_at: string;
106
- deleted_at?: string | null;
107
- };
108
- /**
109
- * Configuration object consumed by {@link TransactionClient}.
110
- * Currently identical to {@link import('../core/types').BaseClientConfig},
111
- * exported here for future extensibility.
112
- */
113
- interface TransactionClientConfig {
114
- baseURL: string;
115
- tenantId: string;
116
- apiKey?: string;
117
- headers?: Record<string, string>;
118
- timeout?: number;
119
- retries?: number;
120
- debug?: boolean;
121
- environment?: 'production' | 'sandbox';
122
- }
123
- type TransactionCreateResponse = {
124
- transaction: Transaction;
125
- message: string;
126
- };
127
-
128
- /**
129
- * Webhook event types and payload definitions.
130
- */
131
-
132
- type WebhookEventType = 'risk.score.changed' | 'risk.category.changed' | 'profile.created' | 'profile.updated' | 'geolocation.verified' | 'geolocation.blocked' | 'kyc.status.changed' | 'kyc.approved' | 'kyc.declined' | 'decision.recorded' | 'label.applied' | 'location_request.completed' | 'compliance.check.failed' | 'tax.reminder.sent' | 'transaction.callback';
133
- interface BaseWebhookEvent<T extends WebhookEventType = WebhookEventType, P = unknown> {
134
- id: UUID;
135
- type: T;
136
- tenant_id: string;
137
- environment: 'production' | 'sandbox';
138
- customer_id: string;
139
- payload: P;
140
- timestamp: Timestamp;
141
- }
142
- interface RiskScoreChangedPayload {
143
- previous_score: number;
144
- new_score: number;
145
- risk_level: RiskLevel;
146
- factors: string[];
147
- }
148
- interface RiskCategoryChangedPayload {
149
- previous_category: string;
150
- new_category: string;
151
- risk_level: RiskLevel;
152
- }
153
- interface ProfileCreatedPayload {
154
- customer_id: string;
155
- entity_type: string;
156
- source: string;
157
- }
158
- interface ProfileUpdatedPayload {
159
- customer_id: string;
160
- updated_fields: string[];
161
- }
162
- interface GeolocationVerifiedPayload {
163
- latitude: number;
164
- longitude: number;
165
- country: string;
166
- region?: string;
167
- is_compliant: boolean;
168
- }
169
- interface GeolocationBlockedPayload {
170
- latitude: number;
171
- longitude: number;
172
- country: string;
173
- region?: string;
174
- reasons: string[];
175
- }
176
- interface KycStatusChangedPayload {
177
- previous_status: string;
178
- new_status: string;
179
- provider?: string;
180
- }
181
- interface DecisionRecordedPayload {
182
- decision_id: string;
183
- decision_type: string;
184
- category: string;
185
- source: string;
186
- risk_score?: number;
187
- }
188
- interface LabelAppliedPayload {
189
- label_type: string;
190
- reasons?: string[];
191
- }
192
- interface LocationRequestCompletedPayload {
193
- request_id: string;
194
- status: string;
195
- latitude?: number;
196
- longitude?: number;
197
- }
198
- interface ComplianceCheckFailedPayload {
199
- check_type: string;
200
- reasons: string[];
201
- severity: string;
202
- }
203
- type TaxReminderType = 'w9_request' | 'w8ben_expiry' | 're_request';
204
- type TaxFormType = 'W9' | 'W8BEN' | 'W8BENE';
205
- interface TaxReminderSentPayload {
206
- customer_id: string;
207
- profile_id: string;
208
- form_type: TaxFormType;
209
- reminder_type: TaxReminderType;
210
- reminder_number: number;
211
- message: string;
212
- }
213
- /**
214
- * Fired after every transaction is created. Carries the final transaction
215
- * state so the client can mirror status, withholding, and amount details.
216
- * status === "hold" means the client should freeze the transaction.
217
- */
218
- interface TransactionCallbackPayload {
219
- tx_id: string;
220
- reference: string;
221
- customer_id: string;
222
- transaction_type: TransactionType;
223
- transaction_mode: TransactionMode;
224
- status: TransactionStatus;
225
- amount: string;
226
- currency: string;
227
- withheld_amount: string;
228
- released_amount: string;
229
- withholding_rate: number;
230
- withholding_type: WithholdingType;
231
- withholding_reason?: WithholdingReason;
232
- amount_usd: number;
233
- withheld_usd: number;
234
- released_usd: number;
235
- is_first_withdrawal: boolean;
236
- transaction_date: Timestamp;
237
- }
238
- type WebhookEvent = BaseWebhookEvent<'risk.score.changed', RiskScoreChangedPayload> | BaseWebhookEvent<'risk.category.changed', RiskCategoryChangedPayload> | BaseWebhookEvent<'profile.created', ProfileCreatedPayload> | BaseWebhookEvent<'profile.updated', ProfileUpdatedPayload> | BaseWebhookEvent<'geolocation.verified', GeolocationVerifiedPayload> | BaseWebhookEvent<'geolocation.blocked', GeolocationBlockedPayload> | BaseWebhookEvent<'kyc.status.changed', KycStatusChangedPayload> | BaseWebhookEvent<'kyc.approved', KycStatusChangedPayload> | BaseWebhookEvent<'kyc.declined', KycStatusChangedPayload> | BaseWebhookEvent<'decision.recorded', DecisionRecordedPayload> | BaseWebhookEvent<'label.applied', LabelAppliedPayload> | BaseWebhookEvent<'location_request.completed', LocationRequestCompletedPayload> | BaseWebhookEvent<'compliance.check.failed', ComplianceCheckFailedPayload> | BaseWebhookEvent<'tax.reminder.sent', TaxReminderSentPayload> | BaseWebhookEvent<'transaction.callback', TransactionCallbackPayload>;
239
- interface WebhookHandlerConfig {
240
- /** Webhook signing secret for signature verification */
241
- secret: string;
242
- /** Header name containing the signature (default: 'x-webhook-signature') */
243
- signatureHeader?: string;
244
- /** Maximum age of webhook event in ms (default: 300000 = 5 minutes) */
245
- tolerance?: number;
246
- }
247
- type WebhookEventHandler<T extends WebhookEventType = WebhookEventType> = (event: Extract<WebhookEvent, {
248
- type: T;
249
- }>) => void | Promise<void>;
250
- type WebhookAnyHandler = (event: WebhookEvent) => void | Promise<void>;
251
-
252
- /**
253
- * Webhook event handler with signature verification and typed dispatch.
254
- */
255
-
256
- declare class WebhookHandler {
257
- private handlers;
258
- private anyHandlers;
259
- private readonly secret;
260
- private readonly tolerance;
261
- constructor(config: WebhookHandlerConfig);
262
- /**
263
- * Register a handler for a specific event type.
264
- */
265
- on<T extends WebhookEventType>(eventType: T, handler: WebhookEventHandler<T>): this;
266
- /**
267
- * Register a catch-all handler for all event types.
268
- */
269
- onAny(handler: WebhookAnyHandler): this;
270
- /**
271
- * Verify signature and parse the webhook body.
272
- */
273
- verifyAndParse(body: string, signature: string): Promise<WebhookEvent>;
274
- /**
275
- * Verify signature, parse, and dispatch to registered handlers.
276
- */
277
- handle(body: string, signature: string): Promise<void>;
278
- /**
279
- * Parse an event without signature verification (for testing).
280
- */
281
- parseEvent(body: string): WebhookEvent;
282
- private parseAndValidate;
283
- private dispatch;
284
- }
285
-
286
- /**
287
- * Framework middleware helpers for webhook handling.
288
- *
289
- * Provides pre-built integrations for Express/Connect and Next.js App Router.
290
- */
291
-
292
- interface WebhookMiddlewareOptions extends WebhookHandlerConfig {
293
- /** Event handlers to register */
294
- handlers?: Partial<Record<WebhookEventType, WebhookEventHandler>>;
295
- /** Catch-all handler */
296
- onAny?: WebhookAnyHandler;
297
- }
298
- /**
299
- * Create an Express/Connect-compatible middleware for webhook handling.
300
- *
301
- * Expects the raw body to be available as `req.body` (string).
302
- * Use `express.raw({ type: 'application/json' })` or similar middleware upstream.
303
- */
304
- declare function createWebhookMiddleware(options: WebhookMiddlewareOptions): (req: {
305
- body: string | Buffer;
306
- headers: Record<string, string | string[] | undefined>;
307
- }, res: {
308
- status(code: number): {
309
- json(body: unknown): void;
310
- };
311
- json?(body: unknown): void;
312
- }, next?: (err?: unknown) => void) => Promise<void>;
313
- /**
314
- * Create a Next.js App Router-compatible webhook handler.
315
- *
316
- * Returns an async function `(request: Request) => Promise<Response>`.
317
- */
318
- declare function createNextWebhookHandler(options: WebhookMiddlewareOptions): (request: Request) => Promise<Response>;
319
-
320
- export { type BaseWebhookEvent as B, type ComplianceCheckFailedPayload as C, type DecisionRecordedPayload as D, type GeolocationVerifiedPayload as G, type JSONB as J, type KycStatusChangedPayload as K, type LabelAppliedPayload as L, type ProfileCreatedPayload as P, type RiskScoreChangedPayload as R, type TransactionCreateDTO as T, WebhookHandler as W, type TransactionCreateResponse as a, type TransactionType as b, type TransactionMode as c, type TransactionStatus as d, type WithholdingType as e, type WithholdingReason as f, type Transaction as g, type TransactionClientConfig as h, type WebhookMiddlewareOptions as i, createWebhookMiddleware as j, createNextWebhookHandler as k, type WebhookEventType as l, type RiskCategoryChangedPayload as m, type ProfileUpdatedPayload as n, type GeolocationBlockedPayload as o, type LocationRequestCompletedPayload as p, type TaxReminderType as q, type TaxFormType as r, type TaxReminderSentPayload as s, type TransactionCallbackPayload as t, type WebhookEvent as u, verifyWebhookSignature as v, type WebhookHandlerConfig as w, type WebhookEventHandler as x, type WebhookAnyHandler as y };