16 lines
10 KiB
JavaScript
16 lines
10 KiB
JavaScript
![]() |
"use strict";exports.id=2984,exports.ids=[2984],exports.modules={96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){return function e(r,t){return t in r?r[t]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,t)):"function"==typeof r&&"default"===t?r:void 0}}})},31495:(e,r,t)=>{t.d(r,{A:()=>s});var n=t(48786),o=t(67619);async function s({user:e,confirmedDelegetedUser:r,database:t,table:s,priviledgeRegex:a,dbId:l}){let i,c;try{r?.delegated?(i=await (0,n.A)("SELECT priviledge FROM delegated_user_tables WHERE root_user_id=? AND delegated_user_id=? AND `database`=? AND `table`=?",[r.rootUserId,e.id,t,s]),c=i[0]?.priviledge?.match(a)):(i=await (0,n.A)("SELECT table_slug FROM user_database_tables WHERE user_id=? AND table_slug=? AND db_id=?",[e.id,s,l]),c=!0)}catch(r){(0,o.A)({component:"checkUserRights",message:r.message,user:e})}return!!i&&!!i[0]&&!!c}},60125:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(95969);async function o({request:e,databaseSlug:r,user:t,query:o}){try{let s=t.id,a=null;if(!o?.delegated)return{dbUserId:s};let l=o.dbUserId,i=`${process.env.DSQL_USER_DB_PREFIX}${l}_${r}`,c=`${process.env.DSQL_USER_DELEGATED_DB_COOKIE_PREFIX}${i}`;try{if(!e.cookies?.[c])throw Error("Cookie not present");let t=(0,n.A)({encryptedString:e.cookies[c]});if(!t)throw Error("Invalid Token");if((a=JSON.parse(t)).databaseSlug===r)return{dbUserId:s=a.rootUserId,rootUserId:a.rootUserId,rootUserName:a.rootUserName,rootUserEmail:a.rootUserEmail,rootUserImage:a.rootUserImage,databaseFullName:a.databaseFullName,databaseSlug:a.databaseSlug,allowedTables:a.allowedTables,priviledges:a.priviledges,database:a.databaseSlug,delegated:!0}}catch(e){}return{dbUserId:s}}catch(e){return null}}},41520:(e,r,t)=>{t.d(r,{A:()=>a});var n=t(64292),o=t(7447);async function s({paradigm:e,queryString:r,queryValues:t}){let s="Read Only"==e?(0,o.A)({ro:!0}):(0,o.A)({fa:!0});try{return await (0,n.A)(s,r,t)}catch(e){return console.log(`DSQL_USER_DB_HANDLER Error: ${e.message}`),null}finally{s?.end()}}async function a({dbName:e,entryId:r,entryOrder:t,tableName:n,tableSchema:o}){try{if(o.fields.find(e=>!!e.fieldName?.match(/^order$/i))&&t){let e=await s({paradigm:"Full Access",queryString:`SELECT * FROM ${n} WHERE \`order\` = '${t}' AND id != ?`,queryValues:[String(r)]});if(!e?.[0])throw Error("No Existing Order");await s({paradigm:"Full Access",queryString:`UPDATE ${n} SET \`order\` = \`order\` + 1 WHERE \`order\` >= ${t} AND id != ?`,queryValues:[String(r)]})}return!0}catch(e){return!1}}},69842:(e,r,t)=>{async function n(e,r,t){return Object(function(){var e=Error("Cannot find module '@moduletrace/datasquirel/dist/users/user-auth'");throw e.code="MODULE_NOT_FOUND",e}())({req:e,level:t?"deep":void 0}).payload}t.d(r,{A:()=>n}),function(){var e=Error("Cannot find module '@moduletrace/datasquirel/dist/users/user-auth'");throw e.code="MODULE_NOT_FOUND",e}()},30802:(e,r,t)=>{t.d(r,{A:()=>c});var n=t(72583),o=t.n(n),s=t(92652),a=t(68829),l=t(52939),i=t(64292);async function c({dbContext:e,dbFullName:r,tableName:t,data:n,tableSchema:c,identifierColumnName:u,identifierValue:d,encryptionKey:_,encryptionSalt:S}){if(!n||!Object.keys(n).length)return null;let p=(0,l.A)({dbContext:e,dbFullName:r}),D=p?global.DSQL_DB_CONN:global.DSQL_FULL_ACCESS_DB_CONN||global.DSQL_DB_CONN;p?global.DSQL_DB_CONN:global.DSQL_READ_ONLY_DB_CONN||global.DSQL_DB_CONN;let g=Object.keys(n),f=[],E=[];for(let e=0;e<g.length;e++)try{let r=g[e],t=n[r],l=c?c?.fields?.filter(e=>e.fieldName===r):null,i=l&&l[0]?l[0]:null;if(null==t||void 0==t)continue;let u=/<[^>]+>/g;(i?.richText||String(t).match(u))&&(t=o()(t,s.A)),i?.encrypted&&(t=(0,a.A)({data:t,encryptionKey:_,encryptionSalt:S})),"object"==typeof t&&(t=JSON.stringify(t)),i?.pattern&&!new RegExp(i.pattern,i.patternFlags||"").test(t)&&(console.log("DSQL: Pattern not matched =>",t),t=""),"string"==typeof t&&t.match(/^null$/i)&&(t={toSqlString:function(){return"NULL"}}),"string"!=typeof t||t.match(/./i)||(t={toSqlString:function(){return"NULL"}}),f.push(`\`${r}\`=?`),"number"==typeof t?E.push(String(t)):E.push(t)}catch(e){console.log("DSQL: Error
|
||
|
Error Message: ${r}
|
||
|
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(n+=`
|
||
|
User Id: ${e?.id}
|
||
|
User Name: ${e?.first_name} ${e?.last_name}
|
||
|
User Email: ${e?.email}`),s?.url&&(n+=`
|
||
|
URL: ${s.url}`),s?.body&&(n+=`
|
||
|
Request Body: ${JSON.stringify(s.body,null,4)}`),l&&(n+=`
|
||
|
IP: ${l}`),n+=`
|
||
|
Date: ${a.toDateString()}
|
||
|
========================================`,o().existsSync("./.tmp/error.log")||o().writeFileSync("./.tmp/error.log","","utf-8");let i=o().readFileSync("./.tmp/error.log","utf-8");o().writeFileSync("./.tmp/error.log",n),o().appendFileSync("./.tmp/error.log",`
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
${i}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},95969:(e,r,t)=>{t.d(r,{A:()=>a});var n=t(55511),o=t(79428),s=t(32443);function a({encryptedString:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encrypted string is invalid"),e;let{key:a,salt:l,keyLen:i,algorithm:c,bufferAllocSize:u}=(0,s.A)({encryptionKey:r});if(!a?.match(/.{8,}/))return console.log("Decrption key is invalid"),e;if(!l?.match(/.{8,}/))return console.log("Decrption salt is invalid"),e;let d=(0,n.scryptSync)(a,l,i),_=o.Buffer.alloc(u,0),S=(0,n.createDecipheriv)(c,d,_);try{let r=S.update(e,"hex","utf8");return r+=S.final("utf8")}catch(r){return console.log("Error in decrypting =>",r.message),e}}},68829:(e,r,t)=>{t.d(r,{A:()=>a});var n=t(55511),o=t(79428),s=t(32443);function a({data:e,encryptionKey:r,encryptionSalt:t}){if(!e?.match(/./))return console.log("Encryption string is invalid"),e;let{key:a,salt:l,keyLen:i,algorithm:c,bufferAllocSize:u}=(0,s.A)({encryptionKey:r});if(!a?.match(/.{8,}/))return console.log("Encryption key is invalid"),e;if(!l?.match(/.{8,}/))return console.log("Encryption salt is invalid"),e;let d=(0,n.scryptSync)(a,l,i),_=o.Buffer.alloc(u,0),S=(0,n.createCipheriv)(c,d,_);try{let r=S.update(e,"utf8","hex");return r+=S.final("hex")}catch(r){return console.log("Error in encrypting =>",r.message),e}}},48786:(e,r,t)=>{t.d(r,{A:()=>o});var n=t(7447);async function o(...e){let r=(0,n.A)();try{if(!r)throw Error("No Connection provided to DB_HANDLER function!");let t=await r.query(...e);return JSON.parse(JSON.stringify(t))}catch(e){return console.log("DB Error =>",e),{success:!1,error:e.message}}finally{await r?.end()}}},52939:(e,r,t)=>{t.d(r,{A:()=>n});function n({dbContext:e,dbFullName:r}){return!e?.match(/dsql.user/i)&&(!!global.DSQL_USE_LOCAL||!r||!!r.match(/^datasquirel$/))}},64292:(e,r,t)=>{async function n(e,r,t){try{if(!e)throw Error("No Connection Found!");if(!r)throw Error("Query String Required!");if("string"==typeof r){let n=await e.query(o(r),t);return JSON.parse(JSON.stringify(n))}if("object"!=typeof r)return null;{let t=[];for(let n=0;n<r.length;n++)try{let s=r[n],a=await e.query(o(s.query),s.values);t.push(JSON.parse(JSON.stringify(a)))}catch(e){console.log(`connDbHandler Query Error: ${e.message}`),t.push(null)}return t}}catch(e){return console.log(`connDbHandler Error: ${e.message}`),null}finally{e?.end()}}function o(e){return e.replace(/\n/gm,"").replace(/ {2,}/g,"").trim()}t.d(r,{A:()=>n})},7447:(e,r,t)=>{t.d(r,{A:()=>s});var n=t(9973),o=t.n(n);function s(e){return global.DSQL_USE_LOCAL||e?.local?global.DSQL_DB_CONN||o()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.ro?global.DSQL_READ_ONLY_DB_CONN||o()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_READ_ONLY_USERNAME,password:process.env.DSQL_DB_READ_ONLY_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):e?.fa?global.DSQL_FULL_ACCESS_DB_CONN||o()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_FULL_ACCESS_USERNAME,password:process.env.DSQL_DB_FULL_ACCESS_PASSWORD,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}}):global.DSQL_DB_CONN||o()({config:{host:process.env.DSQL_DB_HOST,user:process.env.DSQL_DB_USERNAME,password:process.env.DSQL_DB_PASSWORD,database:e?.noDb?void 0:process.env.DSQL_DB_NAME,port:process.env.DSQL_DB_PORT?Number(process.env.DSQL_DB_PORT):void 0,charset:"utf8mb4"}})}},32443:(e,r,t)=>{t.d(r,{A:()=>n});function n(e){return{key:e?.encryptionKey||process.env.DSQL_ENCRYPTION_PASSWORD,keyLen:process.env.DSQL_ENCRYPTION_KEY_LENGTH?Number(process.env.DSQL_ENCRYPTION_KEY_LENGTH):24,salt:e?.encryptionSalt||process.env.DSQL_ENCRYPTION_SALT,apiKey:e?.apiKey||process.env.DSQL_API_KEY,algorithm:e?.algorithm||process.env.DSQL_ENCRYPTION_ALGORITHM||"aes-192-cbc",bufferAllocSize:e?.bufferAllocSize
|