PageSourceSearch

https://trueresume.ai/_next/static/chunks/pages/account/api-keys-e975100908d6f758.js

js trueresume.ai collected 2026-10-02 01:12:43 UTC 11,812 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9814],{67276:function(e,t,s){(window.__NEXT_P=window.__NEXT_P||[]).push(["/account/api-keys",function(){return s(13272)}])},39200:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});let a=(0,s(63759).Z)("AlertTriangle",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"c3ski4"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},18289:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});let a=(0,s(63759).Z)("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]])},53616:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});let a=(0,s(63759).Z)("Key",[["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["path",{d:"m15.5 7.5 3 3L22 7l-3-3",key:"1rn1fs"}]])},4270:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});let a=(0,s(63759).Z)("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},72278:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});let a=(0,s(63759).Z)("ShieldCheck",[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},37864:function(e,t,s){"use strict";s.d(t,{Z:function(){return a}});let a=(0,s(63759).Z)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},13272:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return g}});var a=s(85893),i=s(67294),n=s(9008),l=s.n(n),r=s(11163),c=s(33299),d=s(85412),o=s(79298),x=s(67694),m=s(53616),h=s(4270),p=s(39200),u=s(72278),y=s(37864),b=s(62190),f=s(78865),j=s(18289);let k=["resumes:read","resumes:write","profile:read","profile:write","jobs:read","bulk:write","analytics:read"];function g(){let{theme:e}=(0,x.F)(),{data:t,status:s}=(0,c.useSession)(),n=(0,r.useRouter)(),g="dark"===e,[N,v]=(0,i.useState)([]),[w,C]=(0,i.useState)(!0),[Z,E]=(0,i.useState)(""),[S,F]=(0,i.useState)(!1),[T,P]=(0,i.useState)(""),[_,A]=(0,i.useState)(""),[I,D]=(0,i.useState)(""),[z,M]=(0,i.useState)(["resumes:read","profile:read"]),[R,L]=(0,i.useState)(!1),[H,K]=(0,i.useState)(null),[O,V]=(0,i.useState)(!1);(0,i.useEffect)(()=>{"unauthenticated"===s&&n.replace("/login?redirect=/account/api-keys")},[s,n]);let q=async()=>{C(!0),E("");try{let e=await fetch("/api/account/api-keys",{credentials:"include"});if(!e.ok)throw Error("HTTP ".concat(e.status));let t=await e.json();v(t.keys||[])}catch(e){E((null==e?void 0:e.message)||"Failed to load API keys")}finally{C(!1)}};(0,i.useEffect)(()=>{"authenticated"===s&&q()},[s]);let X=async()=>{A(""),D("");let e=T.trim();if(!e){A("Give this key a name (e.g. “Production bot”)");return}if(0===z.length){D("Select at least one scope");return}L(!0),E("");try{let t=await fetch("/api/account/api-keys",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,scopes:z})}),s=await t.json();if(!t.ok)throw Error((null==s?void 0:s.message)||"HTTP ".concat(t.status));K(s.secret),F(!1),P(""),M(["resumes:read","profile:read"]),await q()}catch(e){E((null==e?void 0:e.message)||"Failed to create key")}finally{L(!1)}},B=async e=>{if(confirm("Revoke this API key? Existing requests using it will start failing immediately."))try{let t=await fetch("/api/account/api-keys?id=".concat(encodeURIComponent(e)),{method:"DELETE",credentials:"include"});if(!t.ok)throw Error("HTTP ".concat(t.status));await q()}catch(e){E((null==e?void 0:e.message)||"Failed to revoke key")}},G=async()=>{if(H)try{await navigator.clipboard.writeText(H),V(!0),setTimeout(()=>V(!1),1800)}catch(e){}},J=e=>{D(""),M(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return"loading"===s?(0,a.jsx)("div",{className:"min-h-screen flex items-center justify-center",children:"Loading…"}):"unauthenticated"===s?null:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(l(),{children:[(0,a.jsx)("title",{children:"API Keys — TrueResume"}),(0,a.jsx)("meta",{name:"robots",content:"noindex,nofollow"})]}),(0,a.jsxs)("div",{className:"min-h-screen pt-14 sm:pt-16 ".concat(g?"bg-slate-950 text-slate-100":"bg-slate-50 text-slate-900"),"data-testid":"api-keys-page",children:[(0,a.jsx)(d.Z,{}),(0,a.jsxs)("div",{className:"max-w-5xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("h1",{className:"text-3xl font-bold flex items-center gap-3 font-heading",children:[(0,a.jsx)(m.Z,{className:"w-8 h-8 text-brand-500"}),"API Keys"]}),(0,a.jsxs)("p",{className:"text-sm opacity-70 mt-1",children:["Programmatic access to your resumes and career profile."," ",(0,a.jsx)("a",{href:"/developers",className:"text-brand-500 hover:underline",children:"Developer docs →"})]})]}),(0,a.jsxs)("button",{onClick:()=>{A(""),D(""),F(!0)},className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-brand-500 hover:bg-brand-600 text-white font-semibold transition shadow-md shadow-brand-500/30","data-testid":"api-keys-create-btn",children:[(0,a.jsx)(h.Z,{className:"w-4 h-4"})," New key"]}
1)]}),Z&&(0,a.jsxs)("div",{className:"mb-4 p-3 rounded-lg bg-red-500/10 text-red-500 text-sm flex items-center gap-2","data-testid":"api-keys-error",children:[(0,a.jsx)(p.Z,{className:"w-4 h-4"})," ",Z]}),(0,a.jsx)("div",{className:"rounded-xl border overflow-hidden ".concat(g?"bg-[#1A1A1B] border-[#343536]":"bg-white border-[#EDEFF1]"),children:w?(0,a.jsx)("div",{className:"p-8 text-center opacity-60",children:"Loading…"}):0===N.length?(0,a.jsxs)("div",{className:"p-8 text-center",children:[(0,a.jsx)(m.Z,{className:"w-10 h-10 mx-auto mb-3 opacity-40"}),(0,a.jsx)("p",{className:"opacity-70",children:"No API keys yet. Create one to start automating with TrueResume."})]}):(0,a.jsxs)("table",{className:"w-full text-sm","data-testid":"api-keys-table",children:[(0,a.jsx)("thead",{className:g?"bg-[#272729]":"bg-[#F6F7F8]",children:(0,a.jsxs)("tr",{className:"text-left",children:[(0,a.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Name"}),(0,a.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Key ID"}),(0,a.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Scopes"}),(0,a.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Created"}),(0,a.jsx)("th",{className:"px-4 py-3 font-semibold",children:"Status"}),(0,a.jsx)("th",{className:"px-4 py-3"})]})}),(0,a.jsx)("tbody",{children:N.map(e=>(0,a.jsxs)("tr",{className:"border-t ".concat(g?"border-[#343536]":"border-[#EDEFF1]"),"data-testid":"api-key-row-".concat(e._id),children:[(0,a.jsx)("td",{className:"px-4 py-3 font-medium",children:e.name}),(0,a.jsx)("td",{className:"px-4 py-3 font-mono text-xs",children:e.keyId}),(0,a.jsx)("td",{className:"px-4 py-3",children:(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:e.scopes.map(e=>(0,a.jsx)("span",{className:"px-1.5 py-0.5 rounded text-xs font-mono ".concat(g?"bg-slate-800":"bg-slate-100"),children:e},e))})}),(0,a.jsx)("td",{className:"px-4 py-3 text-xs opacity-80",children:new Date(e.createdAt).toLocaleDateString()}),(0,a.jsx)("td",{className:"px-4 py-3",children:e.revokedAt?(0,a.jsx)("span",{className:"text-xs text-red-500",children:"Revoked"}):(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs text-emerald-500",children:[(0,a.jsx)(u.Z,{className:"w-3 h-3"})," Active"]})}),(0,a.jsx)("td",{className:"px-4 py-3",children:!e.revokedAt&&(0,a.jsx)("button",{onClick:()=>B(e._id),className:"p-1.5 rounded text-red-500 hover:bg-red-500/10 transition","aria-label":"Revoke key","data-testid":"api-key-revoke-".concat(e._id),children:(0,a.jsx)(y.Z,{className:"w-4 h-4"})})})]},e._id))})]})})]}),S&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",onClick:()=>{F(!1),A(""),D("")},"data-testid":"api-keys-create-modal",children:(0,a.jsxs)("div",{className:"w-full max-w-md rounded-2xl p-6 shadow-2xl border ".concat(g?"bg-[#272729] border-[#343536]":"bg-white border-[#EDEFF1]"),onClick:e=>e.stopPropagation(),children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h2",{className:"text-xl font-bold ".concat(g?"text-white":"text-[#1C1C1C]"),children:"New API key"}),(0,a.jsx)("button",{onClick:()=>{F(!1),A(""),D("")},type:"button",className:"opacity-60 hover:opacity-100 rounded-lg touch-target inl
1ine-flex items-center justify-center","aria-label":"Close",children:(0,a.jsx)(b.Z,{className:"w-5 h-5"})})]}),(0,a.jsx)("div",{className:"mb-5","data-testid":"api-keys-create-name",children:(0,a.jsx)(o.II,{label:"Name",value:T,placeholder:"Production server",maxLength:80,autoComplete:"off",error:_,onChange:e=>{P(e.target.value),_&&A("")}})}),(0,a.jsx)("p",{className:"text-sm font-medium mb-2 ".concat(g?"text-[#D7DADC]":"text-[#1C1C1C]"),children:"Scopes"}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-2 mb-4",children:k.map(e=>(0,a.jsxs)("label",{className:"flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer text-sm ".concat(z.includes(e)?"bg-brand-500/10 ring-1 ring-brand-500/40":g?"bg-[#343536]":"bg-[#F6F7F8]"),children:[(0,a.jsx)("input",{type:"checkbox",checked:z.includes(e),onChange:()=>J(e),className:"accent-brand-500","data-testid":"api-keys-scope-".concat(e.replace(":","-"))}),(0,a.jsx)("span",{className:"font-mono text-xs",children:e})]},e))}),I?(0,a.jsx)("p",{role:"alert",className:"mb-4 text-sm text-red-500 dark:text-red-400",children:I}):null,(0,a.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,a.jsx)(o.zx,{variant:"secondary",type:"button",size:"sm",onClick:()=>{F(!1),A(""),D("")},testId:"api-keys-create-cancel",children:"Cancel"}),(0,a.jsx)(o.zx,{variant:"primary",type:"button",size:"sm",onClick:()=>void X(),disabled:R,loading:R,testId:"api-keys-create-submit",children:"Create key"})]})]})}),H&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/70 p-4","data-testid":"api-keys-reveal-modal",children:(0,a.jsxs)("div",{className:"w-full max-w-lg rounded-2xl p-6 border shadow-2xl ".concat(g?"bg-[#272729] border-[#343536]":"bg-white border-[#EDEFF1]"),children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,a.jsx)(u.Z,{className:"w-6 h-6 text-emerald-500"}),(0,a.jsx)("h2",{className:"text-xl font-bold",children:"Save this secret now"})]}),(0,a.jsx)("p",{className:"text-sm opacity-80 mb-4",children:"This is the only time you'll see the full secret. Store it in a secret manager. If lost, revoke and create a new key."}),(0,a.jsxs)("div",{className:"relative mb-4",children:[(0,a.jsx)("pre",{className:"rounded-lg p-3 overflow-x-auto text-xs bg-slate-950 text-emerald-300 ring-1 ring-slate-800 break-all whitespace-pre-wrap","data-testid":"api-keys-revealed-secret",children:H}),(0,a.jsx)("button",{onClick:G,className:"absolute top-2 right-2 p-1.5 rounded bg-slate-800 hover:bg-slate-700 text-slate-300 transition","aria-label":"Copy secret","data-testid":"api-keys-copy-secret",children:O?(0,a.jsx)(f.Z,{className:"w-4 h-4 text-emerald-400"}):(0,a.jsx)(j.Z,{className:"w-4 h-4"})})]}),(0,a.jsx)("div",{className:"flex justify-end",children:(0,a.jsx)("button",{onClick:()=>{K(null),V(!1)},className:"px-4 py-2 rounded-lg bg-brand-500 hover:bg-brand-600 text-white font-semibold transition","data-testid":"api-keys-reveal-close",children:"I've saved it"})})]})})]})]})}}},function(e){e.O(0,[4968,1296,5412,2888,9774,179],function(){return e(e.s=67276)}),_N_E=e.O()}]);

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.