Remove blockingApproval

// FREEBIE
pull/749/head
lilia 8 years ago committed by Scott Nonnenberg
parent 53e7e1be3a
commit c6bfdec84d

@ -232,7 +232,6 @@
var attributes = cursor.value; var attributes = cursor.value;
attributes.timestamp = 0; attributes.timestamp = 0;
attributes.firstUse = false; attributes.firstUse = false;
attributes.blockingApproval = true;
attributes.nonblockingApproval = false; attributes.nonblockingApproval = false;
attributes.seen = 0; attributes.seen = 0;
promises.push(new Promise(function(resolve, reject) { promises.push(new Promise(function(resolve, reject) {

@ -355,7 +355,7 @@
var identityKey = dcodeIO.ByteBuffer.wrap(profile.identityKey, 'base64').toArrayBuffer(); var identityKey = dcodeIO.ByteBuffer.wrap(profile.identityKey, 'base64').toArrayBuffer();
return textsecure.storage.protocol.saveIdentity( return textsecure.storage.protocol.saveIdentity(
id, identityKey, storage.get('safety-numbers-approval', true), false id, identityKey, false
); );
}); });
}, },
@ -525,7 +525,7 @@
throw 'No conflicts to resolve'; throw 'No conflicts to resolve';
} }
return textsecure.storage.protocol.saveIdentity(number, identityKey, true, true).then(function() { return textsecure.storage.protocol.saveIdentity(number, identityKey, true).then(function() {
var promise = Promise.resolve(); var promise = Promise.resolve();
var conflicts = this.messageCollection.filter(function(message) { var conflicts = this.messageCollection.filter(function(message) {
return message.hasKeyConflict(number); return message.hasKeyConflict(number);

@ -319,10 +319,6 @@
console.log("isTrustedForSending: Identity keys don't match..."); console.log("isTrustedForSending: Identity keys don't match...");
return false; return false;
} }
if (this.isBlockingApprovalRequired(identityKey)) {
console.log("isTrustedForSending: Needs blocking approval!");
return false;
}
if (this.isNonBlockingApprovalRequired(identityKey)) { if (this.isNonBlockingApprovalRequired(identityKey)) {
console.log("isTrustedForSending: Needs non-blocking approval!"); console.log("isTrustedForSending: Needs non-blocking approval!");
return false; return false;
@ -342,7 +338,7 @@
}); });
}); });
}, },
saveIdentity: function(identifier, publicKey, blockingApproval, nonblockingApproval) { saveIdentity: function(identifier, publicKey, nonblockingApproval) {
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");
} }
@ -361,7 +357,6 @@
publicKey : publicKey, publicKey : publicKey,
firstUse : true, firstUse : true,
timestamp : Date.now(), timestamp : Date.now(),
blockingApproval : blockingApproval,
nonblockingApproval : nonblockingApproval, nonblockingApproval : nonblockingApproval,
}).then(function() { }).then(function() {
resolve(false); resolve(false);
@ -372,16 +367,14 @@
publicKey : publicKey, publicKey : publicKey,
firstUse : false, firstUse : false,
timestamp : Date.now(), timestamp : Date.now(),
blockingApproval : blockingApproval,
nonblockingApproval : nonblockingApproval, nonblockingApproval : nonblockingApproval,
}).then(function() { }).then(function() {
this.trigger('keychange', identifier); this.trigger('keychange', identifier);
resolve(true); resolve(true);
}.bind(this)); }.bind(this));
} else if (this.isBlockingApprovalRequired(identityKey) || this.isNonBlockingApprovalRequired(identityKey)) { } else if (this.isNonBlockingApprovalRequired(identityKey)) {
console.log("Setting approval status..."); console.log("Setting approval status...");
identityKey.save({ identityKey.save({
blockingApproval : blockingApproval,
nonblockingApproval : nonblockingApproval, nonblockingApproval : nonblockingApproval,
}).then(function() { }).then(function() {
resolve(false); resolve(false);
@ -392,11 +385,6 @@
}.bind(this)); }.bind(this));
}.bind(this)); }.bind(this));
}, },
isBlockingApprovalRequired: function(identityKey) {
return (!identityKey.get('firstUse')
&& storage.get('safety-numbers-approval', true)
&& !identityKey.get('blockingApproval'));
},
isNonBlockingApprovalRequired: function(identityKey) { isNonBlockingApprovalRequired: function(identityKey) {
return (!identityKey.get('firstUse') return (!identityKey.get('firstUse')
&& Date.now() - identityKey.get('timestamp') < TIMESTAMP_THRESHOLD && Date.now() - identityKey.get('timestamp') < TIMESTAMP_THRESHOLD

@ -81,7 +81,6 @@ describe("SignalProtocolStore", function() {
publicKey : testKey.pubKey, publicKey : testKey.pubKey,
firstUse : true, firstUse : true,
timestamp : oldTimestamp, timestamp : oldTimestamp,
blockingApproval : false,
nonblockingApproval : false, nonblockingApproval : false,
}).then(function() { }).then(function() {
store.saveIdentity(identifier, newIdentity).then(function() { store.saveIdentity(identifier, newIdentity).then(function() {
@ -102,7 +101,6 @@ describe("SignalProtocolStore", function() {
record.save({ record.save({
publicKey : testKey.pubKey, publicKey : testKey.pubKey,
timestamp : oldTimestamp, timestamp : oldTimestamp,
blockingApproval : false,
nonblockingApproval : false, nonblockingApproval : false,
}).then(function() { done(); }); }).then(function() { done(); });
}); });
@ -111,9 +109,8 @@ describe("SignalProtocolStore", function() {
record.save({ firstUse: true }).then(function() { done(); }); record.save({ firstUse: true }).then(function() { done(); });
}); });
it('nothing changes', function(done) { it('nothing changes', function(done) {
store.saveIdentity(identifier, testKey.pubKey, true, true).then(function() { store.saveIdentity(identifier, testKey.pubKey, true).then(function() {
record.fetch().then(function() { record.fetch().then(function() {
assert(!record.get('blockingApproval'));
assert(!record.get('nonblockingApproval')); assert(!record.get('nonblockingApproval'));
assert.strictEqual(record.get('timestamp'), oldTimestamp); assert.strictEqual(record.get('timestamp'), oldTimestamp);
done(); done();
@ -125,30 +122,10 @@ describe("SignalProtocolStore", function() {
before(function(done) { before(function(done) {
record.save({ firstUse: false }).then(function() { done(); }); record.save({ firstUse: false }).then(function() { done(); });
}); });
describe('If blocking approval is required', function() {
before(function() {
storage.put('safety-numbers-approval', true);
});
it('updates blocking and non-blocking approval', function(done) {
store.saveIdentity(identifier, testKey.pubKey, true, true).then(function() {
record.fetch().then(function() {
assert(record.get('blockingApproval'));
assert(record.get('nonblockingApproval'));
assert.strictEqual(record.get('timestamp'), oldTimestamp);
assert.strictEqual(record.get('firstUse'), false);
done();
});
});
});
});
describe('If nonblocking approval is required', function() { describe('If nonblocking approval is required', function() {
before(function() { it('updates non-blocking approval', function(done) {
storage.put('safety-numbers-approval', false); store.saveIdentity(identifier, testKey.pubKey, true).then(function() {
});
it('updates blocking and non-blocking approval', function(done) {
store.saveIdentity(identifier, testKey.pubKey, true, true).then(function() {
record.fetch().then(function() { record.fetch().then(function() {
assert(record.get('blockingApproval'));
assert(record.get('nonblockingApproval')); assert(record.get('nonblockingApproval'));
assert.strictEqual(record.get('timestamp'), oldTimestamp); assert.strictEqual(record.get('timestamp'), oldTimestamp);
assert.strictEqual(record.get('firstUse'), false); assert.strictEqual(record.get('firstUse'), false);
@ -249,7 +226,7 @@ describe("SignalProtocolStore", function() {
}); });
it('returns true if neither blocking nor nonblocking approval is required', function(done) { it('returns true if neither blocking nor nonblocking approval is required', function(done) {
storage.put('safety-numbers-approval', false); storage.put('safety-numbers-approval', false);
store.saveIdentity(identifier, newIdentity, true, true).then(function() { store.saveIdentity(identifier, newIdentity, true).then(function() {
store.isTrustedIdentity(identifier, newIdentity, store.Direction.SENDING).then(function(trusted) { store.isTrustedIdentity(identifier, newIdentity, store.Direction.SENDING).then(function(trusted) {
if (trusted) { if (trusted) {
done(); done();

Loading…
Cancel
Save