Attachments: support for incrementalMac and chunkSize

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
automated-signal 2024-10-09 15:31:32 -05:00 committed by GitHub
parent 4834e3ddc2
commit aaf9e1a418
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 322 additions and 69 deletions

View file

@ -27,6 +27,7 @@ const UNPROCESSED_ATTACHMENT: Proto.IAttachmentPointer = {
key: new Uint8Array([1, 2, 3]),
digest: new Uint8Array([4, 5, 6]),
contentType: IMAGE_GIF,
incrementalMac: new Uint8Array(),
size: 34,
};
@ -36,6 +37,7 @@ const PROCESSED_ATTACHMENT: ProcessedAttachment = {
key: 'AQID',
digest: 'BAUG',
contentType: IMAGE_GIF,
incrementalMac: undefined,
size: 34,
};
@ -84,6 +86,27 @@ describe('processDataMessage', () => {
]);
});
it('should process attachments with incrementalMac/chunkSize', () => {
const out = check({
attachments: [
{
...UNPROCESSED_ATTACHMENT,
incrementalMac: new Uint8Array([0, 0, 0]),
chunkSize: 2,
},
],
});
assert.deepStrictEqual(out.attachments, [
{
...PROCESSED_ATTACHMENT,
chunkSize: 2,
downloadPath: 'random-path',
incrementalMac: 'AAAA',
},
]);
});
it('should throw on too many attachments', () => {
const attachments: Array<Proto.IAttachmentPointer> = [];
for (let i = 0; i < ATTACHMENT_MAX + 1; i += 1) {