1 line
57 KiB
JavaScript
1 line
57 KiB
JavaScript
"use strict";(self.webpackChunkkms=self.webpackChunkkms||[]).push([[665],{665:(e,t,n)=>{n.r(t),n.d(t,{default:()=>p});var a=n(4914),r=n.n(a),l=n(7435),i=n(5101),o=n(5742),s=n(4133),c=n(3065),m=n(5302),d=n(1283);const p=()=>{const e=()=>{const e=window.location.pathname;return e.includes("/applications")?"applications":e.includes("/tokens")?"tokens":e.includes("/token-tester")?"token-tester":e.includes("/audit")?"audit":"dashboard"},[t,n]=r().useState(e()),[a,p]=r().useState(!1),[u,E]=r().useState("");return r().useEffect(()=>{const t=()=>{n(e())};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[]),r().createElement(l.Box,{w:"100%",pos:"relative"},r().createElement(l.Stack,{gap:"lg"},r().createElement("div",null,r().createElement(l.Group,{justify:"space-between",align:"flex-start"},r().createElement("div",null,r().createElement(l.Group,{align:"center",gap:"sm",mb:"xs"},r().createElement(l.Title,{order:1,size:"h2"},"Key Management System"),r().createElement(l.ActionIcon,{variant:"subtle",size:"lg",onClick:()=>{p(e=>!e)},"aria-label":a?"Remove from favorites":"Add to favorites"},a?r().createElement(i.IconStarFilled,{size:20,color:"gold"}):r().createElement(i.IconStar,{size:20})))),r().createElement(l.Group,{align:"flex-start",gap:"lg"},r().createElement("div",null,r().createElement(l.Select,{placeholder:"Choose a color",data:[{value:"red",label:"Red"},{value:"blue",label:"Blue"},{value:"green",label:"Green"},{value:"purple",label:"Purple"},{value:"orange",label:"Orange"},{value:"pink",label:"Pink"},{value:"teal",label:"Teal"}],value:u,onChange:e=>E(e||""),size:"sm",w:150}))))),r().createElement(l.Tabs,{value:t,onChange:e=>{if(e){const t="/app/kms",a="dashboard"===e?t:`${t}/${e}`;window.history.pushState(null,"",a),n(e),window.dispatchEvent(new PopStateEvent("popstate",{state:null}))}}},r().createElement(l.Tabs.List,null,r().createElement(l.Tabs.Tab,{value:"dashboard",leftSection:r().createElement(i.IconDashboard,{size:16})},"Dashboard"),r().createElement(l.Tabs.Tab,{value:"applications",leftSection:r().createElement(i.IconApps,{size:16})},"Applications"),r().createElement(l.Tabs.Tab,{value:"tokens",leftSection:r().createElement(i.IconKey,{size:16})},"Tokens"),r().createElement(l.Tabs.Tab,{value:"token-tester",leftSection:r().createElement(i.IconTestPipe,{size:16})},"Token Tester"),r().createElement(l.Tabs.Tab,{value:"audit",leftSection:r().createElement(i.IconFileText,{size:16})},"Audit Log")),r().createElement(l.Box,{pt:"md"},(()=>{switch(t){case"applications":return r().createElement(o.A,null);case"tokens":return r().createElement(s.A,null);case"token-tester":return r().createElement(c.A,null);case"audit":return r().createElement(m.A,null);default:return r().createElement(d.A,null)}})()))))}},1283:(e,t,n)=>{n.d(t,{A:()=>s});var a=n(4914),r=n.n(a),l=n(7435),i=n(5101),o=n(7246);const s=()=>{const[e,t]=(0,a.useState)(null),[n,s]=(0,a.useState)(!0);(0,a.useEffect)(()=>{c()},[]);const c=async()=>{try{s(!0);const e=await o.K.getApplications(100,0);let n=0;for(const t of e.data)try{n+=(await o.K.getTokensForApplication(t.app_id,100,0)).count}catch(e){console.debug(`No tokens found for app ${t.app_id}`)}const a={totalApplications:e.count,totalTokens:n,recentActivity:0,systemHealth:"healthy"};t(a)}catch(e){console.error("Failed to load dashboard data:",e),t({totalApplications:0,totalTokens:0,recentActivity:0,systemHealth:"error"})}finally{s(!1)}};if(n)return r().createElement(l.Stack,{align:"center",justify:"center",h:400},r().createElement(l.Loader,{size:"lg"}),r().createElement(l.Text,null,"Loading dashboard..."));const m=[{title:"Applications",value:e?.totalApplications||0,icon:i.IconApps,color:"blue",description:"Active applications"},{title:"API Tokens",value:e?.totalTokens||0,icon:i.IconKey,color:"green",description:"Generated tokens"},{title:"Recent Activity",value:e?.recentActivity||0,icon:i.IconActivity,color:"orange",description:"Events today"},{title:"System Health",value:"healthy"===e?.systemHealth?"100%":"85%",icon:"healthy"===e?.systemHealth?i.IconTrendingUp:i.IconAlertTriangle,color:"healthy"===e?.systemHealth?"green":"yellow",description:"System status"}];return r().createElement(l.Stack,{gap:"lg"},r().createElement(l.SimpleGrid,{cols:{base:1,sm:2,lg:4},spacing:"lg"},m.map(e=>r().createElement(l.Card,{key:e.title,shadow:"sm",radius:"md",withBorder:!0,p:"lg"},r().createElement(l.Group,{justify:"space-between",mb:"xs"},r().createElement(l.Text,{size:"sm",c:"dimmed",fw:500},e.title),r().createElement(l.ThemeIcon,{color:e.color,variant:"light",size:"lg"},r().createElement(e.icon,{size:20}))),r().createElement(l.Text,{size:"xl",fw:700,mb:"xs"},e.value),r().createElement(l.Text,{size:"xs",c:"dimmed"},e.description)))),r().createElement(l.Grid,null,r().createElement(l.Grid.Col,{span:{base:12,md:8}},r().createElement(l.Card,{shadow:"sm",radius:"md",withBorder:!0,p:"lg",h:300},r().createElement(l.Title,{order:3,mb:"md"},"Activity Timeline"),r().createElement(l.Stack,{justify:"center",align:"center",h:200},r().createElement(l.Text,{c:"dimmed",ta:"center"},"Activity timeline will be displayed here",r().createElement("br",null),r().createElement(l.Text,{size:"xs",c:"dimmed"},"Integration with audit events coming soon"))))),r().createElement(l.Grid.Col,{span:{base:12,md:4}},r().createElement(l.Card,{shadow:"sm",radius:"md",withBorder:!0,p:"lg",h:300},r().createElement(l.Title,{order:3,mb:"md"},"System Status"),r().createElement(l.Stack,{gap:"md",align:"center"},r().createElement(l.RingProgress,{size:120,thickness:12,sections:[{value:"healthy"===e?.systemHealth?100:85,color:"healthy"===e?.systemHealth?"green":"yellow"}],label:r().createElement(l.Text,{ta:"center",fw:700,size:"lg"},"healthy"===e?.systemHealth?"100%":"85%")}),r().createElement(l.Badge,{color:"healthy"===e?.systemHealth?"green":"yellow",variant:"light",size:"lg"},"healthy"===e?.systemHealth?"Healthy":"Warning"),r().createElement(l.Text,{size:"sm",c:"dimmed",ta:"center"},"All systems operational"))))))}},2501:(e,t,n)=>{n.d(t,{A:()=>o});var a=n(4914),r=n.n(a),l=n(4273),i=n(7246);const o=({opened:e,onClose:t,onSuccess:n,editingApp:a})=>{const o=e=>{const t=e.match(/^(\d+)([hmd]?)$/);if(!t)return 86400;const n=parseInt(t[1]);switch(t[2]||"h"){case"m":return 60*n;case"h":default:return 3600*n;case"d":return 86400*n}},s=[{name:"app_id",label:"Application ID",type:"text",required:!0,placeholder:"my-app-id",disabled:!!a},{name:"app_link",label:"Application Link",type:"text",required:!0,placeholder:"https://myapp.example.com",validation:{url:!0}},{name:"type",label:"Application Type",type:"multiselect",required:!0,options:[{value:"static",label:"Static Token App"},{value:"user",label:"User Token App"}]},{name:"callback_url",label:"Callback URL",type:"text",required:!0,placeholder:"https://myapp.example.com/callback",validation:{url:!0}},{name:"token_prefix",label:"Token Prefix (Optional)",type:"text",required:!1,placeholder:"myapp_"},{name:"token_renewal_duration",label:"Token Renewal Duration",type:"text",required:!1,placeholder:"24h",defaultValue:"24h"},{name:"max_token_duration",label:"Max Token Duration",type:"text",required:!1,placeholder:"168h",defaultValue:"168h"}];return r().createElement(l.Z8,{opened:e,onClose:t,onSuccess:n,title:"Application",editMode:!!a,editItem:a,fields:s,onSubmit:async e=>{const t={...e,token_renewal_duration_seconds:o(e.token_renewal_duration||"24h"),max_token_duration_seconds:o(e.max_token_duration||"168h"),owner:{type:"individual",name:"Admin User",owner:"admin@example.com"}};a?await i.K.updateApplication(a.app_id,t):await i.K.createApplication(t)},width:450})}},3065:(e,t,n)=>{n.d(t,{A:()=>E});var a=n(4914),r=n.n(a),l=n(7435),i=n(6658),o=n(5101),s=n(972),c=n(7373),m=n(7246),d=n(4353),p=n.n(d);function u(){return u=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},u.apply(null,arguments)}const E=()=>{const[e,t]=(0,a.useState)([]),[n,d]=(0,a.useState)(!1),[E,h]=(0,a.useState)(null),b=(0,s.m)({initialValues:{app_id:"",user_id:"",token:"",permissions:[]},validate:{app_id:e=>e.length<1?"Application is required":null,token:e=>e.length<1?"Token is required":null}});(0,a.useEffect)(()=>{g()},[]);const g=async()=>{try{const e=await m.K.getApplications(100,0);t(e.data)}catch(e){console.error("Failed to load applications:",e)}};return r().createElement(l.Stack,{gap:"lg"},r().createElement(l.Grid,null,r().createElement(l.Grid.Col,{span:{base:12,md:6}},r().createElement(l.Card,{shadow:"sm",radius:"md",withBorder:!0,p:"lg"},r().createElement(l.Title,{order:3,mb:"md"},"Test Configuration"),r().createElement("form",{onSubmit:b.onSubmit(async e=>{try{d(!0),h(null);const t={...e,user_id:e.user_id||void 0,permissions:e.permissions&&e.permissions.length>0?e.permissions:void 0},n=await m.K.verifyToken(t);h(n),n.valid?c.notifications.show({title:"Token Verified",message:"Token is "+(n.permitted?"valid and permitted":"valid but not permitted"),color:n.permitted?"green":"orange"}):c.notifications.show({title:"Token Invalid",message:n.error||"Token verification failed",color:"red"})}catch(e){console.error("Failed to verify token:",e),c.notifications.show({title:"Error",message:"Failed to verify token",color:"red"})}finally{d(!1)}})},r().createElement(l.Stack,{gap:"md"},r().createElement(l.Select,u({label:"Application",placeholder:"Select an application to test against",required:!0,data:e.map(e=>({value:e.app_id,label:`${e.app_id} (${e.type.join(", ")})`}))},b.getInputProps("app_id"))),r().createElement(l.TextInput,u({label:"User ID (Optional)",placeholder:"user@example.com",description:"Leave empty for token-only verification"},b.getInputProps("user_id"))),r().createElement(l.Textarea,u({label:"Token",placeholder:"Paste your token here...",required:!0,minRows:3},b.getInputProps("token"))),r().createElement("div",null,r().createElement(l.Text,{size:"sm",fw:500,mb:"xs"},"Required Permissions (Optional)"),r().createElement(l.Text,{size:"xs",c:"dimmed",mb:"md"},"Leave empty to skip permission checks"),r().createElement(i.A,{permissions:b.values.permissions,onChange:e=>b.setFieldValue("permissions",e)})),r().createElement(l.Group,{justify:"flex-end"},r().createElement(l.Button,{type:"submit",loading:n,leftSection:n?r().createElement(l.Loader,{size:16}):r().createElement(o.IconTestPipe,{size:16}),disabled:0===e.length},n?"Testing...":"Test Token")))))),r().createElement(l.Grid.Col,{span:{base:12,md:6}},r().createElement(l.Card,{shadow:"sm",radius:"md",withBorder:!0,p:"lg",h:"100%"},r().createElement(l.Title,{order:3,mb:"md"},"Test Results"),!E&&!n&&r().createElement(l.Stack,{align:"center",justify:"center",h:300},r().createElement(o.IconTestPipe,{size:48,color:"gray"}),r().createElement(l.Text,{c:"dimmed",ta:"center"},'Configure your test parameters and click "Test Token" to see results')),n&&r().createElement(l.Stack,{align:"center",justify:"center",h:300},r().createElement(l.Loader,{size:"lg"}),r().createElement(l.Text,null,"Verifying token...")),E&&r().createElement(l.Stack,{gap:"md"},r().createElement(l.Alert,{icon:r().createElement((e=>e.valid?e.valid&&e.permitted?o.IconCheck:o.IconAlertCircle:o.IconX)(E),{size:16}),title:E.valid?E.permitted?"Token Valid & Permitted":"Token Valid but Not Permitted":"Token Invalid",color:(e=>e.valid?e.valid&&e.permitted?"green":"orange":"red")(E)},E.error||(E.valid&&E.permitted?"Token is valid and has the required permissions":E.valid?"Token is valid but lacks some required permissions":"Token verification failed")),r().createElement(l.Divider,null),r().createElement(l.Stack,{gap:"xs"},r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Valid:"),r().createElement(l.Badge,{color:E.valid?"green":"red",variant:"light"},E.valid?"Yes":"No")),r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Permitted:"),r().createElement(l.Badge,{color:E.permitted?"green":"red",variant:"light"},E.permitted?"Yes":"No")),r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Token Type:"),r().createElement(l.Badge,{variant:"light"},E.token_type)),E.user_id&&r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"User ID:"),r().createElement(l.Text,{size:"sm",style:{fontFamily:"monospace"}},E.user_id)),E.expires_at&&r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Expires At:"),r().createElement(l.Text,{size:"sm"},p()(E.expires_at).format("MMM DD, YYYY HH:mm"))),E.max_valid_at&&r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Max Valid Until:"),r().createElement(l.Text,{size:"sm"},p()(E.max_valid_at).format("MMM DD, YYYY HH:mm")))),E.permissions&&E.permissions.length>0&&r().createElement(r().Fragment,null,r().createElement(l.Divider,null),r().createElement("div",null,r().createElement(l.Text,{fw:500,mb:"xs"},"Token Permissions:"),r().createElement(l.Group,{gap:"xs"},E.permissions.map(e=>r().createElement(l.Badge,{key:e,variant:"light",size:"sm",color:"blue"},e))))),E.permission_results&&Object.keys(E.permission_results).length>0&&r().createElement(r().Fragment,null,r().createElement(l.Divider,null),r().createElement("div",null,r().createElement(l.Text,{fw:500,mb:"xs"},"Permission Check Results:"),r().createElement(l.Stack,{gap:"xs"},Object.entries(E.permission_results).map(([e,t])=>r().createElement(l.Group,{key:e,justify:"space-between"},r().createElement(l.Text,{size:"sm",style:{fontFamily:"monospace"}},e),r().createElement(l.Badge,{color:t?"green":"red",variant:"light",size:"sm"},t?"Granted":"Denied")))))),E.claims&&Object.keys(E.claims).length>0&&r().createElement(r().Fragment,null,r().createElement(l.Divider,null),r().createElement("div",null,r().createElement(l.Text,{fw:500,mb:"xs"},"Token Claims:"),r().createElement(l.Code,{block:!0},JSON.stringify(E.claims,null,2)))))))),0===e.length&&r().createElement(l.Alert,{icon:r().createElement(o.IconAlertCircle,{size:16}),title:"No Applications Found",color:"yellow"},"You need to create at least one application before you can test tokens."))}},4133:(e,t,n)=>{n.d(t,{A:()=>u});var a=n(4914),r=n.n(a),l=n(7435),i=n(5101),o=n(972),s=n(7373),c=n(7246),m=n(7918),d=n(4353),p=n.n(d);const u=()=>{const[e,t]=(0,a.useState)([]),[n,d]=(0,a.useState)([]),[u,E]=(0,a.useState)(!1),[h,b]=(0,a.useState)(!1),[g,f]=(0,a.useState)(!1),[y,v]=(0,a.useState)(null),T=(0,o.m)({initialValues:{app_id:"",owner:{type:"individual",name:"Admin User",owner:"admin@example.com"},permissions:[]},validate:{app_id:e=>e.length<1?"Application is required":null,permissions:e=>e.length<1?"At least one permission is required":null}});(0,a.useEffect)(()=>{x(),k()},[]);const x=async()=>{try{const e=await c.K.getApplications(100,0);t(e.data)}catch(e){console.error("Failed to load applications:",e)}},k=async()=>{try{E(!0);const e=await c.K.getApplications(100,0),t=[];for(const n of e.data)try{const e=(await c.K.getTokensForApplication(n.app_id,100,0)).data.map(e=>({...e,app:n}));t.push(...e)}catch(e){}d(t)}catch(e){console.error("Failed to load tokens:",e),s.notifications.show({title:"Error",message:"Failed to load tokens",color:"red"})}finally{E(!1)}},w=e=>{navigator.clipboard.writeText(e),s.notifications.show({title:"Copied",message:"Copied to clipboard",color:"blue"})},_=n.map(e=>r().createElement(l.Table.Tr,{key:e.id},r().createElement(l.Table.Td,null,r().createElement(l.Group,{gap:"xs"},r().createElement(i.IconKey,{size:16,color:"blue"}),r().createElement(l.Text,{size:"sm",style:{fontFamily:"monospace"}},e.id.substring(0,8),"..."))),r().createElement(l.Table.Td,null,r().createElement(l.Badge,{variant:"light",color:"blue"},e.app?.app_id||"Unknown")),r().createElement(l.Table.Td,null,r().createElement(l.Text,{size:"sm",c:"dimmed"},e.owner.name," (",e.owner.owner,")")),r().createElement(l.Table.Td,null,r().createElement(l.Badge,{variant:"light",color:"green"},e.type)),r().createElement(l.Table.Td,null,r().createElement(l.Text,{size:"sm"},p()(e.created_at).format("MMM DD, YYYY"))),r().createElement(l.Table.Td,null,r().createElement(l.Group,{gap:"xs"},r().createElement(l.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>w(e.id),title:"Copy Token ID"},r().createElement(i.IconCopy,{size:16})),r().createElement(l.ActionIcon,{variant:"subtle",color:"red",onClick:()=>(async e=>{if(window.confirm("Are you sure you want to delete this token? This action cannot be undone."))try{await c.K.deleteToken(e),s.notifications.show({title:"Success",message:"Token deleted successfully",color:"green"}),k()}catch(e){console.error("Failed to delete token:",e),s.notifications.show({title:"Error",message:"Failed to delete token",color:"red"})}})(e.id),title:"Delete Token"},r().createElement(i.IconTrash,{size:16}))))));return r().createElement(l.Stack,{gap:"lg",style:{transition:"margin-right 0.3s ease",marginRight:h?"450px":"0"}},r().createElement(l.Group,{justify:"space-between"},r().createElement("div",null,r().createElement(l.Title,{order:2,mb:"xs"},"API Tokens")),r().createElement(l.Button,{leftSection:r().createElement(i.IconPlus,{size:16}),onClick:()=>{T.reset(),b(!0)},disabled:0===e.length},"Create Token")),0===e.length&&r().createElement(l.Alert,{icon:r().createElement(i.IconAlertCircle,{size:16}),title:"No Applications Found",color:"yellow"},"You need to create at least one application before you can create tokens."),u?r().createElement(l.Stack,{align:"center",justify:"center",h:200},r().createElement(l.Loader,{size:"lg"}),r().createElement(l.Text,null,"Loading tokens...")):0===n.length?r().createElement(l.Card,{shadow:"sm",radius:"md",withBorder:!0,p:"xl"},r().createElement(l.Stack,{align:"center",gap:"md"},r().createElement(i.IconKey,{size:48,color:"gray"}),r().createElement("div",{style:{textAlign:"center"}},r().createElement(l.Text,{fw:500,mb:"xs"},"No tokens found"),r().createElement(l.Text,{size:"sm",c:"dimmed"},"Create your first API token to start using the key management system")),e.length>0&&r().createElement(l.Button,{leftSection:r().createElement(i.IconPlus,{size:16}),onClick:()=>{T.reset(),b(!0)}},"Create Token"))):r().createElement(l.Card,{shadow:"sm",radius:"md",withBorder:!0},r().createElement(l.Table,null,r().createElement(l.Table.Thead,null,r().createElement(l.Table.Tr,null,r().createElement(l.Table.Th,null,"Token ID"),r().createElement(l.Table.Th,null,"Application"),r().createElement(l.Table.Th,null,"Owner"),r().createElement(l.Table.Th,null,"Type"),r().createElement(l.Table.Th,null,"Created"),r().createElement(l.Table.Th,null,"Actions"))),r().createElement(l.Table.Tbody,null,_))),r().createElement(m.A,{opened:h,onClose:()=>{b(!1),T.reset()},onSuccess:()=>{k()},applications:e}),r().createElement(l.Modal,{opened:g,onClose:()=>{f(!1),v(null)},title:"Token Created Successfully",size:"lg"},y&&r().createElement(l.Stack,{gap:"md"},r().createElement(l.Alert,{icon:r().createElement(i.IconCheck,{size:16}),title:"Important",color:"green"},"This is the only time you will see the full token. Make sure to copy and store it securely."),r().createElement("div",null,r().createElement(l.Text,{fw:500,mb:"xs"},"Token:"),r().createElement(l.Group,{gap:"xs"},r().createElement(l.Code,{block:!0,style:{fontSize:"12px",wordBreak:"break-all",flex:1}},y.token),r().createElement(l.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>w(y.token),title:"Copy Token"},r().createElement(i.IconCopy,{size:16})))),r().createElement(l.Divider,null),r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Token ID:"),r().createElement(l.Group,{gap:"xs"},r().createElement(l.Text,{size:"sm",style:{fontFamily:"monospace"}},y.id),r().createElement(l.ActionIcon,{size:"sm",variant:"subtle",onClick:()=>w(y.id)},r().createElement(i.IconCopy,{size:12})))),r().createElement(l.Group,{justify:"space-between",align:"flex-start"},r().createElement(l.Text,{fw:500},"Permissions:"),r().createElement(l.Stack,{gap:"xs",align:"flex-end"},y.permissions.map(e=>r().createElement(l.Badge,{key:e,variant:"light",size:"sm"},e)))),r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Created:"),r().createElement(l.Text,{size:"sm"},p()(y.created_at).format("MMM DD, YYYY HH:mm"))),r().createElement(l.Group,{justify:"flex-end",mt:"lg"},r().createElement(l.Button,{onClick:()=>{f(!1),v(null)}},"Close")))))}},4273:(e,t,n)=>{n.d(t,{BJ:()=>l.Stack,EY:()=>l.Text,Ex:()=>l.Badge,YJ:()=>l.Group,Z8:()=>u,bQ:()=>E});var a=n(1085),r=n(5641),l=n(8002),i=n(7114),o=n(8317),s=n(3970),c=n(2678),m=(n(2170),function(){return m=Object.assign||function(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},m.apply(this,arguments)});function d(e,t,n,a){return new(n||(n=Promise))(function(r,l){function i(e){try{s(a.next(e))}catch(e){l(e)}}function o(e){try{s(a.throw(e))}catch(e){l(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,o)}s((a=a.apply(e,t||[])).next())})}function p(e,t){var n,a,r,l={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=o(0),i.throw=o(1),i.return=o(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function o(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,o[0]&&(l=0)),l;)try{if(n=1,a&&(r=2&o[0]?a.return:o[0]?a.throw||((r=a.return)&&r.call(a),0):a.next)&&!(r=r.call(a,o[1])).done)return r;switch(a=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return l.label++,{value:o[1],done:!1};case 5:l.label++,a=o[1],o=[0];continue;case 7:o=l.ops.pop(),l.trys.pop();continue;default:if(!((r=(r=l.trys).length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){l=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){l.label=o[1];break}if(6===o[0]&&l.label<r[1]){l.label=r[1],r=o;break}if(r&&l.label<r[2]){l.label=r[2],l.ops.push(o);break}r[2]&&l.ops.pop(),l.trys.pop();continue}o=t.call(e,l)}catch(e){o=[6,e],a=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}"function"==typeof SuppressedError&&SuppressedError;var u=function(e){var t=e.opened,n=e.onClose,c=e.onSuccess,u=e.title,E=e.editMode,h=void 0!==E&&E,b=e.editItem,g=e.fields,f=e.onSubmit,y=e.width,v=void 0===y?450:y,T=e.initialValues,x=void 0===T?{}:T;e.validateOnSubmit;var k,w=h&&!!b,_=function(){var e={};return g.forEach(function(t){var n;e[t.name]=null!==(n=t.defaultValue)&&void 0!==n?n:"multiselect"===t.type?[]:""}),m(m({},e),x)},S=(0,o.m)({initialValues:_(),validate:(k={},g.forEach(function(e){k[e.name]=function(t){var n,a,r,l,i,o;return e.required&&(!t||"string"==typeof t&&""===t.trim())?"".concat(e.label," is required"):(null===(n=e.validation)||void 0===n?void 0:n.email)&&t&&!/^\S+@\S+$/.test(t)?"Invalid email format":(null===(a=e.validation)||void 0===a?void 0:a.url)&&t&&!/^https?:\/\/.+/.test(t)?"Invalid URL format":(null===(r=e.validation)||void 0===r?void 0:r.minLength)&&t&&t.length<e.validation.minLength?"".concat(e.label," must be at least ").concat(e.validation.minLength," characters"):(null===(l=e.validation)||void 0===l?void 0:l.maxLength)&&t&&t.length>e.validation.maxLength?"".concat(e.label," must be no more than ").concat(e.validation.maxLength," characters"):(null===(i=e.validation)||void 0===i?void 0:i.pattern)&&t&&!e.validation.pattern.test(t)?"".concat(e.label," format is invalid"):(null===(o=e.validation)||void 0===o?void 0:o.custom)?e.validation.custom(t):null}}),k)});return(0,r.useEffect)(function(){if(w&&b){var e={};g.forEach(function(t){var n,a;e[t.name]=null!==(a=null!==(n=b[t.name])&&void 0!==n?n:t.defaultValue)&&void 0!==a?a:""}),S.setValues(e)}else w||S.setValues(_())},[b,t,w]),(0,a.jsxs)(l.Paper,{style:{position:"fixed",top:60,right:t?0:"-".concat(v,"px"),bottom:0,width:"".concat(v,"px"),zIndex:1e3,borderRadius:0,display:"flex",flexDirection:"column",borderLeft:"1px solid var(--mantine-color-gray-3)",backgroundColor:"var(--mantine-color-body)",transition:"right 0.3s ease"},children:[(0,a.jsxs)(l.Group,{justify:"space-between",p:"md",style:{borderBottom:"1px solid var(--mantine-color-gray-3)"},children:[(0,a.jsx)(l.Title,{order:4,children:w?"Edit ".concat(u):"Create New ".concat(u)}),(0,a.jsx)(l.ActionIcon,{variant:"subtle",color:"gray",onClick:n,children:(0,a.jsx)(i.IconX,{size:18})})]}),(0,a.jsx)(l.ScrollArea,{style:{flex:1},children:(0,a.jsx)(l.Box,{p:"md",children:(0,a.jsx)("form",{onSubmit:S.onSubmit(function(e){return d(void 0,void 0,void 0,function(){var t,a,r;return p(this,function(l){switch(l.label){case 0:return l.trys.push([0,2,,3]),[4,f(e)];case 1:return l.sent(),t={title:"Success",message:"".concat(u," ").concat(w?"updated":"created"," successfully"),color:"green"},s.notifications.show(t),c(),n(),S.reset(),[3,3];case 2:return a=l.sent(),console.error("Error ".concat(w?"updating":"creating"," ").concat(u.toLowerCase(),":"),a),r={title:"Error",message:a.message||"Failed to ".concat(w?"update":"create"," ").concat(u.toLowerCase()),color:"red"},s.notifications.show(r),[3,3];case 3:return[2]}})})}),children:(0,a.jsxs)(l.Stack,{gap:"md",children:[g.map(function(e){var t=S.getInputProps(e.name),n=m({key:e.name,label:e.label,placeholder:e.placeholder,description:e.description,required:e.required,disabled:e.disabled||w&&"id"===e.name},t);switch(e.type){case"email":return(0,a.jsx)(l.TextInput,m({},n,{type:"email"}));case"number":return(0,a.jsx)(l.NumberInput,m({},n));case"textarea":return(0,a.jsx)(l.Textarea,m({},n,{autosize:!0,minRows:3,maxRows:6}));case"select":return(0,a.jsx)(l.Select,m({},n,{data:e.options||[]}));case"multiselect":return(0,a.jsx)(l.MultiSelect,m({},n,{data:e.options||[]}));case"json":return(0,a.jsx)(l.JsonInput,m({},n,{validationError:"Invalid JSON format",formatOnBlur:!0,autosize:!0,minRows:3}));default:return(0,a.jsx)(l.TextInput,m({},n))}}),(0,a.jsxs)(l.Group,{justify:"flex-end",mt:"md",children:[(0,a.jsx)(l.Button,{variant:"light",onClick:n,children:"Cancel"}),(0,a.jsxs)(l.Button,{type:"submit",children:[w?"Update":"Create"," ",u]})]})]})})})})]})},E=function(e){var t=e.data,n=e.columns,o=e.loading,u=void 0!==o&&o,E=e.error,h=void 0===E?null:E,b=e.title,g=e.total,f=void 0===g?0:g,y=e.page,v=void 0===y?1:y,T=e.pageSize,x=void 0===T?10:T,k=e.onPageChange,w=e.onAdd,_=e.onEdit,S=e.onDelete,z=e.onRefresh,A=e.customActions,I=void 0===A?[]:A,C=e.searchable,j=void 0===C||C,D=e.filterable,O=void 0!==D&&D,R=e.filters,P=void 0===R?{}:R,G=e.onFiltersChange,L=e.withBorder,M=void 0===L||L,B=e.withColumnBorders,N=void 0!==B&&B,F=e.striped,Y=void 0===F||F,U=e.highlightOnHover,H=void 0===U||U,K=e.emptyMessage,V=void 0===K?"No data available":K,q=(0,r.useState)(P),X=q[0],W=q[1];(0,r.useEffect)(function(){W(P)},[P]);var $=function(e,t){var n=t[e.key];return e.render?e.render(n,t):null==n?(0,a.jsx)(l.Text,{c:"dimmed",children:"-"}):"boolean"==typeof n?(0,a.jsx)(l.Badge,{color:n?"green":"gray",size:"sm",children:n?"Yes":"No"}):"status"===e.key?(0,a.jsx)(l.Badge,{color:{active:"green",inactive:"gray",pending:"yellow",suspended:"red",success:"green",error:"red",warning:"yellow"}[n]||"blue",size:"sm",children:n}):(0,a.jsx)(l.Text,{children:n.toString()})},J=function(e){var t=[];_&&t.push({key:"edit",label:"Edit",icon:(0,a.jsx)(i.IconEdit,{size:14}),onClick:_}),S&&t.push({key:"delete",label:"Delete",icon:(0,a.jsx)(i.IconTrash,{size:14}),color:"red",onClick:function(){return t=e,void c.jQ.openConfirmModal({title:"Confirm Delete",children:(0,a.jsx)(l.Text,{size:"sm",children:"Are you sure you want to delete this item? This action cannot be undone."}),labels:{confirm:"Delete",cancel:"Cancel"},confirmProps:{color:"red"},onConfirm:function(){return d(void 0,void 0,void 0,function(){var e;return p(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),S?[4,S(t)]:[3,2];case 1:n.sent(),s.notifications.show({title:"Success",message:"Item deleted successfully",color:"green"}),n.label=2;case 2:return[3,4];case 3:return e=n.sent(),s.notifications.show({title:"Error",message:e.message||"Failed to delete item",color:"red"}),[3,4];case 4:return[2]}})})}});var t}}),t.push.apply(t,I);var n=t.filter(function(t){return!t.show||t.show(e)});return 0===n.length?null:(0,a.jsxs)(l.Menu,{position:"bottom-end",children:[(0,a.jsx)(l.Menu.Target,{children:(0,a.jsx)(l.ActionIcon,{variant:"subtle",color:"gray",children:(0,a.jsx)(i.IconDots,{size:16})})}),(0,a.jsx)(l.Menu.Dropdown,{children:n.map(function(t){return(0,a.jsx)(l.Menu.Item,{leftSection:t.icon,color:t.color,onClick:function(){return t.onClick(e)},children:t.label},t.key)})})]})},Z=Math.ceil(f/x);return(0,a.jsxs)(l.Stack,{gap:"md",children:[(0,a.jsxs)(l.Group,{justify:"space-between",children:[(0,a.jsx)(l.Group,{children:b&&(0,a.jsx)(l.Text,{size:"xl",fw:600,children:b})}),(0,a.jsxs)(l.Group,{children:[z&&(0,a.jsx)(l.ActionIcon,{variant:"light",onClick:z,children:(0,a.jsx)(i.IconRefresh,{size:16})}),w&&(0,a.jsx)(l.Button,{leftSection:(0,a.jsx)(i.IconPlus,{size:16}),onClick:w,children:"Add New"})]})]}),(j||O)&&(0,a.jsxs)(l.Group,{children:[j&&(0,a.jsx)(l.TextInput,{placeholder:"Search...",leftSection:(0,a.jsx)(i.IconSearch,{size:16}),value:X.search||"",onChange:function(e){return function(e){!function(e,t){var n,a=m(m({},X),((n={}).search=t,n));W(a),null==G||G(a)}(0,e)}(e.currentTarget.value)},style:{flex:1}}),O&&(0,a.jsx)(l.Group,{children:(0,a.jsx)(l.ActionIcon,{variant:"light",children:(0,a.jsx)(i.IconFilter,{size:16})})})]}),(0,a.jsxs)(l.Paper,{withBorder:M,pos:"relative",children:[(0,a.jsx)(l.LoadingOverlay,{visible:u}),h?(0,a.jsx)(l.Center,{p:"xl",children:(0,a.jsxs)(l.Stack,{align:"center",gap:"xs",children:[(0,a.jsx)(l.Text,{c:"red",fw:500,children:"Error loading data"}),(0,a.jsx)(l.Text,{c:"dimmed",size:"sm",children:h}),z&&(0,a.jsx)(l.Button,{variant:"light",size:"sm",onClick:z,children:"Try Again"})]})}):0===t.length?(0,a.jsx)(l.Center,{p:"xl",children:(0,a.jsxs)(l.Stack,{align:"center",gap:"xs",children:[(0,a.jsx)(l.Text,{c:"dimmed",children:V}),w&&(0,a.jsx)(l.Button,{variant:"light",size:"sm",onClick:w,children:"Add First Item"})]})}):(0,a.jsxs)(l.Table,{striped:Y,highlightOnHover:H,withColumnBorders:N,children:[(0,a.jsx)(l.Table.Thead,{children:(0,a.jsxs)(l.Table.Tr,{children:[n.map(function(e){return(0,a.jsx)(l.Table.Th,{style:{width:e.width},children:e.label},e.key)}),(_||S||I.length>0)&&(0,a.jsx)(l.Table.Th,{style:{width:50},children:"Actions"})]})}),(0,a.jsx)(l.Table.Tbody,{children:t.map(function(e){return(0,a.jsxs)(l.Table.Tr,{children:[n.map(function(t){return(0,a.jsx)(l.Table.Td,{children:$(t,e)},"".concat(e.id,"-").concat(t.key))}),(_||S||I.length>0)&&(0,a.jsx)(l.Table.Td,{children:J(e)})]},e.id)})})]})]}),Z>1&&(0,a.jsx)(l.Group,{justify:"center",children:(0,a.jsx)(l.Pagination,{total:Z,value:v,onChange:k,size:"sm"})})]})};i.IconUsers,i.IconApps,i.IconFunction,i.IconKey,i.IconFunction,i.IconKey,i.IconDatabase,i.IconDatabase},5302:(e,t,n)=>{n.d(t,{A:()=>d});var a=n(4914),r=n.n(a),l=n(7435),i=n(5101),o=n(7373),s=n(7246),c=n(4353),m=n.n(c);const d=()=>{const[e,t]=(0,a.useState)([]),[n,c]=(0,a.useState)(!1),[d,p]=(0,a.useState)(0),[u,E]=(0,a.useState)(1),[h]=(0,a.useState)(20),[b,g]=(0,a.useState)(!1),[f,y]=(0,a.useState)(null),[v,T]=(0,a.useState)({limit:h,offset:0,order_by:"timestamp",order_desc:!0});(0,a.useEffect)(()=>{x()},[v]);const x=async()=>{try{c(!0);const e=await s.K.getAuditEvents(v);t(e.events),p(e.total)}catch(e){console.error("Failed to load audit events:",e),o.notifications.show({title:"Error",message:"Failed to load audit events",color:"red"})}finally{c(!1)}},k=(e,t)=>{E(1),T(n=>({...n,[e]:t,offset:0}))},w=e=>{switch(e.toLowerCase()){case"success":return"green";case"failure":case"error":return"red";case"warning":return"yellow";default:return"gray"}},_=e=>e.startsWith("auth.")?"blue":e.startsWith("app.")?"purple":e.startsWith("token.")?"green":e.startsWith("permission.")?"orange":"gray",S=Math.ceil(d/h),z=e.map(e=>r().createElement(l.Table.Tr,{key:e.id},r().createElement(l.Table.Td,null,r().createElement(l.Text,{size:"sm"},m()(e.timestamp).format("MMM DD, HH:mm:ss"))),r().createElement(l.Table.Td,null,r().createElement(l.Badge,{color:_(e.type),variant:"light",size:"sm"},e.type)),r().createElement(l.Table.Td,null,r().createElement(l.Badge,{color:w(e.status),variant:"light",size:"sm"},e.status)),r().createElement(l.Table.Td,null,r().createElement(l.Text,{size:"sm",c:"dimmed"},e.actor_id||"System")),r().createElement(l.Table.Td,null,r().createElement(l.Text,{size:"sm",lineClamp:2},e.description)),r().createElement(l.Table.Td,null,r().createElement(l.Group,{gap:"xs"},r().createElement(l.Button,{variant:"subtle",size:"xs",leftSection:r().createElement(i.IconEye,{size:14}),onClick:()=>(e=>{y(e),g(!0)})(e)},"Details")))));return r().createElement(l.Stack,{gap:"lg"},r().createElement(l.Group,{justify:"space-between"},r().createElement("div",null,r().createElement(l.Title,{order:2,mb:"xs"},"Audit Log")),r().createElement(l.Button,{leftSection:r().createElement(i.IconRefresh,{size:16}),variant:"light",onClick:x,loading:n},"Refresh")),r().createElement(l.Card,{shadow:"sm",radius:"md",withBorder:!0,p:"md"},r().createElement(l.Stack,{gap:"md"},r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500,size:"sm"},"Filters"),r().createElement(l.Button,{variant:"subtle",size:"xs",onClick:()=>{E(1),T({limit:h,offset:0,order_by:"timestamp",order_desc:!0})}},"Clear All")),r().createElement(l.Grid,null,r().createElement(l.Grid.Col,{span:{base:12,sm:6,md:3}},r().createElement(l.MultiSelect,{label:"Event Types",placeholder:"All types",data:[{value:"auth.login",label:"Authentication - Login"},{value:"auth.logout",label:"Authentication - Logout"},{value:"auth.token_verified",label:"Authentication - Token Verified"},{value:"app.created",label:"Application - Created"},{value:"app.updated",label:"Application - Updated"},{value:"app.deleted",label:"Application - Deleted"},{value:"token.created",label:"Token - Created"},{value:"token.revoked",label:"Token - Revoked"},{value:"token.validated",label:"Token - Validated"},{value:"permission.granted",label:"Permission - Granted"},{value:"permission.denied",label:"Permission - Denied"}],value:v.event_types||[],onChange:e=>k("event_types",e.length?e:void 0),clearable:!0,searchable:!0,size:"sm"})),r().createElement(l.Grid.Col,{span:{base:12,sm:6,md:3}},r().createElement(l.MultiSelect,{label:"Status",placeholder:"All statuses",data:[{value:"success",label:"Success"},{value:"failure",label:"Failure"},{value:"error",label:"Error"},{value:"warning",label:"Warning"}],value:v.statuses||[],onChange:e=>k("statuses",e.length?e:void 0),clearable:!0,size:"sm"})),r().createElement(l.Grid.Col,{span:{base:12,sm:6,md:3}},r().createElement(l.TextInput,{label:"Actor ID",placeholder:"user@example.com",value:v.actor_id||"",onChange:e=>k("actor_id",e.target.value||void 0),size:"sm",leftSection:r().createElement(i.IconSearch,{size:16})})),r().createElement(l.Grid.Col,{span:{base:12,sm:6,md:3}},r().createElement(l.TextInput,{label:"Resource ID",placeholder:"Resource identifier",value:v.resource_id||"",onChange:e=>k("resource_id",e.target.value||void 0),size:"sm",leftSection:r().createElement(i.IconSearch,{size:16})}))))),r().createElement(l.Card,{shadow:"sm",radius:"md",withBorder:!0},n?r().createElement(l.Stack,{align:"center",justify:"center",h:300},r().createElement(l.Loader,{size:"lg"}),r().createElement(l.Text,null,"Loading audit events...")):0===e.length?r().createElement(l.Stack,{align:"center",justify:"center",h:300},r().createElement(i.IconActivity,{size:48,color:"gray"}),r().createElement("div",{style:{textAlign:"center"}},r().createElement(l.Text,{fw:500,mb:"xs"},"No audit events found"),r().createElement(l.Text,{size:"sm",c:"dimmed"},Object.keys(v).filter(e=>"limit"!==e&&"offset"!==e&&"order_by"!==e&&"order_desc"!==e).some(e=>v[e])?"Try adjusting your filters or clearing them to see more results":"Audit events will appear here as system activities occur"))):r().createElement(r().Fragment,null,r().createElement(l.Table,null,r().createElement(l.Table.Thead,null,r().createElement(l.Table.Tr,null,r().createElement(l.Table.Th,null,"Timestamp"),r().createElement(l.Table.Th,null,"Event Type"),r().createElement(l.Table.Th,null,"Status"),r().createElement(l.Table.Th,null,"Actor"),r().createElement(l.Table.Th,null,"Description"),r().createElement(l.Table.Th,null,"Actions"))),r().createElement(l.Table.Tbody,null,z)),S>1&&r().createElement(l.Group,{justify:"space-between",mt:"md",px:"md",pb:"md"},r().createElement(l.Text,{size:"sm",c:"dimmed"},"Showing ",(u-1)*h+1," to ",Math.min(u*h,d)," of ",d," events"),r().createElement(l.Pagination,{total:S,value:u,onChange:e=>{E(e),T(t=>({...t,offset:(e-1)*h}))},size:"sm"})))),r().createElement(l.Modal,{opened:b,onClose:()=>g(!1),title:"Audit Event Details",size:"lg"},f&&r().createElement(l.Stack,{gap:"md"},r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Event ID:"),r().createElement(l.Text,{size:"sm",style:{fontFamily:"monospace"}},f.id)),r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Timestamp:"),r().createElement(l.Text,{size:"sm"},m()(f.timestamp).format("MMMM DD, YYYY HH:mm:ss"))),r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Event Type:"),r().createElement(l.Badge,{color:_(f.type),variant:"light"},f.type)),r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Status:"),r().createElement(l.Badge,{color:w(f.status),variant:"light"},f.status)),r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Action:"),r().createElement(l.Text,{size:"sm"},f.action)),r().createElement(l.Divider,null),r().createElement("div",null,r().createElement(l.Text,{fw:500,mb:"xs"},"Description:"),r().createElement(l.Text,{size:"sm"},f.description)),f.actor_id&&r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Actor ID:"),r().createElement(l.Text,{size:"sm"},f.actor_id)),f.actor_ip&&r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"IP Address:"),r().createElement(l.Text,{size:"sm",style:{fontFamily:"monospace"}},f.actor_ip)),f.resource_id&&r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Resource ID:"),r().createElement(l.Text,{size:"sm"},f.resource_id)),f.resource_type&&r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Resource Type:"),r().createElement(l.Badge,{variant:"outline",size:"sm"},f.resource_type)),f.request_id&&r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Request ID:"),r().createElement(l.Text,{size:"sm",style:{fontFamily:"monospace"}},f.request_id)),f.session_id&&r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{fw:500},"Session ID:"),r().createElement(l.Text,{size:"sm",style:{fontFamily:"monospace"}},f.session_id)),f.user_agent&&r().createElement("div",null,r().createElement(l.Text,{fw:500,mb:"xs"},"User Agent:"),r().createElement(l.Text,{size:"xs",c:"dimmed",style:{fontFamily:"monospace"}},f.user_agent)),f.details&&Object.keys(f.details).length>0&&r().createElement(r().Fragment,null,r().createElement(l.Divider,null),r().createElement("div",null,r().createElement(l.Text,{fw:500,mb:"xs"},"Additional Details:"),r().createElement(l.Code,{block:!0},JSON.stringify(f.details,null,2)))))))}},5742:(e,t,n)=>{n.d(t,{A:()=>p});var a=n(4914),r=n.n(a),l=n(4273),i=n(5101),o=n(7373),s=n(7246),c=n(2501),m=n(4353),d=n.n(m);const p=()=>{const[e,t]=(0,a.useState)([]),[n,m]=(0,a.useState)(!1),[p,u]=(0,a.useState)(!1),[E,h]=(0,a.useState)(null);(0,a.useEffect)(()=>{b()},[]);const b=async()=>{try{m(!0);const e=await s.K.getApplications(100,0);t(e.data)}catch(e){console.error("Failed to load applications:",e)}finally{m(!1)}},g=[{key:"app_id",label:"Application ID",render:e=>r().createElement(l.EY,{fw:500},e)},{key:"type",label:"Type",render:e=>r().createElement(l.YJ,{gap:"xs"},e.map(e=>r().createElement(l.Ex,{key:e,variant:"light",size:"sm"},e)))},{key:"owner",label:"Owner",render:e=>r().createElement(l.EY,{size:"sm",c:"dimmed"},e.name," (",e.owner,")")},{key:"created_at",label:"Created",render:e=>r().createElement(l.EY,{size:"sm"},d()(e).format("MMM DD, YYYY"))}],f=[{key:"view",label:"View Details",icon:r().createElement(i.IconEye,{size:14}),onClick:e=>{console.log("View details for:",e.app_id)}},{key:"copy",label:"Copy App ID",icon:r().createElement(i.IconCopy,{size:14}),onClick:e=>{return t=e.app_id,navigator.clipboard.writeText(t),void o.notifications.show({title:"Copied",message:"Copied to clipboard",color:"blue"});var t}}];return r().createElement(l.BJ,{gap:"md"},r().createElement(l.bQ,{data:e,columns:g,loading:n,title:"Applications",searchable:!0,onAdd:()=>{h(null),u(!0)},onEdit:e=>{h(e),u(!0)},onDelete:async e=>{await s.K.deleteApplication(e.app_id),b()},onRefresh:b,customActions:f,emptyMessage:"No applications found"}),r().createElement(c.A,{opened:p,onClose:()=>u(!1),onSuccess:()=>{u(!1),h(null),b()},editingApp:E}))}},6658:(e,t,n)=>{n.d(t,{A:()=>s});var a=n(4914),r=n.n(a),l=n(7435),i=n(5101);const o=[{id:"app",label:"Application",description:"Access to application management",children:[{id:"app.read",label:"Read",description:"Read application information"},{id:"app.write",label:"Write",description:"Create and update applications"},{id:"app.delete",label:"Delete",description:"Delete applications"}]},{id:"token",label:"Token",description:"Access to token management",children:[{id:"token.read",label:"Read",description:"Read token information"},{id:"token.create",label:"Create",description:"Create new tokens"},{id:"token.revoke",label:"Revoke",description:"Revoke existing tokens"}]},{id:"repo",label:"Repository",description:"Access to repository operations",children:[{id:"repo.read",label:"Read",description:"Read repository data"},{id:"repo.write",label:"Write",description:"Write to repositories"},{id:"repo.admin",label:"Admin",description:"Administrative access to repositories"}]},{id:"permission",label:"Permission",description:"Access to permission management",children:[{id:"permission.read",label:"Read",description:"Read permission information"},{id:"permission.write",label:"Write",description:"Create and update permissions"},{id:"permission.grant",label:"Grant",description:"Grant permissions to tokens"},{id:"permission.revoke",label:"Revoke",description:"Revoke permissions from tokens"}]}],s=({permissions:e,onChange:t})=>{const[n,s]=(0,a.useState)(new Set);(0,a.useEffect)(()=>{const e=o.map(e=>e.id);s(new Set(e))},[]);const c=(a,o=0)=>{const m=(t=>{if(!t.children)return e.includes(t.id)?"checked":"unchecked";const n=t.children.filter(t=>e.includes(t.id));return 0===n.length?"unchecked":n.length===t.children.length?"checked":"indeterminate"})(a),d=n.has(a.id),p=a.children&&a.children.length>0;return r().createElement(l.Box,{key:a.id},r().createElement(l.Paper,{p:"xs",radius:"sm",style:{border:"1px solid var(--mantine-color-gray-3)",marginBottom:"2px"}},r().createElement(l.Group,{gap:"xs",wrap:"nowrap",align:"flex-start"},p?r().createElement(l.ActionIcon,{variant:"subtle",size:"sm",onClick:()=>{return e=a.id,void s(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});var e},style:{marginTop:"1px"}},d?r().createElement(i.IconChevronDown,{size:14}):r().createElement(i.IconChevronRight,{size:14})):r().createElement(l.Box,{w:28}),r().createElement(l.Checkbox,{checked:"checked"===m,indeterminate:"indeterminate"===m,onChange:n=>((n,a)=>{let r=[...e];n.children?a?n.children.forEach(e=>{r.includes(e.id)||r.push(e.id)}):n.children.forEach(e=>{r=r.filter(t=>t!==e.id)}):a?r.includes(n.id)||r.push(n.id):r=r.filter(e=>e!==n.id),t(r)})(a,n.currentTarget.checked),size:"sm",style:{marginTop:"1px"}}),r().createElement(l.Box,{style:{flex:1}},r().createElement(l.Group,{gap:"xs",wrap:"nowrap"},r().createElement(l.Text,{size:"sm",fw:p?600:500},a.label,p&&" (all)"),a.description&&r().createElement(l.Text,{size:"xs",c:"dimmed",style:{whiteSpace:"nowrap"}},"- ",a.description))))),p&&r().createElement(l.Collapse,{in:d},r().createElement(l.Box,{pl:"lg",mt:"2px"},r().createElement(l.Stack,{gap:"2px"},a.children.map(e=>c(e,o+1))))))};return r().createElement(l.Stack,{gap:"xs"},r().createElement(l.Text,{size:"sm",fw:500,mb:"xs"},"Select permissions for this token"),o.map(e=>c(e)))}},7246:(e,t,n)=>{n.d(t,{K:()=>r});var a=n(7536);const r=new class{constructor(){this.baseURL={SHELL:"/bin/bash",npm_command:"run",SESSION_MANAGER:"local/unix:@/tmp/.ICE-unix/2780,unix/unix:/tmp/.ICE-unix/2780",COREPACK_ENABLE_AUTO_PIN:"0",npm_config_userconfig:"/home/bazzite/.npmrc",COLORTERM:"truecolor",XDG_CONFIG_DIRS:"/home/bazzite/.config/kdedefaults:/etc/xdg:/usr/share/kde-settings/kde-profile/default/xdg",npm_config_cache:"/home/bazzite/.npm",XDG_SESSION_PATH:"/org/freedesktop/DisplayManager/Session1",HISTCONTROL:"ignoredups",XDG_MENU_PREFIX:"plasma-",PTYXIS_PROFILE:"2871e8027773ae74d6c87a5f659bbc74",HOSTNAME:"bazzite",HISTSIZE:"1000",ICEAUTHORITY:"/run/user/1000/iceauth_gsimwA",NODE:"/var/home/linuxbrew/.linuxbrew/Cellar/node/24.7.0/bin/node",SSH_AUTH_SOCK:"/run/user/1000/ssh-agent.socket",MEMORY_PRESSURE_WRITE:"c29tZSAyMDAwMDAgMjAwMDAwMAA=",COLOR:"0",npm_config_local_prefix:"/var/home/bazzite/Projects/skybridge",HOMEBREW_PREFIX:"/home/linuxbrew/.linuxbrew",DESKTOP_SESSION:"plasma",GTK_RC_FILES:"/etc/gtk/gtkrc:/home/bazzite/.gtkrc:/home/bazzite/.config/gtkrc",GDK_CORE_DEVICE_EVENTS:"1",npm_config_globalconfig:"/home/bazzite/.npm-global/etc/npmrc",GPG_TTY:"not a tty",EDITOR:"/usr/bin/nano",XDG_SEAT:"seat0",PWD:"/home/bazzite/Projects/skybridge/kms/web",XDG_SESSION_DESKTOP:"KDE",LOGNAME:"bazzite",XDG_SESSION_TYPE:"wayland",npm_config_init_module:"/home/bazzite/.npm-init.js",SYSTEMD_EXEC_PID:"1044088",_:"/var/home/bazzite/Projects/skybridge/kms/web/node_modules/.bin/webpack",XAUTHORITY:"/run/user/1000/xauth_PJACoS",SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS:"0",CLAUDECODE:"1",XKB_DEFAULT_MODEL:"pc105",GTK2_RC_FILES:"/home/bazzite/.gtkrc-2.0-kde4",HOME:"/home/bazzite",SSH_ASKPASS:"/usr/bin/ksshaskpass",LANG:"en_US.UTF-8",LS_COLORS:"rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;37;41:su=37;41:sg=30;43:ca=00:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.7z=01;31:*.ace=01;31:*.alz=01;31:*.apk=01;31:*.arc=01;31:*.arj=01;31:*.bz=01;31:*.bz2=01;31:*.cab=01;31:*.cpio=01;31:*.crate=01;31:*.deb=01;31:*.drpm=01;31:*.dwm=01;31:*.dz=01;31:*.ear=01;31:*.egg=01;31:*.esd=01;31:*.gz=01;31:*.jar=01;31:*.lha=01;31:*.lrz=01;31:*.lz=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.lzo=01;31:*.pyz=01;31:*.rar=01;31:*.rpm=01;31:*.rz=01;31:*.sar=01;31:*.swm=01;31:*.t7z=01;31:*.tar=01;31:*.taz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tgz=01;31:*.tlz=01;31:*.txz=01;31:*.tz=01;31:*.tzo=01;31:*.tzst=01;31:*.udeb=01;31:*.war=01;31:*.whl=01;31:*.wim=01;31:*.xz=01;31:*.z=01;31:*.zip=01;31:*.zoo=01;31:*.zst=01;31:*.avif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.m4a=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.oga=01;36:*.opus=01;36:*.spx=01;36:*.xspf=01;36:*~=00;90:*#=00;90:*.bak=00;90:*.crdownload=00;90:*.dpkg-dist=00;90:*.dpkg-new=00;90:*.dpkg-old=00;90:*.dpkg-tmp=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:*.swp=00;90:*.tmp=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:",XDG_CURRENT_DESKTOP:"KDE",npm_package_version:"1.0.0",MEMORY_PRESSURE_WATCH:"/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/app.slice/dbus-:1.3-org.gnome.Ptyxis@1.service/memory.pressure",VTE_VERSION:"8003",WAYLAND_DISPLAY:"wayland-0",XDG_SEAT_PATH:"/org/freedesktop/DisplayManager/Seat0",INVOCATION_ID:"5816b6bc5ea841b7ac69cd8b4a88771f",MANAGERPID:"2409",INIT_CWD:"/var/home/bazzite/Projects/skybridge/kms/web",STEAM_FRAME_FORCE_CLOSE:"1",KDE_SESSION_UID:"1000",INFOPATH:"/home/linuxbrew/.linuxbrew/share/info:",npm_lifecycle_script:"webpack --mode production",XKB_DEFAULT_LAYOUT:"us",npm_config_npm_version:"11.5.1",XDG_SESSION_CLASS:"user",TERM:"xterm-256color",npm_package_name:"kms",npm_config_prefix:"/home/bazzite/.npm-global",LESSOPEN:"||/usr/bin/lesspipe.sh %s",USER:"bazzite",HOMEBREW_CELLAR:"/home/linuxbrew/.linuxbrew/Cellar",QT_WAYLAND_RECONNECT:"1",KDE_SESSION_VERSION:"6",PAM_KWALLET5_LOGIN:"/run/user/1000/kwallet5.socket",SUDO_ASKPASS:"/usr/bin/ksshaskpass",DISPLAY:":0",npm_lifecycle_event:"build",SHLVL:"2",GIT_EDITOR:"true",HOMEBREW_REPOSITORY:"/home/linuxbrew/.linuxbrew/Homebrew",XDG_VTNR:"2",XDG_SESSION_ID:"2",npm_config_user_agent:"npm/11.5.1 node/v24.7.0 linux x64 workspaces/true",OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE:"delta",npm_execpath:"/var/home/linuxbrew/.linuxbrew/lib/node_modules/npm/bin/npm-cli.js",XDG_RUNTIME_DIR:"/run/user/1000",CLAUDE_CODE_ENTRYPOINT:"cli",DEBUGINFOD_URLS:"https://debuginfod.fedoraproject.org/ ",npm_package_json:"/var/home/bazzite/Projects/skybridge/kms/web/package.json",DEBUGINFOD_IMA_CERT_PATH:"/etc/keys/ima:",KDEDIRS:"/usr",JOURNAL_STREAM:"9:2817901",XDG_DATA_DIRS:"/home/bazzite/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share",KDE_FULL_SESSION:"true",npm_config_noproxy:"",PATH:"/var/home/bazzite/Projects/skybridge/kms/web/node_modules/.bin:/var/home/bazzite/Projects/skybridge/kms/node_modules/.bin:/var/home/bazzite/Projects/skybridge/node_modules/.bin:/var/home/bazzite/Projects/node_modules/.bin:/var/home/bazzite/node_modules/.bin:/var/home/node_modules/.bin:/var/node_modules/.bin:/node_modules/.bin:/var/home/linuxbrew/.linuxbrew/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/home/bazzite/.npm-global/bin:/home/bazzite/.npm-global/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/bazzite/.npm-global/bin:/home/bazzite/.npm-global/bin:/home/bazzite/.local/bin:/home/bazzite/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin",npm_config_node_gyp:"/var/home/linuxbrew/.linuxbrew/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",DBUS_SESSION_BUS_ADDRESS:"unix:path=/run/user/1000/bus",npm_config_global_prefix:"/home/bazzite/.npm-global",KDE_APPLICATIONS_AS_SCOPE:"1",MAIL:"/var/spool/mail/bazzite",PTYXIS_VERSION:"48.5",BREW_BASH_COMPLETION:"1",npm_node_execpath:"/var/home/linuxbrew/.linuxbrew/Cellar/node/24.7.0/bin/node",FLATPAK_TTY_PROGRESS:"1",OLDPWD:"/home/bazzite/Projects/skybridge"}.REACT_APP_API_URL||"http://localhost:8080",this.api=a.A.create({baseURL:this.baseURL,headers:{"Content-Type":"application/json"}}),this.api.interceptors.request.use(e=>(e.headers["X-User-Email"]="admin@example.com",e)),this.api.interceptors.response.use(e=>e,e=>(console.error("API Error:",e),Promise.reject(e)))}async getApplications(e=50,t=0){return(await this.api.get(`/api/applications?limit=${e}&offset=${t}`)).data}async getApplication(e){return(await this.api.get(`/api/applications/${e}`)).data}async createApplication(e){return(await this.api.post("/api/applications",e)).data}async updateApplication(e,t){return(await this.api.put(`/api/applications/${e}`,t)).data}async deleteApplication(e){await this.api.delete(`/api/applications/${e}`)}async getTokensForApplication(e,t=50,n=0){return(await this.api.get(`/api/applications/${e}/tokens?limit=${t}&offset=${n}`)).data}async createToken(e,t){return(await this.api.post(`/api/applications/${e}/tokens`,t)).data}async deleteToken(e){await this.api.delete(`/api/tokens/${e}`)}async verifyToken(e){return(await this.api.post("/api/verify",e)).data}async getAuditEvents(e){const t=new URLSearchParams;e&&(e.event_types?.length&&e.event_types.forEach(e=>t.append("event_types",e)),e.statuses?.length&&e.statuses.forEach(e=>t.append("statuses",e)),e.actor_id&&t.set("actor_id",e.actor_id),e.resource_id&&t.set("resource_id",e.resource_id),e.resource_type&&t.set("resource_type",e.resource_type),e.start_time&&t.set("start_time",e.start_time),e.end_time&&t.set("end_time",e.end_time),e.limit&&t.set("limit",e.limit.toString()),e.offset&&t.set("offset",e.offset.toString()),e.order_by&&t.set("order_by",e.order_by),void 0!==e.order_desc&&t.set("order_desc",e.order_desc.toString()));const n="/api/audit/events"+(t.toString()?"?"+t.toString():"");return(await this.api.get(n)).data}async getAuditEvent(e){return(await this.api.get(`/api/audit/events/${e}`)).data}async getAuditStats(e){const t=new URLSearchParams;e&&(e.event_types?.length&&e.event_types.forEach(e=>t.append("event_types",e)),e.start_time&&t.set("start_time",e.start_time),e.end_time&&t.set("end_time",e.end_time),e.group_by&&t.set("group_by",e.group_by));const n="/api/audit/stats"+(t.toString()?"?"+t.toString():"");return(await this.api.get(n)).data}}},7918:(e,t,n)=>{n.d(t,{A:()=>p});var a=n(4914),r=n.n(a),l=n(7435),i=n(5101),o=n(972),s=n(7373),c=n(6658),m=n(7246);function d(){return d=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)({}).hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},d.apply(null,arguments)}const p=({opened:e,onClose:t,onSuccess:n,applications:p})=>{const[u,E]=(0,a.useState)(!1),[h,b]=(0,a.useState)(null),g=(0,o.m)({initialValues:{app_id:"",owner:{type:"individual",name:"Admin User",owner:"admin@example.com"},permissions:[]},validate:{app_id:e=>e.length<1?"Application is required":null,permissions:e=>e.length<1?"At least one permission is required":null}});(0,a.useEffect)(()=>{e&&g.reset()},[e]);const f=()=>{E(!1),b(null),t()};return r().createElement(r().Fragment,null,r().createElement(l.Paper,{style:{position:"fixed",top:60,right:e?0:"-450px",bottom:0,width:"450px",zIndex:1e3,borderRadius:0,display:"flex",flexDirection:"column",borderLeft:"1px solid var(--mantine-color-gray-3)",backgroundColor:"var(--mantine-color-body)",transition:"right 0.3s ease"}},r().createElement(l.Group,{justify:"space-between",p:"md",style:{borderBottom:"1px solid var(--mantine-color-gray-3)"}},r().createElement(l.Title,{order:4},"Create New Token"),r().createElement(l.ActionIcon,{variant:"subtle",color:"gray",onClick:t},r().createElement(i.IconX,{size:18}))),r().createElement(l.ScrollArea,{style:{flex:1}},r().createElement(l.Box,{p:"md"},r().createElement("form",{onSubmit:g.onSubmit(async e=>{try{const{app_id:t,...a}=e,r=await m.K.createToken(t,a);b(r),E(!0),g.reset(),n(),s.notifications.show({title:"Success",message:"Token created successfully",color:"green"})}catch(e){console.error("Failed to create token:",e),s.notifications.show({title:"Error",message:"Failed to create token",color:"red"})}})},r().createElement(l.Stack,{gap:"md"},r().createElement(l.Select,d({label:"Application",placeholder:"Select an application",required:!0,data:p.map(e=>({value:e.app_id,label:`${e.app_id} (${e.type.join(", ")})`}))},g.getInputProps("app_id"))),r().createElement("div",null,r().createElement(l.Text,{size:"sm",fw:500,mb:"xs"},"Required Permissions"),r().createElement(l.Text,{size:"xs",c:"dimmed",mb:"md"},"Select the permissions this token should have"),r().createElement(c.A,{permissions:g.values.permissions,onChange:e=>g.setFieldValue("permissions",e)})),r().createElement(l.TextInput,d({label:"Owner Name",placeholder:"Token owner name"},g.getInputProps("owner.name"))),r().createElement(l.TextInput,d({label:"Owner Email",placeholder:"owner@example.com"},g.getInputProps("owner.owner"))),r().createElement(l.Group,{justify:"flex-end",mt:"md"},r().createElement(l.Button,{variant:"light",onClick:t},"Cancel"),r().createElement(l.Button,{type:"submit",disabled:0===p.length},"Create Token"))))))),r().createElement(l.Modal,{opened:u,onClose:f,title:"Token Created Successfully",size:"lg",closeOnEscape:!1,closeOnClickOutside:!1},r().createElement(l.Stack,{gap:"md"},r().createElement(l.Alert,{icon:r().createElement(i.IconCheck,{size:16}),title:"Success!",color:"green"},"Your token has been created successfully. Please copy and store it securely as you won't be able to see it again."),r().createElement("div",null,r().createElement(l.Text,{size:"sm",fw:500,mb:"xs"},"Token:"),r().createElement(l.Group,{gap:"xs"},r().createElement(l.Code,{block:!0,style:{flex:1,wordBreak:"break-all",whiteSpace:"pre-wrap"}},h?.token),r().createElement(l.ActionIcon,{variant:"light",onClick:()=>{return h?.token&&(e=h.token,navigator.clipboard.writeText(e),void s.notifications.show({title:"Copied",message:"Copied to clipboard",color:"blue"}));var e},title:"Copy Token"},r().createElement(i.IconCopy,{size:16})))),h?.prefix&&r().createElement("div",null,r().createElement(l.Text,{size:"sm",fw:500,mb:"xs"},"Token Prefix:"),r().createElement(l.Code,null,h.prefix)),r().createElement(l.Divider,null),r().createElement("div",null,r().createElement(l.Text,{size:"sm",fw:500,mb:"xs"},"Token Details:"),r().createElement(l.Stack,{gap:"xs"},r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{size:"sm"},"Token ID:"),r().createElement(l.Code,null,h?.id)),r().createElement(l.Group,{justify:"space-between"},r().createElement(l.Text,{size:"sm"},"Type:"),r().createElement(l.Code,null,h?.type)),h?.permissions&&r().createElement("div",null,r().createElement(l.Text,{size:"sm",mb:"xs"},"Permissions:"),r().createElement(l.Group,{gap:"xs"},h.permissions.map(e=>r().createElement(l.Code,{key:e,size:"xs"},e)))))),r().createElement(l.Group,{justify:"flex-end",mt:"md"},r().createElement(l.Button,{onClick:f},"Done")))))}}}]); |