vesant-sdk 1.6.2 → 1.6.3

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.
@@ -1,177 +1,2 @@
1
- import { U as UUID, T as Timestamp, R as RiskLevel } from '../types-B4Ezqo7V.mjs';
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
- * Webhook event types and payload definitions.
22
- */
23
-
24
- 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';
25
- interface BaseWebhookEvent<T extends WebhookEventType = WebhookEventType, P = unknown> {
26
- id: UUID;
27
- type: T;
28
- tenant_id: string;
29
- environment: 'production' | 'sandbox';
30
- customer_id: string;
31
- payload: P;
32
- timestamp: Timestamp;
33
- }
34
- interface RiskScoreChangedPayload {
35
- previous_score: number;
36
- new_score: number;
37
- risk_level: RiskLevel;
38
- factors: string[];
39
- }
40
- interface RiskCategoryChangedPayload {
41
- previous_category: string;
42
- new_category: string;
43
- risk_level: RiskLevel;
44
- }
45
- interface ProfileCreatedPayload {
46
- customer_id: string;
47
- entity_type: string;
48
- source: string;
49
- }
50
- interface ProfileUpdatedPayload {
51
- customer_id: string;
52
- updated_fields: string[];
53
- }
54
- interface GeolocationVerifiedPayload {
55
- latitude: number;
56
- longitude: number;
57
- country: string;
58
- region?: string;
59
- is_compliant: boolean;
60
- }
61
- interface GeolocationBlockedPayload {
62
- latitude: number;
63
- longitude: number;
64
- country: string;
65
- region?: string;
66
- reasons: string[];
67
- }
68
- interface KycStatusChangedPayload {
69
- previous_status: string;
70
- new_status: string;
71
- provider?: string;
72
- }
73
- interface DecisionRecordedPayload {
74
- decision_id: string;
75
- decision_type: string;
76
- category: string;
77
- source: string;
78
- risk_score?: number;
79
- }
80
- interface LabelAppliedPayload {
81
- label_type: string;
82
- reasons?: string[];
83
- }
84
- interface LocationRequestCompletedPayload {
85
- request_id: string;
86
- status: string;
87
- latitude?: number;
88
- longitude?: number;
89
- }
90
- interface ComplianceCheckFailedPayload {
91
- check_type: string;
92
- reasons: string[];
93
- severity: string;
94
- }
95
- 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>;
96
- interface WebhookHandlerConfig {
97
- /** Webhook signing secret for signature verification */
98
- secret: string;
99
- /** Header name containing the signature (default: 'x-webhook-signature') */
100
- signatureHeader?: string;
101
- /** Maximum age of webhook event in ms (default: 300000 = 5 minutes) */
102
- tolerance?: number;
103
- }
104
- type WebhookEventHandler<T extends WebhookEventType = WebhookEventType> = (event: Extract<WebhookEvent, {
105
- type: T;
106
- }>) => void | Promise<void>;
107
- type WebhookAnyHandler = (event: WebhookEvent) => void | Promise<void>;
108
-
109
- /**
110
- * Webhook event handler with signature verification and typed dispatch.
111
- */
112
-
113
- declare class WebhookHandler {
114
- private handlers;
115
- private anyHandlers;
116
- private readonly secret;
117
- private readonly tolerance;
118
- constructor(config: WebhookHandlerConfig);
119
- /**
120
- * Register a handler for a specific event type.
121
- */
122
- on<T extends WebhookEventType>(eventType: T, handler: WebhookEventHandler<T>): this;
123
- /**
124
- * Register a catch-all handler for all event types.
125
- */
126
- onAny(handler: WebhookAnyHandler): this;
127
- /**
128
- * Verify signature and parse the webhook body.
129
- */
130
- verifyAndParse(body: string, signature: string): Promise<WebhookEvent>;
131
- /**
132
- * Verify signature, parse, and dispatch to registered handlers.
133
- */
134
- handle(body: string, signature: string): Promise<void>;
135
- /**
136
- * Parse an event without signature verification (for testing).
137
- */
138
- parseEvent(body: string): WebhookEvent;
139
- private parseAndValidate;
140
- private dispatch;
141
- }
142
-
143
- /**
144
- * Framework middleware helpers for webhook handling.
145
- *
146
- * Provides pre-built integrations for Express/Connect and Next.js App Router.
147
- */
148
-
149
- interface WebhookMiddlewareOptions extends WebhookHandlerConfig {
150
- /** Event handlers to register */
151
- handlers?: Partial<Record<WebhookEventType, WebhookEventHandler>>;
152
- /** Catch-all handler */
153
- onAny?: WebhookAnyHandler;
154
- }
155
- /**
156
- * Create an Express/Connect-compatible middleware for webhook handling.
157
- *
158
- * Expects the raw body to be available as `req.body` (string).
159
- * Use `express.raw({ type: 'application/json' })` or similar middleware upstream.
160
- */
161
- declare function createWebhookMiddleware(options: WebhookMiddlewareOptions): (req: {
162
- body: string | Buffer;
163
- headers: Record<string, string | string[] | undefined>;
164
- }, res: {
165
- status(code: number): {
166
- json(body: unknown): void;
167
- };
168
- json?(body: unknown): void;
169
- }, next?: (err?: unknown) => void) => Promise<void>;
170
- /**
171
- * Create a Next.js App Router-compatible webhook handler.
172
- *
173
- * Returns an async function `(request: Request) => Promise<Response>`.
174
- */
175
- declare function createNextWebhookHandler(options: WebhookMiddlewareOptions): (request: Request) => Promise<Response>;
176
-
177
- export { type BaseWebhookEvent, type ComplianceCheckFailedPayload, type DecisionRecordedPayload, type GeolocationBlockedPayload, type GeolocationVerifiedPayload, type KycStatusChangedPayload, type LabelAppliedPayload, type LocationRequestCompletedPayload, type ProfileCreatedPayload, type ProfileUpdatedPayload, type RiskCategoryChangedPayload, type RiskScoreChangedPayload, type WebhookAnyHandler, type WebhookEvent, type WebhookEventHandler, type WebhookEventType, WebhookHandler, type WebhookHandlerConfig, type WebhookMiddlewareOptions, createNextWebhookHandler, createWebhookMiddleware, verifyWebhookSignature };
1
+ export { B as BaseWebhookEvent, C as ComplianceCheckFailedPayload, D as DecisionRecordedPayload, o as GeolocationBlockedPayload, G as GeolocationVerifiedPayload, K as KycStatusChangedPayload, L as LabelAppliedPayload, p as LocationRequestCompletedPayload, P as ProfileCreatedPayload, n as ProfileUpdatedPayload, m as RiskCategoryChangedPayload, R as RiskScoreChangedPayload, r as TaxFormType, s as TaxReminderSentPayload, q as TaxReminderType, t as TransactionCallbackPayload, y as WebhookAnyHandler, u as WebhookEvent, x as WebhookEventHandler, l as WebhookEventType, W as WebhookHandler, w as WebhookHandlerConfig, i as WebhookMiddlewareOptions, k as createNextWebhookHandler, j as createWebhookMiddleware, v as verifyWebhookSignature } from '../index-B04H4xfJ.mjs';
2
+ import '../types-B4Ezqo7V.mjs';
@@ -1,177 +1,2 @@
1
- import { U as UUID, T as Timestamp, 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
- * Webhook event types and payload definitions.
22
- */
23
-
24
- 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';
25
- interface BaseWebhookEvent<T extends WebhookEventType = WebhookEventType, P = unknown> {
26
- id: UUID;
27
- type: T;
28
- tenant_id: string;
29
- environment: 'production' | 'sandbox';
30
- customer_id: string;
31
- payload: P;
32
- timestamp: Timestamp;
33
- }
34
- interface RiskScoreChangedPayload {
35
- previous_score: number;
36
- new_score: number;
37
- risk_level: RiskLevel;
38
- factors: string[];
39
- }
40
- interface RiskCategoryChangedPayload {
41
- previous_category: string;
42
- new_category: string;
43
- risk_level: RiskLevel;
44
- }
45
- interface ProfileCreatedPayload {
46
- customer_id: string;
47
- entity_type: string;
48
- source: string;
49
- }
50
- interface ProfileUpdatedPayload {
51
- customer_id: string;
52
- updated_fields: string[];
53
- }
54
- interface GeolocationVerifiedPayload {
55
- latitude: number;
56
- longitude: number;
57
- country: string;
58
- region?: string;
59
- is_compliant: boolean;
60
- }
61
- interface GeolocationBlockedPayload {
62
- latitude: number;
63
- longitude: number;
64
- country: string;
65
- region?: string;
66
- reasons: string[];
67
- }
68
- interface KycStatusChangedPayload {
69
- previous_status: string;
70
- new_status: string;
71
- provider?: string;
72
- }
73
- interface DecisionRecordedPayload {
74
- decision_id: string;
75
- decision_type: string;
76
- category: string;
77
- source: string;
78
- risk_score?: number;
79
- }
80
- interface LabelAppliedPayload {
81
- label_type: string;
82
- reasons?: string[];
83
- }
84
- interface LocationRequestCompletedPayload {
85
- request_id: string;
86
- status: string;
87
- latitude?: number;
88
- longitude?: number;
89
- }
90
- interface ComplianceCheckFailedPayload {
91
- check_type: string;
92
- reasons: string[];
93
- severity: string;
94
- }
95
- 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>;
96
- interface WebhookHandlerConfig {
97
- /** Webhook signing secret for signature verification */
98
- secret: string;
99
- /** Header name containing the signature (default: 'x-webhook-signature') */
100
- signatureHeader?: string;
101
- /** Maximum age of webhook event in ms (default: 300000 = 5 minutes) */
102
- tolerance?: number;
103
- }
104
- type WebhookEventHandler<T extends WebhookEventType = WebhookEventType> = (event: Extract<WebhookEvent, {
105
- type: T;
106
- }>) => void | Promise<void>;
107
- type WebhookAnyHandler = (event: WebhookEvent) => void | Promise<void>;
108
-
109
- /**
110
- * Webhook event handler with signature verification and typed dispatch.
111
- */
112
-
113
- declare class WebhookHandler {
114
- private handlers;
115
- private anyHandlers;
116
- private readonly secret;
117
- private readonly tolerance;
118
- constructor(config: WebhookHandlerConfig);
119
- /**
120
- * Register a handler for a specific event type.
121
- */
122
- on<T extends WebhookEventType>(eventType: T, handler: WebhookEventHandler<T>): this;
123
- /**
124
- * Register a catch-all handler for all event types.
125
- */
126
- onAny(handler: WebhookAnyHandler): this;
127
- /**
128
- * Verify signature and parse the webhook body.
129
- */
130
- verifyAndParse(body: string, signature: string): Promise<WebhookEvent>;
131
- /**
132
- * Verify signature, parse, and dispatch to registered handlers.
133
- */
134
- handle(body: string, signature: string): Promise<void>;
135
- /**
136
- * Parse an event without signature verification (for testing).
137
- */
138
- parseEvent(body: string): WebhookEvent;
139
- private parseAndValidate;
140
- private dispatch;
141
- }
142
-
143
- /**
144
- * Framework middleware helpers for webhook handling.
145
- *
146
- * Provides pre-built integrations for Express/Connect and Next.js App Router.
147
- */
148
-
149
- interface WebhookMiddlewareOptions extends WebhookHandlerConfig {
150
- /** Event handlers to register */
151
- handlers?: Partial<Record<WebhookEventType, WebhookEventHandler>>;
152
- /** Catch-all handler */
153
- onAny?: WebhookAnyHandler;
154
- }
155
- /**
156
- * Create an Express/Connect-compatible middleware for webhook handling.
157
- *
158
- * Expects the raw body to be available as `req.body` (string).
159
- * Use `express.raw({ type: 'application/json' })` or similar middleware upstream.
160
- */
161
- declare function createWebhookMiddleware(options: WebhookMiddlewareOptions): (req: {
162
- body: string | Buffer;
163
- headers: Record<string, string | string[] | undefined>;
164
- }, res: {
165
- status(code: number): {
166
- json(body: unknown): void;
167
- };
168
- json?(body: unknown): void;
169
- }, next?: (err?: unknown) => void) => Promise<void>;
170
- /**
171
- * Create a Next.js App Router-compatible webhook handler.
172
- *
173
- * Returns an async function `(request: Request) => Promise<Response>`.
174
- */
175
- declare function createNextWebhookHandler(options: WebhookMiddlewareOptions): (request: Request) => Promise<Response>;
176
-
177
- export { type BaseWebhookEvent, type ComplianceCheckFailedPayload, type DecisionRecordedPayload, type GeolocationBlockedPayload, type GeolocationVerifiedPayload, type KycStatusChangedPayload, type LabelAppliedPayload, type LocationRequestCompletedPayload, type ProfileCreatedPayload, type ProfileUpdatedPayload, type RiskCategoryChangedPayload, type RiskScoreChangedPayload, type WebhookAnyHandler, type WebhookEvent, type WebhookEventHandler, type WebhookEventType, WebhookHandler, type WebhookHandlerConfig, type WebhookMiddlewareOptions, createNextWebhookHandler, createWebhookMiddleware, verifyWebhookSignature };
1
+ export { B as BaseWebhookEvent, C as ComplianceCheckFailedPayload, D as DecisionRecordedPayload, o as GeolocationBlockedPayload, G as GeolocationVerifiedPayload, K as KycStatusChangedPayload, L as LabelAppliedPayload, p as LocationRequestCompletedPayload, P as ProfileCreatedPayload, n as ProfileUpdatedPayload, m as RiskCategoryChangedPayload, R as RiskScoreChangedPayload, r as TaxFormType, s as TaxReminderSentPayload, q as TaxReminderType, t as TransactionCallbackPayload, y as WebhookAnyHandler, u as WebhookEvent, x as WebhookEventHandler, l as WebhookEventType, W as WebhookHandler, w as WebhookHandlerConfig, i as WebhookMiddlewareOptions, k as createNextWebhookHandler, j as createWebhookMiddleware, v as verifyWebhookSignature } from '../index-CItMPmLL.js';
2
+ import '../types-B4Ezqo7V.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vesant-sdk",
3
- "version": "1.6.2",
3
+ "version": "1.6.3",
4
4
  "description": "TypeScript SDK for Vesant Compliance Platform - Geolocation, KYC, Risk Profiling, CipherText, and Compliance Orchestration",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -60,6 +60,11 @@
60
60
  "types": "./dist/tax/index.d.ts",
61
61
  "import": "./dist/tax/index.mjs",
62
62
  "require": "./dist/tax/index.js"
63
+ },
64
+ "./fraud": {
65
+ "types": "./dist/fraud/index.d.ts",
66
+ "import": "./dist/fraud/index.mjs",
67
+ "require": "./dist/fraud/index.js"
63
68
  }
64
69
  },
65
70
  "files": [