Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API for examining roster of ExportedTree #249

Merged
merged 2 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mls-rs-codec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ assert_matches = "1.5.0"
wasm-bindgen-test = { version = "=0.3.26", default-features = false }

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = { version = "=0.2.87" }
wasm-bindgen = { version = "=0.2.100" }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(mls_build_async)'] }
2 changes: 1 addition & 1 deletion mls-rs-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ assert_matches = "1.5.0"
wasm-bindgen-test = { version = "=0.3.26", default-features = false }

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = { version = "=0.2.87" }
wasm-bindgen = { version = "=0.2.100" }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(mls_build_async)', 'cfg(coverage_nightly)'] }
2 changes: 1 addition & 1 deletion mls-rs-crypto-webcrypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ zeroize = { version = "1", features = ["zeroize_derive"] }
maybe-async = "0.2.10"
async-trait = "0.1.74"
js-sys = "0.3.64"
wasm-bindgen = "=0.2.87"
wasm-bindgen = "=0.2.100"
wasm-bindgen-futures = "0.4.37"
serde-wasm-bindgen = "0.6"
serde = { version = "1.0", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion mls-rs-identity-x509/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ wasm-bindgen-test = { version = "=0.3.26", default-features = false }
getrandom = { version = "0.2", features = ["js"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = { version = "=0.2.87" }
wasm-bindgen = { version = "=0.2.100" }

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(mls_build_async)'] }
2 changes: 1 addition & 1 deletion mls-rs-provider-sqlite/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "Apache-2.0 OR MIT"
[dependencies]
mls-rs-core = { path = "../mls-rs-core", version = "0.20.0" }
thiserror = "1.0.40"
wasm-bindgen = { version = "=0.2.87", optional = true }
wasm-bindgen = { version = "=0.2.100", optional = true }
zeroize = { version = "1", features = ["zeroize_derive"] }
rusqlite = { version = "0.31", default-features = false }
rand = "0.8"
Expand Down
4 changes: 2 additions & 2 deletions mls-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mls-rs"
version = "0.44.0"
version = "0.44.1"
edition = "2021"
description = "An implementation of Messaging Layer Security (RFC 9420)"
homepage = "https://github.com/awslabs/mls-rs"
Expand Down Expand Up @@ -101,7 +101,7 @@ serde = { version = "1.0", default-features = false, features = ["alloc", "deriv
hex = { version = "^0.4.3", default-features = false, features = ["serde", "alloc"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = { version = "=0.2.87" }
wasm-bindgen = { version = "=0.2.100" }
getrandom = { version = "0.2", features = ["js", "custom"], default-features = false }
rand_core = { version = "0.6", default-features = false, features = ["alloc"] }

Expand Down
8 changes: 8 additions & 0 deletions mls-rs/src/group/exported_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use mls_rs_codec::{MlsDecode, MlsEncode, MlsSize};

use crate::{client::MlsError, tree_kem::node::NodeVec};

use super::Roster;

#[cfg_attr(
all(feature = "ffi", not(test)),
safer_ffi_gen::ffi_type(clone, opaque)
Expand Down Expand Up @@ -35,6 +37,12 @@ impl<'a> ExportedTree<'a> {
pub fn into_owned(self) -> ExportedTree<'static> {
ExportedTree(Cow::Owned(self.0.into_owned()))
}

pub fn roster(&'a self) -> Roster<'a> {
Roster {
public_tree: &self.0,
}
}
}

#[cfg_attr(all(feature = "ffi", not(test)), ::safer_ffi_gen::safer_ffi_gen)]
Expand Down
10 changes: 7 additions & 3 deletions mls-rs/src/group/roster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Copyright by contributors to this project.
// SPDX-License-Identifier: (Apache-2.0 OR MIT)

use crate::tree_kem::node::NodeVec;

use super::*;

pub use mls_rs_core::group::Member;
Expand All @@ -21,7 +23,7 @@ pub(crate) fn member_from_leaf_node(leaf_node: &LeafNode, leaf_index: LeafIndex)
)]
#[derive(Clone, Debug)]
pub struct Roster<'a> {
pub(crate) public_tree: &'a TreeKemPublic,
pub(crate) public_tree: &'a NodeVec,
}

#[cfg_attr(all(feature = "ffi", not(test)), safer_ffi_gen::safer_ffi_gen)]
Expand Down Expand Up @@ -60,7 +62,7 @@ impl<'a> Roster<'a> {
let index = LeafIndex(index);

self.public_tree
.get_leaf_node(index)
.borrow_as_leaf(index)
.map(|l| member_from_leaf_node(l, index))
}

Expand All @@ -81,6 +83,8 @@ impl<'a> Roster<'a> {

impl TreeKemPublic {
pub(crate) fn roster(&self) -> Roster {
Roster { public_tree: self }
Roster {
public_tree: &self.nodes,
}
}
}
Loading