PageSourceSearch

https://www.nexars.ai/_next/static/chunks/pages/admin/api-keys-3b5bd0e4bb3ba231.js

js nexars.ai collected 2026-10-05 13:47:07 UTC 9,115 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[13],{9035:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/api-keys",function(){return a(6695)}])},2724:function(e,t,a){"use strict";a.d(t,{GA:function(){return i},OE:function(){return r},Oe:function(){return o},dh:function(){return c}});var s=a(5893);let l={success:"bg-green-100 text-green-800",warning:"bg-yellow-100 text-yellow-800",error:"bg-red-100 text-red-800",info:"bg-blue-100 text-blue-800",neutral:"bg-gray-100 text-gray-800"},n={sm:"px-2 py-0.5 text-xs",md:"px-2.5 py-1 text-sm"};function r(e){let{status:t,label:a,size:r="sm"}=e;return(0,s.jsx)("span",{className:"inline-flex items-center rounded font-medium ".concat(l[t]," ").concat(n[r]),children:a})}function i(e){switch(e){case"success":return"success";case"running":case"pending":return"info";case"failed":return"error";default:return"neutral"}}function c(e){switch(e){case"active":return"success";case"paused":return"warning";default:return"neutral"}}function o(e){switch(e){case"healthy":case"active":return"success";case"deploying":return"info";case"failed":case"error":return"error";case"stopped":return"warning";default:return"neutral"}}},6695:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return u}});var s=a(5893),l=a(7294),n=a(6490),r=a(6288),i=a(2724);async function c(){let e=await fetch("/api/me");if(!e.ok)return{email:null,is_admin:!1};let t=await e.json(),a=await fetch("/api/admin/stats");return{email:t.email,is_admin:a.ok}}let o=[{value:"all",label:"All"},{value:"active",label:"Active"},{value:"stale",label:"Stale"},{value:"revoked",label:"Revoked"}];function d(e){var t;let{apiKey:a,onRevoke:n,processing:r}=e,[c,o]=(0,l.useState)(!1),[d,u]=(0,l.useState)("");return(0,s.jsxs)("tr",{className:"hover:bg-apple-gray-50",children:[(0,s.jsx)("td",{className:"px-6 py-4",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("span",{className:"font-medium text-apple-gray-900",children:a.name}),(0,s.jsxs)("p",{className:"text-xs text-apple-gray-500 font-mono",children:[a.key_prefix,"..."]})]})}),(0,s.jsx)("td",{className:"px-6 py-4",children:(0,s.jsx)("span",{className:"px-2 py-1 bg-apple-blue/10 text-apple-blue rounded text-sm",children:a.app_id})}),(0,s.jsx)("td",{className:"px-6 py-4",children:a.revoked?(0,s.jsx)(i.OE,{status:"error",label:"Revoked"}):a.is_stale?(0,s.jsx)(i.OE,{status:"warning",label:"Stale"}):(0,s.jsx)(i.OE,{status:"success",label:"Active"})}),(0,s.jsx)("td",{className:"px-6 py-4 text-sm text-apple-gray-600",children:a.created_by.split("@")[0]}),(0,s.jsx)("td",{className:"px-6 py-4 text-sm text-apple-gray-500",children:(t=a.created_at)?new Date(t).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric"}):"Never"}),(0,s.jsx)("td",{className:"px-6 py-4 text-sm text-apple-gray-500",children:(0,s.jsx)("span",{className:a.is_stale&&!a.revoked?"text-yellow-600 font-medium":"",children:function(e){if(!e)return"Never";let t=new Date(e),a=Math.floor((new Date().getTime()-t.getTime())/864e5);return 0===a?"Today":1===a?"Yesterday":a<7?"".concat(a," days ago"):a<30?"".concat(Math.floor(a/7)," weeks ago"):a<365?"".concat(Math.floor(a/30)," months ago"):"".concat(Math.floor(a/365)," years ago")}(a.last_used_at)})}),(0,s.jsx)("td",{className:"px-6 py-4",children:!a.revoked&&(c?(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{type:"text",className:"px-2 py-1 text-xs border border-apple-gray-200 rounded w-24",placeholder:"Reason...",value:d,onChange:e=>u(e.target.value)}),(0,s.jsx)("button",{onClick:()=>n(a.id,d||void 0),disabled:r,className:"p-1 text-red-600 hover:bg-red-50 rounded",children:(0,s.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),(0,s.jsx)("button",{onClick:()=>{o(!1),u("")},className:"p-1 text-apple-gray-400 hover:bg-apple-gray-50 rounded",children:(0,s.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}):(0,s.jsx)("button",{onClick:()=>o(!0),className:"p-1 text-red-600 hover:bg-red-50 rounded",title:"Revoke key",children:(0,s.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}))})]})}function u(){let[e,t]=(0,l.useState)(null),[a,i]=(0,l.useState)(!0),[u,p]=(0,l.useState)(!1),[x,m]=(0,l.useState)(!1),[h,y]=(0,l.useState)(null),[g,v]=(0,l.useState)("all"),[f,j]=(0,l.useState)(null),k=(0,l.useCallback)(async()=>{p(!0);let e=new URLSearchParams({status:g}),t=await fetch("/api/admin/api-keys?".concat(e));t.ok&&y(await t.json()),p(!1)},[g]);(0,l.useEffect)(()=>{(async function(){t(await c()),i(!1)})()},[]),(0,l.useEffect)(()=>{(null==e?void 0:e.is_admin)&&k()},[null==e?void 0:e.is_admin,k]);let N=async(e,t)=>{m(!0);try{let a=await fetch("/api/admin/api-keys",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({key_id:e,reason:t})}),s=await a.json();a.ok?(j({type:"success",text:s.message}),await k()):j({type:"error",text:s.detail||"Failed to revoke key"})}catch(e){j({type:"error",text:"Failed to revoke key"})}m(!1),setTimeout(()=>j(null),5e3)};return a?(0,s.jsx)("div",{className:"min-h-screen bg-apple-gray-50 flex items-center justify-center",children:(0,s.jsx)("div",{className:"animate-pulse text-apple-gray-500",children:"Loading..."})}):(null==e?void 0:e.is_admin)?(0,s.jsxs)(n.H,{title:"API Keys",userEmail:(null==e?void 0:e.email)||void 0,children:[f&&(0,s.jsx)("div",{className:"mb-6 px-4 py-3 rounded-lg ".concat("success"===f.type?"bg-green-100 text-green-800":"bg-red-100 text-red-800"),children:f.text}),(null==h?void 0:h.stats)&&(0,s.jsxs)("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4 mb-6",children:[(0,s.jsx)(r.A,{title:"Total Keys",value:h.stats.total,color:"blue"}),(0,s.jsx)(r.A,{title:"Active",value:h.stats.active,color:"green"}),(0,s.jsx)(r.A,{title:"Stale (30+ days)",value:h.stats.stale,color:h.stats.stale>0?"yellow":"gray"}),(0,s.jsx)(r.A,{title:"Revoked",value:h.stats.revoked,color:"red"})]}),(null==h?void 0:h.stats)&&h.stats.stale>0&&"stale"!==g&&(0,s.jsxs)("div",{className:"mb-6 px-4 py-3 bg-yellow-50 border border-yellow-200 rounded-lg flex items-center gap-3",children:[(0,s.jsx)("svg",{className:"w-5 h-5 text-yellow-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),(0,s.jsxs)("span",{className:"text-yellow-800",children:[(0,s.jsx)("strong",{children:h.stats.stale})," API key",1!==h.stats.stale?"s have":" has"," not been used in 30+ days."," ",(0,s.jsx)("button",{onClick:()=>v("stale"),className:"underline hover:no-underline",children:"View stale keys"})]})]}),(0,s.jsx)("div",{className:"flex gap-1 bg-apple-gray-100 p-1 rounded-lg w-fit mb-6",children:o.map(e=>(0,s.jsx)("button",{onClick:()=>v(e.value),className:"px-3 py-1.5 text-sm font-medium rounded-md transition-colors ".concat(g===e.value?"bg-white text-apple-gray-900 shadow-sm":"text-apple-gray-600 hover:text-apple-gray-900"),children:e.label},e.value))}),(0,s.jsxs)("div",{className:"card overflow-hidden",children:[(0,s.jsx)("div",{className:"px-6 py-4 border-b border-apple-gray-100",children:(0,s.jsx)("h2",{className:"font-semibold text-apple-gray-900",children:"API Key Inventory"})}),u?(0,s.jsx)("div",{className:"py-8 text-center text-apple-gray-500 animate-pulse",children:"Loading..."}):(null==h?void 0:h.keys)&&h.keys.length>0?(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full",children:[(0,s.jsx)("thead",{className:"bg-apple-gray-50 text-xs text-apple-gray-500 uppercase",children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{className:"px-6 py-3 text-left font-medium",children:"Name"}),(0,s.jsx)("th",{className:"px-6 py-3 text-left font-medium",children:"App"}),(0,s.jsx)("th",{className:"px-6 py-3 text-left font-medium",children:"Status"}),(0,s.jsx)("th",{className:"px-6 py-3 text-left font-medium",children:"Created By"}),(0,s.jsx)("th",{className:"px-6 py-3 text-left font-medium",children:"Created"}),(0,s.jsx)("th",{className:"px-6 py-3 text-left font-medium",children:"Last Used"}),(0,s.jsx)("th",{className:"px-6 py-3 text-left font-medium",children:"Actions"})]})}),(0,s.jsx)("tbody",{className:"divide-y divide-apple-gray-100",children:h.keys.map(e=>(0,s.jsx)(d,{apiKey:e,onRevoke:N,processing:x},e.id))})]})}):(0,s.jsx)("div",{className:"py-8 text-center text-apple-gray-500",children:"No API keys found"})]})]}):(0,s.jsx)(n.l,{})}}},function(e){e.O(0,[959,664,477,888,774,179],function(){return e(e.s=9035)}),_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.