From b4be3f77215ab55e35c3fed45c33acbd02cc77dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matou=C5=A1=20Dzivjak?= Date: Sun, 12 Apr 2026 11:42:53 +0200 Subject: [PATCH] feat(sdk): webhooks Initial draft of a webhook capabilities. The goal of this PR is to test the interfacing between the webhooks service that we are working on and the SDKs. --- codegen/src/api.ts | 1 + examples/webhooks/index.ts | 82 +++ examples/webhooks/package-lock.json | 1030 +++++++++++++++++++++++++++ examples/webhooks/package.json | 19 + sdk/README.md | 57 ++ sdk/package-lock.json | 39 +- sdk/src/client.ts | 5 + sdk/src/index.ts | 1 + sdk/src/webhooks.ts | 325 +++++++++ sdk/tests/webhooks.test.ts | 186 +++++ 10 files changed, 1733 insertions(+), 12 deletions(-) create mode 100644 examples/webhooks/index.ts create mode 100644 examples/webhooks/package-lock.json create mode 100644 examples/webhooks/package.json create mode 100644 sdk/src/webhooks.ts create mode 100644 sdk/tests/webhooks.test.ts diff --git a/codegen/src/api.ts b/codegen/src/api.ts index 039697b8..31b09767 100644 --- a/codegen/src/api.ts +++ b/codegen/src/api.ts @@ -28,6 +28,7 @@ export async function generateIndex( export type { APIConfig } from './client' export { APIError, SumUpError } from './core' export type { RequestOptions } from './core' + export * from './webhooks' export * from './types' `); diff --git a/examples/webhooks/index.ts b/examples/webhooks/index.ts new file mode 100644 index 00000000..3f154233 --- /dev/null +++ b/examples/webhooks/index.ts @@ -0,0 +1,82 @@ +/** + * Minimal Express server that verifies and parses SumUp webhooks. + * + * Required environment variables: + * - `SUMUP_WEBHOOK_SECRET` + * + * Optional environment variables: + * - `SUMUP_API_KEY` + * - `PORT` + */ + +import SumUp, { + CheckoutCreatedEvent, + SIGNATURE_HEADER, + TIMESTAMP_HEADER, + WebhookPayloadError, + WebhookSignatureError, + WebhookSignatureExpiredError, + WebhookTimestampError, +} from "@sumup/sdk"; +import express from "express"; + +const webhookSecret = process.env.SUMUP_WEBHOOK_SECRET; +if (!webhookSecret) { + throw new Error( + "Missing SUMUP_WEBHOOK_SECRET environment variable. Please configure it before starting the example.", + ); +} + +const client = new SumUp({ + apiKey: process.env.SUMUP_API_KEY, +}); +const webhooks = client.webhookHandler(webhookSecret); + +const app = express(); +app.use("/webhooks", express.raw({ type: "*/*" })); + +/** Receives webhook deliveries, verifies them, and logs the event. */ +app.post("/webhooks", async (req, res) => { + const signature = req.header(SIGNATURE_HEADER) ?? ""; + const timestamp = req.header(TIMESTAMP_HEADER) ?? ""; + const body = req.body instanceof Buffer ? req.body.toString("utf8") : ""; + + try { + const event = await webhooks.verifyAndParse(body, signature, timestamp); + + console.info("Received webhook", { + id: event.id, + objectId: event.object.id, + type: event.type, + }); + + if (event instanceof CheckoutCreatedEvent) { + const checkout = await event.fetchObject(); + console.info("Fetched checkout status", checkout.status); + } + + res.status(204).end(); + } catch (error) { + if ( + error instanceof WebhookSignatureError || + error instanceof WebhookSignatureExpiredError || + error instanceof WebhookTimestampError + ) { + res.status(401).send("Invalid webhook signature"); + return; + } + + if (error instanceof WebhookPayloadError) { + res.status(400).send("Invalid webhook payload"); + return; + } + + console.error("Unhandled webhook error", error); + res.status(500).send("Internal Server Error"); + } +}); + +const port = Number(process.env.PORT ?? 3000); +app.listen(port, () => { + console.info(`Listening for webhooks on http://localhost:${port}/webhooks`); +}); diff --git a/examples/webhooks/package-lock.json b/examples/webhooks/package-lock.json new file mode 100644 index 00000000..ca75f4d7 --- /dev/null +++ b/examples/webhooks/package-lock.json @@ -0,0 +1,1030 @@ +{ + "name": "webhooks", + "version": "0.0.1", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "webhooks", + "version": "0.0.1", + "license": "Apache-2.0", + "dependencies": { + "@sumup/sdk": "file:../../sdk", + "express": "^5.2.1", + "typescript": "^5.7.3" + }, + "devDependencies": { + "@biomejs/biome": "2.1.2" + } + }, + "../../sdk": { + "name": "@sumup/sdk", + "version": "0.1.4", + "license": "Apache-2.0", + "devDependencies": { + "@biomejs/biome": "^2.1.2", + "@rslib/core": "^0.20.0", + "rsbuild-plugin-dts": "^0.20.0", + "rsbuild-plugin-publint": "^0.3.0", + "ts-node": "^10.9.2", + "typedoc": "^0.28.3", + "typescript": "^5.7.3", + "vitest": "^4.0.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@biomejs/biome": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-2.1.2.tgz", + "integrity": "sha512-yq8ZZuKuBVDgAS76LWCfFKHSYIAgqkxVB3mGVVpOe2vSkUTs7xG46zXZeNPRNVjiJuw0SZ3+J2rXiYx0RUpfGg==", + "dev": true, + "license": "MIT OR Apache-2.0", + "bin": { + "biome": "bin/biome" + }, + "engines": { + "node": ">=14.21.3" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/biome" + }, + "optionalDependencies": { + "@biomejs/cli-darwin-arm64": "2.1.2", + "@biomejs/cli-darwin-x64": "2.1.2", + "@biomejs/cli-linux-arm64": "2.1.2", + "@biomejs/cli-linux-arm64-musl": "2.1.2", + "@biomejs/cli-linux-x64": "2.1.2", + "@biomejs/cli-linux-x64-musl": "2.1.2", + "@biomejs/cli-win32-arm64": "2.1.2", + "@biomejs/cli-win32-x64": "2.1.2" + } + }, + "node_modules/@biomejs/cli-darwin-arm64": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-2.1.2.tgz", + "integrity": "sha512-leFAks64PEIjc7MY/cLjE8u5OcfBKkcDB0szxsWUB4aDfemBep1WVKt0qrEyqZBOW8LPHzrFMyDl3FhuuA0E7g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-darwin-x64": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-2.1.2.tgz", + "integrity": "sha512-Nmmv7wRX5Nj7lGmz0FjnWdflJg4zii8Ivruas6PBKzw5SJX/q+Zh2RfnO+bBnuKLXpj8kiI2x2X12otpH6a32A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-2.1.2.tgz", + "integrity": "sha512-NWNy2Diocav61HZiv2enTQykbPP/KrA/baS7JsLSojC7Xxh2nl9IczuvE5UID7+ksRy2e7yH7klm/WkA72G1dw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64-musl": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.1.2.tgz", + "integrity": "sha512-qgHvafhjH7Oca114FdOScmIKf1DlXT1LqbOrrbR30kQDLFPEOpBG0uzx6MhmsrmhGiCFCr2obDamu+czk+X0HQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-2.1.2.tgz", + "integrity": "sha512-Km/UYeVowygTjpX6sGBzlizjakLoMQkxWbruVZSNE6osuSI63i4uCeIL+6q2AJlD3dxoiBJX70dn1enjQnQqwA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64-musl": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-2.1.2.tgz", + "integrity": "sha512-xlB3mU14ZUa3wzLtXfmk2IMOGL+S0aHFhSix/nssWS/2XlD27q+S6f0dlQ8WOCbYoXcuz8BCM7rCn2lxdTrlQA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-arm64": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-2.1.2.tgz", + "integrity": "sha512-G8KWZli5ASOXA3yUQgx+M4pZRv3ND16h77UsdunUL17uYpcL/UC7RkWTdkfvMQvogVsAuz5JUcBDjgZHXxlKoA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-x64": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-2.1.2.tgz", + "integrity": "sha512-9zajnk59PMpjBkty3bK2IrjUsUHvqe9HWwyAWQBjGLE7MIBjbX2vwv1XPEhmO2RRuGoTkVx3WCanHrjAytICLA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@sumup/sdk": { + "resolved": "../../sdk", + "link": true + }, + "node_modules/accepts": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz", + "integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==", + "license": "MIT", + "dependencies": { + "mime-types": "^3.0.0", + "negotiator": "^1.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/body-parser": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.2.2.tgz", + "integrity": "sha512-oP5VkATKlNwcgvxi0vM0p/D3n2C3EReYVX+DNYs5TjZFn/oQt2j+4sVJtSMr18pdRr8wjTcBl6LoV+FUwzPmNA==", + "license": "MIT", + "dependencies": { + "bytes": "^3.1.2", + "content-type": "^1.0.5", + "debug": "^4.4.3", + "http-errors": "^2.0.0", + "iconv-lite": "^0.7.0", + "on-finished": "^2.4.1", + "qs": "^6.14.1", + "raw-body": "^3.0.1", + "type-is": "^2.0.1" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/content-disposition": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz", + "integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz", + "integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==", + "license": "MIT", + "engines": { + "node": ">=6.6.0" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz", + "integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==", + "license": "MIT", + "dependencies": { + "accepts": "^2.0.0", + "body-parser": "^2.2.1", + "content-disposition": "^1.0.0", + "content-type": "^1.0.5", + "cookie": "^0.7.1", + "cookie-signature": "^1.2.1", + "debug": "^4.4.0", + "depd": "^2.0.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "finalhandler": "^2.1.0", + "fresh": "^2.0.0", + "http-errors": "^2.0.0", + "merge-descriptors": "^2.0.0", + "mime-types": "^3.0.0", + "on-finished": "^2.4.1", + "once": "^1.4.0", + "parseurl": "^1.3.3", + "proxy-addr": "^2.0.7", + "qs": "^6.14.0", + "range-parser": "^1.2.1", + "router": "^2.2.0", + "send": "^1.1.0", + "serve-static": "^2.2.0", + "statuses": "^2.0.1", + "type-is": "^2.0.1", + "vary": "^1.1.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/finalhandler": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz", + "integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "on-finished": "^2.4.1", + "parseurl": "^1.3.3", + "statuses": "^2.0.1" + }, + "engines": { + "node": ">= 18.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz", + "integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/iconv-lite": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.2.tgz", + "integrity": "sha512-im9DjEDQ55s9fL4EYzOAv0yMqmMBSZp6G0VvFyTMPKWxiSBHUj9NW/qqLmXUwXrrM7AvqSlTCfvqRb0cM8yYqw==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.0.tgz", + "integrity": "sha512-aisnrDP4GNe06UcKFnV5bfMNPBUw4jsLGaWwWfnH3v02GnBuXX2MCVn5RbrWo0j3pczUilYblq7fQ7Nw2t5XKw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/merge-descriptors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", + "integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/mime-db": { + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz", + "integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==", + "license": "MIT", + "dependencies": { + "mime-db": "^1.54.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "license": "ISC", + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz", + "integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==", + "license": "MIT", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.15.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.15.1.tgz", + "integrity": "sha512-6YHEFRL9mfgcAvql/XhwTvf5jKcOiiupt2FiJxHkiX1z4j7WL8J/jRHYLluORvc1XxB5rV20KoeK00gVJamspg==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz", + "integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.7.0", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/router": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", + "integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.0", + "depd": "^2.0.0", + "is-promise": "^4.0.0", + "parseurl": "^1.3.3", + "path-to-regexp": "^8.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz", + "integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==", + "license": "MIT", + "dependencies": { + "debug": "^4.4.3", + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "etag": "^1.8.1", + "fresh": "^2.0.0", + "http-errors": "^2.0.1", + "mime-types": "^3.0.2", + "ms": "^2.1.3", + "on-finished": "^2.4.1", + "range-parser": "^1.2.1", + "statuses": "^2.0.2" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/serve-static": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz", + "integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==", + "license": "MIT", + "dependencies": { + "encodeurl": "^2.0.0", + "escape-html": "^1.0.3", + "parseurl": "^1.3.3", + "send": "^1.2.0" + }, + "engines": { + "node": ">= 18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz", + "integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/type-is": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-2.0.1.tgz", + "integrity": "sha512-OZs6gsjF4vMp32qrCbiVSkrFmXtG/AZhY3t0iAMrMBiAZyV9oALtXO8hsrHbMXF9x6L3grlFuwW2oAz7cav+Gw==", + "license": "MIT", + "dependencies": { + "content-type": "^1.0.5", + "media-typer": "^1.1.0", + "mime-types": "^3.0.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "license": "ISC" + } + } +} diff --git a/examples/webhooks/package.json b/examples/webhooks/package.json new file mode 100644 index 00000000..fcb5e2eb --- /dev/null +++ b/examples/webhooks/package.json @@ -0,0 +1,19 @@ +{ + "name": "webhooks", + "version": "0.0.1", + "description": "Webhook example with SumUp SDK", + "main": "index.js", + "license": "Apache-2.0", + "scripts": { + "lint": "biome check", + "lint:fix": "biome check --write" + }, + "dependencies": { + "@sumup/sdk": "file:../../sdk", + "express": "^5.2.1", + "typescript": "^5.7.3" + }, + "devDependencies": { + "@biomejs/biome": "2.1.2" + } +} diff --git a/sdk/README.md b/sdk/README.md index 8b05e7e3..0aef4ccd 100644 --- a/sdk/README.md +++ b/sdk/README.md @@ -124,6 +124,38 @@ const { data, response } = await client.merchants console.info(response.status, data); ``` +## Webhooks + +The SDK includes helpers to verify and parse SumUp webhooks using the same +signature model as the other SDKs: + +- `X-SumUp-Webhook-Signature` +- `X-SumUp-Webhook-Timestamp` +- signed payload format `v1::` + +```ts +import SumUp, { + CheckoutCreatedEvent, + SIGNATURE_HEADER, + TIMESTAMP_HEADER, +} from "@sumup/sdk"; + +const client = new SumUp({ apiKey: process.env.SUMUP_API_KEY }); +const webhooks = client.webhookHandler(process.env.SUMUP_WEBHOOK_SECRET!); + +const body = await request.text(); +const event = await webhooks.verifyAndParse( + body, + request.headers.get(SIGNATURE_HEADER) ?? "", + request.headers.get(TIMESTAMP_HEADER) ?? "", +); + +if (event instanceof CheckoutCreatedEvent) { + const checkout = await event.fetchObject(); + console.info(checkout.status); +} +``` + ## Examples Install dependencies inside an example directory before running it: @@ -194,6 +226,31 @@ npx tsx index.ts Then open `http://localhost:8080/login` in your browser to start the flow. +### `examples/webhooks` + +Runs a minimal Express server that verifies SumUp webhook signatures, parses the +event payload, and optionally fetches the referenced resource. + +Required environment variables: + +```bash +export SUMUP_WEBHOOK_SECRET="whsec_..." +``` + +Optional environment variables: + +```bash +export SUMUP_API_KEY="sup_sk_..." +export PORT="3000" +``` + +Run it with: + +```bash +cd examples/webhooks +npx tsx index.ts +``` + ## Support For SDK reference material and API details: diff --git a/sdk/package-lock.json b/sdk/package-lock.json index e18d518b..79a82cfa 100644 --- a/sdk/package-lock.json +++ b/sdk/package-lock.json @@ -384,21 +384,21 @@ } }, "node_modules/@emnapi/core": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.9.1.tgz", - "integrity": "sha512-mukuNALVsoix/w1BJwFzwXBN/dHeejQtuVzcDsfOEsdpCumXb/E9j8w11h5S54tT1xhifGfbbSm/ICrObRb3KA==", + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.9.2.tgz", + "integrity": "sha512-UC+ZhH3XtczQYfOlu3lNEkdW/p4dsJ1r/bP7H8+rhao3TTTMO1ATq/4DdIi23XuGoFY+Cz0JmCbdVl0hz9jZcA==", "dev": true, "license": "MIT", "optional": true, "dependencies": { - "@emnapi/wasi-threads": "1.2.0", + "@emnapi/wasi-threads": "1.2.1", "tslib": "^2.4.0" } }, "node_modules/@emnapi/runtime": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.9.1.tgz", - "integrity": "sha512-VYi5+ZVLhpgK4hQ0TAjiQiZ6ol0oe4mBx7mVv7IflsiEp0OWoVsp/+f9Vc1hOhE0TtkORVrI1GvzyreqpgWtkA==", + "version": "1.9.2", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.9.2.tgz", + "integrity": "sha512-3U4+MIWHImeyu1wnmVygh5WlgfYDtyf0k8AbLhMFxOipihf6nrWC4syIm/SwEeec0mNSafiiNnMJwbza/Is6Lw==", "dev": true, "license": "MIT", "optional": true, @@ -407,9 +407,9 @@ } }, "node_modules/@emnapi/wasi-threads": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.0.tgz", - "integrity": "sha512-N10dEJNSsUx41Z6pZsXU8FjPjpBEplgH24sfkmITrBED1/U2Esum9F3lfLrMjKHHjmi557zQn7kR9R+XWXu5Rg==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.1.tgz", + "integrity": "sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==", "dev": true, "license": "MIT", "optional": true, @@ -711,6 +711,17 @@ "node": ">=14.0.0" } }, + "node_modules/@rolldown/binding-wasm32-wasi/node_modules/@emnapi/wasi-threads": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.0.tgz", + "integrity": "sha512-N10dEJNSsUx41Z6pZsXU8FjPjpBEplgH24sfkmITrBED1/U2Esum9F3lfLrMjKHHjmi557zQn7kR9R+XWXu5Rg==", + "dev": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@rolldown/binding-wasm32-wasi/node_modules/@napi-rs/wasm-runtime": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.3.tgz", @@ -777,6 +788,7 @@ "integrity": "sha512-IBbQx7SrnSpD7j2p2qyq3qDxoqmG4E6lcflTpbBitX6iUrzpVRQbP4rktXZ2iuY7ph9+FtUK/SVAVA+Ocm3Nig==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@rspack/core": "2.0.0-beta.9", "@swc/helpers": "^0.5.20" @@ -1071,6 +1083,7 @@ "integrity": "sha512-jI/VAmtdjB/RnI8GTnokyX7Ug8c+g+ffD6QRLa6XQewtnGyukKkKSk3wLTM3b5cjt1jNh9x0jfVlagdN2gDKQg==", "dev": true, "license": "Apache-2.0", + "peer": true, "dependencies": { "tslib": "^2.8.0" } @@ -1849,6 +1862,7 @@ "integrity": "sha512-QP88BAKvMam/3NxH6vj2o21R6MjxZUAd6nlwAS/pnGvN9IVLocLHxGYIzFhg6fUQ+5th6P4dv4eW9jX3DSIj7A==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -2193,6 +2207,7 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -2213,8 +2228,7 @@ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", "dev": true, - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", @@ -2229,6 +2243,7 @@ "integrity": "sha512-P1PbweD+2/udplnThz3btF4cf6AgPky7kk23RtHUkJIU5BIxwPprhRGmOAHs6FTI7UiGbTNrgNP6jSYD6JaRnw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "lightningcss": "^1.32.0", "picomatch": "^4.0.4", diff --git a/sdk/src/client.ts b/sdk/src/client.ts index 90df6e96..3ce94dab 100644 --- a/sdk/src/client.ts +++ b/sdk/src/client.ts @@ -3,6 +3,7 @@ import * as Core from "./core"; import { buildRuntimeHeaders } from "./runtime"; import { VERSION } from "./version"; +import { WebhookHandler } from "./webhooks"; export type APIConfig = { apiKey?: string; @@ -84,6 +85,10 @@ export class HTTPClient { }); } + public webhookHandler(secret: string, toleranceMs?: number): WebhookHandler { + return new WebhookHandler(this, secret, toleranceMs); + } + public request>({ body, path, diff --git a/sdk/src/index.ts b/sdk/src/index.ts index 676a5d4a..1039572f 100644 --- a/sdk/src/index.ts +++ b/sdk/src/index.ts @@ -7,6 +7,7 @@ export type { RequestOptions } from "./core"; export { APIError, SumUpError } from "./core"; export * from "./resources/checkouts"; export * from "./types"; +export * from "./webhooks"; import { Checkouts } from "./resources/checkouts"; diff --git a/sdk/src/webhooks.ts b/sdk/src/webhooks.ts new file mode 100644 index 00000000..0b61856b --- /dev/null +++ b/sdk/src/webhooks.ts @@ -0,0 +1,325 @@ +import type { HTTPClient } from "./client"; +import { SumUpError } from "./core"; +import type { CheckoutSuccess } from "./types/checkout-success"; +import type { Member } from "./types/member"; + +/** Header carrying the versioned webhook signature. */ +export const SIGNATURE_HEADER = "X-SumUp-Webhook-Signature"; +/** Header carrying the Unix timestamp used for signing. */ +export const TIMESTAMP_HEADER = "X-SumUp-Webhook-Timestamp"; +/** Current webhook signature scheme version. */ +export const SIGNATURE_VERSION = "v1"; +/** Default maximum allowed clock skew in milliseconds. */ +export const DEFAULT_TOLERANCE_MS = 5 * 60 * 1000; + +/** Base class for webhook verification and parsing failures. */ +export class WebhookError extends SumUpError {} + +/** Error thrown when the webhook signature is missing or invalid. */ +export class WebhookSignatureError extends WebhookError {} + +/** Error thrown when the webhook timestamp header is missing or malformed. */ +export class WebhookTimestampError extends WebhookError {} + +/** Error thrown when the webhook timestamp falls outside the allowed tolerance. */ +export class WebhookSignatureExpiredError extends WebhookSignatureError {} + +/** Error thrown when the webhook payload is not valid JSON or has the wrong shape. */ +export class WebhookPayloadError extends WebhookError {} + +/** Reference to the resource associated with a webhook event. */ +export type WebhookObject = { + id: string; + type: string; + url: string; +}; + +type WebhookPayload = { + id: string; + type: string; + created_at: string; + object: WebhookObject; +}; + +export type KnownWebhookEventType = + | "checkout.created" + | "checkout.updated" + | "checkout.paid" + | "checkout.failed" + | "checkout.expired" + | "member.created" + | "member.updated"; + +/** Generic SumUp webhook event envelope. */ +export class WebhookEvent { + readonly id: string; + readonly type: string; + readonly createdAt: Date; + readonly object: WebhookObject; + + protected _client?: HTTPClient; + + constructor(payload: WebhookPayload) { + this.id = payload.id; + this.type = payload.type; + this.createdAt = new Date(payload.created_at); + this.object = payload.object; + } + + /** Binds an SDK client so fetchable events can resolve their referenced object. */ + bindClient(client?: HTTPClient): this { + this._client = client; + return this; + } +} + +class FetchableWebhookEvent extends WebhookEvent { + /** Fetches the latest representation of the object referenced by this event. */ + async fetchObject(): Promise { + if (!this._client) { + throw new SumUpError("Webhook event is not bound to a SumUp client."); + } + return this._client.get({ path: this.object.url }); + } +} + +/** Event emitted when a checkout is created. */ +export class CheckoutCreatedEvent extends FetchableWebhookEvent {} + +/** Event emitted when a checkout is updated. */ +export class CheckoutUpdatedEvent extends FetchableWebhookEvent {} + +/** Event emitted when a checkout is paid. */ +export class CheckoutPaidEvent extends FetchableWebhookEvent {} + +/** Event emitted when a checkout payment attempt fails. */ +export class CheckoutFailedEvent extends FetchableWebhookEvent {} + +/** Event emitted when a checkout expires. */ +export class CheckoutExpiredEvent extends FetchableWebhookEvent {} + +/** Event emitted when a member is created. */ +export class MemberCreatedEvent extends FetchableWebhookEvent {} + +/** Event emitted when a member is updated. */ +export class MemberUpdatedEvent extends FetchableWebhookEvent {} + +export type KnownWebhookEvent = + | CheckoutCreatedEvent + | CheckoutUpdatedEvent + | CheckoutPaidEvent + | CheckoutFailedEvent + | CheckoutExpiredEvent + | MemberCreatedEvent + | MemberUpdatedEvent; + +/** Any webhook event the SDK can parse, including unknown event types. */ +export type WebhookNotification = KnownWebhookEvent | WebhookEvent; + +export class WebhookHandler { + /** + * Creates a webhook helper bound to an optional client and signing secret. + * + * When bound to a client, typed webhook events can resolve their referenced + * API resource via `fetchObject()`. + */ + constructor( + private readonly client?: HTTPClient, + private readonly secret?: string, + private readonly toleranceMs: number = DEFAULT_TOLERANCE_MS, + ) {} + + /** Verifies the webhook signature and timestamp headers for a raw payload. */ + async verify( + body: string | ArrayBuffer | ArrayBufferView, + signatureHeader: string, + timestampHeader: string, + ): Promise { + if (!signatureHeader) { + throw new WebhookSignatureError("Missing webhook signature header."); + } + if (!timestampHeader) { + throw new WebhookTimestampError("Missing webhook timestamp header."); + } + + const timestamp = Number(timestampHeader); + if (!Number.isInteger(timestamp)) { + throw new WebhookTimestampError("Invalid webhook timestamp header."); + } + if (Math.abs(Date.now() - timestamp * 1000) > this.toleranceMs) { + throw new WebhookSignatureExpiredError( + "Webhook timestamp outside allowed tolerance.", + ); + } + + const [version, digest] = signatureHeader.split("=", 2); + if (version !== SIGNATURE_VERSION || !digest) { + throw new WebhookSignatureError("Invalid webhook signature header."); + } + if (!this.secret) { + throw new WebhookSignatureError( + "Webhook signing secret is not configured.", + ); + } + + const expectedDigest = await signPayload(this.secret, timestamp, body); + if (!safeEqualHex(expectedDigest, digest)) { + throw new WebhookSignatureError("Invalid webhook signature."); + } + } + + /** Parses a raw webhook payload into the most specific known event type. */ + parse(body: string | ArrayBuffer | ArrayBufferView): WebhookNotification { + const payload = parsePayload(body); + const event = createKnownWebhookEvent(payload); + if (!event) { + return new WebhookEvent(payload).bindClient(this.client); + } + return event.bindClient(this.client); + } + + /** Verifies the webhook and then parses it into an event object. */ + async verifyAndParse( + body: string | ArrayBuffer | ArrayBufferView, + signatureHeader: string, + timestampHeader: string, + ): Promise { + await this.verify(body, signatureHeader, timestampHeader); + return this.parse(body); + } +} + +function parsePayload( + body: string | ArrayBuffer | ArrayBufferView, +): WebhookPayload { + let payload: unknown; + try { + payload = JSON.parse(toText(body)); + } catch (error) { + throw new WebhookPayloadError( + `Invalid webhook payload: ${error instanceof Error ? error.message : String(error)}`, + ); + } + + if ( + !payload || + typeof payload !== "object" || + typeof (payload as WebhookPayload).id !== "string" || + typeof (payload as WebhookPayload).type !== "string" || + typeof (payload as WebhookPayload).created_at !== "string" || + !(payload as WebhookPayload).object || + typeof (payload as WebhookPayload).object.id !== "string" || + typeof (payload as WebhookPayload).object.type !== "string" || + typeof (payload as WebhookPayload).object.url !== "string" + ) { + throw new WebhookPayloadError("Invalid webhook payload shape."); + } + + return payload as WebhookPayload; +} + +function createKnownWebhookEvent( + payload: WebhookPayload, +): KnownWebhookEvent | undefined { + switch (payload.type) { + case "checkout.created": + assertObjectType(payload, "checkout"); + return new CheckoutCreatedEvent(payload); + case "checkout.updated": + assertObjectType(payload, "checkout"); + return new CheckoutUpdatedEvent(payload); + case "checkout.paid": + assertObjectType(payload, "checkout"); + return new CheckoutPaidEvent(payload); + case "checkout.failed": + assertObjectType(payload, "checkout"); + return new CheckoutFailedEvent(payload); + case "checkout.expired": + assertObjectType(payload, "checkout"); + return new CheckoutExpiredEvent(payload); + case "member.created": + assertObjectType(payload, "member"); + return new MemberCreatedEvent(payload); + case "member.updated": + assertObjectType(payload, "member"); + return new MemberUpdatedEvent(payload); + default: + return undefined; + } +} + +function assertObjectType( + payload: WebhookPayload, + expectedObjectType: WebhookObject["type"], +): void { + if (payload.object.type !== expectedObjectType) { + throw new WebhookError( + `Unexpected object type '${payload.object.type}' for event '${payload.type}'.`, + ); + } +} + +/** Creates a versioned HMAC digest for the provided webhook payload. */ +export async function signPayload( + secret: string, + timestamp: number, + body: string | ArrayBuffer | ArrayBufferView, +): Promise { + const key = await crypto.subtle.importKey( + "raw", + new TextEncoder().encode(secret), + { name: "HMAC", hash: "SHA-256" }, + false, + ["sign"], + ); + const signature = await crypto.subtle.sign( + "HMAC", + key, + new TextEncoder().encode( + `${SIGNATURE_VERSION}:${timestamp}:${toText(body)}`, + ), + ); + return toHex(new Uint8Array(signature)); +} + +function toText(body: string | ArrayBuffer | ArrayBufferView): string { + if (typeof body === "string") { + return body; + } + if (body instanceof ArrayBuffer) { + return new TextDecoder().decode(body); + } + return new TextDecoder().decode(body); +} + +function toHex(bytes: Uint8Array): string { + return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join( + "", + ); +} + +function safeEqualHex(left: string, right: string): boolean { + const leftBytes = fromHex(left); + const rightBytes = fromHex(right); + if (!leftBytes || !rightBytes || leftBytes.length !== rightBytes.length) { + return false; + } + + let mismatch = 0; + for (let index = 0; index < leftBytes.length; index += 1) { + mismatch |= leftBytes[index] ^ rightBytes[index]; + } + return mismatch === 0; +} + +function fromHex(hex: string): Uint8Array | undefined { + if (hex.length % 2 !== 0 || /[^0-9a-f]/i.test(hex)) { + return undefined; + } + + const bytes = new Uint8Array(hex.length / 2); + for (let index = 0; index < hex.length; index += 2) { + bytes[index / 2] = Number.parseInt(hex.slice(index, index + 2), 16); + } + return bytes; +} diff --git a/sdk/tests/webhooks.test.ts b/sdk/tests/webhooks.test.ts new file mode 100644 index 00000000..0819ebe0 --- /dev/null +++ b/sdk/tests/webhooks.test.ts @@ -0,0 +1,186 @@ +import { afterEach, describe, expect, it, vi } from "vitest"; + +import { SumUp } from "../src"; +import { + CheckoutCreatedEvent, + DEFAULT_TOLERANCE_MS, + SIGNATURE_VERSION, + signPayload, + WebhookError, + WebhookEvent, + WebhookPayloadError, + WebhookSignatureError, + WebhookSignatureExpiredError, + WebhookTimestampError, +} from "../src/webhooks"; + +afterEach(() => { + vi.restoreAllMocks(); + vi.useRealTimers(); +}); + +describe("webhooks", () => { + it("creates a bound webhook handler from the client", () => { + const client = new SumUp(); + + const handler = client.webhookHandler("whsec_test"); + + expect(handler).toBeDefined(); + }); + + it("verifies a valid webhook signature", async () => { + const client = new SumUp(); + const handler = client.webhookHandler("whsec_test"); + const body = JSON.stringify({ + id: "evt_123", + type: "checkout.created", + created_at: "2026-04-11T10:00:00Z", + object: { + id: "chk_123", + type: "checkout", + url: "https://api.sumup.com/v0.1/checkouts/chk_123", + }, + }); + const timestamp = Math.floor(Date.now() / 1000); + const signature = `${SIGNATURE_VERSION}=${await signPayload( + "whsec_test", + timestamp, + body, + )}`; + + await expect( + handler.verify(body, signature, String(timestamp)), + ).resolves.toBeUndefined(); + }); + + it("rejects invalid webhook timestamps", async () => { + const handler = new SumUp().webhookHandler("whsec_test"); + + await expect( + handler.verify("{}", "v1=deadbeef", "not-a-timestamp"), + ).rejects.toBeInstanceOf(WebhookTimestampError); + }); + + it("rejects expired webhook timestamps", async () => { + const body = "{}"; + const timestamp = Math.floor( + (Date.now() - DEFAULT_TOLERANCE_MS - 1000) / 1000, + ); + const signature = `${SIGNATURE_VERSION}=${await signPayload( + "whsec_test", + timestamp, + body, + )}`; + const handler = new SumUp().webhookHandler("whsec_test"); + + await expect( + handler.verify(body, signature, String(timestamp)), + ).rejects.toBeInstanceOf(WebhookSignatureExpiredError); + }); + + it("parses typed webhook events", () => { + const event = new SumUp().webhookHandler("whsec_test").parse( + JSON.stringify({ + id: "evt_123", + type: "checkout.created", + created_at: "2026-04-11T10:00:00Z", + object: { + id: "chk_123", + type: "checkout", + url: "https://api.sumup.com/v0.1/checkouts/chk_123", + }, + }), + ); + + expect(event).toBeInstanceOf(CheckoutCreatedEvent); + }); + + it("falls back to a generic webhook event for unknown event types", () => { + const event = new SumUp().webhookHandler("whsec_test").parse( + JSON.stringify({ + id: "evt_123", + type: "checkout.unknown", + created_at: "2026-04-11T10:00:00Z", + object: { + id: "chk_123", + type: "checkout", + url: "https://api.sumup.com/v0.1/checkouts/chk_123", + }, + }), + ); + + expect(event).toBeInstanceOf(WebhookEvent); + }); + + it("rejects unexpected object types for known events", () => { + const handler = new SumUp().webhookHandler("whsec_test"); + + expect(() => + handler.parse( + JSON.stringify({ + id: "evt_123", + type: "checkout.created", + created_at: "2026-04-11T10:00:00Z", + object: { + id: "mem_123", + type: "member", + url: "https://api.sumup.com/v0.1/merchants/MC123/members/mem_123", + }, + }), + ), + ).toThrow(WebhookError); + }); + + it("rejects invalid webhook payload JSON", () => { + const handler = new SumUp().webhookHandler("whsec_test"); + + expect(() => handler.parse("{")).toThrow(WebhookPayloadError); + }); + + it("fetches the referenced object from typed events", async () => { + const client = new SumUp(); + const getSpy = vi.spyOn(client, "get").mockImplementation( + async () => + ({ + id: "chk_123", + status: "PENDING", + }) as never, + ); + + const event = client.webhookHandler("whsec_test").parse( + JSON.stringify({ + id: "evt_123", + type: "checkout.created", + created_at: "2026-04-11T10:00:00Z", + object: { + id: "chk_123", + type: "checkout", + url: "https://api.sumup.com/v0.1/checkouts/chk_123", + }, + }), + ); + + expect(event).toBeInstanceOf(CheckoutCreatedEvent); + await expect( + (event as CheckoutCreatedEvent).fetchObject(), + ).resolves.toEqual({ + id: "chk_123", + status: "PENDING", + }); + expect(getSpy).toHaveBeenCalledWith({ + path: "https://api.sumup.com/v0.1/checkouts/chk_123", + }); + }); + + it("rejects invalid webhook signatures", async () => { + const handler = new SumUp().webhookHandler("whsec_test"); + + await expect( + handler.verify( + "{}", + "v1=deadbeef", + String(Math.floor(Date.now() / 1000)), + ), + ).rejects.toBeInstanceOf(WebhookSignatureError); + }); +});