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

16 lines
11 KiB
JavaScript
Raw Normal View History

2025-01-14 15:27:08 +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:f}){try{let y=[a.toString(),s],E=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:f});if(E&&E[0])return await _({user:E[0],social_platform:s,invitation:m,database:e,additionalFields:p,useLocal:f});let A=t||g||null;if(!A)return{success:!1,payload:null,msg:"No Email Present"};let S=`SELECT * FROM datasquirel.users WHERE email='${A}'`,b=await (0,d.A)({database:e||"datasquirel",queryString:S,useLocal:f});if(b&&b[0])return{success:!1,payload:null,msg:"This Email is already taken"};let h=[A,s,a],D=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:h,useLocal:f});if(D&&D[0])return await _({user:l,social_platform:s,invitation:m,database:e,additionalFields:p,useLocal:f});let v=(0,u.A)({data:a.toString()}),R={social_login:"1",verification_status:g?"0":"1",password:v};Object.keys(l).forEach(e=>{R[e]=l[e]});let L=await (0,c.A)({dbContext:e?"Dsql User":void 0,paradigm:e?"Full Access":void 0,dbFullName:e||"datasquirel",tableName:"users",duplicateColumnName:"email",duplicateColumnValue:A,data:{...R,email:A},useLocal:f});if(!L?.insertId)return console.log("Social User Failed to insert in 'handleSocialDb.ts' backend function =>",L),{success:!1,payload:null,msg:"Social User Failed to insert in 'handleSocialDb.ts' backend function"};{e||await (0,o.A)({userId:L.insertId,useLocal:f});let a=`SELECT * FROM datasquirel.users WHERE id='${L.insertId}'`,t=await (0,d.A)({database:e||"datasquirel",queryString:a,useLocal:f});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:L.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-${L.insertId}`,a=n().join(l,`images/user-images/user-${L.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:f})}}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 15:27:08 +00:00
${o}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},30944:(e,a,t)=>{t.d(a,{A:()=>n});var s=t(43775),r=t(67619),i=t(7447),l=t(64292);async function n({queryString:e,queryValuesArray:a,database:t,tableSchema:n,useLocal:o,debug:d}){let u=(0,i.A)({fa:!0});o&&(u=(0,i.A)({local:!0})),t?.match(/^datasquirel$/)&&(u=(0,i.A)()),d&&(console.log("varDatabaseDbHandler:query:",e),console.log("varDatabaseDbHandler:values:",a));let c=await (0,l.A)(u,e,a);if(d&&console.log("varDatabaseDbHandler:results:",c),c&&n)try{return await (0,s.A)({unparsedResults:c,tableSchema:n})}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(c)return c;else return null}},95969:(e,a,t)=>{t.d(a,{A:()=>l});var s=t(55511),r=t(79428),i=t(32443);function l({encryptedString:e,encryptionKey:a,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let{key:l,salt:n,keyLen:o,algorithm:d,bufferAllocSize:u}=(0,i.A)({encryptionKey:a});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 c=(0,s.scryptSync)(l,n,o),m=r.Buffer.alloc(u,0),_=(0,s.createDecipheriv)(d,c,m);try{let a=_.update(e,"hex","utf8");return a+=_.final("utf8")}catch(a){return console.log("Error in decrypting =>",a.message),e}}},47546:(e,a,t)=>{t.d(a,{A:()=>r});var s=t(7447);function r(...e){let a=(0,s.A)();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}}finally{a?.end()}}}};