| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -34,8 +34,8 @@
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  async function DHDecrypt(symmetricKey, ivAndCiphertext) {
 | 
					 | 
					 | 
					 | 
					  async function DHDecrypt(symmetricKey, ivAndCiphertext) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const iv = ivAndCiphertext.slice(0, IV_LENGTH);
 | 
					 | 
					 | 
					 | 
					    const iv = ivAndCiphertext.slice(0, IV_LENGTH);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const cipherText = ivAndCiphertext.slice(IV_LENGTH);
 | 
					 | 
					 | 
					 | 
					    const ciphertext = ivAndCiphertext.slice(IV_LENGTH);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return libsignal.crypto.decrypt(symmetricKey, cipherText, iv);
 | 
					 | 
					 | 
					 | 
					    return libsignal.crypto.decrypt(symmetricKey, ciphertext, iv);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  }
 | 
					 | 
					 | 
					 | 
					  }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  class FallBackSessionCipher {
 | 
					 | 
					 | 
					 | 
					  class FallBackSessionCipher {
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					 | 
					@ -131,18 +131,18 @@
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      return this._ephemeralPubKeyHex;
 | 
					 | 
					 | 
					 | 
					      return this._ephemeralPubKeyHex;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    async decrypt(snodeAddress, ivAndCipherTextBase64) {
 | 
					 | 
					 | 
					 | 
					    async decrypt(snodeAddress, ivAndCiphertextBase64) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      const ivAndCipherText = dcodeIO.ByteBuffer.wrap(
 | 
					 | 
					 | 
					 | 
					      const ivAndCiphertext = dcodeIO.ByteBuffer.wrap(
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        ivAndCipherTextBase64,
 | 
					 | 
					 | 
					 | 
					        ivAndCiphertextBase64,
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        'base64'
 | 
					 | 
					 | 
					 | 
					        'base64'
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      ).toArrayBuffer();
 | 
					 | 
					 | 
					 | 
					      ).toArrayBuffer();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      const symmetricKey = await this._getSymmetricKey(snodeAddress);
 | 
					 | 
					 | 
					 | 
					      const symmetricKey = await this._getSymmetricKey(snodeAddress);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      try {
 | 
					 | 
					 | 
					 | 
					      try {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        const decrypted = await DHDecrypt(symmetricKey, ivAndCipherText);
 | 
					 | 
					 | 
					 | 
					        const decrypted = await DHDecrypt(symmetricKey, ivAndCiphertext);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        const decoder = new TextDecoder();
 | 
					 | 
					 | 
					 | 
					        const decoder = new TextDecoder();
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return decoder.decode(decrypted);
 | 
					 | 
					 | 
					 | 
					        return decoder.decode(decrypted);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      } catch (e) {
 | 
					 | 
					 | 
					 | 
					      } catch (e) {
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        return ivAndCipherText;
 | 
					 | 
					 | 
					 | 
					        return ivAndCiphertext;
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      }
 | 
					 | 
					 | 
					 | 
					      }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -153,17 +153,15 @@
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					        plainText = textEncoder.encode(plainText);
 | 
					 | 
					 | 
					 | 
					        plainText = textEncoder.encode(plainText);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      }
 | 
					 | 
					 | 
					 | 
					      }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      const symmetricKey = await this._getSymmetricKey(snodeAddress);
 | 
					 | 
					 | 
					 | 
					      const symmetricKey = await this._getSymmetricKey(snodeAddress);
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      const cipherText = await DHEncrypt(symmetricKey, plainText);
 | 
					 | 
					 | 
					 | 
					      const ciphertext = await DHEncrypt(symmetricKey, plainText);
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      return dcodeIO.ByteBuffer.wrap(cipherText).toString('base64');
 | 
					 | 
					 | 
					 | 
					      return dcodeIO.ByteBuffer.wrap(ciphertext).toString('base64');
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    }
 | 
					 | 
					 | 
					 | 
					    }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  }
 | 
					 | 
					 | 
					 | 
					  }
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  async function decryptToken({ ivAndCipherText64, serverPubKey64 }) {
 | 
					 | 
					 | 
					 | 
					  async function decryptToken({ cipherText64, serverPubKey64 }) {
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const ivAndCipherText = new Uint8Array(
 | 
					 | 
					 | 
					 | 
					    const ivAndCiphertext = new Uint8Array(
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      dcodeIO.ByteBuffer.fromBase64(ivAndCipherText64).toArrayBuffer()
 | 
					 | 
					 | 
					 | 
					      dcodeIO.ByteBuffer.fromBase64(cipherText64).toArrayBuffer()
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    );
 | 
					 | 
					 | 
					 | 
					    );
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const iv = ivAndCipherText.slice(0, IV_LENGTH);
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const cipherText = ivAndCipherText.slice(IV_LENGTH);
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const serverPubKey = new Uint8Array(
 | 
					 | 
					 | 
					 | 
					    const serverPubKey = new Uint8Array(
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      dcodeIO.ByteBuffer.fromBase64(serverPubKey64).toArrayBuffer()
 | 
					 | 
					 | 
					 | 
					      dcodeIO.ByteBuffer.fromBase64(serverPubKey64).toArrayBuffer()
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -174,7 +172,8 @@
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					      privKey
 | 
					 | 
					 | 
					 | 
					      privKey
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    );
 | 
					 | 
					 | 
					 | 
					    );
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const token = await libsignal.crypto.decrypt(symmetricKey, cipherText, iv);
 | 
					 | 
					 | 
					 | 
					    const token = await DHDecrypt(symmetricKey, ivAndCiphertext);
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    const tokenString = dcodeIO.ByteBuffer.wrap(token).toString('utf8');
 | 
					 | 
					 | 
					 | 
					    const tokenString = dcodeIO.ByteBuffer.wrap(token).toString('utf8');
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					    return tokenString;
 | 
					 | 
					 | 
					 | 
					    return tokenString;
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					  }
 | 
					 | 
					 | 
					 | 
					  }
 | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
 
 |