hfs 0.49.0-alpha4 → 0.49.0-beta6

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-5436e6f5.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-69d63cd1.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-3c132d35.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-69d63cd1.js"></script>
9
9
  <link rel="stylesheet" href="/assets/index-db5f0e4b.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hfs",
3
- "version": "0.49.0-alpha4",
3
+ "version": "0.49.0-beta6",
4
4
  "description": "HTTP File Server",
5
5
  "keywords": [
6
6
  "file server",
@@ -71,6 +71,7 @@
71
71
  "find-process": "^1.4.7",
72
72
  "formidable": "^3.5.1",
73
73
  "fs-x-attributes": "^1.0.2",
74
+ "iconv-lite": "^0.6.3",
74
75
  "koa": "^2.13.4",
75
76
  "koa-compress": "^5.1.0",
76
77
  "koa-mount": "^4.0.0",
package/src/acme.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.acme_email = exports.acme_domain = exports.makeCert = exports.acmeMiddleware = void 0;
6
+ exports.makeCert = exports.acmeMiddleware = void 0;
7
7
  const cross_1 = require("./cross");
8
8
  const http_1 = require("http");
9
9
  const nat_1 = require("./nat");
@@ -96,12 +96,14 @@ exports.makeCert = (0, debounceAsync_1.debounceAsync)(async (domain, email) => {
96
96
  listen_1.cert.set(CERT_FILE); // update config
97
97
  listen_1.privateKey.set(KEY_FILE);
98
98
  }, 0);
99
- (0, config_1.defineConfig)('acme_renew', false); // handle config changes
99
+ const acmeDomain = (0, config_1.defineConfig)('acme_domain', '');
100
+ const acmeEmail = (0, config_1.defineConfig)('acme_email', '');
101
+ const acmeRenew = (0, config_1.defineConfig)('acme_renew', false); // handle config changes
100
102
  events_1.default.once('https ready', () => (0, cross_1.repeat)(cross_1.HOUR, renewCert));
101
- exports.acme_domain = (0, config_1.defineConfig)('acme_domain', '');
102
- exports.acme_email = (0, config_1.defineConfig)('acme_email', '');
103
103
  // checks if the cert is near expiration date, and if so renews it
104
104
  const renewCert = (0, debounceAsync_1.debounceAsync)(async () => {
105
+ if (!acmeRenew.get())
106
+ return;
105
107
  const cert = (0, listen_1.getCertObject)();
106
108
  if (!cert)
107
109
  return;
@@ -110,6 +112,6 @@ const renewCert = (0, debounceAsync_1.debounceAsync)(async () => {
110
112
  // not expiring in a month
111
113
  if (now > new Date(cert.validFrom) && now < validTo && validTo.getTime() - now.getTime() >= 30 * cross_1.DAY)
112
114
  return console.log("certificate still good");
113
- await (0, exports.makeCert)(exports.acme_domain.get(), exports.acme_email.get())
115
+ await (0, exports.makeCert)(acmeDomain.get(), acmeEmail.get())
114
116
  .catch(e => console.log("error renewing certificate: ", String(e)));
115
117
  }, 0, { retain: cross_1.DAY, retainFailure: cross_1.HOUR });
@@ -33,11 +33,6 @@ const apis = {
33
33
  },
34
34
  set_account({ username, changes }, ctx) {
35
35
  var _a;
36
- const { admin } = changes;
37
- if (admin === null)
38
- changes.admin = undefined;
39
- else if (admin !== undefined && typeof admin !== 'boolean')
40
- return new apiMiddleware_1.ApiError(const_1.HTTP_BAD_REQUEST, "invalid admin");
41
36
  const acc = (0, perm_1.getAccount)(username);
42
37
  if (!acc)
43
38
  return new apiMiddleware_1.ApiError(const_1.HTTP_BAD_REQUEST);
@@ -57,10 +52,14 @@ const apis = {
57
52
  return (0, perm_1.delAccount)(username) ? {} : new apiMiddleware_1.ApiError(const_1.HTTP_BAD_REQUEST);
58
53
  },
59
54
  async change_password_others({ username, newPassword }) {
60
- return (0, api_helpers_1.changePasswordHelper)((0, perm_1.getAccount)(username), newPassword);
55
+ const a = (0, perm_1.getAccount)(username);
56
+ return a ? (0, api_helpers_1.changePasswordHelper)(a, newPassword)
57
+ : new apiMiddleware_1.ApiError(const_1.HTTP_NOT_FOUND);
61
58
  },
62
59
  async change_srp_others({ username, salt, verifier }) {
63
- return (0, api_helpers_1.changeSrpHelper)((0, perm_1.getAccount)(username), salt, verifier);
60
+ const a = (0, perm_1.getAccount)(username);
61
+ return a ? (0, api_helpers_1.changeSrpHelper)(a, salt, verifier)
62
+ : new apiMiddleware_1.ApiError(const_1.HTTP_NOT_FOUND);
64
63
  }
65
64
  };
66
65
  exports.default = apis;
package/src/api.auth.js CHANGED
@@ -118,15 +118,23 @@ const refresh_session = async ({}, ctx) => {
118
118
  return !ctx.session ? new apiMiddleware_1.ApiError(const_1.HTTP_SERVER_ERROR) : {
119
119
  username: (0, perm_1.getCurrentUsername)(ctx),
120
120
  adminUrl: (0, adminApis_1.ctxAdminAccess)(ctx) ? ctx.state.revProxyPath + const_1.ADMIN_URI : undefined,
121
+ canChangePassword: canChangePassword(ctx.state.account),
121
122
  ...makeExp(),
122
123
  };
123
124
  };
124
125
  exports.refresh_session = refresh_session;
125
126
  const change_password = async ({ newPassword }, ctx) => {
126
- return (0, api_helpers_1.changePasswordHelper)(ctx.state.account, newPassword);
127
+ const a = ctx.state.account;
128
+ return !a || !canChangePassword(a) ? new apiMiddleware_1.ApiError(const_1.HTTP_UNAUTHORIZED)
129
+ : (0, api_helpers_1.changePasswordHelper)(a, newPassword);
127
130
  };
128
131
  exports.change_password = change_password;
129
132
  const change_srp = async ({ salt, verifier }, ctx) => {
130
- return (0, api_helpers_1.changeSrpHelper)(ctx.state.account, salt, verifier);
133
+ const a = ctx.state.account;
134
+ return !a || !canChangePassword(a) ? new apiMiddleware_1.ApiError(const_1.HTTP_UNAUTHORIZED)
135
+ : (0, api_helpers_1.changeSrpHelper)(a, salt, verifier);
131
136
  };
132
137
  exports.change_srp = change_srp;
138
+ function canChangePassword(account) {
139
+ return account && !(0, perm_1.getFromAccount)(account, a => a.disable_password_change);
140
+ }
@@ -30,7 +30,8 @@ const get_file_list = async ({ uri, offset, limit, search, c }, ctx) => {
30
30
  const fakeChild = (0, vfs_1.applyParentToChild)({}, node); // we want to know if we want to delete children
31
31
  const can_delete = (0, vfs_1.hasPermission)(fakeChild, 'can_delete', ctx);
32
32
  const can_archive = (0, vfs_1.hasPermission)(fakeChild, 'can_archive', ctx);
33
- const props = { can_archive, can_upload, can_delete, accept: node.accept };
33
+ const can_comment = can_upload && (0, comments_1.areCommentsEnabled)();
34
+ const props = { can_archive, can_upload, can_delete, accept: node.accept, can_comment };
34
35
  if (!list)
35
36
  return { ...props, list: await (0, misc_1.asyncGeneratorToArray)(produceEntries()) };
36
37
  setTimeout(async () => {
@@ -8,8 +8,6 @@ const const_1 = require("./const");
8
8
  async function changePasswordHelper(account, newPassword) {
9
9
  if (!newPassword) // clear text version
10
10
  return new apiMiddleware_1.ApiError(const_1.HTTP_BAD_REQUEST, 'missing parameters');
11
- if (!account)
12
- return new apiMiddleware_1.ApiError(const_1.HTTP_UNAUTHORIZED);
13
11
  await (0, perm_1.updateAccount)(account, account => {
14
12
  account.password = newPassword;
15
13
  });
@@ -21,8 +19,6 @@ async function changeSrpHelper(account, salt, verifier) {
21
19
  return new apiMiddleware_1.ApiError(const_1.HTTP_NOT_ACCEPTABLE);
22
20
  if (!salt || !verifier)
23
21
  return new apiMiddleware_1.ApiError(const_1.HTTP_BAD_REQUEST, 'missing parameters');
24
- if (!account)
25
- return new apiMiddleware_1.ApiError(const_1.HTTP_UNAUTHORIZED);
26
22
  await (0, perm_1.updateAccount)(account, account => {
27
23
  (0, perm_1.saveSrpInfo)(account, salt, verifier);
28
24
  delete account.hashed_password; // remove leftovers
package/src/api.vfs.js CHANGED
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
5
  };
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.windowsIntegration = exports.runReg = void 0;
7
8
  const vfs_1 = require("./vfs");
8
9
  const lodash_1 = __importDefault(require("lodash"));
9
10
  const promises_1 = require("fs/promises");
@@ -15,6 +16,8 @@ const util_os_1 = require("./util-os");
15
16
  const listen_1 = require("./listen");
16
17
  const os_1 = require("os");
17
18
  const open_1 = __importDefault(require("open"));
19
+ const util_1 = require("util");
20
+ const child_process_1 = require("child_process");
18
21
  // to manipulate the tree we need the original node
19
22
  async function urlToNodeOriginal(uri) {
20
23
  const n = await (0, vfs_1.urlToNode)(uri);
@@ -156,7 +159,7 @@ const apis = {
156
159
  if (closestFolder)
157
160
  while (path && !await (0, misc_1.isDirectory)(path))
158
161
  path = (0, path_1.dirname)(path);
159
- return { path };
162
+ return { path, isFolder: await (0, misc_1.isDirectory)(path) };
160
163
  },
161
164
  get_ls({ path, files = true, fileMask }, ctx) {
162
165
  return new apiMiddleware_1.SendListReadable({
@@ -203,6 +206,15 @@ const apis = {
203
206
  async windows_integration() {
204
207
  return { finish: await windowsIntegration() };
205
208
  },
209
+ async windows_integrated() {
210
+ return {
211
+ is: await (0, util_1.promisify)(child_process_1.execFile)('reg', ['query', WINDOWS_REG_KEY])
212
+ .then(x => x.stdout.includes('REG_SZ'), () => false)
213
+ };
214
+ },
215
+ async windows_remove() {
216
+ return { finish: await runReg(['*', 'Directory'].map(k => `\n\n[-${WINDOWS_REG_KEY.replace('*', k)}]`).join('')) };
217
+ },
206
218
  };
207
219
  exports.default = apis;
208
220
  // pick only selected props, and consider null and empty string as undefined
@@ -219,23 +231,29 @@ function simplifyName(node) {
219
231
  if ((0, vfs_1.getNodeName)(noName) === name)
220
232
  delete node.name;
221
233
  }
222
- async function windowsIntegration() {
223
- const status = await (0, listen_1.getServerStatus)();
224
- const url = 'http://localhost:' + status.http.port;
225
- const content = `Windows Registry Editor Version 5.00
226
- ` + ['*', 'Directory'].map(k => `
227
- [HKEY_CLASSES_ROOT\\${k}\\shell\\AddToHFS3]
228
- @="Add to HFS (new)"
229
-
230
- [HKEY_CLASSES_ROOT\\${k}\\shell\\AddToHFS3\\command]
231
- @="powershell -Command \\"$p = '%1'.Replace('\\\\', '\\\\\\\\'); $j = '{ \\\\\\"source\\\\\\": \\\\\\"' + $p + '\\\\\\" }'; $wsh = New-Object -ComObject Wscript.Shell; try { $res = Invoke-WebRequest -Uri '${url}/~/api/add_vfs' -Method POST -Headers @{ 'x-hfs-anti-csrf' = '1' } -ContentType 'application/json' -TimeoutSec 1 -Body $j; $json = $res.Content | ConvertFrom-Json; $link = $json.link; $link | Set-Clipboard; } catch { $wsh.Popup('Server is down', 0, 'Error', 16); }\\""
232
- `);
234
+ const WINDOWS_REG_KEY = 'HKEY_CLASSES_ROOT\\*\\shell\\AddToHFS3';
235
+ const WINDOWS_REG_KEY2 = WINDOWS_REG_KEY + '\\command';
236
+ async function runReg(content) {
233
237
  const path = (0, os_1.homedir)() + '\\desktop\\hfs-windows-menu.reg';
234
- await (0, promises_1.writeFile)(path, content, 'utf8');
238
+ await (0, promises_1.writeFile)(path, 'Windows Registry Editor Version 5.00\n\n' + content, 'utf8');
235
239
  try {
236
240
  await (0, open_1.default)(path, { wait: true });
241
+ await (0, promises_1.unlink)(path);
237
242
  }
238
243
  catch (_a) {
239
244
  return path;
240
245
  }
241
246
  }
247
+ exports.runReg = runReg;
248
+ async function windowsIntegration() {
249
+ const status = await (0, listen_1.getServerStatus)();
250
+ const url = 'http://localhost:' + status.http.port;
251
+ return runReg(['*', 'Directory'].map(k => `
252
+ [${WINDOWS_REG_KEY.replace('*', k)}]
253
+ @="Add to HFS (new)"
254
+
255
+ [${WINDOWS_REG_KEY2.replace('*', k)}]
256
+ @="powershell -Command \\"$p = '%1'.Replace('\\\\', '\\\\\\\\'); $j = '{ \\\\\\"source\\\\\\": \\\\\\"' + $p + '\\\\\\" }'; $wsh = New-Object -ComObject Wscript.Shell; try { $res = Invoke-WebRequest -Uri '${url}/~/api/add_vfs' -Method POST -Headers @{ 'x-hfs-anti-csrf' = '1' } -ContentType 'application/json' -TimeoutSec 1 -Body $j; $json = $res.Content | ConvertFrom-Json; $link = $json.link; $link | Set-Clipboard; } catch { $wsh.Popup('Server is down', 0, 'Error', 16); }\\""
257
+ `).join(''));
258
+ }
259
+ exports.windowsIntegration = windowsIntegration;
package/src/comments.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.setCommentFor = exports.getCommentFor = exports.descriptIon = exports.DESCRIPT_ION = void 0;
6
+ exports.areCommentsEnabled = exports.setCommentFor = exports.getCommentFor = exports.descriptIon = exports.DESCRIPT_ION = void 0;
7
7
  const config_1 = require("./config");
8
8
  const path_1 = require("path");
9
9
  const cross_1 = require("./cross");
@@ -11,8 +11,10 @@ const util_files_1 = require("./util-files");
11
11
  const promises_1 = require("fs/promises");
12
12
  const misc_1 = require("./misc");
13
13
  const lodash_1 = __importDefault(require("lodash"));
14
+ const iconv_lite_1 = __importDefault(require("iconv-lite"));
14
15
  exports.DESCRIPT_ION = 'descript.ion';
15
16
  exports.descriptIon = (0, config_1.defineConfig)('descript_ion', true);
17
+ const descriptIonEncoding = (0, config_1.defineConfig)('descript_ion_encoding', 'utf8');
16
18
  async function getCommentFor(path) {
17
19
  return !path || !exports.descriptIon.get() ? undefined
18
20
  : readDescription((0, path_1.dirname)(path)).then(x => x.get((0, cross_1.basename)(path)), () => undefined);
@@ -32,12 +34,19 @@ exports.setCommentFor = (0, misc_1.singleFromBatch)(async (jobs) => {
32
34
  // encode comments in descript.ion format
33
35
  let txt = '';
34
36
  comments.forEach((c, f) => txt += (f.includes(' ') ? `"${f}"` : f) + ' ' + (c.includes('\n') ? c.replaceAll('\n', '\\n') + MULTILINE_SUFFIX : c) + '\n');
35
- await (0, promises_1.writeFile)((0, path_1.join)(folder, exports.DESCRIPT_ION), txt);
37
+ const buffer = iconv_lite_1.default.encode(txt, descriptIonEncoding.get());
38
+ await (0, promises_1.writeFile)((0, path_1.join)(folder, exports.DESCRIPT_ION), buffer);
36
39
  }));
37
40
  });
41
+ function areCommentsEnabled() {
42
+ return exports.descriptIon.get();
43
+ }
44
+ exports.areCommentsEnabled = areCommentsEnabled;
38
45
  const MULTILINE_SUFFIX = '\x04\xc2';
39
46
  function readDescription(path) {
40
- return (0, util_files_1.parseFile)((0, path_1.join)(path, exports.DESCRIPT_ION), txt => new Map(txt.split('\n').map(line => {
47
+ return (0, util_files_1.parseFile)((0, path_1.join)(path, exports.DESCRIPT_ION), raw =>
48
+ // decoding could also be done with native TextDecoder.decode, but we need iconv for the encoding anyway
49
+ new Map(iconv_lite_1.default.decode(raw, descriptIonEncoding.get()).split('\n').map(line => {
41
50
  const quoted = line[0] === '"' ? 1 : 0;
42
51
  const i = quoted ? line.indexOf('"', 2) + 1 : line.indexOf(' ');
43
52
  const fn = line.slice(quoted, i - quoted);
@@ -47,3 +56,8 @@ function readDescription(path) {
47
56
  return [fn, comment];
48
57
  })));
49
58
  }
59
+ descriptIonEncoding.sub(() => {
60
+ for (const k of util_files_1.parseFileCache.keys())
61
+ if (k.endsWith(exports.DESCRIPT_ION))
62
+ util_files_1.parseFileCache.delete(k);
63
+ });
package/src/const.js CHANGED
@@ -42,7 +42,7 @@ 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-10-18T21:04:49.738Z";
45
+ exports.BUILD_TIMESTAMP = "2023-10-24T13:57:53.140Z";
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('-');
@@ -77,4 +77,5 @@ else if (!winExe) { // still considering whether to use this behavior with Windo
77
77
  }
78
78
  console.log('cwd', process.cwd());
79
79
  console.log('node', process.version);
80
+ console.log('platform', process.platform);
80
81
  console.log('pid', process.pid);
package/src/cross.js CHANGED
@@ -285,7 +285,8 @@ exports.isWindowsDrive = isWindowsDrive;
285
285
  function isEqualLax(a, b) {
286
286
  return a == b //eslint-disable-line
287
287
  || (a && b && typeof a === 'object' && typeof b === 'object'
288
- && Object.entries(a).every(([k, v]) => isEqualLax(v, b[k])));
288
+ && Object.entries(a).every(([k, v]) => isEqualLax(v, b[k]))
289
+ && Object.entries(b).every(([k, v]) => Object.hasOwn(a, k) || isEqualLax(v, a[k])));
289
290
  }
290
291
  exports.isEqualLax = isEqualLax;
291
292
  function xlate(input, table) {
@@ -103,8 +103,6 @@ const serveGuiAndSharedFiles = async (ctx, next) => {
103
103
  if (ctx.originalUrl === '/favicon.ico' && adminApis_1.favicon.get()) // originalUrl to not be subject to changes (vhosting plugin)
104
104
  return (0, serveFile_1.serveFile)(ctx, adminApis_1.favicon.get());
105
105
  let node = await (0, vfs_1.urlToNode)(path, ctx);
106
- if ((node === null || node === void 0 ? void 0 : node.default) && (path.endsWith('/') || !node.default.match(/\.html?$/i))) // final/ needed on browser to make resource urls correctly
107
- node = (_a = await (0, vfs_1.urlToNode)(node.default, ctx, node)) !== null && _a !== void 0 ? _a : node;
108
106
  if (!node)
109
107
  return sendErrorPage(ctx, const_1.HTTP_NOT_FOUND);
110
108
  if (ctx.method === 'POST') { // curl -F upload=@file url/
@@ -123,10 +121,14 @@ const serveGuiAndSharedFiles = async (ctx, next) => {
123
121
  res();
124
122
  }));
125
123
  }
124
+ if (node.default && path.endsWith('/')) // final/ needed on browser to make resource urls correctly with html pages
125
+ node = (_a = await (0, vfs_1.urlToNode)(node.default, ctx, node)) !== null && _a !== void 0 ? _a : node;
126
126
  if (!await (0, vfs_1.nodeIsDirectory)(node))
127
- return !node.source && await next()
128
- || (0, vfs_1.statusCodeForMissingPerm)(node, 'can_read', ctx)
129
- || (0, serveFile_1.serveFileNode)(ctx, node);
127
+ return !node.source ? sendErrorPage(ctx, const_1.HTTP_METHOD_NOT_ALLOWED)
128
+ : !(0, vfs_1.statusCodeForMissingPerm)(node, 'can_read', ctx) ? (0, serveFile_1.serveFileNode)(ctx, node)
129
+ : ctx.status !== const_1.HTTP_UNAUTHORIZED ? null
130
+ : !path.endsWith('/') ? ctx.set('WWW-Authenticate', 'Basic') // this is necessary to support standard urls with credentials. Final / means we are dealing with default file...
131
+ : (ctx.state.serveApp = true) && serveFrontendFiles(ctx, next); // ...for which we still provide fancy login
130
132
  if (!path.endsWith('/'))
131
133
  return ctx.redirect(ctx.state.revProxyPath + ctx.originalUrl.replace(/(\?|$)/, '/$1')); // keep query-string, if any
132
134
  if ((0, vfs_1.statusCodeForMissingPerm)(node, 'can_list', ctx)) {
package/src/perm.js CHANGED
@@ -132,7 +132,7 @@ function renameAccount(from, to) {
132
132
  }
133
133
  exports.renameAccount = renameAccount;
134
134
  // we consider all the following fields, when falsy, as equivalent to be missing. If this changes in the future, please adjust addAccount and setAccount
135
- const assignableProps = ['redirect', 'ignore_limits', 'belongs', 'admin', 'disabled'];
135
+ const assignableProps = ['redirect', 'ignore_limits', 'belongs', 'admin', 'disabled', 'disable_password_change'];
136
136
  function addAccount(username, props) {
137
137
  username = normalizeUsername(username);
138
138
  if (!username || getAccount(username, false))
@@ -149,8 +149,6 @@ function setAccount(acc, changes) {
149
149
  if (!v)
150
150
  rest[k] = undefined;
151
151
  Object.assign(acc, rest);
152
- if (!acc.disabled)
153
- delete acc.disabled;
154
152
  if (changes.username)
155
153
  renameAccount(acc.username, changes.username);
156
154
  saveAccountsAsap();
package/src/plugins.js CHANGED
@@ -226,7 +226,7 @@ class Plugin {
226
226
  const { id } = this;
227
227
  try {
228
228
  await ((_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.unload) === null || _b === void 0 ? void 0 : _b.call(_a));
229
- if (!reloading) // we already printed 'reloading'
229
+ if (!reloading && id !== SERVER_CODE_ID) // we already printed 'reloading'
230
230
  console.log('unloaded plugin', id);
231
231
  }
232
232
  catch (e) {
package/src/util-files.js CHANGED
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.parseFile = exports.loadFileAttr = exports.storeFileAttr = exports.isValidFileName = exports.createFileWithPath = exports.prepareFolder = exports.unzip = exports.dirStream = exports.adjustStaticPathForGlob = exports.dirTraversal = exports.watchDir = exports.readFileBusy = exports.isDirectory = void 0;
30
+ exports.parseFile = exports.parseFileCache = exports.loadFileAttr = exports.storeFileAttr = exports.isValidFileName = exports.createFileWithPath = exports.prepareFolder = exports.unzip = exports.dirStream = exports.adjustStaticPathForGlob = exports.dirTraversal = exports.watchDir = exports.readFileBusy = exports.isDirectory = void 0;
31
31
  const promises_1 = __importStar(require("fs/promises"));
32
32
  const misc_1 = require("./misc");
33
33
  const util_1 = require("util");
@@ -199,15 +199,15 @@ async function loadFileAttr(path, k) {
199
199
  }
200
200
  exports.loadFileAttr = loadFileAttr;
201
201
  // read and parse a file, caching unless timestamp has changed
202
- const cache = new Map();
202
+ exports.parseFileCache = new Map();
203
203
  async function parseFile(path, parse) {
204
204
  const { mtime: ts } = await (0, promises_1.stat)(path);
205
- const cached = cache.get(path);
206
- if (ts === (cached === null || cached === void 0 ? void 0 : cached.ts))
205
+ const cached = exports.parseFileCache.get(path);
206
+ if (cached && Number(ts) === Number(cached.ts))
207
207
  return cached.parsed;
208
- const raw = await (0, promises_1.readFile)(path, 'utf8');
208
+ const raw = await (0, promises_1.readFile)(path);
209
209
  const parsed = parse(raw);
210
- cache.set(path, { ts, parsed });
210
+ exports.parseFileCache.set(path, { ts, parsed });
211
211
  return parsed;
212
212
  }
213
213
  exports.parseFile = parseFile;
package/src/vfs.js CHANGED
@@ -168,11 +168,8 @@ function hasPermission(node, perm, ctx) {
168
168
  exports.hasPermission = hasPermission;
169
169
  function statusCodeForMissingPerm(node, perm, ctx, assign = true) {
170
170
  const ret = getCode();
171
- if (ret && assign) {
171
+ if (ret && assign)
172
172
  ctx.status = ret;
173
- if (ret === const_1.HTTP_UNAUTHORIZED) // this is necessary to support standard urls with credentials
174
- ctx.set('WWW-Authenticate', 'Basic'); // we support basic authentication
175
- }
176
173
  return ret;
177
174
  function getCode() {
178
175
  if (!node.source && perm === 'can_upload') // Upload possible only if we know where to store. First check node.source because is supposedly faster.
package/admin/Thumbs.db DELETED
Binary file