PageSourceSearch

https://studio.findem.ai/assets/ApiKeys-BGFd7oOG.js

js findem.ai collected 2026-09-24 19:16:19 UTC 13,004 bytes, 1 lines download raw bytes

1import{W as ye,u as je,r,o as P,j as e,b7 as v,X as ke,c2 as ge,b_ as Ne,bz as T,M as we,S as V,N as w,B as o,ce as B,aE as ve,bD as be,D as Ce,a9 as Se,d as Z,bZ as ze,C as J,l as Ke,as as Ie}from"./index-C-_Qp0pL.js";import{K as A}from"./key-IZ2OnXa_.js";import{E as Q}from"./eye-CzqvBRgF.js";import{C as X}from"./copy-SST6cGDg.js";const Ae=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Y=ye("eye-off",Ae);function Le(t){return t.slice(0,12)+"•".repeat(20)+t.slice(-4)}function ee(t){return t.keyHint?t.keyHint:t.key?t.key.slice(-4):""}function O(t){if(!t)return"Not tracked";const i=new Date(t);return Number.isNaN(i.getTime())?String(t):i.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function se(){return e.jsx("span",{className:"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-paper text-ink-soft shadow-sm ring-1 ring-paper-border",children:e.jsx(A,{size:14,"aria-hidden":"true"})})}function _e({label:t,count:i,emptyLabel:c,children:m}){const[d,p]=r.useState(!1);return e.jsxs("div",{className:"mb-3",children:[e.jsxs(o,{variant:"ghost",size:"sm",onClick:()=>p(h=>!h),"aria-expanded":!d,className:"group h-auto w-full !justify-start gap-1.5 px-2.5 pb-1 pt-3 !text-left",children:[d?e.jsx(Ce,{size:13,className:"text-ink-mute"}):e.jsx(Se,{size:13,className:"text-ink-mute"}),e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-ink-soft group-hover:text-ink",children:t}),typeof i=="number"?e.jsx("span",{className:"ml-1 text-[11px] font-medium text-ink-mute",children:i}):null]}),d?null:i>0?m:e.jsx("p",{className:"px-4 py-2 text-[12px] leading-5 text-ink-mute",children:c})]})}function De({item:t,active:i,onClick:c}){const m=ee(t);return e.jsxs(o,{variant:"ghost",onClick:c,className:`h-auto w-full !justify-start gap-3 rounded-lg px-2.5 py-2 !text-left transition-colors ${i?"!bg-paper-active text-ink":"text-ink-soft hover:!bg-paper-soft hover:text-ink"}`,children:[e.jsx(se,{}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-left text-[13.5px] font-medium",children:t.name}),e.jsx("span",{className:"block truncate text-left font-mono text-[11.5px] font-normal text-ink-mute",children:m?`••••${m}`:`Created ${O(t.createdAt)}`})]}),t.justCreated?e.jsx(Z,{tone:"success",className:"rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wide",children:"New"}):null]})}function R({label:t,value:i}){return e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-ink-mute",children:t}),e.jsx("p",{className:"mt-1 truncate text-[13px] font-medium text-ink",children:i})]})}function Me({scopeLabel:t}){return e.jsx("div",{className:"flex h-full items-center justify-center p-10",children:e.jsx(B,{icon:e.jsx(ze,{size:28}),title:"API keys are org-only",description:e.jsxs(e.Fragment,{children:["The current MCP scope is ",e.jsx("span",{className:"font-medium text-ink",children:t}),". Switch the workspace to an org from the panel on the left, then create keys here."]}),className:"max-w-sm"})})}function Ee({item:t,orgLabel:i,visible:c,copied:m,deleting:d,onToggleVisible:p,onCopy:h,onRequestDelete:N,onCancelDelete:f,onConfirmDelete:y,onCreate:j}){if(!t)return e.jsx("div",{className:"flex h-full items-center justify-center p-10",children:e.jsx(B,{icon:e.jsx(A,{size:28}),title:"Select a key",description:"Pick a key on the left to view its details, or create a new one.",actions:e.jsx(o,{variant:"primary",onClick:j,iconLeft:e.jsx(T,{size:14}),children:"Create key"}),className:"max-w-sm"})});const u=!!t.key,k=ee(t),L=u?c?t.key:Le(t.key):k?`${"•".repeat(24)}${k}`:"Secret available only at creation time";return e.jsxs("div",{className:"w-full max-w-5xl px-4 py-5 sm:px-8 sm:py-7",children:[e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx(se,{}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h1",{className:"truncate text-xl font-semibold text-ink",children:t.name}),t.justCreated?e.jsx(Z,{tone:"success",children:"New"}):null]}),e.jsxs("p",{className:"mt-1 max-w-3xl text-[13px] leading-5 text-ink-soft",children:["Works only for ",i,"’s MCP URLs and spends this org’s credits."]})]})]}),e.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:[u?e.jsxs(e.Fragment,{children:[e.jsx(o,{size:"sm",iconLeft:c?e.jsx(Y,{size:14}):e.jsx(Q,{size:14}),onClick:p,children:c?"Hide":"Show"}),e.jsx(o,{size:"sm",iconLeft:m?e.jsx(J,{size:14,className:"text-emerald-600"}):e.jsx(X,{size:14}),onClick:h,children:m?"Copied":"Copy"})]}):null,d?e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-1.5",children:[e.jsx(Ke,{size:13,className:"text-red-500"}),e.jsx("span",{className:"text-[12px] font-medium text-red-700",children:"Revoke?"}),e.jsx(o,{size:"sm",variant:"danger",onClick:y,children:"Yes"}),e.jsx(o,{size:"sm",variant:"ghost",onClick:f,children:"No"})]}):e.jsx(o,{size:"sm",iconLeft:e.jsx(Ie,{size:14}),onClick:N,className:"text-ink-soft hover:!bg-red-50 hover:text-red-600",children:"Revoke"})]})]}),e.jsxs("div",{className:"mt-6 grid gap-4 border-y border-paper-border py-4 sm:grid-cols-3",children:[e.jsx(R,{label:"Scope",value:i}),e.jsx(R,{label:"Created",value:O(t.createdAt)}),e.jsx(R,{label:"Last used",value:t.lastUsedAt?O(t.lastUsedAt):"Never"})]}),e.jsxs("div",{className:"mt-6",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-ink-mute",children:"Secret"}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("code",{className:"min-w-0 flex-1 truncate rounded-lg border border-paper-border bg-paper px-3 py-2 font-mono text-[12.5px] text-ink-soft",children:L}),u?e.jsxs(e.Fragment,{children:[e.jsx(v,{label:c?"Hide key":"Show key",variant:"ghost",size:"icon",icon:c?e.jsx(Y,{size:15}):e.jsx(Q,{size:15}),onClick:p,className:"h-9 w-9 text-ink-mute"}),e.jsx(v,{label:"Copy key",variant:"ghost",size:"icon",icon:m?e.jsx(J,{size:15,className:"text-emerald-600"}):e.jsx(X,{size:15}),onClick:h,className:"h-9 w-9 text-ink-mute"})]}):null]}),u?null:e.jsx(w,{tone:"warning",className:"mt-3 py-2 text-[12.5px]",children:"The full secret is only shown when the key is created. Create a new key if you need a fresh copy."})]})]})}function Be(){const{mcpScopeOrg:t,mcpScopeLabel:i,loadingOrgs:c,isOrgMcpScope:m}=je(),[d,p]=r.useState([]),[h,N]=r.useState(!0),[f,y]=r.useState(""),[j,u]=r.useState(null),[k,L]=r.useState(null),[te,b]=r.useState(!1),[C,_]=r.useState({name:""}),[H,g]=r.useState(""),[U,$]=r.useState(!1),[ae,D]=r.useState(()=>new Set),[ne,G]=r.useState(null),[re,S]=r.useState(null),[z,ie]=r.useState(""),[M,le]=r.useState(!1),x=m&&t?.mcp_org_id||"",ce=t?.org_name||i||"the selected org",K=r.useCallback(async()=>
1{if(!x){p([]),N(!1),y("");return}N(!0),y("");try{const s=await P.list(x),n=Array.isArray(s?.keys)?s.keys:[];p(n.map(a=>({id:a.id,name:a.name,key:a.key_value||"",keyHint:a.key_hint||"",createdAt:a.created_at,lastUsedAt:a.last_used_at})))}catch(s){y(s.message)}finally{N(!1)}},[x]);r.useEffect(()=>{K()},[K]);const I=r.useMemo(()=>{const s=z.trim().toLowerCase(),n=d.map(a=>({...a,justCreated:a.id===k}));return s?n.filter(a=>[a.name,a.keyHint].filter(Boolean).join(" ").toLowerCase().includes(s)):n},[d,z,k]),oe=I[0]?.id||null,W=j&&I.some(s=>s.id===j)?j:oe,l=d.map(s=>({...s,justCreated:s.id===k})).find(s=>s.id===W)||null,de=s=>{u(s),b(!1),S(null)},E=()=>{_({name:""}),g(""),b(!0)},q=()=>{b(!1),g("")};async function xe(s){if(s.preventDefault(),!C.name.trim()){g("Please enter a name");return}if(!x){g("Switch the MCP scope to an org before creating a key.");return}$(!0),g("");try{const a=(await P.create(x,C.name.trim()))?.key||{},fe={id:a.id,name:a.name||C.name.trim(),key:a.key_value||"",keyHint:a.key_hint||"",createdAt:a.created_at||new Date().toISOString(),lastUsedAt:a.last_used_at};p(F=>[fe,...F]),D(F=>new Set([...F,a.id])),L(a.id),u(a.id),_({name:""}),b(!1)}catch(n){g(n.message)}finally{$(!1)}}async function me(s){try{if(!x)throw new Error("Switch the MCP scope to an org before revoking a key.");await P.remove(x,s),p(n=>n.filter(a=>a.id!==s)),S(null),D(n=>{const a=new Set(n);return a.delete(s),a}),j===s&&u(null)}catch(n){y("Revoke failed: "+n.message)}}function pe(s){D(n=>{const a=new Set(n);return a.has(s)?a.delete(s):a.add(s),a})}function ue(s,n){s&&navigator.clipboard.writeText(s).then(()=>{G(n),setTimeout(()=>G(a=>a===n?null:a),2e3)})}const he=!!x;return e.jsxs("div",{className:"flex min-h-full flex-col text-ink md:h-full md:min-h-0 md:overflow-hidden md:flex-row",children:[e.jsxs("aside",{className:"flex shrink-0 flex-col border-b border-paper-border md:min-h-0 md:w-[320px] md:border-b-0 md:border-r",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 px-4 pb-2 pt-5",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-[0.12em] text-ink-mute",children:"Workspace"}),e.jsx("h1",{className:"mt-1 text-lg font-semibold text-ink",children:"API keys"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(v,{label:M?"Close key search":"Search keys",icon:M?e.jsx(ke,{size:16}):e.jsx(ge,{size:16}),variant:"ghost",size:"icon",onClick:()=>le(s=>!s),className:"h-8 w-8 text-ink-mute"}),e.jsx(v,{label:"Refresh keys",icon:e.jsx(Ne,{size:15}),variant:"ghost",size:"icon",onClick:K,disabled:!x||c,className:"h-8 w-8 text-ink-mute"}),he?e.jsx(v,{label:"New key",icon:e.jsx(T,{size:17}),variant:"ghost",size:"icon",onClick:E,className:"h-8 w-8 text-ink-mute"}):null]})]}),e.jsxs("div",{className:"flex-1 px-2 pb-6 md:min-h-0 md:overflow-y-auto",children:[M?e.jsx("div",{className:"pb-2",children:e.jsx(we,{autoFocus:!0,value:z,onChange:s=>ie(s.target.value),placeholder:"Search keys",inputClassName:"py-1.5 text-[13px]"})}):null,c||h?e.jsx("div",{className:"px-3 py-6",children:e.jsx(V,{label:"Loading keys..."})}):x?e.jsx(_e,{label:"Keys",count:I.length,emptyLabel:z?"No keys match this search.":"No org keys yet.",children:e.jsx("div",{className:"space-y-0.5",children:I.map(s=>e.jsx(De,{item:s,active:s.id===W,onClick:()=>de(s.id)},s.id))})}):e.jsx("p",{className:"px-4 py-2 text-[12px] leading-5 text-ink-mute",children:"Switch to an org to view and manage keys."})]})]}),e.jsx("main",{className:"min-w-0 flex-1 md:h-full md:min-h-0 md:overflow-y-auto",children:c||h?e.jsx("div",{className:"flex h-full items-center justify-center p-10",children:e.jsx(V,{label:"Loading keys..."})}):x?f&&!d.length?e.jsx("div",{className:"flex h-full items-center justify-center p-10",children:e.jsxs("div",{className:"max-w-sm text-center",children:[e.jsx(w,{tone:"danger",children:f}),e.jsx(o,{onClick:K,className:"mt-3",children:"Retry"})]})}):d.length?e.jsxs(e.Fragment,{children:[f?e.jsx("div",{className:"px-4 pt-5 sm:px-8",children:e.jsx(w,{tone:"danger",className:"py-2 text-[12.5px]",children:f})}):null,e.jsx(Ee,{item:l,orgLabel:ce,visible:l?ae.has(l.id):!1,copied:l?ne===l.id:!1,deleting:l?re===l.id:!1,onToggleVisible:()=>l&&pe(l.id),onCopy:()=>l&&ue(l.key,l.id),onRequestDelete:()=>l&&S(l.id),onCancelDelete:()=>S(null),onConfirmDelete:()=>l&&me(l.id),onCreate:E})]}):e.jsx("div",{className:"flex h-full items-center justify-center p-10",children:e.jsx(B,{icon:e.jsx(A,{size:28}),title:"No org keys yet",description:"Create a key for direct MCP access into this org from Claude, apps, or server-side tools.",actions:e.jsx(o,{variant:"primary",onClick:E,iconLeft:e.jsx(T,{size:14}),children:"Create your first key"}),className:"max-w-sm"})}):e.jsx(Me,{scopeLabel:i})}),e.jsx(ve,{open:te,onClose:q,size:"sm",icon:e.jsx(A,{size:18,className:"text-ink-soft"}),title:"New API key",description:"Generate a credential for direct MCP access into this org from Claude, apps, or server-side tools.",children:e.jsxs("form",{onSubmit:xe,className:"space-y-4",children:[e.jsx(w,{tone:"info",className:"py-2 text-[12.5px]",children:"The full secret is shown only once, right after you create the key. Copy it somewhere safe."}),e.jsx(be,{label:"Key name",value:C.name,onChange:s=>_(n=>({...n,name:s.target.value}
1)),placeholder:"e.g. Claude Desktop",autoFocus:!0}),H?e.jsx(w,{tone:"danger",className:"py-2 text-[12.5px]",children:H}):null,e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2 pt-1",children:[e.jsx(o,{type:"button",onClick:q,children:"Cancel"}),e.jsx(o,{type:"submit",variant:"primary",loading:U,children:U?"Generating...":"Generate key"})]})]})})]})}export{Be as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.