Skip to content

Remove duplicated Cipher and Folder client #225

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

Merged
merged 20 commits into from
May 23, 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
1 change: 1 addition & 0 deletions .github/workflows/build-wasm-internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:

- name: NPM setup
run: npm ci
working-directory: crates/bitwarden-wasm-internal/npm

- name: Install rust
uses: dtolnay/rust-toolchain@56f84321dbccf38fb67ce29ab63e4754056677e0 # stable
Expand Down
46 changes: 33 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ bitwarden-api-identity = { path = "crates/bitwarden-api-identity", version = "=1
bitwarden-cli = { path = "crates/bitwarden-cli", version = "=1.0.0" }
bitwarden-core = { path = "crates/bitwarden-core", version = "=1.0.0" }
bitwarden-crypto = { path = "crates/bitwarden-crypto", version = "=1.0.0" }
bitwarden-error = { path = "crates/bitwarden-error", version = "=1.0.0" }
bitwarden-error-macro = { path = "crates/bitwarden-error-macro", version = "=1.0.0" }
bitwarden-exporters = { path = "crates/bitwarden-exporters", version = "=1.0.0" }
bitwarden-fido = { path = "crates/bitwarden-fido", version = "=1.0.0" }
bitwarden-generators = { path = "crates/bitwarden-generators", version = "=1.0.0" }
Expand All @@ -32,17 +34,20 @@ bitwarden-send = { path = "crates/bitwarden-send", version = "=1.0.0" }
bitwarden-threading = { path = "crates/bitwarden-threading", version = "=1.0.0" }
bitwarden-sm = { path = "bitwarden_license/bitwarden-sm", version = "=1.0.0" }
bitwarden-ssh = { path = "crates/bitwarden-ssh", version = "=1.0.0" }
bitwarden-uuid = { path = "crates/bitwarden-uuid", version = "=1.0.0" }
bitwarden-uuid-macro = { path = "crates/bitwarden-uuid-macro", version = "=1.0.0" }
bitwarden-vault = { path = "crates/bitwarden-vault", version = "=1.0.0" }
bitwarden-error = { path = "crates/bitwarden-error", version = "=1.0.0" }
bitwarden-error-macro = { path = "crates/bitwarden-error-macro", version = "=1.0.0" }

# External crates that are expected to maintain a consistent version across all crates
chrono = { version = ">=0.4.26, <0.5", features = [
"clock",
"serde",
"std",
], default-features = false }
js-sys = { version = ">=0.3.72, <0.4" }
log = ">=0.4.18, <0.5"
proc-macro2 = ">=1.0.89, <2"
quote = ">=1.0.37, <2"
reqwest = { version = ">=0.12.5, <0.13", features = [
"json",
"multipart",
Expand All @@ -53,6 +58,7 @@ serde = { version = ">=1.0, <2.0", features = ["derive"] }
serde_json = ">=1.0.96, <2.0"
serde_qs = ">=0.12.0, <0.16"
serde_repr = ">=0.1.12, <0.2"
syn = ">=2.0.87, <3"
thiserror = ">=1.0.40, <3"
tokio = { version = "1.36.0", features = ["macros"] }
tsify-next = { version = ">=0.5.4, <0.6", features = [
Expand All @@ -62,7 +68,6 @@ uniffi = "=0.28.3"
uuid = { version = ">=1.3.3, <2.0", features = ["serde", "v4", "js"] }
validator = { version = ">=0.18.1, <0.20", features = ["derive"] }
wasm-bindgen = { version = ">=0.2.91, <0.3", features = ["serde-serialize"] }
js-sys = { version = ">=0.3.72, <0.4" }
wasm-bindgen-futures = "0.4.41"
wasm-bindgen-test = "0.3.45"

Expand Down
1 change: 1 addition & 0 deletions crates/bitwarden-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ bitwarden-api-api = { workspace = true }
bitwarden-api-identity = { workspace = true }
bitwarden-crypto = { workspace = true }
bitwarden-error = { workspace = true }
bitwarden-uuid = { workspace = true }
chrono = { workspace = true, features = ["std"] }
# We don't use this directly (it's used by rand), but we need it here to enable WASM support
getrandom = { version = ">=0.2.9, <0.3", features = ["js"] }
Expand Down
3 changes: 3 additions & 0 deletions crates/bitwarden-core/src/ids.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use bitwarden_uuid::uuid;

uuid!(pub OrganizationId);
3 changes: 3 additions & 0 deletions crates/bitwarden-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,6 @@ mod util;

pub use bitwarden_crypto::ZeroizingAllocator;
pub use client::{Client, ClientSettings, DeviceType};

mod ids;
pub use ids::*;
6 changes: 3 additions & 3 deletions crates/bitwarden-error-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ wasm = []

[dependencies]
darling = "0.20.10"
proc-macro2 = "1.0.89"
quote = "1.0.37"
syn = "2.0.87"
proc-macro2 = { workspace = true }
quote = { workspace = true }
syn = { workspace = true }

[lints]
workspace = true
Expand Down
3 changes: 2 additions & 1 deletion crates/bitwarden-uniffi/src/vault/ciphers.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use bitwarden_core::OrganizationId;
use bitwarden_vault::{Cipher, CipherListView, CipherView, EncryptionContext, Fido2CredentialView};
use uuid::Uuid;

Expand Down Expand Up @@ -41,7 +42,7 @@
) -> Result<CipherView> {
Ok(self
.0
.move_to_organization(cipher, organization_id)
.move_to_organization(cipher, OrganizationId::new(organization_id))

Check warning on line 45 in crates/bitwarden-uniffi/src/vault/ciphers.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden-uniffi/src/vault/ciphers.rs#L45

Added line #L45 was not covered by tests
.map_err(Error::Cipher)?)
}
}
26 changes: 26 additions & 0 deletions crates/bitwarden-uuid-macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "bitwarden-uuid-macro"
description = """
Internal crate for the bitwarden crate. Do not use.
"""

version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
readme.workspace = true
homepage.workspace = true
repository.workspace = true
license-file.workspace = true
keywords.workspace = true

[dependencies]
proc-macro2 = { workspace = true }
quote = { workspace = true }
syn = { workspace = true }

[lints]
workspace = true

[lib]
proc-macro = true
3 changes: 3 additions & 0 deletions crates/bitwarden-uuid-macro/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Bitwarden UUID Macro

Provides uuid macros for simplifying UUID handling when working with WebAssembly.
75 changes: 75 additions & 0 deletions crates/bitwarden-uuid-macro/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#![doc = include_str!("../README.md")]

use proc_macro::TokenStream;
use quote::quote;
use syn::{
parse::{Parse, ParseStream},
parse_macro_input, Ident, Visibility,
};

#[proc_macro]
pub fn uuid(input: TokenStream) -> TokenStream {
// Parse input as: vis ident
let input = parse_macro_input!(input as IdTypeInput);
let ident = input.ident;
let vis = input.vis;
let name_str = ident.to_string();

let tsify_type = format!("Tagged<Uuid, \"{}\">", name_str);
let doc_string = format!(" NewType wrapper for `{}`", name_str);

let expanded = quote! {
#[doc = #doc_string]
#[cfg_attr(feature = "wasm", derive(::tsify_next::Tsify), tsify(into_wasm_abi, from_wasm_abi))]
#[derive(
::serde::Serialize, ::serde::Deserialize,
::std::cmp::PartialEq, ::std::cmp::Eq,
::std::clone::Clone, ::std::marker::Copy, ::std::fmt::Debug
)]
#[repr(transparent)]
#vis struct #ident
(
#[cfg_attr(feature = "wasm", tsify(type = #tsify_type))]
::uuid::Uuid
);

#[cfg(feature = "uniffi")]
uniffi::custom_newtype!(#ident, uuid::Uuid);

impl #ident {
pub fn new(value: uuid::Uuid) -> Self {
Self(value)
}
}

impl ::std::str::FromStr for #ident {
type Err = uuid::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
uuid::Uuid::from_str(s).map(Self)
}
}

impl From<#ident> for ::uuid::Uuid {
fn from(value: #ident) -> Self {
value.0
}
}
};

