hfs 0.48.0 → 0.48.2

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-799f615e.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-e24651da.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-799f615e.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-e24651da.js"></script>
9
9
  <link rel="stylesheet" href="/assets/index-cadcb0e9.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hfs",
3
- "version": "0.48.0",
3
+ "version": "0.48.2",
4
4
  "description": "HTTP File Server",
5
5
  "keywords": [
6
6
  "file server",
@@ -35,6 +35,7 @@
35
35
  "node": ">=18.12.0"
36
36
  },
37
37
  "files": [
38
+ "central.json",
38
39
  "src/*",
39
40
  "admin/*",
40
41
  "frontend/*",
package/src/api.net.js CHANGED
@@ -35,7 +35,7 @@ const getNatInfo = (0, misc_1.debounceAsync)(async () => {
35
35
  const gettingIp = getPublicIp(); // don't wait, do it in parallel
36
36
  const res = await client.getGateway().catch(() => null);
37
37
  const status = await (0, listen_1.getServerStatus)();
38
- const mappings = res && await client.getMappings().catch(() => null);
38
+ const mappings = res && await (0, misc_1.haveTimeout)(5000, client.getMappings()).catch(() => null);
39
39
  console.debug('mappings found', mappings);
40
40
  const gatewayIp = res ? new URL(res.gateway.description).hostname : await findGateway().catch(() => null);
41
41
  const localIp = (res === null || res === void 0 ? void 0 : res.address) || (await (0, listen_1.getIps)())[0];
@@ -129,7 +129,7 @@ async function generateSSLCert(domain, email) {
129
129
  let check = await checkPort(domain, 80); // some check services may not consider the domain, but we already verified that
130
130
  if (check && !check.success && upnp && externalPort !== 80) { // consider a short-lived mapping
131
131
  // @ts-ignore
132
- await client.createMapping({ private: 80, public: { host: '', port: 80 }, description: 'hfs challenge', ttl: 0 }).catch(() => { });
132
+ await client.createMapping({ private: 80, public: { host: '', port: 80 }, description: 'hfs temporary', ttl: 30 }).catch(() => { });
133
133
  check = await checkPort(domain, 80); // repeat test
134
134
  }
135
135
  if (!check)
package/src/const.js CHANGED
@@ -38,11 +38,11 @@ exports.DEV = process.env.DEV || exports.argv.dev ? 'DEV' : '';
38
38
  exports.ORIGINAL_CWD = process.cwd();
39
39
  exports.HFS_STARTED = new Date();
40
40
  const PKG_PATH = (0, path_1.join)(__dirname, '..', 'package.json');
41
- exports.BUILD_TIMESTAMP = "2023-09-18T18:17:57.330Z";
41
+ exports.BUILD_TIMESTAMP = "2023-09-20T22:00:36.550Z";
42
42
  const pkg = JSON.parse(fs.readFileSync(PKG_PATH, 'utf8'));
43
43
  exports.VERSION = pkg.version;
44
44
  exports.RUNNING_BETA = exports.VERSION.includes('-');
45
- exports.API_VERSION = 8.3;
45
+ exports.API_VERSION = 8.4;
46
46
  exports.COMPATIBLE_API_VERSION = 1; // while changes in the api are not breaking, this number stays the same, otherwise it is made equal to API_VERSION
47
47
  exports.HFS_REPO = 'rejetto/hfs';
48
48
  exports.HFS_REPO_BRANCH = exports.RUNNING_BETA ? 'next' : 'main';
package/src/cross.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.xlate = exports.isEqualLax = exports.isWindowsDrive = exports.isIP = exports.isPrimitive = exports.formatTimestamp = exports.repeat = exports.asyncGeneratorToArray = exports.filterMapGenerator = exports.throw_ = exports.hasProp = exports.typedEntries = exports.typedKeys = exports.objRenameKey = exports.randomId = exports.getOrSet = exports.waitFor = exports.newObj = exports.removeStarting = exports.findDefined = exports.isOrderedEqual = exports.swap = exports.tryJson = exports.basename = exports.pendingPromise = exports._log = exports.wantArray = exports.formatPerc = exports.with_ = exports.try_ = exports.setHidden = exports.onlyTruthy = exports.truthy = exports.enforceFinal = exports.objSameKeys = exports.wait = exports.prefix = exports.formatBytes = exports.MAX_TILES_SIZE = exports.DAY = exports.HOUR = exports.MINUTE = exports.WIKI_URL = exports.REPO_URL = void 0;
6
+ exports.xlate = exports.isEqualLax = exports.isWindowsDrive = exports.isIP = exports.isPrimitive = exports.formatTimestamp = exports.repeat = exports.asyncGeneratorToArray = exports.filterMapGenerator = exports.throw_ = exports.hasProp = exports.typedEntries = exports.typedKeys = exports.objRenameKey = exports.randomId = exports.getOrSet = exports.waitFor = exports.newObj = exports.removeStarting = exports.findDefined = exports.isOrderedEqual = exports.swap = exports.tryJson = exports.basename = exports.pendingPromise = exports._log = exports.wantArray = exports.formatPerc = exports.with_ = exports.try_ = exports.setHidden = exports.onlyTruthy = exports.truthy = exports.enforceFinal = exports.objSameKeys = exports.haveTimeout = exports.wait = exports.prefix = exports.formatBytes = exports.MAX_TILES_SIZE = exports.DAY = exports.HOUR = exports.MINUTE = exports.WIKI_URL = exports.REPO_URL = void 0;
7
7
  // This file is part of HFS - Copyright 2021-2023, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
8
8
  // all content here is shared between client and server
9
9
  const lodash_1 = __importDefault(require("lodash"));
@@ -32,6 +32,10 @@ function wait(ms, val) {
32
32
  return new Promise(res => setTimeout(res, ms, val));
33
33
  }
34
34
  exports.wait = wait;
35
+ function haveTimeout(ms, job, error) {
36
+ return Promise.race([job, wait(ms).then(() => { throw error; })]);
37
+ }
38
+ exports.haveTimeout = haveTimeout;
35
39
  function objSameKeys(src, newValue) {
36
40
  return Object.fromEntries(Object.entries(src).map(([k, v]) => [k, newValue(v, k)]));
37
41
  }
package/src/plugins.js CHANGED
@@ -155,7 +155,11 @@ const pluginsMiddleware = async (ctx, next) => {
155
155
  var _a;
156
156
  const after = {};
157
157
  // run middleware plugins
158
- for (const [id, pl] of Object.entries(plugins).concat([['.', await serverCode.compiled()]]))
158
+ const entries = Object.entries(plugins);
159
+ const sc = await serverCode.compiled();
160
+ if (sc)
161
+ entries.push(['.', await serverCode.compiled()]);
162
+ for (const [id, pl] of entries)
159
163
  try {
160
164
  const res = await ((_a = pl.middleware) === null || _a === void 0 ? void 0 : _a.call(pl, ctx));
161
165
  if (res === true)
package/src/update.js CHANGED
@@ -20,7 +20,8 @@ async function getUpdates() {
20
20
  const stable = await (0, github_1.getRepoInfo)(const_1.HFS_REPO + '/releases/latest');
21
21
  const verStable = ver(stable);
22
22
  const ret = await getBetas();
23
- if (stable && (config_1.currentVersion.olderThan(stable.tag_name) || const_1.RUNNING_BETA)) // if we are running a beta, also offer the latest stable
23
+ stable.isNewer = config_1.currentVersion.olderThan(stable.tag_name) || const_1.RUNNING_BETA;
24
+ if (stable.isNewer)
24
25
  ret.push(stable);
25
26
  return ret;
26
27
  function ver(x) {