feat(client): redesign native UI, themes, settings and avatars
Separate conversation drafts and voice view state, add native settings and restricted CSS themes, implement validated avatar cropping, and refresh dependencies with documented desktop compatibility backports.
This commit is contained in:
parent
44d284a568
commit
8e5ab56611
276 changed files with 53546 additions and 3399 deletions
|
|
@ -11,12 +11,12 @@ fn make_nonce(cid: &[u8; 8], seq: u64) -> [u8; 12] {
|
|||
}
|
||||
|
||||
pub fn encrypt_with_key(key: &[u8; 32], cid: &[u8; 8], seq: u64, plaintext: &[u8]) -> Vec<u8> {
|
||||
let cipher = ChaCha20Poly1305::new(Key::from_slice(key));
|
||||
let cipher = ChaCha20Poly1305::new(&Key::from(*key));
|
||||
let nonce_bytes = make_nonce(cid, seq);
|
||||
let nonce = Nonce::from_slice(&nonce_bytes);
|
||||
let nonce = Nonce::from(nonce_bytes);
|
||||
cipher
|
||||
.encrypt(
|
||||
nonce,
|
||||
&nonce,
|
||||
Payload {
|
||||
msg: plaintext,
|
||||
aad: &[],
|
||||
|
|
@ -31,12 +31,12 @@ pub fn decrypt_with_key(
|
|||
seq: u64,
|
||||
ciphertext: &[u8],
|
||||
) -> anyhow::Result<Vec<u8>> {
|
||||
let cipher = ChaCha20Poly1305::new(Key::from_slice(key));
|
||||
let cipher = ChaCha20Poly1305::new(&Key::from(*key));
|
||||
let nonce_bytes = make_nonce(cid, seq);
|
||||
let nonce = Nonce::from_slice(&nonce_bytes);
|
||||
let nonce = Nonce::from(nonce_bytes);
|
||||
cipher
|
||||
.decrypt(
|
||||
nonce,
|
||||
&nonce,
|
||||
Payload {
|
||||
msg: ciphertext,
|
||||
aad: &[],
|
||||
|
|
@ -44,3 +44,25 @@ pub fn decrypt_with_key(
|
|||
)
|
||||
.map_err(|e| anyhow::anyhow!("decryption failed: {e:?}"))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn ciphertext_matches_existing_lnex_wire_format() {
|
||||
let key = core::array::from_fn(|index| index as u8);
|
||||
let cid = [7, 0, 0, 0, 0x40, 0x41, 0x42, 0x43];
|
||||
// Independently checked with Python cryptography and shared with gateway.
|
||||
let expected = hex::decode(
|
||||
"1fa23e7a312509b0fc8729521811348ff880daa5598c43a57635975f81278abdf4461b25af86aee1c3",
|
||||
)
|
||||
.unwrap();
|
||||
let ciphertext = encrypt_with_key(&key, &cid, 0x47464544, b"VNOX dependency migration");
|
||||
assert_eq!(ciphertext, expected);
|
||||
assert_eq!(
|
||||
decrypt_with_key(&key, &cid, 0x47464544, &expected).unwrap(),
|
||||
b"VNOX dependency migration",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ impl SessionCrypto {
|
|||
}
|
||||
|
||||
pub fn new_ephemeral() -> (EphemeralSecret, PublicKey) {
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = rand::rng();
|
||||
let sk = EphemeralSecret::random_from_rng(&mut rng);
|
||||
let pk = PublicKey::from(&sk);
|
||||
(sk, pk)
|
||||
|
|
|
|||
|
|
@ -66,12 +66,9 @@ pub async fn session_loop(
|
|||
let pkt = result?;
|
||||
if pkt.packet_id == PID_CHANNEL_STATE
|
||||
&& let Ok(p) = serde_json::from_slice::<ChannelStatePayload>(&pkt.payload)
|
||||
&& !p.voice_endpoint.is_empty()
|
||||
{
|
||||
voice_endpoint = if p.voice_endpoint.is_empty() {
|
||||
None
|
||||
} else {
|
||||
p.voice_endpoint.parse().ok()
|
||||
};
|
||||
voice_endpoint = p.voice_endpoint.parse().ok();
|
||||
}
|
||||
internal::dispatch::incoming(pkt.packet_id, &pkt.payload, event_tx).await?;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue