vesant-sdk 1.7.0-dev.fce9898 → 1.7.0-dev.fe84882
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{client-DoMSYMMR.d.ts → client-0NOPDnT0.d.ts} +29 -26
- package/dist/{client-DMIRx7Tu.d.mts → client-CvWNRwwg.d.mts} +29 -26
- package/dist/{client-ZNdnpWe7.d.mts → client-Dps40EtF.d.mts} +2 -2
- package/dist/{client-C3DCmGe9.d.ts → client-SMxqod4j.d.ts} +2 -2
- package/dist/{client-BolQlL5e.d.mts → client-q9fN8Hhf.d.mts} +103 -1
- package/dist/{client-BolQlL5e.d.ts → client-q9fN8Hhf.d.ts} +103 -1
- package/dist/compliance/index.d.mts +3 -3
- package/dist/compliance/index.d.ts +3 -3
- package/dist/compliance/index.js +133 -22
- package/dist/compliance/index.js.map +1 -1
- package/dist/compliance/index.mjs +133 -22
- package/dist/compliance/index.mjs.map +1 -1
- package/dist/decisions/index.d.mts +1 -1
- package/dist/decisions/index.d.ts +1 -1
- package/dist/decisions/index.js +68 -7
- package/dist/decisions/index.js.map +1 -1
- package/dist/decisions/index.mjs +68 -7
- package/dist/decisions/index.mjs.map +1 -1
- package/dist/geolocation/index.d.mts +59 -4
- package/dist/geolocation/index.d.ts +59 -4
- package/dist/geolocation/index.js +136 -19
- package/dist/geolocation/index.js.map +1 -1
- package/dist/geolocation/index.mjs +134 -20
- package/dist/geolocation/index.mjs.map +1 -1
- package/dist/index-C3zUKydT.d.mts +264 -0
- package/dist/index-DSDgS09k.d.ts +264 -0
- package/dist/index.d.mts +26 -9
- package/dist/index.d.ts +26 -9
- package/dist/index.js +324 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +317 -58
- package/dist/index.mjs.map +1 -1
- package/dist/kyc/core.d.mts +2 -2
- package/dist/kyc/core.d.ts +2 -2
- package/dist/kyc/core.js +94 -19
- package/dist/kyc/core.js.map +1 -1
- package/dist/kyc/core.mjs +94 -19
- package/dist/kyc/core.mjs.map +1 -1
- package/dist/kyc/index.d.mts +90 -13
- package/dist/kyc/index.d.ts +90 -13
- package/dist/kyc/index.js +94 -19
- package/dist/kyc/index.js.map +1 -1
- package/dist/kyc/index.mjs +94 -19
- package/dist/kyc/index.mjs.map +1 -1
- package/dist/react.d.mts +9 -3
- package/dist/react.d.ts +9 -3
- package/dist/react.js +180 -77
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +180 -77
- package/dist/react.mjs.map +1 -1
- package/dist/risk-profile/index.d.mts +1 -1
- package/dist/risk-profile/index.d.ts +1 -1
- package/dist/risk-profile/index.js +68 -7
- package/dist/risk-profile/index.js.map +1 -1
- package/dist/risk-profile/index.mjs +68 -7
- package/dist/risk-profile/index.mjs.map +1 -1
- package/dist/scores/index.d.mts +1 -1
- package/dist/scores/index.d.ts +1 -1
- package/dist/scores/index.js +68 -7
- package/dist/scores/index.js.map +1 -1
- package/dist/scores/index.mjs +68 -7
- package/dist/scores/index.mjs.map +1 -1
- package/dist/tax/index.d.mts +2 -2
- package/dist/tax/index.d.ts +2 -2
- package/dist/tax/index.js +73 -9
- package/dist/tax/index.js.map +1 -1
- package/dist/tax/index.mjs +73 -9
- package/dist/tax/index.mjs.map +1 -1
- package/dist/webhooks/index.d.mts +2 -189
- package/dist/webhooks/index.d.ts +2 -189
- package/dist/webhooks/index.js +85 -21
- package/dist/webhooks/index.js.map +1 -1
- package/dist/webhooks/index.mjs +85 -22
- package/dist/webhooks/index.mjs.map +1 -1
- package/package.json +4 -1
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { U as UUID, T as Timestamp, R as RiskLevel } from './types-CBQRNL-l.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pluggable dedup store for webhook replay protection.
|
|
5
|
+
*
|
|
6
|
+
* The default InMemoryDedupStore is process-local — correct for a single
|
|
7
|
+
* long-lived process, but useless across replicas / serverless invocations where
|
|
8
|
+
* the backend's at-least-once retries land on different instances. Supply a
|
|
9
|
+
* shared implementation (e.g. Redis with SETNX + TTL) via WebhookHandlerConfig
|
|
10
|
+
* to dedup reliably in those deployments.
|
|
11
|
+
*/
|
|
12
|
+
interface WebhookDedupStore {
|
|
13
|
+
/** Has this event id already been processed? */
|
|
14
|
+
seen(id: string): Promise<boolean>;
|
|
15
|
+
/** Record this event id as processed, retained for at least ttlMs. */
|
|
16
|
+
mark(id: string, ttlMs: number): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
interface InMemoryDedupStoreOptions {
|
|
19
|
+
/** Purge expired entries once the map grows past this size (default: 1000). */
|
|
20
|
+
maxEntries?: number;
|
|
21
|
+
/** Injectable clock (default: Date.now). */
|
|
22
|
+
now?: () => number;
|
|
23
|
+
}
|
|
24
|
+
declare class InMemoryDedupStore implements WebhookDedupStore {
|
|
25
|
+
private readonly expiryById;
|
|
26
|
+
private readonly maxEntries;
|
|
27
|
+
private readonly now;
|
|
28
|
+
constructor(opts?: InMemoryDedupStoreOptions);
|
|
29
|
+
seen(id: string): Promise<boolean>;
|
|
30
|
+
mark(id: string, ttlMs: number): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Webhook signature verification utilities.
|
|
35
|
+
*
|
|
36
|
+
* Supports both Web Crypto API (browsers, Deno, Cloudflare Workers)
|
|
37
|
+
* and Node.js crypto module with automatic runtime detection.
|
|
38
|
+
* Uses constant-time comparison to prevent timing attacks.
|
|
39
|
+
*/
|
|
40
|
+
interface VerifyWebhookSignatureOptions {
|
|
41
|
+
/** Max allowed clock skew in ms for the signed-timestamp scheme (default: 300000). */
|
|
42
|
+
tolerance?: number;
|
|
43
|
+
/** Clock source for the tolerance check (default: Date.now). */
|
|
44
|
+
now?: () => number;
|
|
45
|
+
/** Accept the legacy body-only `sha256=<hex>` format (default: true, for migration). */
|
|
46
|
+
allowLegacy?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Verify an HMAC-SHA256 webhook signature.
|
|
50
|
+
*
|
|
51
|
+
* Supports two schemes:
|
|
52
|
+
* - Signed-timestamp (preferred): `t=<unix>,v1=<hex>` where the HMAC is computed
|
|
53
|
+
* over `${t}.${payload}`. The timestamp is inside the signed material, so a
|
|
54
|
+
* replayed body is rejected once `|now - t|` exceeds the tolerance — the check
|
|
55
|
+
* is done BEFORE the HMAC compare and authenticates the timestamp.
|
|
56
|
+
* - Legacy (body-only): `sha256=<hex>` (or raw hex) over the payload alone. Kept
|
|
57
|
+
* for the migration window; disable via `allowLegacy: false`.
|
|
58
|
+
*
|
|
59
|
+
* @returns true if the signature is valid
|
|
60
|
+
*/
|
|
61
|
+
declare function verifyWebhookSignature(payload: string, signature: string, secret: string, opts?: VerifyWebhookSignatureOptions): Promise<boolean>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Webhook event types and payload definitions.
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
type WebhookEventType = 'notification.created' | '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';
|
|
68
|
+
interface BaseWebhookEvent<T extends WebhookEventType = WebhookEventType, P = unknown> {
|
|
69
|
+
/**
|
|
70
|
+
* Top-level event id (typed events). The notification envelope carries none —
|
|
71
|
+
* the handler resolves the id from `notification.id`.
|
|
72
|
+
*/
|
|
73
|
+
id?: UUID;
|
|
74
|
+
event_type: T;
|
|
75
|
+
tenant_id: string;
|
|
76
|
+
environment: 'production' | 'sandbox';
|
|
77
|
+
/** Absent on the notification envelope; present on typed events. */
|
|
78
|
+
customer_id?: string;
|
|
79
|
+
payload: P;
|
|
80
|
+
timestamp: Timestamp;
|
|
81
|
+
metadata?: Record<string, unknown>;
|
|
82
|
+
}
|
|
83
|
+
interface RiskScoreChangedPayload {
|
|
84
|
+
previous_score: number;
|
|
85
|
+
new_score: number;
|
|
86
|
+
risk_level: RiskLevel;
|
|
87
|
+
factors: string[];
|
|
88
|
+
}
|
|
89
|
+
interface RiskCategoryChangedPayload {
|
|
90
|
+
previous_category: string;
|
|
91
|
+
new_category: string;
|
|
92
|
+
risk_level: RiskLevel;
|
|
93
|
+
}
|
|
94
|
+
interface ProfileCreatedPayload {
|
|
95
|
+
customer_id: string;
|
|
96
|
+
entity_type: string;
|
|
97
|
+
source: string;
|
|
98
|
+
}
|
|
99
|
+
interface ProfileUpdatedPayload {
|
|
100
|
+
customer_id: string;
|
|
101
|
+
updated_fields: string[];
|
|
102
|
+
}
|
|
103
|
+
interface GeolocationVerifiedPayload {
|
|
104
|
+
latitude: number;
|
|
105
|
+
longitude: number;
|
|
106
|
+
country: string;
|
|
107
|
+
region?: string;
|
|
108
|
+
is_compliant: boolean;
|
|
109
|
+
}
|
|
110
|
+
interface GeolocationBlockedPayload {
|
|
111
|
+
latitude: number;
|
|
112
|
+
longitude: number;
|
|
113
|
+
country: string;
|
|
114
|
+
region?: string;
|
|
115
|
+
reasons: string[];
|
|
116
|
+
}
|
|
117
|
+
interface KycStatusChangedPayload {
|
|
118
|
+
previous_status: string;
|
|
119
|
+
new_status: string;
|
|
120
|
+
provider?: string;
|
|
121
|
+
}
|
|
122
|
+
interface DecisionRecordedPayload {
|
|
123
|
+
decision_id: string;
|
|
124
|
+
decision_type: string;
|
|
125
|
+
category: string;
|
|
126
|
+
source: string;
|
|
127
|
+
risk_score?: number;
|
|
128
|
+
}
|
|
129
|
+
interface LabelAppliedPayload {
|
|
130
|
+
label_type: string;
|
|
131
|
+
reasons?: string[];
|
|
132
|
+
}
|
|
133
|
+
interface LocationRequestCompletedPayload {
|
|
134
|
+
request_id: string;
|
|
135
|
+
status: string;
|
|
136
|
+
latitude?: number;
|
|
137
|
+
longitude?: number;
|
|
138
|
+
}
|
|
139
|
+
interface ComplianceCheckFailedPayload {
|
|
140
|
+
check_type: string;
|
|
141
|
+
reasons: string[];
|
|
142
|
+
severity: string;
|
|
143
|
+
}
|
|
144
|
+
interface TaxReminderSentPayload {
|
|
145
|
+
/** W-form the reminder is for (e.g. "W-9", "W-8BEN", "W-8BEN-E") */
|
|
146
|
+
form_type: string;
|
|
147
|
+
/** Sequential count of reminders sent in the current solicitation cycle */
|
|
148
|
+
reminder_count: number;
|
|
149
|
+
/** Configured maximum reminders per cycle (reminder_max_count) */
|
|
150
|
+
max_count: number;
|
|
151
|
+
}
|
|
152
|
+
interface WebhookNotification {
|
|
153
|
+
id: string;
|
|
154
|
+
user_id?: string;
|
|
155
|
+
title?: string;
|
|
156
|
+
message?: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The `notification.created` envelope emitted by notification-service. Unlike the
|
|
160
|
+
* typed events it has no top-level `id`/`customer_id` and no `payload`; the data
|
|
161
|
+
* is nested under `notification`.
|
|
162
|
+
*/
|
|
163
|
+
interface NotificationWebhookEvent {
|
|
164
|
+
id?: UUID;
|
|
165
|
+
event_type: 'notification.created';
|
|
166
|
+
tenant_id: string;
|
|
167
|
+
environment: 'production' | 'sandbox';
|
|
168
|
+
customer_id?: string;
|
|
169
|
+
notification: WebhookNotification;
|
|
170
|
+
timestamp: Timestamp;
|
|
171
|
+
metadata?: Record<string, unknown>;
|
|
172
|
+
}
|
|
173
|
+
type WebhookEvent = NotificationWebhookEvent | 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>;
|
|
174
|
+
interface WebhookHandlerConfig {
|
|
175
|
+
/** Webhook signing secret for signature verification */
|
|
176
|
+
secret: string;
|
|
177
|
+
/** Header name containing the signature (default: 'x-webhook-signature') */
|
|
178
|
+
signatureHeader?: string;
|
|
179
|
+
/** Maximum age of webhook event in ms (default: 300000 = 5 minutes) */
|
|
180
|
+
tolerance?: number;
|
|
181
|
+
/** Enable replay protection to reject duplicate event IDs (default: true) */
|
|
182
|
+
replayProtection?: boolean;
|
|
183
|
+
/** Pluggable dedup store for replay protection (default: in-memory, process-local). */
|
|
184
|
+
dedupStore?: WebhookDedupStore;
|
|
185
|
+
/** Accept the legacy body-only `sha256=<hex>` signature during migration (default: true). */
|
|
186
|
+
allowLegacySignature?: boolean;
|
|
187
|
+
}
|
|
188
|
+
type WebhookEventHandler<T extends WebhookEventType = WebhookEventType> = (event: Extract<WebhookEvent, {
|
|
189
|
+
event_type: T;
|
|
190
|
+
}>) => void | Promise<void>;
|
|
191
|
+
type WebhookAnyHandler = (event: WebhookEvent) => void | Promise<void>;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Webhook event handler with signature verification and typed dispatch.
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
declare class WebhookHandler {
|
|
198
|
+
private handlers;
|
|
199
|
+
private anyHandlers;
|
|
200
|
+
private readonly secret;
|
|
201
|
+
private readonly tolerance;
|
|
202
|
+
private readonly replayProtection;
|
|
203
|
+
private readonly allowLegacySignature;
|
|
204
|
+
private readonly dedupStore;
|
|
205
|
+
constructor(config: WebhookHandlerConfig);
|
|
206
|
+
/**
|
|
207
|
+
* Register a handler for a specific event type.
|
|
208
|
+
*/
|
|
209
|
+
on<T extends WebhookEventType>(eventType: T, handler: WebhookEventHandler<T>): this;
|
|
210
|
+
/**
|
|
211
|
+
* Register a catch-all handler for all event types.
|
|
212
|
+
*/
|
|
213
|
+
onAny(handler: WebhookAnyHandler): this;
|
|
214
|
+
/**
|
|
215
|
+
* Verify signature and parse the webhook body.
|
|
216
|
+
*/
|
|
217
|
+
verifyAndParse(body: string, signature: string): Promise<WebhookEvent>;
|
|
218
|
+
/**
|
|
219
|
+
* Verify signature, parse, and dispatch to registered handlers.
|
|
220
|
+
*/
|
|
221
|
+
handle(body: string, signature: string): Promise<void>;
|
|
222
|
+
/**
|
|
223
|
+
* Parse an event without signature verification (for testing).
|
|
224
|
+
*/
|
|
225
|
+
parseEvent(body: string): Promise<WebhookEvent>;
|
|
226
|
+
private parseAndValidate;
|
|
227
|
+
private dispatch;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Framework middleware helpers for webhook handling.
|
|
232
|
+
*
|
|
233
|
+
* Provides pre-built integrations for Express/Connect and Next.js App Router.
|
|
234
|
+
*/
|
|
235
|
+
|
|
236
|
+
interface WebhookMiddlewareOptions extends WebhookHandlerConfig {
|
|
237
|
+
/** Event handlers to register */
|
|
238
|
+
handlers?: Partial<Record<WebhookEventType, WebhookEventHandler>>;
|
|
239
|
+
/** Catch-all handler */
|
|
240
|
+
onAny?: WebhookAnyHandler;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Create an Express/Connect-compatible middleware for webhook handling.
|
|
244
|
+
*
|
|
245
|
+
* Expects the raw body to be available as `req.body` (string).
|
|
246
|
+
* Use `express.raw({ type: 'application/json' })` or similar middleware upstream.
|
|
247
|
+
*/
|
|
248
|
+
declare function createWebhookMiddleware(options: WebhookMiddlewareOptions): (req: {
|
|
249
|
+
body: string | Buffer;
|
|
250
|
+
headers: Record<string, string | string[] | undefined>;
|
|
251
|
+
}, res: {
|
|
252
|
+
status(code: number): {
|
|
253
|
+
json(body: unknown): void;
|
|
254
|
+
};
|
|
255
|
+
json?(body: unknown): void;
|
|
256
|
+
}, next?: (err?: unknown) => void) => Promise<void>;
|
|
257
|
+
/**
|
|
258
|
+
* Create a Next.js App Router-compatible webhook handler.
|
|
259
|
+
*
|
|
260
|
+
* Returns an async function `(request: Request) => Promise<Response>`.
|
|
261
|
+
*/
|
|
262
|
+
declare function createNextWebhookHandler(options: WebhookMiddlewareOptions): (request: Request) => Promise<Response>;
|
|
263
|
+
|
|
264
|
+
export { type BaseWebhookEvent as B, type ComplianceCheckFailedPayload as C, type DecisionRecordedPayload as D, type GeolocationBlockedPayload as G, InMemoryDedupStore as I, type KycStatusChangedPayload as K, type LabelAppliedPayload as L, type NotificationWebhookEvent as N, type ProfileCreatedPayload as P, type RiskCategoryChangedPayload as R, type TaxReminderSentPayload as T, type VerifyWebhookSignatureOptions as V, type WebhookAnyHandler as W, type GeolocationVerifiedPayload as a, type InMemoryDedupStoreOptions as b, type LocationRequestCompletedPayload as c, type ProfileUpdatedPayload as d, type RiskScoreChangedPayload as e, type WebhookDedupStore as f, type WebhookEvent as g, type WebhookEventHandler as h, type WebhookEventType as i, WebhookHandler as j, type WebhookHandlerConfig as k, type WebhookMiddlewareOptions as l, type WebhookNotification as m, createNextWebhookHandler as n, createWebhookMiddleware as o, verifyWebhookSignature as v };
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { U as UUID, T as Timestamp, R as RiskLevel } from './types-CBQRNL-l.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pluggable dedup store for webhook replay protection.
|
|
5
|
+
*
|
|
6
|
+
* The default InMemoryDedupStore is process-local — correct for a single
|
|
7
|
+
* long-lived process, but useless across replicas / serverless invocations where
|
|
8
|
+
* the backend's at-least-once retries land on different instances. Supply a
|
|
9
|
+
* shared implementation (e.g. Redis with SETNX + TTL) via WebhookHandlerConfig
|
|
10
|
+
* to dedup reliably in those deployments.
|
|
11
|
+
*/
|
|
12
|
+
interface WebhookDedupStore {
|
|
13
|
+
/** Has this event id already been processed? */
|
|
14
|
+
seen(id: string): Promise<boolean>;
|
|
15
|
+
/** Record this event id as processed, retained for at least ttlMs. */
|
|
16
|
+
mark(id: string, ttlMs: number): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
interface InMemoryDedupStoreOptions {
|
|
19
|
+
/** Purge expired entries once the map grows past this size (default: 1000). */
|
|
20
|
+
maxEntries?: number;
|
|
21
|
+
/** Injectable clock (default: Date.now). */
|
|
22
|
+
now?: () => number;
|
|
23
|
+
}
|
|
24
|
+
declare class InMemoryDedupStore implements WebhookDedupStore {
|
|
25
|
+
private readonly expiryById;
|
|
26
|
+
private readonly maxEntries;
|
|
27
|
+
private readonly now;
|
|
28
|
+
constructor(opts?: InMemoryDedupStoreOptions);
|
|
29
|
+
seen(id: string): Promise<boolean>;
|
|
30
|
+
mark(id: string, ttlMs: number): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Webhook signature verification utilities.
|
|
35
|
+
*
|
|
36
|
+
* Supports both Web Crypto API (browsers, Deno, Cloudflare Workers)
|
|
37
|
+
* and Node.js crypto module with automatic runtime detection.
|
|
38
|
+
* Uses constant-time comparison to prevent timing attacks.
|
|
39
|
+
*/
|
|
40
|
+
interface VerifyWebhookSignatureOptions {
|
|
41
|
+
/** Max allowed clock skew in ms for the signed-timestamp scheme (default: 300000). */
|
|
42
|
+
tolerance?: number;
|
|
43
|
+
/** Clock source for the tolerance check (default: Date.now). */
|
|
44
|
+
now?: () => number;
|
|
45
|
+
/** Accept the legacy body-only `sha256=<hex>` format (default: true, for migration). */
|
|
46
|
+
allowLegacy?: boolean;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Verify an HMAC-SHA256 webhook signature.
|
|
50
|
+
*
|
|
51
|
+
* Supports two schemes:
|
|
52
|
+
* - Signed-timestamp (preferred): `t=<unix>,v1=<hex>` where the HMAC is computed
|
|
53
|
+
* over `${t}.${payload}`. The timestamp is inside the signed material, so a
|
|
54
|
+
* replayed body is rejected once `|now - t|` exceeds the tolerance — the check
|
|
55
|
+
* is done BEFORE the HMAC compare and authenticates the timestamp.
|
|
56
|
+
* - Legacy (body-only): `sha256=<hex>` (or raw hex) over the payload alone. Kept
|
|
57
|
+
* for the migration window; disable via `allowLegacy: false`.
|
|
58
|
+
*
|
|
59
|
+
* @returns true if the signature is valid
|
|
60
|
+
*/
|
|
61
|
+
declare function verifyWebhookSignature(payload: string, signature: string, secret: string, opts?: VerifyWebhookSignatureOptions): Promise<boolean>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Webhook event types and payload definitions.
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
type WebhookEventType = 'notification.created' | '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';
|
|
68
|
+
interface BaseWebhookEvent<T extends WebhookEventType = WebhookEventType, P = unknown> {
|
|
69
|
+
/**
|
|
70
|
+
* Top-level event id (typed events). The notification envelope carries none —
|
|
71
|
+
* the handler resolves the id from `notification.id`.
|
|
72
|
+
*/
|
|
73
|
+
id?: UUID;
|
|
74
|
+
event_type: T;
|
|
75
|
+
tenant_id: string;
|
|
76
|
+
environment: 'production' | 'sandbox';
|
|
77
|
+
/** Absent on the notification envelope; present on typed events. */
|
|
78
|
+
customer_id?: string;
|
|
79
|
+
payload: P;
|
|
80
|
+
timestamp: Timestamp;
|
|
81
|
+
metadata?: Record<string, unknown>;
|
|
82
|
+
}
|
|
83
|
+
interface RiskScoreChangedPayload {
|
|
84
|
+
previous_score: number;
|
|
85
|
+
new_score: number;
|
|
86
|
+
risk_level: RiskLevel;
|
|
87
|
+
factors: string[];
|
|
88
|
+
}
|
|
89
|
+
interface RiskCategoryChangedPayload {
|
|
90
|
+
previous_category: string;
|
|
91
|
+
new_category: string;
|
|
92
|
+
risk_level: RiskLevel;
|
|
93
|
+
}
|
|
94
|
+
interface ProfileCreatedPayload {
|
|
95
|
+
customer_id: string;
|
|
96
|
+
entity_type: string;
|
|
97
|
+
source: string;
|
|
98
|
+
}
|
|
99
|
+
interface ProfileUpdatedPayload {
|
|
100
|
+
customer_id: string;
|
|
101
|
+
updated_fields: string[];
|
|
102
|
+
}
|
|
103
|
+
interface GeolocationVerifiedPayload {
|
|
104
|
+
latitude: number;
|
|
105
|
+
longitude: number;
|
|
106
|
+
country: string;
|
|
107
|
+
region?: string;
|
|
108
|
+
is_compliant: boolean;
|
|
109
|
+
}
|
|
110
|
+
interface GeolocationBlockedPayload {
|
|
111
|
+
latitude: number;
|
|
112
|
+
longitude: number;
|
|
113
|
+
country: string;
|
|
114
|
+
region?: string;
|
|
115
|
+
reasons: string[];
|
|
116
|
+
}
|
|
117
|
+
interface KycStatusChangedPayload {
|
|
118
|
+
previous_status: string;
|
|
119
|
+
new_status: string;
|
|
120
|
+
provider?: string;
|
|
121
|
+
}
|
|
122
|
+
interface DecisionRecordedPayload {
|
|
123
|
+
decision_id: string;
|
|
124
|
+
decision_type: string;
|
|
125
|
+
category: string;
|
|
126
|
+
source: string;
|
|
127
|
+
risk_score?: number;
|
|
128
|
+
}
|
|
129
|
+
interface LabelAppliedPayload {
|
|
130
|
+
label_type: string;
|
|
131
|
+
reasons?: string[];
|
|
132
|
+
}
|
|
133
|
+
interface LocationRequestCompletedPayload {
|
|
134
|
+
request_id: string;
|
|
135
|
+
status: string;
|
|
136
|
+
latitude?: number;
|
|
137
|
+
longitude?: number;
|
|
138
|
+
}
|
|
139
|
+
interface ComplianceCheckFailedPayload {
|
|
140
|
+
check_type: string;
|
|
141
|
+
reasons: string[];
|
|
142
|
+
severity: string;
|
|
143
|
+
}
|
|
144
|
+
interface TaxReminderSentPayload {
|
|
145
|
+
/** W-form the reminder is for (e.g. "W-9", "W-8BEN", "W-8BEN-E") */
|
|
146
|
+
form_type: string;
|
|
147
|
+
/** Sequential count of reminders sent in the current solicitation cycle */
|
|
148
|
+
reminder_count: number;
|
|
149
|
+
/** Configured maximum reminders per cycle (reminder_max_count) */
|
|
150
|
+
max_count: number;
|
|
151
|
+
}
|
|
152
|
+
interface WebhookNotification {
|
|
153
|
+
id: string;
|
|
154
|
+
user_id?: string;
|
|
155
|
+
title?: string;
|
|
156
|
+
message?: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The `notification.created` envelope emitted by notification-service. Unlike the
|
|
160
|
+
* typed events it has no top-level `id`/`customer_id` and no `payload`; the data
|
|
161
|
+
* is nested under `notification`.
|
|
162
|
+
*/
|
|
163
|
+
interface NotificationWebhookEvent {
|
|
164
|
+
id?: UUID;
|
|
165
|
+
event_type: 'notification.created';
|
|
166
|
+
tenant_id: string;
|
|
167
|
+
environment: 'production' | 'sandbox';
|
|
168
|
+
customer_id?: string;
|
|
169
|
+
notification: WebhookNotification;
|
|
170
|
+
timestamp: Timestamp;
|
|
171
|
+
metadata?: Record<string, unknown>;
|
|
172
|
+
}
|
|
173
|
+
type WebhookEvent = NotificationWebhookEvent | 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>;
|
|
174
|
+
interface WebhookHandlerConfig {
|
|
175
|
+
/** Webhook signing secret for signature verification */
|
|
176
|
+
secret: string;
|
|
177
|
+
/** Header name containing the signature (default: 'x-webhook-signature') */
|
|
178
|
+
signatureHeader?: string;
|
|
179
|
+
/** Maximum age of webhook event in ms (default: 300000 = 5 minutes) */
|
|
180
|
+
tolerance?: number;
|
|
181
|
+
/** Enable replay protection to reject duplicate event IDs (default: true) */
|
|
182
|
+
replayProtection?: boolean;
|
|
183
|
+
/** Pluggable dedup store for replay protection (default: in-memory, process-local). */
|
|
184
|
+
dedupStore?: WebhookDedupStore;
|
|
185
|
+
/** Accept the legacy body-only `sha256=<hex>` signature during migration (default: true). */
|
|
186
|
+
allowLegacySignature?: boolean;
|
|
187
|
+
}
|
|
188
|
+
type WebhookEventHandler<T extends WebhookEventType = WebhookEventType> = (event: Extract<WebhookEvent, {
|
|
189
|
+
event_type: T;
|
|
190
|
+
}>) => void | Promise<void>;
|
|
191
|
+
type WebhookAnyHandler = (event: WebhookEvent) => void | Promise<void>;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Webhook event handler with signature verification and typed dispatch.
|
|
195
|
+
*/
|
|
196
|
+
|
|
197
|
+
declare class WebhookHandler {
|
|
198
|
+
private handlers;
|
|
199
|
+
private anyHandlers;
|
|
200
|
+
private readonly secret;
|
|
201
|
+
private readonly tolerance;
|
|
202
|
+
private readonly replayProtection;
|
|
203
|
+
private readonly allowLegacySignature;
|
|
204
|
+
private readonly dedupStore;
|
|
205
|
+
constructor(config: WebhookHandlerConfig);
|
|
206
|
+
/**
|
|
207
|
+
* Register a handler for a specific event type.
|
|
208
|
+
*/
|
|
209
|
+
on<T extends WebhookEventType>(eventType: T, handler: WebhookEventHandler<T>): this;
|
|
210
|
+
/**
|
|
211
|
+
* Register a catch-all handler for all event types.
|
|
212
|
+
*/
|
|
213
|
+
onAny(handler: WebhookAnyHandler): this;
|
|
214
|
+
/**
|
|
215
|
+
* Verify signature and parse the webhook body.
|
|
216
|
+
*/
|
|
217
|
+
verifyAndParse(body: string, signature: string): Promise<WebhookEvent>;
|
|
218
|
+
/**
|
|
219
|
+
* Verify signature, parse, and dispatch to registered handlers.
|
|
220
|
+
*/
|
|
221
|
+
handle(body: string, signature: string): Promise<void>;
|
|
222
|
+
/**
|
|
223
|
+
* Parse an event without signature verification (for testing).
|
|
224
|
+
*/
|
|
225
|
+
parseEvent(body: string): Promise<WebhookEvent>;
|
|
226
|
+
private parseAndValidate;
|
|
227
|
+
private dispatch;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Framework middleware helpers for webhook handling.
|
|
232
|
+
*
|
|
233
|
+
* Provides pre-built integrations for Express/Connect and Next.js App Router.
|
|
234
|
+
*/
|
|
235
|
+
|
|
236
|
+
interface WebhookMiddlewareOptions extends WebhookHandlerConfig {
|
|
237
|
+
/** Event handlers to register */
|
|
238
|
+
handlers?: Partial<Record<WebhookEventType, WebhookEventHandler>>;
|
|
239
|
+
/** Catch-all handler */
|
|
240
|
+
onAny?: WebhookAnyHandler;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Create an Express/Connect-compatible middleware for webhook handling.
|
|
244
|
+
*
|
|
245
|
+
* Expects the raw body to be available as `req.body` (string).
|
|
246
|
+
* Use `express.raw({ type: 'application/json' })` or similar middleware upstream.
|
|
247
|
+
*/
|
|
248
|
+
declare function createWebhookMiddleware(options: WebhookMiddlewareOptions): (req: {
|
|
249
|
+
body: string | Buffer;
|
|
250
|
+
headers: Record<string, string | string[] | undefined>;
|
|
251
|
+
}, res: {
|
|
252
|
+
status(code: number): {
|
|
253
|
+
json(body: unknown): void;
|
|
254
|
+
};
|
|
255
|
+
json?(body: unknown): void;
|
|
256
|
+
}, next?: (err?: unknown) => void) => Promise<void>;
|
|
257
|
+
/**
|
|
258
|
+
* Create a Next.js App Router-compatible webhook handler.
|
|
259
|
+
*
|
|
260
|
+
* Returns an async function `(request: Request) => Promise<Response>`.
|
|
261
|
+
*/
|
|
262
|
+
declare function createNextWebhookHandler(options: WebhookMiddlewareOptions): (request: Request) => Promise<Response>;
|
|
263
|
+
|
|
264
|
+
export { type BaseWebhookEvent as B, type ComplianceCheckFailedPayload as C, type DecisionRecordedPayload as D, type GeolocationBlockedPayload as G, InMemoryDedupStore as I, type KycStatusChangedPayload as K, type LabelAppliedPayload as L, type NotificationWebhookEvent as N, type ProfileCreatedPayload as P, type RiskCategoryChangedPayload as R, type TaxReminderSentPayload as T, type VerifyWebhookSignatureOptions as V, type WebhookAnyHandler as W, type GeolocationVerifiedPayload as a, type InMemoryDedupStoreOptions as b, type LocationRequestCompletedPayload as c, type ProfileUpdatedPayload as d, type RiskScoreChangedPayload as e, type WebhookDedupStore as f, type WebhookEvent as g, type WebhookEventHandler as h, type WebhookEventType as i, WebhookHandler as j, type WebhookHandlerConfig as k, type WebhookMiddlewareOptions as l, type WebhookNotification as m, createNextWebhookHandler as n, createWebhookMiddleware as o, verifyWebhookSignature as v };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,16 +1,33 @@
|
|
|
1
|
-
import { L as Logger } from './client-
|
|
2
|
-
export { B as BaseClient, a as BaseClientConfig, C as CGSConfig, b as CircuitBreaker, c as CircuitBreakerConfig, d as CircuitBreakerState, e as CircuitBreakerStatus, f as RateLimitStatus, g as RateLimitTracker, h as RequestInterceptor, R as RequestOptions,
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
1
|
+
import { L as Logger } from './client-q9fN8Hhf.mjs';
|
|
2
|
+
export { A as AuthCredential, B as BaseClient, a as BaseClientConfig, C as CGSConfig, b as CircuitBreaker, c as CircuitBreakerConfig, d as CircuitBreakerState, e as CircuitBreakerStatus, f as RateLimitStatus, g as RateLimitTracker, h as RefreshingTokenProvider, i as RefreshingTokenProviderOptions, j as RequestInterceptor, R as RequestOptions, k as RequiredBaseClientConfig, l as RequiredCGSConfig, m as RequiredVesantConfig, S as StaticApiKeyProvider, T as TokenProvider, n as TokenProviderContext, V as VesantConfig } from './client-q9fN8Hhf.mjs';
|
|
3
|
+
import { a as PaginatedResponse } from './types-CBQRNL-l.mjs';
|
|
4
|
+
export { A as APIResponse, B as BlockReason, C as CustomerStatus, E as EntityType, b as ErrorResponse, L as LocationCompliance, P as PaginationParams, c as Reason, d as Result, R as RiskLevel, S as SuccessResponse, T as Timestamp, U as UUID, V as VerificationEventType } from './types-CBQRNL-l.mjs';
|
|
5
|
+
export { B as BaseWebhookEvent, C as ComplianceCheckFailedPayload, D as DecisionRecordedPayload, G as GeolocationBlockedPayload, a as GeolocationVerifiedPayload, I as InMemoryDedupStore, b as InMemoryDedupStoreOptions, K as KycStatusChangedPayload, L as LabelAppliedPayload, c as LocationRequestCompletedPayload, N as NotificationWebhookEvent, P as ProfileCreatedPayload, d as ProfileUpdatedPayload, R as RiskCategoryChangedPayload, e as RiskScoreChangedPayload, T as TaxReminderSentPayload, V as VerifyWebhookSignatureOptions, W as WebhookAnyHandler, f as WebhookDedupStore, g as WebhookEvent, h as WebhookEventHandler, i as WebhookEventType, j as WebhookHandler, k as WebhookHandlerConfig, l as WebhookMiddlewareOptions, m as WebhookNotification, n as createNextWebhookHandler, o as createWebhookMiddleware, v as verifyWebhookSignature } from './index-C3zUKydT.mjs';
|
|
6
|
+
export { A as APIError, d as AlertFilters, e as AlertListResponse, f as AlertSeverity, g as AlertStatus, h as AlertType, C as CipherTextCustomerData, i as CipherTextOptions, j as CipherTextPayload, k as CipherTextReason, l as CipherTextResult, m as ComplianceCheckResponse, n as CreateGeofenceRuleRequest, o as CreateJurisdictionRequest, p as CreateLocationRequestRequest, q as DashboardMetrics, r as DecryptedCipherText, s as DeviceFingerprint, D as DeviceFingerprintRequest, t as DeviceTrustResult, u as GeoIPResult, v as GeofenceAction, w as GeofenceEvaluation, x as GeofenceRule, y as GeofenceRuleType, z as GeolocationAlert, G as GeolocationClient, B as GeolocationClientConfig, E as GeolocationConfigResponse, F as GeolocationRecord, J as JurisdictionConfig, H as LocationCaptureRequest, I as LocationCaptureResponse, a as LocationRequest, K as LocationRequestChannel, b as LocationRequestFilters, c as LocationRequestListResponse, M as LocationRequestResult, N as LocationRequestStatus, O as LocationShareInfo, L as LocationVerification, R as ResendLocationRequestRequest, U as UpdateDeviceTrustRequest, P as UpdateGeofenceRuleRequest, Q as UpdateJurisdictionRequest, S as UseAlertsOptions, T as UseAlertsResult, W as UseGeolocationOptions, X as UseGeolocationResult, Y as UseLocationCaptureOptions, Z as UseLocationCaptureResult, _ as UseLocationRequestsOptions, $ as UseLocationRequestsResult, a0 as ValidateCipherTextRequest, V as ValidateCipherTextResponse, a1 as VerifyIPRequest } from './client-CvWNRwwg.mjs';
|
|
7
|
+
export { GpsIntegrityInput, GpsIntegrityOptions, GpsIntegrityResult, assessGpsIntegrity, decodeCipherText, generateCipherText, gpsIntegrityInputFromPosition, isCipherTextExpired, probeGeolocationPermission } from './geolocation/index.mjs';
|
|
7
8
|
export { RiskProfileClient } from './risk-profile/index.mjs';
|
|
8
9
|
export { a as CreateCustomerProfileRequest, a as CreateProfileRequest, C as CustomerProfile, P as CustomerProfileFilters, b as CustomerProfileListResponse, E as EmploymentType, L as LegalForm, c as ProfileDetailsResponse, P as ProfileFilters, b as ProfileListResponse, R as RiskCategory, d as RiskConfiguration, e as RiskDashboardMetrics, f as RiskFactor, g as RiskFactorType, h as RiskHistory, S as ScreeningStatus, U as UpdateProfileRequest } from './types-BOFaMQxI.mjs';
|
|
9
10
|
export { sdkReasons } from './compliance/index.mjs';
|
|
10
|
-
export { C as ComplianceClient, a as ComplianceLocationRequestInput, b as ComplianceLocationRequestResult, c as CurrencyRates, D as DEFAULT_CURRENCY_RATES, E as EventVerificationRequest, d as EventVerificationResponse, L as LoginVerificationRequest, e as LoginVerificationResponse, R as RegistrationVerificationRequest, f as RegistrationVerificationResponse, T as TransactionRiskResult, g as TransactionVerificationRequest, h as TransactionVerificationResponse } from './client-
|
|
11
|
-
export { CheckKycStatusRequest, CheckKycStatusResponse, CreateEventBasedFaceVerificationSessionRequest, CreateEventBasedFaceVerificationSessionResponse, DocumentType, DocumentVerificationRequest, DocumentVerificationResponse, EventBasedFaceVerificationCallback, EventBasedFaceVerificationDeviceType, EventBasedFaceVerificationEvent, EventBasedFaceVerificationFrequencyTrigger, EventBasedFaceVerificationReactionResult, EventBasedFaceVerificationReactions, EventBasedFaceVerificationThresholdTrigger, EventBasedFaceVerificationTriggers, FaceProof, KYC_DECLINED_DESCRIPTIONS, KycAlert, KycAlertFilters, KycAlertListResponse, KycAlertStatus, KycAlertType, KycClient, KycClientConfig, KycCustomerProfile, KycDeclinedCode, KycHandoffSession, KycOverview, KycPagination, KycPreferences, KycRequest, KycRequestFilters, KycRequestListResponse, KycStatus, Name, Proof, ProofDownloadURL, ProofType, RequestAdditionalDocumentsRequest, RequestKycSubmitLinkRequest, RequestKycSubmitLinkResponse, SubmitEventBasedFaceVerificationSessionRequest, SubmittedDocument, SupportedDocumentType, UpdateKycAlertRequest, UpdateKycPreferencesRequest, UpdateKycStatusRequest, UseKycAlertsOptions, UseKycAlertsResult, UseKycOverviewOptions, UseKycOverviewResult, UseKycPreferencesResult, UseKycRequestsOptions, UseKycRequestsResult, UseKycSubmissionOptions, UseKycSubmissionResult } from './kyc/index.mjs';
|
|
11
|
+
export { C as ComplianceClient, a as ComplianceLocationRequestInput, b as ComplianceLocationRequestResult, c as CurrencyRates, D as DEFAULT_CURRENCY_RATES, E as EventVerificationRequest, d as EventVerificationResponse, L as LoginVerificationRequest, e as LoginVerificationResponse, R as RegistrationVerificationRequest, f as RegistrationVerificationResponse, T as TransactionRiskResult, g as TransactionVerificationRequest, h as TransactionVerificationResponse } from './client-Dps40EtF.mjs';
|
|
12
|
+
export { CheckKycStatusRequest, CheckKycStatusResponse, CreateEventBasedFaceVerificationSessionRequest, CreateEventBasedFaceVerificationSessionResponse, DocumentType, DocumentVerificationRequest, DocumentVerificationResponse, EventBasedFaceVerificationCallback, EventBasedFaceVerificationDeviceType, EventBasedFaceVerificationEvent, EventBasedFaceVerificationFrequencyTrigger, EventBasedFaceVerificationReactionResult, EventBasedFaceVerificationReactions, EventBasedFaceVerificationThresholdTrigger, EventBasedFaceVerificationTriggers, FaceProof, KYC_DECLINED_DESCRIPTIONS, KycAlert, KycAlertFilters, KycAlertListResponse, KycAlertStatus, KycAlertType, KycClient, KycClientConfig, KycCustomerData, KycCustomerProfile, KycDeclinedCode, KycHandoffSession, KycOverview, KycPagination, KycPreferences, KycRequest, KycRequestFilters, KycRequestListResponse, KycStatus, Name, Proof, ProofDownloadURL, ProofType, RequestAdditionalDocumentsRequest, RequestKycSubmitLinkRequest, RequestKycSubmitLinkResponse, SubmitEventBasedFaceVerificationSessionRequest, SubmittedDocument, SupportedDocumentType, UpdateKycAlertRequest, UpdateKycPreferencesRequest, UpdateKycStatusRequest, UseKycAlertsOptions, UseKycAlertsResult, UseKycOverviewOptions, UseKycOverviewResult, UseKycPreferencesResult, UseKycRequestsOptions, UseKycRequestsResult, UseKycSubmissionOptions, UseKycSubmissionResult } from './kyc/index.mjs';
|
|
12
13
|
export { CTPFormStatus, CTPTINStatus, ComplianceStats, ComplianceStatsFilters, CustomerTaxProfileDocuments, CustomerTaxProfileRecord, CustomerType, DocumentRequestBreakdown, EmailSendingMethod, EnableWithholdingInput, EnableWithholdingResponse, GlobalTaxRule, ReRequestTaxFormInput, RemindersRunResult, TINCheckResult, TINStatusBreakdown, TaxClient, TaxClientConfig, TaxRuleApprovalStatus, TaxRuleVersion, TaxRules, TransactionAction, TreatyCountry, TreatyCountryListResponse, UpdateTaxRulesInput, WFormCountBreakdown, WFormStatusBreakdown } from './tax/index.mjs';
|
|
13
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Lazily walk every item across all pages of a paginated endpoint. `fetchPage`
|
|
17
|
+
* is called with a 1-based page number and must return a PaginatedResponse.
|
|
18
|
+
* Iteration advances until `total_pages` is reached, and stops early if a page
|
|
19
|
+
* returns no items (a guard against a runaway loop on an over-reported
|
|
20
|
+
* total_pages). Pages are fetched on demand as the consumer iterates.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* for await (const profile of paginate((page) => client.listProfiles({ page }))) {
|
|
24
|
+
* // ...
|
|
25
|
+
* }
|
|
26
|
+
*/
|
|
27
|
+
declare function paginate<T>(fetchPage: (page: number) => Promise<PaginatedResponse<T>>): AsyncGenerator<T, void, void>;
|
|
28
|
+
/** Collect every item from a paginated endpoint into a single array. */
|
|
29
|
+
declare function collectAll<T>(fetchPage: (page: number) => Promise<PaginatedResponse<T>>): Promise<T[]>;
|
|
30
|
+
|
|
14
31
|
/**
|
|
15
32
|
* Error hierarchy for Vesant SDK
|
|
16
33
|
*
|
|
@@ -68,4 +85,4 @@ declare const noopLogger: Logger;
|
|
|
68
85
|
*/
|
|
69
86
|
declare const SDK_VERSION = "1.7.0";
|
|
70
87
|
|
|
71
|
-
export { AuthenticationError, CGSError, CircuitBreakerOpenError, ComplianceBlockedError, ComplianceError, Logger, NetworkError, RateLimitError, SDK_VERSION, ServiceUnavailableError, TimeoutError, ValidationError, VesantError, createConsoleLogger, noopLogger };
|
|
88
|
+
export { AuthenticationError, CGSError, CircuitBreakerOpenError, ComplianceBlockedError, ComplianceError, Logger, NetworkError, PaginatedResponse, RateLimitError, SDK_VERSION, ServiceUnavailableError, TimeoutError, ValidationError, VesantError, collectAll, createConsoleLogger, noopLogger, paginate };
|