1 line
11 KiB
JavaScript
1 line
11 KiB
JavaScript
"use strict";(()=>{var e={};e.id=9634,e.ids=[636,9634],e.modules={30671:(e,t)=>{Object.defineProperty(t,"M",{enumerable:!0,get:function(){return function e(t,r){return r in t?t[r]:"then"in t&&"function"==typeof t.then?t.then(t=>e(t,r)):"function"==typeof t&&"default"===r?t:void 0}}})},80268:(e,t,r)=>{r.r(t),r.d(t,{config:()=>D,default:()=>P,getServerSideProps:()=>E,getStaticPaths:()=>q,getStaticProps:()=>j,reportWebVitals:()=>b,routeModule:()=>M,unstable_getServerProps:()=>N,unstable_getServerSideProps:()=>k,unstable_getStaticParams:()=>L,unstable_getStaticPaths:()=>A,unstable_getStaticProps:()=>w});var s={};r.r(s),r.d(s,{default:()=>_,getServerSideProps:()=>y});var i=r(63865),n=r(9455),o=r(30671),a=r(49407),l=r(68268),u=r(8732);r(82015);var c=r(27912),p=r.n(c),m=r(93615),d=r.n(m),x=r(63715),f=r(20048),h=r.n(f),g=r(72377),S=r.n(g);function _({user:e}){let t=(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("title",{children:"Super User Login | Datasquirel"}),(0,u.jsx)("meta",{name:"description",content:"Welcome to your data app"})]});return(0,u.jsxs)("section",{className:"w-full h-screen justify-center items-center",children:[(0,u.jsx)(p(),{children:t}),(0,u.jsxs)("div",{className:"p-6 bg-slate-100 rounded w-full max-w-2xl flex flex-col items-center",children:[(0,u.jsx)(v,{}),(0,u.jsxs)("form",{onSubmit:e=>{e.preventDefault();let t=e.target;(0,x.A)("/api/admin/loginSuUser",{method:"post",body:{email:t.email.value,password:t.password.value,authKey:t["auth-key"].value}}).then(e=>{window.location.reload()})},className:"flex flex-col items-stretch gap-4 w-full",children:[(0,u.jsx)("input",{type:"text",name:"email",id:"email",placeholder:"Email Address"}),(0,u.jsx)("input",{type:"password",name:"password",id:"password",placeholder:"Password"}),(0,u.jsx)("input",{type:"password",name:"auth-key",id:"auth-key",placeholder:"Auth Key"}),(0,u.jsx)("button",{children:"Login"})]})]})]})}async function y({req:e,res:t,query:r}){let s=await h()(e,t,!0);S()(s)&&console.log("Admin User Detected ...");let i=await d()(e);return i?.logged_in_status?{redirect:{destination:"/su",permanent:!1}}:{props:{user:i}}}function v(){return(0,u.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center",children:[(0,u.jsx)("h1",{className:"text-2xl text-center m-0",children:"Super User Login"}),(0,u.jsxs)("span",{children:["This area is reserved only for the owner of this Admin. To login use the info in your ",(0,u.jsx)("b",{children:"dsql.env"})," File. Use the env variables as follows. Your ",(0,u.jsx)("i",{children:"email address"})," is the same address used to register the first user account"]}),(0,u.jsxs)("ul",{className:"p-0",children:[(0,u.jsxs)("li",{children:["Password:"," ",(0,u.jsx)("i",{className:"info small w-auto inline",children:"dsql.env::"}),(0,u.jsx)("b",{children:" DSQL_USER_KEY"})]}),(0,u.jsxs)("li",{children:["Auth Key:"," ",(0,u.jsx)("i",{className:"info small w-auto inline",children:"dsql.env::"}),(0,u.jsx)("b",{children:" DSQL_SPECIAL_KEY"})]})]})]})}let P=(0,o.M)(s,"default"),j=(0,o.M)(s,"getStaticProps"),q=(0,o.M)(s,"getStaticPaths"),E=(0,o.M)(s,"getServerSideProps"),D=(0,o.M)(s,"config"),b=(0,o.M)(s,"reportWebVitals"),w=(0,o.M)(s,"unstable_getStaticProps"),A=(0,o.M)(s,"unstable_getStaticPaths"),L=(0,o.M)(s,"unstable_getStaticParams"),N=(0,o.M)(s,"unstable_getServerProps"),k=(0,o.M)(s,"unstable_getServerSideProps"),M=new i.PagesRouteModule({definition:{kind:n.A.PAGES,page:"/su/login",pathname:"/su/login",bundlePath:"",filename:""},components:{App:l.default,Document:a.default},userland:s})},93615:(e,t,r)=>{let{IncomingMessage:s}=r(81630),i=r(77463),n=r(6505);e.exports=async function(e){let{keyCookieName:t,csrfCookieName:r}=n(),s=`${t}_su`;if(!e.cookies?.[s])return console.log("No auth key cookie found"),null;let o=i({encryptedString:e.cookies[s]});if(!o)return console.log("No user payload found"),null;let a=JSON.parse(o);return a.password!==process.env.DSQL_USER_KEY?(console.log("Invalid password"),null):a.authKey!==process.env.DSQL_SPECIAL_KEY?(console.log("Invalid auth key"),null):a}},20048:(e,t,r)=>{r(81630);let s=r(67216),i=r(77463),n=r(29021),o=r(6505);async function a(e,t,r,a){let{keyCookieName:l,csrfCookieName:u}=o();if(!e.cookies?.[l]?.match(/./))return null;let c=i({encryptedString:e.cookies[l]});if(!c)return null;let p=JSON.parse(c);if(!p.csrf_k||r&&!e.headers["x-csrf-auth"]?.match(RegExp(`${p.csrf_k}`)))return null;let m=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!m)return console.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(r&&!n.existsSync(`${m}/${p.csrf_k}`))return null;if(0==p.verification_status&&!r){let e=await s(`SELECT verification_status FROM users WHERE id='${p.id}'`);e&&e[0]&&1==e[0].verification_status&&t.setHeader("Set-Cookie",["user_refresh=1"])}return p?.date&&Date.now()-p.date>6048e5?null:p}e.exports=a},72377:e=>{e.exports=function(e,t){return t?e?.id&&String(e?.id)==(process.env.DSQL_SU_USER_ID||"1")&&"true":e?.id&&"1"==String(e?.id)&&"true"}},6505:e=>{e.exports=function(){let e=process.env.DSQL_COOKIES_PREFIX||"dsql_";return{keyCookieName:e+(process.env.DSQL_COOKIES_KEY_NAME||"key"),csrfCookieName:e+(process.env.DSQL_COOKIES_CSRF_NAME||"csrf")}}},77463:(e,t,r)=>{let{scryptSync:s,createDecipheriv:i}=r(55511),{Buffer:n}=r(79428);e.exports=({encryptedString:e,encryptionKey:t,encryptionSalt:r})=>{if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let o=t||process.env.DSQL_ENCRYPTION_PASSWORD,a=r||process.env.DSQL_ENCRYPTION_SALT,l=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!o?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!a?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let u=i("aes-192-cbc",s(o,a,l),n.alloc(16,0));try{let t=u.update(e,"hex","utf8");return t+=u.final("utf8")}catch(t){return console.log("Error in decrypting =>",t.message),e}}},67216:(e,t,r)=>{let s=r(9973),i=r(31976),n=s({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4",ssl:i()}});async function o(...e){try{let t=await n.query(...e);return await n.end(),JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=o},31976:(e,t,r)=>{let s=r(29021);e.exports=function(){let e=process.env.DSQL_SSL_DIR;if(!e?.match(/./))return;let t=`${e}/ca-cert.pem`;if(!s.existsSync(t)){console.log(`${t} does not exist`);return}return{ca:s.readFileSync(`${e}/ca-cert.pem`)}}},49407:(e,t,r)=>{r.r(t),r.d(t,{default:()=>n});var s=r(8732);r(82015);var i=r(20883);function n(e){return(0,s.jsxs)(i.Html,{lang:"en",children:[(0,s.jsxs)(i.Head,{children:[(0,s.jsx)("meta",{name:"author",content:"Datasquirel"}),(0,s.jsx)("meta",{name:"Copyright",content:`Copyright (c) ${new Date().getFullYear()} Datasquirel`}),"dev_dev".match(/dev/)&&(0,s.jsx)("meta",{name:"robots",content:"noindex,nofollow"}),(0,s.jsx)("link",{rel:"preconnect",href:"https://fonts.googleapis.com/",crossOrigin:"anonymous"}),(0,s.jsx)("link",{rel:"preconnect",href:"https://fonts.gstatic.com",crossOrigin:"anonymous"}),(0,s.jsx)("link",{rel:"stylesheet",href:"https://fonts.googleapis.com/css?family=Poppins"}),(0,s.jsx)("link",{rel:"stylesheet",href:"https://fonts.googleapis.com/css?family=Inter"}),(0,s.jsx)("link",{rel:"stylesheet",href:"https://fonts.googleapis.com/css?family=IBM+Plex+Mono"}),(0,s.jsx)("script",{src:"/scripts/themeSelector.js"}),(0,s.jsx)("meta",{httpEquiv:"Content-Type",content:"text/html; charset=UTF-8"}),(0,s.jsx)("meta",{property:"og:site_name",content:"DATASQUIREL"}),(0,s.jsx)("meta",{property:"og:type",content:"website"}),(0,s.jsx)("meta",{name:"twitter:card",content:"summary"}),(0,s.jsx)("meta",{property:"og:image",content:"https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"}),(0,s.jsx)("meta",{itemProp:"image",content:"https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"}),(0,s.jsx)("meta",{name:"twitter:image",content:"https://static.datasquirel.com/images/user-images/user-2/email-banner.jpeg"}),(0,s.jsx)("link",{rel:"stylesheet",href:"/styles/prism.css"}),(0,s.jsx)("script",{src:"/scripts/prism.js",async:!0}),(0,s.jsx)("script",{dangerouslySetInnerHTML:{__html:"var DSQL = {}"}})]}),(0,s.jsxs)("body",{children:[(0,s.jsx)(i.Main,{}),(0,s.jsx)(i.NextScript,{})]})]})}},9455:(e,t)=>{var r;Object.defineProperty(t,"A",{enumerable:!0,get:function(){return r}}),function(e){e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE"}(r||(r={}))},66099:e=>{e.exports=require("@mui/system")},37616:e=>{e.exports=require("@mui/system/DefaultPropsProvider")},24509:e=>{e.exports=require("@mui/system/InitColorSchemeScript")},84781:e=>{e.exports=require("@mui/system/colorManipulator")},18215:e=>{e.exports=require("@mui/system/createStyled")},59989:e=>{e.exports=require("@mui/system/createTheme")},16670:e=>{e.exports=require("@mui/system/styleFunctionSx")},88698:e=>{e.exports=require("@mui/system/useThemeProps")},76831:e=>{e.exports=require("@mui/utils")},28578:e=>{e.exports=require("@mui/utils/capitalize")},14036:e=>{e.exports=require("@mui/utils/composeClasses")},31112:e=>{e.exports=require("@mui/utils/createChainedFunction")},21763:e=>{e.exports=require("@mui/utils/debounce")},7546:e=>{e.exports=require("@mui/utils/deepmerge")},5928:e=>{e.exports=require("@mui/utils/deprecatedPropType")},20985:e=>{e.exports=require("@mui/utils/formatMuiErrorMessage")},61119:e=>{e.exports=require("@mui/utils/generateUtilityClass")},81699:e=>{e.exports=require("@mui/utils/generateUtilityClasses")},29823:e=>{e.exports=require("@mui/utils/isMuiElement")},55402:e=>{e.exports=require("@mui/utils/ownerDocument")},46875:e=>{e.exports=require("@mui/utils/ownerWindow")},48080:e=>{e.exports=require("@mui/utils/requirePropFactory")},39597:e=>{e.exports=require("@mui/utils/setRef")},88190:e=>{e.exports=require("@mui/utils/unsupportedProp")},83889:e=>{e.exports=require("@mui/utils/useControlled")},21956:e=>{e.exports=require("@mui/utils/useEnhancedEffect")},4926:e=>{e.exports=require("@mui/utils/useEventCallback")},7376:e=>{e.exports=require("@mui/utils/useForkRef")},63310:e=>{e.exports=require("@mui/utils/useId")},10977:e=>{e.exports=require("@mui/utils/useIsFocusVisible")},74956:e=>{e.exports=require("clsx")},40361:e=>{e.exports=require("next/dist/compiled/next-server/pages.runtime.prod.js")},27912:e=>{e.exports=require("next/head")},29825:e=>{e.exports=require("prop-types")},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")},29021:e=>{e.exports=require("fs")},81630:e=>{e.exports=require("http")},33873:e=>{e.exports=require("path")}};var t=require("../../webpack-runtime.js");t.C(e);var r=e=>t(t.s=e),s=t.X(0,[9764,883,8268],()=>r(80268));module.exports=s})(); |