Verify makeAttachmentPointer
and encryptAttachment
arguments
The underlying `crypto.subtle.encrypt` API requires it.
This commit is contained in:
parent
8218e308cd
commit
32911002d4
2 changed files with 18 additions and 0 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue