hfs 0.55.2 → 0.56.0-alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/assets/index-D3kXFfFt.css +1 -0
- package/admin/assets/index-nlAmDXAU.js +819 -0
- package/admin/assets/sha512-BP2pyBBC.js +8 -0
- package/admin/index.html +2 -2
- package/frontend/assets/index-legacy-BEI2K_mw.js +50 -0
- package/frontend/assets/polyfills-legacy-Ca1TOBqp.js +1 -0
- package/frontend/assets/sha512-legacy-Z6a6T8lE.js +9 -0
- package/frontend/index.html +2 -2
- package/package.json +1 -1
- package/src/SendList.js +1 -1
- package/src/adminApis.js +1 -1
- package/src/api.auth.js +2 -0
- package/src/api.get_file_list.js +0 -2
- package/src/api.vfs.js +7 -12
- package/src/auth.js +1 -0
- package/src/basicWeb.js +1 -1
- package/src/commands.js +3 -6
- package/src/config.js +31 -10
- package/src/const.js +2 -2
- package/src/cross-const.js +2 -1
- package/src/cross.js +1 -1
- package/src/debounceAsync.js +3 -2
- package/src/frontEndApis.js +12 -0
- package/src/icons.js +35 -0
- package/src/middlewares.js +11 -2
- package/src/misc.js +7 -1
- package/src/nat.js +1 -1
- package/src/outboundProxy.js +43 -0
- package/src/plugins.js +25 -14
- package/src/serveGuiAndSharedFiles.js +15 -0
- package/src/serveGuiFiles.js +5 -0
- package/src/update.js +1 -1
- package/src/upload.js +12 -1
- package/src/util-files.js +3 -1
- package/src/util-http.js +14 -7
- package/src/util-os.js +5 -1
- package/src/vfs.js +29 -10
- package/src/watchLoad.js +3 -2
- package/src/zip.js +3 -1
- package/admin/assets/index-B4HJwRLS.js +0 -809
- package/admin/assets/index-CrbMquLL.css +0 -1
- package/admin/assets/sha512-iUmyklA_.js +0 -8
- package/admin/prism.css +0 -4
- package/admin/prism.js +0 -10
- package/frontend/assets/index-legacy-BFUS5Ol_.js +0 -60
- package/frontend/assets/polyfills-legacy-DMrMt_pQ.js +0 -4
- package/frontend/assets/sha512-legacy-HnxdKRIz.js +0 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(){"use strict";var e,t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};e||(e=1,function(){function e(e,t){return(t||"")+" (SystemJS https://github.com/systemjs/systemjs/blob/main/docs/errors.md#"+e+")"}function n(e,t){if(-1!==e.indexOf("\\")&&(e=e.replace(b,"/")),"/"===e[0]&&"/"===e[1])return t.slice(0,t.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){var n,r=t.slice(0,t.indexOf(":")+1);if(n="/"===t[r.length+1]?"file:"!==r?(n=t.slice(r.length+2)).slice(n.indexOf("/")+1):t.slice(8):t.slice(r.length+("/"===t[r.length])),"/"===e[0])return t.slice(0,t.length-n.length-1)+e;for(var i=n.slice(0,n.lastIndexOf("/")+1)+e,o=[],s=-1,c=0;c<i.length;c++)-1!==s?"/"===i[c]&&(o.push(i.slice(s,c+1)),s=-1):"."===i[c]?"."!==i[c+1]||"/"!==i[c+2]&&c+2!==i.length?"/"===i[c+1]||c+1===i.length?c+=1:s=c:(o.pop(),c+=2):s=c;return-1!==s&&o.push(i.slice(s)),t.slice(0,t.length-n.length)+o.join("")}}function r(e,t){return n(e,t)||(-1!==e.indexOf(":")?e:n("./"+e,t))}function i(e,t,r,i,o){for(var s in e){var c=n(s,r)||s,a=e[s];if("string"==typeof a){var l=f(i,n(a,r)||a,o);l?t[c]=l:u("W1",s,a)}}}function o(e,t,n){var o;for(o in e.imports&&i(e.imports,n.imports,t,n,null),e.scopes||{}){var s=r(o,t);i(e.scopes[o],n.scopes[s]||(n.scopes[s]={}),t,n,s)}for(o in e.depcache||{})n.depcache[r(o,t)]=e.depcache[o];for(o in e.integrity||{})n.integrity[r(o,t)]=e.integrity[o]}function s(e,t){if(t[e])return e;var n=e.length;do{var r=e.slice(0,n+1);if(r in t)return r}while(-1!==(n=e.lastIndexOf("/",n-1)))}function c(e,t){var n=s(e,t);if(n){var r=t[n];if(null===r)return;if(!(e.length>n.length&&"/"!==r[r.length-1]))return r+e.slice(n.length);u("W2",n,r)}}function u(t,n,r){console.warn(e(t,[r,n].join(", ")))}function f(e,t,n){for(var r=e.scopes,i=n&&s(n,r);i;){var o=c(t,r[i]);if(o)return o;i=s(i.slice(0,i.lastIndexOf("/")),r)}return c(t,e.imports)||-1!==t.indexOf(":")&&t}function a(){this[P]={}}function l(t,n,r,i){var o=t[P][n];if(o)return o;var s=[],c=Object.create(null);j&&Object.defineProperty(c,j,{value:"Module"});var u=Promise.resolve().then((function(){return t.instantiate(n,r,i)})).then((function(r){if(!r)throw Error(e(2,n));var i=r[1]((function(e,t){o.h=!0;var n=!1;if("string"==typeof e)e in c&&c[e]===t||(c[e]=t,n=!0);else{for(var r in e)t=e[r],r in c&&c[r]===t||(c[r]=t,n=!0);e&&e.__esModule&&(c.__esModule=e.__esModule)}if(n)for(var i=0;i<s.length;i++){var u=s[i];u&&u(c)}return t}),2===r[1].length?{import:function(e,r){return t.import(e,n,r)},meta:t.createContext(n)}:void 0);return o.e=i.execute||function(){},[r[0],i.setters||[],r[2]||[]]}),(function(e){throw o.e=null,o.er=e,e})),f=u.then((function(e){return Promise.all(e[0].map((function(r,i){var o=e[1][i],s=e[2][i];return Promise.resolve(t.resolve(r,n)).then((function(e){var r=l(t,e,n,s);return Promise.resolve(r.I).then((function(){return o&&(r.i.push(o),!r.h&&r.I||o(r.n)),r}))}))}))).then((function(e){o.d=e}))}));return o=t[P][n]={id:n,i:s,n:c,m:i,I:u,L:f,h:!1,d:void 0,e:void 0,er:void 0,E:void 0,C:void 0,p:void 0}}function h(e,t,n,r){if(!r[t.id])return r[t.id]=!0,Promise.resolve(t.L).then((function(){return t.p&&null!==t.p.e||(t.p=n),Promise.all(t.d.map((function(t){return h(e,t,n,r)})))})).catch((function(e){if(t.er)throw e;throw t.e=null,e}))}function d(e,t){return t.C=h(e,t,t,{}).then((function(){return p(e,t,{})})).then((function(){return t.n}))}function p(e,t,n){function r(){try{var e=o.call(L);if(e)return e=e.then((function(){t.C=t.n,t.E=null}),(function(e){throw t.er=e,t.E=null,e})),t.E=e;t.C=t.n,t.L=t.I=void 0}catch(n){throw t.er=n,n}}if(!n[t.id]){if(n[t.id]=!0,!t.e){if(t.er)throw t.er;return t.E?t.E:void 0}var i,o=t.e;return t.e=null,t.d.forEach((function(r){try{var o=p(e,r,n);o&&(i=i||[]).push(o)}catch(c){throw t.er=c,c}})),i?Promise.all(i).then(r):r()}}function v(){[].forEach.call(document.querySelectorAll("script"),(function(t){if(!t.sp)if("systemjs-module"===t.type){if(t.sp=!0,!t.src)return;System.import("import:"===t.src.slice(0,7)?t.src.slice(7):r(t.src,m)).catch((function(e){if(e.message.indexOf("https://github.com/systemjs/systemjs/blob/main/docs/errors.md#3")>-1){var n=document.createEvent("Event");n.initEvent("error",!1,!1),t.dispatchEvent(n)}return Promise.reject(e)}))}else if("systemjs-importmap"===t.type){t.sp=!0;var n=t.src?(System.fetch||fetch)(t.src,{integrity:t.integrity,priority:t.fetchPriority,passThrough:!0}).then((function(e){if(!e.ok)throw Error(e.status);return e.text()})).catch((function(n){return n.message=e("W4",t.src)+"\n"+n.message,console.warn(n),"function"==typeof t.onerror&&t.onerror(),"{}"})):t.innerHTML;T=T.then((function(){return n})).then((function(n){!function(t,n,r){var i={};try{i=JSON.parse(n)}catch(c){console.warn(Error(e("W5")))}o(i,r,t)}(R,n,t.src||m)}))}}))}var m,g="undefined"!=typeof Symbol,y="undefined"!=typeof self,w="undefined"!=typeof document,E=y?self:t;if(w){var O=document.querySelector("base[href]");O&&(m=O.href)}if(!m&&"undefined"!=typeof location){var x=(m=location.href.split("#")[0].split("?")[0]).lastIndexOf("/");-1!==x&&(m=m.slice(0,x+1))}var S,b=/\\/g,j=g&&Symbol.toStringTag,P=g?Symbol():"@",I=a.prototype;I.import=function(e,t,n){var r=this;return t&&"object"==typeof t&&(n=t,t=void 0),Promise.resolve(r.prepareImport()).then((function(){return r.resolve(e,t,n)})).then((function(e){var t=l(r,e,void 0,n);return t.C||d(r,t)}))},I.createContext=function(e){var t=this;return{url:e,resolve:function(n,r){return Promise.resolve(t.resolve(n,r||e))}}},I.register=function(e,t,n){S=[e,t,n]},I.getRegister=function(){var e=S;return S=void 0,e};var L=Object.freeze(Object.create(null));E.System=new a;var C,M,T=Promise.resolve(),R={imports:{},scopes:{},depcache:{},integrity:{}},_=w;if(I.prepareImport=function(e){return(_||e)&&(v(),_=!1),T},I.getImportMap=function(){return JSON.parse(JSON.stringify(R))},w&&(v(),window.addEventListener("DOMContentLoaded",v)),I.addImportMap=function(e,t){o(e,t||m,R)},w){window.addEventListener("error",(function(e){W=e.filename,q=e.error}));var J=location.origin}I.createScript=function(e){var t=document.createElement("script");t.async=!0,e.indexOf(J+"/")&&(t.crossOrigin="anonymous");var n=R.integrity[e];return n&&(t.integrity=n),t.src=e,t};var W,q,N={},k=I.register;I.register=function(e,t){if(w&&"loading"===document.readyState&&"string"!=typeof e){var n=document.querySelectorAll("script[src]"),r=n[n.length-1];if(r){C=e;var i=this;M=setTimeout((function(){N[r.src]=[e,t],i.import(r.src)}))}}else C=void 0;return k.call(this,e,t)},I.instantiate=function(t,n){var r=N[t];if(r)return delete N[t],r;var i=this;return Promise.resolve(I.createScript(t)).then((function(r){return new Promise((function(o,s){r.addEventListener("error",(function(){s(Error(e(3,[t,n].join(", "))))})),r.addEventListener("load",(function(){if(document.head.removeChild(r),W===t)s(q);else{var e=i.getRegister(t);e&&e[0]===C&&clearTimeout(M),o(e)}})),document.head.appendChild(r)}))}))},I.shouldFetch=function(){return!1},"undefined"!=typeof fetch&&(I.fetch=fetch);var A=I.instantiate,F=/^(text|application)\/(x-)?javascript(;|$)/;I.instantiate=function(t,n,r){var i=this;return this.shouldFetch(t,n,r)?this.fetch(t,{credentials:"same-origin",integrity:R.integrity[t],meta:r}).then((function(r){if(!r.ok)throw Error(e(7,[r.status,r.statusText,t,n].join(", ")));var o=r.headers.get("content-type");if(!o||!F.test(o))throw Error(e(4,o));return r.text().then((function(e){return e.indexOf("//# sourceURL=")<0&&(e+="\n//# sourceURL="+t),(0,eval)(e),i.getRegister(t)}))})):A.apply(this,arguments)},I.resolve=function(t,r){return f(R,n(t,r=r||m)||t,r)||function(t,n){throw Error(e(8,[t,n].join(", ")))}(t,r)};var U=I.instantiate;I.instantiate=function(e,t,n){var r=R.depcache[e];if(r)for(var i=0;i<r.length;i++)l(this,this.resolve(r[i],e),e);return U.call(this,e,t,n)},y&&"function"==typeof importScripts&&(I.instantiate=function(e){var t=this;return Promise.resolve().then((function(){return importScripts(e),t.getRegister(e)}))})}())}();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
System.register(["./index-legacy-BEI2K_mw.js"],(function(h,t){"use strict";var i,s;return{setters:[function(h){i=h.c,s=h.g}],execute:function(){function t(h,t){for(var i=function(){var i=t[s];if("string"!=typeof i&&!Array.isArray(i)){var r=function(t){if("default"!==t&&!(t in h)){var s=Object.getOwnPropertyDescriptor(i,t);s&&Object.defineProperty(h,t,s.get?s:{enumerable:!0,get:function(){return i[t]}})}};for(var e in i)r(e)}},s=0;s<t.length;s++)i();return Object.freeze(Object.defineProperty(h,Symbol.toStringTag,{value:"Module"}))}var r,e={exports:{}},n=(r||(r=1,function(h){!function(){var t="input is invalid type",s="object"==typeof window,r=s?window:{};r.JS_SHA512_NO_WINDOW&&(s=!1);var e=!s&&"object"==typeof self;!r.JS_SHA512_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?r=i:e&&(r=self);var n=!r.JS_SHA512_NO_COMMON_JS&&h.exports,o=!r.JS_SHA512_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,a="0123456789abcdef".split(""),l=[-2147483648,8388608,32768,128],f=[24,16,8,0],c=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],u=["hex","array","digest","arrayBuffer"],y=[];!r.JS_SHA512_NO_NODE_JS&&Array.isArray||(Array.isArray=function(h){return"[object Array]"===Object.prototype.toString.call(h)}),!o||!r.JS_SHA512_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(h){return"object"==typeof h&&h.buffer&&h.buffer.constructor===ArrayBuffer});var p=function(h,t){return function(i){return new _(t,!0).update(i)[h]()}},d=function(h){var t=p("hex",h);t.create=function(){return new _(h)},t.update=function(h){return t.create().update(h)};for(var i=0;i<u.length;++i){var s=u[i];t[s]=p(s,h)}return t},b=function(h,t){return function(i,s){return new w(i,t,!0).update(s)[h]()}},v=function(h){var t=b("hex",h);t.create=function(t){return new w(t,h)},t.update=function(h,i){return t.create(h).update(i)};for(var i=0;i<u.length;++i){var s=u[i];t[s]=b(s,h)}return t};function _(h,t){t?(y[0]=y[1]=y[2]=y[3]=y[4]=y[5]=y[6]=y[7]=y[8]=y[9]=y[10]=y[11]=y[12]=y[13]=y[14]=y[15]=y[16]=y[17]=y[18]=y[19]=y[20]=y[21]=y[22]=y[23]=y[24]=y[25]=y[26]=y[27]=y[28]=y[29]=y[30]=y[31]=y[32]=0,this.blocks=y):this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],384==h?(this.h0h=3418070365,this.h0l=3238371032,this.h1h=1654270250,this.h1l=914150663,this.h2h=2438529370,this.h2l=812702999,this.h3h=355462360,this.h3l=4144912697,this.h4h=1731405415,this.h4l=4290775857,this.h5h=2394180231,this.h5l=1750603025,this.h6h=3675008525,this.h6l=1694076839,this.h7h=1203062813,this.h7l=3204075428):256==h?(this.h0h=573645204,this.h0l=4230739756,this.h1h=2673172387,this.h1l=3360449730,this.h2h=596883563,this.h2l=1867755857,this.h3h=2520282905,this.h3l=1497426621,this.h4h=2519219938,this.h4l=2827943907,this.h5h=3193839141,this.h5l=1401305490,this.h6h=721525244,this.h6l=746961066,this.h7h=246885852,this.h7l=2177182882):224==h?(this.h0h=2352822216,this.h0l=424955298,this.h1h=1944164710,this.h1l=2312950998,this.h2h=502970286,this.h2l=855612546,this.h3h=1738396948,this.h3l=1479516111,this.h4h=258812777,this.h4l=2077511080,this.h5h=2011393907,this.h5l=79989058,this.h6h=1067287976,this.h6l=1780299464,this.h7h=286451373,this.h7l=2446758561):(this.h0h=1779033703,this.h0l=4089235720,this.h1h=3144134277,this.h1l=2227873595,this.h2h=1013904242,this.h2l=4271175723,this.h3h=2773480762,this.h3l=1595750129,this.h4h=1359893119,this.h4l=2917565137,this.h5h=2600822924,this.h5l=725511199,this.h6h=528734635,this.h6l=4215389547,this.h7h=1541459225,this.h7l=327033209),this.bits=h,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1}function w(h,i,s){var r,e=typeof h;if("string"!==e){if("object"!==e)throw new Error(t);if(null===h)throw new Error(t);if(o&&h.constructor===ArrayBuffer)h=new Uint8Array(h);else if(!(Array.isArray(h)||o&&ArrayBuffer.isView(h)))throw new Error(t);r=!0}var n=h.length;if(!r){for(var a,l=[],f=(n=h.length,0),c=0;c<n;++c)(a=h.charCodeAt(c))<128?l[f++]=a:a<2048?(l[f++]=192|a>>6,l[f++]=128|63&a):a<55296||a>=57344?(l[f++]=224|a>>12,l[f++]=128|a>>6&63,l[f++]=128|63&a):(a=65536+((1023&a)<<10|1023&h.charCodeAt(++c)),l[f++]=240|a>>18,l[f++]=128|a>>12&63,l[f++]=128|a>>6&63,l[f++]=128|63&a);h=l}h.length>128&&(h=new _(i,!0).update(h).array());var u=[],y=[];for(c=0;c<128;++c){var p=h[c]||0;u[c]=92^p,y[c]=54^p}_.call(this,i,s),this.update(y),this.oKeyPad=u,this.inner=!0,this.sharedMemory=s}_.prototype.update=function(h){if(this.finalized)throw new Error("finalize already called");var i,s=typeof h;if("string"!==s){if("object"!==s)throw new Error(t);if(null===h)throw new Error(t);if(o&&h.constructor===ArrayBuffer)h=new Uint8Array(h);else if(!(Array.isArray(h)||o&&ArrayBuffer.isView(h)))throw new Error(t);i=!0}for(var r,e,n=0,a=h.length,l=this.blocks;n<a;){if(this.hashed&&(this.hashed=!1,l[0]=this.block,l[1]=l[2]=l[3]=l[4]=l[5]=l[6]=l[7]=l[8]=l[9]=l[10]=l[11]=l[12]=l[13]=l[14]=l[15]=l[16]=l[17]=l[18]=l[19]=l[20]=l[21]=l[22]=l[23]=l[24]=l[25]=l[26]=l[27]=l[28]=l[29]=l[30]=l[31]=l[32]=0),i)for(e=this.start;n<a&&e<128;++n)l[e>>2]|=h[n]<<f[3&e++];else for(e=this.start;n<a&&e<128;++n)(r=h.charCodeAt(n))<128?l[e>>2]|=r<<f[3&e++]:r<2048?(l[e>>2]|=(192|r>>6)<<f[3&e++],l[e>>2]|=(128|63&r)<<f[3&e++]):r<55296||r>=57344?(l[e>>2]|=(224|r>>12)<<f[3&e++],l[e>>2]|=(128|r>>6&63)<<f[3&e++],l[e>>2]|=(128|63&r)<<f[3&e++]):(r=65536+((1023&r)<<10|1023&h.charCodeAt(++n)),l[e>>2]|=(240|r>>18)<<f[3&e++],l[e>>2]|=(128|r>>12&63)<<f[3&e++],l[e>>2]|=(128|r>>6&63)<<f[3&e++],l[e>>2]|=(128|63&r)<<f[3&e++]);this.lastByteIndex=e,this.bytes+=e-this.start,e>=128?(this.block=l[32],this.start=e-128,this.hash(),this.hashed=!0):this.start=e}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this},_.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var h=this.blocks,t=this.lastByteIndex;h[32]=this.block,h[t>>2]|=l[3&t],this.block=h[32],t>=112&&(this.hashed||this.hash(),h[0]=this.block,h[1]=h[2]=h[3]=h[4]=h[5]=h[6]=h[7]=h[8]=h[9]=h[10]=h[11]=h[12]=h[13]=h[14]=h[15]=h[16]=h[17]=h[18]=h[19]=h[20]=h[21]=h[22]=h[23]=h[24]=h[25]=h[26]=h[27]=h[28]=h[29]=h[30]=h[31]=h[32]=0),h[30]=this.hBytes<<3|this.bytes>>>29,h[31]=this.bytes<<3,this.hash()}},_.prototype.hash=function(){var h,t,i,s,r,e,n,o,a,l,f,u,y,p,d,b,v,_,w,A,g,S,B,U,O,k=this.h0h,x=this.h0l,z=this.h1h,j=this.h1l,E=this.h2h,N=this.h2l,m=this.h3h,J=this.h3l,P=this.h4h,H=this.h4l,I=this.h5h,R=this.h5l,V=this.h6h,C=this.h6l,D=this.h7h,K=this.h7l,M=this.blocks;for(h=32;h<160;h+=2)t=((A=M[h-30])>>>1|(g=M[h-29])<<31)^(A>>>8|g<<24)^A>>>7,i=(g>>>1|A<<31)^(g>>>8|A<<24)^(g>>>7|A<<25),s=((A=M[h-4])>>>19|(g=M[h-3])<<13)^(g>>>29|A<<3)^A>>>6,r=(g>>>19|A<<13)^(A>>>29|g<<3)^(g>>>6|A<<26),A=M[h-32],g=M[h-31],a=((S=M[h-14])>>>16)+(A>>>16)+(t>>>16)+(s>>>16)+((o=(65535&S)+(65535&A)+(65535&t)+(65535&s)+((n=((B=M[h-13])>>>16)+(g>>>16)+(i>>>16)+(r>>>16)+((e=(65535&B)+(65535&g)+(65535&i)+(65535&r))>>>16))>>>16))>>>16),M[h]=a<<16|65535&o,M[h+1]=n<<16|65535&e;var F=k,T=x,W=z,Y=j,q=E,G=N,L=m,Q=J,X=P,Z=H,$=I,hh=R,th=V,ih=C,sh=D,rh=K;for(b=W&q,v=Y&G,h=0;h<160;h+=8)t=(F>>>28|T<<4)^(T>>>2|F<<30)^(T>>>7|F<<25),i=(T>>>28|F<<4)^(F>>>2|T<<30)^(F>>>7|T<<25),s=(X>>>14|Z<<18)^(X>>>18|Z<<14)^(Z>>>9|X<<23),r=(Z>>>14|X<<18)^(Z>>>18|X<<14)^(X>>>9|Z<<23),_=(l=F&W)^F&q^b,w=(f=T&Y)^T&G^v,U=X&$^~X&th,O=Z&hh^~Z&ih,A=M[h],g=M[h+1],A=(a=((S=c[h])>>>16)+(A>>>16)+(U>>>16)+(s>>>16)+(sh>>>16)+((o=(65535&S)+(65535&A)+(65535&U)+(65535&s)+(65535&sh)+((n=((B=c[h+1])>>>16)+(g>>>16)+(O>>>16)+(r>>>16)+(rh>>>16)+((e=(65535&B)+(65535&g)+(65535&O)+(65535&r)+(65535&rh))>>>16))>>>16))>>>16))<<16|65535&o,g=n<<16|65535&e,S=(a=(_>>>16)+(t>>>16)+((o=(65535&_)+(65535&t)+((n=(w>>>16)+(i>>>16)+((e=(65535&w)+(65535&i))>>>16))>>>16))>>>16))<<16|65535&o,B=n<<16|65535&e,sh=(a=(L>>>16)+(A>>>16)+((o=(65535&L)+(65535&A)+((n=(Q>>>16)+(g>>>16)+((e=(65535&Q)+(65535&g))>>>16))>>>16))>>>16))<<16|65535&o,rh=n<<16|65535&e,t=((L=(a=(S>>>16)+(A>>>16)+((o=(65535&S)+(65535&A)+((n=(B>>>16)+(g>>>16)+((e=(65535&B)+(65535&g))>>>16))>>>16))>>>16))<<16|65535&o)>>>28|(Q=n<<16|65535&e)<<4)^(Q>>>2|L<<30)^(Q>>>7|L<<25),i=(Q>>>28|L<<4)^(L>>>2|Q<<30)^(L>>>7|Q<<25),s=(sh>>>14|rh<<18)^(sh>>>18|rh<<14)^(rh>>>9|sh<<23),r=(rh>>>14|sh<<18)^(rh>>>18|sh<<14)^(sh>>>9|rh<<23),_=(u=L&F)^L&W^l,w=(y=Q&T)^Q&Y^f,U=sh&X^~sh&$,O=rh&Z^~rh&hh,A=M[h+2],g=M[h+3],A=(a=((S=c[h+2])>>>16)+(A>>>16)+(U>>>16)+(s>>>16)+(th>>>16)+((o=(65535&S)+(65535&A)+(65535&U)+(65535&s)+(65535&th)+((n=((B=c[h+3])>>>16)+(g>>>16)+(O>>>16)+(r>>>16)+(ih>>>16)+((e=(65535&B)+(65535&g)+(65535&O)+(65535&r)+(65535&ih))>>>16))>>>16))>>>16))<<16|65535&o,g=n<<16|65535&e,S=(a=(_>>>16)+(t>>>16)+((o=(65535&_)+(65535&t)+((n=(w>>>16)+(i>>>16)+((e=(65535&w)+(65535&i))>>>16))>>>16))>>>16))<<16|65535&o,B=n<<16|65535&e,th=(a=(q>>>16)+(A>>>16)+((o=(65535&q)+(65535&A)+((n=(G>>>16)+(g>>>16)+((e=(65535&G)+(65535&g))>>>16))>>>16))>>>16))<<16|65535&o,ih=n<<16|65535&e,t=((q=(a=(S>>>16)+(A>>>16)+((o=(65535&S)+(65535&A)+((n=(B>>>16)+(g>>>16)+((e=(65535&B)+(65535&g))>>>16))>>>16))>>>16))<<16|65535&o)>>>28|(G=n<<16|65535&e)<<4)^(G>>>2|q<<30)^(G>>>7|q<<25),i=(G>>>28|q<<4)^(q>>>2|G<<30)^(q>>>7|G<<25),s=(th>>>14|ih<<18)^(th>>>18|ih<<14)^(ih>>>9|th<<23),r=(ih>>>14|th<<18)^(ih>>>18|th<<14)^(th>>>9|ih<<23),_=(p=q&L)^q&F^u,w=(d=G&Q)^G&T^y,U=th&sh^~th&X,O=ih&rh^~ih&Z,A=M[h+4],g=M[h+5],A=(a=((S=c[h+4])>>>16)+(A>>>16)+(U>>>16)+(s>>>16)+($>>>16)+((o=(65535&S)+(65535&A)+(65535&U)+(65535&s)+(65535&$)+((n=((B=c[h+5])>>>16)+(g>>>16)+(O>>>16)+(r>>>16)+(hh>>>16)+((e=(65535&B)+(65535&g)+(65535&O)+(65535&r)+(65535&hh))>>>16))>>>16))>>>16))<<16|65535&o,g=n<<16|65535&e,S=(a=(_>>>16)+(t>>>16)+((o=(65535&_)+(65535&t)+((n=(w>>>16)+(i>>>16)+((e=(65535&w)+(65535&i))>>>16))>>>16))>>>16))<<16|65535&o,B=n<<16|65535&e,$=(a=(W>>>16)+(A>>>16)+((o=(65535&W)+(65535&A)+((n=(Y>>>16)+(g>>>16)+((e=(65535&Y)+(65535&g))>>>16))>>>16))>>>16))<<16|65535&o,hh=n<<16|65535&e,t=((W=(a=(S>>>16)+(A>>>16)+((o=(65535&S)+(65535&A)+((n=(B>>>16)+(g>>>16)+((e=(65535&B)+(65535&g))>>>16))>>>16))>>>16))<<16|65535&o)>>>28|(Y=n<<16|65535&e)<<4)^(Y>>>2|W<<30)^(Y>>>7|W<<25),i=(Y>>>28|W<<4)^(W>>>2|Y<<30)^(W>>>7|Y<<25),s=($>>>14|hh<<18)^($>>>18|hh<<14)^(hh>>>9|$<<23),r=(hh>>>14|$<<18)^(hh>>>18|$<<14)^($>>>9|hh<<23),_=(b=W&q)^W&L^p,w=(v=Y&G)^Y&Q^d,U=$&th^~$&sh,O=hh&ih^~hh&rh,A=M[h+6],g=M[h+7],A=(a=((S=c[h+6])>>>16)+(A>>>16)+(U>>>16)+(s>>>16)+(X>>>16)+((o=(65535&S)+(65535&A)+(65535&U)+(65535&s)+(65535&X)+((n=((B=c[h+7])>>>16)+(g>>>16)+(O>>>16)+(r>>>16)+(Z>>>16)+((e=(65535&B)+(65535&g)+(65535&O)+(65535&r)+(65535&Z))>>>16))>>>16))>>>16))<<16|65535&o,g=n<<16|65535&e,S=(a=(_>>>16)+(t>>>16)+((o=(65535&_)+(65535&t)+((n=(w>>>16)+(i>>>16)+((e=(65535&w)+(65535&i))>>>16))>>>16))>>>16))<<16|65535&o,B=n<<16|65535&e,X=(a=(F>>>16)+(A>>>16)+((o=(65535&F)+(65535&A)+((n=(T>>>16)+(g>>>16)+((e=(65535&T)+(65535&g))>>>16))>>>16))>>>16))<<16|65535&o,Z=n<<16|65535&e,F=(a=(S>>>16)+(A>>>16)+((o=(65535&S)+(65535&A)+((n=(B>>>16)+(g>>>16)+((e=(65535&B)+(65535&g))>>>16))>>>16))>>>16))<<16|65535&o,T=n<<16|65535&e;a=(k>>>16)+(F>>>16)+((o=(65535&k)+(65535&F)+((n=(x>>>16)+(T>>>16)+((e=(65535&x)+(65535&T))>>>16))>>>16))>>>16),this.h0h=a<<16|65535&o,this.h0l=n<<16|65535&e,a=(z>>>16)+(W>>>16)+((o=(65535&z)+(65535&W)+((n=(j>>>16)+(Y>>>16)+((e=(65535&j)+(65535&Y))>>>16))>>>16))>>>16),this.h1h=a<<16|65535&o,this.h1l=n<<16|65535&e,a=(E>>>16)+(q>>>16)+((o=(65535&E)+(65535&q)+((n=(N>>>16)+(G>>>16)+((e=(65535&N)+(65535&G))>>>16))>>>16))>>>16),this.h2h=a<<16|65535&o,this.h2l=n<<16|65535&e,a=(m>>>16)+(L>>>16)+((o=(65535&m)+(65535&L)+((n=(J>>>16)+(Q>>>16)+((e=(65535&J)+(65535&Q))>>>16))>>>16))>>>16),this.h3h=a<<16|65535&o,this.h3l=n<<16|65535&e,a=(P>>>16)+(X>>>16)+((o=(65535&P)+(65535&X)+((n=(H>>>16)+(Z>>>16)+((e=(65535&H)+(65535&Z))>>>16))>>>16))>>>16),this.h4h=a<<16|65535&o,this.h4l=n<<16|65535&e,a=(I>>>16)+($>>>16)+((o=(65535&I)+(65535&$)+((n=(R>>>16)+(hh>>>16)+((e=(65535&R)+(65535&hh))>>>16))>>>16))>>>16),this.h5h=a<<16|65535&o,this.h5l=n<<16|65535&e,a=(V>>>16)+(th>>>16)+((o=(65535&V)+(65535&th)+((n=(C>>>16)+(ih>>>16)+((e=(65535&C)+(65535&ih))>>>16))>>>16))>>>16),this.h6h=a<<16|65535&o,this.h6l=n<<16|65535&e,a=(D>>>16)+(sh>>>16)+((o=(65535&D)+(65535&sh)+((n=(K>>>16)+(rh>>>16)+((e=(65535&K)+(65535&rh))>>>16))>>>16))>>>16),this.h7h=a<<16|65535&o,this.h7l=n<<16|65535&e},_.prototype.hex=function(){this.finalize();var h=this.h0h,t=this.h0l,i=this.h1h,s=this.h1l,r=this.h2h,e=this.h2l,n=this.h3h,o=this.h3l,l=this.h4h,f=this.h4l,c=this.h5h,u=this.h5l,y=this.h6h,p=this.h6l,d=this.h7h,b=this.h7l,v=this.bits,_=a[h>>28&15]+a[h>>24&15]+a[h>>20&15]+a[h>>16&15]+a[h>>12&15]+a[h>>8&15]+a[h>>4&15]+a[15&h]+a[t>>28&15]+a[t>>24&15]+a[t>>20&15]+a[t>>16&15]+a[t>>12&15]+a[t>>8&15]+a[t>>4&15]+a[15&t]+a[i>>28&15]+a[i>>24&15]+a[i>>20&15]+a[i>>16&15]+a[i>>12&15]+a[i>>8&15]+a[i>>4&15]+a[15&i]+a[s>>28&15]+a[s>>24&15]+a[s>>20&15]+a[s>>16&15]+a[s>>12&15]+a[s>>8&15]+a[s>>4&15]+a[15&s]+a[r>>28&15]+a[r>>24&15]+a[r>>20&15]+a[r>>16&15]+a[r>>12&15]+a[r>>8&15]+a[r>>4&15]+a[15&r]+a[e>>28&15]+a[e>>24&15]+a[e>>20&15]+a[e>>16&15]+a[e>>12&15]+a[e>>8&15]+a[e>>4&15]+a[15&e]+a[n>>28&15]+a[n>>24&15]+a[n>>20&15]+a[n>>16&15]+a[n>>12&15]+a[n>>8&15]+a[n>>4&15]+a[15&n];return v>=256&&(_+=a[o>>28&15]+a[o>>24&15]+a[o>>20&15]+a[o>>16&15]+a[o>>12&15]+a[o>>8&15]+a[o>>4&15]+a[15&o]),v>=384&&(_+=a[l>>28&15]+a[l>>24&15]+a[l>>20&15]+a[l>>16&15]+a[l>>12&15]+a[l>>8&15]+a[l>>4&15]+a[15&l]+a[f>>28&15]+a[f>>24&15]+a[f>>20&15]+a[f>>16&15]+a[f>>12&15]+a[f>>8&15]+a[f>>4&15]+a[15&f]+a[c>>28&15]+a[c>>24&15]+a[c>>20&15]+a[c>>16&15]+a[c>>12&15]+a[c>>8&15]+a[c>>4&15]+a[15&c]+a[u>>28&15]+a[u>>24&15]+a[u>>20&15]+a[u>>16&15]+a[u>>12&15]+a[u>>8&15]+a[u>>4&15]+a[15&u]),512==v&&(_+=a[y>>28&15]+a[y>>24&15]+a[y>>20&15]+a[y>>16&15]+a[y>>12&15]+a[y>>8&15]+a[y>>4&15]+a[15&y]+a[p>>28&15]+a[p>>24&15]+a[p>>20&15]+a[p>>16&15]+a[p>>12&15]+a[p>>8&15]+a[p>>4&15]+a[15&p]+a[d>>28&15]+a[d>>24&15]+a[d>>20&15]+a[d>>16&15]+a[d>>12&15]+a[d>>8&15]+a[d>>4&15]+a[15&d]+a[b>>28&15]+a[b>>24&15]+a[b>>20&15]+a[b>>16&15]+a[b>>12&15]+a[b>>8&15]+a[b>>4&15]+a[15&b]),_},_.prototype.toString=_.prototype.hex,_.prototype.digest=function(){this.finalize();var h=this.h0h,t=this.h0l,i=this.h1h,s=this.h1l,r=this.h2h,e=this.h2l,n=this.h3h,o=this.h3l,a=this.h4h,l=this.h4l,f=this.h5h,c=this.h5l,u=this.h6h,y=this.h6l,p=this.h7h,d=this.h7l,b=this.bits,v=[h>>24&255,h>>16&255,h>>8&255,255&h,t>>24&255,t>>16&255,t>>8&255,255&t,i>>24&255,i>>16&255,i>>8&255,255&i,s>>24&255,s>>16&255,s>>8&255,255&s,r>>24&255,r>>16&255,r>>8&255,255&r,e>>24&255,e>>16&255,e>>8&255,255&e,n>>24&255,n>>16&255,n>>8&255,255&n];return b>=256&&v.push(o>>24&255,o>>16&255,o>>8&255,255&o),b>=384&&v.push(a>>24&255,a>>16&255,a>>8&255,255&a,l>>24&255,l>>16&255,l>>8&255,255&l,f>>24&255,f>>16&255,f>>8&255,255&f,c>>24&255,c>>16&255,c>>8&255,255&c),512==b&&v.push(u>>24&255,u>>16&255,u>>8&255,255&u,y>>24&255,y>>16&255,y>>8&255,255&y,p>>24&255,p>>16&255,p>>8&255,255&p,d>>24&255,d>>16&255,d>>8&255,255&d),v},_.prototype.array=_.prototype.digest,_.prototype.arrayBuffer=function(){this.finalize();var h=this.bits,t=new ArrayBuffer(h/8),i=new DataView(t);return i.setUint32(0,this.h0h),i.setUint32(4,this.h0l),i.setUint32(8,this.h1h),i.setUint32(12,this.h1l),i.setUint32(16,this.h2h),i.setUint32(20,this.h2l),i.setUint32(24,this.h3h),h>=256&&i.setUint32(28,this.h3l),h>=384&&(i.setUint32(32,this.h4h),i.setUint32(36,this.h4l),i.setUint32(40,this.h5h),i.setUint32(44,this.h5l)),512==h&&(i.setUint32(48,this.h6h),i.setUint32(52,this.h6l),i.setUint32(56,this.h7h),i.setUint32(60,this.h7l)),t},_.prototype.clone=function(){var h=new _(this.bits,!1);return this.copyTo(h),h},_.prototype.copyTo=function(h){var t=0,i=["h0h","h0l","h1h","h1l","h2h","h2l","h3h","h3l","h4h","h4l","h5h","h5l","h6h","h6l","h7h","h7l","start","bytes","hBytes","finalized","hashed","lastByteIndex"];for(t=0;t<i.length;++t)h[i[t]]=this[i[t]];for(t=0;t<this.blocks.length;++t)h.blocks[t]=this.blocks[t]},w.prototype=new _,w.prototype.finalize=function(){if(_.prototype.finalize.call(this),this.inner){this.inner=!1;var h=this.array();_.call(this,this.bits,this.sharedMemory),this.update(this.oKeyPad),this.update(h),_.prototype.finalize.call(this)}},w.prototype.clone=function(){var h=new w([],this.bits,!1);this.copyTo(h),h.inner=this.inner;for(var t=0;t<this.oKeyPad.length;++t)h.oKeyPad[t]=this.oKeyPad[t];return h};var A=d(512);A.sha512=A,A.sha384=d(384),A.sha512_256=d(256),A.sha512_224=d(224),A.sha512.hmac=v(512),A.sha384.hmac=v(384),A.sha512_256.hmac=v(256),A.sha512_224.hmac=v(224),n?h.exports=A:(r.sha512=A.sha512,r.sha384=A.sha384,r.sha512_256=A.sha512_256,r.sha512_224=A.sha512_224)}()}(e)),e.exports);
|
|
2
|
+
/*
|
|
3
|
+
* [js-sha512]{@link https://github.com/emn178/js-sha512}
|
|
4
|
+
*
|
|
5
|
+
* @version 0.8.0
|
|
6
|
+
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
7
|
+
* @copyright Chen, Yi-Cyuan 2014-2018
|
|
8
|
+
* @license MIT
|
|
9
|
+
*/h("s",t({__proto__:null,default:s(n)},[n]))}}}));
|
package/frontend/index.html
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
if (isModernBrowser())
|
|
22
22
|
document.getElementById('root').innerHTML = 'Loading...'
|
|
23
23
|
</script>
|
|
24
|
-
<script crossorigin id="vite-legacy-polyfill" src="/assets/polyfills-legacy-
|
|
25
|
-
<script crossorigin id="vite-legacy-entry" data-src="/assets/index-legacy-
|
|
24
|
+
<script crossorigin id="vite-legacy-polyfill" src="/assets/polyfills-legacy-Ca1TOBqp.js"></script>
|
|
25
|
+
<script crossorigin id="vite-legacy-entry" data-src="/assets/index-legacy-BEI2K_mw.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script>
|
|
26
26
|
</body>
|
|
27
27
|
</html>
|
package/package.json
CHANGED
package/src/SendList.js
CHANGED
|
@@ -45,7 +45,7 @@ class SendListReadable extends stream_1.Readable {
|
|
|
45
45
|
this.push(this.buffer);
|
|
46
46
|
this.buffer = [];
|
|
47
47
|
}, bufferTime, { maxWait: bufferTime });
|
|
48
|
-
this.on('
|
|
48
|
+
this.on('close', () => {
|
|
49
49
|
onEnd === null || onEnd === void 0 ? void 0 : onEnd(this);
|
|
50
50
|
this.destroy();
|
|
51
51
|
});
|
package/src/adminApis.js
CHANGED
|
@@ -170,7 +170,7 @@ const frpDebounced = (0, misc_1.debounceAsync)(async () => {
|
|
|
170
170
|
catch (_a) {
|
|
171
171
|
return false;
|
|
172
172
|
}
|
|
173
|
-
});
|
|
173
|
+
}, { retain: 10000 });
|
|
174
174
|
function anyAccountCanLoginAdmin() {
|
|
175
175
|
return Boolean(lodash_1.default.find(perm_1.accountsConfig.get(), perm_1.accountCanLoginAdmin));
|
|
176
176
|
}
|
package/src/api.auth.js
CHANGED
|
@@ -29,6 +29,8 @@ const loginSrp1 = async ({ username }, ctx) => {
|
|
|
29
29
|
ctx.state.dontLog = false; // log even if log_api is false
|
|
30
30
|
return new apiMiddleware_1.ApiError(const_1.HTTP_UNAUTHORIZED);
|
|
31
31
|
}
|
|
32
|
+
if ((0, middlewares_1.failAllowNet)(ctx, account))
|
|
33
|
+
return new apiMiddleware_1.ApiError(const_1.HTTP_UNAUTHORIZED);
|
|
32
34
|
try {
|
|
33
35
|
const { srpServer, ...rest } = await (0, auth_1.srpServerStep1)(account);
|
|
34
36
|
const sid = Math.random();
|
package/src/api.get_file_list.js
CHANGED
|
@@ -62,8 +62,6 @@ const get_file_list = async ({ uri = '/', offset, limit, search, wild, c, onlyFo
|
|
|
62
62
|
}
|
|
63
63
|
async function* produceEntries() {
|
|
64
64
|
for await (const sub of walker) {
|
|
65
|
-
if (ctx.aborted)
|
|
66
|
-
break;
|
|
67
65
|
let name = (0, vfs_1.getNodeName)(sub);
|
|
68
66
|
name = (0, path_1.basename)(name) || name; // on windows, basename('C:') === ''
|
|
69
67
|
if (comments_1.descriptIon.get() && name === comments_1.DESCRIPT_ION)
|
package/src/api.vfs.js
CHANGED
|
@@ -13,8 +13,6 @@ const misc_1 = require("./misc");
|
|
|
13
13
|
const const_1 = require("./const");
|
|
14
14
|
const util_os_1 = require("./util-os");
|
|
15
15
|
const listen_1 = require("./listen");
|
|
16
|
-
const util_1 = require("util");
|
|
17
|
-
const child_process_1 = require("child_process");
|
|
18
16
|
const SendList_1 = require("./SendList");
|
|
19
17
|
// to manipulate the tree we need the original node
|
|
20
18
|
async function urlToNodeOriginal(uri) {
|
|
@@ -189,7 +187,7 @@ const apis = {
|
|
|
189
187
|
const matching = (0, misc_1.makeMatcher)(fileMask);
|
|
190
188
|
path = (0, misc_1.isWindowsDrive)(path) ? path + '\\' : (0, path_1.resolve)(path || '/');
|
|
191
189
|
for await (const entry of (0, misc_1.dirStream)(path)) {
|
|
192
|
-
if (ctx.req.
|
|
190
|
+
if (ctx.req.destroyed)
|
|
193
191
|
return;
|
|
194
192
|
const { path: name } = entry;
|
|
195
193
|
const isDir = entry.isDirectory();
|
|
@@ -222,9 +220,9 @@ const apis = {
|
|
|
222
220
|
const h = status.http.listening ? status.http : status.https;
|
|
223
221
|
const url = h.srv.name + '://localhost:' + h.port;
|
|
224
222
|
for (const k of ['*', 'Directory']) {
|
|
225
|
-
await reg('add', WINDOWS_REG_KEY.replace('*', k), '/ve', '/f', '/d', 'Add to HFS (new)');
|
|
226
|
-
await reg('add', WINDOWS_REG_KEY.replace('*', k), '/v', 'icon', '/f', '/d', const_1.IS_BINARY ? process.execPath : const_1.APP_PATH + '\\hfs.ico');
|
|
227
|
-
await reg('add', WINDOWS_REG_KEY.replace('*', k) + '\\command', '/ve', '/f', '/d', `powershell -WindowStyle Hidden -Command "
|
|
223
|
+
await (0, util_os_1.reg)('add', WINDOWS_REG_KEY.replace('*', k), '/ve', '/f', '/d', 'Add to HFS (new)');
|
|
224
|
+
await (0, util_os_1.reg)('add', WINDOWS_REG_KEY.replace('*', k), '/v', 'icon', '/f', '/d', const_1.IS_BINARY ? process.execPath : const_1.APP_PATH + '\\hfs.ico');
|
|
225
|
+
await (0, util_os_1.reg)('add', WINDOWS_REG_KEY.replace('*', k) + '\\command', '/ve', '/f', '/d', `powershell -WindowStyle Hidden -Command "
|
|
228
226
|
$wsh = New-Object -ComObject Wscript.Shell;
|
|
229
227
|
$j = @{parent=@'\n${parent}\n'@; source=@'\n%1\n'@} | ConvertTo-Json -Compress
|
|
230
228
|
$j = [System.Text.Encoding]::UTF8.GetBytes($j);
|
|
@@ -238,13 +236,13 @@ const apis = {
|
|
|
238
236
|
},
|
|
239
237
|
async windows_integrated() {
|
|
240
238
|
return {
|
|
241
|
-
is: await reg('query', WINDOWS_REG_KEY)
|
|
242
|
-
.then(x => x.
|
|
239
|
+
is: await (0, util_os_1.reg)('query', WINDOWS_REG_KEY)
|
|
240
|
+
.then(x => x.includes('REG_SZ'), () => false)
|
|
243
241
|
};
|
|
244
242
|
},
|
|
245
243
|
async windows_remove() {
|
|
246
244
|
for (const k of ['*', 'Directory'])
|
|
247
|
-
await reg('delete', WINDOWS_REG_KEY.replace('*', k), '/f');
|
|
245
|
+
await (0, util_os_1.reg)('delete', WINDOWS_REG_KEY.replace('*', k), '/f');
|
|
248
246
|
return {};
|
|
249
247
|
},
|
|
250
248
|
};
|
|
@@ -264,6 +262,3 @@ function simplifyName(node) {
|
|
|
264
262
|
delete node.name;
|
|
265
263
|
}
|
|
266
264
|
const WINDOWS_REG_KEY = 'HKCU\\Software\\Classes\\*\\shell\\AddToHFS3';
|
|
267
|
-
function reg(...pars) {
|
|
268
|
-
return (0, util_1.promisify)(child_process_1.execFile)('reg', pars);
|
|
269
|
-
}
|
package/src/auth.js
CHANGED
package/src/basicWeb.js
CHANGED
|
@@ -62,7 +62,7 @@ exports.basicWeb = basicWeb;
|
|
|
62
62
|
function detectBasicAgent(ctx) {
|
|
63
63
|
const ua = ctx.get('user-agent');
|
|
64
64
|
const v = autoBasic.get();
|
|
65
|
-
return v && (
|
|
65
|
+
return v && (/^$|Mozilla\/4|WebKit\/([234]\d\d|5[012]\d|53[0123456])[. ]|Trident|Lynx|curl|Firefox\/(\d|[1234]\d)\./.test(ua)
|
|
66
66
|
|| lodash_1.default.isString(v) && ua.includes(v));
|
|
67
67
|
}
|
|
68
68
|
exports.detectBasicAgent = detectBasicAgent;
|
package/src/commands.js
CHANGED
|
@@ -18,7 +18,7 @@ const github_1 = require("./github");
|
|
|
18
18
|
const cross_1 = require("./cross");
|
|
19
19
|
const api_monitor_1 = __importDefault(require("./api.monitor"));
|
|
20
20
|
const argv_1 = require("./argv");
|
|
21
|
-
if (!argv_1.argv.updating)
|
|
21
|
+
if (!argv_1.argv.updating && !config_1.showHelp)
|
|
22
22
|
try {
|
|
23
23
|
/*
|
|
24
24
|
is this try-block useful in case the stdin is unavailable?
|
|
@@ -49,9 +49,7 @@ function parseCommandLine(line) {
|
|
|
49
49
|
console.error("command failed:", err.message || err);
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
const aliases = {
|
|
53
|
-
exit: 'quit',
|
|
54
|
-
};
|
|
52
|
+
const aliases = { ver: 'version', exit: 'quit' };
|
|
55
53
|
const commands = {
|
|
56
54
|
help: {
|
|
57
55
|
params: '',
|
|
@@ -121,8 +119,7 @@ const commands = {
|
|
|
121
119
|
version: {
|
|
122
120
|
params: '',
|
|
123
121
|
cb() {
|
|
124
|
-
console.log(const_1.VERSION);
|
|
125
|
-
console.log(const_1.BUILD_TIMESTAMP);
|
|
122
|
+
console.log(const_1.VERSION, 'build', const_1.BUILD_TIMESTAMP);
|
|
126
123
|
}
|
|
127
124
|
},
|
|
128
125
|
'start-plugin': {
|
package/src/config.js
CHANGED
|
@@ -27,12 +27,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.configFile = exports.saveConfigAsap = exports.setConfig = exports.getWholeConfig = exports.getConfig = exports.configKeyExists = exports.defineConfig = exports.currentVersion = exports.versionToScalar = void 0;
|
|
30
|
+
exports.showHelp = exports.configFile = exports.saveConfigAsap = exports.setConfig = exports.getWholeConfig = exports.getConfig = exports.configKeyExists = exports.defineConfig = exports.currentVersion = exports.versionToScalar = void 0;
|
|
31
31
|
const const_1 = require("./const");
|
|
32
32
|
const watchLoad_1 = require("./watchLoad");
|
|
33
33
|
const yaml_1 = __importDefault(require("yaml"));
|
|
34
34
|
const lodash_1 = __importDefault(require("lodash"));
|
|
35
|
-
const
|
|
35
|
+
const cross_1 = require("./cross");
|
|
36
|
+
const debounceAsync_1 = require("./debounceAsync");
|
|
36
37
|
const fs_1 = require("fs");
|
|
37
38
|
const path_1 = require("path");
|
|
38
39
|
const events_1 = __importDefault(require("./events"));
|
|
@@ -44,7 +45,7 @@ const argv_1 = require("./argv");
|
|
|
44
45
|
const configProps = {};
|
|
45
46
|
let started = false; // this will tell the difference for subscribeConfig()s that are called before or after config is loaded
|
|
46
47
|
let state = {}; // current state of config properties
|
|
47
|
-
const filePath = (0,
|
|
48
|
+
const filePath = (0, cross_1.with_)(argv_1.argv.config || process.env.HFS_CONFIG, p => {
|
|
48
49
|
if (!p)
|
|
49
50
|
return const_1.CONFIG_FILE;
|
|
50
51
|
p = (0, path_1.resolve)(const_1.ORIGINAL_CWD, p);
|
|
@@ -108,7 +109,7 @@ function defineConfig(k, defaultValue, compiler) {
|
|
|
108
109
|
else
|
|
109
110
|
setConfig1(k, v);
|
|
110
111
|
},
|
|
111
|
-
compiled: () => (compiler ? compiled : (0,
|
|
112
|
+
compiled: () => (compiler ? compiled : (0, cross_1.throw_)("missing compiler")),
|
|
112
113
|
};
|
|
113
114
|
if (compiler)
|
|
114
115
|
ret.sub((...args) => compiled = compiler(...args));
|
|
@@ -126,7 +127,7 @@ function getConfig(k) {
|
|
|
126
127
|
}
|
|
127
128
|
exports.getConfig = getConfig;
|
|
128
129
|
function getWholeConfig({ omit, only }) {
|
|
129
|
-
const defs = (0,
|
|
130
|
+
const defs = (0, cross_1.newObj)(configProps, x => x.defaultValue);
|
|
130
131
|
let copy = lodash_1.default.defaults({}, state, defs);
|
|
131
132
|
if (omit === null || omit === void 0 ? void 0 : omit.length)
|
|
132
133
|
copy = lodash_1.default.omit(copy, omit);
|
|
@@ -140,7 +141,7 @@ function setConfig(newCfg, save) {
|
|
|
140
141
|
const version = lodash_1.default.isString(newCfg.version) ? new Version(newCfg.version) : undefined;
|
|
141
142
|
const considerEnvs = !process.env['HFS_ENV_BOOTSTRAP'] || !started && lodash_1.default.isEmpty(newCfg);
|
|
142
143
|
// first time we consider also CLI args
|
|
143
|
-
const argCfg = !started && lodash_1.default.pickBy((0,
|
|
144
|
+
const argCfg = !started && lodash_1.default.pickBy((0, cross_1.newObj)(configProps, (x, k) => { var _a; return (_a = argv_1.argv[k]) !== null && _a !== void 0 ? _a : (0, cross_1.tryJson)(considerEnvs ? process.env['HFS_' + k.toUpperCase().replaceAll('-', '_')] : '', lodash_1.default.identity); }), x => x !== undefined);
|
|
144
145
|
if (!lodash_1.default.isEmpty(argCfg)) {
|
|
145
146
|
(0, exports.saveConfigAsap)(); // don't set `save` argument, as it would interfere below at check `save===false`
|
|
146
147
|
Object.assign(newCfg, argCfg);
|
|
@@ -163,7 +164,7 @@ function setConfig(newCfg, save) {
|
|
|
163
164
|
if (!newCfg.hasOwnProperty(k))
|
|
164
165
|
apply(k, newCfg[k], true);
|
|
165
166
|
started = true;
|
|
166
|
-
events_1.default.emit('configReady');
|
|
167
|
+
events_1.default.emit('configReady', startedWithoutConfig);
|
|
167
168
|
if (version !== const_1.VERSION) // be sure to save version
|
|
168
169
|
(0, exports.saveConfigAsap)();
|
|
169
170
|
function apply(k, newV, isDefault = false) {
|
|
@@ -189,12 +190,12 @@ function setConfig1(k, newV, saveChanges = true, valueVersion) {
|
|
|
189
190
|
return a === b || JSON.stringify(a) === JSON.stringify(b);
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
|
-
const saveDebounced = (0,
|
|
193
|
+
const saveDebounced = (0, debounceAsync_1.debounceAsync)(async () => {
|
|
193
194
|
while (!started)
|
|
194
|
-
await (0,
|
|
195
|
+
await (0, cross_1.wait)(100);
|
|
195
196
|
// keep backup
|
|
196
197
|
const bak = filePath + '.bak';
|
|
197
|
-
const aWeekAgo = Date.now() -
|
|
198
|
+
const aWeekAgo = Date.now() - cross_1.DAY * 7;
|
|
198
199
|
if (await (0, promises_1.stat)(bak).then(x => aWeekAgo > Number(x.mtime || x.ctime), () => true))
|
|
199
200
|
await (0, promises_1.copyFile)(filePath, bak).catch(() => { }); // ignore errors
|
|
200
201
|
await exports.configFile.save(stringify({ ...state, version: const_1.VERSION }))
|
|
@@ -205,8 +206,10 @@ exports.saveConfigAsap = saveConfigAsap;
|
|
|
205
206
|
function stringify(obj) {
|
|
206
207
|
return yaml_1.default.stringify(obj, { lineWidth: 1000 });
|
|
207
208
|
}
|
|
209
|
+
let startedWithoutConfig = false;
|
|
208
210
|
console.log("config", filePath);
|
|
209
211
|
exports.configFile = (0, watchLoad_1.watchLoad)(filePath, text => {
|
|
212
|
+
startedWithoutConfig = !text;
|
|
210
213
|
try {
|
|
211
214
|
setConfig(yaml_1.default.parse(text, { uniqueKeys: false }) || {}, false);
|
|
212
215
|
}
|
|
@@ -215,8 +218,26 @@ exports.configFile = (0, watchLoad_1.watchLoad)(filePath, text => {
|
|
|
215
218
|
}
|
|
216
219
|
}, {
|
|
217
220
|
failedOnFirstAttempt() {
|
|
221
|
+
startedWithoutConfig = true;
|
|
218
222
|
console.log("No config file, using defaults");
|
|
219
223
|
setTimeout(() => // this is called synchronously, but we need to call setConfig after first tick, when all configs are defined
|
|
220
224
|
setConfig({}, false));
|
|
221
225
|
}
|
|
222
226
|
});
|
|
227
|
+
exports.showHelp = argv_1.argv.help;
|
|
228
|
+
events_1.default.on('configReady', () => {
|
|
229
|
+
if (!exports.showHelp)
|
|
230
|
+
return;
|
|
231
|
+
console.log(`HELP
|
|
232
|
+
You can pass any configuration in the form: --name value
|
|
233
|
+
Most common configurations:
|
|
234
|
+
--create-admin <password>
|
|
235
|
+
--port <port>
|
|
236
|
+
--cert <path>
|
|
237
|
+
--private_key <path>
|
|
238
|
+
--consoleFile <path>
|
|
239
|
+
|
|
240
|
+
For a description of each configuration, please refer to https://rejetto.com/hfs-config
|
|
241
|
+
`);
|
|
242
|
+
process.exit(0);
|
|
243
|
+
});
|
package/src/const.js
CHANGED
|
@@ -39,7 +39,7 @@ const path_1 = require("path");
|
|
|
39
39
|
const cross_1 = require("./cross");
|
|
40
40
|
const argv_1 = require("./argv");
|
|
41
41
|
__exportStar(require("./cross-const"), exports);
|
|
42
|
-
exports.API_VERSION =
|
|
42
|
+
exports.API_VERSION = 11;
|
|
43
43
|
exports.COMPATIBLE_API_VERSION = 1; // while changes in the api are not breaking, this number stays the same, otherwise it is made equal to API_VERSION
|
|
44
44
|
// you can add arguments with this file, currently used for the update process on mac/linux
|
|
45
45
|
exports.ARGS_FILE = (0, path_1.join)((0, os_1.homedir)(), 'hfs-args');
|
|
@@ -54,7 +54,7 @@ exports.DEV = process.env.DEV || argv_1.argv.dev ? 'DEV' : '';
|
|
|
54
54
|
exports.ORIGINAL_CWD = process.cwd();
|
|
55
55
|
exports.HFS_STARTED = new Date();
|
|
56
56
|
const PKG_PATH = (0, path_1.join)(__dirname, '..', 'package.json');
|
|
57
|
-
exports.BUILD_TIMESTAMP = "2025-01-
|
|
57
|
+
exports.BUILD_TIMESTAMP = "2025-01-13T21:57:50.445Z";
|
|
58
58
|
const pkg = JSON.parse(fs.readFileSync(PKG_PATH, 'utf8'));
|
|
59
59
|
exports.VERSION = pkg.version;
|
|
60
60
|
exports.RUNNING_BETA = exports.VERSION.includes('-');
|
package/src/cross-const.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HTTP_MESSAGES = exports.HTTP_SERVICE_UNAVAILABLE = exports.HTTP_SERVER_ERROR = exports.HTTP_TOO_MANY_REQUESTS = exports.HTTP_FAILED_DEPENDENCY = exports.HTTP_FOOL = exports.HTTP_RANGE_NOT_SATISFIABLE = exports.HTTP_PAYLOAD_TOO_LARGE = exports.HTTP_PRECONDITION_FAILED = exports.HTTP_CONFLICT = exports.HTTP_NOT_ACCEPTABLE = exports.HTTP_METHOD_NOT_ALLOWED = exports.HTTP_NOT_FOUND = exports.HTTP_FORBIDDEN = exports.HTTP_UNAUTHORIZED = exports.HTTP_BAD_REQUEST = exports.HTTP_NOT_MODIFIED = exports.HTTP_TEMPORARY_REDIRECT = exports.HTTP_MOVED_PERMANENTLY = exports.HTTP_PARTIAL_CONTENT = exports.HTTP_NO_CONTENT = exports.HTTP_OK = exports.UPLOAD_STATUS = exports.UPLOAD_RESUMABLE = exports.HFS_REPO = exports.PLUGIN_CUSTOM_REST_PREFIX = exports.NBSP = exports.PORT_DISABLED = exports.PLUGINS_PUB_URI = exports.API_URI = exports.ADMIN_URI = exports.FRONTEND_URI = exports.SPECIAL_URI = void 0;
|
|
3
|
+
exports.HTTP_MESSAGES = exports.HTTP_SERVICE_UNAVAILABLE = exports.HTTP_SERVER_ERROR = exports.HTTP_TOO_MANY_REQUESTS = exports.HTTP_FAILED_DEPENDENCY = exports.HTTP_FOOL = exports.HTTP_RANGE_NOT_SATISFIABLE = exports.HTTP_PAYLOAD_TOO_LARGE = exports.HTTP_PRECONDITION_FAILED = exports.HTTP_CONFLICT = exports.HTTP_NOT_ACCEPTABLE = exports.HTTP_METHOD_NOT_ALLOWED = exports.HTTP_NOT_FOUND = exports.HTTP_FORBIDDEN = exports.HTTP_UNAUTHORIZED = exports.HTTP_BAD_REQUEST = exports.HTTP_NOT_MODIFIED = exports.HTTP_TEMPORARY_REDIRECT = exports.HTTP_MOVED_PERMANENTLY = exports.HTTP_PARTIAL_CONTENT = exports.HTTP_NO_CONTENT = exports.HTTP_OK = exports.UPLOAD_STATUS = exports.UPLOAD_RESUMABLE = exports.HFS_REPO = exports.PLUGIN_CUSTOM_REST_PREFIX = exports.NBSP = exports.PORT_DISABLED = exports.ICONS_URI = exports.PLUGINS_PUB_URI = exports.API_URI = exports.ADMIN_URI = exports.FRONTEND_URI = exports.SPECIAL_URI = void 0;
|
|
4
4
|
exports.SPECIAL_URI = '/~/';
|
|
5
5
|
exports.FRONTEND_URI = exports.SPECIAL_URI + 'frontend/';
|
|
6
6
|
exports.ADMIN_URI = exports.SPECIAL_URI + 'admin/';
|
|
7
7
|
exports.API_URI = exports.SPECIAL_URI + 'api/';
|
|
8
8
|
exports.PLUGINS_PUB_URI = exports.SPECIAL_URI + 'plugins/';
|
|
9
|
+
exports.ICONS_URI = exports.SPECIAL_URI + 'icons/';
|
|
9
10
|
exports.PORT_DISABLED = -1;
|
|
10
11
|
exports.NBSP = '\xA0';
|
|
11
12
|
exports.PLUGIN_CUSTOM_REST_PREFIX = '_';
|
package/src/cross.js
CHANGED
|
@@ -363,7 +363,7 @@ function isNumeric(x) {
|
|
|
363
363
|
}
|
|
364
364
|
exports.isNumeric = isNumeric;
|
|
365
365
|
function isPrimitive(x) {
|
|
366
|
-
return
|
|
366
|
+
return x === null || typeof x !== 'object' && typeof x !== 'function'; // from node's documentation
|
|
367
367
|
}
|
|
368
368
|
exports.isPrimitive = isPrimitive;
|
|
369
369
|
function isIP(address) {
|
package/src/debounceAsync.js
CHANGED
|
@@ -6,7 +6,7 @@ exports.singleWorkerFromBatchWorker = exports.debounceAsync = void 0;
|
|
|
6
6
|
function debounceAsync(
|
|
7
7
|
// the function you want to not call too often, too soon
|
|
8
8
|
callback, options = {}) {
|
|
9
|
-
const { wait = 0, leading = false, maxWait = Infinity, cancelable = false, retain = 0, retainFailure } = options;
|
|
9
|
+
const { wait = 0, leading = false, maxWait = Infinity, cancelable = false, retain = 0, retainFailure, reuseRunning } = options;
|
|
10
10
|
let started = 0; // latest callback invocation
|
|
11
11
|
let runningCallback; // latest callback invocation result
|
|
12
12
|
let latestDebouncer; // latest wrapper invocation
|
|
@@ -28,7 +28,7 @@ callback, options = {}) {
|
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
async function debouncer(...args) {
|
|
31
|
-
if (runningCallback)
|
|
31
|
+
if (reuseRunning && runningCallback)
|
|
32
32
|
return runningCallback;
|
|
33
33
|
const now = Date.now();
|
|
34
34
|
if (latestCallback && now - latestTimestamp < (latestHasFailed ? retainFailure !== null && retainFailure !== void 0 ? retainFailure : retain : retain))
|
|
@@ -45,6 +45,7 @@ callback, options = {}) {
|
|
|
45
45
|
}
|
|
46
46
|
if (whoIsWaiting !== args) // another fresher call is waiting
|
|
47
47
|
return latestDebouncer;
|
|
48
|
+
await runningCallback; // in case we don't reuseRunning
|
|
48
49
|
return exec();
|
|
49
50
|
}
|
|
50
51
|
async function exec() {
|
package/src/frontEndApis.js
CHANGED
|
@@ -187,6 +187,18 @@ exports.frontEndApis = {
|
|
|
187
187
|
await (0, comments_1.setCommentFor)(node.source, comment);
|
|
188
188
|
return {};
|
|
189
189
|
},
|
|
190
|
+
async get_folder_size({ uri }, ctx) {
|
|
191
|
+
(0, misc_1.apiAssertTypes)({ string: { uri } });
|
|
192
|
+
const folder = await (0, vfs_1.urlToNode)(uri, ctx);
|
|
193
|
+
if (!folder)
|
|
194
|
+
throw new apiMiddleware_1.ApiError(const_1.HTTP_NOT_FOUND);
|
|
195
|
+
if (!await (0, vfs_1.nodeIsDirectory)(folder))
|
|
196
|
+
throw new apiMiddleware_1.ApiError(const_1.HTTP_METHOD_NOT_ALLOWED);
|
|
197
|
+
let bytes = 0;
|
|
198
|
+
for await (const n of (0, vfs_1.walkNode)(folder, { ctx, onlyFiles: true, depth: Infinity }))
|
|
199
|
+
bytes += await (0, vfs_1.nodeStats)(n).then(x => (x === null || x === void 0 ? void 0 : x.size) || 0, () => 0);
|
|
200
|
+
return { bytes };
|
|
201
|
+
},
|
|
190
202
|
};
|
|
191
203
|
function notifyClient(channel, name, data) {
|
|
192
204
|
if (typeof channel !== 'string')
|
package/src/icons.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.watchIconsFolder = exports.customizedIcons = exports.ICONS_FOLDER = void 0;
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const util_files_1 = require("./util-files");
|
|
9
|
+
const debounceAsync_1 = require("./debounceAsync");
|
|
10
|
+
const promises_1 = require("fs/promises");
|
|
11
|
+
const events_1 = __importDefault(require("./events"));
|
|
12
|
+
exports.ICONS_FOLDER = 'icons';
|
|
13
|
+
events_1.default.once('configReady', () => {
|
|
14
|
+
watchIconsFolder('.', v => exports.customizedIcons = v);
|
|
15
|
+
});
|
|
16
|
+
function watchIconsFolder(parentFolder, cb) {
|
|
17
|
+
const iconsFolder = (0, path_1.join)(parentFolder, exports.ICONS_FOLDER);
|
|
18
|
+
const watcher = (0, util_files_1.watchDir)(iconsFolder, (0, debounceAsync_1.debounceAsync)(async () => {
|
|
19
|
+
let res = {}; // reset
|
|
20
|
+
try {
|
|
21
|
+
for (const f of await (0, promises_1.readdir)(iconsFolder, { withFileTypes: true })) {
|
|
22
|
+
if (!f.isFile())
|
|
23
|
+
continue;
|
|
24
|
+
const k = (0, path_1.basename)(f.name, (0, path_1.extname)(f.name));
|
|
25
|
+
res[k] = f.name;
|
|
26
|
+
}
|
|
27
|
+
cb(res);
|
|
28
|
+
}
|
|
29
|
+
catch (_a) {
|
|
30
|
+
cb(undefined);
|
|
31
|
+
} // no such dir
|
|
32
|
+
}), true);
|
|
33
|
+
return () => watcher.stop();
|
|
34
|
+
}
|
|
35
|
+
exports.watchIconsFolder = watchIconsFolder;
|
package/src/middlewares.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.sessionMiddleware = exports.paramsDecoder = exports.prepareState = exports.getProxyDetected = exports.someSecurity = exports.cloudflareDetected = exports.headRequests = exports.gzipper = exports.sessionDuration = void 0;
|
|
7
|
+
exports.sessionMiddleware = exports.paramsDecoder = exports.failAllowNet = exports.prepareState = exports.getProxyDetected = exports.someSecurity = exports.cloudflareDetected = exports.headRequests = exports.gzipper = exports.sessionDuration = void 0;
|
|
8
8
|
const koa_compress_1 = __importDefault(require("koa-compress"));
|
|
9
9
|
const const_1 = require("./const");
|
|
10
10
|
const misc_1 = require("./misc");
|
|
@@ -106,7 +106,7 @@ const prepareState = async (ctx, next) => {
|
|
|
106
106
|
// calculate these once and for all
|
|
107
107
|
ctx.state.connection = (0, connections_1.socket2connection)(ctx.socket);
|
|
108
108
|
const a = ctx.state.account = await urlLogin() || await getHttpAccount() || (0, perm_1.getAccount)((_b = ctx.session) === null || _b === void 0 ? void 0 : _b.username, false);
|
|
109
|
-
if (a && !(0, perm_1.accountCanLogin)(a))
|
|
109
|
+
if (a && (!(0, perm_1.accountCanLogin)(a) || failAllowNet(ctx, a))) // enforce allow_net also after login
|
|
110
110
|
ctx.state.account = undefined;
|
|
111
111
|
ctx.state.revProxyPath = ctx.get('x-forwarded-prefix');
|
|
112
112
|
(0, connections_1.updateConnectionForCtx)(ctx);
|
|
@@ -147,6 +147,15 @@ const prepareState = async (ctx, next) => {
|
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
149
|
exports.prepareState = prepareState;
|
|
150
|
+
function failAllowNet(ctx, a) {
|
|
151
|
+
var _a, _b;
|
|
152
|
+
const cached = (_a = ctx.session) === null || _a === void 0 ? void 0 : _a.allowNet; // won't reflect changes until session is terminated
|
|
153
|
+
const mask = cached !== null && cached !== void 0 ? cached : (0, perm_1.getFromAccount)(a || '', a => a.allow_net);
|
|
154
|
+
if (!cached && mask && ((_b = ctx.session) === null || _b === void 0 ? void 0 : _b.username))
|
|
155
|
+
ctx.session.allowNet = mask; // must be deleted on logout by setLoggedIn
|
|
156
|
+
return mask && !(0, misc_1.netMatches)(ctx.ip, mask, true);
|
|
157
|
+
}
|
|
158
|
+
exports.failAllowNet = failAllowNet;
|
|
150
159
|
const paramsDecoder = async (ctx, next) => {
|
|
151
160
|
ctx.state.params = ctx.method === 'POST' && ctx.originalUrl.startsWith(const_1.API_URI)
|
|
152
161
|
&& ((0, misc_1.tryJson)(await (0, misc_1.stream2string)(ctx.req)) || {});
|
package/src/misc.js
CHANGED
|
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.deleteNode = exports.createStreamLimiter = exports.apiAssertTypes = exports.AsapStream = exports.asyncGeneratorToReadable = exports.same = exports.makeNetMatcher = exports.isLocalHost = exports.pattern2filter = void 0;
|
|
21
|
+
exports.deleteNode = exports.createStreamLimiter = exports.apiAssertTypes = exports.AsapStream = exports.asyncGeneratorToReadable = exports.same = exports.makeNetMatcher = exports.netMatches = exports.isLocalHost = exports.pattern2filter = void 0;
|
|
22
22
|
const path_1 = require("path");
|
|
23
23
|
const assert_1 = __importDefault(require("assert"));
|
|
24
24
|
__exportStar(require("./util-http"), exports);
|
|
@@ -36,6 +36,7 @@ const vfs_1 = require("./vfs");
|
|
|
36
36
|
const events_1 = __importDefault(require("./events"));
|
|
37
37
|
const promises_1 = require("fs/promises");
|
|
38
38
|
const comments_1 = require("./comments");
|
|
39
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
39
40
|
function pattern2filter(pattern) {
|
|
40
41
|
const matcher = (0, cross_1.makeMatcher)(pattern.includes('*') ? pattern // if you specify *, we'll respect its position
|
|
41
42
|
: pattern.split('|').map(x => `*${x}*`).join('|'));
|
|
@@ -47,6 +48,11 @@ function isLocalHost(c) {
|
|
|
47
48
|
return ip && (0, cross_1.isIpLocalHost)(ip);
|
|
48
49
|
}
|
|
49
50
|
exports.isLocalHost = isLocalHost;
|
|
51
|
+
// this will memory-leak over mask, so be careful with what you use this
|
|
52
|
+
function netMatches(ip, mask, emptyMaskReturns = false) {
|
|
53
|
+
return lodash_1.default.memoize(makeNetMatcher, (a, b) => `${a}\t${b ? 1 : 0}`)(mask, emptyMaskReturns)(ip); // cache the matcher
|
|
54
|
+
}
|
|
55
|
+
exports.netMatches = netMatches;
|
|
50
56
|
function makeNetMatcher(mask, emptyMaskReturns = false) {
|
|
51
57
|
var _a;
|
|
52
58
|
if (!mask)
|
package/src/nat.js
CHANGED
|
@@ -92,7 +92,7 @@ exports.getNatInfo = (0, debounceAsync_1.debounceAsync)(async () => {
|
|
|
92
92
|
externalPort,
|
|
93
93
|
proto: ((_c = status === null || status === void 0 ? void 0 : status.https) === null || _c === void 0 ? void 0 : _c.listening) ? 'https' : ((_d = status === null || status === void 0 ? void 0 : status.http) === null || _d === void 0 ? void 0 : _d.listening) ? 'http' : '',
|
|
94
94
|
};
|
|
95
|
-
});
|
|
95
|
+
}, { reuseRunning: true });
|
|
96
96
|
(0, exports.getNatInfo)();
|
|
97
97
|
function findGateway() {
|
|
98
98
|
return new Promise((resolve, reject) => (0, child_process_1.exec)(const_1.IS_WINDOWS || const_1.IS_MAC ? 'netstat -rn' : 'route -n', (err, out) => {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const config_1 = require("./config");
|
|
7
|
+
const node_url_1 = require("node:url");
|
|
8
|
+
const util_http_1 = require("./util-http");
|
|
9
|
+
const util_os_1 = require("./util-os");
|
|
10
|
+
const events_1 = __importDefault(require("./events"));
|
|
11
|
+
const const_1 = require("./const");
|
|
12
|
+
const cross_1 = require("./cross");
|
|
13
|
+
// don't move this in util-http, where it would mostly belong, as a require to config.ts would prevent tests using util-http
|
|
14
|
+
const outboundProxy = (0, config_1.defineConfig)('outbound_proxy', '', v => {
|
|
15
|
+
try {
|
|
16
|
+
(0, node_url_1.parse)(v);
|
|
17
|
+
util_http_1.httpStream.defaultProxy = v;
|
|
18
|
+
}
|
|
19
|
+
catch (_a) {
|
|
20
|
+
console.warn("invalid URL", v);
|
|
21
|
+
return '';
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
events_1.default.once('configReady', async (startedWithoutConfig) => {
|
|
25
|
+
var _a, _b, _c, _d;
|
|
26
|
+
if (!const_1.IS_WINDOWS || !startedWithoutConfig)
|
|
27
|
+
return;
|
|
28
|
+
// try to read Windows system setting for proxy
|
|
29
|
+
const out = await (0, util_os_1.reg)('query', 'HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings');
|
|
30
|
+
if (!((_a = /ProxyEnable.+(\d)/.exec(out)) === null || _a === void 0 ? void 0 : _a[1]))
|
|
31
|
+
return;
|
|
32
|
+
const read = (_b = /ProxyServer.+?([\d:.]+)/.exec(out)) === null || _b === void 0 ? void 0 : _b[1];
|
|
33
|
+
if (!read)
|
|
34
|
+
return;
|
|
35
|
+
// it can be like "IP:PORT" or "http=IP:PORT;https=IP:PORT;ftp=IP:PORT"
|
|
36
|
+
const url = (0, cross_1.prefix)('https://', (_c = /https=([\d:.]+)/.exec(out)) === null || _c === void 0 ? void 0 : _c[1]) // prefer https
|
|
37
|
+
|| (0, cross_1.prefix)('http://', (_d = /http=([\d:.]+)/.exec(out)) === null || _d === void 0 ? void 0 : _d[1])
|
|
38
|
+
|| !read.includes('=') && 'http://' + read; // simpler form
|
|
39
|
+
if (!url)
|
|
40
|
+
return;
|
|
41
|
+
outboundProxy.set(url);
|
|
42
|
+
console.log("detected proxy", read);
|
|
43
|
+
});
|