v0.0.35: WASM create_call_signal, selectable identity, web sections

FC-P3-T2: WASM create_call_signal() export
- Accepts signal_type string (offer/answer/hangup/etc), payload, target
- Returns bincode WireMessage::CallSignal bytes for WS send

FC-P3-T9: Selectable identity display in web
- ETH address shown in code-style block, click to copy
- addSys() gains rawHtml parameter for rich content

FC-P3-T5: Section navigation comments in web.rs
- 5 section markers: State, Crypto, Network, UI, Commands

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Siavash Sameni
2026-03-29 16:00:43 +04:00
parent 0e7277fb20
commit 0b58ddcee5
5 changed files with 74 additions and 16 deletions

View File

@@ -627,6 +627,46 @@ pub fn create_sender_key_from_distribution(
Ok(hex::encode(encoded))
}
/// Create a CallSignal WireMessage for sending via WebSocket.
///
/// Arguments:
/// - identity: the WasmIdentity of the sender
/// - signal_type: "offer" | "answer" | "ice_candidate" | "hangup" | "reject" | "ringing" | "busy"
/// - payload: SDP offer/answer, ICE candidate JSON, or empty string
/// - target: recipient fingerprint or group name
///
/// Returns: bincode-serialized WireMessage bytes
#[wasm_bindgen]
pub fn create_call_signal(
identity: &WasmIdentity,
signal_type: &str,
payload: &str,
target: &str,
) -> Result<Vec<u8>, JsValue> {
use warzone_protocol::message::{CallSignalType, WireMessage};
let st = match signal_type.to_lowercase().as_str() {
"offer" => CallSignalType::Offer,
"answer" => CallSignalType::Answer,
"ice_candidate" | "icecandidate" => CallSignalType::IceCandidate,
"hangup" => CallSignalType::Hangup,
"reject" => CallSignalType::Reject,
"ringing" => CallSignalType::Ringing,
"busy" => CallSignalType::Busy,
_ => return Err(JsValue::from_str(&format!("unknown signal type: {}", signal_type))),
};
let wire = WireMessage::CallSignal {
id: uuid::Uuid::new_v4().to_string(),
sender_fingerprint: identity.pub_id.fingerprint.to_string(),
signal_type: st,
payload: payload.to_string(),
target: target.to_string(),
};
bincode::serialize(&wire).map_err(|e| JsValue::from_str(&format!("serialize: {}", e)))
}
// Tests live in warzone-protocol to avoid js-sys dependency issues.
// See warzone-protocol/src/x3dh.rs tests for web-client simulation.