M005: add local identity and preference persistence

This commit is contained in:
illusia committed 2026-09-01 17:19:15 +08:00
1 parent 3397e90749
commit 2f8301d188
9 files changed
+556 -17

No files matched your search

+10
View File
@@ -1,5 +1,6 @@
import assert from "node:assert/strict";
import test from "node:test";
import { generateIdentity } from "@honeybbq/teamspeak-client";
import { JoinTicketStore } from "../src/server/join-ticket.js";
test("join tickets are opaque, one-time, and expire", () => {
@@ -12,3 +13,12 @@ test("join tickets are opaque, one-time, and expire", () => {
const expired = store.create(payload, 200);
assert.equal(store.consume(expired, 1201), null);
});
test("join tickets carry identity only in memory and never expose it in the opaque token", () => {
const store = new JoinTicketStore();
const identity = generateIdentity(8).toString();
const payload = { target: { host: "example.com", port: 9987 }, serverPassword: "secret", nickname: "Guest", identity, rememberIdentity: true };
const token = store.create(payload);
assert.equal(token.includes(identity), false);
assert.deepEqual(store.consume(token), payload);
});