hfs 0.36.0 → 0.37.0
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.
- package/admin/assets/{index-553acfd5.js → index-3867a36f.js} +113 -113
- package/admin/assets/{sha512-df6106ba.js → sha512-9a451918.js} +1 -1
- package/admin/index.html +1 -1
- package/frontend/assets/index-420a7286.js +85 -0
- package/frontend/assets/{sha512-99595208.js → sha512-065c5d7c.js} +1 -1
- package/frontend/index.html +2 -2
- package/package.json +2 -2
- package/src/adminApis.js +2 -1
- package/src/api.vfs.js +5 -3
- package/src/const.js +5 -5
- package/src/frontEndApis.js +2 -3
- package/src/serveGuiFiles.js +1 -0
- package/src/update.js +3 -3
- package/src/upload.js +7 -4
- package/src/vfs.js +2 -1
- package/frontend/assets/index-44854bd0.js +0 -85
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as SF}from"./index-
|
|
1
|
+
import{c as SF}from"./index-420a7286.js";function OF(iF,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 iF)){const lF=Object.getOwnPropertyDescriptor(tF,w);lF&&Object.defineProperty(iF,w,lF.get?lF:{enumerable:!0,get:()=>tF[w]})}}}return Object.freeze(Object.defineProperty(iF,Symbol.toStringTag,{value:"Module"}))}var EF={},UF={get exports(){return EF},set exports(iF){EF=iF}};/*
|
|
2
2
|
* [js-sha512]{@link https://github.com/emn178/js-sha512}
|
|
3
3
|
*
|
|
4
4
|
* @version 0.8.0
|
package/frontend/index.html
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
<link href="/fontello.css" rel="stylesheet" />
|
|
7
7
|
<link rel="icon"/>
|
|
8
8
|
<script>SESSION = _HFS_SESSION_</script>
|
|
9
|
-
<title>
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
+
<title>_HFS_TITLE_</title>
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-420a7286.js"></script>
|
|
11
11
|
<link rel="stylesheet" href="/assets/index-216f7ea9.css">
|
|
12
12
|
</head>
|
|
13
13
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hfs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.0",
|
|
4
4
|
"description": "HTTP File Server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"file server",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dist-bin": "npm run dist-modules && cd dist && pkg . -C gzip && mv -f hfs-win-x64.exe hfs.exe && zip hfs-windows.zip hfs.exe -r plugins && cp -f hfs-linux-x64 hfs && zip hfs-linux.zip hfs -r plugins && cp -f hfs-macos-x64 hfs && zip hfs-mac.zip hfs -r plugins && cp -f hfs-macos-arm64 hfs && zip hfs-mac-arm.zip hfs -r plugins && rm hfs",
|
|
28
28
|
"dist-modules": "cp package*.json dist && cd dist && npm ci --omit=dev && npm run dist-crclib && rm package-lock.json && cd .. && node prune_modules",
|
|
29
29
|
"dist-crclib": "npm i -f --no-save --omit=dev @node-rs/crc32-win32-x64-msvc @node-rs/crc32-darwin-arm64 @node-rs/crc32-darwin-x64 ",
|
|
30
|
-
"dist-win": "
|
|
30
|
+
"dist-win": "cp package*.json dist && cd dist && npm ci --omit=dev && npm i -f --no-save --omit=dev @node-rs/crc32-win32 && pkg . -C gzip -t node16-win-x64",
|
|
31
31
|
"dist-node": "npm run dist-modules && cd dist && zip hfs-node.zip -r * -x *.zip *.exe hfs-* *.log logs"
|
|
32
32
|
},
|
|
33
33
|
"engines": {
|
package/src/adminApis.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.ctxAdminAccess = exports.favicon = exports.localhostAdmin = exports.adminApis = void 0;
|
|
30
|
+
exports.ctxAdminAccess = exports.title = exports.favicon = exports.localhostAdmin = exports.adminApis = void 0;
|
|
31
31
|
const apiMiddleware_1 = require("./apiMiddleware");
|
|
32
32
|
const config_1 = require("./config");
|
|
33
33
|
const listen_1 = require("./listen");
|
|
@@ -162,6 +162,7 @@ for (const [k, was] of Object.entries(exports.adminApis))
|
|
|
162
162
|
};
|
|
163
163
|
exports.localhostAdmin = (0, config_1.defineConfig)('localhost_admin', true);
|
|
164
164
|
exports.favicon = (0, config_1.defineConfig)('favicon');
|
|
165
|
+
exports.title = (0, config_1.defineConfig)('title', "File server");
|
|
165
166
|
function ctxAdminAccess(ctx) {
|
|
166
167
|
return !ctx.state.proxiedFor // we consider localhost_admin only if no proxy is detected
|
|
167
168
|
&& exports.localhostAdmin.get() && (0, misc_1.isLocalHost)(ctx)
|
package/src/api.vfs.js
CHANGED
|
@@ -68,9 +68,11 @@ const apis = {
|
|
|
68
68
|
if (!n)
|
|
69
69
|
return new apiMiddleware_1.ApiError(const_1.HTTP_NOT_FOUND, 'path not found');
|
|
70
70
|
props = pickProps(props, ['name', 'source', 'masks', 'default', ...Object.keys(vfs_1.defaultPerms)]);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
if (props.name && props.name !== (0, vfs_1.getNodeName)(n)) {
|
|
72
|
+
const parent = await urlToNodeOriginal((0, path_1.dirname)(uri));
|
|
73
|
+
if ((_a = parent === null || parent === void 0 ? void 0 : parent.children) === null || _a === void 0 ? void 0 : _a.find(x => (0, vfs_1.getNodeName)(x) === props.name))
|
|
74
|
+
return new apiMiddleware_1.ApiError(const_1.HTTP_CONFLICT, 'name already present');
|
|
75
|
+
}
|
|
74
76
|
props = (0, misc_1.objSameKeys)(props, v => v === null ? undefined : v); // null is a way to serialize undefined, that will restore default values
|
|
75
77
|
if (props.masks && typeof props.masks !== 'object')
|
|
76
78
|
delete props.masks;
|
package/src/const.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.APP_PATH = exports.IS_WINDOWS = exports.HTTP_SERVER_ERROR = exports.HTTP_FOOL = exports.HTTP_RANGE_NOT_SATISFIABLE = exports.HTTP_PAYLOAD_TOO_LARGE = exports.HTTP_CONFLICT = exports.HTTP_NOT_ACCEPTABLE = exports.HTTP_METHOD_NOT_ALLOWED = exports.HTTP_NOT_FOUND = exports.HTTP_FORBIDDEN = exports.HTTP_UNAUTHORIZED = exports.HTTP_BAD_REQUEST = exports.HTTP_NOT_MODIFIED = exports.HTTP_TEMPORARY_REDIRECT = exports.HTTP_PARTIAL_CONTENT = exports.HTTP_NO_CONTENT = exports.HTTP_OK = exports.PLUGINS_PUB_URI = exports.API_URI = exports.ADMIN_URI = exports.FRONTEND_URI = exports.SPECIAL_URI = exports.COMPATIBLE_API_VERSION = exports.API_VERSION = exports.SESSION_DURATION = exports.DAY = exports.VERSION = exports.BUILD_TIMESTAMP = exports.HFS_STARTED = exports.ORIGINAL_CWD = exports.DEV = exports.argv = void 0;
|
|
30
|
+
exports.APP_PATH = exports.IS_BINARY = exports.IS_WINDOWS = exports.HTTP_SERVER_ERROR = exports.HTTP_FOOL = exports.HTTP_RANGE_NOT_SATISFIABLE = exports.HTTP_PAYLOAD_TOO_LARGE = exports.HTTP_CONFLICT = exports.HTTP_NOT_ACCEPTABLE = exports.HTTP_METHOD_NOT_ALLOWED = exports.HTTP_NOT_FOUND = exports.HTTP_FORBIDDEN = exports.HTTP_UNAUTHORIZED = exports.HTTP_BAD_REQUEST = exports.HTTP_NOT_MODIFIED = exports.HTTP_TEMPORARY_REDIRECT = exports.HTTP_PARTIAL_CONTENT = exports.HTTP_NO_CONTENT = exports.HTTP_OK = exports.PLUGINS_PUB_URI = exports.API_URI = exports.ADMIN_URI = exports.FRONTEND_URI = exports.SPECIAL_URI = exports.COMPATIBLE_API_VERSION = exports.API_VERSION = exports.SESSION_DURATION = exports.DAY = exports.VERSION = exports.BUILD_TIMESTAMP = exports.HFS_STARTED = exports.ORIGINAL_CWD = exports.DEV = exports.argv = void 0;
|
|
31
31
|
const minimist_1 = __importDefault(require("minimist"));
|
|
32
32
|
const fs = __importStar(require("fs"));
|
|
33
33
|
const os_1 = require("os");
|
|
@@ -38,7 +38,7 @@ 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-02-
|
|
41
|
+
exports.BUILD_TIMESTAMP = "2023-02-24T21:59:58.935Z";
|
|
42
42
|
const pkg = JSON.parse(fs.readFileSync(PKG_PATH, 'utf8'));
|
|
43
43
|
exports.VERSION = pkg.version;
|
|
44
44
|
exports.DAY = 86400000;
|
|
@@ -67,8 +67,8 @@ exports.HTTP_RANGE_NOT_SATISFIABLE = 416;
|
|
|
67
67
|
exports.HTTP_FOOL = 418;
|
|
68
68
|
exports.HTTP_SERVER_ERROR = 500;
|
|
69
69
|
exports.IS_WINDOWS = process.platform === 'win32';
|
|
70
|
-
|
|
71
|
-
exports.APP_PATH = (0, path_1.dirname)(IS_BINARY ? process.
|
|
70
|
+
exports.IS_BINARY = !(0, path_1.basename)(process.execPath).includes('node'); // this won't be node if pkg was used
|
|
71
|
+
exports.APP_PATH = (0, path_1.dirname)(exports.IS_BINARY ? process.execPath : __dirname);
|
|
72
72
|
// we want this to be the first stuff to be printed, then we print it in this module, that is executed at the beginning
|
|
73
73
|
if (exports.DEV)
|
|
74
74
|
console.clear();
|
|
@@ -81,7 +81,7 @@ console.log('version', exports.VERSION || '-');
|
|
|
81
81
|
console.log('build', exports.BUILD_TIMESTAMP || '-');
|
|
82
82
|
if (exports.argv.cwd)
|
|
83
83
|
process.chdir(exports.argv.cwd);
|
|
84
|
-
else if (!process.
|
|
84
|
+
else if (!process.execPath.endsWith('.exe')) { // still considering whether to use this behavior with Windows users, who may be less accustomed to it
|
|
85
85
|
const dir = (0, path_1.join)((0, os_1.homedir)(), '.hfs');
|
|
86
86
|
try {
|
|
87
87
|
(0, fs_1.mkdirSync)(dir);
|
package/src/frontEndApis.js
CHANGED
|
@@ -63,11 +63,10 @@ exports.frontEndApis = {
|
|
|
63
63
|
const parentNode = await (0, vfs_1.urlToNode)(path, ctx);
|
|
64
64
|
if (!parentNode)
|
|
65
65
|
return new apiMiddleware_1.ApiError(const_1.HTTP_NOT_FOUND, 'parent not found');
|
|
66
|
-
|
|
67
|
-
if (!source || !(0, vfs_1.hasPermission)(parentNode, 'can_upload', ctx))
|
|
66
|
+
if (!(0, vfs_1.hasPermission)(parentNode, 'can_upload', ctx))
|
|
68
67
|
return new apiMiddleware_1.ApiError(const_1.HTTP_FORBIDDEN);
|
|
69
68
|
try {
|
|
70
|
-
await (0, promises_1.mkdir)((0, path_1.join)(source, name));
|
|
69
|
+
await (0, promises_1.mkdir)((0, path_1.join)(parentNode.source, name));
|
|
71
70
|
return {};
|
|
72
71
|
}
|
|
73
72
|
catch (e) {
|
package/src/serveGuiFiles.js
CHANGED
|
@@ -82,6 +82,7 @@ async function treatIndex(ctx, body, filesUri) {
|
|
|
82
82
|
return body
|
|
83
83
|
.replace(/((?:src|href) *= *['"])\/?(?![a-z]+:\/\/)/g, '$1' + filesUri)
|
|
84
84
|
.replace('<link rel="icon"/>', `<link rel="icon" href="${adminApis_1.favicon.get() ? '/favicon.ico' : 'data:;'}" />`)
|
|
85
|
+
.replace('_HFS_TITLE_', adminApis_1.title.get())
|
|
85
86
|
.replace('_HFS_SESSION_', session instanceof apiMiddleware_1.ApiError ? 'null' : JSON.stringify(session))
|
|
86
87
|
// replacing this text allow us to avoid injecting in frontends that don't support plugins. Don't use a <--comment--> or it will be removed by webpack
|
|
87
88
|
.replace('_HFS_PLUGINS_', pluginsInjection);
|
package/src/update.js
CHANGED
|
@@ -19,7 +19,7 @@ async function getUpdate() {
|
|
|
19
19
|
}
|
|
20
20
|
exports.getUpdate = getUpdate;
|
|
21
21
|
async function update() {
|
|
22
|
-
if (
|
|
22
|
+
if (!const_1.IS_BINARY)
|
|
23
23
|
throw "only binary versions are supported for now";
|
|
24
24
|
const update = await getUpdate();
|
|
25
25
|
const assetSearch = { win32: 'windows', darwin: 'mac', linux: 'linux' }[process.platform];
|
|
@@ -30,7 +30,7 @@ async function update() {
|
|
|
30
30
|
throw "asset not found";
|
|
31
31
|
const url = asset.browser_download_url;
|
|
32
32
|
console.log("downloading", url);
|
|
33
|
-
const bin = process.
|
|
33
|
+
const bin = process.execPath;
|
|
34
34
|
const binPath = (0, path_1.dirname)(bin);
|
|
35
35
|
const binFile = (0, path_1.basename)(bin);
|
|
36
36
|
const newBinFile = 'new-' + binFile;
|
|
@@ -64,7 +64,7 @@ async function update() {
|
|
|
64
64
|
}
|
|
65
65
|
exports.update = update;
|
|
66
66
|
if (const_1.argv.updating) { // we were launched with a temporary name, restore original name to avoid breaking references
|
|
67
|
-
const bin = process.
|
|
67
|
+
const bin = process.execPath;
|
|
68
68
|
(0, fs_1.renameSync)(bin, (0, path_1.join)((0, path_1.dirname)(bin), const_1.argv.updating));
|
|
69
69
|
console.log("renamed binary file to", const_1.argv.updating);
|
|
70
70
|
}
|
package/src/upload.js
CHANGED
|
@@ -17,19 +17,22 @@ exports.minAvailableMb = (0, config_1.defineConfig)('min_available_mb', 100);
|
|
|
17
17
|
const dontOverwriteUploading = (0, config_1.defineConfig)('dont_overwrite_uploading', false);
|
|
18
18
|
const waitingToBeDeleted = {};
|
|
19
19
|
function uploadWriter(base, path, ctx) {
|
|
20
|
-
if (!
|
|
20
|
+
if (!(0, vfs_1.hasPermission)(base, 'can_upload', ctx))
|
|
21
21
|
return fail(base.can_upload === false ? const_1.HTTP_FORBIDDEN : const_1.HTTP_UNAUTHORIZED);
|
|
22
22
|
const fullPath = (0, path_1.join)(base.source, path);
|
|
23
23
|
const dir = (0, path_1.dirname)(fullPath);
|
|
24
24
|
const min = exports.minAvailableMb.get() * (1 << 20);
|
|
25
25
|
const reqSize = Number(ctx.headers["content-length"]);
|
|
26
|
-
if (
|
|
26
|
+
if (reqSize)
|
|
27
27
|
try {
|
|
28
|
-
|
|
28
|
+
const free = (0, util_os_1.getFreeDiskSync)(dir);
|
|
29
|
+
if (typeof free !== 'number' || isNaN(free))
|
|
30
|
+
throw '';
|
|
31
|
+
if (reqSize > (0, util_os_1.getFreeDiskSync)(dir) - (min || 0))
|
|
29
32
|
return fail(const_1.HTTP_PAYLOAD_TOO_LARGE);
|
|
30
33
|
}
|
|
31
34
|
catch (e) {
|
|
32
|
-
console.warn("can't check disk size", String(e));
|
|
35
|
+
console.warn("can't check disk size", e.message || String(e));
|
|
33
36
|
}
|
|
34
37
|
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
35
38
|
const keepName = (0, path_1.basename)(fullPath).slice(-200);
|
package/src/vfs.js
CHANGED
|
@@ -123,7 +123,8 @@ async function nodeIsDirectory(node) {
|
|
|
123
123
|
exports.nodeIsDirectory = nodeIsDirectory;
|
|
124
124
|
function hasPermission(node, perm, ctx) {
|
|
125
125
|
var _a;
|
|
126
|
-
return
|
|
126
|
+
return (node.source || perm !== 'can_upload') // Upload possible only if we know where to store. First check node.source because is supposedly faster.
|
|
127
|
+
&& matchWho((_a = node[perm]) !== null && _a !== void 0 ? _a : exports.defaultPerms[perm], ctx)
|
|
127
128
|
&& (perm !== 'can_see' || hasPermission(node, 'can_read', ctx)); // can_see is used to hide something you nonetheless can_read, so you MUST also can_read
|
|
128
129
|
}
|
|
129
130
|
exports.hasPermission = hasPermission;
|