mirror of
https://github.com/openpgpjs/openpgpjs.git
synced 2026-03-14 20:35:10 +00:00
Don't mutate prototypes of Uint8Array, ReadableStream and ReadableStreamDefaultWriter
This commit is contained in:
@@ -9,7 +9,7 @@ const input = require('./testInputs.js');
|
||||
|
||||
function stringify(array) {
|
||||
if (openpgp.util.isStream(array)) {
|
||||
return array.readToEnd().then(stringify);
|
||||
return openpgp.stream.readToEnd(array).then(stringify);
|
||||
}
|
||||
|
||||
if (!openpgp.util.isUint8Array(array)) {
|
||||
|
||||
@@ -21,7 +21,7 @@ describe('Streaming', function() {
|
||||
data,
|
||||
passwords: ['test'],
|
||||
});
|
||||
const msgAsciiArmored = util.Uint8Array_to_str(await encrypted.data.readToEnd());
|
||||
const msgAsciiArmored = util.Uint8Array_to_str(await openpgp.stream.readToEnd(encrypted.data));
|
||||
const message = await openpgp.message.readArmored(msgAsciiArmored);
|
||||
const decrypted = await openpgp.decrypt({
|
||||
passwords: ['test'],
|
||||
@@ -48,7 +48,7 @@ describe('Streaming', function() {
|
||||
data,
|
||||
passwords: ['test'],
|
||||
});
|
||||
const msgAsciiArmored = util.Uint8Array_to_str(await encrypted.data.readToEnd());
|
||||
const msgAsciiArmored = util.Uint8Array_to_str(await openpgp.stream.readToEnd(encrypted.data));
|
||||
const message = await openpgp.message.readArmored(msgAsciiArmored);
|
||||
const decrypted = await openpgp.decrypt({
|
||||
passwords: ['test'],
|
||||
@@ -85,6 +85,6 @@ describe('Streaming', function() {
|
||||
format: 'binary'
|
||||
});
|
||||
expect(util.isStream(decrypted.data)).to.be.true;
|
||||
expect(await decrypted.data.readToEnd()).to.deep.equal(util.concatUint8Array(plaintext));
|
||||
expect(await openpgp.stream.readToEnd(decrypted.data)).to.deep.equal(util.concatUint8Array(plaintext));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user