mirror of
https://github.com/tiennm99/llmapikey.git
synced 2026-08-17 16:23:32 +00:00
- Next.js 15 App Router (JS+JSDoc): landing, auth-gated dashboard, docs - GitHub OAuth via Supabase; identity anchored on numeric provider_id - key provisioning: reserve-then-mint-persist-compensate, one key per account - api_keys in unexposed llmapikey schema via direct Postgres; RLS deny-all - live minting gated behind PROVISIONING_ENABLED; Vercel auto-deploy disabled - unit tests (mask, request-body), RLS deny-all test, reconcile script
24 lines
745 B
JavaScript
24 lines
745 B
JavaScript
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
|
|
import { last4, maskFromHint } from "../lib/keys/key-format.js";
|
|
|
|
test("last4 returns the final four characters", () => {
|
|
assert.equal(last4("sk-or-v1-abcd1234"), "1234");
|
|
});
|
|
|
|
test("last4 handles short and empty input", () => {
|
|
assert.equal(last4("xy"), "xy");
|
|
assert.equal(last4(""), "");
|
|
assert.equal(last4(/** @type {any} */ (undefined)), "");
|
|
});
|
|
|
|
test("maskFromHint builds a masked string from the hint", () => {
|
|
assert.equal(maskFromHint("1234"), "sk-or-v1-••••1234");
|
|
});
|
|
|
|
test("maskFromHint degrades gracefully without a hint", () => {
|
|
assert.equal(maskFromHint(null), "••••");
|
|
assert.equal(maskFromHint(""), "••••");
|
|
});
|