hfs 0.45.0-alpha7 → 0.45.0-beta11
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/README.md +1 -1
- package/admin/assets/{index-6c8d0372.js → index-101f19c9.js} +91 -91
- package/admin/assets/{sha512-beb2ef44.js → sha512-c0389c0d.js} +1 -1
- package/admin/index.html +1 -1
- package/frontend/assets/{index-81e42239.js → index-103f8869.js} +20 -20
- package/frontend/assets/{sha512-eec686c3.js → sha512-d8147f4f.js} +1 -1
- package/frontend/index.html +1 -1
- package/package.json +3 -3
- package/src/QuickZipStream.js +11 -6
- package/src/api.auth.js +1 -1
- package/src/commands.js +2 -4
- package/src/config.js +84 -57
- package/src/const.js +2 -3
- package/src/index.js +1 -1
- package/src/langs/embedded.js +2 -1
- package/src/langs/hfs-lang-fr.json +41 -41
- package/src/langs/hfs-lang-it.json +3 -1
- package/src/langs/hfs-lang-pt.json +109 -0
- package/src/listen.js +1 -1
- package/src/log.js +1 -1
- package/src/middlewares.js +38 -6
- package/src/perm.js +1 -1
- package/src/upload.js +2 -0
- package/src/zip.js +8 -2
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": "OgamiWK",
|
|
3
|
+
"version": 1.0,
|
|
4
|
+
"hfs_version": "0.44.0",
|
|
5
|
+
"translate": {
|
|
6
|
+
"Select": "Selecionar",
|
|
7
|
+
"n_files": "{n,plural, one{# Arquivo} other{# Arquivos}}",
|
|
8
|
+
"n_folders": "{n,plural, one{# Pasta} other{# Pastas}}",
|
|
9
|
+
"filter_count": "{n,plural, one{# Filtrado} other{# Filtrados}}",
|
|
10
|
+
"select_count": "{n,plural, one{# Selecionado} other{# Selecionados}}",
|
|
11
|
+
"filter_placeholder": "Digite aqui para filtrar a lista abaixo.",
|
|
12
|
+
"Select some files": "Selecionar alguns arquivos",
|
|
13
|
+
"zip_checkboxes": "Use a caixa de seleção, então você poderá usar o zip novamente.",
|
|
14
|
+
"zip_tooltip_selected": "Baixar os arquivos selecionados como um zip unico.",
|
|
15
|
+
"zip_tooltip_whole": "Baixe a lista inteira (sem filtro) como um único arquivo zip. Se você selecionar alguns elementos, apenas esses serão baixados.",
|
|
16
|
+
"zip_confirm_search": "Baixar todos os resultados desta pesquisa como um arquivo zip?",
|
|
17
|
+
"zip_confirm_folder": "Baixar toda a pasta como zip?",
|
|
18
|
+
"select_tooltip": "A seleção se aplica a \"Zip\" e \"Delete\" (quando disponível), mas você também pode filtrar a lista",
|
|
19
|
+
"delete_hint": "Para deletar, primeiramente selecione",
|
|
20
|
+
"delete_confirm": "Excluir {n,plural, one{# item} other{# items}}?",
|
|
21
|
+
"delete_completed": "Excluir: {n} Completo",
|
|
22
|
+
"delete_failed": ", {n,plural, one{# Falhou} other{# Falharam}}",
|
|
23
|
+
"delete_select": "Selecione algo para excluir.",
|
|
24
|
+
"Delete": "Excluir",
|
|
25
|
+
"Options": "Opções",
|
|
26
|
+
"Search": "Pesquisar",
|
|
27
|
+
"Zip": "Zip",
|
|
28
|
+
"search_msg": "Pesquise nesta pasta e em suas sub-pastas",
|
|
29
|
+
"Searching": "Pesquisando...",
|
|
30
|
+
"Searched": "Encontrado",
|
|
31
|
+
"Clear search": "Limpar pesquisa",
|
|
32
|
+
"Interrupted": "Interrompido",
|
|
33
|
+
"stopped_before": "Parado antes",
|
|
34
|
+
"empty_list": "Lista Vazia",
|
|
35
|
+
"filter_none": "Nada Filtrado",
|
|
36
|
+
"Admin-panel": "Painel de Admin",
|
|
37
|
+
"Login": "Login",
|
|
38
|
+
"Username": "Usuario",
|
|
39
|
+
"Password": "Senha",
|
|
40
|
+
"login_untrusted": "Login Abortado: a identidade do servidor não é confiável!",
|
|
41
|
+
"login_bad_credentials": "Credenciais Invalidas!",
|
|
42
|
+
"login_bad_cookies": "Cookies não estão funcionando, Login Falhou!",
|
|
43
|
+
"User panel": "Painel do Usuario",
|
|
44
|
+
"Change password": "Trocar Senha",
|
|
45
|
+
"enter_pass": "Insira nova senha",
|
|
46
|
+
"enter_pass2": "Insira novamente a nova senha",
|
|
47
|
+
"pass2_mismatch": "A segunda senha digitada não corresponde à primeira. Procedimento abortado.",
|
|
48
|
+
"password_changed": "Senha Alterada!",
|
|
49
|
+
"Logout": "Sair",
|
|
50
|
+
"connection error": "Erro de conexão",
|
|
51
|
+
"Full timestamp:": "Tempo completo:",
|
|
52
|
+
"Search was interrupted": "A pesquisa foi interrompida!",
|
|
53
|
+
"Stop list": "Parar Lista",
|
|
54
|
+
"upload_starting": "Seu download irá começar agora",
|
|
55
|
+
"wrong_account": "A conta {u} não possui acesso, tente outra",
|
|
56
|
+
"no_upload_here": "Voce não tem permissão para fazer upload nesta pasta.",
|
|
57
|
+
"Create folder": "Criar Pasta",
|
|
58
|
+
"Pick files": "Escolher arquivos",
|
|
59
|
+
"Pick folder": "Escolher pasta",
|
|
60
|
+
"send_files": "Enviar {n,plural,one{# arquivo} other{# arquivos}}, {size}",
|
|
61
|
+
"Clear": "Limpar",
|
|
62
|
+
"failed_upload": "Não foi possivel enviar o arquivo {name}",
|
|
63
|
+
"confirm_resume": "Continuar o Envio?",
|
|
64
|
+
"file too large": "Arquivo muito grande",
|
|
65
|
+
"Enter folder name": "Insira o nome da pasta",
|
|
66
|
+
"Successfully created": "Criado com sucesso!",
|
|
67
|
+
"enter_folder": "Insira a pasta",
|
|
68
|
+
"folder_exists": "Uma pasta com o mesmo nome já existe",
|
|
69
|
+
"Sort by": "Classificar por",
|
|
70
|
+
"name": "nome",
|
|
71
|
+
"extension": "extensão",
|
|
72
|
+
"size": "tamanho",
|
|
73
|
+
"time": "tempo",
|
|
74
|
+
"Invert order": "Inverter ordem",
|
|
75
|
+
"Folders first": "Pastas primeiro",
|
|
76
|
+
"Numeric names": "Nomes numéricos",
|
|
77
|
+
"theme:": "Tema:",
|
|
78
|
+
"auto": "automatico",
|
|
79
|
+
"light": "Claro",
|
|
80
|
+
"dark": "Escuro",
|
|
81
|
+
"parent folder": "Pasta Inicial",
|
|
82
|
+
"home": "Inicio",
|
|
83
|
+
"Continue": "Continuar",
|
|
84
|
+
"Confirm": "Sim",
|
|
85
|
+
"Don't": "Não",
|
|
86
|
+
"Warning": "Aviso",
|
|
87
|
+
"Error": "Erro",
|
|
88
|
+
"Info": "Informação",
|
|
89
|
+
"Unauthorized": "Não autorizado",
|
|
90
|
+
"Forbidden": "Proibido",
|
|
91
|
+
"Not found": "Não encontrado",
|
|
92
|
+
"Server error": "Erro no servidor",
|
|
93
|
+
"Upload": "Enviar",
|
|
94
|
+
"upload_concluded": "Envio concluido em:",
|
|
95
|
+
"upload_finished": "{n} Finalizado ({size})",
|
|
96
|
+
"upload_errors": "{n} Falhou",
|
|
97
|
+
"upload_file_rejected": "Alguns arquivos não foram aceitos",
|
|
98
|
+
"download counter": "Contador de Downloads",
|
|
99
|
+
"File menu": "Menu de arquivos",
|
|
100
|
+
"Folder menu": "Menu de Pastas",
|
|
101
|
+
"Name": "Nome",
|
|
102
|
+
"file_open": "Abrir",
|
|
103
|
+
"Download": "Baixar",
|
|
104
|
+
"Missing permission": "Permissão perdida",
|
|
105
|
+
"Reload": "Recarregar",
|
|
106
|
+
"Get list": "Obter a Lista",
|
|
107
|
+
"Skip existing files": "Ignorando arquivos existentes"
|
|
108
|
+
}
|
|
109
|
+
}
|
package/src/listen.js
CHANGED
|
@@ -65,7 +65,7 @@ exports.portCfg.sub(async (port) => {
|
|
|
65
65
|
});
|
|
66
66
|
function openAdmin() {
|
|
67
67
|
for (const srv of [httpSrv, httpsSrv]) {
|
|
68
|
-
const a = srv.address();
|
|
68
|
+
const a = srv === null || srv === void 0 ? void 0 : srv.address();
|
|
69
69
|
if (!a || typeof a === 'string')
|
|
70
70
|
continue;
|
|
71
71
|
const baseUrl = srv.name + '://localhost:' + a.port;
|
package/src/log.js
CHANGED
|
@@ -79,7 +79,7 @@ errorLogFile.sub(path => {
|
|
|
79
79
|
accessErrorLog.setPath(path);
|
|
80
80
|
});
|
|
81
81
|
const logRotation = (0, config_1.defineConfig)('log_rotation', 'weekly');
|
|
82
|
-
const dontLogNet = (0, config_1.defineConfig)('dont_log_net', '127.0.0.1|::1', misc_1.makeNetMatcher);
|
|
82
|
+
const dontLogNet = (0, config_1.defineConfig)('dont_log_net', '127.0.0.1|::1', v => (0, misc_1.makeNetMatcher)(v));
|
|
83
83
|
function log() {
|
|
84
84
|
const debounce = lodash_1.default.debounce(cb => cb(), 1000);
|
|
85
85
|
return async (ctx, next) => {
|
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.serveGuiAndSharedFiles = exports.headRequests = exports.gzipper = void 0;
|
|
7
|
+
exports.paramsDecoder = exports.prepareState = exports.getProxyDetected = exports.someSecurity = exports.sendErrorPage = 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,8 +29,10 @@ 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 lang_1 = require("./lang");
|
|
32
33
|
const forceHttps = (0, config_1.defineConfig)('force_https', true);
|
|
33
34
|
const ignoreProxies = (0, config_1.defineConfig)('ignore_proxies', false);
|
|
35
|
+
exports.sessionDuration = (0, config_1.defineConfig)('session_duration', Number(process.env.SESSION_DURATION) || const_1.DAY / 1000, v => v * 1000);
|
|
34
36
|
exports.gzipper = (0, koa_compress_1.default)({
|
|
35
37
|
threshold: 2048,
|
|
36
38
|
gzip: { flush: zlib_1.constants.Z_SYNC_FLUSH },
|
|
@@ -83,13 +85,13 @@ const serveGuiAndSharedFiles = async (ctx, next) => {
|
|
|
83
85
|
return ctx.redirect(ctx.state.revProxyPath + const_1.ADMIN_URI);
|
|
84
86
|
if (path.startsWith(const_1.ADMIN_URI))
|
|
85
87
|
return (0, adminApis_1.allowAdmin)(ctx) ? serveAdminPrefixed(ctx, next)
|
|
86
|
-
: (ctx
|
|
88
|
+
: sendErrorPage(ctx, const_1.HTTP_FORBIDDEN);
|
|
87
89
|
if (ctx.method === 'PUT') { // curl -T file url/
|
|
88
90
|
const decPath = decodeURI(path);
|
|
89
91
|
let rest = (0, path_1.basename)(decPath);
|
|
90
92
|
const folder = await (0, vfs_1.urlToNode)((0, path_1.dirname)(decPath), ctx, vfs_1.vfs, v => rest = v + '/' + rest);
|
|
91
93
|
if (!folder)
|
|
92
|
-
return ctx
|
|
94
|
+
return sendErrorPage(ctx, const_1.HTTP_NOT_FOUND);
|
|
93
95
|
const dest = (0, upload_1.uploadWriter)(folder, rest, ctx);
|
|
94
96
|
if (dest) {
|
|
95
97
|
await (0, promises_1.pipeline)(ctx.req, dest);
|
|
@@ -103,7 +105,7 @@ const serveGuiAndSharedFiles = async (ctx, next) => {
|
|
|
103
105
|
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
|
|
104
106
|
node = await (0, vfs_1.urlToNode)(node.default, ctx, node);
|
|
105
107
|
if (!node)
|
|
106
|
-
return ctx
|
|
108
|
+
return sendErrorPage(ctx, const_1.HTTP_NOT_FOUND);
|
|
107
109
|
if (ctx.method === 'POST') { // curl -F upload=@file url/
|
|
108
110
|
ctx.body = {};
|
|
109
111
|
const form = (0, formidable_1.default)({
|
|
@@ -123,7 +125,7 @@ const serveGuiAndSharedFiles = async (ctx, next) => {
|
|
|
123
125
|
return ctx.redirect(ctx.state.revProxyPath + ctx.originalUrl.replace(/(\?|$)/, '/$1')); // keep query-string, if any
|
|
124
126
|
if ((0, vfs_1.statusCodeForMissingPerm)(node, 'can_list', ctx)) {
|
|
125
127
|
if (ctx.status === const_1.HTTP_FORBIDDEN)
|
|
126
|
-
return;
|
|
128
|
+
return sendErrorPage(ctx, const_1.HTTP_FORBIDDEN);
|
|
127
129
|
const browserDetected = ctx.get('Upgrade-Insecure-Requests') || ctx.get('Sec-Fetch-Mode'); // ugh, heuristics
|
|
128
130
|
if (!browserDetected) // we don't want to trigger basic authentication on browsers, it's meant for download managers only
|
|
129
131
|
return ctx.set('WWW-Authenticate', 'Basic'); // we support basic authentication
|
|
@@ -136,9 +138,37 @@ const serveGuiAndSharedFiles = async (ctx, next) => {
|
|
|
136
138
|
: serveFrontendFiles(ctx, next);
|
|
137
139
|
};
|
|
138
140
|
exports.serveGuiAndSharedFiles = serveGuiAndSharedFiles;
|
|
141
|
+
// to be used with errors whose recipient is possibly human
|
|
142
|
+
async function sendErrorPage(ctx, code) {
|
|
143
|
+
var _a;
|
|
144
|
+
ctx.status = code;
|
|
145
|
+
const msg = errorMessages[ctx.status];
|
|
146
|
+
if (!msg)
|
|
147
|
+
return;
|
|
148
|
+
const lang = await (0, lang_1.getLangData)(ctx);
|
|
149
|
+
if (!lang)
|
|
150
|
+
return;
|
|
151
|
+
const trans = (_a = Object.values(lang)[0]) === null || _a === void 0 ? void 0 : _a.translate;
|
|
152
|
+
if (!trans)
|
|
153
|
+
return;
|
|
154
|
+
ctx.body = trans[msg];
|
|
155
|
+
}
|
|
156
|
+
exports.sendErrorPage = sendErrorPage;
|
|
157
|
+
const errorMessages = {
|
|
158
|
+
[const_1.HTTP_NOT_FOUND]: "Not found",
|
|
159
|
+
[const_1.HTTP_UNAUTHORIZED]: "Unauthorized",
|
|
160
|
+
[const_1.HTTP_FORBIDDEN]: "Forbidden",
|
|
161
|
+
};
|
|
162
|
+
const baseUrl = (0, config_1.defineConfig)('base_url', '');
|
|
139
163
|
async function sendFolderList(node, ctx) {
|
|
140
|
-
|
|
164
|
+
let { depth = 0, folders, prepend } = ctx.query;
|
|
141
165
|
ctx.type = 'text';
|
|
166
|
+
if (prepend === undefined || prepend === '*') { // * = force auto-detection even if we have baseUrl set
|
|
167
|
+
const { URL } = ctx;
|
|
168
|
+
const base = prepend === undefined && baseUrl.get()
|
|
169
|
+
|| URL.protocol + '//' + URL.host + ctx.state.revProxyPath;
|
|
170
|
+
prepend = base + ctx.originalUrl.split('?')[0];
|
|
171
|
+
}
|
|
142
172
|
const walker = (0, vfs_1.walkNode)(node, ctx, depth === '*' ? Infinity : Number(depth));
|
|
143
173
|
ctx.body = (0, misc_1.asyncGeneratorToReadable)((0, misc_1.filterMapGenerator)(walker, async (el) => {
|
|
144
174
|
const isFolder = await (0, vfs_1.nodeIsDirectory)(el);
|
|
@@ -177,6 +207,8 @@ function getProxyDetected() {
|
|
|
177
207
|
exports.getProxyDetected = getProxyDetected;
|
|
178
208
|
const prepareState = async (ctx, next) => {
|
|
179
209
|
var _a, _b;
|
|
210
|
+
if (ctx.session)
|
|
211
|
+
ctx.session.maxAge = exports.sessionDuration.compiled();
|
|
180
212
|
// calculate these once and for all
|
|
181
213
|
ctx.state.account = (_a = await getHttpAccount(ctx)) !== null && _a !== void 0 ? _a : (0, perm_1.getAccount)((_b = ctx.session) === null || _b === void 0 ? void 0 : _b.username, false);
|
|
182
214
|
const conn = ctx.state.connection = (0, connections_1.socket2connection)(ctx.socket);
|
package/src/perm.js
CHANGED
|
@@ -72,7 +72,7 @@ async function updateAccount(account, changer) {
|
|
|
72
72
|
saveAccountsAsap();
|
|
73
73
|
}
|
|
74
74
|
exports.updateAccount = updateAccount;
|
|
75
|
-
const saveAccountsAsap =
|
|
75
|
+
const saveAccountsAsap = config_1.saveConfigAsap;
|
|
76
76
|
exports.accountsConfig = (0, config_1.defineConfig)('accounts', {});
|
|
77
77
|
exports.accountsConfig.sub(obj => {
|
|
78
78
|
// consider some validation here
|
package/src/upload.js
CHANGED
|
@@ -37,6 +37,8 @@ function uploadWriter(base, path, ctx) {
|
|
|
37
37
|
catch (e) {
|
|
38
38
|
console.warn("can't check disk size:", e.message || String(e));
|
|
39
39
|
}
|
|
40
|
+
if (ctx.query.skipExisting && fs_1.default.existsSync(fullPath))
|
|
41
|
+
return fail(const_1.HTTP_CONFLICT);
|
|
40
42
|
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
41
43
|
const keepName = (0, path_1.basename)(fullPath).slice(-200);
|
|
42
44
|
let tempName = (0, path_1.join)(dir, 'hfs$upload-' + keepName);
|
package/src/zip.js
CHANGED
|
@@ -31,8 +31,10 @@ async function zipStreamFromFolder(node, ctx) {
|
|
|
31
31
|
if (!subNode)
|
|
32
32
|
continue;
|
|
33
33
|
if (await (0, vfs_1.nodeIsDirectory)(subNode)) { // a directory needs to walked
|
|
34
|
-
if ((0, vfs_1.hasPermission)(subNode, 'can_list', ctx))
|
|
34
|
+
if ((0, vfs_1.hasPermission)(subNode, 'can_list', ctx)) {
|
|
35
|
+
yield subNode; // it could be empty
|
|
35
36
|
yield* (0, vfs_1.walkNode)(subNode, ctx, Infinity, uri + '/', 'can_read');
|
|
37
|
+
}
|
|
36
38
|
continue;
|
|
37
39
|
}
|
|
38
40
|
let folder = (0, path_1.dirname)(decodeURIComponent(uri)); // decodeURI() won't account for %23=#
|
|
@@ -45,9 +47,13 @@ async function zipStreamFromFolder(node, ctx) {
|
|
|
45
47
|
return; // the fact you see it doesn't mean you can read it
|
|
46
48
|
const { source } = el;
|
|
47
49
|
const name = (0, vfs_1.getNodeName)(el);
|
|
48
|
-
if (
|
|
50
|
+
if (ctx.req.aborted || !filter(name))
|
|
49
51
|
return;
|
|
50
52
|
try {
|
|
53
|
+
if (el.isFolder)
|
|
54
|
+
return { path: name + '/' };
|
|
55
|
+
if (!source)
|
|
56
|
+
return;
|
|
51
57
|
const st = await promises_1.default.stat(source);
|
|
52
58
|
if (!st || !st.isFile())
|
|
53
59
|
return;
|