PageSourceSearch

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

js findem.ai collected 2026-10-02 05:22:13 UTC 13,117 bytes, 1 lines download raw bytes

1import{l as Z,y as je,r,c9 as R,j as e,I as v,aH as ke,a3 as ge,R as Ne,d as T,bQ as we,S as V,N as w,B as o,E as B,cX as ve,m as be,b0 as Ce,ar as Se,g as ee,bc as ze,cN as W,bM as X,cl as J,c7 as Ie,n as Ke}from"./index-_Ci2S7BU.js";const Le=[["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=Z("eye-off",Le);const Ae=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],L=Z("key",Ae);function _e(t){return t.slice(0,12)+"•".repeat(20)+t.slice(-4)}function se(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 te(){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(L,{size:14,"aria-hidden":"true"})})}function Me({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=se(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(te,{}),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(ee,{tone:"success",className:"rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wide",children:"New"}):null]})}function E({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 Fe({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 Pe({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(L,{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=se(t),A=u?c?t.key:_e(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(te,{}),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(ee,{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(W,{size:14}),onClick:p,children:c?"Hide":"Show"}),e.jsx(o,{size:"sm",iconLeft:m?e.jsx(X,{size:14,className:"text-emerald-600"}):e.jsx(J,{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(Ie,{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(Ke,{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(E,{label:"Scope",value:i}),e.jsx(E,{label:"Created",value:O(t.createdAt)}),e.jsx(E,{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:A}),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(W,{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(X,{size:15,className:"text-emerald-600"}):e.jsx(J,{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 Te(){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,A]=r.useState(null),[ae,b]=r.useState(!1),[C,_]=r.useState({name:""}),[H,g]=r.useState(""),[$,U]=r.useState(!1),[ne,M]=r.useState(()=>new Set),[re,q]=r.useState(null),[ie,S]=r.useState(null),[z,le]=r.useState(""),[D,ce]=r.useState(!1),x=m&&t?.mcp_org_id||"",oe=t?.org_name||i||"the selected org",I=r.useCallback(async()=>
1{if(!x){p([]),N(!1),y("");return}N(!0),y("");try{const s=await R.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(()=>{I()},[I]);const K=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]),de=K[0]?.id||null,G=j&&K.some(s=>s.id===j)?j:de,l=d.map(s=>({...s,justCreated:s.id===k})).find(s=>s.id===G)||null,xe=s=>{u(s),b(!1),S(null)},F=()=>{_({name:""}),g(""),b(!0)},Q=()=>{b(!1),g("")};async function me(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}U(!0),g("");try{const a=(await R.create(x,C.name.trim()))?.key||{},ye={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(P=>[ye,...P]),M(P=>new Set([...P,a.id])),A(a.id),u(a.id),_({name:""}),b(!1)}catch(n){g(n.message)}finally{U(!1)}}async function pe(s){try{if(!x)throw new Error("Switch the MCP scope to an org before revoking a key.");await R.remove(x,s),p(n=>n.filter(a=>a.id!==s)),S(null),M(n=>{const a=new Set(n);return a.delete(s),a}),j===s&&u(null)}catch(n){y("Revoke failed: "+n.message)}}function ue(s){M(n=>{const a=new Set(n);return a.has(s)?a.delete(s):a.add(s),a})}function he(s,n){s&&navigator.clipboard.writeText(s).then(()=>{q(n),setTimeout(()=>q(a=>a===n?null:a),2e3)})}const fe=!!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:D?"Close key search":"Search keys",icon:D?e.jsx(ke,{size:16}):e.jsx(ge,{size:16}),variant:"ghost",size:"icon",onClick:()=>ce(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:I,disabled:!x||c,className:"h-8 w-8 text-ink-mute"}),fe?e.jsx(v,{label:"New key",icon:e.jsx(T,{size:17}),variant:"ghost",size:"icon",onClick:F,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:[D?e.jsx("div",{className:"pb-2",children:e.jsx(we,{autoFocus:!0,value:z,onChange:s=>le(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(Me,{label:"Keys",count:K.length,emptyLabel:z?"No keys match this search.":"No org keys yet.",children:e.jsx("div",{className:"space-y-0.5",children:K.map(s=>e.jsx(De,{item:s,active:s.id===G,onClick:()=>xe(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:I,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(Pe,{item:l,orgLabel:oe,visible:l?ne.has(l.id):!1,copied:l?re===l.id:!1,deleting:l?ie===l.id:!1,onToggleVisible:()=>l&&ue(l.id),onCopy:()=>l&&he(l.key,l.id),onRequestDelete:()=>l&&S(l.id),onCancelDelete:()=>S(null),onConfirmDelete:()=>l&&pe(l.id),onCreate:F})]}):e.jsx("div",{className:"flex h-full items-center justify-center p-10",children:e.jsx(B,{icon:e.jsx(L,{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:F,iconLeft:e.jsx(T,{size:14}),children:"Create your first key"}),className:"max-w-sm"})}):e.jsx(Fe,{scopeLabel:i})}),e.jsx(ve,{open:ae,onClose:Q,size:"sm",icon:e.jsx(L,{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:me,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:$,children:$?"Generating...":"Generate key"})]})]})})]})}export{Te 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.