[Add] Description
Some checks failed
CI / checks (push) Failing after 1m55s

[Add] AuthenticationPolicy on host
This commit is contained in:
Alex Emmet 2026-07-02 19:39:40 +02:00
commit 56903049b6
4 changed files with 349 additions and 102 deletions

View file

@ -302,12 +302,15 @@ impl WasmClient {
.await?;
let version_str = format!("{}", PROTOCOL_VERSION);
let ident = CommunicationValue::new(CommunicationType::Identification)
let mut ident = CommunicationValue::new(CommunicationType::Identification)
.add_typed_default(DataType::Version, DataValue::Str(version_str))
.add_typed_default(
DataType::Id,
DataValue::UnsignedNumber(config.client_id as u128),
);
if let Some(desc) = &config.description {
ident = ident.add_typed_default(DataType::Description, DataValue::Str(desc.clone()));
}
let ident_bytes = ident
.to_bytes()
.map_err(|e| js_error(&format!("encode failed: {}", e)))?;
@ -351,12 +354,16 @@ impl WasmClient {
.await?;
// 1. Send the unsigned Identification hello.
let hello = CommunicationValue::new(CommunicationType::Identification)
let mut hello = CommunicationValue::new(CommunicationType::Identification)
.add_typed_default(DataType::Version, DataValue::Str(version_str.clone()))
.add_typed_default(DataType::Id, DataValue::UnsignedNumber(client_id as u128))
.add_typed_default(DataType::Id, DataValue::UnsignedNumber(client_id as u128));
if let Some(desc) = &config.description {
hello = hello.add_typed_default(DataType::Description, DataValue::Str(desc.clone()));
}
let hello_bytes = hello
.to_bytes()
.map_err(|e| js_error(&format!("encode failed: {}", e)))?;
transport.send_frame(&hello).await?;
transport.send_frame(&hello_bytes).await?;
// 2. Receive and verify the host's challenge.
let server_challenge = self
@ -463,12 +470,16 @@ impl WasmClient {
.await?;
// 1. Send the unsigned Register hello (version + public-key bundle).
let hello = CommunicationValue::new(CommunicationType::Register)
let mut hello = CommunicationValue::new(CommunicationType::Register)
.add_typed_default(DataType::Version, DataValue::Str(version_str.clone()))
.add_typed_default(DataType::PublicKeys, DataValue::Bytes(pk_bytes.clone()))
.add_typed_default(DataType::PublicKeys, DataValue::Bytes(pk_bytes.clone()));
if let Some(desc) = &config.description {
hello = hello.add_typed_default(DataType::Description, DataValue::Str(desc.clone()));
}
let hello_bytes = hello
.to_bytes()
.map_err(|e| js_error(&format!("encode failed: {}", e)))?;
transport.send_frame(&hello).await?;
transport.send_frame(&hello_bytes).await?;
// 2. Receive and verify the host's challenge (register binds id = 0).
let server_challenge = self

View file

@ -6,6 +6,7 @@ pub struct ConnectionConfig {
pub(crate) server_certificate_hashes: Option<Vec<String>>,
pub(crate) client_id: u64,
pub(crate) max_message_size: u32,
pub(crate) description: Option<String>,
}
#[wasm_bindgen]
@ -17,6 +18,7 @@ impl ConnectionConfig {
server_certificate_hashes: None,
client_id: 0,
max_message_size: 1_000_000_000,
description: None,
}
}
@ -49,4 +51,14 @@ impl ConnectionConfig {
pub fn max_message_size(&self) -> u32 {
self.max_message_size
}
#[wasm_bindgen(setter)]
pub fn set_description(&mut self, description: String) {
self.description = Some(description);
}
#[wasm_bindgen(getter)]
pub fn description(&self) -> Option<String> {
self.description.clone()
}
}