Add verified status

// FREEBIE
This commit is contained in:
lilia 2017-06-12 12:55:16 -07:00 committed by Scott Nonnenberg
parent c6bfdec84d
commit b93042f12f
2 changed files with 20 additions and 0 deletions

View file

@ -233,6 +233,7 @@
attributes.timestamp = 0; attributes.timestamp = 0;
attributes.firstUse = false; attributes.firstUse = false;
attributes.nonblockingApproval = false; attributes.nonblockingApproval = false;
attributes.verified = 0;
attributes.seen = 0; attributes.seen = 0;
promises.push(new Promise(function(resolve, reject) { promises.push(new Promise(function(resolve, reject) {
var putRequest = identityKeys.put(attributes, attributes.id); var putRequest = identityKeys.put(attributes, attributes.id);

View file

@ -9,6 +9,12 @@
RECEIVING: 2, RECEIVING: 2,
}; };
var VerifiedStatus = {
DEFAULT: 0,
VERIFIED: 1,
UNVERIFIED: 2,
};
var StaticByteBufferProto = new dcodeIO.ByteBuffer().__proto__; var StaticByteBufferProto = new dcodeIO.ByteBuffer().__proto__;
var StaticArrayBufferProto = new ArrayBuffer().__proto__; var StaticArrayBufferProto = new ArrayBuffer().__proto__;
var StaticUint8ArrayProto = new Uint8Array().__proto__; var StaticUint8ArrayProto = new Uint8Array().__proto__;
@ -319,6 +325,10 @@
console.log("isTrustedForSending: Identity keys don't match..."); console.log("isTrustedForSending: Identity keys don't match...");
return false; return false;
} }
if (identityKey.get('verified') === VerifiedStatus.UNVERIFIED) {
console.log("Needs unverified 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;
@ -357,16 +367,24 @@
publicKey : publicKey, publicKey : publicKey,
firstUse : true, firstUse : true,
timestamp : Date.now(), timestamp : Date.now(),
verified : VerifiedStatus.DEFAULT,
nonblockingApproval : nonblockingApproval, nonblockingApproval : nonblockingApproval,
}).then(function() { }).then(function() {
resolve(false); resolve(false);
}); });
} else if (!equalArrayBuffers(oldpublicKey, publicKey)) { } else if (!equalArrayBuffers(oldpublicKey, publicKey)) {
console.log("Replacing existing identity..."); console.log("Replacing existing identity...");
var verifiedStatus;
if (identityKey.get('verified') === VerifiedStatus.VERIFIED) {
verifiedStatus = VerifiedStatus.UNVERIFIED;
} else {
verifiedStatus = VerifiedStatus.DEFAULT;
}
identityKey.save({ identityKey.save({
publicKey : publicKey, publicKey : publicKey,
firstUse : false, firstUse : false,
timestamp : Date.now(), timestamp : Date.now(),
verified : verifiedStatus,
nonblockingApproval : nonblockingApproval, nonblockingApproval : nonblockingApproval,
}).then(function() { }).then(function() {
this.trigger('keychange', identifier); this.trigger('keychange', identifier);
@ -439,4 +457,5 @@
window.SignalProtocolStore = SignalProtocolStore; window.SignalProtocolStore = SignalProtocolStore;
window.SignalProtocolStore.prototype.Direction = Direction; window.SignalProtocolStore.prototype.Direction = Direction;
window.SignalProtocolStore.prototype.VerifiedStatus = VerifiedStatus;
})(); })();