feat(platform): add Discord onboarding and Velocity gate

This commit is contained in:
dmg
2026-08-01 13:45:18 -04:00
parent 9d305e5dc9
commit c5de0a1810
80 changed files with 4840 additions and 1572 deletions
+18
View File
@@ -0,0 +1,18 @@
import { describe, expect, it } from "vitest";
import { hashToken, isRequestTimestampFresh, verifyHashedToken } from "../src/index";
describe("plugin request authentication", () => {
it("compares an opaque token with its stored hash", () => {
const storedHash = hashToken("correct-high-entropy-token");
expect(verifyHashedToken("correct-high-entropy-token", storedHash)).toBe(true);
expect(verifyHashedToken("wrong-token", storedHash)).toBe(false);
expect(verifyHashedToken("correct-high-entropy-token", "malformed")).toBe(false);
});
it("rejects stale and excessively future-dated requests", () => {
const now = new Date("2026-08-01T12:00:00.000Z");
expect(isRequestTimestampFresh(new Date("2026-08-01T11:59:30.000Z"), now, 45_000)).toBe(true);
expect(isRequestTimestampFresh(new Date("2026-08-01T11:59:14.000Z"), now, 45_000)).toBe(false);
expect(isRequestTimestampFresh(new Date("2026-08-01T12:00:46.000Z"), now, 45_000)).toBe(false);
});
});