| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -10,6 +10,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  before(done => {
 | 
					 | 
					 | 
					 | 
					  before(done => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    store = textsecure.storage.protocol;
 | 
					 | 
					 | 
					 | 
					    store = textsecure.storage.protocol;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					    store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    identityKey = {
 | 
					 | 
					 | 
					 | 
					    identityKey = {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      pubKey: libsignal.crypto.getRandomBytes(33),
 | 
					 | 
					 | 
					 | 
					      pubKey: libsignal.crypto.getRandomBytes(33),
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      privKey: libsignal.crypto.getRandomBytes(32),
 | 
					 | 
					 | 
					 | 
					      privKey: libsignal.crypto.getRandomBytes(32),
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -86,6 +87,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          verified: store.VerifiedStatus.DEFAULT,
 | 
					 | 
					 | 
					 | 
					          verified: store.VerifiedStatus.DEFAULT,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        });
 | 
					 | 
					 | 
					 | 
					        });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        await store.saveIdentity(identifier, newIdentity);
 | 
					 | 
					 | 
					 | 
					        await store.saveIdentity(identifier, newIdentity);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      });
 | 
					 | 
					 | 
					 | 
					      });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      it('marks the key not firstUse', async () => {
 | 
					 | 
					 | 
					 | 
					      it('marks the key not firstUse', async () => {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -107,6 +109,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            nonblockingApproval: false,
 | 
					 | 
					 | 
					 | 
					            nonblockingApproval: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            verified: store.VerifiedStatus.DEFAULT,
 | 
					 | 
					 | 
					 | 
					            verified: store.VerifiedStatus.DEFAULT,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          });
 | 
					 | 
					 | 
					 | 
					          });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          await store.saveIdentity(identifier, newIdentity);
 | 
					 | 
					 | 
					 | 
					          await store.saveIdentity(identifier, newIdentity);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        });
 | 
					 | 
					 | 
					 | 
					        });
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -125,6 +128,8 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            nonblockingApproval: false,
 | 
					 | 
					 | 
					 | 
					            nonblockingApproval: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            verified: store.VerifiedStatus.VERIFIED,
 | 
					 | 
					 | 
					 | 
					            verified: store.VerifiedStatus.VERIFIED,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          });
 | 
					 | 
					 | 
					 | 
					          });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          await store.saveIdentity(identifier, newIdentity);
 | 
					 | 
					 | 
					 | 
					          await store.saveIdentity(identifier, newIdentity);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        });
 | 
					 | 
					 | 
					 | 
					        });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        it('sets the new key to unverified', async () => {
 | 
					 | 
					 | 
					 | 
					        it('sets the new key to unverified', async () => {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -147,6 +152,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            verified: store.VerifiedStatus.UNVERIFIED,
 | 
					 | 
					 | 
					 | 
					            verified: store.VerifiedStatus.UNVERIFIED,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          });
 | 
					 | 
					 | 
					 | 
					          });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          await store.saveIdentity(identifier, newIdentity);
 | 
					 | 
					 | 
					 | 
					          await store.saveIdentity(identifier, newIdentity);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        });
 | 
					 | 
					 | 
					 | 
					        });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        it('sets the new key to unverified', async () => {
 | 
					 | 
					 | 
					 | 
					        it('sets the new key to unverified', async () => {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -168,12 +174,14 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          nonblockingApproval: false,
 | 
					 | 
					 | 
					 | 
					          nonblockingApproval: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          verified: store.VerifiedStatus.DEFAULT,
 | 
					 | 
					 | 
					 | 
					          verified: store.VerifiedStatus.DEFAULT,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        });
 | 
					 | 
					 | 
					 | 
					        });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					        await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      });
 | 
					 | 
					 | 
					 | 
					      });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      describe('If it is marked firstUse', () => {
 | 
					 | 
					 | 
					 | 
					      describe('If it is marked firstUse', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        before(async () => {
 | 
					 | 
					 | 
					 | 
					        before(async () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          const identity = await window.Signal.Data.getIdentityKeyById(number);
 | 
					 | 
					 | 
					 | 
					          const identity = await window.Signal.Data.getIdentityKeyById(number);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          identity.firstUse = true;
 | 
					 | 
					 | 
					 | 
					          identity.firstUse = true;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          await window.Signal.Data.createOrUpdateIdentityKey(identity);
 | 
					 | 
					 | 
					 | 
					          await window.Signal.Data.createOrUpdateIdentityKey(identity);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        });
 | 
					 | 
					 | 
					 | 
					        });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        it('nothing changes', async () => {
 | 
					 | 
					 | 
					 | 
					        it('nothing changes', async () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          await store.saveIdentity(identifier, testKey.pubKey, true);
 | 
					 | 
					 | 
					 | 
					          await store.saveIdentity(identifier, testKey.pubKey, true);
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -188,6 +196,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          const identity = await window.Signal.Data.getIdentityKeyById(number);
 | 
					 | 
					 | 
					 | 
					          const identity = await window.Signal.Data.getIdentityKeyById(number);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          identity.firstUse = false;
 | 
					 | 
					 | 
					 | 
					          identity.firstUse = false;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          await window.Signal.Data.createOrUpdateIdentityKey(identity);
 | 
					 | 
					 | 
					 | 
					          await window.Signal.Data.createOrUpdateIdentityKey(identity);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        });
 | 
					 | 
					 | 
					 | 
					        });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        describe('If nonblocking approval is required', () => {
 | 
					 | 
					 | 
					 | 
					        describe('If nonblocking approval is required', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          let now;
 | 
					 | 
					 | 
					 | 
					          let now;
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -198,6 +207,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            );
 | 
					 | 
					 | 
					 | 
					            );
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            identity.timestamp = now;
 | 
					 | 
					 | 
					 | 
					            identity.timestamp = now;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            await window.Signal.Data.createOrUpdateIdentityKey(identity);
 | 
					 | 
					 | 
					 | 
					            await window.Signal.Data.createOrUpdateIdentityKey(identity);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          });
 | 
					 | 
					 | 
					 | 
					          });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          it('sets non-blocking approval', async () => {
 | 
					 | 
					 | 
					 | 
					          it('sets non-blocking approval', async () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            await store.saveIdentity(identifier, testKey.pubKey, true);
 | 
					 | 
					 | 
					 | 
					            await store.saveIdentity(identifier, testKey.pubKey, true);
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -311,6 +321,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        verified: store.VerifiedStatus.DEFAULT,
 | 
					 | 
					 | 
					 | 
					        verified: store.VerifiedStatus.DEFAULT,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        nonblockingApproval: false,
 | 
					 | 
					 | 
					 | 
					        nonblockingApproval: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      });
 | 
					 | 
					 | 
					 | 
					      });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    describe('with no public key argument', () => {
 | 
					 | 
					 | 
					 | 
					    describe('with no public key argument', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      before(saveRecordDefault);
 | 
					 | 
					 | 
					 | 
					      before(saveRecordDefault);
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -370,6 +381,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      describe('when there is no existing record', () => {
 | 
					 | 
					 | 
					 | 
					      describe('when there is no existing record', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        before(async () => {
 | 
					 | 
					 | 
					 | 
					        before(async () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          await window.Signal.Data.removeIdentityKeyById(number);
 | 
					 | 
					 | 
					 | 
					          await window.Signal.Data.removeIdentityKeyById(number);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        });
 | 
					 | 
					 | 
					 | 
					        });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        it('does nothing', async () => {
 | 
					 | 
					 | 
					 | 
					        it('does nothing', async () => {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -403,6 +415,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.VERIFIED,
 | 
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.VERIFIED,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            });
 | 
					 | 
					 | 
					 | 
					            });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          });
 | 
					 | 
					 | 
					 | 
					          });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          it('does not save the new identity (because this is a less secure state)', async () => {
 | 
					 | 
					 | 
					 | 
					          it('does not save the new identity (because this is a less secure state)', async () => {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -434,6 +447,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.VERIFIED,
 | 
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.VERIFIED,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            });
 | 
					 | 
					 | 
					 | 
					            });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          });
 | 
					 | 
					 | 
					 | 
					          });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          it('updates the verified status', async () => {
 | 
					 | 
					 | 
					 | 
					          it('updates the verified status', async () => {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -462,6 +476,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.DEFAULT,
 | 
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.DEFAULT,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            });
 | 
					 | 
					 | 
					 | 
					            });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          });
 | 
					 | 
					 | 
					 | 
					          });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          it('does not hang', async () => {
 | 
					 | 
					 | 
					 | 
					          it('does not hang', async () => {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -480,6 +495,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      describe('when there is no existing record', () => {
 | 
					 | 
					 | 
					 | 
					      describe('when there is no existing record', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        before(async () => {
 | 
					 | 
					 | 
					 | 
					        before(async () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          await window.Signal.Data.removeIdentityKeyById(number);
 | 
					 | 
					 | 
					 | 
					          await window.Signal.Data.removeIdentityKeyById(number);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        });
 | 
					 | 
					 | 
					 | 
					        });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        it('saves the new identity and marks it verified', async () => {
 | 
					 | 
					 | 
					 | 
					        it('saves the new identity and marks it verified', async () => {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -510,6 +526,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.VERIFIED,
 | 
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.VERIFIED,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            });
 | 
					 | 
					 | 
					 | 
					            });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          });
 | 
					 | 
					 | 
					 | 
					          });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          it('saves the new identity and marks it UNVERIFIED', async () => {
 | 
					 | 
					 | 
					 | 
					          it('saves the new identity and marks it UNVERIFIED', async () => {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -541,6 +558,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.DEFAULT,
 | 
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.DEFAULT,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            });
 | 
					 | 
					 | 
					 | 
					            });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          });
 | 
					 | 
					 | 
					 | 
					          });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          it('updates the verified status', async () => {
 | 
					 | 
					 | 
					 | 
					          it('updates the verified status', async () => {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -571,6 +589,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.UNVERIFIED,
 | 
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.UNVERIFIED,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            });
 | 
					 | 
					 | 
					 | 
					            });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          });
 | 
					 | 
					 | 
					 | 
					          });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          it('does not hang', async () => {
 | 
					 | 
					 | 
					 | 
					          it('does not hang', async () => {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -589,6 +608,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      describe('when there is no existing record', () => {
 | 
					 | 
					 | 
					 | 
					      describe('when there is no existing record', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        before(async () => {
 | 
					 | 
					 | 
					 | 
					        before(async () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          await window.Signal.Data.removeIdentityKeyById(number);
 | 
					 | 
					 | 
					 | 
					          await window.Signal.Data.removeIdentityKeyById(number);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					          await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        });
 | 
					 | 
					 | 
					 | 
					        });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        it('saves the new identity and marks it verified', async () => {
 | 
					 | 
					 | 
					 | 
					        it('saves the new identity and marks it verified', async () => {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -615,6 +635,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.VERIFIED,
 | 
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.VERIFIED,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            });
 | 
					 | 
					 | 
					 | 
					            });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          });
 | 
					 | 
					 | 
					 | 
					          });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          it('saves the new identity and marks it VERIFIED', async () => {
 | 
					 | 
					 | 
					 | 
					          it('saves the new identity and marks it VERIFIED', async () => {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -646,6 +667,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.UNVERIFIED,
 | 
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.UNVERIFIED,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            });
 | 
					 | 
					 | 
					 | 
					            });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          });
 | 
					 | 
					 | 
					 | 
					          });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          it('saves the identity and marks it verified', async () => {
 | 
					 | 
					 | 
					 | 
					          it('saves the identity and marks it verified', async () => {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -676,6 +698,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.VERIFIED,
 | 
					 | 
					 | 
					 | 
					              verified: store.VerifiedStatus.VERIFIED,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
					 | 
					 | 
					 | 
					              nonblockingApproval: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					            });
 | 
					 | 
					 | 
					 | 
					            });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					            await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          });
 | 
					 | 
					 | 
					 | 
					          });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					          it('does not hang', async () => {
 | 
					 | 
					 | 
					 | 
					          it('does not hang', async () => {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -703,6 +726,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        nonblockingApproval: false,
 | 
					 | 
					 | 
					 | 
					        nonblockingApproval: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      });
 | 
					 | 
					 | 
					 | 
					      });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      const untrusted = await store.isUntrusted(number);
 | 
					 | 
					 | 
					 | 
					      const untrusted = await store.isUntrusted(number);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      assert.strictEqual(untrusted, false);
 | 
					 | 
					 | 
					 | 
					      assert.strictEqual(untrusted, false);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    });
 | 
					 | 
					 | 
					 | 
					    });
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -716,6 +740,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        firstUse: false,
 | 
					 | 
					 | 
					 | 
					        firstUse: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        nonblockingApproval: true,
 | 
					 | 
					 | 
					 | 
					        nonblockingApproval: true,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      });
 | 
					 | 
					 | 
					 | 
					      });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      const untrusted = await store.isUntrusted(number);
 | 
					 | 
					 | 
					 | 
					      const untrusted = await store.isUntrusted(number);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      assert.strictEqual(untrusted, false);
 | 
					 | 
					 | 
					 | 
					      assert.strictEqual(untrusted, false);
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -730,6 +755,7 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        firstUse: true,
 | 
					 | 
					 | 
					 | 
					        firstUse: true,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        nonblockingApproval: false,
 | 
					 | 
					 | 
					 | 
					        nonblockingApproval: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      });
 | 
					 | 
					 | 
					 | 
					      });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      const untrusted = await store.isUntrusted(number);
 | 
					 | 
					 | 
					 | 
					      const untrusted = await store.isUntrusted(number);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      assert.strictEqual(untrusted, false);
 | 
					 | 
					 | 
					 | 
					      assert.strictEqual(untrusted, false);
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -744,6 +770,8 @@ describe('SignalProtocolStore', () => {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        firstUse: false,
 | 
					 | 
					 | 
					 | 
					        firstUse: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        nonblockingApproval: false,
 | 
					 | 
					 | 
					 | 
					        nonblockingApproval: false,
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      });
 | 
					 | 
					 | 
					 | 
					      });
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					      await store.hydrateCaches();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      const untrusted = await store.isUntrusted(number);
 | 
					 | 
					 | 
					 | 
					      const untrusted = await store.isUntrusted(number);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      assert.strictEqual(untrusted, true);
 | 
					 | 
					 | 
					 | 
					      assert.strictEqual(untrusted, true);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    });
 | 
					 | 
					 | 
					 | 
					    });
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
 
 |