initial commit
Some checks failed
CI / lint (push) Successful in 1m37s
CI / test-python (push) Successful in 1m49s
CI / test-zig (push) Successful in 1m39s
CI / test-wasm (push) Successful in 1m54s
CI / test (push) Successful in 14m44s
CI / miri (push) Successful in 14m18s
CI / build (push) Successful in 1m9s
CI / fuzz-regression (push) Successful in 9m9s
CI / publish (push) Failing after 1m10s
CI / publish-python (push) Failing after 1m46s
CI / publish-wasm (push) Has been cancelled
Some checks failed
CI / lint (push) Successful in 1m37s
CI / test-python (push) Successful in 1m49s
CI / test-zig (push) Successful in 1m39s
CI / test-wasm (push) Successful in 1m54s
CI / test (push) Successful in 14m44s
CI / miri (push) Successful in 14m18s
CI / build (push) Successful in 1m9s
CI / fuzz-regression (push) Successful in 9m9s
CI / publish (push) Failing after 1m10s
CI / publish-python (push) Failing after 1m46s
CI / publish-wasm (push) Has been cancelled
Signed-off-by: Kamal Tufekcic <kamal@lo.sh>
This commit is contained in:
commit
1d99048c95
165830 changed files with 79062 additions and 0 deletions
54
soliton_wasm/src/call.rs
Normal file
54
soliton_wasm/src/call.rs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
//! Call key derivation.
|
||||
|
||||
use crate::errors::to_js_err;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
/// Call keys for encrypted voice/video media.
|
||||
///
|
||||
/// Call `free()` when done to zeroize key material.
|
||||
#[wasm_bindgen]
|
||||
pub struct CallKeys {
|
||||
inner: Option<soliton::call::CallKeys>,
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
impl CallKeys {
|
||||
/// Current send key (32 bytes).
|
||||
#[wasm_bindgen(js_name = "sendKey")]
|
||||
pub fn send_key(&self) -> Result<Vec<u8>, JsValue> {
|
||||
let inner = self
|
||||
.inner
|
||||
.as_ref()
|
||||
.ok_or_else(|| crate::errors::js_error("call keys consumed"))?;
|
||||
Ok(inner.send_key().to_vec())
|
||||
}
|
||||
|
||||
/// Current recv key (32 bytes).
|
||||
#[wasm_bindgen(js_name = "recvKey")]
|
||||
pub fn recv_key(&self) -> Result<Vec<u8>, JsValue> {
|
||||
let inner = self
|
||||
.inner
|
||||
.as_ref()
|
||||
.ok_or_else(|| crate::errors::js_error("call keys consumed"))?;
|
||||
Ok(inner.recv_key().to_vec())
|
||||
}
|
||||
|
||||
/// Advance the call chain — derives fresh keys, zeroizes old ones.
|
||||
pub fn advance(&mut self) -> Result<(), JsValue> {
|
||||
let inner = self
|
||||
.inner
|
||||
.as_mut()
|
||||
.ok_or_else(|| crate::errors::js_error("call keys consumed"))?;
|
||||
inner.advance().map_err(to_js_err)
|
||||
}
|
||||
|
||||
pub fn free(&mut self) {
|
||||
self.inner = None;
|
||||
}
|
||||
}
|
||||
|
||||
impl CallKeys {
|
||||
pub fn from_inner(inner: soliton::call::CallKeys) -> Self {
|
||||
Self { inner: Some(inner) }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue