"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})();