mirror of
https://gitlab.com/timvisee/send.git
synced 2025-12-07 06:30:53 +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))}`;
|
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 {
|
export default class FileSender extends Nanobus {
|
||||||
constructor(file) {
|
constructor(file) {
|
||||||
super('FileSender');
|
super('FileSender');
|
||||||
@@ -259,7 +286,6 @@ export default class FileSender extends Nanobus {
|
|||||||
true,
|
true,
|
||||||
['sign']
|
['sign']
|
||||||
);
|
);
|
||||||
const authHeader = await getAuthHeader(authKey, file.nonce);
|
|
||||||
const pwdKey = await window.crypto.subtle.importKey(
|
const pwdKey = await window.crypto.subtle.importKey(
|
||||||
'raw',
|
'raw',
|
||||||
encoder.encode(password),
|
encoder.encode(password),
|
||||||
@@ -283,30 +309,14 @@ export default class FileSender extends Nanobus {
|
|||||||
['sign']
|
['sign']
|
||||||
);
|
);
|
||||||
const rawAuth = await window.crypto.subtle.exportKey('raw', newAuthKey);
|
const rawAuth = await window.crypto.subtle.exportKey('raw', newAuthKey);
|
||||||
return new Promise((resolve, reject) => {
|
try {
|
||||||
const xhr = new XMLHttpRequest();
|
await sendPassword(file, authKey, rawAuth);
|
||||||
xhr.onreadystatechange = () => {
|
} catch (e) {
|
||||||
if (xhr.readyState === XMLHttpRequest.DONE) {
|
if (e.message === '401' && file.nonce !== e.nonce) {
|
||||||
if (xhr.status === 200) {
|
await sendPassword(file, authKey, rawAuth);
|
||||||
return resolve(xhr.response);
|
} else {
|
||||||
}
|
throw e;
|
||||||
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)) }));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -236,6 +236,10 @@ a {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.upload-window.ondrag * {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
.link {
|
.link {
|
||||||
color: #0094fb;
|
color: #0094fb;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
|
|||||||
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "firefox-send",
|
"name": "firefox-send",
|
||||||
"version": "2.2.0",
|
"version": "2.2.1",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "firefox-send",
|
"name": "firefox-send",
|
||||||
"description": "File Sharing Experiment",
|
"description": "File Sharing Experiment",
|
||||||
"version": "2.2.0",
|
"version": "2.2.1",
|
||||||
"author": "Mozilla (https://mozilla.org)",
|
"author": "Mozilla (https://mozilla.org)",
|
||||||
"repository": "mozilla/send",
|
"repository": "mozilla/send",
|
||||||
"homepage": "https://github.com/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.
|
passwordTryAgain = Contraseña incorrecta. Inténtelo de nuevo.
|
||||||
// This label is followed by the password needed to download a file
|
// This label is followed by the password needed to download a file
|
||||||
passwordResult = Contraseña: { $password }
|
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.
|
passwordTryAgain = Net krekt wachtwurd. Probearje it opnij.
|
||||||
// This label is followed by the password needed to download a file
|
// This label is followed by the password needed to download a file
|
||||||
passwordResult = Wachtwurd: { $password }
|
passwordResult = Wachtwurd: { $password }
|
||||||
|
reportIPInfringement = IP-ynbrek melde
|
||||||
|
|||||||
@@ -25,6 +25,17 @@ uploadingFileNotification = Upozorniť ma na ukončenie nahrávania
|
|||||||
uploadSuccessConfirmHeader = Pripravené na odoslanie
|
uploadSuccessConfirmHeader = Pripravené na odoslanie
|
||||||
uploadSvgAlt = Nahrať
|
uploadSvgAlt = Nahrať
|
||||||
uploadSuccessTimingHeader = Platnosť odkazu vyprší po 1 prevzatí alebo po uplynutí 24 hodín.
|
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 }
|
copyUrlFormLabelWithName = Skopírovaním a zdieľaním odkazu odošlete váš súbor: { $filename }
|
||||||
copyUrlFormButton = Kopírovať do schránky
|
copyUrlFormButton = Kopírovať do schránky
|
||||||
copiedUrl = Skopírované!
|
copiedUrl = Skopírované!
|
||||||
@@ -89,3 +100,4 @@ addPasswordButton = Pridať heslo
|
|||||||
passwordTryAgain = Nesprávne heslo. Skúste to znova.
|
passwordTryAgain = Nesprávne heslo. Skúste to znova.
|
||||||
// This label is followed by the password needed to download a file
|
// This label is followed by the password needed to download a file
|
||||||
passwordResult = Heslo: { $password }
|
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.
|
passwordTryAgain = Maling password. Subukan muli.
|
||||||
// This label is followed by the password needed to download a file
|
// This label is followed by the password needed to download a file
|
||||||
passwordResult = Password: { $password }
|
passwordResult = Password: { $password }
|
||||||
|
reportIPInfringement = Report IP Infringement
|
||||||
|
|||||||
@@ -25,6 +25,17 @@ uploadingFileNotification = Сповістити мене, коли вивант
|
|||||||
uploadSuccessConfirmHeader = Готовий до надсилання
|
uploadSuccessConfirmHeader = Готовий до надсилання
|
||||||
uploadSvgAlt = Вивантажити
|
uploadSvgAlt = Вивантажити
|
||||||
uploadSuccessTimingHeader = Час дії цього посилання закінчиться після 1 завантаження, або через 24 години.
|
uploadSuccessTimingHeader = Час дії цього посилання закінчиться після 1 завантаження, або через 24 години.
|
||||||
|
expireInfo = Посилання на ваш файл стане недійсним після { $downloadCount } файла, або через { $timespan }.
|
||||||
|
downloadCount = { $num ->
|
||||||
|
[one] 1 завантаження
|
||||||
|
[few] { $num } завантаження
|
||||||
|
*[other] { $num } завантажень
|
||||||
|
}
|
||||||
|
timespanHours = { $num ->
|
||||||
|
[one] 1 година
|
||||||
|
[few] { $num } години
|
||||||
|
*[other] { $num } годин
|
||||||
|
}
|
||||||
copyUrlFormLabelWithName = Скопіювати і поділитися посиланням на ваш файл: { $filename }
|
copyUrlFormLabelWithName = Скопіювати і поділитися посиланням на ваш файл: { $filename }
|
||||||
copyUrlFormButton = Копіювати у буфер обміну
|
copyUrlFormButton = Копіювати у буфер обміну
|
||||||
copiedUrl = Скопійовано!
|
copiedUrl = Скопійовано!
|
||||||
@@ -89,3 +100,4 @@ addPasswordButton = Додати пароль
|
|||||||
passwordTryAgain = Невірний пароль. Спробуйте знову.
|
passwordTryAgain = Невірний пароль. Спробуйте знову.
|
||||||
// This label is followed by the password needed to download a file
|
// This label is followed by the password needed to download a file
|
||||||
passwordResult = Пароль: { $password }
|
passwordResult = Пароль: { $password }
|
||||||
|
reportIPInfringement = Повідомити про порушення прав на інтелектуальну власність
|
||||||
|
|||||||
@@ -24,12 +24,12 @@ module.exports = async function(req, res) {
|
|||||||
res.set('WWW-Authenticate', `send-v1 ${meta.nonce}`);
|
res.set('WWW-Authenticate', `send-v1 ${meta.nonce}`);
|
||||||
return res.sendStatus(401);
|
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) {
|
} 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, 'auth', req.body.auth);
|
||||||
storage.setField(id, 'pwd', 1);
|
storage.setField(id, 'pwd', 1);
|
||||||
res.sendStatus(200);
|
res.sendStatus(200);
|
||||||
|
|||||||
Reference in New Issue
Block a user