Files
tiennm99 3eda216dc6 feat(keys): store raw OpenRouter key and make it retrievable
Persist the raw key (migration 0002 adds openrouter_key) so users can copy it
again from the dashboard instead of a one-time-only reveal; admin console shows
the full key. Retain openrouter_key_hash for revocation. Keys remain in the
unexposed llmapikey schema (deny-all RLS, server-only direct connection).

- activate() stores the raw key; dashboard + generate-key return the full key.
- key-display warning updated (no longer shown-once).
- admin table renders the full key.
2026-06-14 14:10:46 +07:00

42 lines
1.1 KiB
JavaScript

"use client";
import { useState } from "react";
/**
* Raw key display with a copy button. The key is stored and retrievable on the
* dashboard, so this renders both at creation and on return visits.
*
* @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">
Keep this key secret treat it like a password. You can always copy it
again here on your dashboard.
</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>
);
}