hfs 0.52.0-alpha2 → 0.52.0-beta4

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.
@@ -0,0 +1,8 @@
1
+ import{g as OF,c as UF}from"./index-SY22o0dA.js";function gF(sF,hF){for(var eF=0;eF<hF.length;eF++){const tF=hF[eF];if(typeof tF!="string"&&!Array.isArray(tF)){for(const w in tF)if(w!=="default"&&!(w in sF)){const lF=Object.getOwnPropertyDescriptor(tF,w);lF&&Object.defineProperty(sF,w,lF.get?lF:{enumerable:!0,get:()=>tF[w]})}}}return Object.freeze(Object.defineProperty(sF,Symbol.toStringTag,{value:"Module"}))}var dF={exports:{}};/*
2
+ * [js-sha512]{@link https://github.com/emn178/js-sha512}
3
+ *
4
+ * @version 0.8.0
5
+ * @author Chen, Yi-Cyuan [emn178@gmail.com]
6
+ * @copyright Chen, Yi-Cyuan 2014-2018
7
+ * @license MIT
8
+ */(function(sF){(function(){var hF="input is invalid type",eF="finalize already called",tF=typeof window=="object",w=tF?window:{};w.JS_SHA512_NO_WINDOW&&(tF=!1);var lF=!tF&&typeof self=="object",bF=!w.JS_SHA512_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;bF?w=UF:lF&&(w=self);var wF=!w.JS_SHA512_NO_COMMON_JS&&!0&&sF.exports,aF=!w.JS_SHA512_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",F="0123456789abcdef".split(""),SF=[-2147483648,8388608,32768,128],xF=[24,16,8,0],iF=[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],fF=["hex","array","digest","arrayBuffer"],C=[];(w.JS_SHA512_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(x){return Object.prototype.toString.call(x)==="[object Array]"}),aF&&(w.JS_SHA512_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(x){return typeof x=="object"&&x.buffer&&x.buffer.constructor===ArrayBuffer});var yF=function(x,r){return function(e){return new v(r,!0).update(e)[x]()}},oF=function(x){var r=yF("hex",x);r.create=function(){return new v(x)},r.update=function(B){return r.create().update(B)};for(var e=0;e<fF.length;++e){var n=fF[e];r[n]=yF(n,x)}return r},vF=function(x,r){return function(e,n){return new rF(e,r,!0).update(n)[x]()}},nF=function(x){var r=vF("hex",x);r.create=function(B){return new rF(B,x)},r.update=function(B,l){return r.create(B).update(l)};for(var e=0;e<fF.length;++e){var n=fF[e];r[n]=vF(n,x)}return r};function v(x,r){r?(C[0]=C[1]=C[2]=C[3]=C[4]=C[5]=C[6]=C[7]=C[8]=C[9]=C[10]=C[11]=C[12]=C[13]=C[14]=C[15]=C[16]=C[17]=C[18]=C[19]=C[20]=C[21]=C[22]=C[23]=C[24]=C[25]=C[26]=C[27]=C[28]=C[29]=C[30]=C[31]=C[32]=0,this.blocks=C):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],x==384?(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):x==256?(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):x==224?(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=x,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1}v.prototype.update=function(x){if(this.finalized)throw new Error(eF);var r,e=typeof x;if(e!=="string"){if(e==="object"){if(x===null)throw new Error(hF);if(aF&&x.constructor===ArrayBuffer)x=new Uint8Array(x);else if(!Array.isArray(x)&&(!aF||!ArrayBuffer.isView(x)))throw new Error(hF)}else throw new Error(hF);r=!0}for(var n,B=0,l,c=x.length,s=this.blocks;B<c;){if(this.hashed&&(this.hashed=!1,s[0]=this.block,s[1]=s[2]=s[3]=s[4]=s[5]=s[6]=s[7]=s[8]=s[9]=s[10]=s[11]=s[12]=s[13]=s[14]=s[15]=s[16]=s[17]=s[18]=s[19]=s[20]=s[21]=s[22]=s[23]=s[24]=s[25]=s[26]=s[27]=s[28]=s[29]=s[30]=s[31]=s[32]=0),r)for(l=this.start;B<c&&l<128;++B)s[l>>2]|=x[B]<<xF[l++&3];else for(l=this.start;B<c&&l<128;++B)n=x.charCodeAt(B),n<128?s[l>>2]|=n<<xF[l++&3]:n<2048?(s[l>>2]|=(192|n>>6)<<xF[l++&3],s[l>>2]|=(128|n&63)<<xF[l++&3]):n<55296||n>=57344?(s[l>>2]|=(224|n>>12)<<xF[l++&3],s[l>>2]|=(128|n>>6&63)<<xF[l++&3],s[l>>2]|=(128|n&63)<<xF[l++&3]):(n=65536+((n&1023)<<10|x.charCodeAt(++B)&1023),s[l>>2]|=(240|n>>18)<<xF[l++&3],s[l>>2]|=(128|n>>12&63)<<xF[l++&3],s[l>>2]|=(128|n>>6&63)<<xF[l++&3],s[l>>2]|=(128|n&63)<<xF[l++&3]);this.lastByteIndex=l,this.bytes+=l-this.start,l>=128?(this.block=s[32],this.start=l-128,this.hash(),this.hashed=!0):this.start=l}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296<<0,this.bytes=this.bytes%4294967296),this},v.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var x=this.blocks,r=this.lastByteIndex;x[32]=this.block,x[r>>2]|=SF[r&3],this.block=x[32],r>=112&&(this.hashed||this.hash(),x[0]=this.block,x[1]=x[2]=x[3]=x[4]=x[5]=x[6]=x[7]=x[8]=x[9]=x[10]=x[11]=x[12]=x[13]=x[14]=x[15]=x[16]=x[17]=x[18]=x[19]=x[20]=x[21]=x[22]=x[23]=x[24]=x[25]=x[26]=x[27]=x[28]=x[29]=x[30]=x[31]=x[32]=0),x[30]=this.hBytes<<3|this.bytes>>>29,x[31]=this.bytes<<3,this.hash()}},v.prototype.hash=function(){var x=this.h0h,r=this.h0l,e=this.h1h,n=this.h1l,B=this.h2h,l=this.h2l,c=this.h3h,s=this.h3l,E=this.h4h,D=this.h4l,d=this.h5h,_=this.h5l,b=this.h6h,S=this.h6l,O=this.h7h,U=this.h7l,y=this.blocks,A,z,P,H,I,h,t,i,a,EF,CF,cF,DF,uF,pF,AF,BF,Z,q,f,o,u,p,Q,FF;for(A=32;A<160;A+=2)f=y[A-30],o=y[A-29],z=(f>>>1|o<<31)^(f>>>8|o<<24)^f>>>7,P=(o>>>1|f<<31)^(o>>>8|f<<24)^(o>>>7|f<<25),f=y[A-4],o=y[A-3],H=(f>>>19|o<<13)^(o>>>29|f<<3)^f>>>6,I=(o>>>19|f<<13)^(f>>>29|o<<3)^(o>>>6|f<<26),f=y[A-32],o=y[A-31],u=y[A-14],p=y[A-13],h=(p&65535)+(o&65535)+(P&65535)+(I&65535),t=(p>>>16)+(o>>>16)+(P>>>16)+(I>>>16)+(h>>>16),i=(u&65535)+(f&65535)+(z&65535)+(H&65535)+(t>>>16),a=(u>>>16)+(f>>>16)+(z>>>16)+(H>>>16)+(i>>>16),y[A]=a<<16|i&65535,y[A+1]=t<<16|h&65535;var J=x,M=r,g=e,R=n,j=B,N=l,T=c,m=s,K=E,V=D,W=d,k=_,Y=b,X=S,$=O,G=U;for(AF=g&j,BF=R&N,A=0;A<160;A+=8)z=(J>>>28|M<<4)^(M>>>2|J<<30)^(M>>>7|J<<25),P=(M>>>28|J<<4)^(J>>>2|M<<30)^(J>>>7|M<<25),H=(K>>>14|V<<18)^(K>>>18|V<<14)^(V>>>9|K<<23),I=(V>>>14|K<<18)^(V>>>18|K<<14)^(K>>>9|V<<23),EF=J&g,CF=M&R,Z=EF^J&j^AF,q=CF^M&N^BF,Q=K&W^~K&Y,FF=V&k^~V&X,f=y[A],o=y[A+1],u=iF[A],p=iF[A+1],h=(p&65535)+(o&65535)+(FF&65535)+(I&65535)+(G&65535),t=(p>>>16)+(o>>>16)+(FF>>>16)+(I>>>16)+(G>>>16)+(h>>>16),i=(u&65535)+(f&65535)+(Q&65535)+(H&65535)+($&65535)+(t>>>16),a=(u>>>16)+(f>>>16)+(Q>>>16)+(H>>>16)+($>>>16)+(i>>>16),f=a<<16|i&65535,o=t<<16|h&65535,h=(q&65535)+(P&65535),t=(q>>>16)+(P>>>16)+(h>>>16),i=(Z&65535)+(z&65535)+(t>>>16),a=(Z>>>16)+(z>>>16)+(i>>>16),u=a<<16|i&65535,p=t<<16|h&65535,h=(m&65535)+(o&65535),t=(m>>>16)+(o>>>16)+(h>>>16),i=(T&65535)+(f&65535)+(t>>>16),a=(T>>>16)+(f>>>16)+(i>>>16),$=a<<16|i&65535,G=t<<16|h&65535,h=(p&65535)+(o&65535),t=(p>>>16)+(o>>>16)+(h>>>16),i=(u&65535)+(f&65535)+(t>>>16),a=(u>>>16)+(f>>>16)+(i>>>16),T=a<<16|i&65535,m=t<<16|h&65535,z=(T>>>28|m<<4)^(m>>>2|T<<30)^(m>>>7|T<<25),P=(m>>>28|T<<4)^(T>>>2|m<<30)^(T>>>7|m<<25),H=($>>>14|G<<18)^($>>>18|G<<14)^(G>>>9|$<<23),I=(G>>>14|$<<18)^(G>>>18|$<<14)^($>>>9|G<<23),cF=T&J,DF=m&M,Z=cF^T&g^EF,q=DF^m&R^CF,Q=$&K^~$&W,FF=G&V^~G&k,f=y[A+2],o=y[A+3],u=iF[A+2],p=iF[A+3],h=(p&65535)+(o&65535)+(FF&65535)+(I&65535)+(X&65535),t=(p>>>16)+(o>>>16)+(FF>>>16)+(I>>>16)+(X>>>16)+(h>>>16),i=(u&65535)+(f&65535)+(Q&65535)+(H&65535)+(Y&65535)+(t>>>16),a=(u>>>16)+(f>>>16)+(Q>>>16)+(H>>>16)+(Y>>>16)+(i>>>16),f=a<<16|i&65535,o=t<<16|h&65535,h=(q&65535)+(P&65535),t=(q>>>16)+(P>>>16)+(h>>>16),i=(Z&65535)+(z&65535)+(t>>>16),a=(Z>>>16)+(z>>>16)+(i>>>16),u=a<<16|i&65535,p=t<<16|h&65535,h=(N&65535)+(o&65535),t=(N>>>16)+(o>>>16)+(h>>>16),i=(j&65535)+(f&65535)+(t>>>16),a=(j>>>16)+(f>>>16)+(i>>>16),Y=a<<16|i&65535,X=t<<16|h&65535,h=(p&65535)+(o&65535),t=(p>>>16)+(o>>>16)+(h>>>16),i=(u&65535)+(f&65535)+(t>>>16),a=(u>>>16)+(f>>>16)+(i>>>16),j=a<<16|i&65535,N=t<<16|h&65535,z=(j>>>28|N<<4)^(N>>>2|j<<30)^(N>>>7|j<<25),P=(N>>>28|j<<4)^(j>>>2|N<<30)^(j>>>7|N<<25),H=(Y>>>14|X<<18)^(Y>>>18|X<<14)^(X>>>9|Y<<23),I=(X>>>14|Y<<18)^(X>>>18|Y<<14)^(Y>>>9|X<<23),uF=j&T,pF=N&m,Z=uF^j&J^cF,q=pF^N&M^DF,Q=Y&$^~Y&K,FF=X&G^~X&V,f=y[A+4],o=y[A+5],u=iF[A+4],p=iF[A+5],h=(p&65535)+(o&65535)+(FF&65535)+(I&65535)+(k&65535),t=(p>>>16)+(o>>>16)+(FF>>>16)+(I>>>16)+(k>>>16)+(h>>>16),i=(u&65535)+(f&65535)+(Q&65535)+(H&65535)+(W&65535)+(t>>>16),a=(u>>>16)+(f>>>16)+(Q>>>16)+(H>>>16)+(W>>>16)+(i>>>16),f=a<<16|i&65535,o=t<<16|h&65535,h=(q&65535)+(P&65535),t=(q>>>16)+(P>>>16)+(h>>>16),i=(Z&65535)+(z&65535)+(t>>>16),a=(Z>>>16)+(z>>>16)+(i>>>16),u=a<<16|i&65535,p=t<<16|h&65535,h=(R&65535)+(o&65535),t=(R>>>16)+(o>>>16)+(h>>>16),i=(g&65535)+(f&65535)+(t>>>16),a=(g>>>16)+(f>>>16)+(i>>>16),W=a<<16|i&65535,k=t<<16|h&65535,h=(p&65535)+(o&65535),t=(p>>>16)+(o>>>16)+(h>>>16),i=(u&65535)+(f&65535)+(t>>>16),a=(u>>>16)+(f>>>16)+(i>>>16),g=a<<16|i&65535,R=t<<16|h&65535,z=(g>>>28|R<<4)^(R>>>2|g<<30)^(R>>>7|g<<25),P=(R>>>28|g<<4)^(g>>>2|R<<30)^(g>>>7|R<<25),H=(W>>>14|k<<18)^(W>>>18|k<<14)^(k>>>9|W<<23),I=(k>>>14|W<<18)^(k>>>18|W<<14)^(W>>>9|k<<23),AF=g&j,BF=R&N,Z=AF^g&T^uF,q=BF^R&m^pF,Q=W&Y^~W&$,FF=k&X^~k&G,f=y[A+6],o=y[A+7],u=iF[A+6],p=iF[A+7],h=(p&65535)+(o&65535)+(FF&65535)+(I&65535)+(V&65535),t=(p>>>16)+(o>>>16)+(FF>>>16)+(I>>>16)+(V>>>16)+(h>>>16),i=(u&65535)+(f&65535)+(Q&65535)+(H&65535)+(K&65535)+(t>>>16),a=(u>>>16)+(f>>>16)+(Q>>>16)+(H>>>16)+(K>>>16)+(i>>>16),f=a<<16|i&65535,o=t<<16|h&65535,h=(q&65535)+(P&65535),t=(q>>>16)+(P>>>16)+(h>>>16),i=(Z&65535)+(z&65535)+(t>>>16),a=(Z>>>16)+(z>>>16)+(i>>>16),u=a<<16|i&65535,p=t<<16|h&65535,h=(M&65535)+(o&65535),t=(M>>>16)+(o>>>16)+(h>>>16),i=(J&65535)+(f&65535)+(t>>>16),a=(J>>>16)+(f>>>16)+(i>>>16),K=a<<16|i&65535,V=t<<16|h&65535,h=(p&65535)+(o&65535),t=(p>>>16)+(o>>>16)+(h>>>16),i=(u&65535)+(f&65535)+(t>>>16),a=(u>>>16)+(f>>>16)+(i>>>16),J=a<<16|i&65535,M=t<<16|h&65535;h=(r&65535)+(M&65535),t=(r>>>16)+(M>>>16)+(h>>>16),i=(x&65535)+(J&65535)+(t>>>16),a=(x>>>16)+(J>>>16)+(i>>>16),this.h0h=a<<16|i&65535,this.h0l=t<<16|h&65535,h=(n&65535)+(R&65535),t=(n>>>16)+(R>>>16)+(h>>>16),i=(e&65535)+(g&65535)+(t>>>16),a=(e>>>16)+(g>>>16)+(i>>>16),this.h1h=a<<16|i&65535,this.h1l=t<<16|h&65535,h=(l&65535)+(N&65535),t=(l>>>16)+(N>>>16)+(h>>>16),i=(B&65535)+(j&65535)+(t>>>16),a=(B>>>16)+(j>>>16)+(i>>>16),this.h2h=a<<16|i&65535,this.h2l=t<<16|h&65535,h=(s&65535)+(m&65535),t=(s>>>16)+(m>>>16)+(h>>>16),i=(c&65535)+(T&65535)+(t>>>16),a=(c>>>16)+(T>>>16)+(i>>>16),this.h3h=a<<16|i&65535,this.h3l=t<<16|h&65535,h=(D&65535)+(V&65535),t=(D>>>16)+(V>>>16)+(h>>>16),i=(E&65535)+(K&65535)+(t>>>16),a=(E>>>16)+(K>>>16)+(i>>>16),this.h4h=a<<16|i&65535,this.h4l=t<<16|h&65535,h=(_&65535)+(k&65535),t=(_>>>16)+(k>>>16)+(h>>>16),i=(d&65535)+(W&65535)+(t>>>16),a=(d>>>16)+(W>>>16)+(i>>>16),this.h5h=a<<16|i&65535,this.h5l=t<<16|h&65535,h=(S&65535)+(X&65535),t=(S>>>16)+(X>>>16)+(h>>>16),i=(b&65535)+(Y&65535)+(t>>>16),a=(b>>>16)+(Y>>>16)+(i>>>16),this.h6h=a<<16|i&65535,this.h6l=t<<16|h&65535,h=(U&65535)+(G&65535),t=(U>>>16)+(G>>>16)+(h>>>16),i=(O&65535)+($&65535)+(t>>>16),a=(O>>>16)+($>>>16)+(i>>>16),this.h7h=a<<16|i&65535,this.h7l=t<<16|h&65535},v.prototype.hex=function(){this.finalize();var x=this.h0h,r=this.h0l,e=this.h1h,n=this.h1l,B=this.h2h,l=this.h2l,c=this.h3h,s=this.h3l,E=this.h4h,D=this.h4l,d=this.h5h,_=this.h5l,b=this.h6h,S=this.h6l,O=this.h7h,U=this.h7l,y=this.bits,A=F[x>>28&15]+F[x>>24&15]+F[x>>20&15]+F[x>>16&15]+F[x>>12&15]+F[x>>8&15]+F[x>>4&15]+F[x&15]+F[r>>28&15]+F[r>>24&15]+F[r>>20&15]+F[r>>16&15]+F[r>>12&15]+F[r>>8&15]+F[r>>4&15]+F[r&15]+F[e>>28&15]+F[e>>24&15]+F[e>>20&15]+F[e>>16&15]+F[e>>12&15]+F[e>>8&15]+F[e>>4&15]+F[e&15]+F[n>>28&15]+F[n>>24&15]+F[n>>20&15]+F[n>>16&15]+F[n>>12&15]+F[n>>8&15]+F[n>>4&15]+F[n&15]+F[B>>28&15]+F[B>>24&15]+F[B>>20&15]+F[B>>16&15]+F[B>>12&15]+F[B>>8&15]+F[B>>4&15]+F[B&15]+F[l>>28&15]+F[l>>24&15]+F[l>>20&15]+F[l>>16&15]+F[l>>12&15]+F[l>>8&15]+F[l>>4&15]+F[l&15]+F[c>>28&15]+F[c>>24&15]+F[c>>20&15]+F[c>>16&15]+F[c>>12&15]+F[c>>8&15]+F[c>>4&15]+F[c&15];return y>=256&&(A+=F[s>>28&15]+F[s>>24&15]+F[s>>20&15]+F[s>>16&15]+F[s>>12&15]+F[s>>8&15]+F[s>>4&15]+F[s&15]),y>=384&&(A+=F[E>>28&15]+F[E>>24&15]+F[E>>20&15]+F[E>>16&15]+F[E>>12&15]+F[E>>8&15]+F[E>>4&15]+F[E&15]+F[D>>28&15]+F[D>>24&15]+F[D>>20&15]+F[D>>16&15]+F[D>>12&15]+F[D>>8&15]+F[D>>4&15]+F[D&15]+F[d>>28&15]+F[d>>24&15]+F[d>>20&15]+F[d>>16&15]+F[d>>12&15]+F[d>>8&15]+F[d>>4&15]+F[d&15]+F[_>>28&15]+F[_>>24&15]+F[_>>20&15]+F[_>>16&15]+F[_>>12&15]+F[_>>8&15]+F[_>>4&15]+F[_&15]),y==512&&(A+=F[b>>28&15]+F[b>>24&15]+F[b>>20&15]+F[b>>16&15]+F[b>>12&15]+F[b>>8&15]+F[b>>4&15]+F[b&15]+F[S>>28&15]+F[S>>24&15]+F[S>>20&15]+F[S>>16&15]+F[S>>12&15]+F[S>>8&15]+F[S>>4&15]+F[S&15]+F[O>>28&15]+F[O>>24&15]+F[O>>20&15]+F[O>>16&15]+F[O>>12&15]+F[O>>8&15]+F[O>>4&15]+F[O&15]+F[U>>28&15]+F[U>>24&15]+F[U>>20&15]+F[U>>16&15]+F[U>>12&15]+F[U>>8&15]+F[U>>4&15]+F[U&15]),A},v.prototype.toString=v.prototype.hex,v.prototype.digest=function(){this.finalize();var x=this.h0h,r=this.h0l,e=this.h1h,n=this.h1l,B=this.h2h,l=this.h2l,c=this.h3h,s=this.h3l,E=this.h4h,D=this.h4l,d=this.h5h,_=this.h5l,b=this.h6h,S=this.h6l,O=this.h7h,U=this.h7l,y=this.bits,A=[x>>24&255,x>>16&255,x>>8&255,x&255,r>>24&255,r>>16&255,r>>8&255,r&255,e>>24&255,e>>16&255,e>>8&255,e&255,n>>24&255,n>>16&255,n>>8&255,n&255,B>>24&255,B>>16&255,B>>8&255,B&255,l>>24&255,l>>16&255,l>>8&255,l&255,c>>24&255,c>>16&255,c>>8&255,c&255];return y>=256&&A.push(s>>24&255,s>>16&255,s>>8&255,s&255),y>=384&&A.push(E>>24&255,E>>16&255,E>>8&255,E&255,D>>24&255,D>>16&255,D>>8&255,D&255,d>>24&255,d>>16&255,d>>8&255,d&255,_>>24&255,_>>16&255,_>>8&255,_&255),y==512&&A.push(b>>24&255,b>>16&255,b>>8&255,b&255,S>>24&255,S>>16&255,S>>8&255,S&255,O>>24&255,O>>16&255,O>>8&255,O&255,U>>24&255,U>>16&255,U>>8&255,U&255),A},v.prototype.array=v.prototype.digest,v.prototype.arrayBuffer=function(){this.finalize();var x=this.bits,r=new ArrayBuffer(x/8),e=new DataView(r);return e.setUint32(0,this.h0h),e.setUint32(4,this.h0l),e.setUint32(8,this.h1h),e.setUint32(12,this.h1l),e.setUint32(16,this.h2h),e.setUint32(20,this.h2l),e.setUint32(24,this.h3h),x>=256&&e.setUint32(28,this.h3l),x>=384&&(e.setUint32(32,this.h4h),e.setUint32(36,this.h4l),e.setUint32(40,this.h5h),e.setUint32(44,this.h5l)),x==512&&(e.setUint32(48,this.h6h),e.setUint32(52,this.h6l),e.setUint32(56,this.h7h),e.setUint32(60,this.h7l)),r},v.prototype.clone=function(){var x=new v(this.bits,!1);return this.copyTo(x),x},v.prototype.copyTo=function(x){var r=0,e=["h0h","h0l","h1h","h1l","h2h","h2l","h3h","h3l","h4h","h4l","h5h","h5l","h6h","h6l","h7h","h7l","start","bytes","hBytes","finalized","hashed","lastByteIndex"];for(r=0;r<e.length;++r)x[e[r]]=this[e[r]];for(r=0;r<this.blocks.length;++r)x.blocks[r]=this.blocks[r]};function rF(x,r,e){var n,B=typeof x;if(B!=="string"){if(B==="object"){if(x===null)throw new Error(hF);if(aF&&x.constructor===ArrayBuffer)x=new Uint8Array(x);else if(!Array.isArray(x)&&(!aF||!ArrayBuffer.isView(x)))throw new Error(hF)}else throw new Error(hF);n=!0}var l=x.length;if(!n){for(var c=[],l=x.length,s=0,E,D=0;D<l;++D)E=x.charCodeAt(D),E<128?c[s++]=E:E<2048?(c[s++]=192|E>>6,c[s++]=128|E&63):E<55296||E>=57344?(c[s++]=224|E>>12,c[s++]=128|E>>6&63,c[s++]=128|E&63):(E=65536+((E&1023)<<10|x.charCodeAt(++D)&1023),c[s++]=240|E>>18,c[s++]=128|E>>12&63,c[s++]=128|E>>6&63,c[s++]=128|E&63);x=c}x.length>128&&(x=new v(r,!0).update(x).array());for(var d=[],_=[],D=0;D<128;++D){var b=x[D]||0;d[D]=92^b,_[D]=54^b}v.call(this,r,e),this.update(_),this.oKeyPad=d,this.inner=!0,this.sharedMemory=e}rF.prototype=new v,rF.prototype.finalize=function(){if(v.prototype.finalize.call(this),this.inner){this.inner=!1;var x=this.array();v.call(this,this.bits,this.sharedMemory),this.update(this.oKeyPad),this.update(x),v.prototype.finalize.call(this)}},rF.prototype.clone=function(){var x=new rF([],this.bits,!1);this.copyTo(x),x.inner=this.inner;for(var r=0;r<this.oKeyPad.length;++r)x.oKeyPad[r]=this.oKeyPad[r];return x};var L=oF(512);L.sha512=L,L.sha384=oF(384),L.sha512_256=oF(256),L.sha512_224=oF(224),L.sha512.hmac=nF(512),L.sha384.hmac=nF(384),L.sha512_256.hmac=nF(256),L.sha512_224.hmac=nF(224),wF?sF.exports=L:(w.sha512=L.sha512,w.sha384=L.sha384,w.sha512_256=L.sha512_256,w.sha512_224=L.sha512_224)})()})(dF);var _F=dF.exports;const RF=OF(_F),NF=gF({__proto__:null,default:RF},[_F]);export{NF as s};
@@ -1,6 +1,6 @@
1
1
  @font-face {
2
2
  font-family: 'fontello';
3
- src: url('fontello.woff2?39711600') format('woff2');
3
+ src: url('fontello.woff2?39711601') format('woff2');
4
4
  font-weight: normal;
5
5
  font-style: normal;
6
6
  }
@@ -65,6 +65,7 @@
65
65
  .fa-lock:before { content: '\e817'; } /* '' */
66
66
  .fa-reload:before { content: '\e818'; } /* '' */
67
67
  .fa-cut:before { content: '\e819'; } /* '' */
68
+ .fa-shuffle:before { content: '\e81a'; } /* '' */
68
69
  .fa-spin6:before { content: '\e839'; } /* '' */
69
70
  .fa-crown:before { content: '\e844'; } /* '' */
70
71
  .fa-download:before { content: '\f02e'; } /* '' */
@@ -72,7 +73,7 @@
72
73
  .fa-link:before { content: '\f08e'; } /* '' */
73
74
  .fa-filter:before { content: '\f0b0'; } /* '' */
74
75
  .fa-zoom:before { content: '\f0b2'; } /* '' */
75
- .copy:before { content: '\f0c5'; } /* '' */
76
+ .fa-copy:before { content: '\f0c5'; } /* '' */
76
77
  .fa-menu:before { content: '\f0c9'; } /* '' */
77
78
  .fa-comment:before { content: '\f0e5'; } /* '' */
78
79
  .fa-paste:before { content: '\f0ea'; } /* '' */
Binary file
@@ -4,8 +4,9 @@
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-r8i8c_PX.js"></script>
8
- <link rel="stylesheet" crossorigin href="/assets/index-EdGoLuWB.css">
7
+ <script src="//polyfill.io/v3/polyfill.min.js?features=es2022%2Ces2021%2Ces2020%2Ces2019%2Ces2018%2Ces2017"></script>
8
+ <script type="module" crossorigin src="/assets/index-SY22o0dA.js"></script>
9
+ <link rel="stylesheet" crossorigin href="/assets/index-Kys6yJtN.css">
9
10
  </head>
10
11
  <body>
11
12
  <noscript>You need to enable JavaScript to run this app.</noscript>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hfs",
3
- "version": "0.52.0-alpha2",
3
+ "version": "0.52.0-beta4",
4
4
  "description": "HTTP File Server",
5
5
  "keywords": [
6
6
  "file server",
@@ -24,13 +24,17 @@
24
24
  "test": "mocha -r ts-node/register 'tests/**/*.ts'",
25
25
  "pub": "cd dist && npm publish",
26
26
  "dist": "npm run build-all && npm run dist-bin",
27
- "dist-bin": "npm run dist-modules && npm run dist-win && npm run dist-linux && npm run dist-mac && npm run dist-mac-arm",
27
+ "dist-bin": "npm run dist-modules && npm run dist-bin-win && npm run dist-bin-linux && npm run dist-bin-mac && npm run dist-bin-mac-arm",
28
28
  "dist-modules": "cp package*.json central.json dist && cd dist && npm ci --omit=dev && cd .. && node prune_modules",
29
29
  "dist-pre": "cd dist && rm -rf node_modules/@node-rs/crc32-*",
30
- "dist-win": "npm run dist-pre && cd dist && npm i -f --no-save --omit=dev @node-rs/crc32-win32-x64-msvc && pkg . --public -C gzip -t node18-win-x64 && zip hfs-windows.zip hfs.exe -r plugins && cd ..",
31
- "dist-mac-arm": "npm run dist-pre && cd dist && npm i -f --no-save --omit=dev @node-rs/crc32-darwin-arm64 && pkg . --public -C gzip -t node18-macos-arm64 && zip hfs-mac-arm.zip hfs -r plugins && cd ..",
32
- "dist-mac": "npm run dist-pre && cd dist && npm i -f --no-save --omit=dev @node-rs/crc32-darwin-x64 && pkg . --public -C gzip -t node18-macos-x64 && zip hfs-mac.zip hfs -r plugins && cd ..",
33
- "dist-linux": "npm run dist-pre && cd dist && npm i -f --no-save --omit=dev @node-rs/crc32-linux-x64-gnu && pkg . --public -C gzip -t node18-linux-x64 && zip hfs-linux.zip hfs -r plugins && cd ..",
30
+ "dist-bin-win": "npm run dist-pre && cd dist && npm i -f --no-save --omit=dev @node-rs/crc32-win32-x64-msvc && pkg . --public -C gzip -t node18-win-x64 && zip hfs-windows.zip hfs.exe -r plugins && cd ..",
31
+ "dist-bin-mac-arm": "npm run dist-pre && cd dist && npm i -f --no-save --omit=dev @node-rs/crc32-darwin-arm64 && pkg . --public -C gzip -t node18-macos-arm64 && zip hfs-mac-arm.zip hfs -r plugins && cd ..",
32
+ "dist-bin-mac": "npm run dist-pre && cd dist && npm i -f --no-save --omit=dev @node-rs/crc32-darwin-x64 && pkg . --public -C gzip -t node18-macos-x64 && zip hfs-mac.zip hfs -r plugins && cd ..",
33
+ "dist-bin-linux": "npm run dist-pre && cd dist && npm i -f --no-save --omit=dev @node-rs/crc32-linux-x64-gnu && pkg . --public -C gzip -t node18-linux-x64 && zip hfs-linux.zip hfs -r plugins && cd ..",
34
+ "dist-win": "npm run dist-modules && npm run dist-bin-win",
35
+ "dist-mac-arm": "npm run dist-modules && npm run dist-bin-mac-arm",
36
+ "dist-mac": "npm run dist-modules && npm run dist-bin-mac",
37
+ "dist-linux": "npm run dist-modules && npm run dist-bin-linux",
34
38
  "dist-node": "npm run dist-modules && cd dist && zip hfs-node.zip -r * -x *.zip *.exe hfs-* *.log logs"
35
39
  },
36
40
  "engines": {
@@ -28,7 +28,7 @@ const get_file_list = async ({ uri = '/', offset, limit, search, c, onlyFolders,
28
28
  return fail(const_1.HTTP_METHOD_NOT_ALLOWED);
29
29
  offset = Number(offset);
30
30
  limit = Number(limit);
31
- const filter = (0, misc_1.pattern2filter)(search);
31
+ const filter = (0, misc_1.pattern2filter)(String(search || ''));
32
32
  const walker = (0, vfs_1.walkNode)(node, { ctx: admin ? undefined : ctx, onlyFolders, depth: search ? Infinity : 0 });
33
33
  const onDirEntryHandlers = (0, plugins_1.mapPlugins)(plug => plug.onDirEntry);
34
34
  const can_upload = admin || (0, vfs_1.hasPermission)(node, 'can_upload', ctx);
package/src/api.log.js CHANGED
@@ -8,11 +8,24 @@ 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 fs_1 = require("fs");
12
- const readline_1 = __importDefault(require("readline"));
13
11
  const misc_1 = require("./misc");
14
12
  const SendList_1 = require("./SendList");
13
+ const serveFile_1 = require("./serveFile");
15
14
  exports.default = {
15
+ async get_log_file({ file = 'log', range = '' }, ctx) {
16
+ const log = lodash_1.default.find(log_1.loggers, { name: file });
17
+ if (!log)
18
+ throw cross_1.HTTP_NOT_FOUND;
19
+ if (!log.path)
20
+ throw cross_1.HTTP_NOT_ACCEPTABLE;
21
+ ctx.attachment(log.path);
22
+ if (range)
23
+ ctx.request.header.range = `bytes=${range}`;
24
+ if (ctx.method === 'POST') // this would cause method_not_allowed
25
+ ctx.method = 'GET';
26
+ await (0, serveFile_1.serveFile)(ctx, log.path);
27
+ return null;
28
+ },
16
29
  get_log({ file = 'log' }, ctx) {
17
30
  return new SendList_1.SendListReadable({
18
31
  bufferTime: 10,
@@ -27,48 +40,15 @@ exports.default = {
27
40
  events_1.default.on('console', x => list.add(x));
28
41
  return;
29
42
  }
30
- const logger = log_1.loggers.find(l => l.name === file);
31
- if (!logger)
43
+ if (!lodash_1.default.find(log_1.loggers, { name: file }))
32
44
  return list.error(cross_1.HTTP_NOT_FOUND, true);
33
- const input = (0, fs_1.createReadStream)(logger.path);
34
- input.on('error', async (e) => {
35
- if (e.code === 'ENOENT') // ignore ENOENT, consider it an empty log
36
- return list.ready();
37
- list.error(e.code || e.message);
38
- });
39
- input.on('end', () => list.ready());
40
- input.on('ready', () => {
41
- readline_1.default.createInterface({ input }).on('line', line => {
42
- if (ctx.aborted)
43
- return input.close();
44
- const obj = parse(line);
45
- if (obj)
46
- list.add(obj);
47
- }).on('close', () => {
48
- ctx.res.once('close', (0, misc_1.onOff)(events_1.default, {
49
- [logger.name](entry) {
50
- list.add(entry);
51
- }
52
- }));
53
- });
54
- });
45
+ list.ready();
46
+ ctx.res.once('close', (0, misc_1.onOff)(events_1.default, {
47
+ [file](entry) {
48
+ list.add(entry);
49
+ }
50
+ }));
55
51
  }
56
52
  });
57
- function parse(line) {
58
- const m = /^(.+?) (.+?) (.+?) \[(.{11}):(.{14})] "(\w+) ([^"]+) HTTP\/\d.\d" (\d+) (-|\d+) ?(.*)/.exec(line);
59
- if (!m)
60
- return;
61
- const [, ip, , user, date, time, method, uri, status, length, extra] = m;
62
- return {
63
- ip,
64
- user: user === '-' ? undefined : user,
65
- ts: new Date(date + ' ' + time),
66
- method,
67
- uri,
68
- status: Number(status),
69
- length: length === '-' ? undefined : Number(length),
70
- extra: (0, cross_1.tryJson)((0, cross_1.tryJson)(extra)) || undefined,
71
- };
72
- }
73
53
  },
74
54
  };
package/src/api.vfs.js CHANGED
@@ -84,6 +84,8 @@ const apis = {
84
84
  return new apiMiddleware_1.ApiError(const_1.HTTP_NOT_FOUND, 'path not found');
85
85
  props = pickProps(props, ALLOWED_KEYS); // sanitize
86
86
  if (props.name && props.name !== (0, vfs_1.getNodeName)(n)) {
87
+ if (!(0, misc_1.isValidFileName)(props.name))
88
+ return new apiMiddleware_1.ApiError(const_1.HTTP_BAD_REQUEST, 'bad name');
87
89
  const parent = await urlToNodeOriginal((0, path_1.dirname)(uri));
88
90
  if ((_a = parent === null || parent === void 0 ? void 0 : parent.children) === null || _a === void 0 ? void 0 : _a.find(x => (0, vfs_1.getNodeName)(x) === props.name))
89
91
  return new apiMiddleware_1.ApiError(const_1.HTTP_CONFLICT, 'name already present');
@@ -99,6 +101,8 @@ const apis = {
99
101
  var _a;
100
102
  if (!source && !name)
101
103
  return new apiMiddleware_1.ApiError(const_1.HTTP_BAD_REQUEST, 'name or source required');
104
+ if (!(0, misc_1.isValidFileName)(name))
105
+ return new apiMiddleware_1.ApiError(const_1.HTTP_BAD_REQUEST, 'bad name');
102
106
  const parentNode = parent ? await urlToNodeOriginal(parent) : vfs_1.vfs;
103
107
  if (!parentNode)
104
108
  return new apiMiddleware_1.ApiError(const_1.HTTP_NOT_FOUND, 'parent not found');
@@ -128,7 +132,7 @@ const apis = {
128
132
  },
129
133
  async del_vfs({ uris }) {
130
134
  if (!uris || !Array.isArray(uris))
131
- return new apiMiddleware_1.ApiError(const_1.HTTP_BAD_REQUEST, 'invalid uris');
135
+ return new apiMiddleware_1.ApiError(const_1.HTTP_BAD_REQUEST, 'bad uris');
132
136
  return {
133
137
  errors: await Promise.all(uris.map(async (uri) => {
134
138
  if (typeof uri !== 'string')
@@ -44,11 +44,15 @@ function apiMiddleware(apis) {
44
44
  else if (typeof (v === null || v === void 0 ? void 0 : v[0]) === 'string')
45
45
  v.forEach((x, i) => fixUri(v, i));
46
46
  res = await apiFun(params, ctx);
47
+ if (res === null)
48
+ return;
47
49
  function fixUri(obj, k) {
48
50
  obj[k] = (0, misc_1.removeStarting)(ctx.state.revProxyPath, obj[k]);
49
51
  }
50
52
  }
51
53
  catch (e) {
54
+ if (typeof e === 'number')
55
+ e = new ApiError(const_1.HTTP_NOT_FOUND);
52
56
  res = e;
53
57
  }
54
58
  if (isAsyncGenerator(res))
package/src/const.js CHANGED
@@ -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-01-31T22:47:53.249Z";
48
+ exports.BUILD_TIMESTAMP = "2024-02-11T10:59:36.071Z";
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
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
20
  exports.typedEntries = exports.typedKeys = exports.objRenameKey = exports.randomId = exports.getOrSet = exports.waitFor = exports.newObj = exports.findDefined = exports.isOrderedEqual = exports.swap = exports.tryJson = exports.dirname = exports.basename = exports.pendingPromise = exports._dbg = exports._log = exports.wantArray = exports.formatPerc = exports.with_ = exports.try_ = exports.setHidden = exports.onlyTruthy = exports.truthy = exports.splitAt = exports.strinsert = exports.removeStarting = exports.enforceFinal = exports.objSameKeys = exports.haveTimeout = exports.wait = exports.prefix = exports.formatSpeed = exports.formatBytes = exports.isWhoObject = exports.PERM_KEYS = exports.defaultPerms = exports.WHO_ANY_ACCOUNT = exports.WHO_NO_ONE = exports.WHO_ANYONE = exports.LIST = exports.CFG = exports.THEME_OPTIONS = exports.SORT_BY_OPTIONS = exports.FRONTEND_OPTIONS = exports.MAX_TILE_SIZE = exports.DAY = exports.HOUR = exports.MINUTE = exports.WIKI_URL = exports.REPO_URL = void 0;
21
- exports.shortenAgent = exports.replace = exports.matches = exports.makeMatcher = exports.runAt = exports.pathEncode = exports.promiseBestEffort = exports.escapeHTML = exports.ipForUrl = exports.isIpLan = exports.isIpLocalHost = exports.xlate = exports.isEqualLax = exports.isWindowsDrive = exports.isIP = exports.isPrimitive = exports.formatTimestamp = exports.repeat = exports.asyncGeneratorToArray = exports.filterMapGenerator = exports.throw_ = exports.hasProp = void 0;
21
+ exports.shortenAgent = exports.inCommon = exports.replace = exports.matches = exports.makeMatcher = exports.runAt = exports.pathEncode = exports.promiseBestEffort = exports.escapeHTML = exports.ipForUrl = exports.isIpLan = exports.isIpLocalHost = exports.xlate = exports.isEqualLax = exports.isWindowsDrive = exports.isIP = exports.isPrimitive = exports.formatTimestamp = exports.repeat = exports.asyncGeneratorToArray = exports.filterMapGenerator = exports.throw_ = exports.hasProp = void 0;
22
22
  // This file is part of HFS - Copyright 2021-2023, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
23
23
  // all content here is shared between client and server
24
24
  const lodash_1 = __importDefault(require("lodash"));
@@ -405,6 +405,14 @@ function replace(s, symbols, delimiter = '') {
405
405
  return s;
406
406
  }
407
407
  exports.replace = replace;
408
+ function inCommon(a, b) {
409
+ let i = 0;
410
+ const n = a.length;
411
+ while (i < n && a[i] === b[i])
412
+ i++;
413
+ return i;
414
+ }
415
+ exports.inCommon = inCommon;
408
416
  function shortenAgent(agent) {
409
417
  var _a;
410
418
  return lodash_1.default.findKey(BROWSERS, re => re.test(agent))
package/src/errorPages.js CHANGED
@@ -10,7 +10,7 @@ function getErrorSections() {
10
10
  }
11
11
  exports.getErrorSections = getErrorSections;
12
12
  // to be used with errors whose recipient is possibly human
13
- async function sendErrorPage(ctx, code) {
13
+ async function sendErrorPage(ctx, code = ctx.status) {
14
14
  var _a, _b;
15
15
  ctx.type = 'text';
16
16
  ctx.set('content-disposition', ''); // reset ctx.attachment
@@ -23,7 +23,7 @@ async function sendErrorPage(ctx, code) {
23
23
  return;
24
24
  const trans = (_a = Object.values(lang)[0]) === null || _a === void 0 ? void 0 : _a.translate;
25
25
  ctx.body = (_b = trans === null || trans === void 0 ? void 0 : trans[msg]) !== null && _b !== void 0 ? _b : msg;
26
- const errorPage = (0, customHtml_1.getSection)(String(ctx.status));
26
+ const errorPage = (0, customHtml_1.getSection)(ctx.status === cross_1.HTTP_UNAUTHORIZED ? 'unauthorized' : String(ctx.status));
27
27
  if (!errorPage)
28
28
  return;
29
29
  if (errorPage.includes('<'))
@@ -71,7 +71,7 @@ exports.frontEndApis = {
71
71
  },
72
72
  async create_folder({ uri, name }, ctx) {
73
73
  (0, misc_1.apiAssertTypes)({ string: { uri, name } });
74
- if (!(0, util_files_1.isValidFileName)(name) || (0, util_files_1.dirTraversal)(name))
74
+ if (!(0, util_files_1.isValidFileName)(name))
75
75
  return new apiMiddleware_1.ApiError(const_1.HTTP_BAD_REQUEST, 'bad name');
76
76
  const parentNode = await (0, vfs_1.urlToNode)(uri, ctx);
77
77
  if (!parentNode)
@@ -148,9 +148,15 @@ exports.frontEndApis = {
148
148
  const srcNode = await (0, vfs_1.urlToNode)(src, ctx);
149
149
  if (!srcNode)
150
150
  return const_1.HTTP_NOT_FOUND;
151
+ const s = srcNode.source;
152
+ const d = (0, path_1.join)(destNode.source, (0, path_1.basename)(srcNode.source));
151
153
  return (0, vfs_1.statusCodeForMissingPerm)(srcNode, 'can_delete', ctx)
152
- || (0, promises_1.rename)(srcNode.source, (0, path_1.join)(destNode.source, (0, path_1.basename)(srcNode.source)))
153
- .catch(e => e.code || String(e));
154
+ || (0, promises_1.rename)(s, d).catch(async (e) => {
155
+ if (e.code !== 'EXDEV')
156
+ throw e; // exdev = different drive
157
+ await (0, promises_1.copyFile)(s, d);
158
+ await (0, promises_1.unlink)(s);
159
+ }).catch(e => e.code || String(e));
154
160
  }))
155
161
  };
156
162
  },
package/src/geo.js CHANGED
@@ -20,7 +20,7 @@ setInterval(checkFiles, misc_1.DAY); // keep updated at run-time
20
20
  exports.ip2country = lodash_1.default.memoize((ip) => ip2location.getCountryShortAsync(ip).then(v => v === '-' ? '' : v, () => ''));
21
21
  const geoFilter = async (ctx, next) => {
22
22
  var _a;
23
- if (enabled.get() && !(0, misc_1.isLocalHost)(ctx)) {
23
+ if (enabled.get() && !(0, misc_1.isLocalHost)(ctx) && !(0, misc_1.isIpLan)(ctx.ip)) {
24
24
  const { connection } = ctx.state;
25
25
  const country = (_a = connection.country) !== null && _a !== void 0 ? _a : (connection.country = await (0, exports.ip2country)(ctx.ip));
26
26
  if (country)
@@ -113,12 +113,8 @@
113
113
  "File Show help": "Guida File Show",
114
114
  "showHelpMain": "Puoi usare la tastiera per alcune azioni:",
115
115
  "showHelp_space": "spazio",
116
- "showHelp_←/→_body": "vai al precedente/prossimo file",
117
- "showHelp_↑/↓_body": "scorri immagini lunghe",
118
- "showHelp_space_body": "seleziona",
119
- "showHelp_D_body": "download",
120
- "showHelp_Z_body": "cambia modalità zoom",
121
- "showHelp_F_body": "pieno schermo",
116
+ "showHelp_←/→_body": "Vai al precedente/prossimo file",
117
+ "showHelp_↑/↓_body": "Scorri immagini lunghe",
122
118
  "Destination": "Destinazione",
123
119
  "in_queue": "{n} in coda",
124
120
  "enter_comment": "Comment for this file",
@@ -141,6 +137,10 @@
141
137
  "autoplay_seconds": "Secondi di attesa mostrando immagini",
142
138
  "Select all": "Seleziona tutto",
143
139
  "go_first": "Vai all'inizio",
144
- "go_last": "Vai alla fine"
140
+ "go_last": "Vai alla fine",
141
+ "Shuffle": "Riproduzione casuale",
142
+ "Repeat": "Ripeti a fine lista",
143
+ "showHelpListShortcut": "Dalla lista dei file, clicca tenendo {key} per accedere velocemente al File Show",
144
+ "Invalid value": "Valore non valido"
145
145
  }
146
146
  }
package/src/misc.js CHANGED
@@ -20,7 +20,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.apiAssertTypes = exports.AsapStream = exports.asyncGeneratorToReadable = exports.same = exports.makeNetMatcher = exports.isLocalHost = exports.onOff = exports.pattern2filter = exports.onFirstEvent = exports.onProcessExit = void 0;
22
22
  const path_1 = require("path");
23
- const lodash_1 = __importDefault(require("lodash"));
24
23
  const assert_1 = __importDefault(require("assert"));
25
24
  __exportStar(require("./util-http"), exports);
26
25
  __exportStar(require("./util-files"), exports);
@@ -51,8 +50,8 @@ function onFirstEvent(emitter, events, cb) {
51
50
  }
52
51
  exports.onFirstEvent = onFirstEvent;
53
52
  function pattern2filter(pattern) {
54
- const re = new RegExp(lodash_1.default.escapeRegExp(pattern), 'i');
55
- return (s) => !s || !pattern || re.test((0, path_1.basename)(s));
53
+ const matcher = (0, cross_1.makeMatcher)(pattern.includes('*') ? pattern : `*${pattern}*`); // if you specify *, we'll respect its position
54
+ return (s) => !s || !pattern || matcher((0, path_1.basename)(s));
56
55
  }
57
56
  exports.pattern2filter = pattern2filter;
58
57
  // install multiple handlers and returns a handy 'uninstall' function which requires no parameter. Pass a map {event:handler}
package/src/nat.js CHANGED
@@ -66,12 +66,13 @@ exports.getPublicIps = (0, debounceAsync_1.debounceAsync)(async () => {
66
66
  exports.getNatInfo = (0, debounceAsync_1.debounceAsync)(async () => {
67
67
  var _a, _b, _c, _d;
68
68
  const gettingIps = (0, exports.getPublicIps)(); // don't wait, do it in parallel
69
- const res = await exports.upnpClient.getGateway().catch(() => null);
69
+ const res = await (0, cross_1.haveTimeout)(10000, exports.upnpClient.getGateway()).catch(() => null);
70
70
  const status = await (0, listen_1.getServerStatus)();
71
71
  const mappings = res && await (0, cross_1.haveTimeout)(5000, exports.upnpClient.getMappings()).catch(() => null);
72
72
  console.debug('mappings found', mappings === null || mappings === void 0 ? void 0 : mappings.map(x => x.description));
73
73
  const gatewayIp = res ? new URL(res.gateway.description).hostname : await findGateway().catch(() => undefined);
74
- const localIp = (res === null || res === void 0 ? void 0 : res.address) || (await (0, listen_1.getIps)())[0];
74
+ const localIps = await (0, listen_1.getIps)(false);
75
+ const localIp = (res === null || res === void 0 ? void 0 : res.address) || gatewayIp ? lodash_1.default.maxBy(localIps, x => (0, cross_1.inCommon)(x, gatewayIp)) : localIps[0];
75
76
  const internalPort = ((_a = status === null || status === void 0 ? void 0 : status.https) === null || _a === void 0 ? void 0 : _a.listening) && status.https.port || ((_b = status === null || status === void 0 ? void 0 : status.http) === null || _b === void 0 ? void 0 : _b.listening) && status.http.port || undefined;
76
77
  const mapped = lodash_1.default.find(mappings, x => x.private.host === localIp && x.private.port === internalPort);
77
78
  const externalPort = mapped === null || mapped === void 0 ? void 0 : mapped.public.port;
package/src/serveFile.js CHANGED
@@ -122,7 +122,7 @@ function applyRange(ctx, totalSize = ctx.response.length) {
122
122
  return ctx.throw(const_1.HTTP_BAD_REQUEST, 'bad range');
123
123
  const max = totalSize - 1;
124
124
  const start = bytes[0] ? Number(bytes[0]) : Math.max(0, totalSize - Number(bytes[1])); // a negative start is relative to the end
125
- const end = bytes[0] ? Number(bytes[1] || max) : max;
125
+ const end = (bytes[0] && bytes[1]) ? Math.min(max, Number(bytes[1])) : max;
126
126
  // we don't support last-bytes without knowing max
127
127
  if (isNaN(end) && isNaN(max) || end > max || start > max) {
128
128
  ctx.status = const_1.HTTP_RANGE_NOT_SATISFIABLE;
@@ -88,7 +88,7 @@ const serveGuiAndSharedFiles = async (ctx, next) => {
88
88
  return !node.source ? (0, errorPages_1.sendErrorPage)(ctx, cross_const_1.HTTP_METHOD_NOT_ALLOWED)
89
89
  : !(0, vfs_1.statusCodeForMissingPerm)(node, 'can_read', ctx) ? (0, serveFile_1.serveFileNode)(ctx, node)
90
90
  : ctx.status !== cross_const_1.HTTP_UNAUTHORIZED ? null
91
- : !path.endsWith('/') ? ctx.set('WWW-Authenticate', 'Basic') // this is necessary to support standard urls with credentials. Final / means we are dealing with default file...
91
+ : !path.endsWith('/') ? (ctx.set('WWW-Authenticate', 'Basic'), (0, errorPages_1.sendErrorPage)(ctx)) // this is necessary to support standard urls with credentials. Final / means we are dealing with default file...
92
92
  : (ctx.state.serveApp = true) && serveFrontendFiles(ctx, next); // ...for which we still provide fancy login
93
93
  if (!path.endsWith('/'))
94
94
  return ctx.redirect(ctx.state.revProxyPath + ctx.originalUrl.replace(/(\?|$)/, '/$1')); // keep query-string, if any
@@ -104,7 +104,7 @@ async function treatIndex(ctx, filesUri, body) {
104
104
  })));
105
105
  const lang = await (0, lang_1.getLangData)(ctx);
106
106
  let ret = body
107
- .replace(/((?:src|href) *= *['"])\/?(?![a-z]+:\/\/)/g, '$1' + ctx.state.revProxyPath + filesUri)
107
+ .replace(/((?:src|href) *= *['"])\/?(?!([a-z]+:\/)?\/)/g, '$1' + ctx.state.revProxyPath + filesUri)
108
108
  .replace('<body>', () => `<body>
109
109
  ${!isFrontend ? '' : `
110
110
  <title>${adminApis_1.title.get()}</title>
package/src/util-files.js CHANGED
@@ -182,7 +182,7 @@ function createFileWithPath(path, options) {
182
182
  }
183
183
  exports.createFileWithPath = createFileWithPath;
184
184
  function isValidFileName(name) {
185
- return !/^\.\.?$|[/:*?"<>|\\]/.test(name);
185
+ return !/^\.\.?$|[/:*?"<>|\\]/.test(name) && !dirTraversal(name);
186
186
  }
187
187
  exports.isValidFileName = isValidFileName;
188
188
  const FILE_ATTR_PREFIX = 'user.hfs.'; // user. prefix to be linux compatible
package/src/vfs.js CHANGED
@@ -79,11 +79,9 @@ async function urlToNode(url, ctx, parent = exports.vfs, getRest) {
79
79
  const ret = await getNodeByName(name, parent);
80
80
  if (!ret)
81
81
  return;
82
- if (ret === null || ret === void 0 ? void 0 : ret.original)
83
- return urlToNode(rest, ctx, ret, getRest);
84
- if (parent.default)
82
+ if (parent.default) // web folders have this default setting to ensure a standard behavior
85
83
  inheritFromParent({ mime: { '*': const_1.MIME_AUTO } }, ret);
86
- if (rest)
84
+ if (rest || (ret === null || ret === void 0 ? void 0 : ret.original))
87
85
  return urlToNode(rest, ctx, ret, getRest);
88
86
  if (ret.source)
89
87
  try {
@@ -102,7 +100,7 @@ async function urlToNode(url, ctx, parent = exports.vfs, getRest) {
102
100
  exports.urlToNode = urlToNode;
103
101
  async function getNodeByName(name, parent) {
104
102
  var _a;
105
- if ((0, misc_1.dirTraversal)(name) || /[\\/]/.test(name))
103
+ if (!(0, misc_1.isValidFileName)(name))
106
104
  return;
107
105
  // does the tree node have a child that goes by this name, otherwise attempt disk
108
106
  const child = ((_a = parent.children) === null || _a === void 0 ? void 0 : _a.find(isSameFilenameAs(name))) || childFromDisk();