dsql-admin/dsql-app/.local_dist/server/chunks/4385.js

16 lines
11 KiB
JavaScript
Raw Normal View History

2024-12-08 19:56:57 +00:00
"use strict";exports.id=4385,exports.ids=[4385],exports.modules={14385:(e,a,t)=>{let s=t(29021),r=t(59474),i=t(33873),l=t(5194),n=t(57638),o=t(20503),d=t(47670),u=t(86041);e.exports=async function({database:e,social_id:a,email:t,social_platform:c,payload:_,invitation:m,supEmail:p,additionalFields:g,useLocal:E}){try{let S=[a.toString(),c],f=await n({database:e||"datasquirel",queryString:"SELECT * FROM users WHERE social_id = ? AND social_login='1' AND social_platform = ? ",queryValuesArray:S,useLocal:E});if(f&&f[0])return await u({user:f[0],social_platform:c,invitation:m,database:e,additionalFields:g,useLocal:E});let y=t||p||null;if(!y)return{success:!1,payload:null,msg:"No Email Present"};let b=`SELECT * FROM users WHERE email='${y}'`,D=await n({database:e||"datasquirel",queryString:b,useLocal:E});if(D&&D[0])return{success:!1,payload:null,msg:"This Email is already taken"};let h=[y,c,a],R=await n({database:e||"datasquirel",queryString:"SELECT * FROM users WHERE email=? AND social_login='1' AND social_platform=? AND social_id=?",queryValuesArray:h,useLocal:E});if(R&&R[0])return await u({user:_,social_platform:c,invitation:m,database:e,additionalFields:g,useLocal:E});let A=o({data:a.toString()}),v={social_login:"1",verification_status:p?"0":"1",password:A};Object.keys(_).forEach(e=>{v[e]=_[e]});let L=await d({dbContext:e?"Dsql User":void 0,paradigm:e?"Full Access":void 0,dbFullName:e||"datasquirel",tableName:"users",duplicateColumnName:"email",duplicateColumnValue:y,data:{...v,email:y},useLocal:E});if(!L?.insertId)return console.log("Social User Failed to insert in 'handleSocialDb.js' backend function =>",L),{success:!1,payload:null,msg:"Social User Failed to insert in 'handleSocialDb.js' backend function"};{e||await l({userId:L.insertId,useLocal:E});let a=`SELECT * FROM users WHERE id='${L.insertId}'`,t=await n({database:e||"datasquirel",queryString:a,useLocal:E});if(!t||!t[0])return{success:!1,payload:null,msg:"User Insertion Failed!"};if(p&&e?.match(/^datasquirel$/)){let e=o({data:JSON.stringify({id:L.insertId,email:p,dateCode:Date.now()})});r({to:p,subject:"Verify Email Address",text:"Please click the link to verify your email address",html:s.readFileSync("./email/send-email-verification-link.html","utf8").replace(/{{host}}/,process.env.DSQL_HOST||"").replace(/{{token}}/,e||"")}).then(e=>{})}let d=process.env.DSQL_STATIC_SERVER_DIR;if(!d)return console.log("Static File ENV not Found!"),{success:!1,payload:null,msg:"Static File ENV not Found!"};if(!e||e?.match(/^datasquirel$/)){let e=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${L.insertId}`,a=i.join(d,`images/user-images/user-${L.insertId}`);s.mkdirSync(e),s.mkdirSync(a),s.writeFileSync(`${e}/main.json`,JSON.stringify([]),"utf8")}return await u({user:t[0],social_platform:c,invitation:m,database:e,additionalFields:g,useLocal:E})}}catch(e){return console.log("ERROR in 'handleSocialDb.js' backend function =>",e.message),{success:!1,payload:null,msg:e.message}}}},86041:(e,a,t)=>{let s=t(44767),{ServerResponse:r}=t(81630),i=t(57638);async function l({user:e,social_platform:a,invitation:t,database:r,additionalFields:l,useLocal:n}){let o=[e.email,e.social_id,a],d=await i({database:r||"datasquirel",queryString:"SELECT * FROM users WHERE email=? AND social_id=? AND social_platform=?",queryValuesArray:o,useLocal:n});if(!d?.[0])return{success:!1,payload:null};let u=Math.random().toString(36).substring(2)+"-"+Math.random().toString(36).substring(2),c={id:d[0].id,first_name:d[0].first_name,last_name:d[0].last_name,username:d[0].username,user_type:d[0].user_type,email:d[0].email,social_id:d[0].social_id,image:d[0].image,image_thumbnail:d[0].image_thumbnail,verification_status:d[0].verification_status,social_login:d[0].social_login,social_platform:d[0].social_platform,csrf_k:u,logged_in_status:!0,date:Date.now()};return l?.[0]&&l.forEach(e=>{c[e]=d[0][e]}),t&&(!r||r?.match(/^datasquirel$/))&&s({query:t,user:c,useLocal:n}),{success:!0,payload:c,csrf:u}}t(20503),t(31341),e.exports=l},44767:(e,a,t)=>{let s=t(48225),r=t(51348),i=t(47670),l=t(44900);e.exports=async function({query:e,us
Error Message: ${a}
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(r+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),i?.url&&(r+=`
URL: ${i.url}`),i?.body&&(r+=`
Request Body: ${JSON.stringify(i.body,null,4)}`),n&&(r+=`
IP: ${n}`),r+=`
Date: ${l.toDateString()}
========================================`,s.existsSync("./.tmp/error.log")||s.writeFileSync("./.tmp/error.log","","utf-8");let o=s.readFileSync("./.tmp/error.log","utf-8");s.writeFileSync("./.tmp/error.log",r),s.appendFileSync("./.tmp/error.log",`
${o}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},57638:(e,a,t)=>{t(29021);let s=t(6061),r=t(48225),i=t(51348),l=t(21339),n=t(44900);e.exports=async function({queryString:e,queryValuesArray:a,database:t,tableSchema:o,useLocal:d}){let u;let c=!!t?.match(/^datasquirel$/),_=d?n:c?i:l;try{u=e&&a&&Array.isArray(a)&&a[0]?c?await _(e,a):await _({paradigm:"Full Access",database:t,queryString:e,queryValues:a}):c?await _(e):await _({paradigm:"Full Access",database:t,queryString:e})}catch(e){r({component:"varDatabaseDbHandler/lines-29-32",message:e.message})}if(u&&o)try{let e=u;return await s({unparsedResults:e,tableSchema:o})}catch(e){return console.log("\x1b[31mvarDatabaseDbHandler ERROR\x1b[0m =>",t,e),r({component:"varDatabaseDbHandler/lines-52-53",message:e.message}),null}else if(u)return u;else return null}},72835:(e,a,t)=>{let{scryptSync:s,createDecipheriv:r}=t(55511),{Buffer:i}=t(79428);e.exports=({encryptedString:e,encryptionKey:a,encryptionSalt:t})=>{if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let l=a||process.env.DSQL_ENCRYPTION_PASSWORD,n=t||process.env.DSQL_ENCRYPTION_SALT,o=process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24;if(!l?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!n?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let d=r("aes-192-cbc",s(l,n,o),i.alloc(16,0));try{let a=d.update(e,"hex","utf8");return a+=d.final("utf8")}catch(a){return console.log("Error in decrypting =>",a.message),e}}},45356:(e,a,t)=>{let s=t(9973),r=t(21580),i=s({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,charset:"utf8mb4",ssl:r()}});e.exports=function(...e){try{return new Promise((a,t)=>{i.query(...e).then(e=>{i.end(),a(JSON.parse(JSON.stringify(e)))}).catch(e=>{i.end(),a({error:e.message,sql:e.sql})})})}catch(e){return{success:!1,error:e.message}}}}};