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

16 lines
11 KiB
JavaScript
Raw Normal View History

2025-01-14 06:42:13 +00:00
"use strict";exports.id=3704,exports.ids=[3704],exports.modules={83704:(e,a,t)=>{t.d(a,{A:()=>g});var s=t(29021),r=t.n(s),i=t(96052),l=t(33873),n=t.n(l),o=t(67580),d=t(30944),u=t(68829),c=t(98e3),m=t(49941);async function _({user:e,social_platform:a,invitation:t,database:s,additionalFields:r,useLocal:i}){let l=s||"datasquirel",n=`SELECT * FROM \`${l}\`.\`users\` WHERE email=? AND social_id=? AND social_platform=?`,o=[e.email,e.social_id,a],u=await (0,d.A)({database:l,queryString:n,queryValuesArray:o,useLocal:i});if(!u?.[0])return{success:!1,payload:null};let c=Math.random().toString(36).substring(2)+"-"+Math.random().toString(36).substring(2),_={id:u[0].id,first_name:u[0].first_name,last_name:u[0].last_name,username:u[0].username,user_type:u[0].user_type,email:u[0].email,social_id:u[0].social_id,image:u[0].image,image_thumbnail:u[0].image_thumbnail,verification_status:u[0].verification_status,social_login:u[0].social_login,social_platform:u[0].social_platform,csrf_k:c,logged_in_status:!0,date:Date.now()};return r?.[0]&&r.forEach(e=>{_[e]=u[0][e]}),t&&(!s||s?.match(/^datasquirel$/))&&(0,m.A)({query:t,user:_,useLocal:i}),{success:!0,payload:_,csrf:c}}async function g({database:e,social_id:a,email:t,social_platform:s,payload:l,invitation:m,supEmail:g,additionalFields:p,useLocal:E}){try{let y=[a.toString(),s],A=await (0,d.A)({database:e||"datasquirel",queryString:"SELECT * FROM datasquirel.users WHERE social_id = ? AND social_login='1' AND social_platform = ? ",queryValuesArray:y,useLocal:E});if(A&&A[0])return await _({user:A[0],social_platform:s,invitation:m,database:e,additionalFields:p,useLocal:E});let S=t||g||null;if(!S)return{success:!1,payload:null,msg:"No Email Present"};let f=`SELECT * FROM datasquirel.users WHERE email='${S}'`,b=await (0,d.A)({database:e||"datasquirel",queryString:f,useLocal:E});if(b&&b[0])return{success:!1,payload:null,msg:"This Email is already taken"};let D=[S,s,a],h=await (0,d.A)({database:e||"datasquirel",queryString:"SELECT * FROM datasquirel.users WHERE email=? AND social_login='1' AND social_platform=? AND social_id=?",queryValuesArray:D,useLocal:E});if(h&&h[0])return await _({user:l,social_platform:s,invitation:m,database:e,additionalFields:p,useLocal:E});let R=(0,u.A)({data:a.toString()}),v={social_login:"1",verification_status:g?"0":"1",password:R};Object.keys(l).forEach(e=>{v[e]=l[e]});let N=await (0,c.A)({dbContext:e?"Dsql User":void 0,paradigm:e?"Full Access":void 0,dbFullName:e||"datasquirel",tableName:"users",duplicateColumnName:"email",duplicateColumnValue:S,data:{...v,email:S},useLocal:E});if(!N?.insertId)return console.log("Social User Failed to insert in 'handleSocialDb.ts' backend function =>",N),{success:!1,payload:null,msg:"Social User Failed to insert in 'handleSocialDb.ts' backend function"};{e||await (0,o.A)({userId:N.insertId,useLocal:E});let a=`SELECT * FROM datasquirel.users WHERE id='${N.insertId}'`,t=await (0,d.A)({database:e||"datasquirel",queryString:a,useLocal:E});if(!t||!t[0])return{success:!1,payload:null,msg:"User Insertion Failed!"};if(g&&e?.match(/^datasquirel$/)){let e=(0,u.A)({data:JSON.stringify({id:N.insertId,email:g,dateCode:Date.now()})});(0,i.A)({to:g,subject:"Verify Email Address",text:"Please click the link to verify your email address",html:r().readFileSync("./email/send-email-verification-link.html","utf8").replace(/{{host}}/,process.env.DSQL_HOST||"").replace(/{{token}}/,e||"")}).then(()=>{})}let l=process.env.DSQL_STATIC_SERVER_DIR;if(!l)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-${N.insertId}`,a=n().join(l,`images/user-images/user-${N.insertId}`);r().mkdirSync(e),r().mkdirSync(a),r().writeFileSync(`${e}/main.json`,JSON.stringify([]),"utf8")}return await _({user:t[0],social_platform:s,invitation:m,database:e,additionalFields:p,useLocal:E})}}catch(e){return console.log("ERROR in 'handleSocialDb.ts' backend function =>",e.message),{success:!1,payload:null,msg:e.message}}}},49941:(e,a,t)=>{t.d(a,{A:()=
2025-01-13 08:00:21 +00:00
Error Message: ${a}
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(s+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),i?.url&&(s+=`
URL: ${i.url}`),i?.body&&(s+=`
Request Body: ${JSON.stringify(i.body,null,4)}`),n&&(s+=`
IP: ${n}`),s+=`
Date: ${l.toDateString()}
2025-01-14 06:42:13 +00:00
========================================`,r().existsSync("./.tmp/error.log")||r().writeFileSync("./.tmp/error.log","","utf-8");let o=r().readFileSync("./.tmp/error.log","utf-8");r().writeFileSync("./.tmp/error.log",s),r().appendFileSync("./.tmp/error.log",`
2025-01-13 08:00:21 +00:00
2025-01-14 06:42:13 +00:00
${o}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},30944:(e,a,t)=>{t.d(a,{A:()=>o});var s=t(43775),r=t(67619),i=t(48786),l=t(37275),n=t(7971);async function o({queryString:e,queryValuesArray:a,database:t,tableSchema:o,useLocal:d}){let u;let c=!!d||!!t?.match(/^datasquirel$/),m=d?n.A:c?i.A:l.A;try{u=e&&a&&Array.isArray(a)&&a[0]?c?await m(e,a):await m({paradigm:"Full Access",queryString:e,queryValues:a}):c?await m(e):await m({paradigm:"Full Access",queryString:e})}catch(e){console.log(`varDatabaseDbHandler Error: ${e.message}`),(0,r.A)({component:"varDatabaseDbHandler/lines-29-32",message:e.message})}if(u&&o)try{let e=u;return await (0,s.A)({unparsedResults:e,tableSchema:o})}catch(e){return console.log("\x1b[31mvarDatabaseDbHandler ERROR\x1b[0m =>",t,e),(0,r.A)({component:"varDatabaseDbHandler/lines-52-53",message:e.message}),null}else if(u)return u;else return null}},95969:(e,a,t)=>{t.d(a,{A:()=>i});var s=t(55511),r=t(79428);function i({encryptedString:e,encryptionKey:a,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let i=a||process.env.DSQL_ENCRYPTION_PASSWORD,l=t||process.env.DSQL_ENCRYPTION_SALT,n=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(!l?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let o=(0,s.scryptSync)(i,l,n),d=r.Buffer.alloc(16,0),u=(0,s.createDecipheriv)("aes-192-cbc",o,d);try{let a=u.update(e,"hex","utf8");return a+=u.final("utf8")}catch(a){return console.log("Error in decrypting =>",a.message),e}}},47546:(e,a,t)=>{t.d(a,{A:()=>s});function s(...e){let a=global.DSQL_DB_CONN;try{return new Promise((t,s)=>{a.query(...e).then(e=>{a.end(),t(JSON.parse(JSON.stringify(e)))}).catch(e=>{a.end(),t({error:e.message,sql:e.sql})})})}catch(e){return{success:!1,error:e.message}}}}};