mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 12:19:41 +00:00
Verify makeAttachmentPointer and encryptAttachment arguments
The underlying `crypto.subtle.encrypt` API requires it.
This commit is contained in:
@@ -116,10 +116,21 @@ function MessageSender(url, username, password, cdn_url) {
|
||||
|
||||
MessageSender.prototype = {
|
||||
constructor: MessageSender,
|
||||
|
||||
// makeAttachmentPointer :: Attachment -> Promise AttachmentPointerProto
|
||||
makeAttachmentPointer: function(attachment) {
|
||||
if (typeof attachment !== 'object' || attachment == null) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
if (!(attachment.data instanceof ArrayBuffer) &&
|
||||
!ArrayBuffer.isView(attachment.data)) {
|
||||
return Promise.reject(new TypeError(
|
||||
'`attachment.data` must be an `ArrayBuffer` or `ArrayBufferView`; got: ' +
|
||||
typeof attachment.data
|
||||
));
|
||||
}
|
||||
|
||||
var proto = new textsecure.protobuf.AttachmentPointer();
|
||||
proto.key = libsignal.crypto.getRandomBytes(64);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user