16 lines
18 KiB
JavaScript
16 lines
18 KiB
JavaScript
"use strict";(()=>{var e={};e.id=8810,e.ids=[3220,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:()=>b,default:()=>y,getServerSideProps:()=>v,getStaticPaths:()=>D,getStaticProps:()=>x,reportWebVitals:()=>N,routeModule:()=>j,unstable_getServerProps:()=>O,unstable_getServerSideProps:()=>R,unstable_getStaticParams:()=>P,unstable_getStaticPaths:()=>A,unstable_getStaticProps:()=>L});var s={};r.r(s),r.d(s,{CreateAccountContext:()=>S,default:()=>h,getServerSideProps:()=>E});var a=r(63865),n=r(9455),i=r(30671),o=r(49407),l=r(89600),c=r(8732),u=r(82015),d=r.n(u),p=r(71457),_=r(87472),m=r(70045);function g(e){let{query:t,invitingUser:r}=d().useContext(S);return(0,c.jsxs)("section",{className:"flex-col items-center lg:items-center gap-20 p-0",children:[(0,c.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,c.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,c.jsxs)("span",{className:"text-xs bg-emerald-100 rounded-full px-4 py-1 mb-4",children:["You have been invited by"," ",(0,c.jsxs)("b",{children:[r.first_name," ",r.last_name," (",r.email,")"]})," ","to manage an account. Please create an account to gain access."]}),(0,c.jsx)("h1",{className:"m-0 text-center text-2xl",children:"Create An Account"}),(0,c.jsx)(m.A,{query:t})]})]})}r(20048),r(26123),r(67216),r(63715);var f=r(55966);r(6505);let S=d().createContext({});function h(e){let t="Create Account | Datasquirel",r="Create a FREE account and start storing data.",s=(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("title",{children:t}),(0,c.jsx)("meta",{name:"description",content:r}),(0,c.jsx)(_.A,{pageTitle:t,pageDescription:r,pagePathname:"/"})]}),[a,n]=d().useState(null);return e.query?.invite?(0,c.jsx)(f.A,{}):(0,c.jsx)(p.A,{head:s,children:(0,c.jsx)(S.Provider,{value:{user:a,query:e.query,invitingUser:e.invitingUser},children:(0,c.jsx)("main",{children:(0,c.jsx)(g,{})})})})}async function E({req:e,res:t,query:r}){return{redirect:{destination:"/login",permanent:!1}}}let y=(0,i.M)(s,"default"),x=(0,i.M)(s,"getStaticProps"),D=(0,i.M)(s,"getStaticPaths"),v=(0,i.M)(s,"getServerSideProps"),b=(0,i.M)(s,"config"),N=(0,i.M)(s,"reportWebVitals"),L=(0,i.M)(s,"unstable_getStaticProps"),A=(0,i.M)(s,"unstable_getStaticPaths"),P=(0,i.M)(s,"unstable_getStaticParams"),O=(0,i.M)(s,"unstable_getServerProps"),R=(0,i.M)(s,"unstable_getServerSideProps"),j=new a.PagesRouteModule({definition:{kind:n.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:()=>n});var s=r(8732);r(82015);var a=r(32415);function n(){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"})})]})})}},20048:(e,t,r)=>{r(81630);let s=r(67216),a=r(77463),n=r(29021),i=r(6505);async function o(e,t,r,o){let{keyCookieName:l,csrfCookieName:c}=i();if(!e.cookies?.[l]?.match(/./))return null;let u=a({encryptedString:e.cookies[l]});if(!u)return null;let d=JSON.parse(u);if(!d.csrf_k||r&&!e.headers["x-csrf-auth"]?.match(RegExp(`${d.csrf_k}`)))return null;let p=process.env.DSQL_USER_LOGIN_KEYS_PATH;if(!p)return console.log("DSQL_USER_LOGIN_KEYS_PATH env variable not found. Please set this variable."),null;if(r&&!n.existsSync(`${p}/${d.csrf_k}`))return null;if(0==d.verification_status&&!r){let e=await s(`SELECT verification_status FROM users WHERE id='${d.id}'`);e&&e[0]&&1==e[0].verification_status&&t.setHeader("Set-Cookie",["user_refresh=1"])}return d?.date&&Date.now()-d.date>6048e5?null:d}e.exports=o},26123:(e,t,r)=>{let s=r(22373),a=r(67216),n=r(43290),i=r(88896);e.exports=async function({query:e,user:t,useLocal:r}){try{let s=r?i:a,{invite:o,database_access:l,priviledge:c,email:u}=e,d=[o,u],p=await s("SELECT date_created_code FROM invitations WHERE inviting_user_id=? AND invited_user_email=?",d);if(!p||!p[0])throw Error("No Invitation Found");let _=[o],m=await s("SELECT first_name,last_name,email FROM users WHERE id=?",_);if(m?.[0]){let e=await s("SELECT email FROM user_users WHERE user_id=? AND invited_user_id=? AND user_type='admin' AND email=?",[o,t.id,u]);if(e?.[0])console.log("User already added");else{n({dbFullName:"datasquirel",tableName:"user_users",data:{user_id:o,invited_user_id:t.id,database_access:l,first_name:t.first_name,last_name:t.last_name,phone:t.phone,email:t.email,username:t.username,user_type:"admin",user_priviledge:c,image:t.image,image_thumbnail:t.image_thumbnail},useLocal:r});let e=await s("SELECT db_tables_data FROM invitations WHERE inviting_user_id=? AND invited_user_email=?",[o,u]);if(await s("DELETE FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=?",[o,t.id]),e&&e[0]){let s=e[0].db_tables_data.split("|");for(let e=0;e<s.length;e++){let[a,i]=s[e].split("-");await n({dbFullName:"datasquirel",tableName:"delegated_user_tables",data:{delegated_user_id:t.id,root_user_id:o,database:a,table:i,priviledge:c},useLocal:r})}}}await s("UPDATE invitations SET invitation_status='Accepted' WHERE inviting_user_id=? AND invited_user_email=?",[o,u])}}catch(e){s({component:"addAdminUserOnLogin",message:e.message,user:t})}}},6505:e=>{e.exports=function(e){let t=process.env.DSQL_COOKIES_PREFIX||"dsql_",r=process.env.DSQL_COOKIES_KEY_NAME||"key",s=process.env.DSQL_COOKIES_CSRF_NAME||"csrf",a=process.env.DSQL_COOKIES_ONE_TIME_CODE_NAME||"one-time-code",n=e?.database?.replace(/^datasquirel_user_\d+_/,"")||process.env.DSQL_DB_NAME?.replace(/^datasquirel_user_\d+_/,""),i=t;e?.userId&&(i+=`user_${e.userId}_`),n&&(i+=`${n}_`),i+=r;let o=t;e?.userId&&(o+=`user_${e.userId}_`),n&&(o+=`${n}_`),o+=s;let l=t;return e?.userId&&(l+=`user_${e.userId}_`),n&&(l+=`${n}_`),{keyCookieName:i,csrfCookieName:o,oneTimeCodeName:l+=a}}},43290:(e,t,r)=>{let s=r(72583),a=r(67942),n=r(19760);r(27825);let i=r(67216),o=r(1231),l=r(53219),c=r(88896);async function u({dbContext:e,paradigm:t,dbFullName:r,tableName:u,data:d,tableSchema:p,duplicateColumnName:_,duplicateColumnValue:m,update:g,encryptionKey:f,encryptionSalt:S,useLocal:h}){let E=!!h||!e?.match(/dsql.user/i)&&(!r||!!r.match(/^datasquirel$/)),y=h?c:E?i:o;if(d?.date_created_timestamp&&delete d.date_created_timestamp,d?.date_updated_timestamp&&delete d.date_updated_timestamp,d?.date_updated&&delete d.date_updated,d?.date_updated_code&&delete d.date_updated_code,d?.date_created&&delete d.date_created,d?.date_created_code&&delete d.date_created_code,_&&"string"==typeof _){let s=E?await y(`SELECT * FROM \`${u}\` WHERE \`${_}\`=?`,[m]):await y({paradigm:"Read Only",database:r,queryString:`SELECT * FROM \`${u}\` WHERE \`${_}\`=?`,queryValues:[m]});if(s?.[0]&&!g)return null;if(s&&s[0]&&g)return await n({dbContext:e,paradigm:t,dbFullName:r,tableName:u,data:d,tableSchema:p,encryptionKey:f,encryptionSalt:S,identifierColumnName:_,identifierValue:m||""})}let x=Object.keys(d),D=[],v=[];for(let e=0;e<x.length;e++)try{let t=x[e],r=d?.[t],n=p?p?.fields?.filter(e=>e.fieldName==t):null,i=n&&n[0]?n[0]:null;if(null==r||void 0==r||i?.dataType?.match(/int$/i)&&"string"==typeof r&&!r?.match(/./))continue;i?.encrypted&&(r=l({data:r,encryptionKey:f,encryptionSalt:S}),console.log("DSQL: Encrypted value =>",r));let o=/<[^>]+>/g;(i?.richText||String(r).match(o))&&(r=s(r,a)),i?.pattern&&!new RegExp(i.pattern,i.patternFlags||"").test(r)&&(console.log("DSQL: Pattern not matched =>",r),r=""),D.push("`"+t+"`"),"object"==typeof r&&(r=JSON.stringify(r)),"number"==typeof r?v.push(String(r)):v.push(r)}catch(e){console.log("DSQL: Error in parsing data keys =>",e.message);continue}d?.date_created||(D.push("`date_created`"),v.push(Date())),d?.date_created_code||(D.push("`date_created_code`"),v.push(Date.now())),d?.date_updated||(D.push("`date_updated`"),v.push(Date())),d?.date_updated_code||(D.push("`date_updated_code`"),v.push(Date.now()));let b=`INSERT INTO \`${u}\` (${D.join(",")}) VALUES (${v.map(()=>"?").join(",")})`;return E?await y(b,v):await y({paradigm:t,database:r,queryString:b,queryValues:v})}e.exports=u},19760:(e,t,r)=>{let s=r(72583),a=r(67942),n=r(67216),i=r(1231),o=r(53219),l=r(88896);async function c({dbContext:e,paradigm:t,dbFullName:r,tableName:c,data:u,tableSchema:d,identifierColumnName:p,identifierValue:_,encryptionKey:m,encryptionSalt:g,useLocal:f}){if(!u||!Object.keys(u).length)return null;let S=!!f||!e?.match(/dsql.user/i)&&(!r||!!r.match(/^datasquirel$/)),h=f?l:S?n:i,E=Object.keys(u),y=[],x=[];for(let e=0;e<E.length;e++)try{let t=E[e],r=u[t],n=d?d?.fields?.filter(e=>e.fieldName===t):null,i=n&&n[0]?n[0]:null;if(null==r||void 0==r)continue;let l=/<[^>]+>/g;(i?.richText||String(r).match(l))&&(r=s(r,a)),i?.encrypted&&(r=o({data:r,encryptionKey:m,encryptionSalt:g})),"object"==typeof r&&(r=JSON.stringify(r)),i?.pattern&&!new RegExp(i.pattern,i.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"}}),y.push(`\`${t}\`=?`),"number"==typeof r?x.push(String(r)):x.push(r)}catch(e){console.log("DSQL: Error in parsing data keys in update function =>",e.message);continue}y.push(`date_updated='${Date()}'`),y.push(`date_updated_code='${Date.now()}'`);let D=`UPDATE ${c} SET ${y.join(",")} WHERE \`${p}\`=?`;return x.push(_),S?await h(D,x):await h({paradigm:t,database:r,queryString:D,queryValues:x})}e.exports=c},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"]}}},22373:(e,t,r)=>{let s=r(29021),{IncomingMessage:a}=r(81630);e.exports=async function({user:e,message:t,component:r,noMail:a,req:n}){let i=new Date,o=(()=>{if(!n)return null;try{let e=n.headers["x-forwarded-for"],t=n.headers["x-real-ip"],r=n.headers["cf-connecting-ip"],s=Array.isArray(e)?e[0]:e?.split(",")[0],a=r||s||t||n.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}`),n?.url&&(a+=`
|
|
URL: ${n.url}`),n?.body&&(a+=`
|
|
Request Body: ${JSON.stringify(n.body,null,4)}`),o&&(a+=`
|
|
IP: ${o}`),a+=`
|
|
Date: ${i.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)}}},77463:(e,t,r)=>{let{scryptSync:s,createDecipheriv:a}=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 i=t||process.env.DSQL_ENCRYPTION_PASSWORD,o=r||process.env.DSQL_ENCRYPTION_SALT,l=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!i?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!o?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let c=a("aes-192-cbc",s(i,o,l),n.alloc(16,0));try{let t=c.update(e,"hex","utf8");return t+=c.final("utf8")}catch(t){return console.log("Error in decrypting =>",t.message),e}}},53219:(e,t,r)=>{let{scryptSync:s,createCipheriv:a}=r(55511),{Buffer:n}=r(79428);e.exports=({data:e,encryptionKey:t,encryptionSalt:r})=>{if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let i=t||process.env.DSQL_ENCRYPTION_PASSWORD,o=r||process.env.DSQL_ENCRYPTION_SALT,l=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!i?.match(/.{8,}/))return console.log("Encryption key is invalid"),e;if(!o?.match(/.{8,}/))return console.log("Encryption salt is invalid"),e;let c=a("aes-192-cbc",s(i,o,l),n.alloc(16,0));try{let t=c.update(e,"utf8","hex");return t+=c.final("hex")}catch(t){return console.log("Error in encrypting =>",t.message),e}}},67216:(e,t,r)=>{let s=r(9973),a=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:a()}});async function i(...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=i},1231:(e,t,r)=>{let s=r(29021);r(33873);let a=r(9973),n=r(31976),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,charset:"utf8mb4",ssl:n()}});e.exports=function({paradigm:e,database:t,queryString:r,queryValues:o}){try{return new Promise((l,c)=>{let u=!!e?.match(/full.access|^fa$/i);try{function d(e){i.end(),l(JSON.parse(JSON.stringify(e)))}function p(e){i.end(),l({error:e.message,queryStringGenerated:r,queryValuesGenerated:o,sql:e.sql})}i=u?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: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,database:t,ssl:n()}}),o&&Array.isArray(o)&&o[0]?i.query(r,o).then(d).catch(p):i.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}}}},88896:(e,t,r)=>{let s=r(9973),a=r(31976);async function n(...e){let t=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()},onConnect:()=>{console.log("Connection Successful!")},onConnectError:e=>{console.log("Connection Error",e.message)},onError:e=>{console.log("Client Error",e.message)}});console.log("Querying ...");try{let r=await t.query(...e);return await t.end(),JSON.parse(JSON.stringify(r))}catch(e){return console.log("DB Error =>",e.message),{success:!1,error:e.message}}}e.exports=n},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 a=r(20883);function n(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={}))},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")},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,[883,9821,9600,2414,45],()=>r(90467));module.exports=s})(); |