Padded attachments, attachments v2

* Handle incoming padded attachments
* Attachments v2 - multipart form POST, and direct CDN GET access
* Pad outgoing attachments before encryption (disabled for now)
This commit is contained in:
Scott Nonnenberg 2019-05-08 13:14:52 -07:00
parent 4a8e0bd466
commit 26a3342d2a
7 changed files with 519 additions and 105 deletions

View file

@ -1234,17 +1234,19 @@ MessageReceiver.prototype.extend({
window.Signal.Crypto.base64ToArrayBuffer(digest)
);
if (!size || size !== data.byteLength) {
if (!size) {
throw new Error(
`downloadAttachment: Size ${size} did not match downloaded attachment size ${
`downloadAttachment: Size was not provided, actual size was ${
data.byteLength
}`
);
}
const typedArray = window.Signal.Crypto.getFirstBytes(data, size);
return {
..._.omit(attachment, 'digest', 'key'),
data,
data: window.Signal.Crypto.typedArrayToArrayBuffer(typedArray),
};
},
handleAttachment(attachment) {