Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

nuxt-webhook-validators

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuxt-webhook-validators - npm Package Compare versions

Comparing version
0.2.5
to
0.2.6
+8
dist/runtime/server/lib/validators/slack.d.ts
import { type H3Event } from 'h3';
/**
* Validates Slack webhooks on the Edge
* @see {@link https://docs.slack.dev/authentication/verifying-requests-from-slack/}
* @param event H3Event
* @returns {boolean} `true` if the webhook is valid, `false` otherwise
*/
export declare const isValidSlackWebhook: (event: H3Event) => Promise<boolean>;
import { getRequestHeaders, readRawBody } from "h3";
import { computeSignature, HMAC_SHA256, ensureConfiguration } from "../helpers.js";
const SLACK_SIGNATURE = "X-Slack-Signature".toLowerCase();
const SLACK_TIMESTAMP = "X-Slack-Request-Timestamp".toLowerCase();
const DEFAULT_TOLERANCE = 300;
export const isValidSlackWebhook = async (event) => {
const config = ensureConfiguration("slack", event);
const headers = getRequestHeaders(event);
const body = await readRawBody(event);
const fullSignature = headers[SLACK_SIGNATURE];
const timestamp = headers[SLACK_TIMESTAMP];
if (!body || !fullSignature || !timestamp) return false;
const now = Math.floor(Date.now() / 1e3);
if (now - Number.parseInt(timestamp) > DEFAULT_TOLERANCE) return false;
const [signatureVersion, webhookSignature] = fullSignature.split("=");
const payload = `${signatureVersion}:${timestamp}:${body}`;
const computedHash = await computeSignature(config.secretKey, HMAC_SHA256, payload);
return computedHash === webhookSignature;
};
+1
-1

@@ -7,3 +7,3 @@ {

},
"version": "0.2.5",
"version": "0.2.6",
"builder": {

@@ -10,0 +10,0 @@ "@nuxt/module-builder": "1.0.2",

import { defineNuxtModule, createResolver, addServerImportsDir } from '@nuxt/kit';
import { defu } from 'defu';
const module = defineNuxtModule({
const module$1 = defineNuxtModule({
meta: {

@@ -65,2 +65,5 @@ name: "webhook-validators",

});
runtimeConfig.webhook.slack = defu(runtimeConfig.webhook.slack, {
secretKey: ""
});
runtimeConfig.webhook.stripe = defu(runtimeConfig.webhook.stripe, {

@@ -84,2 +87,2 @@ secretKey: ""

export { module as default };
export { module$1 as default };
{
"name": "nuxt-webhook-validators",
"version": "0.2.5",
"version": "0.2.6",
"description": "A simple nuxt module that works on the edge to easily validate incoming webhooks from different services.",

@@ -33,3 +33,3 @@ "keywords": [

"dependencies": {
"@nuxt/kit": "^4.1.2",
"@nuxt/kit": "^4.2.2",
"defu": "^6.1.4",

@@ -39,14 +39,14 @@ "scule": "^1.3.0"

"devDependencies": {
"@nuxt/devtools": "^2.6.5",
"@nuxt/eslint-config": "^1.9.0",
"@nuxt/devtools": "^3.1.1",
"@nuxt/eslint-config": "^1.11.0",
"@nuxt/module-builder": "^1.0.2",
"@nuxt/schema": "^4.1.2",
"@nuxt/test-utils": "^3.19.2",
"@types/node": "^24.5.2",
"@nuxt/schema": "^4.2.2",
"@nuxt/test-utils": "^3.21.0",
"@types/node": "^24.10.2",
"changelogen": "^0.6.2",
"eslint": "^9.36.0",
"nuxt": "^4.1.2",
"typescript": "^5.9.2",
"vitest": "^3.2.4",
"vue-tsc": "^3.0.8"
"eslint": "^9.39.1",
"nuxt": "^4.2.2",
"typescript": "^5.9.3",
"vitest": "^4.0.15",
"vue-tsc": "^3.1.8"
},

@@ -53,0 +53,0 @@ "scripts": {

@@ -17,3 +17,3 @@ ![webhook-validators](https://github.com/Yizack/nuxt-webhook-validators/assets/16264115/56cded71-46b2-4895-8732-484ab6df5181)

- 20 [Webhook validators](#supported-webhook-validators)
- 21 [Webhook validators](#supported-webhook-validators)
- Works on the edge

@@ -99,2 +99,3 @@ - Exposed [Server utils](#server-utils)

- Shopify
- Slack
- Stripe

@@ -101,0 +102,0 @@ - Svix