hfs 0.52.5 → 0.53.0-alpha2

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.
Files changed (44) hide show
  1. package/admin/assets/index-Dsv2tjnU.js +805 -0
  2. package/admin/assets/{sha512-7RFRcaOB.js → sha512-BjLhiBem.js} +1 -1
  3. package/admin/index.html +2 -2
  4. package/frontend/assets/index-legacy-C21Ot_ue.js +60 -0
  5. package/frontend/assets/polyfills-legacy-DMrMt_pQ.js +4 -0
  6. package/frontend/assets/sha512-legacy-DYmEZJfO.js +9 -0
  7. package/frontend/index.html +3 -2
  8. package/package.json +1 -1
  9. package/plugins/antibrute/plugin.js +34 -23
  10. package/src/QuickZipStream.js +1 -1
  11. package/src/SendList.js +1 -3
  12. package/src/api.accounts.js +2 -2
  13. package/src/api.auth.js +7 -2
  14. package/src/api.get_file_list.js +1 -1
  15. package/src/api.log.js +2 -6
  16. package/src/api.plugins.js +22 -23
  17. package/src/api.vfs.js +1 -1
  18. package/src/auth.js +14 -5
  19. package/src/comments.js +5 -1
  20. package/src/config.js +15 -21
  21. package/src/const.js +2 -2
  22. package/src/cross.js +6 -8
  23. package/src/ddns.js +19 -18
  24. package/src/events.js +56 -5
  25. package/src/geo.js +1 -1
  26. package/src/github.js +21 -5
  27. package/src/index.js +1 -1
  28. package/src/langs/hfs-lang-it.json +7 -3
  29. package/src/listen.js +1 -1
  30. package/src/log.js +4 -0
  31. package/src/middlewares.js +8 -5
  32. package/src/misc.js +2 -15
  33. package/src/perm.js +15 -10
  34. package/src/plugins.js +5 -5
  35. package/src/roots.js +15 -23
  36. package/src/serveGuiAndSharedFiles.js +11 -8
  37. package/src/serveGuiFiles.js +9 -15
  38. package/src/throttler.js +11 -9
  39. package/src/upload.js +7 -1
  40. package/admin/assets/index-V2liwvHg.js +0 -811
  41. package/frontend/assets/index-c8LVGHJd.js +0 -101
  42. package/frontend/assets/index-oekM6dN8.css +0 -1
  43. package/frontend/assets/sha512-PGV0A--c.js +0 -8
  44. /package/admin/assets/{index-sCDewjON.css → index-CwIN7CM4.css} +0 -0