TokenStream::from(expanded)
}

// Helper struct to parse "vis ident"
struct IdTypeInput {
vis: Visibility,
ident: Ident,
}

impl Parse for IdTypeInput {
fn parse(input: ParseStream) -> syn::Result<Self> {
let vis: Visibility = input.parse()?;
let ident: Ident = input.parse()?;
Ok(IdTypeInput { vis, ident })
}
}
26 changes: 26 additions & 0 deletions crates/bitwarden-uuid/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "bitwarden-uuid"
description = """
Internal crate for the bitwarden crate. Do not use.
"""

version.workspace = true
authors.workspace = true
edition.workspace = true
rust-version.workspace = true
readme.workspace = true
homepage.workspace = true
repository.workspace = true
license-file.workspace = true
keywords.workspace = true

[dependencies]
bitwarden-uuid-macro = { workspace = true }

[lints]
workspace = true

[dev-dependencies]
serde = { workspace = true }
serde_json = { workspace = true }
uuid = { workspace = true }
3 changes: 3 additions & 0 deletions crates/bitwarden-uuid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Bitwarden UUID

Provides UUID macros for simplifying UUID handling when working with WebAssembly.
3 changes: 3 additions & 0 deletions crates/bitwarden-uuid/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#![doc = include_str!("../README.md")]

pub use bitwarden_uuid_macro::uuid;
Loading
Loading