You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			36 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			JavaScript
		
	
			
		
		
	
	
			36 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			JavaScript
		
	
/* global libsignal, textsecure */
 | 
						|
 | 
						|
describe('Protocol Wrapper', function thisNeeded() {
 | 
						|
  const store = textsecure.storage.protocol;
 | 
						|
  const identifier = '+5558675309';
 | 
						|
 | 
						|
  this.timeout(5000);
 | 
						|
 | 
						|
  before(done => {
 | 
						|
    localStorage.clear();
 | 
						|
    libsignal.KeyHelper.generateIdentityKeyPair()
 | 
						|
      .then(key => textsecure.storage.protocol.saveIdentity(identifier, key))
 | 
						|
      .then(() => {
 | 
						|
        done();
 | 
						|
      });
 | 
						|
  });
 | 
						|
 | 
						|
  describe('processPreKey', () => {
 | 
						|
    it('rejects if the identity key changes', () => {
 | 
						|
      const address = new libsignal.SignalProtocolAddress(identifier, 1);
 | 
						|
      const builder = new libsignal.SessionBuilder(store, address);
 | 
						|
      return builder
 | 
						|
        .processPreKey({
 | 
						|
          identityKey: textsecure.crypto.getRandomBytes(33),
 | 
						|
          encodedNumber: address.toString(),
 | 
						|
        })
 | 
						|
        .then(() => {
 | 
						|
          throw new Error('Allowed to overwrite identity key');
 | 
						|
        })
 | 
						|
        .catch(e => {
 | 
						|
          assert.strictEqual(e.message, 'Identity key changed');
 | 
						|
        });
 | 
						|
    });
 | 
						|
  });
 | 
						|
});
 |