@@ -0,0 +1,4 @@
1
+ !function(){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};
2
+ /*!
3
+ * SJS 6.15.1
4
+ */!function(){function t(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(e,n,r){console.warn(t(e,[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(e,n,r,i){var o=e[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 e.instantiate(n,r,i)})).then((function(r){if(!r)throw Error(t(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(t,r){return e.import(t,n,r)},meta:e.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(t){return Promise.all(t[0].map((function(r,i){var o=t[1][i],s=t[2][i];return Promise.resolve(e.resolve(r,n)).then((function(t){var r=l(e,t,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=e[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(e){if(!e.sp)if("systemjs-module"===e.type){if(e.sp=!0,!e.src)return;System.import("import:"===e.src.slice(0,7)?e.src.slice(7):r(e.src,m)).catch((function(t){if(t.message.indexOf("https://github.com/systemjs/systemjs/blob/main/docs/errors.md#3")>-1){var n=document.createEvent("Event");n.initEvent("error",!1,!1),e.dispatchEvent(n)}return Promise.reject(t)}))}else if("systemjs-importmap"===e.type){e.sp=!0;var n=e.src?(System.fetch||fetch)(e.src,{integrity:e.integrity,priority:e.fetchPriority,passThrough:!0}).then((function(e){if(!e.ok)throw Error(e.status);return e.text()})).catch((function(n){return n.message=t("W4",e.src)+"\n"+n.message,console.warn(n),"function"==typeof e.onerror&&e.onerror(),"{}"})):e.innerHTML;T=T.then((function(){return n})).then((function(n){!function(e,n,r){var i={};try{i=JSON.parse(n)}catch(c){console.warn(Error(t("W5")))}o(i,r,e)}(R,n,e.src||m)}))}}))}var m,g="undefined"!=typeof Symbol,y="undefined"!=typeof self,w="undefined"!=typeof document,E=y?self:e;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(e,n){var r=N[e];if(r)return delete N[e],r;var i=this;return Promise.resolve(I.createScript(e)).then((function(r){return new Promise((function(o,s){r.addEventListener("error",(function(){s(Error(t(3,[e,n].join(", "))))})),r.addEventListener("load",(function(){if(document.head.removeChild(r),W===e)s(q);else{var t=i.getRegister(e);t&&t[0]===C&&clearTimeout(M),o(t)}})),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(e,n,r){var i=this;return this.shouldFetch(e,n,r)?this.fetch(e,{credentials:"same-origin",integrity:R.integrity[e],meta:r}).then((function(r){if(!r.ok)throw Error(t(7,[r.status,r.statusText,e,n].join(", ")));var o=r.headers.get("content-type");if(!o||!F.test(o))throw Error(t(4,o));return r.text().then((function(t){return t.indexOf("//# sourceURL=")<0&&(t+="\n//# sourceURL="+e),(0,eval)(t),i.getRegister(e)}))})):A.apply(this,arguments)},I.resolve=function(e,r){return f(R,n(e,r=r||m)||e,r)||function(e,n){throw Error(t(8,[e,n].join(", ")))}(e,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-C21Ot_ue.js"],(function(h,t){"use strict";var i,s;return{setters:[function(h){i=h.g,s=h.c}],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={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
+ */!function(h){!function(){var t="input is invalid type",i="object"==typeof window,r=i?window:{};r.JS_SHA512_NO_WINDOW&&(i=!1);var e=!i&&"object"==typeof self;!r.JS_SHA512_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?r=s: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)}()}(r);var e=r.exports;h("s",t({__proto__:null,default:i(e)},[e]))}}}));
@@ -4,12 +4,13 @@
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=0" />
6
6
  <link href="/fontello.css" rel="stylesheet" />
7
- <script type="module" crossorigin src="/assets/index-c8LVGHJd.js"></script>
8
- <link rel="stylesheet" crossorigin href="/assets/index-oekM6dN8.css">
7
+
9
8
  </head>
10
9
  <body>
11
10
  <noscript>You need to enable JavaScript to run this app.</noscript>
12
11
  <div id="root"></div>
13
12
  <script nomodule>document.getElementById('root').innerText = "Please use a newer browser"</script>
13
+ <script crossorigin id="vite-legacy-polyfill" src="/assets/polyfills-legacy-DMrMt_pQ.js"></script>
14
+ <script crossorigin id="vite-legacy-entry" data-src="/assets/index-legacy-C21Ot_ue.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script>
14
15
  </body>
15
16
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hfs",
3
- "version": "0.52.5",
3
+ "version": "0.53.0-alpha2",
4
4
  "description": "HTTP File Server",
5
5
  "keywords": [
6
6
  "file server",
@@ -1,10 +1,12 @@
1
- exports.version = 2
1
+ exports.version = 3
2
2
  exports.description = "Introduce increasing delays between login attempts."
3
- exports.apiRequired = 3 // log
3
+ exports.apiRequired = 8.8 // attemptingLogin
4
4
 
5
5
  exports.config = {
6
- increment: { type: 'number', min: 1, defaultValue: 5, helperText: "Seconds to add to the delay for each login attempt" },
7
- max: { type: 'number', min: 1, defaultValue: 60, helperText: "Max seconds to delay before next login is allowed" },
6
+ increment: { type: 'number', min: 1, defaultValue: 5, unit: "seconds", helperText: "How longer user must wait for each login attempt" },
7
+ max: { type: 'number', min: 1, defaultValue: 60, label: "Max delay", unit: "seconds", helperText: "Max seconds to delay before next login is allowed" },
8
+ blockAfter: { type: 'number', xs: 6, min: 1, max: 9999, defaultValue: 100, label: "Block IP after", unit: "attempts", helperText: "localhost excluded" },
9
+ blockForHours: { type: 'number', xs: 6, min: 0, defaultValue: 24, label: "Block for", unit: "hours" },
8
10
  }
9
11
  exports.configDialog = {
10
12
  maxWidth: 'xs',
@@ -13,26 +15,35 @@ exports.configDialog = {
13
15
  const byIp = {}
14
16
 
15
17
  exports.init = api => {
16
- const LOGIN_URI = api.Const.API_URI + 'loginSrp1'
17
- const { getOrSet } = api.require('./misc')
18
+ const { getOrSet, isLocalHost, HOUR } = api.require('./misc')
19
+ const { block } = api.require('./block')
18
20
  return {
19
- async middleware(ctx) {
20
- if (ctx.path !== LOGIN_URI) return
21
- const { ip } = ctx
22
- const now = Date.now()
23
- const rec = getOrSet(byIp, ip, () => ({ delay: 0, next: now }))
24
- const wait = rec.next - now
25
- const max = api.getConfig('max') * 1000
26
- const inc = api.getConfig('increment') * 1000
27
- rec.delay = Math.min(max, rec.delay + inc)
28
- rec.next += rec.delay
29
- clearTimeout(rec.timer)
30
- if (wait > 0) {
31
- api.log('delaying', ip, 'for', Math.round(wait / 1000))
32
- ctx.set('x-anti-brute-force', wait)
33
- await new Promise(resolve => setTimeout(resolve, wait))
21
+ unload: api.events.multi({
22
+ attemptingLogin: async ctx => {
23
+ const { ip } = ctx
24
+ const now = new Date
25
+ const rec = getOrSet(byIp, ip, () => ({ attempts: 0, next: now }))
26
+ const max = api.getConfig('max') * 1000
27
+ const delay = Math.min(max, 1000 * api.getConfig('increment') * ++rec.attempts)
28
+ const wait = rec.next - now
29
+ rec.next = new Date(+rec.next + delay)
30
+ if (rec.attempts > api.getConfig('blockAfter') && !isLocalHost(ctx)) {
31
+ const hours = api.getConfig('blockForHours')
32
+ const newRule = { ip, comment: "From antibrute plugin", expire: hours ? new Date(now.getTime() + hours * HOUR) : undefined }
33
+ block.set(x => [...x, newRule])
34
+ }
35
+ clearTimeout(rec.timer)
36
+ if (wait > 0) {
37
+ api.log('delaying', ip, 'for', Math.round(wait / 1000))
38
+ ctx.set('x-anti-brute-force', wait)
39
+ await new Promise(resolve => setTimeout(resolve, wait))
40
+ }
41
+ rec.timer = setTimeout(() => delete byIp[ip], 24 * HOUR) // no memory leak
42
+ },
43
+ login: ctx => {
44
+ if (ctx.state.account)
45
+ delete byIp[ctx.ip] // reset if login was successful
34
46
  }
35
- rec.timer = setTimeout(() => delete byIp[ip], rec.delay * 10) // no memory leak
36
- }
47
+ })
37
48
  }
38
49
  }
@@ -200,7 +200,7 @@ class QuickZipStream extends stream_1.Readable {
200
200
  offset = ZIP64_SIZE_LIMIT;
201
201
  }
202
202
  const extraData = buffer(!extra.length ? []
203
- : [2, 1, 2, 8 * extra.length, ...extra.map(x => [8, x]).flat()]);
203
+ : [2, 1, 2, 8 * extra.length, ...extra.flatMap(x => [8, x])]);
204
204
  if (extraData.length && version < 45)
205
205
  version = 45;
206
206
  this.controlledPush([
package/src/SendList.js CHANGED
@@ -7,7 +7,6 @@ exports.SendListReadable = void 0;
7
7
  const stream_1 = require("stream");
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
9
  const cross_1 = require("./cross");
10
- const misc_1 = require("./misc");
11
10
  const events_1 = __importDefault(require("./events"));
12
11
  // offer an api for a generic dynamic list. Suitable to be the result of an api.
13
12
  class SendListReadable extends stream_1.Readable {
@@ -116,8 +115,7 @@ class SendListReadable extends stream_1.Readable {
116
115
  this.push(null);
117
116
  }
118
117
  events(ctx, eventMap) {
119
- const off = (0, misc_1.onOff)(events_1.default, eventMap);
120
- ctx.res.once('close', off);
118
+ ctx.res.once('close', events_1.default.multi(eventMap));
121
119
  return this;
122
120
  }
123
121
  isClosed() {
@@ -16,7 +16,7 @@ function prepareAccount(ac) {
16
16
  username: ac.username,
17
17
  hasPassword: (0, perm_1.accountHasPassword)(ac),
18
18
  adminActualAccess: (0, perm_1.accountCanLoginAdmin)(ac),
19
- invalidated: auth_1.invalidSessions.has(ac.username),
19
+ invalidated: auth_1.invalidateSessionBefore.get(ac.username),
20
20
  };
21
21
  }
22
22
  exports.default = {
@@ -62,7 +62,7 @@ exports.default = {
62
62
  },
63
63
  invalidate_sessions({ username }) {
64
64
  (0, misc_1.apiAssertTypes)({ string: { username } });
65
- auth_1.invalidSessions.add(username);
65
+ auth_1.invalidateSessionBefore.set(username, Date.now());
66
66
  return {};
67
67
  },
68
68
  async change_srp({ username, salt, verifier }) {
package/src/api.auth.js CHANGED
@@ -1,5 +1,8 @@
1
1
  "use strict";
2
2
  // This file is part of HFS - Copyright 2021-2023, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
3
6
  Object.defineProperty(exports, "__esModule", { value: true });
4
7
  exports.change_my_srp = exports.refresh_session = exports.logout = exports.loginSrp2 = exports.loginSrp1 = void 0;
5
8
  const perm_1 = require("./perm");
@@ -9,6 +12,7 @@ const adminApis_1 = require("./adminApis");
9
12
  const middlewares_1 = require("./middlewares");
10
13
  const auth_1 = require("./auth");
11
14
  const config_1 = require("./config");
15
+ const events_1 = __importDefault(require("./events"));
12
16
  const ongoingLogins = {}; // store data that doesn't fit session object
13
17
  const keepSessionAlive = (0, config_1.defineConfig)('keep_session_alive', true);
14
18
  const loginSrp1 = async ({ username }, ctx) => {
@@ -17,6 +21,7 @@ const loginSrp1 = async ({ username }, ctx) => {
17
21
  const account = (0, perm_1.getAccount)(username);
18
22
  if (!ctx.session)
19
23
  return new apiMiddleware_1.ApiError(const_1.HTTP_SERVER_ERROR);
24
+ await events_1.default.emitAsync('attemptingLogin', ctx);
20
25
  if (!account || !(0, perm_1.accountCanLogin)(account)) { // TODO simulate fake account to prevent knowing valid usernames
21
26
  ctx.logExtra({ u: username });
22
27
  ctx.state.dontLog = false; // log even if log_api is false
@@ -27,7 +32,7 @@ const loginSrp1 = async ({ username }, ctx) => {
27
32
  const sid = Math.random();
28
33
  ongoingLogins[sid] = step1;
29
34
  setTimeout(() => delete ongoingLogins[sid], 60000);
30
- ctx.session.loggingIn = { username, sid };
35
+ ctx.session.loggingIn = { username, sid }; // temporarily store until process is complete
31
36
  return rest;
32
37
  }
33
38
  catch (code) {
@@ -42,13 +47,13 @@ const loginSrp2 = async ({ pubKey, proof }, ctx) => {
42
47
  if (!ctx.session.loggingIn)
43
48
  return new apiMiddleware_1.ApiError(const_1.HTTP_CONFLICT);
44
49
  const { username, sid } = ctx.session.loggingIn;
50
+ delete ctx.session.loggingIn;
45
51
  const step1 = ongoingLogins[sid];
46
52
  if (!step1)
47
53
  return new apiMiddleware_1.ApiError(const_1.HTTP_NOT_FOUND);
48
54
  try {
49
55
  const M2 = await step1.step2(BigInt(pubKey), BigInt(proof));
50
56
  await (0, auth_1.setLoggedIn)(ctx, username);
51
- delete ctx.session.loggingIn;
52
57
  return {
53
58
  proof: String(M2),
54
59
  redirect: (_a = ctx.state.account) === null || _a === void 0 ? void 0 : _a.redirect,
@@ -100,7 +100,7 @@ const get_file_list = async ({ uri = '/', offset, limit, search, c, onlyFolders,
100
100
  const { source, url } = node;
101
101
  const name = (0, vfs_1.getNodeName)(node);
102
102
  if (url)
103
- return name ? { n: name, url } : null;
103
+ return name ? { n: name, url, target: node.target } : null;
104
104
  const isFolder = await (0, vfs_1.nodeIsDirectory)(node);
105
105
  try {
106
106
  const st = source ? await (0, promises_1.stat)(source) : undefined;
package/src/api.log.js CHANGED
@@ -8,7 +8,6 @@ const consoleLog_1 = require("./consoleLog");
8
8
  const cross_1 = require("./cross");
9
9
  const events_1 = __importDefault(require("./events"));
10
10
  const log_1 = require("./log");
11
- const misc_1 = require("./misc");
12
11
  const SendList_1 = require("./SendList");
13
12
  const serveFile_1 = require("./serveFile");
14
13
  exports.default = {
@@ -43,11 +42,8 @@ exports.default = {
43
42
  if (!lodash_1.default.find(log_1.loggers, { name: file }))
44
43
  return list.error(cross_1.HTTP_NOT_FOUND, true);
45
44
  list.ready();
46
- ctx.res.once('close', (0, misc_1.onOff)(events_1.default, {
47
- [file](entry) {
48
- list.add(entry);
49
- }
50
- }));
45
+ // unsubscribe when connection is interrupted
46
+ ctx.res.once('close', events_1.default.on(file, x => list.add(x)));
51
47
  }
52
48
  });
53
49
  },
@@ -10,7 +10,6 @@ const lodash_1 = __importDefault(require("lodash"));
10
10
  const assert_1 = __importDefault(require("assert"));
11
11
  const misc_1 = require("./misc");
12
12
  const apiMiddleware_1 = require("./apiMiddleware");
13
- const events_1 = __importDefault(require("./events"));
14
13
  const promises_1 = require("fs/promises");
15
14
  const github_1 = require("./github");
16
15
  const const_1 = require("./const");
@@ -83,7 +82,7 @@ const apis = {
83
82
  return {
84
83
  enabled: plugins_1.enablePlugins.get().includes(id),
85
84
  config: {
86
- ...(0, misc_1.newObj)((0, plugins_1.getPluginConfigFields)(id) || {}, v => v === null || v === void 0 ? void 0 : v.defaultValue),
85
+ ...(0, misc_1.newObj)((0, plugins_1.getPluginConfigFields)(id), v => v === null || v === void 0 ? void 0 : v.defaultValue),
87
86
  ...plugins_1.pluginsConfig.get()[id]
88
87
  }
89
88
  };
@@ -91,33 +90,33 @@ const apis = {
91
90
  get_online_plugins({ text }, ctx) {
92
91
  return new SendList_1.SendListReadable({
93
92
  async doAtStart(list) {
93
+ const repos = [];
94
+ list.events(ctx, {
95
+ pluginInstalled: p => {
96
+ if (repos.includes(p.repo))
97
+ list.update({ id: p.repo }, { installed: true });
98
+ },
99
+ pluginUninstalled: folder => {
100
+ const repo = (0, github_1.getFolder2repo)()[folder];
101
+ if (typeof repo !== 'string')
102
+ return; // custom repo
103
+ if (repos.includes(repo))
104
+ list.update({ id: repo }, { installed: false });
105
+ },
106
+ pluginDownload({ id, status }) {
107
+ if (repos.includes(id))
108
+ list.update({ id }, { downloading: status !== null && status !== void 0 ? status : null });
109
+ }
110
+ });
94
111
  try {
95
- // avoid creating N listeners on ctx.req, and getting a warning
96
- const undo = [];
97
- ctx.req.once('close', () => undo.forEach(x => x()));
98
- const folder2repo = (0, github_1.getFolder2repo)();
99
- for await (const pl of await (0, github_1.searchPlugins)(text)) {
112
+ const already = Object.values((0, github_1.getFolder2repo)()).map(String);
113
+ for await (const pl of await (0, github_1.searchPlugins)(text, { skipRepos: already })) {
100
114
  const repo = pl.repo || pl.id; // .repo property can be more trustworthy in case github user renamed and left the previous link in 'repo'
101
- if (lodash_1.default.includes(folder2repo, repo))
102
- continue; // don't include installed plugins
103
115
  const missing = await (0, plugins_1.getMissingDependencies)(pl);
104
116
  if (missing.length)
105
117
  pl.missing = missing;
106
118
  list.add(pl);
107
- // watch for events about this plugin, until this request is closed
108
- undo.push((0, misc_1.onOff)(events_1.default, {
109
- pluginInstalled: p => {
110
- if (p.repo === repo)
111
- list.update({ id: repo }, { installed: true });
112
- },
113
- pluginUninstalled: folder => {
114
- if (repo === (0, github_1.getFolder2repo)()[folder])
115
- list.update({ id: repo }, { installed: false });
116
- },
117
- ['pluginDownload_' + repo](status) {
118
- list.update({ id: repo }, { downloading: status !== null && status !== void 0 ? status : null });
119
- }
120
- }));
119
+ repos.push(repo);
121
120
  }
122
121
  }
123
122
  catch (err) {
package/src/api.vfs.js CHANGED
@@ -21,7 +21,7 @@ async function urlToNodeOriginal(uri) {
21
21
  const n = await (0, vfs_1.urlToNode)(uri);
22
22
  return (n === null || n === void 0 ? void 0 : n.isTemp) ? n.original : n;
23
23
  }
24
- const ALLOWED_KEYS = ['name', 'source', 'masks', 'default', 'accept', 'rename', 'mime', 'url', ...misc_1.PERM_KEYS];
24
+ const ALLOWED_KEYS = ['name', 'source', 'masks', 'default', 'accept', 'rename', 'mime', 'url', 'target', ...misc_1.PERM_KEYS];
25
25
  const apis = {
26
26
  async get_vfs() {
27
27
  return { root: await recur() };
package/src/auth.js CHANGED
@@ -1,12 +1,16 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.invalidSessions = exports.setLoggedIn = exports.getCurrentUsername = exports.srpCheck = exports.srpStep1 = void 0;
6
+ exports.invalidateSessionBefore = exports.setLoggedIn = exports.getCurrentUsername = exports.srpCheck = exports.srpStep1 = void 0;
4
7
  const perm_1 = require("./perm");
5
8
  const cross_const_1 = require("./cross-const");
6
9
  const tssrp6a_1 = require("tssrp6a");
7
10
  const srp_1 = require("./srp");
8
11
  const cross_1 = require("./cross");
9
12
  const node_crypto_1 = require("node:crypto");
13
+ const events_1 = __importDefault(require("./events"));
10
14
  const srp6aNimbusRoutines = new tssrp6a_1.SRPRoutines(new tssrp6a_1.SRPParameters());
11
15
  async function srpStep1(account) {
12
16
  if (!account.srp)
@@ -45,14 +49,19 @@ async function setLoggedIn(ctx, username) {
45
49
  if (!s)
46
50
  return ctx.throw(cross_const_1.HTTP_SERVER_ERROR, 'session');
47
51
  if (username === false) {
52
+ events_1.default.emit('logout', ctx);
48
53
  delete s.username;
49
54
  return;
50
55
  }
51
- exports.invalidSessions.delete(username);
52
- s.username = (0, perm_1.normalizeUsername)(username);
53
56
  const a = ctx.state.account = (0, perm_1.getAccount)(username);
54
- if (a && !a.expire && a.days_to_live)
57
+ if (!a)
58
+ return;
59
+ s.username = (0, perm_1.normalizeUsername)(username);
60
+ s.ts = Date.now();
61
+ if (!a.expire && a.days_to_live)
55
62
  (0, perm_1.updateAccount)(a, { expire: new Date(Date.now() + a.days_to_live * cross_1.DAY) });
63
+ await events_1.default.emitAsync('login', ctx);
56
64
  }
57
65
  exports.setLoggedIn = setLoggedIn;
58
- exports.invalidSessions = new Set(); // since session are currently stored in cookies, we need to memorize this until we meet again
66
+ // since session are currently stored in cookies, we need to store this information
67
+ exports.invalidateSessionBefore = new Map();
package/src/comments.js CHANGED
@@ -12,6 +12,7 @@ const fs_1 = require("fs");
12
12
  const misc_1 = require("./misc");
13
13
  const lodash_1 = __importDefault(require("lodash"));
14
14
  const iconv_lite_1 = __importDefault(require("iconv-lite"));
15
+ const promises_1 = require("node:fs/promises");
15
16
  exports.DESCRIPT_ION = 'descript.ion';
16
17
  exports.descriptIon = (0, config_1.defineConfig)('descript_ion', true);
17
18
  const descriptIonEncoding = (0, config_1.defineConfig)('descript_ion_encoding', 'utf8');
@@ -31,8 +32,11 @@ exports.setCommentFor = (0, misc_1.singleWorkerFromBatchWorker)(async (jobs) =>
31
32
  else
32
33
  comments.set(file, comment);
33
34
  }
35
+ const path = (0, path_1.join)(folder, exports.DESCRIPT_ION);
36
+ if (!comments.size)
37
+ return (0, promises_1.unlink)(path);
34
38
  // encode comments in descript.ion format
35
- const ws = (0, fs_1.createWriteStream)((0, path_1.join)(folder, exports.DESCRIPT_ION));
39
+ const ws = (0, fs_1.createWriteStream)(path);
36
40
  comments.forEach((comment, filename) => {
37
41
  const multiline = comment.includes('\n');
38
42
  const line = (filename.includes(' ') ? `"${filename}"` : filename)
package/src/config.js CHANGED
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.configFile = exports.saveConfigAsap = exports.setConfig = exports.getWholeConfig = exports.getConfig = exports.configKeyExists = exports.defineConfig = exports.currentVersion = exports.versionToScalar = void 0;
8
- const events_1 = __importDefault(require("events"));
9
8
  const const_1 = require("./const");
10
9
  const watchLoad_1 = require("./watchLoad");
11
10
  const yaml_1 = __importDefault(require("yaml"));
@@ -13,15 +12,13 @@ const lodash_1 = __importDefault(require("lodash"));
13
12
  const misc_1 = require("./misc");
14
13
  const fs_1 = require("fs");
15
14
  const path_1 = require("path");
16
- const events_2 = __importDefault(require("./events"));
15
+ const events_1 = __importDefault(require("./events"));
17
16
  const promises_1 = require("fs/promises");
18
17
  const FILE = 'config.yaml';
19
18
  // keep definition of config properties
20
19
  const configProps = {};
21
20
  let started = false; // this will tell the difference for subscribeConfig()s that are called before or after config is loaded
22
21
  let state = {}; // current state of config properties
23
- const cfgEvents = new events_1.default();
24
- cfgEvents.setMaxListeners(10000);
25
22
  const filePath = (0, misc_1.with_)(const_1.argv.config || process.env.HFS_CONFIG, p => {
26
23
  if (!p)
27
24
  return FILE;
@@ -52,7 +49,7 @@ class Version extends String {
52
49
  return (0, exports.versionToScalar)(this.valueOf());
53
50
  }
54
51
  }
55
- const CONFIG_CHANGE_EVENT_PREFIX = 'new.';
52
+ const CONFIG_CHANGE_EVENT_PREFIX = 'config.';
56
53
  exports.currentVersion = new Version(const_1.VERSION);
57
54
  const configVersion = defineConfig('version', const_1.VERSION, v => new Version(v));
58
55
  function defineConfig(k, defaultValue, compiler) {
@@ -68,20 +65,17 @@ function defineConfig(k, defaultValue, compiler) {
68
65
  sub(cb) {
69
66
  if (started) // initial event already passed, we'll make the first call
70
67
  cb(getConfig(k), { k, was: defaultValue, defaultValue, version: configVersion.compiled() });
71
- const eventName = CONFIG_CHANGE_EVENT_PREFIX + k;
72
- return (0, misc_1.onOff)(cfgEvents, {
73
- [eventName](v, was, version) {
74
- if (stack.includes(cb))
75
- return; // avoid infinite loop in case a subscriber changes the value
76
- stack.push(cb);
77
- try {
78
- return cb(v, { k, was, version, defaultValue });
79
- }
80
- finally {
81
- stack.pop();
82
- }
68
+ return events_1.default.on(CONFIG_CHANGE_EVENT_PREFIX + k, (v, was, version) => {
69
+ if (stack.includes(cb))
70
+ return; // avoid infinite loop in case a subscriber changes the value
71
+ stack.push(cb);
72
+ try {
73
+ return cb(v, { k, was, version, defaultValue });
83
74
  }
84
- });
75
+ finally {
76
+ stack.pop();
77
+ }
78
+ }, { warnAfter: 1000 }); // e.g. each plugin watch enable_plugins
85
79
  },
86
80
  set(v) {
87
81
  if (typeof v === 'function')
@@ -135,7 +129,7 @@ function setConfig(newCfg, save) {
135
129
  if (save === false) // false is used when loading whole config, and in such case we should not leave previous values untreated. Also, we need this only after we already `started`.
136
130
  for (const k of Object.keys(state))
137
131
  if (!newCfg.hasOwnProperty(k))
138
- apply(k, newCfg[k]);
132
+ apply(k, undefined);
139
133
  return;
140
134
  }
141
135
  // first time we emit also for the default values
@@ -143,7 +137,7 @@ function setConfig(newCfg, save) {
143
137
  if (!newCfg.hasOwnProperty(k))
144
138
  apply(k, newCfg[k], true);
145
139
  started = true;
146
- events_2.default.emit('config ready');
140
+ events_1.default.emit('config ready');
147
141
  if (version !== const_1.VERSION) // be sure to save version
148
142
  (0, exports.saveConfigAsap)();
149
143
  function apply(k, newV, isDefault = false) {
@@ -162,7 +156,7 @@ function setConfig1(k, newV, saveChanges = true, valueVersion) {
162
156
  return; // no change
163
157
  const was = getConfig(k); // include cloned default, if necessary
164
158
  state[k] = newV;
165
- cfgEvents.emit(CONFIG_CHANGE_EVENT_PREFIX + k, getConfig(k), was, valueVersion);
159
+ events_1.default.emit(CONFIG_CHANGE_EVENT_PREFIX + k, getConfig(k), was, valueVersion);
166
160
  if (saveChanges)
167
161
  (0, exports.saveConfigAsap)();
168
162
  function same(a, b) {
package/src/const.js CHANGED
@@ -37,7 +37,7 @@ const os_1 = require("os");
37
37
  const fs_1 = require("fs");
38
38
  const path_1 = require("path");
39
39
  __exportStar(require("./cross-const"), exports);
40
- exports.API_VERSION = 8.72;
40
+ exports.API_VERSION = 8.8;
41
41
  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
42
42
  exports.HFS_REPO = 'rejetto/hfs';
43
43
  exports.argv = (0, minimist_1.default)(process.argv.slice(2));
@@ -45,7 +45,7 @@ exports.DEV = process.env.DEV || exports.argv.dev ? 'DEV' : '';
45
45
  exports.ORIGINAL_CWD = process.cwd();
46
46
  exports.HFS_STARTED = new Date();
47
47
  const PKG_PATH = (0, path_1.join)(__dirname, '..', 'package.json');
48
- exports.BUILD_TIMESTAMP = "2024-05-05T21:55:37.328Z";
48
+ exports.BUILD_TIMESTAMP = "2024-05-08T10:54:50.461Z";
49
49
  const pkg = JSON.parse(fs.readFileSync(PKG_PATH, 'utf8'));
50
50
  exports.VERSION = pkg.version;
51
51
  exports.RUNNING_BETA = exports.VERSION.includes('-');
package/src/cross.js CHANGED
@@ -43,8 +43,8 @@ exports.FRONTEND_OPTIONS = {
43
43
  exports.SORT_BY_OPTIONS = ['name', 'extension', 'size', 'time'];
44
44
  exports.THEME_OPTIONS = { auto: '', light: 'light', dark: 'dark' };
45
45
  exports.CFG = constMap(['geo_enable', 'geo_allow', 'geo_list', 'geo_allow_unknown', 'dynamic_dns_url',
46
- 'log', 'error_log', 'log_rotation', 'dont_log_net', 'log_gui', 'log_api', 'log_ua',
47
- 'max_downloads', 'max_downloads_per_ip', 'max_downloads_per_account', 'roots', 'roots_mandatory']);
46
+ 'log', 'error_log', 'log_rotation', 'dont_log_net', 'log_gui', 'log_api', 'log_ua', 'log_spam',
47
+ 'max_downloads', 'max_downloads_per_ip', 'max_downloads_per_account', 'roots', 'force_address']);
48
48
  exports.LIST = { add: '+', remove: '-', update: '=', props: 'props', ready: 'ready', error: 'e' };
49
49
  exports.WHO_ANYONE = true;
50
50
  exports.WHO_NO_ONE = false;
@@ -216,9 +216,7 @@ function findDefined(a, cb) {
216
216
  }
217
217
  exports.findDefined = findDefined;
218
218
  function newObj(src, returnNewValue, recur = false) {
219
- if (!src)
220
- return {};
221
- const pairs = Object.entries(src).map(([k, v]) => {
219
+ const pairs = Object.entries(src || {}).map(([k, v]) => {
222
220
  if (typeof k === 'symbol')
223
221
  return;
224
222
  let _k = k;
@@ -315,7 +313,7 @@ function repeat(everyMs, cb) {
315
313
  }
316
314
  exports.repeat = repeat;
317
315
  function formatTimestamp(x) {
318
- return !x ? '-' : (x instanceof Date ? x : new Date(x)).toLocaleString();
316
+ return !x ? '' : (x instanceof Date ? x : new Date(x)).toLocaleString();
319
317
  }
320
318
  exports.formatTimestamp = formatTimestamp;
321
319
  function isPrimitive(x) {
@@ -407,8 +405,8 @@ function matches(s, mask, emptyMaskReturns = false) {
407
405
  exports.matches = matches;
408
406
  function replace(s, symbols, delimiter = '') {
409
407
  const [open, close] = splitAt(' ', delimiter);
410
- for (const [k, v] of typedEntries(symbols))
411
- s = s.replace(open + k + close, lodash_1.default.isFunction(v) ? v() : v);
408
+ for (const [k, v] of Object.entries(symbols))
409
+ s = s.replaceAll(open + k + close, v); // typescript doesn't handle overloaded functions (like replaceAll) with union types https://stackoverflow.com/a/66510061/646132
412
410
  return s;
413
411
  }
414
412
  exports.replace = replace;