dsql-admin/dsql-app/.local_dist/server/pages/admin/[user_id]/api-keys.js
Benjamin Toby e95f4d1087 Updates
2025-02-16 17:12:40 +01:00

1 line
21 KiB
JavaScript

"use strict";(()=>{var e={};e.id=9419,e.ids=[9419],e.modules={30671:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,a){return a in t?t[a]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,a)):"function"==typeof t&&"default"===a?t:void 0}}})},88214:(e,t,a)=>{a.a(e,async(e,s)=>{try{a.r(t),a.d(t,{config:()=>m,default:()=>p,getServerSideProps:()=>y,getStaticPaths:()=>h,getStaticProps:()=>u,reportWebVitals:()=>x,routeModule:()=>S,unstable_getServerProps:()=>v,unstable_getServerSideProps:()=>_,unstable_getStaticParams:()=>A,unstable_getStaticPaths:()=>g,unstable_getStaticProps:()=>f});var r=a(63865),l=a(9455),i=a(30671),n=a(5583),c=a(53881),o=a(11045),d=e([o]);o=(d.then?(await d)():d)[0];let p=(0,i.M)(o,"default"),u=(0,i.M)(o,"getStaticProps"),h=(0,i.M)(o,"getStaticPaths"),y=(0,i.M)(o,"getServerSideProps"),m=(0,i.M)(o,"config"),x=(0,i.M)(o,"reportWebVitals"),f=(0,i.M)(o,"unstable_getStaticProps"),g=(0,i.M)(o,"unstable_getStaticPaths"),A=(0,i.M)(o,"unstable_getStaticParams"),v=(0,i.M)(o,"unstable_getServerProps"),_=(0,i.M)(o,"unstable_getServerSideProps"),S=new r.PagesRouteModule({definition:{kind:l.A.PAGES,page:"/admin/[user_id]/api-keys",pathname:"/admin/[user_id]/api-keys",bundlePath:"",filename:""},components:{App:c.default,Document:n.default},userland:o});s()}catch(e){s(e)}})},48963:(e,t,a)=>{a.d(t,{A:()=>p});var s,r=a(8732),l=a(82015),i=a.n(l),n=a(24872),c=a(46169),o=a(91140),d=a(16757);function p(){async function e(e){return await (0,n.A)({tableName:"api_keys",columnName:"slug",value:e})}let[t,a]=i().useState(!1),[l,p]=i().useState(null);return(0,r.jsxs)(o.Ay,{title:"add-new-api-key-popup",children:[t&&(0,r.jsx)(d.A,{}),(0,r.jsx)("h4",{className:"m-0",children:"Add New Api Key"}),(0,r.jsxs)("form",{className:"w-full flex flex-col items-stretch gap-2",onSubmit:e=>{e.preventDefault(),a(!0);let t=e.target,s={api_key_name:t.api_key_name.value,api_key_slug:t.api_key_slug.value,api_key_scope:t.api_key_scope.value,target_database:t.target_database?.value||void 0,target_table:t.target_table?.value||void 0};(0,c.A)("/api/addApiKey",{method:"post",body:s},!0).then(e=>{e.success?window.location.reload():setTimeout(()=>{a(!1)},2e3)})},children:[l&&(0,r.jsx)("div",{children:(0,r.jsx)("span",{children:l})}),(0,r.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,r.jsx)("label",{htmlFor:"api_key_name",children:"Api Key Name"}),(0,r.jsx)("input",{type:"text",name:"api_key_name",id:"api_key_name",placeholder:"Api Key Name",onInput:e=>{let t=e.target;t&&(t.closest("form").api_key_slug.value=t.value.toLowerCase().replace(/ /g,"_").replace(/[^a-zA-Z0-9-_]/g,""))},required:!0})]}),(0,r.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,r.jsx)("label",{htmlFor:"api_key_slug",children:"Api Key Slug"}),(0,r.jsx)("input",{type:"text",name:"api_key_slug",id:"api_key_slug",placeholder:"Api Key Slug",onInput:t=>{let a=t.target;a?.value.match(/./)?(a?.classList.remove("warning"),p(null)):a?.classList.add("warning"),window.clearTimeout(s),s=setTimeout(()=>{e(a.value).then(e=>{e.result?(a?.classList.add("warning"),p("Duplicate Table Name")):(a?.classList.remove("warning"),p(null))})},300)},required:!0})]}),(0,r.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,r.jsxs)("div",{className:"",children:[(0,r.jsx)("label",{htmlFor:"api_key_scope",children:"Api Scope"}),(0,r.jsxs)("div",{className:"dropdown-wrapper reversed",children:[(0,r.jsx)("span",{className:"px-2 py-1 bg-slate-100 rounded-full text-xs font-semibold",children:"Info"}),(0,r.jsx)("div",{className:"dropdown always left-aligned -ml-10 -mb-2",style:{minWidth:"300px"},children:(0,r.jsxs)("div",{className:"flex-col items-start gap-2 text-sm leading-snug",children:[(0,r.jsx)("span",{children:"Scope is the range of access the API Key can have"}),(0,r.jsxs)("ul",{className:"ml-0 pl-4 flex flex-col gap-2",children:[(0,r.jsx)("li",{children:(0,r.jsxs)("span",{children:[(0,r.jsx)("b",{children:"Read Only:"})," Can only read from databases"]})}),(0,r.jsx)("li",{children:(0,r.jsxs)("span",{children:[(0,r.jsx)("b",{children:"Full Access:"})," Can read and Write to databases"]})})]})]})})]})]}),(0,r.jsxs)("select",{name:"api_key_scope",id:"api_key_scope",children:[(0,r.jsx)("option",{value:"readOnly",children:"Read Only"}),(0,r.jsx)("option",{value:"fullAccess",children:"Full Access"})]})]}),(0,r.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,r.jsx)("label",{htmlFor:"target_database",children:"Target Databases"}),(0,r.jsx)("input",{type:"text",name:"target_database",id:"target_database",placeholder:"Target Databases (optional). Comma Separated"})]}),(0,r.jsxs)("div",{className:"flex flex-col items-start gap-0.5 w-full",children:[(0,r.jsx)("label",{htmlFor:"target_table",children:"Target Tables"}),(0,r.jsx)("input",{type:"text",name:"target_table",id:"target_table",placeholder:"Target Tables (optional). Comma Separated"})]}),(0,r.jsx)("button",{type:"submit",className:t?" pointer-events-none opacity-40":"",children:"Create New Api Key"})]})]})}},36806:(e,t,a)=>{a.a(e,async(e,s)=>{try{a.d(t,{A:()=>h});var r=a(8732),l=a(82015),i=a.n(l),n=a(11045),c=a(53926),o=a(66485),d=a(65532),p=a(91140),u=e([n]);function h(){let{user:e,apiKeys:t,setApiKeys:a,setTargetApiKey:s}=i().useContext(n.ApiKeysContext);return(0,r.jsxs)(i().Fragment,{children:[(0,r.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,r.jsxs)("div",{className:"w-full justify-between flex-wrap",children:[(0,r.jsx)("h1",{className:"text-3xl m-0",children:"Api Keys"}),(0,r.jsxs)("button",{className:"flex items-center gap-2",onClick:e=>{(0,p.PB)("add-new-api-key-popup")},children:[(0,r.jsx)("span",{className:"symbol",children:"+"}),(0,r.jsx)("span",{children:"Add New Api Key"})]})]}),(0,r.jsx)(c.A,{user:e})]}),e?.verification_status?.toString().match(/1/)?(0,r.jsx)(d.A,{apiKeys:t,setTargetApiKey:s,user:e}):(0,r.jsx)(o.A,{})]})}n=(u.then?(await u)():u)[0],s()}catch(e){s(e)}})},65532:(e,t,a)=>{a.d(t,{A:()=>p});var s=a(8732),r=a(82015),l=a.n(r),i=a(91140),n=a(46169),c=a(16757),o=a(55904);function d({apiKeyObject:e,setTargetApiKey:t}){let[a,r]=l().useState(!1);return(0,s.jsxs)("div",{className:"card no-hover justify-between items-center"+(e.scope.match(/fullAccess/)?" green":""),onClick:a=>{a.target?.closest("button")||(t(e),(0,i.PB)("target-media-popup"))},children:[a&&(0,s.jsx)(c.A,{width:"20px"}),(0,s.jsxs)("div",{className:"text-sm flex-wrap",children:[(0,s.jsx)("div",{children:e.scope.match(/readOnly/)?(0,s.jsx)("span",{className:"notification"}):e.scope.match(/fullAccess/)?(0,s.jsx)("span",{className:"notification success"}):"No Scope"}),(0,s.jsx)("span",{className:"title text-xl",style:{fontSize:"16px"},children:e.name}),(0,s.jsxs)("span",{className:"text-slate-400 ",children:["Created: ",e.date_created.substring(0,24)]})]}),(0,s.jsxs)(o.A,{children:[(0,s.jsx)("button",{className:"outlined light-gray small-text",onClick:t=>{alert(e.apiKeyPayload)},children:"Reveal Api Key"}),(0,s.jsx)("button",{className:"outlined light-gray small-text",onClick:t=>{navigator.clipboard.writeText(e.apiKeyPayload).then(()=>{alert("Api Key Copied To Clipboard")})},children:"Copy Api Key"}),(0,s.jsx)("button",{className:"outlined light-gray small-text"+(a?" pointer-events-none opacity-40":""),onClick:t=>{r(!0),window.confirm("Delete this Api Key?")?(0,n.A)("/api/deleteApiKey",{method:"post",body:e},!0).then(e=>{}).finally(()=>{window.location.reload()}):r(!1)},children:"Delete Api Key"})]})]})}function p({user:e,apiKeys:t,setTargetApiKey:a}){return(0,s.jsx)(l().Fragment,{children:(0,s.jsxs)("section",{className:"p-0 items-start gap-4 overflow-visible bg-transparent border-transparent",children:[(0,s.jsx)("div",{className:"w-full flex-col items-stretch gap-4",children:t&&a&&t[0]&&t.map((e,t)=>(0,s.jsx)(d,{apiKeyObject:e,setTargetApiKey:a},t))}),!t||!t[0]&&(0,s.jsxs)("div",{className:"button outlined gray dashed w-full p-10 flex-col",onClick:e=>{(0,i.PB)("add-new-api-key-popup")},children:[(0,s.jsx)("span",{className:"text-slate-400",children:"No Api Keys Added."}),(0,s.jsx)("span",{className:"",children:"Add Api Key"})]})]})})}},12069:(e,t,a)=>{a.d(t,{A:()=>c});var s=a(8732),r=a(82015),l=a.n(r),i=a(91140),n=a(16757);function c({targetApiKey:e}){let[t,a]=l().useState(!1);return(0,s.jsxs)(i.Ay,{title:"target-api-key-preview-popup",noContainer:!0,fullPage:!0,children:[t&&(0,s.jsx)(n.A,{}),e&&(0,s.jsx)(l().Fragment,{children:(0,s.jsx)("span",{children:"Target Api Key"})})]})}},53926:(e,t,a)=>{a.d(t,{A:()=>i});var s=a(8732),r=a(82015),l=a.n(r);function i({confirmedDelegetedUser:e,linksArray:t,user:a}){let[r,i]=l().useState(t||null);return r&&r[1]?(0,s.jsx)("div",{className:"text-sm mt-2 flex-wrap",children:r.map((e,t,a)=>t===r.length-1?(0,s.jsx)("a",{href:e.path,className:"text-slate-400 dark:text-slate-500 pointer-events-none",children:e.title},t):(0,s.jsxs)(l().Fragment,{children:[(0,s.jsx)("a",{href:e.path,className:"query-url",children:e.title}),(0,s.jsx)("span",{className:"opacity-20",children:"|"})]},t))}):(0,s.jsx)(l().Fragment,{})}},91140:(e,t,a)=>{a.d(t,{Ay:()=>n,PB:()=>c,fs:()=>o});var s=a(8732),r=a(58150),l=a(82015),i=a.n(l);function n({children:e,title:t,data:a,fullPage:l,wrapperClasses:n,closePopupDispatch:c,wrapperStyle:d,noContainer:p}){return l?(0,s.jsxs)("div",{className:"popup-bg overflow-hidden "+(n||""),"data-popupid":t||null,style:d,children:[p?(0,s.jsx)(i().Fragment,{children:e}):(0,s.jsx)("div",{className:"relative w-full h-full z-50","data-data":a?JSON.stringify(a):"",children:e}),(0,s.jsx)("button",{className:"popup-cancel-button fixed outlined gray",onClick:e=>{o(),c&&c()},children:(0,s.jsx)(r.A,{color:"white",size:20})}),(0,s.jsx)("div",{className:"popup-canceller",onClick:e=>{o(),c&&c()}})]}):(0,s.jsxs)("div",{className:"popup-bg","data-popupid":t||null,children:[p?(0,s.jsx)(i().Fragment,{children:e}):(0,s.jsxs)("div",{className:"popup-content-container minimal-scrollbars","data-data":a?JSON.stringify(a):"",children:[e,(0,s.jsx)("button",{className:"outlined gray popup-cancel-button",onClick:e=>{o(),c&&c()},children:(0,s.jsx)("span",{className:"font-normal",children:"✖"})})]}),p&&(0,s.jsx)("button",{className:"gray popup-cancel-button",onClick:e=>{o(),c&&c()},children:(0,s.jsx)("span",{className:"font-normal",children:"✖"})}),(0,s.jsx)("div",{className:"popup-canceller",onClick:e=>{o(),c&&c()}})]})}function c(e,t){let a=document.querySelector(`[data-popupid='${e}']`);a&&(a.style.display="flex",t?.(a))}function o(e){document.querySelectorAll("[data-popupid]").forEach(e=>{e.style.display="none"}),e?.()}},66485:(e,t,a)=>{a.d(t,{A:()=>r});var s=a(8732);function r(){return(0,s.jsxs)("a",{href:"/email-verification",className:"card w-full items-center justify-center py-4 gap-2",children:[(0,s.jsx)("img",{src:"/images/warning.png",alt:"Down Arrow",width:25,className:""}),(0,s.jsx)("span",{children:"Your Account is not verified. Please verify your account."})]})}a(82015)},55904:(e,t,a)=>{a.d(t,{A:()=>i});var s=a(8732),r=a(82015),l=a.n(r);function i({children:e,column:t,className:a}){let r=l().useRef();return(0,s.jsx)("div",{className:"items-stretch gap-0"+(t?" flex-col":" flex-wrap xl:flex-nowrap")+(a?" "+a:""),ref:r,children:e})}},24872:(e,t,a)=>{a.d(t,{A:()=>r});var s=a(46169);async function r({tableName:e,columnName:t,value:a,dbFullName:r,dispatch:l,userId:i,dbId:n}){return await (0,s.A)(`/api/checkDuplicateData?tableName=${e}&type=${t}&value=${a}${r?"&dbFullName="+r:""}${i?"&userId="+i:""}${n?"&dbId="+n:""}`)}},23293:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]])},92441:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("BookText",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20",key:"t4utmx"}],["path",{d:"M8 7h6",key:"1f0q6e"}],["path",{d:"M8 11h8",key:"vwpz6n"}]])},52530:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},67105:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("CloudUpload",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M12 12v9",key:"192myk"}],["path",{d:"m16 16-4-4-4 4",key:"119tzi"}]])},26628:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("DatabaseBackup",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 12a9 3 0 0 0 5 2.69",key:"1ui2ym"}],["path",{d:"M21 9.3V5",key:"6k6cib"}],["path",{d:"M3 5v14a9 3 0 0 0 6.47 2.88",key:"i62tjy"}],["path",{d:"M12 12v4h4",key:"1bxaet"}],["path",{d:"M13 20a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L12 16",key:"1f4ei9"}]])},34637:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]])},29743:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("FileKey2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v6",key:"rc0qvx"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"4",cy:"16",r:"2",key:"1ehqvc"}],["path",{d:"m10 10-4.5 4.5",key:"7fwrp6"}],["path",{d:"m9 11 1 1",key:"wa6s5q"}]])},34479:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("FileWarning",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},10643:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]])},66916:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("HardDrive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]])},20427:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("Home",[["path",{d:"m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"y5dka4"}],["polyline",{points:"9 22 9 12 15 12 15 22",key:"e2us08"}]])},83158:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("Images",[["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18",key:"nf6bnh"}],["circle",{cx:"12",cy:"8",r:"2",key:"1822b1"}],["rect",{width:"16",height:"16",x:"6",y:"2",rx:"2",key:"12espp"}]])},62011:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("LockKeyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]])},66918:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("RotateCw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]])},2459:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]])},80006:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("SquareChevronRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]])},25294:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]])},58150:(e,t,a)=>{a.d(t,{A:()=>s});let s=(0,a(82544).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},71205:(e,t,a)=>{a.d(t,{A:()=>i});var s=a(55511),r=a(79428),l=a(48243);function i({encryptedString:e,encryptionKey:t,encryptionSalt:a}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let{key:i,salt:n,keyLen:c,algorithm:o,bufferAllocSize:d}=(0,l.A)({encryptionKey:t});if(!i?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!n?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let p=(0,s.scryptSync)(i,n,c),u=r.Buffer.alloc(d,0),h=(0,s.createDecipheriv)(o,p,u);try{let t=h.update(e,"hex","utf8");return t+=h.final("utf8")}catch(t){return console.log("Error in decrypting =>",t.message),e}}},71934:(e,t,a)=>{a.d(t,{A:()=>r});var s=a(51779);async function r(...e){let t=(0,s.A)();try{if(!t)throw Error("No Connection provided to DB_HANDLER function!");let a=await t.query(...e);return JSON.parse(JSON.stringify(a))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await t?.end()}}},51779:(e,t,a)=>{a.d(t,{A:()=>l});var s=a(9973),r=a.n(s);function l(e){return global.DSQL_USE_LOCAL||e?.local?global.DSQL_DB_CONN||r()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.ro?global.DSQL_READ_ONLY_DB_CONN||r()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.fa?global.DSQL_FULL_ACCESS_DB_CONN||r()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):global.DSQL_DB_CONN||r()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}})}},48243:(e,t,a)=>{a.d(t,{A:()=>s});function s(e){return{key:e?.encryptionKey||process.env.DSQL_ENCRYPTION_PASSWORD,keyLen:process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24,salt:e?.encryptionSalt||process.env.DSQL_ENCRYPTION_SALT,apiKey:e?.apiKey||process.env.DSQL_API_KEY,algorithm:e?.algorithm||process.env.DSQL_ENCRYPTION_ALGORITHM||"aes-192-cbc",bufferAllocSize:e?.bufferAllocSize||(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE?function(e,t){try{let t=Number(e);if("number"!=typeof t||isNaN(t))return 0;return Math.round(t)}catch(e){return console.log(`Numberfy ERROR: ${e.message}`),0}}(process.env.DSQL_ENCRYPTION_BUFFER_ALLOCATION_SIZE):void 0)||16}}},11045:(e,t,a)=>{a.a(e,async(e,s)=>{try{a.r(t),a.d(t,{ApiKeysContext:()=>f,default:()=>m,getServerSideProps:()=>x});var r=a(8732),l=a(82015),i=a.n(l),n=a(72837),c=a(92702),o=a(36806),d=a(12069),p=a(48963),u=a(71934),h=a(71205),y=e([n,o]);[n,o]=y.then?(await y)():y;let f=i().createContext({});function m({user:e,fetchedApiKeys:t}){let a=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("title",{children:"Api Keys | Datasquirel"}),(0,r.jsx)("meta",{name:"description",content:"Welcome to your data app"})]}),[s,l]=i().useState(t),[c,u]=i().useState(null),[h,y]=i().useState(null);return(0,r.jsx)(f.Provider,{value:{user:e,apiKeys:s,setApiKeys:l,targetApiKey:h,setTargetApiKey:y,newApiKey:c,setNewApiKey:u},children:(0,r.jsxs)(i().Fragment,{children:[(0,r.jsx)(n.A,{head:a,children:(0,r.jsx)(o.A,{})}),h&&(0,r.jsx)(d.A,{targetApiKey:h}),(0,r.jsx)(p.A,{})]})})}async function x({req:e,res:t,query:a}){let s=await (0,c.A)(e,t);if(!s?.logged_in_status)return{redirect:{destination:"/logout",permanent:!1}};let r=await (0,u.A)(`SELECT * FROM api_keys WHERE user_id='${s.id}'`),l=[];if(r&&r[0])for(let e=0;e<r.length;e++){let t=r[e],a=(0,h.A)({encryptedString:t.key});l.push({...t,apiKeyPayload:a})}return{props:{user:s,fetchedApiKeys:l}}}s()}catch(e){s(e)}})},9455:(e,t)=>{Object.defineProperty(t,"A",{enumerable:!0,get:function(){return a}});var a=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},76102:e=>{e.exports=require("@moduletrace/datasquirel/dist/client")},13893:e=>{e.exports=require("@moduletrace/datasquirel/dist/client/fetch")},39383:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/actions/users/user-auth")},65967:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson")},93726:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy")},30889:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify")},27825:e=>{e.exports=require("lodash")},40361:e=>{e.exports=require("next/dist/compiled/next-server/pages.runtime.prod.js")},27912:e=>{e.exports=require("next/head")},82015:e=>{e.exports=require("react")},22326:e=>{e.exports=require("react-dom")},8732:e=>{e.exports=require("react/jsx-runtime")},9973:e=>{e.exports=require("serverless-mysql")},79428:e=>{e.exports=require("buffer")},55511:e=>{e.exports=require("crypto")},33873:e=>{e.exports=require("path")},75979:e=>{e.exports=import("tailwind-merge")}};var t=require("../../../webpack-runtime.js");t.C(e);var a=e=>t(t.s=e),s=t.X(0,[883,9821,3881,8892],()=>a(88214));module.exports=s})();