Add verified status
// FREEBIE
This commit is contained in:
		
					parent
					
						
							
								c6bfdec84d
							
						
					
				
			
			
				commit
				
					
						b93042f12f
					
				
			
		
					 2 changed files with 20 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -233,6 +233,7 @@
 | 
			
		|||
                    attributes.timestamp = 0;
 | 
			
		||||
                    attributes.firstUse = false;
 | 
			
		||||
                    attributes.nonblockingApproval = false;
 | 
			
		||||
                    attributes.verified = 0;
 | 
			
		||||
                    attributes.seen = 0;
 | 
			
		||||
                    promises.push(new Promise(function(resolve, reject) {
 | 
			
		||||
                      var putRequest = identityKeys.put(attributes, attributes.id);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -9,6 +9,12 @@
 | 
			
		|||
      RECEIVING: 2,
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    var VerifiedStatus = {
 | 
			
		||||
      DEFAULT: 0,
 | 
			
		||||
      VERIFIED: 1,
 | 
			
		||||
      UNVERIFIED: 2,
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    var StaticByteBufferProto = new dcodeIO.ByteBuffer().__proto__;
 | 
			
		||||
    var StaticArrayBufferProto = new ArrayBuffer().__proto__;
 | 
			
		||||
    var StaticUint8ArrayProto = new Uint8Array().__proto__;
 | 
			
		||||
| 
						 | 
				
			
			@ -319,6 +325,10 @@
 | 
			
		|||
                console.log("isTrustedForSending: Identity keys don't match...");
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            if (identityKey.get('verified') === VerifiedStatus.UNVERIFIED) {
 | 
			
		||||
               console.log("Needs unverified approval!");
 | 
			
		||||
               return false;
 | 
			
		||||
            }
 | 
			
		||||
            if (this.isNonBlockingApprovalRequired(identityKey)) {
 | 
			
		||||
                console.log("isTrustedForSending: Needs non-blocking approval!");
 | 
			
		||||
                return false;
 | 
			
		||||
| 
						 | 
				
			
			@ -357,16 +367,24 @@
 | 
			
		|||
                            publicKey           : publicKey,
 | 
			
		||||
                            firstUse            : true,
 | 
			
		||||
                            timestamp           : Date.now(),
 | 
			
		||||
                            verified            : VerifiedStatus.DEFAULT,
 | 
			
		||||
                            nonblockingApproval : nonblockingApproval,
 | 
			
		||||
                        }).then(function() {
 | 
			
		||||
                            resolve(false);
 | 
			
		||||
                        });
 | 
			
		||||
                    } else if (!equalArrayBuffers(oldpublicKey, publicKey)) {
 | 
			
		||||
                        console.log("Replacing existing identity...");
 | 
			
		||||
                        var verifiedStatus;
 | 
			
		||||
                        if (identityKey.get('verified') === VerifiedStatus.VERIFIED) {
 | 
			
		||||
                            verifiedStatus = VerifiedStatus.UNVERIFIED;
 | 
			
		||||
                        } else {
 | 
			
		||||
                            verifiedStatus = VerifiedStatus.DEFAULT;
 | 
			
		||||
                        }
 | 
			
		||||
                        identityKey.save({
 | 
			
		||||
                            publicKey           : publicKey,
 | 
			
		||||
                            firstUse            : false,
 | 
			
		||||
                            timestamp           : Date.now(),
 | 
			
		||||
                            verified            : verifiedStatus,
 | 
			
		||||
                            nonblockingApproval : nonblockingApproval,
 | 
			
		||||
                        }).then(function() {
 | 
			
		||||
                            this.trigger('keychange', identifier);
 | 
			
		||||
| 
						 | 
				
			
			@ -439,4 +457,5 @@
 | 
			
		|||
 | 
			
		||||
    window.SignalProtocolStore = SignalProtocolStore;
 | 
			
		||||
    window.SignalProtocolStore.prototype.Direction = Direction;
 | 
			
		||||
    window.SignalProtocolStore.prototype.VerifiedStatus = VerifiedStatus;
 | 
			
		||||
})();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue