Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
args.resources[size].forEach(({ type: transientType }) => {
it(`can encrypt a ${size} ${getConstructorName(originalType)} into a ${getConstructorName(transientType)} and decrypt back a ${getConstructorName(originalType)}`, async () => {
const encrypted = await aliceLaptop.encryptData(clear, { type: transientType });
expectType(encrypted, transientType);
const outputOptions = {};
outputOptions.type = originalType;
if (global.Blob && outputOptions.type === Blob) {
outputOptions.mime = clear.type;
}
if (global.File && outputOptions.type === File) {
outputOptions.mime = clear.type;
outputOptions.name = clear.name;
outputOptions.lastModified = clear.lastModified;
}
const decrypted = await aliceLaptop.decryptData(encrypted, outputOptions);
args.resources[size].forEach(({ type, resource: clear }) => {
it(`can encrypt and decrypt a ${size} ${getConstructorName(type)}`, async () => {
const onProgress = sinon.spy();
const encrypted = await aliceLaptop.encryptData(clear, { onProgress });
expectSameType(encrypted, clear);
expectProgressReport(onProgress, getDataLength(encrypted));
onProgress.resetHistory();
const decrypted = await aliceLaptop.decryptData(encrypted, { onProgress });
expectSameType(decrypted, clear);
expectDeepEqual(decrypted, clear);
expectProgressReport(onProgress, getDataLength(decrypted), encryptionV4.defaultMaxEncryptedChunkSize - encryptionV4.overhead);
});
});
});
testOptions.forEach(options => {
const { type } = options;
it(`can merge binary chunks into a ${getConstructorName(type)}`, async () => {
const stream = new MergerStream(options);
const output: Array = [];
stream.on('data', (data) => { output.push(data); });
const testPromise = new Promise((resolve, reject) => {
stream.on('error', reject);
stream.on('end', async () => {
try {
expect(output).to.have.lengthOf(1);
expect(output[0]).to.be.an.instanceOf(type);
const outputBytes = await castData(output[0], { type: Uint8Array });
expect(outputBytes).to.deep.equal(bytes);
if (global.Blob && output[0] instanceof global.Blob) {