Export is PDF, RULE.md, and Print on US Letter, with every shared term, no member names, and a takeaway that points at Ask an organizer. Finished Rules keep type and place so the team can read folded counts without a database, Umami can sit beside the app with no cookies, and the person who holds the pen gets working PDF and RULE.md links 48 hours later.
20 lines
582 B
TypeScript
20 lines
582 B
TypeScript
import { createHmac, timingSafeEqual } from "crypto";
|
|
|
|
export function ruleExportToken(ruleId: string, pepper: string): string {
|
|
return createHmac("sha256", pepper)
|
|
.update(`rule-export:${ruleId}`)
|
|
.digest("base64url");
|
|
}
|
|
|
|
export function ruleExportTokenMatches(
|
|
ruleId: string,
|
|
token: string,
|
|
pepper: string,
|
|
): boolean {
|
|
if (token.length === 0) return false;
|
|
const expected = Buffer.from(ruleExportToken(ruleId, pepper));
|
|
const actual = Buffer.from(token);
|
|
if (expected.length !== actual.length) return false;
|
|
return timingSafeEqual(expected, actual);
|
|
}
|