mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-12-24 23:09:28 -05:00
making the feature detection more robust, let users with no WASM create uncompressed pastes, remove dead & duplicate code
This commit is contained in:
parent
ff68043c9f
commit
6fcd82fb85
@ -161,5 +161,7 @@
|
|||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
||||||
"<a href=\"%s\">Вижте тази страница</a> за повече информация.",
|
"<a href=\"%s\">Вижте тази страница</a> за повече информация.",
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
||||||
"Браузъра ви може да се нуждае от HTTPS връзка за да използва WebCrypto API. Пробвай <a href=\"%s\">да минеш на HTTPS</a>."
|
"Браузъра ви може да се нуждае от HTTPS връзка за да използва WebCrypto API. Пробвай <a href=\"%s\">да минеш на HTTPS</a>.",
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.":
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones."
|
||||||
}
|
}
|
||||||
|
@ -161,5 +161,7 @@
|
|||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>."
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.",
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.":
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones."
|
||||||
}
|
}
|
||||||
|
@ -161,5 +161,7 @@
|
|||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
||||||
"<a href=\"%s\">Besuche diesen FAQ Eintrag</a> für weitere Informationen dazu.",
|
"<a href=\"%s\">Besuche diesen FAQ Eintrag</a> für weitere Informationen dazu.",
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
||||||
"Dein Browser benötigt möglicherweise eine HTTPS Verbindung um das WebCrypto API nutzen zu können. Versuche <a href=\"%s\">auf HTTPS zu wechseln</a>."
|
"Dein Browser benötigt möglicherweise eine HTTPS Verbindung um das WebCrypto API nutzen zu können. Versuche <a href=\"%s\">auf HTTPS zu wechseln</a>.",
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.":
|
||||||
|
"Dein Browser unterstützt WebAssembly nicht, welches für zlib Komprimierung benötigt wird. Du kannst unkomprimierte Dokumente erzeugen, aber keine komprimierten lesen."
|
||||||
}
|
}
|
||||||
|
@ -161,5 +161,7 @@
|
|||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>."
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.",
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.":
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones."
|
||||||
}
|
}
|
||||||
|
@ -170,5 +170,7 @@
|
|||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
||||||
"Pour plus d'informations <a href=\"%s\">consultez cette rubrique de la FAQ</a>.",
|
"Pour plus d'informations <a href=\"%s\">consultez cette rubrique de la FAQ</a>.",
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
||||||
"Votre navigateur peut nécessiter une connexion HTTPS pour prendre en charge l’API WebCrypto. Essayez <a href=\"%s\">de passer en HTTPS</a>."
|
"Votre navigateur peut nécessiter une connexion HTTPS pour prendre en charge l’API WebCrypto. Essayez <a href=\"%s\">de passer en HTTPS</a>.",
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.":
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones."
|
||||||
}
|
}
|
||||||
|
@ -161,5 +161,7 @@
|
|||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>."
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.",
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.":
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones."
|
||||||
}
|
}
|
||||||
|
@ -161,5 +161,7 @@
|
|||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>."
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.",
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.":
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones."
|
||||||
}
|
}
|
||||||
|
@ -161,5 +161,7 @@
|
|||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>."
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.",
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.":
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones."
|
||||||
}
|
}
|
||||||
|
@ -161,5 +161,7 @@
|
|||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>."
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.",
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.":
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones."
|
||||||
}
|
}
|
||||||
|
@ -170,5 +170,7 @@
|
|||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
||||||
"Per mai d’informacions <a href=\"%s\">vejatz aqueste article de FAQ</a>.",
|
"Per mai d’informacions <a href=\"%s\">vejatz aqueste article de FAQ</a>.",
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
||||||
"Se pòt que vòstre navigator faga besonh d’una connexion HTTPS per èsser compatible amb l’API WebCrypto. Ensajatz de <a href=\"%s\">passar al HTTPS</a>."
|
"Se pòt que vòstre navigator faga besonh d’una connexion HTTPS per èsser compatible amb l’API WebCrypto. Ensajatz de <a href=\"%s\">passar al HTTPS</a>.",
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.":
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones."
|
||||||
}
|
}
|
||||||
|
@ -161,5 +161,7 @@
|
|||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>."
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.",
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.":
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones."
|
||||||
}
|
}
|
||||||
|
@ -161,5 +161,7 @@
|
|||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>."
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.",
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.":
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones."
|
||||||
}
|
}
|
||||||
|
@ -171,5 +171,7 @@
|
|||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
||||||
"Для продробностей <a href=\"%s\">прочтите информацию в FAQ</a>.",
|
"Для продробностей <a href=\"%s\">прочтите информацию в FAQ</a>.",
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
||||||
"Ваш браузер требует использования HTTPS подключения для поддержки WebCrypto API. Попробуйте <a href=\"%s\">переключиться на HTTPS</a>."
|
"Ваш браузер требует использования HTTPS подключения для поддержки WebCrypto API. Попробуйте <a href=\"%s\">переключиться на HTTPS</a>.",
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.":
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones."
|
||||||
}
|
}
|
||||||
|
@ -170,5 +170,7 @@
|
|||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>."
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.",
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.":
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones."
|
||||||
}
|
}
|
||||||
|
@ -161,5 +161,7 @@
|
|||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
"For more information <a href=\"%s\">see this FAQ entry</a>.":
|
||||||
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
"For more information <a href=\"%s\">see this FAQ entry</a>.",
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.":
|
||||||
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>."
|
"Your browser may require an HTTPS connection to support the WebCrypto API. Try <a href=\"%s\">switching to HTTPS</a>.",
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones.":
|
||||||
|
"Your browser doesn't support WebAssembly, used for zlib compression. You can create uncompressed documents, but can't read compressed ones."
|
||||||
}
|
}
|
||||||
|
@ -789,7 +789,8 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
utf16To8(message)
|
utf16To8(message)
|
||||||
);
|
);
|
||||||
if (mode === 'zlib') {
|
if (mode === 'zlib') {
|
||||||
return z.deflate(message).buffer;
|
let zlib = (await z);
|
||||||
|
return zlib.deflate(message).buffer;
|
||||||
}
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
@ -809,7 +810,12 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
{
|
{
|
||||||
if (mode === 'zlib' || mode === 'none') {
|
if (mode === 'zlib' || mode === 'none') {
|
||||||
if (mode === 'zlib') {
|
if (mode === 'zlib') {
|
||||||
data = z.inflate(
|
let zlib = (await z);
|
||||||
|
if (typeof zlib === 'undefined') {
|
||||||
|
Alert.showError('Your browser doesn\'t support WebAssembly, used for zlib compression. You can create uncompressed documents, but can\'t read compressed ones.')
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
data = zlib.inflate(
|
||||||
new Uint8Array(data)
|
new Uint8Array(data)
|
||||||
).buffer;
|
).buffer;
|
||||||
}
|
}
|
||||||
@ -883,7 +889,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
stringToArraybuffer(
|
stringToArraybuffer(
|
||||||
utf16To8(password)
|
utf16To8(password)
|
||||||
)
|
)
|
||||||
);
|
).catch(Alert.showError);
|
||||||
password = Array.prototype.map.call(
|
password = Array.prototype.map.call(
|
||||||
new Uint8Array(passwordBuffer),
|
new Uint8Array(passwordBuffer),
|
||||||
x => ('00' + x.toString(16)).slice(-2)
|
x => ('00' + x.toString(16)).slice(-2)
|
||||||
@ -903,7 +909,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
{name: 'PBKDF2'}, // we use PBKDF2 for key derivation
|
{name: 'PBKDF2'}, // we use PBKDF2 for key derivation
|
||||||
false, // the key may not be exported
|
false, // the key may not be exported
|
||||||
['deriveKey'] // we may only use it for key derivation
|
['deriveKey'] // we may only use it for key derivation
|
||||||
);
|
).catch(Alert.showError);
|
||||||
|
|
||||||
// derive a stronger key for use with AES
|
// derive a stronger key for use with AES
|
||||||
return window.crypto.subtle.deriveKey(
|
return window.crypto.subtle.deriveKey(
|
||||||
@ -920,7 +926,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
},
|
},
|
||||||
false, // the key may not be exported
|
false, // the key may not be exported
|
||||||
['encrypt', 'decrypt'] // we may only use it for en- and decryption
|
['encrypt', 'decrypt'] // we may only use it for en- and decryption
|
||||||
);
|
).catch(Alert.showError);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -959,7 +965,12 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
{
|
{
|
||||||
// AES in Galois Counter Mode, keysize 256 bit,
|
// AES in Galois Counter Mode, keysize 256 bit,
|
||||||
// authentication tag 128 bit, 10000 iterations in key derivation
|
// authentication tag 128 bit, 10000 iterations in key derivation
|
||||||
const spec = [
|
const compression = (
|
||||||
|
typeof (await z) === 'undefined' ?
|
||||||
|
'none' : // client lacks support for WASM
|
||||||
|
$('body').data('compression') || 'zlib'
|
||||||
|
),
|
||||||
|
spec = [
|
||||||
getRandomBytes(16), // initialization vector
|
getRandomBytes(16), // initialization vector
|
||||||
getRandomBytes(8), // salt
|
getRandomBytes(8), // salt
|
||||||
100000, // iterations
|
100000, // iterations
|
||||||
@ -967,7 +978,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
128, // tag size
|
128, // tag size
|
||||||
'aes', // algorithm
|
'aes', // algorithm
|
||||||
'gcm', // algorithm mode
|
'gcm', // algorithm mode
|
||||||
$('body').data('compression') || 'zlib' // compression
|
compression // compression
|
||||||
], encodedSpec = [];
|
], encodedSpec = [];
|
||||||
for (let i = 0; i < spec.length; ++i) {
|
for (let i = 0; i < spec.length; ++i) {
|
||||||
encodedSpec[i] = i < 2 ? btoa(spec[i]) : spec[i];
|
encodedSpec[i] = i < 2 ? btoa(spec[i]) : spec[i];
|
||||||
@ -987,8 +998,8 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
await window.crypto.subtle.encrypt(
|
await window.crypto.subtle.encrypt(
|
||||||
cryptoSettings(JSON.stringify(adata), spec),
|
cryptoSettings(JSON.stringify(adata), spec),
|
||||||
await deriveKey(key, password, spec),
|
await deriveKey(key, password, spec),
|
||||||
await compress(message, spec[7])
|
await compress(message, compression)
|
||||||
)
|
).catch(Alert.showError)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
adata
|
adata
|
||||||
@ -1043,7 +1054,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
stringToArraybuffer(
|
stringToArraybuffer(
|
||||||
atob(cipherMessage)
|
atob(cipherMessage)
|
||||||
)
|
)
|
||||||
),
|
).catch(Alert.showError),
|
||||||
spec[7]
|
spec[7]
|
||||||
);
|
);
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
@ -1194,7 +1205,6 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
me.getPasteId = function()
|
me.getPasteId = function()
|
||||||
{
|
{
|
||||||
const idRegEx = /^[a-z0-9]{16}$/;
|
const idRegEx = /^[a-z0-9]{16}$/;
|
||||||
const idRegExFind = /[a-z0-9]{16}/;
|
|
||||||
|
|
||||||
// return cached value
|
// return cached value
|
||||||
if (id !== null) {
|
if (id !== null) {
|
||||||
@ -1573,6 +1583,22 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
handleNotification(1, $statusMessage, message, icon);
|
handleNotification(1, $statusMessage, message, icon);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* display a warning message
|
||||||
|
*
|
||||||
|
* This automatically passes the text to I18n for translation.
|
||||||
|
*
|
||||||
|
* @name Alert.showWarning
|
||||||
|
* @function
|
||||||
|
* @param {string|array} message string, use an array for %s/%d options
|
||||||
|
* @param {string|null} icon optional, the icon to show, default:
|
||||||
|
* leave previous icon
|
||||||
|
*/
|
||||||
|
me.showWarning = function(message, icon)
|
||||||
|
{
|
||||||
|
handleNotification(2, $errorMessage, message, icon);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* display an error message
|
* display an error message
|
||||||
*
|
*
|
||||||
@ -1699,7 +1725,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
currentIcon = [
|
currentIcon = [
|
||||||
'glyphicon-time', // loading icon
|
'glyphicon-time', // loading icon
|
||||||
'glyphicon-info-sign', // status icon
|
'glyphicon-info-sign', // status icon
|
||||||
'', // reserved for warning, not used yet
|
'glyphicon-warning-sign', // warning icon
|
||||||
'glyphicon-alert' // error icon
|
'glyphicon-alert' // error icon
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
@ -1768,14 +1794,14 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Alert.showError(
|
Alert.showError('Cannot parse response from URL shortener.');
|
||||||
I18n._('Cannot parse response from URL shortener.')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail(function(data, textStatus, errorThrown) {
|
.fail(function(data, textStatus, errorThrown) {
|
||||||
console.error(textStatus, errorThrown);
|
console.error(textStatus, errorThrown);
|
||||||
// we don't know why it failed, could be CORS of the external server not setup properly, in which case we follow old behavior to open it in new tab
|
// we don't know why it failed, could be CORS of the external
|
||||||
|
// server not setup properly, in which case we follow old
|
||||||
|
// behavior to open it in new tab
|
||||||
window.open(
|
window.open(
|
||||||
`${$shortenButton.data('shortener')}${encodeURIComponent($pasteUrl.attr('href'))}`,
|
`${$shortenButton.data('shortener')}${encodeURIComponent($pasteUrl.attr('href'))}`,
|
||||||
'_blank',
|
'_blank',
|
||||||
@ -2731,9 +2757,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
// revert loading status…
|
// revert loading status…
|
||||||
me.hideAttachment();
|
me.hideAttachment();
|
||||||
me.hideAttachmentPreview();
|
me.hideAttachmentPreview();
|
||||||
Alert.showError(
|
Alert.showWarning('Your browser does not support uploading encrypted files. Please use a newer browser.');
|
||||||
I18n._('Your browser does not support uploading encrypted files. Please use a newer browser.')
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4194,8 +4218,6 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
const PasteEncrypter = (function () {
|
const PasteEncrypter = (function () {
|
||||||
const me = {};
|
const me = {};
|
||||||
|
|
||||||
let requirementsChecked = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called after successful paste upload
|
* called after successful paste upload
|
||||||
*
|
*
|
||||||
@ -4428,16 +4450,13 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
});
|
});
|
||||||
cipherMessage['attachment'] = await fileReading;
|
cipherMessage['attachment'] = await fileReading;
|
||||||
} else {
|
} else {
|
||||||
Alert.showError(
|
const error = 'Cannot process attachment data.';
|
||||||
I18n._('Cannot process attachment data.')
|
Alert.showError(error);
|
||||||
);
|
throw new TypeError(error);
|
||||||
throw new TypeError('Cannot process attachment data.');
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
Alert.showError(
|
Alert.showError('Cannot retrieve attachment.');
|
||||||
I18n._('Cannot retrieve attachment.')
|
|
||||||
);
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4528,8 +4547,6 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let format = '',
|
|
||||||
text = '';
|
|
||||||
if (paste.v > 1) {
|
if (paste.v > 1) {
|
||||||
// version 2 paste
|
// version 2 paste
|
||||||
const pasteMessage = JSON.parse(pastePlain);
|
const pasteMessage = JSON.parse(pastePlain);
|
||||||
@ -4630,9 +4647,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
|
|
||||||
// log detailed error, but display generic translation
|
// log detailed error, but display generic translation
|
||||||
console.error(message);
|
console.error(message);
|
||||||
Alert.showError(
|
Alert.showError('Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.');
|
||||||
I18n._('Could not decrypt data. Did you enter a wrong password? Retry with the button at the top.')
|
|
||||||
);
|
|
||||||
|
|
||||||
// reset password, so it can be re-entered
|
// reset password, so it can be re-entered
|
||||||
Prompt.reset();
|
Prompt.reset();
|
||||||
@ -4702,8 +4717,6 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
* initial (security) check
|
* initial (security) check
|
||||||
*
|
*
|
||||||
* @name InitialCheck
|
* @name InitialCheck
|
||||||
* @param {object} window
|
|
||||||
* @param {object} document
|
|
||||||
* @class
|
* @class
|
||||||
*/
|
*/
|
||||||
const InitialCheck = (function () {
|
const InitialCheck = (function () {
|
||||||
@ -4848,6 +4861,9 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
$('#httpnotice').removeClass('hidden');
|
$('#httpnotice').removeClass('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
z = zlib.catch(function () {
|
||||||
|
Alert.showWarning('Your browser doesn\'t support WebAssembly, used for zlib compression. You can create uncompressed documents, but can\'t read compressed ones.');
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4926,9 +4942,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
|
|
||||||
// missing decryption key (or paste ID) in URL?
|
// missing decryption key (or paste ID) in URL?
|
||||||
if (window.location.hash.length === 0) {
|
if (window.location.hash.length === 0) {
|
||||||
Alert.showError(
|
Alert.showError('Cannot decrypt paste: Decryption key missing in URL (Did you use a redirector or an URL shortener which strips part of the URL?)');
|
||||||
I18n._('Cannot decrypt paste: Decryption key missing in URL (Did you use a redirector or an URL shortener which strips part of the URL?)')
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5054,7 +5068,6 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
|||||||
Prompt.init();
|
Prompt.init();
|
||||||
TopNav.init();
|
TopNav.init();
|
||||||
UiHelper.init();
|
UiHelper.init();
|
||||||
z = (await zlib);
|
|
||||||
if (!InitialCheck.init()) {
|
if (!InitialCheck.init()) {
|
||||||
// something major is wrong, stop right away
|
// something major is wrong, stop right away
|
||||||
return;
|
return;
|
||||||
|
@ -8,6 +8,9 @@ describe('CryptTool', function () {
|
|||||||
await new Promise(resolve => setTimeout(resolve, 1900));
|
await new Promise(resolve => setTimeout(resolve, 1900));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ensure zlib is getting loaded
|
||||||
|
$.PrivateBin.InitialCheck.init();
|
||||||
|
|
||||||
this.timeout(30000);
|
this.timeout(30000);
|
||||||
it('can en- and decrypt any message', function () {
|
it('can en- and decrypt any message', function () {
|
||||||
jsc.assert(jsc.forall(
|
jsc.assert(jsc.forall(
|
||||||
|
@ -71,7 +71,7 @@ if ($MARKDOWN):
|
|||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.11.js" integrity="sha512-p7UyJuyBkhMcMgE4mDsgK0Lz70OvetLefua1oXs1OujWv9gOxh4xy8InFux7bZ4/DAZsTmO4rgVwZW9BHKaTaw==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.11.js" integrity="sha512-p7UyJuyBkhMcMgE4mDsgK0Lz70OvetLefua1oXs1OujWv9gOxh4xy8InFux7bZ4/DAZsTmO4rgVwZW9BHKaTaw==" crossorigin="anonymous"></script>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-86VTqw2HsaCQ0DAunK2MH68P+8RLbbaK7HZP8nwDtwNoF44usxDCptmD8TC+zwQc7HM46AkrvVFb3ZkIb6VhMQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-aACEZbSPO13YywWwP/gTTBdZgYlKuDfKAJU5PJyqVRsuZiT7rAAhFRf1KdF8OX8QFHqTrQhQ47qlFtIslJMnkg==" crossorigin="anonymous"></script>
|
||||||
<!--[if IE]>
|
<!--[if IE]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
@ -49,7 +49,7 @@ if ($MARKDOWN):
|
|||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.11.js" integrity="sha512-p7UyJuyBkhMcMgE4mDsgK0Lz70OvetLefua1oXs1OujWv9gOxh4xy8InFux7bZ4/DAZsTmO4rgVwZW9BHKaTaw==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/purify-1.0.11.js" integrity="sha512-p7UyJuyBkhMcMgE4mDsgK0Lz70OvetLefua1oXs1OujWv9gOxh4xy8InFux7bZ4/DAZsTmO4rgVwZW9BHKaTaw==" crossorigin="anonymous"></script>
|
||||||
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-86VTqw2HsaCQ0DAunK2MH68P+8RLbbaK7HZP8nwDtwNoF44usxDCptmD8TC+zwQc7HM46AkrvVFb3ZkIb6VhMQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" data-cfasync="false" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-aACEZbSPO13YywWwP/gTTBdZgYlKuDfKAJU5PJyqVRsuZiT7rAAhFRf1KdF8OX8QFHqTrQhQ47qlFtIslJMnkg==" crossorigin="anonymous"></script>
|
||||||
<!--[if IE]>
|
<!--[if IE]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
Loading…
Reference in New Issue
Block a user