Move web_api.js and js/modules/crypto.js to TypeScript

This commit is contained in:
Scott Nonnenberg 2020-03-31 13:03:38 -07:00
parent 71436d18e2
commit 9ab54b9b83
29 changed files with 770 additions and 427 deletions

View file

@ -1321,7 +1321,7 @@ MessageReceiver.prototype.extend({
throw new Error('Failure: Ask sender to update Signal and resend.');
}
const data = await textsecure.crypto.decryptAttachment(
const paddedData = await textsecure.crypto.decryptAttachment(
encrypted,
window.Signal.Crypto.base64ToArrayBuffer(key),
window.Signal.Crypto.base64ToArrayBuffer(digest)
@ -1329,15 +1329,15 @@ MessageReceiver.prototype.extend({
if (!_.isNumber(size)) {
throw new Error(
`downloadAttachment: Size was not provided, actual size was ${data.byteLength}`
`downloadAttachment: Size was not provided, actual size was ${paddedData.byteLength}`
);
}
const typedArray = window.Signal.Crypto.getFirstBytes(data, size);
const data = window.Signal.Crypto.getFirstBytes(paddedData, size);
return {
..._.omit(attachment, 'digest', 'key'),
data: window.Signal.Crypto.typedArrayToArrayBuffer(typedArray),
data,
};
},
handleAttachment(attachment) {