hfs 0.26.7 → 0.26.8

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 (162) hide show
  1. package/admin/.DS_Store +0 -0
  2. package/admin/.eslintrc +8 -0
  3. package/admin/.gitignore +23 -0
  4. package/admin/index.html +1 -3
  5. package/admin/package.json +67 -0
  6. package/admin/{logo.svg → public/logo.svg} +0 -0
  7. package/admin/src/AccountForm.ts +92 -0
  8. package/admin/src/AccountsPage.ts +143 -0
  9. package/admin/src/App.ts +83 -0
  10. package/admin/src/ArrayField.ts +84 -0
  11. package/admin/src/ConfigPage.ts +279 -0
  12. package/admin/src/FileField.ts +52 -0
  13. package/admin/src/FileForm.ts +148 -0
  14. package/admin/src/FilePicker.ts +166 -0
  15. package/admin/src/HomePage.ts +96 -0
  16. package/admin/src/InstalledPlugins.ts +158 -0
  17. package/admin/src/LoginRequired.ts +75 -0
  18. package/admin/src/LogoutPage.ts +27 -0
  19. package/admin/src/LogsPage.ts +75 -0
  20. package/admin/src/MainMenu.ts +74 -0
  21. package/admin/src/MenuButton.ts +38 -0
  22. package/admin/src/MonitorPage.ts +200 -0
  23. package/admin/src/OnlinePlugins.ts +101 -0
  24. package/admin/src/PermField.ts +80 -0
  25. package/admin/src/PluginsPage.ts +27 -0
  26. package/admin/src/VfsMenuBar.ts +58 -0
  27. package/admin/src/VfsPage.ts +124 -0
  28. package/admin/src/VfsTree.ts +95 -0
  29. package/admin/src/addFiles.ts +59 -0
  30. package/admin/src/api.ts +246 -0
  31. package/admin/src/dialog.ts +203 -0
  32. package/admin/src/index.css +21 -0
  33. package/admin/src/index.ts +10 -0
  34. package/admin/src/md.ts +31 -0
  35. package/admin/src/misc.ts +141 -0
  36. package/admin/src/react-app-env.d.ts +1 -0
  37. package/admin/src/reportWebVitals.ts +15 -0
  38. package/admin/src/setupTests.ts +5 -0
  39. package/admin/src/state.ts +40 -0
  40. package/admin/src/theme.ts +37 -0
  41. package/admin/tsconfig.json +26 -0
  42. package/admin/vite.config.ts +32 -0
  43. package/frontend/.DS_Store +0 -0
  44. package/frontend/.eslintrc +8 -0
  45. package/frontend/.gitignore +23 -0
  46. package/frontend/index.html +1 -3
  47. package/frontend/package.json +51 -0
  48. package/frontend/{fontello.css → public/fontello.css} +0 -0
  49. package/frontend/{fontello.woff2 → public/fontello.woff2} +0 -0
  50. package/frontend/src/App.ts +25 -0
  51. package/frontend/src/Breadcrumbs.ts +43 -0
  52. package/frontend/src/BrowseFiles.ts +141 -0
  53. package/frontend/src/Head.ts +45 -0
  54. package/frontend/src/UserPanel.ts +52 -0
  55. package/frontend/src/api.ts +78 -0
  56. package/frontend/src/components.ts +54 -0
  57. package/frontend/src/dialog.css +76 -0
  58. package/frontend/src/dialog.ts +105 -0
  59. package/frontend/src/icons.ts +46 -0
  60. package/frontend/src/index.scss +307 -0
  61. package/frontend/src/index.ts +10 -0
  62. package/frontend/src/login.ts +50 -0
  63. package/frontend/src/menu.ts +188 -0
  64. package/frontend/src/misc.ts +54 -0
  65. package/frontend/src/options.ts +52 -0
  66. package/frontend/src/react-app-env.d.ts +1 -0
  67. package/frontend/src/reportWebVitals.ts +15 -0
  68. package/frontend/src/setupTests.ts +5 -0
  69. package/frontend/src/state.ts +82 -0
  70. package/frontend/src/useAuthorized.ts +17 -0
  71. package/frontend/src/useFetchList.ts +144 -0
  72. package/frontend/src/useTheme.ts +23 -0
  73. package/frontend/tsconfig.json +26 -0
  74. package/frontend/vite.config.ts +21 -0
  75. package/package.json +2 -1
  76. package/plugins/vhosting/plugin.js +1 -1
  77. package/src/QuickZipStream.ts +279 -0
  78. package/src/ThrottledStream.ts +98 -0
  79. package/src/adminApis.ts +161 -0
  80. package/src/api.accounts.ts +78 -0
  81. package/src/api.auth.ts +131 -0
  82. package/src/api.file_list.ts +102 -0
  83. package/src/api.helpers.ts +30 -0
  84. package/src/api.monitor.ts +106 -0
  85. package/src/api.plugins.ts +139 -0
  86. package/src/api.vfs.ts +182 -0
  87. package/src/apiMiddleware.ts +124 -0
  88. package/src/block.ts +35 -0
  89. package/src/commands.ts +122 -0
  90. package/src/config.ts +166 -0
  91. package/src/connections.ts +60 -0
  92. package/src/const.ts +57 -0
  93. package/src/crypt.ts +16 -0
  94. package/src/debounceAsync.ts +51 -0
  95. package/src/events.ts +6 -0
  96. package/src/frontEndApis.ts +17 -0
  97. package/src/github.ts +102 -0
  98. package/src/index.ts +53 -0
  99. package/src/listen.ts +220 -0
  100. package/src/log.ts +128 -0
  101. package/src/middlewares.ts +176 -0
  102. package/src/misc.ts +149 -0
  103. package/src/pbkdf2.ts +83 -0
  104. package/src/perm.ts +194 -0
  105. package/src/plugins.ts +342 -0
  106. package/src/serveFile.ts +104 -0
  107. package/src/serveGuiFiles.ts +95 -0
  108. package/src/sse.ts +29 -0
  109. package/src/throttler.ts +106 -0
  110. package/src/update.ts +67 -0
  111. package/src/util-files.ts +137 -0
  112. package/src/util-generators.ts +29 -0
  113. package/src/util-http.ts +29 -0
  114. package/src/vfs.ts +258 -0
  115. package/src/watchLoad.ts +75 -0
  116. package/src/zip.ts +69 -0
  117. package/admin/assets/index.0f549e00.js +0 -281
  118. package/admin/assets/index.dcc78777.css +0 -1
  119. package/admin/assets/sha512.ea1121b3.js +0 -8
  120. package/frontend/assets/index.1151988f.js +0 -85
  121. package/frontend/assets/index.93366732.css +0 -1
  122. package/frontend/assets/sha512.bb881250.js +0 -8
  123. package/src/QuickZipStream.js +0 -285
  124. package/src/ThrottledStream.js +0 -93
  125. package/src/adminApis.js +0 -169
  126. package/src/api.accounts.js +0 -59
  127. package/src/api.auth.js +0 -130
  128. package/src/api.file_list.js +0 -103
  129. package/src/api.helpers.js +0 -32
  130. package/src/api.monitor.js +0 -102
  131. package/src/api.plugins.js +0 -127
  132. package/src/api.vfs.js +0 -164
  133. package/src/apiMiddleware.js +0 -136
  134. package/src/block.js +0 -33
  135. package/src/commands.js +0 -124
  136. package/src/config.js +0 -168
  137. package/src/connections.js +0 -57
  138. package/src/const.js +0 -83
  139. package/src/crypt.js +0 -21
  140. package/src/debounceAsync.js +0 -48
  141. package/src/events.js +0 -9
  142. package/src/frontEndApis.js +0 -38
  143. package/src/github.js +0 -102
  144. package/src/index.js +0 -55
  145. package/src/listen.js +0 -235
  146. package/src/log.js +0 -137
  147. package/src/middlewares.js +0 -154
  148. package/src/misc.js +0 -160
  149. package/src/pbkdf2.js +0 -74
  150. package/src/perm.js +0 -176
  151. package/src/plugins.js +0 -343
  152. package/src/serveFile.js +0 -104
  153. package/src/serveGuiFiles.js +0 -113
  154. package/src/sse.js +0 -29
  155. package/src/throttler.js +0 -91
  156. package/src/update.js +0 -69
  157. package/src/util-files.js +0 -148
  158. package/src/util-generators.js +0 -30
  159. package/src/util-http.js +0 -30
  160. package/src/vfs.js +0 -227
  161. package/src/watchLoad.js +0 -73
  162. package/src/zip.js +0 -69
