mirror of
https://github.com/timvisee/send.git
synced 2025-10-05 10:29:26 +02:00
remove browser dependency on "buffer"
This commit is contained in:
parent
72d2d6ef31
commit
7130c2e7b0
8 changed files with 304 additions and 65 deletions
|
@ -1,12 +1,11 @@
|
|||
const ece = require('http_ece');
|
||||
require('buffer');
|
||||
|
||||
import assert from 'assert';
|
||||
import Archive from '../../../app/archive';
|
||||
import { b64ToArray } from '../../../app/utils';
|
||||
import { blobStream, concatStream } from '../../../app/streams';
|
||||
import { decryptStream, encryptStream } from '../../../app/ece.js';
|
||||
import { encryptedSize } from '../../../app/utils';
|
||||
import { encryptedSize, concat } from '../../../app/utils';
|
||||
|
||||
const rs = 36;
|
||||
|
||||
|
@ -75,15 +74,15 @@ describe('Streaming', function() {
|
|||
const encStream = encryptStream(stream, key, rs, salt);
|
||||
const reader = encStream.getReader();
|
||||
|
||||
let result = Buffer.from([]);
|
||||
let result = new Uint8Array(0);
|
||||
|
||||
let state = await reader.read();
|
||||
while (!state.done) {
|
||||
result = Buffer.concat([result, state.value]);
|
||||
result = concat(result, state.value);
|
||||
state = await reader.read();
|
||||
}
|
||||
|
||||
assert.deepEqual(result, encrypted);
|
||||
assert.deepEqual(result, new Uint8Array(encrypted));
|
||||
});
|
||||
|
||||
it('can decrypt', async function() {
|
||||
|
@ -91,15 +90,14 @@ describe('Streaming', function() {
|
|||
const decStream = decryptStream(stream, key, rs);
|
||||
|
||||
const reader = decStream.getReader();
|
||||
let result = Buffer.from([]);
|
||||
let result = new Uint8Array(0);
|
||||
|
||||
let state = await reader.read();
|
||||
while (!state.done) {
|
||||
result = Buffer.concat([result, state.value]);
|
||||
result = concat(result, state.value);
|
||||
state = await reader.read();
|
||||
}
|
||||
|
||||
assert.deepEqual(result, decrypted);
|
||||
assert.deepEqual(result, new Uint8Array(decrypted));
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue