mirror of
https://gitlab.com/timvisee/send.git
synced 2025-12-06 22:20:55 +03:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d039c38f00 | ||
|
|
81f3347981 | ||
|
|
b96d2949f7 | ||
|
|
a2e745a349 | ||
|
|
0fe02b18ce | ||
|
|
655eb8c253 | ||
|
|
d9356f8171 | ||
|
|
be7d23163c | ||
|
|
7ac2e57484 | ||
|
|
727ea1283a | ||
|
|
3314057059 |
@@ -12,6 +12,33 @@ async function getAuthHeader(authKey, nonce) {
|
||||
return `send-v1 ${arrayToB64(new Uint8Array(sig))}`;
|
||||
}
|
||||
|
||||
async function sendPassword(file, authKey, rawAuth) {
|
||||
const authHeader = await getAuthHeader(authKey, file.nonce);
|
||||
return new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = () => {
|
||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||||
if (xhr.status === 200) {
|
||||
return resolve(xhr.response);
|
||||
}
|
||||
if (xhr.status === 401) {
|
||||
const nonce = xhr.getResponseHeader('WWW-Authenticate').split(' ')[1];
|
||||
file.nonce = nonce;
|
||||
}
|
||||
reject(new Error(xhr.status));
|
||||
}
|
||||
};
|
||||
xhr.onerror = () => reject(new Error(0));
|
||||
xhr.ontimeout = () => reject(new Error(0));
|
||||
xhr.open('post', `/api/password/${file.id}`);
|
||||
xhr.setRequestHeader('Authorization', authHeader);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.responseType = 'json';
|
||||
xhr.timeout = 2000;
|
||||
xhr.send(JSON.stringify({ auth: arrayToB64(new Uint8Array(rawAuth)) }));
|
||||
});
|
||||
}
|
||||
|
||||
export default class FileSender extends Nanobus {
|
||||
constructor(file) {
|
||||
super('FileSender');
|
||||
@@ -259,7 +286,6 @@ export default class FileSender extends Nanobus {
|
||||
true,
|
||||
['sign']
|
||||
);
|
||||
const authHeader = await getAuthHeader(authKey, file.nonce);
|
||||
const pwdKey = await window.crypto.subtle.importKey(
|
||||
'raw',
|
||||
encoder.encode(password),
|
||||
@@ -283,30 +309,14 @@ export default class FileSender extends Nanobus {
|
||||
['sign']
|
||||
);
|
||||
const rawAuth = await window.crypto.subtle.exportKey('raw', newAuthKey);
|
||||
return new Promise((resolve, reject) => {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.onreadystatechange = () => {
|
||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
||||
if (xhr.status === 200) {
|
||||
return resolve(xhr.response);
|
||||
}
|
||||
if (xhr.status === 401) {
|
||||
const nonce = xhr
|
||||
.getResponseHeader('WWW-Authenticate')
|
||||
.split(' ')[1];
|
||||
file.nonce = nonce;
|
||||
}
|
||||
reject(new Error(xhr.status));
|
||||
}
|
||||
};
|
||||
xhr.onerror = () => reject(new Error(0));
|
||||
xhr.ontimeout = () => reject(new Error(0));
|
||||
xhr.open('post', `/api/password/${file.id}`);
|
||||
xhr.setRequestHeader('Authorization', authHeader);
|
||||
xhr.setRequestHeader('Content-Type', 'application/json');
|
||||
xhr.responseType = 'json';
|
||||
xhr.timeout = 2000;
|
||||
xhr.send(JSON.stringify({ auth: arrayToB64(new Uint8Array(rawAuth)) }));
|
||||
});
|
||||
try {
|
||||
await sendPassword(file, authKey, rawAuth);
|
||||
} catch (e) {
|
||||
if (e.message === '401' && file.nonce !== e.nonce) {
|
||||
await sendPassword(file, authKey, rawAuth);
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,6 +236,10 @@ a {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.upload-window.ondrag * {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.link {
|
||||
color: #0094fb;
|
||||
text-decoration: none;
|
||||
|
||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "firefox-send",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "firefox-send",
|
||||
"description": "File Sharing Experiment",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.1",
|
||||
"author": "Mozilla (https://mozilla.org)",
|
||||
"repository": "mozilla/send",
|
||||
"homepage": "https://github.com/mozilla/send/",
|
||||
|
||||
@@ -98,3 +98,4 @@ addPasswordButton = Añadir contraseña
|
||||
passwordTryAgain = Contraseña incorrecta. Inténtelo de nuevo.
|
||||
// This label is followed by the password needed to download a file
|
||||
passwordResult = Contraseña: { $password }
|
||||
reportIPInfringement = Denunciar vulneración de propiedad intelectual
|
||||
|
||||
@@ -98,3 +98,4 @@ addPasswordButton = Wachtwurd tafoegje
|
||||
passwordTryAgain = Net krekt wachtwurd. Probearje it opnij.
|
||||
// This label is followed by the password needed to download a file
|
||||
passwordResult = Wachtwurd: { $password }
|
||||
reportIPInfringement = IP-ynbrek melde
|
||||
|
||||
@@ -25,6 +25,17 @@ uploadingFileNotification = Upozorniť ma na ukončenie nahrávania
|
||||
uploadSuccessConfirmHeader = Pripravené na odoslanie
|
||||
uploadSvgAlt = Nahrať
|
||||
uploadSuccessTimingHeader = Platnosť odkazu vyprší po 1 prevzatí alebo po uplynutí 24 hodín.
|
||||
expireInfo = Platnosť odkazu na váš súbor vyprší po { $downloadCount } alebo po { $timespan }.
|
||||
downloadCount = { $num ->
|
||||
[one] 1 prevzatí
|
||||
[few] { $num } prevzatiach
|
||||
*[other] { $num } prevzatiach
|
||||
}
|
||||
timespanHours = { $num ->
|
||||
[one] 1 hodine
|
||||
[few] { $num } hodinách
|
||||
*[other] { $num } hodinách
|
||||
}
|
||||
copyUrlFormLabelWithName = Skopírovaním a zdieľaním odkazu odošlete váš súbor: { $filename }
|
||||
copyUrlFormButton = Kopírovať do schránky
|
||||
copiedUrl = Skopírované!
|
||||
@@ -89,3 +100,4 @@ addPasswordButton = Pridať heslo
|
||||
passwordTryAgain = Nesprávne heslo. Skúste to znova.
|
||||
// This label is followed by the password needed to download a file
|
||||
passwordResult = Heslo: { $password }
|
||||
reportIPInfringement = Nahlásiť porušenie práv duševného vlastníctva
|
||||
|
||||
@@ -97,3 +97,4 @@ addPasswordButton = Magdagdag ng password
|
||||
passwordTryAgain = Maling password. Subukan muli.
|
||||
// This label is followed by the password needed to download a file
|
||||
passwordResult = Password: { $password }
|
||||
reportIPInfringement = Report IP Infringement
|
||||
|
||||
@@ -25,6 +25,17 @@ uploadingFileNotification = Сповістити мене, коли вивант
|
||||
uploadSuccessConfirmHeader = Готовий до надсилання
|
||||
uploadSvgAlt = Вивантажити
|
||||
uploadSuccessTimingHeader = Час дії цього посилання закінчиться після 1 завантаження, або через 24 години.
|
||||
expireInfo = Посилання на ваш файл стане недійсним після { $downloadCount } файла, або через { $timespan }.
|
||||
downloadCount = { $num ->
|
||||
[one] 1 завантаження
|
||||
[few] { $num } завантаження
|
||||
*[other] { $num } завантажень
|
||||
}
|
||||
timespanHours = { $num ->
|
||||
[one] 1 година
|
||||
[few] { $num } години
|
||||
*[other] { $num } годин
|
||||
}
|
||||
copyUrlFormLabelWithName = Скопіювати і поділитися посиланням на ваш файл: { $filename }
|
||||
copyUrlFormButton = Копіювати у буфер обміну
|
||||
copiedUrl = Скопійовано!
|
||||
@@ -89,3 +100,4 @@ addPasswordButton = Додати пароль
|
||||
passwordTryAgain = Невірний пароль. Спробуйте знову.
|
||||
// This label is followed by the password needed to download a file
|
||||
passwordResult = Пароль: { $password }
|
||||
reportIPInfringement = Повідомити про порушення прав на інтелектуальну власність
|
||||
|
||||
@@ -24,12 +24,12 @@ module.exports = async function(req, res) {
|
||||
res.set('WWW-Authenticate', `send-v1 ${meta.nonce}`);
|
||||
return res.sendStatus(401);
|
||||
}
|
||||
const nonce = crypto.randomBytes(16).toString('base64');
|
||||
storage.setField(id, 'nonce', nonce);
|
||||
res.set('WWW-Authenticate', `send-v1 ${nonce}`);
|
||||
} catch (e) {
|
||||
res.sendStatus(404);
|
||||
return res.sendStatus(404);
|
||||
}
|
||||
const nonce = crypto.randomBytes(16).toString('base64');
|
||||
storage.setField(id, 'nonce', nonce);
|
||||
res.set('WWW-Authenticate', `send-v1 ${nonce}`);
|
||||
storage.setField(id, 'auth', req.body.auth);
|
||||
storage.setField(id, 'pwd', 1);
|
||||
res.sendStatus(200);
|
||||
|
||||
Reference in New Issue
Block a user