hfs 0.49.0-beta6 → 0.49.0-beta8
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-8539bfb1.js → index-cf4a0b7e.js} +71 -71
- package/{frontend/assets/sha512-70734098.js → admin/assets/sha512-c8b8e363.js} +1 -1
- package/admin/index.html +1 -1
- package/frontend/assets/index-3df7feea.css +1 -0
- package/frontend/assets/{index-69d63cd1.js → index-3ee10591.js} +19 -19
- package/{admin/assets/sha512-af211650.js → frontend/assets/sha512-b62cdb66.js} +1 -1
- package/frontend/fontello.css +2 -1
- package/frontend/fontello.woff2 +0 -0
- package/frontend/index.html +2 -2
- package/package.json +1 -1
- package/src/adminApis.js +2 -1
- package/src/api.plugins.js +3 -0
- package/src/api.vfs.js +28 -30
- package/src/const.js +1 -1
- package/src/cross-const.js +7 -1
- package/src/customHtml.js +1 -1
- package/src/errorPages.js +30 -0
- package/src/middlewares.js +7 -27
- package/frontend/assets/index-db5f0e4b.css +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as OF,c as UF}from"./index-
|
|
1
|
+
import{g as OF,c as UF}from"./index-3ee10591.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
|
package/frontend/fontello.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
@font-face {
|
|
2
2
|
font-family: 'fontello';
|
|
3
|
-
src: url('fontello.woff2?
|
|
3
|
+
src: url('fontello.woff2?11723613') format('woff2');
|
|
4
4
|
font-weight: normal;
|
|
5
5
|
font-style: normal;
|
|
6
6
|
}
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
.fa-crown:before { content: '\e844'; } /* '' */
|
|
69
69
|
.fa-download:before { content: '\f02e'; } /* '' */
|
|
70
70
|
.fa-upload:before { content: '\f02f'; } /* '' */
|
|
71
|
+
.fa-link:before { content: '\f08e'; } /* '' */
|
|
71
72
|
.fa-filter:before { content: '\f0b0'; } /* '' */
|
|
72
73
|
.fa-zoom:before { content: '\f0b2'; } /* '' */
|
|
73
74
|
.fa-menu:before { content: '\f0c9'; } /* '' */
|
package/frontend/fontello.woff2
CHANGED
|
Binary file
|
package/frontend/index.html
CHANGED
|
@@ -5,8 +5,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
7
|
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
9
|
-
<link rel="stylesheet" href="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-3ee10591.js"></script>
|
|
9
|
+
<link rel="stylesheet" href="/assets/index-3df7feea.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
12
12
|
<noscript>You need to enable JavaScript to run this app.</noscript>
|
package/package.json
CHANGED
package/src/adminApis.js
CHANGED
|
@@ -54,6 +54,7 @@ const lodash_1 = __importDefault(require("lodash"));
|
|
|
54
54
|
const update_1 = require("./update");
|
|
55
55
|
const consoleLog_1 = require("./consoleLog");
|
|
56
56
|
const path_1 = require("path");
|
|
57
|
+
const errorPages_1 = require("./errorPages");
|
|
57
58
|
exports.adminApis = {
|
|
58
59
|
...api_vfs_1.default,
|
|
59
60
|
...api_accounts_1.default,
|
|
@@ -92,7 +93,7 @@ exports.adminApis = {
|
|
|
92
93
|
get_custom_html() {
|
|
93
94
|
return {
|
|
94
95
|
sections: Object.fromEntries([
|
|
95
|
-
...customHtml_1.customHtmlSections.map(k => [k, '']),
|
|
96
|
+
...customHtml_1.customHtmlSections.concat((0, errorPages_1.getErrorSections)()).map(k => [k, '']),
|
|
96
97
|
...customHtml_1.customHtmlState.sections
|
|
97
98
|
])
|
|
98
99
|
};
|
package/src/api.plugins.js
CHANGED
|
@@ -100,6 +100,9 @@ const apis = {
|
|
|
100
100
|
const repo = pl.repo || pl.id; // .repo property can be more trustworthy in case github user renamed and left the previous link in 'repo'
|
|
101
101
|
if (lodash_1.default.includes(folder2repo, repo))
|
|
102
102
|
continue; // don't include installed plugins
|
|
103
|
+
const missing = await (0, plugins_1.getMissingDependencies)(pl);
|
|
104
|
+
if (missing.length)
|
|
105
|
+
pl.missing = missing;
|
|
103
106
|
list.add(pl);
|
|
104
107
|
// watch for events about this plugin, until this request is closed
|
|
105
108
|
undo.push((0, misc_1.onOff)(events_1.default, {
|
package/src/api.vfs.js
CHANGED
|
@@ -4,7 +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 =
|
|
7
|
+
exports.windowsIntegration = void 0;
|
|
8
8
|
const vfs_1 = require("./vfs");
|
|
9
9
|
const lodash_1 = __importDefault(require("lodash"));
|
|
10
10
|
const promises_1 = require("fs/promises");
|
|
@@ -14,8 +14,6 @@ const misc_1 = require("./misc");
|
|
|
14
14
|
const const_1 = require("./const");
|
|
15
15
|
const util_os_1 = require("./util-os");
|
|
16
16
|
const listen_1 = require("./listen");
|
|
17
|
-
const os_1 = require("os");
|
|
18
|
-
const open_1 = __importDefault(require("open"));
|
|
19
17
|
const util_1 = require("util");
|
|
20
18
|
const child_process_1 = require("child_process");
|
|
21
19
|
// to manipulate the tree we need the original node
|
|
@@ -73,7 +71,7 @@ const apis = {
|
|
|
73
71
|
if (lodash_1.default.isEmpty(oldParent.children))
|
|
74
72
|
delete oldParent.children;
|
|
75
73
|
(parentNode.children || (parentNode.children = [])).push(fromNode);
|
|
76
|
-
|
|
74
|
+
(0, vfs_1.saveVfs)();
|
|
77
75
|
return {};
|
|
78
76
|
},
|
|
79
77
|
async set_vfs({ uri, props }) {
|
|
@@ -91,7 +89,7 @@ const apis = {
|
|
|
91
89
|
delete props.masks;
|
|
92
90
|
Object.assign(n, props);
|
|
93
91
|
simplifyName(n);
|
|
94
|
-
|
|
92
|
+
(0, vfs_1.saveVfs)();
|
|
95
93
|
return n;
|
|
96
94
|
},
|
|
97
95
|
async add_vfs({ parent, source, name }) {
|
|
@@ -118,7 +116,7 @@ const apis = {
|
|
|
118
116
|
child.name = name;
|
|
119
117
|
simplifyName(child);
|
|
120
118
|
(parentNode.children || (parentNode.children = [])).unshift(child);
|
|
121
|
-
|
|
119
|
+
(0, vfs_1.saveVfs)();
|
|
122
120
|
const link = (0, listen_1.getBaseUrlOrDefault)()
|
|
123
121
|
+ (parent ? (0, misc_1.enforceFinal)('/', parent) : '/')
|
|
124
122
|
+ encodeURIComponent((0, vfs_1.getNodeName)(child))
|
|
@@ -161,6 +159,10 @@ const apis = {
|
|
|
161
159
|
path = (0, path_1.dirname)(path);
|
|
162
160
|
return { path, isFolder: await (0, misc_1.isDirectory)(path) };
|
|
163
161
|
},
|
|
162
|
+
async mkdir({ path }) {
|
|
163
|
+
await (0, promises_1.mkdir)(path, { recursive: true });
|
|
164
|
+
return {};
|
|
165
|
+
},
|
|
164
166
|
get_ls({ path, files = true, fileMask }, ctx) {
|
|
165
167
|
return new apiMiddleware_1.SendListReadable({
|
|
166
168
|
async doAtStart(list) {
|
|
@@ -204,16 +206,19 @@ const apis = {
|
|
|
204
206
|
});
|
|
205
207
|
},
|
|
206
208
|
async windows_integration() {
|
|
207
|
-
|
|
209
|
+
await windowsIntegration();
|
|
210
|
+
return {};
|
|
208
211
|
},
|
|
209
212
|
async windows_integrated() {
|
|
210
213
|
return {
|
|
211
|
-
is: await (
|
|
214
|
+
is: await reg('query', WINDOWS_REG_KEY)
|
|
212
215
|
.then(x => x.stdout.includes('REG_SZ'), () => false)
|
|
213
216
|
};
|
|
214
217
|
},
|
|
215
218
|
async windows_remove() {
|
|
216
|
-
|
|
219
|
+
for (const k of ['*', 'Directory'])
|
|
220
|
+
await reg('delete', WINDOWS_REG_KEY.replace('*', k), '/f');
|
|
221
|
+
return {};
|
|
217
222
|
},
|
|
218
223
|
};
|
|
219
224
|
exports.default = apis;
|
|
@@ -231,29 +236,22 @@ function simplifyName(node) {
|
|
|
231
236
|
if ((0, vfs_1.getNodeName)(noName) === name)
|
|
232
237
|
delete node.name;
|
|
233
238
|
}
|
|
234
|
-
const WINDOWS_REG_KEY = '
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
await (0, promises_1.writeFile)(path, 'Windows Registry Editor Version 5.00\n\n' + content, 'utf8');
|
|
239
|
-
try {
|
|
240
|
-
await (0, open_1.default)(path, { wait: true });
|
|
241
|
-
await (0, promises_1.unlink)(path);
|
|
242
|
-
}
|
|
243
|
-
catch (_a) {
|
|
244
|
-
return path;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
exports.runReg = runReg;
|
|
239
|
+
const WINDOWS_REG_KEY = 'HKCU\\Software\\Classes\\*\\shell\\AddToHFS3';
|
|
240
|
+
if (const_1.IS_WINDOWS) // legacy 0.49.0-beta7 2023-10-27. Remove in 0.50
|
|
241
|
+
for (const k of ['*', 'Directory'])
|
|
242
|
+
reg('delete', `HKCR\\${k}\\shell\\AddToHFS3`, '/f').catch(() => { });
|
|
248
243
|
async function windowsIntegration() {
|
|
249
244
|
const status = await (0, listen_1.getServerStatus)();
|
|
250
245
|
const url = 'http://localhost:' + status.http.port;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
246
|
+
for (const k of ['*', 'Directory']) {
|
|
247
|
+
await reg('add', WINDOWS_REG_KEY.replace('*', k), '/ve', '/f', '/d', 'Add to HFS (new)');
|
|
248
|
+
await reg('add', WINDOWS_REG_KEY.replace('*', k) + '\\command', '/ve', '/f', '/d', `powershell -Command "
|
|
249
|
+
$j = '{ \\"source\\": "' + ('%1'|convertTo-json) + '" }'; $wsh = New-Object -ComObject Wscript.Shell;
|
|
250
|
+
try { $res = Invoke-WebRequest -Uri '${url}/~/api/add_vfs' -Method POST -Headers @{ 'x-hfs-anti-csrf' = '1' } -ContentType 'application/json' -TimeoutSec 1 -Body $j;
|
|
251
|
+
$json = $res.Content | ConvertFrom-Json; $link = $json.link; $link | Set-Clipboard; } catch { $wsh.Popup('Server is down', 0, 'Error', 16); }"`);
|
|
252
|
+
}
|
|
258
253
|
}
|
|
259
254
|
exports.windowsIntegration = windowsIntegration;
|
|
255
|
+
function reg(...pars) {
|
|
256
|
+
return (0, util_1.promisify)(child_process_1.execFile)('reg', pars);
|
|
257
|
+
}
|
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-
|
|
45
|
+
exports.BUILD_TIMESTAMP = "2023-10-29T14:01:58.401Z";
|
|
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('-');
|
package/src/cross-const.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HTTP_SERVICE_UNAVAILABLE = exports.HTTP_SERVER_ERROR = exports.HTTP_FAILED_DEPENDENCY = exports.HTTP_FOOL = exports.HTTP_RANGE_NOT_SATISFIABLE = exports.HTTP_PAYLOAD_TOO_LARGE = exports.HTTP_PRECONDITION_FAILED = 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_MOVED_PERMANENTLY = 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.HFS_REPO = exports.COMPATIBLE_API_VERSION = exports.API_VERSION = void 0;
|
|
3
|
+
exports.HTTP_MESSAGES = exports.HTTP_SERVICE_UNAVAILABLE = exports.HTTP_SERVER_ERROR = exports.HTTP_FAILED_DEPENDENCY = exports.HTTP_FOOL = exports.HTTP_RANGE_NOT_SATISFIABLE = exports.HTTP_PAYLOAD_TOO_LARGE = exports.HTTP_PRECONDITION_FAILED = 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_MOVED_PERMANENTLY = 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.HFS_REPO = exports.COMPATIBLE_API_VERSION = exports.API_VERSION = void 0;
|
|
4
4
|
exports.API_VERSION = 8.4;
|
|
5
5
|
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
|
|
6
6
|
exports.HFS_REPO = 'rejetto/hfs';
|
|
@@ -29,3 +29,9 @@ exports.HTTP_FOOL = 418;
|
|
|
29
29
|
exports.HTTP_FAILED_DEPENDENCY = 424;
|
|
30
30
|
exports.HTTP_SERVER_ERROR = 500;
|
|
31
31
|
exports.HTTP_SERVICE_UNAVAILABLE = 503;
|
|
32
|
+
exports.HTTP_MESSAGES = {
|
|
33
|
+
[exports.HTTP_UNAUTHORIZED]: "Unauthorized",
|
|
34
|
+
[exports.HTTP_FORBIDDEN]: "Forbidden",
|
|
35
|
+
[exports.HTTP_NOT_FOUND]: "Not found",
|
|
36
|
+
[exports.HTTP_SERVER_ERROR]: "Server error",
|
|
37
|
+
};
|
package/src/customHtml.js
CHANGED
|
@@ -16,7 +16,7 @@ function watchLoadCustomHtml(folder = '') {
|
|
|
16
16
|
const state = new Map();
|
|
17
17
|
const res = (0, watchLoad_1.watchLoad)((0, misc_1.prefix)('', folder, '/') + FILE, data => {
|
|
18
18
|
var _a;
|
|
19
|
-
const re = /^\[(
|
|
19
|
+
const re = /^\[([^\]]+)] *$/gm;
|
|
20
20
|
state.clear();
|
|
21
21
|
if (!data)
|
|
22
22
|
return;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sendErrorPage = exports.getErrorSections = void 0;
|
|
4
|
+
const lang_1 = require("./lang");
|
|
5
|
+
const customHtml_1 = require("./customHtml");
|
|
6
|
+
const cross_1 = require("./cross");
|
|
7
|
+
const declaredErrorPages = [cross_1.HTTP_NOT_FOUND, cross_1.HTTP_FORBIDDEN].map(String);
|
|
8
|
+
function getErrorSections() {
|
|
9
|
+
return declaredErrorPages;
|
|
10
|
+
}
|
|
11
|
+
exports.getErrorSections = getErrorSections;
|
|
12
|
+
async function sendErrorPage(ctx, code) {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
ctx.status = code;
|
|
15
|
+
const msg = cross_1.HTTP_MESSAGES[ctx.status];
|
|
16
|
+
if (!msg)
|
|
17
|
+
return;
|
|
18
|
+
const lang = await (0, lang_1.getLangData)(ctx);
|
|
19
|
+
if (!lang)
|
|
20
|
+
return;
|
|
21
|
+
const trans = (_a = Object.values(lang)[0]) === null || _a === void 0 ? void 0 : _a.translate;
|
|
22
|
+
ctx.body = (_b = trans === null || trans === void 0 ? void 0 : trans[msg]) !== null && _b !== void 0 ? _b : msg;
|
|
23
|
+
const errorPage = (0, customHtml_1.getSection)(String(ctx.status));
|
|
24
|
+
if (!errorPage)
|
|
25
|
+
return;
|
|
26
|
+
if (errorPage.includes('<'))
|
|
27
|
+
ctx.type = 'html';
|
|
28
|
+
ctx.body = errorPage.replace('$MESSAGE', String(ctx.body));
|
|
29
|
+
}
|
|
30
|
+
exports.sendErrorPage = sendErrorPage;
|
package/src/middlewares.js
CHANGED
|
@@ -4,7 +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.paramsDecoder = exports.prepareState = exports.getProxyDetected = exports.someSecurity = exports.
|
|
7
|
+
exports.paramsDecoder = exports.prepareState = exports.getProxyDetected = exports.someSecurity = exports.serveGuiAndSharedFiles = exports.headRequests = exports.gzipper = exports.sessionDuration = void 0;
|
|
8
8
|
const koa_compress_1 = __importDefault(require("koa-compress"));
|
|
9
9
|
const const_1 = require("./const");
|
|
10
10
|
const const_2 = require("./const");
|
|
@@ -29,7 +29,7 @@ const adminApis_1 = require("./adminApis");
|
|
|
29
29
|
const zlib_1 = require("zlib");
|
|
30
30
|
const listen_1 = require("./listen");
|
|
31
31
|
const config_1 = require("./config");
|
|
32
|
-
const
|
|
32
|
+
const errorPages_1 = require("./errorPages");
|
|
33
33
|
const forceHttps = (0, config_1.defineConfig)('force_https', true);
|
|
34
34
|
const ignoreProxies = (0, config_1.defineConfig)('ignore_proxies', false);
|
|
35
35
|
exports.sessionDuration = (0, config_1.defineConfig)('session_duration', Number(process.env.SESSION_DURATION) || misc_1.DAY / 1000, v => v * 1000);
|
|
@@ -86,13 +86,13 @@ const serveGuiAndSharedFiles = async (ctx, next) => {
|
|
|
86
86
|
return ctx.redirect(ctx.state.revProxyPath + const_1.ADMIN_URI);
|
|
87
87
|
if (path.startsWith(const_1.ADMIN_URI))
|
|
88
88
|
return (0, adminApis_1.allowAdmin)(ctx) ? serveAdminPrefixed(ctx, next)
|
|
89
|
-
: sendErrorPage(ctx, const_1.HTTP_FORBIDDEN);
|
|
89
|
+
: (0, errorPages_1.sendErrorPage)(ctx, const_1.HTTP_FORBIDDEN);
|
|
90
90
|
if (ctx.method === 'PUT') { // curl -T file url/
|
|
91
91
|
const decPath = decodeURI(path);
|
|
92
92
|
let rest = (0, path_1.basename)(decPath);
|
|
93
93
|
const folder = await (0, vfs_1.urlToNode)((0, path_1.dirname)(decPath), ctx, vfs_1.vfs, v => rest = v + '/' + rest);
|
|
94
94
|
if (!folder)
|
|
95
|
-
return sendErrorPage(ctx, const_1.HTTP_NOT_FOUND);
|
|
95
|
+
return (0, errorPages_1.sendErrorPage)(ctx, const_1.HTTP_NOT_FOUND);
|
|
96
96
|
const dest = (0, upload_1.uploadWriter)(folder, rest, ctx);
|
|
97
97
|
if (dest) {
|
|
98
98
|
await (0, promises_1.pipeline)(ctx.req, dest);
|
|
@@ -104,7 +104,7 @@ const serveGuiAndSharedFiles = async (ctx, next) => {
|
|
|
104
104
|
return (0, serveFile_1.serveFile)(ctx, adminApis_1.favicon.get());
|
|
105
105
|
let node = await (0, vfs_1.urlToNode)(path, ctx);
|
|
106
106
|
if (!node)
|
|
107
|
-
return sendErrorPage(ctx, const_1.HTTP_NOT_FOUND);
|
|
107
|
+
return (0, errorPages_1.sendErrorPage)(ctx, const_1.HTTP_NOT_FOUND);
|
|
108
108
|
if (ctx.method === 'POST') { // curl -F upload=@file url/
|
|
109
109
|
if (ctx.request.type !== 'multipart/form-data')
|
|
110
110
|
return ctx.status = const_1.HTTP_BAD_REQUEST;
|
|
@@ -124,7 +124,7 @@ const serveGuiAndSharedFiles = async (ctx, next) => {
|
|
|
124
124
|
if (node.default && path.endsWith('/')) // final/ needed on browser to make resource urls correctly with html pages
|
|
125
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 ? sendErrorPage(ctx, const_1.HTTP_METHOD_NOT_ALLOWED)
|
|
127
|
+
return !node.source ? (0, errorPages_1.sendErrorPage)(ctx, const_1.HTTP_METHOD_NOT_ALLOWED)
|
|
128
128
|
: !(0, vfs_1.statusCodeForMissingPerm)(node, 'can_read', ctx) ? (0, serveFile_1.serveFileNode)(ctx, node)
|
|
129
129
|
: ctx.status !== const_1.HTTP_UNAUTHORIZED ? null
|
|
130
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...
|
|
@@ -133,7 +133,7 @@ const serveGuiAndSharedFiles = async (ctx, next) => {
|
|
|
133
133
|
return ctx.redirect(ctx.state.revProxyPath + ctx.originalUrl.replace(/(\?|$)/, '/$1')); // keep query-string, if any
|
|
134
134
|
if ((0, vfs_1.statusCodeForMissingPerm)(node, 'can_list', ctx)) {
|
|
135
135
|
if (ctx.status === const_1.HTTP_FORBIDDEN)
|
|
136
|
-
return sendErrorPage(ctx, const_1.HTTP_FORBIDDEN);
|
|
136
|
+
return (0, errorPages_1.sendErrorPage)(ctx, const_1.HTTP_FORBIDDEN);
|
|
137
137
|
const browserDetected = ctx.get('Upgrade-Insecure-Requests') || ctx.get('Sec-Fetch-Mode'); // ugh, heuristics
|
|
138
138
|
if (!browserDetected) // we don't want to trigger basic authentication on browsers, it's meant for download managers only
|
|
139
139
|
return ctx.set('WWW-Authenticate', 'Basic'); // we support basic authentication
|
|
@@ -147,26 +147,6 @@ const serveGuiAndSharedFiles = async (ctx, next) => {
|
|
|
147
147
|
};
|
|
148
148
|
exports.serveGuiAndSharedFiles = serveGuiAndSharedFiles;
|
|
149
149
|
// to be used with errors whose recipient is possibly human
|
|
150
|
-
async function sendErrorPage(ctx, code) {
|
|
151
|
-
var _a;
|
|
152
|
-
ctx.status = code;
|
|
153
|
-
const msg = errorMessages[ctx.status];
|
|
154
|
-
if (!msg)
|
|
155
|
-
return;
|
|
156
|
-
const lang = await (0, lang_1.getLangData)(ctx);
|
|
157
|
-
if (!lang)
|
|
158
|
-
return;
|
|
159
|
-
const trans = (_a = Object.values(lang)[0]) === null || _a === void 0 ? void 0 : _a.translate;
|
|
160
|
-
if (!trans)
|
|
161
|
-
return;
|
|
162
|
-
ctx.body = trans[msg];
|
|
163
|
-
}
|
|
164
|
-
exports.sendErrorPage = sendErrorPage;
|
|
165
|
-
const errorMessages = {
|
|
166
|
-
[const_1.HTTP_NOT_FOUND]: "Not found",
|
|
167
|
-
[const_1.HTTP_UNAUTHORIZED]: "Unauthorized",
|
|
168
|
-
[const_1.HTTP_FORBIDDEN]: "Forbidden",
|
|
169
|
-
};
|
|
170
150
|
async function sendFolderList(node, ctx) {
|
|
171
151
|
let { depth = 0, folders, prepend } = ctx.query;
|
|
172
152
|
ctx.type = 'text';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@charset "UTF-8";:root{height:100dvh;--bg: #fff;--text: #555;--ghost-contrast: #8882;--ghost-contrast-alt: #eee;--faint-contrast: #8884;--mild-contrast: #8886;--good-contrast: #000a;--button-bg: #6080aa;--button-text: #eaeaea;--focus-color: #468;--separator: " – "}:root .highlightedText,:root .file-menu a:hover{color:#0006;text-shadow:0 0 3px rgba(0,0,0,.4)}:root .theme-dark{--bg: #000;--text: #999;--ghost-contrast-alt: #181818;--good-contrast: #fffa;--button-bg: #345;--button-text: #999;color-scheme:dark}:root .theme-dark .highlightedText,:root .theme-dark .file-menu a:hover,:root .file-menu .theme-dark a:hover{color:#fff;text-shadow:0 0 3px #fff}:root .theme-dark a{color:#8ac}:root .theme-dark .dialog-closer{background:#633}:root .theme-dark .dialog-icon{color:#ccc}:root .theme-dark .dialog-icon .icon{color:#aaa}:root .theme-dark .dialog-backdrop{background:rgba(51,51,51,.7333333333)}:root .theme-dark .error-msg{color:#b88;background-color:#623}:root .theme-dark button.toggled{color:#eee}body{background-color:var(--bg);margin:0;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}body,button,select,input{font-size:12pt}#root>div{max-width:54em;margin:auto;min-height:100vh;display:flex;flex-direction:column}body,input{color:var(--text)}code{font-family:source-code-pro,Menlo,Monaco,Consolas,Courier New,monospace}input:not([type=checkbox],[type=range]),select,textarea{padding:.3em .4em;border-radius:.5em;background:var(--bg);border-color:var(--mild-contrast);color:var(--good-contrast);max-width:100%;box-sizing:border-box;width:100%}input[type=range]{width:calc(100% - 1px)}input[type=checkbox]{transform:scale(1.7);accent-color:var(--button-bg)}textarea{font-size:14pt}label input[type=checkbox]{margin-right:.8em}select{text-align:center}.hidden{display:none!important}[class^=fa-]:before,[class*=" fa-"]:before{margin:0}.icon{font-size:1.2em;height:1.2em;width:1.4em;display:inline-block;text-align:center}img.file-icon{height:1em}.file-icon{background-size:contain;background-repeat:no-repeat;background-position:center;vertical-align:text-bottom}.icon.mirror:before{transform:scaleX(-1)}a{text-decoration:none;color:var(--button-bg)}button{background-color:var(--button-bg);color:var(--button-text);padding:.5em 1em;border:transparent;text-decoration:none;border-radius:.3em;vertical-align:middle;cursor:pointer;transition:background-color .5s}button:hover{outline:1px solid var(--mild-contrast)}button[disabled]{background-color:var(--faint-contrast)}button.toggled{color:#fff;text-shadow:0 0 3px #fff}button:focus-visible,.breadcrumb:focus-visible{outline:3px solid var(--focus-color)}a>button{width:100%}input:focus-visible,select:focus-visible,ul a:focus-visible{border-radius:.3em;border-color:transparent;outline:2px solid var(--focus-color)}.icon-button,ul.dir li .entry-panel .file-menu-button{font-size:.7em;padding:.2em .4em;margin-left:.4em;vertical-align:bottom}.error-msg{background-color:#faa;color:#833;padding:.5em 1em}.hide-back,.upload-toolbar,header{background-color:var(--bg)}header{position:sticky;top:0;padding:.2em .1em;z-index:3}kbd{background-color:#eee;border-radius:3px;border:1px solid #b4b4b4;box-shadow:0 1px 1px #0003,0 2px #ffffffb3 inset;color:#333;display:inline-block;font-size:.85em;font-weight:700;line-height:1;padding:2px 4px;white-space:nowrap;margin-right:.5em}.before-sliding{width:0!important;flex:0!important;margin:0!important;height:0!important;padding:0!important;overflow:hidden!important;transition:flex .5s}.show-sliding{transition:flex .5s;overflow:clip;flex:1;white-space:nowrap}.ani-working{animation:1s blink infinite}@keyframes blink{0%{opacity:1}50%{opacity:.2}}@keyframes spin{to{transform:rotate(360deg)}}@keyframes fade-in{0%{opacity:0}to{opacity:1}}.spinner,.icon.spinner:before{animation:1.5s spin infinite linear;display:inline-flex;justify-content:center;align-items:center;width:min-content}.breadcrumb{padding:.1em .6em .2em;line-height:1.8em;border-radius:.7em;background-color:var(--button-bg);color:var(--button-text);border-top:1px solid #666;margin-right:-.1em}.breadcrumb:nth-child(-n+3) .icon{padding:0 .2em}#folder-stats,#filter-bar>span{font-size:90%}#folder-stats{margin:.5em 0 0 .5em;float:right}#folder-stats .icon{margin-right:.3em}#filter{flex:1;box-sizing:border-box}#filter-bar{display:flex;align-items:center;gap:.8em;margin:.2em 0 0;padding:2px 0 1px 3px;height:1.8em}#filter-bar input[type=checkbox]{margin-top:.3em}#filter-bar span:empty{display:none}ul.dir{flex:1;padding:0;margin:0;clear:both}ul.dir>p{text-align:center}ul.dir li{display:block;list-style-type:none;padding:.3em .3em .4em;border-bottom:1px solid var(--faint-contrast)}ul.dir li:nth-of-type(odd){background-color:var(--ghost-contrast)}ul.dir li input[type=checkbox]{margin-right:1em}@media (hover: none){ul.dir li .link-wrapper .popup-menu-button{display:none}}@media (hover: hover){ul.dir li .link-wrapper:not(:hover) .popup-menu-button{display:none}ul.dir li .link-wrapper:hover{padding:1em;margin:-1em}}ul.dir li .link-wrapper a:last-of-type{word-break:break-word;padding-right:.3em}ul.dir li .link-wrapper a .icon{margin-right:.5em;vertical-align:text-bottom;display:inline-block;text-align:center}ul.dir li .link-wrapper a:hover{text-decoration:underline}ul.dir li .entry-panel{float:right;padding-top:.3em;display:flex;align-items:center}ul.dir li .entry-panel .file-menu-button{margin:-3px 0 -3px .4em}ul.dir li .entry-panel .entry-details{font-size:90%;margin-left:4px;font-variant-numeric:tabular-nums}ul.dir li .entry-panel .entry-details .entry-size-unit{margin-left:.3em}ul.dir li>div:last-of-type{clear:both}ul.dir li.page-separator{margin-top:1em;position:relative}ul.dir li.page-separator:before{content:attr(label);position:absolute;top:-1.8em;font-size:smaller;margin-left:calc(50% - 1em);opacity:.9}.entry-comment{display:inline;white-space:pre-wrap;word-break:break-word}.entry-comment:before,.entry-comment:after{font-size:1.5em;font-family:serif;line-height:1px;position:relative}.entry-comment:before{content:"“";margin-left:.5em;margin-right:.1em;top:.2em}.entry-comment:after{content:"„";top:-.1em;margin-left:.1em}#menu-bar{display:flex;justify-content:space-evenly;flex-wrap:wrap}#menu-bar>*{flex:1;margin:.1em}#menu-bar>*:first-child{margin-left:0}#menu-bar>*:last-child{margin-right:0}#menu-bar button{padding:min(1vh,.5em) 0}#searched{margin:.2em}#user-panel{display:flex;flex-direction:column;gap:1em}#user-panel a>button{width:100%}button label{cursor:inherit;margin-left:.4em}.dialog-backdrop.working{font-size:5em;animation:1s fade-in}.dialog-content{padding:.2em}.dialog-alert .dialog-content{text-align:center}.dialog-alert .dialog-content p{text-align:left;display:inline-block}.dialog{min-width:11em;--color: var(--button-bg)}.dialog-icon .icon{margin-left:-1px;font-size:95%;margin-top:.4em;border-radius:.6em 0}#paging{position:sticky;bottom:0;display:flex;gap:.1em;background-color:var(--bg);padding:0 .2em .2em}#paging>button{z-index:1}#paging button{box-shadow:0 0 .3em .3em #0003}#paging #paging-middle{padding:0 .5em;margin:0 -.3em;display:flex;gap:.5em;flex:1;overflow-x:auto}#paging #paging-middle>button{flex:1;padding-top:0;padding-bottom:0}#paging button{background:var(--button-bg);text-align:center;white-space:nowrap;padding:.5em}.upload-toolbar{position:sticky;top:-4px}.upload-progress:before{content:var(--separator)}.entry-size:after{content:var(--separator)}.upload-progress{min-width:4em;display:inline-block;margin-left:.5em}.upload-list{margin-top:1em}.upload-list td:nth-child(1){width:0}.upload-list td:nth-child(2){text-align:right;width:0;white-space:nowrap;padding-left:.5em}.upload-list td:nth-child(3){padding:.2em .5em;word-break:break-word}.nowrap{white-space:nowrap}.dialog-login form{display:flex;flex-direction:column;gap:1.2em}.dialog-login label{display:block;margin-bottom:.5em;margin-left:.1em}.miss-perm{margin:.3em}.popup-menu-button{font-size:.8em;padding:.2em .3em;position:absolute;opacity:.8;white-space:nowrap}.popup-menu-button:hover{opacity:1}.file-dialog .dialog{min-width:13em}.file-dialog-properties{word-break:break-word;line-height:1.5em;margin:0}.file-dialog-properties dt{font-weight:700}.file-dialog-properties dd{margin-left:1.5em}.file-menu{margin-top:1em;padding-top:1em;border-top:1px solid var(--faint-contrast);display:flex;flex-direction:column;gap:1em}.file-menu a{display:flex;align-items:flex-start}.file-menu a label{margin-top:.1em}.file-menu a label small{display:block}.file-menu a .icon{margin-right:.5em}#root>.tiles-mode{max-width:none;margin:0 1em;--tiles-size: 5;--name-lines: 3;--name-height: calc(4.7em + var(--tiles-size) * .4em + 1.2em * var(--name-lines));--tile-width: calc(5em + 1em * var(--tiles-size))}#root>.tiles-mode ul.dir{display:grid;grid-template-columns:repeat(auto-fill,minmax(var(--tile-width),1fr));grid-auto-rows:calc(var(--name-height) + 1.3em);gap:0 20px}#root>.tiles-mode ul.dir li{text-align:center;position:relative;display:flex;flex-direction:column;border-bottom:none;overflow-x:clip;padding:.5em 0 0}#root>.tiles-mode ul.dir li .link-wrapper:not(:hover){max-height:var(--name-height);display:block;display:-webkit-box;overflow:hidden;-webkit-line-clamp:calc(var(--name-lines) + 1);-webkit-box-orient:vertical}#root>.tiles-mode ul.dir li .link-wrapper a:last-of-type{padding:0}#root>.tiles-mode ul.dir li .link-wrapper a span{display:block}#root>.tiles-mode ul.dir li .link-wrapper a .icon.icon{font-size:calc(1.2rem + .6rem * var(--tiles-size))}#root>.tiles-mode ul.dir li .link-wrapper a img.icon{width:auto;height:1em;padding:.1em 0}#root>.tiles-mode ul.dir li .link-wrapper a .icon{font-size:4rem;display:block;margin:auto}#root>.tiles-mode ul.dir li .link-wrapper:hover{overflow:visible;display:block;z-index:1}#root>.tiles-mode ul.dir li .link-wrapper:hover .icon:before{text-decoration:none}#root>.tiles-mode ul.dir li .link-wrapper:hover{padding:0;margin:0}#root>.tiles-mode ul.dir li:nth-of-type(odd){background-color:var(--bg)}#root>.tiles-mode ul.dir li .entry-panel{justify-content:center;font-size:10pt}#root>.tiles-mode ul.dir li .entry-details{font-size:80%}#root>.tiles-mode ul.dir li.page-separator:before{content:""}#root>.tiles-mode ul.dir li input[type=checkbox]{margin:0;position:absolute;top:.3em;right:1em}#root>.tiles-mode ul.dir li .link-wrapper a{display:inline}#root>.tiles-mode ul.dir li:hover{--bg: var(--ghost-contrast-alt);background:var(--bg)}#root>.tiles-mode ul.dir li:hover .link-wrapper,#root>.tiles-mode ul.dir li:hover .entry-panel{z-index:1;background:var(--bg)}#root>.tiles-mode ul.dir li:hover input[type=checkbox]{z-index:2}#root>.tiles-mode ul.dir li:hover .entry-panel{padding-bottom:.3em}#root>.tiles-mode .entry-size:after{content:none}#root>.tiles-mode .entry-ts{display:none}#root>.tiles-mode .popup-menu-button{position:absolute;top:0;left:0}#root>.tiles-mode #filter-bar{margin-bottom:1em}#root>.tiles-mode #paging{z-index:1}#root .file-show{--nav-size: min(25vh, 25vw)}#root .file-show>div{height:100%;width:100%}#root .file-show .showing-container{width:100%;height:100%;display:flex;justify-content:center;align-items:center}#root .file-show .showing{max-width:calc(100% - var(--nav-size) * 2);max-height:100%}#root .file-show img.showing{max-width:100%}#root .file-show .main{flex:1;position:relative;max-height:100%;overflow:hidden}#root .file-show .freeY .main,#root .file-show .fullWidth .main{overflow-y:auto}#root .file-show .freeY .showing,#root .file-show .fullWidth .showing{max-height:initial;margin:auto}#root .file-show .freeY .showing-container,#root .file-show .fullWidth .showing-container{overflow:auto;align-items:flex-start}#root .file-show .fullWidth .showing-container,#root .file-show .fullWidth .showing{width:100%}#root .file-show .nav{position:absolute;margin:-.4em;font-size:var(--nav-size);cursor:pointer;opacity:.3;-webkit-text-stroke:2px black;user-select:none;transition:opacity .3s}#root .file-show .nav:hover{opacity:.7}#root .file-show .nav.nav-hidden{opacity:0}#root .file-show .bar{padding:.5em 1em;background:var(--bg);opacity:.8;display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:.5em 1.5em}#root .file-show .bar .entry-details{font-size:smaller}#root .file-show .bar .entry-ts{display:inherit}#root .file-show .bar .entry-size:after{display:none}.file-show-help kbd{margin:.5em}.file-show-help kbd:first-of-type{margin-top:1em}@media (min-width: 42em){body{scrollbar-width:thin;scrollbar-color:var(--button-bg) var(--ghost-contrast)}body::-webkit-scrollbar{width:12px}body::-webkit-scrollbar-track{background:var(--ghost-contrast)}body::-webkit-scrollbar-thumb{background-color:var(--button-bg);border-radius:20px;border:1px solid var(--ghost-contrast)}}@media (max-width: 42em){:root{--ghost-contrast: #8883}body,button,select{font-size:14pt}#menu-bar button label,#filter-bar button label{display:none}#filter-bar{margin-top:.4em}#filter-bar button{width:17.6vw;height:2.3em}.breadcrumb{word-break:break-all}.breadcrumb .icon{font-size:24px}#root>.tiles-mode{margin:0}}@media (max-height: 600px){.file-dialog .dialog-content{display:flex;gap:3em;margin:1em}.file-dialog .dialog-content .file-menu{margin-top:0;padding-top:0;border-top:none;margin-left:2em;padding-left:2em;border-left:1px solid var(--faint-contrast)}}@media (pointer: coarse){#root>.tiles-mode .file-menu-button{font-size:1em;margin-top:.3em}}.dialog-backdrop{position:fixed;inset:0;background:#8886;backdrop-filter:blur(2px);display:flex;justify-content:center;align-items:center;z-index:1000}.dialog{background:#fff;background:var(--bg);padding:max(.5em,1vw,2vh);padding-top:0;border-radius:1em;position:relative;margin:0 3vw;overflow:hidden;max-height:calc(100vh - 2em);display:flex;flex-direction:column;justify-content:center}.dialog-icon{color:#fff;background-color:var(--color);position:absolute;top:0;width:2em;height:1.8em;text-align:center;border-radius:.8em 0}.dialog-icon-text{display:flex;align-items:center;justify-content:center}.dialog-title{font-size:120%;margin:.3em 0;padding:0 .5em;min-height:1.2em}.dialog-closer~.dialog-title{margin-right:2em}.dialog-type~.dialog-title{margin-left:2em}.dialog-icon~.dialog-title{text-align:center}.dialog-closer{border-radius:0 .8em;right:0;padding:0;background-color:#c88}.dialog-icon~.dialog-content{margin-top:1em}.dialog-type{left:0;top:0;overflow:hidden;opacity:.7}.dialog-content{overflow:auto;max-height:calc(100vh - 4.5em)}.dialog-content p{white-space:pre-wrap;margin:.5em 0}.dialog-confirm .dialog-content button{margin-top:1em}.dialog-alert-info{--color: #282 }.dialog-alert-warning{--color: #c91 }.dialog-alert-error{--color: #822}@media (max-width: 42em){.dialog-icon{font-size:120%}.dialog-icon~.dialog-content{margin-top:1.5em}}.dialog-prompt label{display:block;margin:.5em .1em}
|