@ewanc26/supporters 0.1.3 → 0.1.5
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/webhook.d.ts +7 -1
- package/dist/webhook.js +3 -3
- package/package.json +1 -1
package/dist/webhook.d.ts
CHANGED
|
@@ -12,4 +12,10 @@ export declare class WebhookError extends Error {
|
|
|
12
12
|
readonly status: number;
|
|
13
13
|
constructor(message: string, status: number);
|
|
14
14
|
}
|
|
15
|
-
export
|
|
15
|
+
export interface ParseWebhookOptions {
|
|
16
|
+
/** Override KOFI_VERIFICATION_TOKEN from process.env */
|
|
17
|
+
secret?: string;
|
|
18
|
+
/** Optional secondary token to accept (e.g. Ko-fi's hardcoded test token) */
|
|
19
|
+
testToken?: string;
|
|
20
|
+
}
|
|
21
|
+
export declare function parseWebhook(request: Request, options?: ParseWebhookOptions): Promise<KofiWebhookPayload>;
|
package/dist/webhook.js
CHANGED
|
@@ -14,11 +14,11 @@ export class WebhookError extends Error {
|
|
|
14
14
|
this.status = status;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
export async function parseWebhook(request) {
|
|
18
|
-
const secret = process.env.KOFI_VERIFICATION_TOKEN;
|
|
17
|
+
export async function parseWebhook(request, options) {
|
|
18
|
+
const secret = options?.secret ?? process.env.KOFI_VERIFICATION_TOKEN;
|
|
19
19
|
if (!secret)
|
|
20
20
|
throw new WebhookError('KOFI_VERIFICATION_TOKEN is not set', 500);
|
|
21
|
-
const testToken =
|
|
21
|
+
const testToken = options?.testToken;
|
|
22
22
|
const contentType = request.headers.get('content-type') ?? '';
|
|
23
23
|
if (!contentType.includes('application/x-www-form-urlencoded')) {
|
|
24
24
|
throw new WebhookError('Unexpected content-type', 400);
|
package/package.json
CHANGED