From c77bbed0ea4f84a2008770ff4181a863654b9a55 Mon Sep 17 00:00:00 2001 From: Justin Stayton Date: Thu, 19 Mar 2026 17:20:03 -0400 Subject: [PATCH 1/2] Add TypeScript declaration file (#32) --- package.json | 1 + src/main.d.ts | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/main.d.ts diff --git a/package.json b/package.json index 75b0e36..4ffe136 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "bugs": "https://github.com/TRUEPIC/webhook-verifier-nodejs/issues", "license": "MIT", "main": "./src/main.js", + "types": "./src/main.d.ts", "repository": { "type": "git", "url": "git+https://github.com/TRUEPIC/webhook-verifier-nodejs.git" diff --git a/src/main.d.ts b/src/main.d.ts new file mode 100644 index 0000000..0e52416 --- /dev/null +++ b/src/main.d.ts @@ -0,0 +1,36 @@ +/** + * Options for verifying a Truepic webhook. + */ +interface VerifyTruepicWebhookOptions { + /** The full URL that received the request and is registered with Truepic. */ + url: string + /** The shared secret that's registered with Truepic. */ + secret: string + /** The value of the `truepic-signature` header from the request. */ + header: string + /** The raw body (unparsed JSON) from the request. */ + body: string + /** The number of minutes allowed between the request being sent and received. Defaults to `5`. */ + leewayMinutes?: number +} + +/** + * The custom error thrown when webhook verification fails. + */ +declare class TruepicWebhookVerifierError extends Error { + constructor(message: string) + name: 'TruepicWebhookVerifierError' +} + +/** + * Verify a webhook from Truepic Vision or Lens. + */ +declare function verifyTruepicWebhook( + options: VerifyTruepicWebhookOptions, +): true + +declare namespace verifyTruepicWebhook { + export { TruepicWebhookVerifierError } +} + +export = verifyTruepicWebhook From 8b34a8d93d8de197d2ce7768163d2888270f728b Mon Sep 17 00:00:00 2001 From: Justin Stayton Date: Thu, 19 Mar 2026 17:21:40 -0400 Subject: [PATCH 2/2] v2.4.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5a1cc34..5837640 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@truepic/webhook-verifier", - "version": "2.3.0", + "version": "2.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@truepic/webhook-verifier", - "version": "2.3.0", + "version": "2.4.0", "license": "MIT", "devDependencies": { "@eslint/js": "^10.0.1", diff --git a/package.json b/package.json index 4ffe136..b5dac94 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@truepic/webhook-verifier", - "version": "2.3.0", + "version": "2.4.0", "description": "Verify webhooks from Truepic Vision or Lens in your Node.js app", "homepage": "https://github.com/TRUEPIC/webhook-verifier-nodejs#readme", "bugs": "https://github.com/TRUEPIC/webhook-verifier-nodejs/issues",