mirror of
https://github.com/Chewbaccalakis/rfid-database.git
synced 2026-09-09 16:01:56 -07:00
Add Next.js app with SQLite/Drizzle storage for sites and LF/HF tag dumps, multi-user Auth.js (credentials + optional OIDC), personal API tokens in Settings, versioned /api/v1 for UI and future CLI use, MCT/Proxmark/JSON import-export, PWA offline shell, Vitest tests, and GitHub Actions CI. Co-authored-by: Cursor Agent <[email protected]>
18 lines
620 B
TypeScript
18 lines
620 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { generateApiToken, hashToken, isApiTokenFormat } from "@/lib/auth/tokens";
|
|
|
|
describe("api tokens", () => {
|
|
it("generates rfid_ prefixed tokens", () => {
|
|
const { token, tokenHash, prefix } = generateApiToken();
|
|
expect(isApiTokenFormat(token)).toBe(true);
|
|
expect(tokenHash).toBe(hashToken(token));
|
|
expect(prefix).toBe(token.slice(0, 12));
|
|
expect(hashToken(token)).not.toBe(token);
|
|
});
|
|
|
|
it("rejects non-tokens", () => {
|
|
expect(isApiTokenFormat("Bearer abc")).toBe(false);
|
|
expect(isApiTokenFormat("rfid_short")).toBe(false);
|
|
});
|
|
});
|