|
|
|
@ -34627,19 +34627,7 @@ window.libsignal.protocol = function(storage_interface) {
|
|
|
|
|
var address = SignalProtocolAddress.fromString(deviceObject.encodedNumber);
|
|
|
|
|
var builder = new SessionBuilder(storage_interface, address);
|
|
|
|
|
|
|
|
|
|
return builder.processPreKey({
|
|
|
|
|
identityKey: toArrayBuffer(deviceObject.identityKey),
|
|
|
|
|
preKey: {
|
|
|
|
|
keyId: deviceObject.preKeyId,
|
|
|
|
|
publicKey: toArrayBuffer(deviceObject.preKey),
|
|
|
|
|
},
|
|
|
|
|
signedPreKey: {
|
|
|
|
|
keyId: deviceObject.signedKeyId,
|
|
|
|
|
publicKey: toArrayBuffer(deviceObject.signedKey),
|
|
|
|
|
signature: toArrayBuffer(deviceObject.signedKeySignature),
|
|
|
|
|
},
|
|
|
|
|
registrationId: deviceObject.registrationId
|
|
|
|
|
});
|
|
|
|
|
return builder.processPreKey(deviceObject);
|
|
|
|
|
}
|
|
|
|
|
}).then(function() {
|
|
|
|
|
return getRecord(deviceObject.encodedNumber).then(function(refreshed) {
|
|
|
|
@ -35458,6 +35446,13 @@ libsignal.SessionBuilder = SessionBuilder;
|
|
|
|
|
throw e;
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
processPreKey: function(preKeyBundle) {
|
|
|
|
|
return queueJobForNumber(preKeyBundle.encodedNumber, function() {
|
|
|
|
|
var address = libsignal.SignalProtocolAddress.fromString(preKeyBundle.encodedNumber);
|
|
|
|
|
var builder = new libsignal.SessionBuilder(textsecure.storage.protocol, address);
|
|
|
|
|
return builder.processPreKey(preKeyBundle);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
})();
|
|
|
|
@ -35699,24 +35694,8 @@ libsignal.SessionBuilder = SessionBuilder;
|
|
|
|
|
|
|
|
|
|
window.textsecure.storage.devices = {
|
|
|
|
|
saveKeysToDeviceObject: function(deviceObject) {
|
|
|
|
|
var number = textsecure.utils.unencodeNumber(deviceObject.encodedNumber)[0];
|
|
|
|
|
return textsecure.storage.protocol.loadIdentityKey(number).then(function(identityKey) {
|
|
|
|
|
if (identityKey !== undefined && deviceObject.identityKey !== undefined && getString(identityKey) != getString(deviceObject.identityKey)) {
|
|
|
|
|
var error = new Error("Identity key changed");
|
|
|
|
|
error.identityKey = deviceObject.identityKey;
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return textsecure.storage.protocol.putIdentityKey(number, deviceObject.identityKey).then(function() {
|
|
|
|
|
tempKeys[deviceObject.encodedNumber] = {
|
|
|
|
|
preKey: deviceObject.preKey,
|
|
|
|
|
preKeyId: deviceObject.preKeyId,
|
|
|
|
|
signedKey: deviceObject.signedKey,
|
|
|
|
|
signedKeyId: deviceObject.signedKeyId,
|
|
|
|
|
signedKeySignature: deviceObject.signedKeySignature,
|
|
|
|
|
registrationId: deviceObject.registrationId
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
return textsecure.protocol_wrapper.processPreKey(deviceObject).then(function() {
|
|
|
|
|
tempKeys[deviceObject.encodedNumber] = deviceObject;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
@ -37480,23 +37459,19 @@ OutgoingMessage.prototype = {
|
|
|
|
|
getKeysForNumber: function(number, updateDevices) {
|
|
|
|
|
var handleResult = function(response) {
|
|
|
|
|
return Promise.all(response.devices.map(function(device) {
|
|
|
|
|
if (updateDevices === undefined || updateDevices.indexOf(device.deviceId) > -1)
|
|
|
|
|
return textsecure.storage.devices.saveKeysToDeviceObject({
|
|
|
|
|
encodedNumber: number + "." + device.deviceId,
|
|
|
|
|
identityKey: response.identityKey,
|
|
|
|
|
preKey: device.preKey.publicKey,
|
|
|
|
|
preKeyId: device.preKey.keyId,
|
|
|
|
|
signedKey: device.signedPreKey.publicKey,
|
|
|
|
|
signedKeyId: device.signedPreKey.keyId,
|
|
|
|
|
signedKeySignature: device.signedPreKey.signature,
|
|
|
|
|
registrationId: device.registrationId
|
|
|
|
|
}).catch(function(error) {
|
|
|
|
|
device.identityKey = response.identityKey;
|
|
|
|
|
device.encodedNumber = number + "." + device.deviceId;
|
|
|
|
|
if (updateDevices === undefined || updateDevices.indexOf(device.deviceId) > -1) {
|
|
|
|
|
return textsecure.storage.devices.saveKeysToDeviceObject(device).catch(function(error) {
|
|
|
|
|
if (error.message === "Identity key changed") {
|
|
|
|
|
error = new textsecure.OutgoingIdentityKeyError(number, this.message.toArrayBuffer(), this.timestamp, error.identityKey);
|
|
|
|
|
error = new textsecure.OutgoingIdentityKeyError(
|
|
|
|
|
number, this.message.toArrayBuffer(),
|
|
|
|
|
this.timestamp, device.identityKey);
|
|
|
|
|
this.registerError(number, "Identity key changed", error);
|
|
|
|
|
}
|
|
|
|
|
throw error;
|
|
|
|
|
}.bind(this));
|
|
|
|
|
}
|
|
|
|
|
}.bind(this)));
|
|
|
|
|
}.bind(this);
|
|
|
|
|
|
|
|
|
|