@webhooks-cc/sdk 0.3.1 → 0.5.0
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/index.d.mts +63 -1
- package/dist/index.d.ts +63 -1
- package/dist/index.js +744 -2
- package/dist/index.mjs +743 -2
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -73,6 +73,28 @@ interface SendOptions {
|
|
|
73
73
|
/** Request body (will be JSON-serialized if not a string) */
|
|
74
74
|
body?: unknown;
|
|
75
75
|
}
|
|
76
|
+
type TemplateProvider = "stripe" | "github" | "shopify" | "twilio" | "standard-webhooks";
|
|
77
|
+
/**
|
|
78
|
+
* Options for sending a provider template webhook with signed headers.
|
|
79
|
+
*/
|
|
80
|
+
interface SendTemplateOptions {
|
|
81
|
+
/** Provider template to use */
|
|
82
|
+
provider: TemplateProvider;
|
|
83
|
+
/** Provider-specific template preset (uses provider default if omitted) */
|
|
84
|
+
template?: string;
|
|
85
|
+
/** Shared secret used for provider signature generation */
|
|
86
|
+
secret: string;
|
|
87
|
+
/** Provider event/topic name (provider default used if omitted) */
|
|
88
|
+
event?: string;
|
|
89
|
+
/** HTTP method override (default: "POST") */
|
|
90
|
+
method?: string;
|
|
91
|
+
/** Additional headers merged after template headers */
|
|
92
|
+
headers?: Record<string, string>;
|
|
93
|
+
/** Body override; if omitted a provider-specific template body is generated */
|
|
94
|
+
body?: unknown;
|
|
95
|
+
/** Unix timestamp (seconds) override for deterministic signatures in tests */
|
|
96
|
+
timestamp?: number;
|
|
97
|
+
}
|
|
76
98
|
/**
|
|
77
99
|
* Options for listing captured requests.
|
|
78
100
|
*/
|
|
@@ -150,10 +172,33 @@ interface OperationDescription {
|
|
|
150
172
|
description: string;
|
|
151
173
|
params: Record<string, string>;
|
|
152
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Options for sending a webhook directly to an arbitrary URL.
|
|
177
|
+
* Supports optional provider signing (Standard Webhooks, Stripe, etc.).
|
|
178
|
+
*/
|
|
179
|
+
interface SendToOptions {
|
|
180
|
+
/** Provider template for signing (optional). When set, secret is required. */
|
|
181
|
+
provider?: TemplateProvider;
|
|
182
|
+
/** Provider-specific template preset (e.g. "checkout.session.completed" for Stripe) */
|
|
183
|
+
template?: string;
|
|
184
|
+
/** Secret for provider signature generation (required when provider is set) */
|
|
185
|
+
secret?: string;
|
|
186
|
+
/** Event name for provider headers */
|
|
187
|
+
event?: string;
|
|
188
|
+
/** HTTP method (default: "POST") */
|
|
189
|
+
method?: string;
|
|
190
|
+
/** HTTP headers to include */
|
|
191
|
+
headers?: Record<string, string>;
|
|
192
|
+
/** Request body (will be JSON-serialized if not a string) */
|
|
193
|
+
body?: unknown;
|
|
194
|
+
/** Unix timestamp (seconds) override for deterministic signatures in tests */
|
|
195
|
+
timestamp?: number;
|
|
196
|
+
}
|
|
153
197
|
/** Self-describing schema returned by client.describe(). */
|
|
154
198
|
interface SDKDescription {
|
|
155
199
|
version: string;
|
|
156
200
|
endpoints: Record<string, OperationDescription>;
|
|
201
|
+
sendTo: OperationDescription;
|
|
157
202
|
requests: Record<string, OperationDescription>;
|
|
158
203
|
}
|
|
159
204
|
|
|
@@ -228,7 +273,18 @@ declare class WebhooksCC {
|
|
|
228
273
|
update: (slug: string, options: UpdateEndpointOptions) => Promise<Endpoint>;
|
|
229
274
|
delete: (slug: string) => Promise<void>;
|
|
230
275
|
send: (slug: string, options?: SendOptions) => Promise<Response>;
|
|
276
|
+
sendTemplate: (slug: string, options: SendTemplateOptions) => Promise<Response>;
|
|
231
277
|
};
|
|
278
|
+
/**
|
|
279
|
+
* Send a webhook directly to any URL with optional provider signing.
|
|
280
|
+
* Use this for local integration testing — send properly signed webhooks
|
|
281
|
+
* to localhost handlers without routing through webhooks.cc infrastructure.
|
|
282
|
+
*
|
|
283
|
+
* @param url - Target URL to send the webhook to (http or https)
|
|
284
|
+
* @param options - Method, headers, body, and optional provider signing
|
|
285
|
+
* @returns Raw fetch Response from the target
|
|
286
|
+
*/
|
|
287
|
+
sendTo: (url: string, options?: SendToOptions) => Promise<Response>;
|
|
232
288
|
requests: {
|
|
233
289
|
list: (endpointSlug: string, options?: ListRequestsOptions) => Promise<Request[]>;
|
|
234
290
|
get: (requestId: string) => Promise<Request>;
|
|
@@ -302,6 +358,12 @@ declare function isTwilioWebhook(request: Request): boolean;
|
|
|
302
358
|
declare function isPaddleWebhook(request: Request): boolean;
|
|
303
359
|
/** Check if a request looks like a Linear webhook. */
|
|
304
360
|
declare function isLinearWebhook(request: Request): boolean;
|
|
361
|
+
/**
|
|
362
|
+
* Check if a request looks like a Standard Webhooks request.
|
|
363
|
+
* Matches on the presence of all three Standard Webhooks headers:
|
|
364
|
+
* webhook-id, webhook-timestamp, and webhook-signature.
|
|
365
|
+
*/
|
|
366
|
+
declare function isStandardWebhook(request: Request): boolean;
|
|
305
367
|
|
|
306
368
|
/** Match requests by HTTP method (case-insensitive). */
|
|
307
369
|
declare function matchMethod(method: string): (request: Request) => boolean;
|
|
@@ -353,4 +415,4 @@ interface SSEFrame {
|
|
|
353
415
|
*/
|
|
354
416
|
declare function parseSSE(stream: ReadableStream<Uint8Array>): AsyncGenerator<SSEFrame, void, undefined>;
|
|
355
417
|
|
|
356
|
-
export { ApiError, type ClientHooks, type ClientOptions, type CreateEndpointOptions, type Endpoint, type ErrorHookInfo, type ListRequestsOptions, NotFoundError, type OperationDescription, RateLimitError, type Request, type RequestHookInfo, type ResponseHookInfo, type SDKDescription, type SSEFrame, type SendOptions, type SubscribeOptions, TimeoutError, UnauthorizedError, type UpdateEndpointOptions, type WaitForOptions, WebhooksCC, WebhooksCCError, isGitHubWebhook, isLinearWebhook, isPaddleWebhook, isShopifyWebhook, isSlackWebhook, isStripeWebhook, isTwilioWebhook, matchAll, matchAny, matchBodyPath, matchHeader, matchJsonField, matchMethod, parseDuration, parseJsonBody, parseSSE };
|
|
418
|
+
export { ApiError, type ClientHooks, type ClientOptions, type CreateEndpointOptions, type Endpoint, type ErrorHookInfo, type ListRequestsOptions, NotFoundError, type OperationDescription, RateLimitError, type Request, type RequestHookInfo, type ResponseHookInfo, type SDKDescription, type SSEFrame, type SendOptions, type SendTemplateOptions, type SendToOptions, type SubscribeOptions, type TemplateProvider, TimeoutError, UnauthorizedError, type UpdateEndpointOptions, type WaitForOptions, WebhooksCC, WebhooksCCError, isGitHubWebhook, isLinearWebhook, isPaddleWebhook, isShopifyWebhook, isSlackWebhook, isStandardWebhook, isStripeWebhook, isTwilioWebhook, matchAll, matchAny, matchBodyPath, matchHeader, matchJsonField, matchMethod, parseDuration, parseJsonBody, parseSSE };
|
package/dist/index.d.ts
CHANGED
|
@@ -73,6 +73,28 @@ interface SendOptions {
|
|
|
73
73
|
/** Request body (will be JSON-serialized if not a string) */
|
|
74
74
|
body?: unknown;
|
|
75
75
|
}
|
|
76
|
+
type TemplateProvider = "stripe" | "github" | "shopify" | "twilio" | "standard-webhooks";
|
|
77
|
+
/**
|
|
78
|
+
* Options for sending a provider template webhook with signed headers.
|
|
79
|
+
*/
|
|
80
|
+
interface SendTemplateOptions {
|
|
81
|
+
/** Provider template to use */
|
|
82
|
+
provider: TemplateProvider;
|
|
83
|
+
/** Provider-specific template preset (uses provider default if omitted) */
|
|
84
|
+
template?: string;
|
|
85
|
+
/** Shared secret used for provider signature generation */
|
|
86
|
+
secret: string;
|
|
87
|
+
/** Provider event/topic name (provider default used if omitted) */
|
|
88
|
+
event?: string;
|
|
89
|
+
/** HTTP method override (default: "POST") */
|
|
90
|
+
method?: string;
|
|
91
|
+
/** Additional headers merged after template headers */
|
|
92
|
+
headers?: Record<string, string>;
|
|
93
|
+
/** Body override; if omitted a provider-specific template body is generated */
|
|
94
|
+
body?: unknown;
|
|
95
|
+
/** Unix timestamp (seconds) override for deterministic signatures in tests */
|
|
96
|
+
timestamp?: number;
|
|
97
|
+
}
|
|
76
98
|
/**
|
|
77
99
|
* Options for listing captured requests.
|
|
78
100
|
*/
|
|
@@ -150,10 +172,33 @@ interface OperationDescription {
|
|
|
150
172
|
description: string;
|
|
151
173
|
params: Record<string, string>;
|
|
152
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Options for sending a webhook directly to an arbitrary URL.
|
|
177
|
+
* Supports optional provider signing (Standard Webhooks, Stripe, etc.).
|
|
178
|
+
*/
|
|
179
|
+
interface SendToOptions {
|
|
180
|
+
/** Provider template for signing (optional). When set, secret is required. */
|
|
181
|
+
provider?: TemplateProvider;
|
|
182
|
+
/** Provider-specific template preset (e.g. "checkout.session.completed" for Stripe) */
|
|
183
|
+
template?: string;
|
|
184
|
+
/** Secret for provider signature generation (required when provider is set) */
|
|
185
|
+
secret?: string;
|
|
186
|
+
/** Event name for provider headers */
|
|
187
|
+
event?: string;
|
|
188
|
+
/** HTTP method (default: "POST") */
|
|
189
|
+
method?: string;
|
|
190
|
+
/** HTTP headers to include */
|
|
191
|
+
headers?: Record<string, string>;
|
|
192
|
+
/** Request body (will be JSON-serialized if not a string) */
|
|
193
|
+
body?: unknown;
|
|
194
|
+
/** Unix timestamp (seconds) override for deterministic signatures in tests */
|
|
195
|
+
timestamp?: number;
|
|
196
|
+
}
|
|
153
197
|
/** Self-describing schema returned by client.describe(). */
|
|
154
198
|
interface SDKDescription {
|
|
155
199
|
version: string;
|
|
156
200
|
endpoints: Record<string, OperationDescription>;
|
|
201
|
+
sendTo: OperationDescription;
|
|
157
202
|
requests: Record<string, OperationDescription>;
|
|
158
203
|
}
|
|
159
204
|
|
|
@@ -228,7 +273,18 @@ declare class WebhooksCC {
|
|
|
228
273
|
update: (slug: string, options: UpdateEndpointOptions) => Promise<Endpoint>;
|
|
229
274
|
delete: (slug: string) => Promise<void>;
|
|
230
275
|
send: (slug: string, options?: SendOptions) => Promise<Response>;
|
|
276
|
+
sendTemplate: (slug: string, options: SendTemplateOptions) => Promise<Response>;
|
|
231
277
|
};
|
|
278
|
+
/**
|
|
279
|
+
* Send a webhook directly to any URL with optional provider signing.
|
|
280
|
+
* Use this for local integration testing — send properly signed webhooks
|
|
281
|
+
* to localhost handlers without routing through webhooks.cc infrastructure.
|
|
282
|
+
*
|
|
283
|
+
* @param url - Target URL to send the webhook to (http or https)
|
|
284
|
+
* @param options - Method, headers, body, and optional provider signing
|
|
285
|
+
* @returns Raw fetch Response from the target
|
|
286
|
+
*/
|
|
287
|
+
sendTo: (url: string, options?: SendToOptions) => Promise<Response>;
|
|
232
288
|
requests: {
|
|
233
289
|
list: (endpointSlug: string, options?: ListRequestsOptions) => Promise<Request[]>;
|
|
234
290
|
get: (requestId: string) => Promise<Request>;
|
|
@@ -302,6 +358,12 @@ declare function isTwilioWebhook(request: Request): boolean;
|
|
|
302
358
|
declare function isPaddleWebhook(request: Request): boolean;
|
|
303
359
|
/** Check if a request looks like a Linear webhook. */
|
|
304
360
|
declare function isLinearWebhook(request: Request): boolean;
|
|
361
|
+
/**
|
|
362
|
+
* Check if a request looks like a Standard Webhooks request.
|
|
363
|
+
* Matches on the presence of all three Standard Webhooks headers:
|
|
364
|
+
* webhook-id, webhook-timestamp, and webhook-signature.
|
|
365
|
+
*/
|
|
366
|
+
declare function isStandardWebhook(request: Request): boolean;
|
|
305
367
|
|
|
306
368
|
/** Match requests by HTTP method (case-insensitive). */
|
|
307
369
|
declare function matchMethod(method: string): (request: Request) => boolean;
|
|
@@ -353,4 +415,4 @@ interface SSEFrame {
|
|
|
353
415
|
*/
|
|
354
416
|
declare function parseSSE(stream: ReadableStream<Uint8Array>): AsyncGenerator<SSEFrame, void, undefined>;
|
|
355
417
|
|
|
356
|
-
export { ApiError, type ClientHooks, type ClientOptions, type CreateEndpointOptions, type Endpoint, type ErrorHookInfo, type ListRequestsOptions, NotFoundError, type OperationDescription, RateLimitError, type Request, type RequestHookInfo, type ResponseHookInfo, type SDKDescription, type SSEFrame, type SendOptions, type SubscribeOptions, TimeoutError, UnauthorizedError, type UpdateEndpointOptions, type WaitForOptions, WebhooksCC, WebhooksCCError, isGitHubWebhook, isLinearWebhook, isPaddleWebhook, isShopifyWebhook, isSlackWebhook, isStripeWebhook, isTwilioWebhook, matchAll, matchAny, matchBodyPath, matchHeader, matchJsonField, matchMethod, parseDuration, parseJsonBody, parseSSE };
|
|
418
|
+
export { ApiError, type ClientHooks, type ClientOptions, type CreateEndpointOptions, type Endpoint, type ErrorHookInfo, type ListRequestsOptions, NotFoundError, type OperationDescription, RateLimitError, type Request, type RequestHookInfo, type ResponseHookInfo, type SDKDescription, type SSEFrame, type SendOptions, type SendTemplateOptions, type SendToOptions, type SubscribeOptions, type TemplateProvider, TimeoutError, UnauthorizedError, type UpdateEndpointOptions, type WaitForOptions, WebhooksCC, WebhooksCCError, isGitHubWebhook, isLinearWebhook, isPaddleWebhook, isShopifyWebhook, isSlackWebhook, isStandardWebhook, isStripeWebhook, isTwilioWebhook, matchAll, matchAny, matchBodyPath, matchHeader, matchJsonField, matchMethod, parseDuration, parseJsonBody, parseSSE };
|