|
1 | 1 | const ApiError = require("./error");
|
2 | 2 |
|
3 |
| -/** |
4 |
| - * @see {@link validateWebhook} |
5 |
| - * @overload |
6 |
| - * @param {object} requestData - The request data |
7 |
| - * @param {string} requestData.id - The webhook ID header from the incoming request. |
8 |
| - * @param {string} requestData.timestamp - The webhook timestamp header from the incoming request. |
9 |
| - * @param {string} requestData.body - The raw body of the incoming webhook request. |
10 |
| - * @param {string} requestData.secret - The webhook secret, obtained from `replicate.webhooks.defaul.secret` method. |
11 |
| - * @param {string} requestData.signature - The webhook signature header from the incoming request, comprising one or more space-delimited signatures. |
12 |
| - */ |
13 |
| - |
14 |
| -/** |
15 |
| - * @see {@link validateWebhook} |
16 |
| - * @overload |
17 |
| - * @param {object} requestData - The request object |
18 |
| - * @param {object} requestData.headers - The request headers |
19 |
| - * @param {string} requestData.headers["webhook-id"] - The webhook ID header from the incoming request |
20 |
| - * @param {string} requestData.headers["webhook-timestamp"] - The webhook timestamp header from the incoming request |
21 |
| - * @param {string} requestData.headers["webhook-signature"] - The webhook signature header from the incoming request, comprising one or more space-delimited signatures |
22 |
| - * @param {string} requestData.body - The raw body of the incoming webhook request |
23 |
| - * @param {string} secret - The webhook secret, obtained from `replicate.webhooks.defaul.secret` method |
24 |
| - */ |
25 |
| - |
26 | 3 | /**
|
27 | 4 | * Validate a webhook signature
|
28 | 5 | *
|
| 6 | + * @typedef {Object} WebhookPayload |
| 7 | + * @property {string} id - The webhook ID header from the incoming request. |
| 8 | + * @property {string} timestamp - The webhook timestamp header from the incoming request. |
| 9 | + * @property {string} body - The raw body of the incoming webhook request. |
| 10 | + * @property {string} signature - The webhook signature header from the incoming request, comprising one or more space-delimited signatures. |
| 11 | + * |
| 12 | + * @param {Request | WebhookPayload} requestData |
| 13 | + * @param {string} secret - The webhook secret, obtained from `replicate.webhooks.defaul.secret` method. |
29 | 14 | * @returns {Promise<boolean>} - True if the signature is valid
|
30 | 15 | * @throws {Error} - If the request is missing required headers, body, or secret
|
31 | 16 | */
|
|
0 commit comments