hfs 0.50.2 → 0.50.4

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.
@@ -1,4 +1,4 @@
1
- import{g as OF,c as UF}from"./index-fb217d34.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:{}};/*
1
+ import{g as OF,c as UF}from"./index-e6ecc47c.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
2
  * [js-sha512]{@link https://github.com/emn178/js-sha512}
3
3
  *
4
4
  * @version 0.8.0
@@ -5,7 +5,7 @@
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
7
 
8
- <script type="module" crossorigin src="/assets/index-fb217d34.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-e6ecc47c.js"></script>
9
9
  <link rel="stylesheet" href="/assets/index-b90320b6.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hfs",
3
- "version": "0.50.2",
3
+ "version": "0.50.4",
4
4
  "description": "HTTP File Server",
5
5
  "keywords": [
6
6
  "file server",
@@ -95,10 +95,10 @@ const get_file_list = async ({ uri, offset, limit, search, c }, ctx) => {
95
95
  const name = (0, vfs_1.getNodeName)(node);
96
96
  if (url)
97
97
  return name ? { n: name, url } : null;
98
- if (!source)
98
+ if (!source) // virtual folder
99
99
  return name ? { n: name + '/' } : null;
100
100
  if (node.isFolder && await hasDefaultFile(node))
101
- return { n: name, web: true };
101
+ return { n: name + '/', web: true };
102
102
  try {
103
103
  const st = await (0, promises_1.stat)(source);
104
104
  const folder = st.isDirectory();
package/src/const.js CHANGED
@@ -42,11 +42,11 @@ exports.DEV = process.env.DEV || exports.argv.dev ? 'DEV' : '';
42
42
  exports.ORIGINAL_CWD = process.cwd();
43
43
  exports.HFS_STARTED = new Date();
44
44
  const PKG_PATH = (0, path_1.join)(__dirname, '..', 'package.json');
45
- exports.BUILD_TIMESTAMP = "2023-12-10T17:46:54.825Z";
45
+ exports.BUILD_TIMESTAMP = "2023-12-18T13:45:53.278Z";
46
46
  const pkg = JSON.parse(fs.readFileSync(PKG_PATH, 'utf8'));
47
47
  exports.VERSION = pkg.version;
48
48
  exports.RUNNING_BETA = exports.VERSION.includes('-');
49
- exports.HFS_REPO_BRANCH = exports.RUNNING_BETA ? 'next' : 'main';
49
+ exports.HFS_REPO_BRANCH = exports.RUNNING_BETA ? exports.VERSION.split('.')[1] : 'main';
50
50
  exports.IS_WINDOWS = process.platform === 'win32';
51
51
  exports.IS_MAC = process.platform === 'darwin';
52
52
  exports.IS_BINARY = !(0, path_1.basename)(process.execPath).includes('node'); // this won't be node if pkg was used
package/src/index.js CHANGED
@@ -28,14 +28,15 @@ const selfCheck_1 = require("./selfCheck");
28
28
  const acme_1 = require("./acme");
29
29
  require("./geo");
30
30
  const geo_1 = require("./geo");
31
+ const events_1 = __importDefault(require("./events"));
31
32
  (0, assert_1.ok)(lodash_1.default.intersection(Object.keys(frontEndApis_1.frontEndApis), Object.keys(adminApis_1.adminApis)).length === 0); // they share same endpoints, don't clash
32
33
  process.title = 'HFS ' + const_1.VERSION;
33
34
  const keys = ((_a = process.env.COOKIE_SIGN_KEYS) === null || _a === void 0 ? void 0 : _a.split(','))
34
35
  || [(0, misc_1.randomId)(30)]; // randomness at start gives some extra security, btu also invalidates existing sessions
35
36
  exports.app = new koa_1.default({ keys });
36
- exports.app.use(middlewares_1.someSecurity)
37
+ exports.app.use(middlewares_1.sessionMiddleware)
38
+ .use(middlewares_1.someSecurity)
37
39
  .use(acme_1.acmeMiddleware)
38
- .use(middlewares_1.sessionMiddleware)
39
40
  .use(middlewares_1.prepareState)
40
41
  .use(geo_1.geoFilter)
41
42
  .use(selfCheck_1.selfCheckMiddleware)
@@ -48,6 +49,7 @@ exports.app.use(middlewares_1.someSecurity)
48
49
  .use((0, koa_mount_1.default)(const_1.API_URI, (0, apiMiddleware_1.apiMiddleware)({ ...frontEndApis_1.frontEndApis, ...adminApis_1.adminApis })))
49
50
  .use(middlewares_1.serveGuiAndSharedFiles)
50
51
  .on('error', errorHandler);
52
+ events_1.default.emit('app', exports.app);
51
53
  function errorHandler(err) {
52
54
  const { code } = err;
53
55
  if (const_1.DEV && code === 'ENOENT' && err.path.endsWith('sockjs-node'))
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Massimo Melina",
3
3
  "version": 1.8,
4
- "hfs_version": "0.49.0",
4
+ "hfs_version": "0.50.0",
5
5
  "translate": {
6
6
  "Select": "Seleziona",
7
7
  "n_files": "{n} file",
@@ -124,6 +124,7 @@
124
124
  "enter_comment": "Comment for this file",
125
125
  "Comment": "Comment",
126
126
  "upload_dd_hint": "Puoi uploadare file trascinandoli sulla lista principale",
127
+ "Upload not available": "Upload non disponibile",
127
128
  "_PLUGINS SECTION": "",
128
129
  "_PLUGIN thumbnails": "",
129
130
  "Enable tiles mode": "Modalità griglia",
@@ -132,6 +132,7 @@
132
132
  "enter_comment": "Комментарий для файла",
133
133
  "Comment": "Комментировать",
134
134
  "upload_dd_hint": "Вы можете загрузить файлы перетащив их в список файлов",
135
+ "Upload not available": "Загрузка недоступна",
135
136
  "_PLUGINS SECTION": "",
136
137
  "_PLUGIN thumbnails": "",
137
138
  "Enable tiles mode": "Просмотр в режиме плиток",
@@ -31,6 +31,7 @@ const config_1 = require("./config");
31
31
  const errorPages_1 = require("./errorPages");
32
32
  const koa_session_1 = __importDefault(require("koa-session"));
33
33
  const index_1 = require("./index");
34
+ const events_1 = __importDefault(require("./events"));
34
35
  const forceHttps = (0, config_1.defineConfig)('force_https', true);
35
36
  const ignoreProxies = (0, config_1.defineConfig)('ignore_proxies', false);
36
37
  const forceBaseUrl = (0, config_1.defineConfig)('force_base_url', false);
@@ -246,10 +247,14 @@ const paramsDecoder = async (ctx, next) => {
246
247
  await next();
247
248
  };
248
249
  exports.paramsDecoder = paramsDecoder;
249
- const sessionMiddleware = (ctx, next) => (0, koa_session_1.default)({
250
- key: 'hfs_$id' + (ctx.secure ? '' : '_http'),
251
- signed: true,
252
- rolling: true,
253
- sameSite: 'lax'
254
- }, index_1.app)(ctx, next);
250
+ // once https cookie is created, http cannot do the same. The solution is to use 2 different cookies.
251
+ // But koa-session doesn't support 2 cookies, so I made this hacky solution: keep track of the options object, to modify the key at run-time.
252
+ let internalSessionMw;
253
+ let options;
254
+ events_1.default.on('app', () => // wait for app to be defined
255
+ internalSessionMw = (0, koa_session_1.default)(options = { signed: true, rolling: true, sameSite: 'lax' }, index_1.app));
256
+ const sessionMiddleware = (ctx, next) => {
257
+ options.key = 'hfs_' + ctx.protocol;
258
+ return internalSessionMw(ctx, next);
259
+ };
255
260
  exports.sessionMiddleware = sessionMiddleware;
package/src/util-files.js CHANGED
@@ -128,7 +128,7 @@ async function* dirStream(path, deep = 0) {
128
128
  if (!const_1.IS_WINDOWS)
129
129
  return;
130
130
  const winPath = path.replace(/\//g, '\\');
131
- const out = await (0, util_os_1.runCmd)('dir', ['/ah', '/b', deep ? '/s' : '', winPath])
131
+ const out = await (0, util_os_1.runCmd)('dir', ['/ah', '/b', deep ? '/s' : '/c', winPath]) // cannot pass '', so we pass /c as a noop parameter
132
132
  .catch(() => ''); // error in case of no matching file
133
133
  return out.split('\r\n').slice(0, -1).map(x => !deep ? x : x.slice(winPath.length + 1).replace(/\\/g, '/'));
134
134
  }