nuxt-webhook-validators
Advanced tools
| import { type H3Event } from 'h3'; | ||
| /** | ||
| * Validates Fourthwall webhooks on the Edge | ||
| * @see {@link https://docs.fourthwall.com/webhooks/signature-verification/} | ||
| * @param event H3Event | ||
| * @returns {boolean} `true` if the webhook is valid, `false` otherwise | ||
| */ | ||
| export declare const isValidFourthwallWebhook: (event: H3Event) => Promise<boolean>; |
| import { getRequestHeaders, readRawBody } from "h3"; | ||
| import { computeSignature, HMAC_SHA256, ensureConfiguration } from "../helpers.js"; | ||
| const FOURTHWALL_SIGNATURE = "X-Fourthwall-Hmac-SHA256".toLowerCase(); | ||
| export const isValidFourthwallWebhook = async (event) => { | ||
| const config = ensureConfiguration("fourthwall", event); | ||
| const headers = getRequestHeaders(event); | ||
| const body = await readRawBody(event); | ||
| const webhookSignature = headers[FOURTHWALL_SIGNATURE]; | ||
| if (!body || !webhookSignature) return false; | ||
| const computedHash = await computeSignature(config.secretKey, HMAC_SHA256, body, { encoding: "base64" }); | ||
| return computedHash === webhookSignature; | ||
| }; |
+2
-2
@@ -7,7 +7,7 @@ { | ||
| }, | ||
| "version": "0.2.0", | ||
| "version": "0.2.1", | ||
| "builder": { | ||
| "@nuxt/module-builder": "1.0.0", | ||
| "@nuxt/module-builder": "1.0.1", | ||
| "unbuild": "3.5.0" | ||
| } | ||
| } |
+3
-0
@@ -24,2 +24,5 @@ import { defineNuxtModule, createResolver, addServerImportsDir } from '@nuxt/kit'; | ||
| }); | ||
| runtimeConfig.webhook.fourthwall = defu(runtimeConfig.webhook.fourthwall, { | ||
| secretKey: "" | ||
| }); | ||
| runtimeConfig.webhook.github = defu(runtimeConfig.webhook.github, { | ||
@@ -26,0 +29,0 @@ secretKey: "" |
+11
-11
| { | ||
| "name": "nuxt-webhook-validators", | ||
| "version": "0.2.0", | ||
| "version": "0.2.1", | ||
| "description": "A simple nuxt module that works on the edge to easily validate incoming webhooks from different services.", | ||
@@ -45,3 +45,3 @@ "keywords": [ | ||
| "dependencies": { | ||
| "@nuxt/kit": "^3.16.2", | ||
| "@nuxt/kit": "^3.17.1", | ||
| "defu": "^6.1.4", | ||
@@ -51,16 +51,16 @@ "scule": "^1.3.0" | ||
| "devDependencies": { | ||
| "@nuxt/devtools": "^2.3.2", | ||
| "@nuxt/devtools": "^2.4.0", | ||
| "@nuxt/eslint-config": "^1.3.0", | ||
| "@nuxt/module-builder": "^1.0.0", | ||
| "@nuxt/schema": "^3.16.2", | ||
| "@nuxt/module-builder": "^1.0.1", | ||
| "@nuxt/schema": "^3.17.1", | ||
| "@nuxt/test-utils": "^3.17.2", | ||
| "@types/node": "^22.14.0", | ||
| "@types/node": "^22.15.3", | ||
| "changelogen": "^0.6.1", | ||
| "eslint": "^9.24.0", | ||
| "nuxt": "^3.16.2", | ||
| "eslint": "^9.25.1", | ||
| "nuxt": "^3.17.1", | ||
| "typescript": "^5.8.3", | ||
| "vitest": "^3.1.1", | ||
| "vue-tsc": "^2.2.8" | ||
| "vitest": "^3.1.2", | ||
| "vue-tsc": "^2.2.10" | ||
| }, | ||
| "packageManager": "pnpm@10.7.1" | ||
| "packageManager": "pnpm@10.10.0" | ||
| } |
+4
-3
@@ -17,3 +17,3 @@  | ||
| - 18 [Webhook validators](#supported-webhook-validators) | ||
| - 19 [Webhook validators](#supported-webhook-validators) | ||
| - Works on the edge | ||
@@ -84,2 +84,3 @@ - Exposed [Server utils](#server-utils) | ||
| - Dropbox | ||
| - Fourthwall | ||
| - GitHub | ||
@@ -163,6 +164,6 @@ - GitLab | ||
| [nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js | ||
| [nuxt-src]: https://img.shields.io/badge/Nuxt-020420?logo=nuxt | ||
| [nuxt-href]: https://nuxt.com | ||
| [modules-src]: https://img.shields.io/badge/Modules-020420?logo=nuxt.js | ||
| [modules-src]: https://img.shields.io/badge/Modules-020420?logo=nuxt | ||
| [modules-href]: https://nuxt.com/modules/webhook-validators |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
40852
2.86%47
4.44%745
3.19%167
0.6%Updated