1
2
3
4
5
6
7
8
9
10
11
12
import assert from "node:assert/strict";
import * as app from "./app.mjs";
const fixtureKey = "synthetic-test-fixture";
const payload = '{"event":"demo.created"}';
const signature = app.sign(payload, fixtureKey);
assert.equal(app.verify(payload, signature, fixtureKey), true);
assert.equal(app.verify(payload + " ", signature, fixtureKey), false);
assert.equal(app.verify(payload, "malformed", fixtureKey), false);
assert.equal(app.verify(payload, signature, "different-fixture"), false);
console.log("All checks passed");