Files
llmapikey/tests/mask-helper.test.js
tiennm99 02fa52ccf9 feat: scaffold OpenRouter key giveaway site (gated, code-only)
- 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
2026-06-13 14:18:52 +07:00

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(""), "••••");
});