Rewrite ReplayableErrors
ReplayableErrors make it easy for the frontend to handle identity key errors by wrapping the necessary steps into one convenient little replay() callback function. The frontend remains agnostic to what those steps are. It just calls replay() once the user has acknowledged the key change. The protocol layer is responsible for registering the callbacks needed by the IncomingIdentityKeyError and OutgoingIdentityKeyError.
This commit is contained in:
parent
14c53ff710
commit
4a401f07f3
8 changed files with 86 additions and 42 deletions
|
@ -366,7 +366,7 @@ window.textsecure.protocol = function() {
|
|||
//TODO: Wipe identity key!
|
||||
return handlePreKeyWhisperMessage(from, encodedMessage);
|
||||
}
|
||||
textsecure.replay.registerReplayFunction(wipeIdentityAndTryMessageAgain, textsecure.replay.REPLAY_FUNCS.INIT_SESSION);
|
||||
textsecure.replay.registerFunction(wipeIdentityAndTryMessageAgain, textsecure.replay.Type.INIT_SESSION);
|
||||
|
||||
initSessionFromPreKeyWhisperMessage = function(encodedNumber, message) {
|
||||
var preKeyPair = crypto_storage.getStoredKeyPair("preKey" + message.preKeyId);
|
||||
|
@ -394,7 +394,7 @@ window.textsecure.protocol = function() {
|
|||
closeSession(open_session); // To be returned and saved later
|
||||
} else {
|
||||
// ...otherwise create an error that the UI will pick up and ask the user if they want to re-negotiate
|
||||
throw new Error("Received message with unknown identity key", "The identity of the sender has changed. This may be malicious, or the sender may have simply reinstalled TextSecure.", textsecure.replay.REPLAY_FUNCS.INIT_SESSION, [encodedNumber, getString(message.encode())]);
|
||||
throw new textsecure.IncomingIdentityKeyError(encodedNumber, getString(message.encode()));
|
||||
}
|
||||
}
|
||||
return initSession(false, preKeyPair, signedPreKeyPair, encodedNumber, toArrayBuffer(message.identityKey), toArrayBuffer(message.baseKey), undefined)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue