This commit is contained in:
2026-03-12 14:56:39 +01:00
parent 97b135c352
commit 65d1a4fd18
105 changed files with 293 additions and 274 deletions
+6
View File
@@ -0,0 +1,6 @@
"use strict";(()=>{var e={};e.id=204,e.ids=[204],e.modules={8804:e=>{e.exports=require("@moduletrace/nsqlite")},1635:e=>{e.exports=require("dayjs")},145:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},6249:(e,t)=>{Object.defineProperty(t,"l",{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}}})},7541:(e,t,r)=>{r.r(t),r.d(t,{config:()=>g,default:()=>h,routeModule:()=>_});var s={};r.r(s),r.d(s,{default:()=>p});var n=r(1802),i=r(7153),u=r(6249),o=r(2632),a=r(2253),d=r(2481),c=r(8804),l=r.n(c),f=r(1282);async function m({user_id:e}){let t=(await l().select({table:"users",targetId:(0,a._n)(e)})).singleRes;if(!t?.id||!t.username||t.is_super_admin)return;let{username:r}=t;console.log("username",r);let{force_command_file:s,sshd_config_file:n}=(0,d.Z)({user:t}),i=`/bin/bash << 'TURBOCIHEREDOC'
`;i+=`deluser --remove-all-files ${r} || echo "User Deleted!"
rm -f ${s}
rm -f ${n}
TURBOCIHEREDOC
`,(0,f.execSync)(i),l().delete({table:"users",targetId:t.id})}async function p(e,t){try{if("POST"!==e.method)return t.json({success:!1,msg:"Wrong Method"});let{singleRes:r}=await (0,o.Z)({req:e});if(!r?.id||!r.super_admin)return t.json({success:!1,msg:"Unauthorized"});let{user_id:s}=e.body;if((0,a._n)(s)==r.id)throw Error("Can't delete root user!");return await m({user_id:(0,a._n)(s)}),t.json({success:!0})}catch(e){return t.json({success:!1,msg:e.message})}}let h=(0,u.l)(s,"default"),g=(0,u.l)(s,"config"),_=new n.PagesAPIRouteModule({definition:{kind:i.x.PAGES_API,page:"/api/admin/delete-user",pathname:"/api/admin/delete-user",bundlePath:"",filename:""},userland:s})},2253:(e,t,r)=>{r.d(t,{dF:()=>u(),_n:()=>c,lV:()=>a()});let s=require("@moduletrace/datasquirel/dist/client");var n=r.n(s);let i=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson");var u=r.n(i);let o=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify");var a=r.n(o);let d=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy"),c=r.n(d)();n().utils.serializeQuery,n().utils.deserializeQuery},6941:(e,t,r)=>{function s(e,t){let r=[];for(let e=0;e<t.length;e++){let{name:s,options:n,value:i}=t[e],u=[`${encodeURIComponent(s)}=${encodeURIComponent(i)}`];n.expires&&u.push(`Expires=${n.expires.toDate().toUTCString()}`),void 0!==n.maxAge&&u.push(`Max-Age=${n.maxAge}`),n.path&&u.push(`Path=${n.path}`),n.domain&&u.push(`Domain=${n.domain}`),n.secure&&u.push("Secure"),n.httpOnly&&u.push("HttpOnly"),r.push(u)}let s=r.map(e=>e.join("; "));e.setHeader("Set-Cookie",s)}function n(e,t){return e.split(";").reduce((e,t)=>{let[r,s]=t.trim().split("=").map(decodeURIComponent);return e[r]=s,e},{})[t]||null}r.d(t,{d8:()=>s,ej:()=>n}),r(1635)},9786:(e,t,r)=>{r.d(t,{Z:()=>u});var s=r(2048);let n=require("path");var i=r.n(n);function u(){let{TURBOCI_DEPLOYMENT_ID_FILE:e}=function(){let e=i().resolve(__dirname,"../../"),t="/root/.turboci",r=i().join(t,".config"),s=i().join(r,"turboci.json"),n=i().join(t,"deployment_id"),u=i().join(t,".ssh"),o=i().join(u,"turboci");return{APP_DIR:e,TURBOCI_CONFIG_DIR:r,TURBOCI_CONFIG_JSON_FILE:s,TURBOCI_DIR:t,TURBOCI_SSH_DIR:u,TURBOCI_SSH_KEY_FILE:o,TURBOCI_DEPLOYMENT_ID_FILE:n}}();if(!(0,s.existsSync)(e))throw Error(`\`${e}\` does not exist.`);let t=(0,s.readFileSync)(e,"utf-8").split("-").shift();if(!t)throw Error("Invalid deployment_id");return{auth_key_cookie_name:`turboci-admin-${t}-auth-key`,csrf_cookie_name:`turboci-admin-${t}-csrf`}}},2481:(e,t,r)=>{r.d(t,{Z:()=>s});function s({user:e}){let{username:t}=e,r=`/home/${t}`,s=`${r}/.ssh`,n=`${s}/${t}`;return{user_dir:r,ssh_dir:s,ssh_key_file:n,sshd_config_file:`/etc/ssh/sshd_config.d/${t}.conf`,force_command_file:`/usr/local/bin/turboci-deployment-user-${t}`}}},2632:(e,t,r)=>{r.d(t,{Z:()=>a});var s=r(6941);let n=require("@moduletrace/datasquirel/dist/package-shared/functions/dsql/decrypt");var i=r.n(n),u=r(2253),o=r(9786);async function a({req:e,bun_req:t}){try{let{auth_key_cookie_name:r,csrf_cookie_name:n}=(0,o.Z)(),a=e?.headers.cookie||t?.headers.get("cookie");if(!a)return{success:!1,msg:"Couldn't grab cookie string"};let d=(0,s.ej)(a,r);if(!d)return{success:!1,msg:`No ${r} found in request object.`};let c=i()({encryptedString:d}),l=u.dF.parse(c);if(!l?.id)return{success:!1,msg:"Invalid Auth Key"};let f=(0,s.ej)(a,n);if(!f)return{success:!1,msg:`No ${n} found in request object.`};if(f!==l.csrf_k)return{success:!1,msg:"CSRF mismatch"};return{success:!0,singleRes:l}}catch(e){return{success:!1}}}},7153:(e,t)=>{var r;Object.defineProperty(t,"x",{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"}(r||(r={}))},1802:(e,t,r)=>{e.exports=r(145)}};var t=require("../../../webpack-api-runtime.js");t.C(e);var r=t(t.s=7541);module.exports=r})();
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
"use strict";(()=>{var e={};e.id=482,e.ids=[482],e.modules={8804:e=>{e.exports=require("@moduletrace/nsqlite")},1635:e=>{e.exports=require("dayjs")},145:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},2048:e=>{e.exports=require("fs")},6249:(e,t)=>{Object.defineProperty(t,"l",{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}}})},4441:(e,t,r)=>{r.r(t),r.d(t,{config:()=>m,default:()=>p,routeModule:()=>f});var i={};r.r(i),r.d(i,{default:()=>c});var s=r(1802),n=r(7153),u=r(6249),a=r(2632),o=r(8804),d=r.n(o),l=r(2048);async function c(e,t){try{let{singleRes:r}=await (0,a.Z)({req:e});if(!r?.id||!r.super_admin)return t.json({success:!1,msg:"Unauthorized"});let{user_id:i}=e.query,s=(await d().select({table:"users",targetId:i})).singleRes;if(!s?.username)throw Error("Couldn't grab user");let n=`/home/${s.username}/.ssh/${s.username}`;if(!(0,l.existsSync)(n))throw Error("No Private SSH key file found");(0,l.createReadStream)(n).pipe(t)}catch(e){return t.json({success:!1,msg:e.message})}}let p=(0,u.l)(i,"default"),m=(0,u.l)(i,"config"),f=new s.PagesAPIRouteModule({definition:{kind:n.x.PAGES_API,page:"/api/admin/download-private-ssh-key",pathname:"/api/admin/download-private-ssh-key",bundlePath:"",filename:""},userland:i})},2253:(e,t,r)=>{r.d(t,{dF:()=>u(),_n:()=>l,lV:()=>o()});let i=require("@moduletrace/datasquirel/dist/client");var s=r.n(i);let n=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson");var u=r.n(n);let a=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify");var o=r.n(a);let d=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy"),l=r.n(d)();s().utils.serializeQuery,s().utils.deserializeQuery},6941:(e,t,r)=>{function i(e,t){let r=[];for(let e=0;e<t.length;e++){let{name:i,options:s,value:n}=t[e],u=[`${encodeURIComponent(i)}=${encodeURIComponent(n)}`];s.expires&&u.push(`Expires=${s.expires.toDate().toUTCString()}`),void 0!==s.maxAge&&u.push(`Max-Age=${s.maxAge}`),s.path&&u.push(`Path=${s.path}`),s.domain&&u.push(`Domain=${s.domain}`),s.secure&&u.push("Secure"),s.httpOnly&&u.push("HttpOnly"),r.push(u)}let i=r.map(e=>e.join("; "));e.setHeader("Set-Cookie",i)}function s(e,t){return e.split(";").reduce((e,t)=>{let[r,i]=t.trim().split("=").map(decodeURIComponent);return e[r]=i,e},{})[t]||null}r.d(t,{d8:()=>i,ej:()=>s}),r(1635)},9786:(e,t,r)=>{r.d(t,{Z:()=>u});var i=r(2048);let s=require("path");var n=r.n(s);function u(){let{TURBOCI_DEPLOYMENT_ID_FILE:e}=function(){let e=n().resolve(__dirname,"../../"),t="/root/.turboci",r=n().join(t,".config"),i=n().join(r,"turboci.json"),s=n().join(t,"deployment_id"),u=n().join(t,".ssh"),a=n().join(u,"turboci");return{APP_DIR:e,TURBOCI_CONFIG_DIR:r,TURBOCI_CONFIG_JSON_FILE:i,TURBOCI_DIR:t,TURBOCI_SSH_DIR:u,TURBOCI_SSH_KEY_FILE:a,TURBOCI_DEPLOYMENT_ID_FILE:s}}();if(!(0,i.existsSync)(e))throw Error(`\`${e}\` does not exist.`);let t=(0,i.readFileSync)(e,"utf-8").split("-").shift();if(!t)throw Error("Invalid deployment_id");return{auth_key_cookie_name:`turboci-admin-${t}-auth-key`,csrf_cookie_name:`turboci-admin-${t}-csrf`}}},2632:(e,t,r)=>{r.d(t,{Z:()=>o});var i=r(6941);let s=require("@moduletrace/datasquirel/dist/package-shared/functions/dsql/decrypt");var n=r.n(s),u=r(2253),a=r(9786);async function o({req:e,bun_req:t}){try{let{auth_key_cookie_name:r,csrf_cookie_name:s}=(0,a.Z)(),o=e?.headers.cookie||t?.headers.get("cookie");if(!o)return{success:!1,msg:"Couldn't grab cookie string"};let d=(0,i.ej)(o,r);if(!d)return{success:!1,msg:`No ${r} found in request object.`};let l=n()({encryptedString:d}),c=u.dF.parse(l);if(!c?.id)return{success:!1,msg:"Invalid Auth Key"};let p=(0,i.ej)(o,s);if(!p)return{success:!1,msg:`No ${s} found in request object.`};if(p!==c.csrf_k)return{success:!1,msg:"CSRF mismatch"};return{success:!0,singleRes:c}}catch(e){return{success:!1}}}},7153:(e,t)=>{var r;Object.defineProperty(t,"x",{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"}(r||(r={}))},1802:(e,t,r)=>{e.exports=r(145)}};var t=require("../../../webpack-api-runtime.js");t.C(e);var r=t(t.s=4441);module.exports=r})();
File diff suppressed because one or more lines are too long
+39
View File
@@ -0,0 +1,39 @@
"use strict";(()=>{var e={};e.id=837,e.ids=[837],e.modules={8804:e=>{e.exports=require("@moduletrace/nsqlite")},1635:e=>{e.exports=require("dayjs")},145:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},1282:e=>{e.exports=require("child_process")},2048:e=>{e.exports=require("fs")},6249:(e,t)=>{Object.defineProperty(t,"l",{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}}})},8635:(e,t,r)=>{r.r(t),r.d(t,{config:()=>p,default:()=>h,routeModule:()=>f});var s={};r.r(s),r.d(s,{default:()=>m});var n=r(1802),i=r(7153),o=r(6249),u=r(2632),a=r(8804),c=r.n(a),d=r(2253),l=r(246);async function m(e,t){try{if("POST"!==e.method)return t.json({success:!1,msg:"Wrong Method"});let{singleRes:r}=await (0,u.Z)({req:e});if(!r?.id||!r.super_admin)return t.json({success:!1,msg:"Unauthorized"});let{new_user:s,user_id:n}=e.body;if(!s)throw Error("No User Form Sent.");let{first_name:i,last_name:o,email:a,image:m,username:h}=s;if(!i?.match(/./))return t.json({success:!1,msg:"First name is required"});return await c().update({table:"users",targetId:(0,d._n)(n),data:{first_name:i,last_name:o,email:a,image:m,username:h}}),await (0,l.Z)({user_id:(0,d._n)(n)}),t.json({success:!0})}catch(e){return t.json({success:!1,msg:e.message})}}let h=(0,o.l)(s,"default"),p=(0,o.l)(s,"config"),f=new n.PagesAPIRouteModule({definition:{kind:i.x.PAGES_API,page:"/api/admin/edit-user",pathname:"/api/admin/edit-user",bundlePath:"",filename:""},userland:s})},2253:(e,t,r)=>{r.d(t,{dF:()=>o(),_n:()=>d,lV:()=>a()});let s=require("@moduletrace/datasquirel/dist/client");var n=r.n(s);let i=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson");var o=r.n(i);let u=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify");var a=r.n(u);let c=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy"),d=r.n(c)();n().utils.serializeQuery,n().utils.deserializeQuery},246:(e,t,r)=>{r.d(t,{Z:()=>c});var s=r(2253),n=r(2481),i=r(8804),o=r.n(i),u=r(1282),a=r(2048);async function c({user_id:e}){let t=(await o().select({table:"users",targetId:(0,s._n)(e)})).singleRes;if(!t?.id||!t.username||t.is_super_admin)return;let{username:r}=t,{force_command_file:i,ssh_dir:c,ssh_key_file:d,sshd_config_file:l,user_dir:m}=(0,n.Z)({user:t}),h=`/bin/bash << 'TURBOCIHEREDOC'
`;(0,a.existsSync)(m)||(h+=`useradd --create-home --shell /bin/bash --comment "TurboCI Deployment user ${r}" ${r}
passwd --lock "${r}"
mkdir -p "${c}"
ssh-keygen -t ed25519 -f "${d}" -N "" -C "${r}@$(hostname)"
cp "${d}.pub" "${c}/authorized_keys"
chown -R "${r}:${r}" "${c}"
chmod 700 "${c}"
chmod 600 "${d}"
chmod 644 "${d}.pub"
chmod 600 "${c}/authorized_keys"
`),h+=`cat << 'EOF' > ${i}
#!/bin/bash
case "$SSH_ORIGINAL_COMMAND" in
"shell")
exec /bin/bash
;;
*)
echo "Access denied."
exit 1
;;
esac
EOF
chmod +x ${i}
cat << 'EOF' > ${l}
Match User ${r}
PasswordAuthentication no
PubkeyAuthentication yes
AuthenticationMethods publickey
AllowTcpForwarding yes
X11Forwarding no
ForceCommand ${i}
PermitOpen localhost:80
PermitTTY no
EOF
TURBOCIHEREDOC
`,(0,u.execSync)(h)}},6941:(e,t,r)=>{function s(e,t){let r=[];for(let e=0;e<t.length;e++){let{name:s,options:n,value:i}=t[e],o=[`${encodeURIComponent(s)}=${encodeURIComponent(i)}`];n.expires&&o.push(`Expires=${n.expires.toDate().toUTCString()}`),void 0!==n.maxAge&&o.push(`Max-Age=${n.maxAge}`),n.path&&o.push(`Path=${n.path}`),n.domain&&o.push(`Domain=${n.domain}`),n.secure&&o.push("Secure"),n.httpOnly&&o.push("HttpOnly"),r.push(o)}let s=r.map(e=>e.join("; "));e.setHeader("Set-Cookie",s)}function n(e,t){return e.split(";").reduce((e,t)=>{let[r,s]=t.trim().split("=").map(decodeURIComponent);return e[r]=s,e},{})[t]||null}r.d(t,{d8:()=>s,ej:()=>n}),r(1635)},9786:(e,t,r)=>{r.d(t,{Z:()=>o});var s=r(2048);let n=require("path");var i=r.n(n);function o(){let{TURBOCI_DEPLOYMENT_ID_FILE:e}=function(){let e=i().resolve(__dirname,"../../"),t="/root/.turboci",r=i().join(t,".config"),s=i().join(r,"turboci.json"),n=i().join(t,"deployment_id"),o=i().join(t,".ssh"),u=i().join(o,"turboci");return{APP_DIR:e,TURBOCI_CONFIG_DIR:r,TURBOCI_CONFIG_JSON_FILE:s,TURBOCI_DIR:t,TURBOCI_SSH_DIR:o,TURBOCI_SSH_KEY_FILE:u,TURBOCI_DEPLOYMENT_ID_FILE:n}}();if(!(0,s.existsSync)(e))throw Error(`\`${e}\` does not exist.`);let t=(0,s.readFileSync)(e,"utf-8").split("-").shift();if(!t)throw Error("Invalid deployment_id");return{auth_key_cookie_name:`turboci-admin-${t}-auth-key`,csrf_cookie_name:`turboci-admin-${t}-csrf`}}},2481:(e,t,r)=>{r.d(t,{Z:()=>s});function s({user:e}){let{username:t}=e,r=`/home/${t}`,s=`${r}/.ssh`,n=`${s}/${t}`;return{user_dir:r,ssh_dir:s,ssh_key_file:n,sshd_config_file:`/etc/ssh/sshd_config.d/${t}.conf`,force_command_file:`/usr/local/bin/turboci-deployment-user-${t}`}}},2632:(e,t,r)=>{r.d(t,{Z:()=>a});var s=r(6941);let n=require("@moduletrace/datasquirel/dist/package-shared/functions/dsql/decrypt");var i=r.n(n),o=r(2253),u=r(9786);async function a({req:e,bun_req:t}){try{let{auth_key_cookie_name:r,csrf_cookie_name:n}=(0,u.Z)(),a=e?.headers.cookie||t?.headers.get("cookie");if(!a)return{success:!1,msg:"Couldn't grab cookie string"};let c=(0,s.ej)(a,r);if(!c)return{success:!1,msg:`No ${r} found in request object.`};let d=i()({encryptedString:c}),l=o.dF.parse(d);if(!l?.id)return{success:!1,msg:"Invalid Auth Key"};let m=(0,s.ej)(a,n);if(!m)return{success:!1,msg:`No ${n} found in request object.`};if(m!==l.csrf_k)return{success:!1,msg:"CSRF mismatch"};return{success:!0,singleRes:l}}catch(e){return{success:!1}}}},7153:(e,t)=>{var r;Object.defineProperty(t,"x",{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"}(r||(r={}))},1802:(e,t,r)=>{e.exports=r(145)}};var t=require("../../../webpack-api-runtime.js");t.C(e);var r=t(t.s=8635);module.exports=r})();
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
"use strict";(()=>{var e={};e.id=908,e.ids=[908],e.modules={5529:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/functions/dsql/hashPassword")},8804:e=>{e.exports=require("@moduletrace/nsqlite")},1635:e=>{e.exports=require("dayjs")},145:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},2048:e=>{e.exports=require("fs")},6249:(e,t)=>{Object.defineProperty(t,"l",{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}}})},6644:(e,t,r)=>{r.r(t),r.d(t,{config:()=>l,default:()=>d,routeModule:()=>c});var i={};r.r(i),r.d(i,{default:()=>u});var s=r(1802),n=r(7153),a=r(6249),o=r(4751);async function u(e,t){try{if("POST"!==e.method)return t.json({success:!1,msg:"Wrong Method"});let{email:r,username:i,password:s}=e.body;if("string"!=typeof s||!s?.match(/./))throw Error("Password is required!");let n=await (0,o.Z)({res:t,email_or_username:r||i,password:s});return t.json(n)}catch(e){return t.json({success:!1,msg:e.message})}}let d=(0,a.l)(i,"default"),l=(0,a.l)(i,"config"),c=new s.PagesAPIRouteModule({definition:{kind:n.x.PAGES_API,page:"/api/auth/login",pathname:"/api/auth/login",bundlePath:"",filename:""},userland:i})},2253:(e,t,r)=>{r.d(t,{dF:()=>a(),_n:()=>l,lV:()=>u()});let i=require("@moduletrace/datasquirel/dist/client");var s=r.n(i);let n=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson");var a=r.n(n);let o=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify");var u=r.n(o);let d=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy"),l=r.n(d)();s().utils.serializeQuery,s().utils.deserializeQuery},4751:(e,t,r)=>{r.d(t,{Z:()=>f});var i=r(8804),s=r.n(i),n=r(6941),a=r(2253);let o=require("@moduletrace/datasquirel/dist/package-shared/functions/dsql/encrypt");var u=r.n(o),d=r(5529),l=r.n(d),c=r(1635),p=r.n(c),m=r(9786);async function f({res:e,user_id:t,password:r,email_or_username:i}){let o;if(t){let e=await s().select({table:"users",targetId:t});if(!e.singleRes?.id)throw Error("Couldn't Find user for login");o=e.singleRes}if(i){let e=await s().select({table:"users",query:{query:{email:{value:i},username:{value:i}},searchOperator:"OR"}});if(!e.singleRes?.id)throw Error("Couldn't Find user for login");o=e.singleRes}if(!o)return{success:!1,msg:"User Not Found!"};if(r&&l()({password:r})!==o.password)return{success:!1,msg:"Invalid Password."};let d=Date.now(),c=Math.random().toString(36).substring(2)+"-"+Math.random().toString(36).substring(2),f={first_name:o.first_name,last_name:o.last_name,date:d,email:o.email,csrf_k:c,id:o.id,logged_in_status:!0,image:o.image,image_thumbnail:o.image,super_admin:!!o.is_super_admin},g=a.dF.stringify(f),h=u()({data:g||""}),_=p()(Date.now()).add(7,"days");_.add(7,"days");let{auth_key_cookie_name:y,csrf_cookie_name:P}=(0,m.Z)();return(0,n.d8)(e,[{name:y,value:h||"",options:{secure:"localhost"!==process.env.DOMAIN,path:"/",expires:_,domain:process.env.DOMAIN}},{name:P,value:c,options:{path:"/",expires:_,domain:process.env.DOMAIN}}]),{success:!0,singleRes:f}}},6941:(e,t,r)=>{function i(e,t){let r=[];for(let e=0;e<t.length;e++){let{name:i,options:s,value:n}=t[e],a=[`${encodeURIComponent(i)}=${encodeURIComponent(n)}`];s.expires&&a.push(`Expires=${s.expires.toDate().toUTCString()}`),void 0!==s.maxAge&&a.push(`Max-Age=${s.maxAge}`),s.path&&a.push(`Path=${s.path}`),s.domain&&a.push(`Domain=${s.domain}`),s.secure&&a.push("Secure"),s.httpOnly&&a.push("HttpOnly"),r.push(a)}let i=r.map(e=>e.join("; "));e.setHeader("Set-Cookie",i)}function s(e,t){return e.split(";").reduce((e,t)=>{let[r,i]=t.trim().split("=").map(decodeURIComponent);return e[r]=i,e},{})[t]||null}r.d(t,{d8:()=>i,ej:()=>s}),r(1635)},9786:(e,t,r)=>{r.d(t,{Z:()=>a});var i=r(2048);let s=require("path");var n=r.n(s);function a(){let{TURBOCI_DEPLOYMENT_ID_FILE:e}=function(){let e=n().resolve(__dirname,"../../"),t="/root/.turboci",r=n().join(t,".config"),i=n().join(r,"turboci.json"),s=n().join(t,"deployment_id"),a=n().join(t,".ssh"),o=n().join(a,"turboci");return{APP_DIR:e,TURBOCI_CONFIG_DIR:r,TURBOCI_CONFIG_JSON_FILE:i,TURBOCI_DIR:t,TURBOCI_SSH_DIR:a,TURBOCI_SSH_KEY_FILE:o,TURBOCI_DEPLOYMENT_ID_FILE:s}}();if(!(0,i.existsSync)(e))throw Error(`\`${e}\` does not exist.`);let t=(0,i.readFileSync)(e,"utf-8").split("-").shift();if(!t)throw Error("Invalid deployment_id");return{auth_key_cookie_name:`turboci-admin-${t}-auth-key`,csrf_cookie_name:`turboci-admin-${t}-csrf`}}},7153:(e,t)=>{var r;Object.defineProperty(t,"x",{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"}(r||(r={}))},1802:(e,t,r)=>{e.exports=r(145)}};var t=require("../../../webpack-api-runtime.js");t.C(e);var r=t(t.s=6644);module.exports=r})();
"use strict";(()=>{var e={};e.id=908,e.ids=[908],e.modules={5529:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/functions/dsql/hashPassword")},8804:e=>{e.exports=require("@moduletrace/nsqlite")},1635:e=>{e.exports=require("dayjs")},145:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},2048:e=>{e.exports=require("fs")},6249:(e,t)=>{Object.defineProperty(t,"l",{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}}})},6644:(e,t,r)=>{r.r(t),r.d(t,{config:()=>l,default:()=>d,routeModule:()=>c});var i={};r.r(i),r.d(i,{default:()=>u});var a=r(1802),n=r(7153),s=r(6249),o=r(4751);async function u(e,t){try{if("POST"!==e.method)return t.json({success:!1,msg:"Wrong Method"});let{email:r,username:i,password:a}=e.body;if("string"!=typeof a||!a?.match(/./))throw Error("Password is required!");let n=await (0,o.Z)({res:t,email_or_username:r||i,password:a,req:e});return t.json(n)}catch(e){return t.json({success:!1,msg:e.message})}}let d=(0,s.l)(i,"default"),l=(0,s.l)(i,"config"),c=new a.PagesAPIRouteModule({definition:{kind:n.x.PAGES_API,page:"/api/auth/login",pathname:"/api/auth/login",bundlePath:"",filename:""},userland:i})},2253:(e,t,r)=>{r.d(t,{dF:()=>s(),_n:()=>l,lV:()=>u()});let i=require("@moduletrace/datasquirel/dist/client");var a=r.n(i);let n=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson");var s=r.n(n);let o=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify");var u=r.n(o);let d=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy"),l=r.n(d)();a().utils.serializeQuery,a().utils.deserializeQuery},4751:(e,t,r)=>{r.d(t,{Z:()=>f});var i=r(8804),a=r.n(i),n=r(6941),s=r(2253);let o=require("@moduletrace/datasquirel/dist/package-shared/functions/dsql/encrypt");var u=r.n(o),d=r(5529),l=r.n(d),c=r(1635),m=r.n(c),p=r(9786);async function f({req:e,res:t,user_id:r,password:i,email_or_username:o}){let d;if(r){let e=await a().select({table:"users",targetId:r});if(!e.singleRes?.id)throw Error("Couldn't Find user for login");d=e.singleRes}if(o){let e=await a().select({table:"users",query:{query:{email:{value:o},username:{value:o}},searchOperator:"OR"}});if(!e.singleRes?.id)throw Error("Couldn't Find user for login");d=e.singleRes}if(!d)return{success:!1,msg:"User Not Found!"};if(i&&l()({password:i})!==d.password)return{success:!1,msg:"Invalid Password."};let c=Date.now(),f=Math.random().toString(36).substring(2)+"-"+Math.random().toString(36).substring(2),h={first_name:d.first_name,last_name:d.last_name,date:c,email:d.email,csrf_k:f,id:d.id,logged_in_status:!0,image:d.image,image_thumbnail:d.image,super_admin:!!d.is_super_admin},g=s.dF.stringify(h),_=u()({data:g||""}),y=m()(Date.now()).add(7,"days");y.add(7,"days");let{auth_key_cookie_name:P,csrf_cookie_name:q}=(0,p.Z)(),v=e.headers.host;return(0,n.d8)(t,[{name:P,value:_||"",options:{secure:"localhost"!==v,path:"/",expires:y,domain:v}},{name:q,value:f,options:{path:"/",expires:y,domain:v}}]),{success:!0,singleRes:h}}},6941:(e,t,r)=>{function i(e,t){let r=[];for(let e=0;e<t.length;e++){let{name:i,options:a,value:n}=t[e],s=[`${encodeURIComponent(i)}=${encodeURIComponent(n)}`];a.expires&&s.push(`Expires=${a.expires.toDate().toUTCString()}`),void 0!==a.maxAge&&s.push(`Max-Age=${a.maxAge}`),a.path&&s.push(`Path=${a.path}`),a.domain&&s.push(`Domain=${a.domain}`),a.secure&&s.push("Secure"),a.httpOnly&&s.push("HttpOnly"),r.push(s)}let i=r.map(e=>e.join("; "));e.setHeader("Set-Cookie",i)}function a(e,t){return e.split(";").reduce((e,t)=>{let[r,i]=t.trim().split("=").map(decodeURIComponent);return e[r]=i,e},{})[t]||null}r.d(t,{d8:()=>i,ej:()=>a}),r(1635)},9786:(e,t,r)=>{r.d(t,{Z:()=>s});var i=r(2048);let a=require("path");var n=r.n(a);function s(){let{TURBOCI_DEPLOYMENT_ID_FILE:e}=function(){let e=n().resolve(__dirname,"../../"),t="/root/.turboci",r=n().join(t,".config"),i=n().join(r,"turboci.json"),a=n().join(t,"deployment_id"),s=n().join(t,".ssh"),o=n().join(s,"turboci");return{APP_DIR:e,TURBOCI_CONFIG_DIR:r,TURBOCI_CONFIG_JSON_FILE:i,TURBOCI_DIR:t,TURBOCI_SSH_DIR:s,TURBOCI_SSH_KEY_FILE:o,TURBOCI_DEPLOYMENT_ID_FILE:a}}();if(!(0,i.existsSync)(e))throw Error(`\`${e}\` does not exist.`);let t=(0,i.readFileSync)(e,"utf-8").split("-").shift();if(!t)throw Error("Invalid deployment_id");return{auth_key_cookie_name:`turboci-admin-${t}-auth-key`,csrf_cookie_name:`turboci-admin-${t}-csrf`}}},7153:(e,t)=>{var r;Object.defineProperty(t,"x",{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"}(r||(r={}))},1802:(e,t,r)=>{e.exports=r(145)}};var t=require("../../../webpack-api-runtime.js");t.C(e);var r=t(t.s=6644);module.exports=r})();
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"version":1,"files":["../../../../../node_modules/next/dist/compiled/@opentelemetry/api/index.js","../../../../../node_modules/next/dist/compiled/@opentelemetry/api/package.json","../../../../../node_modules/next/dist/compiled/bytes/index.js","../../../../../node_modules/next/dist/compiled/bytes/package.json","../../../../../node_modules/next/dist/compiled/jsonwebtoken/index.js","../../../../../node_modules/next/dist/compiled/jsonwebtoken/package.json","../../../../../node_modules/next/dist/compiled/next-server/pages-api.runtime.prod.js","../../../../../node_modules/next/dist/compiled/node-html-parser/index.js","../../../../../node_modules/next/dist/compiled/node-html-parser/package.json","../../../../../node_modules/next/dist/compiled/raw-body/index.js","../../../../../node_modules/next/dist/compiled/raw-body/package.json","../../../../../node_modules/next/dist/lib/semver-noop.js","../../../../../node_modules/next/dist/server/lib/trace/constants.js","../../../../../node_modules/next/dist/server/lib/trace/tracer.js","../../../../../node_modules/next/package.json","../../../../../package.json","../../../package.json","../../chunks/150.js","../../chunks/248.js","../../chunks/752.js","../../chunks/800.js","../../chunks/824.js","../../chunks/859.js","../../chunks/font-manifest.json","../../webpack-api-runtime.js"]}
{"version":1,"files":["../../../../../node_modules/next/dist/compiled/@opentelemetry/api/index.js","../../../../../node_modules/next/dist/compiled/@opentelemetry/api/package.json","../../../../../node_modules/next/dist/compiled/bytes/index.js","../../../../../node_modules/next/dist/compiled/bytes/package.json","../../../../../node_modules/next/dist/compiled/jsonwebtoken/index.js","../../../../../node_modules/next/dist/compiled/jsonwebtoken/package.json","../../../../../node_modules/next/dist/compiled/next-server/pages-api.runtime.prod.js","../../../../../node_modules/next/dist/compiled/node-html-parser/index.js","../../../../../node_modules/next/dist/compiled/node-html-parser/package.json","../../../../../node_modules/next/dist/compiled/raw-body/index.js","../../../../../node_modules/next/dist/compiled/raw-body/package.json","../../../../../node_modules/next/dist/lib/semver-noop.js","../../../../../node_modules/next/dist/server/lib/trace/constants.js","../../../../../node_modules/next/dist/server/lib/trace/tracer.js","../../../../../node_modules/next/package.json","../../../../../package.json","../../../package.json","../../chunks/150.js","../../chunks/248.js","../../chunks/330.js","../../chunks/752.js","../../chunks/824.js","../../chunks/859.js","../../chunks/font-manifest.json","../../webpack-api-runtime.js"]}