-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Description
Part of #1051
Relevant test here https://github.com/FlowCrypt/flowcrypt-mobile-core/blob/master/source/test.ts#L53
Only port encryptFile for now (which results in binary - unarmored - output). Don't port decryptFile because there are many error scenarios that we want to behave the same as before.
for (const keypairName of allKeypairNames.filter(name => name != 'expired')) {
ava.default(`encryptFile -> decryptFile ${keypairName}`, async t => {
const { pubKeys, keys } = getKeypairs(keypairName);
const name = 'myfile.txt';
const content = Buffer.from([10, 20, 40, 80, 160, 0, 25, 50, 75, 100, 125, 150, 175, 200, 225, 250]);
const { data: encryptedFile, json: encryptJson } = await request('encryptFile', { pubKeys, name }, content);
expectEmptyJson(encryptJson);
expectData(encryptedFile);
const { data: decryptedContent, json: decryptJson } = await request('decryptFile', { keys }, encryptedFile);
expect(decryptJson).to.deep.equal({ success: true, name });
expectData(decryptedContent, 'binary', content);
t.pass();
});
}Current implementation here https://github.com/FlowCrypt/flowcrypt-mobile-core/blob/master/source/mobile-interface/endpoints.ts
public encryptFile = async (uncheckedReq: any, data: Buffers): Promise<Buffers> => {
const req = ValidateInput.encryptFile(uncheckedReq);
const encrypted = await PgpMsg.encrypt({ pubkeys: req.pubKeys, data: Buf.concat(data), filename: req.name, armor: false }) as OpenPGP.EncryptBinaryResult;
return fmtRes({}, encrypted.message.packets.write());
}Reactions are currently unavailable