@rendobar/sdk 5.0.0 → 5.1.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/README.md +8 -8
- package/dist/index.d.cts +69 -2
- package/dist/index.d.mts +69 -2
- package/dist/webhooks.cjs +1 -0
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.mts +1 -1
- package/dist/webhooks.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -253,14 +253,14 @@ const endpoint = await client.webhooks.create({
|
|
|
253
253
|
subscribedEvents: ["job.completed", "job.failed"],
|
|
254
254
|
});
|
|
255
255
|
|
|
256
|
-
// Verify
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
);
|
|
256
|
+
// Verify a delivery in your webhook handler. Pass the raw body (a string, not
|
|
257
|
+
// parsed JSON) and the request headers. verifyWebhook reads the signature and
|
|
258
|
+
// timestamp headers, rebuilds the signed string, checks the HMAC, rejects stale
|
|
259
|
+
// deliveries (replay protection), and handles secret rotation.
|
|
260
|
+
import { verifyWebhook } from "@rendobar/sdk/webhooks";
|
|
261
|
+
|
|
262
|
+
const ok = await verifyWebhook(rawBody, request.headers, signingSecret);
|
|
263
|
+
if (!ok) throw new Error("invalid signature");
|
|
264
264
|
```
|
|
265
265
|
|
|
266
266
|
## Realtime Events (WebSocket)
|
package/dist/index.d.cts
CHANGED
|
@@ -2301,6 +2301,13 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2301
2301
|
completedAt: ZodNullable<ZodNumber>;
|
|
2302
2302
|
settledAt: ZodNullable<ZodNumber>;
|
|
2303
2303
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2304
|
+
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2305
|
+
status: ZodEnum<{
|
|
2306
|
+
pending: "pending";
|
|
2307
|
+
delivered: "delivered";
|
|
2308
|
+
failed: "failed";
|
|
2309
|
+
}>;
|
|
2310
|
+
}, $strip>>>;
|
|
2304
2311
|
status: ZodLiteral<"waiting">;
|
|
2305
2312
|
}, $strip>, ZodObject<{
|
|
2306
2313
|
id: ZodString;
|
|
@@ -2346,6 +2353,13 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2346
2353
|
completedAt: ZodNullable<ZodNumber>;
|
|
2347
2354
|
settledAt: ZodNullable<ZodNumber>;
|
|
2348
2355
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2356
|
+
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2357
|
+
status: ZodEnum<{
|
|
2358
|
+
pending: "pending";
|
|
2359
|
+
delivered: "delivered";
|
|
2360
|
+
failed: "failed";
|
|
2361
|
+
}>;
|
|
2362
|
+
}, $strip>>>;
|
|
2349
2363
|
status: ZodLiteral<"dispatched">;
|
|
2350
2364
|
progress: ZodOptional<ZodNullable<ZodNumber>>;
|
|
2351
2365
|
eta: ZodOptional<ZodNullable<ZodNumber>>;
|
|
@@ -2393,6 +2407,13 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2393
2407
|
completedAt: ZodNullable<ZodNumber>;
|
|
2394
2408
|
settledAt: ZodNullable<ZodNumber>;
|
|
2395
2409
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2410
|
+
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2411
|
+
status: ZodEnum<{
|
|
2412
|
+
pending: "pending";
|
|
2413
|
+
delivered: "delivered";
|
|
2414
|
+
failed: "failed";
|
|
2415
|
+
}>;
|
|
2416
|
+
}, $strip>>>;
|
|
2396
2417
|
status: ZodLiteral<"running">;
|
|
2397
2418
|
progress: ZodNullable<ZodNumber>;
|
|
2398
2419
|
eta: ZodNullable<ZodNumber>;
|
|
@@ -2440,6 +2461,13 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2440
2461
|
completedAt: ZodNullable<ZodNumber>;
|
|
2441
2462
|
settledAt: ZodNullable<ZodNumber>;
|
|
2442
2463
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2464
|
+
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2465
|
+
status: ZodEnum<{
|
|
2466
|
+
pending: "pending";
|
|
2467
|
+
delivered: "delivered";
|
|
2468
|
+
failed: "failed";
|
|
2469
|
+
}>;
|
|
2470
|
+
}, $strip>>>;
|
|
2443
2471
|
status: ZodLiteral<"complete">;
|
|
2444
2472
|
output: ZodObject<{
|
|
2445
2473
|
data: ZodUnknown;
|
|
@@ -2529,6 +2557,13 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2529
2557
|
completedAt: ZodNullable<ZodNumber>;
|
|
2530
2558
|
settledAt: ZodNullable<ZodNumber>;
|
|
2531
2559
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2560
|
+
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2561
|
+
status: ZodEnum<{
|
|
2562
|
+
pending: "pending";
|
|
2563
|
+
delivered: "delivered";
|
|
2564
|
+
failed: "failed";
|
|
2565
|
+
}>;
|
|
2566
|
+
}, $strip>>>;
|
|
2532
2567
|
status: ZodLiteral<"failed">;
|
|
2533
2568
|
error: ZodObject<{
|
|
2534
2569
|
code: ZodString;
|
|
@@ -2585,6 +2620,13 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2585
2620
|
completedAt: ZodNullable<ZodNumber>;
|
|
2586
2621
|
settledAt: ZodNullable<ZodNumber>;
|
|
2587
2622
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2623
|
+
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2624
|
+
status: ZodEnum<{
|
|
2625
|
+
pending: "pending";
|
|
2626
|
+
delivered: "delivered";
|
|
2627
|
+
failed: "failed";
|
|
2628
|
+
}>;
|
|
2629
|
+
}, $strip>>>;
|
|
2588
2630
|
status: ZodLiteral<"cancelled">;
|
|
2589
2631
|
}, $strip>], "status">;
|
|
2590
2632
|
declare const jobCreatedResponseSchema: ZodObject<{
|
|
@@ -2722,10 +2764,10 @@ declare const webhookDeliverySchema: ZodObject<{
|
|
|
2722
2764
|
event: ZodString;
|
|
2723
2765
|
payload: ZodString;
|
|
2724
2766
|
status: ZodEnum<{
|
|
2725
|
-
failed: "failed";
|
|
2726
|
-
cancelled: "cancelled";
|
|
2727
2767
|
pending: "pending";
|
|
2728
2768
|
delivered: "delivered";
|
|
2769
|
+
failed: "failed";
|
|
2770
|
+
cancelled: "cancelled";
|
|
2729
2771
|
}>;
|
|
2730
2772
|
statusCode: ZodNullable<ZodNumber>;
|
|
2731
2773
|
responseBody: ZodNullable<ZodString>;
|
|
@@ -3643,6 +3685,31 @@ type CreateJobParams = {
|
|
|
3643
3685
|
params?: Record<string, unknown>;
|
|
3644
3686
|
idempotencyKey?: string;
|
|
3645
3687
|
forceAsync?: boolean;
|
|
3688
|
+
/**
|
|
3689
|
+
* Per-job completion callback. On a terminal state (complete/failed/cancelled)
|
|
3690
|
+
* Rendobar POSTs the standard job envelope to `url`. HTTPS only. The URL is the
|
|
3691
|
+
* capability — keep it secret, or use the callback as a trigger and re-fetch the
|
|
3692
|
+
* job for authoritative data.
|
|
3693
|
+
*
|
|
3694
|
+
* Optional `headers` (e.g. `{ Authorization: "Bearer …" }`) are sent with the
|
|
3695
|
+
* POST, so the callback can hit an authed target directly — for example
|
|
3696
|
+
* Cloudflare's Workflows events endpoint, with no receiver Worker.
|
|
3697
|
+
*
|
|
3698
|
+
* Set `verify: true` to opt into signing: the POST then carries an
|
|
3699
|
+
* `X-Rendobar-Signature` (same HMAC scheme as webhooks). Fetch your org's
|
|
3700
|
+
* callback signing secret once (`GET /orgs/current/callback-secret`) and verify
|
|
3701
|
+
* with `verifyCallback(rawBody, headers, secret)` from `@rendobar/sdk/webhooks`.
|
|
3702
|
+
*
|
|
3703
|
+
* `events` opts into EXTRA non-terminal events. Terminal events
|
|
3704
|
+
* (complete/failed/cancelled) always fire and can't be filtered out, so a
|
|
3705
|
+
* `waitForEvent` can never hang. Today the only opt-in extra is `job.started`.
|
|
3706
|
+
*/
|
|
3707
|
+
callback?: {
|
|
3708
|
+
url: string;
|
|
3709
|
+
headers?: Record<string, string>;
|
|
3710
|
+
verify?: boolean;
|
|
3711
|
+
events?: "job.started"[];
|
|
3712
|
+
};
|
|
3646
3713
|
};
|
|
3647
3714
|
type ListJobsParams = {
|
|
3648
3715
|
status?: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -2301,6 +2301,13 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2301
2301
|
completedAt: ZodNullable<ZodNumber>;
|
|
2302
2302
|
settledAt: ZodNullable<ZodNumber>;
|
|
2303
2303
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2304
|
+
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2305
|
+
status: ZodEnum<{
|
|
2306
|
+
pending: "pending";
|
|
2307
|
+
delivered: "delivered";
|
|
2308
|
+
failed: "failed";
|
|
2309
|
+
}>;
|
|
2310
|
+
}, $strip>>>;
|
|
2304
2311
|
status: ZodLiteral<"waiting">;
|
|
2305
2312
|
}, $strip>, ZodObject<{
|
|
2306
2313
|
id: ZodString;
|
|
@@ -2346,6 +2353,13 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2346
2353
|
completedAt: ZodNullable<ZodNumber>;
|
|
2347
2354
|
settledAt: ZodNullable<ZodNumber>;
|
|
2348
2355
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2356
|
+
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2357
|
+
status: ZodEnum<{
|
|
2358
|
+
pending: "pending";
|
|
2359
|
+
delivered: "delivered";
|
|
2360
|
+
failed: "failed";
|
|
2361
|
+
}>;
|
|
2362
|
+
}, $strip>>>;
|
|
2349
2363
|
status: ZodLiteral<"dispatched">;
|
|
2350
2364
|
progress: ZodOptional<ZodNullable<ZodNumber>>;
|
|
2351
2365
|
eta: ZodOptional<ZodNullable<ZodNumber>>;
|
|
@@ -2393,6 +2407,13 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2393
2407
|
completedAt: ZodNullable<ZodNumber>;
|
|
2394
2408
|
settledAt: ZodNullable<ZodNumber>;
|
|
2395
2409
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2410
|
+
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2411
|
+
status: ZodEnum<{
|
|
2412
|
+
pending: "pending";
|
|
2413
|
+
delivered: "delivered";
|
|
2414
|
+
failed: "failed";
|
|
2415
|
+
}>;
|
|
2416
|
+
}, $strip>>>;
|
|
2396
2417
|
status: ZodLiteral<"running">;
|
|
2397
2418
|
progress: ZodNullable<ZodNumber>;
|
|
2398
2419
|
eta: ZodNullable<ZodNumber>;
|
|
@@ -2440,6 +2461,13 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2440
2461
|
completedAt: ZodNullable<ZodNumber>;
|
|
2441
2462
|
settledAt: ZodNullable<ZodNumber>;
|
|
2442
2463
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2464
|
+
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2465
|
+
status: ZodEnum<{
|
|
2466
|
+
pending: "pending";
|
|
2467
|
+
delivered: "delivered";
|
|
2468
|
+
failed: "failed";
|
|
2469
|
+
}>;
|
|
2470
|
+
}, $strip>>>;
|
|
2443
2471
|
status: ZodLiteral<"complete">;
|
|
2444
2472
|
output: ZodObject<{
|
|
2445
2473
|
data: ZodUnknown;
|
|
@@ -2529,6 +2557,13 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2529
2557
|
completedAt: ZodNullable<ZodNumber>;
|
|
2530
2558
|
settledAt: ZodNullable<ZodNumber>;
|
|
2531
2559
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2560
|
+
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2561
|
+
status: ZodEnum<{
|
|
2562
|
+
pending: "pending";
|
|
2563
|
+
delivered: "delivered";
|
|
2564
|
+
failed: "failed";
|
|
2565
|
+
}>;
|
|
2566
|
+
}, $strip>>>;
|
|
2532
2567
|
status: ZodLiteral<"failed">;
|
|
2533
2568
|
error: ZodObject<{
|
|
2534
2569
|
code: ZodString;
|
|
@@ -2585,6 +2620,13 @@ declare const jobResponseSchema: ZodDiscriminatedUnion<[ZodObject<{
|
|
|
2585
2620
|
completedAt: ZodNullable<ZodNumber>;
|
|
2586
2621
|
settledAt: ZodNullable<ZodNumber>;
|
|
2587
2622
|
retentionExpiresAt: ZodNullable<ZodNumber>;
|
|
2623
|
+
callback: ZodOptional<ZodNullable<ZodObject<{
|
|
2624
|
+
status: ZodEnum<{
|
|
2625
|
+
pending: "pending";
|
|
2626
|
+
delivered: "delivered";
|
|
2627
|
+
failed: "failed";
|
|
2628
|
+
}>;
|
|
2629
|
+
}, $strip>>>;
|
|
2588
2630
|
status: ZodLiteral<"cancelled">;
|
|
2589
2631
|
}, $strip>], "status">;
|
|
2590
2632
|
declare const jobCreatedResponseSchema: ZodObject<{
|
|
@@ -2722,10 +2764,10 @@ declare const webhookDeliverySchema: ZodObject<{
|
|
|
2722
2764
|
event: ZodString;
|
|
2723
2765
|
payload: ZodString;
|
|
2724
2766
|
status: ZodEnum<{
|
|
2725
|
-
failed: "failed";
|
|
2726
|
-
cancelled: "cancelled";
|
|
2727
2767
|
pending: "pending";
|
|
2728
2768
|
delivered: "delivered";
|
|
2769
|
+
failed: "failed";
|
|
2770
|
+
cancelled: "cancelled";
|
|
2729
2771
|
}>;
|
|
2730
2772
|
statusCode: ZodNullable<ZodNumber>;
|
|
2731
2773
|
responseBody: ZodNullable<ZodString>;
|
|
@@ -3643,6 +3685,31 @@ type CreateJobParams = {
|
|
|
3643
3685
|
params?: Record<string, unknown>;
|
|
3644
3686
|
idempotencyKey?: string;
|
|
3645
3687
|
forceAsync?: boolean;
|
|
3688
|
+
/**
|
|
3689
|
+
* Per-job completion callback. On a terminal state (complete/failed/cancelled)
|
|
3690
|
+
* Rendobar POSTs the standard job envelope to `url`. HTTPS only. The URL is the
|
|
3691
|
+
* capability — keep it secret, or use the callback as a trigger and re-fetch the
|
|
3692
|
+
* job for authoritative data.
|
|
3693
|
+
*
|
|
3694
|
+
* Optional `headers` (e.g. `{ Authorization: "Bearer …" }`) are sent with the
|
|
3695
|
+
* POST, so the callback can hit an authed target directly — for example
|
|
3696
|
+
* Cloudflare's Workflows events endpoint, with no receiver Worker.
|
|
3697
|
+
*
|
|
3698
|
+
* Set `verify: true` to opt into signing: the POST then carries an
|
|
3699
|
+
* `X-Rendobar-Signature` (same HMAC scheme as webhooks). Fetch your org's
|
|
3700
|
+
* callback signing secret once (`GET /orgs/current/callback-secret`) and verify
|
|
3701
|
+
* with `verifyCallback(rawBody, headers, secret)` from `@rendobar/sdk/webhooks`.
|
|
3702
|
+
*
|
|
3703
|
+
* `events` opts into EXTRA non-terminal events. Terminal events
|
|
3704
|
+
* (complete/failed/cancelled) always fire and can't be filtered out, so a
|
|
3705
|
+
* `waitForEvent` can never hang. Today the only opt-in extra is `job.started`.
|
|
3706
|
+
*/
|
|
3707
|
+
callback?: {
|
|
3708
|
+
url: string;
|
|
3709
|
+
headers?: Record<string, string>;
|
|
3710
|
+
verify?: boolean;
|
|
3711
|
+
events?: "job.started"[];
|
|
3712
|
+
};
|
|
3646
3713
|
};
|
|
3647
3714
|
type ListJobsParams = {
|
|
3648
3715
|
status?: string;
|
package/dist/webhooks.cjs
CHANGED
package/dist/webhooks.d.cts
CHANGED
|
@@ -40,4 +40,4 @@ declare function verifyWebhook(body: string, headers: WebhookHeaders, secret: st
|
|
|
40
40
|
*/
|
|
41
41
|
declare function verifyWebhookSignature(payload: string, signature: string, secret: string): Promise<boolean>;
|
|
42
42
|
//#endregion
|
|
43
|
-
export { type WebhookHeaders, verifyWebhook, verifyWebhookSignature };
|
|
43
|
+
export { type WebhookHeaders, verifyWebhook as verifyCallback, verifyWebhook, verifyWebhookSignature };
|
package/dist/webhooks.d.mts
CHANGED
|
@@ -40,4 +40,4 @@ declare function verifyWebhook(body: string, headers: WebhookHeaders, secret: st
|
|
|
40
40
|
*/
|
|
41
41
|
declare function verifyWebhookSignature(payload: string, signature: string, secret: string): Promise<boolean>;
|
|
42
42
|
//#endregion
|
|
43
|
-
export { type WebhookHeaders, verifyWebhook, verifyWebhookSignature };
|
|
43
|
+
export { type WebhookHeaders, verifyWebhook as verifyCallback, verifyWebhook, verifyWebhookSignature };
|
package/dist/webhooks.mjs
CHANGED