mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 14:28:41 +01:00
* feat(feedback): a client's seat on the site itself; visitors follow notes without an account Step 3 — the seat reaches the site: - A member pass (#loki-member=) names the person, not the owner. Their project page's Open link and the widget's sign-in door give it to anyone on the project who does not build it. The widget stays the ordinary panel and sends it with each note; ingest files it through the same path as asking in Loki, so a client's note on the site builds on their allowance and goes live on their word. Membership is read when used. - The owner's own link is no longer what a client is sent: the preview's share card offers Invite them as Client. - An approved /change request seats its requester as the site's client (5 changes a month), and their request page says where to ask. Step 4 — the way back without an account: - The tracking link opens on the note's status (the My feedback card), for six months; an account is optional, below it. - A visitor who leaves an email gets the link by mail (three a day per address), and again in the shipped mail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx * chore(widget): keep the conversation within its length limit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx * chore(widget): hand the passes on through one helper Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx * test(feedback): the shared reporter card and the six-month link Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NZqZujmXpupVDC1Hi5Jbsx --------- Co-authored-by: Claude <noreply@anthropic.com>
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import {
|
|
createFeedbackClaimToken,
|
|
feedbackClaimPath,
|
|
verifyFeedbackClaimToken,
|
|
} from "@/lib/feedback/claim-token";
|
|
|
|
process.env.AUTH_SECRET = "test-only-feedback-claim-secret";
|
|
|
|
let pass = 0;
|
|
let fail = 0;
|
|
function check(label: string, value: boolean) {
|
|
if (value) pass++;
|
|
else {
|
|
fail++;
|
|
console.error(`✗ ${label}`);
|
|
}
|
|
}
|
|
|
|
const id = "28ed5be9-3700-4e1a-9819-516ed899ec62";
|
|
const token = createFeedbackClaimToken(id, 1_000);
|
|
check("valid claim resolves only its feedback id", verifyFeedbackClaimToken(token, 2_000) === id);
|
|
check("tampered id is rejected", verifyFeedbackClaimToken(`x${token}`, 2_000) === null);
|
|
check(
|
|
"expired claim is rejected",
|
|
verifyFeedbackClaimToken(token, 181 * 24 * 60 * 60 * 1000) === null,
|
|
);
|
|
check("malformed claim is rejected", verifyFeedbackClaimToken("not-a-token", 2_000) === null);
|
|
|
|
const path = feedbackClaimPath(id, 1_000);
|
|
const fromPath = new URL(path, "https://loki.test").searchParams.get("token") ?? "";
|
|
check("the claim path lands on /claim-feedback", path.startsWith("/claim-feedback?token="));
|
|
check(
|
|
"…and its token verifies to the same report",
|
|
verifyFeedbackClaimToken(fromPath, 2_000) === id,
|
|
);
|
|
|
|
console.log(`${pass} passed, ${fail} failed`);
|
|
if (fail) process.exit(1);
|