@@ -1 +0,0 @@
1
- :root{--bg: #fff;--text: #555;--faint-contrast: #0002;--mild-contrast: #0005;--good-contrast: #000a;--button-bg: #68a;--button-text: #fff;--focus-color: #468}:root .theme-dark{--bg: #000;--text: #999;--faint-contrast: #fff2;--mild-contrast: #fff5;--good-contrast: #fffa;--button-bg: #345;--button-text: #999}:root .theme-dark body{color-scheme:dark}:root .theme-dark a{color:#8ac}:root .theme-dark .dialog-closer{background:#633}:root .theme-dark .dialog-icon{color:#ccc}:root .theme-dark .dialog-backdrop{background:rgba(51,51,51,.7333333333)}body{background:var(--bg);margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}body,button,select,input{font-size:12pt}#root{max-width:50em;margin:auto;min-height:100vh;display:flex;flex-direction:column}body,input{color:var(--text)}code{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace}input,select{padding:.3em .4em;border-radius:.5em;background:var(--bg);border-color:var(--mild-contrast);color:var(--good-contrast);max-width:100%;box-sizing:border-box}input[type=checkbox]{margin:0 1.3em 0 .8em;transform:scale(1.7);accent-color:var(--button-bg)}.hidden{display:none!important}.icon{font-size:1.2em}.icon.mirror:before{transform:scaleX(-1)}a{text-decoration:none;color:#57a}button{background-color:var(--button-bg);color:var(--button-text);padding:.5em 1em;border:transparent;text-decoration:none;border-radius:.3em;vertical-align:middle;cursor:pointer}button.toggled{opacity:.6}button:focus-visible,.breadcrumb:focus-visible{outline:3px solid var(--focus-color)}input:focus-visible,select:focus-visible,ul a:focus-visible{border-radius:.3em;border-color:transparent;outline:2px solid var(--focus-color)}.error-msg{background-color:#faa;color:#833}header{position:sticky;top:0;background:var(--bg);padding:.2em;z-index:1}.ani-working{animation:1s blink infinite}@keyframes blink{0%{opacity:1}50%{opacity:.2}}@keyframes spin{to{transform:rotate(360deg)}}@keyframes fade-in{0%{opacity:0}to{opacity:1}}.spinner,.icon.spinner:before{animation:1.5s spin infinite linear}.icon.emoji.spinner{display:inline-block}.breadcrumb{padding:.1em .6em .2em;line-height:1.8em;border-radius:.7em;background-color:var(--button-bg);color:var(--button-text);border-top:1px solid #666;margin-right:-.1em}.breadcrumb:nth-child(-n+3) .icon{padding:0 .2em}#folder-stats{font-size:90%;margin:.4em 0 0 .5em;float:right}#folder-stats .icon{margin-right:.3em}header input{width:100%;margin:.2em auto;box-sizing:border-box}#filter-bar{display:flex;gap:.3em;margin:.5em 0}#filter-bar input{flex:1}#filter-bar button{padding:0 .5em}ul.dir{flex:1;padding:0;margin:0;clear:both}ul.dir li{display:block;list-style-type:none;margin-bottom:.3em;padding:.3em;border-top:1px solid var(--button-bg)}ul.dir li a{word-break:break-word;padding-right:.3em}ul.dir li a .icon{margin-right:.3em}ul.dir li a.container-folder:hover{text-decoration:underline}ul.dir li .entry-props{float:right;font-size:90%;margin-left:12px;margin-top:.2em}ul.dir li .entry-props .icon{margin:0 .3em}ul.dir li .entry-props .entry-size{display:inline-block}#menu-panel{margin-bottom:.2em}#menu-bar{display:flex;justify-content:space-evenly;flex-wrap:wrap}#menu-bar>*{flex:auto;margin:.1em}#menu-bar button{padding-left:0;padding-right:0}#menu-bar>a>button{width:100%}#searched{margin:.2em}#user-panel{display:flex;flex-direction:column;gap:1em}#user-panel a>button{width:100%}button label{cursor:inherit;margin-left:.5em}.dialog-backdrop.working{font-size:5em;animation:1s fade-in}.dialog-content{padding:.2em}.dialog-confirm,.dialog-prompt{--color: var(--button-bg)}#paging{display:flex;position:sticky;bottom:0;background:var(--bg);gap:.5em;overflow-x:auto}#paging>button{flex:1;background:var(--button-bg);text-align:center}*{scrollbar-width:thin;scrollbar-color:var(--button-bg) var(--faint-contrast)}*::-webkit-scrollbar{width:12px}*::-webkit-scrollbar-track{background:var(--faint-contrast)}*::-webkit-scrollbar-thumb{background-color:var(--button-bg);border-radius:20px;border:1px solid var(--faint-contrast)}@media (max-width: 42em){body,button,select{font-size:14pt}#menu-bar button label{display:none}#filter-bar{margin:.2em 0}#filter-bar label{display:none}#filter-bar button{width:17.6vw;height:2.3em}.breadcrumb{word-break:break-all}.breadcrumb .icon{font-size:24px}}.dialog-backdrop{position:fixed;inset:0;background:#888a;display:flex;justify-content:center;align-items:center;z-index:1000}.dialog{background:#fff;background:var(--bg);padding:max(.5em,1vw);border-radius:1em;position:relative;margin:0 3vw;overflow:hidden;max-height:calc(100vh - 2em)}.dialog-icon{color:#fff;background-color:var(--color);position:absolute;top:0;width:1.8em;height:1.7em;text-align:center;border-radius:.8em 0}.dialog-closer{border-radius:0 .8em;right:0;padding:0;background-color:#c99}.dialog-icon~.dialog-content{margin-top:1.3em}.dialog-type{left:0;top:0;overflow:hidden;line-height:1.7em}.dialog-content{overflow:auto;max-height:calc(100vh - 4em)}.dialog-content p{white-space:pre-wrap;margin:.5em 0}.dialog-confirm .dialog-content button{margin-top:1em}.dialog-alert-info{--color: #282 }.dialog-alert-warning{--color: #c91 }.dialog-alert-error{--color: #822}@media (max-width: 50em){.dialog-closer{font-size:120%}.dialog-icon~.dialog-content{margin-top:2em}}
@@ -1,8 +0,0 @@
1
- import{c as SF}from"./index.1151988f.js";function OF(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 yF={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",_F=!w.JS_SHA512_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;_F?w=SF:lF&&(w=self);var bF=!w.JS_SHA512_NO_COMMON_JS&&!0&&sF.exports,aF=!w.JS_SHA512_NO_ARRAY_BUFFER&&typeof ArrayBuffer!="undefined",F="0123456789abcdef".split(""),wF=[-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 vF=function(x,r){return function(e){return new v(r,!0).update(e)[x]()}},nF=function(x){var r=vF("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 o=fF[e];r[o]=vF(o,x)}return r},dF=function(x,r){return function(e,o){return new rF(e,r,!0).update(o)[x]()}},oF=function(x){var r=dF("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 o=fF[e];r[o]=dF(o,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 o,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)o=x.charCodeAt(B),o<128?s[l>>2]|=o<<xF[l++&3]:o<2048?(s[l>>2]|=(192|o>>6)<<xF[l++&3],s[l>>2]|=(128|o&63)<<xF[l++&3]):o<55296||o>=57344?(s[l>>2]|=(224|o>>12)<<xF[l++&3],s[l>>2]|=(128|o>>6&63)<<xF[l++&3],s[l>>2]|=(128|o&63)<<xF[l++&3]):(o=65536+((o&1023)<<10|x.charCodeAt(++B)&1023),s[l>>2]|=(240|o>>18)<<xF[l++&3],s[l>>2]|=(128|o>>12&63)<<xF[l++&3],s[l>>2]|=(128|o>>6&63)<<xF[l++&3],s[l>>2]|=(128|o&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]|=wF[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,o=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,n,u,p,Q,FF;for(A=32;A<160;A+=2)f=y[A-30],n=y[A-29],z=(f>>>1|n<<31)^(f>>>8|n<<24)^f>>>7,P=(n>>>1|f<<31)^(n>>>8|f<<24)^(n>>>7|f<<25),f=y[A-4],n=y[A-3],H=(f>>>19|n<<13)^(n>>>29|f<<3)^f>>>6,I=(n>>>19|f<<13)^(f>>>29|n<<3)^(n>>>6|f<<26),f=y[A-32],n=y[A-31],u=y[A-14],p=y[A-13],h=(p&65535)+(n&65535)+(P&65535)+(I&65535),t=(p>>>16)+(n>>>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=o,j=B,N=l,T=c,K=s,m=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=(m>>>14|V<<18)^(m>>>18|V<<14)^(V>>>9|m<<23),I=(V>>>14|m<<18)^(V>>>18|m<<14)^(m>>>9|V<<23),EF=J&g,CF=M&R,Z=EF^J&j^AF,q=CF^M&N^BF,Q=m&W^~m&Y,FF=V&k^~V&X,f=y[A],n=y[A+1],u=iF[A],p=iF[A+1],h=(p&65535)+(n&65535)+(FF&65535)+(I&65535)+(G&65535),t=(p>>>16)+(n>>>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,n=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=(K&65535)+(n&65535),t=(K>>>16)+(n>>>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)+(n&65535),t=(p>>>16)+(n>>>16)+(h>>>16),i=(u&65535)+(f&65535)+(t>>>16),a=(u>>>16)+(f>>>16)+(i>>>16),T=a<<16|i&65535,K=t<<16|h&65535,z=(T>>>28|K<<4)^(K>>>2|T<<30)^(K>>>7|T<<25),P=(K>>>28|T<<4)^(T>>>2|K<<30)^(T>>>7|K<<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=K&M,Z=cF^T&g^EF,q=DF^K&R^CF,Q=$&m^~$&W,FF=G&V^~G&k,f=y[A+2],n=y[A+3],u=iF[A+2],p=iF[A+3],h=(p&65535)+(n&65535)+(FF&65535)+(I&65535)+(X&65535),t=(p>>>16)+(n>>>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,n=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)+(n&65535),t=(N>>>16)+(n>>>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)+(n&65535),t=(p>>>16)+(n>>>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&K,Z=uF^j&J^cF,q=pF^N&M^DF,Q=Y&$^~Y&m,FF=X&G^~X&V,f=y[A+4],n=y[A+5],u=iF[A+4],p=iF[A+5],h=(p&65535)+(n&65535)+(FF&65535)+(I&65535)+(k&65535),t=(p>>>16)+(n>>>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,n=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)+(n&65535),t=(R>>>16)+(n>>>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)+(n&65535),t=(p>>>16)+(n>>>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&K^pF,Q=W&Y^~W&$,FF=k&X^~k&G,f=y[A+6],n=y[A+7],u=iF[A+6],p=iF[A+7],h=(p&65535)+(n&65535)+(FF&65535)+(I&65535)+(V&65535),t=(p>>>16)+(n>>>16)+(FF>>>16)+(I>>>16)+(V>>>16)+(h>>>16),i=(u&65535)+(f&65535)+(Q&65535)+(H&65535)+(m&65535)+(t>>>16),a=(u>>>16)+(f>>>16)+(Q>>>16)+(H>>>16)+(m>>>16)+(i>>>16),f=a<<16|i&65535,n=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)+(n&65535),t=(M>>>16)+(n>>>16)+(h>>>16),i=(J&65535)+(f&65535)+(t>>>16),a=(J>>>16)+(f>>>16)+(i>>>16),m=a<<16|i&65535,V=t<<16|h&65535,h=(p&65535)+(n&65535),t=(p>>>16)+(n>>>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=(o&65535)+(R&65535),t=(o>>>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)+(K&65535),t=(s>>>16)+(K>>>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)+(m&65535)+(t>>>16),a=(E>>>16)+(m>>>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,o=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[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[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,o=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,o>>24&255,o>>16&255,o>>8&255,o&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 o,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);o=!0}var l=x.length;if(!o){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=nF(512);L.sha512=L,L.sha384=nF(384),L.sha512_256=nF(256),L.sha512_224=nF(224),L.sha512.hmac=oF(512),L.sha384.hmac=oF(384),L.sha512_256.hmac=oF(256),L.sha512_224.hmac=oF(224),bF?sF.exports=L:(w.sha512=L.sha512,w.sha384=L.sha384,w.sha512_256=L.sha512_256,w.sha512_224=L.sha512_224)})()})(yF);const UF=yF.exports,RF=OF({__proto__:null,default:UF},[yF.exports]);export{RF as s};
@@ -1,285 +0,0 @@
1
- "use strict";
2
- // This file is part of HFS - Copyright 2021-2022, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
- var __importDefault = (this && this.__importDefault) || function (mod) {
27
- return (mod && mod.__esModule) ? mod : { "default": mod };
28
- };
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.QuickZipStream = void 0;
31
- const stream_1 = require("stream");
32
- // @ts-ignore
33
- const buffer_crc32_1 = require("buffer-crc32");
34
- const assert_1 = __importDefault(require("assert"));
35
- const ZIP64_SIZE_LIMIT = 0xffffffff;
36
- const ZIP64_NUMBER_LIMIT = 0xffff;
37
- let crc32function;
38
- Promise.resolve().then(() => __importStar(require('@node-rs/crc32'))).then(lib => crc32function = lib.crc32, () => {
39
- console.log('using generic lib for crc32');
40
- crc32function = buffer_crc32_1.unsigned;
41
- });
42
- const FLAGS = 0x0808; // bit3 = no crc in local header + bit11 = utf8
43
- class QuickZipStream extends stream_1.Readable {
44
- constructor(walker) {
45
- super({});
46
- this.walker = walker;
47
- this.finished = false;
48
- this.entries = [];
49
- this.dataWritten = 0;
50
- this.consumedCalculating = [];
51
- this.skip = 0;
52
- }
53
- earlyClose() {
54
- this.finished = true;
55
- this.push(null);
56
- }
57
- applyRange(start, end) {
58
- if (end < start)
59
- return this.earlyClose();
60
- this.skip = start;
61
- this.limit = end - start + 1;
62
- }
63
- controlledPush(chunk) {
64
- if (Array.isArray(chunk))
65
- chunk = buffer(chunk);
66
- this.dataWritten += chunk.length;
67
- if (this.skip) {
68
- if (this.skip >= chunk.length) {
69
- this.skip -= chunk.length;
70
- return true;
71
- }
72
- chunk = chunk.subarray(this.skip);
73
- this.skip = 0;
74
- }
75
- const lastBit = this.limit < chunk.length;
76
- if (lastBit)
77
- chunk = chunk.subarray(0, this.limit);
78
- const ret = this.push(chunk);
79
- if (lastBit)
80
- this.earlyClose();
81
- return ret;
82
- }
83
- async calculateSize(howLong = 1000) {
84
- const endBy = Date.now() + howLong;
85
- while (1) {
86
- if (Date.now() >= endBy)
87
- return NaN;
88
- const { value } = await this.walker.next();
89
- if (!value)
90
- break;
91
- this.consumedCalculating.push(value); // we keep same shape of the generator, so
92
- }
93
- // if we reach here, then we were able to consume all entries of the walker (in time)
94
- let offset = 0;
95
- let centralDirSize = 0;
96
- for (const file of this.consumedCalculating) {
97
- const pathSize = Buffer.from(file.path, 'utf8').length;
98
- const extraLength = (file.size > ZIP64_SIZE_LIMIT ? 2 : 0) + (offset > ZIP64_SIZE_LIMIT ? 1 : 0);
99
- const extraDataSize = extraLength && (2 + 2 + extraLength * 8);
100
- offset += 4 + 2 + 2 + 2 + 4 + 4 + 4 + 4 + 2 + 2 + pathSize + file.size;
101
- centralDirSize += 4 + 2 + 2 + 2 + 2 + 4 + 4 + 4 + 4 + 2 + 2 + 2 + 2 + 2 + 4 + 4 + pathSize + extraDataSize;
102
- }
103
- const n = this.consumedCalculating.length;
104
- const centralDirOffset = offset;
105
- if (n >= ZIP64_NUMBER_LIMIT
106
- || centralDirOffset >= ZIP64_SIZE_LIMIT
107
- || centralDirSize >= ZIP64_SIZE_LIMIT)
108
- centralDirSize += 4 + 8 + 2 + 2 + 4 + 4 + 8 + 8 + 8 + 8 + 4 + 4 + 8 + 4;
109
- centralDirSize += 4 + 4 + 2 + 2 + 4 + 4 + 2;
110
- return offset + centralDirSize;
111
- }
112
- async _read() {
113
- if (this.finished || this.destroyed)
114
- return;
115
- if (this.workingFile)
116
- return this.workingFile.resume();
117
- const file = this.consumedCalculating.shift() || (await this.walker.next()).value;
118
- if (!file)
119
- return this.closeArchive();
120
- let { path, sourcePath, getData, size, ts, mode } = file;
121
- const pathAsBuffer = Buffer.from(path, 'utf8');
122
- const offset = this.dataWritten;
123
- const version = 20;
124
- this.controlledPush([
125
- 4, 0x04034b50,
126
- 2, version,
127
- 2, FLAGS,
128
- 2, 0,
129
- ...ts2buf(ts),
130
- 4, 0,
131
- 4, 0,
132
- 4, 0,
133
- 2, pathAsBuffer.length,
134
- 2, 0, // extra length
135
- ]);
136
- this.controlledPush(pathAsBuffer);
137
- if (this.finished)
138
- return;
139
- const cache = sourcePath ? crcCache[sourcePath] : undefined;
140
- const cacheHit = Number(cache === null || cache === void 0 ? void 0 : cache.ts) === Number(ts);
141
- let crc = cacheHit ? cache.crc : crc32function('');
142
- const extAttr = !mode ? 0 : (mode | 0x8000) * 0x10000; // it's like <<16 but doesn't overflow so easily
143
- const entry = { size, crc, pathAsBuffer, ts, offset, version, extAttr };
144
- if (this.skip >= size && cacheHit) {
145
- this.skip -= size;
146
- this.dataWritten += size;
147
- this.entries.push(entry);
148
- setTimeout(() => this.push('')); // this "signal" works only after _read() is done
149
- return;
150
- }
151
- const data = getData();
152
- data.on('error', (err) => console.error(err));
153
- data.on('end', () => {
154
- this.workingFile = undefined;
155
- entry.crc = crc;
156
- if (sourcePath)
157
- crcCache[sourcePath] = { ts, crc };
158
- this.entries.push(entry);
159
- this.push(''); // continue piping
160
- });
161
- this.workingFile = data;
162
- data.on('data', chunk => {
163
- if (this.destroyed)
164
- return data.destroy();
165
- if (!this.controlledPush(chunk)) // destination buffer full
166
- data.pause(); // slow down
167
- if (!cacheHit)
168
- crc = crc32function(chunk, crc);
169
- if (this.finished)
170
- return data.destroy();
171
- });
172
- }
173
- closeArchive() {
174
- this.finished = true;
175
- let centralDirOffset = this.dataWritten;
176
- for (let { size, ts, crc, offset, pathAsBuffer, version, extAttr } of this.entries) {
177
- const extra = [];
178
- if (size > ZIP64_SIZE_LIMIT) {
179
- extra.push(size, size);
180
- size = ZIP64_SIZE_LIMIT;
181
- }
182
- if (offset > ZIP64_SIZE_LIMIT) {
183
- extra.push(offset);
184
- offset = ZIP64_SIZE_LIMIT;
185
- }
186
- const extraData = buffer(!extra.length ? []
187
- : [2, 1, 2, 8 * extra.length, ...extra.map(x => [8, x]).flat()]);
188
- if (extraData.length && version < 45)
189
- version = 45;
190
- this.controlledPush([
191
- 4, 0x02014b50,
192
- 2, version,
193
- 2, version,
194
- 2, FLAGS,
195
- 2, 0,
196
- ...ts2buf(ts),
197
- 4, crc,
198
- 4, size,
199
- 4, size,
200
- 2, pathAsBuffer.length,
201
- 2, extraData.length,
202
- 2, 0,
203
- 2, 0,
204
- 2, 0,
205
- 4, extAttr,
206
- 4, offset,
207
- ]);
208
- this.controlledPush(pathAsBuffer);
209
- this.controlledPush(extraData);
210
- }
211
- const after = this.dataWritten;
212
- let centralDirSize = after - centralDirOffset;
213
- let n = this.entries.length;
214
- if (n >= ZIP64_NUMBER_LIMIT
215
- || centralDirOffset >= ZIP64_SIZE_LIMIT
216
- || centralDirSize >= ZIP64_SIZE_LIMIT) {
217
- this.controlledPush([
218
- 4, 0x06064b50,
219
- 8, 44,
220
- 2, 45,
221
- 2, 45,
222
- 4, 0,
223
- 4, 0,
224
- 8, n,
225
- 8, n,
226
- 8, centralDirSize,
227
- 8, centralDirOffset,
228
- ]);
229
- this.controlledPush([
230
- 4, 0x07064b50,
231
- 4, 0,
232
- 8, after,
233
- 4, 1,
234
- ]);
235
- centralDirOffset = ZIP64_SIZE_LIMIT;
236
- centralDirSize = ZIP64_SIZE_LIMIT;
237
- n = ZIP64_NUMBER_LIMIT;
238
- }
239
- this.controlledPush([
240
- 4, 0x06054b50,
241
- 4, 0,
242
- 2, n,
243
- 2, n,
244
- 4, centralDirSize,
245
- 4, centralDirOffset,
246
- 2, 0, // comment length
247
- ]);
248
- this.push(null); // EOF
249
- }
250
- }
251
- exports.QuickZipStream = QuickZipStream;
252
- function buffer(pairs) {
253
- (0, assert_1.default)(pairs.length % 2 === 0);
254
- let total = 0;
255
- for (let i = 0; i < pairs.length; i += 2)
256
- total += pairs[i];
257
- const ret = Buffer.alloc(total, 0);
258
- let offset = 0;
259
- let i = 0;
260
- while (i < pairs.length) {
261
- const size = pairs[i++];
262
- const data = pairs[i++];
263
- if (size === 1)
264
- ret.writeUInt8(data, offset);
265
- else if (size === 2)
266
- ret.writeUInt16LE(data, offset);
267
- else if (size === 4)
268
- ret.writeUInt32LE(data, offset);
269
- else if (size === 8)
270
- ret.writeBigUInt64LE(BigInt(data), offset);
271
- else
272
- throw 'unsupported';
273
- offset += size;
274
- }
275
- return ret;
276
- }
277
- function ts2buf(ts) {
278
- const date = ((ts.getFullYear() - 1980) & 0x7F) << 9 | (ts.getMonth() + 1) << 5 | ts.getDate();
279
- const time = ts.getHours() << 11 | ts.getMinutes() << 5 | (ts.getSeconds() / 2) & 0x0F;
280
- return [
281
- 2, time,
282
- 2, date,
283
- ];
284
- }
285
- const crcCache = {};
@@ -1,93 +0,0 @@
1
- "use strict";
2
- // This file is part of HFS - Copyright 2021-2022, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.ThrottleGroup = exports.ThrottledStream = void 0;
5
- const stream_1 = require("stream");
6
- const limiter_1 = require("limiter");
7
- // throttled stream
8
- class ThrottledStream extends stream_1.Transform {
9
- constructor(group, copyStats) {
10
- super();
11
- this.group = group;
12
- this.sent = 0;
13
- this.lastSpeed = 0;
14
- this.lastSpeedTime = Date.now();
15
- this.totalSent = 0; // total sent over connection, since connection can be re-used for multiple requests
16
- if (!copyStats)
17
- return;
18
- this.sent = copyStats.sent;
19
- this.totalSent = copyStats.totalSent;
20
- this.lastSpeedTime = copyStats.lastSpeedTime;
21
- this.lastSpeed = copyStats.lastSpeed;
22
- }
23
- async _transform(chunk, encoding, done) {
24
- let pos = 0;
25
- while (1) {
26
- let n = this.group.suggestChunkSize();
27
- const slice = chunk.slice(pos, pos + n);
28
- n = slice.length;
29
- if (!n) // we're done here
30
- return done();
31
- try {
32
- await this.group.consume(n);
33
- this.push(slice);
34
- this.sent += n;
35
- this.totalSent += n;
36
- pos += n;
37
- this.emit('sent', n);
38
- }
39
- catch (e) {
40
- done(e);
41
- return;
42
- }
43
- }
44
- }
45
- // @return kBs
46
- getSpeed() {
47
- const now = Date.now();
48
- const past = now - this.lastSpeedTime;
49
- if (past >= 1000) { // recalculate?
50
- this.lastSpeedTime = now;
51
- this.lastSpeed = this.sent / past;
52
- this.sent = 0;
53
- }
54
- return this.lastSpeed;
55
- }
56
- getBytesSent() {
57
- return this.totalSent;
58
- }
59
- }
60
- exports.ThrottledStream = ThrottledStream;
61
- class ThrottleGroup {
62
- constructor(kBs, parent) {
63
- this.parent = parent;
64
- this.bucket = this.updateLimit(kBs); // assignment is redundant and yet the best way I've found to shut up typescript
65
- }
66
- // @return kBs
67
- getLimit() {
68
- return this.bucket.bucketSize / 1000;
69
- }
70
- updateLimit(kBs) {
71
- if (kBs < 0)
72
- throw new Error('invalid bytesPerSecond');
73
- kBs *= 1000;
74
- return this.bucket = new limiter_1.TokenBucket({
75
- bucketSize: kBs,
76
- tokensPerInterval: kBs,
77
- interval: 'second',
78
- });
79
- }
80
- suggestChunkSize() {
81
- var _a;
82
- let b = this.bucket;
83
- b.parentBucket = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.bucket;
84
- let min = b.bucketSize;
85
- while (b = b.parentBucket)
86
- min = Math.min(min, b.bucketSize);
87
- return min / 10;
88
- }
89
- consume(n) {
90
- return this.bucket.removeTokens(n);
91
- }
92
- }
93
- exports.ThrottleGroup = ThrottleGroup;
package/src/adminApis.js DELETED
@@ -1,169 +0,0 @@
1
- "use strict";
2
- // This file is part of HFS - Copyright 2021-2022, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
- var __importDefault = (this && this.__importDefault) || function (mod) {
27
- return (mod && mod.__esModule) ? mod : { "default": mod };
28
- };
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.ctxAdminAccess = exports.localhostAdmin = exports.adminApis = void 0;
31
- const apiMiddleware_1 = require("./apiMiddleware");
32
- const config_1 = require("./config");
33
- const listen_1 = require("./listen");
34
- const const_1 = require("./const");
35
- const api_vfs_1 = __importDefault(require("./api.vfs"));
36
- const api_accounts_1 = __importDefault(require("./api.accounts"));
37
- const api_plugins_1 = __importDefault(require("./api.plugins"));
38
- const api_monitor_1 = __importDefault(require("./api.monitor"));
39
- const connections_1 = require("./connections");
40
- const misc_1 = require("./misc");
41
- const lodash_1 = __importDefault(require("lodash"));
42
- const events_1 = __importDefault(require("./events"));
43
- const perm_1 = require("./perm");
44
- const middlewares_1 = require("./middlewares");
45
- const promises_1 = require("fs/promises");
46
- const fs_1 = require("fs");
47
- const readline = __importStar(require("readline"));
48
- const log_1 = require("./log");
49
- const child_process_1 = require("child_process");
50
- const util_1 = require("util");
51
- exports.adminApis = {
52
- ...api_vfs_1.default,
53
- ...api_accounts_1.default,
54
- ...api_plugins_1.default,
55
- ...api_monitor_1.default,
56
- async set_config({ values: v }) {
57
- var _a, _b;
58
- if (v) {
59
- const st = (0, listen_1.getStatus)();
60
- const noHttp = ((_a = v.port) !== null && _a !== void 0 ? _a : listen_1.portCfg.get()) < 0 || !st.httpSrv.listening;
61
- const noHttps = ((_b = v.https_port) !== null && _b !== void 0 ? _b : listen_1.httpsPortCfg.get()) < 0 || !st.httpsSrv.listening;
62
- if (noHttp && noHttps)
63
- return new apiMiddleware_1.ApiError(const_1.FORBIDDEN, "You cannot switch off both http and https ports");
64
- await (0, config_1.setConfig)(v);
65
- }
66
- return {};
67
- },
68
- get_config: config_1.getWholeConfig,
69
- async get_status() {
70
- const st = (0, listen_1.getStatus)();
71
- return {
72
- started: const_1.HFS_STARTED,
73
- build: const_1.BUILD_TIMESTAMP,
74
- version: const_1.VERSION,
75
- apiVersion: const_1.API_VERSION,
76
- compatibleApiVersion: const_1.COMPATIBLE_API_VERSION,
77
- http: await serverStatus(st.httpSrv, listen_1.portCfg.get()),
78
- https: await serverStatus(st.httpsSrv, listen_1.httpsPortCfg.get()),
79
- urls: (0, listen_1.getUrls)(),
80
- proxyDetected: (0, middlewares_1.getProxyDetected)(),
81
- frpDetected: exports.localhostAdmin.get() && !(0, middlewares_1.getProxyDetected)()
82
- && (0, connections_1.getConnections)().every(misc_1.isLocalHost)
83
- && await frpDebounced(),
84
- };
85
- async function serverStatus(h, configuredPort) {
86
- var _a;
87
- const busy = await h.busy;
88
- await (0, misc_1.wait)(0); // simple trick to wait for also .error to be updated. If this trickery becomes necessary elsewhere, then we should make also error a Promise.
89
- return {
90
- ...lodash_1.default.pick(h, ['listening', 'error']),
91
- busy,
92
- port: ((_a = h === null || h === void 0 ? void 0 : h.address()) === null || _a === void 0 ? void 0 : _a.port) || configuredPort,
93
- };
94
- }
95
- },
96
- async save_pem({ cert, private_key, name = 'self' }) {
97
- if (!cert || !private_key)
98
- return new apiMiddleware_1.ApiError(400);
99
- const files = { cert: name + '.cert', private_key: name + '.key' };
100
- await (0, promises_1.writeFile)(files.private_key, private_key);
101
- await (0, promises_1.writeFile)(files.cert, cert);
102
- return files;
103
- },
104
- async get_log({ file = 'log' }, ctx) {
105
- return new apiMiddleware_1.SendListReadable({
106
- bufferTime: 10,
107
- doAtStart(list) {
108
- const logger = log_1.loggers.find(l => l.name === file);
109
- if (!logger)
110
- return list.error(404, true);
111
- const input = (0, fs_1.createReadStream)(logger.path);
112
- input.on('error', async (e) => {
113
- if (e.code === 'ENOENT') // ignore ENOENT, consider it an empty log
114
- return list.ready();
115
- list.error(e.code || e.message);
116
- });
117
- input.on('end', () => list.ready());
118
- input.on('ready', () => {
119
- readline.createInterface({ input }).on('line', line => {
120
- if (ctx.aborted)
121
- return input.close();
122
- const obj = parse(line);
123
- if (obj)
124
- list.add(obj);
125
- }).on('close', () => {
126
- ctx.res.once('close', (0, misc_1.onOff)(events_1.default, {
127
- [logger.name](entry) {
128
- list.add(entry);
129
- }
130
- }));
131
- });
132
- });
133
- }
134
- });
135
- function parse(line) {
136
- const m = /^(.+?) (.+?) (.+?) \[(.{11}):(.{14})] "(\w+) ([^"]+) HTTP\/\d.\d" (\d+) (-|\d+)/.exec(line);
137
- if (!m)
138
- return;
139
- const [, ip, , user, date, time, method, uri, status, length] = m;
140
- return {
141
- ip,
142
- user: user === '-' ? undefined : user,
143
- ts: new Date(date + ' ' + time),
144
- method,
145
- uri,
146
- status: Number(status),
147
- length: length === '-' ? undefined : Number(length),
148
- };
149
- }
150
- },
151
- };
152
- for (const k in exports.adminApis) {
153
- const was = exports.adminApis[k];
154
- exports.adminApis[k] = (params, ctx) => ctxAdminAccess(ctx) ? was(params, ctx)
155
- : new apiMiddleware_1.ApiError(const_1.UNAUTHORIZED);
156
- }
157
- exports.localhostAdmin = (0, config_1.defineConfig)('localhost_admin', true);
158
- function ctxAdminAccess(ctx) {
159
- return !ctx.state.proxiedFor // we consider localhost_admin only if no proxy is detected
160
- && exports.localhostAdmin.get() && (0, misc_1.isLocalHost)(ctx)
161
- || (0, perm_1.getFromAccount)(ctx.state.account, a => a.admin);
162
- }
163
- exports.ctxAdminAccess = ctxAdminAccess;
164
- const frpDebounced = (0, misc_1.debounceAsync)(async () => {
165
- if (!const_1.IS_WINDOWS)
166
- return false;
167
- const { stdout } = await (0, util_1.promisify)(child_process_1.execFile)('tasklist', ['/fi', 'imagename eq frpc.exe', '/nh']);
168
- return stdout.includes('frpc');
169
- });