"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.archiveZip=exports.genZip=exports.unzip=void 0;const AdmZip=require("adm-zip"),fse=require("fs-extra"),archiver=require("archiver");async function unzip(e,r){return console.warn("@@@@@ [unzip]",e),new Promise((i,t)=>{try{setTimeout(()=>{const n=new AdmZip(e),o=n.getEntries();for(const e of o){const r=e.entryName;/^\.\.(\\|\/)+/.test(r)&&t("illegal access"),/(\\|\/)+\.\.(\\|\/)+/.test(r)&&t("illegal access"),/(\\|\/)+\.\.$/.test(r)&&t("illegal access")}n.extractAllTo(r,!0),i({})},200)}catch(e){console.warn("@@@@@ [unzip] Fail. Error:",e),t(e)}})}function genZip(e,r){const i=new AdmZip;i.addLocalFolder(e),fse.writeFileSync(r,i.toBuffer())}function archiveZip(e,r){return new Promise((i,t)=>{const n=fse.createWriteStream(r),o=archiver("zip",{zlib:{level:9}});o.on("error",e=>{t(e)}),o.on("end",()=>{i({})}),o.pipe(n),o.directory(e,!1),o.finalize()})}exports.unzip=unzip,exports.genZip=genZip,exports.archiveZip=archiveZip;