Files
llmapikey/components/key-display.js
T
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

42 lines
1.1 KiB
JavaScript

"use client";
import { useState } from "react";
/**
* One-time raw key display with a copy button and a prominent "shown once"
* warning. After this render the key is gone (never re-fetchable) — v1 has no
* recovery path, which is acceptable for a free key.
*
* @param {{ rawKey: string, model: string }} props
*/
export function KeyDisplay({ rawKey, model }) {
const [copied, setCopied] = useState(false);
async function copy() {
try {
await navigator.clipboard.writeText(rawKey);
setCopied(true);
} catch {
setCopied(false);
}
}
return (
<div className="panel">
<p className="warn">
Copy this key now it is shown only once and cannot be recovered.
</p>
<div className="key-box">
<code>{rawKey}</code>
<button className="btn" onClick={copy}>
{copied ? "Copied ✓" : "Copy"}
</button>
</div>
<p className="muted">
Use it as a Bearer token against <code>https://openrouter.ai/api/v1</code>{" "}
with model <code>{model}</code>. See <a href="/docs">the docs</a>.
</p>
</div>
);
}