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

1 line
27 KiB
JavaScript

"use strict";(()=>{var e={};e.id=2504,e.ids=[2504],e.modules={30671:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,s){return s in t?t[s]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,s)):"function"==typeof t&&"default"===s?t:void 0}}})},44088:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.r(t),s.d(t,{config:()=>m,default:()=>u,getServerSideProps:()=>x,getStaticPaths:()=>h,getStaticProps:()=>p,reportWebVitals:()=>y,routeModule:()=>b,unstable_getServerProps:()=>j,unstable_getServerSideProps:()=>g,unstable_getStaticParams:()=>A,unstable_getStaticPaths:()=>v,unstable_getStaticProps:()=>f});var r=s(63865),n=s(9455),l=s(30671),i=s(5583),c=s(53881),d=s(30350),o=e([d]);d=(o.then?(await o)():o)[0];let u=(0,l.M)(d,"default"),p=(0,l.M)(d,"getStaticProps"),h=(0,l.M)(d,"getStaticPaths"),x=(0,l.M)(d,"getServerSideProps"),m=(0,l.M)(d,"config"),y=(0,l.M)(d,"reportWebVitals"),f=(0,l.M)(d,"unstable_getStaticProps"),v=(0,l.M)(d,"unstable_getStaticPaths"),A=(0,l.M)(d,"unstable_getStaticParams"),j=(0,l.M)(d,"unstable_getServerProps"),g=(0,l.M)(d,"unstable_getServerSideProps"),b=new r.PagesRouteModule({definition:{kind:n.A.PAGES,page:"/admin/[user_id]/connect",pathname:"/admin/[user_id]/connect",bundlePath:"",filename:""},components:{App:c.default,Document:i.default},userland:d});a()}catch(e){a(e)}})},49773:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.d(t,{A:()=>p});var r=s(8732),n=s(82015),l=s.n(n),i=s(53926),c=s(30350),d=s(81344),o=s(46168),u=e([c,d,o]);function p(){let{user:e,query:t,mariadbUserCred:s}=l().useContext(c.ConnectContext);return(0,r.jsxs)(l().Fragment,{children:[(0,r.jsxs)("div",{className:"flex-col items-start gap-0 w-full",children:[(0,r.jsx)("div",{className:"",children:(0,r.jsx)("h1",{className:"text-3xl m-0",children:"Connect"})}),(0,r.jsx)(i.A,{user:e})]}),(0,r.jsx)(d.A,{}),(0,r.jsx)(o.A,{})]})}[c,d,o]=u.then?(await u)():u,a()}catch(e){a(e)}})},81344:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.d(t,{A:()=>u});var r=s(8732),n=s(82015),l=s.n(n),i=s(30350),c=s(96089),d=s(25088),o=e([i]);function u(){let{user:e,query:t,mariadbUserCred:s}=l().useContext(i.ConnectContext);return(0,r.jsx)("section",{className:"paper",children:(0,r.jsxs)("div",{className:"flex-col items-start w-full",children:[(0,r.jsx)("span",{children:"You can connect to your database remotely using any MySQL/Mariadb client. Use these credentials to connect:"}),(0,r.jsx)("hr",{}),(0,r.jsxs)("ul",{className:"m-0",children:[(0,r.jsxs)("li",{children:["Server:"," ",(0,r.jsx)("b",{children:"172.72.0.24"})]}),(0,r.jsxs)("li",{children:["Username: ",(0,r.jsx)("b",{children:s?.mariadb_user})]}),(0,r.jsxs)("li",{children:["Host: ",(0,r.jsx)("b",{children:s?.mariadb_host})]}),(0,r.jsxs)("li",{children:["Password: ",(0,r.jsx)("b",{children:"*****************"}),(0,r.jsx)("button",{className:"ghost inline-block -my-4",onClick:e=>{navigator.clipboard.writeText(s?.mariadb_pass||"").then(()=>{window.alert("Copied Password!")})},children:(0,r.jsx)(c.A,{})})]}),(0,r.jsx)("li",{children:(0,r.jsxs)("div",{className:"flex",children:["SSL Certificate:"," ",(0,r.jsx)("b",{children:(0,r.jsx)("span",{className:"flex items-center gap-2",children:(0,r.jsxs)("a",{href:"https://datasquirel.com/documents/ssl/ca-cert.pem",className:"flex items-center gap-2 border-none hover:opacity-60",target:"_blank",children:[(0,r.jsx)(d.A,{}),"Download"]})})})]})})]})]})})}i=(o.then?(await o)():o)[0],a()}catch(e){a(e)}})},63997:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.d(t,{A:()=>p});var r=s(8732),n=s(82015),l=s.n(n),i=s(30350),c=s(91140),d=s(16757),o=s(1756),u=e([i,o]);function p(){let{targetMariadbUser:e}=l().useContext(i.ConnectContext),[t,s]=l().useState(!1);return(0,r.jsx)(c.Ay,{title:"edit-mariadb-user-popup",children:t&&e?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("h3",{children:(0,r.jsxs)("div",{className:"flex",children:[(0,r.jsx)("span",{children:"Edit"}),(0,r.jsxs)("span",{className:"info inline w-auto text-xl green",children:[e.username,"@",e.host]})]})}),(0,r.jsx)("hr",{}),(0,r.jsx)(o.A,{mariaDBUser:e,edit:!0})]}):(0,r.jsx)("div",{className:"p-20",children:(0,r.jsx)(d.A,{width:"25px"})})})}[i,o]=u.then?(await u)():u,a()}catch(e){a(e)}})},1756:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.d(t,{A:()=>p});var r=s(8732),n=s(82015),l=s.n(n),i=s(30350),c=s(16757),d=s(46169),o=s(78604),u=e([i,o]);function p({mariaDBUser:e,edit:t,username:s}){let{user:a}=l().useContext(i.ConnectContext),n=a?.id==Number("1"),u=e?Object.keys(e):["username","host","password"],p=/username|host|password/,h=n?void 0:/username/,x=/host/,m=(()=>{try{if(t&&e?.grants)return JSON.parse(e.grants);return null}catch(e){return null}})(),[y,f]=l().useState(m||[{database:"*",table:"*",privileges:["ALL PRIVILEGES"]}]),[v,A]=l().useState(!1);return(0,r.jsxs)("form",{onSubmit:s=>{if(s.preventDefault(),!window.confirm(t?"Update this user?":"Create this new User?"))return;let a=s.target,r=Array.from(a),l={};if(r.forEach(e=>{"INPUT"==e.nodeName&&(l[e.name]=e.value)}),t&&!n&&delete l.username,!y?.[0]){alert("Please add at least one grant");return}A(!0),(0,d.A)(t?"/api/sql-users/update":"/api/sql-users/create",{method:"POST",body:{data:l,edit:!!t,prev:e,grants:y}},!0).then(e=>{e.success?window.location.reload():e.msg&&(window.alert(e.msg),A(!1))})},className:"w-full gap-4 flex flex-col",children:[v&&(0,r.jsx)(c.A,{width:"25px"}),u.map((t,s)=>{let n=e?e[t]:"username"==t?`dsql_user_${a?.id}`:null,l=h?.test(t),i=x.test(t);return t.match(p)?(0,r.jsxs)("div",{className:"flex-col items-start w-full gap-1",children:[(0,r.jsx)("label",{htmlFor:t,children:t}),(0,r.jsx)("input",{type:t.match("password")?"password":"text",name:t,id:t,defaultValue:n||void 0,readOnly:l,className:l?"bg-slate-100 opacity-50 pointer-events-none":"",placeholder:t,required:i})]},s+1):null}),(0,r.jsx)(o.A,{grants:y,setGrants:f,edit:t}),(0,r.jsx)("button",{type:"submit",children:t?"Update User":"Create SQL User"})]})}[i,o]=u.then?(await u)():u,a()}catch(e){a(e)}})},78604:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.d(t,{A:()=>d});var r=s(8732),n=s(82015),l=s.n(n),i=s(30350);s(46169);var c=e([i]);function d({grants:e,setGrants:t,edit:s}){let{user:a,targetMariadbUser:n}=l().useContext(i.ConnectContext),c=!!String(n?.primary).match(/1/)&&s,d=!!e.find(e=>"*"==e.database),o=!!e.find(e=>"*"==e.table),u=!!e.find(e=>e.privileges.includes("ALL PRIVILEGES")),[p,h]=l().useState([]),[x,m]=l().useState(),[y,f]=l().useState([]),[v,A]=l().useState(),[j,g]=l().useState(["ALL PRIVILEGES"]),[b,S]=l().useState("ALL PRIVILEGES"),[N,_]=l().useState(!1);return(0,r.jsxs)("div",{id:"grant-select-block",className:"flex flex-col items-stretch w-full p-6 border border-slate-200 border-solid rounded",children:[(0,r.jsx)("h4",{className:"m-0 text-lg",children:"Grants"}),(0,r.jsx)("span",{children:"This section determines fine grained access of this user to databases and tables"}),(0,r.jsx)("hr",{}),(0,r.jsx)("div",{className:"flex-wrap",children:e?.[0]?e.map((s,a)=>(0,r.jsxs)("div",{className:"text-sm pr-10 bg-secondary text-white px-3 py-2 rounded flex-wrap relative",children:[(0,r.jsx)("span",{children:s.privileges}),(0,r.jsx)("span",{children:"="}),(0,r.jsxs)("span",{children:[" ",s.database.replace(/datasquirel_user_\d+_/,"")]}),(0,r.jsx)("span",{children:"."}),(0,r.jsx)("span",{children:s.table}),!c&&(0,r.jsx)("div",{className:"button white absolute top-1.5 right-1.5 p-2 w-6 h-6",onClick:s=>{let r=[...e];r.splice(a,1),t(r)},children:"x"})]},a)):(0,r.jsx)("span",{className:"text-slate-400 px-4 py-2 bg-slate-100 w-full flex items-center justify-center",children:"No Grants"})}),(0,r.jsx)("hr",{}),d&&o&&u?(0,r.jsx)("span",{className:"text-sm text-slate-500",children:'All Privileges have been granted! Delete "ALL PRIVILEGES on *.*" to add fine-grained privileges'}):N?(0,r.jsx)(r.Fragment,{children:c?(0,r.jsx)("span",{className:"text-slate-400",children:"Primary users have full control over all databases."}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex-col items-start w-full gap-1",children:[(0,r.jsx)("label",{htmlFor:"grants-database",children:"Database"}),(0,r.jsxs)("select",{name:"grants-database",id:"grants-database",className:"text-sm",onChange:e=>{let t=e.target.value;if("NULL"==t)return;let s=p.find(e=>e.db_full_name==t);s&&m(s)},children:[(0,r.jsx)("option",{value:"*",children:"--ALL-DATABASES--"}),p.map((e,t)=>(0,r.jsx)("option",{value:e.db_full_name,children:e.db_name},t+1))]})]}),(0,r.jsxs)("div",{className:"flex-col items-start w-full gap-1",children:[(0,r.jsx)("label",{htmlFor:"grants-table",children:"Table"}),(0,r.jsxs)("select",{name:"grants-table",id:"grants-table",className:"text-sm",onChange:e=>{let t=e.target.value;if("NULL"==t)return;let s=y.find(e=>e.table_slug==t);s&&A(s)},children:[(0,r.jsx)("option",{value:"*",children:"--ALL-TABLES--"}),y?.[0]&&y.map((e,t)=>(0,r.jsx)("option",{value:e.table_slug,children:e.table_name},t+1))]})]}),(0,r.jsxs)("div",{className:"flex-col items-start w-full gap-1",children:[(0,r.jsx)("label",{htmlFor:"grants-databases",children:"Permissions"}),(0,r.jsx)("div",{className:"flex-wrap gap-y-2 mb-1",children:j?.[0]?j.map((e,t)=>(0,r.jsxs)("span",{className:"text-xs px-2 py-1 border border-solid border-slate-200 rounded",children:[e,(0,r.jsx)("span",{className:"cursor-pointer p-2 hover:opacity-50",onClick:e=>{let s=[...j];s.splice(t,1),g(s)},children:"x"})]},t)):(0,r.jsx)("span",{className:"text-xs px-3 py-1 bg-slate-100 text-slate-400",children:"No Permissions Selected"})}),(0,r.jsxs)("div",{className:"w-full items-stretch",children:[(0,r.jsx)("select",{name:"grants-databases",id:"grants-databases",className:"text-sm",onChange:e=>{let t=e.target.value;S(t)},children:["ALL PRIVILEGES","ALTER","ALTER ROUTINE","CREATE","CREATE ROUTINE","CREATE TEMPORARY TABLES","CREATE VIEW","DELETE","DROP","EVENT","EXECUTE","FILE","INDEX","INSERT","LOCK TABLES","PROCESS","REFERENCES","RELOAD","REPLICATION CLIENT","REPLICATION SLAVE","SELECT","SHOW VIEW","SUPER","TRIGGER","UPDATE","USAGE"].map((e,t)=>(0,r.jsx)("option",{value:e,children:e},t))}),(0,r.jsx)("div",{className:"button outlined gray text-2xl",onClick:e=>{if(!j.includes(b)){if(j.includes("ALL PRIVILEGES")){alert("ALL PRIVILEGES already covers for the rest. Remove ALL PRIVILEGES permission to add others");return}g([...j,b])}},children:"+"})]})]}),!c&&(0,r.jsx)("div",{className:"button outlined secondary",onClick:s=>{if(!j?.[0]){alert("Please select atleast 1 permission. *REMEMBER to click the + button to add the permission to the list");return}let a={database:x?.db_full_name||"*",privileges:j,table:v?.table_slug||"*"},r=[...e,a];t(r),_(!1)},children:"Add"}),(0,r.jsx)("div",{className:"button outlined gray",onClick:()=>{_(!1)},children:"Cancel"})]})}):c?(0,r.jsx)("span",{className:"text-slate-400",children:"Primary users have full control over all databases."}):(0,r.jsxs)("div",{className:"button outlined gray",onClick:e=>{_(!0)},children:[(0,r.jsx)("span",{className:"text-2xl h-6 flex items-center justify-center",children:"+"}),"\xa0Add Grant"]})]})}i=(c.then?(await c)():c)[0],a()}catch(e){a(e)}})},6925:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.d(t,{A:()=>m});var r=s(8732),n=s(82015),l=s.n(n),i=s(30350),c=s(91140),d=s(16757),o=s(46169),u=s(11717),p=s(96725),h=s(96089),x=e([i]);function m({mariadbUser:e}){let{setTargetMariadbUser:t}=l().useContext(i.ConnectContext),s=!!String(e.primary)?.match(/1/),[a,n]=l().useState(!1);return(0,r.jsxs)("div",{className:"card w-full col"+(s?" green":""),children:[a&&(0,r.jsx)(d.A,{width:"25px"}),(0,r.jsxs)("div",{className:"w-full justify-between h-auto md:h-8 flex-wrap",children:[(0,r.jsxs)("span",{className:"title",children:[e.username,"@",e.host]}),(0,r.jsxs)("div",{children:[s&&(0,r.jsx)("span",{className:"info small w-auto",children:"Primary User"}),(0,r.jsx)("button",{className:"ghost",title:"Edit User",onClick:s=>{t?.(e),(0,c.PB)("edit-mariadb-user-popup")},children:(0,r.jsx)(u.A,{size:20})}),!s&&(0,r.jsx)("button",{className:"ghost -ml-6",title:"Edit User",onClick:t=>{window.confirm("Are you sure you want to delete this User?")&&(n(!0),(0,o.A)("/api/sql-users/delete",{method:"POST",body:{id:e.id}},!0).then(e=>{e.success?window.location.reload():e.msg&&window.alert(e.msg)}).finally(()=>{setTimeout(()=>{n(!1)},1e3)}))},children:(0,r.jsx)(p.A,{})})]})]}),(0,r.jsx)("hr",{}),(0,r.jsxs)("ul",{className:"m-0",children:[(0,r.jsxs)("li",{children:["Username: ",(0,r.jsx)("b",{children:e.username})]}),(0,r.jsxs)("li",{children:["Host: ",(0,r.jsx)("b",{children:e.host}),(0,r.jsx)("span",{className:"info gray font-normal",children:"% is a wildcard. Example: 192.168.1.%"})]}),(0,r.jsxs)("li",{children:["Password: ",(0,r.jsx)("b",{children:"*****************"}),(0,r.jsx)("button",{className:"ghost inline-block -my-4",onClick:t=>{navigator.clipboard.writeText(e.password||"").then(()=>{window.alert("Copied Password!")})},children:(0,r.jsx)(h.A,{size:20})})]})]})]})}i=(x.then?(await x)():x)[0],a()}catch(e){a(e)}})},46168:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.d(t,{A:()=>u});var r=s(8732),n=s(82015),l=s.n(n),i=s(30350),c=s(6925),d=s(91140),o=e([i,c]);function u(){let{mariadbUsers:e}=l().useContext(i.ConnectContext);return(0,r.jsxs)("section",{className:"paper",children:[(0,r.jsxs)("div",{className:"w-full justify-between",children:[(0,r.jsx)("h2",{className:"text-xl m-0",children:"SQL Users"}),(0,r.jsx)("div",{children:(0,r.jsx)("button",{onClick:e=>{(0,d.PB)("new-mariadb-user-popup")},children:"Add SQL User"})})]}),(0,r.jsxs)("div",{className:"flex-col items-start w-full",children:[(0,r.jsx)("span",{children:"You can customize your SQL users and permissions here. You can add up to 10 hosts/IP addresses (including your primary host)"}),(0,r.jsx)("hr",{}),(0,r.jsx)("div",{className:"grid w-full grid-cols-1 xl:grid-cols-2 gap-6",children:e?.map((e,t)=>r.jsx(c.A,{mariadbUser:e},t+1))})]})]})}[i,c]=o.then?(await o)():o,a()}catch(e){a(e)}})},40445:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.d(t,{A:()=>c});var r=s(8732);s(82015);var n=s(91140),l=s(1756),i=e([l]);function c(){return(0,r.jsxs)(n.Ay,{title:"new-mariadb-user-popup",children:[(0,r.jsx)("h3",{children:"New MariaDB User"}),(0,r.jsx)("hr",{}),(0,r.jsx)(l.A,{})]})}l=(i.then?(await i)():i)[0],a()}catch(e){a(e)}})},53926:(e,t,s)=>{s.d(t,{A:()=>l});var a=s(8732),r=s(82015),n=s.n(r);function l({confirmedDelegetedUser:e,linksArray:t,user:s}){let[r,l]=n().useState(t||null);return r&&r[1]?(0,a.jsx)("div",{className:"text-sm mt-2 flex-wrap",children:r.map((e,t,s)=>t===r.length-1?(0,a.jsx)("a",{href:e.path,className:"text-slate-400 dark:text-slate-500 pointer-events-none",children:e.title},t):(0,a.jsxs)(n().Fragment,{children:[(0,a.jsx)("a",{href:e.path,className:"query-url",children:e.title}),(0,a.jsx)("span",{className:"opacity-20",children:"|"})]},t))}):(0,a.jsx)(n().Fragment,{})}},91140:(e,t,s)=>{s.d(t,{Ay:()=>i,PB:()=>c,fs:()=>d});var a=s(8732),r=s(58150),n=s(82015),l=s.n(n);function i({children:e,title:t,data:s,fullPage:n,wrapperClasses:i,closePopupDispatch:c,wrapperStyle:o,noContainer:u}){return n?(0,a.jsxs)("div",{className:"popup-bg overflow-hidden "+(i||""),"data-popupid":t||null,style:o,children:[u?(0,a.jsx)(l().Fragment,{children:e}):(0,a.jsx)("div",{className:"relative w-full h-full z-50","data-data":s?JSON.stringify(s):"",children:e}),(0,a.jsx)("button",{className:"popup-cancel-button fixed outlined gray",onClick:e=>{d(),c&&c()},children:(0,a.jsx)(r.A,{color:"white",size:20})}),(0,a.jsx)("div",{className:"popup-canceller",onClick:e=>{d(),c&&c()}})]}):(0,a.jsxs)("div",{className:"popup-bg","data-popupid":t||null,children:[u?(0,a.jsx)(l().Fragment,{children:e}):(0,a.jsxs)("div",{className:"popup-content-container minimal-scrollbars","data-data":s?JSON.stringify(s):"",children:[e,(0,a.jsx)("button",{className:"outlined gray popup-cancel-button",onClick:e=>{d(),c&&c()},children:(0,a.jsx)("span",{className:"font-normal",children:"✖"})})]}),u&&(0,a.jsx)("button",{className:"gray popup-cancel-button",onClick:e=>{d(),c&&c()},children:(0,a.jsx)("span",{className:"font-normal",children:"✖"})}),(0,a.jsx)("div",{className:"popup-canceller",onClick:e=>{d(),c&&c()}})]})}function c(e,t){let s=document.querySelector(`[data-popupid='${e}']`);s&&(s.style.display="flex",t?.(s))}function d(e){document.querySelectorAll("[data-popupid]").forEach(e=>{e.style.display="none"}),e?.()}},23293:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(82544).A)("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]])},92441:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(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,s)=>{s.d(t,{A:()=>a});let a=(0,s(82544).A)("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]])},96725:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(82544).A)("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]])},67105:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(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"}]])},96089:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(82544).A)("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"}]])},26628:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(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,s)=>{s.d(t,{A:()=>a});let a=(0,s(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"}]])},25088:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(82544).A)("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]])},29743:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(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,s)=>{s.d(t,{A:()=>a});let a=(0,s(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,s)=>{s.d(t,{A:()=>a});let a=(0,s(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,s)=>{s.d(t,{A:()=>a});let a=(0,s(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,s)=>{s.d(t,{A:()=>a});let a=(0,s(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,s)=>{s.d(t,{A:()=>a});let a=(0,s(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,s)=>{s.d(t,{A:()=>a});let a=(0,s(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,s)=>{s.d(t,{A:()=>a});let a=(0,s(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,s)=>{s.d(t,{A:()=>a});let a=(0,s(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,s)=>{s.d(t,{A:()=>a});let a=(0,s(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"}]])},11717:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(82544).A)("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a2.121 2.121 0 1 1 3 3L12 15l-4 1 1-4Z",key:"1lpok0"}]])},25294:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(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,s)=>{s.d(t,{A:()=>a});let a=(0,s(82544).A)("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]])},71205:(e,t,s)=>{s.d(t,{A:()=>l});var a=s(55511),r=s(79428),n=s(48243);function l({encryptedString:e,encryptionKey:t,encryptionSalt:s}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let{key:l,salt:i,keyLen:c,algorithm:d,bufferAllocSize:o}=(0,n.A)({encryptionKey:t});if(!l?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!i?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let u=(0,a.scryptSync)(l,i,c),p=r.Buffer.alloc(o,0),h=(0,a.createDecipheriv)(d,u,p);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,s)=>{s.d(t,{A:()=>r});var a=s(51779);async function r(...e){let t=(0,a.A)();try{if(!t)throw Error("No Connection provided to DB_HANDLER function!");let s=await t.query(...e);return JSON.parse(JSON.stringify(s))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await t?.end()}}},51779:(e,t,s)=>{s.d(t,{A:()=>n});var a=s(9973),r=s.n(a);function n(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,s)=>{s.d(t,{A:()=>a});function a(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}}},30350:(e,t,s)=>{s.a(e,async(e,a)=>{try{s.r(t),s.d(t,{ConnectContext:()=>f,default:()=>m,getServerSideProps:()=>y});var r=s(8732),n=s(82015),l=s.n(n),i=s(72837),c=s(92702),d=s(71934),o=s(49773),u=s(63997),p=s(40445),h=s(71205),x=e([i,o,u,p]);[i,o,u,p]=x.then?(await x)():x;let f=l().createContext({});function m({user:e,query:t,mariadbUserCred:s,mariadbUsers:a}){let n=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("title",{children:"SQL Connect | Datasquirel"}),(0,r.jsx)("meta",{name:"description",content:"Connect to your database remotely"})]}),[c,d]=l().useState(null),[h,x]=l().useState(0);return(0,r.jsx)(f.Provider,{value:{user:e,query:t,mariadbUserCred:s,mariadbUsers:a,targetMariadbUser:c,setTargetMariadbUser:d,refresh:h,setRefresh:x},children:(0,r.jsxs)(l().Fragment,{children:[(0,r.jsx)(i.A,{head:n,aceEditor:!0,children:(0,r.jsx)(o.A,{})}),(0,r.jsx)(u.A,{}),(0,r.jsx)(p.A,{})]})})}async function y({req:e,res:t,query:s}){let a=await (0,c.A)(e,t);if(!a?.logged_in_status)return{redirect:{destination:"/login",permanent:!1}};let r=await (0,d.A)("SELECT mariadb_user, mariadb_host, mariadb_pass FROM users WHERE id = ?",[a.id]),n=r?.[0]||{};n?.mariadb_pass&&(n.mariadb_pass=(0,h.A)({encryptedString:n.mariadb_pass}));let l=await (0,d.A)("SELECT * FROM mariadb_users WHERE user_id = ?",[a.id]);if(l?.[0])for(let e=0;e<l.length;e++){let t=l[e];t.password=(0,h.A)({encryptedString:t.password})}return{props:{user:a,query:s,mariadbUserCred:n,mariadbUsers:l}}}a()}catch(e){a(e)}})},9455:(e,t)=>{Object.defineProperty(t,"A",{enumerable:!0,get:function(){return s}});var s=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 s=e=>t(t.s=e),a=t.X(0,[883,9821,3881,8892],()=>s(44088));module.exports=a})();