@ -35674,18 +35674,9 @@ libsignal.SessionBuilder = SessionBuilder;
window . textsecure = window . textsecure || { } ;
window . textsecure = window . textsecure || { } ;
window . textsecure . storage = window . textsecure . storage || { } ;
window . textsecure . storage = window . textsecure . storage || { } ;
var tempKeys = { } ;
window . textsecure . storage . devices = {
window . textsecure . storage . devices = {
saveKeysToDeviceObject : function ( deviceObject ) {
saveKeysToDeviceObject : function ( deviceObject ) {
return textsecure . protocol _wrapper . processPreKey ( deviceObject ) . then ( function ( ) {
return textsecure . protocol _wrapper . processPreKey ( deviceObject ) ;
tempKeys [ deviceObject . encodedNumber ] = deviceObject ;
} ) ;
} ,
removeTempKeysFromDevice : function ( encodedNumber ) {
delete tempKeys [ encodedNumber ] ;
return Promise . resolve ( ) ;
} ,
} ,
getStaleDeviceIdsForNumber : function ( number ) {
getStaleDeviceIdsForNumber : function ( number ) {
@ -35695,9 +35686,9 @@ libsignal.SessionBuilder = SessionBuilder;
}
}
var updateDevices = [ ] ;
var updateDevices = [ ] ;
return Promise . all ( deviceIds . map ( function ( deviceId ) {
return Promise . all ( deviceIds . map ( function ( deviceId ) {
var encodedNumber = number + '.' + deviceId ;
var address = new libsignal . SignalProtocolAddress ( number , deviceId ) . toString ( ) ;
return textsecure . protocol _wrapper . hasOpenSession ( encodedNumber ) . then ( function ( hasSession ) {
return textsecure . protocol _wrapper . hasOpenSession ( address ) . then ( function ( hasSession ) {
if ( ! hasSession && ! tempKeys [ encodedNumber ] ) {
if ( ! hasSession ) {
updateDevices . push ( deviceId ) ;
updateDevices . push ( deviceId ) ;
}
}
} ) ;
} ) ;
@ -35712,24 +35703,13 @@ libsignal.SessionBuilder = SessionBuilder;
return [ ] ;
return [ ] ;
}
}
return textsecure . storage . protocol . getDeviceIds ( number ) . then ( function ( deviceIds ) {
return textsecure . storage . protocol . getDeviceIds ( number ) . then ( function ( deviceIds ) {
// Add pending devices from tempKeys
for ( var encodedNumber in tempKeys ) {
var deviceNumber = textsecure . utils . unencodeNumber ( encodedNumber ) [ 0 ] ;
var deviceId = parseInt ( textsecure . utils . unencodeNumber ( encodedNumber ) [ 1 ] ) ;
if ( deviceNumber === number && deviceIds . indexOf ( deviceId ) < 0 ) {
deviceIds . push ( deviceId ) ;
}
}
return Promise . all ( deviceIds . map ( function ( deviceId ) {
return Promise . all ( deviceIds . map ( function ( deviceId ) {
var encodedNumber = number + '.' + deviceId ;
var address = new libsignal . SignalProtocolAddress ( number , deviceId ) . toString ( ) ;
var deviceObject = tempKeys [ encodedNumber ] || { } ;
return textsecure . protocol _wrapper . getRegistrationId ( address ) . then ( function ( registrationId ) {
deviceObject . encodedNumber = encodedNumber ;
return {
deviceObject . identityKey = identityKey ;
encodedNumber : address ,
return textsecure . protocol _wrapper . getRegistrationId ( encodedNumber ) . then ( function ( registrationId ) {
registrationId : registrationId
if ( deviceObject . registrationId === undefined ) {
} ;
deviceObject . registrationId = registrationId ;
}
return deviceObject ;
} ) ;
} ) ;
} ) ) ;
} ) ) ;
} ) ;
} ) ;
@ -35741,7 +35721,6 @@ libsignal.SessionBuilder = SessionBuilder;
for ( var j in deviceIdsToRemove ) {
for ( var j in deviceIdsToRemove ) {
promise = promise . then ( function ( ) {
promise = promise . then ( function ( ) {
var encodedNumber = number + "." + deviceIdsToRemove [ j ] ;
var encodedNumber = number + "." + deviceIdsToRemove [ j ] ;
delete tempKeys [ encodedNumber ] ;
return textsecure . storage . protocol . removeSession ( encodedNumber ) ;
return textsecure . storage . protocol . removeSession ( encodedNumber ) ;
} ) ;
} ) ;
}
}
@ -37522,10 +37501,7 @@ OutgoingMessage.prototype = {
var plaintext = this . message . toArrayBuffer ( ) ;
var plaintext = this . message . toArrayBuffer ( ) ;
return Promise . all ( deviceObjectList . map ( function ( device ) {
return Promise . all ( deviceObjectList . map ( function ( device ) {
return textsecure . protocol _wrapper . encryptMessageFor ( device , plaintext ) . then ( function ( encryptedMsg ) {
return textsecure . protocol _wrapper . encryptMessageFor ( device , plaintext ) . then ( function ( encryptedMsg ) {
var json = this . toJSON ( device , encryptedMsg ) ;
return this . toJSON ( device , encryptedMsg ) ;
return textsecure . storage . devices . removeTempKeysFromDevice ( device . encodedNumber ) . then ( function ( ) {
return json ;
} ) ;
} . bind ( this ) ) ;
} . bind ( this ) ) ;
} . bind ( this ) ) ) ;
} . bind ( this ) ) ) ;
} ,
} ,