hfs 0.52.0-alpha1 → 0.52.0-alpha2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{g as OF,c as UF}from"./index-k3m-mkMr.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-r8i8c_PX.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
@@ -4,8 +4,8 @@
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-YSw6ytlU.js"></script>
8
- <link rel="stylesheet" crossorigin href="/assets/index-v-wWWrzz.css">
7
+ <script type="module" crossorigin src="/assets/index-r8i8c_PX.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-EdGoLuWB.css">
9
9
  </head>
10
10
  <body>
11
11
  <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-alpha1",
3
+ "version": "0.52.0-alpha2",
4
4
  "description": "HTTP File Server",
5
5
  "keywords": [
6
6
  "file server",
package/src/api.auth.js CHANGED
@@ -11,10 +11,6 @@ const auth_1 = require("./auth");
11
11
  const config_1 = require("./config");
12
12
  const ongoingLogins = {}; // store data that doesn't fit session object
13
13
  const keepSessionAlive = (0, config_1.defineConfig)('keep_session_alive', true);
14
- function makeExp() {
15
- return !keepSessionAlive.get() ? undefined
16
- : { exp: new Date(Date.now() + middlewares_1.sessionDuration.compiled()) };
17
- }
18
14
  const loginSrp1 = async ({ username }, ctx) => {
19
15
  if (!username)
20
16
  return new apiMiddleware_1.ApiError(const_1.HTTP_BAD_REQUEST);
@@ -78,11 +74,13 @@ const logout = async ({}, ctx) => {
78
74
  };
79
75
  exports.logout = logout;
80
76
  const refresh_session = async ({}, ctx) => {
77
+ var _a;
81
78
  return !ctx.session ? new apiMiddleware_1.ApiError(const_1.HTTP_SERVER_ERROR) : {
82
79
  username: (0, auth_1.getCurrentUsername)(ctx),
83
80
  adminUrl: (0, adminApis_1.ctxAdminAccess)(ctx) ? ctx.state.revProxyPath + const_1.ADMIN_URI : undefined,
84
81
  canChangePassword: canChangePassword(ctx.state.account),
85
- ...makeExp(),
82
+ exp: keepSessionAlive.get() ? new Date(Date.now() + middlewares_1.sessionDuration.compiled()) : undefined,
83
+ accountExp: (_a = ctx.state.account) === null || _a === void 0 ? void 0 : _a.expire,
86
84
  };
87
85
  };
88
86
  exports.refresh_session = refresh_session;
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-28T20:45:20.575Z";
48
+ exports.BUILD_TIMESTAMP = "2024-01-31T22:47:53.249Z";
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
@@ -174,7 +174,7 @@ function basename(path) {
174
174
  }
175
175
  exports.basename = basename;
176
176
  function dirname(path) {
177
- return path.slice(0, path.lastIndexOf('/', path.length - 1));
177
+ return path.slice(0, Math.max(0, path.lastIndexOf('/', path.length - 1)));
178
178
  }
179
179
  exports.dirname = dirname;
180
180
  function tryJson(s, except) {
@@ -312,7 +312,7 @@ function repeat(everyMs, cb) {
312
312
  }
313
313
  exports.repeat = repeat;
314
314
  function formatTimestamp(x) {
315
- return x ? new Date(x).toLocaleString() : '-';
315
+ return !x ? '-' : (x instanceof Date ? x : new Date(x)).toLocaleString();
316
316
  }
317
317
  exports.formatTimestamp = formatTimestamp;
318
318
  function isPrimitive(x) {
package/src/customHtml.js CHANGED
@@ -8,7 +8,7 @@ const promises_1 = require("fs/promises");
8
8
  const plugins_1 = require("./plugins");
9
9
  const FILE = 'custom.html';
10
10
  exports.customHtmlSections = ['beforeHeader', 'afterHeader', 'afterMenuBar', 'afterList',
11
- 'top', 'bottom', 'afterEntryName', 'beforeLogin', 'unauthorized'];
11
+ 'top', 'bottom', 'afterEntryName', 'beforeLogin', 'unauthorized', 'htmlHead'];
12
12
  exports.customHtmlState = (0, vanilla_1.proxy)({
13
13
  sections: watchLoadCustomHtml().state
14
14
  });
package/src/ddns.js CHANGED
@@ -39,7 +39,7 @@ dynamicDnsUrl.sub(v => {
39
39
  const str = String(res.body).trim();
40
40
  return (re ? str.match(re) : res.ok) ? '' : (str || res.statusMessage);
41
41
  }, (err) => err.code || err.message || String(err));
42
- last = { ts: new Date(), error, url };
42
+ last = { ts: new Date().toJSON(), error, url };
43
43
  events_1.default.emit('dynamicDnsError', last);
44
44
  console.log('dynamic dns update', error || 'ok');
45
45
  });
@@ -139,7 +139,6 @@
139
139
  "Link": "Link",
140
140
  "Auto-play": "Auto-play",
141
141
  "autoplay_seconds": "Secondi di attesa mostrando immagini",
142
- "Select file": "Seleziona file",
143
142
  "Select all": "Seleziona tutto",
144
143
  "go_first": "Vai all'inizio",
145
144
  "go_last": "Vai alla fine"
@@ -143,6 +143,7 @@ async function treatIndex(ctx, filesUri, body) {
143
143
  `);
144
144
  if (isFrontend)
145
145
  ret = ret
146
+ .replace('<head>', '<head>' + (0, customHtml_1.getSection)('htmlHead'))
146
147
  .replace('<body>', '<body>' + (0, customHtml_1.getSection)('top'))
147
148
  .replace('</body>', (0, customHtml_1.getSection)('bottom') + '</body>');
148
149
  return ret;