Convert to array buffer
This commit is contained in:
parent
1f8040998f
commit
2ad422afc8
1 changed files with 3 additions and 1 deletions
|
@ -33,7 +33,6 @@
|
||||||
|
|
||||||
if (thing instanceof Array) {
|
if (thing instanceof Array) {
|
||||||
// Assuming Uint16Array from curve25519
|
// Assuming Uint16Array from curve25519
|
||||||
//TODO: Move to convertToArrayBuffer
|
|
||||||
var res = new ArrayBuffer(thing.length * 2);
|
var res = new ArrayBuffer(thing.length * 2);
|
||||||
var uint = new Uint16Array(res);
|
var uint = new Uint16Array(res);
|
||||||
for (var i = 0; i < thing.length; i++)
|
for (var i = 0; i < thing.length; i++)
|
||||||
|
@ -256,6 +255,9 @@
|
||||||
putIdentityKey: function(identifier, publicKey) {
|
putIdentityKey: function(identifier, publicKey) {
|
||||||
if (identifier === null || identifier === undefined)
|
if (identifier === null || identifier === undefined)
|
||||||
throw new Error("Tried to put identity key for undefined/null key");
|
throw new Error("Tried to put identity key for undefined/null key");
|
||||||
|
if (!(publicKey instanceof ArrayBuffer)) {
|
||||||
|
publicKey = convertToArrayBuffer(publicKey);
|
||||||
|
}
|
||||||
var number = textsecure.utils.unencodeNumber(identifier)[0];
|
var number = textsecure.utils.unencodeNumber(identifier)[0];
|
||||||
return new Promise(function(resolve) {
|
return new Promise(function(resolve) {
|
||||||
var identityKey = new IdentityKey({id: number});
|
var identityKey = new IdentityKey({id: number});
|
||||||
|
|
Loading…
Reference in a new issue