dsql-admin/dsql-app/.local_dist/server/pages/create-account.js
Benjamin Toby 3ffd2d6777 Updates
2024-12-05 08:03:33 +01:00

16 lines
17 KiB
JavaScript

"use strict";(()=>{var e={};e.id=8810,e.ids=[636,8810],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}}})},90467:(e,t,r)=>{r.r(t),r.d(t,{config:()=>q,default:()=>y,getServerSideProps:()=>D,getStaticPaths:()=>v,getStaticProps:()=>E,reportWebVitals:()=>b,routeModule:()=>L,unstable_getServerProps:()=>w,unstable_getServerSideProps:()=>R,unstable_getStaticParams:()=>j,unstable_getStaticPaths:()=>P,unstable_getStaticProps:()=>A});var s={};r.r(s),r.d(s,{CreateAccountContext:()=>h,default:()=>x,getServerSideProps:()=>S});var a=r(63865),i=r(9455),n=r(30671),o=r(49407),l=r(68268),u=r(8732),c=r(82015),d=r.n(c),p=r(71457),m=r(87472),_=r(70045);function g(e){let{query:t,invitingUser:r}=d().useContext(h);return(0,u.jsxs)("section",{className:"flex-col items-center lg:items-center gap-20 p-0",children:[(0,u.jsx)("img",{src:"/images/grid.webp",alt:"Dotted image background",className:"absolute top-0 left-0 w-full h-full object-cover opacity-80 dark:opacity-10 z-0"}),(0,u.jsxs)("div",{className:"w-full lg:w-1/2 max-w-6xl gap-4 flex-col items-center px-4 py-10 bg-white dark:bg-slate-900 relative z-10",children:[r?.first_name&&(0,u.jsxs)("span",{className:"text-xs bg-emerald-100 rounded-full px-4 py-1 mb-4",children:["You have been invited by"," ",(0,u.jsxs)("b",{children:[r.first_name," ",r.last_name," (",r.email,")"]})," ","to manage an account. Please create an account to gain access."]}),(0,u.jsx)("h1",{className:"m-0 text-center text-2xl",children:"Create An Account"}),(0,u.jsx)(_.A,{query:t})]})]})}r(20048),r(22172),r(67216),r(93353),r(32415),r(63715);var f=r(55966);let h=d().createContext({});function x(e){let t="Create Account | Datasquirel",r="Create a FREE account and start storing data.",s=(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("title",{children:t}),(0,u.jsx)("meta",{name:"description",content:r}),(0,u.jsx)(m.A,{pageTitle:t,pageDescription:r,pagePathname:"/"})]}),[a,i]=d().useState(null);return e.query?.invite?(0,u.jsx)(f.A,{}):(0,u.jsx)(p.A,{head:s,children:(0,u.jsx)(h.Provider,{value:{user:a,query:e.query,invitingUser:e.invitingUser},children:(0,u.jsx)("main",{children:(0,u.jsx)(g,{})})})})}async function S({req:e,res:t,query:r}){return{redirect:{destination:"/login",permanent:!1}}}let y=(0,n.M)(s,"default"),E=(0,n.M)(s,"getStaticProps"),v=(0,n.M)(s,"getStaticPaths"),D=(0,n.M)(s,"getServerSideProps"),q=(0,n.M)(s,"config"),b=(0,n.M)(s,"reportWebVitals"),A=(0,n.M)(s,"unstable_getStaticProps"),P=(0,n.M)(s,"unstable_getStaticPaths"),j=(0,n.M)(s,"unstable_getStaticParams"),w=(0,n.M)(s,"unstable_getServerProps"),R=(0,n.M)(s,"unstable_getServerSideProps"),L=new a.PagesRouteModule({definition:{kind:i.A.PAGES,page:"/create-account",pathname:"/create-account",bundlePath:"",filename:""},components:{App:l.default,Document:o.default},userland:s})},55966:(e,t,r)=>{r.d(t,{A:()=>i});var s=r(8732);r(82015);var a=r(32415);function i(){return(0,s.jsx)("div",{className:"flex flex-col gap-4 items-center justify-center w-full h-screen p-6 bg-slate-100",children:(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 px-6 py-20 bg-white rounded shadow-sm max-w-2xl w-full",children:[(0,s.jsx)("img",{src:"/images/logo-icon-alt-2.webp",alt:"Datasquirel Logo",width:60}),(0,s.jsx)("div",{className:"w-10 h-10 flex flex-col items-center justify-center",children:(0,s.jsx)(a.A,{width:"25px",position:"relative"})})]})})}},22172:(e,t,r)=>{r(29021),r(28187);let s=r(68942),a=r(67216),i=r(43290);e.exports=async function({query:e,user:t}){try{let{invite:r,database_access:s,priviledge:n,email:o}=e,l=await a("SELECT date_created_code FROM invitations WHERE inviting_user_id=? AND invited_user_email=?",[r,o]);if(!l||!l[0])throw Error("No Invitation Found");let u=await a("SELECT first_name,last_name,email FROM users WHERE id=?",[r]);if(u?.[0]){let e=await a("SELECT email FROM user_users WHERE user_id=? AND invited_user_id=? AND user_type='admin' AND email=?",[r,t.id,o]);if(e?.[0])console.log("User already added");else{i({dbFullName:"datasquirel",tableName:"user_users",data:{user_id:r,invited_user_id:t.id,database_access:s,first_name:t.first_name,last_name:t.last_name,phone:t.phone,email:t.email,username:t.username,user_type:"admin",user_priviledge:n,image:t.image,image_thumbnail:t.image_thumbnail}});let e=await a("SELECT db_tables_data FROM invitations WHERE inviting_user_id=? AND invited_user_email=?",[r,o]);if(await a("DELETE FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=?",[r,t.id]),e&&e[0]){let s=e[0].db_tables_data.split("|");for(let e=0;e<s.length;e++){let[a,o]=s[e].split("-");await i({dbFullName:"datasquirel",tableName:"delegated_user_tables",data:{delegated_user_id:t.id,root_user_id:r,database:a,table:o,priviledge:n}})}}}await a("UPDATE invitations SET invitation_status='Accepted' WHERE inviting_user_id=? AND invited_user_email=?",[r,o])}}catch(e){s({component:"addAdminUserOnLogin",message:e.message,user:t})}}},68942:(e,t,r)=>{let s=r(29021),{IncomingMessage:a}=r(81630);e.exports=async function({user:e,message:t,component:r,noMail:a,req:i}){let n=new Date,o=(()=>{if(!i)return null;try{let e=i.headers["x-forwarded-for"],t=i.headers["x-real-ip"],r=i.headers["cf-connecting-ip"],s=Array.isArray(e)?e[0]:e?.split(",")[0],a=r||s||t||i.socket.remoteAddress;if(!a)return null;return String(a)}catch(e){return null}})();try{let a=`🚀 SERVER ERROR ===========================
Error Message: ${t}
Component: ${r}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(a+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),i?.url&&(a+=`
URL: ${i.url}`),i?.body&&(a+=`
Request Body: ${JSON.stringify(i.body,null,4)}`),o&&(a+=`
IP: ${o}`),a+=`
Date: ${n.toDateString()}
========================================`,s.existsSync("./.tmp/error.log")||s.writeFileSync("./.tmp/error.log","","utf-8");let l=s.readFileSync("./.tmp/error.log","utf-8");s.writeFileSync("./.tmp/error.log",a),s.appendFileSync("./.tmp/error.log",`
${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},20048:(e,t,r)=>{r(81630);let s=r(67216),a=r(83007),i=r(29021);async function n(e,t,r,n){if(!e.cookies?.datasquirelAuthKey?.match(/./))return null;let o=a(e.cookies.datasquirelAuthKey);if(!o)return null;let l=JSON.parse(o);if(!l.csrf_k||r&&!e.headers["x-csrf-auth"]?.match(RegExp(`${l.csrf_k}`)))return null;let u=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!u)return console.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(r&&!i.existsSync(`${u}/${l.csrf_k}`))return null;if(0==l.verification_status&&!r){let e=await s(`SELECT verification_status FROM users WHERE id='${l.id}'`);e&&e[0]&&1==e[0].verification_status&&t.setHeader("Set-Cookie",["user_refresh=1"])}return l?.date&&Date.now()-l.date>6048e5?null:l}e.exports=n},43290:(e,t,r)=>{let s=r(81339),a=r(72583),i=r(67942);r(19760);let n=r(19760);r(27825);let o=r(67216),l=r(1231);async function u({dbContext:e,paradigm:t,dbFullName:r,tableName:u,data:c,tableSchema:d,duplicateColumnName:p,duplicateColumnValue:m,update:_,encryptionKey:g,encryptionSalt:f}){let h=!e?.match(/dsql.user/i)&&(!r||!!r.match(/^datasquirel$/)),x=h?o:l;if(c?.date_created_timestamp&&delete c.date_created_timestamp,c?.date_updated_timestamp&&delete c.date_updated_timestamp,c?.date_updated&&delete c.date_updated,c?.date_updated_code&&delete c.date_updated_code,c?.date_created&&delete c.date_created,c?.date_created_code&&delete c.date_created_code,p&&"string"==typeof p){let s=h?await x(`SELECT * FROM \`${u}\` WHERE \`${p}\`=?`,[m]):await x({paradigm:"Read Only",database:r,queryString:`SELECT * FROM \`${u}\` WHERE \`${p}\`=?`,queryValues:[m]});if(s?.[0]&&!_)return null;if(s&&s[0]&&_)return await n({dbContext:e,paradigm:t,dbFullName:r,tableName:u,data:c,tableSchema:d,encryptionKey:g,encryptionSalt:f,identifierColumnName:p,identifierValue:m||""})}let S=Object.keys(c),y=[],E=[];for(let e=0;e<S.length;e++)try{let t=S[e],r=c?.[t],n=d?d?.fields?.filter(e=>e.fieldName==t):null,o=n&&n[0]?n[0]:null;if(null==r||void 0==r||o?.dataType?.match(/int$/i)&&"string"==typeof r&&!r?.match(/./))continue;o?.encrypted&&(r=s(r,g,f),console.log("DSQL: Encrypted value =>",r)),o?.richText&&(r=a(r,i)),o?.pattern&&!new RegExp(o.pattern,o.patternFlags||"").test(r)&&(console.log("DSQL: Pattern not matched =>",r),r=""),y.push("`"+t+"`"),"object"==typeof r&&(r=JSON.stringify(r)),"number"==typeof r?E.push(String(r)):E.push(r)}catch(e){console.log("DSQL: Error in parsing data keys =>",e.message);continue}c?.date_created||(y.push("`date_created`"),E.push(Date())),c?.date_created_code||(y.push("`date_created_code`"),E.push(Date.now())),c?.date_updated||(y.push("`date_updated`"),E.push(Date())),c?.date_updated_code||(y.push("`date_updated_code`"),E.push(Date.now()));let v=`INSERT INTO \`${u}\` (${y.join(",")}) VALUES (${E.map(()=>"?").join(",")})`;return h?await x(v,E):await x({paradigm:t,database:r,queryString:v,queryValues:E})}e.exports=u},19760:(e,t,r)=>{let s=r(81339),a=r(72583),i=r(67942),n=r(67216),o=r(1231);async function l({dbContext:e,paradigm:t,dbFullName:r,tableName:l,data:u,tableSchema:c,identifierColumnName:d,identifierValue:p,encryptionKey:m,encryptionSalt:_}){if(!u||!Object.keys(u).length)return null;let g=!e?.match(/dsql.user/i)&&(!r||!!r.match(/^datasquirel$/)),f=g?n:o,h=Object.keys(u),x=[],S=[];for(let e=0;e<h.length;e++)try{let t=h[e],r=u[t],n=c?c?.fields?.filter(e=>e.fieldName===t):null,o=n&&n[0]?n[0]:null;if(null==r||void 0==r)continue;o?.richText&&(r=a(r,i)),o?.encrypted&&(r=s(r,m,_)),"object"==typeof r&&(r=JSON.stringify(r)),o?.pattern&&!new RegExp(o.pattern,o.patternFlags||"").test(r)&&(console.log("DSQL: Pattern not matched =>",r),r=""),"string"==typeof r&&r.match(/^null$/i)&&(r={toSqlString:function(){return"NULL"}}),"string"!=typeof r||r.match(/./i)||(r={toSqlString:function(){return"NULL"}}),x.push(`\`${t}\`=?`),"number"==typeof r?S.push(String(r)):S.push(r)}catch(e){console.log("DSQL: Error in parsing data keys in update function =>",e.message);continue}x.push(`date_updated='${Date()}'`),x.push(`date_updated_code='${Date.now()}'`);let y=`UPDATE ${l} SET ${x.join(",")} WHERE \`${d}\`=?`;return S.push(p),g?await f(y,S):await f({paradigm:t,database:r,queryString:y,queryValues:S})}e.exports=l},83007:(e,t,r)=>{let{scryptSync:s,createDecipheriv:a}=r(55511),{Buffer:i}=r(79428);e.exports=e=>{let t=a("aes-192-cbc",s(process.env.DSQL_ENCRYPTION_PASSWORD||"",process.env.DSQL_ENCRYPTION_SALT||"",24),i.alloc(16,0));try{let r=t.update(e,"hex","utf8");return r+=t.final("utf8")}catch(e){return null}}},81339:(e,t,r)=>{let{scryptSync:s,createCipheriv:a}=r(55511),{Buffer:i}=r(79428),n=r(22373);e.exports=(e,t,r)=>{let o=a("aes-192-cbc",s(t||process.env.DSQL_ENCRYPTION_PASSWORD||"",r||process.env.DSQL_ENCRYPTION_SALT||"",24),i.alloc(16,0));try{let t=o.update(e,"utf8","hex");return t+=o.final("hex")}catch(e){return n({component:"encrypt",message:e.message}),null}}},67942:e=>{e.exports={allowedTags:["b","i","em","strong","a","p","span","ul","ol","li","h1","h2","h3","h4","h5","h6","img","div","button","pre","code","br"],allowedAttributes:{a:["href"],img:["src","alt","width","height","class","style"],"*":["style","class"]}}},67216:(e,t,r)=>{let s=r(9973),a=r(31976),i=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:a()}});async function n(...e){try{let t=await i.query(...e);return await i.end(),JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}}e.exports=n},1231:(e,t,r)=>{let s=r(29021);r(33873);let a=r(9973),i=r(31976),n=a({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,charset:"utf8mb4",ssl:i()}});e.exports=function({paradigm:e,database:t,queryString:r,queryValues:o}){try{return new Promise((l,u)=>{let c=!!e?.match(/full.access|^fa$/i);try{function d(e){n.end(),l(JSON.parse(JSON.stringify(e)))}function p(e){n.end(),l({error:e.message,queryStringGenerated:r,queryValuesGenerated:o,sql:e.sql})}n=c?a({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,database:t,ssl:i()}}):a({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,database:t,ssl:i()}}),o&&Array.isArray(o)&&o[0]?n.query(r,o).then(d).catch(p):n.query(r).then(d).catch(p)}catch(e){s.appendFileSync("./.tmp/dbErrorLogs.txt",e.message+"\n"+Date()+"\n\n\n","utf8"),l({error:e.message})}})}catch(e){return{success:!1,error:e.message}}}},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:()=>i});var s=r(8732);r(82015);var a=r(20883);function i(e){return(0,s.jsxs)(a.Html,{lang:"en",children:[(0,s.jsxs)(a.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)(a.Main,{}),(0,s.jsx)(a.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={}))},28187:e=>{e.exports=require("@moduletrace/datasquirel")},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")},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")},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")},72583:e=>{e.exports=require("sanitize-html")},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,2414,1137],()=>r(90467));module.exports=s})();