"use client"; import { useState, useCallback } from "react"; import { Copy, Check, AlertTriangle } from "lucide-react"; import { Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Alert, AlertDescription, Input, } from "../../../shadcnui"; export interface OAuthClientSecretDisplayProps { /** The client secret to display */ secret: string; /** Called when user dismisses the dialog */ onDismiss: () => void; /** Whether the dialog is open */ open: boolean; /** Optional client name for context */ clientName?: string; } /** * Modal dialog for displaying a client secret ONE TIME * Shows warning that secret cannot be retrieved again * * @example * ```tsx * const [secret, setSecret] = useAtom(oauthNewClientSecretAtom); * * setSecret(null)} * /> * ``` */ export function OAuthClientSecretDisplay({ secret, onDismiss, open, clientName }: OAuthClientSecretDisplayProps) { const [copied, setCopied] = useState(false); const handleCopy = useCallback(async () => { try { await navigator.clipboard.writeText(secret); setCopied(true); setTimeout(() => setCopied(false), 2000); } catch (err) { console.error("Failed to copy to clipboard:", err); } }, [secret]); const handleDismiss = useCallback(() => { setCopied(false); onDismiss(); }, [onDismiss]); return ( !isOpen && handleDismiss()}> Save Your Client Secret {clientName ? `Your client secret for "${clientName}" is shown below.` : "Your client secret is shown below."} This is the only time your client secret will be displayed.
Copy it now and store it securely. You will not be able to retrieve it later.
e.currentTarget.select()} />
{copied &&

Copied to clipboard!

}
); }