mirror of
https://github.com/tiennm99/llmapikey.git
synced 2026-07-05 09:06:04 +00:00
02fa52ccf9
- 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
28 lines
704 B
JavaScript
28 lines
704 B
JavaScript
/**
|
|
* Pure key formatting helpers. No secrets, no I/O — safe to import anywhere and
|
|
* unit-testable in isolation.
|
|
*/
|
|
|
|
/**
|
|
* Last 4 chars of a raw key, for masked display/storage. The raw key itself is
|
|
* never stored; only this hint is.
|
|
*
|
|
* @param {string} rawKey
|
|
* @returns {string}
|
|
*/
|
|
export function last4(rawKey) {
|
|
if (typeof rawKey !== "string" || rawKey.length === 0) return "";
|
|
return rawKey.slice(-4);
|
|
}
|
|
|
|
/**
|
|
* Masked representation from a stored last-4 hint, e.g. "sk-or-v1-••••1234".
|
|
*
|
|
* @param {string | null | undefined} hint
|
|
* @returns {string}
|
|
*/
|
|
export function maskFromHint(hint) {
|
|
if (!hint) return "••••";
|
|
return `sk-or-v1-••••${hint}`;
|
|
}
|