Skip to main content
Branchfeature/review-demo
12 lines · 525 BBlameRaw
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");