Show warning when we discover key change on verify
FREEBIE
This commit is contained in:
parent
91f50c028f
commit
8112cd220a
5 changed files with 79 additions and 42 deletions
|
@ -12,18 +12,20 @@
|
|||
'click button.verify': 'toggleVerified',
|
||||
},
|
||||
initialize: function(options) {
|
||||
this.our_number = textsecure.storage.user.getNumber();
|
||||
this.ourNumber = textsecure.storage.user.getNumber();
|
||||
if (options.newKey) {
|
||||
this.their_key = options.newKey;
|
||||
this.theirKey = options.newKey;
|
||||
}
|
||||
|
||||
Promise.all([
|
||||
this.loadKeys().then(function() {
|
||||
this.listenTo(this.model, 'change', this.render);
|
||||
}.bind(this));
|
||||
},
|
||||
loadKeys: function() {
|
||||
return Promise.all([
|
||||
this.loadTheirKey(),
|
||||
this.loadOurKey(),
|
||||
]).then(this.generateSecurityNumber.bind(this))
|
||||
.then(function() {
|
||||
this.listenTo(this.model, 'change', this.render);
|
||||
}.bind(this))
|
||||
.then(this.render.bind(this));
|
||||
//.then(this.makeQRCode.bind(this));
|
||||
},
|
||||
|
@ -31,40 +33,59 @@
|
|||
// Per Lilia: We can't turn this on until it generates a Latin1 string, as is
|
||||
// required by the mobile clients.
|
||||
new QRCode(this.$('.qr')[0]).makeCode(
|
||||
dcodeIO.ByteBuffer.wrap(this.our_key).toString('base64')
|
||||
dcodeIO.ByteBuffer.wrap(this.ourKey).toString('base64')
|
||||
);
|
||||
},
|
||||
loadTheirKey: function() {
|
||||
if (this.their_key) {
|
||||
return Promise.resolve(this.their_key);
|
||||
} else {
|
||||
return textsecure.storage.protocol.loadIdentityKey(
|
||||
this.model.id
|
||||
).then(function(their_key) {
|
||||
this.their_key = their_key;
|
||||
}.bind(this));
|
||||
}
|
||||
return textsecure.storage.protocol.loadIdentityKey(
|
||||
this.model.id
|
||||
).then(function(theirKey) {
|
||||
this.theirKey = theirKey;
|
||||
}.bind(this));
|
||||
},
|
||||
loadOurKey: function() {
|
||||
if (this.our_key) {
|
||||
return Promise.resolve(this.our_key);
|
||||
} else {
|
||||
return textsecure.storage.protocol.loadIdentityKey(
|
||||
this.our_number
|
||||
).then(function(our_key) {
|
||||
this.our_key = our_key;
|
||||
}.bind(this));
|
||||
}
|
||||
return textsecure.storage.protocol.loadIdentityKey(
|
||||
this.ourNumber
|
||||
).then(function(ourKey) {
|
||||
this.ourKey = ourKey;
|
||||
}.bind(this));
|
||||
},
|
||||
generateSecurityNumber: function() {
|
||||
return new libsignal.FingerprintGenerator(5200).createFor(
|
||||
this.our_number, this.our_key, this.model.id, this.their_key
|
||||
this.ourNumber, this.ourKey, this.model.id, this.theirKey
|
||||
).then(function(securityNumber) {
|
||||
this.securityNumber = securityNumber;
|
||||
}.bind(this));
|
||||
},
|
||||
onSafetyNumberChanged: function() {
|
||||
this.model.getProfiles().then(this.loadKeys.bind(this));
|
||||
|
||||
var dialog = new Whisper.ConfirmationDialogView({
|
||||
message: i18n('changedRightAfterVerify', this.model.getTitle(), this.model.getTitle()),
|
||||
resolve: function() {},
|
||||
});
|
||||
|
||||
dialog.$el.insertBefore(this.el);
|
||||
dialog.focusCancel();
|
||||
},
|
||||
toggleVerified: function() {
|
||||
this.model.toggleVerified();
|
||||
this.$('button.verify').attr('disabled', true);
|
||||
this.model.toggleVerified().catch(function(result) {
|
||||
if (result instanceof Error) {
|
||||
if (result.name === 'OutgoingIdentityKeyError') {
|
||||
this.onSafetyNumberChanged();
|
||||
}
|
||||
} else {
|
||||
var keyError = _.some(result.errors, function(error) {
|
||||
return error.name === 'OutgoingIdentityKeyError';
|
||||
});
|
||||
if (keyError) {
|
||||
this.onSafetyNumberChanged();
|
||||
}
|
||||
}
|
||||
}.bind(this)).then(function() {
|
||||
this.$('button.verify').removeAttr('disabled');
|
||||
}.bind(this));
|
||||
},
|
||||
render_attributes: function() {
|
||||
var s = this.securityNumber;
|
||||
|
@ -80,11 +101,11 @@
|
|||
|
||||
return {
|
||||
learnMore : i18n('learnMore'),
|
||||
their_key_unknown : i18n('theirIdentityUnknown'),
|
||||
theirKeyUnknown : i18n('theirIdentityUnknown'),
|
||||
yourSafetyNumberWith : i18n('yourSafetyNumberWith', this.model.getTitle()),
|
||||
verifyHelp : i18n('verifyHelp', this.model.getTitle()),
|
||||
verifyButton : verifyButton,
|
||||
has_their_key : this.their_key !== undefined,
|
||||
hasTheirKey : this.theirKey !== undefined,
|
||||
chunks : chunks,
|
||||
isVerified : isVerified,
|
||||
verifiedStatus : verifiedStatus
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue