From 85ac7c440d792705f612de66772bf67a35613cd2 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 7 Jun 2024 18:08:28 +0200 Subject: [PATCH 001/214] Use Fido2Credential instead of view in CipherView (#821) We don't need to expose the `Fido2CredentialView` for ciphers since the data isn't used by the UI. Instead we can expose the encrypted view and ensure it is re-encrypted on move. --- .../src/platform/fido2/authenticator.rs | 11 ++- crates/bitwarden/src/vault/cipher/cipher.rs | 90 ++++++++++++++++++- crates/bitwarden/src/vault/cipher/login.rs | 40 ++++----- crates/bitwarden/src/vault/cipher/mod.rs | 1 - 4 files changed, 115 insertions(+), 27 deletions(-) diff --git a/crates/bitwarden/src/platform/fido2/authenticator.rs b/crates/bitwarden/src/platform/fido2/authenticator.rs index 69aae6f0c..96e53ad00 100644 --- a/crates/bitwarden/src/platform/fido2/authenticator.rs +++ b/crates/bitwarden/src/platform/fido2/authenticator.rs @@ -15,7 +15,7 @@ use super::{ Fido2UserInterface, SelectedCredential, AAGUID, }; use crate::{ - error::{require, Error, Result}, + error::{Error, Result}, platform::fido2::string_to_guid_bytes, vault::{ login::Fido2CredentialView, CipherView, Fido2CredentialFullView, Fido2CredentialNewView, @@ -163,10 +163,12 @@ impl<'a> Fido2Authenticator<'a> { &mut self, rp_id: String, ) -> Result> { + let enc = self.client.get_encryption_settings()?; let result = self.credential_store.find_credentials(None, rp_id).await?; + Ok(result .into_iter() - .filter_map(|c| c.login?.fido2_credentials) + .flat_map(|c| c.decrypt_fido2_credentials(enc)) .flatten() .collect()) } @@ -198,6 +200,8 @@ impl<'a> Fido2Authenticator<'a> { } pub(super) fn get_selected_credential(&self) -> Result { + let enc = self.client.get_encryption_settings()?; + let cipher = self .selected_credential .lock() @@ -205,8 +209,7 @@ impl<'a> Fido2Authenticator<'a> { .clone() .ok_or("No selected credential available")?; - let login = require!(cipher.login.as_ref()); - let creds = require!(login.fido2_credentials.as_ref()); + let creds = cipher.decrypt_fido2_credentials(enc)?; let credential = creds.first().ok_or("No Fido2 credentials found")?.clone(); diff --git a/crates/bitwarden/src/vault/cipher/cipher.rs b/crates/bitwarden/src/vault/cipher/cipher.rs index 15a1c124c..3b688df32 100644 --- a/crates/bitwarden/src/vault/cipher/cipher.rs +++ b/crates/bitwarden/src/vault/cipher/cipher.rs @@ -15,10 +15,10 @@ use super::{ login, secure_note, }; #[cfg(feature = "uniffi")] -use crate::vault::Fido2CredentialFullView; +use crate::{client::encryption_settings::EncryptionSettings, vault::Fido2CredentialView}; use crate::{ error::{require, Error, Result}, - vault::password_history, + vault::{password_history, Fido2CredentialFullView}, }; #[derive(Clone, Copy, Serialize_repr, Deserialize_repr, Debug, JsonSchema)] @@ -349,6 +349,7 @@ impl CipherView { let new_key = SymmetricCryptoKey::generate(rand::thread_rng()); self.reencrypt_attachment_keys(old_key, &new_key)?; + self.reencrypt_fido2_credentials(old_key, &new_key)?; self.key = Some(new_key.to_vec().encrypt_with_key(key)?); Ok(()) @@ -384,6 +385,40 @@ impl CipherView { Ok(()) } + #[cfg(feature = "uniffi")] + pub(crate) fn decrypt_fido2_credentials( + &self, + enc: &EncryptionSettings, + ) -> Result> { + let key = self.locate_key(enc, &None).ok_or(Error::VaultLocked)?; + let cipher_key = Cipher::get_cipher_key(key, &self.key)?; + + let key = cipher_key.as_ref().unwrap_or(key); + + Ok(self + .login + .as_ref() + .and_then(|l| l.fido2_credentials.as_ref()) + .map(|f| f.decrypt_with_key(key)) + .transpose()? + .unwrap_or_default()) + } + + fn reencrypt_fido2_credentials( + &mut self, + old_key: &SymmetricCryptoKey, + new_key: &SymmetricCryptoKey, + ) -> Result<()> { + if let Some(login) = self.login.as_mut() { + if let Some(fido2_credentials) = &mut login.fido2_credentials { + let dec_fido2_credentials: Vec = + fido2_credentials.decrypt_with_key(old_key)?; + *fido2_credentials = dec_fido2_credentials.encrypt_with_key(new_key)?; + } + } + Ok(()) + } + pub fn move_to_organization( &mut self, enc: &dyn KeyContainer, @@ -409,6 +444,7 @@ impl CipherView { } else { // If the cipher does not have a key, we need to reencrypt all attachment keys self.reencrypt_attachment_keys(old_key, new_key)?; + self.reencrypt_fido2_credentials(old_key, new_key)?; } self.organization_id = Some(organization_id); @@ -572,6 +608,7 @@ mod tests { use std::collections::HashMap; use attachment::AttachmentView; + use login::Fido2Credential; use super::*; @@ -612,6 +649,24 @@ mod tests { } } + fn generate_fido2(key: &SymmetricCryptoKey) -> Fido2Credential { + Fido2Credential { + credential_id: "123".to_string().encrypt_with_key(key).unwrap(), + key_type: "public-key".to_string().encrypt_with_key(key).unwrap(), + key_algorithm: "ECDSA".to_string().encrypt_with_key(key).unwrap(), + key_curve: "P-256".to_string().encrypt_with_key(key).unwrap(), + key_value: "123".to_string().encrypt_with_key(key).unwrap(), + rp_id: "123".to_string().encrypt_with_key(key).unwrap(), + user_handle: None, + user_name: None, + counter: "123".to_string().encrypt_with_key(key).unwrap(), + rp_name: None, + user_display_name: None, + discoverable: "true".to_string().encrypt_with_key(key).unwrap(), + creation_date: "2024-06-07T14:12:36.150Z".parse().unwrap(), + } + } + #[test] fn test_generate_cipher_key() { let key = SymmetricCryptoKey::generate(rand::thread_rng()); @@ -776,6 +831,8 @@ mod tests { key: Some(attachment_key_enc), }; cipher.attachments = Some(vec![attachment]); + let cred = generate_fido2(enc.get_key(&None).unwrap()); + cipher.login.as_mut().unwrap().fido2_credentials = Some(vec![cred]); cipher.move_to_organization(&enc, org).unwrap(); @@ -789,6 +846,18 @@ mod tests { .unwrap(); let new_attachment_key_dec: SymmetricCryptoKey = new_attachment_key_dec.try_into().unwrap(); assert_eq!(new_attachment_key_dec.to_vec(), attachment_key.to_vec()); + + let cred2: Fido2CredentialFullView = cipher + .login + .unwrap() + .fido2_credentials + .unwrap() + .first() + .unwrap() + .decrypt_with_key(enc.get_key(&Some(org)).unwrap()) + .unwrap(); + + assert_eq!(cred2.credential_id, "123"); } #[test] @@ -826,6 +895,9 @@ mod tests { }; cipher.attachments = Some(vec![attachment]); + let cred = generate_fido2(&cipher_key); + cipher.login.as_mut().unwrap().fido2_credentials = Some(vec![cred.clone()]); + cipher.move_to_organization(&enc, org).unwrap(); // Check that the cipher key has been re-encrypted with the org key, @@ -849,6 +921,20 @@ mod tests { .to_string(), attachment_key_enc.to_string() ); + + let cred2: Fido2Credential = cipher + .login + .unwrap() + .fido2_credentials + .unwrap() + .first() + .unwrap() + .clone(); + + assert_eq!( + cred2.credential_id.to_string(), + cred.credential_id.to_string() + ); } #[test] diff --git a/crates/bitwarden/src/vault/cipher/login.rs b/crates/bitwarden/src/vault/cipher/login.rs index 85ab98ff6..47dc71dc5 100644 --- a/crates/bitwarden/src/vault/cipher/login.rs +++ b/crates/bitwarden/src/vault/cipher/login.rs @@ -169,24 +169,24 @@ impl From for Fido2CredentialNewView { } } -impl KeyEncryptable for Fido2CredentialFullView { - fn encrypt_with_key( - self, - key: &SymmetricCryptoKey, - ) -> Result { - Ok(Fido2CredentialView { - credential_id: self.credential_id, - key_type: self.key_type, - key_algorithm: self.key_algorithm, - key_curve: self.key_curve, +impl KeyEncryptable for Fido2CredentialFullView { + fn encrypt_with_key(self, key: &SymmetricCryptoKey) -> Result { + Ok(Fido2Credential { + credential_id: self.credential_id.encrypt_with_key(key)?, + key_type: self.key_type.encrypt_with_key(key)?, + key_algorithm: self.key_algorithm.encrypt_with_key(key)?, + key_curve: self.key_curve.encrypt_with_key(key)?, key_value: self.key_value.encrypt_with_key(key)?, - rp_id: self.rp_id, - user_handle: self.user_handle, - user_name: self.user_name, - counter: self.counter, - rp_name: self.rp_name, - user_display_name: self.user_display_name, - discoverable: self.discoverable, + rp_id: self.rp_id.encrypt_with_key(key)?, + user_handle: self + .user_handle + .map(|h| h.encrypt_with_key(key)) + .transpose()?, + user_name: self.user_name.encrypt_with_key(key)?, + counter: self.counter.encrypt_with_key(key)?, + rp_name: self.rp_name.encrypt_with_key(key)?, + user_display_name: self.user_display_name.encrypt_with_key(key)?, + discoverable: self.discoverable.encrypt_with_key(key)?, creation_date: self.creation_date, }) } @@ -266,7 +266,7 @@ pub struct LoginView { pub autofill_on_page_load: Option, // TODO: Remove this once the SDK supports state - pub fido2_credentials: Option>, + pub fido2_credentials: Option>, } impl KeyEncryptable for LoginUriView { @@ -288,7 +288,7 @@ impl KeyEncryptable for LoginView { uris: self.uris.encrypt_with_key(key)?, totp: self.totp.encrypt_with_key(key)?, autofill_on_page_load: self.autofill_on_page_load, - fido2_credentials: self.fido2_credentials.encrypt_with_key(key)?, + fido2_credentials: self.fido2_credentials, }) } } @@ -312,7 +312,7 @@ impl KeyDecryptable for Login { uris: self.uris.decrypt_with_key(key).ok().flatten(), totp: self.totp.decrypt_with_key(key).ok().flatten(), autofill_on_page_load: self.autofill_on_page_load, - fido2_credentials: self.fido2_credentials.decrypt_with_key(key).ok().flatten(), + fido2_credentials: self.fido2_credentials.clone(), }) } } diff --git a/crates/bitwarden/src/vault/cipher/mod.rs b/crates/bitwarden/src/vault/cipher/mod.rs index 91e5bc7eb..92a4e10ad 100644 --- a/crates/bitwarden/src/vault/cipher/mod.rs +++ b/crates/bitwarden/src/vault/cipher/mod.rs @@ -14,7 +14,6 @@ pub use attachment::{ }; pub use cipher::{Cipher, CipherListView, CipherRepromptType, CipherType, CipherView}; pub use field::FieldView; -#[cfg(feature = "uniffi")] pub(crate) use login::Fido2CredentialFullView; pub use login::{Fido2Credential, Fido2CredentialNewView, Fido2CredentialView}; pub use secure_note::SecureNoteType; From 5ee45a1eabee4c67206e6ea39b709382b0b51636 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 10 Jun 2024 14:17:39 +0200 Subject: [PATCH 002/214] [PM-8301] Create bitwarden-core with macro and uniffi (#824) Extract the `require` macro and common uniffi logic to a new crate called `bitwarden-core` since it's required for extracting other bitwarden functionality. --- .github/workflows/publish-rust-crates.yml | 11 +++++ Cargo.lock | 14 ++++++- Cargo.toml | 1 + crates/bitwarden-core/Cargo.toml | 26 ++++++++++++ crates/bitwarden-core/src/error.rs | 19 +++++++++ crates/bitwarden-core/src/lib.rs | 7 ++++ crates/bitwarden-core/src/uniffi_support.rs | 41 +++++++++++++++++++ crates/bitwarden-core/uniffi.toml | 9 ++++ crates/bitwarden-crypto/Cargo.toml | 1 - crates/bitwarden-exporters/Cargo.toml | 3 -- crates/bitwarden-uniffi/Cargo.toml | 1 + crates/bitwarden-uniffi/src/uniffi_support.rs | 4 +- crates/bitwarden/Cargo.toml | 3 +- crates/bitwarden/src/admin_console/policy.rs | 3 +- .../bitwarden/src/auth/login/access_token.rs | 3 +- crates/bitwarden/src/auth/login/api_key.rs | 3 +- .../bitwarden/src/auth/login/auth_request.rs | 3 +- crates/bitwarden/src/auth/login/password.rs | 3 +- crates/bitwarden/src/error.rs | 18 +------- .../src/platform/get_user_api_key.rs | 3 +- .../src/secrets_manager/projects/delete.rs | 6 +-- .../projects/project_response.rs | 6 +-- .../src/secrets_manager/secrets/delete.rs | 6 +-- .../src/secrets_manager/secrets/list.rs | 3 +- .../secrets/secret_response.rs | 6 +-- .../src/secrets_manager/secrets/sync.rs | 7 +--- crates/bitwarden/src/tool/exporters/mod.rs | 3 +- crates/bitwarden/src/tool/send.rs | 3 +- crates/bitwarden/src/uniffi_support.rs | 33 ++------------- crates/bitwarden/src/vault/cipher/cipher.rs | 3 +- crates/bitwarden/src/vault/cipher/field.rs | 3 +- .../bitwarden/src/vault/cipher/linked_id.rs | 3 +- crates/bitwarden/src/vault/cipher/login.rs | 3 +- .../bitwarden/src/vault/cipher/secure_note.rs | 3 +- crates/bitwarden/src/vault/collection.rs | 3 +- crates/bitwarden/src/vault/domain.rs | 3 +- crates/bitwarden/src/vault/folder.rs | 3 +- crates/bitwarden/src/vault/sync.rs | 3 +- crates/bitwarden/uniffi.toml | 6 +-- .../bitwarden/myapplication/MainActivity.kt | 8 ++-- 40 files changed, 190 insertions(+), 100 deletions(-) create mode 100644 crates/bitwarden-core/Cargo.toml create mode 100644 crates/bitwarden-core/src/error.rs create mode 100644 crates/bitwarden-core/src/lib.rs create mode 100644 crates/bitwarden-core/src/uniffi_support.rs create mode 100644 crates/bitwarden-core/uniffi.toml diff --git a/.github/workflows/publish-rust-crates.yml b/.github/workflows/publish-rust-crates.yml index 399810d9b..013fcd254 100644 --- a/.github/workflows/publish-rust-crates.yml +++ b/.github/workflows/publish-rust-crates.yml @@ -29,6 +29,11 @@ on: required: true default: true type: boolean + publish_bitwarden-core: + description: "Publish bitwarden-core crate" + required: true + default: true + type: boolean publish_bitwarden-crypto: description: "Publish bitwarden-crypto crate" required: true @@ -81,6 +86,7 @@ jobs: PUBLISH_BITWARDEN: ${{ github.event.inputs.publish_bitwarden }} PUBLISH_BITWARDEN_API_API: ${{ github.event.inputs.publish_bitwarden-api-api }} PUBLISH_BITWARDEN_API_IDENTITY: ${{ github.event.inputs.publish_bitwarden-api-identity }} + PUBLISH_BITWARDEN_CORE: ${{ github.event.inputs.publish_bitwarden-core }} PUBLISH_BITWARDEN_CRYPTO: ${{ github.event.inputs.publish_bitwarden-crypto }} PUBLISH_BITWARDEN_CLI: ${{ github.event.inputs.publish_bitwarden-cli }} PUBLISH_BITWARDEN_GENERATORS: ${{ github.event.inputs.publish_bitwarden-generators }} @@ -111,6 +117,11 @@ jobs: PACKAGES_LIST="$PACKAGES_LIST bitwarden-api-identity" fi + if [[ "$PUBLISH_BITWARDEN_CORE" == "true" ]]; then + PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-core" + PACKAGES_LIST="$PACKAGES_LIST bitwarden-core" + fi + if [[ "$PUBLISH_BITWARDEN_CRYPTO" == "true" ]]; then PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-crypto" PACKAGES_LIST="$PACKAGES_LIST bitwarden-crypto" diff --git a/Cargo.lock b/Cargo.lock index 6864413c1..a78c2d18e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -369,9 +369,10 @@ name = "bitwarden" version = "0.5.0" dependencies = [ "async-trait", - "base64 0.22.1", + "base64 0.21.7", "bitwarden-api-api", "bitwarden-api-identity", + "bitwarden-core", "bitwarden-crypto", "bitwarden-exporters", "bitwarden-generators", @@ -448,6 +449,16 @@ dependencies = [ "supports-color", ] +[[package]] +name = "bitwarden-core" +version = "0.5.0" +dependencies = [ + "chrono", + "thiserror", + "uniffi", + "uuid", +] + [[package]] name = "bitwarden-crypto" version = "0.5.0" @@ -554,6 +565,7 @@ dependencies = [ "async-lock", "async-trait", "bitwarden", + "bitwarden-core", "bitwarden-crypto", "bitwarden-generators", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 1f32654dc..2da09446c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ bitwarden = { path = "crates/bitwarden", version = "=0.5.0" } bitwarden-api-api = { path = "crates/bitwarden-api-api", version = "=0.5.0" } bitwarden-api-identity = { path = "crates/bitwarden-api-identity", version = "=0.5.0" } bitwarden-cli = { path = "crates/bitwarden-cli", version = "=0.5.0" } +bitwarden-core = { path = "crates/bitwarden-core", version = "=0.5.0" } bitwarden-crypto = { path = "crates/bitwarden-crypto", version = "=0.5.0" } bitwarden-exporters = { path = "crates/bitwarden-exporters", version = "=0.5.0" } bitwarden-generators = { path = "crates/bitwarden-generators", version = "=0.5.0" } diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml new file mode 100644 index 000000000..5f755020c --- /dev/null +++ b/crates/bitwarden-core/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "bitwarden-core" +description = """ +Internal crate for the bitwarden crate. Do not use. +""" + +version.workspace = true +authors.workspace = true +edition.workspace = true +rust-version.workspace = true +homepage.workspace = true +repository.workspace = true +license-file.workspace = true +keywords.workspace = true + +[features] +uniffi = ["dep:uniffi"] + +[dependencies] +chrono = { version = ">=0.4.26, <0.5", default-features = false } +uniffi = { version = "=0.27.2", optional = true } +uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } +thiserror = ">=1.0.40, <2.0" + +[lints] +workspace = true diff --git a/crates/bitwarden-core/src/error.rs b/crates/bitwarden-core/src/error.rs new file mode 100644 index 000000000..e2d890ecb --- /dev/null +++ b/crates/bitwarden-core/src/error.rs @@ -0,0 +1,19 @@ +use thiserror::Error; + +#[derive(Debug, Error)] +#[error("The response received was missing a required field: {0}")] +pub struct MissingFieldError(pub &'static str); + +/// This macro is used to require that a value is present or return an error otherwise. +/// It is equivalent to using `val.ok_or(Error::MissingFields)?`, but easier to use and +/// with a more descriptive error message. +/// Note that this macro will return early from the function if the value is not present. +#[macro_export] +macro_rules! require { + ($val:expr) => { + match $val { + Some(val) => val, + None => return Err($crate::MissingFieldError(stringify!($val)).into()), + } + }; +} diff --git a/crates/bitwarden-core/src/lib.rs b/crates/bitwarden-core/src/lib.rs new file mode 100644 index 000000000..1e62111b5 --- /dev/null +++ b/crates/bitwarden-core/src/lib.rs @@ -0,0 +1,7 @@ +#[cfg(feature = "uniffi")] +uniffi::setup_scaffolding!(); +#[cfg(feature = "uniffi")] +mod uniffi_support; + +mod error; +pub use error::MissingFieldError; diff --git a/crates/bitwarden-core/src/uniffi_support.rs b/crates/bitwarden-core/src/uniffi_support.rs new file mode 100644 index 000000000..320df6cb5 --- /dev/null +++ b/crates/bitwarden-core/src/uniffi_support.rs @@ -0,0 +1,41 @@ +use uuid::Uuid; + +use crate::UniffiCustomTypeConverter; + +type DateTime = chrono::DateTime; +uniffi::custom_type!(DateTime, std::time::SystemTime); + +impl UniffiCustomTypeConverter for chrono::DateTime { + type Builtin = std::time::SystemTime; + + fn into_custom(val: Self::Builtin) -> uniffi::Result { + Ok(Self::from(val)) + } + + fn from_custom(obj: Self) -> Self::Builtin { + obj.into() + } +} + +uniffi::custom_type!(Uuid, String); + +impl UniffiCustomTypeConverter for Uuid { + type Builtin = String; + + fn into_custom(val: Self::Builtin) -> uniffi::Result { + Uuid::parse_str(val.as_str()).map_err(|e| e.into()) + } + + fn from_custom(obj: Self) -> Self::Builtin { + obj.to_string() + } +} + +// Uniffi doesn't emit unused types, this is a dummy record to ensure that the custom type +// converters are emitted +#[allow(dead_code)] +#[derive(uniffi::Record)] +struct UniffiConverterDummyRecord { + uuid: Uuid, + date: DateTime, +} diff --git a/crates/bitwarden-core/uniffi.toml b/crates/bitwarden-core/uniffi.toml new file mode 100644 index 000000000..7a804ef1d --- /dev/null +++ b/crates/bitwarden-core/uniffi.toml @@ -0,0 +1,9 @@ +[bindings.kotlin] +package_name = "com.bitwarden.core" +generate_immutable_records = true +android = true + +[bindings.swift] +ffi_module_name = "BitwardenCoreFFI" +module_name = "BitwardenCore" +generate_immutable_records = true diff --git a/crates/bitwarden-crypto/Cargo.toml b/crates/bitwarden-crypto/Cargo.toml index b15770ced..e03a8d5c1 100644 --- a/crates/bitwarden-crypto/Cargo.toml +++ b/crates/bitwarden-crypto/Cargo.toml @@ -18,7 +18,6 @@ default = [] uniffi = ["dep:uniffi"] # Uniffi bindings no-memory-hardening = [] # Disable memory hardening features -test = [] # Test methods [dependencies] aes = { version = ">=0.8.2, <0.9", features = ["zeroize"] } diff --git a/crates/bitwarden-exporters/Cargo.toml b/crates/bitwarden-exporters/Cargo.toml index 96097c628..b607879ba 100644 --- a/crates/bitwarden-exporters/Cargo.toml +++ b/crates/bitwarden-exporters/Cargo.toml @@ -28,8 +28,5 @@ serde_json = ">=1.0.96, <2.0" thiserror = ">=1.0.40, <2.0" uuid = { version = ">=1.3.3, <2.0", features = ["serde", "v4"] } -[dev-dependencies] -bitwarden-crypto = { workspace = true, features = ["test"] } - [lints] workspace = true diff --git a/crates/bitwarden-uniffi/Cargo.toml b/crates/bitwarden-uniffi/Cargo.toml index 62f9e5806..92cd1f3e9 100644 --- a/crates/bitwarden-uniffi/Cargo.toml +++ b/crates/bitwarden-uniffi/Cargo.toml @@ -21,6 +21,7 @@ bench = false async-lock = "3.3.0" async-trait = "0.1.80" bitwarden = { workspace = true, features = ["internal", "uniffi"] } +bitwarden-core = { workspace = true, features = ["uniffi"] } bitwarden-crypto = { workspace = true, features = ["uniffi"] } bitwarden-generators = { workspace = true, features = ["uniffi"] } chrono = { version = ">=0.4.26, <0.5", features = [ diff --git a/crates/bitwarden-uniffi/src/uniffi_support.rs b/crates/bitwarden-uniffi/src/uniffi_support.rs index a3422d752..74f484869 100644 --- a/crates/bitwarden-uniffi/src/uniffi_support.rs +++ b/crates/bitwarden-uniffi/src/uniffi_support.rs @@ -3,7 +3,7 @@ use uuid::Uuid; // Forward the type definitions to the main bitwarden crate type DateTime = chrono::DateTime; -uniffi::ffi_converter_forward!(DateTime, bitwarden::UniFfiTag, crate::UniFfiTag); +uniffi::ffi_converter_forward!(DateTime, bitwarden_core::UniFfiTag, crate::UniFfiTag); uniffi::ffi_converter_forward!(EncString, bitwarden::UniFfiTag, crate::UniFfiTag); uniffi::ffi_converter_forward!(AsymmetricEncString, bitwarden::UniFfiTag, crate::UniFfiTag); -uniffi::ffi_converter_forward!(Uuid, bitwarden::UniFfiTag, crate::UniFfiTag); +uniffi::ffi_converter_forward!(Uuid, bitwarden_core::UniFfiTag, crate::UniFfiTag); diff --git a/crates/bitwarden/Cargo.toml b/crates/bitwarden/Cargo.toml index 8bfafc462..1bde11717 100644 --- a/crates/bitwarden/Cargo.toml +++ b/crates/bitwarden/Cargo.toml @@ -24,6 +24,7 @@ no-memory-hardening = [ "bitwarden-crypto/no-memory-hardening", ] # Disable memory hardening features uniffi = [ + "bitwarden-core/uniffi", "bitwarden-crypto/uniffi", "bitwarden-generators/uniffi", "dep:uniffi", @@ -39,6 +40,7 @@ async-trait = ">=0.1.80, <0.2" base64 = ">=0.21.2, <0.23" bitwarden-api-api = { workspace = true } bitwarden-api-identity = { workspace = true } +bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } bitwarden-exporters = { workspace = true, optional = true } bitwarden-generators = { workspace = true, optional = true } @@ -95,7 +97,6 @@ reqwest = { version = ">=0.12, <0.13", features = [ security-framework = { version = "=2.10" } [dev-dependencies] -bitwarden-crypto = { workspace = true, features = ["test"] } rand_chacha = "0.3.1" tokio = { version = "1.36.0", features = ["rt", "macros"] } wiremock = "0.6.0" diff --git a/crates/bitwarden/src/admin_console/policy.rs b/crates/bitwarden/src/admin_console/policy.rs index d8ed0b761..6c0a2ec65 100644 --- a/crates/bitwarden/src/admin_console/policy.rs +++ b/crates/bitwarden/src/admin_console/policy.rs @@ -1,12 +1,13 @@ use std::collections::HashMap; use bitwarden_api_api::models::PolicyResponseModel; +use bitwarden_core::require; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; use uuid::Uuid; -use crate::error::{require, Error, Result}; +use crate::error::{Error, Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] pub struct Policy { diff --git a/crates/bitwarden/src/auth/login/access_token.rs b/crates/bitwarden/src/auth/login/access_token.rs index 9366e631f..a376eb0c3 100644 --- a/crates/bitwarden/src/auth/login/access_token.rs +++ b/crates/bitwarden/src/auth/login/access_token.rs @@ -1,6 +1,7 @@ use std::path::{Path, PathBuf}; use base64::{engine::general_purpose::STANDARD, Engine}; +use bitwarden_core::require; use bitwarden_crypto::{EncString, KeyDecryptable, SymmetricCryptoKey}; use chrono::Utc; use schemars::JsonSchema; @@ -14,7 +15,7 @@ use crate::{ AccessToken, JWTToken, }, client::{LoginMethod, ServiceAccountLoginMethod}, - error::{require, Error, Result}, + error::{Error, Result}, secrets_manager::state::{self, ClientState}, Client, }; diff --git a/crates/bitwarden/src/auth/login/api_key.rs b/crates/bitwarden/src/auth/login/api_key.rs index 8b83e3a38..3882931ba 100644 --- a/crates/bitwarden/src/auth/login/api_key.rs +++ b/crates/bitwarden/src/auth/login/api_key.rs @@ -1,3 +1,4 @@ +use bitwarden_core::require; use bitwarden_crypto::{EncString, MasterKey}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -9,7 +10,7 @@ use crate::{ JWTToken, }, client::{LoginMethod, UserLoginMethod}, - error::{require, Result}, + error::Result, Client, }; diff --git a/crates/bitwarden/src/auth/login/auth_request.rs b/crates/bitwarden/src/auth/login/auth_request.rs index fb449e5d4..6a8005b6d 100644 --- a/crates/bitwarden/src/auth/login/auth_request.rs +++ b/crates/bitwarden/src/auth/login/auth_request.rs @@ -2,6 +2,7 @@ use bitwarden_api_api::{ apis::auth_requests_api::{auth_requests_id_response_get, auth_requests_post}, models::{AuthRequestCreateRequestModel, AuthRequestType}, }; +use bitwarden_core::require; use bitwarden_crypto::Kdf; use uuid::Uuid; @@ -11,7 +12,7 @@ use crate::{ auth_request::new_auth_request, }, client::{LoginMethod, UserLoginMethod}, - error::{require, Result}, + error::Result, mobile::crypto::{AuthRequestMethod, InitUserCryptoMethod, InitUserCryptoRequest}, Client, }; diff --git a/crates/bitwarden/src/auth/login/password.rs b/crates/bitwarden/src/auth/login/password.rs index e0cb67dbe..4960b498b 100644 --- a/crates/bitwarden/src/auth/login/password.rs +++ b/crates/bitwarden/src/auth/login/password.rs @@ -22,9 +22,10 @@ pub(crate) async fn login_password( client: &mut Client, input: &PasswordLoginRequest, ) -> Result { + use bitwarden_core::require; use bitwarden_crypto::{EncString, HashPurpose, MasterKey}; - use crate::{client::UserLoginMethod, error::require}; + use crate::client::UserLoginMethod; info!("password logging in"); diff --git a/crates/bitwarden/src/error.rs b/crates/bitwarden/src/error.rs index bc06a7591..9f264b465 100644 --- a/crates/bitwarden/src/error.rs +++ b/crates/bitwarden/src/error.rs @@ -15,6 +15,8 @@ use thiserror::Error; #[derive(Debug, Error)] pub enum Error { + #[error(transparent)] + MissingFieldError(#[from] bitwarden_core::MissingFieldError), #[error("The client is not authenticated or the session has expired")] NotAuthenticated, @@ -26,8 +28,6 @@ pub enum Error { #[error("The response received was invalid and could not be processed")] InvalidResponse, - #[error("The response received was missing some of the required fields: {0}")] - MissingFields(&'static str), #[error("Cryptography error, {0}")] Crypto(#[from] bitwarden_crypto::CryptoError), @@ -154,18 +154,4 @@ macro_rules! impl_bitwarden_error { impl_bitwarden_error!(ApiError); impl_bitwarden_error!(IdentityError); -/// This macro is used to require that a value is present or return an error otherwise. -/// It is equivalent to using `val.ok_or(Error::MissingFields)?`, but easier to use and -/// with a more descriptive error message. -/// Note that this macro will return early from the function if the value is not present. -macro_rules! require { - ($val:expr) => { - match $val { - Some(val) => val, - None => return Err($crate::error::Error::MissingFields(stringify!($val))), - } - }; -} -pub(crate) use require; - pub type Result = std::result::Result; diff --git a/crates/bitwarden/src/platform/get_user_api_key.rs b/crates/bitwarden/src/platform/get_user_api_key.rs index 3e408d926..207721f44 100644 --- a/crates/bitwarden/src/platform/get_user_api_key.rs +++ b/crates/bitwarden/src/platform/get_user_api_key.rs @@ -2,6 +2,7 @@ use bitwarden_api_api::{ apis::accounts_api::accounts_api_key_post, models::{ApiKeyResponseModel, SecretVerificationRequestModel}, }; +use bitwarden_core::require; use bitwarden_crypto::{HashPurpose, MasterKey}; use log::{debug, info}; use schemars::JsonSchema; @@ -10,7 +11,7 @@ use serde::{Deserialize, Serialize}; use super::SecretVerificationRequest; use crate::{ client::{LoginMethod, UserLoginMethod}, - error::{require, Error, Result}, + error::{Error, Result}, Client, }; diff --git a/crates/bitwarden/src/secrets_manager/projects/delete.rs b/crates/bitwarden/src/secrets_manager/projects/delete.rs index 05c808c7e..bfc6e2d82 100644 --- a/crates/bitwarden/src/secrets_manager/projects/delete.rs +++ b/crates/bitwarden/src/secrets_manager/projects/delete.rs @@ -1,14 +1,12 @@ use bitwarden_api_api::models::{ BulkDeleteResponseModel, BulkDeleteResponseModelListResponseModel, }; +use bitwarden_core::require; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; -use crate::{ - client::Client, - error::{require, Result}, -}; +use crate::{client::Client, error::Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] diff --git a/crates/bitwarden/src/secrets_manager/projects/project_response.rs b/crates/bitwarden/src/secrets_manager/projects/project_response.rs index 82e98dff0..e8cac63fd 100644 --- a/crates/bitwarden/src/secrets_manager/projects/project_response.rs +++ b/crates/bitwarden/src/secrets_manager/projects/project_response.rs @@ -1,14 +1,12 @@ use bitwarden_api_api::models::ProjectResponseModel; +use bitwarden_core::require; use bitwarden_crypto::{CryptoError, EncString, KeyDecryptable}; use chrono::{DateTime, Utc}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; -use crate::{ - client::encryption_settings::EncryptionSettings, - error::{require, Result}, -}; +use crate::{client::encryption_settings::EncryptionSettings, error::Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] diff --git a/crates/bitwarden/src/secrets_manager/secrets/delete.rs b/crates/bitwarden/src/secrets_manager/secrets/delete.rs index f3fe264e1..1c54e4169 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/delete.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/delete.rs @@ -1,14 +1,12 @@ use bitwarden_api_api::models::{ BulkDeleteResponseModel, BulkDeleteResponseModelListResponseModel, }; +use bitwarden_core::require; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; -use crate::{ - client::Client, - error::{require, Result}, -}; +use crate::{client::Client, error::Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] diff --git a/crates/bitwarden/src/secrets_manager/secrets/list.rs b/crates/bitwarden/src/secrets_manager/secrets/list.rs index 6cfa85516..a5d263253 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/list.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/list.rs @@ -1,6 +1,7 @@ use bitwarden_api_api::models::{ SecretWithProjectsListResponseModel, SecretsWithProjectsInnerSecret, }; +use bitwarden_core::require; use bitwarden_crypto::{CryptoError, EncString, KeyDecryptable}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -8,7 +9,7 @@ use uuid::Uuid; use crate::{ client::{encryption_settings::EncryptionSettings, Client}, - error::{require, Result}, + error::Result, }; #[derive(Serialize, Deserialize, Debug, JsonSchema)] diff --git a/crates/bitwarden/src/secrets_manager/secrets/secret_response.rs b/crates/bitwarden/src/secrets_manager/secrets/secret_response.rs index 3b89629a4..4f306078d 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/secret_response.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/secret_response.rs @@ -1,16 +1,14 @@ use bitwarden_api_api::models::{ BaseSecretResponseModel, BaseSecretResponseModelListResponseModel, SecretResponseModel, }; +use bitwarden_core::require; use bitwarden_crypto::{CryptoError, EncString, KeyDecryptable}; use chrono::{DateTime, Utc}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; -use crate::{ - client::encryption_settings::EncryptionSettings, - error::{require, Result}, -}; +use crate::{client::encryption_settings::EncryptionSettings, error::Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] diff --git a/crates/bitwarden/src/secrets_manager/secrets/sync.rs b/crates/bitwarden/src/secrets_manager/secrets/sync.rs index e2546022d..565f25ecb 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/sync.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/sync.rs @@ -1,15 +1,12 @@ use bitwarden_api_api::models::SecretsSyncResponseModel; +use bitwarden_core::require; use chrono::{DateTime, Utc}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; use super::SecretResponse; -use crate::{ - client::encryption_settings::EncryptionSettings, - error::{require, Result}, - Client, -}; +use crate::{client::encryption_settings::EncryptionSettings, error::Result, Client}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] diff --git a/crates/bitwarden/src/tool/exporters/mod.rs b/crates/bitwarden/src/tool/exporters/mod.rs index 359cab8c5..b52b91813 100644 --- a/crates/bitwarden/src/tool/exporters/mod.rs +++ b/crates/bitwarden/src/tool/exporters/mod.rs @@ -1,10 +1,11 @@ +use bitwarden_core::require; use bitwarden_crypto::KeyDecryptable; use bitwarden_exporters::export; use schemars::JsonSchema; use crate::{ client::{LoginMethod, UserLoginMethod}, - error::{require, Error, Result}, + error::{Error, Result}, vault::{ login::LoginUriView, Cipher, CipherType, CipherView, Collection, FieldView, Folder, FolderView, SecureNoteType, diff --git a/crates/bitwarden/src/tool/send.rs b/crates/bitwarden/src/tool/send.rs index 2ce83dd0a..ce99396f1 100644 --- a/crates/bitwarden/src/tool/send.rs +++ b/crates/bitwarden/src/tool/send.rs @@ -3,6 +3,7 @@ use base64::{ Engine, }; use bitwarden_api_api::models::{SendFileModel, SendResponseModel, SendTextModel}; +use bitwarden_core::require; use bitwarden_crypto::{ derive_shareable_key, generate_random_bytes, CryptoError, EncString, KeyDecryptable, KeyEncryptable, SymmetricCryptoKey, @@ -14,7 +15,7 @@ use serde_repr::{Deserialize_repr, Serialize_repr}; use uuid::Uuid; use zeroize::Zeroizing; -use crate::error::{require, Error, Result}; +use crate::error::{Error, Result}; const SEND_ITERATIONS: u32 = 100_000; diff --git a/crates/bitwarden/src/uniffi_support.rs b/crates/bitwarden/src/uniffi_support.rs index b23a9cbef..562393307 100644 --- a/crates/bitwarden/src/uniffi_support.rs +++ b/crates/bitwarden/src/uniffi_support.rs @@ -3,7 +3,9 @@ use std::num::NonZeroU32; use bitwarden_crypto::{AsymmetricEncString, EncString}; use uuid::Uuid; -use crate::UniffiCustomTypeConverter; +type DateTime = chrono::DateTime; +uniffi::ffi_converter_forward!(DateTime, bitwarden_core::UniFfiTag, crate::UniFfiTag); +uniffi::ffi_converter_forward!(Uuid, bitwarden_core::UniFfiTag, crate::UniFfiTag); uniffi::ffi_converter_forward!(NonZeroU32, bitwarden_crypto::UniFfiTag, crate::UniFfiTag); uniffi::ffi_converter_forward!(EncString, bitwarden_crypto::UniFfiTag, crate::UniFfiTag); @@ -12,32 +14,3 @@ uniffi::ffi_converter_forward!( bitwarden_crypto::UniFfiTag, crate::UniFfiTag ); - -type DateTime = chrono::DateTime; -uniffi::custom_type!(DateTime, std::time::SystemTime); - -impl UniffiCustomTypeConverter for chrono::DateTime { - type Builtin = std::time::SystemTime; - - fn into_custom(val: Self::Builtin) -> uniffi::Result { - Ok(Self::from(val)) - } - - fn from_custom(obj: Self) -> Self::Builtin { - obj.into() - } -} - -uniffi::custom_type!(Uuid, String); - -impl UniffiCustomTypeConverter for Uuid { - type Builtin = String; - - fn into_custom(val: Self::Builtin) -> uniffi::Result { - Uuid::parse_str(val.as_str()).map_err(|e| e.into()) - } - - fn from_custom(obj: Self) -> Self::Builtin { - obj.to_string() - } -} diff --git a/crates/bitwarden/src/vault/cipher/cipher.rs b/crates/bitwarden/src/vault/cipher/cipher.rs index 3b688df32..72965a297 100644 --- a/crates/bitwarden/src/vault/cipher/cipher.rs +++ b/crates/bitwarden/src/vault/cipher/cipher.rs @@ -1,4 +1,5 @@ use bitwarden_api_api::models::CipherDetailsResponseModel; +use bitwarden_core::require; use bitwarden_crypto::{ CryptoError, EncString, KeyContainer, KeyDecryptable, KeyEncryptable, LocateKey, SymmetricCryptoKey, @@ -17,7 +18,7 @@ use super::{ #[cfg(feature = "uniffi")] use crate::{client::encryption_settings::EncryptionSettings, vault::Fido2CredentialView}; use crate::{ - error::{require, Error, Result}, + error::{Error, Result}, vault::{password_history, Fido2CredentialFullView}, }; diff --git a/crates/bitwarden/src/vault/cipher/field.rs b/crates/bitwarden/src/vault/cipher/field.rs index 8a7b1d5f5..2fd15eb0b 100644 --- a/crates/bitwarden/src/vault/cipher/field.rs +++ b/crates/bitwarden/src/vault/cipher/field.rs @@ -1,4 +1,5 @@ use bitwarden_api_api::models::CipherFieldModel; +use bitwarden_core::require; use bitwarden_crypto::{ CryptoError, EncString, KeyDecryptable, KeyEncryptable, SymmetricCryptoKey, }; @@ -7,7 +8,7 @@ use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; use super::linked_id::LinkedIdType; -use crate::error::{require, Error, Result}; +use crate::error::{Error, Result}; #[derive(Clone, Copy, Serialize_repr, Deserialize_repr, Debug, JsonSchema)] #[repr(u8)] diff --git a/crates/bitwarden/src/vault/cipher/linked_id.rs b/crates/bitwarden/src/vault/cipher/linked_id.rs index 373fe9f96..4d1826ec8 100644 --- a/crates/bitwarden/src/vault/cipher/linked_id.rs +++ b/crates/bitwarden/src/vault/cipher/linked_id.rs @@ -1,3 +1,4 @@ +use bitwarden_core::MissingFieldError; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; @@ -112,7 +113,7 @@ impl TryFrom for LinkedIdType { 416 => Ok(LinkedIdType::Identity(IdentityLinkedIdType::FirstName)), 417 => Ok(LinkedIdType::Identity(IdentityLinkedIdType::LastName)), 418 => Ok(LinkedIdType::Identity(IdentityLinkedIdType::FullName)), - _ => Err(Error::MissingFields("LinkedIdType")), + _ => Err(MissingFieldError("LinkedIdType").into()), } } } diff --git a/crates/bitwarden/src/vault/cipher/login.rs b/crates/bitwarden/src/vault/cipher/login.rs index 47dc71dc5..e065ecfbb 100644 --- a/crates/bitwarden/src/vault/cipher/login.rs +++ b/crates/bitwarden/src/vault/cipher/login.rs @@ -1,5 +1,6 @@ use base64::{engine::general_purpose::STANDARD, Engine}; use bitwarden_api_api::models::{CipherLoginModel, CipherLoginUriModel}; +use bitwarden_core::require; use bitwarden_crypto::{ CryptoError, EncString, KeyDecryptable, KeyEncryptable, SymmetricCryptoKey, }; @@ -8,7 +9,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; -use crate::error::{require, Error, Result}; +use crate::error::{Error, Result}; #[derive(Clone, Copy, Serialize_repr, Deserialize_repr, Debug, JsonSchema)] #[repr(u8)] diff --git a/crates/bitwarden/src/vault/cipher/secure_note.rs b/crates/bitwarden/src/vault/cipher/secure_note.rs index be4fc6689..f74997adc 100644 --- a/crates/bitwarden/src/vault/cipher/secure_note.rs +++ b/crates/bitwarden/src/vault/cipher/secure_note.rs @@ -1,10 +1,11 @@ use bitwarden_api_api::models::CipherSecureNoteModel; +use bitwarden_core::require; use bitwarden_crypto::{CryptoError, KeyDecryptable, KeyEncryptable, SymmetricCryptoKey}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; -use crate::error::{require, Error, Result}; +use crate::error::{Error, Result}; #[derive(Clone, Copy, Serialize_repr, Deserialize_repr, Debug, JsonSchema)] #[repr(u8)] diff --git a/crates/bitwarden/src/vault/collection.rs b/crates/bitwarden/src/vault/collection.rs index cfa17b946..0ffe2618f 100644 --- a/crates/bitwarden/src/vault/collection.rs +++ b/crates/bitwarden/src/vault/collection.rs @@ -1,4 +1,5 @@ use bitwarden_api_api::models::CollectionDetailsResponseModel; +use bitwarden_core::require; use bitwarden_crypto::{ CryptoError, EncString, KeyContainer, KeyDecryptable, LocateKey, SymmetricCryptoKey, }; @@ -6,7 +7,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; -use crate::error::{require, Error, Result}; +use crate::error::{Error, Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] diff --git a/crates/bitwarden/src/vault/domain.rs b/crates/bitwarden/src/vault/domain.rs index 482cb1f59..9e070f25a 100644 --- a/crates/bitwarden/src/vault/domain.rs +++ b/crates/bitwarden/src/vault/domain.rs @@ -1,7 +1,8 @@ +use bitwarden_core::require; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::error::{require, Error, Result}; +use crate::error::{Error, Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] pub struct GlobalDomains { diff --git a/crates/bitwarden/src/vault/folder.rs b/crates/bitwarden/src/vault/folder.rs index 09bf8868e..449860dea 100644 --- a/crates/bitwarden/src/vault/folder.rs +++ b/crates/bitwarden/src/vault/folder.rs @@ -1,4 +1,5 @@ use bitwarden_api_api::models::FolderResponseModel; +use bitwarden_core::require; use bitwarden_crypto::{ CryptoError, EncString, KeyDecryptable, KeyEncryptable, SymmetricCryptoKey, }; @@ -7,7 +8,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; -use crate::error::{require, Error, Result}; +use crate::error::{Error, Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase")] diff --git a/crates/bitwarden/src/vault/sync.rs b/crates/bitwarden/src/vault/sync.rs index bd9d38104..79f29d870 100644 --- a/crates/bitwarden/src/vault/sync.rs +++ b/crates/bitwarden/src/vault/sync.rs @@ -1,6 +1,7 @@ use bitwarden_api_api::models::{ DomainsResponseModel, ProfileOrganizationResponseModel, ProfileResponseModel, SyncResponseModel, }; +use bitwarden_core::require; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; @@ -9,7 +10,7 @@ use super::domain::GlobalDomains; use crate::{ admin_console::Policy, client::{encryption_settings::EncryptionSettings, Client}, - error::{require, Error, Result}, + error::{Error, Result}, vault::{Cipher, Collection, Folder}, }; diff --git a/crates/bitwarden/uniffi.toml b/crates/bitwarden/uniffi.toml index 7a804ef1d..c5fdba5c2 100644 --- a/crates/bitwarden/uniffi.toml +++ b/crates/bitwarden/uniffi.toml @@ -1,9 +1,9 @@ [bindings.kotlin] -package_name = "com.bitwarden.core" +package_name = "com.bitwarden.bitwarden" generate_immutable_records = true android = true [bindings.swift] -ffi_module_name = "BitwardenCoreFFI" -module_name = "BitwardenCore" +ffi_module_name = "BitwardenBitwardenFFI" +module_name = "BitwardenBitwarden" generate_immutable_records = true diff --git a/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt b/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt index f51d0309e..d304da8a1 100644 --- a/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt +++ b/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt @@ -23,10 +23,10 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import androidx.fragment.app.FragmentActivity import com.bitwarden.core.DateTime -import com.bitwarden.core.Folder -import com.bitwarden.core.InitOrgCryptoRequest -import com.bitwarden.core.InitUserCryptoMethod -import com.bitwarden.core.InitUserCryptoRequest +import com.bitwarden.bitwarden.Folder +import com.bitwarden.bitwarden.InitOrgCryptoRequest +import com.bitwarden.bitwarden.InitUserCryptoMethod +import com.bitwarden.bitwarden.InitUserCryptoRequest import com.bitwarden.core.Uuid import com.bitwarden.crypto.HashPurpose import com.bitwarden.crypto.Kdf From 9acd3629383f8e1442c5a1744a33c3dd5de9f221 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 10 Jun 2024 16:44:45 +0200 Subject: [PATCH 003/214] [PM-8301] Create bitwarden-vault (#825) Continue extracting functionality from `bitwarden` to new crates. - Extracts `VaultLocked` to `bitwarden-core`. - Moved `bitwarden/src/vault` models to `bitwarden-vault` crate. - Refactored Authenticator logic to not impl vault owned models. --- .github/workflows/publish-rust-crates.yml | 11 + Cargo.lock | 28 ++- Cargo.toml | 1 + crates/bitwarden-core/src/error.rs | 4 + crates/bitwarden-core/src/lib.rs | 2 +- crates/bitwarden-vault/Cargo.toml | 44 ++++ .../src}/cipher/attachment.rs | 10 +- .../src}/cipher/card.rs | 6 +- .../src}/cipher/cipher.rs | 68 +++--- .../src}/cipher/field.rs | 6 +- .../src}/cipher/identity.rs | 6 +- .../src}/cipher/linked_id.rs | 5 +- .../src}/cipher/local_data.rs | 0 .../src}/cipher/login.rs | 18 +- .../src}/cipher/mod.rs | 8 +- .../src}/cipher/secure_note.rs | 6 +- .../src}/collection.rs | 6 +- .../vault => bitwarden-vault/src}/domain.rs | 8 +- crates/bitwarden-vault/src/error.rs | 11 + crates/bitwarden-vault/src/exporters.rs | 221 ++++++++++++++++++ .../vault => bitwarden-vault/src}/folder.rs | 6 +- crates/bitwarden-vault/src/lib.rs | 20 ++ .../src}/password_history.rs | 6 +- .../src/vault => bitwarden-vault/src}/totp.rs | 21 +- crates/bitwarden-vault/src/uniffi_support.rs | 8 + crates/bitwarden/Cargo.toml | 6 +- crates/bitwarden/src/auth/auth_request.rs | 3 +- crates/bitwarden/src/auth/client_auth.rs | 5 +- .../bitwarden/src/auth/password/validate.rs | 8 +- crates/bitwarden/src/client/client.rs | 10 +- .../src/client/encryption_settings.rs | 5 +- crates/bitwarden/src/error.rs | 17 +- crates/bitwarden/src/mobile/crypto.rs | 11 +- .../bitwarden/src/mobile/tool/client_sends.rs | 13 +- .../src/mobile/vault/client_attachments.rs | 13 +- .../src/mobile/vault/client_ciphers.rs | 23 +- .../src/mobile/vault/client_collection.rs | 11 +- .../src/mobile/vault/client_folders.rs | 7 +- .../mobile/vault/client_password_history.rs | 7 +- .../bitwarden/src/mobile/vault/client_totp.rs | 8 +- .../src/platform/fido2/authenticator.rs | 27 +-- crates/bitwarden/src/platform/fido2/mod.rs | 167 +++++++------ crates/bitwarden/src/platform/fido2/traits.rs | 6 +- .../src/secrets_manager/projects/create.rs | 8 +- .../src/secrets_manager/projects/update.rs | 8 +- .../src/secrets_manager/secrets/create.rs | 8 +- .../src/secrets_manager/secrets/update.rs | 8 +- .../src/tool/exporters/client_exporter.rs | 3 +- crates/bitwarden/src/tool/exporters/mod.rs | 221 +----------------- crates/bitwarden/src/vault/mod.rs | 35 +-- crates/bitwarden/src/vault/sync.rs | 8 +- 51 files changed, 638 insertions(+), 538 deletions(-) create mode 100644 crates/bitwarden-vault/Cargo.toml rename crates/{bitwarden/src/vault => bitwarden-vault/src}/cipher/attachment.rs (98%) rename crates/{bitwarden/src/vault => bitwarden-vault/src}/cipher/card.rs (95%) rename crates/{bitwarden/src/vault => bitwarden-vault/src}/cipher/cipher.rs (95%) rename crates/{bitwarden/src/vault => bitwarden-vault/src}/cipher/field.rs (95%) rename crates/{bitwarden/src/vault => bitwarden-vault/src}/cipher/identity.rs (97%) rename crates/{bitwarden/src/vault => bitwarden-vault/src}/cipher/linked_id.rs (98%) rename crates/{bitwarden/src/vault => bitwarden-vault/src}/cipher/local_data.rs (100%) rename crates/{bitwarden/src/vault => bitwarden-vault/src}/cipher/login.rs (97%) rename crates/{bitwarden/src/vault => bitwarden-vault/src}/cipher/mod.rs (65%) rename crates/{bitwarden/src/vault => bitwarden-vault/src}/cipher/secure_note.rs (93%) rename crates/{bitwarden/src/vault => bitwarden-vault/src}/collection.rs (96%) rename crates/{bitwarden/src/vault => bitwarden-vault/src}/domain.rs (74%) create mode 100644 crates/bitwarden-vault/src/error.rs create mode 100644 crates/bitwarden-vault/src/exporters.rs rename crates/{bitwarden/src/vault => bitwarden-vault/src}/folder.rs (92%) create mode 100644 crates/bitwarden-vault/src/lib.rs rename crates/{bitwarden/src/vault => bitwarden-vault/src}/password_history.rs (95%) rename crates/{bitwarden/src/vault => bitwarden-vault/src}/totp.rs (94%) create mode 100644 crates/bitwarden-vault/src/uniffi_support.rs diff --git a/.github/workflows/publish-rust-crates.yml b/.github/workflows/publish-rust-crates.yml index 013fcd254..2db11507b 100644 --- a/.github/workflows/publish-rust-crates.yml +++ b/.github/workflows/publish-rust-crates.yml @@ -54,6 +54,11 @@ on: required: true default: true type: boolean + publish_bitwarden-vault: + description: "Publish bitwarden-valt crate" + required: true + default: true + type: boolean defaults: run: @@ -91,6 +96,7 @@ jobs: PUBLISH_BITWARDEN_CLI: ${{ github.event.inputs.publish_bitwarden-cli }} PUBLISH_BITWARDEN_GENERATORS: ${{ github.event.inputs.publish_bitwarden-generators }} PUBLISH_BITWARDEN_EXPORTERS: ${{ github.event.inputs.publish_bitwarden-exporters }} + PUBLISH_BITWARDEN_VAULT: ${{ github.event.inputs.publish_bitwarden-vault }} run: | if [[ "$PUBLISH_BITWARDEN" == "false" ]] && [[ "$PUBLISH_BITWARDEN_API_API" == "false" ]] && [[ "$PUBLISH_BITWARDEN_API_IDENTITY" == "false" ]]; then echo "===================================" @@ -142,6 +148,11 @@ jobs: PACKAGES_LIST="$PACKAGES_LIST bitwarden-exporters" fi + if [[ "$PUBLISH_BITWARDEN_VAULT" == "true" ]]; then + PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-vault" + PACKAGES_LIST="$PACKAGES_LIST bitwarden-vault" + fi + echo "Packages command: " $PACKAGES_COMMAND echo "Packages list: " $PACKAGES_LIST diff --git a/Cargo.lock b/Cargo.lock index a78c2d18e..4c5a2de7c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -376,10 +376,10 @@ dependencies = [ "bitwarden-crypto", "bitwarden-exporters", "bitwarden-generators", + "bitwarden-vault", "chrono", "coset", "getrandom", - "hmac", "log", "p256", "passkey", @@ -393,8 +393,6 @@ dependencies = [ "serde_json", "serde_qs", "serde_repr", - "sha1", - "sha2", "thiserror", "tokio", "uniffi", @@ -577,6 +575,30 @@ dependencies = [ "uuid", ] +[[package]] +name = "bitwarden-vault" +version = "0.5.0" +dependencies = [ + "base64 0.21.7", + "bitwarden-api-api", + "bitwarden-core", + "bitwarden-crypto", + "bitwarden-exporters", + "chrono", + "hmac", + "rand", + "reqwest", + "schemars", + "serde", + "serde_json", + "serde_repr", + "sha1", + "sha2", + "thiserror", + "uniffi", + "uuid", +] + [[package]] name = "bitwarden-wasm" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 2da09446c..3f826b761 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ bitwarden-core = { path = "crates/bitwarden-core", version = "=0.5.0" } bitwarden-crypto = { path = "crates/bitwarden-crypto", version = "=0.5.0" } bitwarden-exporters = { path = "crates/bitwarden-exporters", version = "=0.5.0" } bitwarden-generators = { path = "crates/bitwarden-generators", version = "=0.5.0" } +bitwarden-vault = { path = "crates/bitwarden-vault", version = "=0.5.0" } [workspace.lints.clippy] unwrap_used = "deny" diff --git a/crates/bitwarden-core/src/error.rs b/crates/bitwarden-core/src/error.rs index e2d890ecb..2c46407cc 100644 --- a/crates/bitwarden-core/src/error.rs +++ b/crates/bitwarden-core/src/error.rs @@ -4,6 +4,10 @@ use thiserror::Error; #[error("The response received was missing a required field: {0}")] pub struct MissingFieldError(pub &'static str); +#[derive(Debug, Error)] +#[error("The client vault is locked and needs to be unlocked before use")] +pub struct VaultLocked; + /// This macro is used to require that a value is present or return an error otherwise. /// It is equivalent to using `val.ok_or(Error::MissingFields)?`, but easier to use and /// with a more descriptive error message. diff --git a/crates/bitwarden-core/src/lib.rs b/crates/bitwarden-core/src/lib.rs index 1e62111b5..9d701730c 100644 --- a/crates/bitwarden-core/src/lib.rs +++ b/crates/bitwarden-core/src/lib.rs @@ -4,4 +4,4 @@ uniffi::setup_scaffolding!(); mod uniffi_support; mod error; -pub use error::MissingFieldError; +pub use error::{MissingFieldError, VaultLocked}; diff --git a/crates/bitwarden-vault/Cargo.toml b/crates/bitwarden-vault/Cargo.toml new file mode 100644 index 000000000..379b23997 --- /dev/null +++ b/crates/bitwarden-vault/Cargo.toml @@ -0,0 +1,44 @@ +[package] +name = "bitwarden-vault" +description = """ +Internal crate for the bitwarden crate. Do not use. +""" + +version.workspace = true +authors.workspace = true +edition.workspace = true +rust-version.workspace = true +homepage.workspace = true +repository.workspace = true +license-file.workspace = true +keywords.workspace = true + +[features] +uniffi = [ + "bitwarden-core/uniffi", + "bitwarden-crypto/uniffi", + "dep:uniffi", +] # Uniffi bindings + +[dependencies] +base64 = ">=0.21.2, <0.23" +bitwarden-api-api = { workspace = true } +bitwarden-core = { workspace = true } +bitwarden-crypto = { workspace = true } +bitwarden-exporters = { workspace = true } +chrono = { version = ">=0.4.26, <0.5", default-features = false } +rand = ">=0.8.5, <0.9" +hmac = ">=0.12.1, <0.13" +reqwest = { version = ">=0.12, <0.13", default-features = false } +schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } +serde = { version = ">=1.0, <2.0", features = ["derive"] } +serde_json = ">=1.0.96, <2.0" +serde_repr = ">=0.1.12, <0.2" +sha1 = ">=0.10.5, <0.11" +sha2 = ">=0.10.6, <0.11" +thiserror = ">=1.0.40, <2.0" +uniffi = { version = "=0.27.2", optional = true } +uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } + +[lints] +workspace = true diff --git a/crates/bitwarden/src/vault/cipher/attachment.rs b/crates/bitwarden-vault/src/cipher/attachment.rs similarity index 98% rename from crates/bitwarden/src/vault/cipher/attachment.rs rename to crates/bitwarden-vault/src/cipher/attachment.rs index 99d4e270f..db2a09b23 100644 --- a/crates/bitwarden/src/vault/cipher/attachment.rs +++ b/crates/bitwarden-vault/src/cipher/attachment.rs @@ -5,7 +5,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use super::Cipher; -use crate::error::{Error, Result}; +use crate::VaultParseError; #[derive(Serialize, Deserialize, Debug, JsonSchema, Clone)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -125,9 +125,11 @@ impl KeyDecryptable for Attachment { } impl TryFrom for Attachment { - type Error = Error; + type Error = VaultParseError; - fn try_from(attachment: bitwarden_api_api::models::AttachmentResponseModel) -> Result { + fn try_from( + attachment: bitwarden_api_api::models::AttachmentResponseModel, + ) -> Result { Ok(Self { id: attachment.id, url: attachment.url, @@ -144,7 +146,7 @@ mod tests { use base64::{engine::general_purpose::STANDARD, Engine}; use bitwarden_crypto::{EncString, KeyDecryptable, SymmetricCryptoKey}; - use crate::vault::{ + use crate::{ cipher::cipher::{CipherRepromptType, CipherType}, Attachment, AttachmentFile, Cipher, }; diff --git a/crates/bitwarden/src/vault/cipher/card.rs b/crates/bitwarden-vault/src/cipher/card.rs similarity index 95% rename from crates/bitwarden/src/vault/cipher/card.rs rename to crates/bitwarden-vault/src/cipher/card.rs index e7201177a..5a2396d92 100644 --- a/crates/bitwarden/src/vault/cipher/card.rs +++ b/crates/bitwarden-vault/src/cipher/card.rs @@ -5,7 +5,7 @@ use bitwarden_crypto::{ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::error::{Error, Result}; +use crate::VaultParseError; #[derive(Serialize, Deserialize, Debug, JsonSchema, Clone)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -58,9 +58,9 @@ impl KeyDecryptable for Card { } impl TryFrom for Card { - type Error = Error; + type Error = VaultParseError; - fn try_from(card: CipherCardModel) -> Result { + fn try_from(card: CipherCardModel) -> Result { Ok(Self { cardholder_name: EncString::try_from_optional(card.cardholder_name)?, exp_month: EncString::try_from_optional(card.exp_month)?, diff --git a/crates/bitwarden/src/vault/cipher/cipher.rs b/crates/bitwarden-vault/src/cipher/cipher.rs similarity index 95% rename from crates/bitwarden/src/vault/cipher/cipher.rs rename to crates/bitwarden-vault/src/cipher/cipher.rs index 72965a297..5181df94f 100644 --- a/crates/bitwarden/src/vault/cipher/cipher.rs +++ b/crates/bitwarden-vault/src/cipher/cipher.rs @@ -1,5 +1,5 @@ use bitwarden_api_api::models::CipherDetailsResponseModel; -use bitwarden_core::require; +use bitwarden_core::{require, MissingFieldError, VaultLocked}; use bitwarden_crypto::{ CryptoError, EncString, KeyContainer, KeyDecryptable, KeyEncryptable, LocateKey, SymmetricCryptoKey, @@ -8,6 +8,7 @@ use chrono::{DateTime, Utc}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; +use thiserror::Error; use uuid::Uuid; use super::{ @@ -16,11 +17,20 @@ use super::{ login, secure_note, }; #[cfg(feature = "uniffi")] -use crate::{client::encryption_settings::EncryptionSettings, vault::Fido2CredentialView}; -use crate::{ - error::{Error, Result}, - vault::{password_history, Fido2CredentialFullView}, -}; +use crate::Fido2CredentialView; +use crate::{password_history, Fido2CredentialFullView, VaultParseError}; + +#[derive(Debug, Error)] +pub enum CipherError { + #[error(transparent)] + MissingFieldError(#[from] MissingFieldError), + #[error(transparent)] + VaultLocked(#[from] VaultLocked), + #[error(transparent)] + CryptoError(#[from] CryptoError), + #[error("This cipher contains attachments without keys. Those attachments will need to be reuploaded to complete the operation")] + AttachmentsWithoutKeys, +} #[derive(Clone, Copy, Serialize_repr, Deserialize_repr, Debug, JsonSchema)] #[repr(u8)] @@ -343,7 +353,7 @@ fn build_subtitle_identity(first_name: Option, last_name: Option } impl CipherView { - pub fn generate_cipher_key(&mut self, key: &SymmetricCryptoKey) -> Result<()> { + pub fn generate_cipher_key(&mut self, key: &SymmetricCryptoKey) -> Result<(), CryptoError> { let old_ciphers_key = Cipher::get_cipher_key(key, &self.key)?; let old_key = old_ciphers_key.as_ref().unwrap_or(key); @@ -374,7 +384,7 @@ impl CipherView { &mut self, old_key: &SymmetricCryptoKey, new_key: &SymmetricCryptoKey, - ) -> Result<()> { + ) -> Result<(), CryptoError> { if let Some(attachments) = &mut self.attachments { for attachment in attachments { if let Some(attachment_key) = &mut attachment.key { @@ -387,11 +397,11 @@ impl CipherView { } #[cfg(feature = "uniffi")] - pub(crate) fn decrypt_fido2_credentials( + pub fn decrypt_fido2_credentials( &self, - enc: &EncryptionSettings, - ) -> Result> { - let key = self.locate_key(enc, &None).ok_or(Error::VaultLocked)?; + enc: &dyn KeyContainer, + ) -> Result, CipherError> { + let key = self.locate_key(enc, &None).ok_or(VaultLocked)?; let cipher_key = Cipher::get_cipher_key(key, &self.key)?; let key = cipher_key.as_ref().unwrap_or(key); @@ -409,7 +419,7 @@ impl CipherView { &mut self, old_key: &SymmetricCryptoKey, new_key: &SymmetricCryptoKey, - ) -> Result<()> { + ) -> Result<(), CryptoError> { if let Some(login) = self.login.as_mut() { if let Some(fido2_credentials) = &mut login.fido2_credentials { let dec_fido2_credentials: Vec = @@ -424,18 +434,14 @@ impl CipherView { &mut self, enc: &dyn KeyContainer, organization_id: Uuid, - ) -> Result<()> { - let old_key = enc - .get_key(&self.organization_id) - .ok_or(Error::VaultLocked)?; + ) -> Result<(), CipherError> { + let old_key = enc.get_key(&self.organization_id).ok_or(VaultLocked)?; - let new_key = enc - .get_key(&Some(organization_id)) - .ok_or(Error::VaultLocked)?; + let new_key = enc.get_key(&Some(organization_id)).ok_or(VaultLocked)?; // If any attachment is missing a key we can't reencrypt the attachment keys if self.attachments.iter().flatten().any(|a| a.key.is_none()) { - return Err("This cipher contains attachments without keys. Those attachments will need to be reuploaded to complete the operation".into()); + return Err(CipherError::AttachmentsWithoutKeys); } // If the cipher has a key, we need to re-encrypt it with the new organization key @@ -453,14 +459,12 @@ impl CipherView { } #[cfg(feature = "uniffi")] - pub(crate) fn set_new_fido2_credentials( + pub fn set_new_fido2_credentials( &mut self, enc: &dyn KeyContainer, creds: Vec, - ) -> Result<()> { - let key = enc - .get_key(&self.organization_id) - .ok_or(Error::VaultLocked)?; + ) -> Result<(), CipherError> { + let key = enc.get_key(&self.organization_id).ok_or(VaultLocked)?; let ciphers_key = Cipher::get_cipher_key(key, &self.key)?; let ciphers_key = ciphers_key.as_ref().unwrap_or(key); @@ -472,13 +476,11 @@ impl CipherView { } #[cfg(feature = "uniffi")] - pub(crate) fn get_fido2_credentials( + pub fn get_fido2_credentials( &self, enc: &dyn KeyContainer, - ) -> Result> { - let key = enc - .get_key(&self.organization_id) - .ok_or(Error::VaultLocked)?; + ) -> Result, CipherError> { + let key = enc.get_key(&self.organization_id).ok_or(VaultLocked)?; let ciphers_key = Cipher::get_cipher_key(key, &self.key)?; let ciphers_key = ciphers_key.as_ref().unwrap_or(key); @@ -539,9 +541,9 @@ impl LocateKey for CipherView { } impl TryFrom for Cipher { - type Error = Error; + type Error = VaultParseError; - fn try_from(cipher: CipherDetailsResponseModel) -> Result { + fn try_from(cipher: CipherDetailsResponseModel) -> Result { Ok(Self { id: cipher.id, organization_id: cipher.organization_id, diff --git a/crates/bitwarden/src/vault/cipher/field.rs b/crates/bitwarden-vault/src/cipher/field.rs similarity index 95% rename from crates/bitwarden/src/vault/cipher/field.rs rename to crates/bitwarden-vault/src/cipher/field.rs index 2fd15eb0b..2141006af 100644 --- a/crates/bitwarden/src/vault/cipher/field.rs +++ b/crates/bitwarden-vault/src/cipher/field.rs @@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; use super::linked_id::LinkedIdType; -use crate::error::{Error, Result}; +use crate::VaultParseError; #[derive(Clone, Copy, Serialize_repr, Deserialize_repr, Debug, JsonSchema)] #[repr(u8)] @@ -65,9 +65,9 @@ impl KeyDecryptable for Field { } impl TryFrom for Field { - type Error = Error; + type Error = VaultParseError; - fn try_from(model: CipherFieldModel) -> Result { + fn try_from(model: CipherFieldModel) -> Result { Ok(Self { name: EncString::try_from_optional(model.name)?, value: EncString::try_from_optional(model.value)?, diff --git a/crates/bitwarden/src/vault/cipher/identity.rs b/crates/bitwarden-vault/src/cipher/identity.rs similarity index 97% rename from crates/bitwarden/src/vault/cipher/identity.rs rename to crates/bitwarden-vault/src/cipher/identity.rs index 5103793b0..f01274d77 100644 --- a/crates/bitwarden/src/vault/cipher/identity.rs +++ b/crates/bitwarden-vault/src/cipher/identity.rs @@ -5,7 +5,7 @@ use bitwarden_crypto::{ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::error::{Error, Result}; +use crate::VaultParseError; #[derive(Serialize, Deserialize, Debug, JsonSchema, Clone)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -106,9 +106,9 @@ impl KeyDecryptable for Identity { } impl TryFrom for Identity { - type Error = Error; + type Error = VaultParseError; - fn try_from(identity: CipherIdentityModel) -> Result { + fn try_from(identity: CipherIdentityModel) -> Result { Ok(Self { title: EncString::try_from_optional(identity.title)?, first_name: EncString::try_from_optional(identity.first_name)?, diff --git a/crates/bitwarden/src/vault/cipher/linked_id.rs b/crates/bitwarden-vault/src/cipher/linked_id.rs similarity index 98% rename from crates/bitwarden/src/vault/cipher/linked_id.rs rename to crates/bitwarden-vault/src/cipher/linked_id.rs index 4d1826ec8..7ee29dbc2 100644 --- a/crates/bitwarden/src/vault/cipher/linked_id.rs +++ b/crates/bitwarden-vault/src/cipher/linked_id.rs @@ -11,7 +11,6 @@ pub enum LinkedIdType { Identity(IdentityLinkedIdType), } -use crate::error::{Error, Result}; #[cfg(feature = "uniffi")] use crate::UniffiCustomTypeConverter; #[cfg(feature = "uniffi")] @@ -82,9 +81,9 @@ pub enum IdentityLinkedIdType { } impl TryFrom for LinkedIdType { - type Error = Error; + type Error = MissingFieldError; - fn try_from(value: u32) -> Result { + fn try_from(value: u32) -> Result { match value { 100 => Ok(LinkedIdType::Login(LoginLinkedIdType::Username)), 101 => Ok(LinkedIdType::Login(LoginLinkedIdType::Password)), diff --git a/crates/bitwarden/src/vault/cipher/local_data.rs b/crates/bitwarden-vault/src/cipher/local_data.rs similarity index 100% rename from crates/bitwarden/src/vault/cipher/local_data.rs rename to crates/bitwarden-vault/src/cipher/local_data.rs diff --git a/crates/bitwarden/src/vault/cipher/login.rs b/crates/bitwarden-vault/src/cipher/login.rs similarity index 97% rename from crates/bitwarden/src/vault/cipher/login.rs rename to crates/bitwarden-vault/src/cipher/login.rs index e065ecfbb..406286620 100644 --- a/crates/bitwarden/src/vault/cipher/login.rs +++ b/crates/bitwarden-vault/src/cipher/login.rs @@ -9,7 +9,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; -use crate::error::{Error, Result}; +use crate::VaultParseError; #[derive(Clone, Copy, Serialize_repr, Deserialize_repr, Debug, JsonSchema)] #[repr(u8)] @@ -114,7 +114,7 @@ pub struct Fido2CredentialView { // Only meant to be used internally and not exposed to the outside world #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(rename_all = "camelCase", deny_unknown_fields)] -pub(crate) struct Fido2CredentialFullView { +pub struct Fido2CredentialFullView { pub credential_id: String, pub key_type: String, pub key_algorithm: String, @@ -368,9 +368,9 @@ impl KeyDecryptable for Fido2Credential } impl TryFrom for Login { - type Error = Error; + type Error = VaultParseError; - fn try_from(login: CipherLoginModel) -> Result { + fn try_from(login: CipherLoginModel) -> Result { Ok(Self { username: EncString::try_from_optional(login.username)?, password: EncString::try_from_optional(login.password)?, @@ -393,9 +393,9 @@ impl TryFrom for Login { } impl TryFrom for LoginUri { - type Error = Error; + type Error = VaultParseError; - fn try_from(uri: CipherLoginUriModel) -> Result { + fn try_from(uri: CipherLoginUriModel) -> Result { Ok(Self { uri: EncString::try_from_optional(uri.uri)?, r#match: uri.r#match.map(|m| m.into()), @@ -418,9 +418,11 @@ impl From for UriMatchType { } impl TryFrom for Fido2Credential { - type Error = Error; + type Error = VaultParseError; - fn try_from(value: bitwarden_api_api::models::CipherFido2CredentialModel) -> Result { + fn try_from( + value: bitwarden_api_api::models::CipherFido2CredentialModel, + ) -> Result { Ok(Self { credential_id: require!(value.credential_id).parse()?, key_type: require!(value.key_type).parse()?, diff --git a/crates/bitwarden/src/vault/cipher/mod.rs b/crates/bitwarden-vault/src/cipher/mod.rs similarity index 65% rename from crates/bitwarden/src/vault/cipher/mod.rs rename to crates/bitwarden-vault/src/cipher/mod.rs index 92a4e10ad..1b13ac743 100644 --- a/crates/bitwarden/src/vault/cipher/mod.rs +++ b/crates/bitwarden-vault/src/cipher/mod.rs @@ -12,8 +12,10 @@ pub(crate) mod secure_note; pub use attachment::{ Attachment, AttachmentEncryptResult, AttachmentFile, AttachmentFileView, AttachmentView, }; -pub use cipher::{Cipher, CipherListView, CipherRepromptType, CipherType, CipherView}; +pub use cipher::{Cipher, CipherError, CipherListView, CipherRepromptType, CipherType, CipherView}; pub use field::FieldView; -pub(crate) use login::Fido2CredentialFullView; -pub use login::{Fido2Credential, Fido2CredentialNewView, Fido2CredentialView}; +pub use login::{ + Fido2Credential, Fido2CredentialFullView, Fido2CredentialNewView, Fido2CredentialView, Login, + LoginView, +}; pub use secure_note::SecureNoteType; diff --git a/crates/bitwarden/src/vault/cipher/secure_note.rs b/crates/bitwarden-vault/src/cipher/secure_note.rs similarity index 93% rename from crates/bitwarden/src/vault/cipher/secure_note.rs rename to crates/bitwarden-vault/src/cipher/secure_note.rs index f74997adc..8ae39eb4d 100644 --- a/crates/bitwarden/src/vault/cipher/secure_note.rs +++ b/crates/bitwarden-vault/src/cipher/secure_note.rs @@ -5,7 +5,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; -use crate::error::{Error, Result}; +use crate::VaultParseError; #[derive(Clone, Copy, Serialize_repr, Deserialize_repr, Debug, JsonSchema)] #[repr(u8)] @@ -45,9 +45,9 @@ impl KeyDecryptable for SecureNote { } impl TryFrom for SecureNote { - type Error = Error; + type Error = VaultParseError; - fn try_from(model: CipherSecureNoteModel) -> Result { + fn try_from(model: CipherSecureNoteModel) -> Result { Ok(Self { r#type: require!(model.r#type).into(), }) diff --git a/crates/bitwarden/src/vault/collection.rs b/crates/bitwarden-vault/src/collection.rs similarity index 96% rename from crates/bitwarden/src/vault/collection.rs rename to crates/bitwarden-vault/src/collection.rs index 0ffe2618f..f1b58cc28 100644 --- a/crates/bitwarden/src/vault/collection.rs +++ b/crates/bitwarden-vault/src/collection.rs @@ -7,7 +7,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; -use crate::error::{Error, Result}; +use crate::VaultParseError; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -62,9 +62,9 @@ impl KeyDecryptable for Collection { } impl TryFrom for Collection { - type Error = Error; + type Error = VaultParseError; - fn try_from(collection: CollectionDetailsResponseModel) -> Result { + fn try_from(collection: CollectionDetailsResponseModel) -> Result { Ok(Collection { id: collection.id, organization_id: require!(collection.organization_id), diff --git a/crates/bitwarden/src/vault/domain.rs b/crates/bitwarden-vault/src/domain.rs similarity index 74% rename from crates/bitwarden/src/vault/domain.rs rename to crates/bitwarden-vault/src/domain.rs index 9e070f25a..dbdfcaddf 100644 --- a/crates/bitwarden/src/vault/domain.rs +++ b/crates/bitwarden-vault/src/domain.rs @@ -2,7 +2,7 @@ use bitwarden_core::require; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::error::{Error, Result}; +use crate::VaultParseError; #[derive(Serialize, Deserialize, Debug, JsonSchema)] pub struct GlobalDomains { @@ -12,9 +12,11 @@ pub struct GlobalDomains { } impl TryFrom for GlobalDomains { - type Error = Error; + type Error = VaultParseError; - fn try_from(global_domains: bitwarden_api_api::models::GlobalDomains) -> Result { + fn try_from( + global_domains: bitwarden_api_api::models::GlobalDomains, + ) -> Result { Ok(Self { r#type: require!(global_domains.r#type), domains: require!(global_domains.domains), diff --git a/crates/bitwarden-vault/src/error.rs b/crates/bitwarden-vault/src/error.rs new file mode 100644 index 000000000..123337678 --- /dev/null +++ b/crates/bitwarden-vault/src/error.rs @@ -0,0 +1,11 @@ +use thiserror::Error; + +#[derive(Debug, Error)] +pub enum VaultParseError { + #[error(transparent)] + Chrono(#[from] chrono::ParseError), + #[error(transparent)] + Crypto(#[from] bitwarden_crypto::CryptoError), + #[error(transparent)] + MissingFieldError(#[from] bitwarden_core::MissingFieldError), +} diff --git a/crates/bitwarden-vault/src/exporters.rs b/crates/bitwarden-vault/src/exporters.rs new file mode 100644 index 000000000..3b228f231 --- /dev/null +++ b/crates/bitwarden-vault/src/exporters.rs @@ -0,0 +1,221 @@ +use bitwarden_core::{require, MissingFieldError}; + +use crate::{login::LoginUriView, CipherType, CipherView, FieldView, FolderView, SecureNoteType}; + +impl TryFrom for bitwarden_exporters::Folder { + type Error = MissingFieldError; + + fn try_from(value: FolderView) -> Result { + Ok(Self { + id: require!(value.id), + name: value.name, + }) + } +} + +impl TryFrom for bitwarden_exporters::Cipher { + type Error = MissingFieldError; + + fn try_from(value: CipherView) -> Result { + let r = match value.r#type { + CipherType::Login => { + let l = require!(value.login); + bitwarden_exporters::CipherType::Login(Box::new(bitwarden_exporters::Login { + username: l.username, + password: l.password, + login_uris: l + .uris + .unwrap_or_default() + .into_iter() + .map(|u| u.into()) + .collect(), + totp: l.totp, + })) + } + CipherType::SecureNote => bitwarden_exporters::CipherType::SecureNote(Box::new( + bitwarden_exporters::SecureNote { + r#type: value + .secure_note + .map(|t| t.r#type) + .unwrap_or(SecureNoteType::Generic) + .into(), + }, + )), + CipherType::Card => { + let c = require!(value.card); + bitwarden_exporters::CipherType::Card(Box::new(bitwarden_exporters::Card { + cardholder_name: c.cardholder_name, + exp_month: c.exp_month, + exp_year: c.exp_year, + code: c.code, + brand: c.brand, + number: c.number, + })) + } + CipherType::Identity => { + let i = require!(value.identity); + bitwarden_exporters::CipherType::Identity(Box::new(bitwarden_exporters::Identity { + title: i.title, + first_name: i.first_name, + middle_name: i.middle_name, + last_name: i.last_name, + address1: i.address1, + address2: i.address2, + address3: i.address3, + city: i.city, + state: i.state, + postal_code: i.postal_code, + country: i.country, + company: i.company, + email: i.email, + phone: i.phone, + ssn: i.ssn, + username: i.username, + passport_number: i.passport_number, + license_number: i.license_number, + })) + } + }; + + Ok(Self { + id: require!(value.id), + folder_id: value.folder_id, + name: value.name, + notes: value.notes, + r#type: r, + favorite: value.favorite, + reprompt: value.reprompt as u8, + fields: value + .fields + .unwrap_or_default() + .into_iter() + .map(|f| f.into()) + .collect(), + revision_date: value.revision_date, + creation_date: value.creation_date, + deleted_date: value.deleted_date, + }) + } +} + +impl From for bitwarden_exporters::Field { + fn from(value: FieldView) -> Self { + Self { + name: value.name, + value: value.value, + r#type: value.r#type as u8, + linked_id: value.linked_id.map(|id| id.into()), + } + } +} + +impl From for bitwarden_exporters::LoginUri { + fn from(value: LoginUriView) -> Self { + Self { + r#match: value.r#match.map(|v| v as u8), + uri: value.uri, + } + } +} + +impl From for bitwarden_exporters::SecureNoteType { + fn from(value: SecureNoteType) -> Self { + match value { + SecureNoteType::Generic => bitwarden_exporters::SecureNoteType::Generic, + } + } +} + +#[cfg(test)] +mod tests { + use chrono::{DateTime, Utc}; + + use super::*; + use crate::{CipherRepromptType, LoginView}; + + #[test] + fn test_try_from_folder_view() { + let view = FolderView { + id: Some("fd411a1a-fec8-4070-985d-0e6560860e69".parse().unwrap()), + name: "test_name".to_string(), + revision_date: "2024-01-30T17:55:36.150Z".parse().unwrap(), + }; + + let f: bitwarden_exporters::Folder = view.try_into().unwrap(); + + assert_eq!( + f.id, + "fd411a1a-fec8-4070-985d-0e6560860e69".parse().unwrap() + ); + assert_eq!(f.name, "test_name".to_string()); + } + + #[test] + fn test_try_from_cipher_view_login() { + let cipher_view = CipherView { + r#type: CipherType::Login, + login: Some(LoginView { + username: Some("test_username".to_string()), + password: Some("test_password".to_string()), + password_revision_date: None, + uris: None, + totp: None, + autofill_on_page_load: None, + fido2_credentials: None, + }), + id: "fd411a1a-fec8-4070-985d-0e6560860e69".parse().ok(), + organization_id: None, + folder_id: None, + collection_ids: vec![], + key: None, + name: "My login".to_string(), + notes: None, + identity: None, + card: None, + secure_note: None, + favorite: false, + reprompt: CipherRepromptType::None, + organization_use_totp: true, + edit: true, + view_password: true, + local_data: None, + attachments: None, + fields: None, + password_history: None, + creation_date: "2024-01-30T17:55:36.150Z".parse().unwrap(), + deleted_date: None, + revision_date: "2024-01-30T17:55:36.150Z".parse().unwrap(), + }; + + let cipher: bitwarden_exporters::Cipher = cipher_view.try_into().unwrap(); + + assert_eq!( + cipher.id, + "fd411a1a-fec8-4070-985d-0e6560860e69".parse().unwrap() + ); + assert_eq!(cipher.folder_id, None); + assert_eq!(cipher.name, "My login".to_string()); + assert_eq!(cipher.notes, None); + assert!(!cipher.favorite); + assert_eq!(cipher.reprompt, 0); + assert!(cipher.fields.is_empty()); + assert_eq!( + cipher.revision_date, + "2024-01-30T17:55:36.150Z".parse::>().unwrap() + ); + assert_eq!( + cipher.creation_date, + "2024-01-30T17:55:36.150Z".parse::>().unwrap() + ); + assert_eq!(cipher.deleted_date, None); + + if let bitwarden_exporters::CipherType::Login(l) = cipher.r#type { + assert_eq!(l.username, Some("test_username".to_string())); + assert_eq!(l.password, Some("test_password".to_string())); + assert!(l.login_uris.is_empty()); + assert_eq!(l.totp, None); + } else { + panic!("Expected login type"); + } + } +} diff --git a/crates/bitwarden/src/vault/folder.rs b/crates/bitwarden-vault/src/folder.rs similarity index 92% rename from crates/bitwarden/src/vault/folder.rs rename to crates/bitwarden-vault/src/folder.rs index 449860dea..c5ab1401b 100644 --- a/crates/bitwarden/src/vault/folder.rs +++ b/crates/bitwarden-vault/src/folder.rs @@ -8,7 +8,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; -use crate::error::{Error, Result}; +use crate::VaultParseError; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase")] @@ -49,9 +49,9 @@ impl KeyDecryptable for Folder { } impl TryFrom for Folder { - type Error = Error; + type Error = VaultParseError; - fn try_from(folder: FolderResponseModel) -> Result { + fn try_from(folder: FolderResponseModel) -> Result { Ok(Folder { id: folder.id, name: require!(EncString::try_from_optional(folder.name)?), diff --git a/crates/bitwarden-vault/src/lib.rs b/crates/bitwarden-vault/src/lib.rs new file mode 100644 index 000000000..4928f2766 --- /dev/null +++ b/crates/bitwarden-vault/src/lib.rs @@ -0,0 +1,20 @@ +#[cfg(feature = "uniffi")] +uniffi::setup_scaffolding!(); +#[cfg(feature = "uniffi")] +mod uniffi_support; + +mod cipher; +pub use cipher::*; +mod collection; +pub use collection::{Collection, CollectionView}; +mod folder; +pub use folder::{Folder, FolderView}; +mod password_history; +pub use password_history::{PasswordHistory, PasswordHistoryView}; +mod domain; +pub use domain::GlobalDomains; +mod totp; +pub use totp::{generate_totp, TotpError, TotpResponse}; +mod error; +pub use error::VaultParseError; +mod exporters; diff --git a/crates/bitwarden/src/vault/password_history.rs b/crates/bitwarden-vault/src/password_history.rs similarity index 95% rename from crates/bitwarden/src/vault/password_history.rs rename to crates/bitwarden-vault/src/password_history.rs index fcd67db69..5e2075e3b 100644 --- a/crates/bitwarden/src/vault/password_history.rs +++ b/crates/bitwarden-vault/src/password_history.rs @@ -6,7 +6,7 @@ use chrono::{DateTime, Utc}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::error::{Error, Result}; +use crate::VaultParseError; #[derive(Serialize, Deserialize, Debug, JsonSchema, Clone)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -46,9 +46,9 @@ impl KeyDecryptable for PasswordHistory } impl TryFrom for PasswordHistory { - type Error = Error; + type Error = VaultParseError; - fn try_from(model: CipherPasswordHistoryModel) -> Result { + fn try_from(model: CipherPasswordHistoryModel) -> Result { Ok(Self { password: model.password.parse()?, last_used_date: model.last_used_date.parse()?, diff --git a/crates/bitwarden/src/vault/totp.rs b/crates/bitwarden-vault/src/totp.rs similarity index 94% rename from crates/bitwarden/src/vault/totp.rs rename to crates/bitwarden-vault/src/totp.rs index 605fbe19c..d17820bee 100644 --- a/crates/bitwarden/src/vault/totp.rs +++ b/crates/bitwarden-vault/src/totp.rs @@ -5,8 +5,7 @@ use hmac::{Hmac, Mac}; use reqwest::Url; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; - -use crate::error::{Error, Result}; +use thiserror::Error; type HmacSha1 = Hmac; type HmacSha256 = Hmac; @@ -19,6 +18,14 @@ const DEFAULT_ALGORITHM: Algorithm = Algorithm::Sha1; const DEFAULT_DIGITS: u32 = 6; const DEFAULT_PERIOD: u32 = 30; +#[derive(Debug, Error)] +pub enum TotpError { + #[error("Invalid otpauth")] + InvalidOtpauth, + #[error("Missing secret")] + MissingSecret, +} + #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] @@ -43,7 +50,7 @@ pub struct TotpResponse { /// Arguments: /// - `key` - The key to generate the TOTP code from /// - `time` - The time in UTC to generate the TOTP code for, defaults to current system time -pub(crate) fn generate_totp(key: String, time: Option>) -> Result { +pub fn generate_totp(key: String, time: Option>) -> Result { let params: Totp = key.parse()?; let time = time.unwrap_or_else(Utc::now); @@ -119,7 +126,7 @@ impl Totp { } impl FromStr for Totp { - type Err = Error; + type Err = TotpError; /// Parses the provided key and returns the corresponding `Totp`. /// @@ -127,9 +134,9 @@ impl FromStr for Totp { /// - A base32 encoded string /// - OTP Auth URI /// - Steam URI - fn from_str(key: &str) -> Result { + fn from_str(key: &str) -> Result { let params = if key.starts_with("otpauth://") { - let url = Url::parse(key).map_err(|_| "Unable to parse URL")?; + let url = Url::parse(key).map_err(|_| TotpError::InvalidOtpauth)?; let parts: HashMap<_, _> = url.query_pairs().collect(); Totp { @@ -156,7 +163,7 @@ impl FromStr for Totp { &parts .get("secret") .map(|v| v.to_string()) - .ok_or("Missing secret in otpauth URI")?, + .ok_or(TotpError::MissingSecret)?, ), } } else if let Some(secret) = key.strip_prefix("steam://") { diff --git a/crates/bitwarden-vault/src/uniffi_support.rs b/crates/bitwarden-vault/src/uniffi_support.rs new file mode 100644 index 000000000..932f0de7a --- /dev/null +++ b/crates/bitwarden-vault/src/uniffi_support.rs @@ -0,0 +1,8 @@ +use bitwarden_crypto::EncString; +use uuid::Uuid; + +uniffi::ffi_converter_forward!(EncString, bitwarden_crypto::UniFfiTag, crate::UniFfiTag); + +type DateTime = chrono::DateTime; +uniffi::ffi_converter_forward!(DateTime, bitwarden_core::UniFfiTag, crate::UniFfiTag); +uniffi::ffi_converter_forward!(Uuid, bitwarden_core::UniFfiTag, crate::UniFfiTag); diff --git a/crates/bitwarden/Cargo.toml b/crates/bitwarden/Cargo.toml index 1bde11717..e25f4d68a 100644 --- a/crates/bitwarden/Cargo.toml +++ b/crates/bitwarden/Cargo.toml @@ -19,6 +19,7 @@ default = ["secrets"] internal = [ "dep:bitwarden-exporters", "dep:bitwarden-generators", + "dep:bitwarden-vault", ] # Internal testing methods no-memory-hardening = [ "bitwarden-crypto/no-memory-hardening", @@ -27,6 +28,7 @@ uniffi = [ "bitwarden-core/uniffi", "bitwarden-crypto/uniffi", "bitwarden-generators/uniffi", + "bitwarden-vault/uniffi", "dep:uniffi", "dep:passkey", "dep:coset", @@ -44,6 +46,7 @@ bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } bitwarden-exporters = { workspace = true, optional = true } bitwarden-generators = { workspace = true, optional = true } +bitwarden-vault = { workspace = true, optional = true } chrono = { version = ">=0.4.26, <0.5", features = [ "clock", "serde", @@ -52,7 +55,6 @@ chrono = { version = ">=0.4.26, <0.5", features = [ coset = { version = "0.3.7", optional = true } # 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"] } -hmac = ">=0.12.1, <0.13" log = ">=0.4.18, <0.5" p256 = { version = ">=0.13.2, <0.14", optional = true } passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "c48c2ddfd6b884b2d754432576c66cb2b1985a3a", optional = true } @@ -66,8 +68,6 @@ serde = { version = ">=1.0, <2.0", features = ["derive"] } serde_json = ">=1.0.96, <2.0" serde_qs = ">=0.12.0, <0.14" serde_repr = ">=0.1.12, <0.2" -sha1 = ">=0.10.5, <0.11" -sha2 = ">=0.10.6, <0.11" thiserror = ">=1.0.40, <2.0" uniffi = { version = "=0.27.2", optional = true, features = ["tokio"] } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } diff --git a/crates/bitwarden/src/auth/auth_request.rs b/crates/bitwarden/src/auth/auth_request.rs index caf560260..c5ab6537e 100644 --- a/crates/bitwarden/src/auth/auth_request.rs +++ b/crates/bitwarden/src/auth/auth_request.rs @@ -1,4 +1,5 @@ use base64::{engine::general_purpose::STANDARD, Engine}; +use bitwarden_core::VaultLocked; use bitwarden_crypto::{ fingerprint, AsymmetricCryptoKey, AsymmetricEncString, AsymmetricPublicCryptoKey, }; @@ -89,7 +90,7 @@ pub(crate) fn approve_auth_request( let public_key = AsymmetricPublicCryptoKey::from_der(&STANDARD.decode(public_key)?)?; let enc = client.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(Error::VaultLocked)?; + let key = enc.get_key(&None).ok_or(VaultLocked)?; Ok(AsymmetricEncString::encrypt_rsa2048_oaep_sha1( &key.to_vec(), diff --git a/crates/bitwarden/src/auth/client_auth.rs b/crates/bitwarden/src/auth/client_auth.rs index 88f8b0a09..0339c5351 100644 --- a/crates/bitwarden/src/auth/client_auth.rs +++ b/crates/bitwarden/src/auth/client_auth.rs @@ -24,7 +24,6 @@ use crate::{ AuthRequestResponse, RegisterKeyResponse, RegisterRequest, }, client::Kdf, - error::Error, }; pub struct ClientAuth<'a> { @@ -158,9 +157,11 @@ impl<'a> ClientAuth<'a> { #[cfg(feature = "internal")] fn trust_device(client: &Client) -> Result { + use bitwarden_core::VaultLocked; + let enc = client.get_encryption_settings()?; - let user_key = enc.get_key(&None).ok_or(Error::VaultLocked)?; + let user_key = enc.get_key(&None).ok_or(VaultLocked)?; Ok(DeviceKey::trust_device(user_key)?) } diff --git a/crates/bitwarden/src/auth/password/validate.rs b/crates/bitwarden/src/auth/password/validate.rs index 537b819ea..5502ecc55 100644 --- a/crates/bitwarden/src/auth/password/validate.rs +++ b/crates/bitwarden/src/auth/password/validate.rs @@ -43,6 +43,8 @@ pub(crate) fn validate_password_user_key( password: String, encrypted_user_key: String, ) -> Result { + use bitwarden_core::VaultLocked; + let login_method = client .login_method .as_ref() @@ -57,11 +59,9 @@ pub(crate) fn validate_password_user_key( .decrypt_user_key(encrypted_user_key.parse()?) .map_err(|_| "wrong password")?; - let enc = client - .get_encryption_settings() - .map_err(|_| Error::VaultLocked)?; + let enc = client.get_encryption_settings().map_err(|_| VaultLocked)?; - let existing_key = enc.get_key(&None).ok_or(Error::VaultLocked)?; + let existing_key = enc.get_key(&None).ok_or(VaultLocked)?; if user_key.to_vec() != existing_key.to_vec() { return Err("wrong user key".into()); diff --git a/crates/bitwarden/src/client/client.rs b/crates/bitwarden/src/client/client.rs index b30680654..34678983d 100644 --- a/crates/bitwarden/src/client/client.rs +++ b/crates/bitwarden/src/client/client.rs @@ -1,5 +1,6 @@ use std::path::PathBuf; +use bitwarden_core::VaultLocked; #[cfg(feature = "internal")] pub use bitwarden_crypto::Kdf; use bitwarden_crypto::SymmetricCryptoKey; @@ -17,7 +18,7 @@ use crate::{ client_settings::{ClientSettings, DeviceType}, encryption_settings::EncryptionSettings, }, - error::{Error, Result}, + error::Result, }; #[derive(Debug)] @@ -188,7 +189,7 @@ impl Client { } pub(crate) fn get_encryption_settings(&self) -> Result<&EncryptionSettings> { - self.encryption_settings.as_ref().ok_or(Error::VaultLocked) + self.encryption_settings.as_ref().ok_or(VaultLocked.into()) } pub(crate) fn set_login_method(&mut self, login_method: LoginMethod) { @@ -268,10 +269,7 @@ impl Client { &mut self, org_keys: Vec<(Uuid, AsymmetricEncString)>, ) -> Result<&EncryptionSettings> { - let enc = self - .encryption_settings - .as_mut() - .ok_or(Error::VaultLocked)?; + let enc = self.encryption_settings.as_mut().ok_or(VaultLocked)?; enc.set_org_keys(org_keys)?; Ok(&*enc) diff --git a/crates/bitwarden/src/client/encryption_settings.rs b/crates/bitwarden/src/client/encryption_settings.rs index 025b3cec7..0cf91e45d 100644 --- a/crates/bitwarden/src/client/encryption_settings.rs +++ b/crates/bitwarden/src/client/encryption_settings.rs @@ -71,11 +71,10 @@ impl EncryptionSettings { &mut self, org_enc_keys: Vec<(Uuid, AsymmetricEncString)>, ) -> Result<&mut Self> { + use bitwarden_core::VaultLocked; use bitwarden_crypto::KeyDecryptable; - use crate::error::Error; - - let private_key = self.private_key.as_ref().ok_or(Error::VaultLocked)?; + let private_key = self.private_key.as_ref().ok_or(VaultLocked)?; // Make sure we only keep the keys given in the arguments and not any of the previous // ones, which might be from organizations that the user is no longer a part of anymore diff --git a/crates/bitwarden/src/error.rs b/crates/bitwarden/src/error.rs index 9f264b465..9bf7814cf 100644 --- a/crates/bitwarden/src/error.rs +++ b/crates/bitwarden/src/error.rs @@ -17,12 +17,12 @@ use thiserror::Error; pub enum Error { #[error(transparent)] MissingFieldError(#[from] bitwarden_core::MissingFieldError), + #[error(transparent)] + VaultLocked(#[from] bitwarden_core::VaultLocked), + #[error("The client is not authenticated or the session has expired")] NotAuthenticated, - #[error("The client vault is locked and needs to be unlocked before use")] - VaultLocked, - #[error("Access token is not in a valid format: {0}")] AccessTokenInvalid(#[from] AccessTokenInvalidError), @@ -66,6 +66,17 @@ pub enum Error { #[error(transparent)] PasswordError(#[from] PasswordError), + // Vault + #[cfg(feature = "internal")] + #[error(transparent)] + Cipher(#[from] bitwarden_vault::CipherError), + #[cfg(feature = "internal")] + #[error(transparent)] + VaultParse(#[from] bitwarden_vault::VaultParseError), + #[cfg(feature = "internal")] + #[error(transparent)] + Totp(#[from] bitwarden_vault::TotpError), + #[cfg(feature = "internal")] #[error(transparent)] ExportError(#[from] ExportError), diff --git a/crates/bitwarden/src/mobile/crypto.rs b/crates/bitwarden/src/mobile/crypto.rs index ad48656a6..ea5a70cce 100644 --- a/crates/bitwarden/src/mobile/crypto.rs +++ b/crates/bitwarden/src/mobile/crypto.rs @@ -1,5 +1,6 @@ use std::collections::HashMap; +use bitwarden_core::VaultLocked; use bitwarden_crypto::{AsymmetricEncString, EncString}; #[cfg(feature = "internal")] use bitwarden_crypto::{KeyDecryptable, KeyEncryptable, MasterKey, SymmetricCryptoKey}; @@ -175,7 +176,7 @@ pub async fn get_user_encryption_key(client: &mut Client) -> Result { let user_key = client .get_encryption_settings()? .get_key(&None) - .ok_or(Error::VaultLocked)?; + .ok_or(VaultLocked)?; Ok(user_key.to_base64()) } @@ -198,7 +199,7 @@ pub fn update_password( let user_key = client .get_encryption_settings()? .get_key(&None) - .ok_or(Error::VaultLocked)?; + .ok_or(VaultLocked)?; let login_method = client .login_method @@ -243,7 +244,7 @@ pub fn derive_pin_key(client: &mut Client, pin: String) -> Result Res let user_key = client .get_encryption_settings()? .get_key(&None) - .ok_or(Error::VaultLocked)?; + .ok_or(VaultLocked)?; let pin: String = encrypted_pin.decrypt_with_key(user_key)?; let login_method = client @@ -301,7 +302,7 @@ pub(super) fn enroll_admin_password_reset( let public_key = AsymmetricPublicCryptoKey::from_der(&STANDARD.decode(public_key)?)?; let enc = client.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(Error::VaultLocked)?; + let key = enc.get_key(&None).ok_or(VaultLocked)?; Ok(AsymmetricEncString::encrypt_rsa2048_oaep_sha1( &key.to_vec(), diff --git a/crates/bitwarden/src/mobile/tool/client_sends.rs b/crates/bitwarden/src/mobile/tool/client_sends.rs index f98027974..83652c8c4 100644 --- a/crates/bitwarden/src/mobile/tool/client_sends.rs +++ b/crates/bitwarden/src/mobile/tool/client_sends.rs @@ -1,9 +1,10 @@ use std::path::Path; +use bitwarden_core::VaultLocked; use bitwarden_crypto::{EncString, KeyDecryptable, KeyEncryptable}; use crate::{ - error::{Error, Result}, + error::Result, tool::{Send, SendListView, SendView}, Client, }; @@ -15,7 +16,7 @@ pub struct ClientSends<'a> { impl<'a> ClientSends<'a> { pub async fn decrypt(&self, send: Send) -> Result { let enc = self.client.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(Error::VaultLocked)?; + let key = enc.get_key(&None).ok_or(VaultLocked)?; let send_view = send.decrypt_with_key(key)?; @@ -24,7 +25,7 @@ impl<'a> ClientSends<'a> { pub async fn decrypt_list(&self, sends: Vec) -> Result> { let enc = self.client.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(Error::VaultLocked)?; + let key = enc.get_key(&None).ok_or(VaultLocked)?; let send_views = sends.decrypt_with_key(key)?; @@ -45,7 +46,7 @@ impl<'a> ClientSends<'a> { pub async fn decrypt_buffer(&self, send: Send, encrypted_buffer: &[u8]) -> Result> { let enc = self.client.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(Error::VaultLocked)?; + let key = enc.get_key(&None).ok_or(VaultLocked)?; let key = Send::get_key(&send.key, key)?; let buf = EncString::from_buffer(encrypted_buffer)?; @@ -54,7 +55,7 @@ impl<'a> ClientSends<'a> { pub async fn encrypt(&self, send_view: SendView) -> Result { let enc = self.client.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(Error::VaultLocked)?; + let key = enc.get_key(&None).ok_or(VaultLocked)?; let send = send_view.encrypt_with_key(key)?; @@ -78,7 +79,7 @@ impl<'a> ClientSends<'a> { .client .get_encryption_settings()? .get_key(&None) - .ok_or(Error::VaultLocked)?; + .ok_or(VaultLocked)?; let key = Send::get_key(&send.key, key)?; let enc = buffer.encrypt_with_key(&key)?; diff --git a/crates/bitwarden/src/mobile/vault/client_attachments.rs b/crates/bitwarden/src/mobile/vault/client_attachments.rs index 20dcf0c13..ce7570fab 100644 --- a/crates/bitwarden/src/mobile/vault/client_attachments.rs +++ b/crates/bitwarden/src/mobile/vault/client_attachments.rs @@ -1,13 +1,14 @@ use std::path::Path; +use bitwarden_core::VaultLocked; use bitwarden_crypto::{EncString, KeyDecryptable, KeyEncryptable, LocateKey}; +use bitwarden_vault::{ + Attachment, AttachmentEncryptResult, AttachmentFile, AttachmentFileView, AttachmentView, Cipher, +}; use crate::{ error::{Error, Result}, - vault::{ - Attachment, AttachmentEncryptResult, AttachmentFile, AttachmentFileView, AttachmentView, - Cipher, ClientVault, - }, + vault::ClientVault, Client, }; @@ -23,7 +24,7 @@ impl<'a> ClientAttachments<'a> { buffer: &[u8], ) -> Result { let enc = self.client.get_encryption_settings()?; - let key = cipher.locate_key(enc, &None).ok_or(Error::VaultLocked)?; + let key = cipher.locate_key(enc, &None).ok_or(VaultLocked)?; Ok(AttachmentFileView { cipher, @@ -55,7 +56,7 @@ impl<'a> ClientAttachments<'a> { encrypted_buffer: &[u8], ) -> Result> { let enc = self.client.get_encryption_settings()?; - let key = cipher.locate_key(enc, &None).ok_or(Error::VaultLocked)?; + let key = cipher.locate_key(enc, &None).ok_or(VaultLocked)?; AttachmentFile { cipher, diff --git a/crates/bitwarden/src/mobile/vault/client_ciphers.rs b/crates/bitwarden/src/mobile/vault/client_ciphers.rs index 0127179da..63d11766d 100644 --- a/crates/bitwarden/src/mobile/vault/client_ciphers.rs +++ b/crates/bitwarden/src/mobile/vault/client_ciphers.rs @@ -1,11 +1,9 @@ +use bitwarden_core::VaultLocked; use bitwarden_crypto::{CryptoError, KeyDecryptable, KeyEncryptable, LocateKey}; +use bitwarden_vault::{Cipher, CipherListView, CipherView}; use uuid::Uuid; -use crate::{ - error::{Error, Result}, - vault::{Cipher, CipherListView, CipherView, ClientVault}, - Client, -}; +use crate::{error::Result, vault::ClientVault, Client}; pub struct ClientCiphers<'a> { pub(crate) client: &'a Client, @@ -18,15 +16,11 @@ impl<'a> ClientCiphers<'a> { // TODO: Once this flag is removed, the key generation logic should // be moved directly into the KeyEncryptable implementation if cipher_view.key.is_none() && self.client.get_flags().enable_cipher_key_encryption { - let key = cipher_view - .locate_key(enc, &None) - .ok_or(Error::VaultLocked)?; + let key = cipher_view.locate_key(enc, &None).ok_or(VaultLocked)?; cipher_view.generate_cipher_key(key)?; } - let key = cipher_view - .locate_key(enc, &None) - .ok_or(Error::VaultLocked)?; + let key = cipher_view.locate_key(enc, &None).ok_or(VaultLocked)?; let cipher = cipher_view.encrypt_with_key(key)?; Ok(cipher) @@ -79,11 +73,10 @@ impl<'a> ClientVault<'a> { #[cfg(test)] mod tests { + use bitwarden_vault::{Attachment, CipherRepromptType, CipherType, Login}; + use super::*; - use crate::{ - client::test_accounts::test_bitwarden_com_account, - vault::{login::Login, Attachment, CipherRepromptType, CipherType}, - }; + use crate::client::test_accounts::test_bitwarden_com_account; #[tokio::test] async fn test_decrypt_list() { diff --git a/crates/bitwarden/src/mobile/vault/client_collection.rs b/crates/bitwarden/src/mobile/vault/client_collection.rs index 878db238f..26b660461 100644 --- a/crates/bitwarden/src/mobile/vault/client_collection.rs +++ b/crates/bitwarden/src/mobile/vault/client_collection.rs @@ -1,10 +1,7 @@ use bitwarden_crypto::{CryptoError, KeyDecryptable, LocateKey}; +use bitwarden_vault::{Collection, CollectionView}; -use crate::{ - error::Result, - vault::{ClientVault, Collection, CollectionView}, - Client, -}; +use crate::{error::Result, vault::ClientVault, Client}; pub struct ClientCollections<'a> { pub(crate) client: &'a Client, @@ -47,7 +44,9 @@ impl<'a> ClientVault<'a> { #[cfg(test)] mod tests { - use crate::{client::test_accounts::test_bitwarden_com_account, vault::Collection, Client}; + use bitwarden_vault::Collection; + + use crate::{client::test_accounts::test_bitwarden_com_account, Client}; #[tokio::test] async fn test_decrypt_list() { diff --git a/crates/bitwarden/src/mobile/vault/client_folders.rs b/crates/bitwarden/src/mobile/vault/client_folders.rs index 9d396d9e1..cdbcdcd17 100644 --- a/crates/bitwarden/src/mobile/vault/client_folders.rs +++ b/crates/bitwarden/src/mobile/vault/client_folders.rs @@ -1,10 +1,7 @@ use bitwarden_crypto::{CryptoError, KeyDecryptable, KeyEncryptable}; +use bitwarden_vault::{Folder, FolderView}; -use crate::{ - error::Result, - vault::{ClientVault, Folder, FolderView}, - Client, -}; +use crate::{error::Result, vault::ClientVault, Client}; pub struct ClientFolders<'a> { pub(crate) client: &'a Client, diff --git a/crates/bitwarden/src/mobile/vault/client_password_history.rs b/crates/bitwarden/src/mobile/vault/client_password_history.rs index 734969127..b8fe0e0c5 100644 --- a/crates/bitwarden/src/mobile/vault/client_password_history.rs +++ b/crates/bitwarden/src/mobile/vault/client_password_history.rs @@ -1,10 +1,7 @@ use bitwarden_crypto::{CryptoError, KeyDecryptable, KeyEncryptable}; +use bitwarden_vault::{PasswordHistory, PasswordHistoryView}; -use crate::{ - error::Result, - vault::{ClientVault, PasswordHistory, PasswordHistoryView}, - Client, -}; +use crate::{error::Result, vault::ClientVault, Client}; pub struct ClientPasswordHistory<'a> { pub(crate) client: &'a Client, diff --git a/crates/bitwarden/src/mobile/vault/client_totp.rs b/crates/bitwarden/src/mobile/vault/client_totp.rs index 00a7ef6aa..b1e7747b3 100644 --- a/crates/bitwarden/src/mobile/vault/client_totp.rs +++ b/crates/bitwarden/src/mobile/vault/client_totp.rs @@ -1,9 +1,7 @@ +use bitwarden_vault::{generate_totp, TotpResponse}; use chrono::{DateTime, Utc}; -use crate::{ - error::Result, - vault::{generate_totp, ClientVault, TotpResponse}, -}; +use crate::{error::Result, vault::ClientVault}; impl<'a> ClientVault<'a> { /// Generate a TOTP code from a provided key. @@ -17,6 +15,6 @@ impl<'a> ClientVault<'a> { key: String, time: Option>, ) -> Result { - generate_totp(key, time) + Ok(generate_totp(key, time)?) } } diff --git a/crates/bitwarden/src/platform/fido2/authenticator.rs b/crates/bitwarden/src/platform/fido2/authenticator.rs index 96e53ad00..c310cf071 100644 --- a/crates/bitwarden/src/platform/fido2/authenticator.rs +++ b/crates/bitwarden/src/platform/fido2/authenticator.rs @@ -1,6 +1,8 @@ use std::sync::Mutex; +use bitwarden_core::VaultLocked; use bitwarden_crypto::KeyEncryptable; +use bitwarden_vault::{CipherView, Fido2CredentialView}; use log::error; use passkey::{ authenticator::{Authenticator, DiscoverabilitySupport, StoreInfo, UIHint, UserCheck}, @@ -11,15 +13,12 @@ use passkey::{ }; use super::{ - types::*, CheckUserOptions, CheckUserResult, CipherViewContainer, Fido2CredentialStore, - Fido2UserInterface, SelectedCredential, AAGUID, + try_from_credential_new_view, types::*, CheckUserOptions, CheckUserResult, CipherViewContainer, + Fido2CredentialStore, Fido2UserInterface, SelectedCredential, AAGUID, }; use crate::{ - error::{Error, Result}, - platform::fido2::string_to_guid_bytes, - vault::{ - login::Fido2CredentialView, CipherView, Fido2CredentialFullView, Fido2CredentialNewView, - }, + error::Result, + platform::fido2::{fill_with_credential, string_to_guid_bytes, try_from_credential_full}, Client, }; @@ -309,7 +308,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { ) -> Result<()> { let enc = this.authenticator.client.get_encryption_settings()?; - let cred = Fido2CredentialFullView::try_from_credential(cred, user, rp)?; + let cred = try_from_credential_full(cred, user, rp)?; // Get the previously selected cipher and add the new credential to it let mut selected: CipherView = this.authenticator.get_selected_credential()?.cipher; @@ -323,9 +322,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { .replace(selected.clone()); // Encrypt the updated cipher before sending it to the clients to be stored - let key = enc - .get_key(&selected.organization_id) - .ok_or(Error::VaultLocked)?; + let key = enc.get_key(&selected.organization_id).ok_or(VaultLocked)?; let encrypted = selected.encrypt_with_key(key)?; this.authenticator @@ -359,7 +356,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { return Err("Credential ID does not match selected credential".into()); } - let cred = selected.credential.fill_with_credential(cred)?; + let cred = fill_with_credential(&selected.credential, cred)?; let mut selected = selected.cipher; selected.set_new_fido2_credentials(enc, vec![cred])?; @@ -372,9 +369,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { .replace(selected.clone()); // Encrypt the updated cipher before sending it to the clients to be stored - let key = enc - .get_key(&selected.organization_id) - .ok_or(Error::VaultLocked)?; + let key = enc.get_key(&selected.organization_id).ok_or(VaultLocked)?; let encrypted = selected.encrypt_with_key(key)?; this.authenticator @@ -424,7 +419,7 @@ impl passkey::authenticator::UserValidationMethod for UserValidationMethodImpl<' let result = match hint { UIHint::RequestNewCredential(user, rp) => { - let new_credential = Fido2CredentialNewView::try_from_credential(user, rp) + let new_credential = try_from_credential_new_view(user, rp) .map_err(|_| Ctap2Error::InvalidCredential)?; let cipher_view = self diff --git a/crates/bitwarden/src/platform/fido2/mod.rs b/crates/bitwarden/src/platform/fido2/mod.rs index 099ce4fa3..d4bc32a52 100644 --- a/crates/bitwarden/src/platform/fido2/mod.rs +++ b/crates/bitwarden/src/platform/fido2/mod.rs @@ -2,6 +2,9 @@ use std::sync::Mutex; use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine}; use bitwarden_crypto::KeyContainer; +use bitwarden_vault::{ + CipherView, Fido2CredentialFullView, Fido2CredentialNewView, Fido2CredentialView, +}; use passkey::types::{ctap2::Aaguid, Passkey}; mod authenticator; @@ -28,7 +31,6 @@ pub use types::{ use self::crypto::{cose_key_to_pkcs8, pkcs8_to_cose_key}; use crate::{ error::{Error, Result}, - vault::{CipherView, Fido2CredentialFullView, Fido2CredentialNewView, Fido2CredentialView}, Client, }; @@ -105,102 +107,95 @@ impl TryFrom for Passkey { .first() .ok_or(Error::Internal("No Fido2 credentials found".into()))?; - cred.clone().try_into() + try_from_credential_full_view(cred.clone()) } } -impl TryFrom for Passkey { - type Error = crate::error::Error; - - fn try_from(value: Fido2CredentialFullView) -> Result { - let counter: u32 = value.counter.parse().expect("Invalid counter"); - let counter = (counter != 0).then_some(counter); +fn try_from_credential_full_view(value: Fido2CredentialFullView) -> Result { + let counter: u32 = value.counter.parse().expect("Invalid counter"); + let counter = (counter != 0).then_some(counter); - let key = pkcs8_to_cose_key(&value.key_value)?; + let key = pkcs8_to_cose_key(&value.key_value)?; - Ok(Self { - key, - credential_id: string_to_guid_bytes(&value.credential_id)?.into(), - rp_id: value.rp_id.clone(), - user_handle: value.user_handle.map(|u| u.into()), - counter, - }) - } + Ok(Passkey { + key, + credential_id: string_to_guid_bytes(&value.credential_id)?.into(), + rp_id: value.rp_id.clone(), + user_handle: value.user_handle.map(|u| u.into()), + counter, + }) } -impl Fido2CredentialView { - pub(crate) fn fill_with_credential(&self, value: Passkey) -> Result { - let cred_id: Vec = value.credential_id.into(); - - Ok(Fido2CredentialFullView { - credential_id: guid_bytes_to_string(&cred_id)?, - key_type: "public-key".to_owned(), - key_algorithm: "ECDSA".to_owned(), - key_curve: "P-256".to_owned(), - key_value: cose_key_to_pkcs8(&value.key)?, - rp_id: value.rp_id, - rp_name: self.rp_name.clone(), - user_handle: Some(cred_id), - - counter: value.counter.unwrap_or(0).to_string(), - user_name: self.user_name.clone(), - user_display_name: self.user_display_name.clone(), - discoverable: "true".to_owned(), - creation_date: chrono::offset::Utc::now(), - }) - } +pub fn fill_with_credential( + view: &Fido2CredentialView, + value: Passkey, +) -> Result { + let cred_id: Vec = value.credential_id.into(); + + Ok(Fido2CredentialFullView { + credential_id: guid_bytes_to_string(&cred_id)?, + key_type: "public-key".to_owned(), + key_algorithm: "ECDSA".to_owned(), + key_curve: "P-256".to_owned(), + key_value: cose_key_to_pkcs8(&value.key)?, + rp_id: value.rp_id, + rp_name: view.rp_name.clone(), + user_handle: Some(cred_id), + + counter: value.counter.unwrap_or(0).to_string(), + user_name: view.user_name.clone(), + user_display_name: view.user_display_name.clone(), + discoverable: "true".to_owned(), + creation_date: chrono::offset::Utc::now(), + }) } -impl Fido2CredentialNewView { - pub(crate) fn try_from_credential( - user: &passkey::types::ctap2::make_credential::PublicKeyCredentialUserEntity, - rp: &passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, - ) -> Result { - let cred_id: Vec = vec![0; 16]; - - Ok(Fido2CredentialNewView { - credential_id: guid_bytes_to_string(&cred_id)?, - key_type: "public-key".to_owned(), - key_algorithm: "ECDSA".to_owned(), - key_curve: "P-256".to_owned(), - rp_id: rp.id.clone(), - rp_name: rp.name.clone(), - user_handle: Some(cred_id), - - counter: 0.to_string(), - user_name: user.name.clone(), - user_display_name: user.display_name.clone(), - discoverable: "true".to_owned(), - creation_date: chrono::offset::Utc::now(), - }) - } +pub(crate) fn try_from_credential_new_view( + user: &passkey::types::ctap2::make_credential::PublicKeyCredentialUserEntity, + rp: &passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, +) -> Result { + let cred_id: Vec = vec![0; 16]; + + Ok(Fido2CredentialNewView { + credential_id: guid_bytes_to_string(&cred_id)?, + key_type: "public-key".to_owned(), + key_algorithm: "ECDSA".to_owned(), + key_curve: "P-256".to_owned(), + rp_id: rp.id.clone(), + rp_name: rp.name.clone(), + user_handle: Some(cred_id), + + counter: 0.to_string(), + user_name: user.name.clone(), + user_display_name: user.display_name.clone(), + discoverable: "true".to_owned(), + creation_date: chrono::offset::Utc::now(), + }) } -impl Fido2CredentialFullView { - pub(crate) fn try_from_credential( - value: Passkey, - user: passkey::types::ctap2::make_credential::PublicKeyCredentialUserEntity, - rp: passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, - ) -> Result { - let cred_id: Vec = value.credential_id.into(); - - Ok(Fido2CredentialFullView { - credential_id: guid_bytes_to_string(&cred_id)?, - key_type: "public-key".to_owned(), - key_algorithm: "ECDSA".to_owned(), - key_curve: "P-256".to_owned(), - key_value: cose_key_to_pkcs8(&value.key)?, - rp_id: value.rp_id, - rp_name: rp.name, - user_handle: Some(cred_id), - - counter: value.counter.unwrap_or(0).to_string(), - user_name: user.name, - user_display_name: user.display_name, - discoverable: "true".to_owned(), - creation_date: chrono::offset::Utc::now(), - }) - } +pub(crate) fn try_from_credential_full( + value: Passkey, + user: passkey::types::ctap2::make_credential::PublicKeyCredentialUserEntity, + rp: passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, +) -> Result { + let cred_id: Vec = value.credential_id.into(); + + Ok(Fido2CredentialFullView { + credential_id: guid_bytes_to_string(&cred_id)?, + key_type: "public-key".to_owned(), + key_algorithm: "ECDSA".to_owned(), + key_curve: "P-256".to_owned(), + key_value: cose_key_to_pkcs8(&value.key)?, + rp_id: value.rp_id, + rp_name: rp.name, + user_handle: Some(cred_id), + + counter: value.counter.unwrap_or(0).to_string(), + user_name: user.name, + user_display_name: user.display_name, + discoverable: "true".to_owned(), + creation_date: chrono::offset::Utc::now(), + }) } pub fn guid_bytes_to_string(source: &[u8]) -> Result { diff --git a/crates/bitwarden/src/platform/fido2/traits.rs b/crates/bitwarden/src/platform/fido2/traits.rs index cc27e4bd6..f64bf100e 100644 --- a/crates/bitwarden/src/platform/fido2/traits.rs +++ b/crates/bitwarden/src/platform/fido2/traits.rs @@ -1,10 +1,8 @@ +use bitwarden_vault::{Cipher, CipherView, Fido2CredentialNewView}; use passkey::authenticator::UIHint; use thiserror::Error; -use crate::{ - error::Result, - vault::{Cipher, CipherView, Fido2CredentialNewView}, -}; +use crate::error::Result; #[derive(Debug, Error)] pub enum Fido2CallbackError { diff --git a/crates/bitwarden/src/secrets_manager/projects/create.rs b/crates/bitwarden/src/secrets_manager/projects/create.rs index ab3b7bd62..1f82d4c59 100644 --- a/crates/bitwarden/src/secrets_manager/projects/create.rs +++ b/crates/bitwarden/src/secrets_manager/projects/create.rs @@ -1,14 +1,12 @@ use bitwarden_api_api::models::ProjectCreateRequestModel; +use bitwarden_core::VaultLocked; use bitwarden_crypto::KeyEncryptable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; use super::ProjectResponse; -use crate::{ - client::Client, - error::{Error, Result}, -}; +use crate::{client::Client, error::Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -26,7 +24,7 @@ pub(crate) async fn create_project( let key = client .get_encryption_settings()? .get_key(&Some(input.organization_id)) - .ok_or(Error::VaultLocked)?; + .ok_or(VaultLocked)?; let project = Some(ProjectCreateRequestModel { name: input.name.clone().encrypt_with_key(key)?.to_string(), diff --git a/crates/bitwarden/src/secrets_manager/projects/update.rs b/crates/bitwarden/src/secrets_manager/projects/update.rs index e00609ff4..86c269b1a 100644 --- a/crates/bitwarden/src/secrets_manager/projects/update.rs +++ b/crates/bitwarden/src/secrets_manager/projects/update.rs @@ -1,14 +1,12 @@ use bitwarden_api_api::models::ProjectUpdateRequestModel; +use bitwarden_core::VaultLocked; use bitwarden_crypto::KeyEncryptable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; use super::ProjectResponse; -use crate::{ - client::Client, - error::{Error, Result}, -}; +use crate::{client::Client, error::Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -28,7 +26,7 @@ pub(crate) async fn update_project( let key = client .get_encryption_settings()? .get_key(&Some(input.organization_id)) - .ok_or(Error::VaultLocked)?; + .ok_or(VaultLocked)?; let project = Some(ProjectUpdateRequestModel { name: input.name.clone().encrypt_with_key(key)?.to_string(), diff --git a/crates/bitwarden/src/secrets_manager/secrets/create.rs b/crates/bitwarden/src/secrets_manager/secrets/create.rs index 4f84223dc..67f2a695e 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/create.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/create.rs @@ -1,14 +1,12 @@ use bitwarden_api_api::models::SecretCreateRequestModel; +use bitwarden_core::VaultLocked; use bitwarden_crypto::KeyEncryptable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; use super::SecretResponse; -use crate::{ - error::{Error, Result}, - Client, -}; +use crate::{error::Result, Client}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -31,7 +29,7 @@ pub(crate) async fn create_secret( let key = client .get_encryption_settings()? .get_key(&Some(input.organization_id)) - .ok_or(Error::VaultLocked)?; + .ok_or(VaultLocked)?; let secret = Some(SecretCreateRequestModel { key: input.key.clone().encrypt_with_key(key)?.to_string(), diff --git a/crates/bitwarden/src/secrets_manager/secrets/update.rs b/crates/bitwarden/src/secrets_manager/secrets/update.rs index f9e54f810..a25900151 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/update.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/update.rs @@ -1,14 +1,12 @@ use bitwarden_api_api::models::SecretUpdateRequestModel; +use bitwarden_core::VaultLocked; use bitwarden_crypto::KeyEncryptable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; use super::SecretResponse; -use crate::{ - client::Client, - error::{Error, Result}, -}; +use crate::{client::Client, error::Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -31,7 +29,7 @@ pub(crate) async fn update_secret( let key = client .get_encryption_settings()? .get_key(&Some(input.organization_id)) - .ok_or(Error::VaultLocked)?; + .ok_or(VaultLocked)?; let secret = Some(SecretUpdateRequestModel { key: input.key.clone().encrypt_with_key(key)?.to_string(), diff --git a/crates/bitwarden/src/tool/exporters/client_exporter.rs b/crates/bitwarden/src/tool/exporters/client_exporter.rs index 05eb737f3..788ba272e 100644 --- a/crates/bitwarden/src/tool/exporters/client_exporter.rs +++ b/crates/bitwarden/src/tool/exporters/client_exporter.rs @@ -1,7 +1,8 @@ +use bitwarden_vault::{Cipher, Collection, Folder}; + use crate::{ error::Result, tool::exporters::{export_organization_vault, export_vault, ExportFormat}, - vault::{Cipher, Collection, Folder}, Client, }; diff --git a/crates/bitwarden/src/tool/exporters/mod.rs b/crates/bitwarden/src/tool/exporters/mod.rs index b52b91813..321ed5f6c 100644 --- a/crates/bitwarden/src/tool/exporters/mod.rs +++ b/crates/bitwarden/src/tool/exporters/mod.rs @@ -1,15 +1,12 @@ -use bitwarden_core::require; +use bitwarden_core::VaultLocked; use bitwarden_crypto::KeyDecryptable; use bitwarden_exporters::export; +use bitwarden_vault::{Cipher, CipherView, Collection, Folder, FolderView}; use schemars::JsonSchema; use crate::{ client::{LoginMethod, UserLoginMethod}, error::{Error, Result}, - vault::{ - login::LoginUriView, Cipher, CipherType, CipherView, Collection, FieldView, Folder, - FolderView, SecureNoteType, - }, Client, }; @@ -31,7 +28,7 @@ pub(super) fn export_vault( format: ExportFormat, ) -> Result { let enc = client.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(Error::VaultLocked)?; + let key = enc.get_key(&None).ok_or(VaultLocked)?; let folders: Vec = folders.decrypt_with_key(key)?; let folders: Vec = @@ -80,225 +77,13 @@ pub(super) fn export_organization_vault( todo!(); } -impl TryFrom for bitwarden_exporters::Folder { - type Error = Error; - - fn try_from(value: FolderView) -> Result { - Ok(Self { - id: require!(value.id), - name: value.name, - }) - } -} - -impl TryFrom for bitwarden_exporters::Cipher { - type Error = Error; - - fn try_from(value: CipherView) -> Result { - let r = match value.r#type { - CipherType::Login => { - let l = require!(value.login); - bitwarden_exporters::CipherType::Login(Box::new(bitwarden_exporters::Login { - username: l.username, - password: l.password, - login_uris: l - .uris - .unwrap_or_default() - .into_iter() - .map(|u| u.into()) - .collect(), - totp: l.totp, - })) - } - CipherType::SecureNote => bitwarden_exporters::CipherType::SecureNote(Box::new( - bitwarden_exporters::SecureNote { - r#type: value - .secure_note - .map(|t| t.r#type) - .unwrap_or(SecureNoteType::Generic) - .into(), - }, - )), - CipherType::Card => { - let c = require!(value.card); - bitwarden_exporters::CipherType::Card(Box::new(bitwarden_exporters::Card { - cardholder_name: c.cardholder_name, - exp_month: c.exp_month, - exp_year: c.exp_year, - code: c.code, - brand: c.brand, - number: c.number, - })) - } - CipherType::Identity => { - let i = require!(value.identity); - bitwarden_exporters::CipherType::Identity(Box::new(bitwarden_exporters::Identity { - title: i.title, - first_name: i.first_name, - middle_name: i.middle_name, - last_name: i.last_name, - address1: i.address1, - address2: i.address2, - address3: i.address3, - city: i.city, - state: i.state, - postal_code: i.postal_code, - country: i.country, - company: i.company, - email: i.email, - phone: i.phone, - ssn: i.ssn, - username: i.username, - passport_number: i.passport_number, - license_number: i.license_number, - })) - } - }; - - Ok(Self { - id: require!(value.id), - folder_id: value.folder_id, - name: value.name, - notes: value.notes, - r#type: r, - favorite: value.favorite, - reprompt: value.reprompt as u8, - fields: value - .fields - .unwrap_or_default() - .into_iter() - .map(|f| f.into()) - .collect(), - revision_date: value.revision_date, - creation_date: value.creation_date, - deleted_date: value.deleted_date, - }) - } -} - -impl From for bitwarden_exporters::Field { - fn from(value: FieldView) -> Self { - Self { - name: value.name, - value: value.value, - r#type: value.r#type as u8, - linked_id: value.linked_id.map(|id| id.into()), - } - } -} - -impl From for bitwarden_exporters::LoginUri { - fn from(value: LoginUriView) -> Self { - Self { - r#match: value.r#match.map(|v| v as u8), - uri: value.uri, - } - } -} - -impl From for bitwarden_exporters::SecureNoteType { - fn from(value: SecureNoteType) -> Self { - match value { - SecureNoteType::Generic => bitwarden_exporters::SecureNoteType::Generic, - } - } -} - #[cfg(test)] mod tests { use std::num::NonZeroU32; use bitwarden_crypto::Kdf; - use chrono::{DateTime, Utc}; use super::*; - use crate::vault::{login::LoginView, CipherRepromptType}; - - #[test] - fn test_try_from_folder_view() { - let view = FolderView { - id: Some("fd411a1a-fec8-4070-985d-0e6560860e69".parse().unwrap()), - name: "test_name".to_string(), - revision_date: "2024-01-30T17:55:36.150Z".parse().unwrap(), - }; - - let f: bitwarden_exporters::Folder = view.try_into().unwrap(); - - assert_eq!( - f.id, - "fd411a1a-fec8-4070-985d-0e6560860e69".parse().unwrap() - ); - assert_eq!(f.name, "test_name".to_string()); - } - - #[test] - fn test_try_from_cipher_view_login() { - let cipher_view = CipherView { - r#type: CipherType::Login, - login: Some(LoginView { - username: Some("test_username".to_string()), - password: Some("test_password".to_string()), - password_revision_date: None, - uris: None, - totp: None, - autofill_on_page_load: None, - fido2_credentials: None, - }), - id: "fd411a1a-fec8-4070-985d-0e6560860e69".parse().ok(), - organization_id: None, - folder_id: None, - collection_ids: vec![], - key: None, - name: "My login".to_string(), - notes: None, - identity: None, - card: None, - secure_note: None, - favorite: false, - reprompt: CipherRepromptType::None, - organization_use_totp: true, - edit: true, - view_password: true, - local_data: None, - attachments: None, - fields: None, - password_history: None, - creation_date: "2024-01-30T17:55:36.150Z".parse().unwrap(), - deleted_date: None, - revision_date: "2024-01-30T17:55:36.150Z".parse().unwrap(), - }; - - let cipher: bitwarden_exporters::Cipher = cipher_view.try_into().unwrap(); - - assert_eq!( - cipher.id, - "fd411a1a-fec8-4070-985d-0e6560860e69".parse().unwrap() - ); - assert_eq!(cipher.folder_id, None); - assert_eq!(cipher.name, "My login".to_string()); - assert_eq!(cipher.notes, None); - assert!(!cipher.favorite); - assert_eq!(cipher.reprompt, 0); - assert!(cipher.fields.is_empty()); - assert_eq!( - cipher.revision_date, - "2024-01-30T17:55:36.150Z".parse::>().unwrap() - ); - assert_eq!( - cipher.creation_date, - "2024-01-30T17:55:36.150Z".parse::>().unwrap() - ); - assert_eq!(cipher.deleted_date, None); - - if let bitwarden_exporters::CipherType::Login(l) = cipher.r#type { - assert_eq!(l.username, Some("test_username".to_string())); - assert_eq!(l.password, Some("test_password".to_string())); - assert!(l.login_uris.is_empty()); - assert_eq!(l.totp, None); - } else { - panic!("Expected login type"); - } - } #[test] fn test_convert_format() { diff --git a/crates/bitwarden/src/vault/mod.rs b/crates/bitwarden/src/vault/mod.rs index 220337b6c..8a6bf77f6 100644 --- a/crates/bitwarden/src/vault/mod.rs +++ b/crates/bitwarden/src/vault/mod.rs @@ -1,30 +1,9 @@ -mod cipher; -pub use cipher::*; - -#[cfg(feature = "internal")] -mod client_vault; -#[cfg(feature = "internal")] -pub use client_vault::ClientVault; - -mod collection; -pub use collection::{Collection, CollectionView}; - -mod folder; -pub use folder::{Folder, FolderView}; - -mod password_history; -pub use password_history::{PasswordHistory, PasswordHistoryView}; - -#[cfg(feature = "internal")] mod sync; -#[cfg(feature = "internal")] pub use sync::{SyncRequest, SyncResponse}; -#[cfg(feature = "internal")] -mod domain; - -#[cfg(feature = "internal")] -mod totp; -#[cfg(feature = "internal")] -pub(crate) use totp::generate_totp; -#[cfg(feature = "internal")] -pub use totp::TotpResponse; +mod client_vault; +pub use bitwarden_vault::{ + Attachment, AttachmentEncryptResult, AttachmentView, Cipher, CipherListView, CipherView, + Collection, CollectionView, Fido2CredentialNewView, Fido2CredentialView, Folder, FolderView, + PasswordHistory, PasswordHistoryView, TotpResponse, +}; +pub use client_vault::ClientVault; diff --git a/crates/bitwarden/src/vault/sync.rs b/crates/bitwarden/src/vault/sync.rs index 79f29d870..b7b96d63f 100644 --- a/crates/bitwarden/src/vault/sync.rs +++ b/crates/bitwarden/src/vault/sync.rs @@ -2,16 +2,15 @@ use bitwarden_api_api::models::{ DomainsResponseModel, ProfileOrganizationResponseModel, ProfileResponseModel, SyncResponseModel, }; use bitwarden_core::require; +use bitwarden_vault::{Cipher, Collection, Folder, GlobalDomains}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; -use super::domain::GlobalDomains; use crate::{ admin_console::Policy, client::{encryption_settings::EncryptionSettings, Client}, error::{Error, Result}, - vault::{Cipher, Collection, Folder}, }; #[derive(Serialize, Deserialize, Debug, JsonSchema)] @@ -141,14 +140,15 @@ impl ProfileResponse { impl TryFrom for DomainResponse { type Error = Error; - fn try_from(value: DomainsResponseModel) -> Result { + + fn try_from(value: DomainsResponseModel) -> Result { Ok(Self { equivalent_domains: value.equivalent_domains.unwrap_or_default(), global_equivalent_domains: value .global_equivalent_domains .unwrap_or_default() .into_iter() - .map(|s| s.try_into()) + .map(|s| s.try_into().map_err(Error::VaultParse)) .collect::>>()?, }) } From 1e2834b1835e1fba35369e056fc8ce0139337a68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Mon, 10 Jun 2024 16:55:50 +0200 Subject: [PATCH 004/214] Use non-root in bws scratch Docker image (#828) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective After the `bws` Docker image got moved to use `scratch` as a base image, non-root support got removed. This PR introduces it again, which should also remedy the SonarCloud scanner CI failure. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bws/Dockerfile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/bws/Dockerfile b/crates/bws/Dockerfile index ccf9865c9..1f3542e52 100644 --- a/crates/bws/Dockerfile +++ b/crates/bws/Dockerfile @@ -24,8 +24,8 @@ RUN mkdir /lib64-bws RUN ldd /app/target/release/bws | tr -s '[:blank:]' '\n' | grep '^/lib' | xargs -I % cp % /lib-bws RUN ldd /app/target/release/bws | tr -s '[:blank:]' '\n' | grep '^/lib64' | xargs -I % cp % /lib64-bws -# Make a HOME directory for the app stage -RUN mkdir -p /home/app +# Make a user and HOME directory for the app stage +RUN useradd -m app ############################################### # App stage # @@ -35,11 +35,15 @@ FROM scratch ARG TARGETPLATFORM LABEL com.bitwarden.product="bitwarden" -# Set a HOME directory +# Set a HOME directory and copy the user file COPY --from=build /home/app /home/app +COPY --from=build /etc/passwd /etc/passwd ENV HOME=/home/app WORKDIR /home/app +# Switch to the app user +USER app + # Copy built project from the build stage COPY --from=build /app/target/release/bws /bin/bws From aff96d265bbe5e10d5b6ebb239b9ba8134f93f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Mon, 10 Jun 2024 16:58:57 +0200 Subject: [PATCH 005/214] Clear stack after argon2 (#827) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective The argon2 library doesn't seem to clear the stack after doing a hash, but we can overwrite the stack by calling a function that creates a big stack allocated array right after the hash operation. I've tried changing the parameters to the argon2 function and tweaking the array size to see where the limit should be, and in most of my tests clearing around 3700 bytes is enough. I've decided to round it up to the page size to be safe. ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-crypto/src/keys/utils.rs | 9 +++++++++ crates/memory-testing/cases.json | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/bitwarden-crypto/src/keys/utils.rs b/crates/bitwarden-crypto/src/keys/utils.rs index a2df336e1..559234125 100644 --- a/crates/bitwarden-crypto/src/keys/utils.rs +++ b/crates/bitwarden-crypto/src/keys/utils.rs @@ -32,6 +32,15 @@ pub(super) fn derive_kdf_key(secret: &[u8], salt: &[u8], kdf: &Kdf) -> Result Date: Mon, 10 Jun 2024 18:01:59 +0200 Subject: [PATCH 006/214] Fix android after bitwarden-vault PR (#830) #825 broke android. --- Cargo.lock | 1 + crates/bitwarden-uniffi/Cargo.toml | 1 + crates/bitwarden-vault/uniffi.toml | 9 +++++++++ .../java/com/bitwarden/myapplication/MainActivity.kt | 2 +- 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 crates/bitwarden-vault/uniffi.toml diff --git a/Cargo.lock b/Cargo.lock index 4c5a2de7c..5755f5cd5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -566,6 +566,7 @@ dependencies = [ "bitwarden-core", "bitwarden-crypto", "bitwarden-generators", + "bitwarden-vault", "chrono", "env_logger 0.11.3", "log", diff --git a/crates/bitwarden-uniffi/Cargo.toml b/crates/bitwarden-uniffi/Cargo.toml index 92cd1f3e9..e1e4bc10b 100644 --- a/crates/bitwarden-uniffi/Cargo.toml +++ b/crates/bitwarden-uniffi/Cargo.toml @@ -24,6 +24,7 @@ bitwarden = { workspace = true, features = ["internal", "uniffi"] } bitwarden-core = { workspace = true, features = ["uniffi"] } bitwarden-crypto = { workspace = true, features = ["uniffi"] } bitwarden-generators = { workspace = true, features = ["uniffi"] } +bitwarden-vault = { workspace = true, features = ["uniffi"] } chrono = { version = ">=0.4.26, <0.5", features = [ "serde", "std", diff --git a/crates/bitwarden-vault/uniffi.toml b/crates/bitwarden-vault/uniffi.toml new file mode 100644 index 000000000..8d4fbe384 --- /dev/null +++ b/crates/bitwarden-vault/uniffi.toml @@ -0,0 +1,9 @@ +[bindings.kotlin] +package_name = "com.bitwarden.vault" +generate_immutable_records = true +android = true + +[bindings.swift] +ffi_module_name = "BitwardenVaultFFI" +module_name = "BitwardenVault" +generate_immutable_records = true diff --git a/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt b/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt index d304da8a1..889079692 100644 --- a/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt +++ b/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt @@ -23,7 +23,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.unit.dp import androidx.fragment.app.FragmentActivity import com.bitwarden.core.DateTime -import com.bitwarden.bitwarden.Folder +import com.bitwarden.vault.Folder import com.bitwarden.bitwarden.InitOrgCryptoRequest import com.bitwarden.bitwarden.InitUserCryptoMethod import com.bitwarden.bitwarden.InitUserCryptoRequest From dfd0ba8d3d796021a5ac9fb46e2d86d048188add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Tue, 11 Jun 2024 11:27:34 +0200 Subject: [PATCH 007/214] Fix save_credential failing when the selected cipher doesn't have a Passkey (#831) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective The current call to `get_selected_credential` inside `save_credential` will try to fetch and decrypt the ciphers FIDO2 credentials, and error if they are not there. This can only happen when creating a new Passkey, so instead of calling `get_selected_credential` we just get the value from the lock. The other places where `get_selected_credential` is used is in `update_credential` and right at the end of the `assertion`, `register` and `authenticate` operations, so those should be safe. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --------- Co-authored-by: Andreas Coroiu --- crates/bitwarden/src/platform/fido2/authenticator.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/bitwarden/src/platform/fido2/authenticator.rs b/crates/bitwarden/src/platform/fido2/authenticator.rs index c310cf071..7ea6ada4b 100644 --- a/crates/bitwarden/src/platform/fido2/authenticator.rs +++ b/crates/bitwarden/src/platform/fido2/authenticator.rs @@ -311,7 +311,14 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { let cred = try_from_credential_full(cred, user, rp)?; // Get the previously selected cipher and add the new credential to it - let mut selected: CipherView = this.authenticator.get_selected_credential()?.cipher; + let mut selected: CipherView = this + .authenticator + .selected_credential + .lock() + .expect("Mutex is not poisoned") + .clone() + .ok_or("No selected cipher available")?; + selected.set_new_fido2_credentials(enc, vec![cred])?; // Store the updated credential for later use From 47f4b1c9f74e96e7a69655476aeded2e799f1886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Tue, 11 Jun 2024 12:20:59 +0200 Subject: [PATCH 008/214] Rename selected_credential to selected_cipher (#832) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📔 Objective `selected_credential` is a misleading name as the selected value doesn't have to contain credentials, for example when creating a new passkey a cipher will usually not contain any credentials. Renaming it to `selected_cipher` should help clear the confusion a bit. I've left the `get_selected_credential` function with the same name, as in this case we are actually getting the credential inside the cipher. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .../bitwarden/src/platform/fido2/authenticator.rs | 14 +++++++------- crates/bitwarden/src/platform/fido2/mod.rs | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/bitwarden/src/platform/fido2/authenticator.rs b/crates/bitwarden/src/platform/fido2/authenticator.rs index 7ea6ada4b..797ba87a1 100644 --- a/crates/bitwarden/src/platform/fido2/authenticator.rs +++ b/crates/bitwarden/src/platform/fido2/authenticator.rs @@ -27,7 +27,7 @@ pub struct Fido2Authenticator<'a> { pub(crate) user_interface: &'a dyn Fido2UserInterface, pub(crate) credential_store: &'a dyn Fido2CredentialStore, - pub(crate) selected_credential: Mutex>, + pub(crate) selected_cipher: Mutex>, pub(crate) requested_uv: Mutex>, } @@ -202,7 +202,7 @@ impl<'a> Fido2Authenticator<'a> { let enc = self.client.get_encryption_settings()?; let cipher = self - .selected_credential + .selected_cipher .lock() .expect("Mutex is not poisoned") .clone() @@ -275,7 +275,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { // Store the selected credential for later use this.authenticator - .selected_credential + .selected_cipher .lock() .expect("Mutex is not poisoned") .replace(picked.clone()); @@ -313,7 +313,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { // Get the previously selected cipher and add the new credential to it let mut selected: CipherView = this .authenticator - .selected_credential + .selected_cipher .lock() .expect("Mutex is not poisoned") .clone() @@ -323,7 +323,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { // Store the updated credential for later use this.authenticator - .selected_credential + .selected_cipher .lock() .expect("Mutex is not poisoned") .replace(selected.clone()); @@ -370,7 +370,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { // Store the updated credential for later use this.authenticator - .selected_credential + .selected_cipher .lock() .expect("Mutex is not poisoned") .replace(selected.clone()); @@ -437,7 +437,7 @@ impl passkey::authenticator::UserValidationMethod for UserValidationMethodImpl<' .map_err(|_| Ctap2Error::OperationDenied)?; self.authenticator - .selected_credential + .selected_cipher .lock() .expect("Mutex is not poisoned") .replace(cipher_view); diff --git a/crates/bitwarden/src/platform/fido2/mod.rs b/crates/bitwarden/src/platform/fido2/mod.rs index d4bc32a52..b523cf7e5 100644 --- a/crates/bitwarden/src/platform/fido2/mod.rs +++ b/crates/bitwarden/src/platform/fido2/mod.rs @@ -56,7 +56,7 @@ impl<'a> ClientFido2<'a> { client: self.client, user_interface, credential_store, - selected_credential: Mutex::new(None), + selected_cipher: Mutex::new(None), requested_uv: Mutex::new(None), }) } From 3fc7fd27b15ead4c2d41fea711194d1353e2eb49 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 11 Jun 2024 16:17:57 +0200 Subject: [PATCH 009/214] Flip the dependency between exporters and vault (#833) In preparation for #798 we need to flip the relationship between vault and exporters. Due to exporters in the future getting a `client_exporters` which means they need to be able to access the vault models to properly model it. --- Cargo.lock | 3 +- crates/bitwarden-exporters/Cargo.toml | 2 + crates/bitwarden-exporters/src/lib.rs | 2 +- .../src/models.rs} | 47 +++++++++---------- crates/bitwarden-vault/Cargo.toml | 1 - crates/bitwarden-vault/src/cipher/field.rs | 8 ++-- crates/bitwarden-vault/src/cipher/mod.rs | 2 +- .../bitwarden-vault/src/cipher/secure_note.rs | 2 +- crates/bitwarden-vault/src/lib.rs | 1 - 9 files changed, 34 insertions(+), 34 deletions(-) rename crates/{bitwarden-vault/src/exporters.rs => bitwarden-exporters/src/models.rs} (80%) diff --git a/Cargo.lock b/Cargo.lock index 5755f5cd5..480a1d3bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -493,7 +493,9 @@ name = "bitwarden-exporters" version = "0.5.0" dependencies = [ "base64 0.22.1", + "bitwarden-core", "bitwarden-crypto", + "bitwarden-vault", "chrono", "csv", "serde", @@ -584,7 +586,6 @@ dependencies = [ "bitwarden-api-api", "bitwarden-core", "bitwarden-crypto", - "bitwarden-exporters", "chrono", "hmac", "rand", diff --git a/crates/bitwarden-exporters/Cargo.toml b/crates/bitwarden-exporters/Cargo.toml index b607879ba..ac302526c 100644 --- a/crates/bitwarden-exporters/Cargo.toml +++ b/crates/bitwarden-exporters/Cargo.toml @@ -16,7 +16,9 @@ keywords.workspace = true [dependencies] base64 = ">=0.21.2, <0.23" +bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } +bitwarden-vault = { workspace = true } chrono = { version = ">=0.4.26, <0.5", features = [ "clock", "serde", diff --git a/crates/bitwarden-exporters/src/lib.rs b/crates/bitwarden-exporters/src/lib.rs index 762556388..e754a64d1 100644 --- a/crates/bitwarden-exporters/src/lib.rs +++ b/crates/bitwarden-exporters/src/lib.rs @@ -10,8 +10,8 @@ use crate::csv::export_csv; mod json; use json::export_json; mod encrypted_json; - use encrypted_json::export_encrypted_json; +mod models; pub enum Format { Csv, diff --git a/crates/bitwarden-vault/src/exporters.rs b/crates/bitwarden-exporters/src/models.rs similarity index 80% rename from crates/bitwarden-vault/src/exporters.rs rename to crates/bitwarden-exporters/src/models.rs index 3b228f231..1d56e7233 100644 --- a/crates/bitwarden-vault/src/exporters.rs +++ b/crates/bitwarden-exporters/src/models.rs @@ -1,8 +1,9 @@ use bitwarden_core::{require, MissingFieldError}; +use bitwarden_vault::{ + CipherType, CipherView, FieldView, FolderView, LoginUriView, SecureNoteType, +}; -use crate::{login::LoginUriView, CipherType, CipherView, FieldView, FolderView, SecureNoteType}; - -impl TryFrom for bitwarden_exporters::Folder { +impl TryFrom for crate::Folder { type Error = MissingFieldError; fn try_from(value: FolderView) -> Result { @@ -13,14 +14,14 @@ impl TryFrom for bitwarden_exporters::Folder { } } -impl TryFrom for bitwarden_exporters::Cipher { +impl TryFrom for crate::Cipher { type Error = MissingFieldError; fn try_from(value: CipherView) -> Result { let r = match value.r#type { CipherType::Login => { let l = require!(value.login); - bitwarden_exporters::CipherType::Login(Box::new(bitwarden_exporters::Login { + crate::CipherType::Login(Box::new(crate::Login { username: l.username, password: l.password, login_uris: l @@ -32,18 +33,16 @@ impl TryFrom for bitwarden_exporters::Cipher { totp: l.totp, })) } - CipherType::SecureNote => bitwarden_exporters::CipherType::SecureNote(Box::new( - bitwarden_exporters::SecureNote { - r#type: value - .secure_note - .map(|t| t.r#type) - .unwrap_or(SecureNoteType::Generic) - .into(), - }, - )), + CipherType::SecureNote => crate::CipherType::SecureNote(Box::new(crate::SecureNote { + r#type: value + .secure_note + .map(|t| t.r#type) + .unwrap_or(SecureNoteType::Generic) + .into(), + })), CipherType::Card => { let c = require!(value.card); - bitwarden_exporters::CipherType::Card(Box::new(bitwarden_exporters::Card { + crate::CipherType::Card(Box::new(crate::Card { cardholder_name: c.cardholder_name, exp_month: c.exp_month, exp_year: c.exp_year, @@ -54,7 +53,7 @@ impl TryFrom for bitwarden_exporters::Cipher { } CipherType::Identity => { let i = require!(value.identity); - bitwarden_exporters::CipherType::Identity(Box::new(bitwarden_exporters::Identity { + crate::CipherType::Identity(Box::new(crate::Identity { title: i.title, first_name: i.first_name, middle_name: i.middle_name, @@ -98,7 +97,7 @@ impl TryFrom for bitwarden_exporters::Cipher { } } -impl From for bitwarden_exporters::Field { +impl From for crate::Field { fn from(value: FieldView) -> Self { Self { name: value.name, @@ -109,7 +108,7 @@ impl From for bitwarden_exporters::Field { } } -impl From for bitwarden_exporters::LoginUri { +impl From for crate::LoginUri { fn from(value: LoginUriView) -> Self { Self { r#match: value.r#match.map(|v| v as u8), @@ -118,20 +117,20 @@ impl From for bitwarden_exporters::LoginUri { } } -impl From for bitwarden_exporters::SecureNoteType { +impl From for crate::SecureNoteType { fn from(value: SecureNoteType) -> Self { match value { - SecureNoteType::Generic => bitwarden_exporters::SecureNoteType::Generic, + SecureNoteType::Generic => crate::SecureNoteType::Generic, } } } #[cfg(test)] mod tests { + use bitwarden_vault::{CipherRepromptType, LoginView}; use chrono::{DateTime, Utc}; use super::*; - use crate::{CipherRepromptType, LoginView}; #[test] fn test_try_from_folder_view() { @@ -141,7 +140,7 @@ mod tests { revision_date: "2024-01-30T17:55:36.150Z".parse().unwrap(), }; - let f: bitwarden_exporters::Folder = view.try_into().unwrap(); + let f: crate::Folder = view.try_into().unwrap(); assert_eq!( f.id, @@ -187,7 +186,7 @@ mod tests { revision_date: "2024-01-30T17:55:36.150Z".parse().unwrap(), }; - let cipher: bitwarden_exporters::Cipher = cipher_view.try_into().unwrap(); + let cipher: crate::Cipher = cipher_view.try_into().unwrap(); assert_eq!( cipher.id, @@ -209,7 +208,7 @@ mod tests { ); assert_eq!(cipher.deleted_date, None); - if let bitwarden_exporters::CipherType::Login(l) = cipher.r#type { + if let crate::CipherType::Login(l) = cipher.r#type { assert_eq!(l.username, Some("test_username".to_string())); assert_eq!(l.password, Some("test_password".to_string())); assert!(l.login_uris.is_empty()); diff --git a/crates/bitwarden-vault/Cargo.toml b/crates/bitwarden-vault/Cargo.toml index 379b23997..f14f090d9 100644 --- a/crates/bitwarden-vault/Cargo.toml +++ b/crates/bitwarden-vault/Cargo.toml @@ -25,7 +25,6 @@ base64 = ">=0.21.2, <0.23" bitwarden-api-api = { workspace = true } bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } -bitwarden-exporters = { workspace = true } chrono = { version = ">=0.4.26, <0.5", default-features = false } rand = ">=0.8.5, <0.9" hmac = ">=0.12.1, <0.13" diff --git a/crates/bitwarden-vault/src/cipher/field.rs b/crates/bitwarden-vault/src/cipher/field.rs index 2141006af..6c826d4ba 100644 --- a/crates/bitwarden-vault/src/cipher/field.rs +++ b/crates/bitwarden-vault/src/cipher/field.rs @@ -35,11 +35,11 @@ pub struct Field { #[serde(rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] pub struct FieldView { - pub(crate) name: Option, - pub(crate) value: Option, - pub(crate) r#type: FieldType, + pub name: Option, + pub value: Option, + pub r#type: FieldType, - pub(crate) linked_id: Option, + pub linked_id: Option, } impl KeyEncryptable for FieldView { diff --git a/crates/bitwarden-vault/src/cipher/mod.rs b/crates/bitwarden-vault/src/cipher/mod.rs index 1b13ac743..67513d524 100644 --- a/crates/bitwarden-vault/src/cipher/mod.rs +++ b/crates/bitwarden-vault/src/cipher/mod.rs @@ -16,6 +16,6 @@ pub use cipher::{Cipher, CipherError, CipherListView, CipherRepromptType, Cipher pub use field::FieldView; pub use login::{ Fido2Credential, Fido2CredentialFullView, Fido2CredentialNewView, Fido2CredentialView, Login, - LoginView, + LoginUriView, LoginView, }; pub use secure_note::SecureNoteType; diff --git a/crates/bitwarden-vault/src/cipher/secure_note.rs b/crates/bitwarden-vault/src/cipher/secure_note.rs index 8ae39eb4d..2563160bb 100644 --- a/crates/bitwarden-vault/src/cipher/secure_note.rs +++ b/crates/bitwarden-vault/src/cipher/secure_note.rs @@ -25,7 +25,7 @@ pub struct SecureNote { #[serde(rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] pub struct SecureNoteView { - pub(crate) r#type: SecureNoteType, + pub r#type: SecureNoteType, } impl KeyEncryptable for SecureNoteView { diff --git a/crates/bitwarden-vault/src/lib.rs b/crates/bitwarden-vault/src/lib.rs index 4928f2766..1e5b5c5aa 100644 --- a/crates/bitwarden-vault/src/lib.rs +++ b/crates/bitwarden-vault/src/lib.rs @@ -17,4 +17,3 @@ mod totp; pub use totp::{generate_totp, TotpError, TotpResponse}; mod error; pub use error::VaultParseError; -mod exporters; From 3f56e5850a39ad53a885ec8ac92fcc08d3635cf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Tue, 11 Jun 2024 16:21:13 +0200 Subject: [PATCH 010/214] Remove unnecessary into() (#834) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📔 Objective Clippy was complaining in my local build that this into was unnecessary, and for some reason this wasn't caught by CI ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-vault/src/cipher/linked_id.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bitwarden-vault/src/cipher/linked_id.rs b/crates/bitwarden-vault/src/cipher/linked_id.rs index 7ee29dbc2..9e7cd91cc 100644 --- a/crates/bitwarden-vault/src/cipher/linked_id.rs +++ b/crates/bitwarden-vault/src/cipher/linked_id.rs @@ -112,7 +112,7 @@ impl TryFrom for LinkedIdType { 416 => Ok(LinkedIdType::Identity(IdentityLinkedIdType::FirstName)), 417 => Ok(LinkedIdType::Identity(IdentityLinkedIdType::LastName)), 418 => Ok(LinkedIdType::Identity(IdentityLinkedIdType::FullName)), - _ => Err(MissingFieldError("LinkedIdType").into()), + _ => Err(MissingFieldError("LinkedIdType")), } } } From 6c18348b83c5a685132e00b39595f2684bed210e Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 13 Jun 2024 13:59:38 +0200 Subject: [PATCH 011/214] Deny unused async (#838) We currently use async on several methods that don't actually require it. This PR enables the clippy rule which will warn if any async is unnecessary. It also resolves all existing usages. --- Cargo.toml | 1 + crates/bitwarden-uniffi/src/auth/mod.rs | 2 - crates/bitwarden-uniffi/src/crypto.rs | 8 +-- crates/bitwarden-uniffi/src/tool/mod.rs | 24 ++------ crates/bitwarden-uniffi/src/tool/sends.rs | 46 +++++---------- .../bitwarden-uniffi/src/vault/attachments.rs | 46 +++++---------- crates/bitwarden-uniffi/src/vault/ciphers.rs | 19 ++----- .../bitwarden-uniffi/src/vault/collections.rs | 6 +- crates/bitwarden-uniffi/src/vault/folders.rs | 23 +------- .../src/vault/password_history.rs | 6 +- crates/bitwarden/src/auth/client_auth.rs | 4 +- crates/bitwarden/src/mobile/client_crypto.rs | 9 +-- .../bitwarden/src/mobile/tool/client_sends.rs | 18 +++--- .../src/mobile/vault/client_attachments.rs | 12 ++-- .../src/mobile/vault/client_ciphers.rs | 57 ++++++------------- .../src/mobile/vault/client_collection.rs | 8 +-- .../src/mobile/vault/client_folders.rs | 6 +- .../mobile/vault/client_password_history.rs | 7 +-- crates/bitwarden/src/tool/client_generator.rs | 8 +-- .../src/tool/exporters/client_exporter.rs | 4 +- crates/bw/src/main.rs | 34 +++++------ 21 files changed, 114 insertions(+), 234 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3f826b761..be4ab72c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ bitwarden-generators = { path = "crates/bitwarden-generators", version = "=0.5.0 bitwarden-vault = { path = "crates/bitwarden-vault", version = "=0.5.0" } [workspace.lints.clippy] +unused_async = "deny" unwrap_used = "deny" # Compile all dependencies with some optimizations when building this crate on debug diff --git a/crates/bitwarden-uniffi/src/auth/mod.rs b/crates/bitwarden-uniffi/src/auth/mod.rs index 6c18bfc61..1065a01a9 100644 --- a/crates/bitwarden-uniffi/src/auth/mod.rs +++ b/crates/bitwarden-uniffi/src/auth/mod.rs @@ -26,7 +26,6 @@ impl ClientAuth { .await .auth() .password_strength(password, email, additional_inputs) - .await } /// Evaluate if the provided password satisfies the provided policy @@ -42,7 +41,6 @@ impl ClientAuth { .await .auth() .satisfies_policy(password, strength, &policy) - .await } /// Hash the user password diff --git a/crates/bitwarden-uniffi/src/crypto.rs b/crates/bitwarden-uniffi/src/crypto.rs index 0f877d52e..991ff820f 100644 --- a/crates/bitwarden-uniffi/src/crypto.rs +++ b/crates/bitwarden-uniffi/src/crypto.rs @@ -60,15 +60,14 @@ impl ClientCrypto { .write() .await .crypto() - .update_password(new_password) - .await?) + .update_password(new_password)?) } /// Generates a PIN protected user key from the provided PIN. The result can be stored and later /// used to initialize another client instance by using the PIN and the PIN key with /// `initialize_user_crypto`. pub async fn derive_pin_key(&self, pin: String) -> Result { - Ok(self.0 .0.write().await.crypto().derive_pin_key(pin).await?) + Ok(self.0 .0.write().await.crypto().derive_pin_key(pin)?) } /// Derives the pin protected user key from encrypted pin. Used when pin requires master @@ -80,8 +79,7 @@ impl ClientCrypto { .write() .await .crypto() - .derive_pin_user_key(encrypted_pin) - .await?) + .derive_pin_user_key(encrypted_pin)?) } pub async fn enroll_admin_password_reset( diff --git a/crates/bitwarden-uniffi/src/tool/mod.rs b/crates/bitwarden-uniffi/src/tool/mod.rs index 3ad4f7f93..78781b263 100644 --- a/crates/bitwarden-uniffi/src/tool/mod.rs +++ b/crates/bitwarden-uniffi/src/tool/mod.rs @@ -18,26 +18,12 @@ pub struct ClientGenerators(pub(crate) Arc); impl ClientGenerators { /// **API Draft:** Generate Password pub async fn password(&self, settings: PasswordGeneratorRequest) -> Result { - Ok(self - .0 - .0 - .read() - .await - .generator() - .password(settings) - .await?) + Ok(self.0 .0.read().await.generator().password(settings)?) } /// **API Draft:** Generate Passphrase pub async fn passphrase(&self, settings: PassphraseGeneratorRequest) -> Result { - Ok(self - .0 - .0 - .read() - .await - .generator() - .passphrase(settings) - .await?) + Ok(self.0 .0.read().await.generator().passphrase(settings)?) } /// **API Draft:** Generate Username @@ -71,8 +57,7 @@ impl ClientExporters { .read() .await .exporters() - .export_vault(folders, ciphers, format) - .await?) + .export_vault(folders, ciphers, format)?) } /// **API Draft:** Export organization vault @@ -88,7 +73,6 @@ impl ClientExporters { .read() .await .exporters() - .export_organization_vault(collections, ciphers, format) - .await?) + .export_organization_vault(collections, ciphers, format)?) } } diff --git a/crates/bitwarden-uniffi/src/tool/sends.rs b/crates/bitwarden-uniffi/src/tool/sends.rs index e6aef3e51..36f174d38 100644 --- a/crates/bitwarden-uniffi/src/tool/sends.rs +++ b/crates/bitwarden-uniffi/src/tool/sends.rs @@ -11,7 +11,7 @@ pub struct ClientSends(pub Arc); impl ClientSends { /// Encrypt send pub async fn encrypt(&self, send: SendView) -> Result { - Ok(self.0 .0.write().await.sends().encrypt(send).await?) + Ok(self.0 .0.write().await.sends().encrypt(send)?) } /// Encrypt a send file in memory @@ -22,8 +22,7 @@ impl ClientSends { .write() .await .sends() - .encrypt_buffer(send, &buffer) - .await?) + .encrypt_buffer(send, &buffer)?) } /// Encrypt a send file located in the file system @@ -33,28 +32,21 @@ impl ClientSends { decrypted_file_path: String, encrypted_file_path: String, ) -> Result<()> { - Ok(self - .0 - .0 - .write() - .await - .sends() - .encrypt_file( - send, - Path::new(&decrypted_file_path), - Path::new(&encrypted_file_path), - ) - .await?) + Ok(self.0 .0.write().await.sends().encrypt_file( + send, + Path::new(&decrypted_file_path), + Path::new(&encrypted_file_path), + )?) } /// Decrypt send pub async fn decrypt(&self, send: Send) -> Result { - Ok(self.0 .0.write().await.sends().decrypt(send).await?) + Ok(self.0 .0.write().await.sends().decrypt(send)?) } /// Decrypt send list pub async fn decrypt_list(&self, sends: Vec) -> Result> { - Ok(self.0 .0.write().await.sends().decrypt_list(sends).await?) + Ok(self.0 .0.write().await.sends().decrypt_list(sends)?) } /// Decrypt a send file in memory @@ -65,8 +57,7 @@ impl ClientSends { .write() .await .sends() - .decrypt_buffer(send, &buffer) - .await?) + .decrypt_buffer(send, &buffer)?) } /// Decrypt a send file located in the file system @@ -76,17 +67,10 @@ impl ClientSends { encrypted_file_path: String, decrypted_file_path: String, ) -> Result<()> { - Ok(self - .0 - .0 - .write() - .await - .sends() - .decrypt_file( - send, - Path::new(&encrypted_file_path), - Path::new(&decrypted_file_path), - ) - .await?) + Ok(self.0 .0.write().await.sends().decrypt_file( + send, + Path::new(&encrypted_file_path), + Path::new(&decrypted_file_path), + )?) } } diff --git a/crates/bitwarden-uniffi/src/vault/attachments.rs b/crates/bitwarden-uniffi/src/vault/attachments.rs index b844c0318..bdac7c97c 100644 --- a/crates/bitwarden-uniffi/src/vault/attachments.rs +++ b/crates/bitwarden-uniffi/src/vault/attachments.rs @@ -23,8 +23,7 @@ impl ClientAttachments { .await .vault() .attachments() - .encrypt_buffer(cipher, attachment, &buffer) - .await?) + .encrypt_buffer(cipher, attachment, &buffer)?) } /// Encrypt an attachment file located in the file system @@ -35,20 +34,12 @@ impl ClientAttachments { decrypted_file_path: String, encrypted_file_path: String, ) -> Result { - Ok(self - .0 - .0 - .write() - .await - .vault() - .attachments() - .encrypt_file( - cipher, - attachment, - Path::new(&decrypted_file_path), - Path::new(&encrypted_file_path), - ) - .await?) + Ok(self.0 .0.write().await.vault().attachments().encrypt_file( + cipher, + attachment, + Path::new(&decrypted_file_path), + Path::new(&encrypted_file_path), + )?) } /// Decrypt an attachment file in memory pub async fn decrypt_buffer( @@ -64,8 +55,7 @@ impl ClientAttachments { .await .vault() .attachments() - .decrypt_buffer(cipher, attachment, &buffer) - .await?) + .decrypt_buffer(cipher, attachment, &buffer)?) } /// Decrypt an attachment file located in the file system @@ -76,19 +66,11 @@ impl ClientAttachments { encrypted_file_path: String, decrypted_file_path: String, ) -> Result<()> { - Ok(self - .0 - .0 - .write() - .await - .vault() - .attachments() - .decrypt_file( - cipher, - attachment, - Path::new(&encrypted_file_path), - Path::new(&decrypted_file_path), - ) - .await?) + Ok(self.0 .0.write().await.vault().attachments().decrypt_file( + cipher, + attachment, + Path::new(&encrypted_file_path), + Path::new(&decrypted_file_path), + )?) } } diff --git a/crates/bitwarden-uniffi/src/vault/ciphers.rs b/crates/bitwarden-uniffi/src/vault/ciphers.rs index 329ca3c17..d637bc5fc 100644 --- a/crates/bitwarden-uniffi/src/vault/ciphers.rs +++ b/crates/bitwarden-uniffi/src/vault/ciphers.rs @@ -19,21 +19,12 @@ impl ClientCiphers { .await .vault() .ciphers() - .encrypt(cipher_view) - .await?) + .encrypt(cipher_view)?) } /// Decrypt cipher pub async fn decrypt(&self, cipher: Cipher) -> Result { - Ok(self - .0 - .0 - .write() - .await - .vault() - .ciphers() - .decrypt(cipher) - .await?) + Ok(self.0 .0.write().await.vault().ciphers().decrypt(cipher)?) } /// Decrypt cipher list @@ -45,8 +36,7 @@ impl ClientCiphers { .await .vault() .ciphers() - .decrypt_list(ciphers) - .await?) + .decrypt_list(ciphers)?) } /// Move a cipher to an organization, reencrypting the cipher key if necessary @@ -62,7 +52,6 @@ impl ClientCiphers { .await .vault() .ciphers() - .move_to_organization(cipher, organization_id) - .await?) + .move_to_organization(cipher, organization_id)?) } } diff --git a/crates/bitwarden-uniffi/src/vault/collections.rs b/crates/bitwarden-uniffi/src/vault/collections.rs index 36315aaea..f6cde84ab 100644 --- a/crates/bitwarden-uniffi/src/vault/collections.rs +++ b/crates/bitwarden-uniffi/src/vault/collections.rs @@ -18,8 +18,7 @@ impl ClientCollections { .await .vault() .collections() - .decrypt(collection) - .await?) + .decrypt(collection)?) } /// Decrypt collection list @@ -31,7 +30,6 @@ impl ClientCollections { .await .vault() .collections() - .decrypt_list(collections) - .await?) + .decrypt_list(collections)?) } } diff --git a/crates/bitwarden-uniffi/src/vault/folders.rs b/crates/bitwarden-uniffi/src/vault/folders.rs index 8847b9a45..5cceeca8b 100644 --- a/crates/bitwarden-uniffi/src/vault/folders.rs +++ b/crates/bitwarden-uniffi/src/vault/folders.rs @@ -11,28 +11,12 @@ pub struct ClientFolders(pub Arc); impl ClientFolders { /// Encrypt folder pub async fn encrypt(&self, folder: FolderView) -> Result { - Ok(self - .0 - .0 - .write() - .await - .vault() - .folders() - .encrypt(folder) - .await?) + Ok(self.0 .0.write().await.vault().folders().encrypt(folder)?) } /// Decrypt folder pub async fn decrypt(&self, folder: Folder) -> Result { - Ok(self - .0 - .0 - .write() - .await - .vault() - .folders() - .decrypt(folder) - .await?) + Ok(self.0 .0.write().await.vault().folders().decrypt(folder)?) } /// Decrypt folder list @@ -44,7 +28,6 @@ impl ClientFolders { .await .vault() .folders() - .decrypt_list(folders) - .await?) + .decrypt_list(folders)?) } } diff --git a/crates/bitwarden-uniffi/src/vault/password_history.rs b/crates/bitwarden-uniffi/src/vault/password_history.rs index 62c468d4b..863eddbac 100644 --- a/crates/bitwarden-uniffi/src/vault/password_history.rs +++ b/crates/bitwarden-uniffi/src/vault/password_history.rs @@ -18,8 +18,7 @@ impl ClientPasswordHistory { .await .vault() .password_history() - .encrypt(password_history) - .await?) + .encrypt(password_history)?) } /// Decrypt password history @@ -34,7 +33,6 @@ impl ClientPasswordHistory { .await .vault() .password_history() - .decrypt_list(list) - .await?) + .decrypt_list(list)?) } } diff --git a/crates/bitwarden/src/auth/client_auth.rs b/crates/bitwarden/src/auth/client_auth.rs index 0339c5351..14261efee 100644 --- a/crates/bitwarden/src/auth/client_auth.rs +++ b/crates/bitwarden/src/auth/client_auth.rs @@ -46,7 +46,7 @@ impl<'a> ClientAuth<'a> { #[cfg(feature = "internal")] impl<'a> ClientAuth<'a> { - pub async fn password_strength( + pub fn password_strength( &self, password: String, email: String, @@ -55,7 +55,7 @@ impl<'a> ClientAuth<'a> { password_strength(password, email, additional_inputs) } - pub async fn satisfies_policy( + pub fn satisfies_policy( &self, password: String, strength: u8, diff --git a/crates/bitwarden/src/mobile/client_crypto.rs b/crates/bitwarden/src/mobile/client_crypto.rs index 6ef65975d..30e88332a 100644 --- a/crates/bitwarden/src/mobile/client_crypto.rs +++ b/crates/bitwarden/src/mobile/client_crypto.rs @@ -33,20 +33,17 @@ impl<'a> ClientCrypto<'a> { } #[cfg(feature = "internal")] - pub async fn update_password( - &mut self, - new_password: String, - ) -> Result { + pub fn update_password(&mut self, new_password: String) -> Result { update_password(self.client, new_password) } #[cfg(feature = "internal")] - pub async fn derive_pin_key(&mut self, pin: String) -> Result { + pub fn derive_pin_key(&mut self, pin: String) -> Result { derive_pin_key(self.client, pin) } #[cfg(feature = "internal")] - pub async fn derive_pin_user_key(&mut self, encrypted_pin: EncString) -> Result { + pub fn derive_pin_user_key(&mut self, encrypted_pin: EncString) -> Result { derive_pin_user_key(self.client, encrypted_pin) } diff --git a/crates/bitwarden/src/mobile/tool/client_sends.rs b/crates/bitwarden/src/mobile/tool/client_sends.rs index 83652c8c4..9feeec030 100644 --- a/crates/bitwarden/src/mobile/tool/client_sends.rs +++ b/crates/bitwarden/src/mobile/tool/client_sends.rs @@ -14,7 +14,7 @@ pub struct ClientSends<'a> { } impl<'a> ClientSends<'a> { - pub async fn decrypt(&self, send: Send) -> Result { + pub fn decrypt(&self, send: Send) -> Result { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(VaultLocked)?; @@ -23,7 +23,7 @@ impl<'a> ClientSends<'a> { Ok(send_view) } - pub async fn decrypt_list(&self, sends: Vec) -> Result> { + pub fn decrypt_list(&self, sends: Vec) -> Result> { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(VaultLocked)?; @@ -32,19 +32,19 @@ impl<'a> ClientSends<'a> { Ok(send_views) } - pub async fn decrypt_file( + pub fn decrypt_file( &self, send: Send, encrypted_file_path: &Path, decrypted_file_path: &Path, ) -> Result<()> { let data = std::fs::read(encrypted_file_path)?; - let decrypted = self.decrypt_buffer(send, &data).await?; + let decrypted = self.decrypt_buffer(send, &data)?; std::fs::write(decrypted_file_path, decrypted)?; Ok(()) } - pub async fn decrypt_buffer(&self, send: Send, encrypted_buffer: &[u8]) -> Result> { + pub fn decrypt_buffer(&self, send: Send, encrypted_buffer: &[u8]) -> Result> { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(VaultLocked)?; let key = Send::get_key(&send.key, key)?; @@ -53,7 +53,7 @@ impl<'a> ClientSends<'a> { Ok(buf.decrypt_with_key(&key)?) } - pub async fn encrypt(&self, send_view: SendView) -> Result { + pub fn encrypt(&self, send_view: SendView) -> Result { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(VaultLocked)?; @@ -62,19 +62,19 @@ impl<'a> ClientSends<'a> { Ok(send) } - pub async fn encrypt_file( + pub fn encrypt_file( &self, send: Send, decrypted_file_path: &Path, encrypted_file_path: &Path, ) -> Result<()> { let data = std::fs::read(decrypted_file_path)?; - let encrypted = self.encrypt_buffer(send, &data).await?; + let encrypted = self.encrypt_buffer(send, &data)?; std::fs::write(encrypted_file_path, encrypted)?; Ok(()) } - pub async fn encrypt_buffer(&self, send: Send, buffer: &[u8]) -> Result> { + pub fn encrypt_buffer(&self, send: Send, buffer: &[u8]) -> Result> { let key = self .client .get_encryption_settings()? diff --git a/crates/bitwarden/src/mobile/vault/client_attachments.rs b/crates/bitwarden/src/mobile/vault/client_attachments.rs index ce7570fab..2f9edb82b 100644 --- a/crates/bitwarden/src/mobile/vault/client_attachments.rs +++ b/crates/bitwarden/src/mobile/vault/client_attachments.rs @@ -17,7 +17,7 @@ pub struct ClientAttachments<'a> { } impl<'a> ClientAttachments<'a> { - pub async fn encrypt_buffer( + pub fn encrypt_buffer( &self, cipher: Cipher, attachment: AttachmentView, @@ -33,7 +33,7 @@ impl<'a> ClientAttachments<'a> { } .encrypt_with_key(key)?) } - pub async fn encrypt_file( + pub fn encrypt_file( &self, cipher: Cipher, attachment: AttachmentView, @@ -44,12 +44,12 @@ impl<'a> ClientAttachments<'a> { let AttachmentEncryptResult { attachment, contents, - } = self.encrypt_buffer(cipher, attachment, &data).await?; + } = self.encrypt_buffer(cipher, attachment, &data)?; std::fs::write(encrypted_file_path, contents)?; Ok(attachment) } - pub async fn decrypt_buffer( + pub fn decrypt_buffer( &self, cipher: Cipher, attachment: Attachment, @@ -66,7 +66,7 @@ impl<'a> ClientAttachments<'a> { .decrypt_with_key(key) .map_err(Error::Crypto) } - pub async fn decrypt_file( + pub fn decrypt_file( &self, cipher: Cipher, attachment: Attachment, @@ -74,7 +74,7 @@ impl<'a> ClientAttachments<'a> { decrypted_file_path: &Path, ) -> Result<()> { let data = std::fs::read(encrypted_file_path)?; - let decrypted = self.decrypt_buffer(cipher, attachment, &data).await?; + let decrypted = self.decrypt_buffer(cipher, attachment, &data)?; std::fs::write(decrypted_file_path, decrypted)?; Ok(()) } diff --git a/crates/bitwarden/src/mobile/vault/client_ciphers.rs b/crates/bitwarden/src/mobile/vault/client_ciphers.rs index 63d11766d..e459f4e7c 100644 --- a/crates/bitwarden/src/mobile/vault/client_ciphers.rs +++ b/crates/bitwarden/src/mobile/vault/client_ciphers.rs @@ -10,7 +10,7 @@ pub struct ClientCiphers<'a> { } impl<'a> ClientCiphers<'a> { - pub async fn encrypt(&self, mut cipher_view: CipherView) -> Result { + pub fn encrypt(&self, mut cipher_view: CipherView) -> Result { let enc = self.client.get_encryption_settings()?; // TODO: Once this flag is removed, the key generation logic should @@ -26,7 +26,7 @@ impl<'a> ClientCiphers<'a> { Ok(cipher) } - pub async fn decrypt(&self, cipher: Cipher) -> Result { + pub fn decrypt(&self, cipher: Cipher) -> Result { let enc = self.client.get_encryption_settings()?; let key = cipher .locate_key(enc, &None) @@ -37,7 +37,7 @@ impl<'a> ClientCiphers<'a> { Ok(cipher_view) } - pub async fn decrypt_list(&self, ciphers: Vec) -> Result> { + pub fn decrypt_list(&self, ciphers: Vec) -> Result> { let enc = self.client.get_encryption_settings()?; let cipher_views: Result> = ciphers @@ -51,7 +51,7 @@ impl<'a> ClientCiphers<'a> { cipher_views } - pub async fn move_to_organization( + pub fn move_to_organization( &self, mut cipher_view: CipherView, organization_id: Uuid, @@ -114,7 +114,7 @@ mod tests { deleted_date: None, revision_date: "2024-05-31T09:35:55.12Z".parse().unwrap(), }]) - .await + .unwrap(); assert_eq!(dec[0].name, "Test item"); @@ -186,22 +186,13 @@ mod tests { let mut cipher = test_cipher(); cipher.attachments = Some(vec![test_attachment_legacy()]); - let view = client - .vault() - .ciphers() - .decrypt(cipher.clone()) - .await - .unwrap(); + let view = client.vault().ciphers().decrypt(cipher.clone()).unwrap(); // Move cipher to organization - let res = client - .vault() - .ciphers() - .move_to_organization( - view, - "1bc9ac1e-f5aa-45f2-94bf-b181009709b8".parse().unwrap(), - ) - .await; + let res = client.vault().ciphers().move_to_organization( + view, + "1bc9ac1e-f5aa-45f2-94bf-b181009709b8".parse().unwrap(), + ); assert!(res.is_err()); } @@ -214,20 +205,15 @@ mod tests { let attachment = test_attachment_legacy(); cipher.attachments = Some(vec![attachment.clone()]); - let view = client - .vault() - .ciphers() - .decrypt(cipher.clone()) - .await - .unwrap(); + let view = client.vault().ciphers().decrypt(cipher.clone()).unwrap(); assert!(cipher.key.is_none()); // Assert the cipher has a key, and the attachment is still readable - let new_cipher = client.vault().ciphers().encrypt(view).await.unwrap(); + let new_cipher = client.vault().ciphers().encrypt(view).unwrap(); assert!(new_cipher.key.is_some()); - let view = client.vault().ciphers().decrypt(new_cipher).await.unwrap(); + let view = client.vault().ciphers().decrypt(new_cipher).unwrap(); let attachments = view.clone().attachments.unwrap(); let attachment_view = attachments.first().unwrap().clone(); assert!(attachment_view.key.is_none()); @@ -245,7 +231,6 @@ mod tests { .vault() .attachments() .decrypt_buffer(cipher, attachment, buf.as_slice()) - .await .unwrap(); assert_eq!(content, b"Hello"); @@ -259,20 +244,15 @@ mod tests { let attachment = test_attachment_v2(); cipher.attachments = Some(vec![attachment.clone()]); - let view = client - .vault() - .ciphers() - .decrypt(cipher.clone()) - .await - .unwrap(); + let view = client.vault().ciphers().decrypt(cipher.clone()).unwrap(); assert!(cipher.key.is_none()); // Assert the cipher has a key, and the attachment is still readable - let new_cipher = client.vault().ciphers().encrypt(view).await.unwrap(); + let new_cipher = client.vault().ciphers().encrypt(view).unwrap(); assert!(new_cipher.key.is_some()); - let view = client.vault().ciphers().decrypt(new_cipher).await.unwrap(); + let view = client.vault().ciphers().decrypt(new_cipher).unwrap(); let attachments = view.clone().attachments.unwrap(); let attachment_view = attachments.first().unwrap().clone(); assert!(attachment_view.key.is_some()); @@ -296,7 +276,6 @@ mod tests { .vault() .attachments() .decrypt_buffer(cipher, attachment, buf.as_slice()) - .await .unwrap(); assert_eq!(content, b"Hello"); @@ -309,9 +288,8 @@ mod tests { view, "1bc9ac1e-f5aa-45f2-94bf-b181009709b8".parse().unwrap(), ) - .await .unwrap(); - let new_cipher = client.vault().ciphers().encrypt(new_view).await.unwrap(); + let new_cipher = client.vault().ciphers().encrypt(new_view).unwrap(); let attachment = new_cipher .clone() @@ -331,7 +309,6 @@ mod tests { .vault() .attachments() .decrypt_buffer(new_cipher, attachment, buf.as_slice()) - .await .unwrap(); assert_eq!(content, b"Hello"); diff --git a/crates/bitwarden/src/mobile/vault/client_collection.rs b/crates/bitwarden/src/mobile/vault/client_collection.rs index 26b660461..0727130df 100644 --- a/crates/bitwarden/src/mobile/vault/client_collection.rs +++ b/crates/bitwarden/src/mobile/vault/client_collection.rs @@ -8,7 +8,7 @@ pub struct ClientCollections<'a> { } impl<'a> ClientCollections<'a> { - pub async fn decrypt(&self, collection: Collection) -> Result { + pub fn decrypt(&self, collection: Collection) -> Result { let enc = self.client.get_encryption_settings()?; let key = collection .locate_key(enc, &None) @@ -19,7 +19,7 @@ impl<'a> ClientCollections<'a> { Ok(view) } - pub async fn decrypt_list(&self, collections: Vec) -> Result> { + pub fn decrypt_list(&self, collections: Vec) -> Result> { let enc = self.client.get_encryption_settings()?; let views: Result> = collections @@ -59,7 +59,7 @@ mod tests { external_id: None, hide_passwords: false, read_only: false, - }]).await.unwrap(); + }]).unwrap(); assert_eq!(dec[0].name, "Default collection"); } @@ -75,7 +75,7 @@ mod tests { external_id: None, hide_passwords: false, read_only: false, - }).await.unwrap(); + }).unwrap(); assert_eq!(dec.name, "Default collection"); } diff --git a/crates/bitwarden/src/mobile/vault/client_folders.rs b/crates/bitwarden/src/mobile/vault/client_folders.rs index cdbcdcd17..668125da2 100644 --- a/crates/bitwarden/src/mobile/vault/client_folders.rs +++ b/crates/bitwarden/src/mobile/vault/client_folders.rs @@ -8,7 +8,7 @@ pub struct ClientFolders<'a> { } impl<'a> ClientFolders<'a> { - pub async fn encrypt(&self, folder_view: FolderView) -> Result { + pub fn encrypt(&self, folder_view: FolderView) -> Result { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; @@ -17,7 +17,7 @@ impl<'a> ClientFolders<'a> { Ok(folder) } - pub async fn decrypt(&self, folder: Folder) -> Result { + pub fn decrypt(&self, folder: Folder) -> Result { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; @@ -26,7 +26,7 @@ impl<'a> ClientFolders<'a> { Ok(folder_view) } - pub async fn decrypt_list(&self, folders: Vec) -> Result> { + pub fn decrypt_list(&self, folders: Vec) -> Result> { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; diff --git a/crates/bitwarden/src/mobile/vault/client_password_history.rs b/crates/bitwarden/src/mobile/vault/client_password_history.rs index b8fe0e0c5..db0f5fa53 100644 --- a/crates/bitwarden/src/mobile/vault/client_password_history.rs +++ b/crates/bitwarden/src/mobile/vault/client_password_history.rs @@ -8,7 +8,7 @@ pub struct ClientPasswordHistory<'a> { } impl<'a> ClientPasswordHistory<'a> { - pub async fn encrypt(&self, history_view: PasswordHistoryView) -> Result { + pub fn encrypt(&self, history_view: PasswordHistoryView) -> Result { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; @@ -17,10 +17,7 @@ impl<'a> ClientPasswordHistory<'a> { Ok(history) } - pub async fn decrypt_list( - &self, - history: Vec, - ) -> Result> { + pub fn decrypt_list(&self, history: Vec) -> Result> { let enc = self.client.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; diff --git a/crates/bitwarden/src/tool/client_generator.rs b/crates/bitwarden/src/tool/client_generator.rs index 16c786f9b..fe5319fc7 100644 --- a/crates/bitwarden/src/tool/client_generator.rs +++ b/crates/bitwarden/src/tool/client_generator.rs @@ -27,12 +27,12 @@ impl<'a> ClientGenerator<'a> { /// length: 20, /// ..Default::default() /// }; - /// let password = Client::new(None).generator().password(input).await.unwrap(); + /// let password = Client::new(None).generator().password(input).unwrap(); /// println!("{}", password); /// Ok(()) /// } /// ``` - pub async fn password(&self, input: PasswordGeneratorRequest) -> Result { + pub fn password(&self, input: PasswordGeneratorRequest) -> Result { Ok(password(input)?) } @@ -52,12 +52,12 @@ impl<'a> ClientGenerator<'a> { /// num_words: 4, /// ..Default::default() /// }; - /// let passphrase = Client::new(None).generator().passphrase(input).await.unwrap(); + /// let passphrase = Client::new(None).generator().passphrase(input).unwrap(); /// println!("{}", passphrase); /// Ok(()) /// } /// ``` - pub async fn passphrase(&self, input: PassphraseGeneratorRequest) -> Result { + pub fn passphrase(&self, input: PassphraseGeneratorRequest) -> Result { Ok(passphrase(input)?) } diff --git a/crates/bitwarden/src/tool/exporters/client_exporter.rs b/crates/bitwarden/src/tool/exporters/client_exporter.rs index 788ba272e..5257538cd 100644 --- a/crates/bitwarden/src/tool/exporters/client_exporter.rs +++ b/crates/bitwarden/src/tool/exporters/client_exporter.rs @@ -12,7 +12,7 @@ pub struct ClientExporters<'a> { impl<'a> ClientExporters<'a> { /// **Draft:** Export the vault as a CSV, JSON, or encrypted JSON file. - pub async fn export_vault( + pub fn export_vault( &self, folders: Vec, ciphers: Vec, @@ -21,7 +21,7 @@ impl<'a> ClientExporters<'a> { export_vault(self.client, folders, ciphers, format) } - pub async fn export_organization_vault( + pub fn export_organization_vault( &self, collections: Vec, ciphers: Vec, diff --git a/crates/bw/src/main.rs b/crates/bw/src/main.rs index 6674bda1e..6a1918126 100644 --- a/crates/bw/src/main.rs +++ b/crates/bw/src/main.rs @@ -217,30 +217,24 @@ async fn process_commands() -> Result<()> { Commands::Sync {} => todo!(), Commands::Generate { command } => match command { GeneratorCommands::Password(args) => { - let password = client - .generator() - .password(PasswordGeneratorRequest { - lowercase: args.lowercase, - uppercase: args.uppercase, - numbers: args.numbers, - special: args.special, - length: args.length, - ..Default::default() - }) - .await?; + let password = client.generator().password(PasswordGeneratorRequest { + lowercase: args.lowercase, + uppercase: args.uppercase, + numbers: args.numbers, + special: args.special, + length: args.length, + ..Default::default() + })?; println!("{}", password); } GeneratorCommands::Passphrase(args) => { - let passphrase = client - .generator() - .passphrase(PassphraseGeneratorRequest { - num_words: args.words, - word_separator: args.separator.to_string(), - capitalize: args.capitalize, - include_number: args.include_number, - }) - .await?; + let passphrase = client.generator().passphrase(PassphraseGeneratorRequest { + num_words: args.words, + word_separator: args.separator.to_string(), + capitalize: args.capitalize, + include_number: args.include_number, + })?; println!("{}", passphrase); } From e5a8dba1200af5f901cd686877ae47f927d47020 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 13 Jun 2024 15:26:50 +0200 Subject: [PATCH 012/214] Migrate fido logic to use explicit errors (#835) This PR establishes explicit error types for the fido logic. In order to extract the fido logic into a separate `bitwarden-fido` crate, we need to remove the dependencies on the `bitwarden` logic. Most of this is either the `Client` struct which is currently difficult, or the `Error` and `Result` types which this PR focuses on. --- crates/bitwarden-uniffi/src/platform/fido2.rs | 36 ++-- crates/bitwarden/src/client/client.rs | 4 +- crates/bitwarden/src/error.rs | 27 +-- .../src/platform/fido2/authenticator.rs | 161 +++++++++++++++--- crates/bitwarden/src/platform/fido2/client.rs | 35 +++- crates/bitwarden/src/platform/fido2/crypto.rs | 28 +-- crates/bitwarden/src/platform/fido2/mod.rs | 98 +++++++---- crates/bitwarden/src/platform/fido2/traits.rs | 2 - crates/bitwarden/src/platform/fido2/types.rs | 19 ++- 9 files changed, 310 insertions(+), 100 deletions(-) diff --git a/crates/bitwarden-uniffi/src/platform/fido2.rs b/crates/bitwarden-uniffi/src/platform/fido2.rs index 8a1c10e64..3fc67f1d4 100644 --- a/crates/bitwarden-uniffi/src/platform/fido2.rs +++ b/crates/bitwarden-uniffi/src/platform/fido2.rs @@ -1,6 +1,7 @@ use std::sync::Arc; use bitwarden::{ + error::Error, platform::fido2::{ CheckUserOptions, ClientData, Fido2CallbackError as BitFido2CallbackError, GetAssertionRequest, GetAssertionResult, MakeCredentialRequest, MakeCredentialResult, @@ -62,9 +63,12 @@ impl ClientFido2Authenticator { let mut fido2 = platform.fido2(); let ui = UniffiTraitBridge(self.1.as_ref()); let cs = UniffiTraitBridge(self.2.as_ref()); - let mut auth = fido2.create_authenticator(&ui, &cs)?; + let mut auth = fido2.create_authenticator(&ui, &cs); - let result = auth.make_credential(request).await?; + let result = auth + .make_credential(request) + .await + .map_err(Error::MakeCredential)?; Ok(result) } @@ -75,9 +79,12 @@ impl ClientFido2Authenticator { let mut fido2 = platform.fido2(); let ui = UniffiTraitBridge(self.1.as_ref()); let cs = UniffiTraitBridge(self.2.as_ref()); - let mut auth = fido2.create_authenticator(&ui, &cs)?; + let mut auth = fido2.create_authenticator(&ui, &cs); - let result = auth.get_assertion(request).await?; + let result = auth + .get_assertion(request) + .await + .map_err(Error::GetAssertion)?; Ok(result) } @@ -91,9 +98,12 @@ impl ClientFido2Authenticator { let mut fido2 = platform.fido2(); let ui = UniffiTraitBridge(self.1.as_ref()); let cs = UniffiTraitBridge(self.2.as_ref()); - let mut auth = fido2.create_authenticator(&ui, &cs)?; + let mut auth = fido2.create_authenticator(&ui, &cs); - let result = auth.silently_discover_credentials(rp_id).await?; + let result = auth + .silently_discover_credentials(rp_id) + .await + .map_err(Error::SilentlyDiscoverCredentials)?; Ok(result) } } @@ -115,9 +125,12 @@ impl ClientFido2Client { let mut fido2 = platform.fido2(); let ui = UniffiTraitBridge(self.0 .1.as_ref()); let cs = UniffiTraitBridge(self.0 .2.as_ref()); - let mut client = fido2.create_client(&ui, &cs)?; + let mut client = fido2.create_client(&ui, &cs); - let result = client.register(origin, request, client_data).await?; + let result = client + .register(origin, request, client_data) + .await + .map_err(Error::Fido2Client)?; Ok(result) } @@ -133,9 +146,12 @@ impl ClientFido2Client { let mut fido2 = platform.fido2(); let ui = UniffiTraitBridge(self.0 .1.as_ref()); let cs = UniffiTraitBridge(self.0 .2.as_ref()); - let mut client = fido2.create_client(&ui, &cs)?; + let mut client = fido2.create_client(&ui, &cs); - let result = client.authenticate(origin, request, client_data).await?; + let result = client + .authenticate(origin, request, client_data) + .await + .map_err(Error::Fido2Client)?; Ok(result) } } diff --git a/crates/bitwarden/src/client/client.rs b/crates/bitwarden/src/client/client.rs index 34678983d..0d2f30864 100644 --- a/crates/bitwarden/src/client/client.rs +++ b/crates/bitwarden/src/client/client.rs @@ -188,8 +188,8 @@ impl Client { } } - pub(crate) fn get_encryption_settings(&self) -> Result<&EncryptionSettings> { - self.encryption_settings.as_ref().ok_or(VaultLocked.into()) + pub(crate) fn get_encryption_settings(&self) -> Result<&EncryptionSettings, VaultLocked> { + self.encryption_settings.as_ref().ok_or(VaultLocked) } pub(crate) fn set_login_method(&mut self, login_method: LoginMethod) { diff --git a/crates/bitwarden/src/error.rs b/crates/bitwarden/src/error.rs index 9bf7814cf..a7f7e3c3d 100644 --- a/crates/bitwarden/src/error.rs +++ b/crates/bitwarden/src/error.rs @@ -8,8 +8,6 @@ use bitwarden_api_identity::apis::Error as IdentityError; use bitwarden_exporters::ExportError; #[cfg(feature = "internal")] use bitwarden_generators::{PassphraseError, PasswordError, UsernameError}; -#[cfg(feature = "uniffi")] -use passkey::client::WebauthnError; use reqwest::StatusCode; use thiserror::Error; @@ -81,15 +79,25 @@ pub enum Error { #[error(transparent)] ExportError(#[from] ExportError), - #[cfg(feature = "uniffi")] - #[error("Webauthn error: {0:?}")] - WebauthnError(WebauthnError), + // Fido + #[cfg(all(feature = "uniffi", feature = "internal"))] + #[error(transparent)] + MakeCredential(#[from] crate::platform::fido2::MakeCredentialError), + #[cfg(all(feature = "uniffi", feature = "internal"))] + #[error(transparent)] + GetAssertion(#[from] crate::platform::fido2::GetAssertionError), + #[cfg(all(feature = "uniffi", feature = "internal"))] + #[error(transparent)] + SilentlyDiscoverCredentials(#[from] crate::platform::fido2::SilentlyDiscoverCredentialsError), + #[cfg(all(feature = "uniffi", feature = "internal"))] + #[error(transparent)] + Fido2Client(#[from] crate::platform::fido2::Fido2ClientError), #[cfg(feature = "uniffi")] #[error("Uniffi callback error: {0}")] UniffiCallbackError(#[from] uniffi::UnexpectedUniFFICallbackError), - #[cfg(feature = "uniffi")] + #[cfg(all(feature = "uniffi", feature = "internal"))] #[error("Fido2 Callback error: {0:?}")] Fido2CallbackError(#[from] crate::platform::fido2::Fido2CallbackError), @@ -97,13 +105,6 @@ pub enum Error { Internal(Cow<'static, str>), } -#[cfg(feature = "uniffi")] -impl From for Error { - fn from(e: WebauthnError) -> Self { - Self::WebauthnError(e) - } -} - impl From for Error { fn from(s: String) -> Self { Self::Internal(s.into()) diff --git a/crates/bitwarden/src/platform/fido2/authenticator.rs b/crates/bitwarden/src/platform/fido2/authenticator.rs index 797ba87a1..825e4f6d8 100644 --- a/crates/bitwarden/src/platform/fido2/authenticator.rs +++ b/crates/bitwarden/src/platform/fido2/authenticator.rs @@ -1,8 +1,8 @@ use std::sync::Mutex; use bitwarden_core::VaultLocked; -use bitwarden_crypto::KeyEncryptable; -use bitwarden_vault::{CipherView, Fido2CredentialView}; +use bitwarden_crypto::{CryptoError, KeyEncryptable}; +use bitwarden_vault::{CipherError, CipherView, Fido2CredentialView}; use log::error; use passkey::{ authenticator::{Authenticator, DiscoverabilitySupport, StoreInfo, UIHint, UserCheck}, @@ -11,17 +11,71 @@ use passkey::{ Passkey, }, }; +use thiserror::Error; use super::{ try_from_credential_new_view, types::*, CheckUserOptions, CheckUserResult, CipherViewContainer, - Fido2CredentialStore, Fido2UserInterface, SelectedCredential, AAGUID, + Fido2CredentialStore, Fido2UserInterface, SelectedCredential, UnknownEnum, AAGUID, }; use crate::{ - error::Result, - platform::fido2::{fill_with_credential, string_to_guid_bytes, try_from_credential_full}, + platform::fido2::{ + fill_with_credential, string_to_guid_bytes, try_from_credential_full, Fido2CallbackError, + FillCredentialError, InvalidGuid, + }, Client, }; +#[derive(Debug, Error)] +pub enum GetSelectedCredentialError { + #[error("No selected credential available")] + NoSelectedCredential, + #[error("No fido2 credentials found")] + NoCredentialFound, + + #[error(transparent)] + VaultLocked(#[from] VaultLocked), + #[error(transparent)] + CipherError(#[from] CipherError), +} + +#[derive(Debug, Error)] +pub enum MakeCredentialError { + #[error(transparent)] + PublicKeyCredentialParametersError(#[from] PublicKeyCredentialParametersError), + #[error(transparent)] + UnknownEnum(#[from] UnknownEnum), + #[error(transparent)] + Serde(#[from] serde_json::Error), + #[error("Missing attested_credential_data")] + MissingAttestedCredentialData, + #[error("make_credential error: {0}")] + Other(String), +} + +#[derive(Debug, Error)] +pub enum GetAssertionError { + #[error(transparent)] + UnknownEnum(#[from] UnknownEnum), + #[error(transparent)] + Serde(#[from] serde_json::Error), + #[error(transparent)] + GetSelectedCredentialError(#[from] GetSelectedCredentialError), + #[error("Missing attested_credential_data")] + MissingAttestedCredentialData, + #[error("missing user")] + MissingUser, + #[error("get_assertion error: {0}")] + Other(String), +} + +#[derive(Debug, Error)] +pub enum SilentlyDiscoverCredentialsError { + #[error(transparent)] + VaultLocked(#[from] VaultLocked), + #[error(transparent)] + Fido2CallbackError(#[from] Fido2CallbackError), +} + pub struct Fido2Authenticator<'a> { pub(crate) client: &'a mut Client, pub(crate) user_interface: &'a dyn Fido2UserInterface, @@ -35,7 +89,7 @@ impl<'a> Fido2Authenticator<'a> { pub async fn make_credential( &mut self, request: MakeCredentialRequest, - ) -> Result { + ) -> Result { // Insert the received UV to be able to return it later in check_user self.requested_uv .get_mut() @@ -81,14 +135,14 @@ impl<'a> Fido2Authenticator<'a> { let response = match response { Ok(x) => x, - Err(e) => return Err(format!("make_credential error: {e:?}").into()), + Err(e) => return Err(MakeCredentialError::Other(format!("{e:?}"))), }; let authenticator_data = response.auth_data.to_vec(); let attested_credential_data = response .auth_data .attested_credential_data - .ok_or("Missing attested_credential_data")?; + .ok_or(MakeCredentialError::MissingAttestedCredentialData)?; let credential_id = attested_credential_data.credential_id().to_vec(); Ok(MakeCredentialResult { @@ -101,7 +155,7 @@ impl<'a> Fido2Authenticator<'a> { pub async fn get_assertion( &mut self, request: GetAssertionRequest, - ) -> Result { + ) -> Result { // Insert the received UV to be able to return it later in check_user self.requested_uv .get_mut() @@ -138,14 +192,14 @@ impl<'a> Fido2Authenticator<'a> { let response = match response { Ok(x) => x, - Err(e) => return Err(format!("get_assertion error: {e:?}").into()), + Err(e) => return Err(GetAssertionError::Other(format!("{e:?}"))), }; let authenticator_data = response.auth_data.to_vec(); let credential_id = response .auth_data .attested_credential_data - .ok_or("Missing attested_credential_data")? + .ok_or(GetAssertionError::MissingAttestedCredentialData)? .credential_id() .to_vec(); @@ -153,7 +207,11 @@ impl<'a> Fido2Authenticator<'a> { credential_id, authenticator_data, signature: response.signature.into(), - user_handle: response.user.ok_or("Missing user")?.id.into(), + user_handle: response + .user + .ok_or(GetAssertionError::MissingUser)? + .id + .into(), selected_credential: self.get_selected_credential()?, }) } @@ -161,7 +219,7 @@ impl<'a> Fido2Authenticator<'a> { pub async fn silently_discover_credentials( &mut self, rp_id: String, - ) -> Result> { + ) -> Result, SilentlyDiscoverCredentialsError> { let enc = self.client.get_encryption_settings()?; let result = self.credential_store.find_credentials(None, rp_id).await?; @@ -198,7 +256,9 @@ impl<'a> Fido2Authenticator<'a> { } } - pub(super) fn get_selected_credential(&self) -> Result { + pub(super) fn get_selected_credential( + &self, + ) -> Result { let enc = self.client.get_encryption_settings()?; let cipher = self @@ -206,11 +266,14 @@ impl<'a> Fido2Authenticator<'a> { .lock() .expect("Mutex is not poisoned") .clone() - .ok_or("No selected credential available")?; + .ok_or(GetSelectedCredentialError::NoSelectedCredential)?; let creds = cipher.decrypt_fido2_credentials(enc)?; - let credential = creds.first().ok_or("No Fido2 credentials found")?.clone(); + let credential = creds + .first() + .ok_or(GetSelectedCredentialError::NoCredentialFound)? + .clone(); Ok(SelectedCredential { cipher, credential }) } @@ -232,12 +295,24 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { ids: Option<&[passkey::types::webauthn::PublicKeyCredentialDescriptor]>, rp_id: &str, ) -> Result, StatusCode> { + #[derive(Debug, Error)] + enum InnerError { + #[error(transparent)] + VaultLocked(#[from] VaultLocked), + #[error(transparent)] + CipherError(#[from] CipherError), + #[error(transparent)] + CryptoError(#[from] CryptoError), + #[error(transparent)] + Fido2CallbackError(#[from] Fido2CallbackError), + } + // This is just a wrapper around the actual implementation to allow for ? error handling async fn inner( this: &CredentialStoreImpl<'_>, ids: Option<&[passkey::types::webauthn::PublicKeyCredentialDescriptor]>, rp_id: &str, - ) -> Result> { + ) -> Result, InnerError> { let ids: Option>> = ids.map(|ids| ids.iter().map(|id| id.id.clone().into()).collect()); @@ -262,10 +337,10 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { // When using the credential for authentication we have to ask the user to pick one. if this.create_credential { - creds + Ok(creds .into_iter() .map(|c| CipherViewContainer::new(c, enc)) - .collect() + .collect::>()?) } else { let picked = this .authenticator @@ -299,13 +374,30 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { rp: passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, _options: passkey::types::ctap2::get_assertion::Options, ) -> Result<(), StatusCode> { + #[derive(Debug, Error)] + enum InnerError { + #[error(transparent)] + VaultLocked(#[from] VaultLocked), + #[error(transparent)] + FillCredentialError(#[from] FillCredentialError), + #[error(transparent)] + CipherError(#[from] CipherError), + #[error(transparent)] + CryptoError(#[from] CryptoError), + #[error(transparent)] + Fido2CallbackError(#[from] Fido2CallbackError), + + #[error("No selected credential available")] + NoSelectedCredential, + } + // This is just a wrapper around the actual implementation to allow for ? error handling async fn inner( this: &mut CredentialStoreImpl<'_>, cred: Passkey, user: passkey::types::ctap2::make_credential::PublicKeyCredentialUserEntity, rp: passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, - ) -> Result<()> { + ) -> Result<(), InnerError> { let enc = this.authenticator.client.get_encryption_settings()?; let cred = try_from_credential_full(cred, user, rp)?; @@ -317,7 +409,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { .lock() .expect("Mutex is not poisoned") .clone() - .ok_or("No selected cipher available")?; + .ok_or(InnerError::NoSelectedCredential)?; selected.set_new_fido2_credentials(enc, vec![cred])?; @@ -349,8 +441,31 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { } async fn update_credential(&mut self, cred: Passkey) -> Result<(), StatusCode> { + #[derive(Debug, Error)] + enum InnerError { + #[error(transparent)] + VaultLocked(#[from] VaultLocked), + #[error(transparent)] + InvalidGuid(#[from] InvalidGuid), + #[error("Credential ID does not match selected credential")] + CredentialIdMismatch, + #[error(transparent)] + FillCredentialError(#[from] FillCredentialError), + #[error(transparent)] + CipherError(#[from] CipherError), + #[error(transparent)] + CryptoError(#[from] CryptoError), + #[error(transparent)] + Fido2CallbackError(#[from] Fido2CallbackError), + #[error(transparent)] + GetSelectedCredentialError(#[from] GetSelectedCredentialError), + } + // This is just a wrapper around the actual implementation to allow for ? error handling - async fn inner(this: &mut CredentialStoreImpl<'_>, cred: Passkey) -> Result<()> { + async fn inner( + this: &mut CredentialStoreImpl<'_>, + cred: Passkey, + ) -> Result<(), InnerError> { let enc = this.authenticator.client.get_encryption_settings()?; // Get the previously selected cipher and update the credential @@ -360,7 +475,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { let new_id: &Vec = &cred.credential_id; let selected_id = string_to_guid_bytes(&selected.credential.credential_id)?; if new_id != &selected_id { - return Err("Credential ID does not match selected credential".into()); + return Err(InnerError::CredentialIdMismatch); } let cred = fill_with_credential(&selected.credential, cred)?; diff --git a/crates/bitwarden/src/platform/fido2/client.rs b/crates/bitwarden/src/platform/fido2/client.rs index f2f5703cf..0000bc69c 100644 --- a/crates/bitwarden/src/platform/fido2/client.rs +++ b/crates/bitwarden/src/platform/fido2/client.rs @@ -1,6 +1,9 @@ +use passkey::client::WebauthnError; use reqwest::Url; +use thiserror::Error; use super::{ + authenticator::GetSelectedCredentialError, get_string_name_from_enum, types::{ AuthenticatorAssertionResponse, AuthenticatorAttestationResponse, ClientData, @@ -9,7 +12,29 @@ use super::{ Fido2Authenticator, PublicKeyCredentialAuthenticatorAssertionResponse, PublicKeyCredentialAuthenticatorAttestationResponse, }; -use crate::error::Result; + +#[derive(Debug, Error)] +#[error("Invalid origin: {0}")] +pub struct InvalidOriginError(String); + +#[derive(Debug, Error)] +pub enum Fido2ClientError { + #[error(transparent)] + InvalidOrigin(#[from] InvalidOriginError), + #[error(transparent)] + Serde(#[from] serde_json::Error), + #[error(transparent)] + GetSelectedCredentialError(#[from] GetSelectedCredentialError), + + #[error("Webauthn error: {0:?}")] + Webauthn(WebauthnError), +} + +impl From for Fido2ClientError { + fn from(e: WebauthnError) -> Self { + Self::Webauthn(e) + } +} pub struct Fido2Client<'a> { pub(crate) authenticator: Fido2Authenticator<'a>, @@ -21,8 +46,8 @@ impl<'a> Fido2Client<'a> { origin: String, request: String, client_data: ClientData, - ) -> Result { - let origin = Url::parse(&origin).map_err(|e| format!("Invalid origin: {}", e))?; + ) -> Result { + let origin = Url::parse(&origin).map_err(|e| InvalidOriginError(format!("{}", e)))?; let request: passkey::types::webauthn::CredentialCreationOptions = serde_json::from_str(&request)?; @@ -76,8 +101,8 @@ impl<'a> Fido2Client<'a> { origin: String, request: String, client_data: ClientData, - ) -> Result { - let origin = Url::parse(&origin).map_err(|e| format!("Invalid origin: {}", e))?; + ) -> Result { + let origin = Url::parse(&origin).map_err(|e| InvalidOriginError(format!("{}", e)))?; let request: passkey::types::webauthn::CredentialRequestOptions = serde_json::from_str(&request)?; diff --git a/crates/bitwarden/src/platform/fido2/crypto.rs b/crates/bitwarden/src/platform/fido2/crypto.rs index a7fb5cff1..bca8e2a92 100644 --- a/crates/bitwarden/src/platform/fido2/crypto.rs +++ b/crates/bitwarden/src/platform/fido2/crypto.rs @@ -1,24 +1,28 @@ -use coset::{ - iana::{self}, - CoseKey, -}; +use coset::{iana, CoseKey}; use p256::{pkcs8::EncodePrivateKey, SecretKey}; use passkey::authenticator::{private_key_from_cose_key, CoseKeyPair}; +use thiserror::Error; -use crate::error::{Error, Result}; +#[derive(Debug, Error)] +pub enum CoseKeyToPkcs8Error { + #[error("Failed to extract private key from cose_key")] + FailedToExtractPrivateKeyFromCoseKey, + #[error("Failed to convert P256 private key to PKC8")] + FailedToConvertP256PrivateKeyToPkcs8, +} -pub fn cose_key_to_pkcs8(cose_key: &CoseKey) -> Result> { +pub fn cose_key_to_pkcs8(cose_key: &CoseKey) -> Result, CoseKeyToPkcs8Error> { // cose_key. let secret_key = private_key_from_cose_key(cose_key).map_err(|error| { log::error!("Failed to extract private key from cose_key: {:?}", error); - Error::Internal("Failed to extract private key from cose_key".into()) + CoseKeyToPkcs8Error::FailedToExtractPrivateKeyFromCoseKey })?; let vec = secret_key .to_pkcs8_der() .map_err(|error| { log::error!("Failed to convert P256 private key to PKC8: {:?}", error); - Error::Internal("Failed to convert P256 private key to PKC8".into()) + CoseKeyToPkcs8Error::FailedToConvertP256PrivateKeyToPkcs8 })? .as_bytes() .to_vec(); @@ -26,10 +30,14 @@ pub fn cose_key_to_pkcs8(cose_key: &CoseKey) -> Result> { Ok(vec) } -pub fn pkcs8_to_cose_key(secret_key: &[u8]) -> Result { +#[derive(Debug, Error)] +#[error("Failed to extract private key from secret_key")] +pub struct PrivateKeyFromSecretKeyError; + +pub fn pkcs8_to_cose_key(secret_key: &[u8]) -> Result { let secret_key = SecretKey::from_slice(secret_key).map_err(|error| { log::error!("Failed to extract private key from secret_key: {:?}", error); - Error::Internal("Failed to extract private key from secret_key".into()) + PrivateKeyFromSecretKeyError })?; let cose_key_pair = CoseKeyPair::from_secret_key(&secret_key, iana::Algorithm::ES256); diff --git a/crates/bitwarden/src/platform/fido2/mod.rs b/crates/bitwarden/src/platform/fido2/mod.rs index b523cf7e5..3f08b8810 100644 --- a/crates/bitwarden/src/platform/fido2/mod.rs +++ b/crates/bitwarden/src/platform/fido2/mod.rs @@ -3,8 +3,9 @@ use std::sync::Mutex; use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine}; use bitwarden_crypto::KeyContainer; use bitwarden_vault::{ - CipherView, Fido2CredentialFullView, Fido2CredentialNewView, Fido2CredentialView, + CipherError, CipherView, Fido2CredentialFullView, Fido2CredentialNewView, Fido2CredentialView, }; +use crypto::{CoseKeyToPkcs8Error, PrivateKeyFromSecretKeyError}; use passkey::types::{ctap2::Aaguid, Passkey}; mod authenticator; @@ -13,9 +14,12 @@ mod crypto; mod traits; mod types; -pub use authenticator::Fido2Authenticator; -pub use client::Fido2Client; +pub use authenticator::{ + Fido2Authenticator, GetAssertionError, MakeCredentialError, SilentlyDiscoverCredentialsError, +}; +pub use client::{Fido2Client, Fido2ClientError}; pub use passkey::authenticator::UIHint; +use thiserror::Error; pub use traits::{ CheckUserOptions, CheckUserResult, Fido2CallbackError, Fido2CredentialStore, Fido2UserInterface, Verification, @@ -29,10 +33,7 @@ pub use types::{ }; use self::crypto::{cose_key_to_pkcs8, pkcs8_to_cose_key}; -use crate::{ - error::{Error, Result}, - Client, -}; +use crate::Client; // This is the AAGUID for the Bitwarden Passkey provider (d548826e-79b4-db40-a3d8-11116f7e8349) // It is used for the Relaying Parties to identify the authenticator during registration @@ -48,28 +49,26 @@ pub struct ClientFido2<'a> { impl<'a> ClientFido2<'a> { pub fn create_authenticator( &'a mut self, - user_interface: &'a dyn Fido2UserInterface, credential_store: &'a dyn Fido2CredentialStore, - ) -> Result> { - Ok(Fido2Authenticator { + ) -> Fido2Authenticator<'a> { + Fido2Authenticator { client: self.client, user_interface, credential_store, selected_cipher: Mutex::new(None), requested_uv: Mutex::new(None), - }) + } } pub fn create_client( &'a mut self, - user_interface: &'a dyn Fido2UserInterface, credential_store: &'a dyn Fido2CredentialStore, - ) -> Result> { - Ok(Fido2Client { - authenticator: self.create_authenticator(user_interface, credential_store)?, - }) + ) -> Fido2Client<'a> { + Fido2Client { + authenticator: self.create_authenticator(user_interface, credential_store), + } } } @@ -89,7 +88,7 @@ pub(crate) struct CipherViewContainer { } impl CipherViewContainer { - fn new(cipher: CipherView, enc: &dyn KeyContainer) -> Result { + fn new(cipher: CipherView, enc: &dyn KeyContainer) -> Result { let fido2_credentials = cipher.get_fido2_credentials(enc)?; Ok(Self { cipher, @@ -98,20 +97,35 @@ impl CipherViewContainer { } } +#[derive(Debug, Error)] +pub enum Fido2Error { + #[error(transparent)] + UnknownEnum(#[from] UnknownEnum), + + #[error(transparent)] + InvalidGuid(#[from] InvalidGuid), + + #[error(transparent)] + PrivateKeyFromSecretKeyError(#[from] PrivateKeyFromSecretKeyError), + + #[error("No Fido2 credentials found")] + NoFido2CredentialsFound, +} + impl TryFrom for Passkey { - type Error = crate::error::Error; + type Error = Fido2Error; fn try_from(value: CipherViewContainer) -> Result { let cred = value .fido2_credentials .first() - .ok_or(Error::Internal("No Fido2 credentials found".into()))?; + .ok_or(Fido2Error::NoFido2CredentialsFound)?; try_from_credential_full_view(cred.clone()) } } -fn try_from_credential_full_view(value: Fido2CredentialFullView) -> Result { +fn try_from_credential_full_view(value: Fido2CredentialFullView) -> Result { let counter: u32 = value.counter.parse().expect("Invalid counter"); let counter = (counter != 0).then_some(counter); @@ -126,10 +140,18 @@ fn try_from_credential_full_view(value: Fido2CredentialFullView) -> Result Result { +) -> Result { let cred_id: Vec = value.credential_id.into(); Ok(Fido2CredentialFullView { @@ -153,7 +175,7 @@ pub fn fill_with_credential( pub(crate) fn try_from_credential_new_view( user: &passkey::types::ctap2::make_credential::PublicKeyCredentialUserEntity, rp: &passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, -) -> Result { +) -> Result { let cred_id: Vec = vec![0; 16]; Ok(Fido2CredentialNewView { @@ -177,7 +199,7 @@ pub(crate) fn try_from_credential_full( value: Passkey, user: passkey::types::ctap2::make_credential::PublicKeyCredentialUserEntity, rp: passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, -) -> Result { +) -> Result { let cred_id: Vec = value.credential_id.into(); Ok(Fido2CredentialFullView { @@ -198,33 +220,47 @@ pub(crate) fn try_from_credential_full( }) } -pub fn guid_bytes_to_string(source: &[u8]) -> Result { +#[derive(Debug, Error)] +#[error("Input should be a 16 byte array")] +pub struct InvalidInputLength; + +pub fn guid_bytes_to_string(source: &[u8]) -> Result { if source.len() != 16 { - return Err(Error::Internal("Input should be a 16 byte array".into())); + return Err(InvalidInputLength); } Ok(uuid::Uuid::from_bytes(source.try_into().expect("Invalid length")).to_string()) } -pub fn string_to_guid_bytes(source: &str) -> Result> { +#[derive(Debug, Error)] +#[error("Invalid GUID")] +pub struct InvalidGuid; + +pub fn string_to_guid_bytes(source: &str) -> Result, InvalidGuid> { if source.starts_with("b64.") { - let bytes = URL_SAFE_NO_PAD.decode(source.trim_start_matches("b64."))?; + let bytes = URL_SAFE_NO_PAD + .decode(source.trim_start_matches("b64.")) + .map_err(|_| InvalidGuid)?; Ok(bytes) } else { let Ok(uuid) = uuid::Uuid::try_parse(source) else { - return Err(Error::Internal("Input should be a valid GUID".into())); + return Err(InvalidGuid); }; Ok(uuid.as_bytes().to_vec()) } } +#[derive(Debug, Error)] +#[error("Unknown enum value")] +pub struct UnknownEnum; + // Some utilities to convert back and forth between enums and strings -fn get_enum_from_string_name(s: &str) -> Result { +fn get_enum_from_string_name(s: &str) -> Result { let serialized = format!(r#""{}""#, s); - let deserialized: T = serde_json::from_str(&serialized)?; + let deserialized: T = serde_json::from_str(&serialized).map_err(|_| UnknownEnum)?; Ok(deserialized) } -fn get_string_name_from_enum(s: impl serde::Serialize) -> Result { +fn get_string_name_from_enum(s: impl serde::Serialize) -> Result { let serialized = serde_json::to_string(&s)?; let deserialized: String = serde_json::from_str(&serialized)?; Ok(deserialized) diff --git a/crates/bitwarden/src/platform/fido2/traits.rs b/crates/bitwarden/src/platform/fido2/traits.rs index f64bf100e..0769eeb2a 100644 --- a/crates/bitwarden/src/platform/fido2/traits.rs +++ b/crates/bitwarden/src/platform/fido2/traits.rs @@ -2,8 +2,6 @@ use bitwarden_vault::{Cipher, CipherView, Fido2CredentialNewView}; use passkey::authenticator::UIHint; use thiserror::Error; -use crate::error::Result; - #[derive(Debug, Error)] pub enum Fido2CallbackError { #[error("The operation requires user interaction")] diff --git a/crates/bitwarden/src/platform/fido2/types.rs b/crates/bitwarden/src/platform/fido2/types.rs index bee66dbe8..3e41768f6 100644 --- a/crates/bitwarden/src/platform/fido2/types.rs +++ b/crates/bitwarden/src/platform/fido2/types.rs @@ -1,7 +1,8 @@ use passkey::types::webauthn::UserVerificationRequirement; use serde::Serialize; +use thiserror::Error; -use super::{get_enum_from_string_name, SelectedCredential, Verification}; +use super::{get_enum_from_string_name, SelectedCredential, UnknownEnum, Verification}; #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] pub struct PublicKeyCredentialRpEntity { @@ -22,16 +23,26 @@ pub struct PublicKeyCredentialParameters { pub alg: i64, } +#[derive(Debug, Error)] +pub enum PublicKeyCredentialParametersError { + #[error("Invalid algorithm")] + InvalidAlgorithm, + + #[error("Unknown type")] + UnknownEnum(#[from] UnknownEnum), +} + impl TryFrom for passkey::types::webauthn::PublicKeyCredentialParameters { - type Error = crate::error::Error; + type Error = PublicKeyCredentialParametersError; fn try_from(value: PublicKeyCredentialParameters) -> Result { use coset::iana::EnumI64; Ok(Self { ty: get_enum_from_string_name(&value.ty)?, - alg: coset::iana::Algorithm::from_i64(value.alg).ok_or("Invalid algorithm")?, + alg: coset::iana::Algorithm::from_i64(value.alg) + .ok_or(PublicKeyCredentialParametersError::InvalidAlgorithm)?, }) } } @@ -46,7 +57,7 @@ pub struct PublicKeyCredentialDescriptor { impl TryFrom for passkey::types::webauthn::PublicKeyCredentialDescriptor { - type Error = crate::error::Error; + type Error = UnknownEnum; fn try_from(value: PublicKeyCredentialDescriptor) -> Result { Ok(Self { From 07abbc784d94a43b1d13bd7b022c7a5514f3db69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Thu, 13 Jun 2024 16:03:25 +0200 Subject: [PATCH 013/214] Make client internally mutable (#837) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📔 Objective We're having some deadlock problems with the Passkey API by calling certain SDK functions on the `passkey-rs` callbacks. These issues are caused because we're holding a reference to the RwLock during the execution of the Passkey operation and so calling into the SDK from inside that will deadlock. To solve it we can't just use a lock at the client level, and so we need to move to using interior mutability, I've revived an old PR (#70) where we started doing that. This PR is split into two commits, for ease of review: - [Remove all the muts and locks for uniffi](https://github.com/bitwarden/sdk/commit/c56add5c181ecd6028df3c6710da6327b2ad9166): This removes the use of RwLock in bitwarden-uniffi and the `&mut` references used in the bitwarden Client API. Note that this alone won't compile. - [Make client internally mutable](https://github.com/bitwarden/sdk/commit/f61d10496ea5724b639ba991a7b953a7852ca34c): Implements RwLocks in Client to make it internally mutable. Some notes of what the change entails: - I had to wrap `EncryptionSettings` in a `RwLock>` to get the API working, this is quite unfortunate as it forces us to clone `EncryptionSettings` to modify it when calling `set_org_keys`. We can't wrap the `org_keys` in a `RwLock` as we will get lifetime issues in `get_key`. I think the best solution for this will be the work on creating a Crypto store that only returns opaque key references, so we might want to prioritize that. - I extracted `external_client` from `ApiConfigurations`, as it's never mutated and it allows us to keep the same API for `get_http_client` I hate that `Mutex` and `RwLock` return a Result in case they are poisoned, that's never our case and it makes their usage so cumbersome đŸ˜ĸ Note: I've tried to change the smallest amount of code to make the change, so the secrets manager APIs (and bitwarden-json) are still mutable. If we're okay with these changes I can go back to update those in a separate PR. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .../src/keys/asymmetric_crypto_key.rs | 1 + .../src/keys/key_encryptable.rs | 8 +- .../src/keys/symmetric_crypto_key.rs | 1 + crates/bitwarden-uniffi/src/auth/mod.rs | 58 ++--- crates/bitwarden-uniffi/src/crypto.rs | 64 +----- crates/bitwarden-uniffi/src/lib.rs | 5 +- crates/bitwarden-uniffi/src/platform/fido2.rs | 30 +-- crates/bitwarden-uniffi/src/platform/mod.rs | 21 +- crates/bitwarden-uniffi/src/tool/mod.rs | 27 +-- crates/bitwarden-uniffi/src/tool/sends.rs | 42 ++-- .../bitwarden-uniffi/src/vault/attachments.rs | 18 +- crates/bitwarden-uniffi/src/vault/ciphers.rs | 32 +-- .../bitwarden-uniffi/src/vault/collections.rs | 24 +- crates/bitwarden-uniffi/src/vault/folders.rs | 21 +- crates/bitwarden-uniffi/src/vault/mod.rs | 10 +- .../src/vault/password_history.rs | 20 +- crates/bitwarden/src/auth/auth_request.rs | 12 +- crates/bitwarden/src/auth/client_auth.rs | 29 ++- .../bitwarden/src/auth/login/access_token.rs | 8 +- crates/bitwarden/src/auth/login/api_key.rs | 6 +- .../bitwarden/src/auth/login/auth_request.rs | 6 +- crates/bitwarden/src/auth/login/mod.rs | 2 +- crates/bitwarden/src/auth/login/password.rs | 6 +- crates/bitwarden/src/auth/login/two_factor.rs | 2 +- .../bitwarden/src/auth/password/validate.rs | 20 +- crates/bitwarden/src/auth/register.rs | 2 +- crates/bitwarden/src/auth/renew.rs | 41 ++-- crates/bitwarden/src/auth/tde.rs | 2 +- crates/bitwarden/src/client/client.rs | 206 ++++++++++++------ .../src/client/encryption_settings.rs | 3 +- crates/bitwarden/src/client/test_accounts.rs | 8 +- crates/bitwarden/src/mobile/client_crypto.rs | 21 +- crates/bitwarden/src/mobile/crypto.rs | 100 ++++----- .../bitwarden/src/mobile/tool/client_sends.rs | 13 +- .../src/mobile/vault/client_attachments.rs | 4 +- .../src/mobile/vault/client_ciphers.rs | 18 +- .../src/mobile/vault/client_collection.rs | 8 +- .../bitwarden/src/platform/client_platform.rs | 6 +- .../src/platform/fido2/authenticator.rs | 14 +- crates/bitwarden/src/platform/fido2/mod.rs | 6 +- .../src/platform/generate_fingerprint.rs | 6 +- .../src/platform/get_user_api_key.rs | 13 +- .../src/secrets_manager/projects/create.rs | 8 +- .../src/secrets_manager/projects/get.rs | 2 +- .../src/secrets_manager/projects/list.rs | 2 +- .../src/secrets_manager/projects/update.rs | 8 +- .../src/secrets_manager/secrets/create.rs | 8 +- .../src/secrets_manager/secrets/get.rs | 2 +- .../src/secrets_manager/secrets/get_by_ids.rs | 2 +- .../src/secrets_manager/secrets/list.rs | 4 +- .../src/secrets_manager/secrets/sync.rs | 2 +- .../src/secrets_manager/secrets/update.rs | 8 +- crates/bitwarden/src/tool/exporters/mod.rs | 9 +- crates/bitwarden/src/vault/client_vault.rs | 6 +- crates/bitwarden/src/vault/sync.rs | 4 +- crates/bitwarden/tests/register.rs | 2 +- crates/bw/src/auth/login.rs | 6 +- crates/bw/src/main.rs | 2 +- 58 files changed, 442 insertions(+), 577 deletions(-) diff --git a/crates/bitwarden-crypto/src/keys/asymmetric_crypto_key.rs b/crates/bitwarden-crypto/src/keys/asymmetric_crypto_key.rs index be523bbc6..9a2bb43e3 100644 --- a/crates/bitwarden-crypto/src/keys/asymmetric_crypto_key.rs +++ b/crates/bitwarden-crypto/src/keys/asymmetric_crypto_key.rs @@ -36,6 +36,7 @@ impl AsymmetricEncryptable for AsymmetricPublicCryptoKey { /// An asymmetric encryption key. Contains both the public and private key. Can be used to both /// encrypt and decrypt [`AsymmetricEncString`](crate::AsymmetricEncString). +#[derive(Clone)] pub struct AsymmetricCryptoKey { // RsaPrivateKey is not a Copy type so this isn't completely necessary, but // to keep the compiler from making stack copies when moving this struct around, diff --git a/crates/bitwarden-crypto/src/keys/key_encryptable.rs b/crates/bitwarden-crypto/src/keys/key_encryptable.rs index d8f11a011..f1a538d12 100644 --- a/crates/bitwarden-crypto/src/keys/key_encryptable.rs +++ b/crates/bitwarden-crypto/src/keys/key_encryptable.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, hash::Hash}; +use std::{collections::HashMap, hash::Hash, sync::Arc}; use rayon::prelude::*; use uuid::Uuid; @@ -9,6 +9,12 @@ pub trait KeyContainer: Send + Sync { fn get_key(&self, org_id: &Option) -> Option<&SymmetricCryptoKey>; } +impl KeyContainer for Arc { + fn get_key(&self, org_id: &Option) -> Option<&SymmetricCryptoKey> { + self.as_ref().get_key(org_id) + } +} + pub trait LocateKey { fn locate_key<'a>( &self, diff --git a/crates/bitwarden-crypto/src/keys/symmetric_crypto_key.rs b/crates/bitwarden-crypto/src/keys/symmetric_crypto_key.rs index 4857aa2d4..971564b07 100644 --- a/crates/bitwarden-crypto/src/keys/symmetric_crypto_key.rs +++ b/crates/bitwarden-crypto/src/keys/symmetric_crypto_key.rs @@ -10,6 +10,7 @@ use super::key_encryptable::CryptoKey; use crate::CryptoError; /// A symmetric encryption key. Used to encrypt and decrypt [`EncString`](crate::EncString) +#[derive(Clone)] pub struct SymmetricCryptoKey { // GenericArray is equivalent to [u8; N], which is a Copy type placed on the stack. // To keep the compiler from making stack copies when moving this struct around, diff --git a/crates/bitwarden-uniffi/src/auth/mod.rs b/crates/bitwarden-uniffi/src/auth/mod.rs index 1065a01a9..a70eebb8f 100644 --- a/crates/bitwarden-uniffi/src/auth/mod.rs +++ b/crates/bitwarden-uniffi/src/auth/mod.rs @@ -14,7 +14,7 @@ pub struct ClientAuth(pub(crate) Arc); #[uniffi::export(async_runtime = "tokio")] impl ClientAuth { /// **API Draft:** Calculate Password Strength - pub async fn password_strength( + pub fn password_strength( &self, password: String, email: String, @@ -22,14 +22,12 @@ impl ClientAuth { ) -> u8 { self.0 .0 - .write() - .await .auth() .password_strength(password, email, additional_inputs) } /// Evaluate if the provided password satisfies the provided policy - pub async fn satisfies_policy( + pub fn satisfies_policy( &self, password: String, strength: u8, @@ -37,8 +35,6 @@ impl ClientAuth { ) -> bool { self.0 .0 - .write() - .await .auth() .satisfies_policy(password, strength, &policy) } @@ -54,41 +50,33 @@ impl ClientAuth { Ok(self .0 .0 - .read() - .await .kdf() .hash_password(email, password, kdf_params, purpose) .await?) } /// Generate keys needed for registration process - pub async fn make_register_keys( + pub fn make_register_keys( &self, email: String, password: String, kdf: Kdf, ) -> Result { - Ok(self - .0 - .0 - .write() - .await - .auth() - .make_register_keys(email, password, kdf)?) + Ok(self.0 .0.auth().make_register_keys(email, password, kdf)?) } /// Generate keys needed for TDE process - pub async fn make_register_tde_keys( + pub fn make_register_tde_keys( &self, email: String, org_public_key: String, remember_device: bool, ) -> Result { - Ok(self.0 .0.write().await.auth().make_register_tde_keys( - email, - org_public_key, - remember_device, - )?) + Ok(self + .0 + .0 + .auth() + .make_register_tde_keys(email, org_public_key, remember_device)?) } /// Validate the user password @@ -96,12 +84,10 @@ impl ClientAuth { /// To retrieve the user's password hash, use [`ClientAuth::hash_password`] with /// `HashPurpose::LocalAuthentication` during login and persist it. If the login method has no /// password, use the email OTP. - pub async fn validate_password(&self, password: String, password_hash: String) -> Result { + pub fn validate_password(&self, password: String, password_hash: String) -> Result { Ok(self .0 .0 - .write() - .await .auth() .validate_password(password, password_hash)?) } @@ -112,7 +98,7 @@ impl ClientAuth { /// password. Some example are login with device or TDE. /// /// This works by comparing the provided password against the encrypted user key. - pub async fn validate_password_user_key( + pub fn validate_password_user_key( &self, password: String, encrypted_user_key: String, @@ -120,30 +106,22 @@ impl ClientAuth { Ok(self .0 .0 - .write() - .await .auth() .validate_password_user_key(password, encrypted_user_key)?) } /// Initialize a new auth request - pub async fn new_auth_request(&self, email: String) -> Result { - Ok(self.0 .0.write().await.auth().new_auth_request(&email)?) + pub fn new_auth_request(&self, email: String) -> Result { + Ok(self.0 .0.auth().new_auth_request(&email)?) } /// Approve an auth request - pub async fn approve_auth_request(&self, public_key: String) -> Result { - Ok(self - .0 - .0 - .write() - .await - .auth() - .approve_auth_request(public_key)?) + pub fn approve_auth_request(&self, public_key: String) -> Result { + Ok(self.0 .0.auth().approve_auth_request(public_key)?) } /// Trust the current device - pub async fn trust_device(&self) -> Result { - Ok(self.0 .0.write().await.auth().trust_device()?) + pub fn trust_device(&self) -> Result { + Ok(self.0 .0.auth().trust_device()?) } } diff --git a/crates/bitwarden-uniffi/src/crypto.rs b/crates/bitwarden-uniffi/src/crypto.rs index 991ff820f..761a72bc2 100644 --- a/crates/bitwarden-uniffi/src/crypto.rs +++ b/crates/bitwarden-uniffi/src/crypto.rs @@ -15,83 +15,41 @@ impl ClientCrypto { /// Initialization method for the user crypto. Needs to be called before any other crypto /// operations. pub async fn initialize_user_crypto(&self, req: InitUserCryptoRequest) -> Result<()> { - Ok(self - .0 - .0 - .write() - .await - .crypto() - .initialize_user_crypto(req) - .await?) + Ok(self.0 .0.crypto().initialize_user_crypto(req).await?) } /// Initialization method for the organization crypto. Needs to be called after /// `initialize_user_crypto` but before any other crypto operations. pub async fn initialize_org_crypto(&self, req: InitOrgCryptoRequest) -> Result<()> { - Ok(self - .0 - .0 - .write() - .await - .crypto() - .initialize_org_crypto(req) - .await?) + Ok(self.0 .0.crypto().initialize_org_crypto(req).await?) } /// Get the uses's decrypted encryption key. Note: It's very important /// to keep this key safe, as it can be used to decrypt all of the user's data pub async fn get_user_encryption_key(&self) -> Result { - Ok(self - .0 - .0 - .write() - .await - .crypto() - .get_user_encryption_key() - .await?) + Ok(self.0 .0.crypto().get_user_encryption_key().await?) } /// Update the user's password, which will re-encrypt the user's encryption key with the new /// password. This returns the new encrypted user key and the new password hash. - pub async fn update_password(&self, new_password: String) -> Result { - Ok(self - .0 - .0 - .write() - .await - .crypto() - .update_password(new_password)?) + pub fn update_password(&self, new_password: String) -> Result { + Ok(self.0 .0.crypto().update_password(new_password)?) } /// Generates a PIN protected user key from the provided PIN. The result can be stored and later /// used to initialize another client instance by using the PIN and the PIN key with /// `initialize_user_crypto`. - pub async fn derive_pin_key(&self, pin: String) -> Result { - Ok(self.0 .0.write().await.crypto().derive_pin_key(pin)?) + pub fn derive_pin_key(&self, pin: String) -> Result { + Ok(self.0 .0.crypto().derive_pin_key(pin)?) } /// Derives the pin protected user key from encrypted pin. Used when pin requires master /// password on first unlock. - pub async fn derive_pin_user_key(&self, encrypted_pin: EncString) -> Result { - Ok(self - .0 - .0 - .write() - .await - .crypto() - .derive_pin_user_key(encrypted_pin)?) + pub fn derive_pin_user_key(&self, encrypted_pin: EncString) -> Result { + Ok(self.0 .0.crypto().derive_pin_user_key(encrypted_pin)?) } - pub async fn enroll_admin_password_reset( - &self, - public_key: String, - ) -> Result { - Ok(self - .0 - .0 - .write() - .await - .crypto() - .enroll_admin_password_reset(public_key)?) + pub fn enroll_admin_password_reset(&self, public_key: String) -> Result { + Ok(self.0 .0.crypto().enroll_admin_password_reset(public_key)?) } } diff --git a/crates/bitwarden-uniffi/src/lib.rs b/crates/bitwarden-uniffi/src/lib.rs index 318d47417..59f3e2035 100644 --- a/crates/bitwarden-uniffi/src/lib.rs +++ b/crates/bitwarden-uniffi/src/lib.rs @@ -2,7 +2,6 @@ uniffi::setup_scaffolding!(); use std::sync::Arc; -use async_lock::RwLock; use auth::ClientAuth; use bitwarden::client::client_settings::ClientSettings; @@ -24,7 +23,7 @@ use tool::{ClientExporters, ClientGenerators, ClientSends}; use vault::ClientVault; #[derive(uniffi::Object)] -pub struct Client(RwLock); +pub struct Client(bitwarden::Client); #[uniffi::export] impl Client { @@ -32,7 +31,7 @@ impl Client { #[uniffi::constructor] pub fn new(settings: Option) -> Arc { init_logger(); - Arc::new(Self(RwLock::new(bitwarden::Client::new(settings)))) + Arc::new(Self(bitwarden::Client::new(settings))) } /// Crypto operations diff --git a/crates/bitwarden-uniffi/src/platform/fido2.rs b/crates/bitwarden-uniffi/src/platform/fido2.rs index 3fc67f1d4..09162b7d0 100644 --- a/crates/bitwarden-uniffi/src/platform/fido2.rs +++ b/crates/bitwarden-uniffi/src/platform/fido2.rs @@ -57,10 +57,8 @@ impl ClientFido2Authenticator { &self, request: MakeCredentialRequest, ) -> Result { - let mut client = self.0 .0.write().await; - - let mut platform = client.platform(); - let mut fido2 = platform.fido2(); + let platform = self.0 .0.platform(); + let fido2 = platform.fido2(); let ui = UniffiTraitBridge(self.1.as_ref()); let cs = UniffiTraitBridge(self.2.as_ref()); let mut auth = fido2.create_authenticator(&ui, &cs); @@ -73,10 +71,8 @@ impl ClientFido2Authenticator { } pub async fn get_assertion(&self, request: GetAssertionRequest) -> Result { - let mut client = self.0 .0.write().await; - - let mut platform = client.platform(); - let mut fido2 = platform.fido2(); + let platform = self.0 .0.platform(); + let fido2 = platform.fido2(); let ui = UniffiTraitBridge(self.1.as_ref()); let cs = UniffiTraitBridge(self.2.as_ref()); let mut auth = fido2.create_authenticator(&ui, &cs); @@ -92,10 +88,8 @@ impl ClientFido2Authenticator { &self, rp_id: String, ) -> Result> { - let mut client = self.0 .0.write().await; - - let mut platform = client.platform(); - let mut fido2 = platform.fido2(); + let platform = self.0 .0.platform(); + let fido2 = platform.fido2(); let ui = UniffiTraitBridge(self.1.as_ref()); let cs = UniffiTraitBridge(self.2.as_ref()); let mut auth = fido2.create_authenticator(&ui, &cs); @@ -119,10 +113,8 @@ impl ClientFido2Client { request: String, client_data: ClientData, ) -> Result { - let mut client = self.0 .0 .0.write().await; - - let mut platform = client.platform(); - let mut fido2 = platform.fido2(); + let platform = self.0 .0 .0.platform(); + let fido2 = platform.fido2(); let ui = UniffiTraitBridge(self.0 .1.as_ref()); let cs = UniffiTraitBridge(self.0 .2.as_ref()); let mut client = fido2.create_client(&ui, &cs); @@ -140,10 +132,8 @@ impl ClientFido2Client { request: String, client_data: ClientData, ) -> Result { - let mut client = self.0 .0 .0.write().await; - - let mut platform = client.platform(); - let mut fido2 = platform.fido2(); + let platform = self.0 .0 .0.platform(); + let fido2 = platform.fido2(); let ui = UniffiTraitBridge(self.0 .1.as_ref()); let cs = UniffiTraitBridge(self.0 .2.as_ref()); let mut client = fido2.create_client(&ui, &cs); diff --git a/crates/bitwarden-uniffi/src/platform/mod.rs b/crates/bitwarden-uniffi/src/platform/mod.rs index 458306676..fe7c401ee 100644 --- a/crates/bitwarden-uniffi/src/platform/mod.rs +++ b/crates/bitwarden-uniffi/src/platform/mod.rs @@ -9,34 +9,25 @@ mod fido2; #[derive(uniffi::Object)] pub struct ClientPlatform(pub(crate) Arc); -#[uniffi::export(async_runtime = "tokio")] +#[uniffi::export] impl ClientPlatform { /// Fingerprint (public key) - pub async fn fingerprint(&self, req: FingerprintRequest) -> Result { - Ok(self - .0 - .0 - .write() - .await - .platform() - .fingerprint(&req)? - .fingerprint) + pub fn fingerprint(&self, req: FingerprintRequest) -> Result { + Ok(self.0 .0.platform().fingerprint(&req)?.fingerprint) } /// Fingerprint using logged in user's public key - pub async fn user_fingerprint(&self, fingerprint_material: String) -> Result { + pub fn user_fingerprint(&self, fingerprint_material: String) -> Result { Ok(self .0 .0 - .write() - .await .platform() .user_fingerprint(fingerprint_material)?) } /// Load feature flags into the client - pub async fn load_flags(&self, flags: std::collections::HashMap) -> Result<()> { - self.0 .0.write().await.load_flags(flags); + pub fn load_flags(&self, flags: std::collections::HashMap) -> Result<()> { + self.0 .0.load_flags(flags); Ok(()) } diff --git a/crates/bitwarden-uniffi/src/tool/mod.rs b/crates/bitwarden-uniffi/src/tool/mod.rs index 78781b263..a590b41a3 100644 --- a/crates/bitwarden-uniffi/src/tool/mod.rs +++ b/crates/bitwarden-uniffi/src/tool/mod.rs @@ -17,35 +17,28 @@ pub struct ClientGenerators(pub(crate) Arc); #[uniffi::export(async_runtime = "tokio")] impl ClientGenerators { /// **API Draft:** Generate Password - pub async fn password(&self, settings: PasswordGeneratorRequest) -> Result { - Ok(self.0 .0.read().await.generator().password(settings)?) + pub fn password(&self, settings: PasswordGeneratorRequest) -> Result { + Ok(self.0 .0.generator().password(settings)?) } /// **API Draft:** Generate Passphrase - pub async fn passphrase(&self, settings: PassphraseGeneratorRequest) -> Result { - Ok(self.0 .0.read().await.generator().passphrase(settings)?) + pub fn passphrase(&self, settings: PassphraseGeneratorRequest) -> Result { + Ok(self.0 .0.generator().passphrase(settings)?) } /// **API Draft:** Generate Username pub async fn username(&self, settings: UsernameGeneratorRequest) -> Result { - Ok(self - .0 - .0 - .read() - .await - .generator() - .username(settings) - .await?) + Ok(self.0 .0.generator().username(settings).await?) } } #[derive(uniffi::Object)] pub struct ClientExporters(pub(crate) Arc); -#[uniffi::export(async_runtime = "tokio")] +#[uniffi::export] impl ClientExporters { /// **API Draft:** Export user vault - pub async fn export_vault( + pub fn export_vault( &self, folders: Vec, ciphers: Vec, @@ -54,14 +47,12 @@ impl ClientExporters { Ok(self .0 .0 - .read() - .await .exporters() .export_vault(folders, ciphers, format)?) } /// **API Draft:** Export organization vault - pub async fn export_organization_vault( + pub fn export_organization_vault( &self, collections: Vec, ciphers: Vec, @@ -70,8 +61,6 @@ impl ClientExporters { Ok(self .0 .0 - .read() - .await .exporters() .export_organization_vault(collections, ciphers, format)?) } diff --git a/crates/bitwarden-uniffi/src/tool/sends.rs b/crates/bitwarden-uniffi/src/tool/sends.rs index 36f174d38..ac9482429 100644 --- a/crates/bitwarden-uniffi/src/tool/sends.rs +++ b/crates/bitwarden-uniffi/src/tool/sends.rs @@ -7,32 +7,26 @@ use crate::{Client, Result}; #[derive(uniffi::Object)] pub struct ClientSends(pub Arc); -#[uniffi::export(async_runtime = "tokio")] +#[uniffi::export] impl ClientSends { /// Encrypt send - pub async fn encrypt(&self, send: SendView) -> Result { - Ok(self.0 .0.write().await.sends().encrypt(send)?) + pub fn encrypt(&self, send: SendView) -> Result { + Ok(self.0 .0.sends().encrypt(send)?) } /// Encrypt a send file in memory - pub async fn encrypt_buffer(&self, send: Send, buffer: Vec) -> Result> { - Ok(self - .0 - .0 - .write() - .await - .sends() - .encrypt_buffer(send, &buffer)?) + pub fn encrypt_buffer(&self, send: Send, buffer: Vec) -> Result> { + Ok(self.0 .0.sends().encrypt_buffer(send, &buffer)?) } /// Encrypt a send file located in the file system - pub async fn encrypt_file( + pub fn encrypt_file( &self, send: Send, decrypted_file_path: String, encrypted_file_path: String, ) -> Result<()> { - Ok(self.0 .0.write().await.sends().encrypt_file( + Ok(self.0 .0.sends().encrypt_file( send, Path::new(&decrypted_file_path), Path::new(&encrypted_file_path), @@ -40,34 +34,28 @@ impl ClientSends { } /// Decrypt send - pub async fn decrypt(&self, send: Send) -> Result { - Ok(self.0 .0.write().await.sends().decrypt(send)?) + pub fn decrypt(&self, send: Send) -> Result { + Ok(self.0 .0.sends().decrypt(send)?) } /// Decrypt send list - pub async fn decrypt_list(&self, sends: Vec) -> Result> { - Ok(self.0 .0.write().await.sends().decrypt_list(sends)?) + pub fn decrypt_list(&self, sends: Vec) -> Result> { + Ok(self.0 .0.sends().decrypt_list(sends)?) } /// Decrypt a send file in memory - pub async fn decrypt_buffer(&self, send: Send, buffer: Vec) -> Result> { - Ok(self - .0 - .0 - .write() - .await - .sends() - .decrypt_buffer(send, &buffer)?) + pub fn decrypt_buffer(&self, send: Send, buffer: Vec) -> Result> { + Ok(self.0 .0.sends().decrypt_buffer(send, &buffer)?) } /// Decrypt a send file located in the file system - pub async fn decrypt_file( + pub fn decrypt_file( &self, send: Send, encrypted_file_path: String, decrypted_file_path: String, ) -> Result<()> { - Ok(self.0 .0.write().await.sends().decrypt_file( + Ok(self.0 .0.sends().decrypt_file( send, Path::new(&encrypted_file_path), Path::new(&decrypted_file_path), diff --git a/crates/bitwarden-uniffi/src/vault/attachments.rs b/crates/bitwarden-uniffi/src/vault/attachments.rs index bdac7c97c..0084029d2 100644 --- a/crates/bitwarden-uniffi/src/vault/attachments.rs +++ b/crates/bitwarden-uniffi/src/vault/attachments.rs @@ -7,10 +7,10 @@ use crate::{Client, Result}; #[derive(uniffi::Object)] pub struct ClientAttachments(pub Arc); -#[uniffi::export(async_runtime = "tokio")] +#[uniffi::export] impl ClientAttachments { /// Encrypt an attachment file in memory - pub async fn encrypt_buffer( + pub fn encrypt_buffer( &self, cipher: Cipher, attachment: AttachmentView, @@ -19,22 +19,20 @@ impl ClientAttachments { Ok(self .0 .0 - .write() - .await .vault() .attachments() .encrypt_buffer(cipher, attachment, &buffer)?) } /// Encrypt an attachment file located in the file system - pub async fn encrypt_file( + pub fn encrypt_file( &self, cipher: Cipher, attachment: AttachmentView, decrypted_file_path: String, encrypted_file_path: String, ) -> Result { - Ok(self.0 .0.write().await.vault().attachments().encrypt_file( + Ok(self.0 .0.vault().attachments().encrypt_file( cipher, attachment, Path::new(&decrypted_file_path), @@ -42,7 +40,7 @@ impl ClientAttachments { )?) } /// Decrypt an attachment file in memory - pub async fn decrypt_buffer( + pub fn decrypt_buffer( &self, cipher: Cipher, attachment: Attachment, @@ -51,22 +49,20 @@ impl ClientAttachments { Ok(self .0 .0 - .write() - .await .vault() .attachments() .decrypt_buffer(cipher, attachment, &buffer)?) } /// Decrypt an attachment file located in the file system - pub async fn decrypt_file( + pub fn decrypt_file( &self, cipher: Cipher, attachment: Attachment, encrypted_file_path: String, decrypted_file_path: String, ) -> Result<()> { - Ok(self.0 .0.write().await.vault().attachments().decrypt_file( + Ok(self.0 .0.vault().attachments().decrypt_file( cipher, attachment, Path::new(&encrypted_file_path), diff --git a/crates/bitwarden-uniffi/src/vault/ciphers.rs b/crates/bitwarden-uniffi/src/vault/ciphers.rs index d637bc5fc..a8416434c 100644 --- a/crates/bitwarden-uniffi/src/vault/ciphers.rs +++ b/crates/bitwarden-uniffi/src/vault/ciphers.rs @@ -8,39 +8,25 @@ use crate::{Client, Result}; #[derive(uniffi::Object)] pub struct ClientCiphers(pub Arc); -#[uniffi::export(async_runtime = "tokio")] +#[uniffi::export] impl ClientCiphers { /// Encrypt cipher - pub async fn encrypt(&self, cipher_view: CipherView) -> Result { - Ok(self - .0 - .0 - .write() - .await - .vault() - .ciphers() - .encrypt(cipher_view)?) + pub fn encrypt(&self, cipher_view: CipherView) -> Result { + Ok(self.0 .0.vault().ciphers().encrypt(cipher_view)?) } /// Decrypt cipher - pub async fn decrypt(&self, cipher: Cipher) -> Result { - Ok(self.0 .0.write().await.vault().ciphers().decrypt(cipher)?) + pub fn decrypt(&self, cipher: Cipher) -> Result { + Ok(self.0 .0.vault().ciphers().decrypt(cipher)?) } /// Decrypt cipher list - pub async fn decrypt_list(&self, ciphers: Vec) -> Result> { - Ok(self - .0 - .0 - .write() - .await - .vault() - .ciphers() - .decrypt_list(ciphers)?) + pub fn decrypt_list(&self, ciphers: Vec) -> Result> { + Ok(self.0 .0.vault().ciphers().decrypt_list(ciphers)?) } /// Move a cipher to an organization, reencrypting the cipher key if necessary - pub async fn move_to_organization( + pub fn move_to_organization( &self, cipher: CipherView, organization_id: Uuid, @@ -48,8 +34,6 @@ impl ClientCiphers { Ok(self .0 .0 - .write() - .await .vault() .ciphers() .move_to_organization(cipher, organization_id)?) diff --git a/crates/bitwarden-uniffi/src/vault/collections.rs b/crates/bitwarden-uniffi/src/vault/collections.rs index f6cde84ab..47f84426b 100644 --- a/crates/bitwarden-uniffi/src/vault/collections.rs +++ b/crates/bitwarden-uniffi/src/vault/collections.rs @@ -7,29 +7,15 @@ use crate::{Client, Result}; #[derive(uniffi::Object)] pub struct ClientCollections(pub Arc); -#[uniffi::export(async_runtime = "tokio")] +#[uniffi::export] impl ClientCollections { /// Decrypt collection - pub async fn decrypt(&self, collection: Collection) -> Result { - Ok(self - .0 - .0 - .write() - .await - .vault() - .collections() - .decrypt(collection)?) + pub fn decrypt(&self, collection: Collection) -> Result { + Ok(self.0 .0.vault().collections().decrypt(collection)?) } /// Decrypt collection list - pub async fn decrypt_list(&self, collections: Vec) -> Result> { - Ok(self - .0 - .0 - .write() - .await - .vault() - .collections() - .decrypt_list(collections)?) + pub fn decrypt_list(&self, collections: Vec) -> Result> { + Ok(self.0 .0.vault().collections().decrypt_list(collections)?) } } diff --git a/crates/bitwarden-uniffi/src/vault/folders.rs b/crates/bitwarden-uniffi/src/vault/folders.rs index 5cceeca8b..3fa5935b5 100644 --- a/crates/bitwarden-uniffi/src/vault/folders.rs +++ b/crates/bitwarden-uniffi/src/vault/folders.rs @@ -7,27 +7,20 @@ use crate::{Client, Result}; #[derive(uniffi::Object)] pub struct ClientFolders(pub Arc); -#[uniffi::export(async_runtime = "tokio")] +#[uniffi::export] impl ClientFolders { /// Encrypt folder - pub async fn encrypt(&self, folder: FolderView) -> Result { - Ok(self.0 .0.write().await.vault().folders().encrypt(folder)?) + pub fn encrypt(&self, folder: FolderView) -> Result { + Ok(self.0 .0.vault().folders().encrypt(folder)?) } /// Decrypt folder - pub async fn decrypt(&self, folder: Folder) -> Result { - Ok(self.0 .0.write().await.vault().folders().decrypt(folder)?) + pub fn decrypt(&self, folder: Folder) -> Result { + Ok(self.0 .0.vault().folders().decrypt(folder)?) } /// Decrypt folder list - pub async fn decrypt_list(&self, folders: Vec) -> Result> { - Ok(self - .0 - .0 - .write() - .await - .vault() - .folders() - .decrypt_list(folders)?) + pub fn decrypt_list(&self, folders: Vec) -> Result> { + Ok(self.0 .0.vault().folders().decrypt_list(folders)?) } } diff --git a/crates/bitwarden-uniffi/src/vault/mod.rs b/crates/bitwarden-uniffi/src/vault/mod.rs index 62372523d..5259bc2bd 100644 --- a/crates/bitwarden-uniffi/src/vault/mod.rs +++ b/crates/bitwarden-uniffi/src/vault/mod.rs @@ -14,7 +14,7 @@ pub mod password_history; #[derive(uniffi::Object)] pub struct ClientVault(pub(crate) Arc); -#[uniffi::export(async_runtime = "tokio")] +#[uniffi::export] impl ClientVault { /// Folder operations pub fn folders(self: Arc) -> Arc { @@ -47,11 +47,7 @@ impl ClientVault { /// - A base32 encoded string /// - OTP Auth URI /// - Steam URI - pub async fn generate_totp( - &self, - key: String, - time: Option>, - ) -> Result { - Ok(self.0 .0.write().await.vault().generate_totp(key, time)?) + pub fn generate_totp(&self, key: String, time: Option>) -> Result { + Ok(self.0 .0.vault().generate_totp(key, time)?) } } diff --git a/crates/bitwarden-uniffi/src/vault/password_history.rs b/crates/bitwarden-uniffi/src/vault/password_history.rs index 863eddbac..12ef993be 100644 --- a/crates/bitwarden-uniffi/src/vault/password_history.rs +++ b/crates/bitwarden-uniffi/src/vault/password_history.rs @@ -7,32 +7,20 @@ use crate::{Client, Result}; #[derive(uniffi::Object)] pub struct ClientPasswordHistory(pub Arc); -#[uniffi::export(async_runtime = "tokio")] +#[uniffi::export] impl ClientPasswordHistory { /// Encrypt password history - pub async fn encrypt(&self, password_history: PasswordHistoryView) -> Result { + pub fn encrypt(&self, password_history: PasswordHistoryView) -> Result { Ok(self .0 .0 - .write() - .await .vault() .password_history() .encrypt(password_history)?) } /// Decrypt password history - pub async fn decrypt_list( - &self, - list: Vec, - ) -> Result> { - Ok(self - .0 - .0 - .write() - .await - .vault() - .password_history() - .decrypt_list(list)?) + pub fn decrypt_list(&self, list: Vec) -> Result> { + Ok(self.0 .0.vault().password_history().decrypt_list(list)?) } } diff --git a/crates/bitwarden/src/auth/auth_request.rs b/crates/bitwarden/src/auth/auth_request.rs index c5ab6537e..7d90b6a36 100644 --- a/crates/bitwarden/src/auth/auth_request.rs +++ b/crates/bitwarden/src/auth/auth_request.rs @@ -84,7 +84,7 @@ pub(crate) fn auth_request_decrypt_master_key( /// /// Encrypts the user key with a public key. pub(crate) fn approve_auth_request( - client: &mut Client, + client: &Client, public_key: String, ) -> Result { let public_key = AsymmetricPublicCryptoKey::from_der(&STANDARD.decode(public_key)?)?; @@ -130,7 +130,7 @@ mod tests { #[test] fn test_approve() { - let mut client = Client::new(None); + let client = Client::new(None); let master_key = bitwarden_crypto::MasterKey::derive( "asdfasdfasdf".as_bytes(), @@ -154,7 +154,7 @@ mod tests { let fingerprint = fingerprint("test@bitwarden.com", &pbkey).unwrap(); assert_eq!(fingerprint, "childless-unfair-prowler-dropbox-designate"); - approve_auth_request(&mut client, public_key.to_owned()).unwrap(); + approve_auth_request(&client, public_key.to_owned()).unwrap(); } #[tokio::test] @@ -205,7 +205,7 @@ mod tests { let private_key = "2.yN7l00BOlUE0Sb0M//Q53w==|EwKG/BduQRQ33Izqc/ogoBROIoI5dmgrxSo82sgzgAMIBt3A2FZ9vPRMY+GWT85JiqytDitGR3TqwnFUBhKUpRRAq4x7rA6A1arHrFp5Tp1p21O3SfjtvB3quiOKbqWk6ZaU1Np9HwqwAecddFcB0YyBEiRX3VwF2pgpAdiPbSMuvo2qIgyob0CUoC/h4Bz1be7Qa7B0Xw9/fMKkB1LpOm925lzqosyMQM62YpMGkjMsbZz0uPopu32fxzDWSPr+kekNNyLt9InGhTpxLmq1go/pXR2uw5dfpXc5yuta7DB0EGBwnQ8Vl5HPdDooqOTD9I1jE0mRyuBpWTTI3FRnu3JUh3rIyGBJhUmHqGZvw2CKdqHCIrQeQkkEYqOeJRJVdBjhv5KGJifqT3BFRwX/YFJIChAQpebNQKXe/0kPivWokHWwXlDB7S7mBZzhaAPidZvnuIhalE2qmTypDwHy22FyqV58T8MGGMchcASDi/QXI6kcdpJzPXSeU9o+NC68QDlOIrMVxKFeE7w7PvVmAaxEo0YwmuAzzKy9QpdlK0aab/xEi8V4iXj4hGepqAvHkXIQd+r3FNeiLfllkb61p6WTjr5urcmDQMR94/wYoilpG5OlybHdbhsYHvIzYoLrC7fzl630gcO6t4nM24vdB6Ymg9BVpEgKRAxSbE62Tqacxqnz9AcmgItb48NiR/He3n3ydGjPYuKk/ihZMgEwAEZvSlNxYONSbYrIGDtOY+8Nbt6KiH3l06wjZW8tcmFeVlWv+tWotnTY9IqlAfvNVTjtsobqtQnvsiDjdEVtNy/s2ci5TH+NdZluca2OVEr91Wayxh70kpM6ib4UGbfdmGgCo74gtKvKSJU0rTHakQ5L9JlaSDD5FamBRyI0qfL43Ad9qOUZ8DaffDCyuaVyuqk7cz9HwmEmvWU3VQ+5t06n/5kRDXttcw8w+3qClEEdGo1KeENcnXCB32dQe3tDTFpuAIMLqwXs6FhpawfZ5kPYvLPczGWaqftIs/RXJ/EltGc0ugw2dmTLpoQhCqrcKEBDoYVk0LDZKsnzitOGdi9mOWse7Se8798ib1UsHFUjGzISEt6upestxOeupSTOh0v4+AjXbDzRUyogHww3V+Bqg71bkcMxtB+WM+pn1XNbVTyl9NR040nhP7KEf6e9ruXAtmrBC2ah5cFEpLIot77VFZ9ilLuitSz+7T8n1yAh1IEG6xxXxninAZIzi2qGbH69O5RSpOJuJTv17zTLJQIIc781JwQ2TTwTGnx5wZLbffhCasowJKd2EVcyMJyhz6ru0PvXWJ4hUdkARJs3Xu8dus9a86N8Xk6aAPzBDqzYb1vyFIfBxP0oO8xFHgd30Cgmz8UrSE3qeWRrF8ftrI6xQnFjHBGWD/JWSvd6YMcQED0aVuQkuNW9ST/DzQThPzRfPUoiL10yAmV7Ytu4fR3x2sF0Yfi87YhHFuCMpV/DsqxmUizyiJuD938eRcH8hzR/VO53Qo3UIsqOLcyXtTv6THjSlTopQ+JOLOnHm1w8dzYbLN44OG44rRsbihMUQp+wUZ6bsI8rrOnm9WErzkbQFbrfAINdoCiNa6cimYIjvvnMTaFWNymqY1vZxGztQiMiHiHYwTfwHTXrb9j0uPM=|09J28iXv9oWzYtzK2LBT6Yht4IT4MijEkk0fwFdrVQ4="; // Initialize an existing client which is unlocked - let mut existing_device = Client::new(None); + let existing_device = Client::new(None); let master_key = bitwarden_crypto::MasterKey::derive("asdfasdfasdf".as_bytes(), email.as_bytes(), &kdf) @@ -216,11 +216,11 @@ mod tests { .unwrap(); // Initialize a new device which will request to be logged in - let mut new_device = Client::new(None); + let new_device = Client::new(None); // Initialize an auth request, and approve it on the existing device let auth_req = new_auth_request(email).unwrap(); - let approved_req = approve_auth_request(&mut existing_device, auth_req.public_key).unwrap(); + let approved_req = approve_auth_request(&existing_device, auth_req.public_key).unwrap(); // Unlock the vault using the approved request new_device diff --git a/crates/bitwarden/src/auth/client_auth.rs b/crates/bitwarden/src/auth/client_auth.rs index 14261efee..32b429047 100644 --- a/crates/bitwarden/src/auth/client_auth.rs +++ b/crates/bitwarden/src/auth/client_auth.rs @@ -27,17 +27,17 @@ use crate::{ }; pub struct ClientAuth<'a> { - pub(crate) client: &'a mut crate::Client, + pub(crate) client: &'a crate::Client, } impl<'a> ClientAuth<'a> { - pub async fn renew_token(&mut self) -> Result<()> { + pub async fn renew_token(&self) -> Result<()> { renew_token(self.client).await } #[cfg(feature = "secrets")] pub async fn login_access_token( - &mut self, + &self, input: &AccessTokenLoginRequest, ) -> Result { login_access_token(self.client, input).await @@ -74,7 +74,7 @@ impl<'a> ClientAuth<'a> { } pub fn make_register_tde_keys( - &mut self, + &self, email: String, org_public_key: String, remember_device: bool, @@ -82,11 +82,11 @@ impl<'a> ClientAuth<'a> { make_register_tde_keys(self.client, email, org_public_key, remember_device) } - pub async fn register(&mut self, input: &RegisterRequest) -> Result<()> { + pub async fn register(&self, input: &RegisterRequest) -> Result<()> { register(self.client, input).await } - pub async fn prelogin(&mut self, email: String) -> Result { + pub async fn prelogin(&self, email: String) -> Result { use crate::auth::login::{parse_prelogin, request_prelogin}; let response = request_prelogin(self.client, email).await?; @@ -94,20 +94,17 @@ impl<'a> ClientAuth<'a> { } pub async fn login_password( - &mut self, + &self, input: &PasswordLoginRequest, ) -> Result { login_password(self.client, input).await } - pub async fn login_api_key( - &mut self, - input: &ApiKeyLoginRequest, - ) -> Result { + pub async fn login_api_key(&self, input: &ApiKeyLoginRequest) -> Result { login_api_key(self.client, input).await } - pub async fn send_two_factor_email(&mut self, tf: &TwoFactorEmailRequest) -> Result<()> { + pub async fn send_two_factor_email(&self, tf: &TwoFactorEmailRequest) -> Result<()> { send_two_factor_email(self.client, tf).await } @@ -127,7 +124,7 @@ impl<'a> ClientAuth<'a> { new_auth_request(email) } - pub fn approve_auth_request(&mut self, public_key: String) -> Result { + pub fn approve_auth_request(&self, public_key: String) -> Result { approve_auth_request(self.client, public_key) } @@ -139,7 +136,7 @@ impl<'a> ClientAuth<'a> { #[cfg(feature = "internal")] impl<'a> ClientAuth<'a> { pub async fn login_device( - &mut self, + &self, email: String, device_identifier: String, ) -> Result { @@ -148,7 +145,7 @@ impl<'a> ClientAuth<'a> { send_new_auth_request(self.client, email, device_identifier).await } - pub async fn login_device_complete(&mut self, auth_req: NewAuthRequestResponse) -> Result<()> { + pub async fn login_device_complete(&self, auth_req: NewAuthRequestResponse) -> Result<()> { use crate::auth::login::complete_auth_request; complete_auth_request(self.client, auth_req).await @@ -167,7 +164,7 @@ fn trust_device(client: &Client) -> Result { } impl<'a> Client { - pub fn auth(&'a mut self) -> ClientAuth<'a> { + pub fn auth(&'a self) -> ClientAuth<'a> { ClientAuth { client: self } } } diff --git a/crates/bitwarden/src/auth/login/access_token.rs b/crates/bitwarden/src/auth/login/access_token.rs index a376eb0c3..25d8ffb5d 100644 --- a/crates/bitwarden/src/auth/login/access_token.rs +++ b/crates/bitwarden/src/auth/login/access_token.rs @@ -21,7 +21,7 @@ use crate::{ }; pub(crate) async fn login_access_token( - client: &mut Client, + client: &Client, input: &AccessTokenLoginRequest, ) -> Result { //info!("api key logging in"); @@ -99,17 +99,17 @@ pub(crate) async fn login_access_token( } async fn request_access_token( - client: &mut Client, + client: &Client, input: &AccessToken, ) -> Result { let config = client.get_api_configurations().await; AccessTokenRequest::new(input.access_token_id, &input.client_secret) - .send(config) + .send(&config) .await } fn load_tokens_from_state( - client: &mut Client, + client: &Client, state_file: &Path, access_token: &AccessToken, ) -> Result { diff --git a/crates/bitwarden/src/auth/login/api_key.rs b/crates/bitwarden/src/auth/login/api_key.rs index 3882931ba..92f1c76b9 100644 --- a/crates/bitwarden/src/auth/login/api_key.rs +++ b/crates/bitwarden/src/auth/login/api_key.rs @@ -15,7 +15,7 @@ use crate::{ }; pub(crate) async fn login_api_key( - client: &mut Client, + client: &Client, input: &ApiKeyLoginRequest, ) -> Result { //info!("api key logging in"); @@ -58,12 +58,12 @@ pub(crate) async fn login_api_key( } async fn request_api_identity_tokens( - client: &mut Client, + client: &Client, input: &ApiKeyLoginRequest, ) -> Result { let config = client.get_api_configurations().await; ApiTokenRequest::new(&input.client_id, &input.client_secret) - .send(config) + .send(&config) .await } diff --git a/crates/bitwarden/src/auth/login/auth_request.rs b/crates/bitwarden/src/auth/login/auth_request.rs index 6a8005b6d..380a49b9d 100644 --- a/crates/bitwarden/src/auth/login/auth_request.rs +++ b/crates/bitwarden/src/auth/login/auth_request.rs @@ -27,7 +27,7 @@ pub struct NewAuthRequestResponse { } pub(crate) async fn send_new_auth_request( - client: &mut Client, + client: &Client, email: String, device_identifier: String, ) -> Result { @@ -56,7 +56,7 @@ pub(crate) async fn send_new_auth_request( } pub(crate) async fn complete_auth_request( - client: &mut Client, + client: &Client, auth_req: NewAuthRequestResponse, ) -> Result<()> { let config = client.get_api_configurations().await; @@ -81,7 +81,7 @@ pub(crate) async fn complete_auth_request( config.device_type, &auth_req.device_identifier, ) - .send(config) + .send(&config) .await?; if let IdentityTokenResponse::Authenticated(r) = response { diff --git a/crates/bitwarden/src/auth/login/mod.rs b/crates/bitwarden/src/auth/login/mod.rs index 7fac112f5..9c9c711b9 100644 --- a/crates/bitwarden/src/auth/login/mod.rs +++ b/crates/bitwarden/src/auth/login/mod.rs @@ -45,7 +45,7 @@ pub use access_token::{AccessTokenLoginRequest, AccessTokenLoginResponse}; #[cfg(feature = "internal")] pub(crate) async fn request_prelogin( - client: &mut Client, + client: &Client, email: String, ) -> Result { let request_model = PreloginRequestModel::new(email); diff --git a/crates/bitwarden/src/auth/login/password.rs b/crates/bitwarden/src/auth/login/password.rs index 4960b498b..bbbae3d1a 100644 --- a/crates/bitwarden/src/auth/login/password.rs +++ b/crates/bitwarden/src/auth/login/password.rs @@ -19,7 +19,7 @@ use crate::{ #[cfg(feature = "internal")] pub(crate) async fn login_password( - client: &mut Client, + client: &Client, input: &PasswordLoginRequest, ) -> Result { use bitwarden_core::require; @@ -62,7 +62,7 @@ pub(crate) async fn login_password( #[cfg(feature = "internal")] async fn request_identity_tokens( - client: &mut Client, + client: &Client, input: &PasswordLoginRequest, password_hash: &str, ) -> Result { @@ -76,7 +76,7 @@ async fn request_identity_tokens( "b86dd6ab-4265-4ddf-a7f1-eb28d5677f33", &input.two_factor, ) - .send(config) + .send(&config) .await } diff --git a/crates/bitwarden/src/auth/login/two_factor.rs b/crates/bitwarden/src/auth/login/two_factor.rs index c8f0cc55b..197ff77a1 100644 --- a/crates/bitwarden/src/auth/login/two_factor.rs +++ b/crates/bitwarden/src/auth/login/two_factor.rs @@ -16,7 +16,7 @@ pub struct TwoFactorEmailRequest { } pub(crate) async fn send_two_factor_email( - client: &mut Client, + client: &Client, input: &TwoFactorEmailRequest, ) -> Result<()> { // TODO: This should be resolved from the client diff --git a/crates/bitwarden/src/auth/password/validate.rs b/crates/bitwarden/src/auth/password/validate.rs index 5502ecc55..2a077418a 100644 --- a/crates/bitwarden/src/auth/password/validate.rs +++ b/crates/bitwarden/src/auth/password/validate.rs @@ -13,12 +13,9 @@ pub(crate) fn validate_password( password: String, password_hash: String, ) -> Result { - let login_method = client - .login_method - .as_ref() - .ok_or(Error::NotAuthenticated)?; + let login_method = client.get_login_method().ok_or(Error::NotAuthenticated)?; - if let LoginMethod::User(login_method) = login_method { + if let LoginMethod::User(login_method) = login_method.as_ref() { match login_method { UserLoginMethod::Username { email, kdf, .. } | UserLoginMethod::ApiKey { email, kdf, .. } => { @@ -45,12 +42,9 @@ pub(crate) fn validate_password_user_key( ) -> Result { use bitwarden_core::VaultLocked; - let login_method = client - .login_method - .as_ref() - .ok_or(Error::NotAuthenticated)?; + let login_method = client.get_login_method().ok_or(Error::NotAuthenticated)?; - if let LoginMethod::User(login_method) = login_method { + if let LoginMethod::User(login_method) = login_method.as_ref() { match login_method { UserLoginMethod::Username { email, kdf, .. } | UserLoginMethod::ApiKey { email, kdf, .. } => { @@ -86,7 +80,7 @@ mod tests { use crate::client::{Client, Kdf, LoginMethod, UserLoginMethod}; - let mut client = Client::new(None); + let client = Client::new(None); client.set_login_method(LoginMethod::User(UserLoginMethod::Username { email: "test@bitwarden.com".to_string(), kdf: Kdf::PBKDF2 { @@ -110,7 +104,7 @@ mod tests { use crate::client::{Client, Kdf, LoginMethod, UserLoginMethod}; - let mut client = Client::new(None); + let client = Client::new(None); let password = "asdfasdfasdf"; let email = "test@bitwarden.com"; @@ -150,7 +144,7 @@ mod tests { use crate::client::{Client, Kdf, LoginMethod, UserLoginMethod}; - let mut client = Client::new(None); + let client = Client::new(None); let password = b"asdfasdfasdf"; let email = "test@bitwarden.com"; diff --git a/crates/bitwarden/src/auth/register.rs b/crates/bitwarden/src/auth/register.rs index 06313d42b..5ca995ead 100644 --- a/crates/bitwarden/src/auth/register.rs +++ b/crates/bitwarden/src/auth/register.rs @@ -18,7 +18,7 @@ pub struct RegisterRequest { } /// Half baked implementation of user registration -pub(super) async fn register(client: &mut Client, req: &RegisterRequest) -> Result<()> { +pub(super) async fn register(client: &Client, req: &RegisterRequest) -> Result<()> { let config = client.get_api_configurations().await; let kdf = Kdf::default(); diff --git a/crates/bitwarden/src/auth/renew.rs b/crates/bitwarden/src/auth/renew.rs index 783494ae2..01108cf2c 100644 --- a/crates/bitwarden/src/auth/renew.rs +++ b/crates/bitwarden/src/auth/renew.rs @@ -9,29 +9,40 @@ use crate::{ secrets_manager::state::{self, ClientState}, }; -pub(crate) async fn renew_token(client: &mut Client) -> Result<()> { +pub(crate) async fn renew_token(client: &Client) -> Result<()> { const TOKEN_RENEW_MARGIN_SECONDS: i64 = 5 * 60; - if let (Some(expires), Some(login_method)) = (&client.token_expires_on, &client.login_method) { + let tokens = client + .tokens + .read() + .expect("RwLock is not poisoned") + .clone(); + let login_method = client + .login_method + .read() + .expect("RwLock is not poisoned") + .clone(); + + if let (Some(expires), Some(login_method)) = (tokens.expires_on, login_method) { if Utc::now().timestamp() < expires - TOKEN_RENEW_MARGIN_SECONDS { return Ok(()); } - let res = match login_method { + let config = client + .__api_configurations + .read() + .expect("RwLock is not poisoned") + .clone(); + + let res = match login_method.as_ref() { #[cfg(feature = "internal")] LoginMethod::User(u) => match u { UserLoginMethod::Username { client_id, .. } => { - let refresh = client - .refresh_token - .as_deref() - .ok_or(Error::NotAuthenticated)?; + let refresh = tokens.refresh_token.ok_or(Error::NotAuthenticated)?; - crate::auth::api::request::RenewTokenRequest::new( - refresh.to_owned(), - client_id.to_owned(), - ) - .send(&client.__api_configurations) - .await? + crate::auth::api::request::RenewTokenRequest::new(refresh, client_id.to_owned()) + .send(&config) + .await? } UserLoginMethod::ApiKey { client_id, @@ -39,7 +50,7 @@ pub(crate) async fn renew_token(client: &mut Client) -> Result<()> { .. } => { ApiTokenRequest::new(client_id, client_secret) - .send(&client.__api_configurations) + .send(&config) .await? } }, @@ -53,7 +64,7 @@ pub(crate) async fn renew_token(client: &mut Client) -> Result<()> { access_token.access_token_id, &access_token.client_secret, ) - .send(&client.__api_configurations) + .send(&config) .await?; if let (IdentityTokenResponse::Payload(r), Some(state_file), Ok(enc_settings)) = diff --git a/crates/bitwarden/src/auth/tde.rs b/crates/bitwarden/src/auth/tde.rs index 02f36583c..e1ddb0921 100644 --- a/crates/bitwarden/src/auth/tde.rs +++ b/crates/bitwarden/src/auth/tde.rs @@ -10,7 +10,7 @@ use crate::{error::Result, Client}; /// generated user key, and encrypts the user key with the organization public key for admin /// password reset. If remember_device is true, it also generates a device key. pub(super) fn make_register_tde_keys( - client: &mut Client, + client: &Client, email: String, org_public_key: String, remember_device: bool, diff --git a/crates/bitwarden/src/client/client.rs b/crates/bitwarden/src/client/client.rs index 0d2f30864..31e32f034 100644 --- a/crates/bitwarden/src/client/client.rs +++ b/crates/bitwarden/src/client/client.rs @@ -1,4 +1,7 @@ -use std::path::PathBuf; +use std::{ + path::PathBuf, + sync::{Arc, RwLock}, +}; use bitwarden_core::VaultLocked; #[cfg(feature = "internal")] @@ -21,13 +24,10 @@ use crate::{ error::Result, }; -#[derive(Debug)] +#[derive(Debug, Clone)] pub(crate) struct ApiConfigurations { pub identity: bitwarden_api_identity::apis::configuration::Configuration, pub api: bitwarden_api_api::apis::configuration::Configuration, - /// Reqwest client useable for external integrations like email forwarders, HIBP. - #[allow(unused)] - pub external_client: reqwest::Client, pub device_type: DeviceType, } @@ -66,23 +66,37 @@ pub(crate) enum ServiceAccountLoginMethod { }, } +#[derive(Debug, Default, Clone)] +pub(crate) struct Tokens { + // These two fields are always written to, but they are not read + // from the secrets manager SDK. + #[cfg_attr(not(feature = "internal"), allow(dead_code))] + access_token: Option, + pub(crate) expires_on: Option, + + #[cfg_attr(not(feature = "internal"), allow(dead_code))] + pub(crate) refresh_token: Option, +} + /// The main struct to interact with the Bitwarden SDK. #[derive(Debug)] pub struct Client { - token: Option, - pub(crate) refresh_token: Option, - pub(crate) token_expires_on: Option, - pub(crate) login_method: Option, + pub(crate) tokens: RwLock, + pub(crate) login_method: RwLock>>, #[cfg(feature = "internal")] - flags: Flags, + flags: RwLock, /// Use Client::get_api_configurations() to access this. /// It should only be used directly in renew_token #[doc(hidden)] - pub(crate) __api_configurations: ApiConfigurations, + pub(crate) __api_configurations: RwLock>, - encryption_settings: Option, + /// Reqwest client useable for external integrations like email forwarders, HIBP. + #[allow(unused)] + pub(crate) external_client: reqwest::Client, + + encryption_settings: RwLock>>, } impl Client { @@ -135,144 +149,192 @@ impl Client { }; Self { - token: None, - refresh_token: None, - token_expires_on: None, - login_method: None, + tokens: RwLock::new(Tokens::default()), + login_method: RwLock::new(None), #[cfg(feature = "internal")] - flags: Flags::default(), - __api_configurations: ApiConfigurations { + flags: RwLock::new(Flags::default()), + __api_configurations: RwLock::new(Arc::new(ApiConfigurations { identity, api, - external_client, device_type: settings.device_type, - }, - encryption_settings: None, + })), + external_client, + encryption_settings: RwLock::new(None), } } #[cfg(feature = "internal")] - pub fn load_flags(&mut self, flags: std::collections::HashMap) { - self.flags = Flags::load_from_map(flags); + pub fn load_flags(&self, flags: std::collections::HashMap) { + *self.flags.write().expect("RwLock is not poisoned") = Flags::load_from_map(flags); } #[cfg(feature = "internal")] - pub(crate) fn get_flags(&self) -> &Flags { - &self.flags + pub(crate) fn get_flags(&self) -> Flags { + self.flags.read().expect("RwLock is not poisoned").clone() } - pub(crate) async fn get_api_configurations(&mut self) -> &ApiConfigurations { + pub(crate) async fn get_api_configurations(&self) -> Arc { // At the moment we ignore the error result from the token renewal, if it fails, // the token will end up expiring and the next operation is going to fail anyway. self.auth().renew_token().await.ok(); - &self.__api_configurations + self.__api_configurations + .read() + .expect("RwLock is not poisoned") + .clone() } #[cfg(feature = "internal")] pub(crate) fn get_http_client(&self) -> &reqwest::Client { - &self.__api_configurations.external_client + &self.external_client } #[cfg(feature = "internal")] - pub(crate) fn get_login_method(&self) -> &Option { - &self.login_method + pub(crate) fn get_login_method(&self) -> Option> { + self.login_method + .read() + .expect("RwLock is not poisoned") + .clone() } pub fn get_access_token_organization(&self) -> Option { - match self.login_method { + match self + .login_method + .read() + .expect("RwLock is not poisoned") + .as_deref() + { Some(LoginMethod::ServiceAccount(ServiceAccountLoginMethod::AccessToken { organization_id, .. - })) => Some(organization_id), + })) => Some(*organization_id), _ => None, } } - pub(crate) fn get_encryption_settings(&self) -> Result<&EncryptionSettings, VaultLocked> { - self.encryption_settings.as_ref().ok_or(VaultLocked) + pub(crate) fn get_encryption_settings(&self) -> Result, VaultLocked> { + self.encryption_settings + .read() + .expect("RwLock is not poisoned") + .clone() + .ok_or(VaultLocked) } - pub(crate) fn set_login_method(&mut self, login_method: LoginMethod) { + pub(crate) fn set_login_method(&self, login_method: LoginMethod) { use log::debug; debug! {"setting login method: {:#?}", login_method} - self.login_method = Some(login_method); + *self.login_method.write().expect("RwLock is not poisoned") = Some(Arc::new(login_method)); } - pub(crate) fn set_tokens( - &mut self, - token: String, - refresh_token: Option, - expires_in: u64, - ) { - self.token = Some(token.clone()); - self.refresh_token = refresh_token; - self.token_expires_on = Some(Utc::now().timestamp() + expires_in as i64); - self.__api_configurations.identity.oauth_access_token = Some(token.clone()); - self.__api_configurations.api.oauth_access_token = Some(token); + pub(crate) fn set_tokens(&self, token: String, refresh_token: Option, expires_in: u64) { + *self.tokens.write().expect("RwLock is not poisoned") = Tokens { + access_token: Some(token.clone()), + expires_on: Some(Utc::now().timestamp() + expires_in as i64), + refresh_token, + }; + let mut guard = self + .__api_configurations + .write() + .expect("RwLock is not poisoned"); + + let mut inner: ApiConfigurations = guard.as_ref().clone(); + inner.identity.oauth_access_token = Some(token.clone()); + inner.api.oauth_access_token = Some(token); + + *guard = Arc::new(inner); } - #[cfg(feature = "internal")] pub fn is_authed(&self) -> bool { - self.token.is_some() || self.login_method.is_some() + let is_token_set = self + .tokens + .read() + .expect("RwLock is not poisoned") + .access_token + .is_some(); + let is_login_method_set = self + .login_method + .read() + .expect("RwLock is not poisoned") + .is_some(); + + is_token_set || is_login_method_set } #[cfg(feature = "internal")] pub(crate) fn initialize_user_crypto_master_key( - &mut self, + &self, master_key: MasterKey, user_key: EncString, private_key: EncString, - ) -> Result<&EncryptionSettings> { - Ok(self.encryption_settings.insert(EncryptionSettings::new( + ) -> Result<()> { + *self + .encryption_settings + .write() + .expect("RwLock is not poisoned") = Some(Arc::new(EncryptionSettings::new( master_key, user_key, private_key, - )?)) + )?)); + + Ok(()) } #[cfg(feature = "internal")] pub(crate) fn initialize_user_crypto_decrypted_key( - &mut self, + &self, user_key: SymmetricCryptoKey, private_key: EncString, - ) -> Result<&EncryptionSettings> { - Ok(self + ) -> Result<()> { + *self .encryption_settings - .insert(EncryptionSettings::new_decrypted_key( - user_key, - private_key, - )?)) + .write() + .expect("RwLock is not poisoned") = Some(Arc::new( + EncryptionSettings::new_decrypted_key(user_key, private_key)?, + )); + + Ok(()) } #[cfg(feature = "internal")] pub(crate) fn initialize_user_crypto_pin( - &mut self, + &self, pin_key: MasterKey, pin_protected_user_key: EncString, private_key: EncString, - ) -> Result<&EncryptionSettings> { + ) -> Result<()> { let decrypted_user_key = pin_key.decrypt_user_key(pin_protected_user_key)?; self.initialize_user_crypto_decrypted_key(decrypted_user_key, private_key) } - pub(crate) fn initialize_crypto_single_key( - &mut self, - key: SymmetricCryptoKey, - ) -> &EncryptionSettings { - self.encryption_settings - .insert(EncryptionSettings::new_single_key(key)) + pub(crate) fn initialize_crypto_single_key(&self, key: SymmetricCryptoKey) { + *self + .encryption_settings + .write() + .expect("RwLock is not poisoned") = + Some(Arc::new(EncryptionSettings::new_single_key(key))); } #[cfg(feature = "internal")] pub(crate) fn initialize_org_crypto( - &mut self, + &self, org_keys: Vec<(Uuid, AsymmetricEncString)>, - ) -> Result<&EncryptionSettings> { - let enc = self.encryption_settings.as_mut().ok_or(VaultLocked)?; + ) -> Result> { + let mut guard = self + .encryption_settings + .write() + .expect("RwLock is not poisoned"); + + let Some(enc) = guard.as_mut() else { + return Err(VaultLocked.into()); + }; + let mut enc: EncryptionSettings = enc.as_ref().clone(); enc.set_org_keys(org_keys)?; - Ok(&*enc) + let enc = Arc::new(enc); + + *guard = Some(enc.clone()); + + Ok(enc) } } diff --git a/crates/bitwarden/src/client/encryption_settings.rs b/crates/bitwarden/src/client/encryption_settings.rs index 0cf91e45d..f92dd5f09 100644 --- a/crates/bitwarden/src/client/encryption_settings.rs +++ b/crates/bitwarden/src/client/encryption_settings.rs @@ -8,6 +8,7 @@ use uuid::Uuid; #[cfg(feature = "internal")] use crate::error::Result; +#[derive(Clone)] pub struct EncryptionSettings { user_key: SymmetricCryptoKey, pub(crate) private_key: Option, @@ -70,7 +71,7 @@ impl EncryptionSettings { pub(crate) fn set_org_keys( &mut self, org_enc_keys: Vec<(Uuid, AsymmetricEncString)>, - ) -> Result<&mut Self> { + ) -> Result<&Self> { use bitwarden_core::VaultLocked; use bitwarden_crypto::KeyDecryptable; diff --git a/crates/bitwarden/src/client/test_accounts.rs b/crates/bitwarden/src/client/test_accounts.rs index 22927d7d8..7c24df0ac 100644 --- a/crates/bitwarden/src/client/test_accounts.rs +++ b/crates/bitwarden/src/client/test_accounts.rs @@ -12,19 +12,17 @@ use crate::{ impl Client { pub async fn init_test_account(account: TestAccount) -> Self { - let mut client = Client::new(None); + let client = Client::new(None); client.load_flags(HashMap::from([( "enableCipherKeyEncryption".to_owned(), true, )])); - initialize_user_crypto(&mut client, account.user) - .await - .unwrap(); + initialize_user_crypto(&client, account.user).await.unwrap(); if let Some(org) = account.org { - initialize_org_crypto(&mut client, org).await.unwrap(); + initialize_org_crypto(&client, org).await.unwrap(); } client diff --git a/crates/bitwarden/src/mobile/client_crypto.rs b/crates/bitwarden/src/mobile/client_crypto.rs index 30e88332a..88e359844 100644 --- a/crates/bitwarden/src/mobile/client_crypto.rs +++ b/crates/bitwarden/src/mobile/client_crypto.rs @@ -13,51 +13,48 @@ use crate::{ }; pub struct ClientCrypto<'a> { - pub(crate) client: &'a mut crate::Client, + pub(crate) client: &'a crate::Client, } impl<'a> ClientCrypto<'a> { #[cfg(feature = "internal")] - pub async fn initialize_user_crypto(&mut self, req: InitUserCryptoRequest) -> Result<()> { + pub async fn initialize_user_crypto(&self, req: InitUserCryptoRequest) -> Result<()> { initialize_user_crypto(self.client, req).await } #[cfg(feature = "internal")] - pub async fn initialize_org_crypto(&mut self, req: InitOrgCryptoRequest) -> Result<()> { + pub async fn initialize_org_crypto(&self, req: InitOrgCryptoRequest) -> Result<()> { initialize_org_crypto(self.client, req).await } #[cfg(feature = "internal")] - pub async fn get_user_encryption_key(&mut self) -> Result { + pub async fn get_user_encryption_key(&self) -> Result { get_user_encryption_key(self.client).await } #[cfg(feature = "internal")] - pub fn update_password(&mut self, new_password: String) -> Result { + pub fn update_password(&self, new_password: String) -> Result { update_password(self.client, new_password) } #[cfg(feature = "internal")] - pub fn derive_pin_key(&mut self, pin: String) -> Result { + pub fn derive_pin_key(&self, pin: String) -> Result { derive_pin_key(self.client, pin) } #[cfg(feature = "internal")] - pub fn derive_pin_user_key(&mut self, encrypted_pin: EncString) -> Result { + pub fn derive_pin_user_key(&self, encrypted_pin: EncString) -> Result { derive_pin_user_key(self.client, encrypted_pin) } #[cfg(feature = "internal")] - pub fn enroll_admin_password_reset( - &mut self, - public_key: String, - ) -> Result { + pub fn enroll_admin_password_reset(&self, public_key: String) -> Result { enroll_admin_password_reset(self.client, public_key) } } impl<'a> Client { - pub fn crypto(&'a mut self) -> ClientCrypto<'a> { + pub fn crypto(&'a self) -> ClientCrypto<'a> { ClientCrypto { client: self } } } diff --git a/crates/bitwarden/src/mobile/crypto.rs b/crates/bitwarden/src/mobile/crypto.rs index ea5a70cce..fde041e5f 100644 --- a/crates/bitwarden/src/mobile/crypto.rs +++ b/crates/bitwarden/src/mobile/crypto.rs @@ -86,7 +86,7 @@ pub enum AuthRequestMethod { } #[cfg(feature = "internal")] -pub async fn initialize_user_crypto(client: &mut Client, req: InitUserCryptoRequest) -> Result<()> { +pub async fn initialize_user_crypto(client: &Client, req: InitUserCryptoRequest) -> Result<()> { use bitwarden_crypto::DeviceKey; use crate::auth::{auth_request_decrypt_master_key, auth_request_decrypt_user_key}; @@ -165,18 +165,16 @@ pub struct InitOrgCryptoRequest { } #[cfg(feature = "internal")] -pub async fn initialize_org_crypto(client: &mut Client, req: InitOrgCryptoRequest) -> Result<()> { +pub async fn initialize_org_crypto(client: &Client, req: InitOrgCryptoRequest) -> Result<()> { let organization_keys = req.organization_keys.into_iter().collect(); client.initialize_org_crypto(organization_keys)?; Ok(()) } #[cfg(feature = "internal")] -pub async fn get_user_encryption_key(client: &mut Client) -> Result { - let user_key = client - .get_encryption_settings()? - .get_key(&None) - .ok_or(VaultLocked)?; +pub async fn get_user_encryption_key(client: &Client) -> Result { + let enc = client.get_encryption_settings()?; + let user_key = enc.get_key(&None).ok_or(VaultLocked)?; Ok(user_key.to_base64()) } @@ -192,22 +190,14 @@ pub struct UpdatePasswordResponse { new_key: EncString, } -pub fn update_password( - client: &mut Client, - new_password: String, -) -> Result { - let user_key = client - .get_encryption_settings()? - .get_key(&None) - .ok_or(VaultLocked)?; +pub fn update_password(client: &Client, new_password: String) -> Result { + let enc = client.get_encryption_settings()?; + let user_key = enc.get_key(&None).ok_or(VaultLocked)?; - let login_method = client - .login_method - .as_ref() - .ok_or(Error::NotAuthenticated)?; + let login_method = client.get_login_method().ok_or(Error::NotAuthenticated)?; // Derive a new master key from password - let new_master_key = match login_method { + let new_master_key = match login_method.as_ref() { LoginMethod::User( UserLoginMethod::Username { email, kdf, .. } | UserLoginMethod::ApiKey { email, kdf, .. }, @@ -240,18 +230,13 @@ pub struct DerivePinKeyResponse { } #[cfg(feature = "internal")] -pub fn derive_pin_key(client: &mut Client, pin: String) -> Result { - let user_key = client - .get_encryption_settings()? - .get_key(&None) - .ok_or(VaultLocked)?; +pub fn derive_pin_key(client: &Client, pin: String) -> Result { + let enc = client.get_encryption_settings()?; + let user_key = enc.get_key(&None).ok_or(VaultLocked)?; - let login_method = client - .login_method - .as_ref() - .ok_or(Error::NotAuthenticated)?; + let login_method = client.get_login_method().ok_or(Error::NotAuthenticated)?; - let pin_protected_user_key = derive_pin_protected_user_key(&pin, login_method, user_key)?; + let pin_protected_user_key = derive_pin_protected_user_key(&pin, &login_method, user_key)?; Ok(DerivePinKeyResponse { pin_protected_user_key, @@ -260,19 +245,14 @@ pub fn derive_pin_key(client: &mut Client, pin: String) -> Result Result { - let user_key = client - .get_encryption_settings()? - .get_key(&None) - .ok_or(VaultLocked)?; +pub fn derive_pin_user_key(client: &Client, encrypted_pin: EncString) -> Result { + let enc = client.get_encryption_settings()?; + let user_key = enc.get_key(&None).ok_or(VaultLocked)?; let pin: String = encrypted_pin.decrypt_with_key(user_key)?; - let login_method = client - .login_method - .as_ref() - .ok_or(Error::NotAuthenticated)?; + let login_method = client.get_login_method().ok_or(Error::NotAuthenticated)?; - derive_pin_protected_user_key(&pin, login_method, user_key) + derive_pin_protected_user_key(&pin, &login_method, user_key) } #[cfg(feature = "internal")] @@ -294,7 +274,7 @@ fn derive_pin_protected_user_key( #[cfg(feature = "internal")] pub(super) fn enroll_admin_password_reset( - client: &mut Client, + client: &Client, public_key: String, ) -> Result { use base64::{engine::general_purpose::STANDARD, Engine}; @@ -317,7 +297,7 @@ mod tests { #[tokio::test] async fn test_update_password() { - let mut client = Client::new(None); + let client = Client::new(None); let priv_key = "2.kmLY8NJVuiKBFJtNd/ZFpA==|qOodlRXER+9ogCe3yOibRHmUcSNvjSKhdDuztLlucs10jLiNoVVVAc+9KfNErLSpx5wmUF1hBOJM8zwVPjgQTrmnNf/wuDpwiaCxNYb/0v4FygPy7ccAHK94xP1lfqq7U9+tv+/yiZSwgcT+xF0wFpoxQeNdNRFzPTuD9o4134n8bzacD9DV/WjcrXfRjbBCzzuUGj1e78+A7BWN7/5IWLz87KWk8G7O/W4+8PtEzlwkru6Wd1xO19GYU18oArCWCNoegSmcGn7w7NDEXlwD403oY8Oa7ylnbqGE28PVJx+HLPNIdSC6YKXeIOMnVs7Mctd/wXC93zGxAWD6ooTCzHSPVV50zKJmWIG2cVVUS7j35H3rGDtUHLI+ASXMEux9REZB8CdVOZMzp2wYeiOpggebJy6MKOZqPT1R3X0fqF2dHtRFPXrNsVr1Qt6bS9qTyO4ag1/BCvXF3P1uJEsI812BFAne3cYHy5bIOxuozPfipJrTb5WH35bxhElqwT3y/o/6JWOGg3HLDun31YmiZ2HScAsUAcEkA4hhoTNnqy4O2s3yVbCcR7jF7NLsbQc0MDTbnjxTdI4VnqUIn8s2c9hIJy/j80pmO9Bjxp+LQ9a2hUkfHgFhgHxZUVaeGVth8zG2kkgGdrp5VHhxMVFfvB26Ka6q6qE/UcS2lONSv+4T8niVRJz57qwctj8MNOkA3PTEfe/DP/LKMefke31YfT0xogHsLhDkx+mS8FCc01HReTjKLktk/Jh9mXwC5oKwueWWwlxI935ecn+3I2kAuOfMsgPLkoEBlwgiREC1pM7VVX1x8WmzIQVQTHd4iwnX96QewYckGRfNYWz/zwvWnjWlfcg8kRSe+68EHOGeRtC5r27fWLqRc0HNcjwpgHkI/b6czerCe8+07TWql4keJxJxhBYj3iOH7r9ZS8ck51XnOb8tGL1isimAJXodYGzakwktqHAD7MZhS+P02O+6jrg7d+yPC2ZCuS/3TOplYOCHQIhnZtR87PXTUwr83zfOwAwCyv6KP84JUQ45+DItrXLap7nOVZKQ5QxYIlbThAO6eima6Zu5XHfqGPMNWv0bLf5+vAjIa5np5DJrSwz9no/hj6CUh0iyI+SJq4RGI60lKtypMvF6MR3nHLEHOycRUQbZIyTHWl4QQLdHzuwN9lv10ouTEvNr6sFflAX2yb6w3hlCo7oBytH3rJekjb3IIOzBpeTPIejxzVlh0N9OT5MZdh4sNKYHUoWJ8mnfjdM+L4j5Q2Kgk/XiGDgEebkUxiEOQUdVpePF5uSCE+TPav/9FIRGXGiFn6NJMaU7aBsDTFBLloffFLYDpd8/bTwoSvifkj7buwLYM+h/qcnfdy5FWau1cKav+Blq/ZC0qBpo658RTC8ZtseAFDgXoQZuksM10hpP9bzD04Bx30xTGX81QbaSTNwSEEVrOtIhbDrj9OI43KH4O6zLzK+t30QxAv5zjk10RZ4+5SAdYndIlld9Y62opCfPDzRy3ubdve4ZEchpIKWTQvIxq3T5ogOhGaWBVYnkMtM2GVqvWV//46gET5SH/MdcwhACUcZ9kCpMnWH9CyyUwYvTT3UlNyV+DlS27LMPvaw7tx7qa+GfNCoCBd8S4esZpQYK/WReiS8=|pc7qpD42wxyXemdNPuwxbh8iIaryrBPu8f/DGwYdHTw="; @@ -326,7 +306,7 @@ mod tests { }; initialize_user_crypto( - &mut client, + & client, InitUserCryptoRequest { kdf_params: kdf.clone(), email: "test@bitwarden.com".into(), @@ -340,12 +320,12 @@ mod tests { .await .unwrap(); - let new_password_response = update_password(&mut client, "123412341234".into()).unwrap(); + let new_password_response = update_password(&client, "123412341234".into()).unwrap(); - let mut client2 = Client::new(None); + let client2 = Client::new(None); initialize_user_crypto( - &mut client2, + &client2, InitUserCryptoRequest { kdf_params: kdf.clone(), email: "test@bitwarden.com".into(), @@ -390,12 +370,12 @@ mod tests { #[tokio::test] async fn test_initialize_user_crypto_pin() { - let mut client = Client::new(None); + let client = Client::new(None); let priv_key = "2.kmLY8NJVuiKBFJtNd/ZFpA==|qOodlRXER+9ogCe3yOibRHmUcSNvjSKhdDuztLlucs10jLiNoVVVAc+9KfNErLSpx5wmUF1hBOJM8zwVPjgQTrmnNf/wuDpwiaCxNYb/0v4FygPy7ccAHK94xP1lfqq7U9+tv+/yiZSwgcT+xF0wFpoxQeNdNRFzPTuD9o4134n8bzacD9DV/WjcrXfRjbBCzzuUGj1e78+A7BWN7/5IWLz87KWk8G7O/W4+8PtEzlwkru6Wd1xO19GYU18oArCWCNoegSmcGn7w7NDEXlwD403oY8Oa7ylnbqGE28PVJx+HLPNIdSC6YKXeIOMnVs7Mctd/wXC93zGxAWD6ooTCzHSPVV50zKJmWIG2cVVUS7j35H3rGDtUHLI+ASXMEux9REZB8CdVOZMzp2wYeiOpggebJy6MKOZqPT1R3X0fqF2dHtRFPXrNsVr1Qt6bS9qTyO4ag1/BCvXF3P1uJEsI812BFAne3cYHy5bIOxuozPfipJrTb5WH35bxhElqwT3y/o/6JWOGg3HLDun31YmiZ2HScAsUAcEkA4hhoTNnqy4O2s3yVbCcR7jF7NLsbQc0MDTbnjxTdI4VnqUIn8s2c9hIJy/j80pmO9Bjxp+LQ9a2hUkfHgFhgHxZUVaeGVth8zG2kkgGdrp5VHhxMVFfvB26Ka6q6qE/UcS2lONSv+4T8niVRJz57qwctj8MNOkA3PTEfe/DP/LKMefke31YfT0xogHsLhDkx+mS8FCc01HReTjKLktk/Jh9mXwC5oKwueWWwlxI935ecn+3I2kAuOfMsgPLkoEBlwgiREC1pM7VVX1x8WmzIQVQTHd4iwnX96QewYckGRfNYWz/zwvWnjWlfcg8kRSe+68EHOGeRtC5r27fWLqRc0HNcjwpgHkI/b6czerCe8+07TWql4keJxJxhBYj3iOH7r9ZS8ck51XnOb8tGL1isimAJXodYGzakwktqHAD7MZhS+P02O+6jrg7d+yPC2ZCuS/3TOplYOCHQIhnZtR87PXTUwr83zfOwAwCyv6KP84JUQ45+DItrXLap7nOVZKQ5QxYIlbThAO6eima6Zu5XHfqGPMNWv0bLf5+vAjIa5np5DJrSwz9no/hj6CUh0iyI+SJq4RGI60lKtypMvF6MR3nHLEHOycRUQbZIyTHWl4QQLdHzuwN9lv10ouTEvNr6sFflAX2yb6w3hlCo7oBytH3rJekjb3IIOzBpeTPIejxzVlh0N9OT5MZdh4sNKYHUoWJ8mnfjdM+L4j5Q2Kgk/XiGDgEebkUxiEOQUdVpePF5uSCE+TPav/9FIRGXGiFn6NJMaU7aBsDTFBLloffFLYDpd8/bTwoSvifkj7buwLYM+h/qcnfdy5FWau1cKav+Blq/ZC0qBpo658RTC8ZtseAFDgXoQZuksM10hpP9bzD04Bx30xTGX81QbaSTNwSEEVrOtIhbDrj9OI43KH4O6zLzK+t30QxAv5zjk10RZ4+5SAdYndIlld9Y62opCfPDzRy3ubdve4ZEchpIKWTQvIxq3T5ogOhGaWBVYnkMtM2GVqvWV//46gET5SH/MdcwhACUcZ9kCpMnWH9CyyUwYvTT3UlNyV+DlS27LMPvaw7tx7qa+GfNCoCBd8S4esZpQYK/WReiS8=|pc7qpD42wxyXemdNPuwxbh8iIaryrBPu8f/DGwYdHTw="; initialize_user_crypto( - &mut client, + & client, InitUserCryptoRequest { kdf_params: Kdf::PBKDF2 { iterations: 100_000.try_into().unwrap(), @@ -411,12 +391,12 @@ mod tests { .await .unwrap(); - let pin_key = derive_pin_key(&mut client, "1234".into()).unwrap(); + let pin_key = derive_pin_key(&client, "1234".into()).unwrap(); // Verify we can unlock with the pin - let mut client2 = Client::new(None); + let client2 = Client::new(None); initialize_user_crypto( - &mut client2, + &client2, InitUserCryptoRequest { kdf_params: Kdf::PBKDF2 { iterations: 100_000.try_into().unwrap(), @@ -448,13 +428,12 @@ mod tests { ); // Verify we can derive the pin protected user key from the encrypted pin - let pin_protected_user_key = - derive_pin_user_key(&mut client, pin_key.encrypted_pin).unwrap(); + let pin_protected_user_key = derive_pin_user_key(&client, pin_key.encrypted_pin).unwrap(); - let mut client3 = Client::new(None); + let client3 = Client::new(None); initialize_user_crypto( - &mut client3, + &client3, InitUserCryptoRequest { kdf_params: Kdf::PBKDF2 { iterations: 100_000.try_into().unwrap(), @@ -494,7 +473,7 @@ mod tests { use base64::{engine::general_purpose::STANDARD, Engine}; use bitwarden_crypto::AsymmetricCryptoKey; - let mut client = Client::new(None); + let client = Client::new(None); let master_key = bitwarden_crypto::MasterKey::derive( "asdfasdfasdf".as_bytes(), @@ -513,18 +492,15 @@ mod tests { let public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsy7RFHcX3C8Q4/OMmhhbFReYWfB45W9PDTEA8tUZwZmtOiN2RErIS2M1c+K/4HoDJ/TjpbX1f2MZcr4nWvKFuqnZXyewFc+jmvKVewYi+NAu2++vqKq2kKcmMNhwoQDQdQIVy/Uqlp4Cpi2cIwO6ogq5nHNJGR3jm+CpyrafYlbz1bPvL3hbyoGDuG2tgADhyhXUdFuef2oF3wMvn1lAJAvJnPYpMiXUFmj1ejmbwtlxZDrHgUJvUcp7nYdwUKaFoi+sOttHn3u7eZPtNvxMjhSS/X/1xBIzP/mKNLdywH5LoRxniokUk+fV3PYUxJsiU3lV0Trc/tH46jqd8ZGjmwIDAQAB"; - let encrypted = enroll_admin_password_reset(&mut client, public_key.to_owned()).unwrap(); + let encrypted = enroll_admin_password_reset(&client, public_key.to_owned()).unwrap(); let private_key = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCzLtEUdxfcLxDj84yaGFsVF5hZ8Hjlb08NMQDy1RnBma06I3ZESshLYzVz4r/gegMn9OOltfV/Yxlyvida8oW6qdlfJ7AVz6Oa8pV7BiL40C7b76+oqraQpyYw2HChANB1AhXL9SqWngKmLZwjA7qiCrmcc0kZHeOb4KnKtp9iVvPVs+8veFvKgYO4ba2AAOHKFdR0W55/agXfAy+fWUAkC8mc9ikyJdQWaPV6OZvC2XFkOseBQm9Rynudh3BQpoWiL6w620efe7t5k+02/EyOFJL9f/XEEjM/+Yo0t3LAfkuhHGeKiRST59Xc9hTEmyJTeVXROtz+0fjqOp3xkaObAgMBAAECggEACs4xhnO0HaZhh1/iH7zORMIRXKeyxP2LQiTR8xwN5JJ9wRWmGAR9VasS7EZFTDidIGVME2u/h4s5EqXnhxfO+0gGksVvgNXJ/qw87E8K2216g6ZNo6vSGA7H1GH2voWwejJ4/k/cJug6dz2S402rRAKh2Wong1arYHSkVlQp3diiMa5FHAOSE+Cy09O2ZsaF9IXQYUtlW6AVXFrBEPYH2kvkaPXchh8VETMijo6tbvoKLnUHe+wTaDMls7hy8exjtVyI59r3DNzjy1lNGaGb5QSnFMXR+eHhPZc844Wv02MxC15zKABADrl58gpJyjTl6XpDdHCYGsmGpVGH3X9TQQKBgQDz/9beFjzq59ve6rGwn+EtnQfSsyYT+jr7GN8lNEXb3YOFXBgPhfFIcHRh2R00Vm9w2ApfAx2cd8xm2I6HuvQ1Os7g26LWazvuWY0Qzb+KaCLQTEGH1RnTq6CCG+BTRq/a3J8M4t38GV5TWlzv8wr9U4dl6FR4efjb65HXs1GQ4QKBgQC7/uHfrOTEHrLeIeqEuSl0vWNqEotFKdKLV6xpOvNuxDGbgW4/r/zaxDqt0YBOXmRbQYSEhmO3oy9J6XfE1SUln0gbavZeW0HESCAmUIC88bDnspUwS9RxauqT5aF8ODKN/bNCWCnBM1xyonPOs1oT1nyparJVdQoG//Y7vkB3+wKBgBqLqPq8fKAp3XfhHLfUjREDVoiLyQa/YI9U42IOz9LdxKNLo6p8rgVthpvmnRDGnpUuS+KOWjhdqDVANjF6G3t3DG7WNl8Rh5Gk2H4NhFswfSkgQrjebFLlBy9gjQVCWXt8KSmjvPbiY6q52Aaa8IUjA0YJAregvXxfopxO+/7BAoGARicvEtDp7WWnSc1OPoj6N14VIxgYcI7SyrzE0d/1x3ffKzB5e7qomNpxKzvqrVP8DzG7ydh8jaKPmv1MfF8tpYRy3AhmN3/GYwCnPqT75YYrhcrWcVdax5gmQVqHkFtIQkRSCIftzPLlpMGKha/YBV8c1fvC4LD0NPh/Ynv0gtECgYEAyOZg95/kte0jpgUEgwuMrzkhY/AaUJULFuR5MkyvReEbtSBQwV5tx60+T95PHNiFooWWVXiLMsAgyI2IbkxVR1Pzdri3gWK5CTfqb7kLuaj/B7SGvBa2Sxo478KS5K8tBBBWkITqo+wLC0mn3uZi1dyMWO1zopTA+KtEGF2dtGQ="; let private_key = AsymmetricCryptoKey::from_der(&STANDARD.decode(private_key).unwrap()).unwrap(); let decrypted: Vec = encrypted.decrypt_with_key(&private_key).unwrap(); - let expected = client - .get_encryption_settings() - .unwrap() - .get_key(&None) - .unwrap(); + let enc = client.get_encryption_settings().unwrap(); + let expected = enc.get_key(&None).unwrap(); assert_eq!(&decrypted, &expected.to_vec()); } } diff --git a/crates/bitwarden/src/mobile/tool/client_sends.rs b/crates/bitwarden/src/mobile/tool/client_sends.rs index 9feeec030..38a7d072d 100644 --- a/crates/bitwarden/src/mobile/tool/client_sends.rs +++ b/crates/bitwarden/src/mobile/tool/client_sends.rs @@ -75,20 +75,17 @@ impl<'a> ClientSends<'a> { } pub fn encrypt_buffer(&self, send: Send, buffer: &[u8]) -> Result> { - let key = self - .client - .get_encryption_settings()? - .get_key(&None) - .ok_or(VaultLocked)?; + let enc = self.client.get_encryption_settings()?; + let key = enc.get_key(&None).ok_or(VaultLocked)?; let key = Send::get_key(&send.key, key)?; - let enc = buffer.encrypt_with_key(&key)?; - Ok(enc.to_buffer()?) + let encrypted = buffer.encrypt_with_key(&key)?; + Ok(encrypted.to_buffer()?) } } impl<'a> Client { - pub fn sends(&'a mut self) -> ClientSends<'a> { + pub fn sends(&'a self) -> ClientSends<'a> { ClientSends { client: self } } } diff --git a/crates/bitwarden/src/mobile/vault/client_attachments.rs b/crates/bitwarden/src/mobile/vault/client_attachments.rs index 2f9edb82b..4140a4d88 100644 --- a/crates/bitwarden/src/mobile/vault/client_attachments.rs +++ b/crates/bitwarden/src/mobile/vault/client_attachments.rs @@ -24,7 +24,7 @@ impl<'a> ClientAttachments<'a> { buffer: &[u8], ) -> Result { let enc = self.client.get_encryption_settings()?; - let key = cipher.locate_key(enc, &None).ok_or(VaultLocked)?; + let key = cipher.locate_key(&enc, &None).ok_or(VaultLocked)?; Ok(AttachmentFileView { cipher, @@ -56,7 +56,7 @@ impl<'a> ClientAttachments<'a> { encrypted_buffer: &[u8], ) -> Result> { let enc = self.client.get_encryption_settings()?; - let key = cipher.locate_key(enc, &None).ok_or(VaultLocked)?; + let key = cipher.locate_key(&enc, &None).ok_or(VaultLocked)?; AttachmentFile { cipher, diff --git a/crates/bitwarden/src/mobile/vault/client_ciphers.rs b/crates/bitwarden/src/mobile/vault/client_ciphers.rs index e459f4e7c..bbbb01652 100644 --- a/crates/bitwarden/src/mobile/vault/client_ciphers.rs +++ b/crates/bitwarden/src/mobile/vault/client_ciphers.rs @@ -16,11 +16,11 @@ impl<'a> ClientCiphers<'a> { // TODO: Once this flag is removed, the key generation logic should // be moved directly into the KeyEncryptable implementation if cipher_view.key.is_none() && self.client.get_flags().enable_cipher_key_encryption { - let key = cipher_view.locate_key(enc, &None).ok_or(VaultLocked)?; + let key = cipher_view.locate_key(&enc, &None).ok_or(VaultLocked)?; cipher_view.generate_cipher_key(key)?; } - let key = cipher_view.locate_key(enc, &None).ok_or(VaultLocked)?; + let key = cipher_view.locate_key(&enc, &None).ok_or(VaultLocked)?; let cipher = cipher_view.encrypt_with_key(key)?; Ok(cipher) @@ -29,7 +29,7 @@ impl<'a> ClientCiphers<'a> { pub fn decrypt(&self, cipher: Cipher) -> Result { let enc = self.client.get_encryption_settings()?; let key = cipher - .locate_key(enc, &None) + .locate_key(&enc, &None) .ok_or(CryptoError::MissingKey)?; let cipher_view = cipher.decrypt_with_key(key)?; @@ -43,7 +43,7 @@ impl<'a> ClientCiphers<'a> { let cipher_views: Result> = ciphers .iter() .map(|c| -> Result { - let key = c.locate_key(enc, &None).ok_or(CryptoError::MissingKey)?; + let key = c.locate_key(&enc, &None).ok_or(CryptoError::MissingKey)?; Ok(c.decrypt_with_key(key)?) }) .collect(); @@ -57,7 +57,7 @@ impl<'a> ClientCiphers<'a> { organization_id: Uuid, ) -> Result { let enc = self.client.get_encryption_settings()?; - cipher_view.move_to_organization(enc, organization_id)?; + cipher_view.move_to_organization(&enc, organization_id)?; Ok(cipher_view) } } @@ -80,7 +80,7 @@ mod tests { #[tokio::test] async fn test_decrypt_list() { - let mut client = Client::init_test_account(test_bitwarden_com_account()).await; + let client = Client::init_test_account(test_bitwarden_com_account()).await; let dec = client .vault() @@ -181,7 +181,7 @@ mod tests { #[tokio::test] async fn test_move_user_cipher_with_attachment_without_key_to_org_fails() { - let mut client = Client::init_test_account(test_bitwarden_com_account()).await; + let client = Client::init_test_account(test_bitwarden_com_account()).await; let mut cipher = test_cipher(); cipher.attachments = Some(vec![test_attachment_legacy()]); @@ -199,7 +199,7 @@ mod tests { #[tokio::test] async fn test_encrypt_cipher_with_legacy_attachment_without_key() { - let mut client = Client::init_test_account(test_bitwarden_com_account()).await; + let client = Client::init_test_account(test_bitwarden_com_account()).await; let mut cipher = test_cipher(); let attachment = test_attachment_legacy(); @@ -238,7 +238,7 @@ mod tests { #[tokio::test] async fn test_encrypt_cipher_with_v1_attachment_without_key() { - let mut client = Client::init_test_account(test_bitwarden_com_account()).await; + let client = Client::init_test_account(test_bitwarden_com_account()).await; let mut cipher = test_cipher(); let attachment = test_attachment_v2(); diff --git a/crates/bitwarden/src/mobile/vault/client_collection.rs b/crates/bitwarden/src/mobile/vault/client_collection.rs index 0727130df..09f1f3c6a 100644 --- a/crates/bitwarden/src/mobile/vault/client_collection.rs +++ b/crates/bitwarden/src/mobile/vault/client_collection.rs @@ -11,7 +11,7 @@ impl<'a> ClientCollections<'a> { pub fn decrypt(&self, collection: Collection) -> Result { let enc = self.client.get_encryption_settings()?; let key = collection - .locate_key(enc, &None) + .locate_key(&enc, &None) .ok_or(CryptoError::MissingKey)?; let view = collection.decrypt_with_key(key)?; @@ -25,7 +25,7 @@ impl<'a> ClientCollections<'a> { let views: Result> = collections .iter() .map(|c| -> Result { - let key = c.locate_key(enc, &None).ok_or(CryptoError::MissingKey)?; + let key = c.locate_key(&enc, &None).ok_or(CryptoError::MissingKey)?; Ok(c.decrypt_with_key(key)?) }) .collect(); @@ -50,7 +50,7 @@ mod tests { #[tokio::test] async fn test_decrypt_list() { - let mut client = Client::init_test_account(test_bitwarden_com_account()).await; + let client = Client::init_test_account(test_bitwarden_com_account()).await; let dec = client.vault().collections().decrypt_list(vec![Collection { id: Some("66c5ca57-0868-4c7e-902f-b181009709c0".parse().unwrap()), @@ -66,7 +66,7 @@ mod tests { #[tokio::test] async fn test_decrypt() { - let mut client = Client::init_test_account(test_bitwarden_com_account()).await; + let client = Client::init_test_account(test_bitwarden_com_account()).await; let dec = client.vault().collections().decrypt(Collection { id: Some("66c5ca57-0868-4c7e-902f-b181009709c0".parse().unwrap()), diff --git a/crates/bitwarden/src/platform/client_platform.rs b/crates/bitwarden/src/platform/client_platform.rs index 733a86e72..945011393 100644 --- a/crates/bitwarden/src/platform/client_platform.rs +++ b/crates/bitwarden/src/platform/client_platform.rs @@ -8,7 +8,7 @@ use super::{ use crate::{error::Result, Client}; pub struct ClientPlatform<'a> { - pub(crate) client: &'a mut Client, + pub(crate) client: &'a Client, } impl<'a> ClientPlatform<'a> { @@ -28,7 +28,7 @@ impl<'a> ClientPlatform<'a> { } #[cfg(feature = "uniffi")] - pub fn fido2(&'a mut self) -> ClientFido2<'a> { + pub fn fido2(&'a self) -> ClientFido2<'a> { ClientFido2 { client: self.client, } @@ -36,7 +36,7 @@ impl<'a> ClientPlatform<'a> { } impl<'a> Client { - pub fn platform(&'a mut self) -> ClientPlatform<'a> { + pub fn platform(&'a self) -> ClientPlatform<'a> { ClientPlatform { client: self } } } diff --git a/crates/bitwarden/src/platform/fido2/authenticator.rs b/crates/bitwarden/src/platform/fido2/authenticator.rs index 825e4f6d8..d0a7b83e4 100644 --- a/crates/bitwarden/src/platform/fido2/authenticator.rs +++ b/crates/bitwarden/src/platform/fido2/authenticator.rs @@ -77,7 +77,7 @@ pub enum SilentlyDiscoverCredentialsError { } pub struct Fido2Authenticator<'a> { - pub(crate) client: &'a mut Client, + pub(crate) client: &'a Client, pub(crate) user_interface: &'a dyn Fido2UserInterface, pub(crate) credential_store: &'a dyn Fido2CredentialStore, @@ -225,7 +225,7 @@ impl<'a> Fido2Authenticator<'a> { Ok(result .into_iter() - .flat_map(|c| c.decrypt_fido2_credentials(enc)) + .flat_map(|c| c.decrypt_fido2_credentials(&enc)) .flatten() .collect()) } @@ -268,7 +268,7 @@ impl<'a> Fido2Authenticator<'a> { .clone() .ok_or(GetSelectedCredentialError::NoSelectedCredential)?; - let creds = cipher.decrypt_fido2_credentials(enc)?; + let creds = cipher.decrypt_fido2_credentials(&enc)?; let credential = creds .first() @@ -339,7 +339,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { if this.create_credential { Ok(creds .into_iter() - .map(|c| CipherViewContainer::new(c, enc)) + .map(|c| CipherViewContainer::new(c, &enc)) .collect::>()?) } else { let picked = this @@ -355,7 +355,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { .expect("Mutex is not poisoned") .replace(picked.clone()); - Ok(vec![CipherViewContainer::new(picked, enc)?]) + Ok(vec![CipherViewContainer::new(picked, &enc)?]) } } @@ -411,7 +411,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { .clone() .ok_or(InnerError::NoSelectedCredential)?; - selected.set_new_fido2_credentials(enc, vec![cred])?; + selected.set_new_fido2_credentials(&enc, vec![cred])?; // Store the updated credential for later use this.authenticator @@ -481,7 +481,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { let cred = fill_with_credential(&selected.credential, cred)?; let mut selected = selected.cipher; - selected.set_new_fido2_credentials(enc, vec![cred])?; + selected.set_new_fido2_credentials(&enc, vec![cred])?; // Store the updated credential for later use this.authenticator diff --git a/crates/bitwarden/src/platform/fido2/mod.rs b/crates/bitwarden/src/platform/fido2/mod.rs index 3f08b8810..da9d19a65 100644 --- a/crates/bitwarden/src/platform/fido2/mod.rs +++ b/crates/bitwarden/src/platform/fido2/mod.rs @@ -43,12 +43,12 @@ const AAGUID: Aaguid = Aaguid([ pub struct ClientFido2<'a> { #[allow(dead_code)] - pub(crate) client: &'a mut Client, + pub(crate) client: &'a Client, } impl<'a> ClientFido2<'a> { pub fn create_authenticator( - &'a mut self, + &'a self, user_interface: &'a dyn Fido2UserInterface, credential_store: &'a dyn Fido2CredentialStore, ) -> Fido2Authenticator<'a> { @@ -62,7 +62,7 @@ impl<'a> ClientFido2<'a> { } pub fn create_client( - &'a mut self, + &'a self, user_interface: &'a dyn Fido2UserInterface, credential_store: &'a dyn Fido2CredentialStore, ) -> Fido2Client<'a> { diff --git a/crates/bitwarden/src/platform/generate_fingerprint.rs b/crates/bitwarden/src/platform/generate_fingerprint.rs index d62eb5436..521a75c01 100644 --- a/crates/bitwarden/src/platform/generate_fingerprint.rs +++ b/crates/bitwarden/src/platform/generate_fingerprint.rs @@ -33,7 +33,7 @@ pub(crate) fn generate_fingerprint(input: &FingerprintRequest) -> Result Result { info!("Generating fingerprint"); @@ -63,7 +63,7 @@ mod tests { let private_key = "2.tY6WsWKUbBwNU8wROuipiQ==|DNFL1d19xVojUKTTy2gxT+9J1VXbMQLcbMnx1HSeA6U3yZhsLR6DPaGibb3Bp8doIHtrsxzL/JeLb4gLDZ8RnDhFfE4iLRaPakX14kbBXrKH9/uW/zc7TqIVciWhI1PaeFlu8wnVuGt3e5Ysx6Y7Uw7RS8pRT5aE3sX3aDPGZTAdTutLn1VUfkShS5OK5HJl9CdiwV2wOcrf4w/WqtaNUUqGdsJ8C4ELlpBzHxqs+lEm+8pGPYmuGQIjVc0eOR9Tza9GTk3ih1XGc1znOCoKUZbtA29RfbwfmJy/yGi/3RLWZFQGCCij4cLC5OpldiX4JWL5Dhox44p/5IVF3rfxTVz3GCyDOoHevRG/06sUBq6nhbdCQf3lJvxwcQJhoQg4rsapM3rgol+u+TbXRiwWPbfswuLkRlvGFKtKUWMa4S57gj0CFYgSBPdTyhZTB44D7JQ2bd901Ur1dYWcDe4Kn3ZawpxL0cX2ZPlE3v8FXFJf2s8DJytL8yu73GasDzVmaGHxueWWVz7EHjh+pmB4oaAHARcY8d3LActAyl/+bcFRPYQJ68ae6DJhYYJGHIBWMImf2BifGgUX8vUFfUAYjne3D82lRyZQHs3xbl+ZxEPgWiPYRWUtxGXLLP4f9mbl+LeJdehtHNjC8kOduBL0CsP4gmugzNNUXI+Izc/9svno6kFr6SU0LA3MGrOU8ao7UCQbf/Pj/RKnG1gRmBDQqf7IMm6jOyTwdde9NpfQb32iH11PkuAKBvEtUuq9BeAKWjoZku+ycsN2jZH0hzd/QrU2c+E4+yHwX3wSxxorNOXt5EZkJbEDBlpRyE1zWoyy0wIYfcChYLvFN8QFHchlw5wmHxL+OOgdgndAtV/2DCx+NB6caY31qLictME+1GPPlQ7QvicMLgmpSWq83rs4ex/My6p3hCRSrJJiLvjEDZLYWKHHLd5tsPRAjX8ADNWB1VeIeiJrj1wpOCc1PbWpbljbbTsBmVPo6iKm/UDGAHBdQ//0j3FQg8f5w/j+McsoaMpDNHNTiLvjWERR+RBmsEA0lEL00wZz/DHlzOAYHLYYqFMT7GBCQD+Wk/l1TL+X2agUy7Irlk7QbZ4ivfdNIpSW8Ct9MGE6o4wV+nIpXURojgBBTcP85RTBLXXGrIprnK1G/VE8ONag3+nkqIyChjYyk5QMsxqOqSHsbiOxhCdXypbCbY4g9yKJtBJ/ADjxmELj0X7pqsTFqC0eRT7rk9qTBcYBBu6rwlAfq8AKjDB7WjNjzLaMi6lBoe4petBn1xcLkXD5hHra0TULxcYrq8MIb+Vk4CBZZdwwyVm/28SwSjHBIBpRysPAonDDsp3KlahwXEFvRDQR/oFww172GI7cx8SoPn93Qh0JfpTAAowsO3meR8bzUSyd7v3rmtaBPsWHE9zUXye/6nloMU5joEcD6uJaxd0kdaWWIoKLH++zHW1R776wJrS6u+TIWZgHqiIJoCd9fV25BnQcbZRKd6mnfNQkchJ6c6ozXKrFaa8DLdERdfh84+isw5mzW2zMJwHEwtKt6LUTyieC2exzPAwPxJT1+IMjuzuwiLnvGKOq+kwE/LWBSB0ZfGuCP/3jMM8OCfe7Hbpt1TfXcUxUzj6sSjkjQB6qBt+TINRdOFA=|fppguME86utsAOKrBYn6XU95q7daVbZ+3dD9OVkQlAw="; let fingerprint_material = "a09726a0-9590-49d1-a5f5-afe300b6a515"; - let mut client = Client::new(None); + let client = Client::new(None); let master_key = bitwarden_crypto::MasterKey::derive( "asdfasdfasdf".as_bytes(), @@ -83,7 +83,7 @@ mod tests { .unwrap(); let fingerprint = - generate_user_fingerprint(&mut client, fingerprint_material.to_string()).unwrap(); + generate_user_fingerprint(&client, fingerprint_material.to_string()).unwrap(); assert_eq!(fingerprint, "turban-deftly-anime-chatroom-unselfish"); } diff --git a/crates/bitwarden/src/platform/get_user_api_key.rs b/crates/bitwarden/src/platform/get_user_api_key.rs index 207721f44..991040aaf 100644 --- a/crates/bitwarden/src/platform/get_user_api_key.rs +++ b/crates/bitwarden/src/platform/get_user_api_key.rs @@ -1,3 +1,5 @@ +use std::sync::Arc; + use bitwarden_api_api::{ apis::accounts_api::accounts_api_key_post, models::{ApiKeyResponseModel, SecretVerificationRequestModel}, @@ -16,14 +18,14 @@ use crate::{ }; pub(crate) async fn get_user_api_key( - client: &mut Client, + client: &Client, input: &SecretVerificationRequest, ) -> Result { info!("Getting Api Key"); debug!("{:?}", input); let auth_settings = get_login_method(client)?; - let request = get_secret_verification_request(auth_settings, input)?; + let request = get_secret_verification_request(&auth_settings, input)?; let config = client.get_api_configurations().await; @@ -31,12 +33,9 @@ pub(crate) async fn get_user_api_key( UserApiKeyResponse::process_response(response) } -fn get_login_method(client: &Client) -> Result<&LoginMethod> { +fn get_login_method(client: &Client) -> Result> { if client.is_authed() { - client - .get_login_method() - .as_ref() - .ok_or(Error::NotAuthenticated) + client.get_login_method().ok_or(Error::NotAuthenticated) } else { Err(Error::NotAuthenticated) } diff --git a/crates/bitwarden/src/secrets_manager/projects/create.rs b/crates/bitwarden/src/secrets_manager/projects/create.rs index 1f82d4c59..fc5a3b5ae 100644 --- a/crates/bitwarden/src/secrets_manager/projects/create.rs +++ b/crates/bitwarden/src/secrets_manager/projects/create.rs @@ -21,8 +21,8 @@ pub(crate) async fn create_project( client: &mut Client, input: &ProjectCreateRequest, ) -> Result { - let key = client - .get_encryption_settings()? + let enc = client.get_encryption_settings()?; + let key = enc .get_key(&Some(input.organization_id)) .ok_or(VaultLocked)?; @@ -38,7 +38,5 @@ pub(crate) async fn create_project( ) .await?; - let enc = client.get_encryption_settings()?; - - ProjectResponse::process_response(res, enc) + ProjectResponse::process_response(res, &enc) } diff --git a/crates/bitwarden/src/secrets_manager/projects/get.rs b/crates/bitwarden/src/secrets_manager/projects/get.rs index 00afaa194..3e8b7f94a 100644 --- a/crates/bitwarden/src/secrets_manager/projects/get.rs +++ b/crates/bitwarden/src/secrets_manager/projects/get.rs @@ -22,5 +22,5 @@ pub(crate) async fn get_project( let enc = client.get_encryption_settings()?; - ProjectResponse::process_response(res, enc) + ProjectResponse::process_response(res, &enc) } diff --git a/crates/bitwarden/src/secrets_manager/projects/list.rs b/crates/bitwarden/src/secrets_manager/projects/list.rs index 5c491e14b..d5c7d4475 100644 --- a/crates/bitwarden/src/secrets_manager/projects/list.rs +++ b/crates/bitwarden/src/secrets_manager/projects/list.rs @@ -29,7 +29,7 @@ pub(crate) async fn list_projects( let enc = client.get_encryption_settings()?; - ProjectsResponse::process_response(res, enc) + ProjectsResponse::process_response(res, &enc) } #[derive(Serialize, Deserialize, Debug, JsonSchema)] diff --git a/crates/bitwarden/src/secrets_manager/projects/update.rs b/crates/bitwarden/src/secrets_manager/projects/update.rs index 86c269b1a..55cd69757 100644 --- a/crates/bitwarden/src/secrets_manager/projects/update.rs +++ b/crates/bitwarden/src/secrets_manager/projects/update.rs @@ -23,8 +23,8 @@ pub(crate) async fn update_project( client: &mut Client, input: &ProjectPutRequest, ) -> Result { - let key = client - .get_encryption_settings()? + let enc = client.get_encryption_settings()?; + let key = enc .get_key(&Some(input.organization_id)) .ok_or(VaultLocked)?; @@ -37,7 +37,5 @@ pub(crate) async fn update_project( bitwarden_api_api::apis::projects_api::projects_id_put(&config.api, input.id, project) .await?; - let enc = client.get_encryption_settings()?; - - ProjectResponse::process_response(res, enc) + ProjectResponse::process_response(res, &enc) } diff --git a/crates/bitwarden/src/secrets_manager/secrets/create.rs b/crates/bitwarden/src/secrets_manager/secrets/create.rs index 67f2a695e..51c8b28a9 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/create.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/create.rs @@ -26,8 +26,8 @@ pub(crate) async fn create_secret( client: &mut Client, input: &SecretCreateRequest, ) -> Result { - let key = client - .get_encryption_settings()? + let enc = client.get_encryption_settings()?; + let key = enc .get_key(&Some(input.organization_id)) .ok_or(VaultLocked)?; @@ -46,7 +46,5 @@ pub(crate) async fn create_secret( ) .await?; - let enc = client.get_encryption_settings()?; - - SecretResponse::process_response(res, enc) + SecretResponse::process_response(res, &enc) } diff --git a/crates/bitwarden/src/secrets_manager/secrets/get.rs b/crates/bitwarden/src/secrets_manager/secrets/get.rs index 622253a55..eca4b410a 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/get.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/get.rs @@ -21,5 +21,5 @@ pub(crate) async fn get_secret( let enc = client.get_encryption_settings()?; - SecretResponse::process_response(res, enc) + SecretResponse::process_response(res, &enc) } diff --git a/crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs b/crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs index 032962849..1575043d2 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs @@ -26,5 +26,5 @@ pub(crate) async fn get_secrets_by_ids( let enc = client.get_encryption_settings()?; - SecretsResponse::process_response(res, enc) + SecretsResponse::process_response(res, &enc) } diff --git a/crates/bitwarden/src/secrets_manager/secrets/list.rs b/crates/bitwarden/src/secrets_manager/secrets/list.rs index a5d263253..796aafe5d 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/list.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/list.rs @@ -32,7 +32,7 @@ pub(crate) async fn list_secrets( let enc = client.get_encryption_settings()?; - SecretIdentifiersResponse::process_response(res, enc) + SecretIdentifiersResponse::process_response(res, &enc) } #[derive(Serialize, Deserialize, Debug, JsonSchema)] @@ -55,7 +55,7 @@ pub(crate) async fn list_secrets_by_project( let enc = client.get_encryption_settings()?; - SecretIdentifiersResponse::process_response(res, enc) + SecretIdentifiersResponse::process_response(res, &enc) } #[derive(Serialize, Deserialize, Debug, JsonSchema)] diff --git a/crates/bitwarden/src/secrets_manager/secrets/sync.rs b/crates/bitwarden/src/secrets_manager/secrets/sync.rs index 565f25ecb..06c343ef7 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/sync.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/sync.rs @@ -33,7 +33,7 @@ pub(crate) async fn sync_secrets( let enc = client.get_encryption_settings()?; - SecretsSyncResponse::process_response(res, enc) + SecretsSyncResponse::process_response(res, &enc) } #[derive(Serialize, Deserialize, Debug, JsonSchema)] diff --git a/crates/bitwarden/src/secrets_manager/secrets/update.rs b/crates/bitwarden/src/secrets_manager/secrets/update.rs index a25900151..58665eac9 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/update.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/update.rs @@ -26,8 +26,8 @@ pub(crate) async fn update_secret( client: &mut Client, input: &SecretPutRequest, ) -> Result { - let key = client - .get_encryption_settings()? + let enc = client.get_encryption_settings()?; + let key = enc .get_key(&Some(input.organization_id)) .ok_or(VaultLocked)?; @@ -42,7 +42,5 @@ pub(crate) async fn update_secret( let res = bitwarden_api_api::apis::secrets_api::secrets_id_put(&config.api, input.id, secret).await?; - let enc = client.get_encryption_settings()?; - - SecretResponse::process_response(res, enc) + SecretResponse::process_response(res, &enc) } diff --git a/crates/bitwarden/src/tool/exporters/mod.rs b/crates/bitwarden/src/tool/exporters/mod.rs index 321ed5f6c..0c87bc558 100644 --- a/crates/bitwarden/src/tool/exporters/mod.rs +++ b/crates/bitwarden/src/tool/exporters/mod.rs @@ -47,12 +47,9 @@ fn convert_format( client: &Client, format: ExportFormat, ) -> Result { - let login_method = client - .login_method - .as_ref() - .ok_or(Error::NotAuthenticated)?; + let login_method = client.get_login_method().ok_or(Error::NotAuthenticated)?; - let kdf = match login_method { + let kdf = match login_method.as_ref() { LoginMethod::User( UserLoginMethod::Username { kdf, .. } | UserLoginMethod::ApiKey { kdf, .. }, ) => kdf, @@ -87,7 +84,7 @@ mod tests { #[test] fn test_convert_format() { - let mut client = Client::new(None); + let client = Client::new(None); client.set_login_method(LoginMethod::User(UserLoginMethod::Username { client_id: "7b821276-e27c-400b-9853-606393c87f18".to_owned(), email: "test@bitwarden.com".to_owned(), diff --git a/crates/bitwarden/src/vault/client_vault.rs b/crates/bitwarden/src/vault/client_vault.rs index 550947ed5..49ba5edd7 100644 --- a/crates/bitwarden/src/vault/client_vault.rs +++ b/crates/bitwarden/src/vault/client_vault.rs @@ -2,17 +2,17 @@ use super::sync::{sync, SyncRequest, SyncResponse}; use crate::{error::Result, Client}; pub struct ClientVault<'a> { - pub(crate) client: &'a mut crate::Client, + pub(crate) client: &'a crate::Client, } impl<'a> ClientVault<'a> { - pub async fn sync(&mut self, input: &SyncRequest) -> Result { + pub async fn sync(&self, input: &SyncRequest) -> Result { sync(self.client, input).await } } impl<'a> Client { - pub fn vault(&'a mut self) -> ClientVault<'a> { + pub fn vault(&'a self) -> ClientVault<'a> { ClientVault { client: self } } } diff --git a/crates/bitwarden/src/vault/sync.rs b/crates/bitwarden/src/vault/sync.rs index b7b96d63f..d751dbf6f 100644 --- a/crates/bitwarden/src/vault/sync.rs +++ b/crates/bitwarden/src/vault/sync.rs @@ -20,7 +20,7 @@ pub struct SyncRequest { pub exclude_subdomains: Option, } -pub(crate) async fn sync(client: &mut Client, input: &SyncRequest) -> Result { +pub(crate) async fn sync(client: &Client, input: &SyncRequest) -> Result { let config = client.get_api_configurations().await; let sync = bitwarden_api_api::apis::sync_api::sync_get(&config.api, input.exclude_subdomains).await?; @@ -35,7 +35,7 @@ pub(crate) async fn sync(client: &mut Client, input: &SyncRequest) -> Result) -> Result<()> { +pub(crate) async fn login_password(client: Client, email: Option) -> Result<()> { let email = text_prompt_when_none("Email", email)?; let password = Password::new("Password").without_confirmation().prompt()?; @@ -93,7 +93,7 @@ pub(crate) async fn login_password(mut client: Client, email: Option) -> } pub(crate) async fn login_api_key( - mut client: Client, + client: Client, client_id: Option, client_secret: Option, ) -> Result<()> { @@ -117,7 +117,7 @@ pub(crate) async fn login_api_key( } pub(crate) async fn login_device( - mut client: Client, + client: Client, email: Option, device_identifier: Option, ) -> Result<()> { diff --git a/crates/bw/src/main.rs b/crates/bw/src/main.rs index 6a1918126..c8af014f0 100644 --- a/crates/bw/src/main.rs +++ b/crates/bw/src/main.rs @@ -188,7 +188,7 @@ async fn process_commands() -> Result<()> { identity_url: format!("{}/identity", server), ..Default::default() }); - let mut client = bitwarden::Client::new(settings); + let client = bitwarden::Client::new(settings); let email = text_prompt_when_none("Email", email)?; let password = Password::new("Password").prompt()?; From 25b2dc4f9738c3218100b29b116b2fb15576f207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Fri, 14 Jun 2024 10:42:59 +0200 Subject: [PATCH 014/214] Remove Mutex from bitwarden-json (#839) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking With the mutability changes to the client, we don't need a Mutex in `bitwarden-json` anymore either, which means we can remove the `async-lock` dependency as well. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- Cargo.lock | 49 ------------------- crates/bitwarden-json/Cargo.toml | 1 - crates/bitwarden-json/src/client.rs | 7 ++- crates/bitwarden-uniffi/Cargo.toml | 1 - crates/bitwarden/src/auth/client_auth.rs | 2 +- .../src/secrets_manager/client_projects.rs | 14 +++--- .../src/secrets_manager/client_secrets.rs | 20 ++++---- .../src/secrets_manager/projects/create.rs | 2 +- .../src/secrets_manager/projects/delete.rs | 2 +- .../src/secrets_manager/projects/get.rs | 2 +- .../src/secrets_manager/projects/list.rs | 2 +- .../src/secrets_manager/projects/update.rs | 2 +- .../src/secrets_manager/secrets/create.rs | 2 +- .../src/secrets_manager/secrets/delete.rs | 2 +- .../src/secrets_manager/secrets/get.rs | 2 +- .../src/secrets_manager/secrets/get_by_ids.rs | 2 +- .../src/secrets_manager/secrets/list.rs | 4 +- .../src/secrets_manager/secrets/sync.rs | 2 +- .../src/secrets_manager/secrets/update.rs | 2 +- crates/bws/src/main.rs | 2 +- 20 files changed, 35 insertions(+), 87 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 480a1d3bd..63e29ba26 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -224,17 +224,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "async-lock" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d034b430882f8381900d3fe6f0aaa3ad94f2cb4ac519b429692a1bc2dda4ae7b" -dependencies = [ - "event-listener", - "event-listener-strategy", - "pin-project-lite", -] - [[package]] name = "async-trait" version = "0.1.80" @@ -525,7 +514,6 @@ dependencies = [ name = "bitwarden-json" version = "0.3.0" dependencies = [ - "async-lock", "bitwarden", "log", "schemars", @@ -562,7 +550,6 @@ name = "bitwarden-uniffi" version = "0.1.0" dependencies = [ "android_logger", - "async-lock", "async-trait", "bitwarden", "bitwarden-core", @@ -972,15 +959,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "concurrent-queue" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "console" version = "0.15.8" @@ -1533,27 +1511,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "event-listener" -version = "4.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b215c49b2b248c855fb73579eb1f4f26c38ffdc12973e20e07b91d78d5646e" -dependencies = [ - "concurrent-queue", - "parking", - "pin-project-lite", -] - -[[package]] -name = "event-listener-strategy" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "958e4d70b6d5e81971bebec42271ec641e7ff4e170a6fa605f2b8a8b65cb97d3" -dependencies = [ - "event-listener", - "pin-project-lite", -] - [[package]] name = "eyre" version = "0.6.12" @@ -2557,12 +2514,6 @@ dependencies = [ "sha2", ] -[[package]] -name = "parking" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" - [[package]] name = "parking_lot" version = "0.12.2" diff --git a/crates/bitwarden-json/Cargo.toml b/crates/bitwarden-json/Cargo.toml index 4981e8f4b..69ca8e6ab 100644 --- a/crates/bitwarden-json/Cargo.toml +++ b/crates/bitwarden-json/Cargo.toml @@ -20,7 +20,6 @@ internal = ["bitwarden/internal"] # Internal testing methods secrets = ["bitwarden/secrets"] # Secrets manager API [dependencies] -async-lock = ">=3.3.0, <4.0" bitwarden = { workspace = true } log = ">=0.4.18, <0.5" schemars = ">=0.8.12, <0.9" diff --git a/crates/bitwarden-json/src/client.rs b/crates/bitwarden-json/src/client.rs index 91a00bcca..5233a4823 100644 --- a/crates/bitwarden-json/src/client.rs +++ b/crates/bitwarden-json/src/client.rs @@ -1,4 +1,3 @@ -use async_lock::Mutex; use bitwarden::client::client_settings::ClientSettings; #[cfg(feature = "secrets")] @@ -8,12 +7,12 @@ use crate::{ response::{Response, ResponseIntoString}, }; -pub struct Client(Mutex); +pub struct Client(bitwarden::Client); impl Client { pub fn new(settings_input: Option) -> Self { let settings = Self::parse_settings(settings_input); - Self(Mutex::new(bitwarden::Client::new(settings))) + Self(bitwarden::Client::new(settings)) } pub async fn run_command(&self, input_str: &str) -> String { @@ -45,7 +44,7 @@ impl Client { } }; - let mut client = self.0.lock().await; + let client = &self.0; match cmd { #[cfg(feature = "internal")] diff --git a/crates/bitwarden-uniffi/Cargo.toml b/crates/bitwarden-uniffi/Cargo.toml index e1e4bc10b..57415e501 100644 --- a/crates/bitwarden-uniffi/Cargo.toml +++ b/crates/bitwarden-uniffi/Cargo.toml @@ -18,7 +18,6 @@ crate-type = ["lib", "staticlib", "cdylib"] bench = false [dependencies] -async-lock = "3.3.0" async-trait = "0.1.80" bitwarden = { workspace = true, features = ["internal", "uniffi"] } bitwarden-core = { workspace = true, features = ["uniffi"] } diff --git a/crates/bitwarden/src/auth/client_auth.rs b/crates/bitwarden/src/auth/client_auth.rs index 32b429047..2ea92decc 100644 --- a/crates/bitwarden/src/auth/client_auth.rs +++ b/crates/bitwarden/src/auth/client_auth.rs @@ -180,7 +180,7 @@ mod tests { use crate::{auth::login::AccessTokenLoginRequest, secrets_manager::secrets::*}; // Create the mock server with the necessary routes for this test - let (_server, mut client) = crate::util::start_mock(vec![ + let (_server, client) = crate::util::start_mock(vec![ Mock::given(matchers::path("/identity/connect/token")) .respond_with(ResponseTemplate::new(200).set_body_json( serde_json::json!({ diff --git a/crates/bitwarden/src/secrets_manager/client_projects.rs b/crates/bitwarden/src/secrets_manager/client_projects.rs index acd4adfae..5c8f3657a 100644 --- a/crates/bitwarden/src/secrets_manager/client_projects.rs +++ b/crates/bitwarden/src/secrets_manager/client_projects.rs @@ -9,33 +9,33 @@ use crate::{ }; pub struct ClientProjects<'a> { - pub(crate) client: &'a mut crate::Client, + pub(crate) client: &'a crate::Client, } impl<'a> ClientProjects<'a> { - pub async fn get(&mut self, input: &ProjectGetRequest) -> Result { + pub async fn get(&self, input: &ProjectGetRequest) -> Result { get_project(self.client, input).await } - pub async fn create(&mut self, input: &ProjectCreateRequest) -> Result { + pub async fn create(&self, input: &ProjectCreateRequest) -> Result { create_project(self.client, input).await } - pub async fn list(&mut self, input: &ProjectsListRequest) -> Result { + pub async fn list(&self, input: &ProjectsListRequest) -> Result { list_projects(self.client, input).await } - pub async fn update(&mut self, input: &ProjectPutRequest) -> Result { + pub async fn update(&self, input: &ProjectPutRequest) -> Result { update_project(self.client, input).await } - pub async fn delete(&mut self, input: ProjectsDeleteRequest) -> Result { + pub async fn delete(&self, input: ProjectsDeleteRequest) -> Result { delete_projects(self.client, input).await } } impl<'a> Client { - pub fn projects(&'a mut self) -> ClientProjects<'a> { + pub fn projects(&'a self) -> ClientProjects<'a> { ClientProjects { client: self } } } diff --git a/crates/bitwarden/src/secrets_manager/client_secrets.rs b/crates/bitwarden/src/secrets_manager/client_secrets.rs index 6247c0856..1050c95d8 100644 --- a/crates/bitwarden/src/secrets_manager/client_secrets.rs +++ b/crates/bitwarden/src/secrets_manager/client_secrets.rs @@ -12,51 +12,51 @@ use crate::{ }; pub struct ClientSecrets<'a> { - pub(crate) client: &'a mut crate::Client, + pub(crate) client: &'a crate::Client, } impl<'a> ClientSecrets<'a> { - pub async fn get(&mut self, input: &SecretGetRequest) -> Result { + pub async fn get(&self, input: &SecretGetRequest) -> Result { get_secret(self.client, input).await } - pub async fn get_by_ids(&mut self, input: SecretsGetRequest) -> Result { + pub async fn get_by_ids(&self, input: SecretsGetRequest) -> Result { get_secrets_by_ids(self.client, input).await } - pub async fn create(&mut self, input: &SecretCreateRequest) -> Result { + pub async fn create(&self, input: &SecretCreateRequest) -> Result { create_secret(self.client, input).await } pub async fn list( - &mut self, + &self, input: &SecretIdentifiersRequest, ) -> Result { list_secrets(self.client, input).await } pub async fn list_by_project( - &mut self, + &self, input: &SecretIdentifiersByProjectRequest, ) -> Result { list_secrets_by_project(self.client, input).await } - pub async fn update(&mut self, input: &SecretPutRequest) -> Result { + pub async fn update(&self, input: &SecretPutRequest) -> Result { update_secret(self.client, input).await } - pub async fn delete(&mut self, input: SecretsDeleteRequest) -> Result { + pub async fn delete(&self, input: SecretsDeleteRequest) -> Result { delete_secrets(self.client, input).await } - pub async fn sync(&mut self, input: &SecretsSyncRequest) -> Result { + pub async fn sync(&self, input: &SecretsSyncRequest) -> Result { sync_secrets(self.client, input).await } } impl<'a> Client { - pub fn secrets(&'a mut self) -> ClientSecrets<'a> { + pub fn secrets(&'a self) -> ClientSecrets<'a> { ClientSecrets { client: self } } } diff --git a/crates/bitwarden/src/secrets_manager/projects/create.rs b/crates/bitwarden/src/secrets_manager/projects/create.rs index fc5a3b5ae..824a9f3df 100644 --- a/crates/bitwarden/src/secrets_manager/projects/create.rs +++ b/crates/bitwarden/src/secrets_manager/projects/create.rs @@ -18,7 +18,7 @@ pub struct ProjectCreateRequest { } pub(crate) async fn create_project( - client: &mut Client, + client: &Client, input: &ProjectCreateRequest, ) -> Result { let enc = client.get_encryption_settings()?; diff --git a/crates/bitwarden/src/secrets_manager/projects/delete.rs b/crates/bitwarden/src/secrets_manager/projects/delete.rs index bfc6e2d82..644666e35 100644 --- a/crates/bitwarden/src/secrets_manager/projects/delete.rs +++ b/crates/bitwarden/src/secrets_manager/projects/delete.rs @@ -16,7 +16,7 @@ pub struct ProjectsDeleteRequest { } pub(crate) async fn delete_projects( - client: &mut Client, + client: &Client, input: ProjectsDeleteRequest, ) -> Result { let config = client.get_api_configurations().await; diff --git a/crates/bitwarden/src/secrets_manager/projects/get.rs b/crates/bitwarden/src/secrets_manager/projects/get.rs index 3e8b7f94a..9eaf9f104 100644 --- a/crates/bitwarden/src/secrets_manager/projects/get.rs +++ b/crates/bitwarden/src/secrets_manager/projects/get.rs @@ -13,7 +13,7 @@ pub struct ProjectGetRequest { } pub(crate) async fn get_project( - client: &mut Client, + client: &Client, input: &ProjectGetRequest, ) -> Result { let config = client.get_api_configurations().await; diff --git a/crates/bitwarden/src/secrets_manager/projects/list.rs b/crates/bitwarden/src/secrets_manager/projects/list.rs index d5c7d4475..4cb50b7a7 100644 --- a/crates/bitwarden/src/secrets_manager/projects/list.rs +++ b/crates/bitwarden/src/secrets_manager/projects/list.rs @@ -17,7 +17,7 @@ pub struct ProjectsListRequest { } pub(crate) async fn list_projects( - client: &mut Client, + client: &Client, input: &ProjectsListRequest, ) -> Result { let config = client.get_api_configurations().await; diff --git a/crates/bitwarden/src/secrets_manager/projects/update.rs b/crates/bitwarden/src/secrets_manager/projects/update.rs index 55cd69757..1a6e963c0 100644 --- a/crates/bitwarden/src/secrets_manager/projects/update.rs +++ b/crates/bitwarden/src/secrets_manager/projects/update.rs @@ -20,7 +20,7 @@ pub struct ProjectPutRequest { } pub(crate) async fn update_project( - client: &mut Client, + client: &Client, input: &ProjectPutRequest, ) -> Result { let enc = client.get_encryption_settings()?; diff --git a/crates/bitwarden/src/secrets_manager/secrets/create.rs b/crates/bitwarden/src/secrets_manager/secrets/create.rs index 51c8b28a9..a3124e657 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/create.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/create.rs @@ -23,7 +23,7 @@ pub struct SecretCreateRequest { } pub(crate) async fn create_secret( - client: &mut Client, + client: &Client, input: &SecretCreateRequest, ) -> Result { let enc = client.get_encryption_settings()?; diff --git a/crates/bitwarden/src/secrets_manager/secrets/delete.rs b/crates/bitwarden/src/secrets_manager/secrets/delete.rs index 1c54e4169..fa019c731 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/delete.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/delete.rs @@ -16,7 +16,7 @@ pub struct SecretsDeleteRequest { } pub(crate) async fn delete_secrets( - client: &mut Client, + client: &Client, input: SecretsDeleteRequest, ) -> Result { let config = client.get_api_configurations().await; diff --git a/crates/bitwarden/src/secrets_manager/secrets/get.rs b/crates/bitwarden/src/secrets_manager/secrets/get.rs index eca4b410a..a9d285aa7 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/get.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/get.rs @@ -13,7 +13,7 @@ pub struct SecretGetRequest { } pub(crate) async fn get_secret( - client: &mut Client, + client: &Client, input: &SecretGetRequest, ) -> Result { let config = client.get_api_configurations().await; diff --git a/crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs b/crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs index 1575043d2..6ce3eeac8 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs @@ -14,7 +14,7 @@ pub struct SecretsGetRequest { } pub(crate) async fn get_secrets_by_ids( - client: &mut Client, + client: &Client, input: SecretsGetRequest, ) -> Result { let request = Some(GetSecretsRequestModel { ids: input.ids }); diff --git a/crates/bitwarden/src/secrets_manager/secrets/list.rs b/crates/bitwarden/src/secrets_manager/secrets/list.rs index 796aafe5d..3d7af09df 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/list.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/list.rs @@ -20,7 +20,7 @@ pub struct SecretIdentifiersRequest { } pub(crate) async fn list_secrets( - client: &mut Client, + client: &Client, input: &SecretIdentifiersRequest, ) -> Result { let config = client.get_api_configurations().await; @@ -43,7 +43,7 @@ pub struct SecretIdentifiersByProjectRequest { } pub(crate) async fn list_secrets_by_project( - client: &mut Client, + client: &Client, input: &SecretIdentifiersByProjectRequest, ) -> Result { let config = client.get_api_configurations().await; diff --git a/crates/bitwarden/src/secrets_manager/secrets/sync.rs b/crates/bitwarden/src/secrets_manager/secrets/sync.rs index 06c343ef7..804daa5bf 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/sync.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/sync.rs @@ -18,7 +18,7 @@ pub struct SecretsSyncRequest { } pub(crate) async fn sync_secrets( - client: &mut Client, + client: &Client, input: &SecretsSyncRequest, ) -> Result { let config = client.get_api_configurations().await; diff --git a/crates/bitwarden/src/secrets_manager/secrets/update.rs b/crates/bitwarden/src/secrets_manager/secrets/update.rs index 58665eac9..8d29927e8 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/update.rs +++ b/crates/bitwarden/src/secrets_manager/secrets/update.rs @@ -23,7 +23,7 @@ pub struct SecretPutRequest { } pub(crate) async fn update_secret( - client: &mut Client, + client: &Client, input: &SecretPutRequest, ) -> Result { let enc = client.get_encryption_settings()?; diff --git a/crates/bws/src/main.rs b/crates/bws/src/main.rs index eb5c8304b..5f9f9c6c9 100644 --- a/crates/bws/src/main.rs +++ b/crates/bws/src/main.rs @@ -125,7 +125,7 @@ async fn process_commands() -> Result<()> { access_token_obj.access_token_id.to_string(), )?; - let mut client = bitwarden::Client::new(settings); + let client = bitwarden::Client::new(settings); // Load session or return if no session exists let _ = client From 2b53a7c47ac0f6212684eb0649b2fd872ce49b86 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 14 Jun 2024 12:13:16 +0200 Subject: [PATCH 015/214] [PM-8301] Create bitwarden-send (#829) Extract send to separate crate. --- .github/workflows/publish-rust-crates.yml | 11 +++++ Cargo.lock | 20 ++++++++ Cargo.toml | 1 + crates/bitwarden-send/Cargo.toml | 38 +++++++++++++++ crates/bitwarden-send/src/error.rs | 11 +++++ crates/bitwarden-send/src/lib.rs | 9 ++++ .../src/tool => bitwarden-send/src}/send.rs | 47 +++++++++++-------- crates/bitwarden-send/src/uniffi_support.rs | 8 ++++ crates/bitwarden-send/uniffi.toml | 9 ++++ crates/bitwarden-uniffi/Cargo.toml | 1 + crates/bitwarden/Cargo.toml | 3 ++ crates/bitwarden/src/error.rs | 5 ++ crates/bitwarden/src/tool/mod.rs | 4 +- 13 files changed, 145 insertions(+), 22 deletions(-) create mode 100644 crates/bitwarden-send/Cargo.toml create mode 100644 crates/bitwarden-send/src/error.rs create mode 100644 crates/bitwarden-send/src/lib.rs rename crates/{bitwarden/src/tool => bitwarden-send/src}/send.rs (82%) create mode 100644 crates/bitwarden-send/src/uniffi_support.rs create mode 100644 crates/bitwarden-send/uniffi.toml diff --git a/.github/workflows/publish-rust-crates.yml b/.github/workflows/publish-rust-crates.yml index 2db11507b..75b82e5ad 100644 --- a/.github/workflows/publish-rust-crates.yml +++ b/.github/workflows/publish-rust-crates.yml @@ -54,6 +54,11 @@ on: required: true default: true type: boolean + publish_bitwarden-send: + description: "Publish bitwarden-send crate" + required: true + default: true + type: boolean publish_bitwarden-vault: description: "Publish bitwarden-valt crate" required: true @@ -96,6 +101,7 @@ jobs: PUBLISH_BITWARDEN_CLI: ${{ github.event.inputs.publish_bitwarden-cli }} PUBLISH_BITWARDEN_GENERATORS: ${{ github.event.inputs.publish_bitwarden-generators }} PUBLISH_BITWARDEN_EXPORTERS: ${{ github.event.inputs.publish_bitwarden-exporters }} + PUBLISH_BITWARDEN_SEND: ${{ github.event.inputs.publish_bitwarden-send }} PUBLISH_BITWARDEN_VAULT: ${{ github.event.inputs.publish_bitwarden-vault }} run: | if [[ "$PUBLISH_BITWARDEN" == "false" ]] && [[ "$PUBLISH_BITWARDEN_API_API" == "false" ]] && [[ "$PUBLISH_BITWARDEN_API_IDENTITY" == "false" ]]; then @@ -148,6 +154,11 @@ jobs: PACKAGES_LIST="$PACKAGES_LIST bitwarden-exporters" fi + if [[ "$PUBLISH_BITWARDEN_SEND" == "true" ]]; then + PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-send" + PACKAGES_LIST="$PACKAGES_LIST bitwarden-send" + fi + if [[ "$PUBLISH_BITWARDEN_VAULT" == "true" ]]; then PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-vault" PACKAGES_LIST="$PACKAGES_LIST bitwarden-vault" diff --git a/Cargo.lock b/Cargo.lock index 63e29ba26..723d9d338 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -365,6 +365,7 @@ dependencies = [ "bitwarden-crypto", "bitwarden-exporters", "bitwarden-generators", + "bitwarden-send", "bitwarden-vault", "chrono", "coset", @@ -545,6 +546,24 @@ dependencies = [ "tokio", ] +[[package]] +name = "bitwarden-send" +version = "0.5.0" +dependencies = [ + "base64 0.21.7", + "bitwarden-api-api", + "bitwarden-core", + "bitwarden-crypto", + "chrono", + "schemars", + "serde", + "serde_repr", + "thiserror", + "uniffi", + "uuid", + "zeroize", +] + [[package]] name = "bitwarden-uniffi" version = "0.1.0" @@ -555,6 +574,7 @@ dependencies = [ "bitwarden-core", "bitwarden-crypto", "bitwarden-generators", + "bitwarden-send", "bitwarden-vault", "chrono", "env_logger 0.11.3", diff --git a/Cargo.toml b/Cargo.toml index be4ab72c4..e76199527 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,6 +25,7 @@ bitwarden-core = { path = "crates/bitwarden-core", version = "=0.5.0" } bitwarden-crypto = { path = "crates/bitwarden-crypto", version = "=0.5.0" } bitwarden-exporters = { path = "crates/bitwarden-exporters", version = "=0.5.0" } bitwarden-generators = { path = "crates/bitwarden-generators", version = "=0.5.0" } +bitwarden-send = { path = "crates/bitwarden-send", version = "=0.5.0" } bitwarden-vault = { path = "crates/bitwarden-vault", version = "=0.5.0" } [workspace.lints.clippy] diff --git a/crates/bitwarden-send/Cargo.toml b/crates/bitwarden-send/Cargo.toml new file mode 100644 index 000000000..004660f2d --- /dev/null +++ b/crates/bitwarden-send/Cargo.toml @@ -0,0 +1,38 @@ +[package] +name = "bitwarden-send" +description = """ +Internal crate for the bitwarden crate. Do not use. +""" + +version.workspace = true +authors.workspace = true +edition.workspace = true +rust-version.workspace = true +homepage.workspace = true +repository.workspace = true +license-file.workspace = true +keywords.workspace = true + +[features] +uniffi = [ + "bitwarden-core/uniffi", + "bitwarden-crypto/uniffi", + "dep:uniffi", +] # Uniffi bindings + +[dependencies] +base64 = ">=0.21.2, <0.23" +bitwarden-api-api = { workspace = true } +bitwarden-core = { workspace = true } +bitwarden-crypto = { workspace = true } +chrono = { version = ">=0.4.26, <0.5", default-features = false } +schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } +serde = { version = ">=1.0, <2.0", features = ["derive"] } +serde_repr = ">=0.1.12, <0.2" +thiserror = ">=1.0.40, <2.0" +uniffi = { version = "=0.27.2", optional = true } +uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } +zeroize = { version = ">=1.7.0, <2.0" } + +[lints] +workspace = true diff --git a/crates/bitwarden-send/src/error.rs b/crates/bitwarden-send/src/error.rs new file mode 100644 index 000000000..9d220d9cd --- /dev/null +++ b/crates/bitwarden-send/src/error.rs @@ -0,0 +1,11 @@ +use thiserror::Error; + +#[derive(Debug, Error)] +pub enum SendParseError { + #[error(transparent)] + Chrono(#[from] chrono::ParseError), + #[error(transparent)] + Crypto(#[from] bitwarden_crypto::CryptoError), + #[error(transparent)] + MissingFieldError(#[from] bitwarden_core::MissingFieldError), +} diff --git a/crates/bitwarden-send/src/lib.rs b/crates/bitwarden-send/src/lib.rs new file mode 100644 index 000000000..b2bbf6e86 --- /dev/null +++ b/crates/bitwarden-send/src/lib.rs @@ -0,0 +1,9 @@ +#[cfg(feature = "uniffi")] +uniffi::setup_scaffolding!(); +#[cfg(feature = "uniffi")] +mod uniffi_support; + +mod error; +pub use error::SendParseError; +mod send; +pub use send::{Send, SendListView, SendView}; diff --git a/crates/bitwarden/src/tool/send.rs b/crates/bitwarden-send/src/send.rs similarity index 82% rename from crates/bitwarden/src/tool/send.rs rename to crates/bitwarden-send/src/send.rs index ce99396f1..0ada20147 100644 --- a/crates/bitwarden/src/tool/send.rs +++ b/crates/bitwarden-send/src/send.rs @@ -15,7 +15,7 @@ use serde_repr::{Deserialize_repr, Serialize_repr}; use uuid::Uuid; use zeroize::Zeroizing; -use crate::error::{Error, Result}; +use crate::error::SendParseError; const SEND_ITERATIONS: u32 = 100_000; @@ -142,7 +142,7 @@ pub struct SendListView { } impl Send { - pub(crate) fn get_key( + pub fn get_key( send_key: &EncString, enc_key: &SymmetricCryptoKey, ) -> Result { @@ -302,9 +302,9 @@ impl KeyEncryptable for SendView { } impl TryFrom for Send { - type Error = Error; + type Error = SendParseError; - fn try_from(send: SendResponseModel) -> Result { + fn try_from(send: SendResponseModel) -> Result { Ok(Send { id: send.id, access_id: send.access_id, @@ -336,9 +336,9 @@ impl From for SendType { } impl TryFrom for SendFile { - type Error = Error; + type Error = SendParseError; - fn try_from(file: SendFileModel) -> Result { + fn try_from(file: SendFileModel) -> Result { Ok(SendFile { id: file.id, file_name: require!(file.file_name).parse()?, @@ -349,9 +349,9 @@ impl TryFrom for SendFile { } impl TryFrom for SendText { - type Error = Error; + type Error = SendParseError; - fn try_from(text: SendTextModel) -> Result { + fn try_from(text: SendTextModel) -> Result { Ok(SendText { text: EncString::try_from_optional(text.text)?, hidden: text.hidden.unwrap_or(false), @@ -361,13 +361,24 @@ impl TryFrom for SendText { #[cfg(test)] mod tests { - use bitwarden_crypto::{KeyDecryptable, KeyEncryptable, MasterKey}; + use std::collections::HashMap; - use super::{Send, SendText, SendTextView, SendType}; - use crate::{ - client::{encryption_settings::EncryptionSettings, Kdf}, - tool::SendView, - }; + use bitwarden_crypto::{Kdf, KeyContainer, KeyDecryptable, KeyEncryptable, MasterKey}; + + use super::*; + + struct MockKeyContainer(HashMap, SymmetricCryptoKey>); + impl MockKeyContainer { + fn new(master_key: MasterKey, user_key: EncString) -> Result { + let user_key = master_key.decrypt_user_key(user_key)?; + Ok(Self(HashMap::from([(None, user_key)]))) + } + } + impl KeyContainer for MockKeyContainer { + fn get_key<'a>(&'a self, org_id: &Option) -> Option<&'a SymmetricCryptoKey> { + self.0.get(org_id) + } + } #[test] fn test_get_send_key() { @@ -380,10 +391,9 @@ mod tests { }, ) .unwrap(); - let enc = EncryptionSettings::new( + let enc = MockKeyContainer::new( master_key, "2.majkL1/hNz9yptLqNAUSnw==|RiOzMTTJMG948qu8O3Zm1EQUO2E8BuTwFKnO9LWQjMzxMWJM5GbyOq2/A+tumPbTERt4JWur/FKfgHb+gXuYiEYlXPMuVBvT7nv4LPytJuM=|IVqMxHJeR1ZXY0sGngTC0x+WqbG8p6V+BTrdgBbQXjM=".parse().unwrap(), - "2.kmLY8NJVuiKBFJtNd/ZFpA==|qOodlRXER+9ogCe3yOibRHmUcSNvjSKhdDuztLlucs10jLiNoVVVAc+9KfNErLSpx5wmUF1hBOJM8zwVPjgQTrmnNf/wuDpwiaCxNYb/0v4FygPy7ccAHK94xP1lfqq7U9+tv+/yiZSwgcT+xF0wFpoxQeNdNRFzPTuD9o4134n8bzacD9DV/WjcrXfRjbBCzzuUGj1e78+A7BWN7/5IWLz87KWk8G7O/W4+8PtEzlwkru6Wd1xO19GYU18oArCWCNoegSmcGn7w7NDEXlwD403oY8Oa7ylnbqGE28PVJx+HLPNIdSC6YKXeIOMnVs7Mctd/wXC93zGxAWD6ooTCzHSPVV50zKJmWIG2cVVUS7j35H3rGDtUHLI+ASXMEux9REZB8CdVOZMzp2wYeiOpggebJy6MKOZqPT1R3X0fqF2dHtRFPXrNsVr1Qt6bS9qTyO4ag1/BCvXF3P1uJEsI812BFAne3cYHy5bIOxuozPfipJrTb5WH35bxhElqwT3y/o/6JWOGg3HLDun31YmiZ2HScAsUAcEkA4hhoTNnqy4O2s3yVbCcR7jF7NLsbQc0MDTbnjxTdI4VnqUIn8s2c9hIJy/j80pmO9Bjxp+LQ9a2hUkfHgFhgHxZUVaeGVth8zG2kkgGdrp5VHhxMVFfvB26Ka6q6qE/UcS2lONSv+4T8niVRJz57qwctj8MNOkA3PTEfe/DP/LKMefke31YfT0xogHsLhDkx+mS8FCc01HReTjKLktk/Jh9mXwC5oKwueWWwlxI935ecn+3I2kAuOfMsgPLkoEBlwgiREC1pM7VVX1x8WmzIQVQTHd4iwnX96QewYckGRfNYWz/zwvWnjWlfcg8kRSe+68EHOGeRtC5r27fWLqRc0HNcjwpgHkI/b6czerCe8+07TWql4keJxJxhBYj3iOH7r9ZS8ck51XnOb8tGL1isimAJXodYGzakwktqHAD7MZhS+P02O+6jrg7d+yPC2ZCuS/3TOplYOCHQIhnZtR87PXTUwr83zfOwAwCyv6KP84JUQ45+DItrXLap7nOVZKQ5QxYIlbThAO6eima6Zu5XHfqGPMNWv0bLf5+vAjIa5np5DJrSwz9no/hj6CUh0iyI+SJq4RGI60lKtypMvF6MR3nHLEHOycRUQbZIyTHWl4QQLdHzuwN9lv10ouTEvNr6sFflAX2yb6w3hlCo7oBytH3rJekjb3IIOzBpeTPIejxzVlh0N9OT5MZdh4sNKYHUoWJ8mnfjdM+L4j5Q2Kgk/XiGDgEebkUxiEOQUdVpePF5uSCE+TPav/9FIRGXGiFn6NJMaU7aBsDTFBLloffFLYDpd8/bTwoSvifkj7buwLYM+h/qcnfdy5FWau1cKav+Blq/ZC0qBpo658RTC8ZtseAFDgXoQZuksM10hpP9bzD04Bx30xTGX81QbaSTNwSEEVrOtIhbDrj9OI43KH4O6zLzK+t30QxAv5zjk10RZ4+5SAdYndIlld9Y62opCfPDzRy3ubdve4ZEchpIKWTQvIxq3T5ogOhGaWBVYnkMtM2GVqvWV//46gET5SH/MdcwhACUcZ9kCpMnWH9CyyUwYvTT3UlNyV+DlS27LMPvaw7tx7qa+GfNCoCBd8S4esZpQYK/WReiS8=|pc7qpD42wxyXemdNPuwxbh8iIaryrBPu8f/DGwYdHTw=".parse().unwrap(), ).unwrap(); let k = enc.get_key(&None).unwrap(); @@ -398,7 +408,7 @@ mod tests { assert_eq!(send_key_b64, "IR9ImHGm6rRuIjiN7csj94bcZR5WYTJj5GtNfx33zm6tJCHUl+QZlpNPba8g2yn70KnOHsAODLcR0um6E3MAlg=="); } - fn build_encryption_settings() -> EncryptionSettings { + fn build_encryption_settings() -> MockKeyContainer { let master_key = MasterKey::derive( "asdfasdfasdf".as_bytes(), "test@bitwarden.com".as_bytes(), @@ -408,10 +418,9 @@ mod tests { ) .unwrap(); - EncryptionSettings::new( + MockKeyContainer::new( master_key, "2.Q/2PhzcC7GdeiMHhWguYAQ==|GpqzVdr0go0ug5cZh1n+uixeBC3oC90CIe0hd/HWA/pTRDZ8ane4fmsEIcuc8eMKUt55Y2q/fbNzsYu41YTZzzsJUSeqVjT8/iTQtgnNdpo=|dwI+uyvZ1h/iZ03VQ+/wrGEFYVewBUUl/syYgjsNMbE=".parse().unwrap(), - "2.yN7l00BOlUE0Sb0M//Q53w==|EwKG/BduQRQ33Izqc/ogoBROIoI5dmgrxSo82sgzgAMIBt3A2FZ9vPRMY+GWT85JiqytDitGR3TqwnFUBhKUpRRAq4x7rA6A1arHrFp5Tp1p21O3SfjtvB3quiOKbqWk6ZaU1Np9HwqwAecddFcB0YyBEiRX3VwF2pgpAdiPbSMuvo2qIgyob0CUoC/h4Bz1be7Qa7B0Xw9/fMKkB1LpOm925lzqosyMQM62YpMGkjMsbZz0uPopu32fxzDWSPr+kekNNyLt9InGhTpxLmq1go/pXR2uw5dfpXc5yuta7DB0EGBwnQ8Vl5HPdDooqOTD9I1jE0mRyuBpWTTI3FRnu3JUh3rIyGBJhUmHqGZvw2CKdqHCIrQeQkkEYqOeJRJVdBjhv5KGJifqT3BFRwX/YFJIChAQpebNQKXe/0kPivWokHWwXlDB7S7mBZzhaAPidZvnuIhalE2qmTypDwHy22FyqV58T8MGGMchcASDi/QXI6kcdpJzPXSeU9o+NC68QDlOIrMVxKFeE7w7PvVmAaxEo0YwmuAzzKy9QpdlK0aab/xEi8V4iXj4hGepqAvHkXIQd+r3FNeiLfllkb61p6WTjr5urcmDQMR94/wYoilpG5OlybHdbhsYHvIzYoLrC7fzl630gcO6t4nM24vdB6Ymg9BVpEgKRAxSbE62Tqacxqnz9AcmgItb48NiR/He3n3ydGjPYuKk/ihZMgEwAEZvSlNxYONSbYrIGDtOY+8Nbt6KiH3l06wjZW8tcmFeVlWv+tWotnTY9IqlAfvNVTjtsobqtQnvsiDjdEVtNy/s2ci5TH+NdZluca2OVEr91Wayxh70kpM6ib4UGbfdmGgCo74gtKvKSJU0rTHakQ5L9JlaSDD5FamBRyI0qfL43Ad9qOUZ8DaffDCyuaVyuqk7cz9HwmEmvWU3VQ+5t06n/5kRDXttcw8w+3qClEEdGo1KeENcnXCB32dQe3tDTFpuAIMLqwXs6FhpawfZ5kPYvLPczGWaqftIs/RXJ/EltGc0ugw2dmTLpoQhCqrcKEBDoYVk0LDZKsnzitOGdi9mOWse7Se8798ib1UsHFUjGzISEt6upestxOeupSTOh0v4+AjXbDzRUyogHww3V+Bqg71bkcMxtB+WM+pn1XNbVTyl9NR040nhP7KEf6e9ruXAtmrBC2ah5cFEpLIot77VFZ9ilLuitSz+7T8n1yAh1IEG6xxXxninAZIzi2qGbH69O5RSpOJuJTv17zTLJQIIc781JwQ2TTwTGnx5wZLbffhCasowJKd2EVcyMJyhz6ru0PvXWJ4hUdkARJs3Xu8dus9a86N8Xk6aAPzBDqzYb1vyFIfBxP0oO8xFHgd30Cgmz8UrSE3qeWRrF8ftrI6xQnFjHBGWD/JWSvd6YMcQED0aVuQkuNW9ST/DzQThPzRfPUoiL10yAmV7Ytu4fR3x2sF0Yfi87YhHFuCMpV/DsqxmUizyiJuD938eRcH8hzR/VO53Qo3UIsqOLcyXtTv6THjSlTopQ+JOLOnHm1w8dzYbLN44OG44rRsbihMUQp+wUZ6bsI8rrOnm9WErzkbQFbrfAINdoCiNa6cimYIjvvnMTaFWNymqY1vZxGztQiMiHiHYwTfwHTXrb9j0uPM=|09J28iXv9oWzYtzK2LBT6Yht4IT4MijEkk0fwFdrVQ4=".parse().unwrap(), ).unwrap() } diff --git a/crates/bitwarden-send/src/uniffi_support.rs b/crates/bitwarden-send/src/uniffi_support.rs new file mode 100644 index 000000000..932f0de7a --- /dev/null +++ b/crates/bitwarden-send/src/uniffi_support.rs @@ -0,0 +1,8 @@ +use bitwarden_crypto::EncString; +use uuid::Uuid; + +uniffi::ffi_converter_forward!(EncString, bitwarden_crypto::UniFfiTag, crate::UniFfiTag); + +type DateTime = chrono::DateTime; +uniffi::ffi_converter_forward!(DateTime, bitwarden_core::UniFfiTag, crate::UniFfiTag); +uniffi::ffi_converter_forward!(Uuid, bitwarden_core::UniFfiTag, crate::UniFfiTag); diff --git a/crates/bitwarden-send/uniffi.toml b/crates/bitwarden-send/uniffi.toml new file mode 100644 index 000000000..674ea3684 --- /dev/null +++ b/crates/bitwarden-send/uniffi.toml @@ -0,0 +1,9 @@ +[bindings.kotlin] +package_name = "com.bitwarden.send" +generate_immutable_records = true +android = true + +[bindings.swift] +ffi_module_name = "BitwardenSendFFI" +module_name = "BitwardenSend" +generate_immutable_records = true diff --git a/crates/bitwarden-uniffi/Cargo.toml b/crates/bitwarden-uniffi/Cargo.toml index 57415e501..b9ab39aa2 100644 --- a/crates/bitwarden-uniffi/Cargo.toml +++ b/crates/bitwarden-uniffi/Cargo.toml @@ -23,6 +23,7 @@ bitwarden = { workspace = true, features = ["internal", "uniffi"] } bitwarden-core = { workspace = true, features = ["uniffi"] } bitwarden-crypto = { workspace = true, features = ["uniffi"] } bitwarden-generators = { workspace = true, features = ["uniffi"] } +bitwarden-send = { workspace = true, features = ["uniffi"] } bitwarden-vault = { workspace = true, features = ["uniffi"] } chrono = { version = ">=0.4.26, <0.5", features = [ "serde", diff --git a/crates/bitwarden/Cargo.toml b/crates/bitwarden/Cargo.toml index e25f4d68a..4bf6873dc 100644 --- a/crates/bitwarden/Cargo.toml +++ b/crates/bitwarden/Cargo.toml @@ -19,6 +19,7 @@ default = ["secrets"] internal = [ "dep:bitwarden-exporters", "dep:bitwarden-generators", + "dep:bitwarden-send", "dep:bitwarden-vault", ] # Internal testing methods no-memory-hardening = [ @@ -28,6 +29,7 @@ uniffi = [ "bitwarden-core/uniffi", "bitwarden-crypto/uniffi", "bitwarden-generators/uniffi", + "bitwarden-send/uniffi", "bitwarden-vault/uniffi", "dep:uniffi", "dep:passkey", @@ -46,6 +48,7 @@ bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } bitwarden-exporters = { workspace = true, optional = true } bitwarden-generators = { workspace = true, optional = true } +bitwarden-send = { workspace = true, optional = true } bitwarden-vault = { workspace = true, optional = true } chrono = { version = ">=0.4.26, <0.5", features = [ "clock", diff --git a/crates/bitwarden/src/error.rs b/crates/bitwarden/src/error.rs index a7f7e3c3d..c6312750e 100644 --- a/crates/bitwarden/src/error.rs +++ b/crates/bitwarden/src/error.rs @@ -64,6 +64,11 @@ pub enum Error { #[error(transparent)] PasswordError(#[from] PasswordError), + // Send + #[cfg(feature = "internal")] + #[error(transparent)] + SendParseError(#[from] bitwarden_send::SendParseError), + // Vault #[cfg(feature = "internal")] #[error(transparent)] diff --git a/crates/bitwarden/src/tool/mod.rs b/crates/bitwarden/src/tool/mod.rs index 0f4f34564..f67ef0fc1 100644 --- a/crates/bitwarden/src/tool/mod.rs +++ b/crates/bitwarden/src/tool/mod.rs @@ -1,7 +1,5 @@ mod exporters; pub use exporters::{ClientExporters, ExportFormat}; mod client_generator; +pub use bitwarden_send::*; pub use client_generator::ClientGenerator; - -mod send; -pub use send::{Send, SendListView, SendView}; From fb3f1e71a511f603b9d8820efe547df9d293f657 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 14:37:06 +0200 Subject: [PATCH 016/214] [deps]: Update @types/node to v18.19.34 (#822) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@types/node](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node) ([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node)) | [`18.19.33` -> `18.19.34`](https://renovatebot.com/diffs/npm/@types%2fnode/18.19.33/18.19.34) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2fnode/18.19.34?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@types%2fnode/18.19.34?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@types%2fnode/18.19.33/18.19.34?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2fnode/18.19.33/18.19.34?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- languages/js/sdk-client/package-lock.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index 70f0b3a6d..b9a9882d3 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -39,10 +39,11 @@ } }, "node_modules/@types/node": { - "version": "18.19.33", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.33.tgz", - "integrity": "sha512-NR9+KrpSajr2qBVp/Yt5TU/rp+b5Mayi3+OlMlcg2cVCfRmcG5PWZ7S4+MG9PZ5gWBoc9Pd0BKSRViuBCRPu0A==", + "version": "18.19.34", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.34.tgz", + "integrity": "sha512-eXF4pfBNV5DAMKGbI02NnDtWrQ40hAN558/2vvS4gMpMIxaf6JmD7YjnZbq0Q9TDSSkKBamime8ewRoomHdt4g==", "dev": true, + "license": "MIT", "dependencies": { "undici-types": "~5.26.4" } From e4e298b0e332c8fb63a75452302da430f617e689 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 14:43:24 +0200 Subject: [PATCH 017/214] [deps]: Update Rust crate clap to v4.5.7 (#823) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [clap](https://togithub.com/clap-rs/clap) | build-dependencies | patch | `4.5.4` -> `4.5.7` | | [clap](https://togithub.com/clap-rs/clap) | dependencies | patch | `4.5.4` -> `4.5.7` | --- ### Release Notes
clap-rs/clap (clap) ### [`v4.5.7`](https://togithub.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#457---2024-06-10) [Compare Source](https://togithub.com/clap-rs/clap/compare/v4.5.6...v4.5.7) ##### Fixes - Clean up error message when too few arguments for `num_args` ### [`v4.5.6`](https://togithub.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#456---2024-06-06) [Compare Source](https://togithub.com/clap-rs/clap/compare/v4.5.5...v4.5.6) ### [`v4.5.5`](https://togithub.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#455---2024-06-06) [Compare Source](https://togithub.com/clap-rs/clap/compare/v4.5.4...v4.5.5) ##### Fixes - Allow `exclusive` to override `required_unless_present`, `required_unless_present_any`, `required_unless_present_all`
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 723d9d338..12fb59c50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -855,9 +855,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.4" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" +checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" dependencies = [ "clap_builder", "clap_derive", @@ -865,9 +865,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.2" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" +checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" dependencies = [ "anstream", "anstyle", @@ -886,9 +886,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.4" +version = "4.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" +checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" dependencies = [ "heck 0.5.0", "proc-macro2", From 20d176a9b77ab1ac008ad827e5871eb368aa10fe Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 15:10:52 +0200 Subject: [PATCH 018/214] [PM-8872] [deps]: Update Rust crate clap_mangen to v0.2.21 (#844) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [clap_mangen](https://togithub.com/clap-rs/clap) | build-dependencies | patch | `0.2.20` -> `0.2.21` | --- ### Release Notes
clap-rs/clap (clap_mangen) ### [`v0.2.21`](https://togithub.com/clap-rs/clap/compare/clap_mangen-v0.2.20...clap_mangen-v0.2.21) [Compare Source](https://togithub.com/clap-rs/clap/compare/clap_mangen-v0.2.20...clap_mangen-v0.2.21)
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). [PM-8872](https://bitwarden.atlassian.net/browse/PM-8872) [PM-8872]: https://bitwarden.atlassian.net/browse/PM-8872?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 12fb59c50..c93974ae7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -904,9 +904,9 @@ checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "clap_mangen" -version = "0.2.20" +version = "0.2.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1dd95b5ebb5c1c54581dd6346f3ed6a79a3eef95dd372fc2ac13d535535300e" +checksum = "74b70fc13e60c0e1d490dc50eb73a749be6d81f4ef03783df1d9b7b0c62bc937" dependencies = [ "clap", "roff", From 882ccaf8ed018cda50418537558710bb6df52699 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 14 Jun 2024 15:11:39 +0200 Subject: [PATCH 019/214] [PM-8301] Create bitwarden-fido crate (#840) Create bitwarden-fido for authenticator logic. --- .github/workflows/publish-rust-crates.yml | 31 ++++++++---- Cargo.lock | 27 ++++++++-- Cargo.toml | 1 + crates/bitwarden-fido/Cargo.toml | 41 ++++++++++++++++ .../src}/authenticator.rs | 49 +++++++++++++------ .../fido2 => bitwarden-fido/src}/client.rs | 2 +- .../fido2 => bitwarden-fido/src}/crypto.rs | 2 +- .../mod.rs => bitwarden-fido/src/lib.rs} | 41 ++-------------- .../fido2 => bitwarden-fido/src}/traits.rs | 0 .../fido2 => bitwarden-fido/src}/types.rs | 2 +- crates/bitwarden-fido/uniffi.toml | 9 ++++ crates/bitwarden-uniffi/Cargo.toml | 1 + crates/bitwarden/Cargo.toml | 8 +-- crates/bitwarden/src/error.rs | 15 +++--- crates/bitwarden/src/platform/client_fido.rs | 41 ++++++++++++++++ .../bitwarden/src/platform/client_platform.rs | 2 +- crates/bitwarden/src/platform/mod.rs | 11 +++-- 17 files changed, 196 insertions(+), 87 deletions(-) create mode 100644 crates/bitwarden-fido/Cargo.toml rename crates/{bitwarden/src/platform/fido2 => bitwarden-fido/src}/authenticator.rs (93%) rename crates/{bitwarden/src/platform/fido2 => bitwarden-fido/src}/client.rs (99%) rename crates/{bitwarden/src/platform/fido2 => bitwarden-fido/src}/crypto.rs (94%) rename crates/{bitwarden/src/platform/fido2/mod.rs => bitwarden-fido/src/lib.rs} (90%) rename crates/{bitwarden/src/platform/fido2 => bitwarden-fido/src}/traits.rs (100%) rename crates/{bitwarden/src/platform/fido2 => bitwarden-fido/src}/types.rs (99%) create mode 100644 crates/bitwarden-fido/uniffi.toml create mode 100644 crates/bitwarden/src/platform/client_fido.rs diff --git a/.github/workflows/publish-rust-crates.yml b/.github/workflows/publish-rust-crates.yml index 75b82e5ad..deeef87cd 100644 --- a/.github/workflows/publish-rust-crates.yml +++ b/.github/workflows/publish-rust-crates.yml @@ -44,13 +44,18 @@ on: required: true default: true type: boolean - publish_bitwarden-generators: - description: "Publish bitwarden-generators crate" + publish_bitwarden-exporters: + description: "Publish bitwarden-exporters crate" required: true default: true type: boolean - publish_bitwarden-exporters: - description: "Publish bitwarden-exporters crate" + publish_bitwarden-fido: + description: "Publish bitwarden-fido crate" + required: true + default: true + type: boolean + publish_bitwarden-generators: + description: "Publish bitwarden-generators crate" required: true default: true type: boolean @@ -99,8 +104,9 @@ jobs: PUBLISH_BITWARDEN_CORE: ${{ github.event.inputs.publish_bitwarden-core }} PUBLISH_BITWARDEN_CRYPTO: ${{ github.event.inputs.publish_bitwarden-crypto }} PUBLISH_BITWARDEN_CLI: ${{ github.event.inputs.publish_bitwarden-cli }} - PUBLISH_BITWARDEN_GENERATORS: ${{ github.event.inputs.publish_bitwarden-generators }} PUBLISH_BITWARDEN_EXPORTERS: ${{ github.event.inputs.publish_bitwarden-exporters }} + PUBLISH_BITWARDEN_FIDO: ${{ github.event.inputs.publish_bitwarden-fido }} + PUBLISH_BITWARDEN_GENERATORS: ${{ github.event.inputs.publish_bitwarden-generators }} PUBLISH_BITWARDEN_SEND: ${{ github.event.inputs.publish_bitwarden-send }} PUBLISH_BITWARDEN_VAULT: ${{ github.event.inputs.publish_bitwarden-vault }} run: | @@ -144,16 +150,21 @@ jobs: PACKAGES_LIST="$PACKAGES_LIST bitwarden-cli" fi - if [[ "$PUBLISH_BITWARDEN_GENERATORS" == "true" ]]; then - PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-generators" - PACKAGES_LIST="$PACKAGES_LIST bitwarden-generators" - fi - if [[ "$PUBLISH_BITWARDEN_EXPORTERS" == "true" ]]; then PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-exporters" PACKAGES_LIST="$PACKAGES_LIST bitwarden-exporters" fi + if [[ "$PUBLISH_BITWARDEN_FIDO" == "true" ]]; then + PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-fido" + PACKAGES_LIST="$PACKAGES_LIST bitwarden-fido" + fi + + if [[ "$PUBLISH_BITWARDEN_GENERATORS" == "true" ]]; then + PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-generators" + PACKAGES_LIST="$PACKAGES_LIST bitwarden-generators" + fi + if [[ "$PUBLISH_BITWARDEN_SEND" == "true" ]]; then PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-send" PACKAGES_LIST="$PACKAGES_LIST bitwarden-send" diff --git a/Cargo.lock b/Cargo.lock index c93974ae7..08dd83547 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -364,15 +364,13 @@ dependencies = [ "bitwarden-core", "bitwarden-crypto", "bitwarden-exporters", + "bitwarden-fido", "bitwarden-generators", "bitwarden-send", "bitwarden-vault", "chrono", - "coset", "getrandom", "log", - "p256", - "passkey", "rand", "rand_chacha", "reqwest", @@ -494,6 +492,28 @@ dependencies = [ "uuid", ] +[[package]] +name = "bitwarden-fido" +version = "0.5.0" +dependencies = [ + "async-trait", + "base64 0.21.7", + "bitwarden-core", + "bitwarden-crypto", + "bitwarden-vault", + "chrono", + "coset", + "log", + "p256", + "passkey", + "reqwest", + "serde", + "serde_json", + "thiserror", + "uniffi", + "uuid", +] + [[package]] name = "bitwarden-generators" version = "0.5.0" @@ -573,6 +593,7 @@ dependencies = [ "bitwarden", "bitwarden-core", "bitwarden-crypto", + "bitwarden-fido", "bitwarden-generators", "bitwarden-send", "bitwarden-vault", diff --git a/Cargo.toml b/Cargo.toml index e76199527..121c7733f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,6 +24,7 @@ bitwarden-cli = { path = "crates/bitwarden-cli", version = "=0.5.0" } bitwarden-core = { path = "crates/bitwarden-core", version = "=0.5.0" } bitwarden-crypto = { path = "crates/bitwarden-crypto", version = "=0.5.0" } bitwarden-exporters = { path = "crates/bitwarden-exporters", version = "=0.5.0" } +bitwarden-fido = { path = "crates/bitwarden-fido", version = "=0.5.0" } bitwarden-generators = { path = "crates/bitwarden-generators", version = "=0.5.0" } bitwarden-send = { path = "crates/bitwarden-send", version = "=0.5.0" } bitwarden-vault = { path = "crates/bitwarden-vault", version = "=0.5.0" } diff --git a/crates/bitwarden-fido/Cargo.toml b/crates/bitwarden-fido/Cargo.toml new file mode 100644 index 000000000..d34177fd2 --- /dev/null +++ b/crates/bitwarden-fido/Cargo.toml @@ -0,0 +1,41 @@ +[package] +name = "bitwarden-fido" +description = """ +Internal crate for the bitwarden crate. Do not use. +""" + +version.workspace = true +authors.workspace = true +edition.workspace = true +rust-version.workspace = true +homepage.workspace = true +repository.workspace = true +license-file.workspace = true +keywords.workspace = true + +[features] +uniffi = ["dep:uniffi"] + +[dependencies] +async-trait = ">=0.1.80, <0.2" +base64 = ">=0.21.2, <0.23" +bitwarden-core = { workspace = true } +bitwarden-crypto = { workspace = true } +bitwarden-vault = { workspace = true } +chrono = { version = ">=0.4.26, <0.5", features = [ + "clock", + "serde", +], default-features = false } +coset = { version = "0.3.7" } +log = ">=0.4.18, <0.5" +p256 = { version = ">=0.13.2, <0.14" } +passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "c48c2ddfd6b884b2d754432576c66cb2b1985a3a" } +reqwest = { version = ">=0.12, <0.13", default-features = false } +serde = { version = ">=1.0, <2.0", features = ["derive"] } +serde_json = ">=1.0.96, <2.0" +thiserror = ">=1.0.40, <2.0" +uniffi = { version = "=0.27.2", optional = true } +uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } + +[lints] +workspace = true diff --git a/crates/bitwarden/src/platform/fido2/authenticator.rs b/crates/bitwarden-fido/src/authenticator.rs similarity index 93% rename from crates/bitwarden/src/platform/fido2/authenticator.rs rename to crates/bitwarden-fido/src/authenticator.rs index d0a7b83e4..edc5033a7 100644 --- a/crates/bitwarden/src/platform/fido2/authenticator.rs +++ b/crates/bitwarden-fido/src/authenticator.rs @@ -1,7 +1,7 @@ -use std::sync::Mutex; +use std::sync::{Arc, Mutex}; use bitwarden_core::VaultLocked; -use bitwarden_crypto::{CryptoError, KeyEncryptable}; +use bitwarden_crypto::{CryptoError, KeyContainer, KeyEncryptable}; use bitwarden_vault::{CipherError, CipherView, Fido2CredentialView}; use log::error; use passkey::{ @@ -18,11 +18,8 @@ use super::{ Fido2CredentialStore, Fido2UserInterface, SelectedCredential, UnknownEnum, AAGUID, }; use crate::{ - platform::fido2::{ - fill_with_credential, string_to_guid_bytes, try_from_credential_full, Fido2CallbackError, - FillCredentialError, InvalidGuid, - }, - Client, + fill_with_credential, string_to_guid_bytes, try_from_credential_full, Fido2CallbackError, + FillCredentialError, InvalidGuid, }; #[derive(Debug, Error)] @@ -76,16 +73,36 @@ pub enum SilentlyDiscoverCredentialsError { Fido2CallbackError(#[from] Fido2CallbackError), } +/// Temporary trait for solving a circular dependency. When moving `Client` to `bitwarden-core` +/// remove this trait. +pub trait FidoEncryptionSettingStore: Send + Sync { + fn get_encryption_settings(&self) -> Result, VaultLocked>; +} + pub struct Fido2Authenticator<'a> { - pub(crate) client: &'a Client, - pub(crate) user_interface: &'a dyn Fido2UserInterface, - pub(crate) credential_store: &'a dyn Fido2CredentialStore, + pub client: &'a dyn FidoEncryptionSettingStore, + pub user_interface: &'a dyn Fido2UserInterface, + pub credential_store: &'a dyn Fido2CredentialStore, pub(crate) selected_cipher: Mutex>, pub(crate) requested_uv: Mutex>, } impl<'a> Fido2Authenticator<'a> { + pub fn new( + client: &'a dyn FidoEncryptionSettingStore, + user_interface: &'a dyn Fido2UserInterface, + credential_store: &'a dyn Fido2CredentialStore, + ) -> Fido2Authenticator<'a> { + Fido2Authenticator { + client, + user_interface, + credential_store, + selected_cipher: Mutex::new(None), + requested_uv: Mutex::new(None), + } + } + pub async fn make_credential( &mut self, request: MakeCredentialRequest, @@ -225,7 +242,7 @@ impl<'a> Fido2Authenticator<'a> { Ok(result .into_iter() - .flat_map(|c| c.decrypt_fido2_credentials(&enc)) + .flat_map(|c| c.decrypt_fido2_credentials(&*enc)) .flatten() .collect()) } @@ -268,7 +285,7 @@ impl<'a> Fido2Authenticator<'a> { .clone() .ok_or(GetSelectedCredentialError::NoSelectedCredential)?; - let creds = cipher.decrypt_fido2_credentials(&enc)?; + let creds = cipher.decrypt_fido2_credentials(&*enc)?; let credential = creds .first() @@ -339,7 +356,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { if this.create_credential { Ok(creds .into_iter() - .map(|c| CipherViewContainer::new(c, &enc)) + .map(|c| CipherViewContainer::new(c, &*enc)) .collect::>()?) } else { let picked = this @@ -355,7 +372,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { .expect("Mutex is not poisoned") .replace(picked.clone()); - Ok(vec![CipherViewContainer::new(picked, &enc)?]) + Ok(vec![CipherViewContainer::new(picked, &*enc)?]) } } @@ -411,7 +428,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { .clone() .ok_or(InnerError::NoSelectedCredential)?; - selected.set_new_fido2_credentials(&enc, vec![cred])?; + selected.set_new_fido2_credentials(&*enc, vec![cred])?; // Store the updated credential for later use this.authenticator @@ -481,7 +498,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { let cred = fill_with_credential(&selected.credential, cred)?; let mut selected = selected.cipher; - selected.set_new_fido2_credentials(&enc, vec![cred])?; + selected.set_new_fido2_credentials(&*enc, vec![cred])?; // Store the updated credential for later use this.authenticator diff --git a/crates/bitwarden/src/platform/fido2/client.rs b/crates/bitwarden-fido/src/client.rs similarity index 99% rename from crates/bitwarden/src/platform/fido2/client.rs rename to crates/bitwarden-fido/src/client.rs index 0000bc69c..a72dae6f5 100644 --- a/crates/bitwarden/src/platform/fido2/client.rs +++ b/crates/bitwarden-fido/src/client.rs @@ -37,7 +37,7 @@ impl From for Fido2ClientError { } pub struct Fido2Client<'a> { - pub(crate) authenticator: Fido2Authenticator<'a>, + pub authenticator: Fido2Authenticator<'a>, } impl<'a> Fido2Client<'a> { diff --git a/crates/bitwarden/src/platform/fido2/crypto.rs b/crates/bitwarden-fido/src/crypto.rs similarity index 94% rename from crates/bitwarden/src/platform/fido2/crypto.rs rename to crates/bitwarden-fido/src/crypto.rs index bca8e2a92..8c72b5341 100644 --- a/crates/bitwarden/src/platform/fido2/crypto.rs +++ b/crates/bitwarden-fido/src/crypto.rs @@ -11,7 +11,7 @@ pub enum CoseKeyToPkcs8Error { FailedToConvertP256PrivateKeyToPkcs8, } -pub fn cose_key_to_pkcs8(cose_key: &CoseKey) -> Result, CoseKeyToPkcs8Error> { +pub(crate) fn cose_key_to_pkcs8(cose_key: &CoseKey) -> Result, CoseKeyToPkcs8Error> { // cose_key. let secret_key = private_key_from_cose_key(cose_key).map_err(|error| { log::error!("Failed to extract private key from cose_key: {:?}", error); diff --git a/crates/bitwarden/src/platform/fido2/mod.rs b/crates/bitwarden-fido/src/lib.rs similarity index 90% rename from crates/bitwarden/src/platform/fido2/mod.rs rename to crates/bitwarden-fido/src/lib.rs index da9d19a65..f3532a3c8 100644 --- a/crates/bitwarden/src/platform/fido2/mod.rs +++ b/crates/bitwarden-fido/src/lib.rs @@ -1,5 +1,3 @@ -use std::sync::Mutex; - use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine}; use bitwarden_crypto::KeyContainer; use bitwarden_vault::{ @@ -8,14 +6,17 @@ use bitwarden_vault::{ use crypto::{CoseKeyToPkcs8Error, PrivateKeyFromSecretKeyError}; use passkey::types::{ctap2::Aaguid, Passkey}; +#[cfg(feature = "uniffi")] +uniffi::setup_scaffolding!(); + mod authenticator; mod client; mod crypto; mod traits; mod types; - pub use authenticator::{ - Fido2Authenticator, GetAssertionError, MakeCredentialError, SilentlyDiscoverCredentialsError, + Fido2Authenticator, FidoEncryptionSettingStore, GetAssertionError, MakeCredentialError, + SilentlyDiscoverCredentialsError, }; pub use client::{Fido2Client, Fido2ClientError}; pub use passkey::authenticator::UIHint; @@ -33,7 +34,6 @@ pub use types::{ }; use self::crypto::{cose_key_to_pkcs8, pkcs8_to_cose_key}; -use crate::Client; // This is the AAGUID for the Bitwarden Passkey provider (d548826e-79b4-db40-a3d8-11116f7e8349) // It is used for the Relaying Parties to identify the authenticator during registration @@ -41,37 +41,6 @@ const AAGUID: Aaguid = Aaguid([ 0xd5, 0x48, 0x82, 0x6e, 0x79, 0xb4, 0xdb, 0x40, 0xa3, 0xd8, 0x11, 0x11, 0x6f, 0x7e, 0x83, 0x49, ]); -pub struct ClientFido2<'a> { - #[allow(dead_code)] - pub(crate) client: &'a Client, -} - -impl<'a> ClientFido2<'a> { - pub fn create_authenticator( - &'a self, - user_interface: &'a dyn Fido2UserInterface, - credential_store: &'a dyn Fido2CredentialStore, - ) -> Fido2Authenticator<'a> { - Fido2Authenticator { - client: self.client, - user_interface, - credential_store, - selected_cipher: Mutex::new(None), - requested_uv: Mutex::new(None), - } - } - - pub fn create_client( - &'a self, - user_interface: &'a dyn Fido2UserInterface, - credential_store: &'a dyn Fido2CredentialStore, - ) -> Fido2Client<'a> { - Fido2Client { - authenticator: self.create_authenticator(user_interface, credential_store), - } - } -} - #[allow(dead_code)] #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] pub struct SelectedCredential { diff --git a/crates/bitwarden/src/platform/fido2/traits.rs b/crates/bitwarden-fido/src/traits.rs similarity index 100% rename from crates/bitwarden/src/platform/fido2/traits.rs rename to crates/bitwarden-fido/src/traits.rs diff --git a/crates/bitwarden/src/platform/fido2/types.rs b/crates/bitwarden-fido/src/types.rs similarity index 99% rename from crates/bitwarden/src/platform/fido2/types.rs rename to crates/bitwarden-fido/src/types.rs index 3e41768f6..16edde6ea 100644 --- a/crates/bitwarden/src/platform/fido2/types.rs +++ b/crates/bitwarden-fido/src/types.rs @@ -272,7 +272,7 @@ pub struct AuthenticatorAssertionResponse { mod tests { use serde::{Deserialize, Serialize}; - use crate::platform::fido2::types::AndroidClientData; + use super::AndroidClientData; // This is a stripped down of the passkey-rs implementation, to test the // serialization of the `ClientData` enum, and to make sure that () and None diff --git a/crates/bitwarden-fido/uniffi.toml b/crates/bitwarden-fido/uniffi.toml new file mode 100644 index 000000000..395a85b21 --- /dev/null +++ b/crates/bitwarden-fido/uniffi.toml @@ -0,0 +1,9 @@ +[bindings.kotlin] +package_name = "com.bitwarden.fido" +generate_immutable_records = true +android = true + +[bindings.swift] +ffi_module_name = "BitwardenFidoFFI" +module_name = "BitwardenFido" +generate_immutable_records = true diff --git a/crates/bitwarden-uniffi/Cargo.toml b/crates/bitwarden-uniffi/Cargo.toml index b9ab39aa2..f5c1230c0 100644 --- a/crates/bitwarden-uniffi/Cargo.toml +++ b/crates/bitwarden-uniffi/Cargo.toml @@ -22,6 +22,7 @@ async-trait = "0.1.80" bitwarden = { workspace = true, features = ["internal", "uniffi"] } bitwarden-core = { workspace = true, features = ["uniffi"] } bitwarden-crypto = { workspace = true, features = ["uniffi"] } +bitwarden-fido = { workspace = true, features = ["uniffi"] } bitwarden-generators = { workspace = true, features = ["uniffi"] } bitwarden-send = { workspace = true, features = ["uniffi"] } bitwarden-vault = { workspace = true, features = ["uniffi"] } diff --git a/crates/bitwarden/Cargo.toml b/crates/bitwarden/Cargo.toml index 4bf6873dc..eec018df2 100644 --- a/crates/bitwarden/Cargo.toml +++ b/crates/bitwarden/Cargo.toml @@ -31,10 +31,8 @@ uniffi = [ "bitwarden-generators/uniffi", "bitwarden-send/uniffi", "bitwarden-vault/uniffi", + "bitwarden-fido/uniffi", "dep:uniffi", - "dep:passkey", - "dep:coset", - "dep:p256", ] # Uniffi bindings secrets = [] # Secrets manager API wasm-bindgen = ["chrono/wasmbind"] @@ -47,6 +45,7 @@ bitwarden-api-identity = { workspace = true } bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } bitwarden-exporters = { workspace = true, optional = true } +bitwarden-fido = { workspace = true, optional = true } bitwarden-generators = { workspace = true, optional = true } bitwarden-send = { workspace = true, optional = true } bitwarden-vault = { workspace = true, optional = true } @@ -55,12 +54,9 @@ chrono = { version = ">=0.4.26, <0.5", features = [ "serde", "std", ], default-features = false } -coset = { version = "0.3.7", optional = true } # 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"] } log = ">=0.4.18, <0.5" -p256 = { version = ">=0.13.2, <0.14", optional = true } -passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "c48c2ddfd6b884b2d754432576c66cb2b1985a3a", optional = true } rand = ">=0.8.5, <0.9" reqwest = { version = ">=0.12, <0.13", features = [ "http2", diff --git a/crates/bitwarden/src/error.rs b/crates/bitwarden/src/error.rs index c6312750e..76005885f 100644 --- a/crates/bitwarden/src/error.rs +++ b/crates/bitwarden/src/error.rs @@ -87,25 +87,24 @@ pub enum Error { // Fido #[cfg(all(feature = "uniffi", feature = "internal"))] #[error(transparent)] - MakeCredential(#[from] crate::platform::fido2::MakeCredentialError), + MakeCredential(#[from] bitwarden_fido::MakeCredentialError), #[cfg(all(feature = "uniffi", feature = "internal"))] #[error(transparent)] - GetAssertion(#[from] crate::platform::fido2::GetAssertionError), + GetAssertion(#[from] bitwarden_fido::GetAssertionError), #[cfg(all(feature = "uniffi", feature = "internal"))] #[error(transparent)] - SilentlyDiscoverCredentials(#[from] crate::platform::fido2::SilentlyDiscoverCredentialsError), + SilentlyDiscoverCredentials(#[from] bitwarden_fido::SilentlyDiscoverCredentialsError), #[cfg(all(feature = "uniffi", feature = "internal"))] #[error(transparent)] - Fido2Client(#[from] crate::platform::fido2::Fido2ClientError), + Fido2Client(#[from] bitwarden_fido::Fido2ClientError), + #[cfg(all(feature = "uniffi", feature = "internal"))] + #[error("Fido2 Callback error: {0:?}")] + Fido2CallbackError(#[from] bitwarden_fido::Fido2CallbackError), #[cfg(feature = "uniffi")] #[error("Uniffi callback error: {0}")] UniffiCallbackError(#[from] uniffi::UnexpectedUniFFICallbackError), - #[cfg(all(feature = "uniffi", feature = "internal"))] - #[error("Fido2 Callback error: {0:?}")] - Fido2CallbackError(#[from] crate::platform::fido2::Fido2CallbackError), - #[error("Internal error: {0}")] Internal(Cow<'static, str>), } diff --git a/crates/bitwarden/src/platform/client_fido.rs b/crates/bitwarden/src/platform/client_fido.rs new file mode 100644 index 000000000..63808e21b --- /dev/null +++ b/crates/bitwarden/src/platform/client_fido.rs @@ -0,0 +1,41 @@ +use std::sync::Arc; + +use bitwarden_fido::{ + Fido2Authenticator, Fido2Client, Fido2CredentialStore, Fido2UserInterface, + FidoEncryptionSettingStore, +}; + +use crate::Client; + +pub struct ClientFido2<'a> { + #[allow(dead_code)] + pub(crate) client: &'a Client, +} + +impl FidoEncryptionSettingStore for Client { + fn get_encryption_settings( + &self, + ) -> Result, bitwarden_core::VaultLocked> { + Ok(self.get_encryption_settings()?) + } +} + +impl<'a> ClientFido2<'a> { + pub fn create_authenticator( + &'a self, + user_interface: &'a dyn Fido2UserInterface, + credential_store: &'a dyn Fido2CredentialStore, + ) -> Fido2Authenticator<'a> { + Fido2Authenticator::new(self.client, user_interface, credential_store) + } + + pub fn create_client( + &'a self, + user_interface: &'a dyn Fido2UserInterface, + credential_store: &'a dyn Fido2CredentialStore, + ) -> Fido2Client<'a> { + Fido2Client { + authenticator: self.create_authenticator(user_interface, credential_store), + } + } +} diff --git a/crates/bitwarden/src/platform/client_platform.rs b/crates/bitwarden/src/platform/client_platform.rs index 945011393..ca9ce8d63 100644 --- a/crates/bitwarden/src/platform/client_platform.rs +++ b/crates/bitwarden/src/platform/client_platform.rs @@ -1,5 +1,5 @@ #[cfg(feature = "uniffi")] -use super::ClientFido2; +use super::client_fido::ClientFido2; use super::{ generate_fingerprint::{generate_fingerprint, generate_user_fingerprint}, get_user_api_key, FingerprintRequest, FingerprintResponse, SecretVerificationRequest, diff --git a/crates/bitwarden/src/platform/mod.rs b/crates/bitwarden/src/platform/mod.rs index b905d2356..0fc051ac3 100644 --- a/crates/bitwarden/src/platform/mod.rs +++ b/crates/bitwarden/src/platform/mod.rs @@ -1,13 +1,16 @@ -pub mod client_platform; #[cfg(feature = "uniffi")] -pub mod fido2; +pub mod client_fido; +pub mod client_platform; mod generate_fingerprint; mod get_user_api_key; mod secret_verification_request; -#[cfg(feature = "uniffi")] -pub use fido2::{ClientFido2, Fido2Authenticator, Fido2Client}; pub use generate_fingerprint::{FingerprintRequest, FingerprintResponse}; pub(crate) use get_user_api_key::get_user_api_key; pub use get_user_api_key::UserApiKeyResponse; pub use secret_verification_request::SecretVerificationRequest; + +#[cfg(feature = "uniffi")] +pub mod fido2 { + pub use bitwarden_fido::*; +} From 41f6d3ef2451cf2655f5608450fd45a7d8654c9f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 14 Jun 2024 15:14:28 +0200 Subject: [PATCH 020/214] [deps]: Update Rust crate clap_complete to v4.5.5 (#843) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [clap_complete](https://togithub.com/clap-rs/clap) | build-dependencies | patch | `4.5.2` -> `4.5.5` | | [clap_complete](https://togithub.com/clap-rs/clap) | dependencies | patch | `4.5.2` -> `4.5.5` | --- ### Release Notes
clap-rs/clap (clap_complete) ### [`v4.5.5`](https://togithub.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#455---2024-06-06) [Compare Source](https://togithub.com/clap-rs/clap/compare/clap_complete-v4.5.4...clap_complete-v4.5.5) ##### Fixes - Allow `exclusive` to override `required_unless_present`, `required_unless_present_any`, `required_unless_present_all` ### [`v4.5.4`](https://togithub.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#454---2024-03-25) [Compare Source](https://togithub.com/clap-rs/clap/compare/clap_complete-v4.5.3...clap_complete-v4.5.4) ##### Fixes - *(derive)* Allow non-literal `#[arg(id)]` attributes again ### [`v4.5.3`](https://togithub.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#453---2024-03-15) [Compare Source](https://togithub.com/clap-rs/clap/compare/clap_complete-v4.5.2...clap_complete-v4.5.3) ##### Internal - *(derive)* Update `heck`
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Daniel García --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08dd83547..f8d175edb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -898,9 +898,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.2" +version = "4.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd79504325bf38b10165b02e89b4347300f855f273c4cb30c4a3209e6583275e" +checksum = "d2020fa13af48afc65a9a87335bda648309ab3d154cd03c7ff95b378c7ed39c4" dependencies = [ "clap", ] From 56d50014e2ed5f771628c1c0cf347a5c636b5850 Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Fri, 14 Jun 2024 15:55:35 +0200 Subject: [PATCH 021/214] Re-add `Fido2Credential` to uniffi (#842) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-uniffi/src/vault/ciphers.rs | 13 +++++++++++++ crates/bitwarden/src/mobile/vault/client_ciphers.rs | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/crates/bitwarden-uniffi/src/vault/ciphers.rs b/crates/bitwarden-uniffi/src/vault/ciphers.rs index a8416434c..06ddd1df5 100644 --- a/crates/bitwarden-uniffi/src/vault/ciphers.rs +++ b/crates/bitwarden-uniffi/src/vault/ciphers.rs @@ -1,6 +1,7 @@ use std::sync::Arc; use bitwarden::vault::{Cipher, CipherListView, CipherView}; +use bitwarden_vault::Fido2CredentialView; use uuid::Uuid; use crate::{Client, Result}; @@ -25,6 +26,18 @@ impl ClientCiphers { Ok(self.0 .0.vault().ciphers().decrypt_list(ciphers)?) } + pub fn decrypt_fido2_credentials( + &self, + cipher_view: CipherView, + ) -> Result> { + Ok(self + .0 + .0 + .vault() + .ciphers() + .decrypt_fido2_credentials(cipher_view)?) + } + /// Move a cipher to an organization, reencrypting the cipher key if necessary pub fn move_to_organization( &self, diff --git a/crates/bitwarden/src/mobile/vault/client_ciphers.rs b/crates/bitwarden/src/mobile/vault/client_ciphers.rs index bbbb01652..2bf612b56 100644 --- a/crates/bitwarden/src/mobile/vault/client_ciphers.rs +++ b/crates/bitwarden/src/mobile/vault/client_ciphers.rs @@ -51,6 +51,18 @@ impl<'a> ClientCiphers<'a> { cipher_views } + #[cfg(feature = "uniffi")] + pub fn decrypt_fido2_credentials( + &self, + cipher_view: CipherView, + ) -> Result> { + let enc = self.client.get_encryption_settings()?; + + let credentials = cipher_view.decrypt_fido2_credentials(&enc)?; + + Ok(credentials) + } + pub fn move_to_organization( &self, mut cipher_view: CipherView, From 32ac1e477a5578ac039031c76920bc295fbc1c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Fri, 14 Jun 2024 16:55:12 +0200 Subject: [PATCH 022/214] [PM-8874] Set attachment size when encrypting (#846) Set the attachment size after we encrypt the contents --- .../bitwarden-vault/src/cipher/attachment.rs | 87 ++++++++++++++++++- 1 file changed, 84 insertions(+), 3 deletions(-) diff --git a/crates/bitwarden-vault/src/cipher/attachment.rs b/crates/bitwarden-vault/src/cipher/attachment.rs index db2a09b23..d1a058c01 100644 --- a/crates/bitwarden-vault/src/cipher/attachment.rs +++ b/crates/bitwarden-vault/src/cipher/attachment.rs @@ -73,13 +73,29 @@ impl<'a> KeyEncryptable for Attachm let encrypted_contents = self.contents.encrypt_with_key(&attachment_key)?; attachment.key = Some(attachment_key.to_vec().encrypt_with_key(ciphers_key)?); + let contents = encrypted_contents.to_buffer()?; + + // Once we have the encrypted contents, we can set the size of the attachment + attachment.size = Some(contents.len().to_string()); + attachment.size_name = Some(size_name(contents.len())); + Ok(AttachmentEncryptResult { attachment: attachment.encrypt_with_key(ciphers_key)?, - contents: encrypted_contents.to_buffer()?, + contents, }) } } +fn size_name(size: usize) -> String { + let units = ["Bytes", "KB", "MB", "GB", "TB"]; + let size = size as f64; + let unit = (size.ln() / 1024_f64.ln()).floor() as usize; + let size = size / 1024_f64.powi(unit as i32); + + let size_round = (size * 10.0_f64).round() as usize as f64 / 10.0_f64; + format!("{} {}", size_round, units[unit]) +} + impl KeyDecryptable> for AttachmentFile { fn decrypt_with_key(&self, key: &SymmetricCryptoKey) -> Result, CryptoError> { let ciphers_key = Cipher::get_cipher_key(key, &self.cipher.key)?; @@ -144,13 +160,78 @@ impl TryFrom for Attachment #[cfg(test)] mod tests { use base64::{engine::general_purpose::STANDARD, Engine}; - use bitwarden_crypto::{EncString, KeyDecryptable, SymmetricCryptoKey}; + use bitwarden_crypto::{EncString, KeyDecryptable, KeyEncryptable, SymmetricCryptoKey}; use crate::{ cipher::cipher::{CipherRepromptType, CipherType}, - Attachment, AttachmentFile, Cipher, + Attachment, AttachmentFile, AttachmentFileView, AttachmentView, Cipher, }; + #[test] + fn test_size_name_conversions() { + assert_eq!(super::size_name(0), "0 Bytes"); + assert_eq!(super::size_name(19), "19 Bytes"); + assert_eq!(super::size_name(1024), "1 KB"); + assert_eq!(super::size_name(1570), "1.5 KB"); + assert_eq!(super::size_name(1024 * 1024), "1 MB"); + assert_eq!(super::size_name(1024 * 18999), "18.6 MB"); + assert_eq!(super::size_name(1024 * 1024 * 1024), "1 GB"); + assert_eq!(super::size_name(1024 * 1024 * 1024 * 1024), "1 TB"); + } + + #[test] + fn test_encrypt_attachment() { + let user_key: SymmetricCryptoKey = "w2LO+nwV4oxwswVYCxlOfRUseXfvU03VzvKQHrqeklPgiMZrspUe6sOBToCnDn9Ay0tuCBn8ykVVRb7PWhub2Q==".to_string().try_into().unwrap(); + + let attachment = AttachmentView { + id: None, + url: None, + size: Some("100".into()), + size_name: Some("100 Bytes".into()), + file_name: Some("Test.txt".into()), + key: None, + }; + + let contents = b"This is a test file that we will encrypt. It's 100 bytes long, the encrypted version will be longer!"; + + let attachment_file = AttachmentFileView { + cipher: Cipher { + id: None, + organization_id: None, + folder_id: None, + collection_ids: Vec::new(), + key: Some("2.Gg8yCM4IIgykCZyq0O4+cA==|GJLBtfvSJTDJh/F7X4cJPkzI6ccnzJm5DYl3yxOW2iUn7DgkkmzoOe61sUhC5dgVdV0kFqsZPcQ0yehlN1DDsFIFtrb4x7LwzJNIkMgxNyg=|1rGkGJ8zcM5o5D0aIIwAyLsjMLrPsP3EWm3CctBO3Fw=".parse().unwrap()), + name: "2.d24xECyEdMZ3MG9s6SrGNw==|XvJlTeu5KJ22M3jKosy6iw==|8xGiQty4X61cDMx6PVqkJfSQ0ZTdA/5L9TpG7QfovoM=".parse().unwrap(), + notes: None, + r#type: CipherType::Login, + login: None, + identity: None, + card: None, + secure_note: None, + favorite: false, + reprompt: CipherRepromptType::None, + organization_use_totp: false, + edit: true, + view_password: true, + local_data: None, + attachments: None, + fields: None, + password_history: None, + creation_date: "2023-07-24T12:05:09.466666700Z".parse().unwrap(), + deleted_date: None, + revision_date: "2023-07-27T19:28:05.240Z".parse().unwrap(), + }, + attachment, + contents: contents.as_slice(), + }; + + let result = attachment_file.encrypt_with_key(&user_key).unwrap(); + + assert_eq!(result.contents.len(), 161); + assert_eq!(result.attachment.size, Some("161".into())); + assert_eq!(result.attachment.size_name, Some("161 Bytes".into())); + } + #[test] fn test_attachment_key() { let user_key: SymmetricCryptoKey = "w2LO+nwV4oxwswVYCxlOfRUseXfvU03VzvKQHrqeklPgiMZrspUe6sOBToCnDn9Ay0tuCBn8ykVVRb7PWhub2Q==".to_string().try_into().unwrap(); From 444ee1b325b8721c5ab078aead1dc698a11d7b3e Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 17 Jun 2024 11:25:09 +0200 Subject: [PATCH 023/214] Remove calls to client_settings namespace (#848) Now that we expose `ClientSettings` and `DeviceType` directly in the root `bitwarden` crate we can make the `client_settings` module private. I also added `README` files to the newly created crates that missed them. --- crates/bitwarden-cli/README.md | 6 ++++++ crates/bitwarden-core/README.md | 6 ++++++ crates/bitwarden-fido/README.md | 6 ++++++ crates/bitwarden-json/src/client.rs | 2 +- crates/bitwarden-send/README.md | 6 ++++++ crates/bitwarden-uniffi/src/lib.rs | 2 +- crates/bitwarden-vault/README.md | 6 ++++++ crates/bitwarden/README.md | 7 ++----- .../src/auth/api/request/auth_request_token_request.rs | 5 ++--- .../src/auth/api/request/password_token_request.rs | 3 ++- crates/bitwarden/src/auth/login/password.rs | 2 +- crates/bitwarden/src/client/client.rs | 8 ++------ crates/bitwarden/src/client/client_settings.rs | 2 +- crates/bitwarden/src/util.rs | 4 ++-- crates/bw/src/main.rs | 2 +- crates/bws/src/main.rs | 2 +- crates/sdk-schemas/src/main.rs | 2 +- 17 files changed, 47 insertions(+), 24 deletions(-) create mode 100644 crates/bitwarden-cli/README.md create mode 100644 crates/bitwarden-core/README.md create mode 100644 crates/bitwarden-fido/README.md create mode 100644 crates/bitwarden-send/README.md create mode 100644 crates/bitwarden-vault/README.md diff --git a/crates/bitwarden-cli/README.md b/crates/bitwarden-cli/README.md new file mode 100644 index 000000000..651de965b --- /dev/null +++ b/crates/bitwarden-cli/README.md @@ -0,0 +1,6 @@ +# Bitwarden Cli + +This is an internal crate for the Bitwarden SDK do not depend on this directly and use the +[`bitwarden`](https://crates.io/crates/bitwarden) crate instead. + +This crate does not follow semantic versioning and the public interface may change at any time. diff --git a/crates/bitwarden-core/README.md b/crates/bitwarden-core/README.md new file mode 100644 index 000000000..fd697aa3c --- /dev/null +++ b/crates/bitwarden-core/README.md @@ -0,0 +1,6 @@ +# Bitwarden Crypto + +This is an internal crate for the Bitwarden SDK do not depend on this directly and use the +[`bitwarden`](https://crates.io/crates/bitwarden) crate instead. + +This crate does not follow semantic versioning and the public interface may change at any time. diff --git a/crates/bitwarden-fido/README.md b/crates/bitwarden-fido/README.md new file mode 100644 index 000000000..b94a1cb83 --- /dev/null +++ b/crates/bitwarden-fido/README.md @@ -0,0 +1,6 @@ +# Bitwarden Fido + +This is an internal crate for the Bitwarden SDK do not depend on this directly and use the +[`bitwarden`](https://crates.io/crates/bitwarden) crate instead. + +This crate does not follow semantic versioning and the public interface may change at any time. diff --git a/crates/bitwarden-json/src/client.rs b/crates/bitwarden-json/src/client.rs index 5233a4823..dd3469c45 100644 --- a/crates/bitwarden-json/src/client.rs +++ b/crates/bitwarden-json/src/client.rs @@ -1,4 +1,4 @@ -use bitwarden::client::client_settings::ClientSettings; +use bitwarden::ClientSettings; #[cfg(feature = "secrets")] use crate::command::{ProjectsCommand, SecretsCommand}; diff --git a/crates/bitwarden-send/README.md b/crates/bitwarden-send/README.md new file mode 100644 index 000000000..85da845b4 --- /dev/null +++ b/crates/bitwarden-send/README.md @@ -0,0 +1,6 @@ +# Bitwarden Send + +This is an internal crate for the Bitwarden SDK do not depend on this directly and use the +[`bitwarden`](https://crates.io/crates/bitwarden) crate instead. + +This crate does not follow semantic versioning and the public interface may change at any time. diff --git a/crates/bitwarden-uniffi/src/lib.rs b/crates/bitwarden-uniffi/src/lib.rs index 59f3e2035..6ef7e6cf4 100644 --- a/crates/bitwarden-uniffi/src/lib.rs +++ b/crates/bitwarden-uniffi/src/lib.rs @@ -3,7 +3,7 @@ uniffi::setup_scaffolding!(); use std::sync::Arc; use auth::ClientAuth; -use bitwarden::client::client_settings::ClientSettings; +use bitwarden::ClientSettings; pub mod auth; pub mod crypto; diff --git a/crates/bitwarden-vault/README.md b/crates/bitwarden-vault/README.md new file mode 100644 index 000000000..9f3687616 --- /dev/null +++ b/crates/bitwarden-vault/README.md @@ -0,0 +1,6 @@ +# Bitwarden Vault + +This is an internal crate for the Bitwarden SDK do not depend on this directly and use the +[`bitwarden`](https://crates.io/crates/bitwarden) crate instead. + +This crate does not follow semantic versioning and the public interface may change at any time. diff --git a/crates/bitwarden/README.md b/crates/bitwarden/README.md index 47e1afe76..ed0139a65 100644 --- a/crates/bitwarden/README.md +++ b/crates/bitwarden/README.md @@ -19,11 +19,8 @@ Rust **1.71** or higher. ```rust use bitwarden::{ - auth::login::AccessTokenLoginRequest, - client::client_settings::{ClientSettings, DeviceType}, - error::Result, - secrets_manager::secrets::SecretIdentifiersRequest, - Client, + auth::login::AccessTokenLoginRequest, error::Result, + secrets_manager::secrets::SecretIdentifiersRequest, Client, ClientSettings, DeviceType, }; use uuid::Uuid; diff --git a/crates/bitwarden/src/auth/api/request/auth_request_token_request.rs b/crates/bitwarden/src/auth/api/request/auth_request_token_request.rs index cf5ae7ee4..17ef52c26 100644 --- a/crates/bitwarden/src/auth/api/request/auth_request_token_request.rs +++ b/crates/bitwarden/src/auth/api/request/auth_request_token_request.rs @@ -3,9 +3,8 @@ use serde::{Deserialize, Serialize}; use uuid::Uuid; use crate::{ - auth::api::response::IdentityTokenResponse, - client::{client_settings::DeviceType, ApiConfigurations}, - error::Result, + auth::api::response::IdentityTokenResponse, client::ApiConfigurations, error::Result, + DeviceType, }; #[derive(Serialize, Deserialize, Debug)] diff --git a/crates/bitwarden/src/auth/api/request/password_token_request.rs b/crates/bitwarden/src/auth/api/request/password_token_request.rs index 2f6414bcd..f1482fab4 100644 --- a/crates/bitwarden/src/auth/api/request/password_token_request.rs +++ b/crates/bitwarden/src/auth/api/request/password_token_request.rs @@ -6,8 +6,9 @@ use crate::{ api::response::IdentityTokenResponse, login::{TwoFactorProvider, TwoFactorRequest}, }, - client::{client_settings::DeviceType, ApiConfigurations}, + client::ApiConfigurations, error::Result, + DeviceType, }; #[derive(Serialize, Deserialize, Debug)] diff --git a/crates/bitwarden/src/auth/login/password.rs b/crates/bitwarden/src/auth/login/password.rs index bbbae3d1a..8d79d8568 100644 --- a/crates/bitwarden/src/auth/login/password.rs +++ b/crates/bitwarden/src/auth/login/password.rs @@ -66,7 +66,7 @@ async fn request_identity_tokens( input: &PasswordLoginRequest, password_hash: &str, ) -> Result { - use crate::client::client_settings::DeviceType; + use crate::DeviceType; let config = client.get_api_configurations().await; PasswordTokenRequest::new( diff --git a/crates/bitwarden/src/client/client.rs b/crates/bitwarden/src/client/client.rs index 31e32f034..413e704aa 100644 --- a/crates/bitwarden/src/client/client.rs +++ b/crates/bitwarden/src/client/client.rs @@ -16,12 +16,8 @@ use uuid::Uuid; #[cfg(feature = "internal")] use crate::client::flags::Flags; use crate::{ - auth::AccessToken, - client::{ - client_settings::{ClientSettings, DeviceType}, - encryption_settings::EncryptionSettings, - }, - error::Result, + auth::AccessToken, client::encryption_settings::EncryptionSettings, error::Result, + ClientSettings, DeviceType, }; #[derive(Debug, Clone)] diff --git a/crates/bitwarden/src/client/client_settings.rs b/crates/bitwarden/src/client/client_settings.rs index 6e1907787..d82e5d93c 100644 --- a/crates/bitwarden/src/client/client_settings.rs +++ b/crates/bitwarden/src/client/client_settings.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; /// Defaults to /// /// ``` -/// # use bitwarden::client::client_settings::{ClientSettings, DeviceType}; +/// # use bitwarden::{ClientSettings, DeviceType}; /// let settings = ClientSettings { /// identity_url: "https://identity.bitwarden.com".to_string(), /// api_url: "https://api.bitwarden.com".to_string(), diff --git a/crates/bitwarden/src/util.rs b/crates/bitwarden/src/util.rs index aaf47a1a6..59ef930d5 100644 --- a/crates/bitwarden/src/util.rs +++ b/crates/bitwarden/src/util.rs @@ -17,11 +17,11 @@ pub async fn start_mock(mocks: Vec) -> (wiremock::MockServer, cr server.register(mock).await; } - let settings = crate::client::client_settings::ClientSettings { + let settings = crate::ClientSettings { identity_url: format!("http://{}/identity", server.address()), api_url: format!("http://{}/api", server.address()), user_agent: "Bitwarden Rust-SDK [TEST]".into(), - device_type: crate::client::client_settings::DeviceType::SDK, + device_type: crate::DeviceType::SDK, }; (server, crate::Client::new(Some(settings))) diff --git a/crates/bw/src/main.rs b/crates/bw/src/main.rs index c8af014f0..66f63d280 100644 --- a/crates/bw/src/main.rs +++ b/crates/bw/src/main.rs @@ -1,7 +1,7 @@ use bitwarden::{ auth::RegisterRequest, - client::client_settings::ClientSettings, generators::{PassphraseGeneratorRequest, PasswordGeneratorRequest}, + ClientSettings, }; use bitwarden_cli::{install_color_eyre, text_prompt_when_none, Color}; use clap::{command, Args, CommandFactory, Parser, Subcommand}; diff --git a/crates/bws/src/main.rs b/crates/bws/src/main.rs index 5f9f9c6c9..bbd909eff 100644 --- a/crates/bws/src/main.rs +++ b/crates/bws/src/main.rs @@ -2,7 +2,6 @@ use std::{path::PathBuf, process, str::FromStr}; use bitwarden::{ auth::{login::AccessTokenLoginRequest, AccessToken}, - client::client_settings::ClientSettings, secrets_manager::{ projects::{ ProjectCreateRequest, ProjectGetRequest, ProjectPutRequest, ProjectsDeleteRequest, @@ -13,6 +12,7 @@ use bitwarden::{ SecretIdentifiersRequest, SecretPutRequest, SecretsDeleteRequest, SecretsGetRequest, }, }, + ClientSettings, }; use bitwarden_cli::install_color_eyre; use clap::{CommandFactory, Parser}; diff --git a/crates/sdk-schemas/src/main.rs b/crates/sdk-schemas/src/main.rs index 8a4a67592..bc064ec86 100644 --- a/crates/sdk-schemas/src/main.rs +++ b/crates/sdk-schemas/src/main.rs @@ -91,7 +91,7 @@ use bitwarden_json::response::Response; #[derive(JsonSchema)] struct SchemaTypes { // Input types for new Client - client_settings: bitwarden::client::client_settings::ClientSettings, + client_settings: bitwarden::ClientSettings, // Input types for Client::run_command input_command: bitwarden_json::command::Command, From 331c3211b336d129d2a1c9dae631f83ea03f7451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Mon, 17 Jun 2024 11:34:25 +0200 Subject: [PATCH 024/214] Fix individual crate compilation (#847) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📔 Objective This PR fixes some compilation errors when compiling individual crates using `cargo c -p crate-name`: - `send` and `vault` were missing some features of `chrono`, these features are available in other crates in the workspace so when compiling the entire workspace it works, but it returns an error when compiling the individual crates - `fido` depended on some functions from `vault` that were behind a `uniffi` feature. Rust-analyzer will try to compile the crate individually when manually running a test, which is how I notice that this problem was occurring. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-send/Cargo.toml | 5 ++++- crates/bitwarden-vault/Cargo.toml | 5 ++++- crates/bitwarden-vault/src/cipher/cipher.rs | 7 +------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/bitwarden-send/Cargo.toml b/crates/bitwarden-send/Cargo.toml index 004660f2d..9646ddcd9 100644 --- a/crates/bitwarden-send/Cargo.toml +++ b/crates/bitwarden-send/Cargo.toml @@ -25,7 +25,10 @@ base64 = ">=0.21.2, <0.23" bitwarden-api-api = { workspace = true } bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } -chrono = { version = ">=0.4.26, <0.5", default-features = false } +chrono = { version = ">=0.4.26, <0.5", features = [ + "clock", + "serde", +], default-features = false } schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } serde_repr = ">=0.1.12, <0.2" diff --git a/crates/bitwarden-vault/Cargo.toml b/crates/bitwarden-vault/Cargo.toml index f14f090d9..066cf609e 100644 --- a/crates/bitwarden-vault/Cargo.toml +++ b/crates/bitwarden-vault/Cargo.toml @@ -25,7 +25,10 @@ base64 = ">=0.21.2, <0.23" bitwarden-api-api = { workspace = true } bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } -chrono = { version = ">=0.4.26, <0.5", default-features = false } +chrono = { version = ">=0.4.26, <0.5", features = [ + "clock", + "serde", +], default-features = false } rand = ">=0.8.5, <0.9" hmac = ">=0.12.1, <0.13" reqwest = { version = ">=0.12, <0.13", default-features = false } diff --git a/crates/bitwarden-vault/src/cipher/cipher.rs b/crates/bitwarden-vault/src/cipher/cipher.rs index 5181df94f..730b80339 100644 --- a/crates/bitwarden-vault/src/cipher/cipher.rs +++ b/crates/bitwarden-vault/src/cipher/cipher.rs @@ -16,9 +16,7 @@ use super::{ local_data::{LocalData, LocalDataView}, login, secure_note, }; -#[cfg(feature = "uniffi")] -use crate::Fido2CredentialView; -use crate::{password_history, Fido2CredentialFullView, VaultParseError}; +use crate::{password_history, Fido2CredentialFullView, Fido2CredentialView, VaultParseError}; #[derive(Debug, Error)] pub enum CipherError { @@ -396,7 +394,6 @@ impl CipherView { Ok(()) } - #[cfg(feature = "uniffi")] pub fn decrypt_fido2_credentials( &self, enc: &dyn KeyContainer, @@ -458,7 +455,6 @@ impl CipherView { Ok(()) } - #[cfg(feature = "uniffi")] pub fn set_new_fido2_credentials( &mut self, enc: &dyn KeyContainer, @@ -475,7 +471,6 @@ impl CipherView { Ok(()) } - #[cfg(feature = "uniffi")] pub fn get_fido2_credentials( &self, enc: &dyn KeyContainer, From 547d0f2d1567add8a94f27b7092453df5b34c7b2 Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Tue, 18 Jun 2024 11:12:26 +0200 Subject: [PATCH 025/214] Add fido2 credential autofill view (#849) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective This PR adds a function on the Fido2 authenticator which returns all available credentials as a View tailored specifically for integrating with OS-level autofill APIs ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- Cargo.lock | 21 +++-- crates/bitwarden-fido/Cargo.toml | 2 + crates/bitwarden-fido/src/authenticator.rs | 58 +++++++++++-- crates/bitwarden-fido/src/lib.rs | 9 +- crates/bitwarden-fido/src/traits.rs | 2 + crates/bitwarden-fido/src/types.rs | 85 ++++++++++++++++++- crates/bitwarden-fido/src/uniffi_support.rs | 3 + crates/bitwarden-uniffi/src/platform/fido2.rs | 42 ++++++++- crates/bitwarden/src/error.rs | 8 ++ crates/bitwarden/src/platform/client_fido.rs | 26 +++++- crates/bitwarden/src/platform/mod.rs | 2 + 11 files changed, 237 insertions(+), 21 deletions(-) create mode 100644 crates/bitwarden-fido/src/uniffi_support.rs diff --git a/Cargo.lock b/Cargo.lock index f8d175edb..e7fca6a43 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -358,7 +358,7 @@ name = "bitwarden" version = "0.5.0" dependencies = [ "async-trait", - "base64 0.21.7", + "base64 0.22.1", "bitwarden-api-api", "bitwarden-api-identity", "bitwarden-core", @@ -497,16 +497,18 @@ name = "bitwarden-fido" version = "0.5.0" dependencies = [ "async-trait", - "base64 0.21.7", + "base64 0.22.1", "bitwarden-core", "bitwarden-crypto", "bitwarden-vault", "chrono", "coset", + "itertools 0.13.0", "log", "p256", "passkey", "reqwest", + "schemars", "serde", "serde_json", "thiserror", @@ -570,7 +572,7 @@ dependencies = [ name = "bitwarden-send" version = "0.5.0" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "bitwarden-api-api", "bitwarden-core", "bitwarden-crypto", @@ -610,7 +612,7 @@ dependencies = [ name = "bitwarden-vault" version = "0.5.0" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "bitwarden-api-api", "bitwarden-core", "bitwarden-crypto", @@ -2149,6 +2151,15 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.11" @@ -2206,7 +2217,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.5", ] [[package]] diff --git a/crates/bitwarden-fido/Cargo.toml b/crates/bitwarden-fido/Cargo.toml index d34177fd2..2d9dc9eaa 100644 --- a/crates/bitwarden-fido/Cargo.toml +++ b/crates/bitwarden-fido/Cargo.toml @@ -27,10 +27,12 @@ chrono = { version = ">=0.4.26, <0.5", features = [ "serde", ], default-features = false } coset = { version = "0.3.7" } +itertools = "0.13.0" log = ">=0.4.18, <0.5" p256 = { version = ">=0.13.2, <0.14" } passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "c48c2ddfd6b884b2d754432576c66cb2b1985a3a" } reqwest = { version = ">=0.12, <0.13", default-features = false } +schemars = { version = "0.8.21", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } serde_json = ">=1.0.96, <2.0" thiserror = ">=1.0.40, <2.0" diff --git a/crates/bitwarden-fido/src/authenticator.rs b/crates/bitwarden-fido/src/authenticator.rs index edc5033a7..41f5d5b45 100644 --- a/crates/bitwarden-fido/src/authenticator.rs +++ b/crates/bitwarden-fido/src/authenticator.rs @@ -2,7 +2,8 @@ use std::sync::{Arc, Mutex}; use bitwarden_core::VaultLocked; use bitwarden_crypto::{CryptoError, KeyContainer, KeyEncryptable}; -use bitwarden_vault::{CipherError, CipherView, Fido2CredentialView}; +use bitwarden_vault::{CipherError, CipherView}; +use itertools::Itertools; use log::error; use passkey::{ authenticator::{Authenticator, DiscoverabilitySupport, StoreInfo, UIHint, UserCheck}, @@ -67,10 +68,30 @@ pub enum GetAssertionError { #[derive(Debug, Error)] pub enum SilentlyDiscoverCredentialsError { + #[error(transparent)] + CipherError(#[from] CipherError), #[error(transparent)] VaultLocked(#[from] VaultLocked), #[error(transparent)] + InvalidGuid(#[from] InvalidGuid), + #[error(transparent)] Fido2CallbackError(#[from] Fido2CallbackError), + #[error(transparent)] + FromCipherViewError(#[from] Fido2CredentialAutofillViewError), +} + +#[derive(Debug, Error)] +pub enum CredentialsForAutofillError { + #[error(transparent)] + CipherError(#[from] CipherError), + #[error(transparent)] + VaultLocked(#[from] VaultLocked), + #[error(transparent)] + InvalidGuid(#[from] InvalidGuid), + #[error(transparent)] + Fido2CallbackError(#[from] Fido2CallbackError), + #[error(transparent)] + FromCipherViewError(#[from] Fido2CredentialAutofillViewError), } /// Temporary trait for solving a circular dependency. When moving `Client` to `bitwarden-core` @@ -236,15 +257,40 @@ impl<'a> Fido2Authenticator<'a> { pub async fn silently_discover_credentials( &mut self, rp_id: String, - ) -> Result, SilentlyDiscoverCredentialsError> { + ) -> Result, SilentlyDiscoverCredentialsError> { let enc = self.client.get_encryption_settings()?; let result = self.credential_store.find_credentials(None, rp_id).await?; - Ok(result + result .into_iter() - .flat_map(|c| c.decrypt_fido2_credentials(&*enc)) - .flatten() - .collect()) + .map( + |cipher| -> Result, SilentlyDiscoverCredentialsError> { + Ok(Fido2CredentialAutofillView::from_cipher_view(&cipher, &*enc)?) + }, + ) + .flatten_ok() + .collect() + } + + /// Returns all Fido2 credentials that can be used for autofill, in a view + /// tailored for integration with OS autofill systems. + pub async fn credentials_for_autofill( + &mut self, + ) -> Result, CredentialsForAutofillError> { + let enc = self.client.get_encryption_settings()?; + let all_credentials = self.credential_store.all_credentials().await?; + + all_credentials + .into_iter() + .map( + |cipher| -> Result, CredentialsForAutofillError> { + Ok(Fido2CredentialAutofillView::from_cipher_view( + &cipher, &*enc, + )?) + }, + ) + .flatten_ok() + .collect() } pub(super) fn get_authenticator( diff --git a/crates/bitwarden-fido/src/lib.rs b/crates/bitwarden-fido/src/lib.rs index f3532a3c8..b572eef36 100644 --- a/crates/bitwarden-fido/src/lib.rs +++ b/crates/bitwarden-fido/src/lib.rs @@ -8,6 +8,8 @@ use passkey::types::{ctap2::Aaguid, Passkey}; #[cfg(feature = "uniffi")] uniffi::setup_scaffolding!(); +#[cfg(feature = "uniffi")] +mod uniffi_support; mod authenticator; mod client; @@ -15,8 +17,8 @@ mod crypto; mod traits; mod types; pub use authenticator::{ - Fido2Authenticator, FidoEncryptionSettingStore, GetAssertionError, MakeCredentialError, - SilentlyDiscoverCredentialsError, + CredentialsForAutofillError, Fido2Authenticator, FidoEncryptionSettingStore, GetAssertionError, + MakeCredentialError, SilentlyDiscoverCredentialsError, }; pub use client::{Fido2Client, Fido2ClientError}; pub use passkey::authenticator::UIHint; @@ -27,7 +29,8 @@ pub use traits::{ }; pub use types::{ AuthenticatorAssertionResponse, AuthenticatorAttestationResponse, ClientData, - GetAssertionRequest, GetAssertionResult, MakeCredentialRequest, MakeCredentialResult, Options, + Fido2CredentialAutofillView, Fido2CredentialAutofillViewError, GetAssertionRequest, + GetAssertionResult, MakeCredentialRequest, MakeCredentialResult, Options, PublicKeyCredentialAuthenticatorAssertionResponse, PublicKeyCredentialAuthenticatorAttestationResponse, PublicKeyCredentialRpEntity, PublicKeyCredentialUserEntity, diff --git a/crates/bitwarden-fido/src/traits.rs b/crates/bitwarden-fido/src/traits.rs index 0769eeb2a..1e00a318a 100644 --- a/crates/bitwarden-fido/src/traits.rs +++ b/crates/bitwarden-fido/src/traits.rs @@ -41,6 +41,8 @@ pub trait Fido2CredentialStore: Send + Sync { rip_id: String, ) -> Result, Fido2CallbackError>; + async fn all_credentials(&self) -> Result, Fido2CallbackError>; + async fn save_credential(&self, cred: Cipher) -> Result<(), Fido2CallbackError>; } diff --git a/crates/bitwarden-fido/src/types.rs b/crates/bitwarden-fido/src/types.rs index 16edde6ea..d6eaa4752 100644 --- a/crates/bitwarden-fido/src/types.rs +++ b/crates/bitwarden-fido/src/types.rs @@ -1,8 +1,89 @@ +use bitwarden_crypto::KeyContainer; +use bitwarden_vault::{CipherError, CipherView}; use passkey::types::webauthn::UserVerificationRequirement; -use serde::Serialize; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; use thiserror::Error; -use super::{get_enum_from_string_name, SelectedCredential, UnknownEnum, Verification}; +use super::{ + get_enum_from_string_name, string_to_guid_bytes, InvalidGuid, SelectedCredential, UnknownEnum, + Verification, +}; + +#[derive(Serialize, Deserialize, Debug, Clone, JsonSchema)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[cfg_attr(feature = "uniffi", derive(uniffi::Record))] +pub struct Fido2CredentialAutofillView { + pub credential_id: Vec, + pub cipher_id: uuid::Uuid, + pub rp_id: String, + pub user_name_for_ui: Option, + pub user_handle: Vec, +} + +trait NoneWhitespace { + /// Convert only whitespace to None + fn none_whitespace(&self) -> Option; +} + +impl NoneWhitespace for String { + fn none_whitespace(&self) -> Option { + match self.trim() { + "" => None, + s => Some(s.to_owned()), + } + } +} + +impl NoneWhitespace for Option { + fn none_whitespace(&self) -> Option { + self.as_ref().and_then(|s| s.none_whitespace()) + } +} + +#[derive(Debug, Error)] +pub enum Fido2CredentialAutofillViewError { + #[error( + "Autofill credentials can only be created from existing ciphers that have a cipher id" + )] + MissingCipherId, + + #[error(transparent)] + InvalidGuid(#[from] InvalidGuid), + + #[error(transparent)] + CipherError(#[from] CipherError), +} + +impl Fido2CredentialAutofillView { + pub fn from_cipher_view( + cipher: &CipherView, + enc: &dyn KeyContainer, + ) -> Result, Fido2CredentialAutofillViewError> { + let credentials = cipher.decrypt_fido2_credentials(enc)?; + + credentials + .into_iter() + .filter_map(|c| -> Option> { + c.user_handle.map(|user_handle| { + Ok(Fido2CredentialAutofillView { + credential_id: string_to_guid_bytes(&c.credential_id)?, + cipher_id: cipher + .id + .ok_or(Fido2CredentialAutofillViewError::MissingCipherId)?, + rp_id: c.rp_id.clone(), + user_handle, + user_name_for_ui: c + .user_name + .none_whitespace() + .or(c.user_display_name.none_whitespace()) + .or(cipher.name.none_whitespace()), + }) + }) + }) + .collect() + } +} #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] pub struct PublicKeyCredentialRpEntity { diff --git a/crates/bitwarden-fido/src/uniffi_support.rs b/crates/bitwarden-fido/src/uniffi_support.rs new file mode 100644 index 000000000..5bf94d09f --- /dev/null +++ b/crates/bitwarden-fido/src/uniffi_support.rs @@ -0,0 +1,3 @@ +use uuid::Uuid; + +uniffi::ffi_converter_forward!(Uuid, bitwarden_core::UniFfiTag, crate::UniFfiTag); diff --git a/crates/bitwarden-uniffi/src/platform/fido2.rs b/crates/bitwarden-uniffi/src/platform/fido2.rs index 09162b7d0..7cc45a2cb 100644 --- a/crates/bitwarden-uniffi/src/platform/fido2.rs +++ b/crates/bitwarden-uniffi/src/platform/fido2.rs @@ -4,12 +4,13 @@ use bitwarden::{ error::Error, platform::fido2::{ CheckUserOptions, ClientData, Fido2CallbackError as BitFido2CallbackError, - GetAssertionRequest, GetAssertionResult, MakeCredentialRequest, MakeCredentialResult, + Fido2CredentialAutofillView, GetAssertionRequest, GetAssertionResult, + MakeCredentialRequest, MakeCredentialResult, PublicKeyCredentialAuthenticatorAssertionResponse, PublicKeyCredentialAuthenticatorAttestationResponse, PublicKeyCredentialRpEntity, PublicKeyCredentialUserEntity, }, - vault::{Cipher, CipherView, Fido2CredentialNewView, Fido2CredentialView}, + vault::{Cipher, CipherView, Fido2CredentialNewView}, }; use crate::{error::Result, Client}; @@ -42,6 +43,21 @@ impl ClientFido2 { credential_store, ))) } + + pub fn decrypt_fido2_autofill_credentials( + self: Arc, + cipher_view: CipherView, + ) -> Result> { + let result = self + .0 + .0 + .platform() + .fido2() + .decrypt_fido2_autofill_credentials(cipher_view) + .map_err(Error::DecryptFido2AutofillCredentialsError)?; + + Ok(result) + } } #[derive(uniffi::Object)] @@ -87,7 +103,7 @@ impl ClientFido2Authenticator { pub async fn silently_discover_credentials( &self, rp_id: String, - ) -> Result> { + ) -> Result> { let platform = self.0 .0.platform(); let fido2 = platform.fido2(); let ui = UniffiTraitBridge(self.1.as_ref()); @@ -100,6 +116,20 @@ impl ClientFido2Authenticator { .map_err(Error::SilentlyDiscoverCredentials)?; Ok(result) } + + pub async fn credentials_for_autofill(&self) -> Result> { + let platform = self.0 .0.platform(); + let fido2 = platform.fido2(); + let ui = UniffiTraitBridge(self.1.as_ref()); + let cs = UniffiTraitBridge(self.2.as_ref()); + let mut auth = fido2.create_authenticator(&ui, &cs); + + let result = auth + .credentials_for_autofill() + .await + .map_err(Error::CredentialsForAutofillError)?; + Ok(result) + } } #[derive(uniffi::Object)] @@ -216,6 +246,8 @@ pub trait Fido2CredentialStore: Send + Sync { rip_id: String, ) -> Result, Fido2CallbackError>; + async fn all_credentials(&self) -> Result, Fido2CallbackError>; + async fn save_credential(&self, cred: Cipher) -> Result<(), Fido2CallbackError>; } @@ -240,6 +272,10 @@ impl bitwarden::platform::fido2::Fido2CredentialStore .map_err(Into::into) } + async fn all_credentials(&self) -> Result, BitFido2CallbackError> { + self.0.all_credentials().await.map_err(Into::into) + } + async fn save_credential(&self, cred: Cipher) -> Result<(), BitFido2CallbackError> { self.0.save_credential(cred).await.map_err(Into::into) } diff --git a/crates/bitwarden/src/error.rs b/crates/bitwarden/src/error.rs index 76005885f..46f34404f 100644 --- a/crates/bitwarden/src/error.rs +++ b/crates/bitwarden/src/error.rs @@ -96,6 +96,14 @@ pub enum Error { SilentlyDiscoverCredentials(#[from] bitwarden_fido::SilentlyDiscoverCredentialsError), #[cfg(all(feature = "uniffi", feature = "internal"))] #[error(transparent)] + CredentialsForAutofillError(#[from] bitwarden_fido::CredentialsForAutofillError), + #[cfg(all(feature = "uniffi", feature = "internal"))] + #[error(transparent)] + DecryptFido2AutofillCredentialsError( + #[from] crate::platform::fido2::DecryptFido2AutofillCredentialsError, + ), + #[cfg(all(feature = "uniffi", feature = "internal"))] + #[error(transparent)] Fido2Client(#[from] bitwarden_fido::Fido2ClientError), #[cfg(all(feature = "uniffi", feature = "internal"))] #[error("Fido2 Callback error: {0:?}")] diff --git a/crates/bitwarden/src/platform/client_fido.rs b/crates/bitwarden/src/platform/client_fido.rs index 63808e21b..79164b48f 100644 --- a/crates/bitwarden/src/platform/client_fido.rs +++ b/crates/bitwarden/src/platform/client_fido.rs @@ -1,9 +1,11 @@ use std::sync::Arc; use bitwarden_fido::{ - Fido2Authenticator, Fido2Client, Fido2CredentialStore, Fido2UserInterface, - FidoEncryptionSettingStore, + Fido2Authenticator, Fido2Client, Fido2CredentialAutofillView, Fido2CredentialStore, + Fido2UserInterface, FidoEncryptionSettingStore, }; +use bitwarden_vault::CipherView; +use thiserror::Error; use crate::Client; @@ -12,6 +14,14 @@ pub struct ClientFido2<'a> { pub(crate) client: &'a Client, } +#[derive(Debug, Error)] +pub enum DecryptFido2AutofillCredentialsError { + #[error(transparent)] + VaultLocked(#[from] bitwarden_core::VaultLocked), + #[error(transparent)] + Fido2CredentialAutofillViewError(#[from] bitwarden_fido::Fido2CredentialAutofillViewError), +} + impl FidoEncryptionSettingStore for Client { fn get_encryption_settings( &self, @@ -38,4 +48,16 @@ impl<'a> ClientFido2<'a> { authenticator: self.create_authenticator(user_interface, credential_store), } } + + pub fn decrypt_fido2_autofill_credentials( + &'a self, + cipher_view: CipherView, + ) -> Result, DecryptFido2AutofillCredentialsError> { + let enc = self.client.get_encryption_settings()?; + + Ok(Fido2CredentialAutofillView::from_cipher_view( + &cipher_view, + &*enc, + )?) + } } diff --git a/crates/bitwarden/src/platform/mod.rs b/crates/bitwarden/src/platform/mod.rs index 0fc051ac3..82d341e6e 100644 --- a/crates/bitwarden/src/platform/mod.rs +++ b/crates/bitwarden/src/platform/mod.rs @@ -13,4 +13,6 @@ pub use secret_verification_request::SecretVerificationRequest; #[cfg(feature = "uniffi")] pub mod fido2 { pub use bitwarden_fido::*; + + pub use super::client_fido::DecryptFido2AutofillCredentialsError; } From 00b2120b61d37511349252f8161ed14a81705fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Tue, 18 Jun 2024 16:30:29 +0200 Subject: [PATCH 026/214] [PM-8092] Update reqwest and rustls platform verifier (#851) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/PM-8092 ## 📔 Objective The new release of `reqwest` yesterday now unblocks our update to `rustls-platform-verifier` 0.3.1 ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- Cargo.lock | 121 ++++++++++++++++++----- crates/bitwarden-api-api/Cargo.toml | 2 +- crates/bitwarden-api-identity/Cargo.toml | 2 +- crates/bitwarden-fido/Cargo.toml | 2 +- crates/bitwarden-generators/Cargo.toml | 2 +- crates/bitwarden-vault/Cargo.toml | 2 +- crates/bitwarden/Cargo.toml | 8 +- 7 files changed, 103 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e7fca6a43..e4c3f54c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1969,9 +1969,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.26.0" +version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0bea761b46ae2b24eb4aef630d8d1c398157b6fc29e6350ecf090a0b70c952c" +checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", "http", @@ -1982,6 +1982,7 @@ dependencies = [ "tokio", "tokio-rustls", "tower-service", + "webpki-roots", ] [[package]] @@ -2206,9 +2207,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.154" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" @@ -2266,9 +2267,9 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.7.2" +version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memoffset" @@ -2966,6 +2967,53 @@ dependencies = [ "memchr", ] +[[package]] +name = "quinn" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" +dependencies = [ + "bytes", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "thiserror", + "tokio", + "tracing", +] + +[[package]] +name = "quinn-proto" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" +dependencies = [ + "bytes", + "rand", + "ring", + "rustc-hash", + "rustls", + "slab", + "thiserror", + "tinyvec", + "tracing", +] + +[[package]] +name = "quinn-udp" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9096629c45860fc7fb143e125eb826b5e721e10be3263160c7d60ca832cf8c46" +dependencies = [ + "libc", + "once_cell", + "socket2", + "tracing", + "windows-sys 0.52.0", +] + [[package]] name = "quote" version = "1.0.36" @@ -3047,9 +3095,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.4" +version = "1.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c117dbdfde9c8308975b6a18d71f3f385c89461f7b3fb054288ecf2a2058ba4c" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" dependencies = [ "aho-corasick", "memchr", @@ -3059,9 +3107,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" dependencies = [ "aho-corasick", "memchr", @@ -3070,15 +3118,15 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" -version = "0.12.4" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "566cafdd92868e0939d3fb961bd0dc25fcfaaed179291093b3d43e6b3150ea10" +checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" dependencies = [ "base64 0.22.1", "bytes", @@ -3099,6 +3147,7 @@ dependencies = [ "once_cell", "percent-encoding", "pin-project-lite", + "quinn", "rustls", "rustls-pemfile", "rustls-pki-types", @@ -3183,6 +3232,12 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustix" version = "0.38.34" @@ -3198,11 +3253,11 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.4" +version = "0.23.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" +checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" dependencies = [ - "log", + "once_cell", "ring", "rustls-pki-types", "rustls-webpki", @@ -3241,9 +3296,9 @@ checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-platform-verifier" -version = "0.2.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c35b9a497e588f1fb2e1d18a0d46a6d057710f34c3da7084b27353b319453cc" +checksum = "b5f0d26fa1ce3c790f9590868f0109289a044acb954525f933e2aa3b871c157d" dependencies = [ "core-foundation", "core-foundation-sys", @@ -3268,9 +3323,9 @@ checksum = "84e217e7fdc8466b5b35d30f8c0a30febd29173df4a3a0c2115d306b9c4117ad" [[package]] name = "rustls-webpki" -version = "0.102.3" +version = "0.102.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3bce581c0dd41bce533ce695a1437fa16a7ab5ac3ccfa99fe1a620a7885eabf" +checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" dependencies = [ "ring", "rustls-pki-types", @@ -3800,9 +3855,9 @@ dependencies = [ [[package]] name = "sync_wrapper" -version = "0.1.2" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" [[package]] name = "syntect" @@ -3969,9 +4024,9 @@ dependencies = [ [[package]] name = "tokio-rustls" -version = "0.25.0" +version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "775e0c0f0adb3a2f22a00c4745d728b479985fc15ee7ca6a2608388c5569860f" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ "rustls", "rustls-pki-types", @@ -4070,9 +4125,21 @@ checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "log", "pin-project-lite", + "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.63", +] + [[package]] name = "tracing-core" version = "0.1.32" @@ -4513,9 +4580,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.1" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3de34ae270483955a94f4b21bdaaeb83d508bb84a01435f393818edb0012009" +checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" dependencies = [ "rustls-pki-types", ] diff --git a/crates/bitwarden-api-api/Cargo.toml b/crates/bitwarden-api-api/Cargo.toml index 7c6de8278..bd4ec05c0 100644 --- a/crates/bitwarden-api-api/Cargo.toml +++ b/crates/bitwarden-api-api/Cargo.toml @@ -19,4 +19,4 @@ serde_json = ">=1.0.96, <2" serde_repr = ">=0.1.12, <0.2" url = ">=2.5, <3" uuid = { version = ">=1.3.3, <2", features = ["serde", "v4"] } -reqwest = { version = ">=0.12, <0.13", features = ["json", "multipart", "http2"], default-features = false } +reqwest = { version = ">=0.12.5, <0.13", features = ["json", "multipart", "http2"], default-features = false } diff --git a/crates/bitwarden-api-identity/Cargo.toml b/crates/bitwarden-api-identity/Cargo.toml index 00ceada04..d101e9a9e 100644 --- a/crates/bitwarden-api-identity/Cargo.toml +++ b/crates/bitwarden-api-identity/Cargo.toml @@ -19,4 +19,4 @@ serde_json = ">=1.0.96, <2" serde_repr = ">=0.1.12, <0.2" url = ">=2.5, <3" uuid = { version = ">=1.3.3, <2", features = ["serde", "v4"] } -reqwest = { version = ">=0.12, <0.13", features = ["json", "multipart", "http2"], default-features = false } +reqwest = { version = ">=0.12.5, <0.13", features = ["json", "multipart", "http2"], default-features = false } diff --git a/crates/bitwarden-fido/Cargo.toml b/crates/bitwarden-fido/Cargo.toml index 2d9dc9eaa..3e02f544c 100644 --- a/crates/bitwarden-fido/Cargo.toml +++ b/crates/bitwarden-fido/Cargo.toml @@ -31,7 +31,7 @@ itertools = "0.13.0" log = ">=0.4.18, <0.5" p256 = { version = ">=0.13.2, <0.14" } passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "c48c2ddfd6b884b2d754432576c66cb2b1985a3a" } -reqwest = { version = ">=0.12, <0.13", default-features = false } +reqwest = { version = ">=0.12.5, <0.13", default-features = false } schemars = { version = "0.8.21", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } serde_json = ">=1.0.96, <2.0" diff --git a/crates/bitwarden-generators/Cargo.toml b/crates/bitwarden-generators/Cargo.toml index ac7c2a65a..6934f681e 100644 --- a/crates/bitwarden-generators/Cargo.toml +++ b/crates/bitwarden-generators/Cargo.toml @@ -19,7 +19,7 @@ uniffi = ["dep:uniffi"] # Uniffi bindings [dependencies] bitwarden-crypto = { workspace = true } rand = ">=0.8.5, <0.9" -reqwest = { version = ">=0.12, <0.13", features = [ +reqwest = { version = ">=0.12.5, <0.13", features = [ "http2", "json", ], default-features = false } diff --git a/crates/bitwarden-vault/Cargo.toml b/crates/bitwarden-vault/Cargo.toml index 066cf609e..71fd2a5b7 100644 --- a/crates/bitwarden-vault/Cargo.toml +++ b/crates/bitwarden-vault/Cargo.toml @@ -31,7 +31,7 @@ chrono = { version = ">=0.4.26, <0.5", features = [ ], default-features = false } rand = ">=0.8.5, <0.9" hmac = ">=0.12.1, <0.13" -reqwest = { version = ">=0.12, <0.13", default-features = false } +reqwest = { version = ">=0.12.5, <0.13", default-features = false } schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } serde_json = ">=1.0.96, <2.0" diff --git a/crates/bitwarden/Cargo.toml b/crates/bitwarden/Cargo.toml index eec018df2..783d5676d 100644 --- a/crates/bitwarden/Cargo.toml +++ b/crates/bitwarden/Cargo.toml @@ -58,7 +58,7 @@ chrono = { version = ">=0.4.26, <0.5", features = [ getrandom = { version = ">=0.2.9, <0.3", features = ["js"] } log = ">=0.4.18, <0.5" rand = ">=0.8.5, <0.9" -reqwest = { version = ">=0.12, <0.13", features = [ +reqwest = { version = ">=0.12.5, <0.13", features = [ "http2", "json", ], default-features = false } @@ -78,15 +78,15 @@ zxcvbn = ">= 2.2.2, <3.0" # There are a few exceptions to this: # - WASM doesn't require a TLS stack, as it just uses the browsers/node fetch # - Android uses webpki-roots for the moment -reqwest = { version = ">=0.12, <0.13", features = [ +reqwest = { version = ">=0.12.5, <0.13", features = [ "rustls-tls-manual-roots", ], default-features = false } -rustls-platform-verifier = "0.2.0" +rustls-platform-verifier = "0.3.1" [target.'cfg(target_os = "android")'.dependencies] # On android, the use of rustls-platform-verifier is more complicated and going through some changes at the moment, so we fall back to using webpki-roots # This means that for the moment android won't support self-signed certificates, even if they are included in the OS trust store -reqwest = { version = ">=0.12, <0.13", features = [ +reqwest = { version = ">=0.12.5, <0.13", features = [ "rustls-tls-webpki-roots", ], default-features = false } From 4b1d6a1aecda40ccbe6268dfe8c3fb21d5124135 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Fri, 21 Jun 2024 13:30:12 -0400 Subject: [PATCH 027/214] [SM-1287] Refactor out command logic from main.rs in bws (#809) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking [SM-1287](https://bitwarden.atlassian.net/browse/SM-1287) ## 📔 Objective The goal of this PR is to refactor `bws/src/main.rs` and the `process_commands()` function. This PR moves the actual CLI interaction for individual commands to the `command` module and appropriate sub-modules. There are plenty of other additions and changes to be made, but I'm trying to keep this PR a clean refactor and we can address other items in separate PR's. Deprecation of the legacy CLI commands will happen in [SM-1175](https://bitwarden.atlassian.net/browse/SM-1175). ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes [SM-1287]: https://bitwarden.atlassian.net/browse/SM-1287?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ [SM-1175]: https://bitwarden.atlassian.net/browse/SM-1175?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --- crates/bws/src/command/mod.rs | 59 +++++++ crates/bws/src/command/project.rs | 116 +++++++++++++ crates/bws/src/command/secret.rs | 163 +++++++++++++++++++ crates/bws/src/config.rs | 4 +- crates/bws/src/main.rs | 260 ++++++------------------------ crates/bws/src/render.rs | 26 ++- 6 files changed, 406 insertions(+), 222 deletions(-) create mode 100644 crates/bws/src/command/mod.rs create mode 100644 crates/bws/src/command/project.rs create mode 100644 crates/bws/src/command/secret.rs diff --git a/crates/bws/src/command/mod.rs b/crates/bws/src/command/mod.rs new file mode 100644 index 000000000..0fe257c42 --- /dev/null +++ b/crates/bws/src/command/mod.rs @@ -0,0 +1,59 @@ +pub(crate) mod project; +pub(crate) mod secret; + +use std::{path::PathBuf, str::FromStr}; + +use bitwarden::auth::AccessToken; +use clap::CommandFactory; +use clap_complete::Shell; +use color_eyre::eyre::{bail, Result}; + +use crate::{config, Cli, ProfileKey}; + +pub(crate) fn completions(shell: Option) -> Result<()> { + let Some(shell) = shell.or_else(Shell::from_env) else { + bail!("Couldn't autodetect a valid shell. Run `bws completions --help` for more info."); + }; + + let mut cmd = Cli::command(); + let name = cmd.get_name().to_string(); + clap_complete::generate(shell, &mut cmd, name, &mut std::io::stdout()); + + Ok(()) +} + +pub(crate) fn config( + name: Option, + value: Option, + delete: bool, + profile: Option, + access_token: Option, + config_file: Option, +) -> Result<()> { + let profile = if let Some(profile) = profile { + profile + } else if let Some(access_token) = access_token { + AccessToken::from_str(&access_token)? + .access_token_id + .to_string() + } else { + String::from("default") + }; + + if delete { + config::delete_profile(config_file.as_deref(), profile)?; + println!("Profile deleted successfully!"); + } else { + let (name, value) = match (name, value) { + (None, None) => bail!("Missing `name` and `value`"), + (None, Some(_)) => bail!("Missing `value`"), + (Some(_), None) => bail!("Missing `name`"), + (Some(name), Some(value)) => (name, value), + }; + + config::update_profile(config_file.as_deref(), profile, name, value)?; + println!("Profile updated successfully!"); + }; + + Ok(()) +} diff --git a/crates/bws/src/command/project.rs b/crates/bws/src/command/project.rs new file mode 100644 index 000000000..72060fdf4 --- /dev/null +++ b/crates/bws/src/command/project.rs @@ -0,0 +1,116 @@ +use bitwarden::{ + secrets_manager::projects::{ + ProjectCreateRequest, ProjectGetRequest, ProjectPutRequest, ProjectsDeleteRequest, + ProjectsListRequest, + }, + Client, +}; +use color_eyre::eyre::{bail, Result}; +use uuid::Uuid; + +use crate::render::{serialize_response, OutputSettings}; + +pub(crate) async fn list( + client: Client, + organization_id: Uuid, + output_settings: OutputSettings, +) -> Result<()> { + let projects = client + .projects() + .list(&ProjectsListRequest { organization_id }) + .await? + .data; + serialize_response(projects, output_settings); + + Ok(()) +} + +pub(crate) async fn get( + client: Client, + project_id: Uuid, + output_settings: OutputSettings, +) -> Result<()> { + let project = client + .projects() + .get(&ProjectGetRequest { id: project_id }) + .await?; + serialize_response(project, output_settings); + + Ok(()) +} + +pub(crate) async fn create( + client: Client, + organization_id: Uuid, + name: String, + output_settings: OutputSettings, +) -> Result<()> { + let project = client + .projects() + .create(&ProjectCreateRequest { + organization_id, + name, + }) + .await?; + serialize_response(project, output_settings); + + Ok(()) +} + +pub(crate) async fn edit( + client: Client, + organization_id: Uuid, + project_id: Uuid, + name: String, + output_settings: OutputSettings, +) -> Result<()> { + let project = client + .projects() + .update(&ProjectPutRequest { + id: project_id, + organization_id, + name, + }) + .await?; + serialize_response(project, output_settings); + + Ok(()) +} + +pub(crate) async fn delete(client: Client, project_ids: Vec) -> Result<()> { + let count = project_ids.len(); + + let result = client + .projects() + .delete(ProjectsDeleteRequest { ids: project_ids }) + .await?; + + let projects_failed: Vec<(Uuid, String)> = result + .data + .into_iter() + .filter_map(|r| r.error.map(|e| (r.id, e))) + .collect(); + let deleted_projects = count - projects_failed.len(); + + match deleted_projects { + 2.. => println!("{} projects deleted successfully.", deleted_projects), + 1 => println!("{} project deleted successfully.", deleted_projects), + _ => (), + } + + match projects_failed.len() { + 2.. => eprintln!("{} projects had errors:", projects_failed.len()), + 1 => eprintln!("{} project had an error:", projects_failed.len()), + _ => (), + } + + for project in &projects_failed { + eprintln!("{}: {}", project.0, project.1); + } + + if !projects_failed.is_empty() { + bail!("Errors when attempting to delete projects."); + } + + Ok(()) +} diff --git a/crates/bws/src/command/secret.rs b/crates/bws/src/command/secret.rs new file mode 100644 index 000000000..30613016d --- /dev/null +++ b/crates/bws/src/command/secret.rs @@ -0,0 +1,163 @@ +use bitwarden::{ + secrets_manager::secrets::{ + SecretCreateRequest, SecretGetRequest, SecretIdentifiersByProjectRequest, + SecretIdentifiersRequest, SecretPutRequest, SecretsDeleteRequest, SecretsGetRequest, + }, + Client, +}; +use color_eyre::eyre::{bail, Result}; +use uuid::Uuid; + +use crate::render::{serialize_response, OutputSettings}; + +#[derive(Debug)] +pub(crate) struct SecretCreateCommandModel { + pub(crate) key: String, + pub(crate) value: String, + pub(crate) note: Option, + pub(crate) project_id: Uuid, +} + +#[derive(Debug)] +pub(crate) struct SecretEditCommandModel { + pub(crate) id: Uuid, + pub(crate) key: Option, + pub(crate) value: Option, + pub(crate) note: Option, + pub(crate) project_id: Option, +} + +pub(crate) async fn list( + client: Client, + organization_id: Uuid, + project_id: Option, + output_settings: OutputSettings, +) -> Result<()> { + let res = if let Some(project_id) = project_id { + client + .secrets() + .list_by_project(&SecretIdentifiersByProjectRequest { project_id }) + .await? + } else { + client + .secrets() + .list(&SecretIdentifiersRequest { organization_id }) + .await? + }; + + let secret_ids = res.data.into_iter().map(|e| e.id).collect(); + let secrets = client + .secrets() + .get_by_ids(SecretsGetRequest { ids: secret_ids }) + .await? + .data; + serialize_response(secrets, output_settings); + + Ok(()) +} + +pub(crate) async fn get( + client: Client, + secret_id: Uuid, + output_settings: OutputSettings, +) -> Result<()> { + let secret = client + .secrets() + .get(&SecretGetRequest { id: secret_id }) + .await?; + serialize_response(secret, output_settings); + + Ok(()) +} + +pub(crate) async fn create( + client: Client, + organization_id: Uuid, + secret: SecretCreateCommandModel, + output_settings: OutputSettings, +) -> Result<()> { + let secret = client + .secrets() + .create(&SecretCreateRequest { + organization_id, + key: secret.key, + value: secret.value, + note: secret.note.unwrap_or_default(), + project_ids: Some(vec![secret.project_id]), + }) + .await?; + serialize_response(secret, output_settings); + + Ok(()) +} + +pub(crate) async fn edit( + client: Client, + organization_id: Uuid, + secret: SecretEditCommandModel, + output_settings: OutputSettings, +) -> Result<()> { + let old_secret = client + .secrets() + .get(&SecretGetRequest { id: secret.id }) + .await?; + + let new_secret = client + .secrets() + .update(&SecretPutRequest { + id: secret.id, + organization_id, + key: secret.key.unwrap_or(old_secret.key), + value: secret.value.unwrap_or(old_secret.value), + note: secret.note.unwrap_or(old_secret.note), + project_ids: match secret.project_id { + Some(id) => Some(vec![id]), + None => match old_secret.project_id { + Some(id) => Some(vec![id]), + None => bail!("Editing a secret requires a project_id."), + }, + }, + }) + .await?; + serialize_response(new_secret, output_settings); + + Ok(()) +} + +pub(crate) async fn delete(client: Client, secret_ids: Vec) -> Result<()> { + let count = secret_ids.len(); + + let result = client + .secrets() + .delete(SecretsDeleteRequest { ids: secret_ids }) + .await?; + + let secrets_failed: Vec<(Uuid, String)> = result + .data + .into_iter() + .filter_map(|r| r.error.map(|e| (r.id, e))) + .collect(); + let deleted_secrets = count - secrets_failed.len(); + + match deleted_secrets { + 2.. => println!("{} secrets deleted successfully.", deleted_secrets), + 1 => println!("{} secret deleted successfully.", deleted_secrets), + _ => (), + } + + match secrets_failed.len() { + 2.. => eprintln!("{} secrets had errors:", secrets_failed.len()), + 1 => eprintln!("{} secret had an error:", secrets_failed.len()), + _ => (), + } + + for secret in &secrets_failed { + eprintln!("{}: {}", secret.0, secret.1); + } + + if !secrets_failed.is_empty() { + bail!("Errors when attempting to delete secrets."); + } + + Ok(()) +} diff --git a/crates/bws/src/config.rs b/crates/bws/src/config.rs index 9756704f4..f769bb6da 100644 --- a/crates/bws/src/config.rs +++ b/crates/bws/src/config.rs @@ -129,7 +129,7 @@ impl Profile { return Ok(format!("{base}/api")); } - bail!("Profile has no `server_base` or `server_api`") + bail!("Profile has no `server_base` or `server_api`"); } pub(crate) fn identity_url(&self) -> Result { @@ -141,7 +141,7 @@ impl Profile { return Ok(format!("{base}/identity")); } - bail!("Profile has no `server_base` or `server_identity`") + bail!("Profile has no `server_base` or `server_identity`"); } } diff --git a/crates/bws/src/main.rs b/crates/bws/src/main.rs index bbd909eff..be1ea2bd4 100644 --- a/crates/bws/src/main.rs +++ b/crates/bws/src/main.rs @@ -1,32 +1,23 @@ -use std::{path::PathBuf, process, str::FromStr}; +use std::{path::PathBuf, str::FromStr}; use bitwarden::{ auth::{login::AccessTokenLoginRequest, AccessToken}, - secrets_manager::{ - projects::{ - ProjectCreateRequest, ProjectGetRequest, ProjectPutRequest, ProjectsDeleteRequest, - ProjectsListRequest, - }, - secrets::{ - SecretCreateRequest, SecretGetRequest, SecretIdentifiersByProjectRequest, - SecretIdentifiersRequest, SecretPutRequest, SecretsDeleteRequest, SecretsGetRequest, - }, - }, ClientSettings, }; use bitwarden_cli::install_color_eyre; use clap::{CommandFactory, Parser}; -use clap_complete::Shell; use color_eyre::eyre::{bail, Result}; +use command::secret::{SecretCreateCommandModel, SecretEditCommandModel}; use log::error; -use uuid::Uuid; +use render::OutputSettings; mod cli; +mod command; mod config; mod render; mod state; -use crate::{cli::*, render::serialize_response}; +use crate::cli::*; #[tokio::main(flavor = "current_thread")] async fn main() -> Result<()> { @@ -51,47 +42,21 @@ async fn process_commands() -> Result<()> { // These commands don't require authentication, so we process them first match command { Commands::Completions { shell } => { - let Some(shell) = shell.or_else(Shell::from_env) else { - eprintln!("Couldn't autodetect a valid shell. Run `bws completions --help` for more info."); - std::process::exit(1); - }; - - let mut cmd = Cli::command(); - let name = cmd.get_name().to_string(); - clap_complete::generate(shell, &mut cmd, name, &mut std::io::stdout()); - return Ok(()); + return command::completions(shell); } Commands::Config { name, value, delete, } => { - let profile = if let Some(profile) = cli.profile { - profile - } else if let Some(access_token) = cli.access_token { - AccessToken::from_str(&access_token)? - .access_token_id - .to_string() - } else { - String::from("default") - }; - - if delete { - config::delete_profile(cli.config_file.as_deref(), profile)?; - println!("Profile deleted successfully!"); - } else { - let (name, value) = match (name, value) { - (None, None) => bail!("Missing `name` and `value`"), - (None, Some(_)) => bail!("Missing `value`"), - (Some(_), None) => bail!("Missing `name`"), - (Some(name), Some(value)) => (name, value), - }; - - config::update_profile(cli.config_file.as_deref(), profile, name, value)?; - println!("Profile updated successfully!"); - }; - - return Ok(()); + return command::config( + name, + value, + delete, + cli.profile, + cli.access_token, + cli.config_file, + ); } _ => (), } @@ -144,6 +109,8 @@ async fn process_commands() -> Result<()> { } }; + let output_settings = OutputSettings::new(cli.output, color); + // And finally we process all the commands which require authentication match command { Commands::Project { @@ -151,43 +118,21 @@ async fn process_commands() -> Result<()> { } | Commands::List { cmd: ListCommand::Projects, - } => { - let projects = client - .projects() - .list(&ProjectsListRequest { organization_id }) - .await? - .data; - serialize_response(projects, cli.output, color); - } + } => command::project::list(client, organization_id, output_settings).await, Commands::Project { cmd: ProjectCommand::Get { project_id }, } | Commands::Get { cmd: GetCommand::Project { project_id }, - } => { - let project = client - .projects() - .get(&ProjectGetRequest { id: project_id }) - .await?; - serialize_response(project, cli.output, color); - } + } => command::project::get(client, project_id, output_settings).await, Commands::Project { cmd: ProjectCommand::Create { name }, } | Commands::Create { cmd: CreateCommand::Project { name }, - } => { - let project = client - .projects() - .create(&ProjectCreateRequest { - organization_id, - name, - }) - .await?; - serialize_response(project, cli.output, color); - } + } => command::project::create(client, organization_id, name, output_settings).await, Commands::Project { cmd: ProjectCommand::Edit { project_id, name }, @@ -195,15 +140,7 @@ async fn process_commands() -> Result<()> { | Commands::Edit { cmd: EditCommand::Project { project_id, name }, } => { - let project = client - .projects() - .update(&ProjectPutRequest { - id: project_id, - organization_id, - name, - }) - .await?; - serialize_response(project, cli.output, color); + command::project::edit(client, organization_id, project_id, name, output_settings).await } Commands::Project { @@ -211,81 +148,21 @@ async fn process_commands() -> Result<()> { } | Commands::Delete { cmd: DeleteCommand::Project { project_ids }, - } => { - let count = project_ids.len(); - - let result = client - .projects() - .delete(ProjectsDeleteRequest { ids: project_ids }) - .await?; - - let projects_failed: Vec<(Uuid, String)> = result - .data - .into_iter() - .filter_map(|r| r.error.map(|e| (r.id, e))) - .collect(); - let deleted_projects = count - projects_failed.len(); - - if deleted_projects > 1 { - println!("{} projects deleted successfully.", deleted_projects); - } else if deleted_projects == 1 { - println!("{} project deleted successfully.", deleted_projects); - } - - if projects_failed.len() > 1 { - eprintln!("{} projects had errors:", projects_failed.len()); - } else if projects_failed.len() == 1 { - eprintln!("{} project had an error:", projects_failed.len()); - } - - for project in &projects_failed { - eprintln!("{}: {}", project.0, project.1); - } - - if !projects_failed.is_empty() { - process::exit(1); - } - } + } => command::project::delete(client, project_ids).await, Commands::Secret { cmd: SecretCommand::List { project_id }, } | Commands::List { cmd: ListCommand::Secrets { project_id }, - } => { - let res = if let Some(project_id) = project_id { - client - .secrets() - .list_by_project(&SecretIdentifiersByProjectRequest { project_id }) - .await? - } else { - client - .secrets() - .list(&SecretIdentifiersRequest { organization_id }) - .await? - }; - - let secret_ids = res.data.into_iter().map(|e| e.id).collect(); - let secrets = client - .secrets() - .get_by_ids(SecretsGetRequest { ids: secret_ids }) - .await? - .data; - serialize_response(secrets, cli.output, color); - } + } => command::secret::list(client, organization_id, project_id, output_settings).await, Commands::Secret { cmd: SecretCommand::Get { secret_id }, } | Commands::Get { cmd: GetCommand::Secret { secret_id }, - } => { - let secret = client - .secrets() - .get(&SecretGetRequest { id: secret_id }) - .await?; - serialize_response(secret, cli.output, color); - } + } => command::secret::get(client, secret_id, output_settings).await, Commands::Secret { cmd: @@ -305,17 +182,18 @@ async fn process_commands() -> Result<()> { project_id, }, } => { - let secret = client - .secrets() - .create(&SecretCreateRequest { - organization_id, + command::secret::create( + client, + organization_id, + SecretCreateCommandModel { key, value, - note: note.unwrap_or_default(), - project_ids: Some(vec![project_id]), - }) - .await?; - serialize_response(secret, cli.output, color); + note, + project_id, + }, + output_settings, + ) + .await } Commands::Secret { @@ -338,29 +216,19 @@ async fn process_commands() -> Result<()> { project_id, }, } => { - let old_secret = client - .secrets() - .get(&SecretGetRequest { id: secret_id }) - .await?; - - let secret = client - .secrets() - .update(&SecretPutRequest { + command::secret::edit( + client, + organization_id, + SecretEditCommandModel { id: secret_id, - organization_id, - key: key.unwrap_or(old_secret.key), - value: value.unwrap_or(old_secret.value), - note: note.unwrap_or(old_secret.note), - project_ids: match project_id { - Some(id) => Some(vec![id]), - None => match old_secret.project_id { - Some(id) => Some(vec![id]), - None => bail!("Editing a secret requires a project_id."), - }, - }, - }) - .await?; - serialize_response(secret, cli.output, color); + key, + value, + note, + project_id, + }, + output_settings, + ) + .await } Commands::Secret { @@ -368,48 +236,12 @@ async fn process_commands() -> Result<()> { } | Commands::Delete { cmd: DeleteCommand::Secret { secret_ids }, - } => { - let count = secret_ids.len(); - - let result = client - .secrets() - .delete(SecretsDeleteRequest { ids: secret_ids }) - .await?; - - let secrets_failed: Vec<(Uuid, String)> = result - .data - .into_iter() - .filter_map(|r| r.error.map(|e| (r.id, e))) - .collect(); - let deleted_secrets = count - secrets_failed.len(); - - if deleted_secrets > 1 { - println!("{} secrets deleted successfully.", deleted_secrets); - } else if deleted_secrets == 1 { - println!("{} secret deleted successfully.", deleted_secrets); - } - - if secrets_failed.len() > 1 { - eprintln!("{} secrets had errors:", secrets_failed.len()); - } else if secrets_failed.len() == 1 { - eprintln!("{} secret had an error:", secrets_failed.len()); - } - - for secret in &secrets_failed { - eprintln!("{}: {}", secret.0, secret.1); - } - - if !secrets_failed.is_empty() { - process::exit(1); - } - } + } => command::secret::delete(client, secret_ids).await, Commands::Config { .. } | Commands::Completions { .. } => { unreachable!() } } - - Ok(()) } fn get_config_profile( diff --git a/crates/bws/src/render.rs b/crates/bws/src/render.rs index 219e72b68..7b286b511 100644 --- a/crates/bws/src/render.rs +++ b/crates/bws/src/render.rs @@ -8,23 +8,33 @@ use crate::cli::Output; const ASCII_HEADER_ONLY: &str = " -- "; +pub(crate) struct OutputSettings { + pub(crate) output: Output, + pub(crate) color: Color, +} + +impl OutputSettings { + pub(crate) fn new(output: Output, color: Color) -> Self { + OutputSettings { output, color } + } +} + pub(crate) fn serialize_response, const N: usize>( data: T, - output: Output, - color: Color, + output_settings: OutputSettings, ) { - match output { + match output_settings.output { Output::JSON => { let mut text = serde_json::to_string_pretty(&data).expect("Serialize should be infallible"); // Yaml/table/tsv serializations add a newline at the end, so we do the same here for // consistency text.push('\n'); - pretty_print("json", &text, color); + pretty_print("json", &text, output_settings.color); } Output::YAML => { let text = serde_yaml::to_string(&data).expect("Serialize should be infallible"); - pretty_print("yaml", &text, color); + pretty_print("yaml", &text, output_settings.color); } Output::Env => { let valid_key_regex = @@ -50,7 +60,11 @@ pub(crate) fn serialize_response, const N: usiz )); } - pretty_print("sh", &format!("{}\n", text.join("\n")), color); + pretty_print( + "sh", + &format!("{}\n", text.join("\n")), + output_settings.color, + ); } Output::Table => { let mut table = Table::new(); From 72dd93b7c142f0f93594d6dbd99d7f50967bc9a6 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 24 Jun 2024 12:20:41 +0200 Subject: [PATCH 028/214] Change access code generation to use alphanumerical (#853) Currently auth requests uses the password generator to generate a 25 character password. Since we're shuffling around code for #798 this won't be possible much longer. This PR adds a `generate_random_alphanumeric` to the `bitwarden_crypto` crate which generates a cryptographically secure random alphanumerical string that can be used instead. --- crates/bitwarden-crypto/src/lib.rs | 3 +-- crates/bitwarden-crypto/src/util.rs | 10 +++++++++- crates/bitwarden/src/auth/auth_request.rs | 13 +++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/crates/bitwarden-crypto/src/lib.rs b/crates/bitwarden-crypto/src/lib.rs index 3f54dec87..4c71b0029 100644 --- a/crates/bitwarden-crypto/src/lib.rs +++ b/crates/bitwarden-crypto/src/lib.rs @@ -76,9 +76,8 @@ pub use keys::*; mod rsa; pub use crate::rsa::RsaKeyPair; mod util; -pub use util::generate_random_bytes; +pub use util::{generate_random_alphanumeric, generate_random_bytes, pbkdf2}; mod wordlist; -pub use util::pbkdf2; pub use wordlist::EFF_LONG_WORD_LIST; mod allocator; pub use allocator::ZeroizingAllocator; diff --git a/crates/bitwarden-crypto/src/util.rs b/crates/bitwarden-crypto/src/util.rs index b78a4f5ec..72036c615 100644 --- a/crates/bitwarden-crypto/src/util.rs +++ b/crates/bitwarden-crypto/src/util.rs @@ -4,7 +4,7 @@ use ::aes::cipher::{ArrayLength, Unsigned}; use generic_array::GenericArray; use hmac::digest::OutputSizeUser; use rand::{ - distributions::{Distribution, Standard}, + distributions::{Alphanumeric, DistString, Distribution, Standard}, Rng, }; use zeroize::{Zeroize, Zeroizing}; @@ -39,6 +39,14 @@ where Zeroizing::new(rand::thread_rng().gen::()) } +/// Generate a random alphanumeric string of a given length +/// +/// Note: Do not use this generating user facing passwords. Use the `bitwarden-generator` crate for +/// that. +pub fn generate_random_alphanumeric(len: usize) -> String { + Alphanumeric.sample_string(&mut rand::thread_rng(), len) +} + pub fn pbkdf2(password: &[u8], salt: &[u8], rounds: u32) -> [u8; PBKDF_SHA256_HMAC_OUT_SIZE] { pbkdf2::pbkdf2_array::(password, salt, rounds) .expect("hash is a valid fixed size") diff --git a/crates/bitwarden/src/auth/auth_request.rs b/crates/bitwarden/src/auth/auth_request.rs index 7d90b6a36..1abe86ed9 100644 --- a/crates/bitwarden/src/auth/auth_request.rs +++ b/crates/bitwarden/src/auth/auth_request.rs @@ -1,11 +1,11 @@ use base64::{engine::general_purpose::STANDARD, Engine}; use bitwarden_core::VaultLocked; use bitwarden_crypto::{ - fingerprint, AsymmetricCryptoKey, AsymmetricEncString, AsymmetricPublicCryptoKey, + fingerprint, generate_random_alphanumeric, AsymmetricCryptoKey, AsymmetricEncString, + AsymmetricPublicCryptoKey, }; #[cfg(feature = "internal")] use bitwarden_crypto::{EncString, KeyDecryptable, SymmetricCryptoKey}; -use bitwarden_generators::{password, PasswordGeneratorRequest}; use crate::{error::Error, Client}; @@ -41,14 +41,7 @@ pub(crate) fn new_auth_request(email: &str) -> Result Date: Mon, 24 Jun 2024 13:13:21 -0400 Subject: [PATCH 029/214] [deps]: Update dtolnay/rust-toolchain digest to 21dc36f (#855) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/build-android.yml | 4 ++-- .github/workflows/build-cli.yml | 10 +++++----- .github/workflows/build-napi.yml | 2 +- .github/workflows/build-python-wheels.yml | 2 +- .github/workflows/build-rust-crates.yml | 4 ++-- .github/workflows/build-rust-cross-platform.yml | 2 +- .github/workflows/build-wasm.yml | 2 +- .github/workflows/direct-minimal-versions.yml | 2 +- .github/workflows/generate_schemas.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/memory-testing.yml | 2 +- .github/workflows/minimum-rust-version.yml | 2 +- .github/workflows/publish-rust-crates.yml | 2 +- .github/workflows/release-cli.yml | 2 +- .github/workflows/rust-test.yml | 6 +++--- .github/workflows/version-bump.yml | 2 +- 16 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index 58a12f7f0..3bd77bb75 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -28,7 +28,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable @@ -70,7 +70,7 @@ jobs: fetch-depth: 0 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable diff --git a/.github/workflows/build-cli.yml b/.github/workflows/build-cli.yml index 20e22632b..245b36b7c 100644 --- a/.github/workflows/build-cli.yml +++ b/.github/workflows/build-cli.yml @@ -61,7 +61,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable targets: ${{ matrix.settings.target }} @@ -151,7 +151,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable targets: ${{ matrix.settings.target }} @@ -266,7 +266,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable targets: ${{ matrix.settings.target }} @@ -413,7 +413,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable @@ -448,7 +448,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable diff --git a/.github/workflows/build-napi.yml b/.github/workflows/build-napi.yml index 87231d5f0..81fa07417 100644 --- a/.github/workflows/build-napi.yml +++ b/.github/workflows/build-napi.yml @@ -61,7 +61,7 @@ jobs: cache-dependency-path: crates/bitwarden-napi/package-lock.json - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable targets: ${{ matrix.settings.target }} diff --git a/.github/workflows/build-python-wheels.yml b/.github/workflows/build-python-wheels.yml index bc718a430..766fcaf1e 100644 --- a/.github/workflows/build-python-wheels.yml +++ b/.github/workflows/build-python-wheels.yml @@ -71,7 +71,7 @@ jobs: node-version: 18 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable targets: ${{ matrix.settings.target }} diff --git a/.github/workflows/build-rust-crates.yml b/.github/workflows/build-rust-crates.yml index 60a982814..3cbf16aa0 100644 --- a/.github/workflows/build-rust-crates.yml +++ b/.github/workflows/build-rust-crates.yml @@ -39,7 +39,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable targets: ${{ matrix.settings.target }} @@ -69,7 +69,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable targets: ${{ matrix.settings.target }} diff --git a/.github/workflows/build-rust-cross-platform.yml b/.github/workflows/build-rust-cross-platform.yml index ab56a47e8..0c99a5a23 100644 --- a/.github/workflows/build-rust-cross-platform.yml +++ b/.github/workflows/build-rust-cross-platform.yml @@ -38,7 +38,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable diff --git a/.github/workflows/build-wasm.yml b/.github/workflows/build-wasm.yml index 760e83254..45313782f 100644 --- a/.github/workflows/build-wasm.yml +++ b/.github/workflows/build-wasm.yml @@ -35,7 +35,7 @@ jobs: run: npm i -g binaryen - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable targets: wasm32-unknown-unknown diff --git a/.github/workflows/direct-minimal-versions.yml b/.github/workflows/direct-minimal-versions.yml index c9d3900ee..0c58466e1 100644 --- a/.github/workflows/direct-minimal-versions.yml +++ b/.github/workflows/direct-minimal-versions.yml @@ -39,7 +39,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: nightly targets: ${{ matrix.settings.target }} diff --git a/.github/workflows/generate_schemas.yml b/.github/workflows/generate_schemas.yml index 008ee31e9..cf21c54e8 100644 --- a/.github/workflows/generate_schemas.yml +++ b/.github/workflows/generate_schemas.yml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b9b6d4d73..3e5e2a1eb 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,7 +20,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable diff --git a/.github/workflows/memory-testing.yml b/.github/workflows/memory-testing.yml index c0a9fbecd..8b577608f 100644 --- a/.github/workflows/memory-testing.yml +++ b/.github/workflows/memory-testing.yml @@ -30,7 +30,7 @@ jobs: sudo apt -y install gdb - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable diff --git a/.github/workflows/minimum-rust-version.yml b/.github/workflows/minimum-rust-version.yml index af309ceed..f5dbdab4d 100644 --- a/.github/workflows/minimum-rust-version.yml +++ b/.github/workflows/minimum-rust-version.yml @@ -30,7 +30,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: # Important: When updating this, make sure to update the Readme file # and also the `rust-version` field in all the `Cargo.toml`. diff --git a/.github/workflows/publish-rust-crates.yml b/.github/workflows/publish-rust-crates.yml index deeef87cd..f4da56342 100644 --- a/.github/workflows/publish-rust-crates.yml +++ b/.github/workflows/publish-rust-crates.yml @@ -203,7 +203,7 @@ jobs: secrets: "cratesio-api-token" - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index df9715bb1..656f162c2 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -142,7 +142,7 @@ jobs: secrets: "cratesio-api-token" - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable diff --git a/.github/workflows/rust-test.yml b/.github/workflows/rust-test.yml index 8aa844293..9338a093d 100644 --- a/.github/workflows/rust-test.yml +++ b/.github/workflows/rust-test.yml @@ -39,7 +39,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable @@ -58,7 +58,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable components: llvm-tools @@ -87,7 +87,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable targets: wasm32-unknown-unknown diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index 406f3b927..24a2c7997 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -34,7 +34,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Install rust - uses: dtolnay/rust-toolchain@d8352f6b1d2e870bc5716e7a6d9b65c4cc244a1a # stable + uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable with: toolchain: stable From ef86ab9a24db71e35e49fe1ca3e1eafde3eb1738 Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Tue, 25 Jun 2024 11:02:30 +0200 Subject: [PATCH 030/214] Add login username to fido2 name fallback (#857) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective Add `LoginView.username` to `user_name_for_ui` in `Fido2CredentialAutofillView` ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-fido/src/types.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/bitwarden-fido/src/types.rs b/crates/bitwarden-fido/src/types.rs index d6eaa4752..79777d24c 100644 --- a/crates/bitwarden-fido/src/types.rs +++ b/crates/bitwarden-fido/src/types.rs @@ -77,6 +77,10 @@ impl Fido2CredentialAutofillView { .user_name .none_whitespace() .or(c.user_display_name.none_whitespace()) + .or(cipher + .login + .as_ref() + .and_then(|l| l.username.none_whitespace())) .or(cipher.name.none_whitespace()), }) }) From 47cf3cc7708b759b9c137aff737f2542e285a76d Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Wed, 26 Jun 2024 17:18:44 +0200 Subject: [PATCH 031/214] [PM-8301] Invert crates relationship (#798) This PR inverts the relationship between most crates in an effort to make the code base easier to maintain. - Moves most of the logic into `bitwarden-core`. - `bitwarden` provides re-exports from the various crates. - Moved `ClientFeature` structs to the various crates, and introduced `ClientFeatureExt` which exposes it on `Client`. This now becomes the typical way to use functionality. - Created `InternalClient` which contains the internal functionality for hooking up logic between the various crates. --- Cargo.lock | 70 ++++-- Cargo.toml | 1 + .../CHANGELOG.md | 0 crates/bitwarden-core/Cargo.toml | 80 ++++++- crates/bitwarden-core/README.md | 2 +- .../src/.gitignore | 0 .../src/admin_console/mod.rs | 0 .../src/admin_console/policy.rs | 6 +- .../src/auth/access_token.rs | 0 .../src/auth/api/mod.rs | 0 .../auth/api/request/access_token_request.rs | 0 .../src/auth/api/request/api_token_request.rs | 0 .../api/request/auth_request_token_request.rs | 1 + .../src/auth/api/request/mod.rs | 17 +- .../api/request/password_token_request.rs | 0 .../auth/api/request/renew_token_request.rs | 0 .../api/response/identity_captcha_response.rs | 0 .../api/response/identity_payload_response.rs | 0 .../api/response/identity_refresh_response.rs | 0 .../api/response/identity_success_response.rs | 0 .../response/identity_token_fail_response.rs | 0 .../api/response/identity_token_response.rs | 0 .../response/identity_two_factor_response.rs | 0 .../src/auth/api/response/mod.rs | 0 .../two_factor_provider_data/authenticator.rs | 0 .../response/two_factor_provider_data/duo.rs | 0 .../two_factor_provider_data/email.rs | 0 .../response/two_factor_provider_data/mod.rs | 0 .../organization_duo.rs | 0 .../two_factor_provider_data/remember.rs | 0 .../two_factor_provider_data/web_authn.rs | 0 .../two_factor_provider_data/yubi_key.rs | 0 .../auth/api/response/two_factor_providers.rs | 0 .../src/auth/auth_request.rs | 9 +- .../src/auth/client_auth.rs | 40 ++-- .../src/auth/jwt_token.rs | 0 .../src/auth/login/access_token.rs | 48 ++-- .../src/auth/login/api_key.rs | 25 +- .../src/auth/login/auth_request.rs | 21 +- .../src/auth/login/mod.rs | 8 +- .../src/auth/login/password.rs | 27 ++- .../auth/login/response/captcha_response.rs | 0 .../src/auth/login/response/mod.rs | 0 .../response/two_factor/authenticator.rs | 0 .../src/auth/login/response/two_factor/duo.rs | 0 .../auth/login/response/two_factor/email.rs | 0 .../src/auth/login/response/two_factor/mod.rs | 0 .../login/response/two_factor/remember.rs | 0 .../two_factor/two_factor_providers.rs | 0 .../login/response/two_factor/web_authn.rs | 0 .../login/response/two_factor/yubi_key.rs | 0 .../src/auth/login/two_factor.rs | 2 +- .../src/auth/mod.rs | 18 +- .../src/auth/password/mod.rs | 0 .../src/auth/password/policy.rs | 0 .../src/auth/password/strength.rs | 0 .../src/auth/password/validate.rs | 73 ++++-- .../src/auth/register.rs | 6 +- .../src/auth/renew.rs | 17 +- .../src/auth/tde.rs | 20 +- crates/bitwarden-core/src/client/client.rs | 105 ++++++++ .../src/client/client_settings.rs | 2 +- .../src/client/encryption_settings.rs | 6 +- .../src/client/flags.rs | 0 .../src/client/internal.rs} | 224 +++++------------- .../bitwarden-core/src/client/login_method.rs | 46 ++++ crates/bitwarden-core/src/client/mod.rs | 20 ++ .../src/client/test_accounts.rs | 3 +- crates/bitwarden-core/src/error.rs | 116 +++++++++ crates/bitwarden-core/src/lib.rs | 15 ++ .../src/mobile/client_crypto.rs | 0 .../src/mobile/client_kdf.rs | 4 +- .../src/mobile/crypto.rs | 88 ++++--- .../src/mobile/kdf.rs | 0 .../src/mobile/mod.rs | 2 - .../src/platform/client_platform.rs | 9 - .../src/platform/generate_fingerprint.rs | 7 +- .../src/platform/get_user_api_key.rs | 12 +- .../src/platform/mod.rs | 9 - .../platform/secret_verification_request.rs | 0 .../bitwarden-core/src/secrets_manager/mod.rs | 1 + .../src/secrets_manager/state.rs | 0 crates/bitwarden-core/src/uniffi_support.rs | 11 + .../{bitwarden => bitwarden-core}/src/util.rs | 0 .../tests/register.rs | 2 +- crates/bitwarden-crypto/Cargo.toml | 2 +- crates/bitwarden-exporters/Cargo.toml | 7 +- .../src}/client_exporter.rs | 27 ++- crates/bitwarden-exporters/src/error.rs | 21 ++ crates/bitwarden-exporters/src/export.rs | 43 ++++ crates/bitwarden-exporters/src/lib.rs | 48 ++-- .../uniffi.toml | 6 +- crates/bitwarden-fido/Cargo.toml | 4 +- crates/bitwarden-fido/src/authenticator.rs | 38 +-- .../src}/client_fido.rs | 36 +-- crates/bitwarden-fido/src/lib.rs | 6 +- crates/bitwarden-generators/Cargo.toml | 1 + .../src}/client_generator.rs | 53 +++-- crates/bitwarden-generators/src/lib.rs | 2 + crates/bitwarden-json/src/client.rs | 4 + crates/bitwarden-send/Cargo.toml | 2 +- .../src}/client_sends.rs | 48 ++-- crates/bitwarden-send/src/lib.rs | 2 + crates/bitwarden-send/src/send.rs | 2 +- crates/bitwarden-sm/Cargo.toml | 32 +++ crates/bitwarden-sm/src/client_projects.rs | 50 ++++ crates/bitwarden-sm/src/client_secrets.rs | 70 ++++++ crates/bitwarden-sm/src/lib.rs | 7 + .../src}/projects/create.rs | 9 +- .../src}/projects/delete.rs | 12 +- .../src}/projects/get.rs | 8 +- .../src}/projects/list.rs | 16 +- .../src}/projects/mod.rs | 0 .../src}/projects/project_response.rs | 6 +- .../src}/projects/update.rs | 9 +- .../src}/secrets/create.rs | 9 +- .../src}/secrets/delete.rs | 12 +- .../src}/secrets/get.rs | 8 +- .../src}/secrets/get_by_ids.rs | 8 +- .../src}/secrets/list.rs | 26 +- .../src}/secrets/mod.rs | 0 .../src}/secrets/secret_response.rs | 10 +- .../src}/secrets/sync.rs | 11 +- .../src}/secrets/update.rs | 10 +- crates/bitwarden-uniffi/Cargo.toml | 1 + crates/bitwarden-uniffi/src/docs.rs | 3 +- crates/bitwarden-uniffi/src/error.rs | 6 + crates/bitwarden-uniffi/src/platform/fido2.rs | 46 ++-- crates/bitwarden-uniffi/src/platform/mod.rs | 2 +- crates/bitwarden-uniffi/src/tool/mod.rs | 36 ++- crates/bitwarden-uniffi/src/tool/sends.rs | 2 +- .../bitwarden-uniffi/src/vault/attachments.rs | 4 +- crates/bitwarden-uniffi/src/vault/ciphers.rs | 8 +- .../bitwarden-uniffi/src/vault/collections.rs | 2 +- crates/bitwarden-uniffi/src/vault/folders.rs | 2 +- crates/bitwarden-uniffi/src/vault/mod.rs | 12 +- .../src/vault/password_history.rs | 2 +- crates/bitwarden-vault/Cargo.toml | 7 +- crates/bitwarden-vault/src/cipher/cipher.rs | 15 +- .../src}/client_totp.rs | 7 +- crates/bitwarden-vault/src/client_vault.rs | 30 +++ crates/bitwarden-vault/src/lib.rs | 6 + .../src/mobile}/client_attachments.rs | 22 +- .../src/mobile}/client_ciphers.rs | 45 ++-- .../src/mobile}/client_collection.rs | 21 +- .../src/mobile}/client_folders.rs | 16 +- .../src/mobile}/client_password_history.rs | 15 +- crates/bitwarden-vault/src/mobile/mod.rs | 5 + .../src/vault => bitwarden-vault/src}/sync.rs | 55 +++-- crates/bitwarden-wasm/Cargo.toml | 8 + crates/bitwarden-wasm/build.sh | 4 +- crates/bitwarden/Cargo.toml | 62 +---- crates/bitwarden/README.md | 6 +- crates/bitwarden/src/client/mod.rs | 17 -- crates/bitwarden/src/error.rs | 97 +------- crates/bitwarden/src/lib.rs | 59 ++--- crates/bitwarden/src/mobile/tool/mod.rs | 2 - crates/bitwarden/src/mobile/vault/mod.rs | 12 - .../src/secrets_manager/client_projects.rs | 41 ---- .../src/secrets_manager/client_secrets.rs | 62 ----- crates/bitwarden/src/secrets_manager/mod.rs | 9 - crates/bitwarden/src/tool/exporters/mod.rs | 115 --------- crates/bitwarden/src/tool/mod.rs | 5 - crates/bitwarden/src/uniffi_support.rs | 16 -- crates/bitwarden/src/vault/client_vault.rs | 18 -- crates/bitwarden/src/vault/mod.rs | 9 - crates/bw/src/auth/login.rs | 2 +- crates/bw/src/main.rs | 2 +- crates/bws/src/command/project.rs | 9 +- crates/bws/src/command/secret.rs | 9 +- crates/bws/src/main.rs | 2 +- .../bitwarden/myapplication/MainActivity.kt | 6 +- 172 files changed, 1542 insertions(+), 1238 deletions(-) rename crates/{bitwarden => bitwarden-core}/CHANGELOG.md (100%) rename crates/{bitwarden => bitwarden-core}/src/.gitignore (100%) rename crates/{bitwarden => bitwarden-core}/src/admin_console/mod.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/admin_console/policy.rs (98%) rename crates/{bitwarden => bitwarden-core}/src/auth/access_token.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/mod.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/request/access_token_request.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/request/api_token_request.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/request/auth_request_token_request.rs (98%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/request/mod.rs (92%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/request/password_token_request.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/request/renew_token_request.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/identity_captcha_response.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/identity_payload_response.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/identity_refresh_response.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/identity_success_response.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/identity_token_fail_response.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/identity_token_response.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/identity_two_factor_response.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/mod.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/two_factor_provider_data/authenticator.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/two_factor_provider_data/duo.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/two_factor_provider_data/email.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/two_factor_provider_data/mod.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/two_factor_provider_data/organization_duo.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/two_factor_provider_data/remember.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/two_factor_provider_data/web_authn.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/two_factor_provider_data/yubi_key.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/api/response/two_factor_providers.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/auth_request.rs (98%) rename crates/{bitwarden => bitwarden-core}/src/auth/client_auth.rs (91%) rename crates/{bitwarden => bitwarden-core}/src/auth/jwt_token.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/login/access_token.rs (85%) rename crates/{bitwarden => bitwarden-core}/src/auth/login/api_key.rs (84%) rename crates/{bitwarden => bitwarden-core}/src/auth/login/auth_request.rs (88%) rename crates/{bitwarden => bitwarden-core}/src/auth/login/mod.rs (91%) rename crates/{bitwarden => bitwarden-core}/src/auth/login/password.rs (88%) rename crates/{bitwarden => bitwarden-core}/src/auth/login/response/captcha_response.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/login/response/mod.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/login/response/two_factor/authenticator.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/login/response/two_factor/duo.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/login/response/two_factor/email.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/login/response/two_factor/mod.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/login/response/two_factor/remember.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/login/response/two_factor/two_factor_providers.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/login/response/two_factor/web_authn.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/login/response/two_factor/yubi_key.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/login/two_factor.rs (96%) rename crates/{bitwarden => bitwarden-core}/src/auth/mod.rs (95%) rename crates/{bitwarden => bitwarden-core}/src/auth/password/mod.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/password/policy.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/password/strength.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/auth/password/validate.rs (83%) rename crates/{bitwarden => bitwarden-core}/src/auth/register.rs (92%) rename crates/{bitwarden => bitwarden-core}/src/auth/renew.rs (89%) rename crates/{bitwarden => bitwarden-core}/src/auth/tde.rs (80%) create mode 100644 crates/bitwarden-core/src/client/client.rs rename crates/{bitwarden => bitwarden-core}/src/client/client_settings.rs (97%) rename crates/{bitwarden => bitwarden-core}/src/client/encryption_settings.rs (96%) rename crates/{bitwarden => bitwarden-core}/src/client/flags.rs (100%) rename crates/{bitwarden/src/client/client.rs => bitwarden-core/src/client/internal.rs} (57%) create mode 100644 crates/bitwarden-core/src/client/login_method.rs create mode 100644 crates/bitwarden-core/src/client/mod.rs rename crates/{bitwarden => bitwarden-core}/src/client/test_accounts.rs (99%) rename crates/{bitwarden => bitwarden-core}/src/mobile/client_crypto.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/mobile/client_kdf.rs (80%) rename crates/{bitwarden => bitwarden-core}/src/mobile/crypto.rs (90%) rename crates/{bitwarden => bitwarden-core}/src/mobile/kdf.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/mobile/mod.rs (82%) rename crates/{bitwarden => bitwarden-core}/src/platform/client_platform.rs (81%) rename crates/{bitwarden => bitwarden-core}/src/platform/generate_fingerprint.rs (96%) rename crates/{bitwarden => bitwarden-core}/src/platform/get_user_api_key.rs (90%) rename crates/{bitwarden => bitwarden-core}/src/platform/mod.rs (63%) rename crates/{bitwarden => bitwarden-core}/src/platform/secret_verification_request.rs (100%) create mode 100644 crates/bitwarden-core/src/secrets_manager/mod.rs rename crates/{bitwarden => bitwarden-core}/src/secrets_manager/state.rs (100%) rename crates/{bitwarden => bitwarden-core}/src/util.rs (100%) rename crates/{bitwarden => bitwarden-core}/tests/register.rs (97%) rename crates/{bitwarden/src/tool/exporters => bitwarden-exporters/src}/client_exporter.rs (52%) create mode 100644 crates/bitwarden-exporters/src/error.rs create mode 100644 crates/bitwarden-exporters/src/export.rs rename crates/{bitwarden => bitwarden-exporters}/uniffi.toml (50%) rename crates/{bitwarden/src/platform => bitwarden-fido/src}/client_fido.rs (71%) rename crates/{bitwarden/src/tool => bitwarden-generators/src}/client_generator.rs (63%) rename crates/{bitwarden/src/mobile/tool => bitwarden-send/src}/client_sends.rs (65%) create mode 100644 crates/bitwarden-sm/Cargo.toml create mode 100644 crates/bitwarden-sm/src/client_projects.rs create mode 100644 crates/bitwarden-sm/src/client_secrets.rs create mode 100644 crates/bitwarden-sm/src/lib.rs rename crates/{bitwarden/src/secrets_manager => bitwarden-sm/src}/projects/create.rs (82%) rename crates/{bitwarden/src/secrets_manager => bitwarden-sm/src}/projects/delete.rs (86%) rename crates/{bitwarden/src/secrets_manager => bitwarden-sm/src}/projects/get.rs (72%) rename crates/{bitwarden/src/secrets_manager => bitwarden-sm/src}/projects/list.rs (85%) rename crates/{bitwarden/src/secrets_manager => bitwarden-sm/src}/projects/mod.rs (100%) rename crates/{bitwarden/src/secrets_manager => bitwarden-sm/src}/projects/project_response.rs (90%) rename crates/{bitwarden/src/secrets_manager => bitwarden-sm/src}/projects/update.rs (82%) rename crates/{bitwarden/src/secrets_manager => bitwarden-sm/src}/secrets/create.rs (86%) rename crates/{bitwarden/src/secrets_manager => bitwarden-sm/src}/secrets/delete.rs (86%) rename crates/{bitwarden/src/secrets_manager => bitwarden-sm/src}/secrets/get.rs (73%) rename crates/{bitwarden/src/secrets_manager => bitwarden-sm/src}/secrets/get_by_ids.rs (77%) rename crates/{bitwarden/src/secrets_manager => bitwarden-sm/src}/secrets/list.rs (85%) rename crates/{bitwarden/src/secrets_manager => bitwarden-sm/src}/secrets/mod.rs (100%) rename crates/{bitwarden/src/secrets_manager => bitwarden-sm/src}/secrets/secret_response.rs (93%) rename crates/{bitwarden/src/secrets_manager => bitwarden-sm/src}/secrets/sync.rs (86%) rename crates/{bitwarden/src/secrets_manager => bitwarden-sm/src}/secrets/update.rs (85%) rename crates/{bitwarden/src/mobile/vault => bitwarden-vault/src}/client_totp.rs (66%) create mode 100644 crates/bitwarden-vault/src/client_vault.rs rename crates/{bitwarden/src/mobile/vault => bitwarden-vault/src/mobile}/client_attachments.rs (83%) rename crates/{bitwarden/src/mobile/vault => bitwarden-vault/src/mobile}/client_ciphers.rs (89%) rename crates/{bitwarden/src/mobile/vault => bitwarden-vault/src/mobile}/client_collection.rs (81%) rename crates/{bitwarden/src/mobile/vault => bitwarden-vault/src/mobile}/client_folders.rs (69%) rename crates/{bitwarden/src/mobile/vault => bitwarden-vault/src/mobile}/client_password_history.rs (65%) create mode 100644 crates/bitwarden-vault/src/mobile/mod.rs rename crates/{bitwarden/src/vault => bitwarden-vault/src}/sync.rs (76%) delete mode 100644 crates/bitwarden/src/client/mod.rs delete mode 100644 crates/bitwarden/src/mobile/tool/mod.rs delete mode 100644 crates/bitwarden/src/mobile/vault/mod.rs delete mode 100644 crates/bitwarden/src/secrets_manager/client_projects.rs delete mode 100644 crates/bitwarden/src/secrets_manager/client_secrets.rs delete mode 100644 crates/bitwarden/src/secrets_manager/mod.rs delete mode 100644 crates/bitwarden/src/tool/exporters/mod.rs delete mode 100644 crates/bitwarden/src/tool/mod.rs delete mode 100644 crates/bitwarden/src/uniffi_support.rs delete mode 100644 crates/bitwarden/src/vault/client_vault.rs delete mode 100644 crates/bitwarden/src/vault/mod.rs diff --git a/Cargo.lock b/Cargo.lock index e4c3f54c0..a1c0dbe4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -357,8 +357,6 @@ checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" name = "bitwarden" version = "0.5.0" dependencies = [ - "async-trait", - "base64 0.22.1", "bitwarden-api-api", "bitwarden-api-identity", "bitwarden-core", @@ -367,27 +365,10 @@ dependencies = [ "bitwarden-fido", "bitwarden-generators", "bitwarden-send", + "bitwarden-sm", "bitwarden-vault", - "chrono", - "getrandom", - "log", - "rand", - "rand_chacha", - "reqwest", - "rustls-platform-verifier", - "schemars", - "security-framework", - "serde", - "serde_json", - "serde_qs", - "serde_repr", "thiserror", - "tokio", - "uniffi", "uuid", - "wiremock", - "zeroize", - "zxcvbn", ] [[package]] @@ -439,10 +420,37 @@ dependencies = [ name = "bitwarden-core" version = "0.5.0" dependencies = [ + "async-trait", + "base64 0.22.1", + "bitwarden-api-api", + "bitwarden-api-identity", + "bitwarden-crypto", "chrono", + "coset", + "getrandom", + "hmac", + "log", + "p256", + "passkey", + "rand", + "rand_chacha", + "reqwest", + "rustls-platform-verifier", + "schemars", + "security-framework", + "serde", + "serde_json", + "serde_qs", + "serde_repr", + "sha1", + "sha2", "thiserror", + "tokio", "uniffi", "uuid", + "wiremock", + "zeroize", + "zxcvbn", ] [[package]] @@ -486,9 +494,11 @@ dependencies = [ "bitwarden-vault", "chrono", "csv", + "schemars", "serde", "serde_json", "thiserror", + "uniffi", "uuid", ] @@ -520,6 +530,7 @@ dependencies = [ name = "bitwarden-generators" version = "0.5.0" dependencies = [ + "bitwarden-core", "bitwarden-crypto", "rand", "rand_chacha", @@ -586,6 +597,22 @@ dependencies = [ "zeroize", ] +[[package]] +name = "bitwarden-sm" +version = "0.5.0" +dependencies = [ + "bitwarden-api-api", + "bitwarden-core", + "bitwarden-crypto", + "chrono", + "schemars", + "serde", + "serde_json", + "thiserror", + "uniffi", + "uuid", +] + [[package]] name = "bitwarden-uniffi" version = "0.1.0" @@ -595,6 +622,7 @@ dependencies = [ "bitwarden", "bitwarden-core", "bitwarden-crypto", + "bitwarden-exporters", "bitwarden-fido", "bitwarden-generators", "bitwarden-send", @@ -627,6 +655,7 @@ dependencies = [ "sha1", "sha2", "thiserror", + "tokio", "uniffi", "uuid", ] @@ -637,6 +666,7 @@ version = "0.1.0" dependencies = [ "argon2", "bitwarden-json", + "chrono", "console_error_panic_hook", "console_log", "js-sys", diff --git a/Cargo.toml b/Cargo.toml index 121c7733f..e721d9090 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ bitwarden-exporters = { path = "crates/bitwarden-exporters", version = "=0.5.0" bitwarden-fido = { path = "crates/bitwarden-fido", version = "=0.5.0" } bitwarden-generators = { path = "crates/bitwarden-generators", version = "=0.5.0" } bitwarden-send = { path = "crates/bitwarden-send", version = "=0.5.0" } +bitwarden-sm = { path = "crates/bitwarden-sm", version = "=0.5.0" } bitwarden-vault = { path = "crates/bitwarden-vault", version = "=0.5.0" } [workspace.lints.clippy] diff --git a/crates/bitwarden/CHANGELOG.md b/crates/bitwarden-core/CHANGELOG.md similarity index 100% rename from crates/bitwarden/CHANGELOG.md rename to crates/bitwarden-core/CHANGELOG.md diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml index 5f755020c..ba3ebbe68 100644 --- a/crates/bitwarden-core/Cargo.toml +++ b/crates/bitwarden-core/Cargo.toml @@ -3,6 +3,7 @@ name = "bitwarden-core" description = """ Internal crate for the bitwarden crate. Do not use. """ +keywords = ["bitwarden"] version.workspace = true authors.workspace = true @@ -11,16 +12,85 @@ rust-version.workspace = true homepage.workspace = true repository.workspace = true license-file.workspace = true -keywords.workspace = true [features] -uniffi = ["dep:uniffi"] +internal = [] # Internal testing methods +no-memory-hardening = [ + "bitwarden-crypto/no-memory-hardening", +] # Disable memory hardening features +uniffi = [ + "bitwarden-crypto/uniffi", + "dep:uniffi", + "dep:passkey", + "dep:coset", + "dep:p256", +] # Uniffi bindings +secrets = [] # Secrets manager API [dependencies] -chrono = { version = ">=0.4.26, <0.5", default-features = false } -uniffi = { version = "=0.27.2", optional = true } -uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } +async-trait = ">=0.1.80, <0.2" +base64 = ">=0.22.1, <0.23" +bitwarden-api-api = { workspace = true } +bitwarden-api-identity = { workspace = true } +bitwarden-crypto = { workspace = true } +chrono = { version = ">=0.4.26, <0.5", features = [ + "clock", + "serde", + "std", +], default-features = false } +coset = { version = "0.3.7", optional = true } +# 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"] } +hmac = ">=0.12.1, <0.13" +log = ">=0.4.18, <0.5" +p256 = { version = ">=0.13.2, <0.14", optional = true } +passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "c48c2ddfd6b884b2d754432576c66cb2b1985a3a", optional = true } +rand = ">=0.8.5, <0.9" +reqwest = { version = ">=0.12.5, <0.13", features = [ + "http2", + "json", +], default-features = false } +schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } +serde = { version = ">=1.0, <2.0", features = ["derive"] } +serde_json = ">=1.0.96, <2.0" +serde_qs = ">=0.12.0, <0.14" +serde_repr = ">=0.1.12, <0.2" +sha1 = ">=0.10.5, <0.11" +sha2 = ">=0.10.6, <0.11" thiserror = ">=1.0.40, <2.0" +uniffi = { version = "=0.27.2", optional = true, features = ["tokio"] } +uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } +zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } +zxcvbn = ">= 2.2.2, <3.0" + +[target.'cfg(all(not(target_os = "android"), not(target_arch="wasm32")))'.dependencies] +# By default, we use rustls as the TLS stack and rust-platform-verifier to support user-installed root certificates +# There are a few exceptions to this: +# - WASM doesn't require a TLS stack, as it just uses the browsers/node fetch +# - Android uses webpki-roots for the moment +reqwest = { version = ">=0.12.5, <0.13", features = [ + "rustls-tls-manual-roots", +], default-features = false } +rustls-platform-verifier = "0.3.1" + +[target.'cfg(target_os = "android")'.dependencies] +# On android, the use of rustls-platform-verifier is more complicated and going through some changes at the moment, so we fall back to using webpki-roots +# This means that for the moment android won't support self-signed certificates, even if they are included in the OS trust store +reqwest = { version = ">=0.12.5, <0.13", features = [ + "rustls-tls-webpki-roots", +], default-features = false } + +# This is a workaround to fix a bug with version 2.11.0 that added some symbols that are not available on iOS +# The bug is fixed already but the fix is not released yet. https://github.com/kornelski/rust-security-framework/pull/204 +[target.'cfg(target_os = "ios")'.dependencies] +security-framework = { version = "=2.10" } + +[dev-dependencies] +bitwarden-crypto = { workspace = true } +rand_chacha = "0.3.1" +tokio = { version = "1.36.0", features = ["rt", "macros"] } +wiremock = "0.6.0" +zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } [lints] workspace = true diff --git a/crates/bitwarden-core/README.md b/crates/bitwarden-core/README.md index fd697aa3c..baddb938e 100644 --- a/crates/bitwarden-core/README.md +++ b/crates/bitwarden-core/README.md @@ -1,4 +1,4 @@ -# Bitwarden Crypto +# Bitwarden Core This is an internal crate for the Bitwarden SDK do not depend on this directly and use the [`bitwarden`](https://crates.io/crates/bitwarden) crate instead. diff --git a/crates/bitwarden/src/.gitignore b/crates/bitwarden-core/src/.gitignore similarity index 100% rename from crates/bitwarden/src/.gitignore rename to crates/bitwarden-core/src/.gitignore diff --git a/crates/bitwarden/src/admin_console/mod.rs b/crates/bitwarden-core/src/admin_console/mod.rs similarity index 100% rename from crates/bitwarden/src/admin_console/mod.rs rename to crates/bitwarden-core/src/admin_console/mod.rs diff --git a/crates/bitwarden/src/admin_console/policy.rs b/crates/bitwarden-core/src/admin_console/policy.rs similarity index 98% rename from crates/bitwarden/src/admin_console/policy.rs rename to crates/bitwarden-core/src/admin_console/policy.rs index 6c0a2ec65..cde09c24c 100644 --- a/crates/bitwarden/src/admin_console/policy.rs +++ b/crates/bitwarden-core/src/admin_console/policy.rs @@ -1,13 +1,15 @@ use std::collections::HashMap; use bitwarden_api_api::models::PolicyResponseModel; -use bitwarden_core::require; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; use uuid::Uuid; -use crate::error::{Error, Result}; +use crate::{ + error::{Error, Result}, + require, +}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] pub struct Policy { diff --git a/crates/bitwarden/src/auth/access_token.rs b/crates/bitwarden-core/src/auth/access_token.rs similarity index 100% rename from crates/bitwarden/src/auth/access_token.rs rename to crates/bitwarden-core/src/auth/access_token.rs diff --git a/crates/bitwarden/src/auth/api/mod.rs b/crates/bitwarden-core/src/auth/api/mod.rs similarity index 100% rename from crates/bitwarden/src/auth/api/mod.rs rename to crates/bitwarden-core/src/auth/api/mod.rs diff --git a/crates/bitwarden/src/auth/api/request/access_token_request.rs b/crates/bitwarden-core/src/auth/api/request/access_token_request.rs similarity index 100% rename from crates/bitwarden/src/auth/api/request/access_token_request.rs rename to crates/bitwarden-core/src/auth/api/request/access_token_request.rs diff --git a/crates/bitwarden/src/auth/api/request/api_token_request.rs b/crates/bitwarden-core/src/auth/api/request/api_token_request.rs similarity index 100% rename from crates/bitwarden/src/auth/api/request/api_token_request.rs rename to crates/bitwarden-core/src/auth/api/request/api_token_request.rs diff --git a/crates/bitwarden/src/auth/api/request/auth_request_token_request.rs b/crates/bitwarden-core/src/auth/api/request/auth_request_token_request.rs similarity index 98% rename from crates/bitwarden/src/auth/api/request/auth_request_token_request.rs rename to crates/bitwarden-core/src/auth/api/request/auth_request_token_request.rs index 17ef52c26..2b2a47839 100644 --- a/crates/bitwarden/src/auth/api/request/auth_request_token_request.rs +++ b/crates/bitwarden-core/src/auth/api/request/auth_request_token_request.rs @@ -26,6 +26,7 @@ pub struct AuthRequestTokenRequest { access_code: String, } +#[allow(dead_code)] impl AuthRequestTokenRequest { pub fn new( email: &str, diff --git a/crates/bitwarden/src/auth/api/request/mod.rs b/crates/bitwarden-core/src/auth/api/request/mod.rs similarity index 92% rename from crates/bitwarden/src/auth/api/request/mod.rs rename to crates/bitwarden-core/src/auth/api/request/mod.rs index c0cb45251..0d9f39877 100644 --- a/crates/bitwarden/src/auth/api/request/mod.rs +++ b/crates/bitwarden-core/src/auth/api/request/mod.rs @@ -1,21 +1,20 @@ +#[cfg(feature = "secrets")] mod access_token_request; -#[cfg(feature = "internal")] +#[cfg(feature = "secrets")] +pub(crate) use access_token_request::*; + mod api_token_request; +pub(crate) use api_token_request::*; + #[cfg(feature = "internal")] mod password_token_request; #[cfg(feature = "internal")] -mod renew_token_request; +pub(crate) use password_token_request::*; -pub(crate) use access_token_request::*; -#[cfg(feature = "internal")] -pub(crate) use api_token_request::*; +mod renew_token_request; use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine}; -#[cfg(feature = "internal")] -pub(crate) use password_token_request::*; -#[cfg(feature = "internal")] pub(crate) use renew_token_request::*; -#[cfg(feature = "internal")] mod auth_request_token_request; #[cfg(feature = "internal")] pub(crate) use auth_request_token_request::*; diff --git a/crates/bitwarden/src/auth/api/request/password_token_request.rs b/crates/bitwarden-core/src/auth/api/request/password_token_request.rs similarity index 100% rename from crates/bitwarden/src/auth/api/request/password_token_request.rs rename to crates/bitwarden-core/src/auth/api/request/password_token_request.rs diff --git a/crates/bitwarden/src/auth/api/request/renew_token_request.rs b/crates/bitwarden-core/src/auth/api/request/renew_token_request.rs similarity index 100% rename from crates/bitwarden/src/auth/api/request/renew_token_request.rs rename to crates/bitwarden-core/src/auth/api/request/renew_token_request.rs diff --git a/crates/bitwarden/src/auth/api/response/identity_captcha_response.rs b/crates/bitwarden-core/src/auth/api/response/identity_captcha_response.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/identity_captcha_response.rs rename to crates/bitwarden-core/src/auth/api/response/identity_captcha_response.rs diff --git a/crates/bitwarden/src/auth/api/response/identity_payload_response.rs b/crates/bitwarden-core/src/auth/api/response/identity_payload_response.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/identity_payload_response.rs rename to crates/bitwarden-core/src/auth/api/response/identity_payload_response.rs diff --git a/crates/bitwarden/src/auth/api/response/identity_refresh_response.rs b/crates/bitwarden-core/src/auth/api/response/identity_refresh_response.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/identity_refresh_response.rs rename to crates/bitwarden-core/src/auth/api/response/identity_refresh_response.rs diff --git a/crates/bitwarden/src/auth/api/response/identity_success_response.rs b/crates/bitwarden-core/src/auth/api/response/identity_success_response.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/identity_success_response.rs rename to crates/bitwarden-core/src/auth/api/response/identity_success_response.rs diff --git a/crates/bitwarden/src/auth/api/response/identity_token_fail_response.rs b/crates/bitwarden-core/src/auth/api/response/identity_token_fail_response.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/identity_token_fail_response.rs rename to crates/bitwarden-core/src/auth/api/response/identity_token_fail_response.rs diff --git a/crates/bitwarden/src/auth/api/response/identity_token_response.rs b/crates/bitwarden-core/src/auth/api/response/identity_token_response.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/identity_token_response.rs rename to crates/bitwarden-core/src/auth/api/response/identity_token_response.rs diff --git a/crates/bitwarden/src/auth/api/response/identity_two_factor_response.rs b/crates/bitwarden-core/src/auth/api/response/identity_two_factor_response.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/identity_two_factor_response.rs rename to crates/bitwarden-core/src/auth/api/response/identity_two_factor_response.rs diff --git a/crates/bitwarden/src/auth/api/response/mod.rs b/crates/bitwarden-core/src/auth/api/response/mod.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/mod.rs rename to crates/bitwarden-core/src/auth/api/response/mod.rs diff --git a/crates/bitwarden/src/auth/api/response/two_factor_provider_data/authenticator.rs b/crates/bitwarden-core/src/auth/api/response/two_factor_provider_data/authenticator.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/two_factor_provider_data/authenticator.rs rename to crates/bitwarden-core/src/auth/api/response/two_factor_provider_data/authenticator.rs diff --git a/crates/bitwarden/src/auth/api/response/two_factor_provider_data/duo.rs b/crates/bitwarden-core/src/auth/api/response/two_factor_provider_data/duo.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/two_factor_provider_data/duo.rs rename to crates/bitwarden-core/src/auth/api/response/two_factor_provider_data/duo.rs diff --git a/crates/bitwarden/src/auth/api/response/two_factor_provider_data/email.rs b/crates/bitwarden-core/src/auth/api/response/two_factor_provider_data/email.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/two_factor_provider_data/email.rs rename to crates/bitwarden-core/src/auth/api/response/two_factor_provider_data/email.rs diff --git a/crates/bitwarden/src/auth/api/response/two_factor_provider_data/mod.rs b/crates/bitwarden-core/src/auth/api/response/two_factor_provider_data/mod.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/two_factor_provider_data/mod.rs rename to crates/bitwarden-core/src/auth/api/response/two_factor_provider_data/mod.rs diff --git a/crates/bitwarden/src/auth/api/response/two_factor_provider_data/organization_duo.rs b/crates/bitwarden-core/src/auth/api/response/two_factor_provider_data/organization_duo.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/two_factor_provider_data/organization_duo.rs rename to crates/bitwarden-core/src/auth/api/response/two_factor_provider_data/organization_duo.rs diff --git a/crates/bitwarden/src/auth/api/response/two_factor_provider_data/remember.rs b/crates/bitwarden-core/src/auth/api/response/two_factor_provider_data/remember.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/two_factor_provider_data/remember.rs rename to crates/bitwarden-core/src/auth/api/response/two_factor_provider_data/remember.rs diff --git a/crates/bitwarden/src/auth/api/response/two_factor_provider_data/web_authn.rs b/crates/bitwarden-core/src/auth/api/response/two_factor_provider_data/web_authn.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/two_factor_provider_data/web_authn.rs rename to crates/bitwarden-core/src/auth/api/response/two_factor_provider_data/web_authn.rs diff --git a/crates/bitwarden/src/auth/api/response/two_factor_provider_data/yubi_key.rs b/crates/bitwarden-core/src/auth/api/response/two_factor_provider_data/yubi_key.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/two_factor_provider_data/yubi_key.rs rename to crates/bitwarden-core/src/auth/api/response/two_factor_provider_data/yubi_key.rs diff --git a/crates/bitwarden/src/auth/api/response/two_factor_providers.rs b/crates/bitwarden-core/src/auth/api/response/two_factor_providers.rs similarity index 100% rename from crates/bitwarden/src/auth/api/response/two_factor_providers.rs rename to crates/bitwarden-core/src/auth/api/response/two_factor_providers.rs diff --git a/crates/bitwarden/src/auth/auth_request.rs b/crates/bitwarden-core/src/auth/auth_request.rs similarity index 98% rename from crates/bitwarden/src/auth/auth_request.rs rename to crates/bitwarden-core/src/auth/auth_request.rs index 1abe86ed9..7d59f6e69 100644 --- a/crates/bitwarden/src/auth/auth_request.rs +++ b/crates/bitwarden-core/src/auth/auth_request.rs @@ -1,5 +1,4 @@ use base64::{engine::general_purpose::STANDARD, Engine}; -use bitwarden_core::VaultLocked; use bitwarden_crypto::{ fingerprint, generate_random_alphanumeric, AsymmetricCryptoKey, AsymmetricEncString, AsymmetricPublicCryptoKey, @@ -7,7 +6,7 @@ use bitwarden_crypto::{ #[cfg(feature = "internal")] use bitwarden_crypto::{EncString, KeyDecryptable, SymmetricCryptoKey}; -use crate::{error::Error, Client}; +use crate::{error::Error, Client, VaultLocked}; #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] pub struct AuthRequestResponse { @@ -82,7 +81,7 @@ pub(crate) fn approve_auth_request( ) -> Result { let public_key = AsymmetricPublicCryptoKey::from_der(&STANDARD.decode(public_key)?)?; - let enc = client.get_encryption_settings()?; + let enc = client.internal.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(VaultLocked)?; Ok(AsymmetricEncString::encrypt_rsa2048_oaep_sha1( @@ -137,6 +136,7 @@ mod tests { let user_key = "2.Q/2PhzcC7GdeiMHhWguYAQ==|GpqzVdr0go0ug5cZh1n+uixeBC3oC90CIe0hd/HWA/pTRDZ8ane4fmsEIcuc8eMKUt55Y2q/fbNzsYu41YTZzzsJUSeqVjT8/iTQtgnNdpo=|dwI+uyvZ1h/iZ03VQ+/wrGEFYVewBUUl/syYgjsNMbE=".parse().unwrap(); let private_key ="2.yN7l00BOlUE0Sb0M//Q53w==|EwKG/BduQRQ33Izqc/ogoBROIoI5dmgrxSo82sgzgAMIBt3A2FZ9vPRMY+GWT85JiqytDitGR3TqwnFUBhKUpRRAq4x7rA6A1arHrFp5Tp1p21O3SfjtvB3quiOKbqWk6ZaU1Np9HwqwAecddFcB0YyBEiRX3VwF2pgpAdiPbSMuvo2qIgyob0CUoC/h4Bz1be7Qa7B0Xw9/fMKkB1LpOm925lzqosyMQM62YpMGkjMsbZz0uPopu32fxzDWSPr+kekNNyLt9InGhTpxLmq1go/pXR2uw5dfpXc5yuta7DB0EGBwnQ8Vl5HPdDooqOTD9I1jE0mRyuBpWTTI3FRnu3JUh3rIyGBJhUmHqGZvw2CKdqHCIrQeQkkEYqOeJRJVdBjhv5KGJifqT3BFRwX/YFJIChAQpebNQKXe/0kPivWokHWwXlDB7S7mBZzhaAPidZvnuIhalE2qmTypDwHy22FyqV58T8MGGMchcASDi/QXI6kcdpJzPXSeU9o+NC68QDlOIrMVxKFeE7w7PvVmAaxEo0YwmuAzzKy9QpdlK0aab/xEi8V4iXj4hGepqAvHkXIQd+r3FNeiLfllkb61p6WTjr5urcmDQMR94/wYoilpG5OlybHdbhsYHvIzYoLrC7fzl630gcO6t4nM24vdB6Ymg9BVpEgKRAxSbE62Tqacxqnz9AcmgItb48NiR/He3n3ydGjPYuKk/ihZMgEwAEZvSlNxYONSbYrIGDtOY+8Nbt6KiH3l06wjZW8tcmFeVlWv+tWotnTY9IqlAfvNVTjtsobqtQnvsiDjdEVtNy/s2ci5TH+NdZluca2OVEr91Wayxh70kpM6ib4UGbfdmGgCo74gtKvKSJU0rTHakQ5L9JlaSDD5FamBRyI0qfL43Ad9qOUZ8DaffDCyuaVyuqk7cz9HwmEmvWU3VQ+5t06n/5kRDXttcw8w+3qClEEdGo1KeENcnXCB32dQe3tDTFpuAIMLqwXs6FhpawfZ5kPYvLPczGWaqftIs/RXJ/EltGc0ugw2dmTLpoQhCqrcKEBDoYVk0LDZKsnzitOGdi9mOWse7Se8798ib1UsHFUjGzISEt6upestxOeupSTOh0v4+AjXbDzRUyogHww3V+Bqg71bkcMxtB+WM+pn1XNbVTyl9NR040nhP7KEf6e9ruXAtmrBC2ah5cFEpLIot77VFZ9ilLuitSz+7T8n1yAh1IEG6xxXxninAZIzi2qGbH69O5RSpOJuJTv17zTLJQIIc781JwQ2TTwTGnx5wZLbffhCasowJKd2EVcyMJyhz6ru0PvXWJ4hUdkARJs3Xu8dus9a86N8Xk6aAPzBDqzYb1vyFIfBxP0oO8xFHgd30Cgmz8UrSE3qeWRrF8ftrI6xQnFjHBGWD/JWSvd6YMcQED0aVuQkuNW9ST/DzQThPzRfPUoiL10yAmV7Ytu4fR3x2sF0Yfi87YhHFuCMpV/DsqxmUizyiJuD938eRcH8hzR/VO53Qo3UIsqOLcyXtTv6THjSlTopQ+JOLOnHm1w8dzYbLN44OG44rRsbihMUQp+wUZ6bsI8rrOnm9WErzkbQFbrfAINdoCiNa6cimYIjvvnMTaFWNymqY1vZxGztQiMiHiHYwTfwHTXrb9j0uPM=|09J28iXv9oWzYtzK2LBT6Yht4IT4MijEkk0fwFdrVQ4=".parse().unwrap(); client + .internal .initialize_user_crypto_master_key(master_key, user_key, private_key) .unwrap(); @@ -205,6 +205,7 @@ mod tests { .unwrap(); existing_device + .internal .initialize_user_crypto_master_key(master_key, user_key, private_key.parse().unwrap()) .unwrap(); @@ -236,12 +237,14 @@ mod tests { // same assert_eq!( existing_device + .internal .get_encryption_settings() .unwrap() .get_key(&None) .unwrap() .to_base64(), new_device + .internal .get_encryption_settings() .unwrap() .get_key(&None) diff --git a/crates/bitwarden/src/auth/client_auth.rs b/crates/bitwarden-core/src/auth/client_auth.rs similarity index 91% rename from crates/bitwarden/src/auth/client_auth.rs rename to crates/bitwarden-core/src/auth/client_auth.rs index 2ea92decc..fa48481e6 100644 --- a/crates/bitwarden/src/auth/client_auth.rs +++ b/crates/bitwarden-core/src/auth/client_auth.rs @@ -1,30 +1,26 @@ #[cfg(feature = "internal")] -use bitwarden_crypto::{AsymmetricEncString, DeviceKey, TrustDeviceResponse}; +use bitwarden_crypto::{AsymmetricEncString, DeviceKey, Kdf, TrustDeviceResponse}; #[cfg(feature = "internal")] use crate::auth::login::NewAuthRequestResponse; #[cfg(feature = "secrets")] use crate::auth::login::{login_access_token, AccessTokenLoginRequest, AccessTokenLoginResponse}; -use crate::{auth::renew::renew_token, error::Result, Client}; #[cfg(feature = "internal")] -use crate::{ - auth::{ - auth_request::{approve_auth_request, new_auth_request}, - login::{ - login_api_key, login_password, send_two_factor_email, ApiKeyLoginRequest, - ApiKeyLoginResponse, PasswordLoginRequest, PasswordLoginResponse, - TwoFactorEmailRequest, - }, - password::{ - password_strength, satisfies_policy, validate_password, validate_password_user_key, - MasterPasswordPolicyOptions, - }, - register::{make_register_keys, register}, - tde::{make_register_tde_keys, RegisterTdeKeyResponse}, - AuthRequestResponse, RegisterKeyResponse, RegisterRequest, +use crate::auth::{ + auth_request::{approve_auth_request, new_auth_request}, + login::{ + login_api_key, login_password, send_two_factor_email, ApiKeyLoginRequest, + ApiKeyLoginResponse, PasswordLoginRequest, PasswordLoginResponse, TwoFactorEmailRequest, + }, + password::{ + password_strength, satisfies_policy, validate_password, validate_password_user_key, + MasterPasswordPolicyOptions, }, - client::Kdf, + register::{make_register_keys, register}, + tde::{make_register_tde_keys, RegisterTdeKeyResponse}, + AuthRequestResponse, RegisterKeyResponse, RegisterRequest, }; +use crate::{auth::renew::renew_token, error::Result, Client}; pub struct ClientAuth<'a> { pub(crate) client: &'a crate::Client, @@ -32,7 +28,7 @@ pub struct ClientAuth<'a> { impl<'a> ClientAuth<'a> { pub async fn renew_token(&self) -> Result<()> { - renew_token(self.client).await + renew_token(&self.client.internal).await } #[cfg(feature = "secrets")] @@ -154,9 +150,9 @@ impl<'a> ClientAuth<'a> { #[cfg(feature = "internal")] fn trust_device(client: &Client) -> Result { - use bitwarden_core::VaultLocked; + use crate::VaultLocked; - let enc = client.get_encryption_settings()?; + let enc = client.internal.get_encryption_settings()?; let user_key = enc.get_key(&None).ok_or(VaultLocked)?; @@ -169,6 +165,7 @@ impl<'a> Client { } } +/* #[cfg(test)] mod tests { @@ -267,3 +264,4 @@ mod tests { assert_eq!(res.value, "TEST"); } } + */ diff --git a/crates/bitwarden/src/auth/jwt_token.rs b/crates/bitwarden-core/src/auth/jwt_token.rs similarity index 100% rename from crates/bitwarden/src/auth/jwt_token.rs rename to crates/bitwarden-core/src/auth/jwt_token.rs diff --git a/crates/bitwarden/src/auth/login/access_token.rs b/crates/bitwarden-core/src/auth/login/access_token.rs similarity index 85% rename from crates/bitwarden/src/auth/login/access_token.rs rename to crates/bitwarden-core/src/auth/login/access_token.rs index 25d8ffb5d..c445e43c7 100644 --- a/crates/bitwarden/src/auth/login/access_token.rs +++ b/crates/bitwarden-core/src/auth/login/access_token.rs @@ -1,7 +1,6 @@ use std::path::{Path, PathBuf}; use base64::{engine::general_purpose::STANDARD, Engine}; -use bitwarden_core::require; use bitwarden_crypto::{EncString, KeyDecryptable, SymmetricCryptoKey}; use chrono::Utc; use schemars::JsonSchema; @@ -16,6 +15,7 @@ use crate::{ }, client::{LoginMethod, ServiceAccountLoginMethod}, error::{Error, Result}, + require, secrets_manager::state::{self, ClientState}, Client, }; @@ -31,13 +31,15 @@ pub(crate) async fn login_access_token( if let Some(state_file) = &input.state_file { if let Ok(organization_id) = load_tokens_from_state(client, state_file, &access_token) { - client.set_login_method(LoginMethod::ServiceAccount( - ServiceAccountLoginMethod::AccessToken { - access_token, - organization_id, - state_file: Some(state_file.to_path_buf()), - }, - )); + client + .internal + .set_login_method(LoginMethod::ServiceAccount( + ServiceAccountLoginMethod::AccessToken { + access_token, + organization_id, + state_file: Some(state_file.to_path_buf()), + }, + )); return Ok(AccessTokenLoginResponse { authenticated: true, @@ -79,20 +81,22 @@ pub(crate) async fn login_access_token( _ = state::set(state_file, &access_token, state); } - client.set_tokens( + client.internal.set_tokens( r.access_token.clone(), r.refresh_token.clone(), r.expires_in, ); - client.set_login_method(LoginMethod::ServiceAccount( - ServiceAccountLoginMethod::AccessToken { - access_token, - organization_id, - state_file: input.state_file.clone(), - }, - )); - - client.initialize_crypto_single_key(encryption_key); + client + .internal + .set_login_method(LoginMethod::ServiceAccount( + ServiceAccountLoginMethod::AccessToken { + access_token, + organization_id, + state_file: input.state_file.clone(), + }, + )); + + client.internal.initialize_crypto_single_key(encryption_key); } AccessTokenLoginResponse::process_response(response) @@ -102,7 +106,7 @@ async fn request_access_token( client: &Client, input: &AccessToken, ) -> Result { - let config = client.get_api_configurations().await; + let config = client.internal.get_api_configurations().await; AccessTokenRequest::new(input.access_token_id, &input.client_secret) .send(&config) .await @@ -126,8 +130,10 @@ fn load_tokens_from_state( .map_err(|_| "Bad organization id.")?; let encryption_key = SymmetricCryptoKey::try_from(client_state.encryption_key)?; - client.set_tokens(client_state.token, None, time_till_expiration as u64); - client.initialize_crypto_single_key(encryption_key); + client + .internal + .set_tokens(client_state.token, None, time_till_expiration as u64); + client.internal.initialize_crypto_single_key(encryption_key); return Ok(organization_id); } diff --git a/crates/bitwarden/src/auth/login/api_key.rs b/crates/bitwarden-core/src/auth/login/api_key.rs similarity index 84% rename from crates/bitwarden/src/auth/login/api_key.rs rename to crates/bitwarden-core/src/auth/login/api_key.rs index 92f1c76b9..b0e2c8834 100644 --- a/crates/bitwarden/src/auth/login/api_key.rs +++ b/crates/bitwarden-core/src/auth/login/api_key.rs @@ -1,4 +1,3 @@ -use bitwarden_core::require; use bitwarden_crypto::{EncString, MasterKey}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -11,7 +10,7 @@ use crate::{ }, client::{LoginMethod, UserLoginMethod}, error::Result, - Client, + require, Client, }; pub(crate) async fn login_api_key( @@ -33,7 +32,7 @@ pub(crate) async fn login_api_key( let kdf = client.auth().prelogin(email.clone()).await?; - client.set_tokens( + client.internal.set_tokens( r.access_token.clone(), r.refresh_token.clone(), r.expires_in, @@ -41,17 +40,21 @@ pub(crate) async fn login_api_key( let master_key = MasterKey::derive(input.password.as_bytes(), email.as_bytes(), &kdf)?; - client.set_login_method(LoginMethod::User(UserLoginMethod::ApiKey { - client_id: input.client_id.to_owned(), - client_secret: input.client_secret.to_owned(), - email, - kdf, - })); + client + .internal + .set_login_method(LoginMethod::User(UserLoginMethod::ApiKey { + client_id: input.client_id.to_owned(), + client_secret: input.client_secret.to_owned(), + email, + kdf, + })); let user_key: EncString = require!(r.key.as_deref()).parse()?; let private_key: EncString = require!(r.private_key.as_deref()).parse()?; - client.initialize_user_crypto_master_key(master_key, user_key, private_key)?; + client + .internal + .initialize_user_crypto_master_key(master_key, user_key, private_key)?; } ApiKeyLoginResponse::process_response(response) @@ -61,7 +64,7 @@ async fn request_api_identity_tokens( client: &Client, input: &ApiKeyLoginRequest, ) -> Result { - let config = client.get_api_configurations().await; + let config = client.internal.get_api_configurations().await; ApiTokenRequest::new(&input.client_id, &input.client_secret) .send(&config) .await diff --git a/crates/bitwarden/src/auth/login/auth_request.rs b/crates/bitwarden-core/src/auth/login/auth_request.rs similarity index 88% rename from crates/bitwarden/src/auth/login/auth_request.rs rename to crates/bitwarden-core/src/auth/login/auth_request.rs index 380a49b9d..912105db0 100644 --- a/crates/bitwarden/src/auth/login/auth_request.rs +++ b/crates/bitwarden-core/src/auth/login/auth_request.rs @@ -2,7 +2,6 @@ use bitwarden_api_api::{ apis::auth_requests_api::{auth_requests_id_response_get, auth_requests_post}, models::{AuthRequestCreateRequestModel, AuthRequestType}, }; -use bitwarden_core::require; use bitwarden_crypto::Kdf; use uuid::Uuid; @@ -14,7 +13,7 @@ use crate::{ client::{LoginMethod, UserLoginMethod}, error::Result, mobile::crypto::{AuthRequestMethod, InitUserCryptoMethod, InitUserCryptoRequest}, - Client, + require, Client, }; pub struct NewAuthRequestResponse { @@ -31,7 +30,7 @@ pub(crate) async fn send_new_auth_request( email: String, device_identifier: String, ) -> Result { - let config = client.get_api_configurations().await; + let config = client.internal.get_api_configurations().await; let auth = new_auth_request(&email)?; @@ -59,7 +58,7 @@ pub(crate) async fn complete_auth_request( client: &Client, auth_req: NewAuthRequestResponse, ) -> Result<()> { - let config = client.get_api_configurations().await; + let config = client.internal.get_api_configurations().await; let res = auth_requests_id_response_get( &config.api, @@ -87,16 +86,18 @@ pub(crate) async fn complete_auth_request( if let IdentityTokenResponse::Authenticated(r) = response { let kdf = Kdf::default(); - client.set_tokens( + client.internal.set_tokens( r.access_token.clone(), r.refresh_token.clone(), r.expires_in, ); - client.set_login_method(LoginMethod::User(UserLoginMethod::Username { - client_id: "web".to_owned(), - email: auth_req.email.to_owned(), - kdf: kdf.clone(), - })); + client + .internal + .set_login_method(LoginMethod::User(UserLoginMethod::Username { + client_id: "web".to_owned(), + email: auth_req.email.to_owned(), + kdf: kdf.clone(), + })); let method = match res.master_password_hash { Some(_) => AuthRequestMethod::MasterKey { diff --git a/crates/bitwarden/src/auth/login/mod.rs b/crates/bitwarden-core/src/auth/login/mod.rs similarity index 91% rename from crates/bitwarden/src/auth/login/mod.rs rename to crates/bitwarden-core/src/auth/login/mod.rs index 9c9c711b9..0c90dc973 100644 --- a/crates/bitwarden/src/auth/login/mod.rs +++ b/crates/bitwarden-core/src/auth/login/mod.rs @@ -1,6 +1,8 @@ #[cfg(feature = "internal")] +use bitwarden_crypto::Kdf; +#[cfg(feature = "internal")] use { - crate::{client::Kdf, error::Result, Client}, + crate::{error::Result, Client}, bitwarden_api_identity::{ apis::accounts_api::accounts_prelogin_post, models::{PreloginRequestModel, PreloginResponseModel}, @@ -9,11 +11,13 @@ use { pub mod response; +#[cfg(any(feature = "internal", feature = "secrets"))] mod password; #[cfg(feature = "internal")] pub(crate) use password::login_password; #[cfg(feature = "internal")] pub use password::PasswordLoginRequest; +#[cfg(any(feature = "internal", feature = "secrets"))] pub use password::PasswordLoginResponse; #[cfg(feature = "internal")] mod two_factor; @@ -49,7 +53,7 @@ pub(crate) async fn request_prelogin( email: String, ) -> Result { let request_model = PreloginRequestModel::new(email); - let config = client.get_api_configurations().await; + let config = client.internal.get_api_configurations().await; Ok(accounts_prelogin_post(&config.identity, Some(request_model)).await?) } diff --git a/crates/bitwarden/src/auth/login/password.rs b/crates/bitwarden-core/src/auth/login/password.rs similarity index 88% rename from crates/bitwarden/src/auth/login/password.rs rename to crates/bitwarden-core/src/auth/login/password.rs index 8d79d8568..4536657d3 100644 --- a/crates/bitwarden/src/auth/login/password.rs +++ b/crates/bitwarden-core/src/auth/login/password.rs @@ -1,4 +1,6 @@ #[cfg(feature = "internal")] +use bitwarden_crypto::Kdf; +#[cfg(feature = "internal")] use log::info; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -6,7 +8,7 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "internal")] use crate::{ auth::{api::request::PasswordTokenRequest, login::TwoFactorRequest}, - client::{Kdf, LoginMethod}, + client::LoginMethod, Client, }; use crate::{ @@ -22,10 +24,9 @@ pub(crate) async fn login_password( client: &Client, input: &PasswordLoginRequest, ) -> Result { - use bitwarden_core::require; use bitwarden_crypto::{EncString, HashPurpose, MasterKey}; - use crate::client::UserLoginMethod; + use crate::{client::UserLoginMethod, require}; info!("password logging in"); @@ -40,21 +41,25 @@ pub(crate) async fn login_password( let response = request_identity_tokens(client, input, &password_hash).await?; if let IdentityTokenResponse::Authenticated(r) = &response { - client.set_tokens( + client.internal.set_tokens( r.access_token.clone(), r.refresh_token.clone(), r.expires_in, ); - client.set_login_method(LoginMethod::User(UserLoginMethod::Username { - client_id: "web".to_owned(), - email: input.email.to_owned(), - kdf: input.kdf.to_owned(), - })); + client + .internal + .set_login_method(LoginMethod::User(UserLoginMethod::Username { + client_id: "web".to_owned(), + email: input.email.to_owned(), + kdf: input.kdf.to_owned(), + })); let user_key: EncString = require!(r.key.as_deref()).parse()?; let private_key: EncString = require!(r.private_key.as_deref()).parse()?; - client.initialize_user_crypto_master_key(master_key, user_key, private_key)?; + client + .internal + .initialize_user_crypto_master_key(master_key, user_key, private_key)?; } PasswordLoginResponse::process_response(response) @@ -68,7 +73,7 @@ async fn request_identity_tokens( ) -> Result { use crate::DeviceType; - let config = client.get_api_configurations().await; + let config = client.internal.get_api_configurations().await; PasswordTokenRequest::new( &input.email, password_hash, diff --git a/crates/bitwarden/src/auth/login/response/captcha_response.rs b/crates/bitwarden-core/src/auth/login/response/captcha_response.rs similarity index 100% rename from crates/bitwarden/src/auth/login/response/captcha_response.rs rename to crates/bitwarden-core/src/auth/login/response/captcha_response.rs diff --git a/crates/bitwarden/src/auth/login/response/mod.rs b/crates/bitwarden-core/src/auth/login/response/mod.rs similarity index 100% rename from crates/bitwarden/src/auth/login/response/mod.rs rename to crates/bitwarden-core/src/auth/login/response/mod.rs diff --git a/crates/bitwarden/src/auth/login/response/two_factor/authenticator.rs b/crates/bitwarden-core/src/auth/login/response/two_factor/authenticator.rs similarity index 100% rename from crates/bitwarden/src/auth/login/response/two_factor/authenticator.rs rename to crates/bitwarden-core/src/auth/login/response/two_factor/authenticator.rs diff --git a/crates/bitwarden/src/auth/login/response/two_factor/duo.rs b/crates/bitwarden-core/src/auth/login/response/two_factor/duo.rs similarity index 100% rename from crates/bitwarden/src/auth/login/response/two_factor/duo.rs rename to crates/bitwarden-core/src/auth/login/response/two_factor/duo.rs diff --git a/crates/bitwarden/src/auth/login/response/two_factor/email.rs b/crates/bitwarden-core/src/auth/login/response/two_factor/email.rs similarity index 100% rename from crates/bitwarden/src/auth/login/response/two_factor/email.rs rename to crates/bitwarden-core/src/auth/login/response/two_factor/email.rs diff --git a/crates/bitwarden/src/auth/login/response/two_factor/mod.rs b/crates/bitwarden-core/src/auth/login/response/two_factor/mod.rs similarity index 100% rename from crates/bitwarden/src/auth/login/response/two_factor/mod.rs rename to crates/bitwarden-core/src/auth/login/response/two_factor/mod.rs diff --git a/crates/bitwarden/src/auth/login/response/two_factor/remember.rs b/crates/bitwarden-core/src/auth/login/response/two_factor/remember.rs similarity index 100% rename from crates/bitwarden/src/auth/login/response/two_factor/remember.rs rename to crates/bitwarden-core/src/auth/login/response/two_factor/remember.rs diff --git a/crates/bitwarden/src/auth/login/response/two_factor/two_factor_providers.rs b/crates/bitwarden-core/src/auth/login/response/two_factor/two_factor_providers.rs similarity index 100% rename from crates/bitwarden/src/auth/login/response/two_factor/two_factor_providers.rs rename to crates/bitwarden-core/src/auth/login/response/two_factor/two_factor_providers.rs diff --git a/crates/bitwarden/src/auth/login/response/two_factor/web_authn.rs b/crates/bitwarden-core/src/auth/login/response/two_factor/web_authn.rs similarity index 100% rename from crates/bitwarden/src/auth/login/response/two_factor/web_authn.rs rename to crates/bitwarden-core/src/auth/login/response/two_factor/web_authn.rs diff --git a/crates/bitwarden/src/auth/login/response/two_factor/yubi_key.rs b/crates/bitwarden-core/src/auth/login/response/two_factor/yubi_key.rs similarity index 100% rename from crates/bitwarden/src/auth/login/response/two_factor/yubi_key.rs rename to crates/bitwarden-core/src/auth/login/response/two_factor/yubi_key.rs diff --git a/crates/bitwarden/src/auth/login/two_factor.rs b/crates/bitwarden-core/src/auth/login/two_factor.rs similarity index 96% rename from crates/bitwarden/src/auth/login/two_factor.rs rename to crates/bitwarden-core/src/auth/login/two_factor.rs index 197ff77a1..c0a4c10ab 100644 --- a/crates/bitwarden/src/auth/login/two_factor.rs +++ b/crates/bitwarden-core/src/auth/login/two_factor.rs @@ -29,7 +29,7 @@ pub(crate) async fn send_two_factor_email( HashPurpose::ServerAuthorization, )?; - let config = client.get_api_configurations().await; + let config = client.internal.get_api_configurations().await; bitwarden_api_api::apis::two_factor_api::two_factor_send_email_login_post( &config.api, Some(TwoFactorEmailRequestModel { diff --git a/crates/bitwarden/src/auth/mod.rs b/crates/bitwarden-core/src/auth/mod.rs similarity index 95% rename from crates/bitwarden/src/auth/mod.rs rename to crates/bitwarden-core/src/auth/mod.rs index ee409ddd6..b092ba98a 100644 --- a/crates/bitwarden/src/auth/mod.rs +++ b/crates/bitwarden-core/src/auth/mod.rs @@ -1,3 +1,6 @@ +#[cfg(feature = "internal")] +use bitwarden_crypto::{HashPurpose, Kdf, MasterKey}; + mod access_token; pub(super) mod api; pub mod client_auth; @@ -8,25 +11,26 @@ pub mod password; pub mod renew; pub use access_token::AccessToken; pub use jwt_token::JWTToken; -#[cfg(feature = "internal")] -mod register; -#[cfg(feature = "internal")] -use bitwarden_crypto::{HashPurpose, MasterKey}; -#[cfg(feature = "internal")] -pub use register::{RegisterKeyResponse, RegisterRequest}; + #[cfg(feature = "internal")] mod auth_request; #[cfg(feature = "internal")] pub use auth_request::AuthRequestResponse; #[cfg(feature = "internal")] pub(crate) use auth_request::{auth_request_decrypt_master_key, auth_request_decrypt_user_key}; + +#[cfg(feature = "internal")] +mod register; +#[cfg(feature = "internal")] +pub use register::{RegisterKeyResponse, RegisterRequest}; + #[cfg(feature = "internal")] mod tde; #[cfg(feature = "internal")] pub use tde::RegisterTdeKeyResponse; #[cfg(feature = "internal")] -use crate::{client::Kdf, error::Result}; +use crate::error::Result; #[cfg(feature = "internal")] fn determine_password_hash( diff --git a/crates/bitwarden/src/auth/password/mod.rs b/crates/bitwarden-core/src/auth/password/mod.rs similarity index 100% rename from crates/bitwarden/src/auth/password/mod.rs rename to crates/bitwarden-core/src/auth/password/mod.rs diff --git a/crates/bitwarden/src/auth/password/policy.rs b/crates/bitwarden-core/src/auth/password/policy.rs similarity index 100% rename from crates/bitwarden/src/auth/password/policy.rs rename to crates/bitwarden-core/src/auth/password/policy.rs diff --git a/crates/bitwarden/src/auth/password/strength.rs b/crates/bitwarden-core/src/auth/password/strength.rs similarity index 100% rename from crates/bitwarden/src/auth/password/strength.rs rename to crates/bitwarden-core/src/auth/password/strength.rs diff --git a/crates/bitwarden/src/auth/password/validate.rs b/crates/bitwarden-core/src/auth/password/validate.rs similarity index 83% rename from crates/bitwarden/src/auth/password/validate.rs rename to crates/bitwarden-core/src/auth/password/validate.rs index 2a077418a..ebb5395d1 100644 --- a/crates/bitwarden/src/auth/password/validate.rs +++ b/crates/bitwarden-core/src/auth/password/validate.rs @@ -13,8 +13,12 @@ pub(crate) fn validate_password( password: String, password_hash: String, ) -> Result { - let login_method = client.get_login_method().ok_or(Error::NotAuthenticated)?; + let login_method = client + .internal + .get_login_method() + .ok_or(Error::NotAuthenticated)?; + #[allow(irrefutable_let_patterns)] if let LoginMethod::User(login_method) = login_method.as_ref() { match login_method { UserLoginMethod::Username { email, kdf, .. } @@ -40,10 +44,14 @@ pub(crate) fn validate_password_user_key( password: String, encrypted_user_key: String, ) -> Result { - use bitwarden_core::VaultLocked; + use crate::VaultLocked; - let login_method = client.get_login_method().ok_or(Error::NotAuthenticated)?; + let login_method = client + .internal + .get_login_method() + .ok_or(Error::NotAuthenticated)?; + #[allow(irrefutable_let_patterns)] if let LoginMethod::User(login_method) = login_method.as_ref() { match login_method { UserLoginMethod::Username { email, kdf, .. } @@ -53,7 +61,10 @@ pub(crate) fn validate_password_user_key( .decrypt_user_key(encrypted_user_key.parse()?) .map_err(|_| "wrong password")?; - let enc = client.get_encryption_settings().map_err(|_| VaultLocked)?; + let enc = client + .internal + .get_encryption_settings() + .map_err(|_| VaultLocked)?; let existing_key = enc.get_key(&None).ok_or(VaultLocked)?; @@ -72,22 +83,26 @@ pub(crate) fn validate_password_user_key( #[cfg(test)] mod tests { + use bitwarden_crypto::Kdf; + use crate::auth::password::{validate::validate_password_user_key, validate_password}; #[test] fn test_validate_password() { use std::num::NonZeroU32; - use crate::client::{Client, Kdf, LoginMethod, UserLoginMethod}; + use crate::client::{Client, LoginMethod, UserLoginMethod}; let client = Client::new(None); - client.set_login_method(LoginMethod::User(UserLoginMethod::Username { - email: "test@bitwarden.com".to_string(), - kdf: Kdf::PBKDF2 { - iterations: NonZeroU32::new(100_000).unwrap(), - }, - client_id: "1".to_string(), - })); + client + .internal + .set_login_method(LoginMethod::User(UserLoginMethod::Username { + email: "test@bitwarden.com".to_string(), + kdf: Kdf::PBKDF2 { + iterations: NonZeroU32::new(100_000).unwrap(), + }, + client_id: "1".to_string(), + })); let password = "password123".to_string(); let password_hash = "7kTqkF1pY/3JeOu73N9kR99fDDe9O1JOZaVc7KH3lsU=".to_string(); @@ -102,7 +117,9 @@ mod tests { fn test_validate_password_user_key() { use std::num::NonZeroU32; - use crate::client::{Client, Kdf, LoginMethod, UserLoginMethod}; + use bitwarden_crypto::Kdf; + + use crate::client::{Client, LoginMethod, UserLoginMethod}; let client = Client::new(None); @@ -112,11 +129,13 @@ mod tests { iterations: NonZeroU32::new(600_000).unwrap(), }; - client.set_login_method(LoginMethod::User(UserLoginMethod::Username { - email: email.to_string(), - kdf: kdf.clone(), - client_id: "1".to_string(), - })); + client + .internal + .set_login_method(LoginMethod::User(UserLoginMethod::Username { + email: email.to_string(), + kdf: kdf.clone(), + client_id: "1".to_string(), + })); let master_key = bitwarden_crypto::MasterKey::derive(password.as_bytes(), email.as_bytes(), &kdf) @@ -126,6 +145,7 @@ mod tests { let private_key = "2.yN7l00BOlUE0Sb0M//Q53w==|EwKG/BduQRQ33Izqc/ogoBROIoI5dmgrxSo82sgzgAMIBt3A2FZ9vPRMY+GWT85JiqytDitGR3TqwnFUBhKUpRRAq4x7rA6A1arHrFp5Tp1p21O3SfjtvB3quiOKbqWk6ZaU1Np9HwqwAecddFcB0YyBEiRX3VwF2pgpAdiPbSMuvo2qIgyob0CUoC/h4Bz1be7Qa7B0Xw9/fMKkB1LpOm925lzqosyMQM62YpMGkjMsbZz0uPopu32fxzDWSPr+kekNNyLt9InGhTpxLmq1go/pXR2uw5dfpXc5yuta7DB0EGBwnQ8Vl5HPdDooqOTD9I1jE0mRyuBpWTTI3FRnu3JUh3rIyGBJhUmHqGZvw2CKdqHCIrQeQkkEYqOeJRJVdBjhv5KGJifqT3BFRwX/YFJIChAQpebNQKXe/0kPivWokHWwXlDB7S7mBZzhaAPidZvnuIhalE2qmTypDwHy22FyqV58T8MGGMchcASDi/QXI6kcdpJzPXSeU9o+NC68QDlOIrMVxKFeE7w7PvVmAaxEo0YwmuAzzKy9QpdlK0aab/xEi8V4iXj4hGepqAvHkXIQd+r3FNeiLfllkb61p6WTjr5urcmDQMR94/wYoilpG5OlybHdbhsYHvIzYoLrC7fzl630gcO6t4nM24vdB6Ymg9BVpEgKRAxSbE62Tqacxqnz9AcmgItb48NiR/He3n3ydGjPYuKk/ihZMgEwAEZvSlNxYONSbYrIGDtOY+8Nbt6KiH3l06wjZW8tcmFeVlWv+tWotnTY9IqlAfvNVTjtsobqtQnvsiDjdEVtNy/s2ci5TH+NdZluca2OVEr91Wayxh70kpM6ib4UGbfdmGgCo74gtKvKSJU0rTHakQ5L9JlaSDD5FamBRyI0qfL43Ad9qOUZ8DaffDCyuaVyuqk7cz9HwmEmvWU3VQ+5t06n/5kRDXttcw8w+3qClEEdGo1KeENcnXCB32dQe3tDTFpuAIMLqwXs6FhpawfZ5kPYvLPczGWaqftIs/RXJ/EltGc0ugw2dmTLpoQhCqrcKEBDoYVk0LDZKsnzitOGdi9mOWse7Se8798ib1UsHFUjGzISEt6upestxOeupSTOh0v4+AjXbDzRUyogHww3V+Bqg71bkcMxtB+WM+pn1XNbVTyl9NR040nhP7KEf6e9ruXAtmrBC2ah5cFEpLIot77VFZ9ilLuitSz+7T8n1yAh1IEG6xxXxninAZIzi2qGbH69O5RSpOJuJTv17zTLJQIIc781JwQ2TTwTGnx5wZLbffhCasowJKd2EVcyMJyhz6ru0PvXWJ4hUdkARJs3Xu8dus9a86N8Xk6aAPzBDqzYb1vyFIfBxP0oO8xFHgd30Cgmz8UrSE3qeWRrF8ftrI6xQnFjHBGWD/JWSvd6YMcQED0aVuQkuNW9ST/DzQThPzRfPUoiL10yAmV7Ytu4fR3x2sF0Yfi87YhHFuCMpV/DsqxmUizyiJuD938eRcH8hzR/VO53Qo3UIsqOLcyXtTv6THjSlTopQ+JOLOnHm1w8dzYbLN44OG44rRsbihMUQp+wUZ6bsI8rrOnm9WErzkbQFbrfAINdoCiNa6cimYIjvvnMTaFWNymqY1vZxGztQiMiHiHYwTfwHTXrb9j0uPM=|09J28iXv9oWzYtzK2LBT6Yht4IT4MijEkk0fwFdrVQ4=".parse().unwrap(); client + .internal .initialize_user_crypto_master_key(master_key, user_key.parse().unwrap(), private_key) .unwrap(); @@ -142,7 +162,9 @@ mod tests { fn test_validate_password_user_key_wrong_password() { use std::num::NonZeroU32; - use crate::client::{Client, Kdf, LoginMethod, UserLoginMethod}; + use bitwarden_crypto::Kdf; + + use crate::client::{Client, LoginMethod, UserLoginMethod}; let client = Client::new(None); @@ -152,11 +174,13 @@ mod tests { iterations: NonZeroU32::new(600_000).unwrap(), }; - client.set_login_method(LoginMethod::User(UserLoginMethod::Username { - email: email.to_string(), - kdf: kdf.clone(), - client_id: "1".to_string(), - })); + client + .internal + .set_login_method(LoginMethod::User(UserLoginMethod::Username { + email: email.to_string(), + kdf: kdf.clone(), + client_id: "1".to_string(), + })); let master_key = bitwarden_crypto::MasterKey::derive(password, email.as_bytes(), &kdf).unwrap(); @@ -165,6 +189,7 @@ mod tests { let private_key = "2.yN7l00BOlUE0Sb0M//Q53w==|EwKG/BduQRQ33Izqc/ogoBROIoI5dmgrxSo82sgzgAMIBt3A2FZ9vPRMY+GWT85JiqytDitGR3TqwnFUBhKUpRRAq4x7rA6A1arHrFp5Tp1p21O3SfjtvB3quiOKbqWk6ZaU1Np9HwqwAecddFcB0YyBEiRX3VwF2pgpAdiPbSMuvo2qIgyob0CUoC/h4Bz1be7Qa7B0Xw9/fMKkB1LpOm925lzqosyMQM62YpMGkjMsbZz0uPopu32fxzDWSPr+kekNNyLt9InGhTpxLmq1go/pXR2uw5dfpXc5yuta7DB0EGBwnQ8Vl5HPdDooqOTD9I1jE0mRyuBpWTTI3FRnu3JUh3rIyGBJhUmHqGZvw2CKdqHCIrQeQkkEYqOeJRJVdBjhv5KGJifqT3BFRwX/YFJIChAQpebNQKXe/0kPivWokHWwXlDB7S7mBZzhaAPidZvnuIhalE2qmTypDwHy22FyqV58T8MGGMchcASDi/QXI6kcdpJzPXSeU9o+NC68QDlOIrMVxKFeE7w7PvVmAaxEo0YwmuAzzKy9QpdlK0aab/xEi8V4iXj4hGepqAvHkXIQd+r3FNeiLfllkb61p6WTjr5urcmDQMR94/wYoilpG5OlybHdbhsYHvIzYoLrC7fzl630gcO6t4nM24vdB6Ymg9BVpEgKRAxSbE62Tqacxqnz9AcmgItb48NiR/He3n3ydGjPYuKk/ihZMgEwAEZvSlNxYONSbYrIGDtOY+8Nbt6KiH3l06wjZW8tcmFeVlWv+tWotnTY9IqlAfvNVTjtsobqtQnvsiDjdEVtNy/s2ci5TH+NdZluca2OVEr91Wayxh70kpM6ib4UGbfdmGgCo74gtKvKSJU0rTHakQ5L9JlaSDD5FamBRyI0qfL43Ad9qOUZ8DaffDCyuaVyuqk7cz9HwmEmvWU3VQ+5t06n/5kRDXttcw8w+3qClEEdGo1KeENcnXCB32dQe3tDTFpuAIMLqwXs6FhpawfZ5kPYvLPczGWaqftIs/RXJ/EltGc0ugw2dmTLpoQhCqrcKEBDoYVk0LDZKsnzitOGdi9mOWse7Se8798ib1UsHFUjGzISEt6upestxOeupSTOh0v4+AjXbDzRUyogHww3V+Bqg71bkcMxtB+WM+pn1XNbVTyl9NR040nhP7KEf6e9ruXAtmrBC2ah5cFEpLIot77VFZ9ilLuitSz+7T8n1yAh1IEG6xxXxninAZIzi2qGbH69O5RSpOJuJTv17zTLJQIIc781JwQ2TTwTGnx5wZLbffhCasowJKd2EVcyMJyhz6ru0PvXWJ4hUdkARJs3Xu8dus9a86N8Xk6aAPzBDqzYb1vyFIfBxP0oO8xFHgd30Cgmz8UrSE3qeWRrF8ftrI6xQnFjHBGWD/JWSvd6YMcQED0aVuQkuNW9ST/DzQThPzRfPUoiL10yAmV7Ytu4fR3x2sF0Yfi87YhHFuCMpV/DsqxmUizyiJuD938eRcH8hzR/VO53Qo3UIsqOLcyXtTv6THjSlTopQ+JOLOnHm1w8dzYbLN44OG44rRsbihMUQp+wUZ6bsI8rrOnm9WErzkbQFbrfAINdoCiNa6cimYIjvvnMTaFWNymqY1vZxGztQiMiHiHYwTfwHTXrb9j0uPM=|09J28iXv9oWzYtzK2LBT6Yht4IT4MijEkk0fwFdrVQ4=".parse().unwrap(); client + .internal .initialize_user_crypto_master_key(master_key, user_key.parse().unwrap(), private_key) .unwrap(); diff --git a/crates/bitwarden/src/auth/register.rs b/crates/bitwarden-core/src/auth/register.rs similarity index 92% rename from crates/bitwarden/src/auth/register.rs rename to crates/bitwarden-core/src/auth/register.rs index 5ca995ead..07e5e87ba 100644 --- a/crates/bitwarden/src/auth/register.rs +++ b/crates/bitwarden-core/src/auth/register.rs @@ -2,11 +2,11 @@ use bitwarden_api_identity::{ apis::accounts_api::accounts_register_post, models::{KeysRequestModel, RegisterRequestModel}, }; -use bitwarden_crypto::{default_pbkdf2_iterations, HashPurpose, MasterKey, RsaKeyPair}; +use bitwarden_crypto::{default_pbkdf2_iterations, HashPurpose, Kdf, MasterKey, RsaKeyPair}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use crate::{client::Kdf, error::Result, Client}; +use crate::{error::Result, Client}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -19,7 +19,7 @@ pub struct RegisterRequest { /// Half baked implementation of user registration pub(super) async fn register(client: &Client, req: &RegisterRequest) -> Result<()> { - let config = client.get_api_configurations().await; + let config = client.internal.get_api_configurations().await; let kdf = Kdf::default(); diff --git a/crates/bitwarden/src/auth/renew.rs b/crates/bitwarden-core/src/auth/renew.rs similarity index 89% rename from crates/bitwarden/src/auth/renew.rs rename to crates/bitwarden-core/src/auth/renew.rs index 01108cf2c..d53534d58 100644 --- a/crates/bitwarden/src/auth/renew.rs +++ b/crates/bitwarden-core/src/auth/renew.rs @@ -1,15 +1,18 @@ use chrono::Utc; -#[cfg(feature = "internal")] -use crate::{auth::api::request::ApiTokenRequest, client::UserLoginMethod}; +#[cfg(feature = "secrets")] use crate::{ - auth::api::{request::AccessTokenRequest, response::IdentityTokenResponse}, - client::{Client, LoginMethod, ServiceAccountLoginMethod}, - error::{Error, Result}, + auth::api::request::AccessTokenRequest, + client::ServiceAccountLoginMethod, secrets_manager::state::{self, ClientState}, }; +use crate::{ + auth::api::{request::ApiTokenRequest, response::IdentityTokenResponse}, + client::{internal::InternalClient, LoginMethod, UserLoginMethod}, + error::{Error, Result}, +}; -pub(crate) async fn renew_token(client: &Client) -> Result<()> { +pub(crate) async fn renew_token(client: &InternalClient) -> Result<()> { const TOKEN_RENEW_MARGIN_SECONDS: i64 = 5 * 60; let tokens = client @@ -35,7 +38,6 @@ pub(crate) async fn renew_token(client: &Client) -> Result<()> { .clone(); let res = match login_method.as_ref() { - #[cfg(feature = "internal")] LoginMethod::User(u) => match u { UserLoginMethod::Username { client_id, .. } => { let refresh = tokens.refresh_token.ok_or(Error::NotAuthenticated)?; @@ -54,6 +56,7 @@ pub(crate) async fn renew_token(client: &Client) -> Result<()> { .await? } }, + #[cfg(feature = "secrets")] LoginMethod::ServiceAccount(s) => match s { ServiceAccountLoginMethod::AccessToken { access_token, diff --git a/crates/bitwarden/src/auth/tde.rs b/crates/bitwarden-core/src/auth/tde.rs similarity index 80% rename from crates/bitwarden/src/auth/tde.rs rename to crates/bitwarden-core/src/auth/tde.rs index e1ddb0921..8d99b50fe 100644 --- a/crates/bitwarden/src/auth/tde.rs +++ b/crates/bitwarden-core/src/auth/tde.rs @@ -31,14 +31,18 @@ pub(super) fn make_register_tde_keys( None }; - client.set_login_method(crate::client::LoginMethod::User( - crate::client::UserLoginMethod::Username { - client_id: "".to_owned(), - email, - kdf: Kdf::default(), - }, - )); - client.initialize_user_crypto_decrypted_key(user_key.0, key_pair.private.clone())?; + client + .internal + .set_login_method(crate::client::LoginMethod::User( + crate::client::UserLoginMethod::Username { + client_id: "".to_owned(), + email, + kdf: Kdf::default(), + }, + )); + client + .internal + .initialize_user_crypto_decrypted_key(user_key.0, key_pair.private.clone())?; Ok(RegisterTdeKeyResponse { private_key: key_pair.private, diff --git a/crates/bitwarden-core/src/client/client.rs b/crates/bitwarden-core/src/client/client.rs new file mode 100644 index 000000000..3ea4ae7e8 --- /dev/null +++ b/crates/bitwarden-core/src/client/client.rs @@ -0,0 +1,105 @@ +use std::sync::{Arc, RwLock}; + +use reqwest::header::{self, HeaderValue}; + +use super::internal::InternalClient; +#[cfg(feature = "internal")] +use crate::client::flags::Flags; +use crate::client::{ + client_settings::ClientSettings, + internal::{ApiConfigurations, Tokens}, +}; + +/// The main struct to interact with the Bitwarden SDK. +#[derive(Debug)] +pub struct Client { + #[doc(hidden)] + pub internal: InternalClient, +} + +impl Client { + pub fn new(settings_input: Option) -> Self { + let settings = settings_input.unwrap_or_default(); + + fn new_client_builder() -> reqwest::ClientBuilder { + #[allow(unused_mut)] + let mut client_builder = reqwest::Client::builder(); + + #[cfg(all(not(target_os = "android"), not(target_arch = "wasm32")))] + { + client_builder = + client_builder.use_preconfigured_tls(rustls_platform_verifier::tls_config()); + } + + client_builder + } + + let external_client = new_client_builder().build().expect("Build should not fail"); + + let mut headers = header::HeaderMap::new(); + headers.append( + "Device-Type", + HeaderValue::from_str(&(settings.device_type as u8).to_string()) + .expect("All numbers are valid ASCII"), + ); + let client_builder = new_client_builder().default_headers(headers); + + let client = client_builder.build().expect("Build should not fail"); + + let identity = bitwarden_api_identity::apis::configuration::Configuration { + base_path: settings.identity_url, + user_agent: Some(settings.user_agent.clone()), + client: client.clone(), + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, + }; + + let api = bitwarden_api_api::apis::configuration::Configuration { + base_path: settings.api_url, + user_agent: Some(settings.user_agent), + client, + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, + }; + + Self { + internal: InternalClient { + tokens: RwLock::new(Tokens::default()), + login_method: RwLock::new(None), + #[cfg(feature = "internal")] + flags: RwLock::new(Flags::default()), + __api_configurations: RwLock::new(Arc::new(ApiConfigurations { + identity, + api, + device_type: settings.device_type, + })), + external_client, + encryption_settings: RwLock::new(None), + }, + } + } +} + +#[cfg(test)] +mod tests { + #[test] + fn test_reqwest_rustls_platform_verifier_are_compatible() { + // rustls-platform-verifier is generating a rustls::ClientConfig, + // which reqwest accepts as a &dyn Any and then downcasts it to a + // rustls::ClientConfig. + + // This means that if the rustls version of the two crates don't match, + // the downcast will fail and we will get a runtime error. + + // This tests is added to ensure that it doesn't happen. + + let _ = reqwest::ClientBuilder::new() + .use_preconfigured_tls(rustls_platform_verifier::tls_config()) + .build() + .unwrap(); + } +} diff --git a/crates/bitwarden/src/client/client_settings.rs b/crates/bitwarden-core/src/client/client_settings.rs similarity index 97% rename from crates/bitwarden/src/client/client_settings.rs rename to crates/bitwarden-core/src/client/client_settings.rs index d82e5d93c..bd678d131 100644 --- a/crates/bitwarden/src/client/client_settings.rs +++ b/crates/bitwarden-core/src/client/client_settings.rs @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize}; /// Defaults to /// /// ``` -/// # use bitwarden::{ClientSettings, DeviceType}; +/// # use bitwarden_core::{ClientSettings, DeviceType}; /// let settings = ClientSettings { /// identity_url: "https://identity.bitwarden.com".to_string(), /// api_url: "https://api.bitwarden.com".to_string(), diff --git a/crates/bitwarden/src/client/encryption_settings.rs b/crates/bitwarden-core/src/client/encryption_settings.rs similarity index 96% rename from crates/bitwarden/src/client/encryption_settings.rs rename to crates/bitwarden-core/src/client/encryption_settings.rs index f92dd5f09..138d1568e 100644 --- a/crates/bitwarden/src/client/encryption_settings.rs +++ b/crates/bitwarden-core/src/client/encryption_settings.rs @@ -59,6 +59,7 @@ impl EncryptionSettings { /// Initialize the encryption settings with only a single decrypted key. /// This is used only for logging in Secrets Manager with an access token + #[cfg(feature = "secrets")] pub(crate) fn new_single_key(key: SymmetricCryptoKey) -> Self { EncryptionSettings { user_key: key, @@ -72,9 +73,10 @@ impl EncryptionSettings { &mut self, org_enc_keys: Vec<(Uuid, AsymmetricEncString)>, ) -> Result<&Self> { - use bitwarden_core::VaultLocked; use bitwarden_crypto::KeyDecryptable; + use crate::VaultLocked; + let private_key = self.private_key.as_ref().ok_or(VaultLocked)?; // Make sure we only keep the keys given in the arguments and not any of the previous @@ -93,7 +95,7 @@ impl EncryptionSettings { Ok(self) } - pub(crate) fn get_key(&self, org_id: &Option) -> Option<&SymmetricCryptoKey> { + pub fn get_key(&self, org_id: &Option) -> Option<&SymmetricCryptoKey> { // If we don't have a private key set (to decode multiple org keys), we just use the main // user key if self.private_key.is_none() { diff --git a/crates/bitwarden/src/client/flags.rs b/crates/bitwarden-core/src/client/flags.rs similarity index 100% rename from crates/bitwarden/src/client/flags.rs rename to crates/bitwarden-core/src/client/flags.rs diff --git a/crates/bitwarden/src/client/client.rs b/crates/bitwarden-core/src/client/internal.rs similarity index 57% rename from crates/bitwarden/src/client/client.rs rename to crates/bitwarden-core/src/client/internal.rs index 413e704aa..55122b9a1 100644 --- a/crates/bitwarden/src/client/client.rs +++ b/crates/bitwarden-core/src/client/internal.rs @@ -1,67 +1,32 @@ -use std::{ - path::PathBuf, - sync::{Arc, RwLock}, -}; +use std::sync::{Arc, RwLock}; -use bitwarden_core::VaultLocked; -#[cfg(feature = "internal")] -pub use bitwarden_crypto::Kdf; +#[cfg(any(feature = "internal", feature = "secrets"))] use bitwarden_crypto::SymmetricCryptoKey; #[cfg(feature = "internal")] -use bitwarden_crypto::{AsymmetricEncString, EncString, MasterKey}; +use bitwarden_crypto::{AsymmetricEncString, EncString, Kdf, MasterKey}; use chrono::Utc; -use reqwest::header::{self, HeaderValue}; use uuid::Uuid; +#[cfg(feature = "secrets")] +use super::login_method::ServiceAccountLoginMethod; +use super::{encryption_settings::EncryptionSettings, login_method::LoginMethod}; +#[cfg(feature = "internal")] +use super::{flags::Flags, login_method::UserLoginMethod}; #[cfg(feature = "internal")] -use crate::client::flags::Flags; +use crate::error::Error; use crate::{ - auth::AccessToken, client::encryption_settings::EncryptionSettings, error::Result, - ClientSettings, DeviceType, + auth::renew::renew_token, + error::{Result, VaultLocked}, + DeviceType, }; #[derive(Debug, Clone)] -pub(crate) struct ApiConfigurations { +pub struct ApiConfigurations { pub identity: bitwarden_api_identity::apis::configuration::Configuration, pub api: bitwarden_api_api::apis::configuration::Configuration, pub device_type: DeviceType, } -#[derive(Debug)] -pub(crate) enum LoginMethod { - #[cfg(feature = "internal")] - User(UserLoginMethod), - // TODO: Organizations supports api key - // Organization(OrganizationLoginMethod), - ServiceAccount(ServiceAccountLoginMethod), -} - -#[derive(Debug)] -#[cfg(feature = "internal")] -pub(crate) enum UserLoginMethod { - Username { - client_id: String, - email: String, - kdf: Kdf, - }, - ApiKey { - client_id: String, - client_secret: String, - - email: String, - kdf: Kdf, - }, -} - -#[derive(Debug)] -pub(crate) enum ServiceAccountLoginMethod { - AccessToken { - access_token: AccessToken, - organization_id: Uuid, - state_file: Option, - }, -} - #[derive(Debug, Default, Clone)] pub(crate) struct Tokens { // These two fields are always written to, but they are not read @@ -74,16 +39,15 @@ pub(crate) struct Tokens { pub(crate) refresh_token: Option, } -/// The main struct to interact with the Bitwarden SDK. #[derive(Debug)] -pub struct Client { +pub struct InternalClient { pub(crate) tokens: RwLock, pub(crate) login_method: RwLock>>, #[cfg(feature = "internal")] - flags: RwLock, + pub(super) flags: RwLock, - /// Use Client::get_api_configurations() to access this. + /// Use Client::get_api_configurations().await to access this. /// It should only be used directly in renew_token #[doc(hidden)] pub(crate) __api_configurations: RwLock>, @@ -92,98 +56,20 @@ pub struct Client { #[allow(unused)] pub(crate) external_client: reqwest::Client, - encryption_settings: RwLock>>, + pub(super) encryption_settings: RwLock>>, } -impl Client { - pub fn new(settings_input: Option) -> Self { - let settings = settings_input.unwrap_or_default(); - - fn new_client_builder() -> reqwest::ClientBuilder { - #[allow(unused_mut)] - let mut client_builder = reqwest::Client::builder(); - - #[cfg(all(not(target_os = "android"), not(target_arch = "wasm32")))] - { - client_builder = - client_builder.use_preconfigured_tls(rustls_platform_verifier::tls_config()); - } - - client_builder - } - - let external_client = new_client_builder().build().expect("Build should not fail"); - - let mut headers = header::HeaderMap::new(); - headers.append( - "Device-Type", - HeaderValue::from_str(&(settings.device_type as u8).to_string()) - .expect("All numbers are valid ASCII"), - ); - let client_builder = new_client_builder().default_headers(headers); - - let client = client_builder.build().expect("Build should not fail"); - - let identity = bitwarden_api_identity::apis::configuration::Configuration { - base_path: settings.identity_url, - user_agent: Some(settings.user_agent.clone()), - client: client.clone(), - basic_auth: None, - oauth_access_token: None, - bearer_access_token: None, - api_key: None, - }; - - let api = bitwarden_api_api::apis::configuration::Configuration { - base_path: settings.api_url, - user_agent: Some(settings.user_agent), - client, - basic_auth: None, - oauth_access_token: None, - bearer_access_token: None, - api_key: None, - }; - - Self { - tokens: RwLock::new(Tokens::default()), - login_method: RwLock::new(None), - #[cfg(feature = "internal")] - flags: RwLock::new(Flags::default()), - __api_configurations: RwLock::new(Arc::new(ApiConfigurations { - identity, - api, - device_type: settings.device_type, - })), - external_client, - encryption_settings: RwLock::new(None), - } - } - +impl InternalClient { #[cfg(feature = "internal")] pub fn load_flags(&self, flags: std::collections::HashMap) { *self.flags.write().expect("RwLock is not poisoned") = Flags::load_from_map(flags); } #[cfg(feature = "internal")] - pub(crate) fn get_flags(&self) -> Flags { + pub fn get_flags(&self) -> Flags { self.flags.read().expect("RwLock is not poisoned").clone() } - pub(crate) async fn get_api_configurations(&self) -> Arc { - // At the moment we ignore the error result from the token renewal, if it fails, - // the token will end up expiring and the next operation is going to fail anyway. - self.auth().renew_token().await.ok(); - self.__api_configurations - .read() - .expect("RwLock is not poisoned") - .clone() - } - - #[cfg(feature = "internal")] - pub(crate) fn get_http_client(&self) -> &reqwest::Client { - &self.external_client - } - #[cfg(feature = "internal")] pub(crate) fn get_login_method(&self) -> Option> { self.login_method @@ -199,6 +85,7 @@ impl Client { .expect("RwLock is not poisoned") .as_deref() { + #[cfg(feature = "secrets")] Some(LoginMethod::ServiceAccount(ServiceAccountLoginMethod::AccessToken { organization_id, .. @@ -207,14 +94,7 @@ impl Client { } } - pub(crate) fn get_encryption_settings(&self) -> Result, VaultLocked> { - self.encryption_settings - .read() - .expect("RwLock is not poisoned") - .clone() - .ok_or(VaultLocked) - } - + #[cfg(any(feature = "internal", feature = "secrets"))] pub(crate) fn set_login_method(&self, login_method: LoginMethod) { use log::debug; @@ -240,6 +120,7 @@ impl Client { *guard = Arc::new(inner); } + #[cfg(feature = "internal")] pub fn is_authed(&self) -> bool { let is_token_set = self .tokens @@ -256,6 +137,44 @@ impl Client { is_token_set || is_login_method_set } + #[cfg(feature = "internal")] + pub fn get_kdf(&self) -> Result { + match self + .login_method + .read() + .expect("RwLock is not poisoned") + .as_deref() + { + Some(LoginMethod::User( + UserLoginMethod::Username { kdf, .. } | UserLoginMethod::ApiKey { kdf, .. }, + )) => Ok(kdf.clone()), + _ => Err(Error::NotAuthenticated), + } + } + + pub async fn get_api_configurations(&self) -> Arc { + // At the moment we ignore the error result from the token renewal, if it fails, + // the token will end up expiring and the next operation is going to fail anyway. + renew_token(self).await.ok(); + self.__api_configurations + .read() + .expect("RwLock is not poisoned") + .clone() + } + + #[cfg(feature = "internal")] + pub fn get_http_client(&self) -> &reqwest::Client { + &self.external_client + } + + pub fn get_encryption_settings(&self) -> Result, VaultLocked> { + self.encryption_settings + .read() + .expect("RwLock is not poisoned") + .clone() + .ok_or(VaultLocked) + } + #[cfg(feature = "internal")] pub(crate) fn initialize_user_crypto_master_key( &self, @@ -302,6 +221,7 @@ impl Client { self.initialize_user_crypto_decrypted_key(decrypted_user_key, private_key) } + #[cfg(feature = "secrets")] pub(crate) fn initialize_crypto_single_key(&self, key: SymmetricCryptoKey) { *self .encryption_settings @@ -311,7 +231,7 @@ impl Client { } #[cfg(feature = "internal")] - pub(crate) fn initialize_org_crypto( + pub fn initialize_org_crypto( &self, org_keys: Vec<(Uuid, AsymmetricEncString)>, ) -> Result> { @@ -333,23 +253,3 @@ impl Client { Ok(enc) } } - -#[cfg(test)] -mod tests { - #[test] - fn test_reqwest_rustls_platform_verifier_are_compatible() { - // rustls-platform-verifier is generating a rustls::ClientConfig, - // which reqwest accepts as a &dyn Any and then downcasts it to a - // rustls::ClientConfig. - - // This means that if the rustls version of the two crates don't match, - // the downcast will fail and we will get a runtime error. - - // This tests is added to ensure that it doesn't happen. - - let _ = reqwest::ClientBuilder::new() - .use_preconfigured_tls(rustls_platform_verifier::tls_config()) - .build() - .unwrap(); - } -} diff --git a/crates/bitwarden-core/src/client/login_method.rs b/crates/bitwarden-core/src/client/login_method.rs new file mode 100644 index 000000000..67db15a71 --- /dev/null +++ b/crates/bitwarden-core/src/client/login_method.rs @@ -0,0 +1,46 @@ +#[cfg(feature = "secrets")] +use std::path::PathBuf; + +use bitwarden_crypto::Kdf; +#[cfg(feature = "secrets")] +use uuid::Uuid; + +#[cfg(feature = "secrets")] +use crate::auth::AccessToken; + +#[derive(Debug)] +pub(crate) enum LoginMethod { + #[allow(dead_code)] + User(UserLoginMethod), + // TODO: Organizations supports api key + // Organization(OrganizationLoginMethod), + #[cfg(feature = "secrets")] + ServiceAccount(ServiceAccountLoginMethod), +} + +#[allow(dead_code)] +#[derive(Debug)] +pub(crate) enum UserLoginMethod { + Username { + client_id: String, + email: String, + kdf: Kdf, + }, + ApiKey { + client_id: String, + client_secret: String, + + email: String, + kdf: Kdf, + }, +} + +#[cfg(feature = "secrets")] +#[derive(Debug)] +pub(crate) enum ServiceAccountLoginMethod { + AccessToken { + access_token: AccessToken, + organization_id: Uuid, + state_file: Option, + }, +} diff --git a/crates/bitwarden-core/src/client/mod.rs b/crates/bitwarden-core/src/client/mod.rs new file mode 100644 index 000000000..1ef7d9357 --- /dev/null +++ b/crates/bitwarden-core/src/client/mod.rs @@ -0,0 +1,20 @@ +//! Bitwarden SDK Client + +#[allow(clippy::module_inception)] +mod client; +pub mod client_settings; +pub mod encryption_settings; +pub mod internal; +pub use internal::ApiConfigurations; +pub mod login_method; +#[cfg(feature = "secrets")] +pub(crate) use login_method::ServiceAccountLoginMethod; +pub(crate) use login_method::{LoginMethod, UserLoginMethod}; +#[cfg(feature = "internal")] +mod flags; + +pub use client::Client; +pub use client_settings::{ClientSettings, DeviceType}; + +#[cfg(feature = "internal")] +pub mod test_accounts; diff --git a/crates/bitwarden/src/client/test_accounts.rs b/crates/bitwarden-core/src/client/test_accounts.rs similarity index 99% rename from crates/bitwarden/src/client/test_accounts.rs rename to crates/bitwarden-core/src/client/test_accounts.rs index 7c24df0ac..4e83f2c14 100644 --- a/crates/bitwarden/src/client/test_accounts.rs +++ b/crates/bitwarden-core/src/client/test_accounts.rs @@ -1,3 +1,4 @@ +#![allow(clippy::unwrap_used)] use std::collections::HashMap; use bitwarden_crypto::Kdf; @@ -14,7 +15,7 @@ impl Client { pub async fn init_test_account(account: TestAccount) -> Self { let client = Client::new(None); - client.load_flags(HashMap::from([( + client.internal.load_flags(HashMap::from([( "enableCipherKeyEncryption".to_owned(), true, )])); diff --git a/crates/bitwarden-core/src/error.rs b/crates/bitwarden-core/src/error.rs index 2c46407cc..e4ca94a25 100644 --- a/crates/bitwarden-core/src/error.rs +++ b/crates/bitwarden-core/src/error.rs @@ -1,5 +1,121 @@ +//! Errors that can occur when using this SDK + +use std::{borrow::Cow, fmt::Debug}; + +use bitwarden_api_api::apis::Error as ApiError; +use bitwarden_api_identity::apis::Error as IdentityError; +use reqwest::StatusCode; use thiserror::Error; +#[derive(Debug, Error)] +pub enum Error { + #[error(transparent)] + MissingFieldError(#[from] MissingFieldError), + #[error(transparent)] + VaultLocked(#[from] VaultLocked), + + #[error("The client is not authenticated or the session has expired")] + NotAuthenticated, + + #[error("Access token is not in a valid format: {0}")] + AccessTokenInvalid(#[from] AccessTokenInvalidError), + + #[error("The response received was invalid and could not be processed")] + InvalidResponse, + + #[error("Cryptography error, {0}")] + Crypto(#[from] bitwarden_crypto::CryptoError), + + #[error("Error parsing Identity response: {0}")] + IdentityFail(crate::auth::api::response::IdentityTokenFailResponse), + + #[error(transparent)] + Reqwest(#[from] reqwest::Error), + #[error(transparent)] + Serde(#[from] serde_json::Error), + #[error(transparent)] + Io(#[from] std::io::Error), + #[error(transparent)] + InvalidBase64(#[from] base64::DecodeError), + #[error(transparent)] + Chrono(#[from] chrono::ParseError), + + #[error("Received error message from server: [{}] {}", .status, .message)] + ResponseContent { status: StatusCode, message: String }, + + #[error("The state file version is invalid")] + InvalidStateFileVersion, + + #[error("The state file could not be read")] + InvalidStateFile, + + #[error("Internal error: {0}")] + Internal(Cow<'static, str>), +} + +impl From for Error { + fn from(s: String) -> Self { + Self::Internal(s.into()) + } +} + +impl From<&'static str> for Error { + fn from(s: &'static str) -> Self { + Self::Internal(s.into()) + } +} + +#[derive(Debug, Error)] +pub enum AccessTokenInvalidError { + #[error("Doesn't contain a decryption key")] + NoKey, + #[error("Has the wrong number of parts")] + WrongParts, + #[error("Is the wrong version")] + WrongVersion, + #[error("Has an invalid identifier")] + InvalidUuid, + + #[error("Error decoding base64: {0}")] + InvalidBase64(#[from] base64::DecodeError), + + #[error("Invalid base64 length: expected {expected}, got {got}")] + InvalidBase64Length { expected: usize, got: usize }, +} + +// Ensure that the error messages implement Send and Sync +#[cfg(test)] +const _: () = { + fn assert_send() {} + fn assert_sync() {} + fn assert_all() { + assert_send::(); + assert_sync::(); + } +}; + +macro_rules! impl_bitwarden_error { + ($name:ident) => { + impl From<$name> for Error { + fn from(e: $name) -> Self { + match e { + $name::Reqwest(e) => Self::Reqwest(e), + $name::ResponseError(e) => Self::ResponseContent { + status: e.status, + message: e.content, + }, + $name::Serde(e) => Self::Serde(e), + $name::Io(e) => Self::Io(e), + } + } + } + }; +} +impl_bitwarden_error!(ApiError); +impl_bitwarden_error!(IdentityError); + +pub(crate) type Result = std::result::Result; + #[derive(Debug, Error)] #[error("The response received was missing a required field: {0}")] pub struct MissingFieldError(pub &'static str); diff --git a/crates/bitwarden-core/src/lib.rs b/crates/bitwarden-core/src/lib.rs index 9d701730c..409f0133b 100644 --- a/crates/bitwarden-core/src/lib.rs +++ b/crates/bitwarden-core/src/lib.rs @@ -3,5 +3,20 @@ uniffi::setup_scaffolding!(); #[cfg(feature = "uniffi")] mod uniffi_support; +#[cfg(feature = "internal")] +pub mod admin_console; +pub mod auth; +pub mod client; mod error; +pub use error::Error; +#[cfg(feature = "internal")] +pub mod mobile; pub use error::{MissingFieldError, VaultLocked}; +#[cfg(feature = "internal")] +pub mod platform; +#[cfg(feature = "secrets")] +pub mod secrets_manager; +mod util; + +pub use bitwarden_crypto::ZeroizingAllocator; +pub use client::{Client, ClientSettings, DeviceType}; diff --git a/crates/bitwarden/src/mobile/client_crypto.rs b/crates/bitwarden-core/src/mobile/client_crypto.rs similarity index 100% rename from crates/bitwarden/src/mobile/client_crypto.rs rename to crates/bitwarden-core/src/mobile/client_crypto.rs diff --git a/crates/bitwarden/src/mobile/client_kdf.rs b/crates/bitwarden-core/src/mobile/client_kdf.rs similarity index 80% rename from crates/bitwarden/src/mobile/client_kdf.rs rename to crates/bitwarden-core/src/mobile/client_kdf.rs index 4e62e5d59..5ec7aec77 100644 --- a/crates/bitwarden/src/mobile/client_kdf.rs +++ b/crates/bitwarden-core/src/mobile/client_kdf.rs @@ -1,6 +1,6 @@ -use bitwarden_crypto::HashPurpose; +use bitwarden_crypto::{HashPurpose, Kdf}; -use crate::{client::Kdf, error::Result, mobile::kdf::hash_password, Client}; +use crate::{error::Result, mobile::kdf::hash_password, Client}; pub struct ClientKdf<'a> { pub(crate) client: &'a crate::Client, diff --git a/crates/bitwarden/src/mobile/crypto.rs b/crates/bitwarden-core/src/mobile/crypto.rs similarity index 90% rename from crates/bitwarden/src/mobile/crypto.rs rename to crates/bitwarden-core/src/mobile/crypto.rs index fde041e5f..2b6992496 100644 --- a/crates/bitwarden/src/mobile/crypto.rs +++ b/crates/bitwarden-core/src/mobile/crypto.rs @@ -1,18 +1,16 @@ use std::collections::HashMap; -use bitwarden_core::VaultLocked; use bitwarden_crypto::{AsymmetricEncString, EncString}; #[cfg(feature = "internal")] -use bitwarden_crypto::{KeyDecryptable, KeyEncryptable, MasterKey, SymmetricCryptoKey}; +use bitwarden_crypto::{Kdf, KeyDecryptable, KeyEncryptable, MasterKey, SymmetricCryptoKey}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; #[cfg(feature = "internal")] use crate::client::{LoginMethod, UserLoginMethod}; use crate::{ - client::Kdf, error::{Error, Result}, - Client, + Client, VaultLocked, }; #[cfg(feature = "internal")] @@ -99,18 +97,26 @@ pub async fn initialize_user_crypto(client: &Client, req: InitUserCryptoRequest) let master_key = MasterKey::derive(password.as_bytes(), req.email.as_bytes(), &req.kdf_params)?; - client.initialize_user_crypto_master_key(master_key, user_key, private_key)?; + client + .internal + .initialize_user_crypto_master_key(master_key, user_key, private_key)?; } InitUserCryptoMethod::DecryptedKey { decrypted_user_key } => { let user_key = SymmetricCryptoKey::try_from(decrypted_user_key)?; - client.initialize_user_crypto_decrypted_key(user_key, private_key)?; + client + .internal + .initialize_user_crypto_decrypted_key(user_key, private_key)?; } InitUserCryptoMethod::Pin { pin, pin_protected_user_key, } => { let pin_key = MasterKey::derive(pin.as_bytes(), req.email.as_bytes(), &req.kdf_params)?; - client.initialize_user_crypto_pin(pin_key, pin_protected_user_key, private_key)?; + client.internal.initialize_user_crypto_pin( + pin_key, + pin_protected_user_key, + private_key, + )?; } InitUserCryptoMethod::AuthRequest { request_private_key, @@ -129,7 +135,9 @@ pub async fn initialize_user_crypto(client: &Client, req: InitUserCryptoRequest) auth_request_key, )?, }; - client.initialize_user_crypto_decrypted_key(user_key, private_key)?; + client + .internal + .initialize_user_crypto_decrypted_key(user_key, private_key)?; } InitUserCryptoMethod::DeviceKey { device_key, @@ -140,17 +148,21 @@ pub async fn initialize_user_crypto(client: &Client, req: InitUserCryptoRequest) let user_key = device_key .decrypt_user_key(protected_device_private_key, device_protected_user_key)?; - client.initialize_user_crypto_decrypted_key(user_key, private_key)?; + client + .internal + .initialize_user_crypto_decrypted_key(user_key, private_key)?; } } - client.set_login_method(crate::client::LoginMethod::User( - crate::client::UserLoginMethod::Username { - client_id: "".to_string(), - email: req.email, - kdf: req.kdf_params, - }, - )); + client + .internal + .set_login_method(crate::client::LoginMethod::User( + crate::client::UserLoginMethod::Username { + client_id: "".to_string(), + email: req.email, + kdf: req.kdf_params, + }, + )); Ok(()) } @@ -167,13 +179,13 @@ pub struct InitOrgCryptoRequest { #[cfg(feature = "internal")] pub async fn initialize_org_crypto(client: &Client, req: InitOrgCryptoRequest) -> Result<()> { let organization_keys = req.organization_keys.into_iter().collect(); - client.initialize_org_crypto(organization_keys)?; + client.internal.initialize_org_crypto(organization_keys)?; Ok(()) } #[cfg(feature = "internal")] pub async fn get_user_encryption_key(client: &Client) -> Result { - let enc = client.get_encryption_settings()?; + let enc = client.internal.get_encryption_settings()?; let user_key = enc.get_key(&None).ok_or(VaultLocked)?; Ok(user_key.to_base64()) @@ -191,10 +203,13 @@ pub struct UpdatePasswordResponse { } pub fn update_password(client: &Client, new_password: String) -> Result { - let enc = client.get_encryption_settings()?; + let enc = client.internal.get_encryption_settings()?; let user_key = enc.get_key(&None).ok_or(VaultLocked)?; - let login_method = client.get_login_method().ok_or(Error::NotAuthenticated)?; + let login_method = client + .internal + .get_login_method() + .ok_or(Error::NotAuthenticated)?; // Derive a new master key from password let new_master_key = match login_method.as_ref() { @@ -202,7 +217,8 @@ pub fn update_password(client: &Client, new_password: String) -> Result MasterKey::derive(new_password.as_bytes(), email.as_bytes(), kdf)?, - _ => return Err(Error::NotAuthenticated), + #[cfg(feature = "secrets")] + LoginMethod::ServiceAccount(_) => return Err(Error::NotAuthenticated), }; let new_key = new_master_key.encrypt_user_key(user_key)?; @@ -231,10 +247,13 @@ pub struct DerivePinKeyResponse { #[cfg(feature = "internal")] pub fn derive_pin_key(client: &Client, pin: String) -> Result { - let enc = client.get_encryption_settings()?; + let enc = client.internal.get_encryption_settings()?; let user_key = enc.get_key(&None).ok_or(VaultLocked)?; - let login_method = client.get_login_method().ok_or(Error::NotAuthenticated)?; + let login_method = client + .internal + .get_login_method() + .ok_or(Error::NotAuthenticated)?; let pin_protected_user_key = derive_pin_protected_user_key(&pin, &login_method, user_key)?; @@ -246,11 +265,14 @@ pub fn derive_pin_key(client: &Client, pin: String) -> Result Result { - let enc = client.get_encryption_settings()?; + let enc = client.internal.get_encryption_settings()?; let user_key = enc.get_key(&None).ok_or(VaultLocked)?; let pin: String = encrypted_pin.decrypt_with_key(user_key)?; - let login_method = client.get_login_method().ok_or(Error::NotAuthenticated)?; + let login_method = client + .internal + .get_login_method() + .ok_or(Error::NotAuthenticated)?; derive_pin_protected_user_key(&pin, &login_method, user_key) } @@ -266,7 +288,8 @@ fn derive_pin_protected_user_key( UserLoginMethod::Username { email, kdf, .. } | UserLoginMethod::ApiKey { email, kdf, .. }, ) => MasterKey::derive(pin.as_bytes(), email.as_bytes(), kdf)?, - _ => return Err(Error::NotAuthenticated), + #[cfg(feature = "secrets")] + LoginMethod::ServiceAccount(_) => return Err(Error::NotAuthenticated), }; Ok(derived_key.encrypt_user_key(user_key)?) @@ -281,7 +304,7 @@ pub(super) fn enroll_admin_password_reset( use bitwarden_crypto::AsymmetricPublicCryptoKey; let public_key = AsymmetricPublicCryptoKey::from_der(&STANDARD.decode(public_key)?)?; - let enc = client.get_encryption_settings()?; + let enc = client.internal.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(VaultLocked)?; Ok(AsymmetricEncString::encrypt_rsa2048_oaep_sha1( @@ -293,7 +316,7 @@ pub(super) fn enroll_admin_password_reset( #[cfg(test)] mod tests { use super::*; - use crate::{client::Kdf, Client}; + use crate::Client; #[tokio::test] async fn test_update_password() { @@ -354,12 +377,14 @@ mod tests { assert_eq!( client + .internal .get_encryption_settings() .unwrap() .get_key(&None) .unwrap() .to_base64(), client2 + .internal .get_encryption_settings() .unwrap() .get_key(&None) @@ -414,12 +439,14 @@ mod tests { assert_eq!( client + .internal .get_encryption_settings() .unwrap() .get_key(&None) .unwrap() .to_base64(), client2 + .internal .get_encryption_settings() .unwrap() .get_key(&None) @@ -451,12 +478,14 @@ mod tests { assert_eq!( client + .internal .get_encryption_settings() .unwrap() .get_key(&None) .unwrap() .to_base64(), client3 + .internal .get_encryption_settings() .unwrap() .get_key(&None) @@ -487,6 +516,7 @@ mod tests { let user_key = "2.Q/2PhzcC7GdeiMHhWguYAQ==|GpqzVdr0go0ug5cZh1n+uixeBC3oC90CIe0hd/HWA/pTRDZ8ane4fmsEIcuc8eMKUt55Y2q/fbNzsYu41YTZzzsJUSeqVjT8/iTQtgnNdpo=|dwI+uyvZ1h/iZ03VQ+/wrGEFYVewBUUl/syYgjsNMbE=".parse().unwrap(); let private_key ="2.yN7l00BOlUE0Sb0M//Q53w==|EwKG/BduQRQ33Izqc/ogoBROIoI5dmgrxSo82sgzgAMIBt3A2FZ9vPRMY+GWT85JiqytDitGR3TqwnFUBhKUpRRAq4x7rA6A1arHrFp5Tp1p21O3SfjtvB3quiOKbqWk6ZaU1Np9HwqwAecddFcB0YyBEiRX3VwF2pgpAdiPbSMuvo2qIgyob0CUoC/h4Bz1be7Qa7B0Xw9/fMKkB1LpOm925lzqosyMQM62YpMGkjMsbZz0uPopu32fxzDWSPr+kekNNyLt9InGhTpxLmq1go/pXR2uw5dfpXc5yuta7DB0EGBwnQ8Vl5HPdDooqOTD9I1jE0mRyuBpWTTI3FRnu3JUh3rIyGBJhUmHqGZvw2CKdqHCIrQeQkkEYqOeJRJVdBjhv5KGJifqT3BFRwX/YFJIChAQpebNQKXe/0kPivWokHWwXlDB7S7mBZzhaAPidZvnuIhalE2qmTypDwHy22FyqV58T8MGGMchcASDi/QXI6kcdpJzPXSeU9o+NC68QDlOIrMVxKFeE7w7PvVmAaxEo0YwmuAzzKy9QpdlK0aab/xEi8V4iXj4hGepqAvHkXIQd+r3FNeiLfllkb61p6WTjr5urcmDQMR94/wYoilpG5OlybHdbhsYHvIzYoLrC7fzl630gcO6t4nM24vdB6Ymg9BVpEgKRAxSbE62Tqacxqnz9AcmgItb48NiR/He3n3ydGjPYuKk/ihZMgEwAEZvSlNxYONSbYrIGDtOY+8Nbt6KiH3l06wjZW8tcmFeVlWv+tWotnTY9IqlAfvNVTjtsobqtQnvsiDjdEVtNy/s2ci5TH+NdZluca2OVEr91Wayxh70kpM6ib4UGbfdmGgCo74gtKvKSJU0rTHakQ5L9JlaSDD5FamBRyI0qfL43Ad9qOUZ8DaffDCyuaVyuqk7cz9HwmEmvWU3VQ+5t06n/5kRDXttcw8w+3qClEEdGo1KeENcnXCB32dQe3tDTFpuAIMLqwXs6FhpawfZ5kPYvLPczGWaqftIs/RXJ/EltGc0ugw2dmTLpoQhCqrcKEBDoYVk0LDZKsnzitOGdi9mOWse7Se8798ib1UsHFUjGzISEt6upestxOeupSTOh0v4+AjXbDzRUyogHww3V+Bqg71bkcMxtB+WM+pn1XNbVTyl9NR040nhP7KEf6e9ruXAtmrBC2ah5cFEpLIot77VFZ9ilLuitSz+7T8n1yAh1IEG6xxXxninAZIzi2qGbH69O5RSpOJuJTv17zTLJQIIc781JwQ2TTwTGnx5wZLbffhCasowJKd2EVcyMJyhz6ru0PvXWJ4hUdkARJs3Xu8dus9a86N8Xk6aAPzBDqzYb1vyFIfBxP0oO8xFHgd30Cgmz8UrSE3qeWRrF8ftrI6xQnFjHBGWD/JWSvd6YMcQED0aVuQkuNW9ST/DzQThPzRfPUoiL10yAmV7Ytu4fR3x2sF0Yfi87YhHFuCMpV/DsqxmUizyiJuD938eRcH8hzR/VO53Qo3UIsqOLcyXtTv6THjSlTopQ+JOLOnHm1w8dzYbLN44OG44rRsbihMUQp+wUZ6bsI8rrOnm9WErzkbQFbrfAINdoCiNa6cimYIjvvnMTaFWNymqY1vZxGztQiMiHiHYwTfwHTXrb9j0uPM=|09J28iXv9oWzYtzK2LBT6Yht4IT4MijEkk0fwFdrVQ4=".parse().unwrap(); client + .internal .initialize_user_crypto_master_key(master_key, user_key, private_key) .unwrap(); @@ -499,7 +529,7 @@ mod tests { AsymmetricCryptoKey::from_der(&STANDARD.decode(private_key).unwrap()).unwrap(); let decrypted: Vec = encrypted.decrypt_with_key(&private_key).unwrap(); - let enc = client.get_encryption_settings().unwrap(); + let enc = client.internal.get_encryption_settings().unwrap(); let expected = enc.get_key(&None).unwrap(); assert_eq!(&decrypted, &expected.to_vec()); } diff --git a/crates/bitwarden/src/mobile/kdf.rs b/crates/bitwarden-core/src/mobile/kdf.rs similarity index 100% rename from crates/bitwarden/src/mobile/kdf.rs rename to crates/bitwarden-core/src/mobile/kdf.rs diff --git a/crates/bitwarden/src/mobile/mod.rs b/crates/bitwarden-core/src/mobile/mod.rs similarity index 82% rename from crates/bitwarden/src/mobile/mod.rs rename to crates/bitwarden-core/src/mobile/mod.rs index 9425116e5..7c6a916a8 100644 --- a/crates/bitwarden/src/mobile/mod.rs +++ b/crates/bitwarden-core/src/mobile/mod.rs @@ -1,7 +1,5 @@ pub mod crypto; pub mod kdf; -pub mod tool; -pub mod vault; mod client_crypto; mod client_kdf; diff --git a/crates/bitwarden/src/platform/client_platform.rs b/crates/bitwarden-core/src/platform/client_platform.rs similarity index 81% rename from crates/bitwarden/src/platform/client_platform.rs rename to crates/bitwarden-core/src/platform/client_platform.rs index ca9ce8d63..1f117d5fe 100644 --- a/crates/bitwarden/src/platform/client_platform.rs +++ b/crates/bitwarden-core/src/platform/client_platform.rs @@ -1,5 +1,3 @@ -#[cfg(feature = "uniffi")] -use super::client_fido::ClientFido2; use super::{ generate_fingerprint::{generate_fingerprint, generate_user_fingerprint}, get_user_api_key, FingerprintRequest, FingerprintResponse, SecretVerificationRequest, @@ -26,13 +24,6 @@ impl<'a> ClientPlatform<'a> { ) -> Result { get_user_api_key(self.client, &input).await } - - #[cfg(feature = "uniffi")] - pub fn fido2(&'a self) -> ClientFido2<'a> { - ClientFido2 { - client: self.client, - } - } } impl<'a> Client { diff --git a/crates/bitwarden/src/platform/generate_fingerprint.rs b/crates/bitwarden-core/src/platform/generate_fingerprint.rs similarity index 96% rename from crates/bitwarden/src/platform/generate_fingerprint.rs rename to crates/bitwarden-core/src/platform/generate_fingerprint.rs index 521a75c01..6ac41e149 100644 --- a/crates/bitwarden/src/platform/generate_fingerprint.rs +++ b/crates/bitwarden-core/src/platform/generate_fingerprint.rs @@ -38,7 +38,7 @@ pub(crate) fn generate_user_fingerprint( ) -> Result { info!("Generating fingerprint"); - let enc_settings = client.get_encryption_settings()?; + let enc_settings = client.internal.get_encryption_settings()?; let private_key = enc_settings .private_key .as_ref() @@ -54,8 +54,10 @@ pub(crate) fn generate_user_fingerprint( mod tests { use std::num::NonZeroU32; + use bitwarden_crypto::Kdf; + use super::*; - use crate::{client::Kdf, Client}; + use crate::Client; #[test] fn test_generate_user_fingerprint() { @@ -75,6 +77,7 @@ mod tests { .unwrap(); client + .internal .initialize_user_crypto_master_key( master_key, user_key.parse().unwrap(), diff --git a/crates/bitwarden/src/platform/get_user_api_key.rs b/crates/bitwarden-core/src/platform/get_user_api_key.rs similarity index 90% rename from crates/bitwarden/src/platform/get_user_api_key.rs rename to crates/bitwarden-core/src/platform/get_user_api_key.rs index 991040aaf..dcdafa0b4 100644 --- a/crates/bitwarden/src/platform/get_user_api_key.rs +++ b/crates/bitwarden-core/src/platform/get_user_api_key.rs @@ -4,7 +4,6 @@ use bitwarden_api_api::{ apis::accounts_api::accounts_api_key_post, models::{ApiKeyResponseModel, SecretVerificationRequestModel}, }; -use bitwarden_core::require; use bitwarden_crypto::{HashPurpose, MasterKey}; use log::{debug, info}; use schemars::JsonSchema; @@ -14,7 +13,7 @@ use super::SecretVerificationRequest; use crate::{ client::{LoginMethod, UserLoginMethod}, error::{Error, Result}, - Client, + require, Client, }; pub(crate) async fn get_user_api_key( @@ -27,15 +26,18 @@ pub(crate) async fn get_user_api_key( let auth_settings = get_login_method(client)?; let request = get_secret_verification_request(&auth_settings, input)?; - let config = client.get_api_configurations().await; + let config = client.internal.get_api_configurations().await; let response = accounts_api_key_post(&config.api, Some(request)).await?; UserApiKeyResponse::process_response(response) } fn get_login_method(client: &Client) -> Result> { - if client.is_authed() { - client.get_login_method().ok_or(Error::NotAuthenticated) + if client.internal.is_authed() { + client + .internal + .get_login_method() + .ok_or(Error::NotAuthenticated) } else { Err(Error::NotAuthenticated) } diff --git a/crates/bitwarden/src/platform/mod.rs b/crates/bitwarden-core/src/platform/mod.rs similarity index 63% rename from crates/bitwarden/src/platform/mod.rs rename to crates/bitwarden-core/src/platform/mod.rs index 82d341e6e..031554be0 100644 --- a/crates/bitwarden/src/platform/mod.rs +++ b/crates/bitwarden-core/src/platform/mod.rs @@ -1,5 +1,3 @@ -#[cfg(feature = "uniffi")] -pub mod client_fido; pub mod client_platform; mod generate_fingerprint; mod get_user_api_key; @@ -9,10 +7,3 @@ pub use generate_fingerprint::{FingerprintRequest, FingerprintResponse}; pub(crate) use get_user_api_key::get_user_api_key; pub use get_user_api_key::UserApiKeyResponse; pub use secret_verification_request::SecretVerificationRequest; - -#[cfg(feature = "uniffi")] -pub mod fido2 { - pub use bitwarden_fido::*; - - pub use super::client_fido::DecryptFido2AutofillCredentialsError; -} diff --git a/crates/bitwarden/src/platform/secret_verification_request.rs b/crates/bitwarden-core/src/platform/secret_verification_request.rs similarity index 100% rename from crates/bitwarden/src/platform/secret_verification_request.rs rename to crates/bitwarden-core/src/platform/secret_verification_request.rs diff --git a/crates/bitwarden-core/src/secrets_manager/mod.rs b/crates/bitwarden-core/src/secrets_manager/mod.rs new file mode 100644 index 000000000..266c62acc --- /dev/null +++ b/crates/bitwarden-core/src/secrets_manager/mod.rs @@ -0,0 +1 @@ +pub mod state; diff --git a/crates/bitwarden/src/secrets_manager/state.rs b/crates/bitwarden-core/src/secrets_manager/state.rs similarity index 100% rename from crates/bitwarden/src/secrets_manager/state.rs rename to crates/bitwarden-core/src/secrets_manager/state.rs diff --git a/crates/bitwarden-core/src/uniffi_support.rs b/crates/bitwarden-core/src/uniffi_support.rs index 320df6cb5..fcdd2aa78 100644 --- a/crates/bitwarden-core/src/uniffi_support.rs +++ b/crates/bitwarden-core/src/uniffi_support.rs @@ -1,7 +1,18 @@ +use std::num::NonZeroU32; + +use bitwarden_crypto::{AsymmetricEncString, EncString}; use uuid::Uuid; use crate::UniffiCustomTypeConverter; +uniffi::ffi_converter_forward!(NonZeroU32, bitwarden_crypto::UniFfiTag, crate::UniFfiTag); +uniffi::ffi_converter_forward!(EncString, bitwarden_crypto::UniFfiTag, crate::UniFfiTag); +uniffi::ffi_converter_forward!( + AsymmetricEncString, + bitwarden_crypto::UniFfiTag, + crate::UniFfiTag +); + type DateTime = chrono::DateTime; uniffi::custom_type!(DateTime, std::time::SystemTime); diff --git a/crates/bitwarden/src/util.rs b/crates/bitwarden-core/src/util.rs similarity index 100% rename from crates/bitwarden/src/util.rs rename to crates/bitwarden-core/src/util.rs diff --git a/crates/bitwarden/tests/register.rs b/crates/bitwarden-core/tests/register.rs similarity index 97% rename from crates/bitwarden/tests/register.rs rename to crates/bitwarden-core/tests/register.rs index 6e5ea9336..34f61ca3c 100644 --- a/crates/bitwarden/tests/register.rs +++ b/crates/bitwarden-core/tests/register.rs @@ -4,7 +4,7 @@ async fn test_register_initialize_crypto() { use std::num::NonZeroU32; - use bitwarden::{ + use bitwarden_core::{ mobile::crypto::{InitUserCryptoMethod, InitUserCryptoRequest}, Client, }; diff --git a/crates/bitwarden-crypto/Cargo.toml b/crates/bitwarden-crypto/Cargo.toml index e03a8d5c1..9968460b8 100644 --- a/crates/bitwarden-crypto/Cargo.toml +++ b/crates/bitwarden-crypto/Cargo.toml @@ -25,7 +25,7 @@ argon2 = { version = ">=0.5.0, <0.6", features = [ "std", "zeroize", ], default-features = false } -base64 = ">=0.21.2, <0.23" +base64 = ">=0.22.1, <0.23" cbc = { version = ">=0.1.2, <0.2", features = ["alloc", "zeroize"] } generic-array = { version = ">=0.14.7, <1.0", features = ["zeroize"] } hkdf = ">=0.12.3, <0.13" diff --git a/crates/bitwarden-exporters/Cargo.toml b/crates/bitwarden-exporters/Cargo.toml index ac302526c..79e0abb22 100644 --- a/crates/bitwarden-exporters/Cargo.toml +++ b/crates/bitwarden-exporters/Cargo.toml @@ -14,8 +14,11 @@ repository.workspace = true license-file.workspace = true keywords.workspace = true +[features] +uniffi = ["dep:uniffi"] # Uniffi bindings + [dependencies] -base64 = ">=0.21.2, <0.23" +base64 = ">=0.22.1, <0.23" bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } bitwarden-vault = { workspace = true } @@ -25,9 +28,11 @@ chrono = { version = ">=0.4.26, <0.5", features = [ "std", ], default-features = false } csv = "1.3.0" +schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } serde_json = ">=1.0.96, <2.0" thiserror = ">=1.0.40, <2.0" +uniffi = { version = "=0.27.2", optional = true } uuid = { version = ">=1.3.3, <2.0", features = ["serde", "v4"] } [lints] diff --git a/crates/bitwarden/src/tool/exporters/client_exporter.rs b/crates/bitwarden-exporters/src/client_exporter.rs similarity index 52% rename from crates/bitwarden/src/tool/exporters/client_exporter.rs rename to crates/bitwarden-exporters/src/client_exporter.rs index 5257538cd..ffc9963c1 100644 --- a/crates/bitwarden/src/tool/exporters/client_exporter.rs +++ b/crates/bitwarden-exporters/src/client_exporter.rs @@ -1,23 +1,26 @@ +use bitwarden_core::Client; use bitwarden_vault::{Cipher, Collection, Folder}; use crate::{ - error::Result, - tool::exporters::{export_organization_vault, export_vault, ExportFormat}, - Client, + export::{export_organization_vault, export_vault}, + ExportError, ExportFormat, }; pub struct ClientExporters<'a> { - pub(crate) client: &'a crate::Client, + client: &'a Client, } impl<'a> ClientExporters<'a> { - /// **Draft:** Export the vault as a CSV, JSON, or encrypted JSON file. + fn new(client: &'a Client) -> Self { + Self { client } + } + pub fn export_vault( &self, folders: Vec, ciphers: Vec, format: ExportFormat, - ) -> Result { + ) -> Result { export_vault(self.client, folders, ciphers, format) } @@ -26,13 +29,17 @@ impl<'a> ClientExporters<'a> { collections: Vec, ciphers: Vec, format: ExportFormat, - ) -> Result { + ) -> Result { export_organization_vault(collections, ciphers, format) } } -impl<'a> Client { - pub fn exporters(&'a self) -> ClientExporters<'a> { - ClientExporters { client: self } +pub trait ClientExportersExt<'a> { + fn exporters(&'a self) -> ClientExporters<'a>; +} + +impl<'a> ClientExportersExt<'a> for Client { + fn exporters(&'a self) -> ClientExporters<'a> { + ClientExporters::new(self) } } diff --git a/crates/bitwarden-exporters/src/error.rs b/crates/bitwarden-exporters/src/error.rs new file mode 100644 index 000000000..d23819696 --- /dev/null +++ b/crates/bitwarden-exporters/src/error.rs @@ -0,0 +1,21 @@ +use thiserror::Error; + +#[derive(Error, Debug)] +pub enum ExportError { + #[error(transparent)] + MissingField(#[from] bitwarden_core::MissingFieldError), + #[error(transparent)] + VaultLocked(#[from] bitwarden_core::VaultLocked), + + #[error("CSV error: {0}")] + Csv(#[from] crate::csv::CsvError), + #[error("JSON error: {0}")] + Json(#[from] crate::json::JsonError), + #[error("Encrypted JSON error: {0}")] + EncryptedJsonError(#[from] crate::encrypted_json::EncryptedJsonError), + + #[error(transparent)] + BitwardenError(#[from] bitwarden_core::Error), + #[error(transparent)] + BitwardenCryptoError(#[from] bitwarden_crypto::CryptoError), +} diff --git a/crates/bitwarden-exporters/src/export.rs b/crates/bitwarden-exporters/src/export.rs new file mode 100644 index 000000000..0721ae11f --- /dev/null +++ b/crates/bitwarden-exporters/src/export.rs @@ -0,0 +1,43 @@ +use bitwarden_core::{Client, VaultLocked}; +use bitwarden_crypto::KeyDecryptable; +use bitwarden_vault::{Cipher, CipherView, Collection, Folder, FolderView}; + +use crate::{ + csv::export_csv, encrypted_json::export_encrypted_json, json::export_json, ExportError, + ExportFormat, +}; + +pub(crate) fn export_vault( + client: &Client, + folders: Vec, + ciphers: Vec, + format: ExportFormat, +) -> Result { + let enc = client.internal.get_encryption_settings()?; + let key = enc.get_key(&None).ok_or(VaultLocked)?; + + let folders: Vec = folders.decrypt_with_key(key)?; + let folders: Vec = folders.into_iter().flat_map(|f| f.try_into()).collect(); + + let ciphers: Vec = ciphers.decrypt_with_key(key)?; + let ciphers: Vec = ciphers.into_iter().flat_map(|c| c.try_into()).collect(); + + match format { + ExportFormat::Csv => Ok(export_csv(folders, ciphers)?), + ExportFormat::Json => Ok(export_json(folders, ciphers)?), + ExportFormat::EncryptedJson { password } => Ok(export_encrypted_json( + folders, + ciphers, + password, + client.internal.get_kdf()?, + )?), + } +} + +pub(crate) fn export_organization_vault( + _collections: Vec, + _ciphers: Vec, + _format: ExportFormat, +) -> Result { + todo!(); +} diff --git a/crates/bitwarden-exporters/src/lib.rs b/crates/bitwarden-exporters/src/lib.rs index e754a64d1..75b0503e2 100644 --- a/crates/bitwarden-exporters/src/lib.rs +++ b/crates/bitwarden-exporters/src/lib.rs @@ -1,22 +1,28 @@ use std::fmt; -use bitwarden_crypto::Kdf; use chrono::{DateTime, Utc}; -use thiserror::Error; +use schemars::JsonSchema; use uuid::Uuid; +#[cfg(feature = "uniffi")] +uniffi::setup_scaffolding!(); + +mod client_exporter; mod csv; -use crate::csv::export_csv; -mod json; -use json::export_json; mod encrypted_json; -use encrypted_json::export_encrypted_json; +mod json; mod models; - -pub enum Format { +pub use client_exporter::{ClientExporters, ClientExportersExt}; +mod error; +mod export; +pub use error::ExportError; + +#[derive(JsonSchema)] +#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))] +pub enum ExportFormat { Csv, Json, - EncryptedJson { password: String, kdf: Kdf }, + EncryptedJson { password: String }, } /// Export representation of a Bitwarden folder. @@ -126,27 +132,3 @@ pub struct Identity { pub passport_number: Option, pub license_number: Option, } - -#[derive(Error, Debug)] -pub enum ExportError { - #[error("CSV error: {0}")] - Csv(#[from] csv::CsvError), - #[error("JSON error: {0}")] - Json(#[from] json::JsonError), - #[error("Encrypted JSON error: {0}")] - EncryptedJsonError(#[from] encrypted_json::EncryptedJsonError), -} - -pub fn export( - folders: Vec, - ciphers: Vec, - format: Format, -) -> Result { - match format { - Format::Csv => Ok(export_csv(folders, ciphers)?), - Format::Json => Ok(export_json(folders, ciphers)?), - Format::EncryptedJson { password, kdf } => { - Ok(export_encrypted_json(folders, ciphers, password, kdf)?) - } - } -} diff --git a/crates/bitwarden/uniffi.toml b/crates/bitwarden-exporters/uniffi.toml similarity index 50% rename from crates/bitwarden/uniffi.toml rename to crates/bitwarden-exporters/uniffi.toml index c5fdba5c2..7a57dfabd 100644 --- a/crates/bitwarden/uniffi.toml +++ b/crates/bitwarden-exporters/uniffi.toml @@ -1,9 +1,9 @@ [bindings.kotlin] -package_name = "com.bitwarden.bitwarden" +package_name = "com.bitwarden.exporters" generate_immutable_records = true android = true [bindings.swift] -ffi_module_name = "BitwardenBitwardenFFI" -module_name = "BitwardenBitwarden" +ffi_module_name = "BitwardenExportersFFI" +module_name = "BitwardenExporters" generate_immutable_records = true diff --git a/crates/bitwarden-fido/Cargo.toml b/crates/bitwarden-fido/Cargo.toml index 3e02f544c..12c2b6b1d 100644 --- a/crates/bitwarden-fido/Cargo.toml +++ b/crates/bitwarden-fido/Cargo.toml @@ -14,11 +14,11 @@ license-file.workspace = true keywords.workspace = true [features] -uniffi = ["dep:uniffi"] +uniffi = ["dep:uniffi", "bitwarden-core/uniffi", "bitwarden-vault/uniffi"] [dependencies] async-trait = ">=0.1.80, <0.2" -base64 = ">=0.21.2, <0.23" +base64 = ">=0.22.1, <0.23" bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } bitwarden-vault = { workspace = true } diff --git a/crates/bitwarden-fido/src/authenticator.rs b/crates/bitwarden-fido/src/authenticator.rs index 41f5d5b45..e86812bd9 100644 --- a/crates/bitwarden-fido/src/authenticator.rs +++ b/crates/bitwarden-fido/src/authenticator.rs @@ -1,6 +1,6 @@ -use std::sync::{Arc, Mutex}; +use std::sync::Mutex; -use bitwarden_core::VaultLocked; +use bitwarden_core::{Client, VaultLocked}; use bitwarden_crypto::{CryptoError, KeyContainer, KeyEncryptable}; use bitwarden_vault::{CipherError, CipherView}; use itertools::Itertools; @@ -94,14 +94,8 @@ pub enum CredentialsForAutofillError { FromCipherViewError(#[from] Fido2CredentialAutofillViewError), } -/// Temporary trait for solving a circular dependency. When moving `Client` to `bitwarden-core` -/// remove this trait. -pub trait FidoEncryptionSettingStore: Send + Sync { - fn get_encryption_settings(&self) -> Result, VaultLocked>; -} - pub struct Fido2Authenticator<'a> { - pub client: &'a dyn FidoEncryptionSettingStore, + pub client: &'a Client, pub user_interface: &'a dyn Fido2UserInterface, pub credential_store: &'a dyn Fido2CredentialStore, @@ -111,7 +105,7 @@ pub struct Fido2Authenticator<'a> { impl<'a> Fido2Authenticator<'a> { pub fn new( - client: &'a dyn FidoEncryptionSettingStore, + client: &'a Client, user_interface: &'a dyn Fido2UserInterface, credential_store: &'a dyn Fido2CredentialStore, ) -> Fido2Authenticator<'a> { @@ -258,7 +252,7 @@ impl<'a> Fido2Authenticator<'a> { &mut self, rp_id: String, ) -> Result, SilentlyDiscoverCredentialsError> { - let enc = self.client.get_encryption_settings()?; + let enc = self.client.internal.get_encryption_settings()?; let result = self.credential_store.find_credentials(None, rp_id).await?; result @@ -277,7 +271,7 @@ impl<'a> Fido2Authenticator<'a> { pub async fn credentials_for_autofill( &mut self, ) -> Result, CredentialsForAutofillError> { - let enc = self.client.get_encryption_settings()?; + let enc = self.client.internal.get_encryption_settings()?; let all_credentials = self.credential_store.all_credentials().await?; all_credentials @@ -322,7 +316,7 @@ impl<'a> Fido2Authenticator<'a> { pub(super) fn get_selected_credential( &self, ) -> Result { - let enc = self.client.get_encryption_settings()?; + let enc = self.client.internal.get_encryption_settings()?; let cipher = self .selected_cipher @@ -385,7 +379,11 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { .find_credentials(ids, rp_id.to_string()) .await?; - let enc = this.authenticator.client.get_encryption_settings()?; + let enc = this + .authenticator + .client + .internal + .get_encryption_settings()?; // Remove any that don't have Fido2 credentials let creds: Vec<_> = ciphers @@ -461,7 +459,11 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { user: passkey::types::ctap2::make_credential::PublicKeyCredentialUserEntity, rp: passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, ) -> Result<(), InnerError> { - let enc = this.authenticator.client.get_encryption_settings()?; + let enc = this + .authenticator + .client + .internal + .get_encryption_settings()?; let cred = try_from_credential_full(cred, user, rp)?; @@ -529,7 +531,11 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { this: &mut CredentialStoreImpl<'_>, cred: Passkey, ) -> Result<(), InnerError> { - let enc = this.authenticator.client.get_encryption_settings()?; + let enc = this + .authenticator + .client + .internal + .get_encryption_settings()?; // Get the previously selected cipher and update the credential let selected = this.authenticator.get_selected_credential()?; diff --git a/crates/bitwarden/src/platform/client_fido.rs b/crates/bitwarden-fido/src/client_fido.rs similarity index 71% rename from crates/bitwarden/src/platform/client_fido.rs rename to crates/bitwarden-fido/src/client_fido.rs index 79164b48f..84b3de6a1 100644 --- a/crates/bitwarden/src/platform/client_fido.rs +++ b/crates/bitwarden-fido/src/client_fido.rs @@ -1,13 +1,11 @@ -use std::sync::Arc; - -use bitwarden_fido::{ - Fido2Authenticator, Fido2Client, Fido2CredentialAutofillView, Fido2CredentialStore, - Fido2UserInterface, FidoEncryptionSettingStore, -}; +use bitwarden_core::Client; use bitwarden_vault::CipherView; use thiserror::Error; -use crate::Client; +use crate::{ + Fido2Authenticator, Fido2Client, Fido2CredentialAutofillView, Fido2CredentialAutofillViewError, + Fido2CredentialStore, Fido2UserInterface, +}; pub struct ClientFido2<'a> { #[allow(dead_code)] @@ -19,18 +17,14 @@ pub enum DecryptFido2AutofillCredentialsError { #[error(transparent)] VaultLocked(#[from] bitwarden_core::VaultLocked), #[error(transparent)] - Fido2CredentialAutofillViewError(#[from] bitwarden_fido::Fido2CredentialAutofillViewError), + Fido2CredentialAutofillViewError(#[from] Fido2CredentialAutofillViewError), } -impl FidoEncryptionSettingStore for Client { - fn get_encryption_settings( - &self, - ) -> Result, bitwarden_core::VaultLocked> { - Ok(self.get_encryption_settings()?) +impl<'a> ClientFido2<'a> { + pub fn new(client: &'a Client) -> Self { + Self { client } } -} -impl<'a> ClientFido2<'a> { pub fn create_authenticator( &'a self, user_interface: &'a dyn Fido2UserInterface, @@ -53,7 +47,7 @@ impl<'a> ClientFido2<'a> { &'a self, cipher_view: CipherView, ) -> Result, DecryptFido2AutofillCredentialsError> { - let enc = self.client.get_encryption_settings()?; + let enc = self.client.internal.get_encryption_settings()?; Ok(Fido2CredentialAutofillView::from_cipher_view( &cipher_view, @@ -61,3 +55,13 @@ impl<'a> ClientFido2<'a> { )?) } } + +pub trait ClientFido2Ext<'a> { + fn fido2(&'a self) -> ClientFido2<'a>; +} + +impl<'a> ClientFido2Ext<'a> for Client { + fn fido2(&'a self) -> ClientFido2<'a> { + ClientFido2::new(self) + } +} diff --git a/crates/bitwarden-fido/src/lib.rs b/crates/bitwarden-fido/src/lib.rs index b572eef36..830b5cfdf 100644 --- a/crates/bitwarden-fido/src/lib.rs +++ b/crates/bitwarden-fido/src/lib.rs @@ -13,14 +13,16 @@ mod uniffi_support; mod authenticator; mod client; +mod client_fido; mod crypto; mod traits; mod types; pub use authenticator::{ - CredentialsForAutofillError, Fido2Authenticator, FidoEncryptionSettingStore, GetAssertionError, - MakeCredentialError, SilentlyDiscoverCredentialsError, + CredentialsForAutofillError, Fido2Authenticator, GetAssertionError, MakeCredentialError, + SilentlyDiscoverCredentialsError, }; pub use client::{Fido2Client, Fido2ClientError}; +pub use client_fido::{ClientFido2, ClientFido2Ext, DecryptFido2AutofillCredentialsError}; pub use passkey::authenticator::UIHint; use thiserror::Error; pub use traits::{ diff --git a/crates/bitwarden-generators/Cargo.toml b/crates/bitwarden-generators/Cargo.toml index 6934f681e..629722548 100644 --- a/crates/bitwarden-generators/Cargo.toml +++ b/crates/bitwarden-generators/Cargo.toml @@ -17,6 +17,7 @@ keywords.workspace = true uniffi = ["dep:uniffi"] # Uniffi bindings [dependencies] +bitwarden-core = { workspace = true, features = ["internal"] } bitwarden-crypto = { workspace = true } rand = ">=0.8.5, <0.9" reqwest = { version = ">=0.12.5, <0.13", features = [ diff --git a/crates/bitwarden/src/tool/client_generator.rs b/crates/bitwarden-generators/src/client_generator.rs similarity index 63% rename from crates/bitwarden/src/tool/client_generator.rs rename to crates/bitwarden-generators/src/client_generator.rs index fe5319fc7..e5bad6f29 100644 --- a/crates/bitwarden/src/tool/client_generator.rs +++ b/crates/bitwarden-generators/src/client_generator.rs @@ -1,16 +1,19 @@ -use bitwarden_generators::{passphrase, password, username}; +use bitwarden_core::Client; use crate::{ - error::Result, - generators::{PassphraseGeneratorRequest, PasswordGeneratorRequest, UsernameGeneratorRequest}, - Client, + passphrase, password, username, PassphraseError, PassphraseGeneratorRequest, PasswordError, + PasswordGeneratorRequest, UsernameError, UsernameGeneratorRequest, }; pub struct ClientGenerator<'a> { - pub(crate) client: &'a crate::Client, + client: &'a Client, } impl<'a> ClientGenerator<'a> { + fn new(client: &'a Client) -> Self { + Self { client } + } + /// Generates a random password. /// /// The character sets and password length can be customized using the `input` parameter. @@ -18,8 +21,10 @@ impl<'a> ClientGenerator<'a> { /// # Examples /// /// ``` - /// use bitwarden::{Client, generators::PasswordGeneratorRequest, error::Result}; - /// async fn test() -> Result<()> { + /// use bitwarden_core::Client; + /// use bitwarden_generators::{ClientGeneratorExt, PassphraseError, PasswordGeneratorRequest}; + /// + /// async fn test() -> Result<(), PassphraseError> { /// let input = PasswordGeneratorRequest { /// lowercase: true, /// uppercase: true, @@ -32,8 +37,8 @@ impl<'a> ClientGenerator<'a> { /// Ok(()) /// } /// ``` - pub fn password(&self, input: PasswordGeneratorRequest) -> Result { - Ok(password(input)?) + pub fn password(&self, input: PasswordGeneratorRequest) -> Result { + password(input) } /// Generates a random passphrase. @@ -46,8 +51,10 @@ impl<'a> ClientGenerator<'a> { /// # Examples /// /// ``` - /// use bitwarden::{Client, generators::PassphraseGeneratorRequest, error::Result}; - /// async fn test() -> Result<()> { + /// use bitwarden_core::Client; + /// use bitwarden_generators::{ClientGeneratorExt, PassphraseError, PassphraseGeneratorRequest}; + /// + /// async fn test() -> Result<(), PassphraseError> { /// let input = PassphraseGeneratorRequest { /// num_words: 4, /// ..Default::default() @@ -57,8 +64,8 @@ impl<'a> ClientGenerator<'a> { /// Ok(()) /// } /// ``` - pub fn passphrase(&self, input: PassphraseGeneratorRequest) -> Result { - Ok(passphrase(input)?) + pub fn passphrase(&self, input: PassphraseGeneratorRequest) -> Result { + passphrase(input) } /// Generates a random username. @@ -69,8 +76,10 @@ impl<'a> ClientGenerator<'a> { /// will use third-party services, which may require a specific setup or API key. /// /// ``` - /// use bitwarden::{Client, generators::{UsernameGeneratorRequest}, error::Result}; - /// async fn test() -> Result<()> { + /// use bitwarden_core::Client; + /// use bitwarden_generators::{ClientGeneratorExt, UsernameError, UsernameGeneratorRequest}; + /// + /// async fn test() -> Result<(), UsernameError> { /// let input = UsernameGeneratorRequest::Word { /// capitalize: true, /// include_number: true, @@ -80,13 +89,17 @@ impl<'a> ClientGenerator<'a> { /// Ok(()) /// } /// ``` - pub async fn username(&self, input: UsernameGeneratorRequest) -> Result { - Ok(username(input, self.client.get_http_client()).await?) + pub async fn username(&self, input: UsernameGeneratorRequest) -> Result { + username(input, self.client.internal.get_http_client()).await } } -impl<'a> Client { - pub fn generator(&'a self) -> ClientGenerator<'a> { - ClientGenerator { client: self } +pub trait ClientGeneratorExt<'a> { + fn generator(&'a self) -> ClientGenerator<'a>; +} + +impl<'a> ClientGeneratorExt<'a> for Client { + fn generator(&'a self) -> ClientGenerator<'a> { + ClientGenerator::new(self) } } diff --git a/crates/bitwarden-generators/src/lib.rs b/crates/bitwarden-generators/src/lib.rs index 2584382f1..0ebd20295 100644 --- a/crates/bitwarden-generators/src/lib.rs +++ b/crates/bitwarden-generators/src/lib.rs @@ -5,6 +5,8 @@ mod util; pub use password::{password, PasswordError, PasswordGeneratorRequest}; mod username; pub use username::{username, ForwarderServiceType, UsernameError, UsernameGeneratorRequest}; +mod client_generator; +pub use client_generator::{ClientGenerator, ClientGeneratorExt}; mod username_forwarders; #[cfg(feature = "uniffi")] diff --git a/crates/bitwarden-json/src/client.rs b/crates/bitwarden-json/src/client.rs index dd3469c45..536693663 100644 --- a/crates/bitwarden-json/src/client.rs +++ b/crates/bitwarden-json/src/client.rs @@ -1,3 +1,7 @@ +#[cfg(feature = "secrets")] +use bitwarden::secrets_manager::{ClientProjectsExt, ClientSecretsExt}; +#[cfg(feature = "internal")] +use bitwarden::vault::ClientVaultExt; use bitwarden::ClientSettings; #[cfg(feature = "secrets")] diff --git a/crates/bitwarden-send/Cargo.toml b/crates/bitwarden-send/Cargo.toml index 9646ddcd9..bae76a5bf 100644 --- a/crates/bitwarden-send/Cargo.toml +++ b/crates/bitwarden-send/Cargo.toml @@ -21,7 +21,7 @@ uniffi = [ ] # Uniffi bindings [dependencies] -base64 = ">=0.21.2, <0.23" +base64 = ">=0.22.1, <0.23" bitwarden-api-api = { workspace = true } bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } diff --git a/crates/bitwarden/src/mobile/tool/client_sends.rs b/crates/bitwarden-send/src/client_sends.rs similarity index 65% rename from crates/bitwarden/src/mobile/tool/client_sends.rs rename to crates/bitwarden-send/src/client_sends.rs index 38a7d072d..da1c527f0 100644 --- a/crates/bitwarden/src/mobile/tool/client_sends.rs +++ b/crates/bitwarden-send/src/client_sends.rs @@ -1,21 +1,21 @@ use std::path::Path; -use bitwarden_core::VaultLocked; +use bitwarden_core::{Client, Error, VaultLocked}; use bitwarden_crypto::{EncString, KeyDecryptable, KeyEncryptable}; -use crate::{ - error::Result, - tool::{Send, SendListView, SendView}, - Client, -}; +use crate::{Send, SendListView, SendView}; pub struct ClientSends<'a> { - pub(crate) client: &'a Client, + client: &'a Client, } impl<'a> ClientSends<'a> { - pub fn decrypt(&self, send: Send) -> Result { - let enc = self.client.get_encryption_settings()?; + fn new(client: &'a Client) -> Self { + Self { client } + } + + pub fn decrypt(&self, send: Send) -> Result { + let enc = self.client.internal.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(VaultLocked)?; let send_view = send.decrypt_with_key(key)?; @@ -23,8 +23,8 @@ impl<'a> ClientSends<'a> { Ok(send_view) } - pub fn decrypt_list(&self, sends: Vec) -> Result> { - let enc = self.client.get_encryption_settings()?; + pub fn decrypt_list(&self, sends: Vec) -> Result, Error> { + let enc = self.client.internal.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(VaultLocked)?; let send_views = sends.decrypt_with_key(key)?; @@ -37,15 +37,15 @@ impl<'a> ClientSends<'a> { send: Send, encrypted_file_path: &Path, decrypted_file_path: &Path, - ) -> Result<()> { + ) -> Result<(), Error> { let data = std::fs::read(encrypted_file_path)?; let decrypted = self.decrypt_buffer(send, &data)?; std::fs::write(decrypted_file_path, decrypted)?; Ok(()) } - pub fn decrypt_buffer(&self, send: Send, encrypted_buffer: &[u8]) -> Result> { - let enc = self.client.get_encryption_settings()?; + pub fn decrypt_buffer(&self, send: Send, encrypted_buffer: &[u8]) -> Result, Error> { + let enc = self.client.internal.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(VaultLocked)?; let key = Send::get_key(&send.key, key)?; @@ -53,8 +53,8 @@ impl<'a> ClientSends<'a> { Ok(buf.decrypt_with_key(&key)?) } - pub fn encrypt(&self, send_view: SendView) -> Result { - let enc = self.client.get_encryption_settings()?; + pub fn encrypt(&self, send_view: SendView) -> Result { + let enc = self.client.internal.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(VaultLocked)?; let send = send_view.encrypt_with_key(key)?; @@ -67,15 +67,15 @@ impl<'a> ClientSends<'a> { send: Send, decrypted_file_path: &Path, encrypted_file_path: &Path, - ) -> Result<()> { + ) -> Result<(), Error> { let data = std::fs::read(decrypted_file_path)?; let encrypted = self.encrypt_buffer(send, &data)?; std::fs::write(encrypted_file_path, encrypted)?; Ok(()) } - pub fn encrypt_buffer(&self, send: Send, buffer: &[u8]) -> Result> { - let enc = self.client.get_encryption_settings()?; + pub fn encrypt_buffer(&self, send: Send, buffer: &[u8]) -> Result, Error> { + let enc = self.client.internal.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(VaultLocked)?; let key = Send::get_key(&send.key, key)?; @@ -84,8 +84,12 @@ impl<'a> ClientSends<'a> { } } -impl<'a> Client { - pub fn sends(&'a self) -> ClientSends<'a> { - ClientSends { client: self } +pub trait ClientSendsExt<'a> { + fn sends(&'a self) -> ClientSends<'a>; +} + +impl<'a> ClientSendsExt<'a> for Client { + fn sends(&'a self) -> ClientSends<'a> { + ClientSends::new(self) } } diff --git a/crates/bitwarden-send/src/lib.rs b/crates/bitwarden-send/src/lib.rs index b2bbf6e86..e29d7305f 100644 --- a/crates/bitwarden-send/src/lib.rs +++ b/crates/bitwarden-send/src/lib.rs @@ -5,5 +5,7 @@ mod uniffi_support; mod error; pub use error::SendParseError; +mod client_sends; +pub use client_sends::{ClientSends, ClientSendsExt}; mod send; pub use send::{Send, SendListView, SendView}; diff --git a/crates/bitwarden-send/src/send.rs b/crates/bitwarden-send/src/send.rs index 0ada20147..452032cf6 100644 --- a/crates/bitwarden-send/src/send.rs +++ b/crates/bitwarden-send/src/send.rs @@ -15,7 +15,7 @@ use serde_repr::{Deserialize_repr, Serialize_repr}; use uuid::Uuid; use zeroize::Zeroizing; -use crate::error::SendParseError; +use crate::SendParseError; const SEND_ITERATIONS: u32 = 100_000; diff --git a/crates/bitwarden-sm/Cargo.toml b/crates/bitwarden-sm/Cargo.toml new file mode 100644 index 000000000..6580dcf0f --- /dev/null +++ b/crates/bitwarden-sm/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "bitwarden-sm" +description = """ +Internal crate for the bitwarden crate. Do not use. +""" + +version.workspace = true +authors.workspace = true +edition.workspace = true +rust-version.workspace = true +homepage.workspace = true +repository.workspace = true +license-file.workspace = true +keywords.workspace = true + +[dependencies] +bitwarden-api-api = { workspace = true } +bitwarden-core = { workspace = true } +bitwarden-crypto = { workspace = true } +chrono = { version = ">=0.4.26, <0.5", features = [ + "clock", + "serde", +], default-features = false } +schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } +serde = { version = ">=1.0, <2.0", features = ["derive"] } +serde_json = ">=1.0.96, <2.0" +thiserror = ">=1.0.40, <2.0" +uniffi = { version = "=0.27.2", optional = true } +uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } + +[lints] +workspace = true diff --git a/crates/bitwarden-sm/src/client_projects.rs b/crates/bitwarden-sm/src/client_projects.rs new file mode 100644 index 000000000..13b2c6967 --- /dev/null +++ b/crates/bitwarden-sm/src/client_projects.rs @@ -0,0 +1,50 @@ +use bitwarden_core::{Client, Error}; + +use crate::projects::{ + create_project, delete_projects, get_project, list_projects, update_project, + ProjectCreateRequest, ProjectGetRequest, ProjectPutRequest, ProjectResponse, + ProjectsDeleteRequest, ProjectsDeleteResponse, ProjectsListRequest, ProjectsResponse, +}; + +pub struct ClientProjects<'a> { + pub client: &'a Client, +} + +impl<'a> ClientProjects<'a> { + pub fn new(client: &'a Client) -> Self { + Self { client } + } + + pub async fn get(&self, input: &ProjectGetRequest) -> Result { + get_project(self.client, input).await + } + + pub async fn create(&self, input: &ProjectCreateRequest) -> Result { + create_project(self.client, input).await + } + + pub async fn list(&self, input: &ProjectsListRequest) -> Result { + list_projects(self.client, input).await + } + + pub async fn update(&self, input: &ProjectPutRequest) -> Result { + update_project(self.client, input).await + } + + pub async fn delete( + &self, + input: ProjectsDeleteRequest, + ) -> Result { + delete_projects(self.client, input).await + } +} + +pub trait ClientProjectsExt<'a> { + fn projects(&'a self) -> ClientProjects<'a>; +} + +impl<'a> ClientProjectsExt<'a> for Client { + fn projects(&'a self) -> ClientProjects<'a> { + ClientProjects::new(self) + } +} diff --git a/crates/bitwarden-sm/src/client_secrets.rs b/crates/bitwarden-sm/src/client_secrets.rs new file mode 100644 index 000000000..2b1085a0a --- /dev/null +++ b/crates/bitwarden-sm/src/client_secrets.rs @@ -0,0 +1,70 @@ +use bitwarden_core::{Client, Error}; + +use crate::secrets::{ + create_secret, delete_secrets, get_secret, get_secrets_by_ids, list_secrets, + list_secrets_by_project, sync_secrets, update_secret, SecretCreateRequest, SecretGetRequest, + SecretIdentifiersByProjectRequest, SecretIdentifiersRequest, SecretIdentifiersResponse, + SecretPutRequest, SecretResponse, SecretsDeleteRequest, SecretsDeleteResponse, + SecretsGetRequest, SecretsResponse, SecretsSyncRequest, SecretsSyncResponse, +}; + +pub struct ClientSecrets<'a> { + client: &'a Client, +} + +impl<'a> ClientSecrets<'a> { + pub fn new(client: &'a Client) -> Self { + Self { client } + } + + pub async fn get(&self, input: &SecretGetRequest) -> Result { + get_secret(self.client, input).await + } + + pub async fn get_by_ids(&self, input: SecretsGetRequest) -> Result { + get_secrets_by_ids(self.client, input).await + } + + pub async fn create(&self, input: &SecretCreateRequest) -> Result { + create_secret(self.client, input).await + } + + pub async fn list( + &self, + input: &SecretIdentifiersRequest, + ) -> Result { + list_secrets(self.client, input).await + } + + pub async fn list_by_project( + &self, + input: &SecretIdentifiersByProjectRequest, + ) -> Result { + list_secrets_by_project(self.client, input).await + } + + pub async fn update(&self, input: &SecretPutRequest) -> Result { + update_secret(self.client, input).await + } + + pub async fn delete( + &self, + input: SecretsDeleteRequest, + ) -> Result { + delete_secrets(self.client, input).await + } + + pub async fn sync(&self, input: &SecretsSyncRequest) -> Result { + sync_secrets(self.client, input).await + } +} + +pub trait ClientSecretsExt<'a> { + fn secrets(&'a self) -> ClientSecrets<'a>; +} + +impl<'a> ClientSecretsExt<'a> for Client { + fn secrets(&'a self) -> ClientSecrets<'a> { + ClientSecrets::new(self) + } +} diff --git a/crates/bitwarden-sm/src/lib.rs b/crates/bitwarden-sm/src/lib.rs new file mode 100644 index 000000000..6f44bd16d --- /dev/null +++ b/crates/bitwarden-sm/src/lib.rs @@ -0,0 +1,7 @@ +mod client_projects; +mod client_secrets; +pub mod projects; +pub mod secrets; + +pub use client_projects::{ClientProjects, ClientProjectsExt}; +pub use client_secrets::{ClientSecrets, ClientSecretsExt}; diff --git a/crates/bitwarden/src/secrets_manager/projects/create.rs b/crates/bitwarden-sm/src/projects/create.rs similarity index 82% rename from crates/bitwarden/src/secrets_manager/projects/create.rs rename to crates/bitwarden-sm/src/projects/create.rs index 824a9f3df..bacec3cef 100644 --- a/crates/bitwarden/src/secrets_manager/projects/create.rs +++ b/crates/bitwarden-sm/src/projects/create.rs @@ -1,12 +1,11 @@ use bitwarden_api_api::models::ProjectCreateRequestModel; -use bitwarden_core::VaultLocked; +use bitwarden_core::{Client, Error, VaultLocked}; use bitwarden_crypto::KeyEncryptable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; use super::ProjectResponse; -use crate::{client::Client, error::Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -20,8 +19,8 @@ pub struct ProjectCreateRequest { pub(crate) async fn create_project( client: &Client, input: &ProjectCreateRequest, -) -> Result { - let enc = client.get_encryption_settings()?; +) -> Result { + let enc = client.internal.get_encryption_settings()?; let key = enc .get_key(&Some(input.organization_id)) .ok_or(VaultLocked)?; @@ -30,7 +29,7 @@ pub(crate) async fn create_project( name: input.name.clone().encrypt_with_key(key)?.to_string(), }); - let config = client.get_api_configurations().await; + let config = client.internal.get_api_configurations().await; let res = bitwarden_api_api::apis::projects_api::organizations_organization_id_projects_post( &config.api, input.organization_id, diff --git a/crates/bitwarden/src/secrets_manager/projects/delete.rs b/crates/bitwarden-sm/src/projects/delete.rs similarity index 86% rename from crates/bitwarden/src/secrets_manager/projects/delete.rs rename to crates/bitwarden-sm/src/projects/delete.rs index 644666e35..27e7f83e7 100644 --- a/crates/bitwarden/src/secrets_manager/projects/delete.rs +++ b/crates/bitwarden-sm/src/projects/delete.rs @@ -1,13 +1,11 @@ use bitwarden_api_api::models::{ BulkDeleteResponseModel, BulkDeleteResponseModelListResponseModel, }; -use bitwarden_core::require; +use bitwarden_core::{client::Client, require, Error}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; -use crate::{client::Client, error::Result}; - #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct ProjectsDeleteRequest { @@ -18,8 +16,8 @@ pub struct ProjectsDeleteRequest { pub(crate) async fn delete_projects( client: &Client, input: ProjectsDeleteRequest, -) -> Result { - let config = client.get_api_configurations().await; +) -> Result { + let config = client.internal.get_api_configurations().await; let res = bitwarden_api_api::apis::projects_api::projects_delete_post(&config.api, Some(input.ids)) .await?; @@ -36,7 +34,7 @@ pub struct ProjectsDeleteResponse { impl ProjectsDeleteResponse { pub(crate) fn process_response( response: BulkDeleteResponseModelListResponseModel, - ) -> Result { + ) -> Result { Ok(ProjectsDeleteResponse { data: response .data @@ -58,7 +56,7 @@ pub struct ProjectDeleteResponse { impl ProjectDeleteResponse { pub(crate) fn process_response( response: BulkDeleteResponseModel, - ) -> Result { + ) -> Result { Ok(ProjectDeleteResponse { id: require!(response.id), error: response.error, diff --git a/crates/bitwarden/src/secrets_manager/projects/get.rs b/crates/bitwarden-sm/src/projects/get.rs similarity index 72% rename from crates/bitwarden/src/secrets_manager/projects/get.rs rename to crates/bitwarden-sm/src/projects/get.rs index 9eaf9f104..81a669739 100644 --- a/crates/bitwarden/src/secrets_manager/projects/get.rs +++ b/crates/bitwarden-sm/src/projects/get.rs @@ -1,9 +1,9 @@ +use bitwarden_core::{client::Client, Error}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; use super::ProjectResponse; -use crate::{client::Client, error::Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -15,12 +15,12 @@ pub struct ProjectGetRequest { pub(crate) async fn get_project( client: &Client, input: &ProjectGetRequest, -) -> Result { - let config = client.get_api_configurations().await; +) -> Result { + let config = client.internal.get_api_configurations().await; let res = bitwarden_api_api::apis::projects_api::projects_id_get(&config.api, input.id).await?; - let enc = client.get_encryption_settings()?; + let enc = client.internal.get_encryption_settings()?; ProjectResponse::process_response(res, &enc) } diff --git a/crates/bitwarden/src/secrets_manager/projects/list.rs b/crates/bitwarden-sm/src/projects/list.rs similarity index 85% rename from crates/bitwarden/src/secrets_manager/projects/list.rs rename to crates/bitwarden-sm/src/projects/list.rs index 4cb50b7a7..334e06007 100644 --- a/crates/bitwarden/src/secrets_manager/projects/list.rs +++ b/crates/bitwarden-sm/src/projects/list.rs @@ -1,13 +1,13 @@ use bitwarden_api_api::models::ProjectResponseModelListResponseModel; +use bitwarden_core::{ + client::{encryption_settings::EncryptionSettings, Client}, + Error, +}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; use super::ProjectResponse; -use crate::{ - client::{encryption_settings::EncryptionSettings, Client}, - error::Result, -}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -19,15 +19,15 @@ pub struct ProjectsListRequest { pub(crate) async fn list_projects( client: &Client, input: &ProjectsListRequest, -) -> Result { - let config = client.get_api_configurations().await; +) -> Result { + let config = client.internal.get_api_configurations().await; let res = bitwarden_api_api::apis::projects_api::organizations_organization_id_projects_get( &config.api, input.organization_id, ) .await?; - let enc = client.get_encryption_settings()?; + let enc = client.internal.get_encryption_settings()?; ProjectsResponse::process_response(res, &enc) } @@ -42,7 +42,7 @@ impl ProjectsResponse { pub(crate) fn process_response( response: ProjectResponseModelListResponseModel, enc: &EncryptionSettings, - ) -> Result { + ) -> Result { let data = response.data.unwrap_or_default(); Ok(ProjectsResponse { diff --git a/crates/bitwarden/src/secrets_manager/projects/mod.rs b/crates/bitwarden-sm/src/projects/mod.rs similarity index 100% rename from crates/bitwarden/src/secrets_manager/projects/mod.rs rename to crates/bitwarden-sm/src/projects/mod.rs diff --git a/crates/bitwarden/src/secrets_manager/projects/project_response.rs b/crates/bitwarden-sm/src/projects/project_response.rs similarity index 90% rename from crates/bitwarden/src/secrets_manager/projects/project_response.rs rename to crates/bitwarden-sm/src/projects/project_response.rs index e8cac63fd..b0ad1728f 100644 --- a/crates/bitwarden/src/secrets_manager/projects/project_response.rs +++ b/crates/bitwarden-sm/src/projects/project_response.rs @@ -1,13 +1,11 @@ use bitwarden_api_api::models::ProjectResponseModel; -use bitwarden_core::require; +use bitwarden_core::{client::encryption_settings::EncryptionSettings, require, Error}; use bitwarden_crypto::{CryptoError, EncString, KeyDecryptable}; use chrono::{DateTime, Utc}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; -use crate::{client::encryption_settings::EncryptionSettings, error::Result}; - #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct ProjectResponse { @@ -22,7 +20,7 @@ impl ProjectResponse { pub(crate) fn process_response( response: ProjectResponseModel, enc: &EncryptionSettings, - ) -> Result { + ) -> Result { let organization_id = require!(response.organization_id); let enc_key = enc .get_key(&Some(organization_id)) diff --git a/crates/bitwarden/src/secrets_manager/projects/update.rs b/crates/bitwarden-sm/src/projects/update.rs similarity index 82% rename from crates/bitwarden/src/secrets_manager/projects/update.rs rename to crates/bitwarden-sm/src/projects/update.rs index 1a6e963c0..759edff99 100644 --- a/crates/bitwarden/src/secrets_manager/projects/update.rs +++ b/crates/bitwarden-sm/src/projects/update.rs @@ -1,12 +1,11 @@ use bitwarden_api_api::models::ProjectUpdateRequestModel; -use bitwarden_core::VaultLocked; +use bitwarden_core::{client::Client, Error, VaultLocked}; use bitwarden_crypto::KeyEncryptable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; use super::ProjectResponse; -use crate::{client::Client, error::Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -22,8 +21,8 @@ pub struct ProjectPutRequest { pub(crate) async fn update_project( client: &Client, input: &ProjectPutRequest, -) -> Result { - let enc = client.get_encryption_settings()?; +) -> Result { + let enc = client.internal.get_encryption_settings()?; let key = enc .get_key(&Some(input.organization_id)) .ok_or(VaultLocked)?; @@ -32,7 +31,7 @@ pub(crate) async fn update_project( name: input.name.clone().encrypt_with_key(key)?.to_string(), }); - let config = client.get_api_configurations().await; + let config = client.internal.get_api_configurations().await; let res = bitwarden_api_api::apis::projects_api::projects_id_put(&config.api, input.id, project) .await?; diff --git a/crates/bitwarden/src/secrets_manager/secrets/create.rs b/crates/bitwarden-sm/src/secrets/create.rs similarity index 86% rename from crates/bitwarden/src/secrets_manager/secrets/create.rs rename to crates/bitwarden-sm/src/secrets/create.rs index a3124e657..3e83d390d 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/create.rs +++ b/crates/bitwarden-sm/src/secrets/create.rs @@ -1,12 +1,11 @@ use bitwarden_api_api::models::SecretCreateRequestModel; -use bitwarden_core::VaultLocked; +use bitwarden_core::{Client, Error, VaultLocked}; use bitwarden_crypto::KeyEncryptable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; use super::SecretResponse; -use crate::{error::Result, Client}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -25,8 +24,8 @@ pub struct SecretCreateRequest { pub(crate) async fn create_secret( client: &Client, input: &SecretCreateRequest, -) -> Result { - let enc = client.get_encryption_settings()?; +) -> Result { + let enc = client.internal.get_encryption_settings()?; let key = enc .get_key(&Some(input.organization_id)) .ok_or(VaultLocked)?; @@ -38,7 +37,7 @@ pub(crate) async fn create_secret( project_ids: input.project_ids.clone(), }); - let config = client.get_api_configurations().await; + let config = client.internal.get_api_configurations().await; let res = bitwarden_api_api::apis::secrets_api::organizations_organization_id_secrets_post( &config.api, input.organization_id, diff --git a/crates/bitwarden/src/secrets_manager/secrets/delete.rs b/crates/bitwarden-sm/src/secrets/delete.rs similarity index 86% rename from crates/bitwarden/src/secrets_manager/secrets/delete.rs rename to crates/bitwarden-sm/src/secrets/delete.rs index fa019c731..377d19f62 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/delete.rs +++ b/crates/bitwarden-sm/src/secrets/delete.rs @@ -1,13 +1,11 @@ use bitwarden_api_api::models::{ BulkDeleteResponseModel, BulkDeleteResponseModelListResponseModel, }; -use bitwarden_core::require; +use bitwarden_core::{client::Client, require, Error}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; -use crate::{client::Client, error::Result}; - #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct SecretsDeleteRequest { @@ -18,8 +16,8 @@ pub struct SecretsDeleteRequest { pub(crate) async fn delete_secrets( client: &Client, input: SecretsDeleteRequest, -) -> Result { - let config = client.get_api_configurations().await; +) -> Result { + let config = client.internal.get_api_configurations().await; let res = bitwarden_api_api::apis::secrets_api::secrets_delete_post(&config.api, Some(input.ids)) .await?; @@ -36,7 +34,7 @@ pub struct SecretsDeleteResponse { impl SecretsDeleteResponse { pub(crate) fn process_response( response: BulkDeleteResponseModelListResponseModel, - ) -> Result { + ) -> Result { Ok(SecretsDeleteResponse { data: response .data @@ -58,7 +56,7 @@ pub struct SecretDeleteResponse { impl SecretDeleteResponse { pub(crate) fn process_response( response: BulkDeleteResponseModel, - ) -> Result { + ) -> Result { Ok(SecretDeleteResponse { id: require!(response.id), error: response.error, diff --git a/crates/bitwarden/src/secrets_manager/secrets/get.rs b/crates/bitwarden-sm/src/secrets/get.rs similarity index 73% rename from crates/bitwarden/src/secrets_manager/secrets/get.rs rename to crates/bitwarden-sm/src/secrets/get.rs index a9d285aa7..d0964df2e 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/get.rs +++ b/crates/bitwarden-sm/src/secrets/get.rs @@ -1,9 +1,9 @@ +use bitwarden_core::{Client, Error}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; use super::SecretResponse; -use crate::{error::Result, Client}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -15,11 +15,11 @@ pub struct SecretGetRequest { pub(crate) async fn get_secret( client: &Client, input: &SecretGetRequest, -) -> Result { - let config = client.get_api_configurations().await; +) -> Result { + let config = client.internal.get_api_configurations().await; let res = bitwarden_api_api::apis::secrets_api::secrets_id_get(&config.api, input.id).await?; - let enc = client.get_encryption_settings()?; + let enc = client.internal.get_encryption_settings()?; SecretResponse::process_response(res, &enc) } diff --git a/crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs b/crates/bitwarden-sm/src/secrets/get_by_ids.rs similarity index 77% rename from crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs rename to crates/bitwarden-sm/src/secrets/get_by_ids.rs index 6ce3eeac8..b5714c4b7 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/get_by_ids.rs +++ b/crates/bitwarden-sm/src/secrets/get_by_ids.rs @@ -1,10 +1,10 @@ use bitwarden_api_api::models::GetSecretsRequestModel; +use bitwarden_core::{client::Client, Error}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; use super::SecretsResponse; -use crate::{client::Client, error::Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -16,15 +16,15 @@ pub struct SecretsGetRequest { pub(crate) async fn get_secrets_by_ids( client: &Client, input: SecretsGetRequest, -) -> Result { +) -> Result { let request = Some(GetSecretsRequestModel { ids: input.ids }); - let config = client.get_api_configurations().await; + let config = client.internal.get_api_configurations().await; let res = bitwarden_api_api::apis::secrets_api::secrets_get_by_ids_post(&config.api, request).await?; - let enc = client.get_encryption_settings()?; + let enc = client.internal.get_encryption_settings()?; SecretsResponse::process_response(res, &enc) } diff --git a/crates/bitwarden/src/secrets_manager/secrets/list.rs b/crates/bitwarden-sm/src/secrets/list.rs similarity index 85% rename from crates/bitwarden/src/secrets_manager/secrets/list.rs rename to crates/bitwarden-sm/src/secrets/list.rs index 3d7af09df..9de4b9a47 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/list.rs +++ b/crates/bitwarden-sm/src/secrets/list.rs @@ -1,17 +1,15 @@ use bitwarden_api_api::models::{ SecretWithProjectsListResponseModel, SecretsWithProjectsInnerSecret, }; -use bitwarden_core::require; +use bitwarden_core::{ + client::{encryption_settings::EncryptionSettings, Client}, + require, Error, +}; use bitwarden_crypto::{CryptoError, EncString, KeyDecryptable}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; -use crate::{ - client::{encryption_settings::EncryptionSettings, Client}, - error::Result, -}; - #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct SecretIdentifiersRequest { @@ -22,15 +20,15 @@ pub struct SecretIdentifiersRequest { pub(crate) async fn list_secrets( client: &Client, input: &SecretIdentifiersRequest, -) -> Result { - let config = client.get_api_configurations().await; +) -> Result { + let config = client.internal.get_api_configurations().await; let res = bitwarden_api_api::apis::secrets_api::organizations_organization_id_secrets_get( &config.api, input.organization_id, ) .await?; - let enc = client.get_encryption_settings()?; + let enc = client.internal.get_encryption_settings()?; SecretIdentifiersResponse::process_response(res, &enc) } @@ -45,15 +43,15 @@ pub struct SecretIdentifiersByProjectRequest { pub(crate) async fn list_secrets_by_project( client: &Client, input: &SecretIdentifiersByProjectRequest, -) -> Result { - let config = client.get_api_configurations().await; +) -> Result { + let config = client.internal.get_api_configurations().await; let res = bitwarden_api_api::apis::secrets_api::projects_project_id_secrets_get( &config.api, input.project_id, ) .await?; - let enc = client.get_encryption_settings()?; + let enc = client.internal.get_encryption_settings()?; SecretIdentifiersResponse::process_response(res, &enc) } @@ -68,7 +66,7 @@ impl SecretIdentifiersResponse { pub(crate) fn process_response( response: SecretWithProjectsListResponseModel, enc: &EncryptionSettings, - ) -> Result { + ) -> Result { Ok(SecretIdentifiersResponse { data: response .secrets @@ -93,7 +91,7 @@ impl SecretIdentifierResponse { pub(crate) fn process_response( response: SecretsWithProjectsInnerSecret, enc: &EncryptionSettings, - ) -> Result { + ) -> Result { let organization_id = require!(response.organization_id); let enc_key = enc .get_key(&Some(organization_id)) diff --git a/crates/bitwarden/src/secrets_manager/secrets/mod.rs b/crates/bitwarden-sm/src/secrets/mod.rs similarity index 100% rename from crates/bitwarden/src/secrets_manager/secrets/mod.rs rename to crates/bitwarden-sm/src/secrets/mod.rs diff --git a/crates/bitwarden/src/secrets_manager/secrets/secret_response.rs b/crates/bitwarden-sm/src/secrets/secret_response.rs similarity index 93% rename from crates/bitwarden/src/secrets_manager/secrets/secret_response.rs rename to crates/bitwarden-sm/src/secrets/secret_response.rs index 4f306078d..138279b11 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/secret_response.rs +++ b/crates/bitwarden-sm/src/secrets/secret_response.rs @@ -1,15 +1,13 @@ use bitwarden_api_api::models::{ BaseSecretResponseModel, BaseSecretResponseModelListResponseModel, SecretResponseModel, }; -use bitwarden_core::require; +use bitwarden_core::{client::encryption_settings::EncryptionSettings, require, Error}; use bitwarden_crypto::{CryptoError, EncString, KeyDecryptable}; use chrono::{DateTime, Utc}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; -use crate::{client::encryption_settings::EncryptionSettings, error::Result}; - #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct SecretResponse { @@ -29,7 +27,7 @@ impl SecretResponse { pub(crate) fn process_response( response: SecretResponseModel, enc: &EncryptionSettings, - ) -> Result { + ) -> Result { let base = BaseSecretResponseModel { object: response.object, id: response.id, @@ -46,7 +44,7 @@ impl SecretResponse { pub(crate) fn process_base_response( response: BaseSecretResponseModel, enc: &EncryptionSettings, - ) -> Result { + ) -> Result { let org_id = response.organization_id; let enc_key = enc.get_key(&org_id).ok_or(CryptoError::MissingKey)?; @@ -89,7 +87,7 @@ impl SecretsResponse { pub(crate) fn process_response( response: BaseSecretResponseModelListResponseModel, enc: &EncryptionSettings, - ) -> Result { + ) -> Result { Ok(SecretsResponse { data: response .data diff --git a/crates/bitwarden/src/secrets_manager/secrets/sync.rs b/crates/bitwarden-sm/src/secrets/sync.rs similarity index 86% rename from crates/bitwarden/src/secrets_manager/secrets/sync.rs rename to crates/bitwarden-sm/src/secrets/sync.rs index 804daa5bf..9c922a002 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/sync.rs +++ b/crates/bitwarden-sm/src/secrets/sync.rs @@ -1,12 +1,11 @@ use bitwarden_api_api::models::SecretsSyncResponseModel; -use bitwarden_core::require; +use bitwarden_core::{client::encryption_settings::EncryptionSettings, require, Client, Error}; use chrono::{DateTime, Utc}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; use super::SecretResponse; -use crate::{client::encryption_settings::EncryptionSettings, error::Result, Client}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -20,8 +19,8 @@ pub struct SecretsSyncRequest { pub(crate) async fn sync_secrets( client: &Client, input: &SecretsSyncRequest, -) -> Result { - let config = client.get_api_configurations().await; +) -> Result { + let config = client.internal.get_api_configurations().await; let last_synced_date = input.last_synced_date.map(|date| date.to_rfc3339()); let res = bitwarden_api_api::apis::secrets_api::organizations_organization_id_secrets_sync_get( @@ -31,7 +30,7 @@ pub(crate) async fn sync_secrets( ) .await?; - let enc = client.get_encryption_settings()?; + let enc = client.internal.get_encryption_settings()?; SecretsSyncResponse::process_response(res, &enc) } @@ -47,7 +46,7 @@ impl SecretsSyncResponse { pub(crate) fn process_response( response: SecretsSyncResponseModel, enc: &EncryptionSettings, - ) -> Result { + ) -> Result { let has_changes = require!(response.has_changes); if has_changes { diff --git a/crates/bitwarden/src/secrets_manager/secrets/update.rs b/crates/bitwarden-sm/src/secrets/update.rs similarity index 85% rename from crates/bitwarden/src/secrets_manager/secrets/update.rs rename to crates/bitwarden-sm/src/secrets/update.rs index 8d29927e8..00f1ed2a4 100644 --- a/crates/bitwarden/src/secrets_manager/secrets/update.rs +++ b/crates/bitwarden-sm/src/secrets/update.rs @@ -1,12 +1,11 @@ use bitwarden_api_api::models::SecretUpdateRequestModel; -use bitwarden_core::VaultLocked; +use bitwarden_core::{client::Client, Error, VaultLocked}; use bitwarden_crypto::KeyEncryptable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; use super::SecretResponse; -use crate::{client::Client, error::Result}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -25,8 +24,9 @@ pub struct SecretPutRequest { pub(crate) async fn update_secret( client: &Client, input: &SecretPutRequest, -) -> Result { - let enc = client.get_encryption_settings()?; +) -> Result { + let enc = client.internal.get_encryption_settings()?; + let key = enc .get_key(&Some(input.organization_id)) .ok_or(VaultLocked)?; @@ -38,7 +38,7 @@ pub(crate) async fn update_secret( project_ids: input.project_ids.clone(), }); - let config = client.get_api_configurations().await; + let config = client.internal.get_api_configurations().await; let res = bitwarden_api_api::apis::secrets_api::secrets_id_put(&config.api, input.id, secret).await?; diff --git a/crates/bitwarden-uniffi/Cargo.toml b/crates/bitwarden-uniffi/Cargo.toml index f5c1230c0..2b2ecd11e 100644 --- a/crates/bitwarden-uniffi/Cargo.toml +++ b/crates/bitwarden-uniffi/Cargo.toml @@ -22,6 +22,7 @@ async-trait = "0.1.80" bitwarden = { workspace = true, features = ["internal", "uniffi"] } bitwarden-core = { workspace = true, features = ["uniffi"] } bitwarden-crypto = { workspace = true, features = ["uniffi"] } +bitwarden-exporters = { workspace = true, features = ["uniffi"] } bitwarden-fido = { workspace = true, features = ["uniffi"] } bitwarden-generators = { workspace = true, features = ["uniffi"] } bitwarden-send = { workspace = true, features = ["uniffi"] } diff --git a/crates/bitwarden-uniffi/src/docs.rs b/crates/bitwarden-uniffi/src/docs.rs index 0569bbcb2..5edbc7144 100644 --- a/crates/bitwarden-uniffi/src/docs.rs +++ b/crates/bitwarden-uniffi/src/docs.rs @@ -1,9 +1,10 @@ use bitwarden::{ auth::password::MasterPasswordPolicyOptions, + exporters::ExportFormat, generators::{PassphraseGeneratorRequest, PasswordGeneratorRequest}, mobile::crypto::{InitOrgCryptoRequest, InitUserCryptoRequest}, platform::FingerprintRequest, - tool::{ExportFormat, Send, SendListView, SendView}, + send::{Send, SendListView, SendView}, vault::{Cipher, CipherView, Collection, Folder, FolderView, TotpResponse}, }; use bitwarden_crypto::{HashPurpose, Kdf}; diff --git a/crates/bitwarden-uniffi/src/error.rs b/crates/bitwarden-uniffi/src/error.rs index 5eef9bbd5..5a1dfe43a 100644 --- a/crates/bitwarden-uniffi/src/error.rs +++ b/crates/bitwarden-uniffi/src/error.rs @@ -8,6 +8,12 @@ pub enum BitwardenError { E(bitwarden::error::Error), } +impl From for BitwardenError { + fn from(e: bitwarden::Error) -> Self { + Self::E(e.into()) + } +} + impl From for BitwardenError { fn from(e: bitwarden::error::Error) -> Self { Self::E(e) diff --git a/crates/bitwarden-uniffi/src/platform/fido2.rs b/crates/bitwarden-uniffi/src/platform/fido2.rs index 7cc45a2cb..e5245faef 100644 --- a/crates/bitwarden-uniffi/src/platform/fido2.rs +++ b/crates/bitwarden-uniffi/src/platform/fido2.rs @@ -2,16 +2,16 @@ use std::sync::Arc; use bitwarden::{ error::Error, - platform::fido2::{ - CheckUserOptions, ClientData, Fido2CallbackError as BitFido2CallbackError, - Fido2CredentialAutofillView, GetAssertionRequest, GetAssertionResult, - MakeCredentialRequest, MakeCredentialResult, + fido::{ + CheckUserOptions, ClientData, ClientFido2Ext, Fido2CallbackError as BitFido2CallbackError, + GetAssertionRequest, GetAssertionResult, MakeCredentialRequest, MakeCredentialResult, PublicKeyCredentialAuthenticatorAssertionResponse, PublicKeyCredentialAuthenticatorAttestationResponse, PublicKeyCredentialRpEntity, PublicKeyCredentialUserEntity, }, vault::{Cipher, CipherView, Fido2CredentialNewView}, }; +use bitwarden_fido::Fido2CredentialAutofillView; use crate::{error::Result, Client}; @@ -51,7 +51,6 @@ impl ClientFido2 { let result = self .0 .0 - .platform() .fido2() .decrypt_fido2_autofill_credentials(cipher_view) .map_err(Error::DecryptFido2AutofillCredentialsError)?; @@ -73,8 +72,7 @@ impl ClientFido2Authenticator { &self, request: MakeCredentialRequest, ) -> Result { - let platform = self.0 .0.platform(); - let fido2 = platform.fido2(); + let fido2 = self.0 .0.fido2(); let ui = UniffiTraitBridge(self.1.as_ref()); let cs = UniffiTraitBridge(self.2.as_ref()); let mut auth = fido2.create_authenticator(&ui, &cs); @@ -87,8 +85,7 @@ impl ClientFido2Authenticator { } pub async fn get_assertion(&self, request: GetAssertionRequest) -> Result { - let platform = self.0 .0.platform(); - let fido2 = platform.fido2(); + let fido2 = self.0 .0.fido2(); let ui = UniffiTraitBridge(self.1.as_ref()); let cs = UniffiTraitBridge(self.2.as_ref()); let mut auth = fido2.create_authenticator(&ui, &cs); @@ -104,8 +101,8 @@ impl ClientFido2Authenticator { &self, rp_id: String, ) -> Result> { - let platform = self.0 .0.platform(); - let fido2 = platform.fido2(); + let fido2 = self.0 .0.fido2(); + let ui = UniffiTraitBridge(self.1.as_ref()); let cs = UniffiTraitBridge(self.2.as_ref()); let mut auth = fido2.create_authenticator(&ui, &cs); @@ -118,8 +115,7 @@ impl ClientFido2Authenticator { } pub async fn credentials_for_autofill(&self) -> Result> { - let platform = self.0 .0.platform(); - let fido2 = platform.fido2(); + let fido2 = self.0 .0.fido2(); let ui = UniffiTraitBridge(self.1.as_ref()); let cs = UniffiTraitBridge(self.2.as_ref()); let mut auth = fido2.create_authenticator(&ui, &cs); @@ -143,8 +139,7 @@ impl ClientFido2Client { request: String, client_data: ClientData, ) -> Result { - let platform = self.0 .0 .0.platform(); - let fido2 = platform.fido2(); + let fido2 = self.0 .0 .0.fido2(); let ui = UniffiTraitBridge(self.0 .1.as_ref()); let cs = UniffiTraitBridge(self.0 .2.as_ref()); let mut client = fido2.create_client(&ui, &cs); @@ -162,8 +157,7 @@ impl ClientFido2Client { request: String, client_data: ClientData, ) -> Result { - let platform = self.0 .0 .0.platform(); - let fido2 = platform.fido2(); + let fido2 = self.0 .0 .0.fido2(); let ui = UniffiTraitBridge(self.0 .1.as_ref()); let cs = UniffiTraitBridge(self.0 .2.as_ref()); let mut client = fido2.create_client(&ui, &cs); @@ -258,9 +252,7 @@ pub trait Fido2CredentialStore: Send + Sync { struct UniffiTraitBridge(T); #[async_trait::async_trait] -impl bitwarden::platform::fido2::Fido2CredentialStore - for UniffiTraitBridge<&dyn Fido2CredentialStore> -{ +impl bitwarden::fido::Fido2CredentialStore for UniffiTraitBridge<&dyn Fido2CredentialStore> { async fn find_credentials( &self, ids: Option>>, @@ -298,9 +290,9 @@ pub enum UIHint { RequestExistingCredential(CipherView), } -impl From> for UIHint { - fn from(hint: bitwarden::platform::fido2::UIHint<'_, CipherView>) -> Self { - use bitwarden::platform::fido2::UIHint as BWUIHint; +impl From> for UIHint { + fn from(hint: bitwarden::fido::UIHint<'_, CipherView>) -> Self { + use bitwarden::fido::UIHint as BWUIHint; match hint { BWUIHint::InformExcludedCredentialFound(cipher) => { UIHint::InformExcludedCredentialFound(cipher.clone()) @@ -325,16 +317,16 @@ impl From> for UIHint { } #[async_trait::async_trait] -impl bitwarden::platform::fido2::Fido2UserInterface for UniffiTraitBridge<&dyn Fido2UserInterface> { +impl bitwarden::fido::Fido2UserInterface for UniffiTraitBridge<&dyn Fido2UserInterface> { async fn check_user<'a>( &self, options: CheckUserOptions, - hint: bitwarden::platform::fido2::UIHint<'a, CipherView>, - ) -> Result { + hint: bitwarden::fido::UIHint<'a, CipherView>, + ) -> Result { self.0 .check_user(options.clone(), hint.into()) .await - .map(|r| bitwarden::platform::fido2::CheckUserResult { + .map(|r| bitwarden::fido::CheckUserResult { user_present: r.user_present, user_verified: r.user_verified, }) diff --git a/crates/bitwarden-uniffi/src/platform/mod.rs b/crates/bitwarden-uniffi/src/platform/mod.rs index fe7c401ee..63ff6e183 100644 --- a/crates/bitwarden-uniffi/src/platform/mod.rs +++ b/crates/bitwarden-uniffi/src/platform/mod.rs @@ -27,7 +27,7 @@ impl ClientPlatform { /// Load feature flags into the client pub fn load_flags(&self, flags: std::collections::HashMap) -> Result<()> { - self.0 .0.load_flags(flags); + self.0 .0.internal.load_flags(flags); Ok(()) } diff --git a/crates/bitwarden-uniffi/src/tool/mod.rs b/crates/bitwarden-uniffi/src/tool/mod.rs index a590b41a3..1fd439a4f 100644 --- a/crates/bitwarden-uniffi/src/tool/mod.rs +++ b/crates/bitwarden-uniffi/src/tool/mod.rs @@ -1,8 +1,12 @@ use std::sync::Arc; use bitwarden::{ - generators::{PassphraseGeneratorRequest, PasswordGeneratorRequest, UsernameGeneratorRequest}, - tool::ExportFormat, + error::Error, + exporters::{ClientExportersExt, ExportFormat}, + generators::{ + ClientGeneratorExt, PassphraseGeneratorRequest, PasswordGeneratorRequest, + UsernameGeneratorRequest, + }, vault::{Cipher, Collection, Folder}, }; @@ -18,17 +22,33 @@ pub struct ClientGenerators(pub(crate) Arc); impl ClientGenerators { /// **API Draft:** Generate Password pub fn password(&self, settings: PasswordGeneratorRequest) -> Result { - Ok(self.0 .0.generator().password(settings)?) + Ok(self + .0 + .0 + .generator() + .password(settings) + .map_err(Error::PasswordError)?) } /// **API Draft:** Generate Passphrase pub fn passphrase(&self, settings: PassphraseGeneratorRequest) -> Result { - Ok(self.0 .0.generator().passphrase(settings)?) + Ok(self + .0 + .0 + .generator() + .passphrase(settings) + .map_err(Error::PassphraseError)?) } /// **API Draft:** Generate Username pub async fn username(&self, settings: UsernameGeneratorRequest) -> Result { - Ok(self.0 .0.generator().username(settings).await?) + Ok(self + .0 + .0 + .generator() + .username(settings) + .await + .map_err(Error::UsernameError)?) } } @@ -48,7 +68,8 @@ impl ClientExporters { .0 .0 .exporters() - .export_vault(folders, ciphers, format)?) + .export_vault(folders, ciphers, format) + .map_err(Error::ExportError)?) } /// **API Draft:** Export organization vault @@ -62,6 +83,7 @@ impl ClientExporters { .0 .0 .exporters() - .export_organization_vault(collections, ciphers, format)?) + .export_organization_vault(collections, ciphers, format) + .map_err(Error::ExportError)?) } } diff --git a/crates/bitwarden-uniffi/src/tool/sends.rs b/crates/bitwarden-uniffi/src/tool/sends.rs index ac9482429..1d5a056a3 100644 --- a/crates/bitwarden-uniffi/src/tool/sends.rs +++ b/crates/bitwarden-uniffi/src/tool/sends.rs @@ -1,6 +1,6 @@ use std::{path::Path, sync::Arc}; -use bitwarden::tool::{Send, SendListView, SendView}; +use bitwarden::send::{ClientSendsExt, Send, SendListView, SendView}; use crate::{Client, Result}; diff --git a/crates/bitwarden-uniffi/src/vault/attachments.rs b/crates/bitwarden-uniffi/src/vault/attachments.rs index 0084029d2..e8bddd124 100644 --- a/crates/bitwarden-uniffi/src/vault/attachments.rs +++ b/crates/bitwarden-uniffi/src/vault/attachments.rs @@ -1,6 +1,8 @@ use std::{path::Path, sync::Arc}; -use bitwarden::vault::{Attachment, AttachmentEncryptResult, AttachmentView, Cipher}; +use bitwarden::vault::{ + Attachment, AttachmentEncryptResult, AttachmentView, Cipher, ClientVaultExt, +}; use crate::{Client, Result}; diff --git a/crates/bitwarden-uniffi/src/vault/ciphers.rs b/crates/bitwarden-uniffi/src/vault/ciphers.rs index 06ddd1df5..1195cf81a 100644 --- a/crates/bitwarden-uniffi/src/vault/ciphers.rs +++ b/crates/bitwarden-uniffi/src/vault/ciphers.rs @@ -1,6 +1,9 @@ use std::sync::Arc; -use bitwarden::vault::{Cipher, CipherListView, CipherView}; +use bitwarden::{ + error::Error, + vault::{Cipher, CipherListView, CipherView, ClientVaultExt}, +}; use bitwarden_vault::Fido2CredentialView; use uuid::Uuid; @@ -49,6 +52,7 @@ impl ClientCiphers { .0 .vault() .ciphers() - .move_to_organization(cipher, organization_id)?) + .move_to_organization(cipher, organization_id) + .map_err(Error::Cipher)?) } } diff --git a/crates/bitwarden-uniffi/src/vault/collections.rs b/crates/bitwarden-uniffi/src/vault/collections.rs index 47f84426b..84d928e64 100644 --- a/crates/bitwarden-uniffi/src/vault/collections.rs +++ b/crates/bitwarden-uniffi/src/vault/collections.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use bitwarden::vault::{Collection, CollectionView}; +use bitwarden::vault::{ClientVaultExt, Collection, CollectionView}; use crate::{Client, Result}; diff --git a/crates/bitwarden-uniffi/src/vault/folders.rs b/crates/bitwarden-uniffi/src/vault/folders.rs index 3fa5935b5..2efeb1f11 100644 --- a/crates/bitwarden-uniffi/src/vault/folders.rs +++ b/crates/bitwarden-uniffi/src/vault/folders.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use bitwarden::vault::{Folder, FolderView}; +use bitwarden::vault::{ClientVaultExt, Folder, FolderView}; use crate::{Client, Result}; diff --git a/crates/bitwarden-uniffi/src/vault/mod.rs b/crates/bitwarden-uniffi/src/vault/mod.rs index 5259bc2bd..5f4e80707 100644 --- a/crates/bitwarden-uniffi/src/vault/mod.rs +++ b/crates/bitwarden-uniffi/src/vault/mod.rs @@ -1,6 +1,9 @@ use std::sync::Arc; -use bitwarden::vault::TotpResponse; +use bitwarden::{ + error::Error, + vault::{ClientVaultExt, TotpResponse}, +}; use chrono::{DateTime, Utc}; use crate::{error::Result, Client}; @@ -48,6 +51,11 @@ impl ClientVault { /// - OTP Auth URI /// - Steam URI pub fn generate_totp(&self, key: String, time: Option>) -> Result { - Ok(self.0 .0.vault().generate_totp(key, time)?) + Ok(self + .0 + .0 + .vault() + .generate_totp(key, time) + .map_err(Error::Totp)?) } } diff --git a/crates/bitwarden-uniffi/src/vault/password_history.rs b/crates/bitwarden-uniffi/src/vault/password_history.rs index 12ef993be..3fa0fd3bc 100644 --- a/crates/bitwarden-uniffi/src/vault/password_history.rs +++ b/crates/bitwarden-uniffi/src/vault/password_history.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use bitwarden::vault::{PasswordHistory, PasswordHistoryView}; +use bitwarden::vault::{ClientVaultExt, PasswordHistory, PasswordHistoryView}; use crate::{Client, Result}; diff --git a/crates/bitwarden-vault/Cargo.toml b/crates/bitwarden-vault/Cargo.toml index 71fd2a5b7..e875e4c06 100644 --- a/crates/bitwarden-vault/Cargo.toml +++ b/crates/bitwarden-vault/Cargo.toml @@ -21,9 +21,9 @@ uniffi = [ ] # Uniffi bindings [dependencies] -base64 = ">=0.21.2, <0.23" +base64 = ">=0.22.1, <0.23" bitwarden-api-api = { workspace = true } -bitwarden-core = { workspace = true } +bitwarden-core = { workspace = true, features = ["internal"] } bitwarden-crypto = { workspace = true } chrono = { version = ">=0.4.26, <0.5", features = [ "clock", @@ -42,5 +42,8 @@ thiserror = ">=1.0.40, <2.0" uniffi = { version = "=0.27.2", optional = true } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } +[dev-dependencies] +tokio = { version = "1.36.0", features = ["rt", "macros"] } + [lints] workspace = true diff --git a/crates/bitwarden-vault/src/cipher/cipher.rs b/crates/bitwarden-vault/src/cipher/cipher.rs index 730b80339..c1e84638c 100644 --- a/crates/bitwarden-vault/src/cipher/cipher.rs +++ b/crates/bitwarden-vault/src/cipher/cipher.rs @@ -14,9 +14,12 @@ use uuid::Uuid; use super::{ attachment, card, field, identity, local_data::{LocalData, LocalDataView}, - login, secure_note, + secure_note, +}; +use crate::{ + password_history, Fido2CredentialFullView, Fido2CredentialView, Login, LoginView, + VaultParseError, }; -use crate::{password_history, Fido2CredentialFullView, Fido2CredentialView, VaultParseError}; #[derive(Debug, Error)] pub enum CipherError { @@ -65,7 +68,7 @@ pub struct Cipher { pub notes: Option, pub r#type: CipherType, - pub login: Option, + pub login: Option, pub identity: Option, pub card: Option, pub secure_note: Option, @@ -101,7 +104,7 @@ pub struct CipherView { pub notes: Option, pub r#type: CipherType, - pub login: Option, + pub login: Option, pub identity: Option, pub card: Option, pub secure_note: Option, @@ -606,14 +609,14 @@ mod tests { use std::collections::HashMap; use attachment::AttachmentView; - use login::Fido2Credential; use super::*; + use crate::Fido2Credential; fn generate_cipher() -> CipherView { CipherView { r#type: CipherType::Login, - login: Some(login::LoginView { + login: Some(LoginView { username: Some("test_username".to_string()), password: Some("test_password".to_string()), password_revision_date: None, diff --git a/crates/bitwarden/src/mobile/vault/client_totp.rs b/crates/bitwarden-vault/src/client_totp.rs similarity index 66% rename from crates/bitwarden/src/mobile/vault/client_totp.rs rename to crates/bitwarden-vault/src/client_totp.rs index b1e7747b3..da1329125 100644 --- a/crates/bitwarden/src/mobile/vault/client_totp.rs +++ b/crates/bitwarden-vault/src/client_totp.rs @@ -1,7 +1,6 @@ -use bitwarden_vault::{generate_totp, TotpResponse}; use chrono::{DateTime, Utc}; -use crate::{error::Result, vault::ClientVault}; +use crate::{generate_totp, ClientVault, TotpError, TotpResponse}; impl<'a> ClientVault<'a> { /// Generate a TOTP code from a provided key. @@ -14,7 +13,7 @@ impl<'a> ClientVault<'a> { &'a self, key: String, time: Option>, - ) -> Result { - Ok(generate_totp(key, time)?) + ) -> Result { + generate_totp(key, time) } } diff --git a/crates/bitwarden-vault/src/client_vault.rs b/crates/bitwarden-vault/src/client_vault.rs new file mode 100644 index 000000000..67f6792b9 --- /dev/null +++ b/crates/bitwarden-vault/src/client_vault.rs @@ -0,0 +1,30 @@ +use bitwarden_core::Client; + +use crate::{ + sync::{sync, SyncError}, + SyncRequest, SyncResponse, +}; + +pub struct ClientVault<'a> { + pub(crate) client: &'a Client, +} + +impl<'a> ClientVault<'a> { + pub fn new(client: &'a Client) -> Self { + Self { client } + } + + pub async fn sync(&self, input: &SyncRequest) -> Result { + sync(self.client, input).await + } +} + +pub trait ClientVaultExt<'a> { + fn vault(&'a self) -> ClientVault<'a>; +} + +impl<'a> ClientVaultExt<'a> for Client { + fn vault(&'a self) -> ClientVault<'a> { + ClientVault::new(self) + } +} diff --git a/crates/bitwarden-vault/src/lib.rs b/crates/bitwarden-vault/src/lib.rs index 1e5b5c5aa..8a65f021d 100644 --- a/crates/bitwarden-vault/src/lib.rs +++ b/crates/bitwarden-vault/src/lib.rs @@ -17,3 +17,9 @@ mod totp; pub use totp::{generate_totp, TotpError, TotpResponse}; mod error; pub use error::VaultParseError; +mod client_vault; +pub use client_vault::{ClientVault, ClientVaultExt}; +mod client_totp; +mod mobile; +mod sync; +pub use sync::{SyncRequest, SyncResponse}; diff --git a/crates/bitwarden/src/mobile/vault/client_attachments.rs b/crates/bitwarden-vault/src/mobile/client_attachments.rs similarity index 83% rename from crates/bitwarden/src/mobile/vault/client_attachments.rs rename to crates/bitwarden-vault/src/mobile/client_attachments.rs index 4140a4d88..f382075ec 100644 --- a/crates/bitwarden/src/mobile/vault/client_attachments.rs +++ b/crates/bitwarden-vault/src/mobile/client_attachments.rs @@ -1,15 +1,11 @@ use std::path::Path; -use bitwarden_core::VaultLocked; +use bitwarden_core::{Client, Error, VaultLocked}; use bitwarden_crypto::{EncString, KeyDecryptable, KeyEncryptable, LocateKey}; -use bitwarden_vault::{ - Attachment, AttachmentEncryptResult, AttachmentFile, AttachmentFileView, AttachmentView, Cipher, -}; use crate::{ - error::{Error, Result}, - vault::ClientVault, - Client, + Attachment, AttachmentEncryptResult, AttachmentFile, AttachmentFileView, AttachmentView, + Cipher, ClientVault, }; pub struct ClientAttachments<'a> { @@ -22,8 +18,8 @@ impl<'a> ClientAttachments<'a> { cipher: Cipher, attachment: AttachmentView, buffer: &[u8], - ) -> Result { - let enc = self.client.get_encryption_settings()?; + ) -> Result { + let enc = self.client.internal.get_encryption_settings()?; let key = cipher.locate_key(&enc, &None).ok_or(VaultLocked)?; Ok(AttachmentFileView { @@ -39,7 +35,7 @@ impl<'a> ClientAttachments<'a> { attachment: AttachmentView, decrypted_file_path: &Path, encrypted_file_path: &Path, - ) -> Result { + ) -> Result { let data = std::fs::read(decrypted_file_path)?; let AttachmentEncryptResult { attachment, @@ -54,8 +50,8 @@ impl<'a> ClientAttachments<'a> { cipher: Cipher, attachment: Attachment, encrypted_buffer: &[u8], - ) -> Result> { - let enc = self.client.get_encryption_settings()?; + ) -> Result, Error> { + let enc = self.client.internal.get_encryption_settings()?; let key = cipher.locate_key(&enc, &None).ok_or(VaultLocked)?; AttachmentFile { @@ -72,7 +68,7 @@ impl<'a> ClientAttachments<'a> { attachment: Attachment, encrypted_file_path: &Path, decrypted_file_path: &Path, - ) -> Result<()> { + ) -> Result<(), Error> { let data = std::fs::read(encrypted_file_path)?; let decrypted = self.decrypt_buffer(cipher, attachment, &data)?; std::fs::write(decrypted_file_path, decrypted)?; diff --git a/crates/bitwarden/src/mobile/vault/client_ciphers.rs b/crates/bitwarden-vault/src/mobile/client_ciphers.rs similarity index 89% rename from crates/bitwarden/src/mobile/vault/client_ciphers.rs rename to crates/bitwarden-vault/src/mobile/client_ciphers.rs index 2bf612b56..864af8b94 100644 --- a/crates/bitwarden/src/mobile/vault/client_ciphers.rs +++ b/crates/bitwarden-vault/src/mobile/client_ciphers.rs @@ -1,21 +1,26 @@ -use bitwarden_core::VaultLocked; +use bitwarden_core::{Client, Error, VaultLocked}; use bitwarden_crypto::{CryptoError, KeyDecryptable, KeyEncryptable, LocateKey}; -use bitwarden_vault::{Cipher, CipherListView, CipherView}; use uuid::Uuid; -use crate::{error::Result, vault::ClientVault, Client}; +use crate::{Cipher, CipherError, CipherListView, CipherView, ClientVault}; pub struct ClientCiphers<'a> { pub(crate) client: &'a Client, } impl<'a> ClientCiphers<'a> { - pub fn encrypt(&self, mut cipher_view: CipherView) -> Result { - let enc = self.client.get_encryption_settings()?; + pub fn encrypt(&self, mut cipher_view: CipherView) -> Result { + let enc = self.client.internal.get_encryption_settings()?; // TODO: Once this flag is removed, the key generation logic should // be moved directly into the KeyEncryptable implementation - if cipher_view.key.is_none() && self.client.get_flags().enable_cipher_key_encryption { + if cipher_view.key.is_none() + && self + .client + .internal + .get_flags() + .enable_cipher_key_encryption + { let key = cipher_view.locate_key(&enc, &None).ok_or(VaultLocked)?; cipher_view.generate_cipher_key(key)?; } @@ -26,8 +31,8 @@ impl<'a> ClientCiphers<'a> { Ok(cipher) } - pub fn decrypt(&self, cipher: Cipher) -> Result { - let enc = self.client.get_encryption_settings()?; + pub fn decrypt(&self, cipher: Cipher) -> Result { + let enc = self.client.internal.get_encryption_settings()?; let key = cipher .locate_key(&enc, &None) .ok_or(CryptoError::MissingKey)?; @@ -37,12 +42,12 @@ impl<'a> ClientCiphers<'a> { Ok(cipher_view) } - pub fn decrypt_list(&self, ciphers: Vec) -> Result> { - let enc = self.client.get_encryption_settings()?; + pub fn decrypt_list(&self, ciphers: Vec) -> Result, Error> { + let enc = self.client.internal.get_encryption_settings()?; - let cipher_views: Result> = ciphers + let cipher_views: Result, _> = ciphers .iter() - .map(|c| -> Result { + .map(|c| -> Result { let key = c.locate_key(&enc, &None).ok_or(CryptoError::MissingKey)?; Ok(c.decrypt_with_key(key)?) }) @@ -55,10 +60,12 @@ impl<'a> ClientCiphers<'a> { pub fn decrypt_fido2_credentials( &self, cipher_view: CipherView, - ) -> Result> { - let enc = self.client.get_encryption_settings()?; + ) -> Result, Error> { + let enc = self.client.internal.get_encryption_settings()?; - let credentials = cipher_view.decrypt_fido2_credentials(&enc)?; + let credentials = cipher_view + .decrypt_fido2_credentials(&enc) + .map_err(|e| e.to_string())?; Ok(credentials) } @@ -67,8 +74,8 @@ impl<'a> ClientCiphers<'a> { &self, mut cipher_view: CipherView, organization_id: Uuid, - ) -> Result { - let enc = self.client.get_encryption_settings()?; + ) -> Result { + let enc = self.client.internal.get_encryption_settings()?; cipher_view.move_to_organization(&enc, organization_id)?; Ok(cipher_view) } @@ -85,10 +92,10 @@ impl<'a> ClientVault<'a> { #[cfg(test)] mod tests { - use bitwarden_vault::{Attachment, CipherRepromptType, CipherType, Login}; + use bitwarden_core::client::test_accounts::test_bitwarden_com_account; use super::*; - use crate::client::test_accounts::test_bitwarden_com_account; + use crate::{Attachment, CipherRepromptType, CipherType, ClientVaultExt, Login}; #[tokio::test] async fn test_decrypt_list() { diff --git a/crates/bitwarden/src/mobile/vault/client_collection.rs b/crates/bitwarden-vault/src/mobile/client_collection.rs similarity index 81% rename from crates/bitwarden/src/mobile/vault/client_collection.rs rename to crates/bitwarden-vault/src/mobile/client_collection.rs index 09f1f3c6a..42cda4bc5 100644 --- a/crates/bitwarden/src/mobile/vault/client_collection.rs +++ b/crates/bitwarden-vault/src/mobile/client_collection.rs @@ -1,15 +1,15 @@ +use bitwarden_core::{Client, Error}; use bitwarden_crypto::{CryptoError, KeyDecryptable, LocateKey}; -use bitwarden_vault::{Collection, CollectionView}; -use crate::{error::Result, vault::ClientVault, Client}; +use crate::{ClientVault, Collection, CollectionView}; pub struct ClientCollections<'a> { pub(crate) client: &'a Client, } impl<'a> ClientCollections<'a> { - pub fn decrypt(&self, collection: Collection) -> Result { - let enc = self.client.get_encryption_settings()?; + pub fn decrypt(&self, collection: Collection) -> Result { + let enc = self.client.internal.get_encryption_settings()?; let key = collection .locate_key(&enc, &None) .ok_or(CryptoError::MissingKey)?; @@ -19,12 +19,12 @@ impl<'a> ClientCollections<'a> { Ok(view) } - pub fn decrypt_list(&self, collections: Vec) -> Result> { - let enc = self.client.get_encryption_settings()?; + pub fn decrypt_list(&self, collections: Vec) -> Result, Error> { + let enc = self.client.internal.get_encryption_settings()?; - let views: Result> = collections + let views: Result, _> = collections .iter() - .map(|c| -> Result { + .map(|c| -> Result { let key = c.locate_key(&enc, &None).ok_or(CryptoError::MissingKey)?; Ok(c.decrypt_with_key(key)?) }) @@ -44,9 +44,10 @@ impl<'a> ClientVault<'a> { #[cfg(test)] mod tests { - use bitwarden_vault::Collection; + use bitwarden_core::client::test_accounts::test_bitwarden_com_account; - use crate::{client::test_accounts::test_bitwarden_com_account, Client}; + use super::*; + use crate::ClientVaultExt; #[tokio::test] async fn test_decrypt_list() { diff --git a/crates/bitwarden/src/mobile/vault/client_folders.rs b/crates/bitwarden-vault/src/mobile/client_folders.rs similarity index 69% rename from crates/bitwarden/src/mobile/vault/client_folders.rs rename to crates/bitwarden-vault/src/mobile/client_folders.rs index 668125da2..93d89c4d6 100644 --- a/crates/bitwarden/src/mobile/vault/client_folders.rs +++ b/crates/bitwarden-vault/src/mobile/client_folders.rs @@ -1,15 +1,15 @@ +use bitwarden_core::{Client, Error}; use bitwarden_crypto::{CryptoError, KeyDecryptable, KeyEncryptable}; -use bitwarden_vault::{Folder, FolderView}; -use crate::{error::Result, vault::ClientVault, Client}; +use crate::{ClientVault, Folder, FolderView}; pub struct ClientFolders<'a> { pub(crate) client: &'a Client, } impl<'a> ClientFolders<'a> { - pub fn encrypt(&self, folder_view: FolderView) -> Result { - let enc = self.client.get_encryption_settings()?; + pub fn encrypt(&self, folder_view: FolderView) -> Result { + let enc = self.client.internal.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; let folder = folder_view.encrypt_with_key(key)?; @@ -17,8 +17,8 @@ impl<'a> ClientFolders<'a> { Ok(folder) } - pub fn decrypt(&self, folder: Folder) -> Result { - let enc = self.client.get_encryption_settings()?; + pub fn decrypt(&self, folder: Folder) -> Result { + let enc = self.client.internal.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; let folder_view = folder.decrypt_with_key(key)?; @@ -26,8 +26,8 @@ impl<'a> ClientFolders<'a> { Ok(folder_view) } - pub fn decrypt_list(&self, folders: Vec) -> Result> { - let enc = self.client.get_encryption_settings()?; + pub fn decrypt_list(&self, folders: Vec) -> Result, Error> { + let enc = self.client.internal.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; let views = folders.decrypt_with_key(key)?; diff --git a/crates/bitwarden/src/mobile/vault/client_password_history.rs b/crates/bitwarden-vault/src/mobile/client_password_history.rs similarity index 65% rename from crates/bitwarden/src/mobile/vault/client_password_history.rs rename to crates/bitwarden-vault/src/mobile/client_password_history.rs index db0f5fa53..8af07a120 100644 --- a/crates/bitwarden/src/mobile/vault/client_password_history.rs +++ b/crates/bitwarden-vault/src/mobile/client_password_history.rs @@ -1,15 +1,15 @@ +use bitwarden_core::{Client, Error}; use bitwarden_crypto::{CryptoError, KeyDecryptable, KeyEncryptable}; -use bitwarden_vault::{PasswordHistory, PasswordHistoryView}; -use crate::{error::Result, vault::ClientVault, Client}; +use crate::{ClientVault, PasswordHistory, PasswordHistoryView}; pub struct ClientPasswordHistory<'a> { pub(crate) client: &'a Client, } impl<'a> ClientPasswordHistory<'a> { - pub fn encrypt(&self, history_view: PasswordHistoryView) -> Result { - let enc = self.client.get_encryption_settings()?; + pub fn encrypt(&self, history_view: PasswordHistoryView) -> Result { + let enc = self.client.internal.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; let history = history_view.encrypt_with_key(key)?; @@ -17,8 +17,11 @@ impl<'a> ClientPasswordHistory<'a> { Ok(history) } - pub fn decrypt_list(&self, history: Vec) -> Result> { - let enc = self.client.get_encryption_settings()?; + pub fn decrypt_list( + &self, + history: Vec, + ) -> Result, Error> { + let enc = self.client.internal.get_encryption_settings()?; let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; let history_view = history.decrypt_with_key(key)?; diff --git a/crates/bitwarden-vault/src/mobile/mod.rs b/crates/bitwarden-vault/src/mobile/mod.rs new file mode 100644 index 000000000..59e28b6e8 --- /dev/null +++ b/crates/bitwarden-vault/src/mobile/mod.rs @@ -0,0 +1,5 @@ +mod client_attachments; +mod client_ciphers; +mod client_collection; +mod client_folders; +mod client_password_history; diff --git a/crates/bitwarden/src/vault/sync.rs b/crates/bitwarden-vault/src/sync.rs similarity index 76% rename from crates/bitwarden/src/vault/sync.rs rename to crates/bitwarden-vault/src/sync.rs index d751dbf6f..6b4845d35 100644 --- a/crates/bitwarden/src/vault/sync.rs +++ b/crates/bitwarden-vault/src/sync.rs @@ -1,17 +1,27 @@ use bitwarden_api_api::models::{ DomainsResponseModel, ProfileOrganizationResponseModel, ProfileResponseModel, SyncResponseModel, }; -use bitwarden_core::require; -use bitwarden_vault::{Cipher, Collection, Folder, GlobalDomains}; +use bitwarden_core::{ + client::encryption_settings::EncryptionSettings, require, Client, Error, MissingFieldError, +}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use thiserror::Error; use uuid::Uuid; -use crate::{ - admin_console::Policy, - client::{encryption_settings::EncryptionSettings, Client}, - error::{Error, Result}, -}; +use crate::{Cipher, Collection, Folder, GlobalDomains, VaultParseError}; + +#[derive(Debug, Error)] +pub enum SyncError { + #[error(transparent)] + Core(#[from] bitwarden_core::Error), + + #[error(transparent)] + MissingFieldError(#[from] MissingFieldError), + + #[error(transparent)] + VaultParse(#[from] VaultParseError), +} #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] @@ -20,10 +30,11 @@ pub struct SyncRequest { pub exclude_subdomains: Option, } -pub(crate) async fn sync(client: &Client, input: &SyncRequest) -> Result { - let config = client.get_api_configurations().await; - let sync = - bitwarden_api_api::apis::sync_api::sync_get(&config.api, input.exclude_subdomains).await?; +pub(crate) async fn sync(client: &Client, input: &SyncRequest) -> Result { + let config = client.internal.get_api_configurations().await; + let sync = bitwarden_api_api::apis::sync_api::sync_get(&config.api, input.exclude_subdomains) + .await + .map_err(|e| SyncError::Core(e.into()))?; let org_keys: Vec<_> = require!(sync.profile.as_ref()) .organizations @@ -33,7 +44,7 @@ pub(crate) async fn sync(client: &Client, input: &SyncRequest) -> Result, pub domains: Option, - pub policies: Vec, - pub sends: Vec, + //pub policies: Vec, + //pub sends: Vec, } impl SyncResponse { pub(crate) fn process_response( response: SyncResponseModel, enc: &EncryptionSettings, - ) -> Result { + ) -> Result { let profile = require!(response.profile); let ciphers = require!(response.ciphers); @@ -101,8 +112,8 @@ impl SyncResponse { collections: try_into_iter(require!(response.collections))?, ciphers: try_into_iter(ciphers)?, domains: response.domains.map(|d| (*d).try_into()).transpose()?, - policies: try_into_iter(require!(response.policies))?, - sends: try_into_iter(require!(response.sends))?, + //policies: try_into_iter(require!(response.policies))?, + //sends: try_into_iter(require!(response.sends))?, }) } } @@ -110,7 +121,7 @@ impl SyncResponse { impl ProfileOrganizationResponse { fn process_response( response: ProfileOrganizationResponseModel, - ) -> Result { + ) -> Result { Ok(ProfileOrganizationResponse { id: require!(response.id), }) @@ -121,7 +132,7 @@ impl ProfileResponse { fn process_response( response: ProfileResponseModel, _enc: &EncryptionSettings, - ) -> Result { + ) -> Result { Ok(ProfileResponse { id: require!(response.id), name: require!(response.name), @@ -139,7 +150,7 @@ impl ProfileResponse { } impl TryFrom for DomainResponse { - type Error = Error; + type Error = SyncError; fn try_from(value: DomainsResponseModel) -> Result { Ok(Self { @@ -148,8 +159,8 @@ impl TryFrom for DomainResponse { .global_equivalent_domains .unwrap_or_default() .into_iter() - .map(|s| s.try_into().map_err(Error::VaultParse)) - .collect::>>()?, + .map(|s| s.try_into()) + .collect::, _>>()?, }) } } diff --git a/crates/bitwarden-wasm/Cargo.toml b/crates/bitwarden-wasm/Cargo.toml index a4ba8b6ae..c4be614d3 100644 --- a/crates/bitwarden-wasm/Cargo.toml +++ b/crates/bitwarden-wasm/Cargo.toml @@ -34,5 +34,13 @@ wasm-bindgen-futures = "0.4.41" [dev-dependencies] wasm-bindgen-test = "0.3.41" +[target.'cfg(target_arch = "wasm32")'.dependencies] +chrono = { version = ">=0.4.26, <0.5", features = [ + "clock", + "serde", + "std", + "wasmbind", +], default-features = false } + [lints] workspace = true diff --git a/crates/bitwarden-wasm/build.sh b/crates/bitwarden-wasm/build.sh index ae32c775d..d49b12de3 100755 --- a/crates/bitwarden-wasm/build.sh +++ b/crates/bitwarden-wasm/build.sh @@ -4,12 +4,12 @@ cd ../../ if [ "$1" != "-r" ]; then # Dev - cargo build -p bitwarden -p bitwarden-wasm --target wasm32-unknown-unknown --features wasm-bindgen + cargo build -p bitwarden-wasm --target wasm32-unknown-unknown wasm-bindgen --target bundler --out-dir languages/js/wasm ./target/wasm32-unknown-unknown/debug/bitwarden_wasm.wasm wasm-bindgen --target nodejs --out-dir languages/js/wasm/node ./target/wasm32-unknown-unknown/debug/bitwarden_wasm.wasm else # Release - cargo build -p bitwarden -p bitwarden-wasm --target wasm32-unknown-unknown --features wasm-bindgen --release + cargo build -p bitwarden-wasm --target wasm32-unknown-unknown --release wasm-bindgen --target bundler --out-dir languages/js/wasm ./target/wasm32-unknown-unknown/release/bitwarden_wasm.wasm wasm-bindgen --target nodejs --out-dir languages/js/wasm/node ./target/wasm32-unknown-unknown/release/bitwarden_wasm.wasm fi diff --git a/crates/bitwarden/Cargo.toml b/crates/bitwarden/Cargo.toml index 783d5676d..3bd1f02fa 100644 --- a/crates/bitwarden/Cargo.toml +++ b/crates/bitwarden/Cargo.toml @@ -17,29 +17,27 @@ license-file.workspace = true default = ["secrets"] internal = [ + "bitwarden-core/internal", "dep:bitwarden-exporters", "dep:bitwarden-generators", "dep:bitwarden-send", "dep:bitwarden-vault", ] # Internal testing methods no-memory-hardening = [ - "bitwarden-crypto/no-memory-hardening", + "bitwarden-core/no-memory-hardening", ] # Disable memory hardening features uniffi = [ "bitwarden-core/uniffi", "bitwarden-crypto/uniffi", + "bitwarden-exporters/uniffi", + "bitwarden-fido/uniffi", "bitwarden-generators/uniffi", "bitwarden-send/uniffi", "bitwarden-vault/uniffi", - "bitwarden-fido/uniffi", - "dep:uniffi", ] # Uniffi bindings -secrets = [] # Secrets manager API -wasm-bindgen = ["chrono/wasmbind"] +secrets = ["bitwarden-core/secrets", "dep:bitwarden-sm"] # Secrets manager API [dependencies] -async-trait = ">=0.1.80, <0.2" -base64 = ">=0.21.2, <0.23" bitwarden-api-api = { workspace = true } bitwarden-api-identity = { workspace = true } bitwarden-core = { workspace = true } @@ -48,58 +46,12 @@ bitwarden-exporters = { workspace = true, optional = true } bitwarden-fido = { workspace = true, optional = true } bitwarden-generators = { workspace = true, optional = true } bitwarden-send = { workspace = true, optional = true } +bitwarden-sm = { workspace = true, optional = true } bitwarden-vault = { workspace = true, optional = true } -chrono = { version = ">=0.4.26, <0.5", features = [ - "clock", - "serde", - "std", -], default-features = false } -# 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"] } -log = ">=0.4.18, <0.5" -rand = ">=0.8.5, <0.9" -reqwest = { version = ">=0.12.5, <0.13", features = [ - "http2", - "json", -], default-features = false } -schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } -serde = { version = ">=1.0, <2.0", features = ["derive"] } -serde_json = ">=1.0.96, <2.0" -serde_qs = ">=0.12.0, <0.14" -serde_repr = ">=0.1.12, <0.2" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.27.2", optional = true, features = ["tokio"] } -uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } -zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } -zxcvbn = ">= 2.2.2, <3.0" - -[target.'cfg(all(not(target_os = "android"), not(target_arch="wasm32")))'.dependencies] -# By default, we use rustls as the TLS stack and rust-platform-verifier to support user-installed root certificates -# There are a few exceptions to this: -# - WASM doesn't require a TLS stack, as it just uses the browsers/node fetch -# - Android uses webpki-roots for the moment -reqwest = { version = ">=0.12.5, <0.13", features = [ - "rustls-tls-manual-roots", -], default-features = false } -rustls-platform-verifier = "0.3.1" - -[target.'cfg(target_os = "android")'.dependencies] -# On android, the use of rustls-platform-verifier is more complicated and going through some changes at the moment, so we fall back to using webpki-roots -# This means that for the moment android won't support self-signed certificates, even if they are included in the OS trust store -reqwest = { version = ">=0.12.5, <0.13", features = [ - "rustls-tls-webpki-roots", -], default-features = false } - -# This is a workaround to fix a bug with version 2.11.0 that added some symbols that are not available on iOS -# The bug is fixed already but the fix is not released yet. https://github.com/kornelski/rust-security-framework/pull/204 -[target.'cfg(target_os = "ios")'.dependencies] -security-framework = { version = "=2.10" } [dev-dependencies] -rand_chacha = "0.3.1" -tokio = { version = "1.36.0", features = ["rt", "macros"] } -wiremock = "0.6.0" -zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } +uuid = { version = ">=1.3.3, <2.0" } [lints] workspace = true diff --git a/crates/bitwarden/README.md b/crates/bitwarden/README.md index ed0139a65..b0364a19e 100644 --- a/crates/bitwarden/README.md +++ b/crates/bitwarden/README.md @@ -19,8 +19,10 @@ Rust **1.71** or higher. ```rust use bitwarden::{ - auth::login::AccessTokenLoginRequest, error::Result, - secrets_manager::secrets::SecretIdentifiersRequest, Client, ClientSettings, DeviceType, + auth::login::AccessTokenLoginRequest, + error::Result, + secrets_manager::{secrets::SecretIdentifiersRequest, ClientSecretsExt}, + Client, ClientSettings, DeviceType, }; use uuid::Uuid; diff --git a/crates/bitwarden/src/client/mod.rs b/crates/bitwarden/src/client/mod.rs deleted file mode 100644 index 1568152e4..000000000 --- a/crates/bitwarden/src/client/mod.rs +++ /dev/null @@ -1,17 +0,0 @@ -//! Bitwarden SDK Client - -pub(crate) use client::*; -#[allow(clippy::module_inception)] -mod client; -pub mod client_settings; -pub(crate) mod encryption_settings; - -#[cfg(feature = "internal")] -mod flags; - -pub use client::Client; -pub use client_settings::{ClientSettings, DeviceType}; - -#[cfg(feature = "internal")] -#[cfg(test)] -pub(crate) mod test_accounts; diff --git a/crates/bitwarden/src/error.rs b/crates/bitwarden/src/error.rs index 46f34404f..06ef09648 100644 --- a/crates/bitwarden/src/error.rs +++ b/crates/bitwarden/src/error.rs @@ -2,56 +2,16 @@ use std::{borrow::Cow, fmt::Debug}; -use bitwarden_api_api::apis::Error as ApiError; -use bitwarden_api_identity::apis::Error as IdentityError; #[cfg(feature = "internal")] use bitwarden_exporters::ExportError; #[cfg(feature = "internal")] use bitwarden_generators::{PassphraseError, PasswordError, UsernameError}; -use reqwest::StatusCode; use thiserror::Error; #[derive(Debug, Error)] pub enum Error { #[error(transparent)] - MissingFieldError(#[from] bitwarden_core::MissingFieldError), - #[error(transparent)] - VaultLocked(#[from] bitwarden_core::VaultLocked), - - #[error("The client is not authenticated or the session has expired")] - NotAuthenticated, - - #[error("Access token is not in a valid format: {0}")] - AccessTokenInvalid(#[from] AccessTokenInvalidError), - - #[error("The response received was invalid and could not be processed")] - InvalidResponse, - - #[error("Cryptography error, {0}")] - Crypto(#[from] bitwarden_crypto::CryptoError), - - #[error("Error parsing Identity response: {0}")] - IdentityFail(crate::auth::api::response::IdentityTokenFailResponse), - - #[error(transparent)] - Reqwest(#[from] reqwest::Error), - #[error(transparent)] - Serde(#[from] serde_json::Error), - #[error(transparent)] - Io(#[from] std::io::Error), - #[error(transparent)] - InvalidBase64(#[from] base64::DecodeError), - #[error(transparent)] - Chrono(#[from] chrono::ParseError), - - #[error("Received error message from server: [{}] {}", .status, .message)] - ResponseContent { status: StatusCode, message: String }, - - #[error("The state file version is invalid")] - InvalidStateFileVersion, - - #[error("The state file could not be read")] - InvalidStateFile, + Core(#[from] bitwarden_core::Error), // Generators #[cfg(feature = "internal")] @@ -64,20 +24,12 @@ pub enum Error { #[error(transparent)] PasswordError(#[from] PasswordError), - // Send - #[cfg(feature = "internal")] - #[error(transparent)] - SendParseError(#[from] bitwarden_send::SendParseError), - // Vault #[cfg(feature = "internal")] #[error(transparent)] Cipher(#[from] bitwarden_vault::CipherError), #[cfg(feature = "internal")] #[error(transparent)] - VaultParse(#[from] bitwarden_vault::VaultParseError), - #[cfg(feature = "internal")] - #[error(transparent)] Totp(#[from] bitwarden_vault::TotpError), #[cfg(feature = "internal")] @@ -100,18 +52,11 @@ pub enum Error { #[cfg(all(feature = "uniffi", feature = "internal"))] #[error(transparent)] DecryptFido2AutofillCredentialsError( - #[from] crate::platform::fido2::DecryptFido2AutofillCredentialsError, + #[from] bitwarden_fido::DecryptFido2AutofillCredentialsError, ), #[cfg(all(feature = "uniffi", feature = "internal"))] #[error(transparent)] Fido2Client(#[from] bitwarden_fido::Fido2ClientError), - #[cfg(all(feature = "uniffi", feature = "internal"))] - #[error("Fido2 Callback error: {0:?}")] - Fido2CallbackError(#[from] bitwarden_fido::Fido2CallbackError), - - #[cfg(feature = "uniffi")] - #[error("Uniffi callback error: {0}")] - UniffiCallbackError(#[from] uniffi::UnexpectedUniFFICallbackError), #[error("Internal error: {0}")] Internal(Cow<'static, str>), @@ -129,24 +74,6 @@ impl From<&'static str> for Error { } } -#[derive(Debug, Error)] -pub enum AccessTokenInvalidError { - #[error("Doesn't contain a decryption key")] - NoKey, - #[error("Has the wrong number of parts")] - WrongParts, - #[error("Is the wrong version")] - WrongVersion, - #[error("Has an invalid identifier")] - InvalidUuid, - - #[error("Error decoding base64: {0}")] - InvalidBase64(#[from] base64::DecodeError), - - #[error("Invalid base64 length: expected {expected}, got {got}")] - InvalidBase64Length { expected: usize, got: usize }, -} - // Ensure that the error messages implement Send and Sync #[cfg(test)] const _: () = { @@ -158,24 +85,4 @@ const _: () = { } }; -macro_rules! impl_bitwarden_error { - ($name:ident) => { - impl From<$name> for Error { - fn from(e: $name) -> Self { - match e { - $name::Reqwest(e) => Self::Reqwest(e), - $name::ResponseError(e) => Self::ResponseContent { - status: e.status, - message: e.content, - }, - $name::Serde(e) => Self::Serde(e), - $name::Io(e) => Self::Io(e), - } - } - } - }; -} -impl_bitwarden_error!(ApiError); -impl_bitwarden_error!(IdentityError); - pub type Result = std::result::Result; diff --git a/crates/bitwarden/src/lib.rs b/crates/bitwarden/src/lib.rs index b5506485f..40168761c 100644 --- a/crates/bitwarden/src/lib.rs +++ b/crates/bitwarden/src/lib.rs @@ -16,8 +16,10 @@ //! //! ```rust //! use bitwarden::{ -//! auth::login::AccessTokenLoginRequest, error::Result, -//! secrets_manager::secrets::SecretIdentifiersRequest, Client, ClientSettings, DeviceType, +//! auth::login::AccessTokenLoginRequest, +//! error::Result, +//! secrets_manager::{secrets::SecretIdentifiersRequest, ClientSecretsExt}, +//! Client, ClientSettings, DeviceType, //! }; //! use uuid::Uuid; //! @@ -56,35 +58,36 @@ #[doc = include_str!("../README.md")] mod readme {} -#[cfg(feature = "uniffi")] -uniffi::setup_scaffolding!(); - -#[cfg(feature = "internal")] -pub mod admin_console; -pub mod auth; -pub mod client; +pub use bitwarden_core::*; pub mod error; + #[cfg(feature = "internal")] -pub mod mobile; -#[cfg(feature = "internal")] -pub mod platform; -#[cfg(feature = "secrets")] -pub mod secrets_manager; -#[cfg(feature = "internal")] -pub mod tool; -#[cfg(feature = "uniffi")] -pub(crate) mod uniffi_support; -mod util; -#[cfg(feature = "internal")] -pub mod vault; +pub mod internal { + pub mod generators { + pub use bitwarden_generators::*; + } -pub use client::{Client, ClientSettings, DeviceType}; + pub mod exporters { + pub use bitwarden_exporters::*; + } -#[cfg(feature = "internal")] -pub mod generators { - pub use bitwarden_generators::{ - PassphraseGeneratorRequest, PasswordGeneratorRequest, UsernameGeneratorRequest, - }; + pub mod send { + pub use bitwarden_send::*; + } + + pub mod vault { + pub use bitwarden_vault::*; + } + + #[cfg(feature = "uniffi")] + pub mod fido { + pub use bitwarden_fido::*; + } } +#[cfg(feature = "internal")] +pub use internal::*; -pub use bitwarden_crypto::ZeroizingAllocator; +#[cfg(feature = "secrets")] +pub mod secrets_manager { + pub use bitwarden_sm::*; +} diff --git a/crates/bitwarden/src/mobile/tool/mod.rs b/crates/bitwarden/src/mobile/tool/mod.rs deleted file mode 100644 index 729697715..000000000 --- a/crates/bitwarden/src/mobile/tool/mod.rs +++ /dev/null @@ -1,2 +0,0 @@ -mod client_sends; -pub use client_sends::ClientSends; diff --git a/crates/bitwarden/src/mobile/vault/mod.rs b/crates/bitwarden/src/mobile/vault/mod.rs deleted file mode 100644 index 18b96eb50..000000000 --- a/crates/bitwarden/src/mobile/vault/mod.rs +++ /dev/null @@ -1,12 +0,0 @@ -mod client_attachments; -mod client_ciphers; -mod client_collection; -mod client_folders; -mod client_password_history; -mod client_totp; - -pub use client_attachments::ClientAttachments; -pub use client_ciphers::ClientCiphers; -pub use client_collection::ClientCollections; -pub use client_folders::ClientFolders; -pub use client_password_history::ClientPasswordHistory; diff --git a/crates/bitwarden/src/secrets_manager/client_projects.rs b/crates/bitwarden/src/secrets_manager/client_projects.rs deleted file mode 100644 index 5c8f3657a..000000000 --- a/crates/bitwarden/src/secrets_manager/client_projects.rs +++ /dev/null @@ -1,41 +0,0 @@ -use crate::{ - error::Result, - secrets_manager::projects::{ - create_project, delete_projects, get_project, list_projects, update_project, - ProjectCreateRequest, ProjectGetRequest, ProjectPutRequest, ProjectResponse, - ProjectsDeleteRequest, ProjectsDeleteResponse, ProjectsListRequest, ProjectsResponse, - }, - Client, -}; - -pub struct ClientProjects<'a> { - pub(crate) client: &'a crate::Client, -} - -impl<'a> ClientProjects<'a> { - pub async fn get(&self, input: &ProjectGetRequest) -> Result { - get_project(self.client, input).await - } - - pub async fn create(&self, input: &ProjectCreateRequest) -> Result { - create_project(self.client, input).await - } - - pub async fn list(&self, input: &ProjectsListRequest) -> Result { - list_projects(self.client, input).await - } - - pub async fn update(&self, input: &ProjectPutRequest) -> Result { - update_project(self.client, input).await - } - - pub async fn delete(&self, input: ProjectsDeleteRequest) -> Result { - delete_projects(self.client, input).await - } -} - -impl<'a> Client { - pub fn projects(&'a self) -> ClientProjects<'a> { - ClientProjects { client: self } - } -} diff --git a/crates/bitwarden/src/secrets_manager/client_secrets.rs b/crates/bitwarden/src/secrets_manager/client_secrets.rs deleted file mode 100644 index 1050c95d8..000000000 --- a/crates/bitwarden/src/secrets_manager/client_secrets.rs +++ /dev/null @@ -1,62 +0,0 @@ -use crate::{ - error::Result, - secrets_manager::secrets::{ - create_secret, delete_secrets, get_secret, get_secrets_by_ids, list_secrets, - list_secrets_by_project, sync_secrets, update_secret, SecretCreateRequest, - SecretGetRequest, SecretIdentifiersByProjectRequest, SecretIdentifiersRequest, - SecretIdentifiersResponse, SecretPutRequest, SecretResponse, SecretsDeleteRequest, - SecretsDeleteResponse, SecretsGetRequest, SecretsResponse, SecretsSyncRequest, - SecretsSyncResponse, - }, - Client, -}; - -pub struct ClientSecrets<'a> { - pub(crate) client: &'a crate::Client, -} - -impl<'a> ClientSecrets<'a> { - pub async fn get(&self, input: &SecretGetRequest) -> Result { - get_secret(self.client, input).await - } - - pub async fn get_by_ids(&self, input: SecretsGetRequest) -> Result { - get_secrets_by_ids(self.client, input).await - } - - pub async fn create(&self, input: &SecretCreateRequest) -> Result { - create_secret(self.client, input).await - } - - pub async fn list( - &self, - input: &SecretIdentifiersRequest, - ) -> Result { - list_secrets(self.client, input).await - } - - pub async fn list_by_project( - &self, - input: &SecretIdentifiersByProjectRequest, - ) -> Result { - list_secrets_by_project(self.client, input).await - } - - pub async fn update(&self, input: &SecretPutRequest) -> Result { - update_secret(self.client, input).await - } - - pub async fn delete(&self, input: SecretsDeleteRequest) -> Result { - delete_secrets(self.client, input).await - } - - pub async fn sync(&self, input: &SecretsSyncRequest) -> Result { - sync_secrets(self.client, input).await - } -} - -impl<'a> Client { - pub fn secrets(&'a self) -> ClientSecrets<'a> { - ClientSecrets { client: self } - } -} diff --git a/crates/bitwarden/src/secrets_manager/mod.rs b/crates/bitwarden/src/secrets_manager/mod.rs deleted file mode 100644 index 181edf6b6..000000000 --- a/crates/bitwarden/src/secrets_manager/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub mod projects; -pub mod secrets; -pub mod state; - -mod client_projects; -mod client_secrets; - -pub use client_projects::ClientProjects; -pub use client_secrets::ClientSecrets; diff --git a/crates/bitwarden/src/tool/exporters/mod.rs b/crates/bitwarden/src/tool/exporters/mod.rs deleted file mode 100644 index 0c87bc558..000000000 --- a/crates/bitwarden/src/tool/exporters/mod.rs +++ /dev/null @@ -1,115 +0,0 @@ -use bitwarden_core::VaultLocked; -use bitwarden_crypto::KeyDecryptable; -use bitwarden_exporters::export; -use bitwarden_vault::{Cipher, CipherView, Collection, Folder, FolderView}; -use schemars::JsonSchema; - -use crate::{ - client::{LoginMethod, UserLoginMethod}, - error::{Error, Result}, - Client, -}; - -mod client_exporter; -pub use client_exporter::ClientExporters; - -#[derive(JsonSchema)] -#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))] -pub enum ExportFormat { - Csv, - Json, - EncryptedJson { password: String }, -} - -pub(super) fn export_vault( - client: &Client, - folders: Vec, - ciphers: Vec, - format: ExportFormat, -) -> Result { - let enc = client.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(VaultLocked)?; - - let folders: Vec = folders.decrypt_with_key(key)?; - let folders: Vec = - folders.into_iter().flat_map(|f| f.try_into()).collect(); - - let ciphers: Vec = ciphers.decrypt_with_key(key)?; - let ciphers: Vec = - ciphers.into_iter().flat_map(|c| c.try_into()).collect(); - - let format = convert_format(client, format)?; - - Ok(export(folders, ciphers, format)?) -} - -fn convert_format( - client: &Client, - format: ExportFormat, -) -> Result { - let login_method = client.get_login_method().ok_or(Error::NotAuthenticated)?; - - let kdf = match login_method.as_ref() { - LoginMethod::User( - UserLoginMethod::Username { kdf, .. } | UserLoginMethod::ApiKey { kdf, .. }, - ) => kdf, - _ => return Err(Error::NotAuthenticated), - }; - - Ok(match format { - ExportFormat::Csv => bitwarden_exporters::Format::Csv, - ExportFormat::Json => bitwarden_exporters::Format::Json, - ExportFormat::EncryptedJson { password } => bitwarden_exporters::Format::EncryptedJson { - password, - kdf: kdf.clone(), - }, - }) -} - -pub(super) fn export_organization_vault( - _collections: Vec, - _ciphers: Vec, - _format: ExportFormat, -) -> Result { - todo!(); -} - -#[cfg(test)] -mod tests { - use std::num::NonZeroU32; - - use bitwarden_crypto::Kdf; - - use super::*; - - #[test] - fn test_convert_format() { - let client = Client::new(None); - client.set_login_method(LoginMethod::User(UserLoginMethod::Username { - client_id: "7b821276-e27c-400b-9853-606393c87f18".to_owned(), - email: "test@bitwarden.com".to_owned(), - kdf: Kdf::PBKDF2 { - iterations: NonZeroU32::new(600_000).unwrap(), - }, - })); - - assert!(matches!( - convert_format(&client, ExportFormat::Csv).unwrap(), - bitwarden_exporters::Format::Csv - )); - assert!(matches!( - convert_format(&client, ExportFormat::Json).unwrap(), - bitwarden_exporters::Format::Json - )); - assert!(matches!( - convert_format( - &client, - ExportFormat::EncryptedJson { - password: "password".to_string() - } - ) - .unwrap(), - bitwarden_exporters::Format::EncryptedJson { .. } - )); - } -} diff --git a/crates/bitwarden/src/tool/mod.rs b/crates/bitwarden/src/tool/mod.rs deleted file mode 100644 index f67ef0fc1..000000000 --- a/crates/bitwarden/src/tool/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -mod exporters; -pub use exporters::{ClientExporters, ExportFormat}; -mod client_generator; -pub use bitwarden_send::*; -pub use client_generator::ClientGenerator; diff --git a/crates/bitwarden/src/uniffi_support.rs b/crates/bitwarden/src/uniffi_support.rs deleted file mode 100644 index 562393307..000000000 --- a/crates/bitwarden/src/uniffi_support.rs +++ /dev/null @@ -1,16 +0,0 @@ -use std::num::NonZeroU32; - -use bitwarden_crypto::{AsymmetricEncString, EncString}; -use uuid::Uuid; - -type DateTime = chrono::DateTime; -uniffi::ffi_converter_forward!(DateTime, bitwarden_core::UniFfiTag, crate::UniFfiTag); -uniffi::ffi_converter_forward!(Uuid, bitwarden_core::UniFfiTag, crate::UniFfiTag); - -uniffi::ffi_converter_forward!(NonZeroU32, bitwarden_crypto::UniFfiTag, crate::UniFfiTag); -uniffi::ffi_converter_forward!(EncString, bitwarden_crypto::UniFfiTag, crate::UniFfiTag); -uniffi::ffi_converter_forward!( - AsymmetricEncString, - bitwarden_crypto::UniFfiTag, - crate::UniFfiTag -); diff --git a/crates/bitwarden/src/vault/client_vault.rs b/crates/bitwarden/src/vault/client_vault.rs deleted file mode 100644 index 49ba5edd7..000000000 --- a/crates/bitwarden/src/vault/client_vault.rs +++ /dev/null @@ -1,18 +0,0 @@ -use super::sync::{sync, SyncRequest, SyncResponse}; -use crate::{error::Result, Client}; - -pub struct ClientVault<'a> { - pub(crate) client: &'a crate::Client, -} - -impl<'a> ClientVault<'a> { - pub async fn sync(&self, input: &SyncRequest) -> Result { - sync(self.client, input).await - } -} - -impl<'a> Client { - pub fn vault(&'a self) -> ClientVault<'a> { - ClientVault { client: self } - } -} diff --git a/crates/bitwarden/src/vault/mod.rs b/crates/bitwarden/src/vault/mod.rs deleted file mode 100644 index 8a6bf77f6..000000000 --- a/crates/bitwarden/src/vault/mod.rs +++ /dev/null @@ -1,9 +0,0 @@ -mod sync; -pub use sync::{SyncRequest, SyncResponse}; -mod client_vault; -pub use bitwarden_vault::{ - Attachment, AttachmentEncryptResult, AttachmentView, Cipher, CipherListView, CipherView, - Collection, CollectionView, Fido2CredentialNewView, Fido2CredentialView, Folder, FolderView, - PasswordHistory, PasswordHistoryView, TotpResponse, -}; -pub use client_vault::ClientVault; diff --git a/crates/bw/src/auth/login.rs b/crates/bw/src/auth/login.rs index 268014118..51fe64a39 100644 --- a/crates/bw/src/auth/login.rs +++ b/crates/bw/src/auth/login.rs @@ -3,7 +3,7 @@ use bitwarden::{ ApiKeyLoginRequest, PasswordLoginRequest, TwoFactorEmailRequest, TwoFactorProvider, TwoFactorRequest, }, - vault::SyncRequest, + vault::{ClientVaultExt, SyncRequest}, Client, }; use bitwarden_cli::text_prompt_when_none; diff --git a/crates/bw/src/main.rs b/crates/bw/src/main.rs index 66f63d280..a9a7eeea2 100644 --- a/crates/bw/src/main.rs +++ b/crates/bw/src/main.rs @@ -1,6 +1,6 @@ use bitwarden::{ auth::RegisterRequest, - generators::{PassphraseGeneratorRequest, PasswordGeneratorRequest}, + generators::{ClientGeneratorExt, PassphraseGeneratorRequest, PasswordGeneratorRequest}, ClientSettings, }; use bitwarden_cli::{install_color_eyre, text_prompt_when_none, Color}; diff --git a/crates/bws/src/command/project.rs b/crates/bws/src/command/project.rs index 72060fdf4..90024a9f7 100644 --- a/crates/bws/src/command/project.rs +++ b/crates/bws/src/command/project.rs @@ -1,7 +1,10 @@ use bitwarden::{ - secrets_manager::projects::{ - ProjectCreateRequest, ProjectGetRequest, ProjectPutRequest, ProjectsDeleteRequest, - ProjectsListRequest, + secrets_manager::{ + projects::{ + ProjectCreateRequest, ProjectGetRequest, ProjectPutRequest, ProjectsDeleteRequest, + ProjectsListRequest, + }, + ClientProjectsExt, }, Client, }; diff --git a/crates/bws/src/command/secret.rs b/crates/bws/src/command/secret.rs index 30613016d..744ed396d 100644 --- a/crates/bws/src/command/secret.rs +++ b/crates/bws/src/command/secret.rs @@ -1,7 +1,10 @@ use bitwarden::{ - secrets_manager::secrets::{ - SecretCreateRequest, SecretGetRequest, SecretIdentifiersByProjectRequest, - SecretIdentifiersRequest, SecretPutRequest, SecretsDeleteRequest, SecretsGetRequest, + secrets_manager::{ + secrets::{ + SecretCreateRequest, SecretGetRequest, SecretIdentifiersByProjectRequest, + SecretIdentifiersRequest, SecretPutRequest, SecretsDeleteRequest, SecretsGetRequest, + }, + ClientSecretsExt, }, Client, }; diff --git a/crates/bws/src/main.rs b/crates/bws/src/main.rs index be1ea2bd4..092df2208 100644 --- a/crates/bws/src/main.rs +++ b/crates/bws/src/main.rs @@ -101,7 +101,7 @@ async fn process_commands() -> Result<()> { }) .await?; - let organization_id = match client.get_access_token_organization() { + let organization_id = match client.internal.get_access_token_organization() { Some(id) => id, None => { error!("Access token isn't associated to an organization."); diff --git a/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt b/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt index 889079692..c65e0d3c6 100644 --- a/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt +++ b/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt @@ -24,9 +24,9 @@ import androidx.compose.ui.unit.dp import androidx.fragment.app.FragmentActivity import com.bitwarden.core.DateTime import com.bitwarden.vault.Folder -import com.bitwarden.bitwarden.InitOrgCryptoRequest -import com.bitwarden.bitwarden.InitUserCryptoMethod -import com.bitwarden.bitwarden.InitUserCryptoRequest +import com.bitwarden.core.InitOrgCryptoRequest +import com.bitwarden.core.InitUserCryptoMethod +import com.bitwarden.core.InitUserCryptoRequest import com.bitwarden.core.Uuid import com.bitwarden.crypto.HashPurpose import com.bitwarden.crypto.Kdf From 3a48ef6af4494379858002c00f084b3f10147b5b Mon Sep 17 00:00:00 2001 From: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com> Date: Wed, 26 Jun 2024 10:53:41 -0500 Subject: [PATCH 032/214] [SM-1175] Remove deprecated bws commands (#836) The purpose of this PR is to remove all the deprecated commands from bws. Went with building off the refactor in `sm/sm-1287`. Co-authored-by: Colton Hurst --- crates/bws/src/cli.rs | 82 ------------------- crates/bws/src/command/project.rs | 24 +++++- crates/bws/src/command/secret.rs | 60 +++++++++++++- crates/bws/src/main.rs | 126 +----------------------------- 4 files changed, 86 insertions(+), 206 deletions(-) diff --git a/crates/bws/src/cli.rs b/crates/bws/src/cli.rs index 48d2f528e..3c55b3a0e 100644 --- a/crates/bws/src/cli.rs +++ b/crates/bws/src/cli.rs @@ -89,31 +89,6 @@ pub(crate) enum Commands { #[command(subcommand)] cmd: SecretCommand, }, - #[command(long_about = "Create a single item (deprecated)", hide(true))] - Create { - #[command(subcommand)] - cmd: CreateCommand, - }, - #[command(long_about = "Delete one or more items (deprecated)", hide(true))] - Delete { - #[command(subcommand)] - cmd: DeleteCommand, - }, - #[command(long_about = "Edit a single item (deprecated)", hide(true))] - Edit { - #[command(subcommand)] - cmd: EditCommand, - }, - #[command(long_about = "Retrieve a single item (deprecated)", hide(true))] - Get { - #[command(subcommand)] - cmd: GetCommand, - }, - #[command(long_about = "List items (deprecated)", hide(true))] - List { - #[command(subcommand)] - cmd: ListCommand, - }, } #[derive(Subcommand, Debug)] @@ -169,60 +144,3 @@ pub(crate) enum ProjectCommand { }, List, } - -#[derive(Subcommand, Debug)] -pub(crate) enum ListCommand { - Projects, - Secrets { project_id: Option }, -} - -#[derive(Subcommand, Debug)] -pub(crate) enum GetCommand { - Project { project_id: Uuid }, - Secret { secret_id: Uuid }, -} - -#[derive(Subcommand, Debug)] -pub(crate) enum CreateCommand { - Project { - name: String, - }, - Secret { - key: String, - value: String, - - #[arg(long, help = "An optional note to add to the secret")] - note: Option, - - #[arg(long, help = "The ID of the project this secret will be added to")] - project_id: Uuid, - }, -} - -#[derive(Subcommand, Debug)] -pub(crate) enum EditCommand { - #[clap(group = ArgGroup::new("edit_field").required(true).multiple(true))] - Project { - project_id: Uuid, - #[arg(long, group = "edit_field")] - name: String, - }, - #[clap(group = ArgGroup::new("edit_field").required(true).multiple(true))] - Secret { - secret_id: Uuid, - #[arg(long, group = "edit_field")] - key: Option, - #[arg(long, group = "edit_field")] - value: Option, - #[arg(long, group = "edit_field")] - note: Option, - #[arg(long, group = "edit_field")] - project_id: Option, - }, -} - -#[derive(Subcommand, Debug)] -pub(crate) enum DeleteCommand { - Project { project_ids: Vec }, - Secret { secret_ids: Vec }, -} diff --git a/crates/bws/src/command/project.rs b/crates/bws/src/command/project.rs index 90024a9f7..3b521e2cb 100644 --- a/crates/bws/src/command/project.rs +++ b/crates/bws/src/command/project.rs @@ -11,7 +11,29 @@ use bitwarden::{ use color_eyre::eyre::{bail, Result}; use uuid::Uuid; -use crate::render::{serialize_response, OutputSettings}; +use crate::{ + render::{serialize_response, OutputSettings}, + ProjectCommand, +}; + +pub(crate) async fn process_command( + command: ProjectCommand, + client: Client, + organization_id: Uuid, + output_settings: OutputSettings, +) -> Result<()> { + match command { + ProjectCommand::List => list(client, organization_id, output_settings).await, + ProjectCommand::Get { project_id } => get(client, project_id, output_settings).await, + ProjectCommand::Create { name } => { + create(client, organization_id, name, output_settings).await + } + ProjectCommand::Edit { project_id, name } => { + edit(client, organization_id, project_id, name, output_settings).await + } + ProjectCommand::Delete { project_ids } => delete(client, project_ids).await, + } +} pub(crate) async fn list( client: Client, diff --git a/crates/bws/src/command/secret.rs b/crates/bws/src/command/secret.rs index 744ed396d..794a1a0b9 100644 --- a/crates/bws/src/command/secret.rs +++ b/crates/bws/src/command/secret.rs @@ -11,7 +11,10 @@ use bitwarden::{ use color_eyre::eyre::{bail, Result}; use uuid::Uuid; -use crate::render::{serialize_response, OutputSettings}; +use crate::{ + render::{serialize_response, OutputSettings}, + SecretCommand, +}; #[derive(Debug)] pub(crate) struct SecretCreateCommandModel { @@ -30,6 +33,61 @@ pub(crate) struct SecretEditCommandModel { pub(crate) project_id: Option, } +pub(crate) async fn process_command( + command: SecretCommand, + client: Client, + organization_id: Uuid, + output_settings: OutputSettings, +) -> Result<()> { + match command { + SecretCommand::List { project_id } => { + list(client, organization_id, project_id, output_settings).await + } + SecretCommand::Get { secret_id } => get(client, secret_id, output_settings).await, + SecretCommand::Create { + key, + value, + note, + project_id, + } => { + create( + client, + organization_id, + SecretCreateCommandModel { + key, + value, + note, + project_id, + }, + output_settings, + ) + .await + } + SecretCommand::Edit { + secret_id, + key, + value, + note, + project_id, + } => { + edit( + client, + organization_id, + SecretEditCommandModel { + id: secret_id, + key, + value, + note, + project_id, + }, + output_settings, + ) + .await + } + SecretCommand::Delete { secret_ids } => delete(client, secret_ids).await, + } +} + pub(crate) async fn list( client: Client, organization_id: Uuid, diff --git a/crates/bws/src/main.rs b/crates/bws/src/main.rs index 092df2208..14fc30782 100644 --- a/crates/bws/src/main.rs +++ b/crates/bws/src/main.rs @@ -7,7 +7,6 @@ use bitwarden::{ use bitwarden_cli::install_color_eyre; use clap::{CommandFactory, Parser}; use color_eyre::eyre::{bail, Result}; -use command::secret::{SecretCreateCommandModel, SecretEditCommandModel}; use log::error; use render::OutputSettings; @@ -113,130 +112,13 @@ async fn process_commands() -> Result<()> { // And finally we process all the commands which require authentication match command { - Commands::Project { - cmd: ProjectCommand::List, + Commands::Project { cmd } => { + command::project::process_command(cmd, client, organization_id, output_settings).await } - | Commands::List { - cmd: ListCommand::Projects, - } => command::project::list(client, organization_id, output_settings).await, - Commands::Project { - cmd: ProjectCommand::Get { project_id }, + Commands::Secret { cmd } => { + command::secret::process_command(cmd, client, organization_id, output_settings).await } - | Commands::Get { - cmd: GetCommand::Project { project_id }, - } => command::project::get(client, project_id, output_settings).await, - - Commands::Project { - cmd: ProjectCommand::Create { name }, - } - | Commands::Create { - cmd: CreateCommand::Project { name }, - } => command::project::create(client, organization_id, name, output_settings).await, - - Commands::Project { - cmd: ProjectCommand::Edit { project_id, name }, - } - | Commands::Edit { - cmd: EditCommand::Project { project_id, name }, - } => { - command::project::edit(client, organization_id, project_id, name, output_settings).await - } - - Commands::Project { - cmd: ProjectCommand::Delete { project_ids }, - } - | Commands::Delete { - cmd: DeleteCommand::Project { project_ids }, - } => command::project::delete(client, project_ids).await, - - Commands::Secret { - cmd: SecretCommand::List { project_id }, - } - | Commands::List { - cmd: ListCommand::Secrets { project_id }, - } => command::secret::list(client, organization_id, project_id, output_settings).await, - - Commands::Secret { - cmd: SecretCommand::Get { secret_id }, - } - | Commands::Get { - cmd: GetCommand::Secret { secret_id }, - } => command::secret::get(client, secret_id, output_settings).await, - - Commands::Secret { - cmd: - SecretCommand::Create { - key, - value, - note, - project_id, - }, - } - | Commands::Create { - cmd: - CreateCommand::Secret { - key, - value, - note, - project_id, - }, - } => { - command::secret::create( - client, - organization_id, - SecretCreateCommandModel { - key, - value, - note, - project_id, - }, - output_settings, - ) - .await - } - - Commands::Secret { - cmd: - SecretCommand::Edit { - secret_id, - key, - value, - note, - project_id, - }, - } - | Commands::Edit { - cmd: - EditCommand::Secret { - secret_id, - key, - value, - note, - project_id, - }, - } => { - command::secret::edit( - client, - organization_id, - SecretEditCommandModel { - id: secret_id, - key, - value, - note, - project_id, - }, - output_settings, - ) - .await - } - - Commands::Secret { - cmd: SecretCommand::Delete { secret_ids }, - } - | Commands::Delete { - cmd: DeleteCommand::Secret { secret_ids }, - } => command::secret::delete(client, secret_ids).await, Commands::Config { .. } | Commands::Completions { .. } => { unreachable!() From f9d134abf93e5afa16a20f5f2641718b69e3e506 Mon Sep 17 00:00:00 2001 From: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:26:41 -0500 Subject: [PATCH 033/214] [SM-1175] Add sm-1175 to the bws changelog (#860) Add removal of deprecated commands to changelog --- crates/bws/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/bws/CHANGELOG.md b/crates/bws/CHANGELOG.md index 25cec1164..447f7cad6 100644 --- a/crates/bws/CHANGELOG.md +++ b/crates/bws/CHANGELOG.md @@ -7,6 +7,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Removed + +- The deprecated `action type` commands are now removed. Please use `type action` instead. (#836) + ## [0.5.0] - 2024-04-26 ### Added From d43d1cb45557b0828901ff0ab8a2ee8311ac5b9f Mon Sep 17 00:00:00 2001 From: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com> Date: Wed, 26 Jun 2024 16:38:19 -0500 Subject: [PATCH 034/214] [SM-1262] Update cpp documentation (#854) Clean up C++ documentation and add clearer macOS examples. This includes fixing shell commands formatting. --- languages/cpp/CMakeBuild.md | 50 +++++++++---- languages/cpp/ExampleUse.md | 70 ----------------- languages/cpp/examples/ExampleUse.md | 108 +++++++++++++++++++++++++++ 3 files changed, 142 insertions(+), 86 deletions(-) delete mode 100644 languages/cpp/ExampleUse.md create mode 100644 languages/cpp/examples/ExampleUse.md diff --git a/languages/cpp/CMakeBuild.md b/languages/cpp/CMakeBuild.md index 4c7c29814..cb148069e 100644 --- a/languages/cpp/CMakeBuild.md +++ b/languages/cpp/CMakeBuild.md @@ -1,33 +1,51 @@ -# CMAKE build +# CMake Build -## INTRODUCTION +## Introduction -Cmake is used to build the c++ Bitwarden client library. Output should be placed in the build directory. The output contains two dynamic libraries: one that we are building `BitwardenClient` and another that the building library uses `bitwarden_c`. +Cmake is used to build the C++ Bitwarden client library. Output should be placed in the build directory. -## PREREQUISITES +The output contains two dynamic libraries: + +- The C++ client `BitwardenClient` +- The Bitwarden library used by the C++ client `bitwarden_c`. + +See how to use these libraries in the [example use guide](./examples/ExampleUse.md) + +## Prerequisites - Cmake installed, minimum version 3.15 - `schemas.hpp` generated into `include` directory - installed `nlohmann-json` library - installed `boost` library -## BUILD commands +## Build Commands -One should be in the root directory of the c++ wrapper (the same level where is CMakeLists.txt placed). Paths of the three libraries should be placed inside the cmake build command: +One should be in the root directory of the C++ wrapper (the same level where is CMakeLists.txt placed). Paths of the three libraries should be placed inside the cmake build command: -$ mkdir build -$ cd build -$ cmake .. -DNLOHMANN=/path/to/include/nlohmann -DBOOST=/path/to/include/boost -DTARGET=relative/path/to/libbitwarden_c -$ cmake --build . +```bash +mkdir -p build +cd build +cmake .. -DNLOHMANN=/path/to/include/nlohmann -DBOOST=/path/to/include/boost -DTARGET=relative/path/to/libbitwarden_c +cmake --build . +``` +## Example +### macOS -## Example +#### Install Prerequisites -macOS: +```bash +brew install cmake +brew install boost +brew install nlohmann-json +``` -$ mkdir build -$ cd build -$ cmake .. -DNLOHMANN=/opt/hombrew/include -DBOOST=/opt/homebrew/include -DTARGET=../../target/release/libbitwarden_c.dylib -$ cmake --build . +#### Build +```bash +mkdir -p build +cd build +cmake .. -DNLOHMANN=/opt/homebrew/include -DBOOST=/opt/homebrew/include -DTARGET=../../target/release/libbitwarden_c.dylib +cmake --build . +``` diff --git a/languages/cpp/ExampleUse.md b/languages/cpp/ExampleUse.md deleted file mode 100644 index 579cd0e67..000000000 --- a/languages/cpp/ExampleUse.md +++ /dev/null @@ -1,70 +0,0 @@ -# EXAMPLES - - -## PREREQUISITES - -### BITWARDEN Libraries -One should have two libraries at the same path: -- `BitwardeClient` -- `bitwarden_c` - -It should look like `libBitwardeClient.dylib` and `libbitwarden_c.dylib` for the macOS. - -For Linux: `libBitwardeClient.so` and `libbitwarden_c.so` -For Windows: `BitwardeClient.dll` and `bitwarden_c.dll` - -### INCLUDE directory - -`include` directory contains: -- `BitwardenLibrary.h` -- `BitwardenClient.h` -- `BitwardenSettings.h` -- `CommandRunner.h` -- `Projects.h` -- `Secrets.h` -- `schemas.hpp` - -### Other libraries -- `nlohmann-json` (https://github.com/nlohmann/json) -- `boost` (https://www.boost.org/) - - -### COMPILING - -One could use g++/clang++ for compiling. -Example of the folder structure (macOS): - ---root - --build - `libBitwardenClient.dylib` - `libbitwarden_c.dylib` - --include - --`BitwardenLibrary.h` - --`BitwardenClient.h` - --`BitwardenSettings.h` - --`CommandRunner.h` - --`Projects.h` - --`Secrets.h` - --`schemas.hpp` - --examples - --`Wrapper.cpp` - - -1. $ export ACCESS_TOKEN=<"access-token"> -2. $ export ORGANIZATION_ID=<"organization-id"> -3. $ export DYLD_LIBRARY_PATH=/path/to/your/library:$DYLD_LIBRARY_PATH - -The last step is neccessary to add the path for the dynamic library (macOS). -For the Linux one should use: -$ export LD_LIBRARY_PATH=/path/to/your/library:$LD_LIBRARY_PATH -For the Windows: -$ set PATH=%PATH%;C:\path\to\your\library - -4. $ cd examples -5. $ clang++ -std=c++20 -I../include -I/path/to/include/nlohmann -I/path/to/include/boost -L../build/ -o MyBitwardenApp Wrapper.cpp -lBitwardenClient -ldl - -for Windows `-ldl` should be excluded, - -The result is `MyBitwardenApp` in the `examples` directory, and one can run it from the `examples` directory: - -6. $ ./MyBitwardenApp diff --git a/languages/cpp/examples/ExampleUse.md b/languages/cpp/examples/ExampleUse.md new file mode 100644 index 000000000..f5ec6f6ff --- /dev/null +++ b/languages/cpp/examples/ExampleUse.md @@ -0,0 +1,108 @@ +# Examples + +## Prerequisites + +### Bitwarden Libraries + +Have the two Bitwarden libraries at the same path: + +- `BitwardenClient` +- `bitwarden_c` + +For each OS the library files will be the following: + +- macOS: `libBitwardenClient.dylib` and `libbitwarden_c.dylib` +- Linux: `libBitwardenClient.so` and `libbitwarden_c.so` +- Windows: `BitwardenClient.dll` and `bitwarden_c.dll` + +Follow the [cmake build guide](../CMakeBuild.md) to create the libraries locally. + +### Include Directory + +`include` directory contains: + +- `BitwardenLibrary.h` +- `BitwardenClient.h` +- `BitwardenSettings.h` +- `CommandRunner.h` +- `Projects.h` +- `Secrets.h` +- `schemas.hpp` + +### Other Libraries + +- `nlohmann-json` () +- `boost` () + +### Compiling + +Use g++/clang++ for compiling. + +Example of the folder structure (macOS): + +```text +--root + --build + `libBitwardenClient.dylib` + `libbitwarden_c.dylib` + --include + --`BitwardenLibrary.h` + --`BitwardenClient.h` + --`BitwardenSettings.h` + --`CommandRunner.h` + --`Projects.h` + --`Secrets.h` + --`schemas.hpp` + --examples + --`Wrapper.cpp` +``` + +Set the environment variable path for the Bitwarden libraries. + +For macOS: + +```bash +export DYLD_LIBRARY_PATH=/path/to/your/library:$DYLD_LIBRARY_PATH +``` + +For Linux: + +```bash +export LD_LIBRARY_PATH=/path/to/your/library:$LD_LIBRARY_PATH +``` + +For Windows: + +```shell + set "PATH=%PATH%;C:\path\to\your\library" +``` + +Set environment variables used in `Wrapper.cpp`: + +```bash +export ACCESS_TOKEN=<"access-token"> +export ORGANIZATION_ID=<"organization-id"> +export API_URL=http://localhost:4000 +export IDENTITY_URL=http://localhost:33656 +``` + +Compile: + +```bash +cd examples +clang++ -std=c++20 -I../include -I/path/to/include/nlohmann -I/path/to/include/boost -L../build/ -o MyBitwardenApp Wrapper.cpp -lBitwardenClient -ldl +``` + +for Windows `-ldl` should be excluded, + +for macOS nlohmann and boost libraries installed with homebrew the following can be used: + +```bash +-I/opt/homebrew/include +``` + +The result is `MyBitwardenApp` in the `examples` directory, and can be ran from the `examples` directory: + +```bash +./MyBitwardenApp +``` From 84597751740714a50fcd047de855844b7f861e3d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 28 Jun 2024 15:37:13 +0200 Subject: [PATCH 035/214] [deps]: Update @types/node to v18.19.39 (#856) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@types/node](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node) ([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node)) | [`18.19.34` -> `18.19.39`](https://renovatebot.com/diffs/npm/@types%2fnode/18.19.34/18.19.39) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2fnode/18.19.39?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@types%2fnode/18.19.39?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@types%2fnode/18.19.34/18.19.39?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2fnode/18.19.34/18.19.39?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- languages/js/sdk-client/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index b9a9882d3..417dbdba4 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -39,9 +39,9 @@ } }, "node_modules/@types/node": { - "version": "18.19.34", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.34.tgz", - "integrity": "sha512-eXF4pfBNV5DAMKGbI02NnDtWrQ40hAN558/2vvS4gMpMIxaf6JmD7YjnZbq0Q9TDSSkKBamime8ewRoomHdt4g==", + "version": "18.19.39", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.39.tgz", + "integrity": "sha512-nPwTRDKUctxw3di5b4TfT3I0sWDiWoPQCZjXhvdkINntwr8lcoVCKsTgnXeRubKIlfnV+eN/HYk6Jb40tbcEAQ==", "dev": true, "license": "MIT", "dependencies": { From 05475f1eb25780f05ed81f775c2c8a809a70daf5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 28 Jun 2024 16:17:03 +0200 Subject: [PATCH 036/214] [deps]: Lock file maintenance (#859) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. đŸ‘ģ **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 320 +++++++++-------- crates/bitwarden-napi/package-lock.json | 66 ++-- languages/js/sdk-client/package-lock.json | 117 +++++-- package-lock.json | 404 ++++++++++++++++------ 4 files changed, 593 insertions(+), 314 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a1c0dbe4d..bbf507a2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -118,9 +118,9 @@ dependencies = [ [[package]] name = "anstyle-query" -version = "1.0.3" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" dependencies = [ "windows-sys 0.52.0", ] @@ -183,7 +183,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -213,9 +213,9 @@ dependencies = [ [[package]] name = "async-compat" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f68a707c1feb095d8c07f8a65b9f506b117d30af431cab89374357de7c11461b" +checksum = "7bab94bde396a3f7b4962e396fdad640e241ed797d4d8d77fc8c237d14c58fc0" dependencies = [ "futures-core", "futures-io", @@ -232,9 +232,15 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.3.0" @@ -349,9 +355,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bitwarden" @@ -760,15 +766,15 @@ dependencies = [ "tempfile", "thiserror", "tokio", - "toml 0.8.12", + "toml 0.8.14", "uuid", ] [[package]] name = "bytemuck" -version = "1.15.0" +version = "1.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" [[package]] name = "byteorder" @@ -790,9 +796,9 @@ checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" [[package]] name = "camino" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c" +checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" dependencies = [ "serde", ] @@ -837,9 +843,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.97" +version = "1.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" +checksum = "ac367972e516d45567c7eafc73d24e1c193dcf200a8d94e9db7b3d38b349572d" [[package]] name = "cesu8" @@ -930,9 +936,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.5" +version = "4.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2020fa13af48afc65a9a87335bda648309ab3d154cd03c7ff95b378c7ed39c4" +checksum = "fbca90c87c2a04da41e95d1856e8bcd22f159bdbfa147314d2ce5218057b0e58" dependencies = [ "clap", ] @@ -946,14 +952,14 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] name = "clap_lex" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "clap_mangen" @@ -1027,8 +1033,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b34115915337defe99b2aff5c2ce6771e5fbc4079f4b506301f5cf394c8452f7" dependencies = [ "crossterm 0.27.0", - "strum 0.26.2", - "strum_macros 0.26.2", + "strum 0.26.3", + "strum_macros 0.26.4", "unicode-width", ] @@ -1127,9 +1133,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] @@ -1191,9 +1197,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crossterm" @@ -1217,7 +1223,7 @@ version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "crossterm_winapi", "libc", "parking_lot", @@ -1289,7 +1295,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -1337,7 +1343,7 @@ dependencies = [ "proc-macro2", "quote", "strsim 0.11.1", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -1359,7 +1365,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -1493,9 +1499,9 @@ dependencies = [ [[package]] name = "either" -version = "1.11.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "elliptic-curve" @@ -1710,7 +1716,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -1834,15 +1840,15 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "816ec7294445779408f36fe57bc5b7fc1cf59664059096c65f905c1c61f58069" +checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" dependencies = [ + "atomic-waker", "bytes", "fnv", "futures-core", "futures-sink", - "futures-util", "http", "indexmap 2.2.6", "slab", @@ -1947,12 +1953,12 @@ dependencies = [ [[package]] name = "http-body-util" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0475f8b2ac86659c21b64320d5d653f9efe42acd2a4e560073ec61a155a34f1d" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", - "futures-core", + "futures-util", "http", "http-body", "pin-project-lite", @@ -1960,9 +1966,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.8.0" +version = "1.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" +checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" [[package]] name = "httpdate" @@ -2017,9 +2023,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.3" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca38ef113da30126bbff9cd1705f9273e15d45498615d138b0c20279ac7a76aa" +checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" dependencies = [ "bytes", "futures-channel", @@ -2124,7 +2130,7 @@ version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fddf93031af70e75410a2511ec04d49e758ed2f26dad3404a934e0fb45cc12a" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "crossterm 0.25.0", "dyn-clone", "fuzzy-matcher", @@ -2228,11 +2234,11 @@ dependencies = [ [[package]] name = "lazy_static" -version = "1.4.0" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" dependencies = [ - "spin 0.5.2", + "spin", ] [[package]] @@ -2243,9 +2249,9 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19" +checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" dependencies = [ "cfg-if", "windows-targets 0.52.5", @@ -2263,7 +2269,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "libc", ] @@ -2275,9 +2281,9 @@ checksum = "dd1bc4d24ad230d21fb898d1116b1801d7adfc449d42026475862ab48b11e70e" [[package]] name = "linux-raw-sys" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "lock_api" @@ -2291,9 +2297,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.21" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" [[package]] name = "memchr" @@ -2346,9 +2352,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" dependencies = [ "adler", ] @@ -2367,11 +2373,11 @@ dependencies = [ [[package]] name = "napi" -version = "2.16.6" +version = "2.16.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc300228808a0e6aea5a58115c82889240bcf8dab16fc25ad675b33e454b368" +checksum = "a1bd081bbaef43600fd2c5dd4c525b8ecea7dfdacf40ebc674e87851dce6559e" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "ctor", "napi-derive", "napi-sys", @@ -2387,23 +2393,23 @@ checksum = "e1c0f5d67ee408a4685b61f5ab7e58605c8ae3f2b4189f0127d804ff13d5560a" [[package]] name = "napi-derive" -version = "2.16.5" +version = "2.16.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0e034ddf6155192cf83f267ede763fe6c164dfa9971585436b16173718d94c4" +checksum = "70a8a778fd367b13c64232e58632514b795514ece491ce136d96e976d34a3eb8" dependencies = [ "cfg-if", "convert_case", "napi-derive-backend", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] name = "napi-derive-backend" -version = "1.0.67" +version = "1.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff2c00437f3b3266391eb5e6aa25d0029187daf5caf05b8e3271468fb5ae73e" +checksum = "35849e64596ecd467e1ac897153364a1ffd09b1d79b32ebad94ef8980ac73311" dependencies = [ "convert_case", "once_cell", @@ -2411,7 +2417,7 @@ dependencies = [ "quote", "regex", "semver", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -2453,9 +2459,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c165a9ab64cf766f73521c0dd2cfdff64f488b8f0b3e621face3462d3db536d7" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" dependencies = [ "num-integer", "num-traits", @@ -2599,9 +2605,9 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e4af0ca4f6caed20e900d564c242b8e5d4903fdacf31d3daf527b66fe6f42fb" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" dependencies = [ "lock_api", "parking_lot_core", @@ -2671,7 +2677,7 @@ name = "passkey-types" version = "0.2.1" source = "git+https://github.com/bitwarden/passkey-rs?rev=c48c2ddfd6b884b2d754432576c66cb2b1985a3a#c48c2ddfd6b884b2d754432576c66cb2b1985a3a" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "ciborium", "coset", "data-encoding", @@ -2752,7 +2758,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -2816,9 +2822,9 @@ dependencies = [ [[package]] name = "plotters" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" dependencies = [ "num-traits", "plotters-backend", @@ -2829,15 +2835,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" +checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7" [[package]] name = "plotters-svg" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705" dependencies = [ "plotters-backend", ] @@ -2871,9 +2877,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -2966,7 +2972,7 @@ dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -2979,7 +2985,7 @@ dependencies = [ "proc-macro2", "pyo3-build-config", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -3105,11 +3111,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" +checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] @@ -3225,7 +3231,7 @@ dependencies = [ "cfg-if", "getrandom", "libc", - "spin 0.9.8", + "spin", "untrusted", "windows-sys 0.52.0", ] @@ -3274,7 +3280,7 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -3326,9 +3332,9 @@ checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-platform-verifier" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5f0d26fa1ce3c790f9590868f0109289a044acb954525f933e2aa3b871c157d" +checksum = "3e3beb939bcd33c269f4bf946cc829fcd336370267c4a927ac0399c84a3151a1" dependencies = [ "core-foundation", "core-foundation-sys", @@ -3364,9 +3370,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.16" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "092474d1a01ea8278f69e6a358998405fae5b8b963ddaeb2b0b04a128bf1dfb0" +checksum = "955d28af4278de8121b7ebeb796b6a45735dc01436d898801014aced2773a3d6" [[package]] name = "ryu" @@ -3416,7 +3422,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -3448,7 +3454,7 @@ checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -3529,25 +3535,25 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] name = "serde_derive_internals" -version = "0.29.0" +version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "330f01ce65a3a5fe59a60c82f3c9a024b573b8a6e875bd233fe5f934e71d54e3" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4" dependencies = [ "indexmap 2.2.6", "itoa", @@ -3574,14 +3580,14 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] name = "serde_spanned" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" dependencies = [ "serde", ] @@ -3625,7 +3631,7 @@ dependencies = [ "darling 0.20.9", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -3759,12 +3765,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "spin" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" - [[package]] name = "spin" version = "0.9.8" @@ -3816,9 +3816,9 @@ dependencies = [ [[package]] name = "strum" -version = "0.26.2" +version = "0.26.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d8cec3501a5194c432b2b7976db6b7d10ec95c253208b45f83f7136aa985e29" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" [[package]] name = "strum_macros" @@ -3830,27 +3830,27 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] name = "strum_macros" -version = "0.26.2" +version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "quote", "rustversion", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] name = "subtle" -version = "2.5.0" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "supports-color" @@ -3874,9 +3874,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.63" +version = "2.0.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf5be731623ca1a1fb7d8be6f261a3be6d3e2337b8a1f97be944d020c8fcb704" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" dependencies = [ "proc-macro2", "quote", @@ -3940,22 +3940,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -4011,9 +4011,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" dependencies = [ "tinyvec_macros", ] @@ -4026,9 +4026,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.37.0" +version = "1.38.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" dependencies = [ "backtrace", "bytes", @@ -4043,13 +4043,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" +checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -4087,9 +4087,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.12" +version = "0.8.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9dd1545e8208b4a5af1aa9bbd0b4cf7e9ea08fabc5d0a5c67fcaafa17433aa3" +checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" dependencies = [ "serde", "serde_spanned", @@ -4099,18 +4099,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.12" +version = "0.22.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3328d4f68a705b2a4498da1d580585d39a6510f98318a2cec3018a7ec61ddef" +checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" dependencies = [ "indexmap 2.2.6", "serde", @@ -4132,7 +4132,6 @@ dependencies = [ "tokio", "tower-layer", "tower-service", - "tracing", ] [[package]] @@ -4153,7 +4152,6 @@ version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "log", "pin-project-lite", "tracing-attributes", "tracing-core", @@ -4167,7 +4165,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -4232,7 +4230,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a615d6c2764852a2e88a4f16e9ce1ea49bb776b5872956309e170d63a042a34f" dependencies = [ "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -4279,9 +4277,9 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f5e5f3158ecfd4b8ff6fe086db7c8467a2dfdac97fe420f2b7c4aa97af66d6" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "uniffi" @@ -4343,12 +4341,12 @@ dependencies = [ [[package]] name = "uniffi_checksum_derive" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95e86ccd44c138ba12b9132decbabeed84bf686ebe4b6538a5e489a243a7c2c9" +checksum = "d5c400339a9d1d17be34257d0b407e91d64af335e5b4fa49f4bf28467fc8d635" dependencies = [ "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -4380,7 +4378,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.63", + "syn 2.0.68", "toml 0.5.11", "uniffi_meta", ] @@ -4443,9 +4441,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.0" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" dependencies = [ "form_urlencoded", "idna", @@ -4454,15 +4452,15 @@ dependencies = [ [[package]] name = "utf8parse" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.8.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" dependencies = [ "getrandom", "serde", @@ -4528,7 +4526,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", "wasm-bindgen-shared", ] @@ -4562,7 +4560,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4595,7 +4593,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] @@ -4807,9 +4805,9 @@ checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" -version = "0.6.8" +version = "0.6.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" +checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" dependencies = [ "memchr", ] @@ -4850,9 +4848,9 @@ dependencies = [ [[package]] name = "zeroize" -version = "1.7.0" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525b4ec142c6b68a2d10f01f7bbf6755599ca3f81ea53b8431b7dd348f5fdb2d" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" dependencies = [ "serde", "zeroize_derive", @@ -4866,7 +4864,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.63", + "syn 2.0.68", ] [[package]] diff --git a/crates/bitwarden-napi/package-lock.json b/crates/bitwarden-napi/package-lock.json index 708d7369f..8f21b16fd 100644 --- a/crates/bitwarden-napi/package-lock.json +++ b/crates/bitwarden-napi/package-lock.json @@ -22,6 +22,7 @@ "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", "dev": true, + "license": "MIT", "dependencies": { "@jridgewell/trace-mapping": "0.3.9" }, @@ -34,6 +35,7 @@ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.0.0" } @@ -42,13 +44,15 @@ "version": "1.4.15", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@jridgewell/trace-mapping": { "version": "0.3.9", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", "dev": true, + "license": "MIT", "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -59,6 +63,7 @@ "resolved": "https://registry.npmjs.org/@napi-rs/cli/-/cli-2.18.3.tgz", "integrity": "sha512-L0f4kP0dyG8W5Qtc7MtP73VvLLrOLyRcUEBzknIfu8Jk4Jfhrsx1ItMHgyalYqMSslWdY3ojEfAaU5sx1VyeQQ==", "dev": true, + "license": "MIT", "bin": { "napi": "scripts/index.js" }, @@ -74,41 +79,47 @@ "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@tsconfig/node12": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@tsconfig/node14": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@tsconfig/node16": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@types/node": { - "version": "20.12.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.11.tgz", - "integrity": "sha512-vDg9PZ/zi+Nqp6boSOT7plNuthRugEKixDv5sFTIpkE89MmNtEArAShI4mxuX2+UrLEe9pxC1vm2cjm9YlWbJw==", + "version": "20.14.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz", + "integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==", "dev": true, + "license": "MIT", "peer": true, "dependencies": { "undici-types": "~5.26.4" } }, "node_modules/acorn": { - "version": "8.11.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", - "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", + "integrity": "sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==", "dev": true, + "license": "MIT", "bin": { "acorn": "bin/acorn" }, @@ -117,10 +128,14 @@ } }, "node_modules/acorn-walk": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", - "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", + "version": "8.3.3", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz", + "integrity": "sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==", "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.11.0" + }, "engines": { "node": ">=0.4.0" } @@ -129,19 +144,22 @@ "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/create-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/diff": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true, + "license": "BSD-3-Clause", "engines": { "node": ">=0.3.1" } @@ -150,13 +168,15 @@ "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/ts-node": { "version": "10.9.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", "dev": true, + "license": "MIT", "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", @@ -196,10 +216,11 @@ } }, "node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", + "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -213,19 +234,22 @@ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "dev": true, + "license": "MIT", "peer": true }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/yn": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index 417dbdba4..209365dc2 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -16,6 +16,7 @@ "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", "dev": true, + "license": "ISC", "dependencies": { "string-width": "^5.1.2", "string-width-cjs": "npm:string-width@^4.2.0", @@ -33,6 +34,7 @@ "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", "dev": true, + "license": "MIT", "optional": true, "engines": { "node": ">=14" @@ -53,6 +55,7 @@ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", "dev": true, + "license": "MIT", "engines": { "node": ">=12" }, @@ -65,6 +68,7 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", "dev": true, + "license": "MIT", "engines": { "node": ">=12" }, @@ -76,13 +80,15 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/brace-expansion": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, + "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" } @@ -92,6 +98,7 @@ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -103,13 +110,15 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, + "license": "MIT", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -123,19 +132,22 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.2.1.tgz", + "integrity": "sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==", "dev": true, + "license": "ISC", "dependencies": { "cross-spawn": "^7.0.0", "signal-exit": "^4.0.1" @@ -148,16 +160,18 @@ } }, "node_modules/glob": { - "version": "10.3.15", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.15.tgz", - "integrity": "sha512-0c6RlJt1TICLyvJYIApxb8GsXoai0KUP7AxKKAtsYXdgJR1mGEUa7DgwShbdk1nly0PYoZj01xd4hzbq3fsjpw==", + "version": "10.4.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.2.tgz", + "integrity": "sha512-GwMlUF6PkPo3Gk21UxkCohOv0PLcIXVtKyLlpEI28R/cO/4eNOdmLk3CMW1wROV/WR/EsZOWAfBbBOqYvs88/w==", "dev": true, + "license": "ISC", "dependencies": { "foreground-child": "^3.1.0", - "jackspeak": "^2.3.6", - "minimatch": "^9.0.1", - "minipass": "^7.0.4", - "path-scurry": "^1.11.0" + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" }, "bin": { "glob": "dist/esm/bin.mjs" @@ -174,6 +188,7 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -182,13 +197,15 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/jackspeak": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", - "integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.0.tgz", + "integrity": "sha512-JVYhQnN59LVPFCEcVa2C3CrEKYacvjRfqIQl+h8oi91aLYQVWRYbxjPcv1bUiUy/kLmQaANrYfNMCO3kuEDHfw==", "dev": true, + "license": "BlueOak-1.0.0", "dependencies": { "@isaacs/cliui": "^8.0.2" }, @@ -203,19 +220,21 @@ } }, "node_modules/lru-cache": { - "version": "10.2.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.2.tgz", - "integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==", + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.3.0.tgz", + "integrity": "sha512-CQl19J/g+Hbjbv4Y3mFNNXFEL/5t/KCg8POCuUqd4rMKjGG+j1ybER83hxV58zL+dFI1PTkt3GNFSHRt+d8qEQ==", "dev": true, + "license": "ISC", "engines": { "node": "14 || >=16.14" } }, "node_modules/minimatch": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", - "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, + "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -227,19 +246,28 @@ } }, "node_modules/minipass": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.1.tgz", - "integrity": "sha512-UZ7eQ+h8ywIRAW1hIEl2AqdwzJucU/Kp59+8kkZeSvafXhZjul247BvIJjEVFVeON6d7lM46XX1HXCduKAS8VA==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", "dev": true, + "license": "ISC", "engines": { "node": ">=16 || 14 >=14.17" } }, + "node_modules/package-json-from-dist": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz", + "integrity": "sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -249,6 +277,7 @@ "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", "dev": true, + "license": "BlueOak-1.0.0", "dependencies": { "lru-cache": "^10.2.0", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" @@ -265,6 +294,7 @@ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.7.tgz", "integrity": "sha512-nV6YcJo5wbLW77m+8KjH8aB/7/rxQy9SZ0HY5shnwULfS+9nmTtVXAJET5NdZmCzA4fPI/Hm1wo/Po/4mopOdg==", "dev": true, + "license": "ISC", "dependencies": { "glob": "^10.3.7" }, @@ -283,6 +313,7 @@ "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, + "license": "MIT", "dependencies": { "shebang-regex": "^3.0.0" }, @@ -295,6 +326,7 @@ "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -304,6 +336,7 @@ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", "dev": true, + "license": "ISC", "engines": { "node": ">=14" }, @@ -316,6 +349,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", "dev": true, + "license": "MIT", "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", @@ -334,6 +368,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, + "license": "MIT", "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -348,6 +383,7 @@ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -356,13 +392,15 @@ "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/string-width-cjs/node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, + "license": "MIT", "dependencies": { "ansi-regex": "^5.0.1" }, @@ -375,6 +413,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", "dev": true, + "license": "MIT", "dependencies": { "ansi-regex": "^6.0.1" }, @@ -391,6 +430,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, + "license": "MIT", "dependencies": { "ansi-regex": "^5.0.1" }, @@ -403,15 +443,17 @@ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } }, "node_modules/typescript": { - "version": "5.4.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.5.tgz", - "integrity": "sha512-vcI4UpRgg81oIRUFwR0WSIHKt11nJ7SAVlYNIu+QpqeyXP+gpQJy/Z4+F0aGxSE4MqwjyXvW/TzgkLAx2AGHwQ==", + "version": "5.5.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", + "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -424,13 +466,15 @@ "version": "5.26.5", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, + "license": "ISC", "dependencies": { "isexe": "^2.0.0" }, @@ -446,6 +490,7 @@ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^6.1.0", "string-width": "^5.0.1", @@ -464,6 +509,7 @@ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", @@ -481,6 +527,7 @@ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -490,6 +537,7 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -504,13 +552,15 @@ "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/wrap-ansi-cjs/node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, + "license": "MIT", "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -525,6 +575,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, + "license": "MIT", "dependencies": { "ansi-regex": "^5.0.1" }, diff --git a/package-lock.json b/package-lock.json index 42d079262..1b95e9906 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,10 +19,11 @@ } }, "node_modules/@babel/runtime": { - "version": "7.24.5", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.5.tgz", - "integrity": "sha512-Nms86NXrsaeU9vbBJKni6gXiEXZ4CVpYVzEjDH9Sb8vmZ3UljyA1GSOJl/6LGPO8EHLuSF9H+IxNXHPX8QHJ4g==", + "version": "7.24.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.7.tgz", + "integrity": "sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==", "dev": true, + "license": "MIT", "dependencies": { "regenerator-runtime": "^0.14.0" }, @@ -35,6 +36,7 @@ "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", "dev": true, + "license": "MIT", "dependencies": { "@jridgewell/trace-mapping": "0.3.9" }, @@ -46,13 +48,15 @@ "version": "2.1.3", "resolved": "https://registry.npmjs.org/@glideapps/ts-necessities/-/ts-necessities-2.1.3.tgz", "integrity": "sha512-q9U8v/n9qbkd2zDYjuX3qtlbl+OIyI9zF+zQhZjfYOE9VMDH7tfcUSJ9p0lXoY3lxmGFne09yi4iiNeQUwV7AA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@isaacs/cliui": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", "dev": true, + "license": "ISC", "dependencies": { "string-width": "^5.1.2", "string-width-cjs": "npm:string-width@^4.2.0", @@ -70,6 +74,7 @@ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", "dev": true, + "license": "MIT", "engines": { "node": ">=12" }, @@ -82,6 +87,7 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", "dev": true, + "license": "MIT", "engines": { "node": ">=12" }, @@ -93,13 +99,15 @@ "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@isaacs/cliui/node_modules/string-width": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", "dev": true, + "license": "MIT", "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", @@ -117,6 +125,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", "dev": true, + "license": "MIT", "dependencies": { "ansi-regex": "^6.0.1" }, @@ -132,6 +141,7 @@ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^6.1.0", "string-width": "^5.0.1", @@ -149,6 +159,7 @@ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", "dev": true, + "license": "MIT", "engines": { "node": ">=6.0.0" } @@ -157,13 +168,15 @@ "version": "1.4.15", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@jridgewell/trace-mapping": { "version": "0.3.9", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", "dev": true, + "license": "MIT", "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -174,6 +187,7 @@ "resolved": "https://registry.npmjs.org/@lukeed/csprng/-/csprng-1.1.0.tgz", "integrity": "sha512-Z7C/xXCiGWsg0KuKsHTKJxbWhpI3Vs5GwLfOean7MGyVFGqdRgBbAjOCh6u4bbjPc/8MJ2pZmK/0DLdCbivLDA==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -183,6 +197,7 @@ "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-3.0.2.tgz", "integrity": "sha512-Z6GuOUdNQjP7FX+OuV2Ybyamse+/e0BFdTWBX5JxpBDKA+YkdLynDgG6HTF04zy6e9zPa19UX0WA2VDoehwhXQ==", "dev": true, + "license": "MIT", "peerDependencies": { "@nestjs/common": "^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0", "axios": "^1.3.1", @@ -194,6 +209,7 @@ "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.3.0.tgz", "integrity": "sha512-DGv34UHsZBxCM3H5QGE2XE/+oLJzz5+714JQjBhjD9VccFlQs3LRxo/epso4l7nJIiNlZkPyIUC8WzfU/5RTsQ==", "dev": true, + "license": "MIT", "dependencies": { "iterare": "1.2.1", "tslib": "2.6.2", @@ -224,6 +240,7 @@ "integrity": "sha512-N06P5ncknW/Pm8bj964WvLIZn2gNhHliCBoAO1LeBvNImYkecqKcrmLbY49Fa1rmMfEM3MuBHeDys3edeuYAOA==", "dev": true, "hasInstallScript": true, + "license": "MIT", "dependencies": { "@nuxtjs/opencollective": "0.3.2", "fast-safe-stringify": "2.1.1", @@ -261,6 +278,7 @@ "resolved": "https://registry.npmjs.org/@nuxtjs/opencollective/-/opencollective-0.3.2.tgz", "integrity": "sha512-um0xL3fO7Mf4fDxcqx9KryrB7zgRM5JSlvGN5AGkP6JLM5XEKyjeAiPbNxdXVXQ16isuAhYpvP88NgL2BGd6aA==", "dev": true, + "license": "MIT", "dependencies": { "chalk": "^4.1.0", "consola": "^2.15.0", @@ -280,6 +298,7 @@ "integrity": "sha512-4JKyrk55ohQK2FcuZbPdNvxdyXD14jjOIvE8hYjJ+E1cHbRbfXQXbYnjTODFE52Gx8eAxz8C9icuhDYDLn7nww==", "dev": true, "hasInstallScript": true, + "license": "Apache-2.0", "dependencies": { "@nestjs/axios": "3.0.2", "@nestjs/common": "10.3.0", @@ -316,6 +335,7 @@ "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", "dev": true, + "license": "MIT", "optional": true, "engines": { "node": ">=14" @@ -325,31 +345,36 @@ "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@tsconfig/node12": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@tsconfig/node14": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@tsconfig/node16": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/@types/node": { - "version": "20.12.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.11.tgz", - "integrity": "sha512-vDg9PZ/zi+Nqp6boSOT7plNuthRugEKixDv5sFTIpkE89MmNtEArAShI4mxuX2+UrLEe9pxC1vm2cjm9YlWbJw==", + "version": "20.14.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz", + "integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==", "dev": true, + "license": "MIT", "peer": true, "dependencies": { "undici-types": "~5.26.4" @@ -359,13 +384,15 @@ "version": "1.19.25", "resolved": "https://registry.npmjs.org/@types/urijs/-/urijs-1.19.25.tgz", "integrity": "sha512-XOfUup9r3Y06nFAZh3WvO0rBU4OtlfPB/vgxpjg+NRdGU6CN6djdc6OEiH+PcqHCY6eFLo9Ista73uarf4gnBg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", "dev": true, + "license": "MIT", "dependencies": { "event-target-shim": "^5.0.0" }, @@ -374,10 +401,11 @@ } }, "node_modules/acorn": { - "version": "8.11.3", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", - "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", + "integrity": "sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==", "dev": true, + "license": "MIT", "bin": { "acorn": "bin/acorn" }, @@ -386,10 +414,14 @@ } }, "node_modules/acorn-walk": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.2.tgz", - "integrity": "sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==", + "version": "8.3.3", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz", + "integrity": "sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==", "dev": true, + "license": "MIT", + "dependencies": { + "acorn": "^8.11.0" + }, "engines": { "node": ">=0.4.0" } @@ -399,6 +431,7 @@ "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz", "integrity": "sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==", "dev": true, + "license": "MIT", "dependencies": { "debug": "^4.3.4" }, @@ -411,6 +444,7 @@ "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", "dev": true, + "license": "MIT", "dependencies": { "type-fest": "^0.21.3" }, @@ -426,6 +460,7 @@ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -435,6 +470,7 @@ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, + "license": "MIT", "dependencies": { "color-convert": "^2.0.1" }, @@ -449,19 +485,22 @@ "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/axios": { "version": "1.6.8", "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", "dev": true, + "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", @@ -472,7 +511,8 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/base64-js": { "version": "1.5.1", @@ -492,13 +532,15 @@ "type": "consulting", "url": "https://feross.org/support" } - ] + ], + "license": "MIT" }, "node_modules/bl": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", "dev": true, + "license": "MIT", "dependencies": { "buffer": "^5.5.0", "inherits": "^2.0.4", @@ -510,6 +552,7 @@ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, + "license": "MIT", "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -519,7 +562,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/browser-or-node/-/browser-or-node-2.1.1.tgz", "integrity": "sha512-8CVjaLJGuSKMVTxJ2DpBl5XnlNDiT4cQFeuCJJrvJmts9YrTZDizTX7PjC2s6W4x+MBGZeEY6dGMrF04/6Hgqg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/buffer": { "version": "5.7.1", @@ -540,6 +584,7 @@ "url": "https://feross.org/support" } ], + "license": "MIT", "dependencies": { "base64-js": "^1.3.1", "ieee754": "^1.1.13" @@ -550,6 +595,7 @@ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" @@ -565,13 +611,15 @@ "version": "0.7.0", "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/cli-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", "dev": true, + "license": "MIT", "dependencies": { "restore-cursor": "^3.1.0" }, @@ -584,6 +632,7 @@ "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" }, @@ -596,6 +645,7 @@ "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==", "dev": true, + "license": "ISC", "engines": { "node": ">= 10" } @@ -605,6 +655,7 @@ "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", "dev": true, + "license": "ISC", "dependencies": { "string-width": "^4.2.0", "strip-ansi": "^6.0.0", @@ -616,6 +667,7 @@ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", @@ -633,6 +685,7 @@ "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.4.tgz", "integrity": "sha512-JQHZ2QMW6l3aH/j6xCqQThY/9OH4D/9ls34cgkUBiEeocRTU04tHfKPBsUK1PqZCUQM7GiA0IIXJSuXHI64Kbg==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.8" } @@ -641,13 +694,15 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/collection-utils/-/collection-utils-1.0.1.tgz", "integrity": "sha512-LA2YTIlR7biSpXkKYwwuzGjwL5rjWEZVOSnvdUc7gObvWe4WkjxOpfrdhoP7Hs09YWDVfg0Mal9BpAqLfVEzQg==", - "dev": true + "dev": true, + "license": "Apache-2.0" }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, + "license": "MIT", "dependencies": { "color-name": "~1.1.4" }, @@ -659,13 +714,15 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "dev": true, + "license": "MIT", "dependencies": { "delayed-stream": "~1.0.0" }, @@ -678,6 +735,7 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", "dev": true, + "license": "MIT", "engines": { "node": ">= 12" } @@ -686,19 +744,22 @@ "version": "4.1.4", "resolved": "https://registry.npmjs.org/compare-versions/-/compare-versions-4.1.4.tgz", "integrity": "sha512-FemMreK9xNyL8gQevsdRMrvO4lFCkQP7qbuktn1q8ndcNk1+0mz7lgE7b/sNvbhVgY4w6tMN1FDp6aADjqw2rw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/concurrently": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-6.5.1.tgz", "integrity": "sha512-FlSwNpGjWQfRwPLXvJ/OgysbBxPkWpiVjy1042b0U7on7S7qwwMIILRj7WTN1mTgqa582bG6NFuScOoh6Zgdag==", "dev": true, + "license": "MIT", "dependencies": { "chalk": "^4.1.0", "date-fns": "^2.16.1", @@ -721,6 +782,7 @@ "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", "dev": true, + "license": "Apache-2.0", "dependencies": { "tslib": "^1.9.0" }, @@ -733,6 +795,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -747,19 +810,22 @@ "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", - "dev": true + "dev": true, + "license": "0BSD" }, "node_modules/consola": { "version": "2.15.3", "resolved": "https://registry.npmjs.org/consola/-/consola-2.15.3.tgz", "integrity": "sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/console.table": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/console.table/-/console.table-0.10.0.tgz", "integrity": "sha512-dPyZofqggxuvSf7WXvNjuRfnsOk1YazkVP8FdxH4tcH2c37wc79/Yl6Bhr7Lsu00KMgy2ql/qCMuNu8xctZM8g==", "dev": true, + "license": "MIT", "dependencies": { "easy-table": "1.1.0" }, @@ -771,13 +837,15 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/cross-fetch": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz", "integrity": "sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==", "dev": true, + "license": "MIT", "dependencies": { "node-fetch": "^2.6.12" } @@ -787,6 +855,7 @@ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, + "license": "MIT", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", @@ -801,6 +870,7 @@ "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==", "dev": true, + "license": "MIT", "dependencies": { "@babel/runtime": "^7.21.0" }, @@ -813,10 +883,11 @@ } }, "node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", "dev": true, + "license": "MIT", "dependencies": { "ms": "2.1.2" }, @@ -834,6 +905,7 @@ "resolved": "https://registry.npmjs.org/defaults/-/defaults-1.0.4.tgz", "integrity": "sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==", "dev": true, + "license": "MIT", "dependencies": { "clone": "^1.0.2" }, @@ -846,6 +918,7 @@ "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.4.0" } @@ -855,6 +928,7 @@ "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", "dev": true, + "license": "BSD-3-Clause", "engines": { "node": ">=0.3.1" } @@ -863,13 +937,15 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/easy-table": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/easy-table/-/easy-table-1.1.0.tgz", "integrity": "sha512-oq33hWOSSnl2Hoh00tZWaIPi1ievrD9aFG82/IgjlycAnW9hHx5PkJiXpxPsgEE+H7BsbVQXFVFST8TEXS6/pA==", "dev": true, + "license": "MIT", "optionalDependencies": { "wcwidth": ">=1.0.1" } @@ -878,13 +954,15 @@ "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/escalade": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } @@ -894,6 +972,7 @@ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.8.0" } @@ -903,6 +982,7 @@ "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } @@ -912,6 +992,7 @@ "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.8.x" } @@ -921,6 +1002,7 @@ "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", "dev": true, + "license": "MIT", "dependencies": { "chardet": "^0.7.0", "iconv-lite": "^0.4.24", @@ -934,13 +1016,15 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/figures": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", "dev": true, + "license": "MIT", "dependencies": { "escape-string-regexp": "^1.0.5" }, @@ -962,6 +1046,7 @@ "url": "https://github.com/sponsors/RubenVerborgh" } ], + "license": "MIT", "engines": { "node": ">=4.0" }, @@ -972,10 +1057,11 @@ } }, "node_modules/foreground-child": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", - "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.2.1.tgz", + "integrity": "sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==", "dev": true, + "license": "ISC", "dependencies": { "cross-spawn": "^7.0.0", "signal-exit": "^4.0.1" @@ -992,6 +1078,7 @@ "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", "dev": true, + "license": "ISC", "engines": { "node": ">=14" }, @@ -1004,6 +1091,7 @@ "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", "dev": true, + "license": "MIT", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", @@ -1018,6 +1106,7 @@ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", "dev": true, + "license": "MIT", "dependencies": { "graceful-fs": "^4.2.0", "jsonfile": "^6.0.1", @@ -1031,13 +1120,15 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true, + "license": "ISC", "engines": { "node": "6.* || 8.* || >= 10.*" } @@ -1046,7 +1137,9 @@ "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", "dev": true, + "license": "ISC", "dependencies": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -1066,13 +1159,15 @@ "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/handlebars": { "version": "4.7.8", "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz", "integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==", "dev": true, + "license": "MIT", "dependencies": { "minimist": "^1.2.5", "neo-async": "^2.6.2", @@ -1094,6 +1189,7 @@ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -1103,6 +1199,7 @@ "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.4.tgz", "integrity": "sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg==", "dev": true, + "license": "MIT", "dependencies": { "agent-base": "^7.0.2", "debug": "4" @@ -1116,6 +1213,7 @@ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "dev": true, + "license": "MIT", "dependencies": { "safer-buffer": ">= 2.1.2 < 3" }, @@ -1141,13 +1239,16 @@ "type": "consulting", "url": "https://feross.org/support" } - ] + ], + "license": "BSD-3-Clause" }, "node_modules/inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", "dev": true, + "license": "ISC", "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -1157,13 +1258,15 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/inquirer": { "version": "8.2.6", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-8.2.6.tgz", "integrity": "sha512-M1WuAmb7pn9zdFRtQYk26ZBoY043Sse0wVDdk4Bppr+JOXyQYybdtvK+l9wUibhtjdjvtoiNy8tk+EgsYIUqKg==", "dev": true, + "license": "MIT", "dependencies": { "ansi-escapes": "^4.2.1", "chalk": "^4.1.1", @@ -1190,6 +1293,7 @@ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -1199,6 +1303,7 @@ "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-1.0.0.tgz", "integrity": "sha512-2HvIEKRoqS62guEC+qBjpvRubdX910WCMuJTZ+I9yvqKU2/12eSL549HMwtabb4oupdj2sMP50k+XJfB/8JE6w==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -1208,6 +1313,7 @@ "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -1219,28 +1325,32 @@ "version": "1.2.4", "resolved": "https://registry.npmjs.org/is-url/-/is-url-1.2.4.tgz", "integrity": "sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/iterare": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/iterare/-/iterare-1.2.1.tgz", "integrity": "sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q==", "dev": true, + "license": "ISC", "engines": { "node": ">=6" } }, "node_modules/jackspeak": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", - "integrity": "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.0.tgz", + "integrity": "sha512-JVYhQnN59LVPFCEcVa2C3CrEKYacvjRfqIQl+h8oi91aLYQVWRYbxjPcv1bUiUy/kLmQaANrYfNMCO3kuEDHfw==", "dev": true, + "license": "BlueOak-1.0.0", "dependencies": { "@isaacs/cliui": "^8.0.2" }, @@ -1258,13 +1368,15 @@ "version": "3.7.7", "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.7.tgz", "integrity": "sha512-7rCnleh0z2CkXhH67J8K1Ytz0b2Y+yxTPL+/KOJoa20hfnVQ/3/T6W/KflYI4bRHRagNeXeU2bkNGI3v1oS/lw==", - "dev": true + "dev": true, + "license": "BSD-3-Clause" }, "node_modules/jsonfile": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", "dev": true, + "license": "MIT", "dependencies": { "universalify": "^2.0.0" }, @@ -1276,13 +1388,15 @@ "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/log-symbols": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", "dev": true, + "license": "MIT", "dependencies": { "chalk": "^4.1.0", "is-unicode-supported": "^0.1.0" @@ -1295,10 +1409,11 @@ } }, "node_modules/lru-cache": { - "version": "10.2.2", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.2.tgz", - "integrity": "sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==", + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.3.0.tgz", + "integrity": "sha512-CQl19J/g+Hbjbv4Y3mFNNXFEL/5t/KCg8POCuUqd4rMKjGG+j1ybER83hxV58zL+dFI1PTkt3GNFSHRt+d8qEQ==", "dev": true, + "license": "ISC", "engines": { "node": "14 || >=16.14" } @@ -1307,13 +1422,15 @@ "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.6" } @@ -1323,6 +1440,7 @@ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", "dev": true, + "license": "MIT", "dependencies": { "mime-db": "1.52.0" }, @@ -1335,6 +1453,7 @@ "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } @@ -1344,6 +1463,7 @@ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", "dev": true, + "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" }, @@ -1356,15 +1476,17 @@ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", "dev": true, + "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" } }, "node_modules/minipass": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.1.tgz", - "integrity": "sha512-UZ7eQ+h8ywIRAW1hIEl2AqdwzJucU/Kp59+8kkZeSvafXhZjul247BvIJjEVFVeON6d7lM46XX1HXCduKAS8VA==", + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", "dev": true, + "license": "ISC", "engines": { "node": ">=16 || 14 >=14.17" } @@ -1373,25 +1495,29 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/neo-async": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/node-fetch": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", "dev": true, + "license": "MIT", "dependencies": { "whatwg-url": "^5.0.0" }, @@ -1412,6 +1538,7 @@ "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, + "license": "ISC", "dependencies": { "wrappy": "1" } @@ -1421,6 +1548,7 @@ "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", "dev": true, + "license": "MIT", "dependencies": { "mimic-fn": "^2.1.0" }, @@ -1436,6 +1564,7 @@ "resolved": "https://registry.npmjs.org/ora/-/ora-5.4.1.tgz", "integrity": "sha512-5b6Y85tPxZZ7QytO+BQzysW31HJku27cRIlkbAXaNx+BdcVi+LlRFmVXzeF6a7JCwJpyw5c4b+YSVImQIrBpuQ==", "dev": true, + "license": "MIT", "dependencies": { "bl": "^4.1.0", "chalk": "^4.1.0", @@ -1459,21 +1588,31 @@ "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.10.0" } }, + "node_modules/package-json-from-dist": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz", + "integrity": "sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, "node_modules/pako": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", - "dev": true + "dev": true, + "license": "(MIT AND Zlib)" }, "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.10.0" } @@ -1483,6 +1622,7 @@ "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -1492,6 +1632,7 @@ "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", "dev": true, + "license": "BlueOak-1.0.0", "dependencies": { "lru-cache": "^10.2.0", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" @@ -1507,13 +1648,15 @@ "version": "3.2.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.2.0.tgz", "integrity": "sha512-jczvQbCUS7XmS7o+y1aEO9OBVFeZBQ1MDSEqmO7xSoPgOPoowY/SxLpZ6Vh97/8qHZOteiCKb7gkG9gA2ZUxJA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/pluralize": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==", "dev": true, + "license": "MIT", "engines": { "node": ">=4" } @@ -1523,6 +1666,7 @@ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", "dev": true, + "license": "MIT", "bin": { "prettier": "bin/prettier.cjs" }, @@ -1538,6 +1682,7 @@ "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", "dev": true, + "license": "MIT", "engines": { "node": ">= 0.6.0" } @@ -1546,13 +1691,15 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/quicktype-core": { "version": "23.0.81", "resolved": "https://registry.npmjs.org/quicktype-core/-/quicktype-core-23.0.81.tgz", "integrity": "sha512-iJQpCEzSQIkffJPS5NC+0w+Rq9faGgz09L+WIbseu1toFfj+M/3KTG5jhzdY/uN88fWosAom2fMoEADA403+rQ==", "dev": true, + "license": "Apache-2.0", "dependencies": { "@glideapps/ts-necessities": "2.1.3", "@types/urijs": "^1.19.19", @@ -1590,6 +1737,7 @@ "url": "https://feross.org/support" } ], + "license": "MIT", "dependencies": { "base64-js": "^1.3.1", "ieee754": "^1.2.1" @@ -1600,6 +1748,7 @@ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.4.2.tgz", "integrity": "sha512-Lk/fICSyIhodxy1IDK2HazkeGjSmezAWX2egdtJnYhtzKEsBPJowlI6F6LPb5tqIQILrMbx22S5o3GuJavPusA==", "dev": true, + "license": "MIT", "dependencies": { "abort-controller": "^3.0.0", "buffer": "^6.0.3", @@ -1616,6 +1765,7 @@ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", "dev": true, + "license": "MIT", "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -1629,19 +1779,22 @@ "version": "0.1.13", "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz", "integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==", - "dev": true + "dev": true, + "license": "Apache-2.0" }, "node_modules/regenerator-runtime": { "version": "0.14.1", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz", "integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.10.0" } @@ -1651,6 +1804,7 @@ "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", "dev": true, + "license": "MIT", "dependencies": { "onetime": "^5.1.0", "signal-exit": "^3.0.2" @@ -1664,6 +1818,7 @@ "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.7.tgz", "integrity": "sha512-nV6YcJo5wbLW77m+8KjH8aB/7/rxQy9SZ0HY5shnwULfS+9nmTtVXAJET5NdZmCzA4fPI/Hm1wo/Po/4mopOdg==", "dev": true, + "license": "ISC", "dependencies": { "glob": "^10.3.7" }, @@ -1682,21 +1837,24 @@ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, + "license": "MIT", "dependencies": { "balanced-match": "^1.0.0" } }, "node_modules/rimraf/node_modules/glob": { - "version": "10.3.15", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.15.tgz", - "integrity": "sha512-0c6RlJt1TICLyvJYIApxb8GsXoai0KUP7AxKKAtsYXdgJR1mGEUa7DgwShbdk1nly0PYoZj01xd4hzbq3fsjpw==", + "version": "10.4.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.2.tgz", + "integrity": "sha512-GwMlUF6PkPo3Gk21UxkCohOv0PLcIXVtKyLlpEI28R/cO/4eNOdmLk3CMW1wROV/WR/EsZOWAfBbBOqYvs88/w==", "dev": true, + "license": "ISC", "dependencies": { "foreground-child": "^3.1.0", - "jackspeak": "^2.3.6", - "minimatch": "^9.0.1", - "minipass": "^7.0.4", - "path-scurry": "^1.11.0" + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" }, "bin": { "glob": "dist/esm/bin.mjs" @@ -1709,10 +1867,11 @@ } }, "node_modules/rimraf/node_modules/minimatch": { - "version": "9.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.4.tgz", - "integrity": "sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==", + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", "dev": true, + "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, @@ -1728,6 +1887,7 @@ "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.12.0" } @@ -1737,6 +1897,7 @@ "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", "dev": true, + "license": "Apache-2.0", "dependencies": { "tslib": "^2.1.0" } @@ -1759,19 +1920,22 @@ "type": "consulting", "url": "https://feross.org/support" } - ] + ], + "license": "MIT" }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, + "license": "MIT", "dependencies": { "shebang-regex": "^3.0.0" }, @@ -1784,6 +1948,7 @@ "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true, + "license": "MIT", "engines": { "node": ">=8" } @@ -1792,13 +1957,15 @@ "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true, + "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" } @@ -1807,13 +1974,15 @@ "version": "0.0.2-1", "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2-1.tgz", "integrity": "sha512-n98l9E2RMSJ9ON1AKisHzz7V42VDiBQGY6PB1BwRglz99wpVsSuGzQ+jOi6lFXBGVTCrRpltvjm+/XA+tpeJrg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", "dev": true, + "license": "MIT", "dependencies": { "safe-buffer": "~5.2.0" } @@ -1823,6 +1992,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, + "license": "MIT", "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -1838,6 +2008,7 @@ "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, + "license": "MIT", "dependencies": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -1852,6 +2023,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, + "license": "MIT", "dependencies": { "ansi-regex": "^5.0.1" }, @@ -1865,6 +2037,7 @@ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", "dev": true, + "license": "MIT", "dependencies": { "ansi-regex": "^5.0.1" }, @@ -1877,6 +2050,7 @@ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, + "license": "MIT", "dependencies": { "has-flag": "^4.0.0" }, @@ -1888,19 +2062,22 @@ "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/tiny-inflate": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/tiny-inflate/-/tiny-inflate-1.0.3.tgz", "integrity": "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", "dev": true, + "license": "MIT", "dependencies": { "os-tmpdir": "~1.0.2" }, @@ -1912,13 +2089,15 @@ "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/tree-kill": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", "dev": true, + "license": "MIT", "bin": { "tree-kill": "cli.js" } @@ -1928,6 +2107,7 @@ "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", "dev": true, + "license": "MIT", "dependencies": { "@cspotcode/source-map-support": "^0.8.0", "@tsconfig/node10": "^1.0.7", @@ -1970,13 +2150,15 @@ "version": "2.6.2", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", - "dev": true + "dev": true, + "license": "0BSD" }, "node_modules/type-fest": { "version": "0.21.3", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", "dev": true, + "license": "(MIT OR CC0-1.0)", "engines": { "node": ">=10" }, @@ -1989,6 +2171,7 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", "dev": true, + "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -1998,10 +2181,11 @@ } }, "node_modules/uglify-js": { - "version": "3.17.4", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz", - "integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==", + "version": "3.18.0", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.18.0.tgz", + "integrity": "sha512-SyVVbcNBCk0dzr9XL/R/ySrmYf0s372K6/hFklzgcp2lBFyXtw4I7BOdDjlLhE1aVqaI/SHWXWmYdlZxuyF38A==", "dev": true, + "license": "BSD-2-Clause", "optional": true, "bin": { "uglifyjs": "bin/uglifyjs" @@ -2015,6 +2199,7 @@ "resolved": "https://registry.npmjs.org/uid/-/uid-2.0.2.tgz", "integrity": "sha512-u3xV3X7uzvi5b1MncmZo3i2Aw222Zk1keqLA1YkHldREkAhAqi65wuPfe7lHx8H/Wzy+8CE7S7uS3jekIM5s8g==", "dev": true, + "license": "MIT", "dependencies": { "@lukeed/csprng": "^1.0.0" }, @@ -2027,6 +2212,7 @@ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", "dev": true, + "license": "MIT", "peer": true }, "node_modules/unicode-properties": { @@ -2034,6 +2220,7 @@ "resolved": "https://registry.npmjs.org/unicode-properties/-/unicode-properties-1.4.1.tgz", "integrity": "sha512-CLjCCLQ6UuMxWnbIylkisbRj31qxHPAurvena/0iwSVbQ2G1VY5/HjV0IRabOEbDHlzZlRdCrD4NhB0JtU40Pg==", "dev": true, + "license": "MIT", "dependencies": { "base64-js": "^1.3.0", "unicode-trie": "^2.0.0" @@ -2044,6 +2231,7 @@ "resolved": "https://registry.npmjs.org/unicode-trie/-/unicode-trie-2.0.0.tgz", "integrity": "sha512-x7bc76x0bm4prf1VLg79uhAzKw8DVboClSN5VxJuQ+LKDOVEW9CdH+VY7SP+vX7xCYQqzzgQpFqz15zeLvAtZQ==", "dev": true, + "license": "MIT", "dependencies": { "pako": "^0.2.5", "tiny-inflate": "^1.0.0" @@ -2053,13 +2241,15 @@ "version": "0.2.9", "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", "integrity": "sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/universalify": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", "dev": true, + "license": "MIT", "engines": { "node": ">= 10.0.0" } @@ -2068,25 +2258,29 @@ "version": "1.19.11", "resolved": "https://registry.npmjs.org/urijs/-/urijs-1.19.11.tgz", "integrity": "sha512-HXgFDgDommxn5/bIv0cnQZsPhHDA90NPHD6+c/v21U5+Sx5hoP8+dP9IZXBU1gIfvdRfhG8cel9QNPeionfcCQ==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/wcwidth": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz", "integrity": "sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==", "dev": true, + "license": "MIT", "dependencies": { "defaults": "^1.0.3" } @@ -2095,13 +2289,15 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "dev": true + "dev": true, + "license": "BSD-2-Clause" }, "node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", "dev": true, + "license": "MIT", "dependencies": { "tr46": "~0.0.3", "webidl-conversions": "^3.0.0" @@ -2112,6 +2308,7 @@ "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, + "license": "ISC", "dependencies": { "isexe": "^2.0.0" }, @@ -2126,13 +2323,15 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", "integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==", - "dev": true + "dev": true, + "license": "MIT" }, "node_modules/wrap-ansi": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", @@ -2148,6 +2347,7 @@ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, + "license": "MIT", "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", @@ -2164,22 +2364,25 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "dev": true + "dev": true, + "license": "ISC" }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", "dev": true, + "license": "ISC", "engines": { "node": ">=10" } }, "node_modules/yaml": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.2.tgz", - "integrity": "sha512-B3VqDZ+JAg1nZpaEmWtTXUlBneoGx6CPM9b0TENK6aoSu5t73dItudwdgmi6tHlIZZId4dZ9skcAQ2UbcyAeVA==", + "version": "2.4.5", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.5.tgz", + "integrity": "sha512-aBx2bnqDzVOyNKfsysjA2ms5ZlnjSAW2eG3/L5G/CSujfjLJTJsEw1bGw8kCf04KodQWk1pxlGnZ56CRxiawmg==", "dev": true, + "license": "ISC", "bin": { "yaml": "bin.mjs" }, @@ -2192,6 +2395,7 @@ "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", "dev": true, + "license": "MIT", "dependencies": { "cliui": "^7.0.2", "escalade": "^3.1.1", @@ -2210,6 +2414,7 @@ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz", "integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==", "dev": true, + "license": "ISC", "engines": { "node": ">=10" } @@ -2219,6 +2424,7 @@ "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", "dev": true, + "license": "MIT", "engines": { "node": ">=6" } From 56547d7e8e44e89f391baa387b57e4102cb611d2 Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Fri, 28 Jun 2024 12:02:11 -0700 Subject: [PATCH 037/214] [SM-1130] - add install scripts (#645) ## Type of change - [ ] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [x] Build/deploy pipeline (DevOps) - [x] Other ## Objective Allow easy installation of `bws` on most systems with: `curl | sh` on Linux and macOS or `iwr | iex` on Windows ## Code changes - **crates/bws/scripts/install.(sh|ps1):** added install scripts that will download `bws` from GitHub Releases, validate the checksums, and install it. I am unsure if this is the _best_ place to house these scripts and would welcome suggestions for other places these might belong. - **.github/workflows/version-bump.yml:** added version bumps for the install scripts ## Before you submit - Please add **unit tests** where it makes sense to do so --- .github/workflows/version-bump.yml | 9 +- crates/bws/README.md | 20 +++- crates/bws/scripts/install.ps1 | 108 +++++++++++++++++ crates/bws/scripts/install.sh | 180 +++++++++++++++++++++++++++++ 4 files changed, 313 insertions(+), 4 deletions(-) create mode 100755 crates/bws/scripts/install.ps1 create mode 100755 crates/bws/scripts/install.sh diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index 24a2c7997..6c10d51bf 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -103,16 +103,19 @@ jobs: run: cargo set-version -p bitwarden-napi ${{ inputs.version_number }} ### bitwarden - - name: Bump bitwarden crate Version if: ${{ inputs.project == 'bitwarden' }} run: cargo set-version -p bitwarden ${{ inputs.version_number }} ### bws - - name: Bump bws Version if: ${{ inputs.project == 'bws' }} - run: cargo set-version -p bws ${{ inputs.version_number }} + run: | + cargo set-version -p bws ${{ inputs.version_number }} + # bump the version in install.sh + sed -i 's/DEFAULT_BWS_VERSION="[0-9]\+\.[0-9]\+\.[0-9]\+"/DEFAULT_BWS_VERSION="${{ inputs.version_number }}"/' ./crates/bws/scripts/install.sh + # bump the version in install.ps1 + sed -i 's/\$defaultBwsVersion = "[0-9]\+\.[0-9]\+\.[0-9]\+"/\$defaultBwsVersion = "${{ inputs.version_number }}"/' ./crates/bws/scripts/install.ps1 ### python - name: Bump python-sdk Version diff --git a/crates/bws/README.md b/crates/bws/README.md index ace5210f1..2b9c8c99c 100644 --- a/crates/bws/README.md +++ b/crates/bws/README.md @@ -6,11 +6,29 @@ and might be missing some functionality. ## Install +We offer three ways to install bws: + +### Cargo (crates.io) + +Download bws via `cargo` from [crates.io](https://crates.io): + ```bash cargo install bws ``` -Or download a pre-built binary from the [Releases](https://github.com/bitwarden/sdk/releases) page. +### Install Script (from GitHub Releases) + +Linux/macOS: `curl https://bws.bitwarden.com/install | sh` + +Windows: `iwr https://bws.bitwarden.com/install | iex` + +An optional `-u/--uninstall` flag can be passed to the POSIX script to uninstall the CLI. The +PowerShell version accepts an equivalent `-Uninstall` flag. The uninstallation process will remove +the `bws` binary and the configuration directory (`~/.bws`). + +### GitHub Releases (Manual) + +Download a pre-built binary from the [Releases](https://github.com/bitwarden/sdk/releases) page. ## Usage diff --git a/crates/bws/scripts/install.ps1 b/crates/bws/scripts/install.ps1 new file mode 100755 index 000000000..f39846c20 --- /dev/null +++ b/crates/bws/scripts/install.ps1 @@ -0,0 +1,108 @@ +param ( + [switch]$Uninstall +) + +$ErrorActionPreference = "Stop" + +$defaultBwsVersion = "0.5.0" +$bwsVersion = if ($env:bwsVersion) { $env:bwsVersion } else { $defaultBwsVersion } +$installDir = [Environment]::GetFolderPath([Environment+SpecialFolder]::LocalApplicationData) | Join-Path -ChildPath "Programs" | Join-Path -ChildPath "Bitwarden" + +# https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-processor#properties +$processorArch = (Get-CimInstance -ClassName Win32_Processor).Architecture +if ($processorArch -eq 9) { + $arch = "x86_64" +} elseif ($processorArch -eq 12) { + $arch = "aarch64" +} else { + throw "Unsupported architecture: $processorArch" +} + +function Test-BwsInstallation { + $existingBws = Get-Command bws -ErrorAction SilentlyContinue + if ($null -ne $existingBws) { + $userInput = Read-Host "bws is already installed at $($existingBws.Source). Do you want to overwrite it? (Y/N)" + if ($userInput -ne "Y") { + Write-Host "Installation cancelled by user." + exit + } + } +} + +function Invoke-BwsDownload { + Write-Host "Detected architecture: $arch" + + $bwsUrl = "https://github.com/bitwarden/sdk/releases/download/bws-v$bwsVersion/bws-$arch-pc-windows-msvc-$bwsVersion.zip" + Write-Host "Downloading bws from: $bwsUrl" + $outputPath = Join-Path $env:TEMP "bws.zip" + Invoke-WebRequest -Uri $bwsUrl -OutFile $outputPath + return $outputPath +} + +function Test-Checksum { + param($zipPath) + Write-Host "Validating checksum..." + + $checksumUrl = "https://github.com/bitwarden/sdk/releases/download/bws-v$bwsVersion/bws-sha256-checksums-$bwsVersion.txt" + $checksumFile = Join-Path $env:TEMP "bws-checksums.txt" + Invoke-WebRequest -Uri $checksumUrl -OutFile $checksumFile + + $expectedChecksum = (Get-Content $checksumFile | Where-Object { $_ -match "bws-$arch-pc-windows-msvc-$bwsVersion.zip" }).Split(" ")[0] + $actualChecksum = (Get-FileHash -Algorithm SHA256 -Path $zipPath).Hash + + if ($actualChecksum -ne $expectedChecksum) { + throw "Checksum validation failed. Expected: $expectedChecksum, Actual: $actualChecksum" + } else { + Write-Host "Checksum validation successful." + } +} + +function Install-Bws { + param($zipPath) + Write-Host "Installing bws..." + New-Item -ItemType Directory -Force -Path $installDir | Out-Null + Expand-Archive -Force $zipPath -DestinationPath $installDir + Write-Host "bws installed to $installDir" + setx PATH "$env:PATH;$installDir" + Write-Host "$installDir has been added to your PATH" + Write-Host "Please restart your shell to use bws" +} + +function Test-Bws { + Write-Host "Checking bws..." + $bwsPath = Join-Path $installDir "bws.exe" + if (Test-Path $bwsPath) { + Write-Host "bws is installed at $bwsPath" + } else { + throw "bws is not installed" + } +} + +function Remove-Bws { + Write-Host "Uninstalling bws..." + + if (Test-Path $installDir) { + Remove-Item -Path $installDir -Recurse -Force + Write-Host "bws uninstalled from $installDir" + } else { + Write-Host "bws installation directory not found at $installDir. Skipping removal." + } + + $configDir = "$env:USERPROFILE\.bws" + if (Test-Path $configDir -PathType Container) { + Remove-Item -Path $configDir -Recurse -Force + Write-Host "bws config directory removed from $configDir" + } else { + Write-Host "bws config directory not found at $configDir. Skipping removal." + } +} + +if ($Uninstall) { + Remove-Bws +} else { + Test-BwsInstallation + $zipPath = Invoke-BwsDownload + Test-Checksum -zipPath $zipPath + Install-Bws -zipPath $zipPath + Test-Bws +} diff --git a/crates/bws/scripts/install.sh b/crates/bws/scripts/install.sh new file mode 100755 index 000000000..126ae9e22 --- /dev/null +++ b/crates/bws/scripts/install.sh @@ -0,0 +1,180 @@ +#!/bin/sh + +################################################## +# An installer for the bws command line utility. # +################################################## + +DEFAULT_BWS_VERSION="0.5.0" +BWS_VERSION="${BWS_VERSION:-$DEFAULT_BWS_VERSION}" + +main() { + case "$1" in + -u | --uninstall) + uninstall_bws + ;; + *) + check_required + platform_detect + arch_detect + download_bws + validate_checksum + install_bws + ;; + esac +} + +error() { + echo "$1" >&2 + echo "Exiting..." >&2 + exit 1 +} + +check_required() { + if ! command -v curl >/dev/null && ! command -v wget >/dev/null; then + error "curl or wget is required to download bws." + fi + + if ! command -v unzip >/dev/null; then + error "unzip is required to install bws." + fi +} + +can_sudo() { + if command -v sudo >/dev/null; then + echo "Attempting to install bws with sudo. Please enter your password if prompted." + if sudo -v 2>/dev/null; then + echo "sudo is available and we have the necessary permissions." + echo "Installing bws to /usr/local/bin..." + return 0 + else + echo "sudo is available, but we failed to authenticate." + return 1 + fi + else + echo "sudo is not available." + return 1 + fi +} + +platform_detect() { + if [ "$(uname -s)" = "Linux" ]; then + PLATFORM="unknown-linux-gnu" + elif [ "$(uname -s)" = "Darwin" ]; then + PLATFORM="apple-darwin" + else + error "Unsupported platform: $(uname -s)" + fi +} + +arch_detect() { + if [ "$(uname -m)" = "x86_64" ]; then + ARCH="x86_64" + elif [ "$(uname -m)" = "aarch64" ]; then # Linux uname output + ARCH="aarch64" + elif [ "$(uname -m)" = "arm64" ]; then # Darwin uname output + ARCH="aarch64" + else + error "Unsupported architecture: $(uname -m)" + fi +} + +checksum() { + if command -v sha256sum >/dev/null; then + sha256sum "$1" + else + shasum -a 256 "$1" + fi +} + +downloader() { + if command -v curl >/dev/null; then + curl -L -o "$2" "$1" + else + wget -O "$2" "$1" + fi +} + +extract() { + unzip -o "$1" -d "$2" +} + +download_bws() { + bws_url="https://github.com/bitwarden/sdk/releases/download/bws-v${BWS_VERSION}/bws-${ARCH}-${PLATFORM}-${BWS_VERSION}.zip" + echo "Downloading bws from: $bws_url" + tmp_dir="$(mktemp -d)" + downloader "$bws_url" "$tmp_dir/bws.zip" +} + +validate_checksum() { + checksum_url="https://github.com/bitwarden/sdk/releases/download/bws-v${BWS_VERSION}/bws-sha256-checksums-${BWS_VERSION}.txt" + echo "Downloading checksum file from: $checksum_url" + checksum_file="$tmp_dir/bws-checksums.txt" + downloader "$checksum_url" "$checksum_file" + + expected_checksum="$(grep "bws-${ARCH}-${PLATFORM}-${BWS_VERSION}.zip" "$checksum_file" | awk '{print $1}')" + actual_checksum="$(checksum "$tmp_dir/bws.zip" | awk '{print $1}')" + + if [ "$actual_checksum" != "$expected_checksum" ]; then + error "Checksum validation failed. Expected: $expected_checksum, Actual: $actual_checksum" + else + echo "Checksum validation successful." + fi +} + +install_bws() { + echo "Installing bws..." + extract "$tmp_dir/bws.zip" "$tmp_dir" + chmod +x "$tmp_dir/bws" + + if can_sudo; then + sudo install -m 755 "$tmp_dir/bws" /usr/local/bin/bws + + if ! command -v bws >/dev/null; then + error "Installation failed. bws was not found in /usr/local/bin" + fi + + echo "bws installed to /usr/local/bin/bws" + else + echo "Installing to your \$HOME directory..." + user_bin_dir="${HOME}/.local/bin" + mkdir -p "${user_bin_dir}" + install -m 755 "$tmp_dir/bws" "${user_bin_dir}/bws" + + if ! command -v "${user_bin_dir}/bws" >/dev/null; then + error "Installation failed. bws was not found in ${user_bin_dir}" + fi + + echo "bws installed at ${user_bin_dir}/bws" + echo "Please add ${user_bin_dir} to your PATH by adding the following line to your ~/.profile or shell rc file:" + echo "export PATH=\"\$PATH:${user_bin_dir}\"" + fi + + rm -rf "$tmp_dir" +} + +uninstall_bws() { + if command -v bws >/dev/null; then + echo "Uninstalling bws..." + if can_sudo; then + sudo rm "$(command -v bws)" + else + rm "$(command -v bws)" + fi + + # Safely remove the configuration directory + if [ -n "$HOME" ]; then + echo "Removing bws configuration directory at ${HOME}/.bws" + echo "If you use another directory for your configuration, you may want to remove it manually." + rm -rf "${HOME}/.bws" + else + echo "HOME environment variable is not set. Cannot safely remove .bws directory." + fi + + echo "bws uninstalled successfully." + else + echo "bws is not installed." + fi + exit 0 +} + +main "$@" From adeb707c40db1472af8621195a746c99a371a78d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Fri, 28 Jun 2024 21:47:11 +0200 Subject: [PATCH 038/214] Update zxcvbn (#864) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📔 Objective This contains a small breaking change in the zxcvbn API, so I've created the PR manually. With this update and #865 we get rid of any dependencies using `syn 0.x`, which should help a little bit with build times. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- Cargo.lock | 95 +++++-------------- crates/bitwarden-core/Cargo.toml | 2 +- .../src/auth/password/strength.rs | 2 +- 3 files changed, 27 insertions(+), 72 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bbf507a2f..017bceae8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -931,7 +931,7 @@ dependencies = [ "anstream", "anstyle", "clap_lex", - "strsim 0.11.1", + "strsim", ] [[package]] @@ -1298,38 +1298,14 @@ dependencies = [ "syn 2.0.68", ] -[[package]] -name = "darling" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b750cb3417fd1b327431a470f388520309479ab0bf5e323505daf0290cd3850" -dependencies = [ - "darling_core 0.14.4", - "darling_macro 0.14.4", -] - [[package]] name = "darling" version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" dependencies = [ - "darling_core 0.20.9", - "darling_macro 0.20.9", -] - -[[package]] -name = "darling_core" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" -dependencies = [ - "fnv", - "ident_case", - "proc-macro2", - "quote", - "strsim 0.10.0", - "syn 1.0.109", + "darling_core", + "darling_macro", ] [[package]] @@ -1342,28 +1318,17 @@ dependencies = [ "ident_case", "proc-macro2", "quote", - "strsim 0.11.1", + "strsim", "syn 2.0.68", ] -[[package]] -name = "darling_macro" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4aab4dbc9f7611d8b55048a3a16d2d010c2c8334e46304b40ac1cc14bf3b48e" -dependencies = [ - "darling_core 0.14.4", - "quote", - "syn 1.0.109", -] - [[package]] name = "darling_macro" version = "0.20.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ - "darling_core 0.20.9", + "darling_core", "quote", "syn 2.0.68", ] @@ -1415,33 +1380,33 @@ dependencies = [ [[package]] name = "derive_builder" -version = "0.12.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d67778784b508018359cbc8696edb3db78160bab2c2a28ba7f56ef6932997f8" +checksum = "0350b5cb0331628a5916d6c5c0b72e97393b8b6b03b47a9284f4e7f5a405ffd7" dependencies = [ "derive_builder_macro", ] [[package]] name = "derive_builder_core" -version = "0.12.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c11bdc11a0c47bc7d37d582b5285da6849c96681023680b906673c5707af7b0f" +checksum = "d48cda787f839151732d396ac69e3473923d54312c070ee21e9effcaa8ca0b1d" dependencies = [ - "darling 0.14.4", + "darling", "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.68", ] [[package]] name = "derive_builder_macro" -version = "0.12.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebcda35c7a396850a55ffeac740804b40ffec779b98fffbb1738f4033f0ee79e" +checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 1.0.109", + "syn 2.0.68", ] [[package]] @@ -1602,12 +1567,13 @@ dependencies = [ [[package]] name = "fancy-regex" -version = "0.11.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" +checksum = "531e46835a22af56d1e3b66f04844bed63158bc094a628bec1d321d9b4c44bf2" dependencies = [ "bit-set", - "regex", + "regex-automata", + "regex-syntax", ] [[package]] @@ -2988,12 +2954,6 @@ dependencies = [ "syn 2.0.68", ] -[[package]] -name = "quick-error" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" - [[package]] name = "quick-xml" version = "0.31.0" @@ -3628,7 +3588,7 @@ version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" dependencies = [ - "darling 0.20.9", + "darling", "proc-macro2", "quote", "syn 2.0.68", @@ -3793,12 +3753,6 @@ version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8207e78455ffdf55661170876f88daf85356e4edd54e0a3dbc79586ca1e50cbe" -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "strsim" version = "0.11.1" @@ -4869,16 +4823,17 @@ dependencies = [ [[package]] name = "zxcvbn" -version = "2.2.2" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "103fa851fff70ea29af380e87c25c48ff7faac5c530c70bd0e65366d4e0c94e4" +checksum = "579b1d84df61d9d04cd250035843fee2f86a4b4bb176f102fec20779fd0bd38b" dependencies = [ "derive_builder", "fancy-regex", - "itertools 0.10.5", - "js-sys", + "getrandom", + "itertools 0.13.0", "lazy_static", - "quick-error", "regex", "time", + "wasm-bindgen", + "web-sys", ] diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml index ba3ebbe68..f0ba792fb 100644 --- a/crates/bitwarden-core/Cargo.toml +++ b/crates/bitwarden-core/Cargo.toml @@ -61,7 +61,7 @@ thiserror = ">=1.0.40, <2.0" uniffi = { version = "=0.27.2", optional = true, features = ["tokio"] } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } -zxcvbn = ">= 2.2.2, <3.0" +zxcvbn = ">=3.0.1, <4.0" [target.'cfg(all(not(target_os = "android"), not(target_arch="wasm32")))'.dependencies] # By default, we use rustls as the TLS stack and rust-platform-verifier to support user-installed root certificates diff --git a/crates/bitwarden-core/src/auth/password/strength.rs b/crates/bitwarden-core/src/auth/password/strength.rs index 66b5b5823..6f1757fac 100644 --- a/crates/bitwarden-core/src/auth/password/strength.rs +++ b/crates/bitwarden-core/src/auth/password/strength.rs @@ -13,7 +13,7 @@ pub(crate) fn password_strength( let mut arr: Vec<_> = inputs.iter().map(String::as_str).collect(); arr.extend(GLOBAL_INPUTS); - zxcvbn(&password, &arr).map_or(0, |e| e.score()) + zxcvbn(&password, &arr).score().into() } fn email_to_user_inputs(email: &str) -> Vec { From cdca710f251b27df865ae6f7c9058433368aa3ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Fri, 28 Jun 2024 22:19:05 +0200 Subject: [PATCH 039/214] Update PyO3 (#865) Update PyO3 to version 0.21. Note that version 0.22 is already released but `pyo3-log` is not compatible yet. I've also noticed that we're not using `pyo3-asyncio` at all, as we only expose a sync API on the Python libs, so I just removed it. With this update and https://github.com/bitwarden/sdk/pull/864 we get rid of any dependencies using `syn 0.x`, which should help a little bit with build times. --- Cargo.lock | 125 ++++++++++++--------------------- crates/bitwarden-py/Cargo.toml | 10 +-- 2 files changed, 47 insertions(+), 88 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 017bceae8..cc2f03434 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -183,7 +183,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.68", + "syn", ] [[package]] @@ -232,7 +232,7 @@ checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -579,7 +579,6 @@ version = "0.1.0" dependencies = [ "bitwarden-json", "pyo3", - "pyo3-asyncio", "pyo3-build-config", "pyo3-log", "tokio", @@ -952,7 +951,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -1295,7 +1294,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -1319,7 +1318,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.68", + "syn", ] [[package]] @@ -1330,7 +1329,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -1396,7 +1395,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -1406,7 +1405,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.68", + "syn", ] [[package]] @@ -1682,7 +1681,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -2368,7 +2367,7 @@ dependencies = [ "napi-derive-backend", "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -2383,7 +2382,7 @@ dependencies = [ "quote", "regex", "semver", - "syn 2.0.68", + "syn", ] [[package]] @@ -2724,7 +2723,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -2857,9 +2856,9 @@ source = "git+https://github.com/bitwarden/passkey-rs?rev=c48c2ddfd6b884b2d75443 [[package]] name = "pyo3" -version = "0.20.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53bdbb96d49157e65d45cc287af5f32ffadd5f4761438b527b055fb0d4bb8233" +checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8" dependencies = [ "cfg-if", "indoc", @@ -2873,36 +2872,11 @@ dependencies = [ "unindent", ] -[[package]] -name = "pyo3-asyncio" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea6b68e93db3622f3bb3bf363246cf948ed5375afe7abff98ccbdd50b184995" -dependencies = [ - "futures", - "once_cell", - "pin-project-lite", - "pyo3", - "pyo3-asyncio-macros", - "tokio", -] - -[[package]] -name = "pyo3-asyncio-macros" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56c467178e1da6252c95c29ecf898b133f742e9181dca5def15dc24e19d45a39" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "pyo3-build-config" -version = "0.20.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deaa5745de3f5231ce10517a1f5dd97d53e5a2fd77aa6b5842292085831d48d7" +checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50" dependencies = [ "once_cell", "target-lexicon", @@ -2910,9 +2884,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.20.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b42531d03e08d4ef1f6e85a2ed422eb678b8cd62b762e53891c05faf0d4afa" +checksum = "01be5843dc60b916ab4dad1dca6d20b9b4e6ddc8e15f50c47fe6d85f1fb97403" dependencies = [ "libc", "pyo3-build-config", @@ -2920,9 +2894,9 @@ dependencies = [ [[package]] name = "pyo3-log" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c10808ee7250403bedb24bc30c32493e93875fef7ba3e4292226fe924f398bd" +checksum = "2af49834b8d2ecd555177e63b273b708dea75150abc6f5341d0a6e1a9623976c" dependencies = [ "arc-swap", "log", @@ -2931,27 +2905,27 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.20.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7305c720fa01b8055ec95e484a6eca7a83c841267f0dd5280f0c8b8551d2c158" +checksum = "77b34069fc0682e11b31dbd10321cbf94808394c56fd996796ce45217dfac53c" dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.68", + "syn", ] [[package]] name = "pyo3-macros-backend" -version = "0.20.3" +version = "0.21.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c7e9b68bb9c3149c5b0cade5d07f953d6d125eb4337723c4ccdb665f1f96185" +checksum = "08260721f32db5e1a5beae69a55553f56b99bd0e1c3e6e0a5e8851a9d0f5a85c" dependencies = [ "heck 0.4.1", "proc-macro2", "pyo3-build-config", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -3382,7 +3356,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.68", + "syn", ] [[package]] @@ -3414,7 +3388,7 @@ checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -3495,7 +3469,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -3506,7 +3480,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -3540,7 +3514,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -3591,7 +3565,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -3784,7 +3758,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.68", + "syn", ] [[package]] @@ -3797,7 +3771,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.68", + "syn", ] [[package]] @@ -3815,17 +3789,6 @@ dependencies = [ "is_ci", ] -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.68" @@ -3909,7 +3872,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -4003,7 +3966,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -4119,7 +4082,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -4184,7 +4147,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a615d6c2764852a2e88a4f16e9ce1ea49bb776b5872956309e170d63a042a34f" dependencies = [ "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -4300,7 +4263,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5c400339a9d1d17be34257d0b407e91d64af335e5b4fa49f4bf28467fc8d635" dependencies = [ "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -4332,7 +4295,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.68", + "syn", "toml 0.5.11", "uniffi_meta", ] @@ -4480,7 +4443,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.68", + "syn", "wasm-bindgen-shared", ] @@ -4514,7 +4477,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4547,7 +4510,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] @@ -4818,7 +4781,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.68", + "syn", ] [[package]] diff --git a/crates/bitwarden-py/Cargo.toml b/crates/bitwarden-py/Cargo.toml index e9073d802..fc128c66d 100644 --- a/crates/bitwarden-py/Cargo.toml +++ b/crates/bitwarden-py/Cargo.toml @@ -17,18 +17,14 @@ crate-type = ["cdylib"] [dependencies] bitwarden-json = { path = "../bitwarden-json", features = ["secrets"] } -pyo3 = { version = "0.20.2", features = ["extension-module"] } -pyo3-log = "0.9.0" +pyo3 = { version = "0.21.2", features = ["extension-module"] } +pyo3-log = "0.10.0" [build-dependencies] -pyo3-build-config = { version = "0.20.2" } +pyo3-build-config = { version = "0.21.2" } [target.'cfg(not(target_arch="wasm32"))'.dependencies] tokio = { version = "1.36.0", features = ["rt-multi-thread", "macros"] } -pyo3-asyncio = { version = "0.20.0", features = [ - "attributes", - "tokio-runtime", -] } [lints] workspace = true From b375edcce2282941c2e962dc77b80dd27534d73b Mon Sep 17 00:00:00 2001 From: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com> Date: Fri, 28 Jun 2024 16:09:06 -0500 Subject: [PATCH 040/214] Add SM owned files to code owners (#494) Add Secrets Manager owned files to code owners file. --- .github/CODEOWNERS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 632eb5ff8..6bb362e8c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -7,3 +7,7 @@ # DevOps for Actions and other workflow changes. .github/workflows @bitwarden/dept-devops + +# Secrets Manager team +crates/bitwarden-sm @bitwarden/team-secrets-manager-dev +crates/bws @bitwarden/team-secrets-manager-dev From 022ba8a527f1310f8b398bbc0efb8461a667058b Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 2 Jul 2024 10:33:58 +0200 Subject: [PATCH 041/214] Fix ios not compiling after tweaks to fido (#866) We changed the Fido2 interfaces and forgot to update the Ios code. --- languages/swift/iOS/App/ContentView.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/languages/swift/iOS/App/ContentView.swift b/languages/swift/iOS/App/ContentView.swift index 2cda3e68b..25d751a4c 100644 --- a/languages/swift/iOS/App/ContentView.swift +++ b/languages/swift/iOS/App/ContentView.swift @@ -414,6 +414,10 @@ class Fido2UserInterfaceImpl: Fido2UserInterface { } class Fido2CredentialStoreImpl: Fido2CredentialStore { + func allCredentials() async throws -> [BitwardenSdk.CipherView] { + abort() + } + func findCredentials(ids: [Data]?, ripId: String) async throws -> [BitwardenSdk.CipherView] { abort() } From 569e1fcfe29470c11d9c43d16894751bfdfda1e3 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 2 Jul 2024 10:45:08 +0200 Subject: [PATCH 042/214] Always deploy all rust packages (#845) GitHub actions only supports 10 inputs to a workflow_dispatch. As we keep adding packages we've exceeded this limit. Since we no longer need the functionality to release individual packages this PR removes the option all together and instead will always release all packages. In case a package with the same version already exists in crates.io, cargo release won't attempt to publish it and continue on with the other packages. --- .github/workflows/publish-rust-crates.yml | 151 +--------------------- 1 file changed, 3 insertions(+), 148 deletions(-) diff --git a/.github/workflows/publish-rust-crates.yml b/.github/workflows/publish-rust-crates.yml index f4da56342..054cb5bd4 100644 --- a/.github/workflows/publish-rust-crates.yml +++ b/.github/workflows/publish-rust-crates.yml @@ -14,61 +14,6 @@ on: - Initial Release - Redeploy - Dry Run - publish_bitwarden: - description: "Publish bitwarden crate" - required: true - default: true - type: boolean - publish_bitwarden-api-api: - description: "Publish bitwarden-api-api crate" - required: true - default: true - type: boolean - publish_bitwarden-api-identity: - description: "Publish bitwarden-api-identity crate" - required: true - default: true - type: boolean - publish_bitwarden-core: - description: "Publish bitwarden-core crate" - required: true - default: true - type: boolean - publish_bitwarden-crypto: - description: "Publish bitwarden-crypto crate" - required: true - default: true - type: boolean - publish_bitwarden-cli: - description: "Publish bitwarden-cli crate" - required: true - default: true - type: boolean - publish_bitwarden-exporters: - description: "Publish bitwarden-exporters crate" - required: true - default: true - type: boolean - publish_bitwarden-fido: - description: "Publish bitwarden-fido crate" - required: true - default: true - type: boolean - publish_bitwarden-generators: - description: "Publish bitwarden-generators crate" - required: true - default: true - type: boolean - publish_bitwarden-send: - description: "Publish bitwarden-send crate" - required: true - default: true - type: boolean - publish_bitwarden-vault: - description: "Publish bitwarden-valt crate" - required: true - default: true - type: boolean defaults: run: @@ -78,9 +23,6 @@ jobs: setup: name: Setup runs-on: ubuntu-22.04 - outputs: - packages_list: ${{ steps.packages-list.outputs.packages_list }} - packages_command: ${{ steps.packages-list.outputs.packages_command }} steps: - name: Checkout repo uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 @@ -95,94 +37,8 @@ jobs: exit 1 fi - - name: Prepare packages list - id: packages-list - env: - PUBLISH_BITWARDEN: ${{ github.event.inputs.publish_bitwarden }} - PUBLISH_BITWARDEN_API_API: ${{ github.event.inputs.publish_bitwarden-api-api }} - PUBLISH_BITWARDEN_API_IDENTITY: ${{ github.event.inputs.publish_bitwarden-api-identity }} - PUBLISH_BITWARDEN_CORE: ${{ github.event.inputs.publish_bitwarden-core }} - PUBLISH_BITWARDEN_CRYPTO: ${{ github.event.inputs.publish_bitwarden-crypto }} - PUBLISH_BITWARDEN_CLI: ${{ github.event.inputs.publish_bitwarden-cli }} - PUBLISH_BITWARDEN_EXPORTERS: ${{ github.event.inputs.publish_bitwarden-exporters }} - PUBLISH_BITWARDEN_FIDO: ${{ github.event.inputs.publish_bitwarden-fido }} - PUBLISH_BITWARDEN_GENERATORS: ${{ github.event.inputs.publish_bitwarden-generators }} - PUBLISH_BITWARDEN_SEND: ${{ github.event.inputs.publish_bitwarden-send }} - PUBLISH_BITWARDEN_VAULT: ${{ github.event.inputs.publish_bitwarden-vault }} - run: | - if [[ "$PUBLISH_BITWARDEN" == "false" ]] && [[ "$PUBLISH_BITWARDEN_API_API" == "false" ]] && [[ "$PUBLISH_BITWARDEN_API_IDENTITY" == "false" ]]; then - echo "===================================" - echo "[!] You need to specify at least one crate for release!" - echo "===================================" - exit 1 - fi - - PACKAGES_COMMAND="" - PACKAGES_LIST="" - - if [[ "$PUBLISH_BITWARDEN" == "true" ]] ; then - PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden" - PACKAGES_LIST="$PACKAGES_LIST bitwarden" - fi - - if [[ "$PUBLISH_BITWARDEN_API_API" == "true" ]]; then - PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-api-api" - PACKAGES_LIST="$PACKAGES_LIST bitwarden-api-api" - fi - - if [[ "$PUBLISH_BITWARDEN_API_IDENTITY" == "true" ]]; then - PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-api-identity" - PACKAGES_LIST="$PACKAGES_LIST bitwarden-api-identity" - fi - - if [[ "$PUBLISH_BITWARDEN_CORE" == "true" ]]; then - PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-core" - PACKAGES_LIST="$PACKAGES_LIST bitwarden-core" - fi - - if [[ "$PUBLISH_BITWARDEN_CRYPTO" == "true" ]]; then - PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-crypto" - PACKAGES_LIST="$PACKAGES_LIST bitwarden-crypto" - fi - - if [[ "$PUBLISH_BITWARDEN_CLI" == "true" ]]; then - PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-cli" - PACKAGES_LIST="$PACKAGES_LIST bitwarden-cli" - fi - - if [[ "$PUBLISH_BITWARDEN_EXPORTERS" == "true" ]]; then - PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-exporters" - PACKAGES_LIST="$PACKAGES_LIST bitwarden-exporters" - fi - - if [[ "$PUBLISH_BITWARDEN_FIDO" == "true" ]]; then - PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-fido" - PACKAGES_LIST="$PACKAGES_LIST bitwarden-fido" - fi - - if [[ "$PUBLISH_BITWARDEN_GENERATORS" == "true" ]]; then - PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-generators" - PACKAGES_LIST="$PACKAGES_LIST bitwarden-generators" - fi - - if [[ "$PUBLISH_BITWARDEN_SEND" == "true" ]]; then - PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-send" - PACKAGES_LIST="$PACKAGES_LIST bitwarden-send" - fi - - if [[ "$PUBLISH_BITWARDEN_VAULT" == "true" ]]; then - PACKAGES_COMMAND="$PACKAGES_COMMAND -p bitwarden-vault" - PACKAGES_LIST="$PACKAGES_LIST bitwarden-vault" - fi - - echo "Packages command: " $PACKAGES_COMMAND - echo "Packages list: " $PACKAGES_LIST - - echo "packages_list=$PACKAGES_LIST" >> $GITHUB_OUTPUT - echo "packages_command=$PACKAGES_COMMAND" >> $GITHUB_OUTPUT - publish: - name: Publish ${{ needs.setup.outputs.packages_list }} + name: Publish runs-on: ubuntu-latest needs: - setup @@ -220,7 +76,7 @@ jobs: with: token: "${{ secrets.GITHUB_TOKEN }}" initial-status: "in_progress" - environment: "Bitwarden SDK to crates.io: ${{ needs.setup.outputs.packages_list }}" + environment: "Bitwarden SDK" description: "Deployment from branch ${{ github.ref_name }}" task: release @@ -228,9 +84,8 @@ jobs: if: ${{ github.event.inputs.release_type != 'Dry Run' }} env: PUBLISH_GRACE_SLEEP: 10 - PACKAGES_PUBLISH: ${{ needs.setup.outputs.packages_command }} CARGO_REGISTRY_TOKEN: ${{ steps.retrieve-secrets.outputs.cratesio-api-token }} - run: cargo-release release publish $PACKAGES_PUBLISH --execute --no-confirm + run: cargo-release release publish --exclude bw --exclude bws --execute --no-confirm - name: Update deployment status to Success if: ${{ github.event.inputs.release_type != 'Dry Run' && success() }} From 9eb4e39390e6544f93b61804cdf79172d48ee051 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:26:36 +0200 Subject: [PATCH 043/214] [deps]: Update Rust crate clap to v4.5.8 (#868) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [clap](https://togithub.com/clap-rs/clap) | build-dependencies | patch | `4.5.7` -> `4.5.8` | | [clap](https://togithub.com/clap-rs/clap) | dependencies | patch | `4.5.7` -> `4.5.8` | --- ### Release Notes
clap-rs/clap (clap) ### [`v4.5.8`](https://togithub.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#458---2024-06-28) [Compare Source](https://togithub.com/clap-rs/clap/compare/v4.5.7...v4.5.8) ##### Fixes - Reduce extra flushes
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc2f03434..a6c2d39d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -913,9 +913,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.7" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" +checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" dependencies = [ "clap_builder", "clap_derive", @@ -923,9 +923,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.7" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" +checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" dependencies = [ "anstream", "anstyle", @@ -944,9 +944,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.5" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -2219,7 +2219,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" dependencies = [ "cfg-if", - "windows-targets 0.52.5", + "windows-targets 0.48.5", ] [[package]] From 1cb27a6e51fd13de303f60d39aed51f3a2871c77 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:27:34 +0200 Subject: [PATCH 044/214] [deps]: Update Rust crate clap_mangen to v0.2.22 (#870) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [clap_mangen](https://togithub.com/clap-rs/clap) | build-dependencies | patch | `0.2.21` -> `0.2.22` | --- ### Release Notes
clap-rs/clap (clap_mangen) ### [`v0.2.22`](https://togithub.com/clap-rs/clap/compare/clap_mangen-v0.2.21...clap_mangen-v0.2.22) [Compare Source](https://togithub.com/clap-rs/clap/compare/clap_mangen-v0.2.21...clap_mangen-v0.2.22)
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6c2d39d0..c5aa61185 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -962,9 +962,9 @@ checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" [[package]] name = "clap_mangen" -version = "0.2.21" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74b70fc13e60c0e1d490dc50eb73a749be6d81f4ef03783df1d9b7b0c62bc937" +checksum = "f50dde5bc0c853d6248de457e5eb6e5a674a54b93810a34ded88d882ca1fe2de" dependencies = [ "clap", "roff", From c7120e6db1e37615c01e418b1dc96695701818ec Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:28:31 +0200 Subject: [PATCH 045/214] [deps]: Update Rust crate clap_complete to v4.5.7 (#869) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [clap_complete](https://togithub.com/clap-rs/clap) | build-dependencies | patch | `4.5.6` -> `4.5.7` | | [clap_complete](https://togithub.com/clap-rs/clap) | dependencies | patch | `4.5.6` -> `4.5.7` | --- ### Release Notes
clap-rs/clap (clap_complete) ### [`v4.5.7`](https://togithub.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#457---2024-06-10) [Compare Source](https://togithub.com/clap-rs/clap/compare/clap_complete-v4.5.6...clap_complete-v4.5.7) ##### Fixes - Clean up error message when too few arguments for `num_args`
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c5aa61185..4578319b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -935,9 +935,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.6" +version = "4.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbca90c87c2a04da41e95d1856e8bcd22f159bdbfa147314d2ce5218057b0e58" +checksum = "1d598e88f6874d4b888ed40c71efbcbf4076f1dfbae128a08a8c9e45f710605d" dependencies = [ "clap", ] From f9fb74ccb781d2c828a9e7505e05dc16783a1bef Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Thu, 4 Jul 2024 15:59:25 +0200 Subject: [PATCH 046/214] [PM-9498] let user check and pick credential for creation return user check (#874) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective `check_user_and_pick_credential_for_creation` needs to return the result of the `check_user` part of the function ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-fido/src/authenticator.rs | 9 +++---- crates/bitwarden-fido/src/traits.rs | 2 +- crates/bitwarden-uniffi/src/platform/fido2.rs | 27 ++++++++++++++----- languages/swift/iOS/App/ContentView.swift | 2 +- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/crates/bitwarden-fido/src/authenticator.rs b/crates/bitwarden-fido/src/authenticator.rs index e86812bd9..7de2f9dd3 100644 --- a/crates/bitwarden-fido/src/authenticator.rs +++ b/crates/bitwarden-fido/src/authenticator.rs @@ -15,7 +15,7 @@ use passkey::{ use thiserror::Error; use super::{ - try_from_credential_new_view, types::*, CheckUserOptions, CheckUserResult, CipherViewContainer, + try_from_credential_new_view, types::*, CheckUserOptions, CipherViewContainer, Fido2CredentialStore, Fido2UserInterface, SelectedCredential, UnknownEnum, AAGUID, }; use crate::{ @@ -613,7 +613,7 @@ impl passkey::authenticator::UserValidationMethod for UserValidationMethodImpl<' let new_credential = try_from_credential_new_view(user, rp) .map_err(|_| Ctap2Error::InvalidCredential)?; - let cipher_view = self + let (cipher_view, user_check) = self .authenticator .user_interface .check_user_and_pick_credential_for_creation(options, new_credential) @@ -626,10 +626,7 @@ impl passkey::authenticator::UserValidationMethod for UserValidationMethodImpl<' .expect("Mutex is not poisoned") .replace(cipher_view); - Ok(CheckUserResult { - user_present: true, - user_verified: verification != UV::Discouraged, - }) + Ok(user_check) } _ => { self.authenticator diff --git a/crates/bitwarden-fido/src/traits.rs b/crates/bitwarden-fido/src/traits.rs index 1e00a318a..215e5934d 100644 --- a/crates/bitwarden-fido/src/traits.rs +++ b/crates/bitwarden-fido/src/traits.rs @@ -29,7 +29,7 @@ pub trait Fido2UserInterface: Send + Sync { &self, options: CheckUserOptions, new_credential: Fido2CredentialNewView, - ) -> Result; + ) -> Result<(CipherView, CheckUserResult), Fido2CallbackError>; async fn is_verification_enabled(&self) -> bool; } diff --git a/crates/bitwarden-uniffi/src/platform/fido2.rs b/crates/bitwarden-uniffi/src/platform/fido2.rs index e5245faef..3018d7beb 100644 --- a/crates/bitwarden-uniffi/src/platform/fido2.rs +++ b/crates/bitwarden-uniffi/src/platform/fido2.rs @@ -180,6 +180,22 @@ pub struct CheckUserResult { user_verified: bool, } +impl From for bitwarden::fido::CheckUserResult { + fn from(val: CheckUserResult) -> Self { + Self { + user_present: val.user_present, + user_verified: val.user_verified, + } + } +} + +#[allow(dead_code)] +#[derive(uniffi::Record)] +pub struct CheckUserAndPickCredentialForCreationResult { + cipher: CipherViewWrapper, + check_user_result: CheckUserResult, +} + #[derive(Debug, thiserror::Error, uniffi::Error)] pub enum Fido2CallbackError { #[error("The operation requires user interaction")] @@ -227,7 +243,7 @@ pub trait Fido2UserInterface: Send + Sync { &self, options: CheckUserOptions, new_credential: Fido2CredentialNewView, - ) -> Result; + ) -> Result; async fn is_verification_enabled(&self) -> bool; } @@ -326,10 +342,7 @@ impl bitwarden::fido::Fido2UserInterface for UniffiTraitBridge<&dyn Fido2UserInt self.0 .check_user(options.clone(), hint.into()) .await - .map(|r| bitwarden::fido::CheckUserResult { - user_present: r.user_present, - user_verified: r.user_verified, - }) + .map(Into::into) .map_err(Into::into) } async fn pick_credential_for_authentication( @@ -346,11 +359,11 @@ impl bitwarden::fido::Fido2UserInterface for UniffiTraitBridge<&dyn Fido2UserInt &self, options: CheckUserOptions, new_credential: Fido2CredentialNewView, - ) -> Result { + ) -> Result<(CipherView, bitwarden::fido::CheckUserResult), BitFido2CallbackError> { self.0 .check_user_and_pick_credential_for_creation(options, new_credential) .await - .map(|v| v.cipher) + .map(|v| (v.cipher.cipher, v.check_user_result.into())) .map_err(Into::into) } async fn is_verification_enabled(&self) -> bool { diff --git a/languages/swift/iOS/App/ContentView.swift b/languages/swift/iOS/App/ContentView.swift index 25d751a4c..251f0c5f6 100644 --- a/languages/swift/iOS/App/ContentView.swift +++ b/languages/swift/iOS/App/ContentView.swift @@ -400,7 +400,7 @@ class Fido2UserInterfaceImpl: Fido2UserInterface { abort() } - func checkUserAndPickCredentialForCreation(options: BitwardenSdk.CheckUserOptions, newCredential: BitwardenSdk.Fido2CredentialNewView) async throws -> BitwardenSdk.CipherViewWrapper { + func checkUserAndPickCredentialForCreation(options: BitwardenSdk.CheckUserOptions, newCredential: BitwardenSdk.Fido2CredentialNewView) async throws -> BitwardenSdk.CheckUserAndPickCredentialForCreationResult { abort() } From 552e626cd7ba4ab4a674274473cffa75ce277b3a Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 5 Jul 2024 16:47:18 +0200 Subject: [PATCH 047/214] [PM-9529] Add support for legacy user keys encrypted as AES-CBC-256-B64 (#876) https://bitwarden.atlassian.net/browse/PM-9529 Add support for legacy user keys encrypted as AES-CBC-256-B64 --- .../src/client/test_accounts.rs | 74 +++++++++++++++---- .../bitwarden-crypto/src/keys/master_key.rs | 44 ++++++++++- 2 files changed, 100 insertions(+), 18 deletions(-) diff --git a/crates/bitwarden-core/src/client/test_accounts.rs b/crates/bitwarden-core/src/client/test_accounts.rs index 4e83f2c14..858e1d2fa 100644 --- a/crates/bitwarden-core/src/client/test_accounts.rs +++ b/crates/bitwarden-core/src/client/test_accounts.rs @@ -52,21 +52,14 @@ pub struct TestAccount { /// /// ```sql /// INSERT INTO vault_dev.dbo.[User] ( -/// Id, Name, Email, EmailVerified, MasterPassword, -/// MasterPasswordHint, Culture, SecurityStamp, -/// TwoFactorProviders, TwoFactorRecoveryCode, -/// EquivalentDomains, ExcludedGlobalEquivalentDomains, -/// AccountRevisionDate, [Key], PublicKey, -/// PrivateKey, Premium, PremiumExpirationDate, -/// Storage, MaxStorageGb, Gateway, GatewayCustomerId, -/// GatewaySubscriptionId, LicenseKey, -/// CreationDate, RevisionDate, RenewalReminderDate, -/// Kdf, KdfIterations, ReferenceData, -/// ApiKey, ForcePasswordReset, UsesKeyConnector, -/// FailedLoginCount, LastFailedLoginDate, -/// AvatarColor, KdfMemory, KdfParallelism, -/// LastPasswordChangeDate, LastKdfChangeDate, -/// LastKeyRotationDate, LastEmailChangeDate +/// Id, Name, Email, EmailVerified, MasterPassword, MasterPasswordHint, Culture, SecurityStamp, +/// TwoFactorProviders, TwoFactorRecoveryCode, EquivalentDomains, +/// ExcludedGlobalEquivalentDomains, AccountRevisionDate, [Key], PublicKey, PrivateKey, Premium, +/// PremiumExpirationDate, Storage, MaxStorageGb, Gateway, GatewayCustomerId, +/// GatewaySubscriptionId, LicenseKey, CreationDate, RevisionDate, RenewalReminderDate, Kdf, +/// KdfIterations, ReferenceData, ApiKey, ForcePasswordReset, UsesKeyConnector, FailedLoginCount, +/// LastFailedLoginDate, AvatarColor, KdfMemory, KdfParallelism, LastPasswordChangeDate, +/// LastKdfChangeDate, LastKeyRotationDate, LastEmailChangeDate /// ) /// VALUES /// ( @@ -143,3 +136,54 @@ pub fn test_bitwarden_com_account() -> TestAccount { }), } } + +/// ### `legacy@bitwarden.com` +/// +/// Account which has a user_key of type `AesCbc256_B64` which is deprecated. +/// +/// - Email: `legacy@bitwarden.com` +/// - Password: `asdfasdfasdf` +/// - PBKDF2: `600_000` iterations +/// +/// ```sql +/// /// INSERT INTO vault_dev.dbo.[User] ( +/// Id, Name, Email, EmailVerified, MasterPassword, MasterPasswordHint, Culture, SecurityStamp, +/// TwoFactorProviders, TwoFactorRecoveryCode, EquivalentDomains, +/// ExcludedGlobalEquivalentDomains, AccountRevisionDate, [Key], PublicKey, PrivateKey, Premium, +/// PremiumExpirationDate, Storage, MaxStorageGb, Gateway, GatewayCustomerId, +/// GatewaySubscriptionId, LicenseKey, CreationDate, RevisionDate, RenewalReminderDate, Kdf, +/// KdfIterations, ReferenceData, ApiKey, ForcePasswordReset, UsesKeyConnector, FailedLoginCount, +/// LastFailedLoginDate, AvatarColor, KdfMemory, KdfParallelism, LastPasswordChangeDate, +/// LastKdfChangeDate, LastKeyRotationDate, LastEmailChangeDate +/// ) +/// VALUES +/// ( +/// N'764335ba-bb3b-4646-9c19-b1a301229eb2', N'Legacy', N'legacy@bitwarden.com', 1, +/// N'AQAAAAIAAYagAAAAEBPKHRNzY+8XTZGODQaa4hQUW/7qsW73v5O8WmqsS+xplghgtX/qXS1JTHT6PNWUFw==', +/// null, N'en-US', N'a1611dff-b383-4d7f-bb37-18c37507c11e', null, null, null, null, +/// N'2024-07-05 13:27:01.4033333', +/// N'0.8UClLa8IPE1iZT7chy5wzQ==|6PVfHnVk5S3XqEtQemnM5yb4JodxmPkkWzmDRdfyHtjORmvxqlLX40tBJZ+CKxQWmS8tpEB5w39rbgHg/gqs0haGdZG4cPbywsgGzxZ7uNI=', +/// N'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvbVTK0cY7j/9GD4UTIZVywT3vWNIiy5LuI1l9MIKbWh+PyVUB5ySR++Z1tDwx5R87AtXwjQS09j6a4X+uGHW4lRQR3Dngb2CpMutLqFjKk7NYWSj3MU5bKlvsCf2Z59ECJEFqo3eAsHYyrL3CixRsZg3LkQcYT+VT/qOOcI6UkMX50lpma2Cvdf3IAgPf6Enkg/WJ3d7D6aU5YtexTY03uKVbOb2UoO2ZJ29VyYEVEJ+0S6pqe9laeHz/oJ9SI3sRqdEYRmyDsbUWJHRJr7eAVesmiUBU/Ls7t4k/oXjfiJ7K5wqL5yCQ0HkqK8zQhi9wB4u7kHwEa8sDJE+cFQ5bQIDAQAB', +/// N'2.leBIE5u0aQUeXi++JzAnrA==|P8x+hs00RJx7epw+49qVtBhLJxE/JTL5dEHg6kq5pbZLdUY8ZvWK49v0EqgHbv1r298N9+msoO9hmdSIVIAZyycemYDSoc1rX4S1KpS/ZMA/Vd3VLFb+o13Ts62GFQ5ygHKgQZfzjU6jO5P/B/0igzFoxyJDomhW5NBC1P9+e/5qNRZN8loKvAaWc/7XtpRayPQqWx+AgYc2ntb1GF5hRVrW4M47bG5ZKllbJWtQKg2sXIy2lDBbKLRFWF4RFzNVcXQGMoPdWLY0f3uTwUH01dyGmFFMbOvfBEuYqmZyPdd93ve8zuFOEqkj46Ulpq2CVG8NvZARTwsdKl6XB0wGuHFoTsDJT2SJGl67pBBKsVRGxy059QW+9hAIB+emIV0T/7+0rvdeSXZ4AbG+oXGEXFTkHefwJKfeT0MBTAjYKr7ZRLgqvf7n39+nCEJU4l22kp8FmjcWIU7AgNipdGHC+UT2yfOcYlvgBgWDcMXcbVDMyus9105RgcW6PHozUj7yjbohI/A3XWmAFufP6BSnmEFCKoik78X/ry09xwiH2rN4KVXe/k9LpRNB2QBGIVsfgCrkxjeE8r0nA59Rvwrhny1z5BkvMW/N1KrGuafg/IYgegx72gJNuZPZlFu1Vs7HxySHmzYvm3DPV7bzCaAxxNtvZmQquNIEnsDQfjJO76iL1JCtDqNJVzGLHTMTr7S5hkOcydcH3kfKwZdA1ULVd2qu0SwOUEP/ECjU/cS5INy6WPYzNMAe/g2DISpQjNwBb5K17PIiGOR7/Q/A6E8pVnkHiAXuUFr9aLOYN9BWSu5Z+BPHH65na2FDmssix5WV09I2sUBfvdNCjkrUGdYgo8E+vOTn35x9GJHF45uhmgC1yAn/+/RSpORlrSVJ7NNP11dn3htUpSsIy/b7ituAu8Ry5mhicFU8CXJL4NeMlXThUt8P++wxs4wMkBvJ8J9NJAVKbAOA2o+GOdjbh6Ww3IRegkurWh4oL/dFSx0LpaXJuw6HFT/LzticPlSwHtUP11hZ81seMsXmkSZd8IugRFfwpPl7N6PVRWDOKxLf4gPqcnJ11TvfasXy1uolV2vZCPbrbbVzQMPdVwL/OzwfhqsIgQZI8rsDMK5D2EX8MaT8MDfGcsYcVTL9PmuZYLpOUnnHX0A1opAAa9iPw3d+eWB/GAyLvKPnMTUqVNos8HcCktXckCshihA8QuBJOwg3m0j2LPSZ5Jvf8gbXauBmt9I4IlJq0xfpgquYY1WNnO8IcWE4N9W+ASvOr9gnduA6CkDeAlyMUFmdpkeCjGMcsV741bTCPApSQlL3/TOT1cjK3iejWpz0OaVHXyg02hW2fNkOfYfr81GvnLvlHxIg4Prw89gKuWU+kQk82lFQo6QQpqbCbJC2FleurD8tYoSY0srhuioVInffvTxw2NMF7FQEqUcsK9AMKSEiDqzBi35Um/fiE3JL4XZBFw8Xzl7X3ab5nlg8X+xD5uSZY+oxD3sDVXjLaQ5JUoys+MCm0FkUj85l0zT6rvM4QLhU1RDK1U51T9HJhh8hsFJsqL4abRzwEWG7PSi859zN4UsgyuQfmBJv/n7QAFCbrJhVBlGB1TKLZRzvgmKoxTYTG3cJFkjetLcUTwrwC9naxAQRfF4=|ufHf73IzJ707dx44w4fjkuD7tDa50OwmmkxcypAT9uQ=', +/// 0, null, null, null, null, null, null, null, N'2024-07-04 17:38:06.7866667', +/// N'2024-07-05 13:27:01.4033333', null, 0, 600000, +/// N'{"id":null,"initiationPath":"Registration form"}', N'Yi9yvlPzvbOuilU0f0pFYuEuxcDy11', +/// 0, 0, 0, null, null, null, null, null, null, null, N'2024-07-05 13:27:01.4033333' +/// ); +/// ``` +pub fn test_legacy_user_key_account() -> TestAccount { + TestAccount { + user: InitUserCryptoRequest { + kdf_params: Kdf::PBKDF2 { + iterations: 600_000.try_into().unwrap(), + }, + email: "legacy@bitwarden.com".to_owned(), + private_key: "2.leBIE5u0aQUeXi++JzAnrA==|P8x+hs00RJx7epw+49qVtBhLJxE/JTL5dEHg6kq5pbZLdUY8ZvWK49v0EqgHbv1r298N9+msoO9hmdSIVIAZyycemYDSoc1rX4S1KpS/ZMA/Vd3VLFb+o13Ts62GFQ5ygHKgQZfzjU6jO5P/B/0igzFoxyJDomhW5NBC1P9+e/5qNRZN8loKvAaWc/7XtpRayPQqWx+AgYc2ntb1GF5hRVrW4M47bG5ZKllbJWtQKg2sXIy2lDBbKLRFWF4RFzNVcXQGMoPdWLY0f3uTwUH01dyGmFFMbOvfBEuYqmZyPdd93ve8zuFOEqkj46Ulpq2CVG8NvZARTwsdKl6XB0wGuHFoTsDJT2SJGl67pBBKsVRGxy059QW+9hAIB+emIV0T/7+0rvdeSXZ4AbG+oXGEXFTkHefwJKfeT0MBTAjYKr7ZRLgqvf7n39+nCEJU4l22kp8FmjcWIU7AgNipdGHC+UT2yfOcYlvgBgWDcMXcbVDMyus9105RgcW6PHozUj7yjbohI/A3XWmAFufP6BSnmEFCKoik78X/ry09xwiH2rN4KVXe/k9LpRNB2QBGIVsfgCrkxjeE8r0nA59Rvwrhny1z5BkvMW/N1KrGuafg/IYgegx72gJNuZPZlFu1Vs7HxySHmzYvm3DPV7bzCaAxxNtvZmQquNIEnsDQfjJO76iL1JCtDqNJVzGLHTMTr7S5hkOcydcH3kfKwZdA1ULVd2qu0SwOUEP/ECjU/cS5INy6WPYzNMAe/g2DISpQjNwBb5K17PIiGOR7/Q/A6E8pVnkHiAXuUFr9aLOYN9BWSu5Z+BPHH65na2FDmssix5WV09I2sUBfvdNCjkrUGdYgo8E+vOTn35x9GJHF45uhmgC1yAn/+/RSpORlrSVJ7NNP11dn3htUpSsIy/b7ituAu8Ry5mhicFU8CXJL4NeMlXThUt8P++wxs4wMkBvJ8J9NJAVKbAOA2o+GOdjbh6Ww3IRegkurWh4oL/dFSx0LpaXJuw6HFT/LzticPlSwHtUP11hZ81seMsXmkSZd8IugRFfwpPl7N6PVRWDOKxLf4gPqcnJ11TvfasXy1uolV2vZCPbrbbVzQMPdVwL/OzwfhqsIgQZI8rsDMK5D2EX8MaT8MDfGcsYcVTL9PmuZYLpOUnnHX0A1opAAa9iPw3d+eWB/GAyLvKPnMTUqVNos8HcCktXckCshihA8QuBJOwg3m0j2LPSZ5Jvf8gbXauBmt9I4IlJq0xfpgquYY1WNnO8IcWE4N9W+ASvOr9gnduA6CkDeAlyMUFmdpkeCjGMcsV741bTCPApSQlL3/TOT1cjK3iejWpz0OaVHXyg02hW2fNkOfYfr81GvnLvlHxIg4Prw89gKuWU+kQk82lFQo6QQpqbCbJC2FleurD8tYoSY0srhuioVInffvTxw2NMF7FQEqUcsK9AMKSEiDqzBi35Um/fiE3JL4XZBFw8Xzl7X3ab5nlg8X+xD5uSZY+oxD3sDVXjLaQ5JUoys+MCm0FkUj85l0zT6rvM4QLhU1RDK1U51T9HJhh8hsFJsqL4abRzwEWG7PSi859zN4UsgyuQfmBJv/n7QAFCbrJhVBlGB1TKLZRzvgmKoxTYTG3cJFkjetLcUTwrwC9naxAQRfF4=|ufHf73IzJ707dx44w4fjkuD7tDa50OwmmkxcypAT9uQ=".to_owned(), + method: InitUserCryptoMethod::Password { + password: "asdfasdfasdf".to_owned(), + user_key: "0.8UClLa8IPE1iZT7chy5wzQ==|6PVfHnVk5S3XqEtQemnM5yb4JodxmPkkWzmDRdfyHtjORmvxqlLX40tBJZ+CKxQWmS8tpEB5w39rbgHg/gqs0haGdZG4cPbywsgGzxZ7uNI=".to_owned(), + } + }, +org: None, + } +} diff --git a/crates/bitwarden-crypto/src/keys/master_key.rs b/crates/bitwarden-crypto/src/keys/master_key.rs index dd81b9a3a..1b9ee1aa0 100644 --- a/crates/bitwarden-crypto/src/keys/master_key.rs +++ b/crates/bitwarden-crypto/src/keys/master_key.rs @@ -87,9 +87,17 @@ impl MasterKey { /// Decrypt the users user key pub fn decrypt_user_key(&self, user_key: EncString) -> Result { - let stretched_key = stretch_kdf_key(&self.0)?; + let mut dec: Vec = match user_key { + // Legacy. user_keys were encrypted using `AesCbc256_B64` a long time ago. We've since + // moved to using `AesCbc256_HmacSha256_B64`. However, we still need to support + // decrypting these old keys. + EncString::AesCbc256_B64 { .. } => user_key.decrypt_with_key(&self.0)?, + _ => { + let stretched_key = stretch_kdf_key(&self.0)?; + user_key.decrypt_with_key(&stretched_key)? + } + }; - let mut dec: Vec = user_key.decrypt_with_key(&stretched_key)?; SymmetricCryptoKey::try_from(dec.as_mut_slice()) } @@ -124,7 +132,7 @@ mod tests { use rand::SeedableRng; use super::{make_user_key, HashPurpose, Kdf, MasterKey}; - use crate::{keys::symmetric_crypto_key::derive_symmetric_key, SymmetricCryptoKey}; + use crate::{keys::symmetric_crypto_key::derive_symmetric_key, EncString, SymmetricCryptoKey}; #[test] fn test_master_key_derive_pbkdf2() { @@ -271,4 +279,34 @@ mod tests { "Decrypted key doesn't match user key" ); } + + #[test] + fn test_decrypt_user_key_aes_cbc256_b64() { + let password = b"asdfasdfasdf"; + let salt = b"legacy@bitwarden.com"; + let kdf = Kdf::PBKDF2 { + iterations: NonZeroU32::new(600_000).unwrap(), + }; + + let master_key = MasterKey::derive(password, salt, &kdf).unwrap(); + + let user_key: EncString = "0.8UClLa8IPE1iZT7chy5wzQ==|6PVfHnVk5S3XqEtQemnM5yb4JodxmPkkWzmDRdfyHtjORmvxqlLX40tBJZ+CKxQWmS8tpEB5w39rbgHg/gqs0haGdZG4cPbywsgGzxZ7uNI=".parse().unwrap(); + + let decrypted = master_key.decrypt_user_key(user_key).unwrap(); + + assert_eq!( + decrypted.key.as_slice(), + [ + 12, 95, 151, 203, 37, 4, 236, 67, 137, 97, 90, 58, 6, 127, 242, 28, 209, 168, 125, + 29, 118, 24, 213, 44, 117, 202, 2, 115, 132, 165, 125, 148 + ] + ); + assert_eq!( + decrypted.mac_key.as_ref().unwrap().as_slice(), + [ + 186, 215, 234, 137, 24, 169, 227, 29, 218, 57, 180, 237, 73, 91, 189, 51, 253, 26, + 17, 52, 226, 4, 134, 75, 194, 208, 178, 133, 128, 224, 140, 167 + ] + ); + } } From ad5fed31d735f09244a445e992c86a82ad2125a8 Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Mon, 8 Jul 2024 10:41:41 +0200 Subject: [PATCH 048/214] [PM-9499] fix passkey-rs and sdk not returning cbor encoded attestation object (#875) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective Updates to the latest passkey-rs version and now correctly returns `attestation_object` ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- Cargo.lock | 36 ++++------------------ crates/bitwarden-core/Cargo.toml | 2 +- crates/bitwarden-fido/Cargo.toml | 2 +- crates/bitwarden-fido/src/authenticator.rs | 3 +- crates/bitwarden-fido/src/types.rs | 2 +- 5 files changed, 11 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4578319b2..976235308 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2594,7 +2594,7 @@ dependencies = [ [[package]] name = "passkey" version = "0.3.1" -source = "git+https://github.com/bitwarden/passkey-rs?rev=c48c2ddfd6b884b2d754432576c66cb2b1985a3a#c48c2ddfd6b884b2d754432576c66cb2b1985a3a" +source = "git+https://github.com/bitwarden/passkey-rs?rev=ae08e2cb7dd3d44d915caed395c0cdc56b50fa27#ae08e2cb7dd3d44d915caed395c0cdc56b50fa27" dependencies = [ "passkey-authenticator", "passkey-client", @@ -2605,7 +2605,7 @@ dependencies = [ [[package]] name = "passkey-authenticator" version = "0.3.0" -source = "git+https://github.com/bitwarden/passkey-rs?rev=c48c2ddfd6b884b2d754432576c66cb2b1985a3a#c48c2ddfd6b884b2d754432576c66cb2b1985a3a" +source = "git+https://github.com/bitwarden/passkey-rs?rev=ae08e2cb7dd3d44d915caed395c0cdc56b50fa27#ae08e2cb7dd3d44d915caed395c0cdc56b50fa27" dependencies = [ "async-trait", "coset", @@ -2618,7 +2618,7 @@ dependencies = [ [[package]] name = "passkey-client" version = "0.3.1" -source = "git+https://github.com/bitwarden/passkey-rs?rev=c48c2ddfd6b884b2d754432576c66cb2b1985a3a#c48c2ddfd6b884b2d754432576c66cb2b1985a3a" +source = "git+https://github.com/bitwarden/passkey-rs?rev=ae08e2cb7dd3d44d915caed395c0cdc56b50fa27#ae08e2cb7dd3d44d915caed395c0cdc56b50fa27" dependencies = [ "ciborium", "coset", @@ -2628,19 +2628,18 @@ dependencies = [ "public-suffix", "serde", "serde_json", - "typeshare", "url", ] [[package]] name = "passkey-transports" version = "0.1.0" -source = "git+https://github.com/bitwarden/passkey-rs?rev=c48c2ddfd6b884b2d754432576c66cb2b1985a3a#c48c2ddfd6b884b2d754432576c66cb2b1985a3a" +source = "git+https://github.com/bitwarden/passkey-rs?rev=ae08e2cb7dd3d44d915caed395c0cdc56b50fa27#ae08e2cb7dd3d44d915caed395c0cdc56b50fa27" [[package]] name = "passkey-types" version = "0.2.1" -source = "git+https://github.com/bitwarden/passkey-rs?rev=c48c2ddfd6b884b2d754432576c66cb2b1985a3a#c48c2ddfd6b884b2d754432576c66cb2b1985a3a" +source = "git+https://github.com/bitwarden/passkey-rs?rev=ae08e2cb7dd3d44d915caed395c0cdc56b50fa27#ae08e2cb7dd3d44d915caed395c0cdc56b50fa27" dependencies = [ "bitflags 2.6.0", "ciborium", @@ -2653,7 +2652,6 @@ dependencies = [ "serde_json", "sha2", "strum 0.25.0", - "typeshare", ] [[package]] @@ -2852,7 +2850,7 @@ dependencies = [ [[package]] name = "public-suffix" version = "0.1.1" -source = "git+https://github.com/bitwarden/passkey-rs?rev=c48c2ddfd6b884b2d754432576c66cb2b1985a3a#c48c2ddfd6b884b2d754432576c66cb2b1985a3a" +source = "git+https://github.com/bitwarden/passkey-rs?rev=ae08e2cb7dd3d44d915caed395c0cdc56b50fa27#ae08e2cb7dd3d44d915caed395c0cdc56b50fa27" [[package]] name = "pyo3" @@ -4128,28 +4126,6 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" -[[package]] -name = "typeshare" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04f17399b76c2e743d58eac0635d7686e9c00f48cd4776f00695d9882a7d3187" -dependencies = [ - "chrono", - "serde", - "serde_json", - "typeshare-annotation", -] - -[[package]] -name = "typeshare-annotation" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a615d6c2764852a2e88a4f16e9ce1ea49bb776b5872956309e170d63a042a34f" -dependencies = [ - "quote", - "syn", -] - [[package]] name = "unicase" version = "2.7.0" diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml index f0ba792fb..12211a6a2 100644 --- a/crates/bitwarden-core/Cargo.toml +++ b/crates/bitwarden-core/Cargo.toml @@ -44,7 +44,7 @@ getrandom = { version = ">=0.2.9, <0.3", features = ["js"] } hmac = ">=0.12.1, <0.13" log = ">=0.4.18, <0.5" p256 = { version = ">=0.13.2, <0.14", optional = true } -passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "c48c2ddfd6b884b2d754432576c66cb2b1985a3a", optional = true } +passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "ae08e2cb7dd3d44d915caed395c0cdc56b50fa27", optional = true } rand = ">=0.8.5, <0.9" reqwest = { version = ">=0.12.5, <0.13", features = [ "http2", diff --git a/crates/bitwarden-fido/Cargo.toml b/crates/bitwarden-fido/Cargo.toml index 12c2b6b1d..1223a6137 100644 --- a/crates/bitwarden-fido/Cargo.toml +++ b/crates/bitwarden-fido/Cargo.toml @@ -30,7 +30,7 @@ coset = { version = "0.3.7" } itertools = "0.13.0" log = ">=0.4.18, <0.5" p256 = { version = ">=0.13.2, <0.14" } -passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "c48c2ddfd6b884b2d754432576c66cb2b1985a3a" } +passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "ae08e2cb7dd3d44d915caed395c0cdc56b50fa27" } reqwest = { version = ">=0.12.5, <0.13", default-features = false } schemars = { version = "0.8.21", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } diff --git a/crates/bitwarden-fido/src/authenticator.rs b/crates/bitwarden-fido/src/authenticator.rs index 7de2f9dd3..5f02fe545 100644 --- a/crates/bitwarden-fido/src/authenticator.rs +++ b/crates/bitwarden-fido/src/authenticator.rs @@ -170,6 +170,7 @@ impl<'a> Fido2Authenticator<'a> { Err(e) => return Err(MakeCredentialError::Other(format!("{e:?}"))), }; + let attestation_object = response.as_bytes().to_vec(); let authenticator_data = response.auth_data.to_vec(); let attested_credential_data = response .auth_data @@ -179,7 +180,7 @@ impl<'a> Fido2Authenticator<'a> { Ok(MakeCredentialResult { authenticator_data, - attested_credential_data: attested_credential_data.into_iter().collect(), + attestation_object, credential_id, }) } diff --git a/crates/bitwarden-fido/src/types.rs b/crates/bitwarden-fido/src/types.rs index 79777d24c..458a1be53 100644 --- a/crates/bitwarden-fido/src/types.rs +++ b/crates/bitwarden-fido/src/types.rs @@ -176,7 +176,7 @@ pub struct MakeCredentialRequest { #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] pub struct MakeCredentialResult { pub authenticator_data: Vec, - pub attested_credential_data: Vec, + pub attestation_object: Vec, pub credential_id: Vec, } From 990937e301871c7389919fe8d882a8351dc62974 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 8 Jul 2024 11:25:01 +0200 Subject: [PATCH 049/214] Move back changelog (#877) In #798 we accidentally moved the bitwarden crate changelog. Moving it back. --- crates/{bitwarden-core => bitwarden}/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) rename crates/{bitwarden-core => bitwarden}/CHANGELOG.md (90%) diff --git a/crates/bitwarden-core/CHANGELOG.md b/crates/bitwarden/CHANGELOG.md similarity index 90% rename from crates/bitwarden-core/CHANGELOG.md rename to crates/bitwarden/CHANGELOG.md index 1d901f56f..8b622ca3b 100644 --- a/crates/bitwarden-core/CHANGELOG.md +++ b/crates/bitwarden/CHANGELOG.md @@ -14,6 +14,9 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Changed - `ClientSettings` and `DeviceType` is now exported in the root module (#805) +- Secrets Manager now requires `bitwarden::secrets_manager::ClientSecretsExt` and + `bitwarden::secrets_manager::ClientProjectsExt` to be imported in order to access `secrets()` and + `projects` on the client (#798) ### Removed From a746a057cb348475bb67d90cba0ed46fb08637b4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 11:33:18 +0200 Subject: [PATCH 050/214] [deps]: Update Rust crate async-trait to v0.1.81 (#880) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [async-trait](https://togithub.com/dtolnay/async-trait) | dependencies | patch | `0.1.80` -> `0.1.81` | --- ### Release Notes
dtolnay/async-trait (async-trait) ### [`v0.1.81`](https://togithub.com/dtolnay/async-trait/releases/tag/0.1.81) [Compare Source](https://togithub.com/dtolnay/async-trait/compare/0.1.80...0.1.81) - Turn off unneeded features of `syn` dependency ([#​272](https://togithub.com/dtolnay/async-trait/issues/272), thanks [@​klensy](https://togithub.com/klensy))
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 976235308..9b0207ab2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -226,9 +226,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.80" +version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" +checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", From 8180ba7b18f0b4bd89a2be5d4546dea8b7c37bd6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 12:22:16 +0200 Subject: [PATCH 051/214] [deps]: Lock file maintenance (#882) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. đŸ‘ģ **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 145 ++++++++++------------ crates/bitwarden-napi/package-lock.json | 24 ++-- languages/js/sdk-client/package-lock.json | 38 +++--- package-lock.json | 36 +++--- 4 files changed, 118 insertions(+), 125 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b0207ab2..5fbe9df17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -842,9 +842,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.101" +version = "1.0.105" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac367972e516d45567c7eafc73d24e1c193dcf200a8d94e9db7b3d38b349572d" +checksum = "5208975e568d83b6b05cc0a063c8e7e9acc2b43bee6da15616a5b73e109d7437" [[package]] name = "cesu8" @@ -870,7 +870,7 @@ dependencies = [ "num-traits", "serde", "wasm-bindgen", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -1949,9 +1949,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe575dd17d0862a9a33781c8c4696a55c320909004a67a00fb286ba8b1bc496d" +checksum = "c4fe55fb7a772d59a5ff1dfbff4fe0258d19b89fec4b233e75d35d5d2316badc" dependencies = [ "bytes", "futures-channel", @@ -1988,9 +1988,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b875924a60b96e5d7b9ae7b066540b1dd1cbd90d1828f54c92e02a283351c56" +checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" dependencies = [ "bytes", "futures-channel", @@ -2219,7 +2219,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -2238,12 +2238,6 @@ dependencies = [ "libc", ] -[[package]] -name = "line-wrap" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd1bc4d24ad230d21fb898d1116b1801d7adfc449d42026475862ab48b11e70e" - [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -2301,9 +2295,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mime_guess" -version = "2.0.4" +version = "2.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" dependencies = [ "mime", "unicase", @@ -2358,9 +2352,9 @@ checksum = "e1c0f5d67ee408a4685b61f5ab7e58605c8ae3f2b4189f0127d804ff13d5560a" [[package]] name = "napi-derive" -version = "2.16.6" +version = "2.16.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70a8a778fd367b13c64232e58632514b795514ece491ce136d96e976d34a3eb8" +checksum = "eafd2b920906ea5b1f5f1f9d1eff9cc74e4ff8124dca41b501c1413079589187" dependencies = [ "cfg-if", "convert_case", @@ -2372,9 +2366,9 @@ dependencies = [ [[package]] name = "napi-derive-backend" -version = "1.0.68" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35849e64596ecd467e1ac897153364a1ffd09b1d79b32ebad94ef8980ac73311" +checksum = "b370b784440c65eb9001d839012eb912ee43e3a2d0361e2c30c13052372c39fe" dependencies = [ "convert_case", "once_cell", @@ -2534,9 +2528,9 @@ dependencies = [ [[package]] name = "oorandom" -version = "11.1.3" +version = "11.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" +checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" [[package]] name = "openssl-probe" @@ -2588,7 +2582,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -2771,13 +2765,12 @@ checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" [[package]] name = "plist" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9d34169e64b3c7a80c8621a48adaf44e0cf62c78a9b25dd9dd35f1881a17cf9" +checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" dependencies = [ - "base64 0.21.7", + "base64 0.22.1", "indexmap 2.2.6", - "line-wrap", "quick-xml", "serde", "time", @@ -2928,9 +2921,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.31.0" +version = "0.32.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1004a344b30a54e2ee58d66a71b32d2db2feb0a31f9a2d302bf0536f15de2a33" +checksum = "1d3a6e5838b60e0e8fa7a43f22ade549a37d61f8bdbe636d0d7816191de969c2" dependencies = [ "memchr", ] @@ -3146,9 +3139,9 @@ dependencies = [ [[package]] name = "rgb" -version = "0.8.37" +version = "0.8.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05aaa8004b64fd573fc9d002f4e632d51ad4f026c2b5ba95fcb6c2f32c2c47d8" +checksum = "3eeba50c58624afb3be6d04abad8cb7a259d52017068c9f828975aa870a5daf5" dependencies = [ "bytemuck", ] @@ -3235,9 +3228,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1fb85efa936c42c6d5fc28d2629bb51e4b2f4b8a5211e297d599cc5a093792" +checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -3291,9 +3284,9 @@ checksum = "84e217e7fdc8466b5b35d30f8c0a30febd29173df4a3a0c2115d306b9c4117ad" [[package]] name = "rustls-webpki" -version = "0.102.4" +version = "0.102.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff448f7e92e913c4b7d4c6d8e4540a1724b319b4152b8aef6d4cf8339712b33e" +checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" dependencies = [ "ring", "rustls-pki-types", @@ -3452,18 +3445,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", @@ -3483,9 +3476,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.118" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d947f6b3163d8857ea16c4fa0dd4840d52f3041039a85decd46867eb1abef2e4" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ "indexmap 2.2.6", "itoa", @@ -3538,9 +3531,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.8.1" +version = "3.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ad483d2ab0149d5a5ebcd9972a3852711e0153d863bf5a5d0391d28883c4a20" +checksum = "e73139bc5ec2d45e6c5fd85be5a46949c1c39a4c18e56915f5eb4c12f975e377" dependencies = [ "base64 0.22.1", "chrono", @@ -3556,9 +3549,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.8.1" +version = "3.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65569b702f41443e8bc8bbb1c5779bd0450bbe723b56198980e80ec45780bce2" +checksum = "b80d3d6b56b64335c0180e5ffde23b3c5e08c14c585b51a15bd0e95393f46703" dependencies = [ "darling", "proc-macro2", @@ -3789,9 +3782,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.68" +version = "2.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +checksum = "201fcda3845c23e8212cd466bfebf0bd20694490fc0356ae8e428e0824a915a6" dependencies = [ "proc-macro2", "quote", @@ -3926,9 +3919,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.6.1" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" +checksum = "ce6b6a2fb3a985e99cebfaefa9faa3024743da73304ca1c683a36429613d3d22" dependencies = [ "tinyvec_macros", ] @@ -4554,7 +4547,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -4572,7 +4565,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.5", + "windows-targets 0.52.6", ] [[package]] @@ -4592,18 +4585,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.5", - "windows_aarch64_msvc 0.52.5", - "windows_i686_gnu 0.52.5", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc 0.52.5", - "windows_x86_64_gnu 0.52.5", - "windows_x86_64_gnullvm 0.52.5", - "windows_x86_64_msvc 0.52.5", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -4614,9 +4607,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" @@ -4626,9 +4619,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" @@ -4638,15 +4631,15 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" @@ -4656,9 +4649,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" @@ -4668,9 +4661,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" @@ -4680,9 +4673,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" @@ -4692,9 +4685,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" -version = "0.52.5" +version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" diff --git a/crates/bitwarden-napi/package-lock.json b/crates/bitwarden-napi/package-lock.json index 8f21b16fd..2520effcf 100644 --- a/crates/bitwarden-napi/package-lock.json +++ b/crates/bitwarden-napi/package-lock.json @@ -59,9 +59,9 @@ } }, "node_modules/@napi-rs/cli": { - "version": "2.18.3", - "resolved": "https://registry.npmjs.org/@napi-rs/cli/-/cli-2.18.3.tgz", - "integrity": "sha512-L0f4kP0dyG8W5Qtc7MtP73VvLLrOLyRcUEBzknIfu8Jk4Jfhrsx1ItMHgyalYqMSslWdY3ojEfAaU5sx1VyeQQ==", + "version": "2.18.4", + "resolved": "https://registry.npmjs.org/@napi-rs/cli/-/cli-2.18.4.tgz", + "integrity": "sha512-SgJeA4df9DE2iAEpr3M2H0OKl/yjtg1BnRI5/JyowS71tUWhrfSu2LT0V3vlHET+g1hBVlrO60PmEXwUEKp8Mg==", "dev": true, "license": "MIT", "bin": { @@ -104,9 +104,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "20.14.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz", - "integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==", + "version": "20.14.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.10.tgz", + "integrity": "sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ==", "dev": true, "license": "MIT", "peer": true, @@ -115,9 +115,9 @@ } }, "node_modules/acorn": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", - "integrity": "sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", + "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", "dev": true, "license": "MIT", "bin": { @@ -216,9 +216,9 @@ } }, "node_modules/typescript": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", - "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", + "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index 209365dc2..05cc3a534 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -160,9 +160,9 @@ } }, "node_modules/glob": { - "version": "10.4.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.2.tgz", - "integrity": "sha512-GwMlUF6PkPo3Gk21UxkCohOv0PLcIXVtKyLlpEI28R/cO/4eNOdmLk3CMW1wROV/WR/EsZOWAfBbBOqYvs88/w==", + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.3.tgz", + "integrity": "sha512-Q38SGlYRpVtDBPSWEylRyctn7uDeTp4NQERTLiCT1FqA9JXPYWqAVmQU6qh4r/zMM5ehxTcbaO8EjhWnvEhmyg==", "dev": true, "license": "ISC", "dependencies": { @@ -177,7 +177,7 @@ "glob": "dist/esm/bin.mjs" }, "engines": { - "node": ">=16 || 14 >=14.18" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -201,16 +201,16 @@ "license": "ISC" }, "node_modules/jackspeak": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.0.tgz", - "integrity": "sha512-JVYhQnN59LVPFCEcVa2C3CrEKYacvjRfqIQl+h8oi91aLYQVWRYbxjPcv1bUiUy/kLmQaANrYfNMCO3kuEDHfw==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.1.tgz", + "integrity": "sha512-U23pQPDnmYybVkYjObcuYMk43VRlMLLqLI+RdZy8s8WV8WsxO9SnqSroKaluuvcNOdCAlauKszDwd+umbot5Mg==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { "@isaacs/cliui": "^8.0.2" }, "engines": { - "node": ">=14" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -220,13 +220,13 @@ } }, "node_modules/lru-cache": { - "version": "10.3.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.3.0.tgz", - "integrity": "sha512-CQl19J/g+Hbjbv4Y3mFNNXFEL/5t/KCg8POCuUqd4rMKjGG+j1ybER83hxV58zL+dFI1PTkt3GNFSHRt+d8qEQ==", + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.0.tgz", + "integrity": "sha512-bfJaPTuEiTYBu+ulDaeQ0F+uLmlfFkMgXj4cbwfuMSjgObGMzb55FMMbDvbRU0fAHZ4sLGkz2mKwcMg8Dvm8Ww==", "dev": true, "license": "ISC", "engines": { - "node": "14 || >=16.14" + "node": ">=18" } }, "node_modules/minimatch": { @@ -290,9 +290,9 @@ } }, "node_modules/rimraf": { - "version": "5.0.7", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.7.tgz", - "integrity": "sha512-nV6YcJo5wbLW77m+8KjH8aB/7/rxQy9SZ0HY5shnwULfS+9nmTtVXAJET5NdZmCzA4fPI/Hm1wo/Po/4mopOdg==", + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.8.tgz", + "integrity": "sha512-XSh0V2/yNhDEi8HwdIefD8MLgs4LQXPag/nEJWs3YUc3Upn+UHa1GyIkEg9xSSNt7HnkO5FjTvmcRzgf+8UZuw==", "dev": true, "license": "ISC", "dependencies": { @@ -302,7 +302,7 @@ "rimraf": "dist/esm/bin.mjs" }, "engines": { - "node": ">=14.18" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -449,9 +449,9 @@ } }, "node_modules/typescript": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz", - "integrity": "sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==", + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", + "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/package-lock.json b/package-lock.json index 1b95e9906..badb89dd1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -370,9 +370,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "20.14.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.9.tgz", - "integrity": "sha512-06OCtnTXtWOZBJlRApleWndH4JsRVs1pDCc8dLSQp+7PpUpX3ePdHyeNSFTeSe7FtKyQkrlPvHwJOW3SLd8Oyg==", + "version": "20.14.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.10.tgz", + "integrity": "sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ==", "dev": true, "license": "MIT", "peer": true, @@ -401,9 +401,9 @@ } }, "node_modules/acorn": { - "version": "8.12.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.0.tgz", - "integrity": "sha512-RTvkC4w+KNXrM39/lWCUaG0IbRkWdCv7W/IOW9oU6SawyxulvkQy5HQPVTKxEjczcUvapcrw3cFx/60VN/NRNw==", + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", + "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", "dev": true, "license": "MIT", "bin": { @@ -1346,16 +1346,16 @@ } }, "node_modules/jackspeak": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.0.tgz", - "integrity": "sha512-JVYhQnN59LVPFCEcVa2C3CrEKYacvjRfqIQl+h8oi91aLYQVWRYbxjPcv1bUiUy/kLmQaANrYfNMCO3kuEDHfw==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.1.tgz", + "integrity": "sha512-U23pQPDnmYybVkYjObcuYMk43VRlMLLqLI+RdZy8s8WV8WsxO9SnqSroKaluuvcNOdCAlauKszDwd+umbot5Mg==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { "@isaacs/cliui": "^8.0.2" }, "engines": { - "node": ">=14" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -1409,13 +1409,13 @@ } }, "node_modules/lru-cache": { - "version": "10.3.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.3.0.tgz", - "integrity": "sha512-CQl19J/g+Hbjbv4Y3mFNNXFEL/5t/KCg8POCuUqd4rMKjGG+j1ybER83hxV58zL+dFI1PTkt3GNFSHRt+d8qEQ==", + "version": "10.4.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.0.tgz", + "integrity": "sha512-bfJaPTuEiTYBu+ulDaeQ0F+uLmlfFkMgXj4cbwfuMSjgObGMzb55FMMbDvbRU0fAHZ4sLGkz2mKwcMg8Dvm8Ww==", "dev": true, "license": "ISC", "engines": { - "node": "14 || >=16.14" + "node": ">=18" } }, "node_modules/make-error": { @@ -1843,9 +1843,9 @@ } }, "node_modules/rimraf/node_modules/glob": { - "version": "10.4.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.2.tgz", - "integrity": "sha512-GwMlUF6PkPo3Gk21UxkCohOv0PLcIXVtKyLlpEI28R/cO/4eNOdmLk3CMW1wROV/WR/EsZOWAfBbBOqYvs88/w==", + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.3.tgz", + "integrity": "sha512-Q38SGlYRpVtDBPSWEylRyctn7uDeTp4NQERTLiCT1FqA9JXPYWqAVmQU6qh4r/zMM5ehxTcbaO8EjhWnvEhmyg==", "dev": true, "license": "ISC", "dependencies": { @@ -1860,7 +1860,7 @@ "glob": "dist/esm/bin.mjs" }, "engines": { - "node": ">=16 || 14 >=14.18" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/isaacs" From 70ec88081b3be3d86e052a347463093e31eb7151 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 8 Jul 2024 16:54:36 +0200 Subject: [PATCH 052/214] [PM-9540] Trim and lowercase email before using as salt (#883) We should trim and convert emails to lowercase prior to using them as salt for the login and registration methods. Which matches the behaviour of our existing applications, https://github.com/bitwarden/clients/blob/main/apps/cli/src/auth/commands/login.command.ts#L575. --- .../bitwarden-core/src/auth/auth_request.rs | 12 +- .../bitwarden-core/src/auth/login/api_key.rs | 2 +- .../bitwarden-core/src/auth/login/password.rs | 6 +- crates/bitwarden-core/src/auth/mod.rs | 2 +- .../src/auth/password/validate.rs | 15 +-- crates/bitwarden-core/src/auth/register.rs | 2 +- crates/bitwarden-core/src/client/internal.rs | 4 +- .../bitwarden-core/src/mobile/client_kdf.rs | 6 +- crates/bitwarden-core/src/mobile/crypto.rs | 19 +-- crates/bitwarden-core/src/mobile/kdf.rs | 5 +- .../src/platform/generate_fingerprint.rs | 8 +- .../src/platform/get_user_api_key.rs | 2 +- .../bitwarden-crypto/src/keys/master_key.rs | 118 +++++++++++------- crates/bitwarden-crypto/src/keys/pin_key.rs | 15 ++- crates/bitwarden-send/src/send.rs | 8 +- crates/memory-testing/src/main.rs | 2 +- 16 files changed, 129 insertions(+), 97 deletions(-) diff --git a/crates/bitwarden-core/src/auth/auth_request.rs b/crates/bitwarden-core/src/auth/auth_request.rs index 7d59f6e69..2b309127e 100644 --- a/crates/bitwarden-core/src/auth/auth_request.rs +++ b/crates/bitwarden-core/src/auth/auth_request.rs @@ -115,7 +115,7 @@ fn test_auth_request() { mod tests { use std::num::NonZeroU32; - use bitwarden_crypto::Kdf; + use bitwarden_crypto::{Kdf, MasterKey}; use super::*; use crate::mobile::crypto::{AuthRequestMethod, InitUserCryptoMethod, InitUserCryptoRequest}; @@ -124,9 +124,9 @@ mod tests { fn test_approve() { let client = Client::new(None); - let master_key = bitwarden_crypto::MasterKey::derive( - "asdfasdfasdf".as_bytes(), - "test@bitwarden.com".as_bytes(), + let master_key = MasterKey::derive( + "asdfasdfasdf", + "test@bitwarden.com", &Kdf::PBKDF2 { iterations: NonZeroU32::new(600_000).unwrap(), }, @@ -200,9 +200,7 @@ mod tests { // Initialize an existing client which is unlocked let existing_device = Client::new(None); - let master_key = - bitwarden_crypto::MasterKey::derive("asdfasdfasdf".as_bytes(), email.as_bytes(), &kdf) - .unwrap(); + let master_key = MasterKey::derive("asdfasdfasdf", email, &kdf).unwrap(); existing_device .internal diff --git a/crates/bitwarden-core/src/auth/login/api_key.rs b/crates/bitwarden-core/src/auth/login/api_key.rs index b0e2c8834..cce246528 100644 --- a/crates/bitwarden-core/src/auth/login/api_key.rs +++ b/crates/bitwarden-core/src/auth/login/api_key.rs @@ -38,7 +38,7 @@ pub(crate) async fn login_api_key( r.expires_in, ); - let master_key = MasterKey::derive(input.password.as_bytes(), email.as_bytes(), &kdf)?; + let master_key = MasterKey::derive(&input.password, &email, &kdf)?; client .internal diff --git a/crates/bitwarden-core/src/auth/login/password.rs b/crates/bitwarden-core/src/auth/login/password.rs index 4536657d3..0521c9d91 100644 --- a/crates/bitwarden-core/src/auth/login/password.rs +++ b/crates/bitwarden-core/src/auth/login/password.rs @@ -30,11 +30,7 @@ pub(crate) async fn login_password( info!("password logging in"); - let master_key = MasterKey::derive( - input.password.as_bytes(), - input.email.as_bytes(), - &input.kdf, - )?; + let master_key = MasterKey::derive(&input.password, &input.email, &input.kdf)?; let password_hash = master_key .derive_master_key_hash(input.password.as_bytes(), HashPurpose::ServerAuthorization)?; diff --git a/crates/bitwarden-core/src/auth/mod.rs b/crates/bitwarden-core/src/auth/mod.rs index b092ba98a..5b3d615e6 100644 --- a/crates/bitwarden-core/src/auth/mod.rs +++ b/crates/bitwarden-core/src/auth/mod.rs @@ -39,7 +39,7 @@ fn determine_password_hash( password: &str, purpose: HashPurpose, ) -> Result { - let master_key = MasterKey::derive(password.as_bytes(), email.as_bytes(), kdf)?; + let master_key = MasterKey::derive(password, email, kdf)?; Ok(master_key.derive_master_key_hash(password.as_bytes(), purpose)?) } diff --git a/crates/bitwarden-core/src/auth/password/validate.rs b/crates/bitwarden-core/src/auth/password/validate.rs index ebb5395d1..c5f8993d6 100644 --- a/crates/bitwarden-core/src/auth/password/validate.rs +++ b/crates/bitwarden-core/src/auth/password/validate.rs @@ -56,7 +56,7 @@ pub(crate) fn validate_password_user_key( match login_method { UserLoginMethod::Username { email, kdf, .. } | UserLoginMethod::ApiKey { email, kdf, .. } => { - let master_key = MasterKey::derive(password.as_bytes(), email.as_bytes(), kdf)?; + let master_key = MasterKey::derive(&password, email, kdf)?; let user_key = master_key .decrypt_user_key(encrypted_user_key.parse()?) .map_err(|_| "wrong password")?; @@ -117,7 +117,7 @@ mod tests { fn test_validate_password_user_key() { use std::num::NonZeroU32; - use bitwarden_crypto::Kdf; + use bitwarden_crypto::{Kdf, MasterKey}; use crate::client::{Client, LoginMethod, UserLoginMethod}; @@ -137,9 +137,7 @@ mod tests { client_id: "1".to_string(), })); - let master_key = - bitwarden_crypto::MasterKey::derive(password.as_bytes(), email.as_bytes(), &kdf) - .unwrap(); + let master_key = MasterKey::derive(password, email, &kdf).unwrap(); let user_key = "2.Q/2PhzcC7GdeiMHhWguYAQ==|GpqzVdr0go0ug5cZh1n+uixeBC3oC90CIe0hd/HWA/pTRDZ8ane4fmsEIcuc8eMKUt55Y2q/fbNzsYu41YTZzzsJUSeqVjT8/iTQtgnNdpo=|dwI+uyvZ1h/iZ03VQ+/wrGEFYVewBUUl/syYgjsNMbE="; let private_key = "2.yN7l00BOlUE0Sb0M//Q53w==|EwKG/BduQRQ33Izqc/ogoBROIoI5dmgrxSo82sgzgAMIBt3A2FZ9vPRMY+GWT85JiqytDitGR3TqwnFUBhKUpRRAq4x7rA6A1arHrFp5Tp1p21O3SfjtvB3quiOKbqWk6ZaU1Np9HwqwAecddFcB0YyBEiRX3VwF2pgpAdiPbSMuvo2qIgyob0CUoC/h4Bz1be7Qa7B0Xw9/fMKkB1LpOm925lzqosyMQM62YpMGkjMsbZz0uPopu32fxzDWSPr+kekNNyLt9InGhTpxLmq1go/pXR2uw5dfpXc5yuta7DB0EGBwnQ8Vl5HPdDooqOTD9I1jE0mRyuBpWTTI3FRnu3JUh3rIyGBJhUmHqGZvw2CKdqHCIrQeQkkEYqOeJRJVdBjhv5KGJifqT3BFRwX/YFJIChAQpebNQKXe/0kPivWokHWwXlDB7S7mBZzhaAPidZvnuIhalE2qmTypDwHy22FyqV58T8MGGMchcASDi/QXI6kcdpJzPXSeU9o+NC68QDlOIrMVxKFeE7w7PvVmAaxEo0YwmuAzzKy9QpdlK0aab/xEi8V4iXj4hGepqAvHkXIQd+r3FNeiLfllkb61p6WTjr5urcmDQMR94/wYoilpG5OlybHdbhsYHvIzYoLrC7fzl630gcO6t4nM24vdB6Ymg9BVpEgKRAxSbE62Tqacxqnz9AcmgItb48NiR/He3n3ydGjPYuKk/ihZMgEwAEZvSlNxYONSbYrIGDtOY+8Nbt6KiH3l06wjZW8tcmFeVlWv+tWotnTY9IqlAfvNVTjtsobqtQnvsiDjdEVtNy/s2ci5TH+NdZluca2OVEr91Wayxh70kpM6ib4UGbfdmGgCo74gtKvKSJU0rTHakQ5L9JlaSDD5FamBRyI0qfL43Ad9qOUZ8DaffDCyuaVyuqk7cz9HwmEmvWU3VQ+5t06n/5kRDXttcw8w+3qClEEdGo1KeENcnXCB32dQe3tDTFpuAIMLqwXs6FhpawfZ5kPYvLPczGWaqftIs/RXJ/EltGc0ugw2dmTLpoQhCqrcKEBDoYVk0LDZKsnzitOGdi9mOWse7Se8798ib1UsHFUjGzISEt6upestxOeupSTOh0v4+AjXbDzRUyogHww3V+Bqg71bkcMxtB+WM+pn1XNbVTyl9NR040nhP7KEf6e9ruXAtmrBC2ah5cFEpLIot77VFZ9ilLuitSz+7T8n1yAh1IEG6xxXxninAZIzi2qGbH69O5RSpOJuJTv17zTLJQIIc781JwQ2TTwTGnx5wZLbffhCasowJKd2EVcyMJyhz6ru0PvXWJ4hUdkARJs3Xu8dus9a86N8Xk6aAPzBDqzYb1vyFIfBxP0oO8xFHgd30Cgmz8UrSE3qeWRrF8ftrI6xQnFjHBGWD/JWSvd6YMcQED0aVuQkuNW9ST/DzQThPzRfPUoiL10yAmV7Ytu4fR3x2sF0Yfi87YhHFuCMpV/DsqxmUizyiJuD938eRcH8hzR/VO53Qo3UIsqOLcyXtTv6THjSlTopQ+JOLOnHm1w8dzYbLN44OG44rRsbihMUQp+wUZ6bsI8rrOnm9WErzkbQFbrfAINdoCiNa6cimYIjvvnMTaFWNymqY1vZxGztQiMiHiHYwTfwHTXrb9j0uPM=|09J28iXv9oWzYtzK2LBT6Yht4IT4MijEkk0fwFdrVQ4=".parse().unwrap(); @@ -162,13 +160,13 @@ mod tests { fn test_validate_password_user_key_wrong_password() { use std::num::NonZeroU32; - use bitwarden_crypto::Kdf; + use bitwarden_crypto::{Kdf, MasterKey}; use crate::client::{Client, LoginMethod, UserLoginMethod}; let client = Client::new(None); - let password = b"asdfasdfasdf"; + let password = "asdfasdfasdf"; let email = "test@bitwarden.com"; let kdf = Kdf::PBKDF2 { iterations: NonZeroU32::new(600_000).unwrap(), @@ -182,8 +180,7 @@ mod tests { client_id: "1".to_string(), })); - let master_key = - bitwarden_crypto::MasterKey::derive(password, email.as_bytes(), &kdf).unwrap(); + let master_key = MasterKey::derive(password, email, &kdf).unwrap(); let user_key = "2.Q/2PhzcC7GdeiMHhWguYAQ==|GpqzVdr0go0ug5cZh1n+uixeBC3oC90CIe0hd/HWA/pTRDZ8ane4fmsEIcuc8eMKUt55Y2q/fbNzsYu41YTZzzsJUSeqVjT8/iTQtgnNdpo=|dwI+uyvZ1h/iZ03VQ+/wrGEFYVewBUUl/syYgjsNMbE="; let private_key = "2.yN7l00BOlUE0Sb0M//Q53w==|EwKG/BduQRQ33Izqc/ogoBROIoI5dmgrxSo82sgzgAMIBt3A2FZ9vPRMY+GWT85JiqytDitGR3TqwnFUBhKUpRRAq4x7rA6A1arHrFp5Tp1p21O3SfjtvB3quiOKbqWk6ZaU1Np9HwqwAecddFcB0YyBEiRX3VwF2pgpAdiPbSMuvo2qIgyob0CUoC/h4Bz1be7Qa7B0Xw9/fMKkB1LpOm925lzqosyMQM62YpMGkjMsbZz0uPopu32fxzDWSPr+kekNNyLt9InGhTpxLmq1go/pXR2uw5dfpXc5yuta7DB0EGBwnQ8Vl5HPdDooqOTD9I1jE0mRyuBpWTTI3FRnu3JUh3rIyGBJhUmHqGZvw2CKdqHCIrQeQkkEYqOeJRJVdBjhv5KGJifqT3BFRwX/YFJIChAQpebNQKXe/0kPivWokHWwXlDB7S7mBZzhaAPidZvnuIhalE2qmTypDwHy22FyqV58T8MGGMchcASDi/QXI6kcdpJzPXSeU9o+NC68QDlOIrMVxKFeE7w7PvVmAaxEo0YwmuAzzKy9QpdlK0aab/xEi8V4iXj4hGepqAvHkXIQd+r3FNeiLfllkb61p6WTjr5urcmDQMR94/wYoilpG5OlybHdbhsYHvIzYoLrC7fzl630gcO6t4nM24vdB6Ymg9BVpEgKRAxSbE62Tqacxqnz9AcmgItb48NiR/He3n3ydGjPYuKk/ihZMgEwAEZvSlNxYONSbYrIGDtOY+8Nbt6KiH3l06wjZW8tcmFeVlWv+tWotnTY9IqlAfvNVTjtsobqtQnvsiDjdEVtNy/s2ci5TH+NdZluca2OVEr91Wayxh70kpM6ib4UGbfdmGgCo74gtKvKSJU0rTHakQ5L9JlaSDD5FamBRyI0qfL43Ad9qOUZ8DaffDCyuaVyuqk7cz9HwmEmvWU3VQ+5t06n/5kRDXttcw8w+3qClEEdGo1KeENcnXCB32dQe3tDTFpuAIMLqwXs6FhpawfZ5kPYvLPczGWaqftIs/RXJ/EltGc0ugw2dmTLpoQhCqrcKEBDoYVk0LDZKsnzitOGdi9mOWse7Se8798ib1UsHFUjGzISEt6upestxOeupSTOh0v4+AjXbDzRUyogHww3V+Bqg71bkcMxtB+WM+pn1XNbVTyl9NR040nhP7KEf6e9ruXAtmrBC2ah5cFEpLIot77VFZ9ilLuitSz+7T8n1yAh1IEG6xxXxninAZIzi2qGbH69O5RSpOJuJTv17zTLJQIIc781JwQ2TTwTGnx5wZLbffhCasowJKd2EVcyMJyhz6ru0PvXWJ4hUdkARJs3Xu8dus9a86N8Xk6aAPzBDqzYb1vyFIfBxP0oO8xFHgd30Cgmz8UrSE3qeWRrF8ftrI6xQnFjHBGWD/JWSvd6YMcQED0aVuQkuNW9ST/DzQThPzRfPUoiL10yAmV7Ytu4fR3x2sF0Yfi87YhHFuCMpV/DsqxmUizyiJuD938eRcH8hzR/VO53Qo3UIsqOLcyXtTv6THjSlTopQ+JOLOnHm1w8dzYbLN44OG44rRsbihMUQp+wUZ6bsI8rrOnm9WErzkbQFbrfAINdoCiNa6cimYIjvvnMTaFWNymqY1vZxGztQiMiHiHYwTfwHTXrb9j0uPM=|09J28iXv9oWzYtzK2LBT6Yht4IT4MijEkk0fwFdrVQ4=".parse().unwrap(); diff --git a/crates/bitwarden-core/src/auth/register.rs b/crates/bitwarden-core/src/auth/register.rs index 07e5e87ba..6a1c875fb 100644 --- a/crates/bitwarden-core/src/auth/register.rs +++ b/crates/bitwarden-core/src/auth/register.rs @@ -57,7 +57,7 @@ pub(super) fn make_register_keys( password: String, kdf: Kdf, ) -> Result { - let master_key = MasterKey::derive(password.as_bytes(), email.as_bytes(), &kdf)?; + let master_key = MasterKey::derive(&password, &email, &kdf)?; let master_password_hash = master_key.derive_master_key_hash(password.as_bytes(), HashPurpose::ServerAuthorization)?; let (user_key, encrypted_user_key) = master_key.make_user_key()?; diff --git a/crates/bitwarden-core/src/client/internal.rs b/crates/bitwarden-core/src/client/internal.rs index 55122b9a1..ee62c9ee5 100644 --- a/crates/bitwarden-core/src/client/internal.rs +++ b/crates/bitwarden-core/src/client/internal.rs @@ -3,7 +3,7 @@ use std::sync::{Arc, RwLock}; #[cfg(any(feature = "internal", feature = "secrets"))] use bitwarden_crypto::SymmetricCryptoKey; #[cfg(feature = "internal")] -use bitwarden_crypto::{AsymmetricEncString, EncString, Kdf, MasterKey}; +use bitwarden_crypto::{AsymmetricEncString, EncString, Kdf, MasterKey, PinKey}; use chrono::Utc; use uuid::Uuid; @@ -213,7 +213,7 @@ impl InternalClient { #[cfg(feature = "internal")] pub(crate) fn initialize_user_crypto_pin( &self, - pin_key: MasterKey, + pin_key: PinKey, pin_protected_user_key: EncString, private_key: EncString, ) -> Result<()> { diff --git a/crates/bitwarden-core/src/mobile/client_kdf.rs b/crates/bitwarden-core/src/mobile/client_kdf.rs index 5ec7aec77..8cbe38eab 100644 --- a/crates/bitwarden-core/src/mobile/client_kdf.rs +++ b/crates/bitwarden-core/src/mobile/client_kdf.rs @@ -3,7 +3,7 @@ use bitwarden_crypto::{HashPurpose, Kdf}; use crate::{error::Result, mobile::kdf::hash_password, Client}; pub struct ClientKdf<'a> { - pub(crate) client: &'a crate::Client, + pub(crate) _client: &'a crate::Client, } impl<'a> ClientKdf<'a> { @@ -14,12 +14,12 @@ impl<'a> ClientKdf<'a> { kdf_params: Kdf, purpose: HashPurpose, ) -> Result { - hash_password(self.client, email, password, kdf_params, purpose).await + hash_password(email, password, kdf_params, purpose).await } } impl<'a> Client { pub fn kdf(&'a self) -> ClientKdf<'a> { - ClientKdf { client: self } + ClientKdf { _client: self } } } diff --git a/crates/bitwarden-core/src/mobile/crypto.rs b/crates/bitwarden-core/src/mobile/crypto.rs index 2b6992496..0fe9e8731 100644 --- a/crates/bitwarden-core/src/mobile/crypto.rs +++ b/crates/bitwarden-core/src/mobile/crypto.rs @@ -85,7 +85,7 @@ pub enum AuthRequestMethod { #[cfg(feature = "internal")] pub async fn initialize_user_crypto(client: &Client, req: InitUserCryptoRequest) -> Result<()> { - use bitwarden_crypto::DeviceKey; + use bitwarden_crypto::{DeviceKey, PinKey}; use crate::auth::{auth_request_decrypt_master_key, auth_request_decrypt_user_key}; @@ -95,8 +95,7 @@ pub async fn initialize_user_crypto(client: &Client, req: InitUserCryptoRequest) InitUserCryptoMethod::Password { password, user_key } => { let user_key: EncString = user_key.parse()?; - let master_key = - MasterKey::derive(password.as_bytes(), req.email.as_bytes(), &req.kdf_params)?; + let master_key = MasterKey::derive(&password, &req.email, &req.kdf_params)?; client .internal .initialize_user_crypto_master_key(master_key, user_key, private_key)?; @@ -111,7 +110,7 @@ pub async fn initialize_user_crypto(client: &Client, req: InitUserCryptoRequest) pin, pin_protected_user_key, } => { - let pin_key = MasterKey::derive(pin.as_bytes(), req.email.as_bytes(), &req.kdf_params)?; + let pin_key = PinKey::derive(pin.as_bytes(), req.email.as_bytes(), &req.kdf_params)?; client.internal.initialize_user_crypto_pin( pin_key, pin_protected_user_key, @@ -216,7 +215,7 @@ pub fn update_password(client: &Client, new_password: String) -> Result MasterKey::derive(new_password.as_bytes(), email.as_bytes(), kdf)?, + ) => MasterKey::derive(&new_password, email, kdf)?, #[cfg(feature = "secrets")] LoginMethod::ServiceAccount(_) => return Err(Error::NotAuthenticated), }; @@ -283,11 +282,13 @@ fn derive_pin_protected_user_key( login_method: &LoginMethod, user_key: &SymmetricCryptoKey, ) -> Result { + use bitwarden_crypto::PinKey; + let derived_key = match login_method { LoginMethod::User( UserLoginMethod::Username { email, kdf, .. } | UserLoginMethod::ApiKey { email, kdf, .. }, - ) => MasterKey::derive(pin.as_bytes(), email.as_bytes(), kdf)?, + ) => PinKey::derive(pin.as_bytes(), email.as_bytes(), kdf)?, #[cfg(feature = "secrets")] LoginMethod::ServiceAccount(_) => return Err(Error::NotAuthenticated), }; @@ -504,9 +505,9 @@ mod tests { let client = Client::new(None); - let master_key = bitwarden_crypto::MasterKey::derive( - "asdfasdfasdf".as_bytes(), - "test@bitwarden.com".as_bytes(), + let master_key = MasterKey::derive( + "asdfasdfasdf", + "test@bitwarden.com", &Kdf::PBKDF2 { iterations: NonZeroU32::new(600_000).unwrap(), }, diff --git a/crates/bitwarden-core/src/mobile/kdf.rs b/crates/bitwarden-core/src/mobile/kdf.rs index 1c1972086..e52328ed8 100644 --- a/crates/bitwarden-core/src/mobile/kdf.rs +++ b/crates/bitwarden-core/src/mobile/kdf.rs @@ -1,15 +1,14 @@ use bitwarden_crypto::{HashPurpose, Kdf, MasterKey}; -use crate::{error::Result, Client}; +use crate::error::Result; pub async fn hash_password( - _client: &Client, email: String, password: String, kdf_params: Kdf, purpose: HashPurpose, ) -> Result { - let master_key = MasterKey::derive(password.as_bytes(), email.as_bytes(), &kdf_params)?; + let master_key = MasterKey::derive(&password, &email, &kdf_params)?; Ok(master_key.derive_master_key_hash(password.as_bytes(), purpose)?) } diff --git a/crates/bitwarden-core/src/platform/generate_fingerprint.rs b/crates/bitwarden-core/src/platform/generate_fingerprint.rs index 6ac41e149..5d31a1af1 100644 --- a/crates/bitwarden-core/src/platform/generate_fingerprint.rs +++ b/crates/bitwarden-core/src/platform/generate_fingerprint.rs @@ -54,7 +54,7 @@ pub(crate) fn generate_user_fingerprint( mod tests { use std::num::NonZeroU32; - use bitwarden_crypto::Kdf; + use bitwarden_crypto::{Kdf, MasterKey}; use super::*; use crate::Client; @@ -67,9 +67,9 @@ mod tests { let client = Client::new(None); - let master_key = bitwarden_crypto::MasterKey::derive( - "asdfasdfasdf".as_bytes(), - "robb@stark.com".as_bytes(), + let master_key = MasterKey::derive( + "asdfasdfasdf", + "robb@stark.com", &Kdf::PBKDF2 { iterations: NonZeroU32::new(600_000).unwrap(), }, diff --git a/crates/bitwarden-core/src/platform/get_user_api_key.rs b/crates/bitwarden-core/src/platform/get_user_api_key.rs index dcdafa0b4..379707edd 100644 --- a/crates/bitwarden-core/src/platform/get_user_api_key.rs +++ b/crates/bitwarden-core/src/platform/get_user_api_key.rs @@ -52,7 +52,7 @@ fn get_secret_verification_request( .master_password .as_ref() .map(|p| { - let master_key = MasterKey::derive(p.as_bytes(), email.as_bytes(), kdf)?; + let master_key = MasterKey::derive(p, email, kdf)?; master_key.derive_master_key_hash(p.as_bytes(), HashPurpose::ServerAuthorization) }) diff --git a/crates/bitwarden-crypto/src/keys/master_key.rs b/crates/bitwarden-crypto/src/keys/master_key.rs index 1b9ee1aa0..83e51a1b2 100644 --- a/crates/bitwarden-crypto/src/keys/master_key.rs +++ b/crates/bitwarden-crypto/src/keys/master_key.rs @@ -69,8 +69,15 @@ impl MasterKey { } /// Derives a users master key from their password, email and KDF. - pub fn derive(password: &[u8], email: &[u8], kdf: &Kdf) -> Result { - derive_kdf_key(password, email, kdf).map(Self) + /// + /// Note: the email is trimmed and converted to lowercase before being used. + pub fn derive(password: &str, email: &str, kdf: &Kdf) -> Result { + derive_kdf_key( + password.as_bytes(), + email.trim().to_lowercase().as_bytes(), + kdf, + ) + .map(Self) } /// Derive the master key hash, used for local and remote password validation. @@ -85,34 +92,51 @@ impl MasterKey { make_user_key(rand::thread_rng(), self) } + /// Encrypt the users user key + pub fn encrypt_user_key(&self, user_key: &SymmetricCryptoKey) -> Result { + encrypt_user_key(&self.0, user_key) + } + /// Decrypt the users user key pub fn decrypt_user_key(&self, user_key: EncString) -> Result { - let mut dec: Vec = match user_key { - // Legacy. user_keys were encrypted using `AesCbc256_B64` a long time ago. We've since - // moved to using `AesCbc256_HmacSha256_B64`. However, we still need to support - // decrypting these old keys. - EncString::AesCbc256_B64 { .. } => user_key.decrypt_with_key(&self.0)?, - _ => { - let stretched_key = stretch_kdf_key(&self.0)?; - user_key.decrypt_with_key(&stretched_key)? - } - }; - - SymmetricCryptoKey::try_from(dec.as_mut_slice()) + decrypt_user_key(&self.0, user_key) } +} - pub fn encrypt_user_key(&self, user_key: &SymmetricCryptoKey) -> Result { - let stretched_key = stretch_kdf_key(&self.0)?; - - EncString::encrypt_aes256_hmac( - &user_key.to_vec(), - stretched_key - .mac_key - .as_ref() - .ok_or(CryptoError::InvalidMac)?, - &stretched_key.key, - ) - } +/// Helper function to encrypt a user key with a master or pin key. +pub(super) fn encrypt_user_key( + key: &SymmetricCryptoKey, + user_key: &SymmetricCryptoKey, +) -> Result { + let stretched_key = stretch_kdf_key(key)?; + + EncString::encrypt_aes256_hmac( + &user_key.to_vec(), + stretched_key + .mac_key + .as_ref() + .ok_or(CryptoError::InvalidMac)?, + &stretched_key.key, + ) +} + +/// Helper function to decrypt a user key with a master or pin key. +pub(super) fn decrypt_user_key( + key: &SymmetricCryptoKey, + user_key: EncString, +) -> Result { + let mut dec: Vec = match user_key { + // Legacy. user_keys were encrypted using `AesCbc256_B64` a long time ago. We've since + // moved to using `AesCbc256_HmacSha256_B64`. However, we still need to support + // decrypting these old keys. + EncString::AesCbc256_B64 { .. } => user_key.decrypt_with_key(key)?, + _ => { + let stretched_key = stretch_kdf_key(key)?; + user_key.decrypt_with_key(&stretched_key)? + } + }; + + SymmetricCryptoKey::try_from(dec.as_mut_slice()) } /// Generate a new random user key and encrypt it with the master key. @@ -137,8 +161,8 @@ mod tests { #[test] fn test_master_key_derive_pbkdf2() { let master_key = MasterKey::derive( - b"67t9b5g67$%Dh89n", - b"test_key", + "67t9b5g67$%Dh89n", + "test_key", &Kdf::PBKDF2 { iterations: NonZeroU32::new(10000).unwrap(), }, @@ -158,8 +182,8 @@ mod tests { #[test] fn test_master_key_derive_argon2() { let master_key = MasterKey::derive( - b"67t9b5g67$%Dh89n", - b"test_key", + "67t9b5g67$%Dh89n", + "test_key", &Kdf::Argon2id { iterations: NonZeroU32::new(4).unwrap(), memory: NonZeroU32::new(32).unwrap(), @@ -180,26 +204,32 @@ mod tests { #[test] fn test_password_hash_pbkdf2() { - let password = b"asdfasdf"; - let salt = b"test_salt"; + let password = "asdfasdf"; + let salts = [ + "test@bitwarden.com", + "TEST@bitwarden.com", + " test@bitwarden.com", + ]; let kdf = Kdf::PBKDF2 { iterations: NonZeroU32::new(100_000).unwrap(), }; - let master_key = MasterKey::derive(password, salt, &kdf).unwrap(); + for salt in salts.iter() { + let master_key = MasterKey::derive(password, salt, &kdf).unwrap(); - assert_eq!( - "ZF6HjxUTSyBHsC+HXSOhZoXN+UuMnygV5YkWXCY4VmM=", - master_key - .derive_master_key_hash(password, HashPurpose::ServerAuthorization) - .unwrap(), - ); + assert_eq!( + "wmyadRMyBZOH7P/a/ucTCbSghKgdzDpPqUnu/DAVtSw=", + master_key + .derive_master_key_hash(password.as_bytes(), HashPurpose::ServerAuthorization) + .unwrap(), + ); + } } #[test] fn test_password_hash_argon2id() { - let password = b"asdfasdf"; - let salt = b"test_salt"; + let password = "asdfasdf"; + let salt = "test_salt"; let kdf = Kdf::Argon2id { iterations: NonZeroU32::new(4).unwrap(), memory: NonZeroU32::new(32).unwrap(), @@ -211,7 +241,7 @@ mod tests { assert_eq!( "PR6UjYmjmppTYcdyTiNbAhPJuQQOmynKbdEl1oyi/iQ=", master_key - .derive_master_key_hash(password, HashPurpose::ServerAuthorization) + .derive_master_key_hash(password.as_bytes(), HashPurpose::ServerAuthorization) .unwrap(), ); } @@ -282,8 +312,8 @@ mod tests { #[test] fn test_decrypt_user_key_aes_cbc256_b64() { - let password = b"asdfasdfasdf"; - let salt = b"legacy@bitwarden.com"; + let password = "asdfasdfasdf"; + let salt = "legacy@bitwarden.com"; let kdf = Kdf::PBKDF2 { iterations: NonZeroU32::new(600_000).unwrap(), }; diff --git a/crates/bitwarden-crypto/src/keys/pin_key.rs b/crates/bitwarden-crypto/src/keys/pin_key.rs index 475b7ffd9..9e6c02db5 100644 --- a/crates/bitwarden-crypto/src/keys/pin_key.rs +++ b/crates/bitwarden-crypto/src/keys/pin_key.rs @@ -1,3 +1,4 @@ +use super::master_key::{decrypt_user_key, encrypt_user_key}; use crate::{ keys::{ key_encryptable::CryptoKey, @@ -17,8 +18,18 @@ impl PinKey { } /// Derives a users pin key from their password, email and KDF. - pub fn derive(password: &[u8], salt: &[u8], kdf: &Kdf) -> Result { - derive_kdf_key(password, salt, kdf).map(Self) + pub fn derive(password: &[u8], email: &[u8], kdf: &Kdf) -> Result { + derive_kdf_key(password, email, kdf).map(Self) + } + + /// Encrypt the users user key + pub fn encrypt_user_key(&self, user_key: &SymmetricCryptoKey) -> Result { + encrypt_user_key(&self.0, user_key) + } + + /// Decrypt the users user key + pub fn decrypt_user_key(&self, user_key: EncString) -> Result { + decrypt_user_key(&self.0, user_key) } } diff --git a/crates/bitwarden-send/src/send.rs b/crates/bitwarden-send/src/send.rs index 452032cf6..707fbd530 100644 --- a/crates/bitwarden-send/src/send.rs +++ b/crates/bitwarden-send/src/send.rs @@ -384,8 +384,8 @@ mod tests { fn test_get_send_key() { // Initialize user encryption with some test data let master_key = MasterKey::derive( - "asdfasdfasdf".as_bytes(), - "test@bitwarden.com".as_bytes(), + "asdfasdfasdf", + "test@bitwarden.com", &Kdf::PBKDF2 { iterations: 345123.try_into().unwrap(), }, @@ -410,8 +410,8 @@ mod tests { fn build_encryption_settings() -> MockKeyContainer { let master_key = MasterKey::derive( - "asdfasdfasdf".as_bytes(), - "test@bitwarden.com".as_bytes(), + "asdfasdfasdf", + "test@bitwarden.com", &Kdf::PBKDF2 { iterations: 600_000.try_into().unwrap(), }, diff --git a/crates/memory-testing/src/main.rs b/crates/memory-testing/src/main.rs index 056ab582b..133a786ee 100644 --- a/crates/memory-testing/src/main.rs +++ b/crates/memory-testing/src/main.rs @@ -39,7 +39,7 @@ fn main() { email, kdf, } => { - let key = MasterKey::derive(password.as_bytes(), email.as_bytes(), &kdf).unwrap(); + let key = MasterKey::derive(&password, &email, &kdf).unwrap(); let hash = key .derive_master_key_hash( password.as_bytes(), From 7fc5fe4d843cbcfd4b3e02c7a101f8dcdecec1e4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 21:11:07 +0200 Subject: [PATCH 053/214] [deps]: Update rimraf to v5.0.8 (#885) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [rimraf](https://togithub.com/isaacs/rimraf) | [`5.0.7` -> `5.0.8`](https://renovatebot.com/diffs/npm/rimraf/5.0.7/5.0.8) | [![age](https://developer.mend.io/api/mc/badges/age/npm/rimraf/5.0.8?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/rimraf/5.0.8?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/rimraf/5.0.7/5.0.8?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/rimraf/5.0.7/5.0.8?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
isaacs/rimraf (rimraf) ### [`v5.0.8`](https://togithub.com/isaacs/rimraf/compare/v5.0.7...v5.0.8) [Compare Source](https://togithub.com/isaacs/rimraf/compare/v5.0.7...v5.0.8)
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 10 +++++----- package.json | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index badb89dd1..1dfac7662 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "handlebars": "^4.7.8", "prettier": "3.2.5", "quicktype-core": "23.0.81", - "rimraf": "5.0.7", + "rimraf": "5.0.8", "ts-node": "10.9.2", "typescript": "5.3.3" } @@ -1814,9 +1814,9 @@ } }, "node_modules/rimraf": { - "version": "5.0.7", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.7.tgz", - "integrity": "sha512-nV6YcJo5wbLW77m+8KjH8aB/7/rxQy9SZ0HY5shnwULfS+9nmTtVXAJET5NdZmCzA4fPI/Hm1wo/Po/4mopOdg==", + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.8.tgz", + "integrity": "sha512-XSh0V2/yNhDEi8HwdIefD8MLgs4LQXPag/nEJWs3YUc3Upn+UHa1GyIkEg9xSSNt7HnkO5FjTvmcRzgf+8UZuw==", "dev": true, "license": "ISC", "dependencies": { @@ -1826,7 +1826,7 @@ "rimraf": "dist/esm/bin.mjs" }, "engines": { - "node": ">=14.18" + "node": ">=18" }, "funding": { "url": "https://github.com/sponsors/isaacs" diff --git a/package.json b/package.json index dc256ea5d..353978304 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "handlebars": "^4.7.8", "prettier": "3.2.5", "quicktype-core": "23.0.81", - "rimraf": "5.0.7", + "rimraf": "5.0.8", "ts-node": "10.9.2", "typescript": "5.3.3" } From 9a38cb5c39770008a9a61fc0f73e0ed2595feb9d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 21:20:34 +0200 Subject: [PATCH 054/214] [deps]: Update Rust crate itertools to 0.13.0 (#887) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [itertools](https://togithub.com/rust-itertools/itertools) | dependencies | minor | `0.12.1` -> `0.13.0` | --- ### Release Notes
rust-itertools/itertools (itertools) ### [`v0.13.0`](https://togithub.com/rust-itertools/itertools/blob/HEAD/CHANGELOG.md#0130) [Compare Source](https://togithub.com/rust-itertools/itertools/compare/v0.12.1...v0.13.0) ##### Breaking - Removed implementation of `DoubleEndedIterator` for `ConsTuples` ([#​853](https://togithub.com/rust-itertools/itertools/issues/853)) - Made `MultiProduct` fused and fixed on an empty iterator ([#​835](https://togithub.com/rust-itertools/itertools/issues/835), [#​834](https://togithub.com/rust-itertools/itertools/issues/834)) - Changed `iproduct!` to return tuples for maxi one iterator too ([#​870](https://togithub.com/rust-itertools/itertools/issues/870)) - Changed `PutBack::put_back` to return the old value ([#​880](https://togithub.com/rust-itertools/itertools/issues/880)) - Removed deprecated `repeat_call, Itertools::{foreach, step, map_results, fold_results}` ([#​878](https://togithub.com/rust-itertools/itertools/issues/878)) - Removed `TakeWhileInclusive::new` ([#​912](https://togithub.com/rust-itertools/itertools/issues/912)) ##### Added - Added `Itertools::{smallest_by, smallest_by_key, largest, largest_by, largest_by_key}` ([#​654](https://togithub.com/rust-itertools/itertools/issues/654), [#​885](https://togithub.com/rust-itertools/itertools/issues/885)) - Added `Itertools::tail` ([#​899](https://togithub.com/rust-itertools/itertools/issues/899)) - Implemented `DoubleEndedIterator` for `ProcessResults` ([#​910](https://togithub.com/rust-itertools/itertools/issues/910)) - Implemented `Debug` for `FormatWith` ([#​931](https://togithub.com/rust-itertools/itertools/issues/931)) - Added `Itertools::get` ([#​891](https://togithub.com/rust-itertools/itertools/issues/891)) ##### Changed - Deprecated `Itertools::group_by` (renamed `chunk_by`) ([#​866](https://togithub.com/rust-itertools/itertools/issues/866), [#​879](https://togithub.com/rust-itertools/itertools/issues/879)) - Deprecated `unfold` (use `std::iter::from_fn` instead) ([#​871](https://togithub.com/rust-itertools/itertools/issues/871)) - Optimized `GroupingMapBy` ([#​873](https://togithub.com/rust-itertools/itertools/issues/873), [#​876](https://togithub.com/rust-itertools/itertools/issues/876)) - Relaxed `Fn` bounds to `FnMut` in `diff_with, Itertools::into_group_map_by` ([#​886](https://togithub.com/rust-itertools/itertools/issues/886)) - Relaxed `Debug/Clone` bounds for `MapInto` ([#​889](https://togithub.com/rust-itertools/itertools/issues/889)) - Documented the `use_alloc` feature ([#​887](https://togithub.com/rust-itertools/itertools/issues/887)) - Optimized `Itertools::set_from` ([#​888](https://togithub.com/rust-itertools/itertools/issues/888)) - Removed badges in `README.md` ([#​890](https://togithub.com/rust-itertools/itertools/issues/890)) - Added "no-std" categories in `Cargo.toml` ([#​894](https://togithub.com/rust-itertools/itertools/issues/894)) - Fixed `Itertools::k_smallest` on short unfused iterators ([#​900](https://togithub.com/rust-itertools/itertools/issues/900)) - Deprecated `Itertools::tree_fold1` (renamed `tree_reduce`) ([#​895](https://togithub.com/rust-itertools/itertools/issues/895)) - Deprecated `GroupingMap::fold_first` (renamed `reduce`) ([#​902](https://togithub.com/rust-itertools/itertools/issues/902)) - Fixed `Itertools::k_smallest(0)` to consume the iterator, optimized `Itertools::k_smallest(1)` ([#​909](https://togithub.com/rust-itertools/itertools/issues/909)) - Specialized `Combinations::nth` ([#​914](https://togithub.com/rust-itertools/itertools/issues/914)) - Specialized `MergeBy::fold` ([#​920](https://togithub.com/rust-itertools/itertools/issues/920)) - Specialized `CombinationsWithReplacement::nth` ([#​923](https://togithub.com/rust-itertools/itertools/issues/923)) - Specialized `FlattenOk::{fold, rfold}` ([#​927](https://togithub.com/rust-itertools/itertools/issues/927)) - Specialized `Powerset::nth` ([#​924](https://togithub.com/rust-itertools/itertools/issues/924)) - Documentation fixes ([#​882](https://togithub.com/rust-itertools/itertools/issues/882), [#​936](https://togithub.com/rust-itertools/itertools/issues/936)) - Fixed `assert_equal` for iterators longer than `i32::MAX` ([#​932](https://togithub.com/rust-itertools/itertools/issues/932)) - Updated the `must_use` message of non-lazy `KMergeBy` and `TupleCombinations` ([#​939](https://togithub.com/rust-itertools/itertools/issues/939)) ##### Notable Internal Changes - Tested iterator laziness ([#​792](https://togithub.com/rust-itertools/itertools/issues/792)) - Created `CONTRIBUTING.md` ([#​767](https://togithub.com/rust-itertools/itertools/issues/767))
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 11 +---------- crates/sdk-schemas/Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5fbe9df17..ca46f9a37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2144,15 +2144,6 @@ dependencies = [ "either", ] -[[package]] -name = "itertools" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.13.0" @@ -3390,7 +3381,7 @@ dependencies = [ "bitwarden", "bitwarden-json", "bitwarden-uniffi", - "itertools 0.12.1", + "itertools 0.13.0", "schemars", "serde_json", ] diff --git a/crates/sdk-schemas/Cargo.toml b/crates/sdk-schemas/Cargo.toml index 055878b13..05c7f24b3 100644 --- a/crates/sdk-schemas/Cargo.toml +++ b/crates/sdk-schemas/Cargo.toml @@ -23,6 +23,6 @@ anyhow = "1.0.82" bitwarden = { workspace = true } bitwarden-json = { path = "../bitwarden-json" } bitwarden-uniffi = { path = "../bitwarden-uniffi" } -itertools = "0.12.1" +itertools = "0.13.0" schemars = { version = "0.8.16", features = ["preserve_order"] } serde_json = "1.0.113" From eaf4ad1c83750b808071e5cdf6b4b2dd79882e25 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 21:37:32 +0200 Subject: [PATCH 055/214] [deps]: Update prettier to v3.3.2 (#890) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [prettier](https://prettier.io) ([source](https://togithub.com/prettier/prettier)) | [`3.2.5` -> `3.3.2`](https://renovatebot.com/diffs/npm/prettier/3.2.5/3.3.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/prettier/3.3.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/prettier/3.3.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/prettier/3.2.5/3.3.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/prettier/3.2.5/3.3.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
prettier/prettier (prettier) ### [`v3.3.2`](https://togithub.com/prettier/prettier/blob/HEAD/CHANGELOG.md#332) [Compare Source](https://togithub.com/prettier/prettier/compare/3.3.1...3.3.2) [diff](https://togithub.com/prettier/prettier/compare/3.3.1...3.3.2) ##### Fix handlebars path expressions starts with `@` ([#​16358](https://togithub.com/prettier/prettier/pull/16358) by [@​Princeyadav05](https://togithub.com/Princeyadav05)) ```hbs {{! Input }}
{{@​x.y.z}}
{{! Prettier 3.3.1 }}
{{@​x}}
{{! Prettier 3.3.2 }}
{{@​x.y.z}}
``` ### [`v3.3.1`](https://togithub.com/prettier/prettier/blob/HEAD/CHANGELOG.md#331) [Compare Source](https://togithub.com/prettier/prettier/compare/3.3.0...3.3.1) [diff](https://togithub.com/prettier/prettier/compare/3.3.0...3.3.1) ##### Preserve empty lines in front matter ([#​16347](https://togithub.com/prettier/prettier/pull/16347) by [@​fisker](https://togithub.com/fisker)) ```markdown --- foo: - bar1 - bar2 - bar3 --- Markdown --- foo: - bar1 - bar2 - bar3 --- Markdown --- foo: - bar1 - bar2 - bar3 --- Markdown ``` ##### Preserve explicit language in front matter ([#​16348](https://togithub.com/prettier/prettier/pull/16348) by [@​fisker](https://togithub.com/fisker)) ```markdown ---yaml title: Hello slug: home --- --- title: Hello slug: home --- ---yaml title: Hello slug: home --- ``` ##### Avoid line breaks in import attributes ([#​16349](https://togithub.com/prettier/prettier/pull/16349) by [@​fisker](https://togithub.com/fisker)) ```jsx // Input import something from "./some-very-very-very-very-very-very-very-very-long-path.json" with { type: "json" }; // Prettier 3.3.0 import something from "./some-very-very-very-very-very-very-very-very-long-path.json" with { type: "json" }; // Prettier 3.3.1 import something from "./some-very-very-very-very-very-very-very-very-long-path.json" with { type: "json" }; ``` ### [`v3.3.0`](https://togithub.com/prettier/prettier/blob/HEAD/CHANGELOG.md#330) [Compare Source](https://togithub.com/prettier/prettier/compare/3.2.5...3.3.0) [diff](https://togithub.com/prettier/prettier/compare/3.2.5...3.3.0) 🔗 [Release Notes](https://prettier.io/blog/2024/06/01/3.3.0.html)
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1dfac7662..0c5c2ada1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "devDependencies": { "@openapitools/openapi-generator-cli": "2.13.4", "handlebars": "^4.7.8", - "prettier": "3.2.5", + "prettier": "3.3.2", "quicktype-core": "23.0.81", "rimraf": "5.0.8", "ts-node": "10.9.2", @@ -1662,9 +1662,9 @@ } }, "node_modules/prettier": { - "version": "3.2.5", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.2.5.tgz", - "integrity": "sha512-3/GWa9aOC0YeD7LUfvOG2NiDyhOWRvt1k+rcKhOuYnMY24iiCphgneUfJDyFXd6rZCAnuLBv6UeAULtrhT/F4A==", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", + "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", "dev": true, "license": "MIT", "bin": { diff --git a/package.json b/package.json index 353978304..0c9c448ce 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "devDependencies": { "@openapitools/openapi-generator-cli": "2.13.4", "handlebars": "^4.7.8", - "prettier": "3.2.5", + "prettier": "3.3.2", "quicktype-core": "23.0.81", "rimraf": "5.0.8", "ts-node": "10.9.2", From a8a96c4f00fa794dae81345a71d24cfd82bac3ef Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:44:39 +0200 Subject: [PATCH 056/214] [deps]: Update Rust crate android_logger to 0.14 (#886) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [android_logger](https://togithub.com/rust-mobile/android_logger-rs) | dependencies | minor | `0.13` -> `0.14` | --- ### Release Notes
rust-mobile/android_logger-rs (android_logger) ### [`v0.14.1`](https://togithub.com/rust-mobile/android_logger-rs/compare/0.14.0...0.14.1) [Compare Source](https://togithub.com/rust-mobile/android_logger-rs/compare/0.14.0...0.14.1)
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 27 ++++++++------------------- crates/bitwarden-uniffi/Cargo.toml | 2 +- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ca46f9a37..9b3fb8102 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -52,14 +52,13 @@ checksum = "5ecc8056bf6ab9892dcd53216c83d1597487d7dacac16c8df6b877d127df9937" [[package]] name = "android_logger" -version = "0.13.3" +version = "0.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c494134f746c14dc653a35a4ea5aca24ac368529da5370ecf41fe0341c35772f" +checksum = "05b07e8e73d720a1f2e4b6014766e6039fd2e96a4fa44e2a78d0e1fa2ff49826" dependencies = [ "android_log-sys", - "env_logger 0.10.2", + "env_filter", "log", - "once_cell", ] [[package]] @@ -408,7 +407,7 @@ name = "bitwarden-c" version = "0.1.0" dependencies = [ "bitwarden-json", - "env_logger 0.11.3", + "env_logger", "tokio", ] @@ -566,7 +565,7 @@ name = "bitwarden-napi" version = "0.3.1" dependencies = [ "bitwarden-json", - "env_logger 0.11.3", + "env_logger", "log", "napi", "napi-build", @@ -633,7 +632,7 @@ dependencies = [ "bitwarden-send", "bitwarden-vault", "chrono", - "env_logger 0.11.3", + "env_logger", "log", "schemars", "thiserror", @@ -734,7 +733,7 @@ dependencies = [ "bitwarden-crypto", "clap", "color-eyre", - "env_logger 0.11.3", + "env_logger", "inquire", "log", "tempfile", @@ -755,7 +754,7 @@ dependencies = [ "color-eyre", "comfy-table", "directories", - "env_logger 0.11.3", + "env_logger", "log", "regex", "serde", @@ -1515,16 +1514,6 @@ dependencies = [ "regex", ] -[[package]] -name = "env_logger" -version = "0.10.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd405aab171cb85d6735e5c8d9db038c17d3ca007a4d2c25f337935c3d90580" -dependencies = [ - "log", - "regex", -] - [[package]] name = "env_logger" version = "0.11.3" diff --git a/crates/bitwarden-uniffi/Cargo.toml b/crates/bitwarden-uniffi/Cargo.toml index 2b2ecd11e..38f791499 100644 --- a/crates/bitwarden-uniffi/Cargo.toml +++ b/crates/bitwarden-uniffi/Cargo.toml @@ -39,7 +39,7 @@ uniffi = "=0.27.2" uuid = ">=1.3.3, <2" [target.'cfg(target_os = "android")'.dependencies] -android_logger = "0.13" +android_logger = "0.14" [build-dependencies] uniffi = { version = "=0.27.2", features = ["build"] } From 6decd1ffc3cc32ab4757621bcb8370da1624938d Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Tue, 9 Jul 2024 13:33:25 +0200 Subject: [PATCH 057/214] Use oslogger for macOS logging (#891) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective Xcode doesn't seem to be able to pick up `stdio` logs from secondary processes like autofill extensions. This PR switches to using native iOS logging which Xcode supports. ## 📸 Screenshots ![image](https://github.com/bitwarden/sdk/assets/2285588/72ffb8d5-1597-4cdf-98f0-33f0becbbcc7) ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- Cargo.lock | 65 +++++++++++++++++++++--------- crates/bitwarden-uniffi/Cargo.toml | 3 ++ crates/bitwarden-uniffi/src/lib.rs | 7 +++- 3 files changed, 54 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9b3fb8102..4638068d0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -634,6 +634,7 @@ dependencies = [ "chrono", "env_logger", "log", + "oslog", "schemars", "thiserror", "uniffi", @@ -841,9 +842,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.105" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5208975e568d83b6b05cc0a063c8e7e9acc2b43bee6da15616a5b73e109d7437" +checksum = "066fce287b1d4eafef758e89e09d724a24808a9196fe9756b8ca90e86d0719a2" [[package]] name = "cesu8" @@ -912,9 +913,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.8" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", "clap_derive", @@ -922,9 +923,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.8" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ "anstream", "anstyle", @@ -1331,6 +1332,19 @@ dependencies = [ "syn", ] +[[package]] +name = "dashmap" +version = "5.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856" +dependencies = [ + "cfg-if", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + [[package]] name = "data-encoding" version = "2.6.0" @@ -2524,6 +2538,17 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "oslog" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969" +dependencies = [ + "cc", + "dashmap", + "log", +] + [[package]] name = "owo-colors" version = "3.5.0" @@ -3119,9 +3144,9 @@ dependencies = [ [[package]] name = "rgb" -version = "0.8.42" +version = "0.8.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3eeba50c58624afb3be6d04abad8cb7a259d52017068c9f828975aa870a5daf5" +checksum = "1aee83dc281d5a3200d37b299acd13b81066ea126a7f16f0eae70fc9aed241d9" dependencies = [ "bytemuck", ] @@ -3194,9 +3219,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.10" +version = "0.23.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05cff451f60db80f490f3c182b77c35260baace73209e9cdbbe526bfe3a4d402" +checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" dependencies = [ "once_cell", "ring", @@ -3762,9 +3787,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.69" +version = "2.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201fcda3845c23e8212cd466bfebf0bd20694490fc0356ae8e428e0824a915a6" +checksum = "2f0209b68b3613b093e0ec905354eccaedcfe83b8cb37cbdeae64026c3064c16" dependencies = [ "proc-macro2", "quote", @@ -3799,9 +3824,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.14" +version = "0.12.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f" +checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2" [[package]] name = "tempfile" @@ -3899,9 +3924,9 @@ dependencies = [ [[package]] name = "tinyvec" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6b6a2fb3a985e99cebfaefa9faa3024743da73304ca1c683a36429613d3d22" +checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" dependencies = [ "tinyvec_macros", ] @@ -3996,9 +4021,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.14" +version = "0.22.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" +checksum = "d59a3a72298453f564e2b111fa896f8d07fabb36f51f06d7e875fc5e0b5a3ef1" dependencies = [ "indexmap 2.2.6", "serde", @@ -4324,9 +4349,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.9.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" dependencies = [ "getrandom", "serde", diff --git a/crates/bitwarden-uniffi/Cargo.toml b/crates/bitwarden-uniffi/Cargo.toml index 38f791499..f7a464328 100644 --- a/crates/bitwarden-uniffi/Cargo.toml +++ b/crates/bitwarden-uniffi/Cargo.toml @@ -41,6 +41,9 @@ uuid = ">=1.3.3, <2" [target.'cfg(target_os = "android")'.dependencies] android_logger = "0.14" +[target.'cfg(target_os = "ios")'.dependencies] +oslog = "0.2.0" + [build-dependencies] uniffi = { version = "=0.27.2", features = ["build"] } diff --git a/crates/bitwarden-uniffi/src/lib.rs b/crates/bitwarden-uniffi/src/lib.rs index 6ef7e6cf4..f1ce2123f 100644 --- a/crates/bitwarden-uniffi/src/lib.rs +++ b/crates/bitwarden-uniffi/src/lib.rs @@ -75,10 +75,15 @@ impl Client { } fn init_logger() { - #[cfg(not(target_os = "android"))] + #[cfg(not(any(target_os = "android", target_os = "ios")))] let _ = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")) .try_init(); + #[cfg(target_os = "ios")] + let _ = oslog::OsLogger::new("com.8bit.bitwarden") + .level_filter(log::LevelFilter::Info) + .init(); + #[cfg(target_os = "android")] android_logger::init_once( android_logger::Config::default().with_max_level(uniffi::deps::log::LevelFilter::Info), From 91cf1a5ac83dccbd9fc54f077cc94b80eb69ab5f Mon Sep 17 00:00:00 2001 From: Maciej Zieniuk <167752252+mzieniukbw@users.noreply.github.com> Date: Tue, 9 Jul 2024 19:04:02 +0200 Subject: [PATCH 058/214] [SM-1268] Review Java docs (#871) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1268 ## 📔 Objective Review Java language docs. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --------- Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com> --- languages/java/Example.java | 33 ------------------ languages/java/INSTALL.md | 52 +++++++++++++++++++++++++++++ languages/java/README.md | 27 +++++++++++---- languages/java/build.gradle | 37 +++++++++++--------- languages/java/example/Example.java | 52 +++++++++++++++++++++++++++++ languages/java/example/build.gradle | 23 +++++++++++++ languages/java/settings.gradle | 2 ++ 7 files changed, 171 insertions(+), 55 deletions(-) delete mode 100644 languages/java/Example.java create mode 100644 languages/java/INSTALL.md create mode 100644 languages/java/example/Example.java create mode 100644 languages/java/example/build.gradle diff --git a/languages/java/Example.java b/languages/java/Example.java deleted file mode 100644 index eacf23f8a..000000000 --- a/languages/java/Example.java +++ /dev/null @@ -1,33 +0,0 @@ -import java.lang.System; -import java.util.UUID; - -import com.bitwarden.sdk.*; -import com.bitwarden.sdk.schema.*; - -class Example { - public static void main(String[] args) { - - String accessToken = System.getenv("ACCESS_TOKEN"); - UUID organizationId = UUID.fromString(System.getenv("ORGANIZATION_ID")); - String apiUrl = System.getenv("API_URL"); - String identityUrl = System.getenv("IDENTITY_URL"); - - // Configuring the URLS is optional, remove them to use the default values - BitwardenSettings bitwardenSettings = new BitwardenSettings(); - bitwardenSettings.setApiUrl(apiUrl); - bitwardenSettings.setIdentityUrl(identityUrl); - BitwardenClient client = new BitwardenClient(bitwardenSettings); - client.accessTokenLogin(accessToken); - - - ProjectResponse project = client.projects().create(organizationId, "Test Project"); - ProjectsResponse list = client.projects().list(organizationId); - - SecretResponse secret = client.secrets().create("Secret Key", "Secret Value", "Secret Note", organizationId, new UUID[] { project.getID() }); - - System.out.println("Secret: " + secret.getValue()); - - client.secrets().delete(new UUID[] { secret.getID() }); - client.projects().delete(new UUID[] { project.getID() }); - } -} diff --git a/languages/java/INSTALL.md b/languages/java/INSTALL.md new file mode 100644 index 000000000..73e474745 --- /dev/null +++ b/languages/java/INSTALL.md @@ -0,0 +1,52 @@ +# Java build + +## Introduction + +Gradle is used to build Java Bitwarden client library. + +The output of the build is placed in `build/libs` directory and should contain `BitwardenSDK.jar` file. + +## Prerequisites + +- JDK 17 installed. +- Bitwarden SDK native library build. See [SDK README.md](../../README.md) for instructions. + +## Build Commands + +```shell +./gradlew build +``` + +## Example + +### macOS + +#### Install Prerequisites + +Use brew to install JDK 17. + +```shell +brew install --cask temurin@17 +brew install jenv +export PATH="$HOME/.jenv/bin:$PATH" +eval "$(jenv init -)" +jenv add /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home +jenv shell 17 +``` + +#### Build Commands + +```shell +./gradlew build +``` + +## Example SDK Usage Project + +```shell +export ACCESS_TOKEN="" +export ORGANIZATION_ID="" +export API_URL="https://api.bitwarden.com" +export IDENTITY_URL="https://identity.bitwarden.com" + +./gradlew :example:run +``` diff --git a/languages/java/README.md b/languages/java/README.md index 06f1ffec3..02cbc4aaf 100644 --- a/languages/java/README.md +++ b/languages/java/README.md @@ -12,6 +12,8 @@ Review the help documentation on [Access Tokens] ### Create new Bitwarden client ```java +import com.bitwarden.sdk.*; + BitwardenSettings bitwardenSettings = new BitwardenSettings(); bitwardenSettings.setApiUrl("https://api.bitwarden.com"); bitwardenSettings.setIdentityUrl("https://identity.bitwarden.com"); @@ -24,6 +26,13 @@ bitwardenClient.accessTokenLogin(""); ```java UUID organizationId = UUID.fromString(""); var projectResponse = bitwardenClient.projects().create(organizationId, "TestProject"); +UUID projectId = projectResponse.getID(); +``` + +### Get project + +```java +var projectResponse = bitwardenClient.projects().get(projectId); ``` ### List all projects @@ -35,9 +44,7 @@ var projectsResponse = bitwardenClient.projects().list(organizationId); ### Update project ```java -UUID projectId = projectResponse.getID(); -projectResponse = bitwardenClient.projects().get(projectId); -projectResponse = bitwardenClient.projects.update(projectId, organizationId, "TestProjectUpdated"); +var projectResponse = bitwardenClient.projects().update(projectId, organizationId, "TestProjectUpdated"); ``` ### Add new secret @@ -50,19 +57,25 @@ var secretResponse = bitwardenClient.secrets().create(key, value, note, organiza UUID secretId = secretResponse.getID(); ``` +### Get secret + +```java +var secretResponse = bitwardenClient.secrets().get(secretId); +``` + ### Update secret ```java -bitwardenClient.secrets().update(secretId, key2, value2, note2, organizationId, new UUID[]{projectId}); +var secretResponse = bitwardenClient.secrets().update(secretId, key2, value2, note2, organizationId, new UUID[]{projectId}); ``` ### List secrets ```java -var secretIdentifiersResponse secretIdentifiersResponse = bitwardenClient.secrets().list(organizationId); +var secretIdentifiersResponse = bitwardenClient.secrets().list(organizationId); ``` -# Delete secret or project +### Delete secret or project ```java bitwardenClient.secrets().delete(new UUID[]{secretId}); @@ -70,4 +83,4 @@ bitwardenClient.projects().delete(new UUID[]{projectId}); ``` [Access Tokens]: https://bitwarden.com/help/access-tokens/ -[Bitwarden Secrets Manager]: https://bitwarden.com/products/secrets-manager/ \ No newline at end of file +[Bitwarden Secrets Manager]: https://bitwarden.com/products/secrets-manager/ diff --git a/languages/java/build.gradle b/languages/java/build.gradle index 8d91e2e6e..2363d3a32 100644 --- a/languages/java/build.gradle +++ b/languages/java/build.gradle @@ -81,18 +81,25 @@ java { withSourcesJar() } -// Gradle build requires GitHub workflow to copy native library to resources -// Uncomment copyNativeLib and jar tasks to use the local build (modify architecture if needed) -//tasks.register('copyNativeLib', Copy) { -// delete 'src/main/resources/darwin-aarch64' -// from '../../target/debug' -// include '*libbitwarden_c*.dylib' -// include '*libbitwarden_c*.so' -// include '*bitwarden_c*.dll' -// into 'src/main/resources/darwin-aarch64' -//} -// -//jar { -// dependsOn tasks.named("copyNativeLib").get() -// from 'src/main/resources' -//} +jar { + // Copy native library to jar resources for local gradle build + if (System.getenv("GITHUB_TOKEN") == null) { + from('../../target/debug') { + include '*libbitwarden_c*.dylib' + into "darwin-x86-64" + } + from('../../target/debug') { + include '*libbitwarden_c*.dylib' + into "darwin-aarch64" + } + from('../../target/debug') { + include '*libbitwarden_c*.so' + into "linux-x86-64" + } + from('../../target/debug') { + include '*bitwarden_c*.dll' + into "win32-x86-64" + } + } +} + diff --git a/languages/java/example/Example.java b/languages/java/example/Example.java new file mode 100644 index 000000000..2460d76b5 --- /dev/null +++ b/languages/java/example/Example.java @@ -0,0 +1,52 @@ +import java.lang.System; +import java.util.UUID; + +import com.bitwarden.sdk.*; +import com.bitwarden.sdk.schema.*; + +class Example { + public static void main(String[] args) { + if (!System.getenv().containsKey("ACCESS_TOKEN") || !System.getenv().containsKey("ORGANIZATION_ID")) { + System.err.println("Missing environment variable ACCESS_TOKEN or ORGANIZATION_ID"); + System.exit(1); + } + + String accessToken = System.getenv("ACCESS_TOKEN"); + UUID organizationId = UUID.fromString(System.getenv("ORGANIZATION_ID")); + String apiUrl = System.getenv("API_URL"); + String identityUrl = System.getenv("IDENTITY_URL"); + + // Configuring the URLS is optional, remove them to use the default values + BitwardenSettings bitwardenSettings = new BitwardenSettings(); + bitwardenSettings.setApiUrl(apiUrl); + bitwardenSettings.setIdentityUrl(identityUrl); + + try (BitwardenClient client = new BitwardenClient(bitwardenSettings)) { + client.accessTokenLogin(accessToken); + + ProjectResponse project = client.projects().create(organizationId, "Test Project"); + System.out.println("Project id: " + project.getID()); + + project = client.projects().get(project.getID()); + + ProjectsResponse projects = client.projects().list(organizationId); + System.out.println("Projects count: " + projects.getData().length); + + client.projects().update(project.getID(), organizationId, "Updated Test Project"); + + SecretResponse secret = client.secrets().create("Secret Key", "Secret Value", "Secret Note", + organizationId, new UUID[]{project.getID()}); + System.out.println("Secret id: " + secret.getID()); + + secret = client.secrets().get(secret.getID()); + + SecretIdentifiersResponse secrets = client.secrets().list(organizationId); + System.out.println("Secrets count: " + secrets.getData().length); + + client.secrets().update(secret.getID(), "Updated Key", "Updated Value", "Updated Noye", organizationId, new UUID[]{project.getID()}); + + client.secrets().delete(new UUID[]{secret.getID()}); + client.projects().delete(new UUID[]{project.getID()}); + } + } +} diff --git a/languages/java/example/build.gradle b/languages/java/example/build.gradle new file mode 100644 index 000000000..73025e50d --- /dev/null +++ b/languages/java/example/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'application' +} + +repositories { + mavenLocal() + mavenCentral() +} + +dependencies { + implementation rootProject +} + +application { + mainClass = 'Example' +} + +sourceSets { + main { + java.srcDirs += '.' + } +} + diff --git a/languages/java/settings.gradle b/languages/java/settings.gradle index 961795f50..bdf7a7ed8 100644 --- a/languages/java/settings.gradle +++ b/languages/java/settings.gradle @@ -3,3 +3,5 @@ */ rootProject.name = 'BitwardenSDK' + +include "example" From 895112b4efc5b68fe85fa1e72c12e98e1f5c4ae1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:28:36 -0400 Subject: [PATCH 059/214] [deps]: Update System.Text.Json to v8 (#873) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [System.Text.Json](https://dot.net/) ([source](https://togithub.com/dotnet/runtime)) | `7.0.4` -> `8.0.4` | [![age](https://developer.mend.io/api/mc/badges/age/nuget/System.Text.Json/8.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/nuget/System.Text.Json/8.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/nuget/System.Text.Json/7.0.4/8.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/System.Text.Json/7.0.4/8.0.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
dotnet/runtime (System.Text.Json) ### [`v8.0.4`](https://togithub.com/dotnet/runtime/releases/tag/v8.0.4): .NET 8.0.4 [Release](https://togithub.com/dotnet/core/releases/tag/v8.0.4) ### [`v8.0.3`](https://togithub.com/dotnet/runtime/releases/tag/v8.0.3): .NET 8.0.3 [Release](https://togithub.com/dotnet/core/releases/tag/v8.0.3) ### [`v8.0.2`](https://togithub.com/dotnet/runtime/releases/tag/v8.0.2): .NET 8.0.2 [Release](https://togithub.com/dotnet/core/releases/tag/v8.0.2) ### [`v8.0.1`](https://togithub.com/dotnet/runtime/releases/tag/v8.0.1): .NET 8.0.1 [Release](https://togithub.com/dotnet/core/releases/tag/v8.0.1) ### [`v8.0.0`](https://togithub.com/dotnet/runtime/releases/tag/v8.0.0): .NET 8.0.0 [Release](https://togithub.com/dotnet/core/releases/tag/v8.0.0) #### What's Changed - \[release/8.0-rc1] \[release/8.0] Events for IL methods without IL headers by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/92317](https://togithub.com/dotnet/runtime/pull/92317) - \[release/8.0] Update dependencies from dotnet/source-build-externals by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92340](https://togithub.com/dotnet/runtime/pull/92340) - \[release/8.0-rc1] \[release/8.0] Fix wasi build. by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/92368](https://togithub.com/dotnet/runtime/pull/92368) - \[automated] Merge branch 'release/8.0-rc2' => 'release/8.0' by [@​dotnet-maestro-bot](https://togithub.com/dotnet-maestro-bot) in [https://github.com/dotnet/runtime/pull/92325](https://togithub.com/dotnet/runtime/pull/92325) - \[release/8.0] Update dependencies from dotnet/roslyn by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92303](https://togithub.com/dotnet/runtime/pull/92303) - \[automated] Merge branch 'release/8.0-rc1' => 'release/8.0' by [@​dotnet-maestro-bot](https://togithub.com/dotnet-maestro-bot) in [https://github.com/dotnet/runtime/pull/92374](https://togithub.com/dotnet/runtime/pull/92374) - \[release/8.0] Bump version to GA by [@​carlossanlop](https://togithub.com/carlossanlop) in [https://github.com/dotnet/runtime/pull/92305](https://togithub.com/dotnet/runtime/pull/92305) - \[release/8.0] Update dependencies from dotnet/source-build-externals by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92476](https://togithub.com/dotnet/runtime/pull/92476) - \[automated] Merge branch 'release/8.0-rc2' => 'release/8.0' by [@​dotnet-maestro-bot](https://togithub.com/dotnet-maestro-bot) in [https://github.com/dotnet/runtime/pull/92401](https://togithub.com/dotnet/runtime/pull/92401) - \[release/8.0] Update dependencies from dotnet/roslyn by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92418](https://togithub.com/dotnet/runtime/pull/92418) - \[release/8.0] Update dependencies from dotnet/source-build-reference-packages by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92474](https://togithub.com/dotnet/runtime/pull/92474) - \[release/8.0] Update dependencies from dnceng/internal/dotnet-optimization by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92473](https://togithub.com/dotnet/runtime/pull/92473) - \[release/8.0] Update dependencies from dotnet/roslyn by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92488](https://togithub.com/dotnet/runtime/pull/92488) - \[automated] Merge branch 'release/8.0-rc2' => 'release/8.0' by [@​dotnet-maestro-bot](https://togithub.com/dotnet-maestro-bot) in [https://github.com/dotnet/runtime/pull/92484](https://togithub.com/dotnet/runtime/pull/92484) - \[release/8.0] Update dependencies from dotnet/roslyn-analyzers by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92499](https://togithub.com/dotnet/runtime/pull/92499) - \[release/8.0] Update dependencies from dotnet/emsdk by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92532](https://togithub.com/dotnet/runtime/pull/92532) - \[automated] Merge branch 'release/8.0-rc2' => 'release/8.0' by [@​dotnet-maestro-bot](https://togithub.com/dotnet-maestro-bot) in [https://github.com/dotnet/runtime/pull/92515](https://togithub.com/dotnet/runtime/pull/92515) - \[release/8.0] Update dependencies from dotnet/source-build-externals by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92641](https://togithub.com/dotnet/runtime/pull/92641) - \[release/8.0] Update dependencies from dotnet/emsdk dotnet/hotreload-utils by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92606](https://togithub.com/dotnet/runtime/pull/92606) - \[release/8.0]\[wasm] Fix regressed file sizes for blazor by [@​radical](https://togithub.com/radical) in [https://github.com/dotnet/runtime/pull/92627](https://togithub.com/dotnet/runtime/pull/92627) - \[release/8.0] JIT: Fixed containment of STOREIND of HW intrinsics ConvertTo\*/Extract\* by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/92513](https://togithub.com/dotnet/runtime/pull/92513) - \[release/8.0] Define bool as Interop.BOOL to prevent upper bytes setting native bool by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/92681](https://togithub.com/dotnet/runtime/pull/92681) - \[release/8.0] Make CoreCLR/NativeAOT assembly compile with .subsections_via_symbols on Apple platforms by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/92544](https://togithub.com/dotnet/runtime/pull/92544) - \[release/8.0] Fix LLVMAOT Mono runtime variant official build to produce correctly named runtime packs by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/92737](https://togithub.com/dotnet/runtime/pull/92737) - \[release/8.0] Remove all PGO assets except for the runtime PGO archive. by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/92735](https://togithub.com/dotnet/runtime/pull/92735) - \[release/8.0] Put HasNativeCodeReJITAware into GetFunctionAddress by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/92665](https://togithub.com/dotnet/runtime/pull/92665) - \[release/8.0] Update dependencies from dotnet/cecil dotnet/emsdk by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92702](https://togithub.com/dotnet/runtime/pull/92702) - \[release/8.0]\[wasm] Fix Wasm.Build.Tests failing due to an old skiasharp reference by [@​radical](https://togithub.com/radical) in [https://github.com/dotnet/runtime/pull/92747](https://togithub.com/dotnet/runtime/pull/92747) - \[release/8.0] Update dependencies from dotnet/installer by [@​radical](https://togithub.com/radical) in [https://github.com/dotnet/runtime/pull/92745](https://togithub.com/dotnet/runtime/pull/92745) - \[release/8.0] Bring back CopyOutputSymbolsToPublishDirectory by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/92369](https://togithub.com/dotnet/runtime/pull/92369) - \[release/8.0] Update dependencies from `dotnet/installer` by [@​radical](https://togithub.com/radical) in [https://github.com/dotnet/runtime/pull/92795](https://togithub.com/dotnet/runtime/pull/92795) - \[release/8.0] Update dependencies from dnceng/internal/dotnet-optimization by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92762](https://togithub.com/dotnet/runtime/pull/92762) - \[release/8.0] Update dependencies from dnceng/internal/dotnet-optimization by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92816](https://togithub.com/dotnet/runtime/pull/92816) - \[release/8.0]\[wasm]\[debugger] Support multidimensional indexing of object scheme by [@​ilonatommy](https://togithub.com/ilonatommy) in [https://github.com/dotnet/runtime/pull/92753](https://togithub.com/dotnet/runtime/pull/92753) - \[release/8.0] \[browser] Remove duplicated marshaling of return value for JSExport by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/92886](https://togithub.com/dotnet/runtime/pull/92886) - \[release/8.0] \[browser]\[nodejs] keep runtime alive for JSExport calls by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/92890](https://togithub.com/dotnet/runtime/pull/92890) - \[release/8.0] Update dependencies from dotnet/roslyn by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92503](https://togithub.com/dotnet/runtime/pull/92503) - \[release/8.0] Make config binding gen incremental ([#​89587](https://togithub.com/dotnet/runtime/issues/89587)) by [@​layomia](https://togithub.com/layomia) in [https://github.com/dotnet/runtime/pull/92730](https://togithub.com/dotnet/runtime/pull/92730) - \[release/8.0] \[wasm] Endian fix for Webcil by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/92495](https://togithub.com/dotnet/runtime/pull/92495) - \[release/8.0] Update dependencies from dotnet/source-build-externals by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92935](https://togithub.com/dotnet/runtime/pull/92935) - \[release/8.0] Update dependencies from dotnet/cecil dotnet/hotreload-utils by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92932](https://togithub.com/dotnet/runtime/pull/92932) - \[release/8.0]\[wasm] Use intended ports when running `DevServer` by [@​radical](https://togithub.com/radical) in [https://github.com/dotnet/runtime/pull/92906](https://togithub.com/dotnet/runtime/pull/92906) - \[release/8.0] Fix deadlock in EventPipeEventDispatcher by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/92912](https://togithub.com/dotnet/runtime/pull/92912) - \[release/8.0] CI: runtime-wasm-perf: disable for PRs by [@​radical](https://togithub.com/radical) in [https://github.com/dotnet/runtime/pull/92977](https://togithub.com/dotnet/runtime/pull/92977) - \[release/8.0] Throw when applying `JsonObjectHandling.Populate` to types with parameterized constructors. by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/92947](https://togithub.com/dotnet/runtime/pull/92947) - \[release/8.0] Use invariant culture in CBOR date encoding by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/92924](https://togithub.com/dotnet/runtime/pull/92924) - \[release/8.0] Update dependencies from dotnet/roslyn by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93005](https://togithub.com/dotnet/runtime/pull/93005) - \[release/8.0] Update dependencies from dotnet/emsdk by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/92996](https://togithub.com/dotnet/runtime/pull/92996) - \[release/8.0] Update dependencies from dotnet/roslyn by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93040](https://togithub.com/dotnet/runtime/pull/93040) - \[release/8.0] Update dependencies from dnceng/internal/dotnet-optimization by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93065](https://togithub.com/dotnet/runtime/pull/93065) - \[release/8.0] Manually update release/8.0 arcade to latest by [@​lewing](https://togithub.com/lewing) in [https://github.com/dotnet/runtime/pull/92778](https://togithub.com/dotnet/runtime/pull/92778) - \[release/8.0] \[PERF] Update release/8.0-rc1 to release/8.0 in perf.yml by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93136](https://togithub.com/dotnet/runtime/pull/93136) - \[release/8.0] Resolve x64 libc++ being included with linux-arm64 to browser-wasm cross-compiler by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93070](https://togithub.com/dotnet/runtime/pull/93070) - \[release/8.0] Update dependencies from dnceng/internal/dotnet-optimization by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93112](https://togithub.com/dotnet/runtime/pull/93112) - \[8.0] Make thread pool thread timeouts configurable by [@​kouvel](https://togithub.com/kouvel) in [https://github.com/dotnet/runtime/pull/92986](https://togithub.com/dotnet/runtime/pull/92986) - \[release/8.0] Make a copy of assembly path. by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93253](https://togithub.com/dotnet/runtime/pull/93253) - \[release/8.0] Fix Options Source Gen Trimming Issues by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93193](https://togithub.com/dotnet/runtime/pull/93193) - \[release/8.0] Fix a memory leak in runtime interop stubs when using an array of structs of types that use old-style managed marshalers by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93150](https://togithub.com/dotnet/runtime/pull/93150) - \[release/8.0] Handle binding to initialized abstract members by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93120](https://togithub.com/dotnet/runtime/pull/93120) - \[release/8.0] Avoid membarrier on lower Android versions by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93096](https://togithub.com/dotnet/runtime/pull/93096) - \[release/8.0] \[android]\[ios] Fix dispose problem with NativeHttpHandlers ([#​93262](https://togithub.com/dotnet/runtime/issues/93262)) by [@​steveisok](https://togithub.com/steveisok) in [https://github.com/dotnet/runtime/pull/93291](https://togithub.com/dotnet/runtime/pull/93291) - \[release/8.0] Update dependencies from dotnet/roslyn by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93267](https://togithub.com/dotnet/runtime/pull/93267) - \[release/8.0] \[H/3] Fix draining response in metrics test by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93381](https://togithub.com/dotnet/runtime/pull/93381) - \[release/8.0] Update dependencies from dnceng/internal/dotnet-optimization by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93283](https://togithub.com/dotnet/runtime/pull/93283) - \[release/8.0] JIT: Fix exponential blowup of memory dependency arrays in VNForMapSelectWork by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93388](https://togithub.com/dotnet/runtime/pull/93388) - Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID [`2290250`](https://togithub.com/dotnet/runtime/commit/2290250) by [@​dotnet-bot](https://togithub.com/dotnet-bot) in [https://github.com/dotnet/runtime/pull/93422](https://togithub.com/dotnet/runtime/pull/93422) - \[release/8.0] Fix Options Source Gen with Length attributes applied on properties of Interface type by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93482](https://togithub.com/dotnet/runtime/pull/93482) - \[release/8.0] Optimize Options Source Gen when no need to run by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93481](https://togithub.com/dotnet/runtime/pull/93481) - \[release/8.0] Update dependencies from dnceng/internal/dotnet-optimization by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93470](https://togithub.com/dotnet/runtime/pull/93470) - \[release/8.0]\[wasm] Update workload description to include target framework by [@​radical](https://togithub.com/radical) in [https://github.com/dotnet/runtime/pull/93359](https://togithub.com/dotnet/runtime/pull/93359) - \[release/8.0] Adjust System.Net metrics for OTel conformance and consistency by [@​antonfirsov](https://togithub.com/antonfirsov) in [https://github.com/dotnet/runtime/pull/93414](https://togithub.com/dotnet/runtime/pull/93414) - Localized file check-in by OneLocBuild Task: Build definition ID 679: Build ID [`2291029`](https://togithub.com/dotnet/runtime/commit/2291029) by [@​dotnet-bot](https://togithub.com/dotnet-bot) in [https://github.com/dotnet/runtime/pull/93496](https://togithub.com/dotnet/runtime/pull/93496) - \[release/8.0] Workaround for C++ compiler bug on Arm64 by [@​jkotas](https://togithub.com/jkotas) in [https://github.com/dotnet/runtime/pull/93528](https://togithub.com/dotnet/runtime/pull/93528) - \[release/8.0] TcpReceiveSendGetsCanceledByDispose: update test for change in Linux kernel. by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93502](https://togithub.com/dotnet/runtime/pull/93502) - \[release/8.0] Mention Frozen.\* types in PACKAGE.md for System.Collections.Immutable by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93561](https://togithub.com/dotnet/runtime/pull/93561) - \[release/8.0] \[hot reload]\[debugger] Resolve field types before use by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93559](https://togithub.com/dotnet/runtime/pull/93559) - \[release/8.0] Update dependencies from dnceng/internal/dotnet-optimization by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93549](https://togithub.com/dotnet/runtime/pull/93549) - \[release/8.0] Update dependencies from 7 repositories by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93282](https://togithub.com/dotnet/runtime/pull/93282) - \[release/8.0] Update dependencies from dotnet/roslyn by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93628](https://togithub.com/dotnet/runtime/pull/93628) - \[release/8.0] Remove base type rooting for types in rooted assemblies by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93355](https://togithub.com/dotnet/runtime/pull/93355) - \[release/8.0] Update dependencies from dotnet/roslyn by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93642](https://togithub.com/dotnet/runtime/pull/93642) - \[release/8.0] Fix build of IJW test after VS upgrade by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93649](https://togithub.com/dotnet/runtime/pull/93649) - \[release/8.0] Ensure Parallel.ForAsync unregisters from CancellationToken by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93674](https://togithub.com/dotnet/runtime/pull/93674) - \[release/8.0] Revert "Workaround a C++/CLI bug involving DIMs ([#​89253](https://togithub.com/dotnet/runtime/issues/89253))" by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93679](https://togithub.com/dotnet/runtime/pull/93679) - \[release/8.0] \[mono] Disallow casts of bounded arrays to array special interfaces by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93617](https://togithub.com/dotnet/runtime/pull/93617) - \[release/8.0] Update dependencies from dotnet/roslyn by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93700](https://togithub.com/dotnet/runtime/pull/93700) - \[release/8.0]\[wasm] Fix Vector128 SIMD fmin and fmax by [@​radekdoulik](https://togithub.com/radekdoulik) in [https://github.com/dotnet/runtime/pull/93677](https://togithub.com/dotnet/runtime/pull/93677) - \[release/8.0] Update dependencies from dotnet/hotreload-utils by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93726](https://togithub.com/dotnet/runtime/pull/93726) - \[release/8.0] Update dependencies from dotnet/source-build-externals by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93728](https://togithub.com/dotnet/runtime/pull/93728) - \[release/8.0] JIT: remove incorrect type deduction for an Unsafe.As case by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93703](https://togithub.com/dotnet/runtime/pull/93703) - \[release/8.0] Add package readmes (continued) by [@​ViktorHofer](https://togithub.com/ViktorHofer) in [https://github.com/dotnet/runtime/pull/93769](https://togithub.com/dotnet/runtime/pull/93769) - \[release/8.0] Update dependencies from dotnet/arcade by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93727](https://togithub.com/dotnet/runtime/pull/93727) - \[release/8.0] Support specifying multiple directories through SSL_CERT_DIR. by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93749](https://togithub.com/dotnet/runtime/pull/93749) - \[release/8.0] Fix analysis of interface methods on generic types by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93748](https://togithub.com/dotnet/runtime/pull/93748) - \[release/8.0] Update dependencies from dnceng/internal/dotnet-optimization by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93776](https://togithub.com/dotnet/runtime/pull/93776) - \[release/8.0] \[Test Only] Fix options source gen test by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93782](https://togithub.com/dotnet/runtime/pull/93782) - \[release/8.0] \[iOS]\[non-icu] HybridGlobalization Get available locales by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93751](https://togithub.com/dotnet/runtime/pull/93751) - \[release/8.0] Update dependencies from dotnet/sdk by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93783](https://togithub.com/dotnet/runtime/pull/93783) - \[release/8.0] Vectorize TensorPrimitives APIs by [@​michaelgsharp](https://togithub.com/michaelgsharp) in [https://github.com/dotnet/runtime/pull/93746](https://togithub.com/dotnet/runtime/pull/93746) - \[release/8.0] Add package readme to System.Numerics.Tensors by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93806](https://togithub.com/dotnet/runtime/pull/93806) - \[release/8.0] Add runtime base address to Native AOT crash info JSON by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93791](https://togithub.com/dotnet/runtime/pull/93791) - \[release/8.0] Update dependencies from dotnet/emsdk by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93801](https://togithub.com/dotnet/runtime/pull/93801) - \[release/8.0] Update APICompat settings under source build by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93865](https://togithub.com/dotnet/runtime/pull/93865) - \[release/8.0] Improve performance of UnmanagedMemoryStream by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93812](https://togithub.com/dotnet/runtime/pull/93812) - \[release/8.0] Update dependencies from dotnet/emsdk by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93881](https://togithub.com/dotnet/runtime/pull/93881) - \[release/8.0] Update dependencies from dnceng/internal/dotnet-optimization by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/93827](https://togithub.com/dotnet/runtime/pull/93827) - \[release/8.0] Stable branding for .NET 8 GA by [@​carlossanlop](https://togithub.com/carlossanlop) in [https://github.com/dotnet/runtime/pull/93807](https://togithub.com/dotnet/runtime/pull/93807) - \[release/8.0]\[wasm] Fix perf pipeline runs by [@​radical](https://togithub.com/radical) in [https://github.com/dotnet/runtime/pull/93888](https://togithub.com/dotnet/runtime/pull/93888) - \[release/8.0] Honor JsonSerializerOptions.PropertyNameCaseInsensitive in property name conflict resolution. by [@​github-actions](https://togithub.com/github-actions) in [https://github.com/dotnet/runtime/pull/93935](https://togithub.com/dotnet/runtime/pull/93935) - \[release/8.0] Update MsQuic by [@​carlossanlop](https://togithub.com/carlossanlop) in [https://github.com/dotnet/runtime/pull/93979](https://togithub.com/dotnet/runtime/pull/93979) - \[release/8.0] Bump net7 downlevel version to 7.0.14 by [@​steveisok](https://togithub.com/steveisok) in [https://github.com/dotnet/runtime/pull/94192](https://togithub.com/dotnet/runtime/pull/94192) - \[release/8.0] Update dependencies from dotnet/emsdk by [@​dotnet-maestro](https://togithub.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/94196](https://togithub.com/dotnet/runtime/pull/94196) **Full Changelog**: https://github.com/dotnet/runtime/compare/v8.0.0-rc.2.23479.6...v8.0.0
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: cd-bitwarden <106776772+cd-bitwarden@users.noreply.github.com> --- languages/csharp/Bitwarden.Sdk/Bitwarden.Sdk.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/csharp/Bitwarden.Sdk/Bitwarden.Sdk.csproj b/languages/csharp/Bitwarden.Sdk/Bitwarden.Sdk.csproj index 35770eedf..d2363f4a9 100644 --- a/languages/csharp/Bitwarden.Sdk/Bitwarden.Sdk.csproj +++ b/languages/csharp/Bitwarden.Sdk/Bitwarden.Sdk.csproj @@ -25,7 +25,7 @@ - + From 110a6b3dbfe8f4b2dbffa474df446fff452479f3 Mon Sep 17 00:00:00 2001 From: Maciej Zieniuk <167752252+mzieniukbw@users.noreply.github.com> Date: Tue, 9 Jul 2024 22:53:35 +0200 Subject: [PATCH 060/214] SM-837 SM input names validation (#810) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-837 ## 📔 Objective Input validation and sanitisation for SM should be the same as we do in `bitwarden/clients` Validation: - Project create or update on fields: - `name`: required, max length 500 - Secret create or update on fields: - `key`: required, max length 500 - `value`: required, max length 25000 - `notes`: max length 7000 Sanitisation to SM cli: - Project create or update on fields: - `name`: trim - Secret create or update on fields: - `key`: trim - `notes`: trim ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --------- Co-authored-by: Daniel García --- Cargo.lock | 129 ++++++++++---- crates/bitwarden-core/Cargo.toml | 1 + crates/bitwarden-core/src/error.rs | 67 +++++++ crates/bitwarden-core/src/lib.rs | 3 +- .../src/enc_string/symmetric.rs | 17 ++ crates/bitwarden-sm/Cargo.toml | 4 + crates/bitwarden-sm/src/projects/create.rs | 85 ++++++++- crates/bitwarden-sm/src/projects/update.rs | 86 ++++++++- crates/bitwarden-sm/src/secrets/create.rs | 162 ++++++++++++++++- crates/bitwarden-sm/src/secrets/update.rs | 165 +++++++++++++++++- 10 files changed, 668 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4638068d0..3f849995c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -182,7 +182,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn", + "syn 2.0.70", ] [[package]] @@ -231,7 +231,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -453,6 +453,7 @@ dependencies = [ "tokio", "uniffi", "uuid", + "validator", "wiremock", "zeroize", "zxcvbn", @@ -613,8 +614,10 @@ dependencies = [ "serde", "serde_json", "thiserror", + "tokio", "uniffi", "uuid", + "validator", ] [[package]] @@ -951,7 +954,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -1294,7 +1297,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -1318,7 +1321,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn", + "syn 2.0.70", ] [[package]] @@ -1329,7 +1332,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -1408,7 +1411,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -1418,7 +1421,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn", + "syn 2.0.70", ] [[package]] @@ -1684,7 +1687,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -2355,7 +2358,7 @@ dependencies = [ "napi-derive-backend", "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -2370,7 +2373,7 @@ dependencies = [ "quote", "regex", "semver", - "syn", + "syn 2.0.70", ] [[package]] @@ -2720,7 +2723,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -2836,6 +2839,30 @@ dependencies = [ "elliptic-curve", ] +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.109", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + [[package]] name = "proc-macro2" version = "1.0.86" @@ -2908,7 +2935,7 @@ dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -2921,7 +2948,7 @@ dependencies = [ "proc-macro2", "pyo3-build-config", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -3352,7 +3379,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn", + "syn 2.0.70", ] [[package]] @@ -3384,7 +3411,7 @@ checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -3465,7 +3492,7 @@ checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -3476,7 +3503,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -3510,7 +3537,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -3561,7 +3588,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -3754,7 +3781,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", + "syn 2.0.70", ] [[package]] @@ -3767,7 +3794,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn", + "syn 2.0.70", ] [[package]] @@ -3785,6 +3812,16 @@ dependencies = [ "is_ci", ] +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.70" @@ -3868,7 +3905,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -3962,7 +3999,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -4078,7 +4115,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -4237,7 +4274,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5c400339a9d1d17be34257d0b407e91d64af335e5b4fa49f4bf28467fc8d635" dependencies = [ "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -4269,7 +4306,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn", + "syn 2.0.70", "toml 0.5.11", "uniffi_meta", ] @@ -4357,6 +4394,36 @@ dependencies = [ "serde", ] +[[package]] +name = "validator" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db79c75af171630a3148bd3e6d7c4f42b6a9a014c2945bc5ed0020cbb8d9478e" +dependencies = [ + "idna", + "once_cell", + "regex", + "serde", + "serde_derive", + "serde_json", + "url", + "validator_derive", +] + +[[package]] +name = "validator_derive" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55591299b7007f551ed1eb79a684af7672c19c3193fb9e0a31936987bb2438ec" +dependencies = [ + "darling", + "once_cell", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 2.0.70", +] + [[package]] name = "valuable" version = "0.1.0" @@ -4417,7 +4484,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.70", "wasm-bindgen-shared", ] @@ -4451,7 +4518,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4484,7 +4551,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] @@ -4755,7 +4822,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.70", ] [[package]] diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml index 12211a6a2..09989de65 100644 --- a/crates/bitwarden-core/Cargo.toml +++ b/crates/bitwarden-core/Cargo.toml @@ -60,6 +60,7 @@ sha2 = ">=0.10.6, <0.11" thiserror = ">=1.0.40, <2.0" uniffi = { version = "=0.27.2", optional = true, features = ["tokio"] } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } +validator = { version = "0.18.1", features = ["derive"] } zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } zxcvbn = ">=3.0.1, <4.0" diff --git a/crates/bitwarden-core/src/error.rs b/crates/bitwarden-core/src/error.rs index e4ca94a25..300aba452 100644 --- a/crates/bitwarden-core/src/error.rs +++ b/crates/bitwarden-core/src/error.rs @@ -4,8 +4,10 @@ use std::{borrow::Cow, fmt::Debug}; use bitwarden_api_api::apis::Error as ApiError; use bitwarden_api_identity::apis::Error as IdentityError; +use log::debug; use reqwest::StatusCode; use thiserror::Error; +use validator::ValidationErrors; #[derive(Debug, Error)] pub enum Error { @@ -43,6 +45,9 @@ pub enum Error { #[error("Received error message from server: [{}] {}", .status, .message)] ResponseContent { status: StatusCode, message: String }, + #[error(transparent)] + ValidationError(#[from] ValidationError), + #[error("The state file version is invalid")] InvalidStateFileVersion, @@ -137,3 +142,65 @@ macro_rules! require { } }; } + +// Validation +#[derive(Debug, Error)] +pub enum ValidationError { + #[error("{0} must not be empty")] + Required(String), + #[error("{0} must not exceed {1} characters in length")] + ExceedsCharacterLength(String, u64), + #[error("{0} must not contain only whitespaces")] + OnlyWhitespaces(String), +} + +const VALIDATION_LENGTH_CODE: &str = "length"; +const VALIDATION_ONLY_WHITESPACES_CODE: &str = "only_whitespaces"; + +pub fn validate_only_whitespaces(value: &str) -> Result<(), validator::ValidationError> { + if !value.is_empty() && value.trim().is_empty() { + return Err(validator::ValidationError::new( + VALIDATION_ONLY_WHITESPACES_CODE, + )); + } + Ok(()) +} + +impl From for Error { + fn from(e: ValidationErrors) -> Self { + debug!("Validation errors: {:#?}", e); + for (field_name, errors) in e.field_errors() { + for error in errors { + match error.code.as_ref() { + VALIDATION_LENGTH_CODE => { + if error.params.contains_key("min") + && error.params["min"].as_u64().expect("Min provided") == 1 + && error.params["value"] + .as_str() + .expect("Value provided") + .is_empty() + { + return Error::ValidationError(ValidationError::Required( + field_name.to_string(), + )); + } else if error.params.contains_key("max") { + return Error::ValidationError( + ValidationError::ExceedsCharacterLength( + field_name.to_string(), + error.params["max"].as_u64().expect("Max provided"), + ), + ); + } + } + VALIDATION_ONLY_WHITESPACES_CODE => { + return Error::ValidationError(ValidationError::OnlyWhitespaces( + field_name.to_string(), + )); + } + _ => {} + } + } + } + format!("Unknown validation error: {:#?}", e).into() + } +} diff --git a/crates/bitwarden-core/src/lib.rs b/crates/bitwarden-core/src/lib.rs index 409f0133b..12b0df3c3 100644 --- a/crates/bitwarden-core/src/lib.rs +++ b/crates/bitwarden-core/src/lib.rs @@ -8,10 +8,9 @@ pub mod admin_console; pub mod auth; pub mod client; mod error; -pub use error::Error; +pub use error::{validate_only_whitespaces, Error, MissingFieldError, VaultLocked}; #[cfg(feature = "internal")] pub mod mobile; -pub use error::{MissingFieldError, VaultLocked}; #[cfg(feature = "internal")] pub mod platform; #[cfg(feature = "secrets")] diff --git a/crates/bitwarden-crypto/src/enc_string/symmetric.rs b/crates/bitwarden-crypto/src/enc_string/symmetric.rs index 44086da49..5e82031fe 100644 --- a/crates/bitwarden-crypto/src/enc_string/symmetric.rs +++ b/crates/bitwarden-crypto/src/enc_string/symmetric.rs @@ -266,6 +266,12 @@ impl KeyEncryptable for String { } } +impl KeyEncryptable for &str { + fn encrypt_with_key(self, key: &SymmetricCryptoKey) -> Result { + self.as_bytes().encrypt_with_key(key) + } +} + impl KeyDecryptable for EncString { fn decrypt_with_key(&self, key: &SymmetricCryptoKey) -> Result { let dec: Vec = self.decrypt_with_key(key)?; @@ -303,6 +309,17 @@ mod tests { assert_eq!(decrypted_str, test_string); } + #[test] + fn test_enc_string_ref_roundtrip() { + let key = derive_symmetric_key("test"); + + let test_string = "encrypted_test_string"; + let cipher = test_string.encrypt_with_key(&key).unwrap(); + + let decrypted_str: String = cipher.decrypt_with_key(&key).unwrap(); + assert_eq!(decrypted_str, test_string); + } + #[test] fn test_enc_string_serialization() { #[derive(serde::Serialize, serde::Deserialize)] diff --git a/crates/bitwarden-sm/Cargo.toml b/crates/bitwarden-sm/Cargo.toml index 6580dcf0f..9f366df16 100644 --- a/crates/bitwarden-sm/Cargo.toml +++ b/crates/bitwarden-sm/Cargo.toml @@ -27,6 +27,10 @@ serde_json = ">=1.0.96, <2.0" thiserror = ">=1.0.40, <2.0" uniffi = { version = "=0.27.2", optional = true } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } +validator = { version = "0.18.1", features = ["derive"] } + +[dev-dependencies] +tokio = { version = "1.36.0", features = ["rt", "macros"] } [lints] workspace = true diff --git a/crates/bitwarden-sm/src/projects/create.rs b/crates/bitwarden-sm/src/projects/create.rs index bacec3cef..7f1d6c545 100644 --- a/crates/bitwarden-sm/src/projects/create.rs +++ b/crates/bitwarden-sm/src/projects/create.rs @@ -1,18 +1,19 @@ use bitwarden_api_api::models::ProjectCreateRequestModel; -use bitwarden_core::{Client, Error, VaultLocked}; +use bitwarden_core::{validate_only_whitespaces, Client, Error, VaultLocked}; use bitwarden_crypto::KeyEncryptable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; +use validator::Validate; use super::ProjectResponse; -#[derive(Serialize, Deserialize, Debug, JsonSchema)] +#[derive(Serialize, Deserialize, Debug, JsonSchema, Validate)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct ProjectCreateRequest { /// Organization where the project will be created pub organization_id: Uuid, - + #[validate(length(min = 1, max = 500), custom(function = validate_only_whitespaces))] pub name: String, } @@ -20,13 +21,15 @@ pub(crate) async fn create_project( client: &Client, input: &ProjectCreateRequest, ) -> Result { + input.validate()?; + let enc = client.internal.get_encryption_settings()?; let key = enc .get_key(&Some(input.organization_id)) .ok_or(VaultLocked)?; let project = Some(ProjectCreateRequestModel { - name: input.name.clone().encrypt_with_key(key)?.to_string(), + name: input.name.clone().trim().encrypt_with_key(key)?.to_string(), }); let config = client.internal.get_api_configurations().await; @@ -39,3 +42,77 @@ pub(crate) async fn create_project( ProjectResponse::process_response(res, &enc) } + +#[cfg(test)] +mod tests { + use super::*; + + async fn create_project(name: String) -> Result { + let input = ProjectCreateRequest { + organization_id: Uuid::new_v4(), + name, + }; + + super::create_project(&Client::new(None), &input).await + } + + #[tokio::test] + async fn test_create_project_request_name_empty_string() { + let response = create_project("".into()).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "name must not be empty" + ); + } + + #[tokio::test] + async fn test_create_project_request_name_all_whitespaces_space() { + let response = create_project(" ".into()).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "name must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_create_project_request_name_all_whitespaces_tab() { + let response = create_project("\t".into()).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "name must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_create_project_request_name_all_whitespaces_newline() { + let response = create_project("\n".into()).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "name must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_create_project_request_name_all_whitespaces_combined() { + let response = create_project(" \t\n".into()).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "name must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_create_project_request_name_501_character_length() { + let response = create_project("a".repeat(501)).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "name must not exceed 500 characters in length" + ); + } +} diff --git a/crates/bitwarden-sm/src/projects/update.rs b/crates/bitwarden-sm/src/projects/update.rs index 759edff99..329e34a61 100644 --- a/crates/bitwarden-sm/src/projects/update.rs +++ b/crates/bitwarden-sm/src/projects/update.rs @@ -1,20 +1,21 @@ use bitwarden_api_api::models::ProjectUpdateRequestModel; -use bitwarden_core::{client::Client, Error, VaultLocked}; +use bitwarden_core::{validate_only_whitespaces, Client, Error, VaultLocked}; use bitwarden_crypto::KeyEncryptable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; +use validator::Validate; use super::ProjectResponse; -#[derive(Serialize, Deserialize, Debug, JsonSchema)] +#[derive(Serialize, Deserialize, Debug, JsonSchema, Validate)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct ProjectPutRequest { /// ID of the project to modify pub id: Uuid, /// Organization ID of the project to modify pub organization_id: Uuid, - + #[validate(length(min = 1, max = 500), custom(function = validate_only_whitespaces))] pub name: String, } @@ -22,13 +23,15 @@ pub(crate) async fn update_project( client: &Client, input: &ProjectPutRequest, ) -> Result { + input.validate()?; + let enc = client.internal.get_encryption_settings()?; let key = enc .get_key(&Some(input.organization_id)) .ok_or(VaultLocked)?; let project = Some(ProjectUpdateRequestModel { - name: input.name.clone().encrypt_with_key(key)?.to_string(), + name: input.name.clone().trim().encrypt_with_key(key)?.to_string(), }); let config = client.internal.get_api_configurations().await; @@ -38,3 +41,78 @@ pub(crate) async fn update_project( ProjectResponse::process_response(res, &enc) } + +#[cfg(test)] +mod tests { + use super::*; + + async fn update_project(name: String) -> Result { + let input = ProjectPutRequest { + id: Uuid::new_v4(), + organization_id: Uuid::new_v4(), + name, + }; + + super::update_project(&Client::new(None), &input).await + } + + #[tokio::test] + async fn test_update_project_request_name_empty_string() { + let response = update_project("".into()).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "name must not be empty" + ); + } + + #[tokio::test] + async fn test_update_project_request_name_all_whitespaces_space() { + let response = update_project(" ".into()).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "name must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_update_project_request_name_all_whitespaces_tab() { + let response = update_project("\t".into()).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "name must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_update_project_request_name_all_whitespaces_newline() { + let response = update_project("\n".into()).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "name must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_update_project_request_name_all_whitespaces_combined() { + let response = update_project(" \t\n".into()).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "name must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_update_project_request_name_501_character_length() { + let response = update_project("a".repeat(501)).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "name must not exceed 500 characters in length" + ); + } +} diff --git a/crates/bitwarden-sm/src/secrets/create.rs b/crates/bitwarden-sm/src/secrets/create.rs index 3e83d390d..bfece0e5a 100644 --- a/crates/bitwarden-sm/src/secrets/create.rs +++ b/crates/bitwarden-sm/src/secrets/create.rs @@ -1,20 +1,24 @@ use bitwarden_api_api::models::SecretCreateRequestModel; -use bitwarden_core::{Client, Error, VaultLocked}; +use bitwarden_core::{validate_only_whitespaces, Client, Error, VaultLocked}; use bitwarden_crypto::KeyEncryptable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; +use validator::Validate; use super::SecretResponse; -#[derive(Serialize, Deserialize, Debug, JsonSchema)] +#[derive(Serialize, Deserialize, Debug, JsonSchema, Validate)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct SecretCreateRequest { /// Organization where the secret will be created pub organization_id: Uuid, + #[validate(length(min = 1, max = 500), custom(function = validate_only_whitespaces))] pub key: String, + #[validate(length(min = 1, max = 25_000))] pub value: String, + #[validate(length(max = 7_000), custom(function = validate_only_whitespaces))] pub note: String, /// IDs of the projects that this secret will belong to @@ -25,15 +29,17 @@ pub(crate) async fn create_secret( client: &Client, input: &SecretCreateRequest, ) -> Result { + input.validate()?; + let enc = client.internal.get_encryption_settings()?; let key = enc .get_key(&Some(input.organization_id)) .ok_or(VaultLocked)?; let secret = Some(SecretCreateRequestModel { - key: input.key.clone().encrypt_with_key(key)?.to_string(), + key: input.key.clone().trim().encrypt_with_key(key)?.to_string(), value: input.value.clone().encrypt_with_key(key)?.to_string(), - note: input.note.clone().encrypt_with_key(key)?.to_string(), + note: input.note.clone().trim().encrypt_with_key(key)?.to_string(), project_ids: input.project_ids.clone(), }); @@ -47,3 +53,151 @@ pub(crate) async fn create_secret( SecretResponse::process_response(res, &enc) } + +#[cfg(test)] +mod tests { + use super::*; + + async fn create_secret( + key: Option, + value: Option, + note: Option, + ) -> Result { + let input = SecretCreateRequest { + organization_id: Uuid::new_v4(), + key: key.unwrap_or_else(|| "test key".into()), + value: value.unwrap_or_else(|| "test value".into()), + note: note.unwrap_or_else(|| "test note".into()), + project_ids: Some(vec![Uuid::new_v4()]), + }; + + super::create_secret(&Client::new(None), &input).await + } + + #[tokio::test] + async fn test_create_secret_request_key_empty_string() { + let response = create_secret(Some("".into()), None, None).await; + assert!(response.is_err()); + assert_eq!(response.err().unwrap().to_string(), "key must not be empty"); + } + + #[tokio::test] + async fn test_create_secret_request_key_all_whitespaces_space() { + let response = create_secret(Some(" ".into()), None, None).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "key must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_create_secret_request_key_all_whitespaces_tab() { + let response = create_secret(Some("\t".into()), None, None).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "key must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_create_secret_request_key_all_whitespaces_newline() { + let response = create_secret(Some("\n".into()), None, None).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "key must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_create_secret_request_key_all_whitespaces_combined() { + let response = create_secret(Some(" \t\n".into()), None, None).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "key must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_create_secret_request_key_501_character_length() { + let response = create_secret(Some("a".repeat(501)), None, None).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "key must not exceed 500 characters in length" + ); + } + + #[tokio::test] + async fn test_create_secret_request_value_empty_string() { + let response = create_secret(None, Some("".into()), None).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "value must not be empty" + ); + } + + #[tokio::test] + async fn test_create_secret_request_value_25001_character_length() { + let response = create_secret(None, Some("a".repeat(25001)), None).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "value must not exceed 25000 characters in length" + ); + } + + #[tokio::test] + async fn test_create_secret_request_note_all_whitespaces_space() { + let response = create_secret(None, None, Some(" ".into())).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "note must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_create_secret_request_note_all_whitespaces_tab() { + let response = create_secret(None, None, Some("\t".into())).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "note must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_create_secret_request_note_all_whitespaces_newline() { + let response = create_secret(None, None, Some("\n".into())).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "note must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_create_secret_request_note_all_whitespaces_combined() { + let response = create_secret(None, None, Some(" \t\n".into())).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "note must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_create_secret_request_note_7001_character_length() { + let response = create_secret(None, None, Some("a".repeat(7001))).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "note must not exceed 7000 characters in length" + ); + } +} diff --git a/crates/bitwarden-sm/src/secrets/update.rs b/crates/bitwarden-sm/src/secrets/update.rs index 00f1ed2a4..ee3f78039 100644 --- a/crates/bitwarden-sm/src/secrets/update.rs +++ b/crates/bitwarden-sm/src/secrets/update.rs @@ -1,22 +1,25 @@ use bitwarden_api_api::models::SecretUpdateRequestModel; -use bitwarden_core::{client::Client, Error, VaultLocked}; +use bitwarden_core::{validate_only_whitespaces, Client, Error, VaultLocked}; use bitwarden_crypto::KeyEncryptable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; +use validator::Validate; use super::SecretResponse; -#[derive(Serialize, Deserialize, Debug, JsonSchema)] +#[derive(Serialize, Deserialize, Debug, JsonSchema, Validate)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct SecretPutRequest { /// ID of the secret to modify pub id: Uuid, /// Organization ID of the secret to modify pub organization_id: Uuid, - + #[validate(length(min = 1, max = 500), custom(function = validate_only_whitespaces))] pub key: String, + #[validate(length(min = 1, max = 25_000))] pub value: String, + #[validate(length(max = 7_000), custom(function = validate_only_whitespaces))] pub note: String, pub project_ids: Option>, } @@ -25,16 +28,17 @@ pub(crate) async fn update_secret( client: &Client, input: &SecretPutRequest, ) -> Result { - let enc = client.internal.get_encryption_settings()?; + input.validate()?; + let enc = client.internal.get_encryption_settings()?; let key = enc .get_key(&Some(input.organization_id)) .ok_or(VaultLocked)?; let secret = Some(SecretUpdateRequestModel { - key: input.key.clone().encrypt_with_key(key)?.to_string(), + key: input.key.clone().trim().encrypt_with_key(key)?.to_string(), value: input.value.clone().encrypt_with_key(key)?.to_string(), - note: input.note.clone().encrypt_with_key(key)?.to_string(), + note: input.note.clone().trim().encrypt_with_key(key)?.to_string(), project_ids: input.project_ids.clone(), }); @@ -44,3 +48,152 @@ pub(crate) async fn update_secret( SecretResponse::process_response(res, &enc) } + +#[cfg(test)] +mod tests { + use super::*; + + async fn update_secret( + key: Option, + value: Option, + note: Option, + ) -> Result { + let input = SecretPutRequest { + id: Uuid::new_v4(), + organization_id: Uuid::new_v4(), + key: key.unwrap_or_else(|| "test key".into()), + value: value.unwrap_or_else(|| "test value".into()), + note: note.unwrap_or_else(|| "test note".into()), + project_ids: Some(vec![Uuid::new_v4()]), + }; + + super::update_secret(&Client::new(None), &input).await + } + + #[tokio::test] + async fn test_update_secret_request_key_empty_string() { + let response = update_secret(Some("".into()), None, None).await; + assert!(response.is_err()); + assert_eq!(response.err().unwrap().to_string(), "key must not be empty"); + } + + #[tokio::test] + async fn test_update_secret_request_key_all_whitespaces_space() { + let response = update_secret(Some(" ".into()), None, None).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "key must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_update_secret_request_key_all_whitespaces_tab() { + let response = update_secret(Some("\t".into()), None, None).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "key must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_update_secret_request_key_all_whitespaces_newline() { + let response = update_secret(Some("\n".into()), None, None).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "key must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_update_secret_request_key_all_whitespaces_combined() { + let response = update_secret(Some(" \t\n".into()), None, None).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "key must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_update_secret_request_key_501_character_length() { + let response = update_secret(Some("a".repeat(501)), None, None).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "key must not exceed 500 characters in length" + ); + } + + #[tokio::test] + async fn test_update_secret_request_value_empty_string() { + let response = update_secret(None, Some("".into()), None).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "value must not be empty" + ); + } + + #[tokio::test] + async fn test_update_secret_request_value_25001_character_length() { + let response = update_secret(None, Some("a".repeat(25001)), None).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "value must not exceed 25000 characters in length" + ); + } + + #[tokio::test] + async fn test_update_secret_request_note_all_whitespaces_space() { + let response = update_secret(None, None, Some(" ".into())).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "note must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_update_secret_request_note_all_whitespaces_tab() { + let response = update_secret(None, None, Some("\t".into())).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "note must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_update_secret_request_note_all_whitespaces_newline() { + let response = update_secret(None, None, Some("\n".into())).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "note must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_update_secret_request_note_all_whitespaces_combined() { + let response = update_secret(None, None, Some(" \t\n".into())).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "note must not contain only whitespaces" + ); + } + + #[tokio::test] + async fn test_update_secret_request_note_7001_character_length() { + let response = update_secret(None, None, Some("a".repeat(7001))).await; + assert!(response.is_err()); + assert_eq!( + response.err().unwrap().to_string(), + "note must not exceed 7000 characters in length" + ); + } +} From 5d11290eff88ea4915179120601507fe2bf877e8 Mon Sep 17 00:00:00 2001 From: cd-bitwarden <106776772+cd-bitwarden@users.noreply.github.com> Date: Wed, 10 Jul 2024 11:05:53 -0400 Subject: [PATCH 061/214] [sm-1253] Updating dotnet version (#894) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective Manually updating the .net version for the c# sdk, renovate had these updates disabled. ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- languages/csharp/global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/csharp/global.json b/languages/csharp/global.json index 10b65be86..391ba3c2a 100644 --- a/languages/csharp/global.json +++ b/languages/csharp/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "6.0.100", + "version": "8.0.100", "rollForward": "latestFeature" } } From de2a64c10b1e37091adc9eb419e5dc19c6c23971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Thu, 11 Jul 2024 14:47:23 +0200 Subject: [PATCH 062/214] Use --locked in installation docs (#896) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective Using `cargo install bws` can cause issues if any minor dependency update has breaking changes. This was the case with #888. By using `--locked`, we make cargo use the `Cargo.lock` file in the package, ensuring any builds use the same dependencies as we tested with. ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bws/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bws/README.md b/crates/bws/README.md index 2b9c8c99c..524a168ad 100644 --- a/crates/bws/README.md +++ b/crates/bws/README.md @@ -13,7 +13,7 @@ We offer three ways to install bws: Download bws via `cargo` from [crates.io](https://crates.io): ```bash -cargo install bws +cargo install bws --locked ``` ### Install Script (from GitHub Releases) From 20e55b1759a942ffd6641688f2ef278c37e6c160 Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Fri, 12 Jul 2024 11:03:19 +0200 Subject: [PATCH 063/214] Fix unreadable passkeys (#892) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective This PR contains 3 bug fixes - The PKCS8 key decode function wasn’t actually trying to read the key as PKCS8 - The SDK decrypted `key_value` and `user_handle` straight to an array buffer, but these fields are actually first encoded as b64 and then encrypted - The Attestation result tried to use `attestation_data.credential_id` to return a `credential_id`, but attestation data is not present during an assertion ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-fido/src/authenticator.rs | 14 ++--- crates/bitwarden-fido/src/crypto.rs | 61 +++++++++++++++++++++- crates/bitwarden-fido/src/lib.rs | 30 ++++++++--- crates/bitwarden-fido/src/types.rs | 42 ++++++++------- crates/bitwarden-vault/src/cipher/login.rs | 8 +-- 5 files changed, 115 insertions(+), 40 deletions(-) diff --git a/crates/bitwarden-fido/src/authenticator.rs b/crates/bitwarden-fido/src/authenticator.rs index 5f02fe545..972415327 100644 --- a/crates/bitwarden-fido/src/authenticator.rs +++ b/crates/bitwarden-fido/src/authenticator.rs @@ -58,8 +58,8 @@ pub enum GetAssertionError { Serde(#[from] serde_json::Error), #[error(transparent)] GetSelectedCredentialError(#[from] GetSelectedCredentialError), - #[error("Missing attested_credential_data")] - MissingAttestedCredentialData, + #[error(transparent)] + InvalidGuid(#[from] InvalidGuid), #[error("missing user")] MissingUser, #[error("get_assertion error: {0}")] @@ -228,13 +228,9 @@ impl<'a> Fido2Authenticator<'a> { Err(e) => return Err(GetAssertionError::Other(format!("{e:?}"))), }; + let selected_credential = self.get_selected_credential()?; let authenticator_data = response.auth_data.to_vec(); - let credential_id = response - .auth_data - .attested_credential_data - .ok_or(GetAssertionError::MissingAttestedCredentialData)? - .credential_id() - .to_vec(); + let credential_id = string_to_guid_bytes(&selected_credential.credential.credential_id)?; Ok(GetAssertionResult { credential_id, @@ -245,7 +241,7 @@ impl<'a> Fido2Authenticator<'a> { .ok_or(GetAssertionError::MissingUser)? .id .into(), - selected_credential: self.get_selected_credential()?, + selected_credential, }) } diff --git a/crates/bitwarden-fido/src/crypto.rs b/crates/bitwarden-fido/src/crypto.rs index 8c72b5341..7d2ccab98 100644 --- a/crates/bitwarden-fido/src/crypto.rs +++ b/crates/bitwarden-fido/src/crypto.rs @@ -1,5 +1,8 @@ use coset::{iana, CoseKey}; -use p256::{pkcs8::EncodePrivateKey, SecretKey}; +use p256::{ + pkcs8::{DecodePrivateKey, EncodePrivateKey}, + SecretKey, +}; use passkey::authenticator::{private_key_from_cose_key, CoseKeyPair}; use thiserror::Error; @@ -35,7 +38,7 @@ pub(crate) fn cose_key_to_pkcs8(cose_key: &CoseKey) -> Result, CoseKeyTo pub struct PrivateKeyFromSecretKeyError; pub fn pkcs8_to_cose_key(secret_key: &[u8]) -> Result { - let secret_key = SecretKey::from_slice(secret_key).map_err(|error| { + let secret_key = SecretKey::from_pkcs8_der(secret_key).map_err(|error| { log::error!("Failed to extract private key from secret_key: {:?}", error); PrivateKeyFromSecretKeyError })?; @@ -43,3 +46,57 @@ pub fn pkcs8_to_cose_key(secret_key: &[u8]) -> Result CoseKey { + // Hardcoded CoseKey for testing purposes + let bytes = vec![ + 166, 1, 2, 3, 38, 32, 1, 33, 88, 32, 200, 30, 161, 146, 196, 121, 165, 149, 92, 232, + 49, 48, 245, 253, 73, 234, 204, 3, 209, 153, 166, 77, 59, 232, 70, 16, 206, 77, 84, + 156, 28, 77, 34, 88, 32, 82, 141, 165, 28, 241, 82, 31, 33, 183, 206, 29, 91, 93, 111, + 216, 216, 26, 62, 211, 49, 191, 86, 238, 118, 241, 124, 131, 106, 214, 95, 170, 160, + 35, 88, 32, 147, 171, 4, 49, 68, 170, 47, 51, 74, 211, 94, 40, 212, 244, 95, 55, 154, + 92, 171, 241, 0, 55, 84, 151, 79, 244, 151, 198, 135, 45, 97, 238, + ]; + + ::from_slice(bytes.as_slice()).unwrap() + } + + #[test] + fn test_cose_key_to_pkcs8_and_back() { + let cose_key = private_key_for_testing(); + + let pkcs8 = cose_key_to_pkcs8(&cose_key).expect("CoseKey to PKCS8 failed"); + let cose_key2 = pkcs8_to_cose_key(&pkcs8).expect("PKCS8 to CoseKey failed"); + + assert_eq!(cose_key, cose_key2); + } + + fn pkcs8_key_for_testing() -> Vec { + vec![ + 0x30, 0x81, 0x87, 0x02, 0x01, 0x00, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, + 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x04, + 0x6d, 0x30, 0x6b, 0x02, 0x01, 0x01, 0x04, 0x20, 0x06, 0x76, 0x5e, 0x85, 0xe0, 0x7f, + 0xef, 0x43, 0xaa, 0x17, 0xe0, 0x7a, 0xd7, 0x85, 0x63, 0x01, 0x80, 0x70, 0x8c, 0x6c, + 0x61, 0x43, 0x7d, 0xc3, 0xb1, 0xe6, 0xf9, 0x09, 0x24, 0xeb, 0x1f, 0xf5, 0xa1, 0x44, + 0x03, 0x42, 0x00, 0x04, 0x35, 0x9a, 0x52, 0xf3, 0x82, 0x44, 0x66, 0x5f, 0x3f, 0xe2, + 0xc4, 0x0b, 0x1c, 0x16, 0x34, 0xc5, 0x60, 0x07, 0x3a, 0x25, 0xfe, 0x7e, 0x7f, 0x7f, + 0xda, 0xd4, 0x1c, 0x36, 0x90, 0x00, 0xee, 0xb1, 0x8e, 0x92, 0xb3, 0xac, 0x91, 0x7f, + 0xb1, 0x8c, 0xa4, 0x85, 0xe7, 0x03, 0x07, 0xd1, 0xf5, 0x5b, 0xd3, 0x7b, 0xc3, 0x56, + 0x11, 0xdf, 0xbc, 0x7a, 0x97, 0x70, 0x32, 0x4b, 0x3c, 0x84, 0x05, 0x71, + ] + } + + #[test] + fn test_pkcs8_to_cose_key_and_back() { + let pkcs8 = pkcs8_key_for_testing(); + + let cose_key = pkcs8_to_cose_key(&pkcs8).expect("PKCS8 to CoseKey failed"); + let pkcs8_2 = cose_key_to_pkcs8(&cose_key).expect("CoseKey to PKCS8 failed"); + + assert_eq!(pkcs8, pkcs8_2); + } +} diff --git a/crates/bitwarden-fido/src/lib.rs b/crates/bitwarden-fido/src/lib.rs index 830b5cfdf..a4bbf5662 100644 --- a/crates/bitwarden-fido/src/lib.rs +++ b/crates/bitwarden-fido/src/lib.rs @@ -73,6 +73,9 @@ impl CipherViewContainer { #[derive(Debug, Error)] pub enum Fido2Error { + #[error(transparent)] + DecodeError(#[from] base64::DecodeError), + #[error(transparent)] UnknownEnum(#[from] UnknownEnum), @@ -102,14 +105,19 @@ impl TryFrom for Passkey { fn try_from_credential_full_view(value: Fido2CredentialFullView) -> Result { let counter: u32 = value.counter.parse().expect("Invalid counter"); let counter = (counter != 0).then_some(counter); + let key_value = URL_SAFE_NO_PAD.decode(value.key_value)?; + let user_handle = value + .user_handle + .map(|u| URL_SAFE_NO_PAD.decode(u)) + .transpose()?; - let key = pkcs8_to_cose_key(&value.key_value)?; + let key = pkcs8_to_cose_key(&key_value)?; Ok(Passkey { key, credential_id: string_to_guid_bytes(&value.credential_id)?.into(), rp_id: value.rp_id.clone(), - user_handle: value.user_handle.map(|u| u.into()), + user_handle: user_handle.map(|u| u.into()), counter, }) } @@ -127,16 +135,20 @@ pub fn fill_with_credential( value: Passkey, ) -> Result { let cred_id: Vec = value.credential_id.into(); + let user_handle = value + .user_handle + .map(|u| URL_SAFE_NO_PAD.encode(u.to_vec())); + let key_value = URL_SAFE_NO_PAD.encode(cose_key_to_pkcs8(&value.key)?); Ok(Fido2CredentialFullView { credential_id: guid_bytes_to_string(&cred_id)?, key_type: "public-key".to_owned(), key_algorithm: "ECDSA".to_owned(), key_curve: "P-256".to_owned(), - key_value: cose_key_to_pkcs8(&value.key)?, + key_value, rp_id: value.rp_id, rp_name: view.rp_name.clone(), - user_handle: Some(cred_id), + user_handle, counter: value.counter.unwrap_or(0).to_string(), user_name: view.user_name.clone(), @@ -151,15 +163,17 @@ pub(crate) fn try_from_credential_new_view( rp: &passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, ) -> Result { let cred_id: Vec = vec![0; 16]; + let user_handle = URL_SAFE_NO_PAD.encode(user.id.to_vec()); Ok(Fido2CredentialNewView { + // TODO: Why do we have a credential id here? credential_id: guid_bytes_to_string(&cred_id)?, key_type: "public-key".to_owned(), key_algorithm: "ECDSA".to_owned(), key_curve: "P-256".to_owned(), rp_id: rp.id.clone(), rp_name: rp.name.clone(), - user_handle: Some(cred_id), + user_handle: Some(user_handle), counter: 0.to_string(), user_name: user.name.clone(), @@ -175,16 +189,18 @@ pub(crate) fn try_from_credential_full( rp: passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, ) -> Result { let cred_id: Vec = value.credential_id.into(); + let key_value = URL_SAFE_NO_PAD.encode(cose_key_to_pkcs8(&value.key)?); + let user_handle = URL_SAFE_NO_PAD.encode(user.id.to_vec()); Ok(Fido2CredentialFullView { credential_id: guid_bytes_to_string(&cred_id)?, key_type: "public-key".to_owned(), key_algorithm: "ECDSA".to_owned(), key_curve: "P-256".to_owned(), - key_value: cose_key_to_pkcs8(&value.key)?, + key_value, rp_id: value.rp_id, rp_name: rp.name, - user_handle: Some(cred_id), + user_handle: Some(user_handle), counter: value.counter.unwrap_or(0).to_string(), user_name: user.name, diff --git a/crates/bitwarden-fido/src/types.rs b/crates/bitwarden-fido/src/types.rs index 458a1be53..8bc8ae42c 100644 --- a/crates/bitwarden-fido/src/types.rs +++ b/crates/bitwarden-fido/src/types.rs @@ -1,3 +1,4 @@ +use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine}; use bitwarden_crypto::KeyContainer; use bitwarden_vault::{CipherError, CipherView}; use passkey::types::webauthn::UserVerificationRequirement; @@ -53,6 +54,9 @@ pub enum Fido2CredentialAutofillViewError { #[error(transparent)] CipherError(#[from] CipherError), + + #[error(transparent)] + Base64DecodeError(#[from] base64::DecodeError), } impl Fido2CredentialAutofillView { @@ -65,25 +69,27 @@ impl Fido2CredentialAutofillView { credentials .into_iter() .filter_map(|c| -> Option> { - c.user_handle.map(|user_handle| { - Ok(Fido2CredentialAutofillView { - credential_id: string_to_guid_bytes(&c.credential_id)?, - cipher_id: cipher - .id - .ok_or(Fido2CredentialAutofillViewError::MissingCipherId)?, - rp_id: c.rp_id.clone(), - user_handle, - user_name_for_ui: c - .user_name - .none_whitespace() - .or(c.user_display_name.none_whitespace()) - .or(cipher - .login - .as_ref() - .and_then(|l| l.username.none_whitespace())) - .or(cipher.name.none_whitespace()), + c.user_handle + .map(|u| URL_SAFE_NO_PAD.decode(u)) + .map(|user_handle| { + Ok(Fido2CredentialAutofillView { + credential_id: string_to_guid_bytes(&c.credential_id)?, + cipher_id: cipher + .id + .ok_or(Fido2CredentialAutofillViewError::MissingCipherId)?, + rp_id: c.rp_id.clone(), + user_handle: user_handle?, + user_name_for_ui: c + .user_name + .none_whitespace() + .or(c.user_display_name.none_whitespace()) + .or(cipher + .login + .as_ref() + .and_then(|l| l.username.none_whitespace())) + .or(cipher.name.none_whitespace()), + }) }) - }) }) .collect() } diff --git a/crates/bitwarden-vault/src/cipher/login.rs b/crates/bitwarden-vault/src/cipher/login.rs index 406286620..d524a724a 100644 --- a/crates/bitwarden-vault/src/cipher/login.rs +++ b/crates/bitwarden-vault/src/cipher/login.rs @@ -101,7 +101,7 @@ pub struct Fido2CredentialView { // so we keep it encrypted until we need it pub key_value: EncString, pub rp_id: String, - pub user_handle: Option>, + pub user_handle: Option, pub user_name: Option, pub counter: String, pub rp_name: Option, @@ -119,9 +119,9 @@ pub struct Fido2CredentialFullView { pub key_type: String, pub key_algorithm: String, pub key_curve: String, - pub key_value: Vec, + pub key_value: String, pub rp_id: String, - pub user_handle: Option>, + pub user_handle: Option, pub user_name: Option, pub counter: String, pub rp_name: Option, @@ -142,7 +142,7 @@ pub struct Fido2CredentialNewView { pub key_algorithm: String, pub key_curve: String, pub rp_id: String, - pub user_handle: Option>, + pub user_handle: Option, pub user_name: Option, pub counter: String, pub rp_name: Option, From 335e9d3ead2de050ad6b775540e9d130957103f4 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Fri, 12 Jul 2024 16:18:13 -0400 Subject: [PATCH 064/214] SM-1238: Go Developer Instructions (#861) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1238 ## 📔 Objective The goal of this PR is to add instructions for third party Go developers that want to use the Go SDK in their own projects. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- languages/go/INSTRUCTIONS.md | 150 +++++++++++++++++++++++++++++++++++ languages/go/README.md | 2 +- 2 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 languages/go/INSTRUCTIONS.md diff --git a/languages/go/INSTRUCTIONS.md b/languages/go/INSTRUCTIONS.md new file mode 100644 index 000000000..1c9702476 --- /dev/null +++ b/languages/go/INSTRUCTIONS.md @@ -0,0 +1,150 @@ +# Instructions + +This guide is for developers who want to use the Bitwarden Go SDK module in their own Go projects. Please see the main [README](./README.md) and [example.go](./example/example.go) file for examples. + +## Supported Targets + +The Bitwarden Go SDK module utilizes FFI calls to the Bitwarden Rust SDK via [cgo](https://pkg.go.dev/cmd/cgo). The module supports the following statically linked targets: + +- Linux `x86-64` & `arm64` +- macOS `x86-64` & `arm64` +- Windows `x86-64` + +## Linux + +### Prerequisites + +- [Go](https://go.dev/dl) +- A C toolchain + +We recommend the [MUSL toolchain](https://musl.libc.org). You can install this on most debian based systems with: + +```shell +sudo apt install musl-tools +``` + +### Set Go Environment Info + +#### Enable cgo + +```shell +go env -w CGO_ENABLED=1 +``` + +#### Set the C compiler + +```shell +go env -w CC=musl-gcc +``` + +#### Verify +```shell +go env +``` + +### Install the Bitwarden Go SDK + +#### Adding the Module + +```shell +go get github.com/bitwarden/sdk-go +``` + +#### Build + +```shell +go build -ldflags '-linkmode external -extldflags "-static -Wl,-unresolved-symbols=ignore-all"' +``` + +## macOS + +### Prerequisites + +- [Go](https://go.dev/dl) +- A C toolchain + +[Clang](https://clang.llvm.org/get_started.html) is the default C and C++ toolchain on Mac OS. The easiest way to ensure you have the toolchain is to install the Xcode Command Line tools. + +You can install Clang with: + + +```shell +xcode-select --install +``` + +### Set Go Environment Info + +#### Enable cgo + +```shell +go env -w CGO_ENABLED=1 +``` + +#### Set the C & C++ compilers + +```shell +go env -w CC=clang CXX=clang++ +``` + +#### Verify +```shell +go env +``` + +### Install the Bitwarden Go SDK + +#### Adding the Module + +```shell +go get github.com/bitwarden/sdk-go +``` + +#### Build + +```shell +go build +``` + +## Windows + +### Prerequisites + +- [Go](https://go.dev/dl) +- [GCC](https://gcc.gnu.org) + +Go [documentation](https://go.dev/wiki/cgo) recommends the mingw-w64 gcc compiler. + +We recommend following the Visual Studio Code [guide](https://code.visualstudio.com/docs/cpp/config-mingw#_installing-the-mingww64-toolchain) for installing the mingw-w64 toolchain. + +### Set Go Environment Info + +#### Enable cgo + +```shell +go env -w CGO_ENABLED=1 +``` + +#### Set the C & C++ compilers + +```shell +go env -w CC=gcc CXX=g++ +``` + +#### Verify +```shell +go env +``` + +### Install the Bitwarden Go SDK + +#### Adding the Module + +```shell +go get github.com/bitwarden/sdk-go +``` + +#### Build + +```shell +go build +``` diff --git a/languages/go/README.md b/languages/go/README.md index 669c31aaa..3aca6e7b3 100644 --- a/languages/go/README.md +++ b/languages/go/README.md @@ -10,7 +10,7 @@ managing projects and secrets, as well as a client interface to facilitate opera ## Installation -Download the SDK files and place them in your Go project directory. +Follow the installation instructions [here](./INSTRUCTIONS.md). ## Table of Contents From 69c173588570b5afa5dfffb0a0c67b23c573c6f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Mon, 15 Jul 2024 12:57:00 +0200 Subject: [PATCH 065/214] Return a more detailed MissingKey error from get_key() (#900) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective This change adds the organization UUID to the `MissingKey` error type, and changes the `get_key` function to return a Result instead of an Option to avoid having to add the error all over the place. Note that some of the `encryption_settings.get_key()` calls were being mapped to `VaultLocked`, that wasn't correct as having the `EncryptionSettings` means the vault is unlocked. Those were changed to `MissingKey(id)` as well. ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .../bitwarden-core/src/auth/auth_request.rs | 4 ++-- crates/bitwarden-core/src/auth/client_auth.rs | 4 +--- .../src/auth/password/validate.rs | 9 ++------ crates/bitwarden-core/src/auth/renew.rs | 2 +- .../src/client/encryption_settings.rs | 15 +++++++----- crates/bitwarden-core/src/mobile/crypto.rs | 12 +++++----- crates/bitwarden-crypto/src/error.rs | 5 ++-- .../src/keys/key_encryptable.rs | 8 +++---- crates/bitwarden-exporters/src/export.rs | 4 ++-- crates/bitwarden-fido/src/authenticator.rs | 4 ++-- crates/bitwarden-send/src/client_sends.rs | 12 +++++----- crates/bitwarden-send/src/send.rs | 9 ++++++-- crates/bitwarden-sm/src/projects/create.rs | 6 ++--- .../src/projects/project_response.rs | 6 ++--- crates/bitwarden-sm/src/projects/update.rs | 6 ++--- crates/bitwarden-sm/src/secrets/create.rs | 6 ++--- crates/bitwarden-sm/src/secrets/list.rs | 6 ++--- .../src/secrets/secret_response.rs | 4 ++-- crates/bitwarden-sm/src/secrets/update.rs | 6 ++--- crates/bitwarden-vault/src/cipher/cipher.rs | 23 +++++++++++-------- crates/bitwarden-vault/src/collection.rs | 2 +- .../src/mobile/client_attachments.rs | 6 ++--- .../src/mobile/client_ciphers.rs | 14 +++++------ .../src/mobile/client_collection.rs | 8 +++---- .../src/mobile/client_folders.rs | 8 +++---- .../src/mobile/client_password_history.rs | 6 ++--- 26 files changed, 93 insertions(+), 102 deletions(-) diff --git a/crates/bitwarden-core/src/auth/auth_request.rs b/crates/bitwarden-core/src/auth/auth_request.rs index 2b309127e..dc9be1b90 100644 --- a/crates/bitwarden-core/src/auth/auth_request.rs +++ b/crates/bitwarden-core/src/auth/auth_request.rs @@ -6,7 +6,7 @@ use bitwarden_crypto::{ #[cfg(feature = "internal")] use bitwarden_crypto::{EncString, KeyDecryptable, SymmetricCryptoKey}; -use crate::{error::Error, Client, VaultLocked}; +use crate::{error::Error, Client}; #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] pub struct AuthRequestResponse { @@ -82,7 +82,7 @@ pub(crate) fn approve_auth_request( let public_key = AsymmetricPublicCryptoKey::from_der(&STANDARD.decode(public_key)?)?; let enc = client.internal.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(VaultLocked)?; + let key = enc.get_key(&None)?; Ok(AsymmetricEncString::encrypt_rsa2048_oaep_sha1( &key.to_vec(), diff --git a/crates/bitwarden-core/src/auth/client_auth.rs b/crates/bitwarden-core/src/auth/client_auth.rs index fa48481e6..1afc39c8c 100644 --- a/crates/bitwarden-core/src/auth/client_auth.rs +++ b/crates/bitwarden-core/src/auth/client_auth.rs @@ -150,11 +150,9 @@ impl<'a> ClientAuth<'a> { #[cfg(feature = "internal")] fn trust_device(client: &Client) -> Result { - use crate::VaultLocked; - let enc = client.internal.get_encryption_settings()?; - let user_key = enc.get_key(&None).ok_or(VaultLocked)?; + let user_key = enc.get_key(&None)?; Ok(DeviceKey::trust_device(user_key)?) } diff --git a/crates/bitwarden-core/src/auth/password/validate.rs b/crates/bitwarden-core/src/auth/password/validate.rs index c5f8993d6..b5f9ccfd2 100644 --- a/crates/bitwarden-core/src/auth/password/validate.rs +++ b/crates/bitwarden-core/src/auth/password/validate.rs @@ -44,8 +44,6 @@ pub(crate) fn validate_password_user_key( password: String, encrypted_user_key: String, ) -> Result { - use crate::VaultLocked; - let login_method = client .internal .get_login_method() @@ -61,12 +59,9 @@ pub(crate) fn validate_password_user_key( .decrypt_user_key(encrypted_user_key.parse()?) .map_err(|_| "wrong password")?; - let enc = client - .internal - .get_encryption_settings() - .map_err(|_| VaultLocked)?; + let enc = client.internal.get_encryption_settings()?; - let existing_key = enc.get_key(&None).ok_or(VaultLocked)?; + let existing_key = enc.get_key(&None)?; if user_key.to_vec() != existing_key.to_vec() { return Err("wrong user key".into()); diff --git a/crates/bitwarden-core/src/auth/renew.rs b/crates/bitwarden-core/src/auth/renew.rs index d53534d58..b35d71d6e 100644 --- a/crates/bitwarden-core/src/auth/renew.rs +++ b/crates/bitwarden-core/src/auth/renew.rs @@ -73,7 +73,7 @@ pub(crate) async fn renew_token(client: &InternalClient) -> Result<()> { if let (IdentityTokenResponse::Payload(r), Some(state_file), Ok(enc_settings)) = (&result, state_file, client.get_encryption_settings()) { - if let Some(enc_key) = enc_settings.get_key(&None) { + if let Ok(enc_key) = enc_settings.get_key(&None) { let state = ClientState::new(r.access_token.clone(), enc_key.to_base64()); _ = state::set(state_file, access_token, state); diff --git a/crates/bitwarden-core/src/client/encryption_settings.rs b/crates/bitwarden-core/src/client/encryption_settings.rs index 138d1568e..828a97139 100644 --- a/crates/bitwarden-core/src/client/encryption_settings.rs +++ b/crates/bitwarden-core/src/client/encryption_settings.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use bitwarden_crypto::{AsymmetricCryptoKey, KeyContainer, SymmetricCryptoKey}; +use bitwarden_crypto::{AsymmetricCryptoKey, CryptoError, KeyContainer, SymmetricCryptoKey}; #[cfg(feature = "internal")] use bitwarden_crypto::{AsymmetricEncString, EncString, MasterKey}; use uuid::Uuid; @@ -95,22 +95,25 @@ impl EncryptionSettings { Ok(self) } - pub fn get_key(&self, org_id: &Option) -> Option<&SymmetricCryptoKey> { + pub fn get_key(&self, org_id: &Option) -> Result<&SymmetricCryptoKey, CryptoError> { // If we don't have a private key set (to decode multiple org keys), we just use the main // user key if self.private_key.is_none() { - return Some(&self.user_key); + return Ok(&self.user_key); } match org_id { - Some(org_id) => self.org_keys.get(org_id), - None => Some(&self.user_key), + Some(org_id) => self + .org_keys + .get(org_id) + .ok_or(CryptoError::MissingKey(*org_id)), + None => Ok(&self.user_key), } } } impl KeyContainer for EncryptionSettings { - fn get_key(&self, org_id: &Option) -> Option<&SymmetricCryptoKey> { + fn get_key(&self, org_id: &Option) -> Result<&SymmetricCryptoKey, CryptoError> { EncryptionSettings::get_key(self, org_id) } } diff --git a/crates/bitwarden-core/src/mobile/crypto.rs b/crates/bitwarden-core/src/mobile/crypto.rs index 0fe9e8731..3f8bc562c 100644 --- a/crates/bitwarden-core/src/mobile/crypto.rs +++ b/crates/bitwarden-core/src/mobile/crypto.rs @@ -10,7 +10,7 @@ use serde::{Deserialize, Serialize}; use crate::client::{LoginMethod, UserLoginMethod}; use crate::{ error::{Error, Result}, - Client, VaultLocked, + Client, }; #[cfg(feature = "internal")] @@ -185,7 +185,7 @@ pub async fn initialize_org_crypto(client: &Client, req: InitOrgCryptoRequest) - #[cfg(feature = "internal")] pub async fn get_user_encryption_key(client: &Client) -> Result { let enc = client.internal.get_encryption_settings()?; - let user_key = enc.get_key(&None).ok_or(VaultLocked)?; + let user_key = enc.get_key(&None)?; Ok(user_key.to_base64()) } @@ -203,7 +203,7 @@ pub struct UpdatePasswordResponse { pub fn update_password(client: &Client, new_password: String) -> Result { let enc = client.internal.get_encryption_settings()?; - let user_key = enc.get_key(&None).ok_or(VaultLocked)?; + let user_key = enc.get_key(&None)?; let login_method = client .internal @@ -247,7 +247,7 @@ pub struct DerivePinKeyResponse { #[cfg(feature = "internal")] pub fn derive_pin_key(client: &Client, pin: String) -> Result { let enc = client.internal.get_encryption_settings()?; - let user_key = enc.get_key(&None).ok_or(VaultLocked)?; + let user_key = enc.get_key(&None)?; let login_method = client .internal @@ -265,7 +265,7 @@ pub fn derive_pin_key(client: &Client, pin: String) -> Result Result { let enc = client.internal.get_encryption_settings()?; - let user_key = enc.get_key(&None).ok_or(VaultLocked)?; + let user_key = enc.get_key(&None)?; let pin: String = encrypted_pin.decrypt_with_key(user_key)?; let login_method = client @@ -306,7 +306,7 @@ pub(super) fn enroll_admin_password_reset( let public_key = AsymmetricPublicCryptoKey::from_der(&STANDARD.decode(public_key)?)?; let enc = client.internal.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(VaultLocked)?; + let key = enc.get_key(&None)?; Ok(AsymmetricEncString::encrypt_rsa2048_oaep_sha1( &key.to_vec(), diff --git a/crates/bitwarden-crypto/src/error.rs b/crates/bitwarden-crypto/src/error.rs index 7cfb354d7..2f21975fc 100644 --- a/crates/bitwarden-crypto/src/error.rs +++ b/crates/bitwarden-crypto/src/error.rs @@ -1,6 +1,7 @@ use std::fmt::Debug; use thiserror::Error; +use uuid::Uuid; use crate::fingerprint::FingerprintError; @@ -16,8 +17,8 @@ pub enum CryptoError { InvalidKeyLen, #[error("The value is not a valid UTF8 String")] InvalidUtf8String, - #[error("Missing Key")] - MissingKey, + #[error("Missing Key for organization with ID {0}")] + MissingKey(Uuid), #[error("EncString error, {0}")] EncString(#[from] EncStringParseError), diff --git a/crates/bitwarden-crypto/src/keys/key_encryptable.rs b/crates/bitwarden-crypto/src/keys/key_encryptable.rs index f1a538d12..044be9fcb 100644 --- a/crates/bitwarden-crypto/src/keys/key_encryptable.rs +++ b/crates/bitwarden-crypto/src/keys/key_encryptable.rs @@ -3,14 +3,14 @@ use std::{collections::HashMap, hash::Hash, sync::Arc}; use rayon::prelude::*; use uuid::Uuid; -use crate::{error::Result, SymmetricCryptoKey}; +use crate::{error::Result, CryptoError, SymmetricCryptoKey}; pub trait KeyContainer: Send + Sync { - fn get_key(&self, org_id: &Option) -> Option<&SymmetricCryptoKey>; + fn get_key(&self, org_id: &Option) -> Result<&SymmetricCryptoKey, CryptoError>; } impl KeyContainer for Arc { - fn get_key(&self, org_id: &Option) -> Option<&SymmetricCryptoKey> { + fn get_key(&self, org_id: &Option) -> Result<&SymmetricCryptoKey, CryptoError> { self.as_ref().get_key(org_id) } } @@ -20,7 +20,7 @@ pub trait LocateKey { &self, enc: &'a dyn KeyContainer, org_id: &Option, - ) -> Option<&'a SymmetricCryptoKey> { + ) -> Result<&'a SymmetricCryptoKey, CryptoError> { enc.get_key(org_id) } } diff --git a/crates/bitwarden-exporters/src/export.rs b/crates/bitwarden-exporters/src/export.rs index 0721ae11f..7fa05413d 100644 --- a/crates/bitwarden-exporters/src/export.rs +++ b/crates/bitwarden-exporters/src/export.rs @@ -1,4 +1,4 @@ -use bitwarden_core::{Client, VaultLocked}; +use bitwarden_core::Client; use bitwarden_crypto::KeyDecryptable; use bitwarden_vault::{Cipher, CipherView, Collection, Folder, FolderView}; @@ -14,7 +14,7 @@ pub(crate) fn export_vault( format: ExportFormat, ) -> Result { let enc = client.internal.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(VaultLocked)?; + let key = enc.get_key(&None)?; let folders: Vec = folders.decrypt_with_key(key)?; let folders: Vec = folders.into_iter().flat_map(|f| f.try_into()).collect(); diff --git a/crates/bitwarden-fido/src/authenticator.rs b/crates/bitwarden-fido/src/authenticator.rs index 972415327..9d4371476 100644 --- a/crates/bitwarden-fido/src/authenticator.rs +++ b/crates/bitwarden-fido/src/authenticator.rs @@ -483,7 +483,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { .replace(selected.clone()); // Encrypt the updated cipher before sending it to the clients to be stored - let key = enc.get_key(&selected.organization_id).ok_or(VaultLocked)?; + let key = enc.get_key(&selected.organization_id)?; let encrypted = selected.encrypt_with_key(key)?; this.authenticator @@ -557,7 +557,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { .replace(selected.clone()); // Encrypt the updated cipher before sending it to the clients to be stored - let key = enc.get_key(&selected.organization_id).ok_or(VaultLocked)?; + let key = enc.get_key(&selected.organization_id)?; let encrypted = selected.encrypt_with_key(key)?; this.authenticator diff --git a/crates/bitwarden-send/src/client_sends.rs b/crates/bitwarden-send/src/client_sends.rs index da1c527f0..bf496e013 100644 --- a/crates/bitwarden-send/src/client_sends.rs +++ b/crates/bitwarden-send/src/client_sends.rs @@ -1,6 +1,6 @@ use std::path::Path; -use bitwarden_core::{Client, Error, VaultLocked}; +use bitwarden_core::{Client, Error}; use bitwarden_crypto::{EncString, KeyDecryptable, KeyEncryptable}; use crate::{Send, SendListView, SendView}; @@ -16,7 +16,7 @@ impl<'a> ClientSends<'a> { pub fn decrypt(&self, send: Send) -> Result { let enc = self.client.internal.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(VaultLocked)?; + let key = enc.get_key(&None)?; let send_view = send.decrypt_with_key(key)?; @@ -25,7 +25,7 @@ impl<'a> ClientSends<'a> { pub fn decrypt_list(&self, sends: Vec) -> Result, Error> { let enc = self.client.internal.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(VaultLocked)?; + let key = enc.get_key(&None)?; let send_views = sends.decrypt_with_key(key)?; @@ -46,7 +46,7 @@ impl<'a> ClientSends<'a> { pub fn decrypt_buffer(&self, send: Send, encrypted_buffer: &[u8]) -> Result, Error> { let enc = self.client.internal.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(VaultLocked)?; + let key = enc.get_key(&None)?; let key = Send::get_key(&send.key, key)?; let buf = EncString::from_buffer(encrypted_buffer)?; @@ -55,7 +55,7 @@ impl<'a> ClientSends<'a> { pub fn encrypt(&self, send_view: SendView) -> Result { let enc = self.client.internal.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(VaultLocked)?; + let key = enc.get_key(&None)?; let send = send_view.encrypt_with_key(key)?; @@ -76,7 +76,7 @@ impl<'a> ClientSends<'a> { pub fn encrypt_buffer(&self, send: Send, buffer: &[u8]) -> Result, Error> { let enc = self.client.internal.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(VaultLocked)?; + let key = enc.get_key(&None)?; let key = Send::get_key(&send.key, key)?; let encrypted = buffer.encrypt_with_key(&key)?; diff --git a/crates/bitwarden-send/src/send.rs b/crates/bitwarden-send/src/send.rs index 707fbd530..3222ec1cf 100644 --- a/crates/bitwarden-send/src/send.rs +++ b/crates/bitwarden-send/src/send.rs @@ -375,8 +375,13 @@ mod tests { } } impl KeyContainer for MockKeyContainer { - fn get_key<'a>(&'a self, org_id: &Option) -> Option<&'a SymmetricCryptoKey> { - self.0.get(org_id) + fn get_key<'a>( + &'a self, + org_id: &Option, + ) -> Result<&'a SymmetricCryptoKey, CryptoError> { + self.0 + .get(org_id) + .ok_or(CryptoError::MissingKey(org_id.unwrap_or_default())) } } diff --git a/crates/bitwarden-sm/src/projects/create.rs b/crates/bitwarden-sm/src/projects/create.rs index 7f1d6c545..bb377e23c 100644 --- a/crates/bitwarden-sm/src/projects/create.rs +++ b/crates/bitwarden-sm/src/projects/create.rs @@ -1,5 +1,5 @@ use bitwarden_api_api::models::ProjectCreateRequestModel; -use bitwarden_core::{validate_only_whitespaces, Client, Error, VaultLocked}; +use bitwarden_core::{validate_only_whitespaces, Client, Error}; use bitwarden_crypto::KeyEncryptable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -24,9 +24,7 @@ pub(crate) async fn create_project( input.validate()?; let enc = client.internal.get_encryption_settings()?; - let key = enc - .get_key(&Some(input.organization_id)) - .ok_or(VaultLocked)?; + let key = enc.get_key(&Some(input.organization_id))?; let project = Some(ProjectCreateRequestModel { name: input.name.clone().trim().encrypt_with_key(key)?.to_string(), diff --git a/crates/bitwarden-sm/src/projects/project_response.rs b/crates/bitwarden-sm/src/projects/project_response.rs index b0ad1728f..a70a3fd78 100644 --- a/crates/bitwarden-sm/src/projects/project_response.rs +++ b/crates/bitwarden-sm/src/projects/project_response.rs @@ -1,6 +1,6 @@ use bitwarden_api_api::models::ProjectResponseModel; use bitwarden_core::{client::encryption_settings::EncryptionSettings, require, Error}; -use bitwarden_crypto::{CryptoError, EncString, KeyDecryptable}; +use bitwarden_crypto::{EncString, KeyDecryptable}; use chrono::{DateTime, Utc}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -22,9 +22,7 @@ impl ProjectResponse { enc: &EncryptionSettings, ) -> Result { let organization_id = require!(response.organization_id); - let enc_key = enc - .get_key(&Some(organization_id)) - .ok_or(CryptoError::MissingKey)?; + let enc_key = enc.get_key(&Some(organization_id))?; let name = require!(response.name) .parse::()? diff --git a/crates/bitwarden-sm/src/projects/update.rs b/crates/bitwarden-sm/src/projects/update.rs index 329e34a61..359b66945 100644 --- a/crates/bitwarden-sm/src/projects/update.rs +++ b/crates/bitwarden-sm/src/projects/update.rs @@ -1,5 +1,5 @@ use bitwarden_api_api::models::ProjectUpdateRequestModel; -use bitwarden_core::{validate_only_whitespaces, Client, Error, VaultLocked}; +use bitwarden_core::{validate_only_whitespaces, Client, Error}; use bitwarden_crypto::KeyEncryptable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -26,9 +26,7 @@ pub(crate) async fn update_project( input.validate()?; let enc = client.internal.get_encryption_settings()?; - let key = enc - .get_key(&Some(input.organization_id)) - .ok_or(VaultLocked)?; + let key = enc.get_key(&Some(input.organization_id))?; let project = Some(ProjectUpdateRequestModel { name: input.name.clone().trim().encrypt_with_key(key)?.to_string(), diff --git a/crates/bitwarden-sm/src/secrets/create.rs b/crates/bitwarden-sm/src/secrets/create.rs index bfece0e5a..dedd6c57f 100644 --- a/crates/bitwarden-sm/src/secrets/create.rs +++ b/crates/bitwarden-sm/src/secrets/create.rs @@ -1,5 +1,5 @@ use bitwarden_api_api::models::SecretCreateRequestModel; -use bitwarden_core::{validate_only_whitespaces, Client, Error, VaultLocked}; +use bitwarden_core::{validate_only_whitespaces, Client, Error}; use bitwarden_crypto::KeyEncryptable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -32,9 +32,7 @@ pub(crate) async fn create_secret( input.validate()?; let enc = client.internal.get_encryption_settings()?; - let key = enc - .get_key(&Some(input.organization_id)) - .ok_or(VaultLocked)?; + let key = enc.get_key(&Some(input.organization_id))?; let secret = Some(SecretCreateRequestModel { key: input.key.clone().trim().encrypt_with_key(key)?.to_string(), diff --git a/crates/bitwarden-sm/src/secrets/list.rs b/crates/bitwarden-sm/src/secrets/list.rs index 9de4b9a47..60a5c9727 100644 --- a/crates/bitwarden-sm/src/secrets/list.rs +++ b/crates/bitwarden-sm/src/secrets/list.rs @@ -5,7 +5,7 @@ use bitwarden_core::{ client::{encryption_settings::EncryptionSettings, Client}, require, Error, }; -use bitwarden_crypto::{CryptoError, EncString, KeyDecryptable}; +use bitwarden_crypto::{EncString, KeyDecryptable}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; @@ -93,9 +93,7 @@ impl SecretIdentifierResponse { enc: &EncryptionSettings, ) -> Result { let organization_id = require!(response.organization_id); - let enc_key = enc - .get_key(&Some(organization_id)) - .ok_or(CryptoError::MissingKey)?; + let enc_key = enc.get_key(&Some(organization_id))?; let key = require!(response.key) .parse::()? diff --git a/crates/bitwarden-sm/src/secrets/secret_response.rs b/crates/bitwarden-sm/src/secrets/secret_response.rs index 138279b11..e480ac3fc 100644 --- a/crates/bitwarden-sm/src/secrets/secret_response.rs +++ b/crates/bitwarden-sm/src/secrets/secret_response.rs @@ -2,7 +2,7 @@ use bitwarden_api_api::models::{ BaseSecretResponseModel, BaseSecretResponseModelListResponseModel, SecretResponseModel, }; use bitwarden_core::{client::encryption_settings::EncryptionSettings, require, Error}; -use bitwarden_crypto::{CryptoError, EncString, KeyDecryptable}; +use bitwarden_crypto::{EncString, KeyDecryptable}; use chrono::{DateTime, Utc}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -46,7 +46,7 @@ impl SecretResponse { enc: &EncryptionSettings, ) -> Result { let org_id = response.organization_id; - let enc_key = enc.get_key(&org_id).ok_or(CryptoError::MissingKey)?; + let enc_key = enc.get_key(&org_id)?; let key = require!(response.key) .parse::()? diff --git a/crates/bitwarden-sm/src/secrets/update.rs b/crates/bitwarden-sm/src/secrets/update.rs index ee3f78039..f2ab7dd12 100644 --- a/crates/bitwarden-sm/src/secrets/update.rs +++ b/crates/bitwarden-sm/src/secrets/update.rs @@ -1,5 +1,5 @@ use bitwarden_api_api::models::SecretUpdateRequestModel; -use bitwarden_core::{validate_only_whitespaces, Client, Error, VaultLocked}; +use bitwarden_core::{validate_only_whitespaces, Client, Error}; use bitwarden_crypto::KeyEncryptable; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -31,9 +31,7 @@ pub(crate) async fn update_secret( input.validate()?; let enc = client.internal.get_encryption_settings()?; - let key = enc - .get_key(&Some(input.organization_id)) - .ok_or(VaultLocked)?; + let key = enc.get_key(&Some(input.organization_id))?; let secret = Some(SecretUpdateRequestModel { key: input.key.clone().trim().encrypt_with_key(key)?.to_string(), diff --git a/crates/bitwarden-vault/src/cipher/cipher.rs b/crates/bitwarden-vault/src/cipher/cipher.rs index c1e84638c..5d348bc3b 100644 --- a/crates/bitwarden-vault/src/cipher/cipher.rs +++ b/crates/bitwarden-vault/src/cipher/cipher.rs @@ -401,7 +401,7 @@ impl CipherView { &self, enc: &dyn KeyContainer, ) -> Result, CipherError> { - let key = self.locate_key(enc, &None).ok_or(VaultLocked)?; + let key = self.locate_key(enc, &None)?; let cipher_key = Cipher::get_cipher_key(key, &self.key)?; let key = cipher_key.as_ref().unwrap_or(key); @@ -435,9 +435,9 @@ impl CipherView { enc: &dyn KeyContainer, organization_id: Uuid, ) -> Result<(), CipherError> { - let old_key = enc.get_key(&self.organization_id).ok_or(VaultLocked)?; + let old_key = enc.get_key(&self.organization_id)?; - let new_key = enc.get_key(&Some(organization_id)).ok_or(VaultLocked)?; + let new_key = enc.get_key(&Some(organization_id))?; // If any attachment is missing a key we can't reencrypt the attachment keys if self.attachments.iter().flatten().any(|a| a.key.is_none()) { @@ -463,7 +463,7 @@ impl CipherView { enc: &dyn KeyContainer, creds: Vec, ) -> Result<(), CipherError> { - let key = enc.get_key(&self.organization_id).ok_or(VaultLocked)?; + let key = enc.get_key(&self.organization_id)?; let ciphers_key = Cipher::get_cipher_key(key, &self.key)?; let ciphers_key = ciphers_key.as_ref().unwrap_or(key); @@ -478,7 +478,7 @@ impl CipherView { &self, enc: &dyn KeyContainer, ) -> Result, CipherError> { - let key = enc.get_key(&self.organization_id).ok_or(VaultLocked)?; + let key = enc.get_key(&self.organization_id)?; let ciphers_key = Cipher::get_cipher_key(key, &self.key)?; let ciphers_key = ciphers_key.as_ref().unwrap_or(key); @@ -524,7 +524,7 @@ impl LocateKey for Cipher { &self, enc: &'a dyn KeyContainer, _: &Option, - ) -> Option<&'a SymmetricCryptoKey> { + ) -> Result<&'a SymmetricCryptoKey, CryptoError> { enc.get_key(&self.organization_id) } } @@ -533,7 +533,7 @@ impl LocateKey for CipherView { &self, enc: &'a dyn KeyContainer, _: &Option, - ) -> Option<&'a SymmetricCryptoKey> { + ) -> Result<&'a SymmetricCryptoKey, CryptoError> { enc.get_key(&self.organization_id) } } @@ -728,8 +728,13 @@ mod tests { struct MockKeyContainer(HashMap, SymmetricCryptoKey>); impl KeyContainer for MockKeyContainer { - fn get_key<'a>(&'a self, org_id: &Option) -> Option<&'a SymmetricCryptoKey> { - self.0.get(org_id) + fn get_key<'a>( + &'a self, + org_id: &Option, + ) -> Result<&'a SymmetricCryptoKey, CryptoError> { + self.0 + .get(org_id) + .ok_or(CryptoError::MissingKey(org_id.unwrap_or_default())) } } diff --git a/crates/bitwarden-vault/src/collection.rs b/crates/bitwarden-vault/src/collection.rs index f1b58cc28..5e0fcbdc5 100644 --- a/crates/bitwarden-vault/src/collection.rs +++ b/crates/bitwarden-vault/src/collection.rs @@ -42,7 +42,7 @@ impl LocateKey for Collection { &self, enc: &'a dyn KeyContainer, _: &Option, - ) -> Option<&'a SymmetricCryptoKey> { + ) -> Result<&'a SymmetricCryptoKey, CryptoError> { enc.get_key(&Some(self.organization_id)) } } diff --git a/crates/bitwarden-vault/src/mobile/client_attachments.rs b/crates/bitwarden-vault/src/mobile/client_attachments.rs index f382075ec..a98a7d1e7 100644 --- a/crates/bitwarden-vault/src/mobile/client_attachments.rs +++ b/crates/bitwarden-vault/src/mobile/client_attachments.rs @@ -1,6 +1,6 @@ use std::path::Path; -use bitwarden_core::{Client, Error, VaultLocked}; +use bitwarden_core::{Client, Error}; use bitwarden_crypto::{EncString, KeyDecryptable, KeyEncryptable, LocateKey}; use crate::{ @@ -20,7 +20,7 @@ impl<'a> ClientAttachments<'a> { buffer: &[u8], ) -> Result { let enc = self.client.internal.get_encryption_settings()?; - let key = cipher.locate_key(&enc, &None).ok_or(VaultLocked)?; + let key = cipher.locate_key(&enc, &None)?; Ok(AttachmentFileView { cipher, @@ -52,7 +52,7 @@ impl<'a> ClientAttachments<'a> { encrypted_buffer: &[u8], ) -> Result, Error> { let enc = self.client.internal.get_encryption_settings()?; - let key = cipher.locate_key(&enc, &None).ok_or(VaultLocked)?; + let key = cipher.locate_key(&enc, &None)?; AttachmentFile { cipher, diff --git a/crates/bitwarden-vault/src/mobile/client_ciphers.rs b/crates/bitwarden-vault/src/mobile/client_ciphers.rs index 864af8b94..345f04df1 100644 --- a/crates/bitwarden-vault/src/mobile/client_ciphers.rs +++ b/crates/bitwarden-vault/src/mobile/client_ciphers.rs @@ -1,5 +1,5 @@ -use bitwarden_core::{Client, Error, VaultLocked}; -use bitwarden_crypto::{CryptoError, KeyDecryptable, KeyEncryptable, LocateKey}; +use bitwarden_core::{Client, Error}; +use bitwarden_crypto::{KeyDecryptable, KeyEncryptable, LocateKey}; use uuid::Uuid; use crate::{Cipher, CipherError, CipherListView, CipherView, ClientVault}; @@ -21,11 +21,11 @@ impl<'a> ClientCiphers<'a> { .get_flags() .enable_cipher_key_encryption { - let key = cipher_view.locate_key(&enc, &None).ok_or(VaultLocked)?; + let key = cipher_view.locate_key(&enc, &None)?; cipher_view.generate_cipher_key(key)?; } - let key = cipher_view.locate_key(&enc, &None).ok_or(VaultLocked)?; + let key = cipher_view.locate_key(&enc, &None)?; let cipher = cipher_view.encrypt_with_key(key)?; Ok(cipher) @@ -33,9 +33,7 @@ impl<'a> ClientCiphers<'a> { pub fn decrypt(&self, cipher: Cipher) -> Result { let enc = self.client.internal.get_encryption_settings()?; - let key = cipher - .locate_key(&enc, &None) - .ok_or(CryptoError::MissingKey)?; + let key = cipher.locate_key(&enc, &None)?; let cipher_view = cipher.decrypt_with_key(key)?; @@ -48,7 +46,7 @@ impl<'a> ClientCiphers<'a> { let cipher_views: Result, _> = ciphers .iter() .map(|c| -> Result { - let key = c.locate_key(&enc, &None).ok_or(CryptoError::MissingKey)?; + let key = c.locate_key(&enc, &None)?; Ok(c.decrypt_with_key(key)?) }) .collect(); diff --git a/crates/bitwarden-vault/src/mobile/client_collection.rs b/crates/bitwarden-vault/src/mobile/client_collection.rs index 42cda4bc5..a3d6ee612 100644 --- a/crates/bitwarden-vault/src/mobile/client_collection.rs +++ b/crates/bitwarden-vault/src/mobile/client_collection.rs @@ -1,5 +1,5 @@ use bitwarden_core::{Client, Error}; -use bitwarden_crypto::{CryptoError, KeyDecryptable, LocateKey}; +use bitwarden_crypto::{KeyDecryptable, LocateKey}; use crate::{ClientVault, Collection, CollectionView}; @@ -10,9 +10,7 @@ pub struct ClientCollections<'a> { impl<'a> ClientCollections<'a> { pub fn decrypt(&self, collection: Collection) -> Result { let enc = self.client.internal.get_encryption_settings()?; - let key = collection - .locate_key(&enc, &None) - .ok_or(CryptoError::MissingKey)?; + let key = collection.locate_key(&enc, &None)?; let view = collection.decrypt_with_key(key)?; @@ -25,7 +23,7 @@ impl<'a> ClientCollections<'a> { let views: Result, _> = collections .iter() .map(|c| -> Result { - let key = c.locate_key(&enc, &None).ok_or(CryptoError::MissingKey)?; + let key = c.locate_key(&enc, &None)?; Ok(c.decrypt_with_key(key)?) }) .collect(); diff --git a/crates/bitwarden-vault/src/mobile/client_folders.rs b/crates/bitwarden-vault/src/mobile/client_folders.rs index 93d89c4d6..d8ebb76ed 100644 --- a/crates/bitwarden-vault/src/mobile/client_folders.rs +++ b/crates/bitwarden-vault/src/mobile/client_folders.rs @@ -1,5 +1,5 @@ use bitwarden_core::{Client, Error}; -use bitwarden_crypto::{CryptoError, KeyDecryptable, KeyEncryptable}; +use bitwarden_crypto::{KeyDecryptable, KeyEncryptable}; use crate::{ClientVault, Folder, FolderView}; @@ -10,7 +10,7 @@ pub struct ClientFolders<'a> { impl<'a> ClientFolders<'a> { pub fn encrypt(&self, folder_view: FolderView) -> Result { let enc = self.client.internal.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; + let key = enc.get_key(&None)?; let folder = folder_view.encrypt_with_key(key)?; @@ -19,7 +19,7 @@ impl<'a> ClientFolders<'a> { pub fn decrypt(&self, folder: Folder) -> Result { let enc = self.client.internal.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; + let key = enc.get_key(&None)?; let folder_view = folder.decrypt_with_key(key)?; @@ -28,7 +28,7 @@ impl<'a> ClientFolders<'a> { pub fn decrypt_list(&self, folders: Vec) -> Result, Error> { let enc = self.client.internal.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; + let key = enc.get_key(&None)?; let views = folders.decrypt_with_key(key)?; diff --git a/crates/bitwarden-vault/src/mobile/client_password_history.rs b/crates/bitwarden-vault/src/mobile/client_password_history.rs index 8af07a120..98d989dbd 100644 --- a/crates/bitwarden-vault/src/mobile/client_password_history.rs +++ b/crates/bitwarden-vault/src/mobile/client_password_history.rs @@ -1,5 +1,5 @@ use bitwarden_core::{Client, Error}; -use bitwarden_crypto::{CryptoError, KeyDecryptable, KeyEncryptable}; +use bitwarden_crypto::{KeyDecryptable, KeyEncryptable}; use crate::{ClientVault, PasswordHistory, PasswordHistoryView}; @@ -10,7 +10,7 @@ pub struct ClientPasswordHistory<'a> { impl<'a> ClientPasswordHistory<'a> { pub fn encrypt(&self, history_view: PasswordHistoryView) -> Result { let enc = self.client.internal.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; + let key = enc.get_key(&None)?; let history = history_view.encrypt_with_key(key)?; @@ -22,7 +22,7 @@ impl<'a> ClientPasswordHistory<'a> { history: Vec, ) -> Result, Error> { let enc = self.client.internal.get_encryption_settings()?; - let key = enc.get_key(&None).ok_or(CryptoError::MissingKey)?; + let key = enc.get_key(&None)?; let history_view = history.decrypt_with_key(key)?; From f0dd3b9b2202fc140af0579e521bd64e8a42cad3 Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Mon, 15 Jul 2024 08:41:38 -0700 Subject: [PATCH 066/214] update go version in SDK and example project (#816) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1288 ## 📔 Objective Follow-up of SM-1288 to update the Go version requirements in our wrapper and example project. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/build-go.yaml | 2 +- .github/workflows/release-go.yml | 2 +- languages/go/example/go.mod | 2 +- languages/go/go.mod | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-go.yaml b/.github/workflows/build-go.yaml index 58918aeec..1d4d3a351 100644 --- a/.github/workflows/build-go.yaml +++ b/.github/workflows/build-go.yaml @@ -11,7 +11,7 @@ on: env: GO111MODULE: on - GO_VERSION: "^1.18" + GO_VERSION: "^1.21" jobs: build: diff --git a/.github/workflows/release-go.yml b/.github/workflows/release-go.yml index d73536f38..74ac5e30e 100644 --- a/.github/workflows/release-go.yml +++ b/.github/workflows/release-go.yml @@ -15,7 +15,7 @@ on: env: GO111MODULE: on - GO_VERSION: "^1.18" + GO_VERSION: "^1.21" _KEY_VAULT: "bitwarden-ci" jobs: diff --git a/languages/go/example/go.mod b/languages/go/example/go.mod index ee8a38d33..cb09b706c 100644 --- a/languages/go/example/go.mod +++ b/languages/go/example/go.mod @@ -2,7 +2,7 @@ module example replace github.com/bitwarden/sdk-go => ../ -go 1.20 +go 1.21 require ( github.com/bitwarden/sdk-go v0.0.0-00010101000000-000000000000 diff --git a/languages/go/go.mod b/languages/go/go.mod index 1d6428e99..ae9f50111 100644 --- a/languages/go/go.mod +++ b/languages/go/go.mod @@ -1,3 +1,3 @@ module github.com/bitwarden/sdk-go -go 1.18 +go 1.21 From 631173392482bef82c7ebc886584f7db877bd1c2 Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Tue, 16 Jul 2024 17:22:45 +0200 Subject: [PATCH 067/214] fix: `discoverable` should not be hard coded (#902) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective Like the title says, `fido2Credential.discoverable` was hardcoded, but should be set from `options` ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-fido/src/authenticator.rs | 7 ++++--- crates/bitwarden-fido/src/lib.rs | 4 ++-- crates/bitwarden-vault/src/cipher/login.rs | 2 -- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/bitwarden-fido/src/authenticator.rs b/crates/bitwarden-fido/src/authenticator.rs index 9d4371476..cbddaf94b 100644 --- a/crates/bitwarden-fido/src/authenticator.rs +++ b/crates/bitwarden-fido/src/authenticator.rs @@ -430,7 +430,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { cred: Passkey, user: passkey::types::ctap2::make_credential::PublicKeyCredentialUserEntity, rp: passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, - _options: passkey::types::ctap2::get_assertion::Options, + options: passkey::types::ctap2::get_assertion::Options, ) -> Result<(), StatusCode> { #[derive(Debug, Error)] enum InnerError { @@ -455,6 +455,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { cred: Passkey, user: passkey::types::ctap2::make_credential::PublicKeyCredentialUserEntity, rp: passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, + options: passkey::types::ctap2::get_assertion::Options, ) -> Result<(), InnerError> { let enc = this .authenticator @@ -462,7 +463,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { .internal .get_encryption_settings()?; - let cred = try_from_credential_full(cred, user, rp)?; + let cred = try_from_credential_full(cred, user, rp, options)?; // Get the previously selected cipher and add the new credential to it let mut selected: CipherView = this @@ -494,7 +495,7 @@ impl passkey::authenticator::CredentialStore for CredentialStoreImpl<'_> { Ok(()) } - inner(self, cred, user, rp).await.map_err(|e| { + inner(self, cred, user, rp, options).await.map_err(|e| { error!("Error saving credential: {e:?}"); VendorError::try_from(0xF1) .expect("Valid vendor error code") diff --git a/crates/bitwarden-fido/src/lib.rs b/crates/bitwarden-fido/src/lib.rs index a4bbf5662..991828eb3 100644 --- a/crates/bitwarden-fido/src/lib.rs +++ b/crates/bitwarden-fido/src/lib.rs @@ -178,7 +178,6 @@ pub(crate) fn try_from_credential_new_view( counter: 0.to_string(), user_name: user.name.clone(), user_display_name: user.display_name.clone(), - discoverable: "true".to_owned(), creation_date: chrono::offset::Utc::now(), }) } @@ -187,6 +186,7 @@ pub(crate) fn try_from_credential_full( value: Passkey, user: passkey::types::ctap2::make_credential::PublicKeyCredentialUserEntity, rp: passkey::types::ctap2::make_credential::PublicKeyCredentialRpEntity, + options: passkey::types::ctap2::get_assertion::Options, ) -> Result { let cred_id: Vec = value.credential_id.into(); let key_value = URL_SAFE_NO_PAD.encode(cose_key_to_pkcs8(&value.key)?); @@ -205,7 +205,7 @@ pub(crate) fn try_from_credential_full( counter: value.counter.unwrap_or(0).to_string(), user_name: user.name, user_display_name: user.display_name, - discoverable: "true".to_owned(), + discoverable: options.rk.to_string(), creation_date: chrono::offset::Utc::now(), }) } diff --git a/crates/bitwarden-vault/src/cipher/login.rs b/crates/bitwarden-vault/src/cipher/login.rs index d524a724a..4b476b075 100644 --- a/crates/bitwarden-vault/src/cipher/login.rs +++ b/crates/bitwarden-vault/src/cipher/login.rs @@ -147,7 +147,6 @@ pub struct Fido2CredentialNewView { pub counter: String, pub rp_name: Option, pub user_display_name: Option, - pub discoverable: String, pub creation_date: DateTime, } @@ -164,7 +163,6 @@ impl From for Fido2CredentialNewView { counter: value.counter, rp_name: value.rp_name, user_display_name: value.user_display_name, - discoverable: value.discoverable, creation_date: value.creation_date, } } From e80c02c347da7a6f427a75c41b1c88530634ac6c Mon Sep 17 00:00:00 2001 From: Robyn MacCallum Date: Tue, 16 Jul 2024 17:47:19 -0400 Subject: [PATCH 068/214] Update Python README.md (#903) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📔 Objective Make some updates to the Python setup instructions ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- languages/python/README.md | 49 +++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/languages/python/README.md b/languages/python/README.md index e5fe5ae70..29f3f97fb 100644 --- a/languages/python/README.md +++ b/languages/python/README.md @@ -2,17 +2,41 @@ ## Requirements - Python 3 +- Rust - `maturin` (install with `pip install maturin`) - `npm` ## Build -From the root of the repository: ```bash +npm install npm run schemas # generate schemas.py cd languages/python/ +``` + +You will need to build and run the script using a virtual environment. +This will be slightly different depending on the OS you are using: + +```bash +# --- Linux/macOS --- +python3 -m venv .venv +source .venv/bin/activate + +# --- Windows --- +python -m venv venv + +venv\Scripts\activate.bat # cmd.exe +venv\Scripts\Activate.ps1 # Powershell +``` + +## Run + +```bash maturin develop +python3 ./example.py + +deactivate # run this to close the virtual session ``` You can now import `BitwardenClient` in your Python code with: @@ -33,26 +57,3 @@ Set the `ORGANIZATION_ID` and `ACCESS_TOKEN` environment variables to your organ ```bash python3 ./example.py ``` - -# Using Virtual Environments - -If you would like to build & run the script within a virtual environment you can do the following. - -## Build - -```bash -npm run schemas # generate schemas.py - -cd languages/python/ -python3 -m venv .venv -maturin develop -``` - -## Run - -```bash -source .venv/bin/activate -python3 ./example.py - -deactivate # run this to close the virtual session -``` From 740895cfe4eabc0a486b99ba3b5036e1390850dd Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Wed, 17 Jul 2024 11:28:38 -0400 Subject: [PATCH 069/214] SM-1327: Fix PYO3 Deprecation (#897) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1327 ## 📔 Objective Update all PYO3 dependencies and fix the necessary deprecation notices. Thanks @Thomas-Avery and @dani-garcia for the collaboration! ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- Cargo.lock | 28 ++++++++++++------------ crates/bitwarden-py/Cargo.toml | 6 ++--- crates/bitwarden-py/src/client.rs | 1 + crates/bitwarden-py/src/python_module.rs | 2 +- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f849995c..766d7a3a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2879,15 +2879,15 @@ source = "git+https://github.com/bitwarden/passkey-rs?rev=ae08e2cb7dd3d44d915cae [[package]] name = "pyo3" -version = "0.21.2" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e00b96a521718e08e03b1a622f01c8a8deb50719335de3f60b3b3950f069d8" +checksum = "4e99090d12f6182924499253aaa1e73bf15c69cea8d2774c3c781e35badc3548" dependencies = [ "cfg-if", "indoc", "libc", "memoffset", - "parking_lot", + "once_cell", "portable-atomic", "pyo3-build-config", "pyo3-ffi", @@ -2897,9 +2897,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.21.2" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7883df5835fafdad87c0d888b266c8ec0f4c9ca48a5bed6bbb592e8dedee1b50" +checksum = "7879eb018ac754bba32cb0eec7526391c02c14a093121857ed09fbf1d1057d41" dependencies = [ "once_cell", "target-lexicon", @@ -2907,9 +2907,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.21.2" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01be5843dc60b916ab4dad1dca6d20b9b4e6ddc8e15f50c47fe6d85f1fb97403" +checksum = "ce2baa5559a411fc1cf519295f24c34b53d5d725818bc96b5abf94762da09041" dependencies = [ "libc", "pyo3-build-config", @@ -2917,9 +2917,9 @@ dependencies = [ [[package]] name = "pyo3-log" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2af49834b8d2ecd555177e63b273b708dea75150abc6f5341d0a6e1a9623976c" +checksum = "3ac84e6eec1159bc2a575c9ae6723baa6ee9d45873e9bebad1e3ad7e8d28a443" dependencies = [ "arc-swap", "log", @@ -2928,9 +2928,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.21.2" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77b34069fc0682e11b31dbd10321cbf94808394c56fd996796ce45217dfac53c" +checksum = "049621c20a23f2def20f4fe67978d1da8d8a883d64b9c21362f3b776e254edc7" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -2940,11 +2940,11 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.21.2" +version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08260721f32db5e1a5beae69a55553f56b99bd0e1c3e6e0a5e8851a9d0f5a85c" +checksum = "0e969ee2e025435f1819d31a275ba4bb9cbbdf3ac535227fdbd85b9322ffe144" dependencies = [ - "heck 0.4.1", + "heck 0.5.0", "proc-macro2", "pyo3-build-config", "quote", diff --git a/crates/bitwarden-py/Cargo.toml b/crates/bitwarden-py/Cargo.toml index fc128c66d..c66a35889 100644 --- a/crates/bitwarden-py/Cargo.toml +++ b/crates/bitwarden-py/Cargo.toml @@ -17,11 +17,11 @@ crate-type = ["cdylib"] [dependencies] bitwarden-json = { path = "../bitwarden-json", features = ["secrets"] } -pyo3 = { version = "0.21.2", features = ["extension-module"] } -pyo3-log = "0.10.0" +pyo3 = { version = "0.22.1", features = ["extension-module"] } +pyo3-log = "0.11.0" [build-dependencies] -pyo3-build-config = { version = "0.21.2" } +pyo3-build-config = { version = "0.22.1" } [target.'cfg(not(target_arch="wasm32"))'.dependencies] tokio = { version = "1.36.0", features = ["rt-multi-thread", "macros"] } diff --git a/crates/bitwarden-py/src/client.rs b/crates/bitwarden-py/src/client.rs index c3ea62444..510de1db4 100644 --- a/crates/bitwarden-py/src/client.rs +++ b/crates/bitwarden-py/src/client.rs @@ -7,6 +7,7 @@ pub struct BitwardenClient(JsonClient); #[pymethods] impl BitwardenClient { #[new] + #[pyo3(signature = (settings_string=None))] pub fn new(settings_string: Option) -> Self { // This will only fail if another logger was already initialized, so we can ignore the // result diff --git a/crates/bitwarden-py/src/python_module.rs b/crates/bitwarden-py/src/python_module.rs index 0df87a563..3e21b852c 100644 --- a/crates/bitwarden-py/src/python_module.rs +++ b/crates/bitwarden-py/src/python_module.rs @@ -3,7 +3,7 @@ use pyo3::prelude::*; use crate::client::BitwardenClient; #[pymodule] -fn bitwarden_py(_py: Python<'_>, m: &PyModule) -> PyResult<()> { +fn bitwarden_py(m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; Ok(()) } From acd14e6bcd2e0a2ee99360c8f05936c9d733eee8 Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Thu, 18 Jul 2024 14:39:32 +0000 Subject: [PATCH 070/214] Update Go docs (#862) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1265 ## 📔 Objective Correct a syntax error and use consistent and descriptive `bitwardenClient` variable name. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- languages/go/README.md | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/languages/go/README.md b/languages/go/README.md index 3aca6e7b3..90b5f664e 100644 --- a/languages/go/README.md +++ b/languages/go/README.md @@ -52,25 +52,31 @@ err := bitwardenClient.AccessTokenLogin(accessToken, &statePath) #### Create a Project ```go -project, err := client.Projects().Create("organization_id", "project_name") +project, err := bitwardenClient.Projects().Create("organization_id", "project_name") ``` #### List Projects ```go -projects, err := client.Projects().List("organization_id") +projects, err := bitwardenClient.Projects().List("organization_id") +``` + +#### Get a Project + +```go +project, err := bitwardenClient.Projects().Get("project_id") ``` #### Update a Project ```go -project, err := client.Projects().Update("project_id", "organization_id", "new_project_name") +project, err := bitwardenClient.Projects().Update("project_id", "organization_id", "new_project_name") ``` #### Delete Projects ```go -project, err := client.Projects().Delete([]string{"project_id_1", "project_id_2"}) +project, err := bitwardenClient.Projects().Delete([]string{"project_id_1", "project_id_2"}) ``` --- @@ -80,34 +86,46 @@ project, err := client.Projects().Delete([]string{"project_id_1", "project_id_2" #### Create a Secret ```go -secret, err := client.Secrets().Create("key", "value", "note", "organization_id", []string{"project_id"}) +secret, err := bitwardenClient.Secrets().Create("key", "value", "note", "organization_id", []string{"project_id"}) ``` #### List Secrets ```go -secrets, err := client.Secrets().List("organization_id") +secrets, err := bitwardenClient.Secrets().List("organization_id") +``` + +#### Get a Secret + +```go +secret, err := bitwardenClient.Secrets().Get("secret_id") +``` + +#### Get Multiple Secrets by IDs + +```go +secrets, err := bitwardenClient.Secrets().GetByIDS([]string{"secret_ids"}) ``` #### Update a Secret ```go -secret, err := client.Secrets().Update("secret_id", "new_key", "new_value", "new_note", "organization_id", []string{"project_id"}) +secret, err := bitwardenClient.Secrets().Update("secret_id", "new_key", "new_value", "new_note", "organization_id", []string{"project_id"}) ``` #### Delete Secrets ```go -secret, err := client.Secrets().Delete([]string{"secret_id_1", "secret_id_2"}) +secret, err := bitwardenClient.Secrets().Delete([]string{"secret_id_1", "secret_id_2"}) ``` #### Secrets Sync ```go -secretsSync, err := client.Secrets().Sync("organization_id", nil) +secretsSync, err := bitwardenClient.Secrets().Sync("organization_id", nil) lastSyncedDate := time.Now() -secretsSync, err := client.Secrets().Sync("organization_id", lastSyncedDate) +secretsSync, err = bitwardenClient.Secrets().Sync("organization_id", lastSyncedDate) ``` --- From 27a71d899284da50e9a08ca87a0068f991dafe44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Fri, 19 Jul 2024 14:40:18 +0200 Subject: [PATCH 071/214] [PM-9527] Add PIN validation support (#912) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/PM-9527 ## 📔 Objective Fede mentioned on Slack some time ago that we currently don't have a simple way to validate the user's PIN like we do with the password. Instead the way to do it was to call `init_crypto` and check that the result is not an error. This requires more data than needed and does a lot of unnecessary operations, so I think it makes sense to expose a simpler way to do PIN verification. In this PR we're decrypting the PIN protected user key and comparing it with the stored user key, similar to what we're doing with `validate_password_user_key`. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-core/src/auth/client_auth.rs | 7 +- crates/bitwarden-core/src/auth/mod.rs | 2 + crates/bitwarden-core/src/auth/pin.rs | 101 ++++++++++++++++++ crates/bitwarden-uniffi/src/auth/mod.rs | 13 ++- 4 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 crates/bitwarden-core/src/auth/pin.rs diff --git a/crates/bitwarden-core/src/auth/client_auth.rs b/crates/bitwarden-core/src/auth/client_auth.rs index 1afc39c8c..6f1afb135 100644 --- a/crates/bitwarden-core/src/auth/client_auth.rs +++ b/crates/bitwarden-core/src/auth/client_auth.rs @@ -1,5 +1,5 @@ #[cfg(feature = "internal")] -use bitwarden_crypto::{AsymmetricEncString, DeviceKey, Kdf, TrustDeviceResponse}; +use bitwarden_crypto::{AsymmetricEncString, DeviceKey, EncString, Kdf, TrustDeviceResponse}; #[cfg(feature = "internal")] use crate::auth::login::NewAuthRequestResponse; @@ -16,6 +16,7 @@ use crate::auth::{ password_strength, satisfies_policy, validate_password, validate_password_user_key, MasterPasswordPolicyOptions, }, + pin::validate_pin, register::{make_register_keys, register}, tde::{make_register_tde_keys, RegisterTdeKeyResponse}, AuthRequestResponse, RegisterKeyResponse, RegisterRequest, @@ -116,6 +117,10 @@ impl<'a> ClientAuth<'a> { validate_password_user_key(self.client, password, encrypted_user_key) } + pub fn validate_pin(&self, pin: String, pin_protected_user_key: EncString) -> Result { + validate_pin(self.client, pin, pin_protected_user_key) + } + pub fn new_auth_request(&self, email: &str) -> Result { new_auth_request(email) } diff --git a/crates/bitwarden-core/src/auth/mod.rs b/crates/bitwarden-core/src/auth/mod.rs index 5b3d615e6..e52870570 100644 --- a/crates/bitwarden-core/src/auth/mod.rs +++ b/crates/bitwarden-core/src/auth/mod.rs @@ -8,6 +8,8 @@ mod jwt_token; pub mod login; #[cfg(feature = "internal")] pub mod password; +#[cfg(feature = "internal")] +pub mod pin; pub mod renew; pub use access_token::AccessToken; pub use jwt_token::JWTToken; diff --git a/crates/bitwarden-core/src/auth/pin.rs b/crates/bitwarden-core/src/auth/pin.rs new file mode 100644 index 000000000..ee093bfa6 --- /dev/null +++ b/crates/bitwarden-core/src/auth/pin.rs @@ -0,0 +1,101 @@ +use bitwarden_crypto::{EncString, PinKey}; + +use crate::{ + client::{LoginMethod, UserLoginMethod}, + error::{Error, Result}, + Client, +}; + +pub(crate) fn validate_pin( + client: &Client, + pin: String, + pin_protected_user_key: EncString, +) -> Result { + let login_method = client + .internal + .get_login_method() + .ok_or(Error::NotAuthenticated)?; + + #[allow(irrefutable_let_patterns)] + let LoginMethod::User(login_method) = login_method.as_ref() else { + return Err(Error::NotAuthenticated); + }; + + match login_method { + UserLoginMethod::Username { email, kdf, .. } + | UserLoginMethod::ApiKey { email, kdf, .. } => { + let enc = client.internal.get_encryption_settings()?; + let user_key = enc.get_key(&None)?; + + let pin_key = PinKey::derive(pin.as_bytes(), email.as_bytes(), kdf)?; + + let Ok(decrypted_key) = pin_key.decrypt_user_key(pin_protected_user_key) else { + return Ok(false); + }; + + Ok(user_key.to_vec() == decrypted_key.to_vec()) + } + } +} + +#[cfg(test)] +mod tests { + use std::num::NonZeroU32; + + use bitwarden_crypto::{Kdf, MasterKey}; + + use super::*; + use crate::client::{Client, LoginMethod, UserLoginMethod}; + + fn init_client() -> Client { + let client = Client::new(None); + + let password = "asdfasdfasdf"; + let email = "test@bitwarden.com"; + let kdf = Kdf::PBKDF2 { + iterations: NonZeroU32::new(600_000).unwrap(), + }; + + client + .internal + .set_login_method(LoginMethod::User(UserLoginMethod::Username { + email: email.to_string(), + kdf: kdf.clone(), + client_id: "1".to_string(), + })); + + let master_key = MasterKey::derive(password, email, &kdf).unwrap(); + + let user_key = "2.Q/2PhzcC7GdeiMHhWguYAQ==|GpqzVdr0go0ug5cZh1n+uixeBC3oC90CIe0hd/HWA/pTRDZ8ane4fmsEIcuc8eMKUt55Y2q/fbNzsYu41YTZzzsJUSeqVjT8/iTQtgnNdpo=|dwI+uyvZ1h/iZ03VQ+/wrGEFYVewBUUl/syYgjsNMbE="; + let private_key = "2.yN7l00BOlUE0Sb0M//Q53w==|EwKG/BduQRQ33Izqc/ogoBROIoI5dmgrxSo82sgzgAMIBt3A2FZ9vPRMY+GWT85JiqytDitGR3TqwnFUBhKUpRRAq4x7rA6A1arHrFp5Tp1p21O3SfjtvB3quiOKbqWk6ZaU1Np9HwqwAecddFcB0YyBEiRX3VwF2pgpAdiPbSMuvo2qIgyob0CUoC/h4Bz1be7Qa7B0Xw9/fMKkB1LpOm925lzqosyMQM62YpMGkjMsbZz0uPopu32fxzDWSPr+kekNNyLt9InGhTpxLmq1go/pXR2uw5dfpXc5yuta7DB0EGBwnQ8Vl5HPdDooqOTD9I1jE0mRyuBpWTTI3FRnu3JUh3rIyGBJhUmHqGZvw2CKdqHCIrQeQkkEYqOeJRJVdBjhv5KGJifqT3BFRwX/YFJIChAQpebNQKXe/0kPivWokHWwXlDB7S7mBZzhaAPidZvnuIhalE2qmTypDwHy22FyqV58T8MGGMchcASDi/QXI6kcdpJzPXSeU9o+NC68QDlOIrMVxKFeE7w7PvVmAaxEo0YwmuAzzKy9QpdlK0aab/xEi8V4iXj4hGepqAvHkXIQd+r3FNeiLfllkb61p6WTjr5urcmDQMR94/wYoilpG5OlybHdbhsYHvIzYoLrC7fzl630gcO6t4nM24vdB6Ymg9BVpEgKRAxSbE62Tqacxqnz9AcmgItb48NiR/He3n3ydGjPYuKk/ihZMgEwAEZvSlNxYONSbYrIGDtOY+8Nbt6KiH3l06wjZW8tcmFeVlWv+tWotnTY9IqlAfvNVTjtsobqtQnvsiDjdEVtNy/s2ci5TH+NdZluca2OVEr91Wayxh70kpM6ib4UGbfdmGgCo74gtKvKSJU0rTHakQ5L9JlaSDD5FamBRyI0qfL43Ad9qOUZ8DaffDCyuaVyuqk7cz9HwmEmvWU3VQ+5t06n/5kRDXttcw8w+3qClEEdGo1KeENcnXCB32dQe3tDTFpuAIMLqwXs6FhpawfZ5kPYvLPczGWaqftIs/RXJ/EltGc0ugw2dmTLpoQhCqrcKEBDoYVk0LDZKsnzitOGdi9mOWse7Se8798ib1UsHFUjGzISEt6upestxOeupSTOh0v4+AjXbDzRUyogHww3V+Bqg71bkcMxtB+WM+pn1XNbVTyl9NR040nhP7KEf6e9ruXAtmrBC2ah5cFEpLIot77VFZ9ilLuitSz+7T8n1yAh1IEG6xxXxninAZIzi2qGbH69O5RSpOJuJTv17zTLJQIIc781JwQ2TTwTGnx5wZLbffhCasowJKd2EVcyMJyhz6ru0PvXWJ4hUdkARJs3Xu8dus9a86N8Xk6aAPzBDqzYb1vyFIfBxP0oO8xFHgd30Cgmz8UrSE3qeWRrF8ftrI6xQnFjHBGWD/JWSvd6YMcQED0aVuQkuNW9ST/DzQThPzRfPUoiL10yAmV7Ytu4fR3x2sF0Yfi87YhHFuCMpV/DsqxmUizyiJuD938eRcH8hzR/VO53Qo3UIsqOLcyXtTv6THjSlTopQ+JOLOnHm1w8dzYbLN44OG44rRsbihMUQp+wUZ6bsI8rrOnm9WErzkbQFbrfAINdoCiNa6cimYIjvvnMTaFWNymqY1vZxGztQiMiHiHYwTfwHTXrb9j0uPM=|09J28iXv9oWzYtzK2LBT6Yht4IT4MijEkk0fwFdrVQ4=".parse().unwrap(); + + client + .internal + .initialize_user_crypto_master_key(master_key, user_key.parse().unwrap(), private_key) + .unwrap(); + + client + } + + #[test] + fn test_validate_valid_pin() { + let pin = "1234".to_string(); + let pin_protected_user_key = "2.BXgvdBUeEMyvumqAJkAzPA==|JScDPoqOkVdrC1X755Ubt8tS9pC/thvrvNf5CyNcRg8HZtZ466EcRo7aCqwUzLyTVNRkbCYtFYT+09acGGHur8tGuS7Kmg/pYeaUo4K0UKI=|NpIFg5P9z0SN1MffbixD9OQE0l+NiNmnRQJs/kTsyoQ=" + .parse() + .unwrap(); + + let client = init_client(); + assert!(validate_pin(&client, pin.clone(), pin_protected_user_key).unwrap()); + } + + #[test] + fn test_validate_invalid_pin() { + let pin = "1234".to_string(); + let pin_protected_user_key = "2.BXgvdBUeEMyvumqAJkAyPA==|JScDPoqOkVdrC1X755Ubt8tS9pC/thvrvNf5CyNcRg8HZtZ466EcRo7aCqwUzLyTVNRkbCYtFYT+09acGGHur8tGuS7Kmg/pYeaUo4K0UKI=|NpIFg5P9z0SN1MffbixD9OQE0l+NiNmnRQJs/kTsyoQ=" + .parse() + .unwrap(); + + let client = init_client(); + assert!(!validate_pin(&client, pin.clone(), pin_protected_user_key).unwrap()); + } +} diff --git a/crates/bitwarden-uniffi/src/auth/mod.rs b/crates/bitwarden-uniffi/src/auth/mod.rs index a70eebb8f..644580c5d 100644 --- a/crates/bitwarden-uniffi/src/auth/mod.rs +++ b/crates/bitwarden-uniffi/src/auth/mod.rs @@ -4,7 +4,7 @@ use bitwarden::auth::{ password::MasterPasswordPolicyOptions, AuthRequestResponse, RegisterKeyResponse, RegisterTdeKeyResponse, }; -use bitwarden_crypto::{AsymmetricEncString, HashPurpose, Kdf, TrustDeviceResponse}; +use bitwarden_crypto::{AsymmetricEncString, EncString, HashPurpose, Kdf, TrustDeviceResponse}; use crate::{error::Result, Client}; @@ -110,6 +110,17 @@ impl ClientAuth { .validate_password_user_key(password, encrypted_user_key)?) } + /// Validate the user PIN + /// + /// To validate the user PIN, you need to have the user's pin_protected_user_key. This key is + /// obtained when enabling PIN unlock on the account with the `derive_pin_key` method. + /// + /// This works by comparing the decrypted user key with the current user key, so the client must + /// be unlocked. + pub fn validate_pin(&self, pin: String, pin_protected_user_key: EncString) -> Result { + Ok(self.0 .0.auth().validate_pin(pin, pin_protected_user_key)?) + } + /// Initialize a new auth request pub fn new_auth_request(&self, email: String) -> Result { Ok(self.0 .0.auth().new_auth_request(&email)?) From 5e5ddabacf2e57e62bc975ad039bec691c815f12 Mon Sep 17 00:00:00 2001 From: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:50:21 -0500 Subject: [PATCH 072/214] [SM-1338] Add the ability to edit unassigned secrets (#906) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1338 ## 📔 Objective With the introduction of individual secret permissions, it is possible for a machine account to have **read, write** permission on an unassigned secret. Editing this unassigned secret should be supported by `bws`. This removes the client side validation that restricted the edit of an unassigned secret. --- crates/bws/CHANGELOG.md | 4 ++++ crates/bws/src/command/secret.rs | 11 ++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/bws/CHANGELOG.md b/crates/bws/CHANGELOG.md index 447f7cad6..695ab43df 100644 --- a/crates/bws/CHANGELOG.md +++ b/crates/bws/CHANGELOG.md @@ -7,6 +7,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added + +- The ability to edit unassigned secrets with direct permissions. (#906) + ### Removed - The deprecated `action type` commands are now removed. Please use `type action` instead. (#836) diff --git a/crates/bws/src/command/secret.rs b/crates/bws/src/command/secret.rs index 794a1a0b9..0f1aa3981 100644 --- a/crates/bws/src/command/secret.rs +++ b/crates/bws/src/command/secret.rs @@ -171,13 +171,10 @@ pub(crate) async fn edit( key: secret.key.unwrap_or(old_secret.key), value: secret.value.unwrap_or(old_secret.value), note: secret.note.unwrap_or(old_secret.note), - project_ids: match secret.project_id { - Some(id) => Some(vec![id]), - None => match old_secret.project_id { - Some(id) => Some(vec![id]), - None => bail!("Editing a secret requires a project_id."), - }, - }, + project_ids: secret + .project_id + .or(old_secret.project_id) + .map(|id| vec![id]), }) .await?; serialize_response(new_secret, output_settings); From ecaddf45697c690175c6114e269ef0ff9f5893ac Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:45:14 +0200 Subject: [PATCH 073/214] [deps]: Update @types/node to v18.19.41 (#915) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@types/node](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node) ([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node)) | [`18.19.39` -> `18.19.41`](https://renovatebot.com/diffs/npm/@types%2fnode/18.19.39/18.19.41) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2fnode/18.19.41?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@types%2fnode/18.19.41?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@types%2fnode/18.19.39/18.19.41?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2fnode/18.19.39/18.19.41?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- languages/js/sdk-client/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index 05cc3a534..5dbeba53a 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -41,9 +41,9 @@ } }, "node_modules/@types/node": { - "version": "18.19.39", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.39.tgz", - "integrity": "sha512-nPwTRDKUctxw3di5b4TfT3I0sWDiWoPQCZjXhvdkINntwr8lcoVCKsTgnXeRubKIlfnV+eN/HYk6Jb40tbcEAQ==", + "version": "18.19.41", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.41.tgz", + "integrity": "sha512-LX84pRJ+evD2e2nrgYCHObGWkiQJ1mL+meAgbvnwk/US6vmMY7S2ygBTGV2Jw91s9vUsLSXeDEkUHZIJGLrhsg==", "dev": true, "license": "MIT", "dependencies": { From 55d0a6919d2d7539d101977872e4f17d9757f160 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:46:35 +0200 Subject: [PATCH 074/214] [deps]: Update Rust crate clap_complete to v4.5.8 (#916) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [clap_complete](https://togithub.com/clap-rs/clap) | build-dependencies | patch | `4.5.7` -> `4.5.8` | | [clap_complete](https://togithub.com/clap-rs/clap) | dependencies | patch | `4.5.7` -> `4.5.8` | --- ### Release Notes
clap-rs/clap (clap_complete) ### [`v4.5.8`](https://togithub.com/clap-rs/clap/blob/HEAD/CHANGELOG.md#458---2024-06-28) [Compare Source](https://togithub.com/clap-rs/clap/compare/clap_complete-v4.5.7...clap_complete-v4.5.8) ##### Fixes - Reduce extra flushes
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 766d7a3a6..dcf477176 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -938,9 +938,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.7" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d598e88f6874d4b888ed40c71efbcbf4076f1dfbae128a08a8c9e45f710605d" +checksum = "5b4be9c4c4b1f30b78d8a750e0822b6a6102d97e62061c583a6c1dea2dfb33ae" dependencies = [ "clap", ] @@ -2216,7 +2216,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] From df4910c31ae67fb2af674cee89b14977157fc01a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:47:24 +0200 Subject: [PATCH 075/214] [deps]: Update Rust crate thiserror to v1.0.63 (#918) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [thiserror](https://togithub.com/dtolnay/thiserror) | dependencies | patch | `1.0.61` -> `1.0.63` | --- ### Release Notes
dtolnay/thiserror (thiserror) ### [`v1.0.63`](https://togithub.com/dtolnay/thiserror/releases/tag/1.0.63) [Compare Source](https://togithub.com/dtolnay/thiserror/compare/1.0.62...1.0.63) - Documentation improvements ### [`v1.0.62`](https://togithub.com/dtolnay/thiserror/releases/tag/1.0.62) [Compare Source](https://togithub.com/dtolnay/thiserror/compare/1.0.61...1.0.62) - Support referring to nested tuple struct fields inside `#[error("â€Ļ", â€Ļ)]` attribute ([#​309](https://togithub.com/dtolnay/thiserror/issues/309))
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dcf477176..9d1d62e83 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3890,18 +3890,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.61" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", From 23e1367131709e3083f7045c1a6d846ac910fe46 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:50:08 +0200 Subject: [PATCH 076/214] [deps]: Lock file maintenance (#919) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. đŸ‘ģ **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 185 +++++++++++----------- crates/bitwarden-napi/package-lock.json | 12 +- languages/js/example/package-lock.json | 2 + languages/js/sdk-client/package-lock.json | 37 ++--- package-lock.json | 62 +++----- 5 files changed, 140 insertions(+), 158 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d1d62e83..772bd3420 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -78,9 +78,9 @@ checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" [[package]] name = "ansi_colours" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a1558bd2075d341b9ca698ec8eb6fcc55a746b1fc4255585aad5b141d918a80" +checksum = "14eec43e0298190790f41679fe69ef7a829d2a2ddd78c8c00339e84710e435fe" dependencies = [ "rgb", ] @@ -182,7 +182,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -231,7 +231,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -768,7 +768,7 @@ dependencies = [ "tempfile", "thiserror", "tokio", - "toml 0.8.14", + "toml 0.8.15", "uuid", ] @@ -786,9 +786,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" [[package]] name = "bytesize" @@ -845,9 +845,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.106" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "066fce287b1d4eafef758e89e09d724a24808a9196fe9756b8ca90e86d0719a2" +checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" [[package]] name = "cesu8" @@ -954,7 +954,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -1297,14 +1297,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] name = "darling" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83b2eb4d90d12bdda5ed17de686c2acb4c57914f8f921b8da7e112b5a36f3fe1" +checksum = "6f63b86c8a8826a49b8c21f08a2d07338eec8d900540f8630dc76284be802989" dependencies = [ "darling_core", "darling_macro", @@ -1312,27 +1312,27 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" +checksum = "95133861a8032aaea082871032f5815eb9e98cef03fa916ab4500513994df9e5" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] name = "darling_macro" -version = "0.20.9" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" +checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -1411,7 +1411,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -1421,7 +1421,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -1687,7 +1687,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -1914,9 +1914,9 @@ dependencies = [ [[package]] name = "http-body" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", "http", @@ -1955,9 +1955,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "1.4.0" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4fe55fb7a772d59a5ff1dfbff4fe0258d19b89fec4b233e75d35d5d2316badc" +checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" dependencies = [ "bytes", "futures-channel", @@ -2211,12 +2211,12 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libloading" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e310b3a6b5907f99202fcdb4960ff45b93735d7c7d96b760fcff8db2dc0e103d" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -2349,23 +2349,23 @@ checksum = "e1c0f5d67ee408a4685b61f5ab7e58605c8ae3f2b4189f0127d804ff13d5560a" [[package]] name = "napi-derive" -version = "2.16.8" +version = "2.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eafd2b920906ea5b1f5f1f9d1eff9cc74e4ff8124dca41b501c1413079589187" +checksum = "87c3b5d4ab13e20a4bb9d3a1e2f3d4e77eee4a205d0f810abfd226b971dc6ce5" dependencies = [ "cfg-if", "convert_case", "napi-derive-backend", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] name = "napi-derive-backend" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b370b784440c65eb9001d839012eb912ee43e3a2d0361e2c30c13052372c39fe" +checksum = "96de436a6ab93265beef838f8333c8345438f059df6081fe0ad0b8648ee0c524" dependencies = [ "convert_case", "once_cell", @@ -2373,7 +2373,7 @@ dependencies = [ "quote", "regex", "semver", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -2723,7 +2723,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -2814,9 +2814,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.6.0" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0" +checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" [[package]] name = "powerfmt" @@ -2879,9 +2879,9 @@ source = "git+https://github.com/bitwarden/passkey-rs?rev=ae08e2cb7dd3d44d915cae [[package]] name = "pyo3" -version = "0.22.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e99090d12f6182924499253aaa1e73bf15c69cea8d2774c3c781e35badc3548" +checksum = "831e8e819a138c36e212f3af3fd9eeffed6bf1510a805af35b0edee5ffa59433" dependencies = [ "cfg-if", "indoc", @@ -2897,9 +2897,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.22.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7879eb018ac754bba32cb0eec7526391c02c14a093121857ed09fbf1d1057d41" +checksum = "1e8730e591b14492a8945cdff32f089250b05f5accecf74aeddf9e8272ce1fa8" dependencies = [ "once_cell", "target-lexicon", @@ -2907,9 +2907,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.22.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce2baa5559a411fc1cf519295f24c34b53d5d725818bc96b5abf94762da09041" +checksum = "5e97e919d2df92eb88ca80a037969f44e5e70356559654962cbb3316d00300c6" dependencies = [ "libc", "pyo3-build-config", @@ -2928,27 +2928,27 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.22.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "049621c20a23f2def20f4fe67978d1da8d8a883d64b9c21362f3b776e254edc7" +checksum = "eb57983022ad41f9e683a599f2fd13c3664d7063a3ac5714cae4b7bee7d3f206" dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] name = "pyo3-macros-backend" -version = "0.22.1" +version = "0.22.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e969ee2e025435f1819d31a275ba4bb9cbbdf3ac535227fdbd85b9322ffe144" +checksum = "ec480c0c51ddec81019531705acac51bcdbeae563557c982aa8263bb96880372" dependencies = [ "heck 0.5.0", "proc-macro2", "pyo3-build-config", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -2996,14 +2996,13 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9096629c45860fc7fb143e125eb826b5e721e10be3263160c7d60ca832cf8c46" +checksum = "25a78e6f726d84fcf960409f509ae354a32648f090c8d32a2ea8b1a1bc3bab14" dependencies = [ "libc", "once_cell", "socket2", - "tracing", "windows-sys 0.52.0", ] @@ -3068,9 +3067,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" dependencies = [ "bitflags 2.6.0", ] @@ -3171,9 +3170,9 @@ dependencies = [ [[package]] name = "rgb" -version = "0.8.44" +version = "0.8.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aee83dc281d5a3200d37b299acd13b81066ea126a7f16f0eae70fc9aed241d9" +checksum = "ade4539f42266ded9e755c605bdddf546242b2c961b03b06a7375260788a0523" dependencies = [ "bytemuck", ] @@ -3379,7 +3378,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -3411,7 +3410,7 @@ checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -3458,9 +3457,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" +checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" dependencies = [ "core-foundation-sys", "libc", @@ -3492,7 +3491,7 @@ checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -3503,7 +3502,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -3537,7 +3536,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -3563,9 +3562,9 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.8.3" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e73139bc5ec2d45e6c5fd85be5a46949c1c39a4c18e56915f5eb4c12f975e377" +checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" dependencies = [ "base64 0.22.1", "chrono", @@ -3581,14 +3580,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.8.3" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b80d3d6b56b64335c0180e5ffde23b3c5e08c14c585b51a15bd0e95393f46703" +checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -3781,7 +3780,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -3794,7 +3793,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -3824,9 +3823,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.70" +version = "2.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f0209b68b3613b093e0ec905354eccaedcfe83b8cb37cbdeae64026c3064c16" +checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" dependencies = [ "proc-macro2", "quote", @@ -3905,7 +3904,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -3976,9 +3975,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.0" +version = "1.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" dependencies = [ "backtrace", "bytes", @@ -3999,7 +3998,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -4037,9 +4036,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.14" +version = "0.8.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f49eb2ab21d2f26bd6db7bf383edc527a7ebaee412d17af4d40fdccd442f335" +checksum = "ac2caab0bf757388c6c0ae23b3293fdb463fee59434529014f85e3263b995c28" dependencies = [ "serde", "serde_spanned", @@ -4058,9 +4057,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.15" +version = "0.22.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59a3a72298453f564e2b111fa896f8d07fabb36f51f06d7e875fc5e0b5a3ef1" +checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788" dependencies = [ "indexmap 2.2.6", "serde", @@ -4115,7 +4114,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -4274,7 +4273,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d5c400339a9d1d17be34257d0b407e91d64af335e5b4fa49f4bf28467fc8d635" dependencies = [ "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -4306,7 +4305,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.70", + "syn 2.0.72", "toml 0.5.11", "uniffi_meta", ] @@ -4421,7 +4420,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -4484,7 +4483,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", "wasm-bindgen-shared", ] @@ -4518,7 +4517,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4551,7 +4550,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] @@ -4763,9 +4762,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.13" +version = "0.6.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59b5e5f6c299a3c7890b876a2a587f3115162487e704907d9b6cd29473052ba1" +checksum = "374ec40a2d767a3c1b4972d9475ecd557356637be906f2cb3f7fe17a6eb5e22f" dependencies = [ "memchr", ] @@ -4782,9 +4781,9 @@ dependencies = [ [[package]] name = "wiremock" -version = "0.6.0" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec874e1eef0df2dcac546057fe5e29186f09c378181cd7b635b4b7bcc98e9d81" +checksum = "6a59f8ae78a4737fb724f20106fb35ccb7cfe61ff335665d3042b3aa98e34717" dependencies = [ "assert-json-diff", "async-trait", @@ -4822,7 +4821,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.70", + "syn 2.0.72", ] [[package]] diff --git a/crates/bitwarden-napi/package-lock.json b/crates/bitwarden-napi/package-lock.json index 2520effcf..7047a2457 100644 --- a/crates/bitwarden-napi/package-lock.json +++ b/crates/bitwarden-napi/package-lock.json @@ -41,9 +41,9 @@ } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.15", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", - "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", "dev": true, "license": "MIT" }, @@ -104,9 +104,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "20.14.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.10.tgz", - "integrity": "sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ==", + "version": "20.14.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.11.tgz", + "integrity": "sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==", "dev": true, "license": "MIT", "peer": true, diff --git a/languages/js/example/package-lock.json b/languages/js/example/package-lock.json index d48fd43be..bff8fb2c2 100644 --- a/languages/js/example/package-lock.json +++ b/languages/js/example/package-lock.json @@ -11,6 +11,7 @@ } }, "../sdk-client": { + "name": "@bitwarden/sdk-client", "devDependencies": { "@types/node": "^18.15.11", "rimraf": "^5.0.0", @@ -18,6 +19,7 @@ } }, "../wasm": { + "name": "@bitwarden/sdk-wasm", "version": "0.1.0" }, "node_modules/@bitwarden/sdk-client": { diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index 5dbeba53a..e0c2633c4 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -160,9 +160,9 @@ } }, "node_modules/glob": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.3.tgz", - "integrity": "sha512-Q38SGlYRpVtDBPSWEylRyctn7uDeTp4NQERTLiCT1FqA9JXPYWqAVmQU6qh4r/zMM5ehxTcbaO8EjhWnvEhmyg==", + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", "dev": true, "license": "ISC", "dependencies": { @@ -176,9 +176,6 @@ "bin": { "glob": "dist/esm/bin.mjs" }, - "engines": { - "node": ">=18" - }, "funding": { "url": "https://github.com/sponsors/isaacs" } @@ -201,17 +198,14 @@ "license": "ISC" }, "node_modules/jackspeak": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.1.tgz", - "integrity": "sha512-U23pQPDnmYybVkYjObcuYMk43VRlMLLqLI+RdZy8s8WV8WsxO9SnqSroKaluuvcNOdCAlauKszDwd+umbot5Mg==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { "@isaacs/cliui": "^8.0.2" }, - "engines": { - "node": ">=18" - }, "funding": { "url": "https://github.com/sponsors/isaacs" }, @@ -220,14 +214,11 @@ } }, "node_modules/lru-cache": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.0.tgz", - "integrity": "sha512-bfJaPTuEiTYBu+ulDaeQ0F+uLmlfFkMgXj4cbwfuMSjgObGMzb55FMMbDvbRU0fAHZ4sLGkz2mKwcMg8Dvm8Ww==", + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", "dev": true, - "license": "ISC", - "engines": { - "node": ">=18" - } + "license": "ISC" }, "node_modules/minimatch": { "version": "9.0.5", @@ -290,9 +281,9 @@ } }, "node_modules/rimraf": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.8.tgz", - "integrity": "sha512-XSh0V2/yNhDEi8HwdIefD8MLgs4LQXPag/nEJWs3YUc3Upn+UHa1GyIkEg9xSSNt7HnkO5FjTvmcRzgf+8UZuw==", + "version": "5.0.9", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.9.tgz", + "integrity": "sha512-3i7b8OcswU6CpU8Ej89quJD4O98id7TtVM5U4Mybh84zQXdrFmDLouWBEEaD/QfO3gDDfH+AGFCGsR7kngzQnA==", "dev": true, "license": "ISC", "dependencies": { @@ -302,7 +293,7 @@ "rimraf": "dist/esm/bin.mjs" }, "engines": { - "node": ">=18" + "node": "14 >=14.20 || 16 >=16.20 || >=18" }, "funding": { "url": "https://github.com/sponsors/isaacs" diff --git a/package-lock.json b/package-lock.json index 0c5c2ada1..0b00eebba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,9 +19,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.7.tgz", - "integrity": "sha512-UwgBRMjJP+xv857DCngvqXI3Iq6J4v0wXmwc6sapg+zyhbwmQX67LUEFrkK5tbyJ30jGuG3ZvWpBiB9LCy1kWw==", + "version": "7.24.8", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.8.tgz", + "integrity": "sha512-5F7SDGs1T72ZczbRwbGO9lQi0NLjQxzl6i4lJxLxfW9U5UluCSyEJeniWvnhl3/euNiqQVbo8zruhsDfid0esA==", "dev": true, "license": "MIT", "dependencies": { @@ -165,9 +165,9 @@ } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.4.15", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", - "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", "dev": true, "license": "MIT" }, @@ -370,9 +370,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "20.14.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.10.tgz", - "integrity": "sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ==", + "version": "20.14.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.11.tgz", + "integrity": "sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==", "dev": true, "license": "MIT", "peer": true, @@ -1346,17 +1346,14 @@ } }, "node_modules/jackspeak": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.1.tgz", - "integrity": "sha512-U23pQPDnmYybVkYjObcuYMk43VRlMLLqLI+RdZy8s8WV8WsxO9SnqSroKaluuvcNOdCAlauKszDwd+umbot5Mg==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { "@isaacs/cliui": "^8.0.2" }, - "engines": { - "node": ">=18" - }, "funding": { "url": "https://github.com/sponsors/isaacs" }, @@ -1409,14 +1406,11 @@ } }, "node_modules/lru-cache": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.0.tgz", - "integrity": "sha512-bfJaPTuEiTYBu+ulDaeQ0F+uLmlfFkMgXj4cbwfuMSjgObGMzb55FMMbDvbRU0fAHZ4sLGkz2mKwcMg8Dvm8Ww==", + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", "dev": true, - "license": "ISC", - "engines": { - "node": ">=18" - } + "license": "ISC" }, "node_modules/make-error": { "version": "1.3.6", @@ -1843,9 +1837,9 @@ } }, "node_modules/rimraf/node_modules/glob": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.3.tgz", - "integrity": "sha512-Q38SGlYRpVtDBPSWEylRyctn7uDeTp4NQERTLiCT1FqA9JXPYWqAVmQU6qh4r/zMM5ehxTcbaO8EjhWnvEhmyg==", + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", "dev": true, "license": "ISC", "dependencies": { @@ -1859,9 +1853,6 @@ "bin": { "glob": "dist/esm/bin.mjs" }, - "engines": { - "node": ">=18" - }, "funding": { "url": "https://github.com/sponsors/isaacs" } @@ -1971,11 +1962,10 @@ } }, "node_modules/spawn-command": { - "version": "0.0.2-1", - "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2-1.tgz", - "integrity": "sha512-n98l9E2RMSJ9ON1AKisHzz7V42VDiBQGY6PB1BwRglz99wpVsSuGzQ+jOi6lFXBGVTCrRpltvjm+/XA+tpeJrg==", - "dev": true, - "license": "MIT" + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2.tgz", + "integrity": "sha512-zC8zGoGkmc8J9ndvml8Xksr1Amk9qBujgbF0JAIWO7kXr43w0h/0GJNM/Vustixu+YE8N/MTrQ7N31FvHUACxQ==", + "dev": true }, "node_modules/string_decoder": { "version": "1.3.0", @@ -2181,9 +2171,9 @@ } }, "node_modules/uglify-js": { - "version": "3.18.0", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.18.0.tgz", - "integrity": "sha512-SyVVbcNBCk0dzr9XL/R/ySrmYf0s372K6/hFklzgcp2lBFyXtw4I7BOdDjlLhE1aVqaI/SHWXWmYdlZxuyF38A==", + "version": "3.19.0", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.0.tgz", + "integrity": "sha512-wNKHUY2hYYkf6oSFfhwwiHo4WCHzHmzcXsqXYTN9ja3iApYIFbb2U6ics9hBcYLHcYGQoAlwnZlTrf3oF+BL/Q==", "dev": true, "license": "BSD-2-Clause", "optional": true, From 0cd7985e5d481b1b3a4d72cc594331192dbffa18 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 18:51:57 +0200 Subject: [PATCH 077/214] [deps]: Update rimraf to v6 (#923) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [rimraf](https://togithub.com/isaacs/rimraf) | [`5.0.8` -> `6.0.1`](https://renovatebot.com/diffs/npm/rimraf/5.0.8/6.0.1) | [![age](https://developer.mend.io/api/mc/badges/age/npm/rimraf/6.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/rimraf/6.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/rimraf/5.0.8/6.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/rimraf/5.0.8/6.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | | [rimraf](https://togithub.com/isaacs/rimraf) | [`^5.0.0` -> `^6.0.0`](https://renovatebot.com/diffs/npm/rimraf/5.0.9/6.0.1) | [![age](https://developer.mend.io/api/mc/badges/age/npm/rimraf/6.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/rimraf/6.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/rimraf/5.0.9/6.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/rimraf/5.0.9/6.0.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
isaacs/rimraf (rimraf) ### [`v6.0.1`](https://togithub.com/isaacs/rimraf/compare/v6.0.0...21560c7cdb46c039fccfd3f5fb4218946489881a) [Compare Source](https://togithub.com/isaacs/rimraf/compare/v6.0.0...v6.0.1) ### [`v6.0.0`](https://togithub.com/isaacs/rimraf/compare/v5.0.9...v6.0.0) [Compare Source](https://togithub.com/isaacs/rimraf/compare/v5.0.9...v6.0.0) ### [`v5.0.9`](https://togithub.com/isaacs/rimraf/compare/v5.0.8...546c9ec50c0e94ac08af7188b02fc1dddfc5134e) [Compare Source](https://togithub.com/isaacs/rimraf/compare/v5.0.8...v5.0.9)
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- languages/js/sdk-client/package-lock.json | 68 +++++++++++++---------- languages/js/sdk-client/package.json | 2 +- package-lock.json | 68 +++++++++++++---------- package.json | 2 +- 4 files changed, 80 insertions(+), 60 deletions(-) diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index e0c2633c4..40e80aca6 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -7,7 +7,7 @@ "name": "@bitwarden/sdk-client", "devDependencies": { "@types/node": "^18.15.11", - "rimraf": "^5.0.0", + "rimraf": "^6.0.0", "typescript": "^5.0.3" } }, @@ -160,22 +160,25 @@ } }, "node_modules/glob": { - "version": "10.4.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", - "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.0.tgz", + "integrity": "sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==", "dev": true, "license": "ISC", "dependencies": { "foreground-child": "^3.1.0", - "jackspeak": "^3.1.2", - "minimatch": "^9.0.4", + "jackspeak": "^4.0.1", + "minimatch": "^10.0.0", "minipass": "^7.1.2", "package-json-from-dist": "^1.0.0", - "path-scurry": "^1.11.1" + "path-scurry": "^2.0.0" }, "bin": { "glob": "dist/esm/bin.mjs" }, + "engines": { + "node": "20 || >=22" + }, "funding": { "url": "https://github.com/sponsors/isaacs" } @@ -198,14 +201,17 @@ "license": "ISC" }, "node_modules/jackspeak": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", - "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.1.tgz", + "integrity": "sha512-cub8rahkh0Q/bw1+GxP7aeSe29hHHn2V4m29nnDlvCdlgU+3UGxkZp7Z53jLUdpX3jdTO0nJZUDl3xvbWc2Xog==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { "@isaacs/cliui": "^8.0.2" }, + "engines": { + "node": "20 || >=22" + }, "funding": { "url": "https://github.com/sponsors/isaacs" }, @@ -214,23 +220,26 @@ } }, "node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.0.tgz", + "integrity": "sha512-Qv32eSV1RSCfhY3fpPE2GNZ8jgM9X7rdAfemLWqTUxwiyIC4jJ6Sy0fZ8H+oLWevO6i4/bizg7c8d8i6bxrzbA==", "dev": true, - "license": "ISC" + "license": "ISC", + "engines": { + "node": "20 || >=22" + } }, "node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz", + "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", "dev": true, "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -264,36 +273,37 @@ } }, "node_modules/path-scurry": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", - "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", + "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { - "lru-cache": "^10.2.0", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" }, "engines": { - "node": ">=16 || 14 >=14.18" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/rimraf": { - "version": "5.0.9", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.9.tgz", - "integrity": "sha512-3i7b8OcswU6CpU8Ej89quJD4O98id7TtVM5U4Mybh84zQXdrFmDLouWBEEaD/QfO3gDDfH+AGFCGsR7kngzQnA==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.0.1.tgz", + "integrity": "sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==", "dev": true, "license": "ISC", "dependencies": { - "glob": "^10.3.7" + "glob": "^11.0.0", + "package-json-from-dist": "^1.0.0" }, "bin": { "rimraf": "dist/esm/bin.mjs" }, "engines": { - "node": "14 >=14.20 || 16 >=16.20 || >=18" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" diff --git a/languages/js/sdk-client/package.json b/languages/js/sdk-client/package.json index 9e4998b4f..18bef74cb 100644 --- a/languages/js/sdk-client/package.json +++ b/languages/js/sdk-client/package.json @@ -14,7 +14,7 @@ }, "devDependencies": { "@types/node": "^18.15.11", - "rimraf": "^5.0.0", + "rimraf": "^6.0.0", "typescript": "^5.0.3" } } diff --git a/package-lock.json b/package-lock.json index 0b00eebba..9b1c2dcd7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "handlebars": "^4.7.8", "prettier": "3.3.2", "quicktype-core": "23.0.81", - "rimraf": "5.0.8", + "rimraf": "6.0.1", "ts-node": "10.9.2", "typescript": "5.3.3" } @@ -1346,14 +1346,17 @@ } }, "node_modules/jackspeak": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", - "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.1.tgz", + "integrity": "sha512-cub8rahkh0Q/bw1+GxP7aeSe29hHHn2V4m29nnDlvCdlgU+3UGxkZp7Z53jLUdpX3jdTO0nJZUDl3xvbWc2Xog==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { "@isaacs/cliui": "^8.0.2" }, + "engines": { + "node": "20 || >=22" + }, "funding": { "url": "https://github.com/sponsors/isaacs" }, @@ -1406,11 +1409,14 @@ } }, "node_modules/lru-cache": { - "version": "10.4.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.0.tgz", + "integrity": "sha512-Qv32eSV1RSCfhY3fpPE2GNZ8jgM9X7rdAfemLWqTUxwiyIC4jJ6Sy0fZ8H+oLWevO6i4/bizg7c8d8i6bxrzbA==", "dev": true, - "license": "ISC" + "license": "ISC", + "engines": { + "node": "20 || >=22" + } }, "node_modules/make-error": { "version": "1.3.6", @@ -1622,17 +1628,17 @@ } }, "node_modules/path-scurry": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", - "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", + "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { - "lru-cache": "^10.2.0", - "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" }, "engines": { - "node": ">=16 || 14 >=14.18" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -1808,19 +1814,20 @@ } }, "node_modules/rimraf": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-5.0.8.tgz", - "integrity": "sha512-XSh0V2/yNhDEi8HwdIefD8MLgs4LQXPag/nEJWs3YUc3Upn+UHa1GyIkEg9xSSNt7HnkO5FjTvmcRzgf+8UZuw==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.0.1.tgz", + "integrity": "sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==", "dev": true, "license": "ISC", "dependencies": { - "glob": "^10.3.7" + "glob": "^11.0.0", + "package-json-from-dist": "^1.0.0" }, "bin": { "rimraf": "dist/esm/bin.mjs" }, "engines": { - "node": ">=18" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -1837,37 +1844,40 @@ } }, "node_modules/rimraf/node_modules/glob": { - "version": "10.4.5", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", - "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.0.tgz", + "integrity": "sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==", "dev": true, "license": "ISC", "dependencies": { "foreground-child": "^3.1.0", - "jackspeak": "^3.1.2", - "minimatch": "^9.0.4", + "jackspeak": "^4.0.1", + "minimatch": "^10.0.0", "minipass": "^7.1.2", "package-json-from-dist": "^1.0.0", - "path-scurry": "^1.11.1" + "path-scurry": "^2.0.0" }, "bin": { "glob": "dist/esm/bin.mjs" }, + "engines": { + "node": "20 || >=22" + }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, "node_modules/rimraf/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz", + "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", "dev": true, "license": "ISC", "dependencies": { "brace-expansion": "^2.0.1" }, "engines": { - "node": ">=16 || 14 >=14.17" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" diff --git a/package.json b/package.json index 0c9c448ce..0ae7ad58a 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "handlebars": "^4.7.8", "prettier": "3.3.2", "quicktype-core": "23.0.81", - "rimraf": "5.0.8", + "rimraf": "6.0.1", "ts-node": "10.9.2", "typescript": "5.3.3" } From 4229aa0f72ee3403d6053a7cc485d36e9601d3ab Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 19:08:13 +0200 Subject: [PATCH 078/214] [deps]: Update prettier to v3.3.3 (#921) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [prettier](https://prettier.io) ([source](https://togithub.com/prettier/prettier)) | [`3.3.2` -> `3.3.3`](https://renovatebot.com/diffs/npm/prettier/3.3.2/3.3.3) | [![age](https://developer.mend.io/api/mc/badges/age/npm/prettier/3.3.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/prettier/3.3.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/prettier/3.3.2/3.3.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/prettier/3.3.2/3.3.3?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
prettier/prettier (prettier) ### [`v3.3.3`](https://togithub.com/prettier/prettier/blob/HEAD/CHANGELOG.md#333) [Compare Source](https://togithub.com/prettier/prettier/compare/3.3.2...3.3.3) [diff](https://togithub.com/prettier/prettier/compare/3.3.2...3.3.3) ##### Add parentheses for nullish coalescing in ternary ([#​16391](https://togithub.com/prettier/prettier/pull/16391) by [@​cdignam-segment](https://togithub.com/cdignam-segment)) This change adds clarity to operator precedence. ```js // Input foo ? bar ?? foo : baz; foo ?? bar ? a : b; a ? b : foo ?? bar; // Prettier 3.3.2 foo ? bar ?? foo : baz; foo ?? bar ? a : b; a ? b : foo ?? bar; // Prettier 3.3.3 foo ? (bar ?? foo) : baz; (foo ?? bar) ? a : b; a ? b : (foo ?? bar); ``` ##### Add parentheses for decorator expressions ([#​16458](https://togithub.com/prettier/prettier/pull/16458) by [@​y-schneider](https://togithub.com/y-schneider)) Prevent parentheses around member expressions or tagged template literals from being removed to follow the stricter parsing rules of TypeScript 5.5. ```ts // Input @​(foo`tagged template`) class X {} // Prettier 3.3.2 @​foo`tagged template` class X {} // Prettier 3.3.3 @​(foo`tagged template`) class X {} ``` ##### Support `@let` declaration syntax ([#​16474](https://togithub.com/prettier/prettier/pull/16474) by [@​sosukesuzuki](https://togithub.com/sosukesuzuki)) Adds support for Angular v18 `@let` declaration syntax. Please see the following code example. The `@let` declaration allows you to define local variables within the template: ```html @​let name = 'Frodo';

Dashboard for {{name}}

Hello, {{name}} ``` For more details, please refer to the excellent blog post by the Angular Team: [Introducing @​let in Angular](https://blog.angular.dev/introducing-let-in-angular-686f9f383f0f). We also appreciate the Angular Team for kindly answering our questions to implement this feature.
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9b1c2dcd7..aaa764d8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "devDependencies": { "@openapitools/openapi-generator-cli": "2.13.4", "handlebars": "^4.7.8", - "prettier": "3.3.2", + "prettier": "3.3.3", "quicktype-core": "23.0.81", "rimraf": "6.0.1", "ts-node": "10.9.2", @@ -1662,9 +1662,9 @@ } }, "node_modules/prettier": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", - "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", "dev": true, "license": "MIT", "bin": { diff --git a/package.json b/package.json index 0ae7ad58a..a688901ee 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "devDependencies": { "@openapitools/openapi-generator-cli": "2.13.4", "handlebars": "^4.7.8", - "prettier": "3.3.2", + "prettier": "3.3.3", "quicktype-core": "23.0.81", "rimraf": "6.0.1", "ts-node": "10.9.2", From c837aa0c877cb1714973d89fc1998e2ba9122bd6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 23 Jul 2024 11:16:40 +0200 Subject: [PATCH 079/214] [deps]: Update Rust crate uniffi to v0.28.0 (#889) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [uniffi](https://mozilla.github.io/uniffi-rs) ([source](https://togithub.com/mozilla/uniffi-rs)) | dependencies | minor | `=0.27.2` -> `=0.28.0` | | [uniffi](https://mozilla.github.io/uniffi-rs) ([source](https://togithub.com/mozilla/uniffi-rs)) | build-dependencies | minor | `=0.27.2` -> `=0.28.0` | --- ### Release Notes
mozilla/uniffi-rs (uniffi) ### [`v0.28.0`](https://togithub.com/mozilla/uniffi-rs/blob/HEAD/CHANGELOG.md#v0280-backend-crates-v0280---2024-06-11) [Compare Source](https://togithub.com/mozilla/uniffi-rs/compare/v0.27.3...v0.28.0) ##### What's new? - Objects error types can now be as `Result<>` error type without wrapping them in `Arc<>`. - Swift errors now provide `localizedDescription` ([#​2116](https://togithub.com/mozilla/uniffi-rs/pull/2116)) - Procmacros support tuple-errors (ie, enums used as errors can be tuple-enums.) ##### What's fixed? - Fixed a problem with procmacro defined errors when the error was not used as an `Err` result in the namespace ([#​2108](https://togithub.com/mozilla/uniffi-rs/issues/2108)) - Custom Type names are now treated as type names by all bindings. This means if they will work if they happen to be keywords in the language. There's a very small risk of this being a breaking change if you used a type name which did not already start with a capital letter, but this changes makes all type naming consistent. ([#​2073](https://togithub.com/mozilla/uniffi-rs/issues/2073)) - Macros `uniffi::method` and `uniffi::constructor` can now be used with `cfg_attr`. ([#​2113](https://togithub.com/mozilla/uniffi-rs/pull/2113)) - Python: Fix custom types generating invalid code when there are forward references. ([#​2067](https://togithub.com/mozilla/uniffi-rs/issues/2067)) ##### What's changed? - The internal bindings generation has changed to make it friendlier for external language bindings. However, this a **breaking change** for these bindings. No consumers of any languages are impacted, only the maintainers of these language bindings. ([#​2066](https://togithub.com/mozilla/uniffi-rs/issues/2066)), ([#​2094](https://togithub.com/mozilla/uniffi-rs/pull/2094)) - The async runtime can be specified for constructors/methods, this will override the runtime specified at the impl block level. [All changes in v0.28.0](https://togithub.com/mozilla/uniffi-rs/compare/v0.27.3...v0.28.0). ### [`v0.27.3`](https://togithub.com/mozilla/uniffi-rs/blob/HEAD/CHANGELOG.md#v0273-backend-crates-v0273---2024-06-03) [Compare Source](https://togithub.com/mozilla/uniffi-rs/compare/v0.27.2...v0.27.3) - Removed dependencies on `unicode-linebreak` and `unicode-width`. They were being pulled in a sub-dependencies for the `textwrap` crate, but weren't really useful. [All changes in v0.27.3](https://togithub.com/mozilla/uniffi-rs/compare/v0.27.2...v0.27.3).
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Oscar Hinton --- Cargo.lock | 47 +++++++++++--------------- crates/bitwarden-core/Cargo.toml | 2 +- crates/bitwarden-crypto/Cargo.toml | 2 +- crates/bitwarden-exporters/Cargo.toml | 2 +- crates/bitwarden-fido/Cargo.toml | 2 +- crates/bitwarden-generators/Cargo.toml | 2 +- crates/bitwarden-send/Cargo.toml | 2 +- crates/bitwarden-sm/Cargo.toml | 2 +- crates/bitwarden-uniffi/Cargo.toml | 4 +-- crates/bitwarden-vault/Cargo.toml | 2 +- crates/uniffi-bindgen/Cargo.toml | 2 +- 11 files changed, 30 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 772bd3420..8e96ee6d8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3883,8 +3883,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" dependencies = [ "smawk", - "unicode-linebreak", - "unicode-width", ] [[package]] @@ -4181,12 +4179,6 @@ version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "unicode-linebreak" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" - [[package]] name = "unicode-normalization" version = "0.1.23" @@ -4210,9 +4202,9 @@ checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "uniffi" -version = "0.27.2" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab38ff7ce5037772ca9bf7667e4e8535d110f11c6e2ec8cc9c1a7fc66938650c" +checksum = "f31bff6daf87277a9014bcdefbc2842b0553392919d1096843c5aad899ca4588" dependencies = [ "anyhow", "camino", @@ -4232,19 +4224,18 @@ dependencies = [ [[package]] name = "uniffi_bindgen" -version = "0.27.2" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "480597c3b4074ab2faa39158f45f87f3ac33ccfd7bc7943ff0877372d9d8db97" +checksum = "96061d7e01b185aa405f7c9b134741ab3e50cc6796a47d6fd8ab9a5364b5feed" dependencies = [ "anyhow", "askama", "camino", "cargo_metadata", - "clap", "fs-err", "glob", "goblin", - "heck 0.4.1", + "heck 0.5.0", "once_cell", "paste", "serde", @@ -4257,9 +4248,9 @@ dependencies = [ [[package]] name = "uniffi_build" -version = "0.27.2" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497391e423074ed5dbd828a2860d6203a333123519a285560c5ae1fd78075de4" +checksum = "9d6b86f9b221046af0c533eafe09ece04e2f1ded04ccdc9bba0ec09aec1c52bd" dependencies = [ "anyhow", "camino", @@ -4268,9 +4259,9 @@ dependencies = [ [[package]] name = "uniffi_checksum_derive" -version = "0.27.3" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5c400339a9d1d17be34257d0b407e91d64af335e5b4fa49f4bf28467fc8d635" +checksum = "2fcfa22f55829d3aaa7acfb1c5150224188fe0f27c59a8a3eddcaa24d1ffbe58" dependencies = [ "quote", "syn 2.0.72", @@ -4278,9 +4269,9 @@ dependencies = [ [[package]] name = "uniffi_core" -version = "0.27.2" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52fcb15ab907c37fe50163f05f97d497bc4400d8bfbdb7ef56b3a9ef777188d4" +checksum = "3210d57d6ab6065ab47a2898dacdb7c606fd6a4156196831fa3bf82e34ac58a6" dependencies = [ "anyhow", "async-compat", @@ -4294,9 +4285,9 @@ dependencies = [ [[package]] name = "uniffi_macros" -version = "0.27.2" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "865e2144b19552516c288e7c0425553c64724a8e4862bcb0c169355008e0ff0d" +checksum = "b58691741080935437dc862122e68d7414432a11824ac1137868de46181a0bd2" dependencies = [ "bincode", "camino", @@ -4312,9 +4303,9 @@ dependencies = [ [[package]] name = "uniffi_meta" -version = "0.27.2" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7968bda370d74b9bffb9af1e9cdc9a354ce027dc313963860f26dcf6c8efcecf" +checksum = "7663eacdbd9fbf4a88907ddcfe2e6fa85838eb6dc2418a7d91eebb3786f8e20b" dependencies = [ "anyhow", "bytes", @@ -4324,9 +4315,9 @@ dependencies = [ [[package]] name = "uniffi_testing" -version = "0.27.2" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cfe857c83a2655412745e31929c05486d02b340336b595b7044eff342cf6c91" +checksum = "f922465f7566f25f8fe766920205fdfa9a3fcdc209c6bfb7557f0b5bf45b04dd" dependencies = [ "anyhow", "camino", @@ -4337,9 +4328,9 @@ dependencies = [ [[package]] name = "uniffi_udl" -version = "0.27.2" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af11dd5dd1a60d9af5ef30cd37f37090999d998be0c9d34d5ddaf6cee138ed4a" +checksum = "cef408229a3a407fafa4c36dc4f6ece78a6fb258ab28d2b64bddd49c8cb680f6" dependencies = [ "anyhow", "textwrap", diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml index 09989de65..644ebc6c6 100644 --- a/crates/bitwarden-core/Cargo.toml +++ b/crates/bitwarden-core/Cargo.toml @@ -58,7 +58,7 @@ serde_repr = ">=0.1.12, <0.2" sha1 = ">=0.10.5, <0.11" sha2 = ">=0.10.6, <0.11" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.27.2", optional = true, features = ["tokio"] } +uniffi = { version = "=0.28.0", optional = true, features = ["tokio"] } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } validator = { version = "0.18.1", features = ["derive"] } zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } diff --git a/crates/bitwarden-crypto/Cargo.toml b/crates/bitwarden-crypto/Cargo.toml index 9968460b8..f2bbc6f7e 100644 --- a/crates/bitwarden-crypto/Cargo.toml +++ b/crates/bitwarden-crypto/Cargo.toml @@ -42,7 +42,7 @@ sha1 = ">=0.10.5, <0.11" sha2 = ">=0.10.6, <0.11" subtle = ">=2.5.0, <3.0" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.27.2", optional = true } +uniffi = { version = "=0.28.0", optional = true } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } diff --git a/crates/bitwarden-exporters/Cargo.toml b/crates/bitwarden-exporters/Cargo.toml index 79e0abb22..128cde6e6 100644 --- a/crates/bitwarden-exporters/Cargo.toml +++ b/crates/bitwarden-exporters/Cargo.toml @@ -32,7 +32,7 @@ schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } serde_json = ">=1.0.96, <2.0" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.27.2", optional = true } +uniffi = { version = "=0.28.0", optional = true } uuid = { version = ">=1.3.3, <2.0", features = ["serde", "v4"] } [lints] diff --git a/crates/bitwarden-fido/Cargo.toml b/crates/bitwarden-fido/Cargo.toml index 1223a6137..45d180ce8 100644 --- a/crates/bitwarden-fido/Cargo.toml +++ b/crates/bitwarden-fido/Cargo.toml @@ -36,7 +36,7 @@ schemars = { version = "0.8.21", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } serde_json = ">=1.0.96, <2.0" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.27.2", optional = true } +uniffi = { version = "=0.28.0", optional = true } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } [lints] diff --git a/crates/bitwarden-generators/Cargo.toml b/crates/bitwarden-generators/Cargo.toml index 629722548..acb87fa4b 100644 --- a/crates/bitwarden-generators/Cargo.toml +++ b/crates/bitwarden-generators/Cargo.toml @@ -28,7 +28,7 @@ schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } serde_json = ">=1.0.96, <2.0" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.27.2", optional = true } +uniffi = { version = "=0.28.0", optional = true } [dev-dependencies] rand_chacha = "0.3.1" diff --git a/crates/bitwarden-send/Cargo.toml b/crates/bitwarden-send/Cargo.toml index bae76a5bf..a7d5ec488 100644 --- a/crates/bitwarden-send/Cargo.toml +++ b/crates/bitwarden-send/Cargo.toml @@ -33,7 +33,7 @@ schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } serde_repr = ">=0.1.12, <0.2" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.27.2", optional = true } +uniffi = { version = "=0.28.0", optional = true } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } zeroize = { version = ">=1.7.0, <2.0" } diff --git a/crates/bitwarden-sm/Cargo.toml b/crates/bitwarden-sm/Cargo.toml index 9f366df16..278f82fae 100644 --- a/crates/bitwarden-sm/Cargo.toml +++ b/crates/bitwarden-sm/Cargo.toml @@ -25,7 +25,7 @@ schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } serde_json = ">=1.0.96, <2.0" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.27.2", optional = true } +uniffi = { version = "=0.28.0", optional = true } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } validator = { version = "0.18.1", features = ["derive"] } diff --git a/crates/bitwarden-uniffi/Cargo.toml b/crates/bitwarden-uniffi/Cargo.toml index f7a464328..eba12649c 100644 --- a/crates/bitwarden-uniffi/Cargo.toml +++ b/crates/bitwarden-uniffi/Cargo.toml @@ -35,7 +35,7 @@ log = "0.4.20" env_logger = "0.11.1" schemars = { version = ">=0.8, <0.9", optional = true } thiserror = ">=1.0.40, <2.0" -uniffi = "=0.27.2" +uniffi = "=0.28.0" uuid = ">=1.3.3, <2" [target.'cfg(target_os = "android")'.dependencies] @@ -45,7 +45,7 @@ android_logger = "0.14" oslog = "0.2.0" [build-dependencies] -uniffi = { version = "=0.27.2", features = ["build"] } +uniffi = { version = "=0.28.0", features = ["build"] } [lints] workspace = true diff --git a/crates/bitwarden-vault/Cargo.toml b/crates/bitwarden-vault/Cargo.toml index e875e4c06..a5052eca2 100644 --- a/crates/bitwarden-vault/Cargo.toml +++ b/crates/bitwarden-vault/Cargo.toml @@ -39,7 +39,7 @@ serde_repr = ">=0.1.12, <0.2" sha1 = ">=0.10.5, <0.11" sha2 = ">=0.10.6, <0.11" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.27.2", optional = true } +uniffi = { version = "=0.28.0", optional = true } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } [dev-dependencies] diff --git a/crates/uniffi-bindgen/Cargo.toml b/crates/uniffi-bindgen/Cargo.toml index a3203ea4a..ba6e00ddf 100644 --- a/crates/uniffi-bindgen/Cargo.toml +++ b/crates/uniffi-bindgen/Cargo.toml @@ -17,4 +17,4 @@ name = "uniffi-bindgen" path = "uniffi-bindgen.rs" [dependencies] -uniffi = { version = "=0.27.2", features = ["cli"] } +uniffi = { version = "=0.28.0", features = ["cli"] } From 63783e591a29d9fc6a325c3aa998db45240ae000 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 23 Jul 2024 16:15:41 +0200 Subject: [PATCH 080/214] Remove uniffi from bitwarden-sm crate (#920) Remove uniffi from bitwarden-sm crate. --- Cargo.lock | 1 - crates/bitwarden-sm/Cargo.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8e96ee6d8..e0e43998f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -615,7 +615,6 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "uniffi", "uuid", "validator", ] diff --git a/crates/bitwarden-sm/Cargo.toml b/crates/bitwarden-sm/Cargo.toml index 278f82fae..882780001 100644 --- a/crates/bitwarden-sm/Cargo.toml +++ b/crates/bitwarden-sm/Cargo.toml @@ -25,7 +25,6 @@ schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } serde_json = ">=1.0.96, <2.0" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.28.0", optional = true } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } validator = { version = "0.18.1", features = ["derive"] } From dfdbf7df0d8642f440177c6ef6abe5f04b63c2c4 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Thu, 25 Jul 2024 11:07:55 -0400 Subject: [PATCH 081/214] [SM-1096] Unify State Variable Naming (#895) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1096 ## 📔 Objective The naming around state files and paths is inconsistent. This PR aims to make the usage consistent. Every mention of state for access token auth should follow this naming logic: `state_dir` <- This refers to the state directory, where state files are stored. The sdk is currently only aware of state files, directory handling is still being done in bws. `state_file` <- This refers to a specific state file. In our code we don't append naming to variables to indicate the type (Hungarian Notation), so I thought it pertinent to truncate `_path` from these, preferring more descriptive `state_dir` and `state_file` for the names. Thanks @dani-garcia for pointing this out [here](https://github.com/bitwarden/sdk/pull/559#discussion_r1474654682). ⚠ī¸ **Note** ⚠ī¸ This also simplifies the `state_file_dir` key in the `bws` config file to `state_dir`. There will be more changes to this functionality with SM-1174, so I will wait to update the changelog for the next bws version until all this is completed. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bws/src/cli.rs | 2 +- crates/bws/src/config.rs | 6 +++--- crates/bws/src/main.rs | 6 +++--- crates/bws/src/state.rs | 15 ++++++--------- languages/go/README.md | 6 +++--- languages/go/bitwarden_client.go | 6 +++--- languages/go/example/example.go | 6 +++--- .../python/bitwarden_sdk/bitwarden_client.py | 4 ++-- languages/ruby/examples/example.rb | 4 ++-- 9 files changed, 26 insertions(+), 29 deletions(-) diff --git a/crates/bws/src/cli.rs b/crates/bws/src/cli.rs index 3c55b3a0e..e0ee4264d 100644 --- a/crates/bws/src/cli.rs +++ b/crates/bws/src/cli.rs @@ -19,7 +19,7 @@ pub(crate) enum ProfileKey { server_base, server_api, server_identity, - state_file_dir, + state_dir, } #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug)] diff --git a/crates/bws/src/config.rs b/crates/bws/src/config.rs index f769bb6da..6eae00e44 100644 --- a/crates/bws/src/config.rs +++ b/crates/bws/src/config.rs @@ -20,7 +20,7 @@ pub(crate) struct Profile { pub server_base: Option, pub server_api: Option, pub server_identity: Option, - pub state_file_dir: Option, + pub state_dir: Option, } impl ProfileKey { @@ -29,7 +29,7 @@ impl ProfileKey { ProfileKey::server_base => p.server_base = Some(value), ProfileKey::server_api => p.server_api = Some(value), ProfileKey::server_identity => p.server_identity = Some(value), - ProfileKey::state_file_dir => p.state_file_dir = Some(value), + ProfileKey::state_dir => p.state_dir = Some(value), } } } @@ -117,7 +117,7 @@ impl Profile { server_base: Some(url.to_string()), server_api: None, server_identity: None, - state_file_dir: None, + state_dir: None, }) } pub(crate) fn api_url(&self) -> Result { diff --git a/crates/bws/src/main.rs b/crates/bws/src/main.rs index 14fc30782..de9656a22 100644 --- a/crates/bws/src/main.rs +++ b/crates/bws/src/main.rs @@ -84,8 +84,8 @@ async fn process_commands() -> Result<()> { }) .transpose()?; - let state_file_path = state::get_state_file_path( - profile.and_then(|p| p.state_file_dir).map(Into::into), + let state_file = state::get_state_file( + profile.and_then(|p| p.state_dir).map(Into::into), access_token_obj.access_token_id.to_string(), )?; @@ -96,7 +96,7 @@ async fn process_commands() -> Result<()> { .auth() .login_access_token(&AccessTokenLoginRequest { access_token, - state_file: state_file_path, + state_file, }) .await?; diff --git a/crates/bws/src/state.rs b/crates/bws/src/state.rs index 9c90da81f..b42ca84da 100644 --- a/crates/bws/src/state.rs +++ b/crates/bws/src/state.rs @@ -2,18 +2,15 @@ use std::path::PathBuf; use color_eyre::eyre::Result; -pub(crate) fn get_state_file_path( - state_file_dir: Option, +pub(crate) fn get_state_file( + state_dir: Option, access_token_id: String, ) -> Result> { - if let Some(mut state_file_path) = state_file_dir { - state_file_path.push(access_token_id); + if let Some(mut state_dir) = state_dir { + std::fs::create_dir_all(&state_dir)?; + state_dir.push(access_token_id); - if let Some(parent_folder) = state_file_path.parent() { - std::fs::create_dir_all(parent_folder)?; - } - - return Ok(Some(state_file_path)); + return Ok(Some(state_dir)); } Ok(None) diff --git a/languages/go/README.md b/languages/go/README.md index 90b5f664e..8332f5dc0 100644 --- a/languages/go/README.md +++ b/languages/go/README.md @@ -36,13 +36,13 @@ bitwardenClient, _ := sdk.NewBitwardenClient(&apiURL, &identityURL) ### Login -To login using an access token. Define some `statePath` and pass it to use state, or pass `nil` +To login using an access token. Define some `stateFile` and pass it to use state, or pass `nil` instead to not use state. ```go -statePath := os.Getenv("STATE_PATH") +stateFile := os.Getenv("STATE_FILE") -err := bitwardenClient.AccessTokenLogin(accessToken, &statePath) +err := bitwardenClient.AccessTokenLogin(accessToken, &stateFile) ``` --- diff --git a/languages/go/bitwarden_client.go b/languages/go/bitwarden_client.go index 435ccdd95..c6c9e09b4 100644 --- a/languages/go/bitwarden_client.go +++ b/languages/go/bitwarden_client.go @@ -7,7 +7,7 @@ import ( ) type BitwardenClientInterface interface { - AccessTokenLogin(accessToken string, statePath *string) error + AccessTokenLogin(accessToken string, stateFile *string) error Projects() ProjectsInterface Secrets() SecretsInterface Close() @@ -52,8 +52,8 @@ func NewBitwardenClient(apiURL *string, identityURL *string) (BitwardenClientInt }, nil } -func (c *BitwardenClient) AccessTokenLogin(accessToken string, statePath *string) error { - req := AccessTokenLoginRequest{AccessToken: accessToken, StateFile: statePath} +func (c *BitwardenClient) AccessTokenLogin(accessToken string, stateFile *string) error { + req := AccessTokenLoginRequest{AccessToken: accessToken, StateFile: stateFile} command := Command{AccessTokenLogin: &req} responseStr, err := c.commandRunner.RunCommand(command) diff --git a/languages/go/example/example.go b/languages/go/example/example.go index 517a4fbb6..b97645db6 100644 --- a/languages/go/example/example.go +++ b/languages/go/example/example.go @@ -21,15 +21,15 @@ func main() { organizationIDStr := os.Getenv("ORGANIZATION_ID") projectName := os.Getenv("PROJECT_NAME") - // Configuring the statePath is optional, pass nil + // Configuring the stateFile is optional, pass nil // in AccessTokenLogin() to not use state - statePath := os.Getenv("STATE_PATH") + stateFile := os.Getenv("STATE_FILE") if projectName == "" { projectName = "NewTestProject" // default value } - err := bitwardenClient.AccessTokenLogin(accessToken, &statePath) + err := bitwardenClient.AccessTokenLogin(accessToken, &stateFile) if err != nil { panic(err) } diff --git a/languages/python/bitwarden_sdk/bitwarden_client.py b/languages/python/bitwarden_sdk/bitwarden_client.py index b5ea48c44..e8f12d963 100644 --- a/languages/python/bitwarden_sdk/bitwarden_client.py +++ b/languages/python/bitwarden_sdk/bitwarden_client.py @@ -13,9 +13,9 @@ def __init__(self, settings: ClientSettings = None): self.inner = bitwarden_py.BitwardenClient(settings_json) def access_token_login(self, access_token: str, - state_file_path: str = None): + state_file: str = None): self._run_command( - Command(access_token_login=AccessTokenLoginRequest(access_token, state_file_path)) + Command(access_token_login=AccessTokenLoginRequest(access_token, state_file)) ) def secrets(self): diff --git a/languages/ruby/examples/example.rb b/languages/ruby/examples/example.rb index d1c7ce455..475e52089 100644 --- a/languages/ruby/examples/example.rb +++ b/languages/ruby/examples/example.rb @@ -3,7 +3,7 @@ token = ENV['ACCESS_TOKEN'] organization_id = ENV['ORGANIZATION_ID'] -state_path = ENV['STATE_PATH'] +state_file = ENV['STATE_FILE'] # Configuring the URLS is optional, set them to nil to use the default values api_url = ENV['API_URL'] @@ -12,7 +12,7 @@ bitwarden_settings = BitwardenSDKSecrets::BitwardenSettings.new(api_url, identity_url) bw_client = BitwardenSDKSecrets::BitwardenClient.new(bitwarden_settings) -response = bw_client.access_token_login(token, state_path) +response = bw_client.access_token_login(token, state_file) puts response # CREATE project From 5572ed828cd42a06e24980ca3dc73638d8453f76 Mon Sep 17 00:00:00 2001 From: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com> Date: Tue, 30 Jul 2024 18:20:02 -0500 Subject: [PATCH 082/214] [SM-1370] Update QuickType version (#926) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1370 ## 📔 Objective The purpose of this PR is to update the`QuickType` version. Most language generated schemas were not effected. ### C++ A minor change in the error message for enum parsing. ``` default: throw std::runtime_error("This should not happen"); ``` to ``` default: throw std::runtime_error("Unexpected value in enumeration \"[object Object]\": " + std::to_string(static_cast(x))); ``` ### Go Has several breaking changes. #### omit-empty Previously, the `omit-empty` feature was enabled by default. QuickType's description: `If set, all non-required objects will be tagged with ",omitempty"` For example, the `SecretsSyncRequest` struct `LastSyncedDate` is optional and uses `emitempty`. ``` type SecretsSyncRequest struct { // Optional date time a sync last occurred LastSyncedDate *string `json:"lastSyncedDate,omitempty"` // Organization to sync secrets from OrganizationID string `json:"organizationId"` } ``` To continue this behavior, I added and enabled it in the render options `support/scripts/schemas.ts`. #### just-types-and-package & time Previously, model properties that were `DateTime` types in Bitwarden server models were translated to Go `string` properties. With this newer version of QuickType these `DateTime` properties are now `time.Time` in Go. This required changes to the Sync function `languages/go/secrets.go`. With the `just-types-and-package` render option, `import "time"` is added to the file at the first occurrence of a `time.Time` property. This is most likely a bug and causes build errors. ``` go % go build # github.com/bitwarden/sdk-go ./schema.go:288:1: syntax error: imports must appear before other declarations ``` Removing the `just-types-and-package` render option fixes this problem and has the import moved to the top of the file. This does cause adding some unnecessary marshal & un-marshal functions, that won't be used, into the `schema.go` file. --- languages/go/secrets.go | 8 +------ package-lock.json | 44 ++++++++++++++++---------------------- package.json | 2 +- support/scripts/schemas.ts | 2 +- 4 files changed, 21 insertions(+), 35 deletions(-) diff --git a/languages/go/secrets.go b/languages/go/secrets.go index f11106b9b..825a0f100 100644 --- a/languages/go/secrets.go +++ b/languages/go/secrets.go @@ -134,17 +134,11 @@ func (s *Secrets) Delete(ids []string) (*SecretsDeleteResponse, error) { } func (s *Secrets) Sync(organizationID string, lastSyncedDate *time.Time) (*SecretsSyncResponse, error) { - var lastSyncedDateString *string - if lastSyncedDate != nil { - tempRfc3339 := lastSyncedDate.UTC().Format(time.RFC3339) - lastSyncedDateString = &tempRfc3339 - } - command := Command{ Secrets: &SecretsCommand{ Sync: &SecretsSyncRequest{ OrganizationID: organizationID, - LastSyncedDate: lastSyncedDateString, + LastSyncedDate: lastSyncedDate, }, }, } diff --git a/package-lock.json b/package-lock.json index aaa764d8d..3483f5930 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "@openapitools/openapi-generator-cli": "2.13.4", "handlebars": "^4.7.8", "prettier": "3.3.3", - "quicktype-core": "23.0.81", + "quicktype-core": "23.0.170", "rimraf": "6.0.1", "ts-node": "10.9.2", "typescript": "5.3.3" @@ -45,9 +45,9 @@ } }, "node_modules/@glideapps/ts-necessities": { - "version": "2.1.3", - "resolved": "https://registry.npmjs.org/@glideapps/ts-necessities/-/ts-necessities-2.1.3.tgz", - "integrity": "sha512-q9U8v/n9qbkd2zDYjuX3qtlbl+OIyI9zF+zQhZjfYOE9VMDH7tfcUSJ9p0lXoY3lxmGFne09yi4iiNeQUwV7AA==", + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/@glideapps/ts-necessities/-/ts-necessities-2.2.3.tgz", + "integrity": "sha512-gXi0awOZLHk3TbW55GZLCPP6O+y/b5X1pBXKBVckFONSwF1z1E5ND2BGJsghQFah+pW7pkkyFb2VhUQI2qhL5w==", "dev": true, "license": "MIT" }, @@ -380,13 +380,6 @@ "undici-types": "~5.26.4" } }, - "node_modules/@types/urijs": { - "version": "1.19.25", - "resolved": "https://registry.npmjs.org/@types/urijs/-/urijs-1.19.25.tgz", - "integrity": "sha512-XOfUup9r3Y06nFAZh3WvO0rBU4OtlfPB/vgxpjg+NRdGU6CN6djdc6OEiH+PcqHCY6eFLo9Ista73uarf4gnBg==", - "dev": true, - "license": "MIT" - }, "node_modules/abort-controller": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", @@ -559,9 +552,9 @@ } }, "node_modules/browser-or-node": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/browser-or-node/-/browser-or-node-2.1.1.tgz", - "integrity": "sha512-8CVjaLJGuSKMVTxJ2DpBl5XnlNDiT4cQFeuCJJrvJmts9YrTZDizTX7PjC2s6W4x+MBGZeEY6dGMrF04/6Hgqg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/browser-or-node/-/browser-or-node-3.0.0.tgz", + "integrity": "sha512-iczIdVJzGEYhP5DqQxYM9Hh7Ztpqqi+CXZpSmX8ALFs9ecXkQIeqRyM6TfxEfMVpwhl3dSuDvxdzzo9sUOIVBQ==", "dev": true, "license": "MIT" }, @@ -1695,27 +1688,26 @@ "license": "MIT" }, "node_modules/quicktype-core": { - "version": "23.0.81", - "resolved": "https://registry.npmjs.org/quicktype-core/-/quicktype-core-23.0.81.tgz", - "integrity": "sha512-iJQpCEzSQIkffJPS5NC+0w+Rq9faGgz09L+WIbseu1toFfj+M/3KTG5jhzdY/uN88fWosAom2fMoEADA403+rQ==", + "version": "23.0.170", + "resolved": "https://registry.npmjs.org/quicktype-core/-/quicktype-core-23.0.170.tgz", + "integrity": "sha512-ZsjveG0yJUIijUx4yQshzyQ5EAXKbFSBTQJHnJ+KoSZVxcS+m3GcmDpzrdUIRYMhgLaF11ZGvLSYi5U0xcwemw==", "dev": true, "license": "Apache-2.0", "dependencies": { - "@glideapps/ts-necessities": "2.1.3", - "@types/urijs": "^1.19.19", - "browser-or-node": "^2.1.1", + "@glideapps/ts-necessities": "2.2.3", + "browser-or-node": "^3.0.0", "collection-utils": "^1.0.1", "cross-fetch": "^4.0.0", "is-url": "^1.2.4", - "js-base64": "^3.7.5", + "js-base64": "^3.7.7", "lodash": "^4.17.21", "pako": "^1.0.6", "pluralize": "^8.0.0", - "readable-stream": "4.4.2", + "readable-stream": "4.5.2", "unicode-properties": "^1.4.1", "urijs": "^1.19.1", "wordwrap": "^1.0.0", - "yaml": "^2.3.1" + "yaml": "^2.4.1" } }, "node_modules/quicktype-core/node_modules/buffer": { @@ -1744,9 +1736,9 @@ } }, "node_modules/quicktype-core/node_modules/readable-stream": { - "version": "4.4.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.4.2.tgz", - "integrity": "sha512-Lk/fICSyIhodxy1IDK2HazkeGjSmezAWX2egdtJnYhtzKEsBPJowlI6F6LPb5tqIQILrMbx22S5o3GuJavPusA==", + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz", + "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index a688901ee..3a0e24491 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "@openapitools/openapi-generator-cli": "2.13.4", "handlebars": "^4.7.8", "prettier": "3.3.3", - "quicktype-core": "23.0.81", + "quicktype-core": "23.0.170", "rimraf": "6.0.1", "ts-node": "10.9.2", "typescript": "5.3.3" diff --git a/support/scripts/schemas.ts b/support/scripts/schemas.ts index 757878334..5ea71408c 100644 --- a/support/scripts/schemas.ts +++ b/support/scripts/schemas.ts @@ -95,7 +95,7 @@ async function main() { lang: "go", rendererOptions: { package: "sdk", - "just-types-and-package": true, + "omit-empty": true, }, }); From c711924c1b175e63242f34f06db5510c4e83c918 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 2 Aug 2024 11:10:41 +0200 Subject: [PATCH 083/214] [PM-10446] Add fido flag to CipherListView (#931) Add support for identifying if a login has a fido credential. --- crates/bitwarden-crypto/src/error.rs | 2 + crates/bitwarden-vault/src/cipher/cipher.rs | 94 ++++++++++++++++++++- 2 files changed, 92 insertions(+), 4 deletions(-) diff --git a/crates/bitwarden-crypto/src/error.rs b/crates/bitwarden-crypto/src/error.rs index 2f21975fc..2fc4d2591 100644 --- a/crates/bitwarden-crypto/src/error.rs +++ b/crates/bitwarden-crypto/src/error.rs @@ -19,6 +19,8 @@ pub enum CryptoError { InvalidUtf8String, #[error("Missing Key for organization with ID {0}")] MissingKey(Uuid), + #[error("The item was missing a required field: {0}")] + MissingField(&'static str), #[error("EncString error, {0}")] EncString(#[from] EncStringParseError), diff --git a/crates/bitwarden-vault/src/cipher/cipher.rs b/crates/bitwarden-vault/src/cipher/cipher.rs index 5d348bc3b..9855ac4f1 100644 --- a/crates/bitwarden-vault/src/cipher/cipher.rs +++ b/crates/bitwarden-vault/src/cipher/cipher.rs @@ -43,7 +43,7 @@ pub enum CipherType { Identity = 4, } -#[derive(Clone, Copy, Serialize_repr, Deserialize_repr, Debug, JsonSchema)] +#[derive(Clone, Copy, Serialize_repr, Deserialize_repr, Debug, JsonSchema, PartialEq)] #[repr(u8)] #[cfg_attr(feature = "uniffi", derive(uniffi::Enum))] pub enum CipherRepromptType { @@ -125,7 +125,17 @@ pub struct CipherView { pub revision_date: DateTime, } -#[derive(Serialize, Deserialize, Debug, JsonSchema)] +#[derive(Serialize, Deserialize, Debug, JsonSchema, PartialEq)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))] +pub enum CipherListViewType { + Login { has_fido2: bool }, + SecureNote, + Card, + Identity, +} + +#[derive(Serialize, Deserialize, Debug, JsonSchema, PartialEq)] #[serde(rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] pub struct CipherListView { @@ -137,7 +147,7 @@ pub struct CipherListView { pub name: String, pub sub_title: String, - pub r#type: CipherType, + pub r#type: CipherListViewType, pub favorite: bool, pub reprompt: CipherRepromptType, @@ -502,7 +512,20 @@ impl KeyDecryptable for Cipher { collection_ids: self.collection_ids.clone(), name: self.name.decrypt_with_key(key).ok().unwrap_or_default(), sub_title: self.get_decrypted_subtitle(key).ok().unwrap_or_default(), - r#type: self.r#type, + r#type: match self.r#type { + CipherType::Login => { + let login = self + .login + .as_ref() + .ok_or(CryptoError::MissingField("login"))?; + CipherListViewType::Login { + has_fido2: login.fido2_credentials.is_some(), + } + } + CipherType::SecureNote => CipherListViewType::SecureNote, + CipherType::Card => CipherListViewType::Card, + CipherType::Identity => CipherListViewType::Identity, + }, favorite: self.favorite, reprompt: self.reprompt, edit: self.edit, @@ -668,6 +691,69 @@ mod tests { } } + #[test] + fn test_decrypt_cipher_list_view() { + let key: SymmetricCryptoKey = "w2LO+nwV4oxwswVYCxlOfRUseXfvU03VzvKQHrqeklPgiMZrspUe6sOBToCnDn9Ay0tuCBn8ykVVRb7PWhub2Q==".to_string().try_into().unwrap(); + + let cipher = Cipher { + id: Some("090c19ea-a61a-4df6-8963-262b97bc6266".parse().unwrap()), + organization_id: None, + folder_id: None, + collection_ids: vec![], + key: None, + name: "2.d3rzo0P8rxV9Hs1m1BmAjw==|JOwna6i0zs+K7ZghwrZRuw==|SJqKreLag1ID+g6H1OdmQr0T5zTrVWKzD6hGy3fDqB0=".parse().unwrap(), + notes: None, + r#type: CipherType::Login, + login: Some(Login { + username: Some("2.EBNGgnaMHeO/kYnI3A0jiA==|9YXlrgABP71ebZ5umurCJQ==|GDk5jxiqTYaU7e2AStCFGX+a1kgCIk8j0NEli7Jn0L4=".parse().unwrap()), + password: Some("2.M7ZJ7EuFDXCq66gDTIyRIg==|B1V+jroo6+m/dpHx6g8DxA==|PIXPBCwyJ1ady36a7jbcLg346pm/7N/06W4UZxc1TUo=".parse().unwrap()), + password_revision_date: None, + uris: None, + totp: None, + autofill_on_page_load: None, + fido2_credentials: Some(vec![generate_fido2(&key)]), + }), + identity: None, + card: None, + secure_note: None, + favorite: false, + reprompt: CipherRepromptType::None, + organization_use_totp: false, + edit: true, + view_password: true, + local_data: None, + attachments: None, + fields: None, + password_history: None, + creation_date: "2024-01-30T17:55:36.150Z".parse().unwrap(), + deleted_date: None, + revision_date: "2024-01-30T17:55:36.150Z".parse().unwrap(), + }; + + let view: CipherListView = cipher.decrypt_with_key(&key).unwrap(); + + assert_eq!( + view, + CipherListView { + id: cipher.id, + organization_id: cipher.organization_id, + folder_id: cipher.folder_id, + collection_ids: cipher.collection_ids, + name: "My test login".to_string(), + sub_title: "test_username".to_string(), + r#type: CipherListViewType::Login { has_fido2: true }, + favorite: cipher.favorite, + reprompt: cipher.reprompt, + edit: cipher.edit, + view_password: cipher.view_password, + attachments: 0, + creation_date: cipher.creation_date, + deleted_date: cipher.deleted_date, + revision_date: cipher.revision_date + } + ) + } + #[test] fn test_generate_cipher_key() { let key = SymmetricCryptoKey::generate(rand::thread_rng()); From b2f4a6583101701e14f933fd320a54b753307770 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 2 Aug 2024 12:33:39 +0200 Subject: [PATCH 084/214] [PM-10447] Add support for calculating totp from cipher list view (#932) Add totp to cipher list view, and a way to calculate the current value from a given list view. --- .../src/enc_string/symmetric.rs | 2 +- crates/bitwarden-uniffi/src/vault/mod.rs | 15 ++++ crates/bitwarden-vault/src/cipher/cipher.rs | 47 ++++++++++++- crates/bitwarden-vault/src/client_totp.rs | 15 +++- crates/bitwarden-vault/src/lib.rs | 2 +- crates/bitwarden-vault/src/totp.rs | 69 +++++++++++++++++++ 6 files changed, 144 insertions(+), 6 deletions(-) diff --git a/crates/bitwarden-crypto/src/enc_string/symmetric.rs b/crates/bitwarden-crypto/src/enc_string/symmetric.rs index 5e82031fe..093ab9f62 100644 --- a/crates/bitwarden-crypto/src/enc_string/symmetric.rs +++ b/crates/bitwarden-crypto/src/enc_string/symmetric.rs @@ -44,7 +44,7 @@ use crate::{ /// - `[iv]`: (optional) is the initialization vector used for encryption. /// - `[data]`: is the encrypted data. /// - `[mac]`: (optional) is the MAC used to validate the integrity of the data. -#[derive(Clone, zeroize::ZeroizeOnDrop)] +#[derive(Clone, zeroize::ZeroizeOnDrop, PartialEq)] #[allow(unused, non_camel_case_types)] pub enum EncString { /// 0 diff --git a/crates/bitwarden-uniffi/src/vault/mod.rs b/crates/bitwarden-uniffi/src/vault/mod.rs index 5f4e80707..4cf840868 100644 --- a/crates/bitwarden-uniffi/src/vault/mod.rs +++ b/crates/bitwarden-uniffi/src/vault/mod.rs @@ -4,6 +4,7 @@ use bitwarden::{ error::Error, vault::{ClientVaultExt, TotpResponse}, }; +use bitwarden_vault::CipherListView; use chrono::{DateTime, Utc}; use crate::{error::Result, Client}; @@ -58,4 +59,18 @@ impl ClientVault { .generate_totp(key, time) .map_err(Error::Totp)?) } + + /// Generate a TOTP code from a provided cipher list view. + pub fn generate_totp_cipher_view( + &self, + view: CipherListView, + time: Option>, + ) -> Result { + Ok(self + .0 + .0 + .vault() + .generate_totp_cipher_view(view, time) + .map_err(Error::Totp)?) + } } diff --git a/crates/bitwarden-vault/src/cipher/cipher.rs b/crates/bitwarden-vault/src/cipher/cipher.rs index 9855ac4f1..8ac4bfe79 100644 --- a/crates/bitwarden-vault/src/cipher/cipher.rs +++ b/crates/bitwarden-vault/src/cipher/cipher.rs @@ -98,6 +98,7 @@ pub struct CipherView { pub folder_id: Option, pub collection_ids: Vec, + /// Temporary, required to support re-encrypting existing items. pub key: Option, pub name: String, @@ -129,7 +130,10 @@ pub struct CipherView { #[serde(rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "uniffi", derive(uniffi::Enum))] pub enum CipherListViewType { - Login { has_fido2: bool }, + Login { + has_fido2: bool, + totp: Option, + }, SecureNote, Card, Identity, @@ -144,6 +148,9 @@ pub struct CipherListView { pub folder_id: Option, pub collection_ids: Vec, + /// Temporary, required to support calculating TOTP from CipherListView. + pub key: Option, + pub name: String, pub sub_title: String, @@ -162,6 +169,25 @@ pub struct CipherListView { pub revision_date: DateTime, } +impl CipherListView { + pub(crate) fn get_totp_key( + self, + enc: &dyn KeyContainer, + ) -> Result, CryptoError> { + let key = self.locate_key(enc, &None)?; + let cipher_key = Cipher::get_cipher_key(key, &self.key)?; + let key = cipher_key.as_ref().unwrap_or(key); + + let totp = if let CipherListViewType::Login { totp, .. } = self.r#type { + totp.decrypt_with_key(key)? + } else { + None + }; + + Ok(totp) + } +} + impl KeyEncryptable for CipherView { fn encrypt_with_key(mut self, key: &SymmetricCryptoKey) -> Result { let ciphers_key = Cipher::get_cipher_key(key, &self.key)?; @@ -510,6 +536,7 @@ impl KeyDecryptable for Cipher { organization_id: self.organization_id, folder_id: self.folder_id, collection_ids: self.collection_ids.clone(), + key: self.key.clone(), name: self.name.decrypt_with_key(key).ok().unwrap_or_default(), sub_title: self.get_decrypted_subtitle(key).ok().unwrap_or_default(), r#type: match self.r#type { @@ -520,6 +547,7 @@ impl KeyDecryptable for Cipher { .ok_or(CryptoError::MissingField("login"))?; CipherListViewType::Login { has_fido2: login.fido2_credentials.is_some(), + totp: login.totp.clone(), } } CipherType::SecureNote => CipherListViewType::SecureNote, @@ -560,6 +588,15 @@ impl LocateKey for CipherView { enc.get_key(&self.organization_id) } } +impl LocateKey for CipherListView { + fn locate_key<'a>( + &self, + enc: &'a dyn KeyContainer, + _: &Option, + ) -> Result<&'a SymmetricCryptoKey, CryptoError> { + enc.get_key(&self.organization_id) + } +} impl TryFrom for Cipher { type Error = VaultParseError; @@ -709,7 +746,7 @@ mod tests { password: Some("2.M7ZJ7EuFDXCq66gDTIyRIg==|B1V+jroo6+m/dpHx6g8DxA==|PIXPBCwyJ1ady36a7jbcLg346pm/7N/06W4UZxc1TUo=".parse().unwrap()), password_revision_date: None, uris: None, - totp: None, + totp: Some("2.hqdioUAc81FsKQmO1XuLQg==|oDRdsJrQjoFu9NrFVy8tcJBAFKBx95gHaXZnWdXbKpsxWnOr2sKipIG43pKKUFuq|3gKZMiboceIB5SLVOULKg2iuyu6xzos22dfJbvx0EHk=".parse().unwrap()), autofill_on_page_load: None, fido2_credentials: Some(vec![generate_fido2(&key)]), }), @@ -739,9 +776,13 @@ mod tests { organization_id: cipher.organization_id, folder_id: cipher.folder_id, collection_ids: cipher.collection_ids, + key: cipher.key, name: "My test login".to_string(), sub_title: "test_username".to_string(), - r#type: CipherListViewType::Login { has_fido2: true }, + r#type: CipherListViewType::Login { + has_fido2: true, + totp: cipher.login.as_ref().unwrap().totp.clone() + }, favorite: cipher.favorite, reprompt: cipher.reprompt, edit: cipher.edit, diff --git a/crates/bitwarden-vault/src/client_totp.rs b/crates/bitwarden-vault/src/client_totp.rs index da1329125..6425b72eb 100644 --- a/crates/bitwarden-vault/src/client_totp.rs +++ b/crates/bitwarden-vault/src/client_totp.rs @@ -1,6 +1,8 @@ use chrono::{DateTime, Utc}; -use crate::{generate_totp, ClientVault, TotpError, TotpResponse}; +use crate::{ + generate_totp, generate_totp_cipher_view, CipherListView, ClientVault, TotpError, TotpResponse, +}; impl<'a> ClientVault<'a> { /// Generate a TOTP code from a provided key. @@ -16,4 +18,15 @@ impl<'a> ClientVault<'a> { ) -> Result { generate_totp(key, time) } + + /// Generate a TOTP code from a provided cipher list view. + pub fn generate_totp_cipher_view( + &'a self, + view: CipherListView, + time: Option>, + ) -> Result { + let enc = self.client.internal.get_encryption_settings()?; + + generate_totp_cipher_view(&enc, view, time) + } } diff --git a/crates/bitwarden-vault/src/lib.rs b/crates/bitwarden-vault/src/lib.rs index 8a65f021d..70524bb20 100644 --- a/crates/bitwarden-vault/src/lib.rs +++ b/crates/bitwarden-vault/src/lib.rs @@ -14,7 +14,7 @@ pub use password_history::{PasswordHistory, PasswordHistoryView}; mod domain; pub use domain::GlobalDomains; mod totp; -pub use totp::{generate_totp, TotpError, TotpResponse}; +pub use totp::{generate_totp, generate_totp_cipher_view, TotpError, TotpResponse}; mod error; pub use error::VaultParseError; mod client_vault; diff --git a/crates/bitwarden-vault/src/totp.rs b/crates/bitwarden-vault/src/totp.rs index d17820bee..8aee3e694 100644 --- a/crates/bitwarden-vault/src/totp.rs +++ b/crates/bitwarden-vault/src/totp.rs @@ -1,5 +1,7 @@ use std::{collections::HashMap, str::FromStr}; +use bitwarden_core::VaultLocked; +use bitwarden_crypto::{CryptoError, KeyContainer}; use chrono::{DateTime, Utc}; use hmac::{Hmac, Mac}; use reqwest::Url; @@ -7,6 +9,8 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use thiserror::Error; +use crate::CipherListView; + type HmacSha1 = Hmac; type HmacSha256 = Hmac; type HmacSha512 = Hmac; @@ -24,6 +28,11 @@ pub enum TotpError { InvalidOtpauth, #[error("Missing secret")] MissingSecret, + + #[error(transparent)] + CryptoError(#[from] CryptoError), + #[error(transparent)] + VaultLocked(#[from] VaultLocked), } #[derive(Serialize, Deserialize, Debug, JsonSchema)] @@ -63,6 +72,19 @@ pub fn generate_totp(key: String, time: Option>) -> Result>, +) -> Result { + let key = view.get_totp_key(enc)?.ok_or(TotpError::MissingSecret)?; + + generate_totp(key, time) +} + #[derive(Clone, Copy, Debug)] enum Algorithm { Sha1, @@ -237,9 +259,12 @@ fn decode_b32(s: &str) -> Vec { #[cfg(test)] mod tests { + use bitwarden_crypto::{CryptoError, SymmetricCryptoKey}; use chrono::Utc; + use uuid::Uuid; use super::*; + use crate::{cipher::cipher::CipherListViewType, CipherRepromptType}; #[test] fn test_decode_b32() { @@ -309,4 +334,48 @@ mod tests { assert_eq!(response.code, "730364".to_string()); assert_eq!(response.period, 60); } + + #[test] + fn test_generate_totp_cipher_view() { + let view = CipherListView { + id: Some("090c19ea-a61a-4df6-8963-262b97bc6266".parse().unwrap()), + organization_id: None, + folder_id: None, + collection_ids: vec![], + key: None, + name: "My test login".to_string(), + sub_title: "test_username".to_string(), + r#type: CipherListViewType::Login { + has_fido2: true, + totp: Some("2.hqdioUAc81FsKQmO1XuLQg==|oDRdsJrQjoFu9NrFVy8tcJBAFKBx95gHaXZnWdXbKpsxWnOr2sKipIG43pKKUFuq|3gKZMiboceIB5SLVOULKg2iuyu6xzos22dfJbvx0EHk=".parse().unwrap()), + }, + favorite: false, + reprompt: CipherRepromptType::None, + edit: true, + view_password: true, + attachments: 0, + creation_date: "2024-01-30T17:55:36.150Z".parse().unwrap(), + deleted_date: None, + revision_date: "2024-01-30T17:55:36.150Z".parse().unwrap(), + }; + + struct MockKeyContainer(SymmetricCryptoKey); + impl KeyContainer for MockKeyContainer { + fn get_key<'a>( + &'a self, + _: &Option, + ) -> Result<&'a SymmetricCryptoKey, CryptoError> { + Ok(&self.0) + } + } + + let enc = MockKeyContainer("w2LO+nwV4oxwswVYCxlOfRUseXfvU03VzvKQHrqeklPgiMZrspUe6sOBToCnDn9Ay0tuCBn8ykVVRb7PWhub2Q==".to_string().try_into().unwrap()); + let time = DateTime::parse_from_rfc3339("2023-01-01T00:00:00.000Z") + .unwrap() + .with_timezone(&Utc); + + let response = generate_totp_cipher_view(&enc, view, Some(time)).unwrap(); + assert_eq!(response.code, "559388".to_string()); + assert_eq!(response.period, 30); + } } From 25fa86604ea1669d6dafefaef06572d2a1fcda5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Fri, 2 Aug 2024 13:29:52 +0200 Subject: [PATCH 085/214] Use Arc::make_mut to try to avoid unnecessary clones (#929) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📔 Objective Just discovered that [`Arc::make_mut`](https://doc.rust-lang.org/std/sync/struct.Arc.html#method.make_mut) exists, and it will reuse the `Arc` if it's the only strong reference to it, or clone it if there's more. Previously we were always cloning the value, so this should help avoid some clones, as I don't expect any references to these arcs to be held long. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-core/src/client/internal.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/crates/bitwarden-core/src/client/internal.rs b/crates/bitwarden-core/src/client/internal.rs index ee62c9ee5..199e35459 100644 --- a/crates/bitwarden-core/src/client/internal.rs +++ b/crates/bitwarden-core/src/client/internal.rs @@ -113,11 +113,9 @@ impl InternalClient { .write() .expect("RwLock is not poisoned"); - let mut inner: ApiConfigurations = guard.as_ref().clone(); + let inner = Arc::make_mut(&mut guard); inner.identity.oauth_access_token = Some(token.clone()); inner.api.oauth_access_token = Some(token); - - *guard = Arc::new(inner); } #[cfg(feature = "internal")] @@ -244,12 +242,9 @@ impl InternalClient { return Err(VaultLocked.into()); }; - let mut enc: EncryptionSettings = enc.as_ref().clone(); - enc.set_org_keys(org_keys)?; - let enc = Arc::new(enc); - - *guard = Some(enc.clone()); + let inner = Arc::make_mut(enc); + inner.set_org_keys(org_keys)?; - Ok(enc) + Ok(enc.clone()) } } From b8a024f837a65338e9b6a1f0103a0dfe4ba85632 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 2 Aug 2024 14:33:54 +0200 Subject: [PATCH 086/214] [deps]: Lock file maintenance (#933) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. đŸ‘ģ **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 232 +++++++++++++--------- crates/bitwarden-napi/package-lock.json | 20 +- languages/js/example/package-lock.json | 2 +- languages/js/sdk-client/package-lock.json | 12 +- package-lock.json | 38 ++-- 5 files changed, 170 insertions(+), 134 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e0e43998f..74c2911f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -87,9 +87,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.14" +version = "0.6.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" dependencies = [ "anstyle", "anstyle-parse", @@ -102,33 +102,33 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" +checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" [[package]] name = "anstyle-parse" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" dependencies = [ "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.3" +version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" dependencies = [ "anstyle", "windows-sys 0.52.0", @@ -713,9 +713,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.9.1" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" +checksum = "40723b8fb387abc38f4f4a37c09073622e41dd12327033091ef8950659e6dc0c" dependencies = [ "memchr", "serde", @@ -767,15 +767,15 @@ dependencies = [ "tempfile", "thiserror", "tokio", - "toml 0.8.15", + "toml 0.8.19", "uuid", ] [[package]] name = "bytemuck" -version = "1.16.1" +version = "1.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" +checksum = "102087e286b4677862ea56cf8fc58bb2cdfa8725c40ffb80fe3a008eb7f2fc83" [[package]] name = "byteorder" @@ -785,9 +785,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.1" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" +checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" [[package]] name = "bytesize" @@ -844,9 +844,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.6" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" +checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" [[package]] name = "cesu8" @@ -915,9 +915,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.9" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" +checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" dependencies = [ "clap_builder", "clap_derive", @@ -925,9 +925,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.9" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" +checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" dependencies = [ "anstream", "anstyle", @@ -937,18 +937,18 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.8" +version = "4.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b4be9c4c4b1f30b78d8a750e0822b6a6102d97e62061c583a6c1dea2dfb33ae" +checksum = "a8670053e87c316345e384ca1f3eba3006fc6355ed8b8a1140d104e109e3df34" dependencies = [ "clap", ] [[package]] name = "clap_derive" -version = "4.5.8" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" +checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -958,15 +958,15 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" +checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "clap_mangen" -version = "0.2.22" +version = "0.2.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f50dde5bc0c853d6248de457e5eb6e5a674a54b93810a34ded88d882ca1fe2de" +checksum = "f17415fd4dfbea46e3274fcd8d368284519b358654772afb700dc2e8d2b24eeb" dependencies = [ "clap", "roff", @@ -1013,9 +1013,9 @@ dependencies = [ [[package]] name = "colorchoice" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" +checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" [[package]] name = "combine" @@ -1115,9 +1115,9 @@ checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "coset" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff8aad850c1f86daa47e812913051eb5a26c4d9fb4242a89178bf99b946e4e3c" +checksum = "f4c8cc80f631f8307b887faca24dcc3abc427cd0367f6eb6188f6e8f5b7ad8fb" dependencies = [ "ciborium", "ciborium-io", @@ -1211,7 +1211,7 @@ dependencies = [ "bitflags 1.3.2", "crossterm_winapi", "libc", - "mio", + "mio 0.8.11", "parking_lot", "signal-hook", "signal-hook-mio", @@ -1522,9 +1522,9 @@ dependencies = [ [[package]] name = "env_filter" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a009aa4810eb158359dda09d0c87378e4bbb89b5a801f016885a4707ba24f7ea" +checksum = "4f2c92ceda6ceec50f43169f9ee8424fe2db276791afde7b2cd8bc084cb376ab" dependencies = [ "log", "regex", @@ -1532,9 +1532,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.3" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38b35839ba51819680ba087cd351788c9a3c476841207e0b8cee0b04722343b9" +checksum = "e13fa619b91fb2381732789fc5de83b45675e882f66623b7d8cb4f643017018d" dependencies = [ "anstream", "anstyle", @@ -1820,7 +1820,7 @@ dependencies = [ "futures-core", "futures-sink", "http", - "indexmap 2.2.6", + "indexmap 2.3.0", "slab", "tokio", "tokio-util", @@ -2069,9 +2069,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.2.6" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -2136,9 +2136,9 @@ checksum = "7655c9839580ee829dfacba1d1278c2b7883e50a277ff7541299489d6bdfdc45" [[package]] name = "is_terminal_polyfill" -version = "1.70.0" +version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" [[package]] name = "itertools" @@ -2326,6 +2326,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mio" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" +dependencies = [ + "hermit-abi", + "libc", + "wasi", + "windows-sys 0.52.0", +] + [[package]] name = "napi" version = "2.16.8" @@ -2348,9 +2360,9 @@ checksum = "e1c0f5d67ee408a4685b61f5ab7e58605c8ae3f2b4189f0127d804ff13d5560a" [[package]] name = "napi-derive" -version = "2.16.9" +version = "2.16.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87c3b5d4ab13e20a4bb9d3a1e2f3d4e77eee4a205d0f810abfd226b971dc6ce5" +checksum = "b13934cae1f98599ae96d461d14ce3a9199215de1e9a9a201b64b118b3dfa329" dependencies = [ "cfg-if", "convert_case", @@ -2362,9 +2374,9 @@ dependencies = [ [[package]] name = "napi-derive-backend" -version = "1.0.71" +version = "1.0.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96de436a6ab93265beef838f8333c8345438f059df6081fe0ad0b8648ee0c524" +checksum = "632d41c6057955f455824a7585ce19bc69b2c83472d16581e8f0175fcf4759b7" dependencies = [ "convert_case", "once_cell", @@ -2647,7 +2659,7 @@ dependencies = [ "coset", "data-encoding", "getrandom", - "indexmap 2.2.6", + "indexmap 2.3.0", "rand", "serde", "serde_json", @@ -2777,7 +2789,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" dependencies = [ "base64 0.22.1", - "indexmap 2.2.6", + "indexmap 2.3.0", "quick-xml", "serde", "time", @@ -2825,9 +2837,12 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" +checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f" +dependencies = [ + "zerocopy", +] [[package]] name = "primeorder" @@ -2995,9 +3010,9 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25a78e6f726d84fcf960409f509ae354a32648f090c8d32a2ea8b1a1bc3bab14" +checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" dependencies = [ "libc", "once_cell", @@ -3193,9 +3208,9 @@ dependencies = [ [[package]] name = "roff" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316" +checksum = "88f8660c1ff60292143c98d08fc6e2f654d722db50410e3f3797d40baaf9d8f3" [[package]] name = "rsa" @@ -3244,9 +3259,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.11" +version = "0.23.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4828ea528154ae444e5a642dbb7d5623354030dc9822b83fd9bb79683c7399d0" +checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" dependencies = [ "once_cell", "ring", @@ -3287,9 +3302,9 @@ checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" [[package]] name = "rustls-platform-verifier" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e3beb939bcd33c269f4bf946cc829fcd336370267c4a927ac0399c84a3151a1" +checksum = "93bda3f493b9abe5b93b3e7e3ecde0df292f2bd28c0296b90586ee0055ff5123" dependencies = [ "core-foundation", "core-foundation-sys", @@ -3308,15 +3323,15 @@ dependencies = [ [[package]] name = "rustls-platform-verifier-android" -version = "0.1.0" +version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84e217e7fdc8466b5b35d30f8c0a30febd29173df4a3a0c2115d306b9c4117ad" +checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" [[package]] name = "rustls-webpki" -version = "0.102.5" +version = "0.102.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a6fccd794a42c2c105b513a2f62bc3fd8f3ba57a4593677ceb0bd035164d78" +checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" dependencies = [ "ring", "rustls-pki-types", @@ -3506,12 +3521,13 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.3.0", "itoa", + "memchr", "ryu", "serde", ] @@ -3540,9 +3556,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.6" +version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" +checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] @@ -3569,7 +3585,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.2.6", + "indexmap 2.3.0", "serde", "serde_derive", "serde_json", @@ -3595,7 +3611,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.3.0", "itoa", "ryu", "serde", @@ -3655,12 +3671,12 @@ dependencies = [ [[package]] name = "signal-hook-mio" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" +checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" dependencies = [ "libc", - "mio", + "mio 0.8.11", "signal-hook", ] @@ -3859,9 +3875,9 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.15" +version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4873307b7c257eddcb50c9bedf158eb669578359fb28428bef438fec8e6ba7c2" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" @@ -3972,26 +3988,25 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.1" +version = "1.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" +checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" dependencies = [ "backtrace", "bytes", "libc", - "mio", - "num_cpus", + "mio 1.0.1", "pin-project-lite", "socket2", "tokio-macros", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", @@ -4033,9 +4048,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.15" +version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac2caab0bf757388c6c0ae23b3293fdb463fee59434529014f85e3263b995c28" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ "serde", "serde_spanned", @@ -4045,20 +4060,20 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.6" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.22.16" +version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "278f3d518e152219c994ce877758516bca5e118eaed6996192a774fb9fbf0788" +checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.2.6", + "indexmap 2.3.0", "serde", "serde_spanned", "toml_datetime", @@ -4421,9 +4436,9 @@ checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" [[package]] name = "version_check" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "walkdir" @@ -4752,9 +4767,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.14" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374ec40a2d767a3c1b4972d9475ecd557356637be906f2cb3f7fe17a6eb5e22f" +checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" dependencies = [ "memchr", ] @@ -4793,6 +4808,27 @@ dependencies = [ "url", ] +[[package]] +name = "zerocopy" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.72", +] + [[package]] name = "zeroize" version = "1.8.1" @@ -4816,13 +4852,13 @@ dependencies = [ [[package]] name = "zxcvbn" -version = "3.0.1" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579b1d84df61d9d04cd250035843fee2f86a4b4bb176f102fec20779fd0bd38b" +checksum = "ad76e35b00ad53688d6b90c431cabe3cbf51f7a4a154739e04b63004ab1c736c" dependencies = [ + "chrono", "derive_builder", "fancy-regex", - "getrandom", "itertools 0.13.0", "lazy_static", "regex", diff --git a/crates/bitwarden-napi/package-lock.json b/crates/bitwarden-napi/package-lock.json index 7047a2457..641733b1a 100644 --- a/crates/bitwarden-napi/package-lock.json +++ b/crates/bitwarden-napi/package-lock.json @@ -104,14 +104,14 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "20.14.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.11.tgz", - "integrity": "sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==", + "version": "22.0.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.3.tgz", + "integrity": "sha512-/e0NZtK2gs6Vk2DoyrXSZZ4AlamqTkx0CcKx1Aq8/P4ITlRgU9OtVf5fl+LXkWWJce1M89pkSlH6lJJEnK7bQA==", "dev": true, "license": "MIT", "peer": true, "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~6.11.1" } }, "node_modules/acorn": { @@ -216,9 +216,9 @@ } }, "node_modules/typescript": { - "version": "5.5.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", - "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "dev": true, "license": "Apache-2.0", "bin": { @@ -230,9 +230,9 @@ } }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "version": "6.11.1", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.11.1.tgz", + "integrity": "sha512-mIDEX2ek50x0OlRgxryxsenE5XaQD4on5U2inY7RApK3SOJpofyw7uW2AyfMKkhAxXIceo2DeWGVGwyvng1GNQ==", "dev": true, "license": "MIT", "peer": true diff --git a/languages/js/example/package-lock.json b/languages/js/example/package-lock.json index bff8fb2c2..82ac79b5a 100644 --- a/languages/js/example/package-lock.json +++ b/languages/js/example/package-lock.json @@ -14,7 +14,7 @@ "name": "@bitwarden/sdk-client", "devDependencies": { "@types/node": "^18.15.11", - "rimraf": "^5.0.0", + "rimraf": "^6.0.0", "typescript": "^5.0.3" } }, diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index 40e80aca6..987aa992c 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -41,9 +41,9 @@ } }, "node_modules/@types/node": { - "version": "18.19.41", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.41.tgz", - "integrity": "sha512-LX84pRJ+evD2e2nrgYCHObGWkiQJ1mL+meAgbvnwk/US6vmMY7S2ygBTGV2Jw91s9vUsLSXeDEkUHZIJGLrhsg==", + "version": "18.19.43", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.43.tgz", + "integrity": "sha512-Mw/YlgXnyJdEwLoFv2dpuJaDFriX+Pc+0qOBJ57jC1H6cDxIj2xc5yUrdtArDVG0m+KV6622a4p2tenEqB3C/g==", "dev": true, "license": "MIT", "dependencies": { @@ -450,9 +450,9 @@ } }, "node_modules/typescript": { - "version": "5.5.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", - "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/package-lock.json b/package-lock.json index 3483f5930..5e29e7a96 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,9 +19,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.24.8", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.8.tgz", - "integrity": "sha512-5F7SDGs1T72ZczbRwbGO9lQi0NLjQxzl6i4lJxLxfW9U5UluCSyEJeniWvnhl3/euNiqQVbo8zruhsDfid0esA==", + "version": "7.25.0", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.0.tgz", + "integrity": "sha512-7dRy4DwXwtzBrPbZflqxnvfxLF8kdZXPkhymtDeFoFqE6ldzjQFgYTtYIFARcLEYDrqfBfYcZt1WqFxRoyC9Rw==", "dev": true, "license": "MIT", "dependencies": { @@ -370,14 +370,14 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "20.14.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.11.tgz", - "integrity": "sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==", + "version": "22.0.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.3.tgz", + "integrity": "sha512-/e0NZtK2gs6Vk2DoyrXSZZ4AlamqTkx0CcKx1Aq8/P4ITlRgU9OtVf5fl+LXkWWJce1M89pkSlH6lJJEnK7bQA==", "dev": true, "license": "MIT", "peer": true, "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~6.11.1" } }, "node_modules/abort-controller": { @@ -876,9 +876,9 @@ } }, "node_modules/debug": { - "version": "4.3.5", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", - "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", + "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", "dev": true, "license": "MIT", "dependencies": { @@ -2173,9 +2173,9 @@ } }, "node_modules/uglify-js": { - "version": "3.19.0", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.0.tgz", - "integrity": "sha512-wNKHUY2hYYkf6oSFfhwwiHo4WCHzHmzcXsqXYTN9ja3iApYIFbb2U6ics9hBcYLHcYGQoAlwnZlTrf3oF+BL/Q==", + "version": "3.19.1", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.1.tgz", + "integrity": "sha512-y/2wiW+ceTYR2TSSptAhfnEtpLaQ4Ups5zrjB2d3kuVxHj16j/QJwPl5PvuGy9uARb39J0+iKxcRPvtpsx4A4A==", "dev": true, "license": "BSD-2-Clause", "optional": true, @@ -2200,9 +2200,9 @@ } }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "version": "6.11.1", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.11.1.tgz", + "integrity": "sha512-mIDEX2ek50x0OlRgxryxsenE5XaQD4on5U2inY7RApK3SOJpofyw7uW2AyfMKkhAxXIceo2DeWGVGwyvng1GNQ==", "dev": true, "license": "MIT", "peer": true @@ -2370,9 +2370,9 @@ } }, "node_modules/yaml": { - "version": "2.4.5", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.5.tgz", - "integrity": "sha512-aBx2bnqDzVOyNKfsysjA2ms5ZlnjSAW2eG3/L5G/CSujfjLJTJsEw1bGw8kCf04KodQWk1pxlGnZ56CRxiawmg==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz", + "integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==", "dev": true, "license": "ISC", "bin": { From 6e65f972ceff5a87e626ead97df5989fcd15cfa7 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Thu, 8 Aug 2024 10:02:29 -0400 Subject: [PATCH 087/214] [SM-1399] Update the README for Windows on ARM (#942) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1399 ## 📔 Objective Just `cargo build` is not sufficient for building the SDK on Windows on ARM. We should add clarity to what is required so that `cargo build` will run successfully. Python is required. Clang is also required for [ring](https://crates.io/crates/ring) (more info [here](https://github.com/briansmith/ring/blob/main/BUILDING.md)). ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index ed3093448..497af6547 100644 --- a/README.md +++ b/README.md @@ -20,10 +20,21 @@ are currently open as well as what it's like to work at Bitwarden. ## Getting Started +### Linux / Mac / Windows + ```bash cargo build ``` +### Windows on ARM + +To build, you will need the following in your PATH: + +- [Python](https://www.python.org) +- [Clang](https://clang.llvm.org) + - We recommend installing this via the + [Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) + ## Crates The project is structured as a monorepo using cargo workspaces. Some of the more noteworthy crates From 3621c25f773b56b85bb6e4bc58fa3846ac6ea361 Mon Sep 17 00:00:00 2001 From: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com> Date: Thu, 8 Aug 2024 10:21:57 -0500 Subject: [PATCH 088/214] [SM-1394] Update NAPI language bindings (#934) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1394 ## 📔 Objective The objective of this PR is to get NAPI language bindings in sync with latest SDK/schema changes. This includes adding a project client, state file support, and updating the secret client. --- crates/bitwarden-napi/README.md | 5 +- crates/bitwarden-napi/binding.d.ts | 2 +- crates/bitwarden-napi/binding.js | 76 ++++++- crates/bitwarden-napi/package-lock.json | 211 +----------------- crates/bitwarden-napi/package.json | 5 +- .../src-ts/bitwarden_client/index.ts | 173 ++++++++++---- 6 files changed, 210 insertions(+), 262 deletions(-) diff --git a/crates/bitwarden-napi/README.md b/crates/bitwarden-napi/README.md index d9e3e7f27..e9c3d0a71 100644 --- a/crates/bitwarden-napi/README.md +++ b/crates/bitwarden-napi/README.md @@ -21,10 +21,7 @@ const accessToken = "-- REDACTED --"; const client = new BitwardenClient(settings, LogLevel.Info); // Authenticating using a machine account access token -const result = await client.loginWithAccessToken(accessToken); -if (!result.success) { - throw Error("Authentication failed"); -} +await client.accessTokenLogin(accessToken); // List secrets const secrets = await client.secrets().list(); diff --git a/crates/bitwarden-napi/binding.d.ts b/crates/bitwarden-napi/binding.d.ts index 50ec34289..174d33d92 100644 --- a/crates/bitwarden-napi/binding.d.ts +++ b/crates/bitwarden-napi/binding.d.ts @@ -10,7 +10,7 @@ export const enum LogLevel { Warn = 3, Error = 4, } -export class BitwardenClient { +export declare class BitwardenClient { constructor(settingsInput?: string | undefined | null, logLevel?: LogLevel | undefined | null); runCommand(commandInput: string): Promise; } diff --git a/crates/bitwarden-napi/binding.js b/crates/bitwarden-napi/binding.js index c3cf32037..3da97e8f9 100644 --- a/crates/bitwarden-napi/binding.js +++ b/crates/bitwarden-napi/binding.js @@ -1,4 +1,10 @@ -const { existsSync, readFileSync } = require("fs"); +/* tslint:disable */ +/* eslint-disable */ +/* prettier-ignore */ + +/* auto-generated by NAPI-RS */ + +const { existsSync, readFileSync } = require('fs') const { join } = require("path"); const { platform, arch } = process; @@ -11,7 +17,8 @@ function isMusl() { // For Node 10 if (!process.report || typeof process.report.getReport !== "function") { try { - return readFileSync("/usr/bin/ldd", "utf8").includes("musl"); + const lddPath = require("child_process").execSync("which ldd").toString().trim(); + return readFileSync(lddPath, "utf8").includes("musl"); } catch (e) { return true; } @@ -95,6 +102,15 @@ switch (platform) { } break; case "darwin": + localFileExisted = existsSync(join(__dirname, "sdk-napi.darwin-universal.node")); + try { + if (localFileExisted) { + nativeBinding = require("./sdk-napi.darwin-universal.node"); + } else { + nativeBinding = require("@bitwarden/sdk-napi-darwin-universal"); + } + break; + } catch {} switch (arch) { case "x64": localFileExisted = existsSync(join(__dirname, "sdk-napi.darwin-x64.node")); @@ -192,12 +208,62 @@ switch (platform) { } break; case "arm": - localFileExisted = existsSync(join(__dirname, "sdk-napi.linux-arm-gnueabihf.node")); + if (isMusl()) { + localFileExisted = existsSync(join(__dirname, "sdk-napi.linux-arm-musleabihf.node")); + try { + if (localFileExisted) { + nativeBinding = require("./sdk-napi.linux-arm-musleabihf.node"); + } else { + nativeBinding = require("@bitwarden/sdk-napi-linux-arm-musleabihf"); + } + } catch (e) { + loadError = e; + } + } else { + localFileExisted = existsSync(join(__dirname, "sdk-napi.linux-arm-gnueabihf.node")); + try { + if (localFileExisted) { + nativeBinding = require("./sdk-napi.linux-arm-gnueabihf.node"); + } else { + nativeBinding = require("@bitwarden/sdk-napi-linux-arm-gnueabihf"); + } + } catch (e) { + loadError = e; + } + } + break; + case "riscv64": + if (isMusl()) { + localFileExisted = existsSync(join(__dirname, "sdk-napi.linux-riscv64-musl.node")); + try { + if (localFileExisted) { + nativeBinding = require("./sdk-napi.linux-riscv64-musl.node"); + } else { + nativeBinding = require("@bitwarden/sdk-napi-linux-riscv64-musl"); + } + } catch (e) { + loadError = e; + } + } else { + localFileExisted = existsSync(join(__dirname, "sdk-napi.linux-riscv64-gnu.node")); + try { + if (localFileExisted) { + nativeBinding = require("./sdk-napi.linux-riscv64-gnu.node"); + } else { + nativeBinding = require("@bitwarden/sdk-napi-linux-riscv64-gnu"); + } + } catch (e) { + loadError = e; + } + } + break; + case "s390x": + localFileExisted = existsSync(join(__dirname, "sdk-napi.linux-s390x-gnu.node")); try { if (localFileExisted) { - nativeBinding = require("./sdk-napi.linux-arm-gnueabihf.node"); + nativeBinding = require("./sdk-napi.linux-s390x-gnu.node"); } else { - nativeBinding = require("@bitwarden/sdk-napi-linux-arm-gnueabihf"); + nativeBinding = require("@bitwarden/sdk-napi-linux-s390x-gnu"); } } catch (e) { loadError = e; diff --git a/crates/bitwarden-napi/package-lock.json b/crates/bitwarden-napi/package-lock.json index 641733b1a..8082a7a80 100644 --- a/crates/bitwarden-napi/package-lock.json +++ b/crates/bitwarden-napi/package-lock.json @@ -9,55 +9,13 @@ "version": "0.3.1", "license": "SEE LICENSE IN LICENSE", "devDependencies": { - "@napi-rs/cli": "^2.13.2", - "ts-node": "10.9.2", - "typescript": "^5.0.0" + "@napi-rs/cli": "2.18.4", + "typescript": "5.5.4" }, "engines": { "node": ">= 10" } }, - "node_modules/@cspotcode/source-map-support": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", - "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/trace-mapping": "0.3.9" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", - "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", - "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/resolve-uri": "^3.0.3", - "@jridgewell/sourcemap-codec": "^1.4.10" - } - }, "node_modules/@napi-rs/cli": { "version": "2.18.4", "resolved": "https://registry.npmjs.org/@napi-rs/cli/-/cli-2.18.4.tgz", @@ -75,146 +33,6 @@ "url": "https://github.com/sponsors/Brooooooklyn" } }, - "node_modules/@tsconfig/node10": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", - "integrity": "sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node12": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", - "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node14": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", - "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tsconfig/node16": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", - "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/node": { - "version": "22.0.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.3.tgz", - "integrity": "sha512-/e0NZtK2gs6Vk2DoyrXSZZ4AlamqTkx0CcKx1Aq8/P4ITlRgU9OtVf5fl+LXkWWJce1M89pkSlH6lJJEnK7bQA==", - "dev": true, - "license": "MIT", - "peer": true, - "dependencies": { - "undici-types": "~6.11.1" - } - }, - "node_modules/acorn": { - "version": "8.12.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", - "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", - "dev": true, - "license": "MIT", - "bin": { - "acorn": "bin/acorn" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/acorn-walk": { - "version": "8.3.3", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz", - "integrity": "sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==", - "dev": true, - "license": "MIT", - "dependencies": { - "acorn": "^8.11.0" - }, - "engines": { - "node": ">=0.4.0" - } - }, - "node_modules/arg": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", - "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true, - "license": "MIT" - }, - "node_modules/create-require": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", - "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/diff": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.2.tgz", - "integrity": "sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.3.1" - } - }, - "node_modules/make-error": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", - "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true, - "license": "ISC" - }, - "node_modules/ts-node": { - "version": "10.9.2", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", - "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@cspotcode/source-map-support": "^0.8.0", - "@tsconfig/node10": "^1.0.7", - "@tsconfig/node12": "^1.0.7", - "@tsconfig/node14": "^1.0.0", - "@tsconfig/node16": "^1.0.2", - "acorn": "^8.4.1", - "acorn-walk": "^8.1.1", - "arg": "^4.1.0", - "create-require": "^1.1.0", - "diff": "^4.0.1", - "make-error": "^1.1.1", - "v8-compile-cache-lib": "^3.0.1", - "yn": "3.1.1" - }, - "bin": { - "ts-node": "dist/bin.js", - "ts-node-cwd": "dist/bin-cwd.js", - "ts-node-esm": "dist/bin-esm.js", - "ts-node-script": "dist/bin-script.js", - "ts-node-transpile-only": "dist/bin-transpile.js", - "ts-script": "dist/bin-script-deprecated.js" - }, - "peerDependencies": { - "@swc/core": ">=1.2.50", - "@swc/wasm": ">=1.2.50", - "@types/node": "*", - "typescript": ">=2.7" - }, - "peerDependenciesMeta": { - "@swc/core": { - "optional": true - }, - "@swc/wasm": { - "optional": true - } - } - }, "node_modules/typescript": { "version": "5.5.4", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", @@ -228,31 +46,6 @@ "engines": { "node": ">=14.17" } - }, - "node_modules/undici-types": { - "version": "6.11.1", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.11.1.tgz", - "integrity": "sha512-mIDEX2ek50x0OlRgxryxsenE5XaQD4on5U2inY7RApK3SOJpofyw7uW2AyfMKkhAxXIceo2DeWGVGwyvng1GNQ==", - "dev": true, - "license": "MIT", - "peer": true - }, - "node_modules/v8-compile-cache-lib": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", - "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true, - "license": "MIT" - }, - "node_modules/yn": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", - "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6" - } } } } diff --git a/crates/bitwarden-napi/package.json b/crates/bitwarden-napi/package.json index 509cf1763..9f1048d18 100644 --- a/crates/bitwarden-napi/package.json +++ b/crates/bitwarden-napi/package.json @@ -29,9 +29,8 @@ "version": "napi version" }, "devDependencies": { - "@napi-rs/cli": "^2.13.2", - "ts-node": "10.9.2", - "typescript": "^5.0.0" + "@napi-rs/cli": "2.18.4", + "typescript": "5.5.4" }, "engines": { "node": ">= 10" diff --git a/crates/bitwarden-napi/src-ts/bitwarden_client/index.ts b/crates/bitwarden-napi/src-ts/bitwarden_client/index.ts index eefbb1204..52a53ef4f 100644 --- a/crates/bitwarden-napi/src-ts/bitwarden_client/index.ts +++ b/crates/bitwarden-napi/src-ts/bitwarden_client/index.ts @@ -1,15 +1,34 @@ import * as rust from "../../binding"; import { LogLevel } from "../../binding"; import { - ClientSettings, Convert, - ResponseForAPIKeyLoginResponse, - ResponseForSecretIdentifiersResponse, - ResponseForSecretResponse, - ResponseForSecretsDeleteResponse, - ResponseForSecretsResponse, + ClientSettings, + ProjectResponse, + ProjectsDeleteResponse, + ProjectsResponse, + SecretIdentifiersResponse, + SecretResponse, + SecretsDeleteResponse, + SecretsResponse, + SecretsSyncResponse, } from "./schemas"; +function handleResponse(response: { + success: boolean; + errorMessage?: string | null; + data?: T | null; +}): T { + if (!response.success) { + throw new Error(response.errorMessage || ""); + } + + if (response.data === null) { + throw new Error(response.errorMessage || "SDK response data is null"); + } + + return response.data as T; +} + export class BitwardenClient { client: rust.BitwardenClient; @@ -18,34 +37,26 @@ export class BitwardenClient { this.client = new rust.BitwardenClient(settingsJson, loggingLevel ?? LogLevel.Info); } - async loginWithAccessToken(accessToken: string): Promise { - const commandInput = Convert.commandToJson({ - accessTokenLogin: { - accessToken: accessToken, - }, - }); - const response = await this.client.runCommand(commandInput); - - return Convert.toResponseForAPIKeyLoginResponse(response); - } - - /* - async sync(excludeSubdomains = false): Promise { + async accessTokenLogin(accessToken: string, stateFile?: string): Promise { const response = await this.client.runCommand( Convert.commandToJson({ - sync: { - excludeSubdomains, + accessTokenLogin: { + accessToken, + stateFile, }, - }) + }), ); - return Convert.toResponseForSyncResponse(response); + handleResponse(Convert.toResponseForAccessTokenLoginResponse(response)); } - */ secrets(): SecretsClient { return new SecretsClient(this.client); } + + projects(): ProjectsClient { + return new ProjectsClient(this.client); + } } export class SecretsClient { @@ -55,7 +66,7 @@ export class SecretsClient { this.client = client; } - async get(id: string): Promise { + async get(id: string): Promise { const response = await this.client.runCommand( Convert.commandToJson({ secrets: { @@ -64,10 +75,10 @@ export class SecretsClient { }), ); - return Convert.toResponseForSecretResponse(response); + return handleResponse(Convert.toResponseForSecretResponse(response)); } - async getByIds(ids: string[]): Promise { + async getByIds(ids: string[]): Promise { const response = await this.client.runCommand( Convert.commandToJson({ secrets: { @@ -76,27 +87,28 @@ export class SecretsClient { }), ); - return Convert.toResponseForSecretsResponse(response); + return handleResponse(Convert.toResponseForSecretsResponse(response)); } async create( key: string, + value: string, note: string, + projectIds: string[], organizationId: string, - value: string, - ): Promise { + ): Promise { const response = await this.client.runCommand( Convert.commandToJson({ secrets: { - create: { key, note, organizationId, value }, + create: { key, value, note, projectIds, organizationId }, }, }), ); - return Convert.toResponseForSecretResponse(response); + return handleResponse(Convert.toResponseForSecretResponse(response)); } - async list(organizationId: string): Promise { + async list(organizationId: string): Promise { const response = await this.client.runCommand( Convert.commandToJson({ secrets: { @@ -105,28 +117,29 @@ export class SecretsClient { }), ); - return Convert.toResponseForSecretIdentifiersResponse(response); + return handleResponse(Convert.toResponseForSecretIdentifiersResponse(response)); } async update( id: string, key: string, + value: string, note: string, + projectIds: string[], organizationId: string, - value: string, - ): Promise { + ): Promise { const response = await this.client.runCommand( Convert.commandToJson({ secrets: { - update: { id, key, note, organizationId, value }, + update: { id, key, value, note, projectIds, organizationId }, }, }), ); - return Convert.toResponseForSecretResponse(response); + return handleResponse(Convert.toResponseForSecretResponse(response)); } - async delete(ids: string[]): Promise { + async delete(ids: string[]): Promise { const response = await this.client.runCommand( Convert.commandToJson({ secrets: { @@ -135,6 +148,86 @@ export class SecretsClient { }), ); - return Convert.toResponseForSecretsDeleteResponse(response); + return handleResponse(Convert.toResponseForSecretsDeleteResponse(response)); + } + + async sync(organizationId: string, lastSyncedDate?: Date): Promise { + const response = await this.client.runCommand( + Convert.commandToJson({ + secrets: { + sync: { organizationId, lastSyncedDate }, + }, + }), + ); + + return handleResponse(Convert.toResponseForSecretsSyncResponse(response)); + } +} + +export class ProjectsClient { + client: rust.BitwardenClient; + + constructor(client: rust.BitwardenClient) { + this.client = client; + } + + async get(id: string): Promise { + const response = await this.client.runCommand( + Convert.commandToJson({ + projects: { + get: { id }, + }, + }), + ); + + return handleResponse(Convert.toResponseForProjectResponse(response)); + } + + async create(name: string, organizationId: string): Promise { + const response = await this.client.runCommand( + Convert.commandToJson({ + projects: { + create: { name, organizationId }, + }, + }), + ); + + return handleResponse(Convert.toResponseForProjectResponse(response)); + } + + async list(organizationId: string): Promise { + const response = await this.client.runCommand( + Convert.commandToJson({ + projects: { + list: { organizationId }, + }, + }), + ); + + return handleResponse(Convert.toResponseForProjectsResponse(response)); + } + + async update(id: string, name: string, organizationId: string): Promise { + const response = await this.client.runCommand( + Convert.commandToJson({ + projects: { + update: { id, name, organizationId }, + }, + }), + ); + + return handleResponse(Convert.toResponseForProjectResponse(response)); + } + + async delete(ids: string[]): Promise { + const response = await this.client.runCommand( + Convert.commandToJson({ + projects: { + delete: { ids }, + }, + }), + ); + + return handleResponse(Convert.toResponseForProjectsDeleteResponse(response)); } } From 8d89eea567ae1530d03c4a214d6f609d75c79306 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 11:35:04 +0200 Subject: [PATCH 089/214] [PM-10779] [deps]: Lock file maintenance (#946) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. đŸ‘ģ **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). [PM-10779](https://bitwarden.atlassian.net/browse/PM-10779) [PM-10779]: https://bitwarden.atlassian.net/browse/PM-10779?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 202 +++++++++++----------- languages/js/sdk-client/package-lock.json | 12 +- package-lock.json | 26 +-- 3 files changed, 120 insertions(+), 120 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 74c2911f0..195b01d12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -182,7 +182,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -231,7 +231,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -844,9 +844,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.7" +version = "1.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26a5c3fd7bfa1ce3897a3a3501d362b2d87b7f2583ebcb4a949ec25911025cbc" +checksum = "e9e8aabfac534be767c909e0690571677d49f41bd8465ae876fe043d52ba5292" [[package]] name = "cesu8" @@ -915,9 +915,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.13" +version = "4.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" +checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc" dependencies = [ "clap_builder", "clap_derive", @@ -925,9 +925,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.13" +version = "4.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" +checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" dependencies = [ "anstream", "anstyle", @@ -937,9 +937,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.12" +version = "4.5.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8670053e87c316345e384ca1f3eba3006fc6355ed8b8a1140d104e109e3df34" +checksum = "1d11bff0290e9a266fc9b4ce6fa96c2bf2ca3f9724c41c10202ac1daf7a087f8" dependencies = [ "clap", ] @@ -953,7 +953,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -1109,9 +1109,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.6" +version = "0.8.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "coset" @@ -1296,7 +1296,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -1320,7 +1320,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -1331,7 +1331,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -1410,7 +1410,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -1420,7 +1420,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -1598,9 +1598,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.30" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" dependencies = [ "crc32fast", "miniz_oxide", @@ -1686,7 +1686,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -1993,9 +1993,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.6" +version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956" +checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" dependencies = [ "bytes", "futures-channel", @@ -2328,9 +2328,9 @@ dependencies = [ [[package]] name = "mio" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" +checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ "hermit-abi", "libc", @@ -2340,9 +2340,9 @@ dependencies = [ [[package]] name = "napi" -version = "2.16.8" +version = "2.16.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1bd081bbaef43600fd2c5dd4c525b8ecea7dfdacf40ebc674e87851dce6559e" +checksum = "1277600d452e570cc83cf5f4e8efb389cc21e5cbefadcfba7239f4551e2e3e99" dependencies = [ "bitflags 2.6.0", "ctor", @@ -2360,23 +2360,23 @@ checksum = "e1c0f5d67ee408a4685b61f5ab7e58605c8ae3f2b4189f0127d804ff13d5560a" [[package]] name = "napi-derive" -version = "2.16.10" +version = "2.16.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b13934cae1f98599ae96d461d14ce3a9199215de1e9a9a201b64b118b3dfa329" +checksum = "150d87c4440b9f4815cb454918db498b5aae9a57aa743d20783fe75381181d01" dependencies = [ "cfg-if", "convert_case", "napi-derive-backend", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] name = "napi-derive-backend" -version = "1.0.72" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632d41c6057955f455824a7585ce19bc69b2c83472d16581e8f0175fcf4759b7" +checksum = "0cd81b794fc1d6051acf8c4f3cb4f82833b0621272a232b4ff0cf3df1dbddb61" dependencies = [ "convert_case", "once_cell", @@ -2384,7 +2384,7 @@ dependencies = [ "quote", "regex", "semver", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -2734,7 +2734,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -2837,9 +2837,9 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" -version = "0.2.18" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ "zerocopy", ] @@ -2949,7 +2949,7 @@ dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -2962,7 +2962,7 @@ dependencies = [ "proc-macro2", "pyo3-build-config", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -2976,9 +2976,9 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad" +checksum = "b22d8e7369034b9a7132bc2008cac12f2013c8132b45e0554e6e20e2617f2156" dependencies = [ "bytes", "pin-project-lite", @@ -2986,6 +2986,7 @@ dependencies = [ "quinn-udp", "rustc-hash", "rustls", + "socket2", "thiserror", "tokio", "tracing", @@ -2993,9 +2994,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.3" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe" +checksum = "ba92fb39ec7ad06ca2582c0ca834dfeadcaf06ddfc8e635c80aa7e1c05315fdd" dependencies = [ "bytes", "rand", @@ -3017,6 +3018,7 @@ dependencies = [ "libc", "once_cell", "socket2", + "tracing", "windows-sys 0.52.0", ] @@ -3101,9 +3103,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -3184,9 +3186,9 @@ dependencies = [ [[package]] name = "rgb" -version = "0.8.45" +version = "0.8.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade4539f42266ded9e755c605bdddf546242b2c961b03b06a7375260788a0523" +checksum = "0f86ae463694029097b846d8f99fd5536740602ae00022c0c50c5600720b2f71" dependencies = [ "bytemuck", ] @@ -3240,9 +3242,9 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustc-hash" -version = "1.1.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustix" @@ -3286,9 +3288,9 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d" +checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" dependencies = [ "base64 0.22.1", "rustls-pki-types", @@ -3296,9 +3298,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976295e77ce332211c0d24d92c0e83e50f5c5f046d11082cea19f3df13a3562d" +checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" [[package]] name = "rustls-platform-verifier" @@ -3392,7 +3394,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -3424,7 +3426,7 @@ checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -3490,22 +3492,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.204" +version = "1.0.206" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +checksum = "5b3e4cd94123dd520a128bcd11e34d9e9e423e7e3e50425cb1b4b1e3549d0284" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.204" +version = "1.0.206" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +checksum = "fabfb6138d2383ea8208cf98ccf69cdfb1aff4088460681d84189aa259762f97" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -3516,14 +3518,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] name = "serde_json" -version = "1.0.122" +version = "1.0.124" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" +checksum = "66ad62847a56b3dba58cc891acd13884b9c61138d330c0d7b6181713d4fce38d" dependencies = [ "indexmap 2.3.0", "itoa", @@ -3551,7 +3553,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -3602,7 +3604,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -3795,7 +3797,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -3808,7 +3810,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -3838,9 +3840,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.72" +version = "2.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc4b9b9bf2add8093d3f2c0204471e951b2285580335de42f9d2534f3ae7a8af" +checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7" dependencies = [ "proc-macro2", "quote", @@ -3881,14 +3883,15 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.10.1" +version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1" +checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand", + "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3917,7 +3920,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -3995,7 +3998,7 @@ dependencies = [ "backtrace", "bytes", "libc", - "mio 1.0.1", + "mio 1.0.2", "pin-project-lite", "socket2", "tokio-macros", @@ -4010,7 +4013,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -4114,21 +4117,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "pin-project-lite", - "tracing-attributes", "tracing-core", ] -[[package]] -name = "tracing-attributes" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.72", -] - [[package]] name = "tracing-core" version = "0.1.32" @@ -4278,7 +4269,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fcfa22f55829d3aaa7acfb1c5150224188fe0f27c59a8a3eddcaa24d1ffbe58" dependencies = [ "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -4310,7 +4301,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.72", + "syn 2.0.74", "toml 0.5.11", "uniffi_meta", ] @@ -4425,7 +4416,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -4488,7 +4479,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", "wasm-bindgen-shared", ] @@ -4522,7 +4513,7 @@ checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4555,7 +4546,7 @@ checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -4604,11 +4595,11 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -4644,6 +4635,15 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + [[package]] name = "windows-targets" version = "0.48.5" @@ -4810,9 +4810,9 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.6.6" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", "zerocopy-derive", @@ -4820,13 +4820,13 @@ dependencies = [ [[package]] name = "zerocopy-derive" -version = "0.6.6" +version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] @@ -4847,7 +4847,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.72", + "syn 2.0.74", ] [[package]] diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index 987aa992c..a7fb0db7d 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -41,9 +41,9 @@ } }, "node_modules/@types/node": { - "version": "18.19.43", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.43.tgz", - "integrity": "sha512-Mw/YlgXnyJdEwLoFv2dpuJaDFriX+Pc+0qOBJ57jC1H6cDxIj2xc5yUrdtArDVG0m+KV6622a4p2tenEqB3C/g==", + "version": "18.19.44", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.44.tgz", + "integrity": "sha512-ZsbGerYg72WMXUIE9fYxtvfzLEuq6q8mKERdWFnqTmOvudMxnz+CBNRoOwJ2kNpFOncrKjT1hZwxjlFgQ9qvQA==", "dev": true, "license": "MIT", "dependencies": { @@ -143,9 +143,9 @@ "license": "MIT" }, "node_modules/foreground-child": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.2.1.tgz", - "integrity": "sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", + "integrity": "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==", "dev": true, "license": "ISC", "dependencies": { diff --git a/package-lock.json b/package-lock.json index 5e29e7a96..f149905ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -370,14 +370,14 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.0.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.0.3.tgz", - "integrity": "sha512-/e0NZtK2gs6Vk2DoyrXSZZ4AlamqTkx0CcKx1Aq8/P4ITlRgU9OtVf5fl+LXkWWJce1M89pkSlH6lJJEnK7bQA==", + "version": "22.2.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.2.0.tgz", + "integrity": "sha512-bm6EG6/pCpkxDf/0gDNDdtDILMOHgaQBVOJGdwsqClnxA3xL6jtMv76rLBc006RVMWbmaf0xbmom4Z/5o2nRkQ==", "dev": true, "license": "MIT", "peer": true, "dependencies": { - "undici-types": "~6.11.1" + "undici-types": "~6.13.0" } }, "node_modules/abort-controller": { @@ -1050,9 +1050,9 @@ } }, "node_modules/foreground-child": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.2.1.tgz", - "integrity": "sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", + "integrity": "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==", "dev": true, "license": "ISC", "dependencies": { @@ -2173,9 +2173,9 @@ } }, "node_modules/uglify-js": { - "version": "3.19.1", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.1.tgz", - "integrity": "sha512-y/2wiW+ceTYR2TSSptAhfnEtpLaQ4Ups5zrjB2d3kuVxHj16j/QJwPl5PvuGy9uARb39J0+iKxcRPvtpsx4A4A==", + "version": "3.19.2", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.2.tgz", + "integrity": "sha512-S8KA6DDI47nQXJSi2ctQ629YzwOVs+bQML6DAtvy0wgNdpi+0ySpQK0g2pxBq2xfF2z3YCscu7NNA8nXT9PlIQ==", "dev": true, "license": "BSD-2-Clause", "optional": true, @@ -2200,9 +2200,9 @@ } }, "node_modules/undici-types": { - "version": "6.11.1", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.11.1.tgz", - "integrity": "sha512-mIDEX2ek50x0OlRgxryxsenE5XaQD4on5U2inY7RApK3SOJpofyw7uW2AyfMKkhAxXIceo2DeWGVGwyvng1GNQ==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.13.0.tgz", + "integrity": "sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==", "dev": true, "license": "MIT", "peer": true From 1a36b3bca945cd4f43006ff40b8006be1781263e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 12:12:33 +0200 Subject: [PATCH 090/214] [deps]: Update typescript to v5.5.4 (#949) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [typescript](https://www.typescriptlang.org/) ([source](https://togithub.com/Microsoft/TypeScript)) | [`5.3.3` -> `5.5.4`](https://renovatebot.com/diffs/npm/typescript/5.3.3/5.5.4) | [![age](https://developer.mend.io/api/mc/badges/age/npm/typescript/5.5.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/typescript/5.5.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/typescript/5.3.3/5.5.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/typescript/5.3.3/5.5.4?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
Microsoft/TypeScript (typescript) ### [`v5.5.4`](https://togithub.com/Microsoft/TypeScript/compare/v5.5.3...c8a7d589e647e19c94150d9892909f3aa93e48eb) [Compare Source](https://togithub.com/Microsoft/TypeScript/compare/v5.5.3...v5.5.4) ### [`v5.5.3`](https://togithub.com/Microsoft/TypeScript/compare/v5.5.2...f0e992167440686f948965e5441a918b34251886) [Compare Source](https://togithub.com/Microsoft/TypeScript/compare/v5.5.2...v5.5.3) ### [`v5.5.2`](https://togithub.com/Microsoft/TypeScript/compare/v5.4.5...ce2e60e4ea15a65992e54a9e8877d16be9d42abb) [Compare Source](https://togithub.com/Microsoft/TypeScript/compare/v5.4.5...v5.5.2) ### [`v5.4.5`](https://togithub.com/microsoft/TypeScript/releases/tag/v5.4.5): TypeScript 5.4.5 [Compare Source](https://togithub.com/Microsoft/TypeScript/compare/v5.4.4...v5.4.5) For release notes, check out the [release announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/). For the complete list of fixed issues, check out the - [fixed issues query for Typescript 5.4.0 (Beta)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.0%22+is%3Aclosed+). - [fixed issues query for Typescript 5.4.1 (RC)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.1%22+is%3Aclosed+). - [fixed issues query for Typescript 5.4.2 (Stable)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.2%22+is%3Aclosed+). - [fixed issues query for Typescript 5.4.3 (Stable)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.3%22+is%3Aclosed+). - [fixed issues query for Typescript 5.4.4 (Stable)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.4%22+is%3Aclosed+). - [fixed issues query for Typescript 5.4.5 (Stable)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.5%22+is%3Aclosed+). Downloads are available on: - [NuGet package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild) ### [`v5.4.4`](https://togithub.com/microsoft/TypeScript/releases/tag/v5.4.4): TypeScript 5.4.4 [Compare Source](https://togithub.com/Microsoft/TypeScript/compare/v5.4.3...v5.4.4) For release notes, check out the [release announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/). For the complete list of fixed issues, check out the - [fixed issues query for Typescript 5.4.0 (Beta)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.0%22+is%3Aclosed+). - [fixed issues query for Typescript 5.4.1 (RC)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.1%22+is%3Aclosed+). - [fixed issues query for Typescript 5.4.2 (Stable)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.2%22+is%3Aclosed+). - [fixed issues query for Typescript 5.4.3 (Stable)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.3%22+is%3Aclosed+). - [fixed issues query for Typescript 5.4.4 (Stable)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.4%22+is%3Aclosed+). Downloads are available on: - [NuGet package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild) ### [`v5.4.3`](https://togithub.com/microsoft/TypeScript/releases/tag/v5.4.3): TypeScript 5.4.3 [Compare Source](https://togithub.com/Microsoft/TypeScript/compare/v5.4.2...v5.4.3) For release notes, check out the [release announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/). For the complete list of fixed issues, check out the - [fixed issues query for Typescript 5.4.0 (Beta)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.0%22+is%3Aclosed+). - [fixed issues query for Typescript 5.4.1 (RC)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.1%22+is%3Aclosed+). - [fixed issues query for Typescript 5.4.2 (Stable)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.2%22+is%3Aclosed+). - [fixed issues query for Typescript 5.4.3 (Stable)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.3%22+is%3Aclosed+). Downloads are available on: - [NuGet package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild) ### [`v5.4.2`](https://togithub.com/microsoft/TypeScript/releases/tag/v5.4.2): TypeScript 5.4 [Compare Source](https://togithub.com/Microsoft/TypeScript/compare/v5.3.3...v5.4.2) For release notes, check out the [release announcement](https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/). For the complete list of fixed issues, check out the - [fixed issues query for Typescript 5.4.0 (Beta)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.0%22+is%3Aclosed+). - [fixed issues query for Typescript 5.4.1 (RC)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.1%22+is%3Aclosed+). - [fixed issues query for Typescript 5.4.2 (Stable)](https://togithub.com/Microsoft/TypeScript/issues?utf8=%E2%9C%93\&q=milestone%3A%22TypeScript+5.4.2%22+is%3Aclosed+). Downloads are available on: - [NuGet package](https://www.nuget.org/packages/Microsoft.TypeScript.MSBuild)
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index f149905ab..6ecbfe72d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "quicktype-core": "23.0.170", "rimraf": "6.0.1", "ts-node": "10.9.2", - "typescript": "5.3.3" + "typescript": "5.5.4" } }, "node_modules/@babel/runtime": { @@ -2159,9 +2159,9 @@ } }, "node_modules/typescript": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", - "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/package.json b/package.json index 3a0e24491..8f40e36ab 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,6 @@ "quicktype-core": "23.0.170", "rimraf": "6.0.1", "ts-node": "10.9.2", - "typescript": "5.3.3" + "typescript": "5.5.4" } } From 449788a87a0a3f09e91febd98564f24e2e851931 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 13 Aug 2024 08:17:08 +0200 Subject: [PATCH 091/214] Remove locked security framework (#952) There is a new release of security-framework available which removes the need for us to manually specify the version. --- Cargo.lock | 7 +++---- crates/bitwarden-core/Cargo.toml | 5 ----- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 195b01d12..e9ed72fee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -442,7 +442,6 @@ dependencies = [ "reqwest", "rustls-platform-verifier", "schemars", - "security-framework", "serde", "serde_json", "serde_qs", @@ -3459,11 +3458,11 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.10.0" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "770452e37cad93e0a50d5abc3990d2bc351c36d0328f86cefec2f2fb206eaef6" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.6.0", "core-foundation", "core-foundation-sys", "libc", diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml index 644ebc6c6..365db9443 100644 --- a/crates/bitwarden-core/Cargo.toml +++ b/crates/bitwarden-core/Cargo.toml @@ -81,11 +81,6 @@ reqwest = { version = ">=0.12.5, <0.13", features = [ "rustls-tls-webpki-roots", ], default-features = false } -# This is a workaround to fix a bug with version 2.11.0 that added some symbols that are not available on iOS -# The bug is fixed already but the fix is not released yet. https://github.com/kornelski/rust-security-framework/pull/204 -[target.'cfg(target_os = "ios")'.dependencies] -security-framework = { version = "=2.10" } - [dev-dependencies] bitwarden-crypto = { workspace = true } rand_chacha = "0.3.1" From 3ba55c1ae598791af148939269e808e532d033db Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 13:31:20 -0400 Subject: [PATCH 092/214] [deps]: Update gradle/actions action to v4 (#951) --- .github/workflows/build-android.yml | 2 +- .github/workflows/publish-java.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index 3bd77bb75..d14e5ddb0 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -102,7 +102,7 @@ jobs: run: ./build-schemas.sh - name: Publish - uses: gradle/actions/setup-gradle@db19848a5fa7950289d3668fb053140cf3028d43 # v3.3.2 + uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 with: arguments: sdk:publish build-root-directory: languages/kotlin diff --git a/.github/workflows/publish-java.yml b/.github/workflows/publish-java.yml index 99df6aeda..fe269659a 100644 --- a/.github/workflows/publish-java.yml +++ b/.github/workflows/publish-java.yml @@ -70,7 +70,7 @@ jobs: java-version: 17 - name: Setup Gradle - uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 - name: Publish package to GitHub Packages if: ${{ inputs.release_type != 'Dry Run' }} From f38f5090587b414c573e256a07fd04e5d4e891ee Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 13:31:39 -0400 Subject: [PATCH 093/214] [deps]: Update docker/build-push-action action to v6 (#950) --- .github/workflows/build-cli-docker.yml | 2 +- .github/workflows/release-cli.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-cli-docker.yml b/.github/workflows/build-cli-docker.yml index 375aa1bd9..e25eb7ff8 100644 --- a/.github/workflows/build-cli-docker.yml +++ b/.github/workflows/build-cli-docker.yml @@ -98,7 +98,7 @@ jobs: fi - name: Build and push Docker image - uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 + uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0 with: context: . file: crates/bws/Dockerfile diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index 656f162c2..17d326047 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -216,7 +216,7 @@ jobs: azure-keyvault-name: "bitwarden-ci" - name: Build and push Docker image - uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 + uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0 with: context: . file: crates/bws/Dockerfile From 732e29767eb69cb97592247abedb71785093933d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 13:32:13 -0400 Subject: [PATCH 094/214] [deps]: Update dtolnay/rust-toolchain digest to 7b1c307 (#945) --- .github/workflows/build-android.yml | 4 ++-- .github/workflows/build-cli.yml | 10 +++++----- .github/workflows/build-napi.yml | 2 +- .github/workflows/build-python-wheels.yml | 2 +- .github/workflows/build-rust-crates.yml | 4 ++-- .github/workflows/build-rust-cross-platform.yml | 2 +- .github/workflows/build-wasm.yml | 2 +- .github/workflows/direct-minimal-versions.yml | 2 +- .github/workflows/generate_schemas.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/memory-testing.yml | 2 +- .github/workflows/minimum-rust-version.yml | 2 +- .github/workflows/publish-rust-crates.yml | 2 +- .github/workflows/release-cli.yml | 2 +- .github/workflows/rust-test.yml | 6 +++--- .github/workflows/version-bump.yml | 2 +- 16 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index d14e5ddb0..56f92a3c9 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -28,7 +28,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable @@ -70,7 +70,7 @@ jobs: fetch-depth: 0 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable diff --git a/.github/workflows/build-cli.yml b/.github/workflows/build-cli.yml index 245b36b7c..d347e17f6 100644 --- a/.github/workflows/build-cli.yml +++ b/.github/workflows/build-cli.yml @@ -61,7 +61,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable targets: ${{ matrix.settings.target }} @@ -151,7 +151,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable targets: ${{ matrix.settings.target }} @@ -266,7 +266,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable targets: ${{ matrix.settings.target }} @@ -413,7 +413,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable @@ -448,7 +448,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable diff --git a/.github/workflows/build-napi.yml b/.github/workflows/build-napi.yml index 81fa07417..37dd817f6 100644 --- a/.github/workflows/build-napi.yml +++ b/.github/workflows/build-napi.yml @@ -61,7 +61,7 @@ jobs: cache-dependency-path: crates/bitwarden-napi/package-lock.json - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable targets: ${{ matrix.settings.target }} diff --git a/.github/workflows/build-python-wheels.yml b/.github/workflows/build-python-wheels.yml index 766fcaf1e..84b978324 100644 --- a/.github/workflows/build-python-wheels.yml +++ b/.github/workflows/build-python-wheels.yml @@ -71,7 +71,7 @@ jobs: node-version: 18 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable targets: ${{ matrix.settings.target }} diff --git a/.github/workflows/build-rust-crates.yml b/.github/workflows/build-rust-crates.yml index 3cbf16aa0..93957846f 100644 --- a/.github/workflows/build-rust-crates.yml +++ b/.github/workflows/build-rust-crates.yml @@ -39,7 +39,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable targets: ${{ matrix.settings.target }} @@ -69,7 +69,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable targets: ${{ matrix.settings.target }} diff --git a/.github/workflows/build-rust-cross-platform.yml b/.github/workflows/build-rust-cross-platform.yml index 0c99a5a23..f44f0435f 100644 --- a/.github/workflows/build-rust-cross-platform.yml +++ b/.github/workflows/build-rust-cross-platform.yml @@ -38,7 +38,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable diff --git a/.github/workflows/build-wasm.yml b/.github/workflows/build-wasm.yml index 45313782f..932a26fc2 100644 --- a/.github/workflows/build-wasm.yml +++ b/.github/workflows/build-wasm.yml @@ -35,7 +35,7 @@ jobs: run: npm i -g binaryen - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable targets: wasm32-unknown-unknown diff --git a/.github/workflows/direct-minimal-versions.yml b/.github/workflows/direct-minimal-versions.yml index 0c58466e1..684b52a02 100644 --- a/.github/workflows/direct-minimal-versions.yml +++ b/.github/workflows/direct-minimal-versions.yml @@ -39,7 +39,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: nightly targets: ${{ matrix.settings.target }} diff --git a/.github/workflows/generate_schemas.yml b/.github/workflows/generate_schemas.yml index cf21c54e8..f5f58267f 100644 --- a/.github/workflows/generate_schemas.yml +++ b/.github/workflows/generate_schemas.yml @@ -22,7 +22,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3e5e2a1eb..23af8022d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -20,7 +20,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable diff --git a/.github/workflows/memory-testing.yml b/.github/workflows/memory-testing.yml index 8b577608f..db2f85ad0 100644 --- a/.github/workflows/memory-testing.yml +++ b/.github/workflows/memory-testing.yml @@ -30,7 +30,7 @@ jobs: sudo apt -y install gdb - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable diff --git a/.github/workflows/minimum-rust-version.yml b/.github/workflows/minimum-rust-version.yml index f5dbdab4d..16ca2e5c5 100644 --- a/.github/workflows/minimum-rust-version.yml +++ b/.github/workflows/minimum-rust-version.yml @@ -30,7 +30,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: # Important: When updating this, make sure to update the Readme file # and also the `rust-version` field in all the `Cargo.toml`. diff --git a/.github/workflows/publish-rust-crates.yml b/.github/workflows/publish-rust-crates.yml index 054cb5bd4..d7efd5088 100644 --- a/.github/workflows/publish-rust-crates.yml +++ b/.github/workflows/publish-rust-crates.yml @@ -59,7 +59,7 @@ jobs: secrets: "cratesio-api-token" - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index 17d326047..eb20b30b2 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -142,7 +142,7 @@ jobs: secrets: "cratesio-api-token" - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable diff --git a/.github/workflows/rust-test.yml b/.github/workflows/rust-test.yml index 9338a093d..b63ac3e5a 100644 --- a/.github/workflows/rust-test.yml +++ b/.github/workflows/rust-test.yml @@ -39,7 +39,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable @@ -58,7 +58,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable components: llvm-tools @@ -87,7 +87,7 @@ jobs: uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable targets: wasm32-unknown-unknown diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index 6c10d51bf..2976596c5 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -34,7 +34,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Install rust - uses: dtolnay/rust-toolchain@21dc36fb71dd22e3317045c0c31a3f4249868b17 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable From 4be1e09563ab7e52340ab7323ae478faa8cbd8a0 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 13:42:27 -0400 Subject: [PATCH 095/214] [deps]: Update gh minor (#947) --- .github/workflows/build-android.yml | 12 ++++---- .github/workflows/build-cli-docker.yml | 6 ++-- .github/workflows/build-cli.yml | 30 +++++++++---------- .github/workflows/build-cpp.yml | 8 ++--- .github/workflows/build-dotnet.yml | 18 +++++------ .github/workflows/build-go.yaml | 4 +-- .github/workflows/build-java.yml | 14 ++++----- .github/workflows/build-napi.yml | 8 ++--- .github/workflows/build-python-wheels.yml | 16 +++++----- .github/workflows/build-rust-crates.yml | 4 +-- .../workflows/build-rust-cross-platform.yml | 4 +-- .github/workflows/build-wasm.yml | 6 ++-- .github/workflows/cloc.yml | 2 +- .github/workflows/direct-minimal-versions.yml | 2 +- .github/workflows/generate_schemas.yml | 20 ++++++------- .github/workflows/lint.yml | 6 ++-- .github/workflows/memory-testing.yml | 2 +- .github/workflows/minimum-rust-version.yml | 2 +- .github/workflows/publish-dotnet.yml | 2 +- .github/workflows/publish-java.yml | 6 ++-- .github/workflows/publish-php.yml | 12 ++++---- .github/workflows/publish-python.yml | 4 +-- .github/workflows/publish-ruby.yml | 6 ++-- .github/workflows/publish-rust-crates.yml | 4 +-- .github/workflows/release-cli.yml | 10 +++---- .github/workflows/release-cpp.yml | 6 ++-- .github/workflows/release-go.yml | 6 ++-- .github/workflows/release-napi.yml | 6 ++-- .github/workflows/release-wasm.yml | 6 ++-- .github/workflows/rust-test.yml | 8 ++--- .github/workflows/scan.yml | 10 +++---- .github/workflows/version-bump.yml | 4 +-- 32 files changed, 127 insertions(+), 127 deletions(-) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index 56f92a3c9..567d93907 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -25,7 +25,7 @@ jobs: - target: i686-linux-android steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -46,7 +46,7 @@ jobs: run: cross build -p bitwarden-uniffi --release --target=${{ matrix.settings.target }} - name: Upload artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: android-${{ matrix.settings.target }} path: ./target/${{ matrix.settings.target }}/release/libbitwarden_uniffi.so @@ -57,14 +57,14 @@ jobs: needs: build steps: - name: Checkout repo (PR) - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 if: github.event_name == 'pull_request' with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.ref }} - name: Checkout repo (Push) - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 if: github.event_name == 'push' with: fetch-depth: 0 @@ -80,13 +80,13 @@ jobs: key: cargo-combine-cache - name: Setup Java - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 with: distribution: temurin java-version: 17 - name: Download Artifacts - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 - name: Move artifacts working-directory: languages/kotlin/sdk/src/main/jniLibs diff --git a/.github/workflows/build-cli-docker.yml b/.github/workflows/build-cli-docker.yml index e25eb7ff8..8302529c8 100644 --- a/.github/workflows/build-cli-docker.yml +++ b/.github/workflows/build-cli-docker.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout Repository - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Check Branch to Publish env: @@ -38,10 +38,10 @@ jobs: ########## Set up Docker ########## - name: Set up QEMU emulators - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 + uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 + uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 ########## Login to Docker registries ########## - name: Login to Azure - Prod Subscription diff --git a/.github/workflows/build-cli.yml b/.github/workflows/build-cli.yml index d347e17f6..6dd683142 100644 --- a/.github/workflows/build-cli.yml +++ b/.github/workflows/build-cli.yml @@ -23,7 +23,7 @@ jobs: sign: ${{ steps.sign.outputs.sign }} steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Get Package Version id: retrieve-version @@ -58,7 +58,7 @@ jobs: target: aarch64-pc-windows-msvc steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -123,7 +123,7 @@ jobs: run: 7z a ./bws-${{ matrix.settings.target }}-%_PACKAGE_VERSION%.zip ./target/${{ matrix.settings.target }}/release/bws.exe - name: Upload artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip path: ./bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip @@ -148,7 +148,7 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -233,7 +233,7 @@ jobs: xcrun notarytool submit ./bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip --keychain-profile "notarytool-profile" --wait - name: Upload artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip path: ./bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip @@ -263,7 +263,7 @@ jobs: target: aarch64-unknown-linux-gnu steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -292,7 +292,7 @@ jobs: run: zip -j ./bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip ./target/${{ matrix.settings.target }}/release/bws - name: Upload artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip path: ./bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip @@ -308,15 +308,15 @@ jobs: _PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }} steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Download x86_64-apple-darwin artifact - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: bws-x86_64-apple-darwin-${{ env._PACKAGE_VERSION }}.zip - name: Download aarch64-apple-darwin artifact - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: bws-aarch64-apple-darwin-${{ env._PACKAGE_VERSION }}.zip @@ -397,7 +397,7 @@ jobs: xcrun notarytool submit ./bws-macos-universal-${{ env._PACKAGE_VERSION }}.zip --keychain-profile "notarytool-profile" --wait - name: Upload artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: bws-macos-universal-${{ env._PACKAGE_VERSION }}.zip path: ./bws-macos-universal-${{ env._PACKAGE_VERSION }}.zip @@ -410,7 +410,7 @@ jobs: - setup steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -432,7 +432,7 @@ jobs: sed -i.bak 's/\$NAME\$/Bitwarden Secrets Manager CLI/g' THIRDPARTY.html - name: Upload artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: THIRDPARTY.html path: ./crates/bws/THIRDPARTY.html @@ -445,7 +445,7 @@ jobs: - setup steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -464,7 +464,7 @@ jobs: mv $OUT_DIR/manpages . - name: Upload artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: manpages path: ./manpages/* diff --git a/.github/workflows/build-cpp.yml b/.github/workflows/build-cpp.yml index e5bf3ccfb..d26d22254 100644 --- a/.github/workflows/build-cpp.yml +++ b/.github/workflows/build-cpp.yml @@ -38,7 +38,7 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: install dependencies linux if: runner.os == 'Linux' @@ -87,13 +87,13 @@ jobs: key: vcpkg-${{ runner.os }}-${{ matrix.settings.target }} - name: Download schemas - uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: sdk-schemas-cpp path: languages/cpp/include - name: Download ${{ matrix.settings.target }} files - uses: actions/download-artifact@eaceaf801fd36c7dee90939fad912460b18a1ffe # v4.1.2 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: libbitwarden_c_files-${{ matrix.settings.target }} path: languages/cpp/include @@ -159,7 +159,7 @@ jobs: cp libBitwardenClient.* artifacts - name: Upload C++ package for ${{ matrix.settings.target }} - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: libbitwarden_cpp-${{ matrix.settings.target }} path: languages/cpp/build/artifacts diff --git a/.github/workflows/build-dotnet.yml b/.github/workflows/build-dotnet.yml index 69987ab32..cd6441d77 100644 --- a/.github/workflows/build-dotnet.yml +++ b/.github/workflows/build-dotnet.yml @@ -23,7 +23,7 @@ jobs: version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install xmllint run: sudo apt-get install -y libxml2-utils @@ -44,39 +44,39 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Download C# schemas artifact - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: schemas.cs path: languages/csharp/Bitwarden.Sdk - name: Set up .NET Core - uses: actions/setup-dotnet@4d6c8fcf3c8f7a60068d26b594648e99df24cee3 # v4.0.0 + uses: actions/setup-dotnet@6bd8b7f7774af54e05809fcc5431931b3eb1ddee # v4.0.1 with: global-json-file: languages/csharp/global.json - name: Download x86_64-apple-darwin files - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: libbitwarden_c_files-x86_64-apple-darwin path: languages/csharp/Bitwarden.Sdk/macos-x64 - name: Download aarch64-apple-darwin files - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: libbitwarden_c_files-aarch64-apple-darwin path: languages/csharp/Bitwarden.Sdk/macos-arm64 - name: Download x86_64-unknown-linux-gnu files - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: libbitwarden_c_files-x86_64-unknown-linux-gnu path: languages/csharp/Bitwarden.Sdk/linux-x64 - name: Download x86_64-pc-windows-msvc files - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: libbitwarden_c_files-x86_64-pc-windows-msvc path: languages/csharp/Bitwarden.Sdk/windows-x64 @@ -92,7 +92,7 @@ jobs: working-directory: languages/csharp/Bitwarden.Sdk - name: Upload NuGet package - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: Bitwarden.Sdk.${{ needs.version.outputs.version }}.nupkg path: | diff --git a/.github/workflows/build-go.yaml b/.github/workflows/build-go.yaml index 1d4d3a351..4ad7d0345 100644 --- a/.github/workflows/build-go.yaml +++ b/.github/workflows/build-go.yaml @@ -19,10 +19,10 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout Repository - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Go environment - uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1 + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 with: go-version: ${{ env.GO_VERSION }} diff --git a/.github/workflows/build-java.yml b/.github/workflows/build-java.yml index 5f71969d6..a42663e3f 100644 --- a/.github/workflows/build-java.yml +++ b/.github/workflows/build-java.yml @@ -25,40 +25,40 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Download Java schemas artifact - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: sdk-schemas-java path: languages/java/src/main/java/bit/sdk/schema/ - name: Setup Java - uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 # v4.2.1 + uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 with: distribution: temurin java-version: 17 - name: Download x86_64-apple-darwin files - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: libbitwarden_c_files-x86_64-apple-darwin path: languages/java/src/main/resources/darwin-x86-64 - name: Download aarch64-apple-darwin files - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: libbitwarden_c_files-aarch64-apple-darwin path: languages/java/src/main/resources/darwin-aarch64 - name: Download x86_64-unknown-linux-gnu files - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: libbitwarden_c_files-x86_64-unknown-linux-gnu path: languages/java/src/main/resources/linux-x86-64 - name: Download x86_64-pc-windows-msvc files - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: libbitwarden_c_files-x86_64-pc-windows-msvc path: languages/java/src/main/resources/win32-x86-64 diff --git a/.github/workflows/build-napi.yml b/.github/workflows/build-napi.yml index 37dd817f6..5ad1ebd54 100644 --- a/.github/workflows/build-napi.yml +++ b/.github/workflows/build-napi.yml @@ -51,10 +51,10 @@ jobs: strip *.node steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Node - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version: 18 cache: "npm" @@ -72,7 +72,7 @@ jobs: key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.os }} - name: Retrieve schemas - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: schemas.ts path: ${{ github.workspace }}/crates/bitwarden-napi/src-ts/bitwarden_client/ @@ -84,7 +84,7 @@ jobs: run: ${{ matrix.settings.build }} - name: Upload artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: sdk-bitwarden-napi-${{ matrix.settings.target }} path: ${{ github.workspace }}/crates/bitwarden-napi/sdk-napi.*.node diff --git a/.github/workflows/build-python-wheels.yml b/.github/workflows/build-python-wheels.yml index 84b978324..f6899023d 100644 --- a/.github/workflows/build-python-wheels.yml +++ b/.github/workflows/build-python-wheels.yml @@ -26,7 +26,7 @@ jobs: package_version: ${{ steps.retrieve-version.outputs.package_version }} steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Get Package Version id: retrieve-version @@ -63,10 +63,10 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Node - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version: 18 @@ -82,14 +82,14 @@ jobs: key: ${{ matrix.settings.target }}-cargo-${{ matrix.settings.os }} - name: Retrieve schemas - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 + uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: name: schemas.py path: ${{ github.workspace }}/languages/python/bitwarden_sdk - name: Build wheels if: ${{ matrix.settings.target != 'x86_64-unknown-linux-gnu' }} - uses: PyO3/maturin-action@52b28abb0c6729beb388babfc348bf6ff5aaff31 # v1.42.2 + uses: PyO3/maturin-action@2c5c1560848aaa364c3545136054932db5fa27b7 # v1.44.0 with: target: ${{ matrix.settings.target }} args: --release --find-interpreter --sdist @@ -99,7 +99,7 @@ jobs: - name: Build wheels (Linux - x86_64) if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }} - uses: PyO3/maturin-action@52b28abb0c6729beb388babfc348bf6ff5aaff31 # v1.42.2 + uses: PyO3/maturin-action@2c5c1560848aaa364c3545136054932db5fa27b7 # v1.44.0 with: target: ${{ matrix.settings.target }} args: --release --find-interpreter --sdist @@ -109,14 +109,14 @@ jobs: working-directory: ${{ github.workspace }}/languages/python - name: Upload wheels - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: bitwarden_sdk-${{ env._PACKAGE_VERSION }}-${{ matrix.settings.target }} path: ${{ github.workspace }}/target/wheels/bitwarden_sdk*.whl - name: Upload sdists if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }} # we only need one sdist - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: bitwarden_sdk-${{ env._PACKAGE_VERSION }}-sdist path: ${{ github.workspace }}/target/wheels/bitwarden_sdk-*.tar.gz diff --git a/.github/workflows/build-rust-crates.yml b/.github/workflows/build-rust-crates.yml index 93957846f..068bb9bbd 100644 --- a/.github/workflows/build-rust-crates.yml +++ b/.github/workflows/build-rust-crates.yml @@ -36,7 +36,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -66,7 +66,7 @@ jobs: - build steps: - name: Checkout - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable diff --git a/.github/workflows/build-rust-cross-platform.yml b/.github/workflows/build-rust-cross-platform.yml index f44f0435f..92ed526f2 100644 --- a/.github/workflows/build-rust-cross-platform.yml +++ b/.github/workflows/build-rust-cross-platform.yml @@ -35,7 +35,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -70,7 +70,7 @@ jobs: run: cargo build -p bitwarden-c --target ${{ matrix.settings.target }} --release - name: Upload Artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: libbitwarden_c_files-${{ matrix.settings.target }} path: | diff --git a/.github/workflows/build-wasm.yml b/.github/workflows/build-wasm.yml index 932a26fc2..62be51d79 100644 --- a/.github/workflows/build-wasm.yml +++ b/.github/workflows/build-wasm.yml @@ -22,10 +22,10 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Node - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version: 18 registry-url: "https://npm.pkg.github.com" @@ -52,7 +52,7 @@ jobs: run: ./build.sh -r - name: Upload artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: sdk-bitwarden-wasm path: ${{ github.workspace }}/languages/js/wasm/* diff --git a/.github/workflows/cloc.yml b/.github/workflows/cloc.yml index bba74c1dc..120aeb511 100644 --- a/.github/workflows/cloc.yml +++ b/.github/workflows/cloc.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up cloc run: | diff --git a/.github/workflows/direct-minimal-versions.yml b/.github/workflows/direct-minimal-versions.yml index 684b52a02..3cfec8a48 100644 --- a/.github/workflows/direct-minimal-versions.yml +++ b/.github/workflows/direct-minimal-versions.yml @@ -36,7 +36,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable diff --git a/.github/workflows/generate_schemas.yml b/.github/workflows/generate_schemas.yml index f5f58267f..87f4dd988 100644 --- a/.github/workflows/generate_schemas.yml +++ b/.github/workflows/generate_schemas.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -27,7 +27,7 @@ jobs: toolchain: stable - name: Set up Node - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: cache: "npm" cache-dependency-path: "package-lock.json" @@ -43,55 +43,55 @@ jobs: run: npm run schemas - name: Upload ts schemas artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: schemas.ts path: ${{ github.workspace }}/languages/js/sdk-client/src/schemas.ts if-no-files-found: error - name: Upload c# schemas artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: schemas.cs path: ${{ github.workspace }}/languages/csharp/Bitwarden.Sdk/schemas.cs if-no-files-found: error - name: Upload python schemas artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: schemas.py path: ${{ github.workspace }}/languages/python/bitwarden_sdk/schemas.py if-no-files-found: error - name: Upload ruby schemas artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: schemas.rb path: ${{ github.workspace }}/languages/ruby/bitwarden_sdk_secrets/lib/schemas.rb if-no-files-found: error - name: Upload json schemas artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: sdk-schemas-json path: ${{ github.workspace }}/support/schemas/* if-no-files-found: error - name: Upload Go schemas artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: schemas.go path: ${{ github.workspace }}/languages/go/schema.go - name: Upload java schemas artifact - uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: sdk-schemas-java path: ${{ github.workspace }}/languages/java/src/main/java/com/bitwarden/sdk/schema/* if-no-files-found: error - name: Upload cpp schemas artifact - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 with: name: sdk-schemas-cpp path: ${{ github.workspace }}/languages/cpp/include/schemas.hpp diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 23af8022d..c5d530b6b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -45,12 +45,12 @@ jobs: RUSTFLAGS: "-D warnings" - name: Upload Clippy results to GitHub - uses: github/codeql-action/upload-sarif@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 + uses: github/codeql-action/upload-sarif@eb055d739abdc2e8de2e5f4ba1a8b246daa779aa # v3.26.0 with: sarif_file: clippy_result.sarif - name: Set up Node - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: cache: "npm" cache-dependency-path: "package-lock.json" diff --git a/.github/workflows/memory-testing.yml b/.github/workflows/memory-testing.yml index db2f85ad0..a9635bc68 100644 --- a/.github/workflows/memory-testing.yml +++ b/.github/workflows/memory-testing.yml @@ -22,7 +22,7 @@ jobs: steps: - name: Check out repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up gdb run: | diff --git a/.github/workflows/minimum-rust-version.yml b/.github/workflows/minimum-rust-version.yml index 16ca2e5c5..d4dac0e8d 100644 --- a/.github/workflows/minimum-rust-version.yml +++ b/.github/workflows/minimum-rust-version.yml @@ -27,7 +27,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable diff --git a/.github/workflows/publish-dotnet.yml b/.github/workflows/publish-dotnet.yml index 7a6573b05..1c4cf5840 100644 --- a/.github/workflows/publish-dotnet.yml +++ b/.github/workflows/publish-dotnet.yml @@ -24,7 +24,7 @@ jobs: version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} diff --git a/.github/workflows/publish-java.yml b/.github/workflows/publish-java.yml index fe269659a..c50080728 100644 --- a/.github/workflows/publish-java.yml +++ b/.github/workflows/publish-java.yml @@ -24,7 +24,7 @@ jobs: version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} @@ -48,7 +48,7 @@ jobs: needs: validate steps: - name: Checkout Repository - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Azure login uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 @@ -64,7 +64,7 @@ jobs: maven-sonartype-ossrh-password" - name: Setup java - uses: actions/setup-java@387ac29b308b003ca37ba93a6cab5eb57c8f5f93 # v4.0.0 + uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 with: distribution: temurin java-version: 17 diff --git a/.github/workflows/publish-php.yml b/.github/workflows/publish-php.yml index 5323cffa0..0cf7c59b0 100644 --- a/.github/workflows/publish-php.yml +++ b/.github/workflows/publish-php.yml @@ -24,7 +24,7 @@ jobs: version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} @@ -47,10 +47,10 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout Repository - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@c665c7a15b5295c2488ac8a87af9cb806cd72198 # 2.30.4 + uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # 2.31.1 with: php-version: "8.0" tools: composer @@ -75,7 +75,7 @@ jobs: _PKG_VERSION: ${{ needs.validate.outputs.version }} steps: - name: Checkout SDK repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: path: sdk @@ -92,7 +92,7 @@ jobs: secrets: "github-pat-bitwarden-devops-bot-repo-scope" - name: Checkout SDK-PHP repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: repository: bitwarden/sm-sdk-php path: sm-sdk-php @@ -254,7 +254,7 @@ jobs: packagist-key" - name: Checkout SDK-PHP repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: repository: bitwarden/sm-sdk-php path: sm-sdk-php diff --git a/.github/workflows/publish-python.yml b/.github/workflows/publish-python.yml index 8eaa28757..343fadd8a 100644 --- a/.github/workflows/publish-python.yml +++ b/.github/workflows/publish-python.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Branch check if: ${{ github.event.inputs.release_type != 'Dry Run' }} @@ -42,7 +42,7 @@ jobs: needs: setup steps: - name: Install Python - uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0 + uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1 with: python-version: "3.9" diff --git a/.github/workflows/publish-ruby.yml b/.github/workflows/publish-ruby.yml index 51d1cc765..6dd3e4064 100644 --- a/.github/workflows/publish-ruby.yml +++ b/.github/workflows/publish-ruby.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Branch check if: ${{ github.event.inputs.release_type != 'Dry Run' }} @@ -41,10 +41,10 @@ jobs: needs: setup steps: - name: Checkout Repository - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Ruby - uses: ruby/setup-ruby@cacc9f1c0b3f4eb8a16a6bb0ed10897b43b9de49 # v1.176.0 + uses: ruby/setup-ruby@a6e6f86333f0a2523ece813039b8b4be04560854 # v1.190.0 with: ruby-version: 3.2 diff --git a/.github/workflows/publish-rust-crates.yml b/.github/workflows/publish-rust-crates.yml index d7efd5088..3931e9e2a 100644 --- a/.github/workflows/publish-rust-crates.yml +++ b/.github/workflows/publish-rust-crates.yml @@ -25,7 +25,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Branch check if: ${{ github.event.inputs.release_type != 'Dry Run' }} @@ -44,7 +44,7 @@ jobs: - setup steps: - name: Checkout - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Login to Azure uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index eb20b30b2..009dc9359 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -29,7 +29,7 @@ jobs: release-version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Branch check if: ${{ github.event.inputs.release_type != 'Dry Run' }} @@ -127,7 +127,7 @@ jobs: - setup steps: - name: Checkout - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Login to Azure uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 @@ -165,7 +165,7 @@ jobs: needs: setup steps: - name: Checkout - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Generate tag list id: tag-list @@ -183,10 +183,10 @@ jobs: ########## Set up Docker ########## - name: Set up QEMU emulators - uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0 + uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 + uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 ########## Login to Docker registries ########## - name: Login to Azure - Prod Subscription diff --git a/.github/workflows/release-cpp.yml b/.github/workflows/release-cpp.yml index 65517eb39..c96b8e088 100644 --- a/.github/workflows/release-cpp.yml +++ b/.github/workflows/release-cpp.yml @@ -24,7 +24,7 @@ jobs: version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} @@ -52,7 +52,7 @@ jobs: _PKG_VERSION: ${{ needs.validate.outputs.version }} steps: - name: Login to Azure - Prod Subscription - uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 + uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 with: creds: ${{ secrets.AZURE_CI_SERVICE_PRINCIPAL }} @@ -151,7 +151,7 @@ jobs: - name: Create release if: ${{ inputs.release_type != 'Dry Run' }} - uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5 # v1.13.0 + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 with: tag: cpp-sdk-v${{ env._PKG_VERSION }} name: "C++ SDK v${{ env._PKG_VERSION }}" diff --git a/.github/workflows/release-go.yml b/.github/workflows/release-go.yml index 74ac5e30e..2c2aea4e4 100644 --- a/.github/workflows/release-go.yml +++ b/.github/workflows/release-go.yml @@ -26,7 +26,7 @@ jobs: version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} @@ -55,7 +55,7 @@ jobs: steps: - name: Checkout SDK repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: path: sdk @@ -72,7 +72,7 @@ jobs: secrets: "github-pat-bitwarden-devops-bot-repo-scope" - name: Checkout SDK-Go repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: repository: bitwarden/sdk-go path: sdk-go diff --git a/.github/workflows/release-napi.yml b/.github/workflows/release-napi.yml index f0f1bd667..bdb579ec2 100644 --- a/.github/workflows/release-napi.yml +++ b/.github/workflows/release-napi.yml @@ -33,7 +33,7 @@ jobs: release-version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Branch check if: ${{ github.event.inputs.release_type != 'Dry Run' }} @@ -90,10 +90,10 @@ jobs: _PKG_VERSION: ${{ needs.setup.outputs.release-version }} steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Node - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version: 18 cache: "npm" diff --git a/.github/workflows/release-wasm.yml b/.github/workflows/release-wasm.yml index 1511dd7be..268dd1ce2 100644 --- a/.github/workflows/release-wasm.yml +++ b/.github/workflows/release-wasm.yml @@ -32,7 +32,7 @@ jobs: release-version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Branch check if: ${{ github.event.inputs.release_type != 'Dry Run' }} @@ -89,10 +89,10 @@ jobs: _PKG_VERSION: ${{ needs.setup.outputs.release-version }} steps: - name: Checkout repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Node - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version: 18 cache: "npm" diff --git a/.github/workflows/rust-test.yml b/.github/workflows/rust-test.yml index b63ac3e5a..514e2a310 100644 --- a/.github/workflows/rust-test.yml +++ b/.github/workflows/rust-test.yml @@ -36,7 +36,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -55,7 +55,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -73,7 +73,7 @@ jobs: run: cargo llvm-cov --all-features --lcov --output-path lcov.info --ignore-filename-regex "crates/bitwarden-api-" - name: Upload to codecov.io - uses: codecov/codecov-action@5ecb98a3c6b747ed38dc09f787459979aebb39be # v4.3.1 + uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} @@ -84,7 +84,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable diff --git a/.github/workflows/scan.yml b/.github/workflows/scan.yml index 11fd47651..aecb18356 100644 --- a/.github/workflows/scan.yml +++ b/.github/workflows/scan.yml @@ -26,12 +26,12 @@ jobs: steps: - name: Check out repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: ref: ${{ github.event.pull_request.head.sha }} - name: Scan with Checkmarx - uses: checkmarx/ast-github-action@dd0f9365942f29a99c3be5bdb308958ede8f906b # 2.0.25 + uses: checkmarx/ast-github-action@1fe318de2993222574e6249750ba9000a4e2a6cd # 2.0.33 env: INCREMENTAL: "${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}" with: @@ -46,7 +46,7 @@ jobs: --output-path . ${{ env.INCREMENTAL }} - name: Upload Checkmarx results to GitHub - uses: github/codeql-action/upload-sarif@d39d31e687223d841ef683f52467bd88e9b21c14 # v3.25.3 + uses: github/codeql-action/upload-sarif@eb055d739abdc2e8de2e5f4ba1a8b246daa779aa # v3.26.0 with: sarif_file: cx_result.sarif @@ -60,13 +60,13 @@ jobs: steps: - name: Check out repo - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} - name: Scan with SonarCloud - uses: sonarsource/sonarcloud-github-action@49e6cd3b187936a73b8280d59ffd9da69df63ec9 # v2.1.1 + uses: sonarsource/sonarcloud-github-action@e44258b109568baa0df60ed515909fc6c72cba92 # v2.3.0 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index 2976596c5..3536c96ce 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -59,7 +59,7 @@ jobs: github-pat-bitwarden-devops-bot-repo-scope" - name: Checkout Branch - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: ref: main repository: bitwarden/sdk @@ -236,7 +236,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout Branch - uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: ref: main From cafdb79fee28b901e6439d1767cc2637f7d2326c Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Thu, 15 Aug 2024 11:33:32 -0400 Subject: [PATCH 096/214] [SM-1275] Update AccessTokenLogin to LoginAccessToken for SM (#953) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1275 ## 📔 Objective As requested internally, this updates `AccessTokenLogin` to `LoginAccessToken` for all SM language bindings. This will break functionality for each binding on main until they are each updated (or unless they are already updated). We are reviewing all bindings now and updates for all are on deck. There are a total of ~8 bindings to verify and update for SM, so the only alternative is including all changes in one PR, which would be nice to avoid. @Hinton please let us know if there is anything we are missing with this PR, besides subsequent PR's to fix this for each binding. Is there anything else that should be updated? **Note**: we should not merge this if we plan to release any bindings before the subsequent updates come through. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-json/src/client.rs | 2 +- crates/bitwarden-json/src/command.rs | 2 +- crates/sdk-schemas/src/main.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/bitwarden-json/src/client.rs b/crates/bitwarden-json/src/client.rs index 536693663..81956bf57 100644 --- a/crates/bitwarden-json/src/client.rs +++ b/crates/bitwarden-json/src/client.rs @@ -54,7 +54,7 @@ impl Client { #[cfg(feature = "internal")] Command::PasswordLogin(req) => client.auth().login_password(&req).await.into_string(), #[cfg(feature = "secrets")] - Command::AccessTokenLogin(req) => { + Command::LoginAccessToken(req) => { client.auth().login_access_token(&req).await.into_string() } #[cfg(feature = "internal")] diff --git a/crates/bitwarden-json/src/command.rs b/crates/bitwarden-json/src/command.rs index 62b4bc843..8c0f2a2ca 100644 --- a/crates/bitwarden-json/src/command.rs +++ b/crates/bitwarden-json/src/command.rs @@ -50,7 +50,7 @@ pub enum Command { /// This command is for initiating an authentication handshake with Bitwarden. /// /// Returns: [ApiKeyLoginResponse](bitwarden::auth::login::ApiKeyLoginResponse) - AccessTokenLogin(AccessTokenLoginRequest), + LoginAccessToken(AccessTokenLoginRequest), #[cfg(feature = "internal")] /// > Requires Authentication diff --git a/crates/sdk-schemas/src/main.rs b/crates/sdk-schemas/src/main.rs index bc064ec86..36478fbd7 100644 --- a/crates/sdk-schemas/src/main.rs +++ b/crates/sdk-schemas/src/main.rs @@ -99,7 +99,7 @@ struct SchemaTypes { // Output types for Client::run_command api_key_login: Response, password_login: Response, - access_token_login: Response, + login_access_token: Response, secret_identifiers: Response, secret: Response, secrets: Response, From ac0e0293962b001a4c0cae8259ac4df2c87be9d6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 15 Aug 2024 17:40:59 +0200 Subject: [PATCH 097/214] [deps]: Update rust-wasm-bindgen monorepo (#961) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [js-sys](https://rustwasm.github.io/wasm-bindgen/) ([source](https://togithub.com/rustwasm/wasm-bindgen/tree/HEAD/crates/js-sys)) | dependencies | patch | `0.3.69` -> `0.3.70` | | [wasm-bindgen](https://rustwasm.github.io/) ([source](https://togithub.com/rustwasm/wasm-bindgen)) | dependencies | patch | `0.2.92` -> `0.2.93` | | [wasm-bindgen-futures](https://rustwasm.github.io/wasm-bindgen/) ([source](https://togithub.com/rustwasm/wasm-bindgen/tree/HEAD/crates/futures)) | dependencies | patch | `0.4.42` -> `0.4.43` | | [wasm-bindgen-test](https://togithub.com/rustwasm/wasm-bindgen) | dev-dependencies | patch | `0.3.42` -> `0.3.43` | --- ### Release Notes
rustwasm/wasm-bindgen (wasm-bindgen) ### [`v0.2.93`](https://togithub.com/rustwasm/wasm-bindgen/blob/HEAD/CHANGELOG.md#0293) [Compare Source](https://togithub.com/rustwasm/wasm-bindgen/compare/0.2.92...0.2.93) Released 2024-08-13 ##### Added - Allow exporting functions named `default`. Throw error in wasm-bindgen-cli if --target web and an exported symbol is named `default`. [#​3930](https://togithub.com/rustwasm/wasm-bindgen/pull/3930) - Added support for arbitrary expressions when using `#[wasm_bindgen(typescript_custom_section)]`. [#​3901](https://togithub.com/rustwasm/wasm-bindgen/pull/3901) - Implement `From>` for `JsValue`. [#​3877](https://togithub.com/rustwasm/wasm-bindgen/pull/3877) - Add method `copy_within` for TypedArray, add methods `find_last`,`find_last_index` for Array. [#​3888](https://togithub.com/rustwasm/wasm-bindgen/pull/3888) - Added support for returning `Vec`s from async functions. [#​3630](https://togithub.com/rustwasm/wasm-bindgen/pull/3630) - Added bindings for `InputDeviceInfo` and `MediaTrackCapabilities`. [#​3935](https://togithub.com/rustwasm/wasm-bindgen/pull/3935) - Add bindings for `RTCRtpReceiver.getCapabilities(DOMString)` method. [#​3941](https://togithub.com/rustwasm/wasm-bindgen/pull/3941) - Add bindings for `VisualViewport`. [#​3931](https://togithub.com/rustwasm/wasm-bindgen/pull/3931) - Add bindings for `queueMicrotask`. [#​3981](https://togithub.com/rustwasm/wasm-bindgen/pull/3981) - Add experimental bindings for User Agent Client Hints API [#​3989](https://togithub.com/rustwasm/wasm-bindgen/pull/3989) - Add bindings for `FocusOptions`. [#​3996](https://togithub.com/rustwasm/wasm-bindgen/pull/3996) - Add bindings for `RTCRtpReceiver.jitterBufferTarget`. [#​3968](https://togithub.com/rustwasm/wasm-bindgen/pull/3968) - Generate getters for all WebIDL dictionary types. [#​3993](https://togithub.com/rustwasm/wasm-bindgen/pull/3993) - Support for iterable in WebIDL. Gives `entries`, `keys`, `values` methods for regular and asynchronous, as well as `for_each` for regular, iterables. [#​3962](https://togithub.com/rustwasm/wasm-bindgen/pull/3962) - Add bindings for `HTMLTableCellElement.abbr` and `scope` properties. [#​3972](https://togithub.com/rustwasm/wasm-bindgen/pull/3972) - Add WebIDL definitions relating to `Popover API`. [#​3977](https://togithub.com/rustwasm/wasm-bindgen/pull/3977) - Added the `thread_stack_size` property to the object parameter of `default()` (`init()`) and `initSync()`, making it possible to set the stack size of spawned threads. `__wbindgen_thread_destroy()` now has a third optional parameter for the stack size, the default stack size is assumed when not passing it. When calling from the thread to be destroyed, by passing no parameters, the correct stack size is determined internally. [#​3995](https://togithub.com/rustwasm/wasm-bindgen/pull/3995) - Added bindings to the Device Memory API. [#​4011](https://togithub.com/rustwasm/wasm-bindgen/pull/4011) - Added support for WebIDL records. This added new methods to various APIs, notably `ClipboardItem()`, `GPUDeviceDescriptor.requiredLimits` and `Header()`. [#​4030](https://togithub.com/rustwasm/wasm-bindgen/pull/4030) - Added an official MSRV policy. Library MSRV changes will be accompanied by a minor version bump. CLI tool MSRV can change with any version bump. [#​4038](https://togithub.com/rustwasm/wasm-bindgen/pull/4038) - Added bindings to `NavigatorOptions.vibrate`. [#​4041](https://togithub.com/rustwasm/wasm-bindgen/pull/4041) - Added an experimental Node.JS ES module target, in comparison the current `node` target uses CommonJS, with `--target experimental-nodejs-module` or when testing with `wasm_bindgen_test_configure!(run_in_node_experimental)`. [#​4027](https://togithub.com/rustwasm/wasm-bindgen/pull/4027) - Added importing strings as `JsString` through `#[wasm_bindgen(thread_local, static_string)] static STRING: JsString = "a string literal";`. [#​4055](https://togithub.com/rustwasm/wasm-bindgen/pull/4055) - Added experimental test coverage support for `wasm-bindgen-test-runner`, see the guide for more information. [#​4060](https://togithub.com/rustwasm/wasm-bindgen/pull/4060) ##### Changed - Stabilize Web Share API. [#​3882](https://togithub.com/rustwasm/wasm-bindgen/pull/3882) - Generate JS bindings for WebIDL dictionary setters instead of using `Reflect`. This increases the size of the Web API bindings but should be more performant. Also, importing getters/setters from JS now supports specifying the JS attribute name as a string, e.g. `#[wasm_bindgen(method, setter = "x-cdm-codecs")]`. [#​3898](https://togithub.com/rustwasm/wasm-bindgen/pull/3898) - Greatly improve the performance of sending WebIDL 'string enums' across the JavaScript boundary by converting the enum variant string to/from an int. [#​3915](https://togithub.com/rustwasm/wasm-bindgen/pull/3915) - Use `table.fill` when appropriate. [#​3446](https://togithub.com/rustwasm/wasm-bindgen/pull/3446) - Annotated methods in WebCodecs that throw. [#​3970](https://togithub.com/rustwasm/wasm-bindgen/pull/3970) - Update and stabilize the Clipboard API. [#​3992](https://togithub.com/rustwasm/wasm-bindgen/pull/3992) - Deprecate builder-pattern type setters for WebIDL dictionary types and introduce non-mutable setters instead. [#​3993](https://togithub.com/rustwasm/wasm-bindgen/pull/3993) - Allow imported async functions to return any type that can be converted from a `JsValue`. [#​3919](https://togithub.com/rustwasm/wasm-bindgen/pull/3919) - Update Web Authentication API to level 3. [#​4000](https://togithub.com/rustwasm/wasm-bindgen/pull/4000) - Deprecate `AudioBufferSourceNode.onended` and `AudioBufferSourceNode.stop()`. [#​4020](https://togithub.com/rustwasm/wasm-bindgen/pull/4020) - Increase default stack size for spawned threads from 1 to 2 MB. [#​3995](https://togithub.com/rustwasm/wasm-bindgen/pull/3995) - Deprecated parameters to `default` (`init`) and `initSync` in favor of an object. [#​3995](https://togithub.com/rustwasm/wasm-bindgen/pull/3995) - Update `AbortSignal` and `AbortController` according to the WHATWG specification. [#​4026](https://togithub.com/rustwasm/wasm-bindgen/pull/4026) - Update the Indexed DB API. [#​4027](https://togithub.com/rustwasm/wasm-bindgen/pull/4027) - `UnwrapThrowExt for Result` now makes use of the required `Debug` bound to display the error as well. [#​4035](https://togithub.com/rustwasm/wasm-bindgen/pull/4035) [#​4049](https://togithub.com/rustwasm/wasm-bindgen/pull/4049) - MSRV of CLI tools bumped to v1.76. This does not affect libraries like `wasm-bindgen`, `js-sys` and `web-sys`! [#​4037](https://togithub.com/rustwasm/wasm-bindgen/pull/4037) - Filtered files in published crates, significantly reducing the package size and notably excluding any bash files. [#​4046](https://togithub.com/rustwasm/wasm-bindgen/pull/4046) - Deprecated `JsStatic` in favor of `#[wasm_bindgen(thread_local)]`, which creates a `std::thread::LocalKey`. The syntax is otherwise the same. [#​4057](https://togithub.com/rustwasm/wasm-bindgen/pull/4057) - Removed `impl Deref for JsStatic` when compiling with `cfg(target_feature = "atomics")`, which was unsound. [#​4057](https://togithub.com/rustwasm/wasm-bindgen/pull/4057) - Updated the WebGPU WebIDL to the current draft as of 2024-08-05. [#​4062](https://togithub.com/rustwasm/wasm-bindgen/pull/4062) - Use object URLs for linked modules without `--split-linked-modules`. [#​4067](https://togithub.com/rustwasm/wasm-bindgen/pull/4067) ##### Fixed - Copy port from headless test server when using `WASM_BINDGEN_TEST_ADDRESS`. [#​3873](https://togithub.com/rustwasm/wasm-bindgen/pull/3873) - Fix `catch` not being thread-safe. [#​3879](https://togithub.com/rustwasm/wasm-bindgen/pull/3879) - Fix MSRV compilation. [#​3927](https://togithub.com/rustwasm/wasm-bindgen/pull/3927) - Fix `clippy::empty_docs` lint. [#​3946](https://togithub.com/rustwasm/wasm-bindgen/pull/3946) - Fix missing target features in module when enabling reference types or multi-value transformation. [#​3967](https://togithub.com/rustwasm/wasm-bindgen/pull/3967) - Fixed Rust values getting GC'd while still borrowed. [#​3940](https://togithub.com/rustwasm/wasm-bindgen/pull/3940) - Fixed Rust values not getting GC'd if they were created via. a constructor. [#​3940](https://togithub.com/rustwasm/wasm-bindgen/pull/3940) - Fix triggering `clippy::mem_forget` lint in exported structs. [#​3985](https://togithub.com/rustwasm/wasm-bindgen/pull/3985) - Fix MDN links to static interface methods. [#​4010](https://togithub.com/rustwasm/wasm-bindgen/pull/4010) - Fixed Deno support. [#​3990](https://togithub.com/rustwasm/wasm-bindgen/pull/3990) - Fix `__wbindgen_thread_destroy()` ignoring parameters. [#​3995](https://togithub.com/rustwasm/wasm-bindgen/pull/3995) - Fix `no_std` support and therefor compiling with `default-features = false`. [#​4005](https://togithub.com/rustwasm/wasm-bindgen/pull/4005) - Fix byte order for big-endian platforms. [#​4015](https://togithub.com/rustwasm/wasm-bindgen/pull/4015) - Allow ex/importing structs, functions and parameters named with raw identifiers. [#​4025](https://togithub.com/rustwasm/wasm-bindgen/pull/4025) - Implement a more reliable way to detect the stack pointer. [#​4036](https://togithub.com/rustwasm/wasm-bindgen/pull/4036) - `#[track_caller]` is now always applied on `UnwrapThrowExt` methods when not targetting `wasm32-unknown-unknown`. [#​4042](https://togithub.com/rustwasm/wasm-bindgen/pull/4042) - Fixed linked modules emitting snippet files when not using `--split-linked-modules`. [#​4066](https://togithub.com/rustwasm/wasm-bindgen/pull/4066) ***
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. đŸ‘ģ **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e9ed72fee..f107c5d51 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2185,9 +2185,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "js-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] @@ -2298,6 +2298,16 @@ dependencies = [ "unicase", ] +[[package]] +name = "minicov" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c71e683cd655513b99affab7d317deb690528255a0d5f717f1024093c12b169" +dependencies = [ + "cc", + "walkdir", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -4457,11 +4467,12 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", + "once_cell", "serde", "serde_json", "wasm-bindgen-macro", @@ -4469,9 +4480,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", @@ -4484,9 +4495,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.42" +version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" +checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" dependencies = [ "cfg-if", "js-sys", @@ -4496,9 +4507,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4506,9 +4517,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" +checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", @@ -4519,18 +4530,19 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.92" +version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" +checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "wasm-bindgen-test" -version = "0.3.42" +version = "0.3.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bf62a58e0780af3e852044583deee40983e5886da43a271dd772379987667b" +checksum = "68497a05fb21143a08a7d24fc81763384a3072ee43c44e86aad1744d6adef9d9" dependencies = [ "console_error_panic_hook", "js-sys", + "minicov", "scoped-tls", "wasm-bindgen", "wasm-bindgen-futures", @@ -4539,9 +4551,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.42" +version = "0.3.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7f89739351a2e03cb94beb799d47fb2cac01759b40ec441f7de39b00cbf7ef0" +checksum = "4b8220be1fa9e4c889b30fd207d4906657e7e90b12e0e6b0c8b8d8709f5de021" dependencies = [ "proc-macro2", "quote", From 8e9e8f15c82444eb5c05896395cd8665d905a076 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 15 Aug 2024 21:11:41 +0200 Subject: [PATCH 098/214] Fix gradle deprecation (#960) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective Build android is broken after the breaking changes introduced in #951. This PR follows the recommended changes and splits setup gradle into two steps. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/build-android.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index 567d93907..9de6883f5 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -101,10 +101,11 @@ jobs: working-directory: languages/kotlin run: ./build-schemas.sh - - name: Publish + - name: Setup gradle uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 - with: - arguments: sdk:publish - build-root-directory: languages/kotlin + + - name: Publish + run: ./gradlew sdk:publish + working-directory: languages/kotlin env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 9e4df9701a7b86569b4ec2bead29b3d928e9aaf7 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Thu, 15 Aug 2024 17:52:25 -0400 Subject: [PATCH 099/214] [SM-1174] Access Token Login State by Default in bws (#930) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1174 ## 📔 Objective This PR switches `bws` to use access token login state by default. This will help prevent many users from running into rate limiting issues. The two related config keys in a profile: - `state_dir` -> this is the same as it has been; a custom directory for where state files will be stored - `state_opt_out` -> this is a new key. If it's `true` or `1`, state files will not be used **Note**: the `gnu` build failures are already happening on `main` and have been brought up internally ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bws/src/cli.rs | 3 ++- crates/bws/src/command/mod.rs | 9 ++++++- crates/bws/src/config.rs | 3 +++ crates/bws/src/main.rs | 29 +++++++++++++++++++---- crates/bws/src/state.rs | 31 +++++++++++++++++------- crates/bws/src/util.rs | 44 +++++++++++++++++++++++++++++++++++ 6 files changed, 105 insertions(+), 14 deletions(-) create mode 100644 crates/bws/src/util.rs diff --git a/crates/bws/src/cli.rs b/crates/bws/src/cli.rs index e0ee4264d..f37a7ab5d 100644 --- a/crates/bws/src/cli.rs +++ b/crates/bws/src/cli.rs @@ -11,7 +11,7 @@ pub(crate) const PROFILE_KEY_VAR_NAME: &str = "BWS_PROFILE"; pub(crate) const SERVER_URL_KEY_VAR_NAME: &str = "BWS_SERVER_URL"; pub(crate) const DEFAULT_CONFIG_FILENAME: &str = "config"; -pub(crate) const DEFAULT_CONFIG_DIRECTORY: &str = ".bws"; +pub(crate) const DEFAULT_CONFIG_DIRECTORY: &str = ".config/bws"; #[allow(non_camel_case_types)] #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug)] @@ -20,6 +20,7 @@ pub(crate) enum ProfileKey { server_api, server_identity, state_dir, + state_opt_out, } #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug)] diff --git a/crates/bws/src/command/mod.rs b/crates/bws/src/command/mod.rs index 0fe257c42..adcea5964 100644 --- a/crates/bws/src/command/mod.rs +++ b/crates/bws/src/command/mod.rs @@ -8,7 +8,7 @@ use clap::CommandFactory; use clap_complete::Shell; use color_eyre::eyre::{bail, Result}; -use crate::{config, Cli, ProfileKey}; +use crate::{config, util, Cli, ProfileKey}; pub(crate) fn completions(shell: Option) -> Result<()> { let Some(shell) = shell.or_else(Shell::from_env) else { @@ -48,6 +48,13 @@ pub(crate) fn config( (None, None) => bail!("Missing `name` and `value`"), (None, Some(_)) => bail!("Missing `value`"), (Some(_), None) => bail!("Missing `name`"), + (Some(ProfileKey::state_opt_out), Some(value)) => { + if util::string_to_bool(value.as_str()).is_err() { + bail!("Profile key \"state_opt_out\" must be \"true\" or \"false\""); + } else { + (ProfileKey::state_opt_out, value) + } + } (Some(name), Some(value)) => (name, value), }; diff --git a/crates/bws/src/config.rs b/crates/bws/src/config.rs index 6eae00e44..9fd91849e 100644 --- a/crates/bws/src/config.rs +++ b/crates/bws/src/config.rs @@ -21,6 +21,7 @@ pub(crate) struct Profile { pub server_api: Option, pub server_identity: Option, pub state_dir: Option, + pub state_opt_out: Option, } impl ProfileKey { @@ -30,6 +31,7 @@ impl ProfileKey { ProfileKey::server_api => p.server_api = Some(value), ProfileKey::server_identity => p.server_identity = Some(value), ProfileKey::state_dir => p.state_dir = Some(value), + ProfileKey::state_opt_out => p.state_opt_out = Some(value), } } } @@ -118,6 +120,7 @@ impl Profile { server_api: None, server_identity: None, state_dir: None, + state_opt_out: None, }) } pub(crate) fn api_url(&self) -> Result { diff --git a/crates/bws/src/main.rs b/crates/bws/src/main.rs index de9656a22..5d67bc103 100644 --- a/crates/bws/src/main.rs +++ b/crates/bws/src/main.rs @@ -7,6 +7,7 @@ use bitwarden::{ use bitwarden_cli::install_color_eyre; use clap::{CommandFactory, Parser}; use color_eyre::eyre::{bail, Result}; +use config::Profile; use log::error; use render::OutputSettings; @@ -15,6 +16,7 @@ mod command; mod config; mod render; mod state; +mod util; use crate::cli::*; @@ -84,10 +86,19 @@ async fn process_commands() -> Result<()> { }) .transpose()?; - let state_file = state::get_state_file( - profile.and_then(|p| p.state_dir).map(Into::into), - access_token_obj.access_token_id.to_string(), - )?; + let state_file = match get_state_opt_out(&profile) { + true => None, + false => match state::get_state_file( + profile.and_then(|p| p.state_dir).map(Into::into), + access_token_obj.access_token_id.to_string(), + ) { + Ok(state_file) => Some(state_file), + Err(e) => { + eprintln!("Warning: {}\nRetrieving the state file failed. Attempting to continue without using state. Please set \"state_dir\" in your config file to avoid authentication limits.", e); + None + } + }, + }; let client = bitwarden::Client::new(settings); @@ -150,3 +161,13 @@ fn get_config_profile( }; Ok(profile) } + +fn get_state_opt_out(profile: &Option) -> bool { + if let Some(profile) = profile { + if let Some(state_opt_out) = &profile.state_opt_out { + return util::string_to_bool(state_opt_out).unwrap_or(false); + } + } + + false +} diff --git a/crates/bws/src/state.rs b/crates/bws/src/state.rs index b42ca84da..b5756a056 100644 --- a/crates/bws/src/state.rs +++ b/crates/bws/src/state.rs @@ -1,17 +1,32 @@ use std::path::PathBuf; -use color_eyre::eyre::Result; +use color_eyre::eyre::{bail, Result}; +use directories::BaseDirs; + +use crate::DEFAULT_CONFIG_DIRECTORY; + +pub(crate) const DEFAULT_STATE_DIRECTORY: &str = "state"; pub(crate) fn get_state_file( state_dir: Option, access_token_id: String, -) -> Result> { - if let Some(mut state_dir) = state_dir { - std::fs::create_dir_all(&state_dir)?; - state_dir.push(access_token_id); +) -> Result { + let mut state_dir = match state_dir { + Some(state_dir) => state_dir, + None => { + if let Some(base_dirs) = BaseDirs::new() { + base_dirs + .home_dir() + .join(DEFAULT_CONFIG_DIRECTORY) + .join(DEFAULT_STATE_DIRECTORY) + } else { + bail!("A valid home directory doesn't exist"); + } + } + }; - return Ok(Some(state_dir)); - } + std::fs::create_dir_all(&state_dir)?; + state_dir.push(access_token_id); - Ok(None) + Ok(state_dir) } diff --git a/crates/bws/src/util.rs b/crates/bws/src/util.rs new file mode 100644 index 000000000..a3541ffea --- /dev/null +++ b/crates/bws/src/util.rs @@ -0,0 +1,44 @@ +const STRING_TO_BOOL_ERROR_MESSAGE: &str = "Could not convert string to bool"; + +pub(crate) fn string_to_bool(value: &str) -> Result { + match value.trim().to_lowercase().as_str() { + "true" | "1" => Ok(true), + "false" | "0" => Ok(false), + _ => Err(STRING_TO_BOOL_ERROR_MESSAGE), + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_string_to_bool_true_true() { + let result = string_to_bool("true"); + assert_eq!(result, Ok(true)); + } + + #[test] + fn test_string_to_bool_one_true() { + let result = string_to_bool("1"); + assert_eq!(result, Ok(true)); + } + + #[test] + fn test_string_to_bool_false_false() { + let result = string_to_bool("false"); + assert_eq!(result, Ok(false)); + } + + #[test] + fn test_string_to_bool_zero_false() { + let result = string_to_bool("0"); + assert_eq!(result, Ok(false)); + } + + #[test] + fn test_string_to_bool_bad_string_errors() { + let result = string_to_bool("hello world"); + assert_eq!(result, Err(STRING_TO_BOOL_ERROR_MESSAGE)); + } +} From 7472f9b8a353fd95511fff792c651df1d8b4fd52 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 09:26:44 +0200 Subject: [PATCH 100/214] [PM-10965] [deps]: Update @types/node to v20 (#962) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@types/node](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node) ([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node)) | [`^18.15.11` -> `^20.0.0`](https://renovatebot.com/diffs/npm/@types%2fnode/18.19.44/20.14.15) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2fnode/20.14.15?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@types%2fnode/20.14.15?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@types%2fnode/18.19.44/20.14.15?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2fnode/18.19.44/20.14.15?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). [PM-10965](https://bitwarden.atlassian.net/browse/PM-10965) [PM-10965]: https://bitwarden.atlassian.net/browse/PM-10965?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- languages/js/sdk-client/package-lock.json | 8 ++++---- languages/js/sdk-client/package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index a7fb0db7d..677fe7824 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -6,7 +6,7 @@ "": { "name": "@bitwarden/sdk-client", "devDependencies": { - "@types/node": "^18.15.11", + "@types/node": "^20.0.0", "rimraf": "^6.0.0", "typescript": "^5.0.3" } @@ -41,9 +41,9 @@ } }, "node_modules/@types/node": { - "version": "18.19.44", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.44.tgz", - "integrity": "sha512-ZsbGerYg72WMXUIE9fYxtvfzLEuq6q8mKERdWFnqTmOvudMxnz+CBNRoOwJ2kNpFOncrKjT1hZwxjlFgQ9qvQA==", + "version": "20.14.15", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.15.tgz", + "integrity": "sha512-Fz1xDMCF/B00/tYSVMlmK7hVeLh7jE5f3B7X1/hmV0MJBwE27KlS7EvD/Yp+z1lm8mVhwV5w+n8jOZG8AfTlKw==", "dev": true, "license": "MIT", "dependencies": { diff --git a/languages/js/sdk-client/package.json b/languages/js/sdk-client/package.json index 18bef74cb..17269acc6 100644 --- a/languages/js/sdk-client/package.json +++ b/languages/js/sdk-client/package.json @@ -13,7 +13,7 @@ "clean": "rimraf dist" }, "devDependencies": { - "@types/node": "^18.15.11", + "@types/node": "^20.0.0", "rimraf": "^6.0.0", "typescript": "^5.0.3" } From 7a18777de48cae1454aae46fe434a9083868804a Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Fri, 16 Aug 2024 11:50:21 -0700 Subject: [PATCH 101/214] [SM-1129] Run command with secrets (#621) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Type of change - [ ] Bug fix - [x] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ## Objective Add a `run` command to allow running processes with secrets injected. Example: `bws run 'docker compose up -d'`, `bws run -- docker compose up -d`, or from stdin: `echo 'docker compose up -d' | bws run` Where the compose file is expecting secrets: ```yaml services: echo: image: hashicorp/http-echo container_name: echo ports: - "127.0.0.1:5678:5678" command: [ "-text", "Local DB user: ${LOCAL_DB_USER}\nLocal DB pass: ${LOCAL_DB_PASS}", # secrets from Secrets Manager ] ``` Other examples: `bws run -- npm run start`, `bws run -- 'echo $SECRET_BY_NAME_FROM_SM'`, etc. A `--shell` option is provided to override the default shell (`sh` on UNIX-like OSes, and `powershell` on Windows) where the process is executed. A `--no-inherit-env` option is provided for additional safety in cases where you want to pass the minimum amount of values into a process. `$PATH` is always passed though, as omitting it would cause nearly every command to fail. If duplicate keynames are detected, the `run` command will error-out and suggest using the `--uuids-as-keynames` argument. This argument (and equivalent environment variable `BWS_UUIDS_AS_KEYNAMES`) will use the secret UUID (in POSIX-compliant form; ex `_36527bf9_ed6c_41ad_ba49_b11d00b371f4`). ## Code changes - **crates/bws/src/command/run.rs:** add the `run` command and associated args - **crates/bws/src/cli.rs:** add args for `--shell`, `--no-inherit-env`, and `--uuids-as-keynames`; add environment variable for `BWS_UUIDS_AS_KEYNAMES` - **crates/bws/src/util.rs:** add `is_valid_posix_name` and `uuid_to_posix` functions - **crates/bws/src/render.rs:** use `is_valid_posix_name` from `util` crate - **crates/bws/Cargo.toml:** use `which` to detect presence of a shell ## Before you submit - Please add **unit tests** where it makes sense to do so --------- Co-authored-by: Daniel García Co-authored-by: Oscar Hinton --- Cargo.lock | 20 +++++ crates/bws/Cargo.toml | 2 + crates/bws/src/cli.rs | 22 +++++ crates/bws/src/command/mod.rs | 1 + crates/bws/src/command/run.rs | 149 ++++++++++++++++++++++++++++++++++ crates/bws/src/main.rs | 22 +++++ crates/bws/src/render.rs | 7 +- crates/bws/src/util.rs | 51 +++++++++++- 8 files changed, 268 insertions(+), 6 deletions(-) create mode 100644 crates/bws/src/command/run.rs diff --git a/Cargo.lock b/Cargo.lock index f107c5d51..735a7fe14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -757,6 +757,7 @@ dependencies = [ "comfy-table", "directories", "env_logger", + "itertools 0.13.0", "log", "regex", "serde", @@ -768,6 +769,7 @@ dependencies = [ "tokio", "toml 0.8.19", "uuid", + "which", ] [[package]] @@ -4588,6 +4590,18 @@ dependencies = [ "nom", ] +[[package]] +name = "which" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8211e4f58a2b2805adfbefbc07bab82958fc91e3836339b1ab7ae32465dce0d7" +dependencies = [ + "either", + "home", + "rustix", + "winsafe", +] + [[package]] name = "winapi" version = "0.3.9" @@ -4795,6 +4809,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "winsafe" +version = "0.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" + [[package]] name = "wiremock" version = "0.6.1" diff --git a/crates/bws/Cargo.toml b/crates/bws/Cargo.toml index 6686b5e1e..1b13c68a1 100644 --- a/crates/bws/Cargo.toml +++ b/crates/bws/Cargo.toml @@ -30,6 +30,7 @@ color-eyre = "0.6.3" comfy-table = "7.1.1" directories = "5.0.1" env_logger = "0.11.1" +itertools = "0.13.0" log = "0.4.20" regex = { version = "1.10.3", features = [ "std", @@ -43,6 +44,7 @@ thiserror = "1.0.57" tokio = { version = "1.36.0", features = ["rt-multi-thread", "macros"] } toml = "0.8.10" uuid = { version = "1.7.0", features = ["serde"] } +which = "6.0.1" [build-dependencies] bitwarden-cli = { workspace = true } diff --git a/crates/bws/src/cli.rs b/crates/bws/src/cli.rs index f37a7ab5d..9c81e8bfd 100644 --- a/crates/bws/src/cli.rs +++ b/crates/bws/src/cli.rs @@ -9,6 +9,7 @@ pub(crate) const ACCESS_TOKEN_KEY_VAR_NAME: &str = "BWS_ACCESS_TOKEN"; pub(crate) const CONFIG_FILE_KEY_VAR_NAME: &str = "BWS_CONFIG_FILE"; pub(crate) const PROFILE_KEY_VAR_NAME: &str = "BWS_PROFILE"; pub(crate) const SERVER_URL_KEY_VAR_NAME: &str = "BWS_SERVER_URL"; +pub(crate) const UUIDS_AS_KEYNAMES_VAR_NAME: &str = "BWS_UUIDS_AS_KEYNAMES"; pub(crate) const DEFAULT_CONFIG_FILENAME: &str = "config"; pub(crate) const DEFAULT_CONFIG_DIRECTORY: &str = ".config/bws"; @@ -90,6 +91,27 @@ pub(crate) enum Commands { #[command(subcommand)] cmd: SecretCommand, }, + #[command(long_about = "Run a command with secrets injected")] + Run { + #[arg(help = "The command to run")] + command: Vec, + #[arg(long, help = "The shell to use")] + shell: Option, + #[arg( + long, + help = "Don't inherit environment variables from the current shell" + )] + no_inherit_env: bool, + #[arg(long, help = "The ID of the project to use")] + project_id: Option, + #[arg( + long, + global = true, + env = UUIDS_AS_KEYNAMES_VAR_NAME, + help = "Use the secret UUID (in its POSIX form) instead of the key name for the environment variable" + )] + uuids_as_keynames: bool, + }, } #[derive(Subcommand, Debug)] diff --git a/crates/bws/src/command/mod.rs b/crates/bws/src/command/mod.rs index adcea5964..98287e452 100644 --- a/crates/bws/src/command/mod.rs +++ b/crates/bws/src/command/mod.rs @@ -1,4 +1,5 @@ pub(crate) mod project; +pub(crate) mod run; pub(crate) mod secret; use std::{path::PathBuf, str::FromStr}; diff --git a/crates/bws/src/command/run.rs b/crates/bws/src/command/run.rs new file mode 100644 index 000000000..6548778eb --- /dev/null +++ b/crates/bws/src/command/run.rs @@ -0,0 +1,149 @@ +use std::{ + collections::HashMap, + io::{IsTerminal, Read}, + process, +}; + +use bitwarden::{ + secrets_manager::{ + secrets::{SecretIdentifiersByProjectRequest, SecretIdentifiersRequest, SecretsGetRequest}, + ClientSecretsExt, + }, + Client, +}; +use color_eyre::eyre::{bail, Result}; +use itertools::Itertools; +use uuid::Uuid; +use which::which; + +use crate::{ + util::{is_valid_posix_name, uuid_to_posix}, + ACCESS_TOKEN_KEY_VAR_NAME, +}; + +// Essential environment variables that should be preserved even when `--no-inherit-env` is used +const WINDOWS_ESSENTIAL_VARS: &[&str] = &["SystemRoot", "ComSpec", "windir"]; + +pub(crate) async fn run( + client: Client, + organization_id: Uuid, + project_id: Option, + uuids_as_keynames: bool, + no_inherit_env: bool, + shell: Option, + command: Vec, +) -> Result { + let is_windows = std::env::consts::OS == "windows"; + + let shell = shell.unwrap_or_else(|| { + if is_windows { + "powershell".to_string() + } else { + "sh".to_string() + } + }); + + if which(&shell).is_err() { + bail!("Shell '{}' not found", shell); + } + + let user_command = if command.is_empty() { + if std::io::stdin().is_terminal() { + bail!("No command provided"); + } + + let mut buffer = String::new(); + std::io::stdin().read_to_string(&mut buffer)?; + buffer + } else { + command.join(" ") + }; + + let res = if let Some(project_id) = project_id { + client + .secrets() + .list_by_project(&SecretIdentifiersByProjectRequest { project_id }) + .await? + } else { + client + .secrets() + .list(&SecretIdentifiersRequest { organization_id }) + .await? + }; + + let secret_ids = res.data.into_iter().map(|e| e.id).collect(); + let secrets = client + .secrets() + .get_by_ids(SecretsGetRequest { ids: secret_ids }) + .await? + .data; + + if !uuids_as_keynames { + if let Some(duplicate) = secrets.iter().map(|s| &s.key).duplicates().next() { + bail!("Multiple secrets with name: '{}'. Use --uuids-as-keynames or use unique names for secrets", duplicate); + } + } + + let environment: HashMap = secrets + .into_iter() + .map(|s| { + if uuids_as_keynames { + (uuid_to_posix(&s.id), s.value) + } else { + (s.key, s.value) + } + }) + .inspect(|(k, _)| { + if !is_valid_posix_name(k) { + eprintln!( + "Warning: secret '{}' does not have a POSIX-compliant name", + k + ); + } + }) + .collect(); + + let mut command = process::Command::new(shell); + command + .arg("-c") + .arg(&user_command) + .stdout(process::Stdio::inherit()) + .stderr(process::Stdio::inherit()); + + if no_inherit_env { + let path = std::env::var("PATH").unwrap_or_else(|_| match is_windows { + true => "C:\\Windows;C:\\Windows\\System32".to_string(), + false => "/bin:/usr/bin".to_string(), + }); + + command.env_clear(); + + // Preserve essential PowerShell environment variables on Windows + if is_windows { + for &var in WINDOWS_ESSENTIAL_VARS { + if let Ok(value) = std::env::var(var) { + command.env(var, value); + } + } + } + + command.env("PATH", path); // PATH is always necessary + command.envs(environment); + } else { + command.env_remove(ACCESS_TOKEN_KEY_VAR_NAME); + command.envs(environment); + } + + // propagate the exit status from the child process + match command.spawn() { + Ok(mut child) => match child.wait() { + Ok(exit_status) => Ok(exit_status.code().unwrap_or(1)), + Err(e) => { + bail!("Failed to wait for process: {}", e) + } + }, + Err(e) => { + bail!("Failed to execute process: {}", e) + } + } +} diff --git a/crates/bws/src/main.rs b/crates/bws/src/main.rs index 5d67bc103..e77c8fd24 100644 --- a/crates/bws/src/main.rs +++ b/crates/bws/src/main.rs @@ -131,6 +131,28 @@ async fn process_commands() -> Result<()> { command::secret::process_command(cmd, client, organization_id, output_settings).await } + Commands::Run { + command, + shell, + no_inherit_env, + project_id, + uuids_as_keynames, + } => { + let exit_code = command::run::run( + client, + organization_id, + project_id, + uuids_as_keynames, + no_inherit_env, + shell, + command, + ) + .await?; + + // exit with the exit code from the child process + std::process::exit(exit_code); + } + Commands::Config { .. } | Commands::Completions { .. } => { unreachable!() } diff --git a/crates/bws/src/render.rs b/crates/bws/src/render.rs index 7b286b511..bf0c26f6c 100644 --- a/crates/bws/src/render.rs +++ b/crates/bws/src/render.rs @@ -4,7 +4,7 @@ use chrono::{DateTime, Utc}; use comfy_table::Table; use serde::Serialize; -use crate::cli::Output; +use crate::{cli::Output, util::is_valid_posix_name}; const ASCII_HEADER_ONLY: &str = " -- "; @@ -37,15 +37,12 @@ pub(crate) fn serialize_response, const N: usiz pretty_print("yaml", &text, output_settings.color); } Output::Env => { - let valid_key_regex = - regex::Regex::new("^[a-zA-Z_][a-zA-Z0-9_]*$").expect("regex is valid"); - let mut commented_out = false; let mut text: Vec = data .get_values() .into_iter() .map(|row| { - if valid_key_regex.is_match(&row[1]) { + if is_valid_posix_name(&row[1]) { format!("{}=\"{}\"", row[1], row[2]) } else { commented_out = true; diff --git a/crates/bws/src/util.rs b/crates/bws/src/util.rs index a3541ffea..a86f0f569 100644 --- a/crates/bws/src/util.rs +++ b/crates/bws/src/util.rs @@ -1,5 +1,15 @@ +use regex::Regex; +use uuid::Uuid; + +const VALID_POSIX_NAME_REGEX: &str = "^[a-zA-Z_][a-zA-Z0-9_]*$"; const STRING_TO_BOOL_ERROR_MESSAGE: &str = "Could not convert string to bool"; +pub(crate) fn is_valid_posix_name(input_text: &str) -> bool { + Regex::new(VALID_POSIX_NAME_REGEX) + .expect("VALID_POSIX_NAME_REGEX to be a valid regex") + .is_match(input_text) +} + pub(crate) fn string_to_bool(value: &str) -> Result { match value.trim().to_lowercase().as_str() { "true" | "1" => Ok(true), @@ -8,10 +18,49 @@ pub(crate) fn string_to_bool(value: &str) -> Result { } } -#[cfg(test)] +/// Converts a UUID to a POSIX-compliant environment variable name. +/// +/// POSIX environment variable names must start with a letter or an underscore +/// and can only contain letters, numbers, and underscores. +pub(crate) fn uuid_to_posix(uuid: &Uuid) -> String { + format!("_{}", uuid.to_string().replace('-', "_")) +} + mod tests { + #[allow(unused_imports)] use super::*; + #[test] + fn test_is_valid_posix_name_true() { + assert!(is_valid_posix_name("a_valid_name")); + assert!(is_valid_posix_name("another_valid_name")); + assert!(is_valid_posix_name("_another_valid_name")); + assert!(is_valid_posix_name("ANOTHER_ONE")); + assert!(is_valid_posix_name( + "abcdefghijklmnopqrstuvwxyz__ABCDEFGHIJKLMNOPQRSTUVWXYZ__0123456789" + )); + } + + #[test] + fn test_is_valid_posix_name_false() { + assert!(!is_valid_posix_name("")); + assert!(!is_valid_posix_name("1a")); + assert!(!is_valid_posix_name("a bad name")); + assert!(!is_valid_posix_name("another-bad-name")); + assert!(!is_valid_posix_name("a\nbad\nname")); + } + + #[test] + fn test_uuid_to_posix_success() { + assert_eq!( + "_759130d0_29dd_48bd_831a_e3bdbafeeb6e", + uuid_to_posix( + &uuid::Uuid::parse_str("759130d0-29dd-48bd-831a-e3bdbafeeb6e").expect("valid uuid") + ) + ); + assert!(is_valid_posix_name(&uuid_to_posix(&uuid::Uuid::new_v4()))); + } + #[test] fn test_string_to_bool_true_true() { let result = string_to_bool("true"); From f8f9a58957b61eb7311bf79d965fe610e655f12d Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 09:25:03 +0200 Subject: [PATCH 102/214] [deps]: Lock file maintenance (#978) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. đŸ‘ģ **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 175 ++++++++++++---------- languages/js/example/package-lock.json | 2 +- languages/js/sdk-client/package-lock.json | 14 +- package-lock.json | 14 +- 4 files changed, 110 insertions(+), 95 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 735a7fe14..ecfc787bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -182,7 +182,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -231,7 +231,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -774,9 +774,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.16.3" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "102087e286b4677862ea56cf8fc58bb2cdfa8725c40ffb80fe3a008eb7f2fc83" +checksum = "6fd4c6dcc3b0aea2f5c0b4b82c2b15fe39ddbc76041a310848f4706edf76bb31" [[package]] name = "byteorder" @@ -798,9 +798,9 @@ checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" [[package]] name = "camino" -version = "1.1.7" +version = "1.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0ec6b951b160caa93cc0c7b209e5a3bff7aae9062213451ac99493cd844c239" +checksum = "8b96ec4966b5813e2c0507c1f86115c8c5abaadc3980879c3424042a02fd1ad3" dependencies = [ "serde", ] @@ -845,9 +845,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.10" +version = "1.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e8aabfac534be767c909e0690571677d49f41bd8465ae876fe043d52ba5292" +checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" +dependencies = [ + "shlex", +] [[package]] name = "cesu8" @@ -916,9 +919,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.15" +version = "4.5.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11d8838454fda655dafd3accb2b6e2bea645b9e4078abe84a22ceb947235c5cc" +checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" dependencies = [ "clap_builder", "clap_derive", @@ -938,9 +941,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.14" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d11bff0290e9a266fc9b4ce6fa96c2bf2ca3f9724c41c10202ac1daf7a087f8" +checksum = "1ee158892bd7ce77aa15c208abbdb73e155d191c287a659b57abd5adb92feb03" dependencies = [ "clap", ] @@ -954,7 +957,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -1126,9 +1129,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" dependencies = [ "libc", ] @@ -1297,7 +1300,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -1321,7 +1324,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -1332,7 +1335,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -1411,7 +1414,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -1421,7 +1424,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -1687,7 +1690,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -1821,7 +1824,7 @@ dependencies = [ "futures-core", "futures-sink", "http", - "indexmap 2.3.0", + "indexmap 2.4.0", "slab", "tokio", "tokio-util", @@ -1868,6 +1871,12 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "hermit-abi" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" + [[package]] name = "hex" version = "0.4.3" @@ -2070,9 +2079,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" +checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -2120,11 +2129,11 @@ checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" [[package]] name = "is-terminal" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b" +checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" dependencies = [ - "hermit-abi", + "hermit-abi 0.4.0", "libc", "windows-sys 0.52.0", ] @@ -2205,9 +2214,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.155" +version = "0.2.157" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "374af5f94e54fa97cf75e945cce8a6b201e88a1a07e688b47dfd2a59c66dbd86" [[package]] name = "libloading" @@ -2343,7 +2352,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80e04d1dcff3aae0704555fe5fee3bcfaf3d1fdf8a7e521d5b9d2b42acb52cec" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", "wasi", "windows-sys 0.52.0", @@ -2380,7 +2389,7 @@ dependencies = [ "napi-derive-backend", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -2395,7 +2404,7 @@ dependencies = [ "quote", "regex", "semver", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -2504,7 +2513,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi", + "hermit-abi 0.3.9", "libc", ] @@ -2670,7 +2679,7 @@ dependencies = [ "coset", "data-encoding", "getrandom", - "indexmap 2.3.0", + "indexmap 2.4.0", "rand", "serde", "serde_json", @@ -2745,7 +2754,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -2800,7 +2809,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" dependencies = [ "base64 0.22.1", - "indexmap 2.3.0", + "indexmap 2.4.0", "quick-xml", "serde", "time", @@ -2960,7 +2969,7 @@ dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -2973,7 +2982,7 @@ dependencies = [ "proc-macro2", "pyo3-build-config", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -3405,7 +3414,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -3437,7 +3446,7 @@ checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -3503,22 +3512,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.206" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b3e4cd94123dd520a128bcd11e34d9e9e423e7e3e50425cb1b4b1e3549d0284" +checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.206" +version = "1.0.208" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fabfb6138d2383ea8208cf98ccf69cdfb1aff4088460681d84189aa259762f97" +checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -3529,16 +3538,16 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] name = "serde_json" -version = "1.0.124" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66ad62847a56b3dba58cc891acd13884b9c61138d330c0d7b6181713d4fce38d" +checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" dependencies = [ - "indexmap 2.3.0", + "indexmap 2.4.0", "itoa", "memchr", "ryu", @@ -3564,7 +3573,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -3598,7 +3607,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.3.0", + "indexmap 2.4.0", "serde", "serde_derive", "serde_json", @@ -3615,7 +3624,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -3624,7 +3633,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.3.0", + "indexmap 2.4.0", "itoa", "ryu", "serde", @@ -3672,6 +3681,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + [[package]] name = "signal-hook" version = "0.3.17" @@ -3808,7 +3823,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -3821,7 +3836,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -3851,9 +3866,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.74" +version = "2.0.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fceb41e3d546d0bd83421d3409b1460cc7444cd389341a4c880fe7a042cb3d7" +checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" dependencies = [ "proc-macro2", "quote", @@ -3931,7 +3946,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -4002,9 +4017,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.2" +version = "1.39.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" +checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" dependencies = [ "backtrace", "bytes", @@ -4024,7 +4039,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -4087,7 +4102,7 @@ version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.3.0", + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -4111,15 +4126,15 @@ dependencies = [ [[package]] name = "tower-layer" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" [[package]] name = "tower-service" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" [[package]] name = "tracing" @@ -4275,12 +4290,12 @@ dependencies = [ [[package]] name = "uniffi_checksum_derive" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fcfa22f55829d3aaa7acfb1c5150224188fe0f27c59a8a3eddcaa24d1ffbe58" +checksum = "a22dbe67c1c957ac6e7611bdf605a6218aa86b0eebeb8be58b70ae85ad7d73dc" dependencies = [ "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -4312,7 +4327,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.74", + "syn 2.0.75", "toml 0.5.11", "uniffi_meta", ] @@ -4427,7 +4442,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -4491,7 +4506,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", "wasm-bindgen-shared", ] @@ -4525,7 +4540,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4559,14 +4574,14 @@ checksum = "4b8220be1fa9e4c889b30fd207d4906657e7e90b12e0e6b0c8b8d8709f5de021" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] name = "web-sys" -version = "0.3.69" +version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" +checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" dependencies = [ "js-sys", "wasm-bindgen", @@ -4592,9 +4607,9 @@ dependencies = [ [[package]] name = "which" -version = "6.0.1" +version = "6.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8211e4f58a2b2805adfbefbc07bab82958fc91e3836339b1ab7ae32465dce0d7" +checksum = "b4ee928febd44d98f2f459a4a79bd4d928591333a494a10a868418ac1b39cf1f" dependencies = [ "either", "home", @@ -4857,7 +4872,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] @@ -4878,7 +4893,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.74", + "syn 2.0.75", ] [[package]] diff --git a/languages/js/example/package-lock.json b/languages/js/example/package-lock.json index 82ac79b5a..2b7016955 100644 --- a/languages/js/example/package-lock.json +++ b/languages/js/example/package-lock.json @@ -13,7 +13,7 @@ "../sdk-client": { "name": "@bitwarden/sdk-client", "devDependencies": { - "@types/node": "^18.15.11", + "@types/node": "^20.0.0", "rimraf": "^6.0.0", "typescript": "^5.0.3" } diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index 677fe7824..d1e07c723 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -41,13 +41,13 @@ } }, "node_modules/@types/node": { - "version": "20.14.15", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.14.15.tgz", - "integrity": "sha512-Fz1xDMCF/B00/tYSVMlmK7hVeLh7jE5f3B7X1/hmV0MJBwE27KlS7EvD/Yp+z1lm8mVhwV5w+n8jOZG8AfTlKw==", + "version": "20.16.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.0.tgz", + "integrity": "sha512-vDxceJcoZhIVh67S568bm1UGZO0DX0hpplJZxzeXMKwIPLn190ec5RRxQ69BKhX44SUGIxxgMdDY557lGLKprQ==", "dev": true, "license": "MIT", "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~6.19.2" } }, "node_modules/ansi-regex": { @@ -464,9 +464,9 @@ } }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "version": "6.19.6", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.6.tgz", + "integrity": "sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==", "dev": true, "license": "MIT" }, diff --git a/package-lock.json b/package-lock.json index 6ecbfe72d..eb615f178 100644 --- a/package-lock.json +++ b/package-lock.json @@ -370,14 +370,14 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.2.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.2.0.tgz", - "integrity": "sha512-bm6EG6/pCpkxDf/0gDNDdtDILMOHgaQBVOJGdwsqClnxA3xL6jtMv76rLBc006RVMWbmaf0xbmom4Z/5o2nRkQ==", + "version": "22.4.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.4.0.tgz", + "integrity": "sha512-49AbMDwYUz7EXxKU/r7mXOsxwFr4BYbvB7tWYxVuLdb2ibd30ijjXINSMAHiEEZk5PCRBmW1gUeisn2VMKt3cQ==", "dev": true, "license": "MIT", "peer": true, "dependencies": { - "undici-types": "~6.13.0" + "undici-types": "~6.19.2" } }, "node_modules/abort-controller": { @@ -2200,9 +2200,9 @@ } }, "node_modules/undici-types": { - "version": "6.13.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.13.0.tgz", - "integrity": "sha512-xtFJHudx8S2DSoujjMd1WeWvn7KKWFRESZTMeL1RptAYERu29D6jphMjjY+vn96jvN3kVPDNxU/E13VTaXj6jg==", + "version": "6.19.6", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.6.tgz", + "integrity": "sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==", "dev": true, "license": "MIT", "peer": true From 0d4c73c276c41c23603d89d93c7751aa13ed3a80 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 09:28:48 +0200 Subject: [PATCH 103/214] [deps]: Update @types/node to v20.16.1 (#975) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@types/node](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node) ([source](https://togithub.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node)) | [`20.16.0` -> `20.16.1`](https://renovatebot.com/diffs/npm/@types%2fnode/20.16.0/20.16.1) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@types%2fnode/20.16.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@types%2fnode/20.16.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@types%2fnode/20.16.0/20.16.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@types%2fnode/20.16.0/20.16.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- languages/js/sdk-client/package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index d1e07c723..035fc1cbc 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -41,9 +41,9 @@ } }, "node_modules/@types/node": { - "version": "20.16.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.0.tgz", - "integrity": "sha512-vDxceJcoZhIVh67S568bm1UGZO0DX0hpplJZxzeXMKwIPLn190ec5RRxQ69BKhX44SUGIxxgMdDY557lGLKprQ==", + "version": "20.16.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.1.tgz", + "integrity": "sha512-zJDo7wEadFtSyNz5QITDfRcrhqDvQI1xQNQ0VoizPjM/dVAODqqIUWbJPkvsxmTI0MYRGRikcdjMPhOssnPejQ==", "dev": true, "license": "MIT", "dependencies": { From de3b6e2bdddb8acf5c31db12a8e649e0042621bd Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 19 Aug 2024 14:33:29 +0200 Subject: [PATCH 104/214] [PM-10929] Support Key Connector (#959) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/PM-10929 ## 📔 Objective Add support for Key Connector. - Adds support for `KeyConnector` to `initialize_user_crypto`. - Support generating a random master key that can be sent to the key connector. - Support getting the current master key and sending it to the key connector. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-core/src/auth/client_auth.rs | 15 +++- .../bitwarden-core/src/auth/key_connector.rs | 42 ++++++++++ crates/bitwarden-core/src/auth/mod.rs | 4 + .../src/mobile/client_crypto.rs | 13 ++- crates/bitwarden-core/src/mobile/crypto.rs | 81 ++++++++++++++----- .../bitwarden-crypto/src/keys/master_key.rs | 18 ++++- crates/bitwarden-uniffi/src/auth/mod.rs | 19 ++++- crates/bitwarden-uniffi/src/crypto.rs | 8 +- 8 files changed, 163 insertions(+), 37 deletions(-) create mode 100644 crates/bitwarden-core/src/auth/key_connector.rs diff --git a/crates/bitwarden-core/src/auth/client_auth.rs b/crates/bitwarden-core/src/auth/client_auth.rs index 6f1afb135..829868556 100644 --- a/crates/bitwarden-core/src/auth/client_auth.rs +++ b/crates/bitwarden-core/src/auth/client_auth.rs @@ -1,16 +1,18 @@ #[cfg(feature = "internal")] -use bitwarden_crypto::{AsymmetricEncString, DeviceKey, EncString, Kdf, TrustDeviceResponse}; +use bitwarden_crypto::{ + AsymmetricEncString, CryptoError, DeviceKey, EncString, Kdf, TrustDeviceResponse, +}; -#[cfg(feature = "internal")] -use crate::auth::login::NewAuthRequestResponse; #[cfg(feature = "secrets")] use crate::auth::login::{login_access_token, AccessTokenLoginRequest, AccessTokenLoginResponse}; #[cfg(feature = "internal")] use crate::auth::{ auth_request::{approve_auth_request, new_auth_request}, + key_connector::{make_key_connector_keys, KeyConnectorResponse}, login::{ login_api_key, login_password, send_two_factor_email, ApiKeyLoginRequest, - ApiKeyLoginResponse, PasswordLoginRequest, PasswordLoginResponse, TwoFactorEmailRequest, + ApiKeyLoginResponse, NewAuthRequestResponse, PasswordLoginRequest, PasswordLoginResponse, + TwoFactorEmailRequest, }, password::{ password_strength, satisfies_policy, validate_password, validate_password_user_key, @@ -79,6 +81,11 @@ impl<'a> ClientAuth<'a> { make_register_tde_keys(self.client, email, org_public_key, remember_device) } + pub fn make_key_connector_keys(&self) -> Result { + let mut rng = rand::thread_rng(); + make_key_connector_keys(&mut rng) + } + pub async fn register(&self, input: &RegisterRequest) -> Result<()> { register(self.client, input).await } diff --git a/crates/bitwarden-core/src/auth/key_connector.rs b/crates/bitwarden-core/src/auth/key_connector.rs new file mode 100644 index 000000000..b4006b472 --- /dev/null +++ b/crates/bitwarden-core/src/auth/key_connector.rs @@ -0,0 +1,42 @@ +use bitwarden_crypto::{CryptoError, MasterKey, RsaKeyPair}; + +#[cfg_attr(feature = "uniffi", derive(uniffi::Record))] +pub struct KeyConnectorResponse { + pub master_key: String, + pub encrypted_user_key: String, + pub keys: RsaKeyPair, +} + +pub(super) fn make_key_connector_keys( + mut rng: impl rand::RngCore, +) -> Result { + let master_key = MasterKey::generate(&mut rng); + let (user_key, encrypted_user_key) = master_key.make_user_key()?; + let keys = user_key.make_key_pair()?; + + Ok(KeyConnectorResponse { + master_key: master_key.to_base64(), + encrypted_user_key: encrypted_user_key.to_string(), + keys, + }) +} + +#[cfg(test)] +mod tests { + use rand::SeedableRng; + use rand_chacha::ChaCha8Rng; + + use super::*; + + #[test] + fn test_make_key_connector_keys() { + let mut rng = ChaCha8Rng::from_seed([0u8; 32]); + + let result = make_key_connector_keys(&mut rng).unwrap(); + + assert_eq!( + result.master_key, + "PgDvL4lfQNZ/W7joHwmloSyEDsPOmn87GBvhiO9xGh4=" + ); + } +} diff --git a/crates/bitwarden-core/src/auth/mod.rs b/crates/bitwarden-core/src/auth/mod.rs index e52870570..30babdc7d 100644 --- a/crates/bitwarden-core/src/auth/mod.rs +++ b/crates/bitwarden-core/src/auth/mod.rs @@ -30,6 +30,10 @@ pub use register::{RegisterKeyResponse, RegisterRequest}; mod tde; #[cfg(feature = "internal")] pub use tde::RegisterTdeKeyResponse; +#[cfg(feature = "internal")] +mod key_connector; +#[cfg(feature = "internal")] +pub use key_connector::KeyConnectorResponse; #[cfg(feature = "internal")] use crate::error::Result; diff --git a/crates/bitwarden-core/src/mobile/client_crypto.rs b/crates/bitwarden-core/src/mobile/client_crypto.rs index 88e359844..293b8f9b3 100644 --- a/crates/bitwarden-core/src/mobile/client_crypto.rs +++ b/crates/bitwarden-core/src/mobile/client_crypto.rs @@ -1,6 +1,7 @@ #[cfg(feature = "internal")] use bitwarden_crypto::{AsymmetricEncString, EncString}; +use super::crypto::{derive_key_connector, DeriveKeyConnectorRequest}; use crate::Client; #[cfg(feature = "internal")] use crate::{ @@ -17,40 +18,38 @@ pub struct ClientCrypto<'a> { } impl<'a> ClientCrypto<'a> { - #[cfg(feature = "internal")] pub async fn initialize_user_crypto(&self, req: InitUserCryptoRequest) -> Result<()> { initialize_user_crypto(self.client, req).await } - #[cfg(feature = "internal")] pub async fn initialize_org_crypto(&self, req: InitOrgCryptoRequest) -> Result<()> { initialize_org_crypto(self.client, req).await } - #[cfg(feature = "internal")] pub async fn get_user_encryption_key(&self) -> Result { get_user_encryption_key(self.client).await } - #[cfg(feature = "internal")] pub fn update_password(&self, new_password: String) -> Result { update_password(self.client, new_password) } - #[cfg(feature = "internal")] pub fn derive_pin_key(&self, pin: String) -> Result { derive_pin_key(self.client, pin) } - #[cfg(feature = "internal")] pub fn derive_pin_user_key(&self, encrypted_pin: EncString) -> Result { derive_pin_user_key(self.client, encrypted_pin) } - #[cfg(feature = "internal")] pub fn enroll_admin_password_reset(&self, public_key: String) -> Result { enroll_admin_password_reset(self.client, public_key) } + + /// Derive the master key for migrating to the key connector + pub fn derive_key_connector(&self, request: DeriveKeyConnectorRequest) -> Result { + derive_key_connector(request) + } } impl<'a> Client { diff --git a/crates/bitwarden-core/src/mobile/crypto.rs b/crates/bitwarden-core/src/mobile/crypto.rs index 3f8bc562c..15ddeb9b7 100644 --- a/crates/bitwarden-core/src/mobile/crypto.rs +++ b/crates/bitwarden-core/src/mobile/crypto.rs @@ -1,19 +1,18 @@ use std::collections::HashMap; -use bitwarden_crypto::{AsymmetricEncString, EncString}; -#[cfg(feature = "internal")] -use bitwarden_crypto::{Kdf, KeyDecryptable, KeyEncryptable, MasterKey, SymmetricCryptoKey}; +use bitwarden_crypto::{ + AsymmetricEncString, EncString, Kdf, KeyDecryptable, KeyEncryptable, MasterKey, + SymmetricCryptoKey, +}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -#[cfg(feature = "internal")] -use crate::client::{LoginMethod, UserLoginMethod}; use crate::{ + client::{LoginMethod, UserLoginMethod}, error::{Error, Result}, Client, }; -#[cfg(feature = "internal")] #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] @@ -28,7 +27,6 @@ pub struct InitUserCryptoRequest { pub method: InitUserCryptoMethod, } -#[cfg(feature = "internal")] #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "uniffi", derive(uniffi::Enum))] @@ -64,9 +62,14 @@ pub enum InitUserCryptoMethod { /// The user's symmetric crypto key, encrypted with the Device Key. device_protected_user_key: AsymmetricEncString, }, + KeyConnector { + /// Base64 encoded master key, retrieved from the key connector. + master_key: String, + /// The user's encrypted symmetric crypto key + user_key: String, + }, } -#[cfg(feature = "internal")] #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "uniffi", derive(uniffi::Enum))] @@ -83,7 +86,6 @@ pub enum AuthRequestMethod { }, } -#[cfg(feature = "internal")] pub async fn initialize_user_crypto(client: &Client, req: InitUserCryptoRequest) -> Result<()> { use bitwarden_crypto::{DeviceKey, PinKey}; @@ -151,6 +153,17 @@ pub async fn initialize_user_crypto(client: &Client, req: InitUserCryptoRequest) .internal .initialize_user_crypto_decrypted_key(user_key, private_key)?; } + InitUserCryptoMethod::KeyConnector { + master_key, + user_key, + } => { + let master_key = MasterKey::new(SymmetricCryptoKey::try_from(master_key)?); + let user_key: EncString = user_key.parse()?; + + client + .internal + .initialize_user_crypto_master_key(master_key, user_key, private_key)?; + } } client @@ -166,7 +179,6 @@ pub async fn initialize_user_crypto(client: &Client, req: InitUserCryptoRequest) Ok(()) } -#[cfg(feature = "internal")] #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] @@ -175,14 +187,12 @@ pub struct InitOrgCryptoRequest { pub organization_keys: HashMap, } -#[cfg(feature = "internal")] pub async fn initialize_org_crypto(client: &Client, req: InitOrgCryptoRequest) -> Result<()> { let organization_keys = req.organization_keys.into_iter().collect(); client.internal.initialize_org_crypto(organization_keys)?; Ok(()) } -#[cfg(feature = "internal")] pub async fn get_user_encryption_key(client: &Client) -> Result { let enc = client.internal.get_encryption_settings()?; let user_key = enc.get_key(&None)?; @@ -190,7 +200,6 @@ pub async fn get_user_encryption_key(client: &Client) -> Result { Ok(user_key.to_base64()) } -#[cfg(feature = "internal")] #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] @@ -233,7 +242,6 @@ pub fn update_password(client: &Client, new_password: String) -> Result Result { let enc = client.internal.get_encryption_settings()?; let user_key = enc.get_key(&None)?; @@ -262,7 +269,6 @@ pub fn derive_pin_key(client: &Client, pin: String) -> Result Result { let enc = client.internal.get_encryption_settings()?; let user_key = enc.get_key(&None)?; @@ -276,7 +282,6 @@ pub fn derive_pin_user_key(client: &Client, encrypted_pin: EncString) -> Result< derive_pin_protected_user_key(&pin, &login_method, user_key) } -#[cfg(feature = "internal")] fn derive_pin_protected_user_key( pin: &str, login_method: &LoginMethod, @@ -296,7 +301,6 @@ fn derive_pin_protected_user_key( Ok(derived_key.encrypt_user_key(user_key)?) } -#[cfg(feature = "internal")] pub(super) fn enroll_admin_password_reset( client: &Client, public_key: String, @@ -314,8 +318,30 @@ pub(super) fn enroll_admin_password_reset( )?) } +#[cfg_attr(feature = "uniffi", derive(uniffi::Record))] +pub struct DeriveKeyConnectorRequest { + /// Encrypted user key, used to validate the master key + pub user_key_encrypted: EncString, + + pub password: String, + pub kdf: Kdf, + pub email: String, +} + +/// Derive the master key for migrating to the key connector +pub(super) fn derive_key_connector(request: DeriveKeyConnectorRequest) -> Result { + let master_key = MasterKey::derive(&request.password, &request.email, &request.kdf)?; + master_key + .decrypt_user_key(request.user_key_encrypted) + .map_err(|_| "wrong password")?; + + Ok(master_key.to_base64()) +} + #[cfg(test)] mod tests { + use std::num::NonZeroU32; + use super::*; use crate::Client; @@ -495,11 +521,8 @@ mod tests { ); } - #[cfg(feature = "internal")] #[test] fn test_enroll_admin_password_reset() { - use std::num::NonZeroU32; - use base64::{engine::general_purpose::STANDARD, Engine}; use bitwarden_crypto::AsymmetricCryptoKey; @@ -534,4 +557,20 @@ mod tests { let expected = enc.get_key(&None).unwrap(); assert_eq!(&decrypted, &expected.to_vec()); } + + #[test] + fn test_derive_key_connector() { + let request = DeriveKeyConnectorRequest { + password: "asdfasdfasdf".to_string(), + email: "test@bitwarden.com".to_string(), + kdf: Kdf::PBKDF2 { + iterations: NonZeroU32::new(600_000).unwrap(), + }, + user_key_encrypted: "2.Q/2PhzcC7GdeiMHhWguYAQ==|GpqzVdr0go0ug5cZh1n+uixeBC3oC90CIe0hd/HWA/pTRDZ8ane4fmsEIcuc8eMKUt55Y2q/fbNzsYu41YTZzzsJUSeqVjT8/iTQtgnNdpo=|dwI+uyvZ1h/iZ03VQ+/wrGEFYVewBUUl/syYgjsNMbE=".parse().unwrap(), + }; + + let result = derive_key_connector(request).unwrap(); + + assert_eq!(result, "ySXq1RVLKEaV1eoQE/ui9aFKIvXTl9PAXwp1MljfF50="); + } } diff --git a/crates/bitwarden-crypto/src/keys/master_key.rs b/crates/bitwarden-crypto/src/keys/master_key.rs index 83e51a1b2..fc9762c3c 100644 --- a/crates/bitwarden-crypto/src/keys/master_key.rs +++ b/crates/bitwarden-crypto/src/keys/master_key.rs @@ -1,6 +1,8 @@ use std::num::NonZeroU32; use base64::{engine::general_purpose::STANDARD, Engine}; +use generic_array::{typenum::U32, GenericArray}; +use rand::Rng; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -64,10 +66,20 @@ pub enum HashPurpose { pub struct MasterKey(SymmetricCryptoKey); impl MasterKey { - pub fn new(key: SymmetricCryptoKey) -> MasterKey { + pub fn new(key: SymmetricCryptoKey) -> Self { Self(key) } + /// Generate a new random master key. Primarily used for KeyConnector. + pub fn generate(mut rng: impl rand::RngCore) -> Self { + let mut key = Box::pin(GenericArray::::default()); + + rng.fill(key.as_mut_slice()); + + // Master Keys never contains a mac_key. + Self::new(SymmetricCryptoKey { key, mac_key: None }) + } + /// Derives a users master key from their password, email and KDF. /// /// Note: the email is trimmed and converted to lowercase before being used. @@ -101,6 +113,10 @@ impl MasterKey { pub fn decrypt_user_key(&self, user_key: EncString) -> Result { decrypt_user_key(&self.0, user_key) } + + pub fn to_base64(&self) -> String { + self.0.to_base64() + } } /// Helper function to encrypt a user key with a master or pin key. diff --git a/crates/bitwarden-uniffi/src/auth/mod.rs b/crates/bitwarden-uniffi/src/auth/mod.rs index 644580c5d..d036991e3 100644 --- a/crates/bitwarden-uniffi/src/auth/mod.rs +++ b/crates/bitwarden-uniffi/src/auth/mod.rs @@ -1,8 +1,11 @@ use std::sync::Arc; -use bitwarden::auth::{ - password::MasterPasswordPolicyOptions, AuthRequestResponse, RegisterKeyResponse, - RegisterTdeKeyResponse, +use bitwarden::{ + auth::{ + password::MasterPasswordPolicyOptions, AuthRequestResponse, KeyConnectorResponse, + RegisterKeyResponse, RegisterTdeKeyResponse, + }, + Error, }; use bitwarden_crypto::{AsymmetricEncString, EncString, HashPurpose, Kdf, TrustDeviceResponse}; @@ -79,6 +82,16 @@ impl ClientAuth { .make_register_tde_keys(email, org_public_key, remember_device)?) } + /// Generate keys needed to onboard a new user without master key to key connector + pub fn make_key_connector_keys(&self) -> Result { + Ok(self + .0 + .0 + .auth() + .make_key_connector_keys() + .map_err(Error::Crypto)?) + } + /// Validate the user password /// /// To retrieve the user's password hash, use [`ClientAuth::hash_password`] with diff --git a/crates/bitwarden-uniffi/src/crypto.rs b/crates/bitwarden-uniffi/src/crypto.rs index 761a72bc2..8a089404a 100644 --- a/crates/bitwarden-uniffi/src/crypto.rs +++ b/crates/bitwarden-uniffi/src/crypto.rs @@ -1,7 +1,8 @@ use std::sync::Arc; use bitwarden::mobile::crypto::{ - DerivePinKeyResponse, InitOrgCryptoRequest, InitUserCryptoRequest, UpdatePasswordResponse, + DeriveKeyConnectorRequest, DerivePinKeyResponse, InitOrgCryptoRequest, InitUserCryptoRequest, + UpdatePasswordResponse, }; use bitwarden_crypto::{AsymmetricEncString, EncString}; @@ -52,4 +53,9 @@ impl ClientCrypto { pub fn enroll_admin_password_reset(&self, public_key: String) -> Result { Ok(self.0 .0.crypto().enroll_admin_password_reset(public_key)?) } + + /// Derive the master key for migrating to the key connector + pub fn derive_key_connector(&self, request: DeriveKeyConnectorRequest) -> Result { + Ok(self.0 .0.crypto().derive_key_connector(request)?) + } } From 2ff096f4dbfde6d08373e3cad8e47ae7843ab73c Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 19 Aug 2024 17:36:19 +0200 Subject: [PATCH 105/214] Bump MSRV to 1.75 (#980) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective The #972 PR requires MSRV 1.73, and #924 will require. MSRV 1.75. To avoid upgrading twice I suggest immediately changing to 1.75. This is noted as a change in both the CLI and bitwarden change logs. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/minimum-rust-version.yml | 2 +- crates/bitwarden/CHANGELOG.md | 1 + crates/bws/CHANGELOG.md | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/minimum-rust-version.yml b/.github/workflows/minimum-rust-version.yml index d4dac0e8d..19b81de63 100644 --- a/.github/workflows/minimum-rust-version.yml +++ b/.github/workflows/minimum-rust-version.yml @@ -34,7 +34,7 @@ jobs: with: # Important: When updating this, make sure to update the Readme file # and also the `rust-version` field in all the `Cargo.toml`. - toolchain: 1.71.0 + toolchain: 1.75.0 targets: ${{ matrix.settings.target }} - name: Cache cargo registry diff --git a/crates/bitwarden/CHANGELOG.md b/crates/bitwarden/CHANGELOG.md index 8b622ca3b..689b58e72 100644 --- a/crates/bitwarden/CHANGELOG.md +++ b/crates/bitwarden/CHANGELOG.md @@ -17,6 +17,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - Secrets Manager now requires `bitwarden::secrets_manager::ClientSecretsExt` and `bitwarden::secrets_manager::ClientProjectsExt` to be imported in order to access `secrets()` and `projects` on the client (#798) +- Updated MSRV `1.75.0` (#980) ### Removed diff --git a/crates/bws/CHANGELOG.md b/crates/bws/CHANGELOG.md index 695ab43df..2690c14f2 100644 --- a/crates/bws/CHANGELOG.md +++ b/crates/bws/CHANGELOG.md @@ -11,6 +11,10 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - The ability to edit unassigned secrets with direct permissions. (#906) +### Changed + +- Updated MSRV `1.75.0` (#980) + ### Removed - The deprecated `action type` commands are now removed. Please use `type action` instead. (#836) From d287ef3022ec3d8801abdf915a4a20ba263166a2 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 18:02:35 +0200 Subject: [PATCH 106/214] [deps]: Update Rust crate uniffi to v0.28.1 (#972) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [uniffi](https://mozilla.github.io/uniffi-rs) ([source](https://togithub.com/mozilla/uniffi-rs)) | dependencies | patch | `=0.28.0` -> `=0.28.1` | | [uniffi](https://mozilla.github.io/uniffi-rs) ([source](https://togithub.com/mozilla/uniffi-rs)) | build-dependencies | patch | `=0.28.0` -> `=0.28.1` | --- ### Release Notes
mozilla/uniffi-rs (uniffi) ### [`v0.28.1`](https://togithub.com/mozilla/uniffi-rs/blob/HEAD/CHANGELOG.md#v0281-backend-crates-v0281---2024-08-09) [Compare Source](https://togithub.com/mozilla/uniffi-rs/compare/v0.28.0...v0.28.1) ##### What's new? - Lift errors will not cause an abort when `panic=abort` is set. - Added the `cargo_metadata` feature, which is on by default. In some cases, this can be disabled for better compatibility with projects that don't use cargo. - A new bindgen command line option `--metadata-no-deps` is available to avoid processing cargo_metadata for all dependencies. - In UDL it's now possible (and preferred) to remove the `[Rust=]` attribute and use a plain-old typedef. See [the manual page for this](https://mozilla.github.io/uniffi-rs/next/udl/ext_types.html#types-from-procmacros-in-this-crate). ##### What's changed? - Kotlin will use the more efficient Enum.entries property instead of Enum.values() when possible [All changes in v0.28.1](https://togithub.com/mozilla/uniffi-rs/compare/v0.28.0...v0.28.1).
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 34 +++++++++++++------------- crates/bitwarden-core/Cargo.toml | 2 +- crates/bitwarden-crypto/Cargo.toml | 2 +- crates/bitwarden-exporters/Cargo.toml | 2 +- crates/bitwarden-fido/Cargo.toml | 2 +- crates/bitwarden-generators/Cargo.toml | 2 +- crates/bitwarden-send/Cargo.toml | 2 +- crates/bitwarden-uniffi/Cargo.toml | 4 +-- crates/bitwarden-vault/Cargo.toml | 2 +- crates/uniffi-bindgen/Cargo.toml | 2 +- 10 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ecfc787bd..b8f6cdc5b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4233,12 +4233,13 @@ checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] name = "uniffi" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31bff6daf87277a9014bcdefbc2842b0553392919d1096843c5aad899ca4588" +checksum = "2db87def739fe4183947f8419d572d1849a4a09355eba4e988a2105cfd0ac6a7" dependencies = [ "anyhow", "camino", + "cargo_metadata", "clap", "uniffi_bindgen", "uniffi_build", @@ -4255,9 +4256,9 @@ dependencies = [ [[package]] name = "uniffi_bindgen" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96061d7e01b185aa405f7c9b134741ab3e50cc6796a47d6fd8ab9a5364b5feed" +checksum = "7a112599c9556d1581e4a3d72019a74c2c3e122cc27f4af12577a429c4d5e614" dependencies = [ "anyhow", "askama", @@ -4273,15 +4274,14 @@ dependencies = [ "textwrap", "toml 0.5.11", "uniffi_meta", - "uniffi_testing", "uniffi_udl", ] [[package]] name = "uniffi_build" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6b86f9b221046af0c533eafe09ece04e2f1ded04ccdc9bba0ec09aec1c52bd" +checksum = "e2b12684401d2a8508ca9c72a95bbc45906417e42fc80942abaf033bbf01aa33" dependencies = [ "anyhow", "camino", @@ -4300,9 +4300,9 @@ dependencies = [ [[package]] name = "uniffi_core" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3210d57d6ab6065ab47a2898dacdb7c606fd6a4156196831fa3bf82e34ac58a6" +checksum = "5a0c35aaad30e3a9e6d4fe34e358d64dbc92ee09045b48591b05fc9f12e0905b" dependencies = [ "anyhow", "async-compat", @@ -4316,9 +4316,9 @@ dependencies = [ [[package]] name = "uniffi_macros" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b58691741080935437dc862122e68d7414432a11824ac1137868de46181a0bd2" +checksum = "db66474c5c61b0f7afc3b4995fecf9b72b340daa5ca0ef3da7778d75eb5482ea" dependencies = [ "bincode", "camino", @@ -4334,9 +4334,9 @@ dependencies = [ [[package]] name = "uniffi_meta" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7663eacdbd9fbf4a88907ddcfe2e6fa85838eb6dc2418a7d91eebb3786f8e20b" +checksum = "d898893f102e0e39b8bcb7e3d2188f4156ba280db32db9e8af1f122d057e9526" dependencies = [ "anyhow", "bytes", @@ -4346,9 +4346,9 @@ dependencies = [ [[package]] name = "uniffi_testing" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f922465f7566f25f8fe766920205fdfa9a3fcdc209c6bfb7557f0b5bf45b04dd" +checksum = "2c6aa4f0cf9d12172d84fc00a35a6c1f3522b526daad05ae739f709f6941b9b6" dependencies = [ "anyhow", "camino", @@ -4359,9 +4359,9 @@ dependencies = [ [[package]] name = "uniffi_udl" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cef408229a3a407fafa4c36dc4f6ece78a6fb258ab28d2b64bddd49c8cb680f6" +checksum = "6b044e9c519e0bb51e516ab6f6d8f4f4dcf900ce30d5ad07c03f924e2824f28e" dependencies = [ "anyhow", "textwrap", diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml index 365db9443..3247b66bc 100644 --- a/crates/bitwarden-core/Cargo.toml +++ b/crates/bitwarden-core/Cargo.toml @@ -58,7 +58,7 @@ serde_repr = ">=0.1.12, <0.2" sha1 = ">=0.10.5, <0.11" sha2 = ">=0.10.6, <0.11" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.28.0", optional = true, features = ["tokio"] } +uniffi = { version = "=0.28.1", optional = true, features = ["tokio"] } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } validator = { version = "0.18.1", features = ["derive"] } zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } diff --git a/crates/bitwarden-crypto/Cargo.toml b/crates/bitwarden-crypto/Cargo.toml index f2bbc6f7e..b071b4ee9 100644 --- a/crates/bitwarden-crypto/Cargo.toml +++ b/crates/bitwarden-crypto/Cargo.toml @@ -42,7 +42,7 @@ sha1 = ">=0.10.5, <0.11" sha2 = ">=0.10.6, <0.11" subtle = ">=2.5.0, <3.0" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.28.0", optional = true } +uniffi = { version = "=0.28.1", optional = true } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } diff --git a/crates/bitwarden-exporters/Cargo.toml b/crates/bitwarden-exporters/Cargo.toml index 128cde6e6..858e9f522 100644 --- a/crates/bitwarden-exporters/Cargo.toml +++ b/crates/bitwarden-exporters/Cargo.toml @@ -32,7 +32,7 @@ schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } serde_json = ">=1.0.96, <2.0" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.28.0", optional = true } +uniffi = { version = "=0.28.1", optional = true } uuid = { version = ">=1.3.3, <2.0", features = ["serde", "v4"] } [lints] diff --git a/crates/bitwarden-fido/Cargo.toml b/crates/bitwarden-fido/Cargo.toml index 45d180ce8..e85e56a19 100644 --- a/crates/bitwarden-fido/Cargo.toml +++ b/crates/bitwarden-fido/Cargo.toml @@ -36,7 +36,7 @@ schemars = { version = "0.8.21", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } serde_json = ">=1.0.96, <2.0" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.28.0", optional = true } +uniffi = { version = "=0.28.1", optional = true } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } [lints] diff --git a/crates/bitwarden-generators/Cargo.toml b/crates/bitwarden-generators/Cargo.toml index acb87fa4b..442e00c08 100644 --- a/crates/bitwarden-generators/Cargo.toml +++ b/crates/bitwarden-generators/Cargo.toml @@ -28,7 +28,7 @@ schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } serde_json = ">=1.0.96, <2.0" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.28.0", optional = true } +uniffi = { version = "=0.28.1", optional = true } [dev-dependencies] rand_chacha = "0.3.1" diff --git a/crates/bitwarden-send/Cargo.toml b/crates/bitwarden-send/Cargo.toml index a7d5ec488..417cac89e 100644 --- a/crates/bitwarden-send/Cargo.toml +++ b/crates/bitwarden-send/Cargo.toml @@ -33,7 +33,7 @@ schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } serde_repr = ">=0.1.12, <0.2" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.28.0", optional = true } +uniffi = { version = "=0.28.1", optional = true } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } zeroize = { version = ">=1.7.0, <2.0" } diff --git a/crates/bitwarden-uniffi/Cargo.toml b/crates/bitwarden-uniffi/Cargo.toml index eba12649c..561fe55d1 100644 --- a/crates/bitwarden-uniffi/Cargo.toml +++ b/crates/bitwarden-uniffi/Cargo.toml @@ -35,7 +35,7 @@ log = "0.4.20" env_logger = "0.11.1" schemars = { version = ">=0.8, <0.9", optional = true } thiserror = ">=1.0.40, <2.0" -uniffi = "=0.28.0" +uniffi = "=0.28.1" uuid = ">=1.3.3, <2" [target.'cfg(target_os = "android")'.dependencies] @@ -45,7 +45,7 @@ android_logger = "0.14" oslog = "0.2.0" [build-dependencies] -uniffi = { version = "=0.28.0", features = ["build"] } +uniffi = { version = "=0.28.1", features = ["build"] } [lints] workspace = true diff --git a/crates/bitwarden-vault/Cargo.toml b/crates/bitwarden-vault/Cargo.toml index a5052eca2..04a64078f 100644 --- a/crates/bitwarden-vault/Cargo.toml +++ b/crates/bitwarden-vault/Cargo.toml @@ -39,7 +39,7 @@ serde_repr = ">=0.1.12, <0.2" sha1 = ">=0.10.5, <0.11" sha2 = ">=0.10.6, <0.11" thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.28.0", optional = true } +uniffi = { version = "=0.28.1", optional = true } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } [dev-dependencies] diff --git a/crates/uniffi-bindgen/Cargo.toml b/crates/uniffi-bindgen/Cargo.toml index ba6e00ddf..042ea8b65 100644 --- a/crates/uniffi-bindgen/Cargo.toml +++ b/crates/uniffi-bindgen/Cargo.toml @@ -17,4 +17,4 @@ name = "uniffi-bindgen" path = "uniffi-bindgen.rs" [dependencies] -uniffi = { version = "=0.28.0", features = ["cli"] } +uniffi = { version = "=0.28.1", features = ["cli"] } From 5149ec3cce82b19f57b92fedf746c8ba3957f6aa Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 20 Aug 2024 10:28:27 +0200 Subject: [PATCH 107/214] [deps]: Update Rust crate clap_complete to v4.5.19 (#968) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [clap_complete](https://togithub.com/clap-rs/clap) | build-dependencies | patch | `4.5.18` -> `4.5.19` | | [clap_complete](https://togithub.com/clap-rs/clap) | dependencies | patch | `4.5.18` -> `4.5.19` | --- ### Release Notes
clap-rs/clap (clap_complete) ### [`v4.5.19`](https://togithub.com/clap-rs/clap/compare/clap_complete-v4.5.18...clap_complete-v4.5.19) [Compare Source](https://togithub.com/clap-rs/clap/compare/clap_complete-v4.5.18...clap_complete-v4.5.19)
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b8f6cdc5b..b33da52a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -941,9 +941,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.18" +version = "4.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ee158892bd7ce77aa15c208abbdb73e155d191c287a659b57abd5adb92feb03" +checksum = "7eddf1c00919f37952199f7dbc834789cd33356ed10278ee40c8572b8fb88cf2" dependencies = [ "clap", ] @@ -2225,7 +2225,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.52.6", + "windows-targets 0.48.5", ] [[package]] From 9134e98dc066034d6fe9b163816f1258b0fa423b Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Tue, 20 Aug 2024 10:38:25 -0400 Subject: [PATCH 108/214] [SM-1413] Resolve Concurrency Issues in C FFI (#981) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1413 ## 📔 Objective ### The Issue Through the C FFI, we were running into concurrency issues with multiple Tokio runtimes. A draft PR showing the concurrency issue with instructions can be found [here](https://github.com/bitwarden/sdk/pull/955). ### The Fix This PR fixes this issue for `bitwarden-c` and `bitwarden-py`, by preserving the runtime. Thanks @dani-garcia for the fix and working together on this one! ### Extra This also refactors the `AccessTokenLogin` type as a follow up for testing purposes for Go as initiated by [this](https://github.com/bitwarden/sdk/pull/953) PR. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-c/src/c.rs | 37 ++++++++++++++++++++++--------- crates/bitwarden-py/src/client.rs | 16 ++++++------- languages/go/bitwarden_client.go | 2 +- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/crates/bitwarden-c/src/c.rs b/crates/bitwarden-c/src/c.rs index 32abe3dc0..bd10f7d88 100644 --- a/crates/bitwarden-c/src/c.rs +++ b/crates/bitwarden-c/src/c.rs @@ -4,17 +4,24 @@ use bitwarden_json::client::Client; use crate::{box_ptr, ffi_ref}; +#[repr(C)] +pub struct CClient { + /// Associates the tokio runtime to the `Client`, ensuring the runtime has the same lifecycle + /// as the `Client`. + runtime: tokio::runtime::Runtime, + client: Client, +} + #[no_mangle] -#[tokio::main] -pub async extern "C" fn run_command( - c_str_ptr: *const c_char, - client_ptr: *const Client, -) -> *mut c_char { +pub extern "C" fn run_command(c_str_ptr: *const c_char, client_ptr: *const CClient) -> *mut c_char { let client = unsafe { ffi_ref!(client_ptr) }; let input_str = str::from_utf8(unsafe { CStr::from_ptr(c_str_ptr) }.to_bytes()) .expect("Input should be a valid string"); - let result = client.run_command(input_str).await; + let result = client + .runtime + .block_on(client.client.run_command(input_str)); + match std::ffi::CString::new(result) { Ok(cstr) => cstr.into_raw(), Err(_) => panic!("failed to return command result: null encountered"), @@ -23,17 +30,25 @@ pub async extern "C" fn run_command( // Init client, potential leak! You need to call free_mem after this! #[no_mangle] -pub extern "C" fn init(c_str_ptr: *const c_char) -> *mut Client { +pub extern "C" fn init(c_str_ptr: *const c_char) -> *mut CClient { // This will only fail if another logger was already initialized, so we can ignore the result let _ = env_logger::try_init(); - if c_str_ptr.is_null() { - box_ptr!(Client::new(None)) + + let runtime = tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build() + .expect("Failed to build tokio runtime"); + + let client = if c_str_ptr.is_null() { + Client::new(None) } else { let input_string = str::from_utf8(unsafe { CStr::from_ptr(c_str_ptr) }.to_bytes()) .expect("Input should be a valid string") .to_owned(); - box_ptr!(Client::new(Some(input_string))) - } + Client::new(Some(input_string)) + }; + + box_ptr!(CClient { runtime, client }) } // Free mem diff --git a/crates/bitwarden-py/src/client.rs b/crates/bitwarden-py/src/client.rs index 510de1db4..9c12a624d 100644 --- a/crates/bitwarden-py/src/client.rs +++ b/crates/bitwarden-py/src/client.rs @@ -2,7 +2,7 @@ use bitwarden_json::client::Client as JsonClient; use pyo3::prelude::*; #[pyclass] -pub struct BitwardenClient(JsonClient); +pub struct BitwardenClient(tokio::runtime::Runtime, JsonClient); #[pymethods] impl BitwardenClient { @@ -13,16 +13,16 @@ impl BitwardenClient { // result let _ = pyo3_log::try_init(); - Self(JsonClient::new(settings_string)) + let runtime = tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build() + .expect("Failed to build tokio runtime"); + + Self(runtime, JsonClient::new(settings_string)) } #[pyo3(text_signature = "($self, command_input)")] fn run_command(&self, command_input: String) -> String { - run_command(&self.0, &command_input) + self.0.block_on(self.1.run_command(&command_input)) } } - -#[tokio::main] -async fn run_command(client: &JsonClient, input_str: &str) -> String { - client.run_command(input_str).await -} diff --git a/languages/go/bitwarden_client.go b/languages/go/bitwarden_client.go index c6c9e09b4..5e951ecd1 100644 --- a/languages/go/bitwarden_client.go +++ b/languages/go/bitwarden_client.go @@ -54,7 +54,7 @@ func NewBitwardenClient(apiURL *string, identityURL *string) (BitwardenClientInt func (c *BitwardenClient) AccessTokenLogin(accessToken string, stateFile *string) error { req := AccessTokenLoginRequest{AccessToken: accessToken, StateFile: stateFile} - command := Command{AccessTokenLogin: &req} + command := Command{LoginAccessToken: &req} responseStr, err := c.commandRunner.RunCommand(command) if err != nil { From bfe98e0b106d93c8c18f05d325de6c060a6f2bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Wed, 21 Aug 2024 11:57:39 +0200 Subject: [PATCH 109/214] [PM-5635] Support rustls-platform-verifier on Android (#639) ## Type of change ``` - [ ] Bug fix - [ ] New feature development - [x] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ``` ## Objective Support rustls-platform-verifier on Android, I still have some errors with some self signed certificates left to investigate, but it works already with valid certificates. --- Cargo.lock | 5 +- crates/bitwarden-core/Cargo.toml | 15 +--- crates/bitwarden-core/src/client/client.rs | 2 +- crates/bitwarden-uniffi/Cargo.toml | 5 ++ .../bitwarden-uniffi/src/android_support.rs | 77 +++++++++++++++++++ crates/bitwarden-uniffi/src/lib.rs | 7 ++ .../kotlin/app/src/main/AndroidManifest.xml | 1 + .../bitwarden/myapplication/MainActivity.kt | 5 ++ .../main/res/xml/network_security_config.xml | 24 ++++++ languages/kotlin/sdk/build.gradle | 1 + languages/kotlin/settings.gradle | 17 ++++ 11 files changed, 144 insertions(+), 15 deletions(-) create mode 100644 crates/bitwarden-uniffi/src/android_support.rs create mode 100644 languages/kotlin/app/src/main/res/xml/network_security_config.xml diff --git a/Cargo.lock b/Cargo.lock index b33da52a2..8ec312beb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -634,8 +634,11 @@ dependencies = [ "bitwarden-vault", "chrono", "env_logger", + "jni", + "libloading", "log", "oslog", + "rustls-platform-verifier", "schemars", "thiserror", "uniffi", @@ -1998,7 +2001,6 @@ dependencies = [ "tokio", "tokio-rustls", "tower-service", - "webpki-roots", ] [[package]] @@ -3190,7 +3192,6 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "webpki-roots", "winreg", ] diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml index 3247b66bc..07a7ba426 100644 --- a/crates/bitwarden-core/Cargo.toml +++ b/crates/bitwarden-core/Cargo.toml @@ -64,22 +64,13 @@ validator = { version = "0.18.1", features = ["derive"] } zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } zxcvbn = ">=3.0.1, <4.0" -[target.'cfg(all(not(target_os = "android"), not(target_arch="wasm32")))'.dependencies] +[target.'cfg(not(target_arch="wasm32"))'.dependencies] # By default, we use rustls as the TLS stack and rust-platform-verifier to support user-installed root certificates -# There are a few exceptions to this: -# - WASM doesn't require a TLS stack, as it just uses the browsers/node fetch -# - Android uses webpki-roots for the moment +# The only exception is WASM, as it just uses the browsers/node fetch reqwest = { version = ">=0.12.5, <0.13", features = [ "rustls-tls-manual-roots", ], default-features = false } -rustls-platform-verifier = "0.3.1" - -[target.'cfg(target_os = "android")'.dependencies] -# On android, the use of rustls-platform-verifier is more complicated and going through some changes at the moment, so we fall back to using webpki-roots -# This means that for the moment android won't support self-signed certificates, even if they are included in the OS trust store -reqwest = { version = ">=0.12.5, <0.13", features = [ - "rustls-tls-webpki-roots", -], default-features = false } +rustls-platform-verifier = "0.3.3" [dev-dependencies] bitwarden-crypto = { workspace = true } diff --git a/crates/bitwarden-core/src/client/client.rs b/crates/bitwarden-core/src/client/client.rs index 3ea4ae7e8..e736d8c99 100644 --- a/crates/bitwarden-core/src/client/client.rs +++ b/crates/bitwarden-core/src/client/client.rs @@ -25,7 +25,7 @@ impl Client { #[allow(unused_mut)] let mut client_builder = reqwest::Client::builder(); - #[cfg(all(not(target_os = "android"), not(target_arch = "wasm32")))] + #[cfg(not(target_arch = "wasm32"))] { client_builder = client_builder.use_preconfigured_tls(rustls_platform_verifier::tls_config()); diff --git a/crates/bitwarden-uniffi/Cargo.toml b/crates/bitwarden-uniffi/Cargo.toml index 561fe55d1..414948d4d 100644 --- a/crates/bitwarden-uniffi/Cargo.toml +++ b/crates/bitwarden-uniffi/Cargo.toml @@ -41,6 +41,11 @@ uuid = ">=1.3.3, <2" [target.'cfg(target_os = "android")'.dependencies] android_logger = "0.14" +# The use of rustls-platform-verifier requires some extra support to communicate with the Android platform +jni = ">=0.19, <0.20" +libloading = ">=0.8.1, <0.9" +rustls-platform-verifier = "0.3.3" + [target.'cfg(target_os = "ios")'.dependencies] oslog = "0.2.0" diff --git a/crates/bitwarden-uniffi/src/android_support.rs b/crates/bitwarden-uniffi/src/android_support.rs new file mode 100644 index 000000000..c6d8b70a7 --- /dev/null +++ b/crates/bitwarden-uniffi/src/android_support.rs @@ -0,0 +1,77 @@ +use std::error::Error; + +use jni::sys::{jint, jsize, JavaVM}; + +pub fn init() { + static ANDROID_INIT: std::sync::Once = std::sync::Once::new(); + + fn init_inner() -> Result<(), Box> { + let jvm = java_vm()?; + let env = jvm.attach_current_thread_permanently()?; + init_verifier(&env)?; + Ok(()) + } + + ANDROID_INIT.call_once(|| { + if let Err(e) = init_inner() { + log::error!("Failed to initialize Android support: {}", e); + } + }); +} + +type JniGetCreatedJavaVms = + unsafe extern "system" fn(vmBuf: *mut *mut JavaVM, bufLen: jsize, nVMs: *mut jsize) -> jint; +const JNI_GET_JAVA_VMS_NAME: &[u8] = b"JNI_GetCreatedJavaVMs"; + +fn java_vm() -> Result> { + // Ideally we would use JNI to get a reference to the JavaVM, but that's not possible since + // UniFFI uses JNA + // + // If we could use JNI, we'd just need to export a function and call it from the Android app: + // #[export_name = "Java_com_orgname_android_rust_init"] + // extern "C" fn java_init(env: JNIEnv, _class: JClass, context: JObject, ) -> jboolean { + // + // Instead we have to use libloading to get a reference to the JavaVM: + // + // https://github.com/mozilla/uniffi-rs/issues/1778#issuecomment-1807979746 + let lib = libloading::os::unix::Library::this(); + let get_created_java_vms: JniGetCreatedJavaVms = unsafe { *lib.get(JNI_GET_JAVA_VMS_NAME)? }; + + let mut java_vms: [*mut JavaVM; 1] = [std::ptr::null_mut() as *mut JavaVM]; + let mut vm_count: i32 = 0; + + let ok = unsafe { get_created_java_vms(java_vms.as_mut_ptr(), 1, &mut vm_count) }; + if ok != jni::sys::JNI_OK { + return Err("Failed to get JavaVM".into()); + } + if vm_count != 1 { + return Err(format!("Invalid JavaVM count: {vm_count}").into()); + } + + let jvm = unsafe { jni::JavaVM::from_raw(java_vms[0]) }?; + Ok(jvm) +} + +fn init_verifier(env: &jni::JNIEnv<'_>) -> jni::errors::Result<()> { + let activity_thread = env + .call_static_method( + "android/app/ActivityThread", + "currentActivityThread", + "()Landroid/app/ActivityThread;", + &[], + )? + .l()?; + + let context = env + .call_method( + activity_thread, + "getApplication", + "()Landroid/app/Application;", + &[], + )? + .l()?; + + Ok(rustls_platform_verifier::android::init_hosted( + &env, context, + )?) +} diff --git a/crates/bitwarden-uniffi/src/lib.rs b/crates/bitwarden-uniffi/src/lib.rs index f1ce2123f..d0209de01 100644 --- a/crates/bitwarden-uniffi/src/lib.rs +++ b/crates/bitwarden-uniffi/src/lib.rs @@ -16,6 +16,9 @@ pub mod vault; #[cfg(feature = "docs")] pub mod docs; +#[cfg(target_os = "android")] +mod android_support; + use crypto::ClientCrypto; use error::Result; use platform::ClientPlatform; @@ -31,6 +34,10 @@ impl Client { #[uniffi::constructor] pub fn new(settings: Option) -> Arc { init_logger(); + + #[cfg(target_os = "android")] + android_support::init(); + Arc::new(Self(bitwarden::Client::new(settings))) } diff --git a/languages/kotlin/app/src/main/AndroidManifest.xml b/languages/kotlin/app/src/main/AndroidManifest.xml index 09e0fe67a..de89e684b 100644 --- a/languages/kotlin/app/src/main/AndroidManifest.xml +++ b/languages/kotlin/app/src/main/AndroidManifest.xml @@ -11,6 +11,7 @@ android:fullBackupContent="@xml/backup_rules" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" + android:networkSecurityConfig="@xml/network_security_config" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.MyApplication" diff --git a/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt b/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt index c65e0d3c6..e421416d6 100644 --- a/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt +++ b/languages/kotlin/app/src/main/java/com/bitwarden/myapplication/MainActivity.kt @@ -63,6 +63,11 @@ import javax.net.ssl.X509TrustManager * handle a lot of errors and edge cases that a production application would need to deal with. * Developers are encouraged to review and improve the code as needed to meet their security requirements. * Additionally, we recommend to consult with security experts and conduct thorough testing before using the code in production. + * + * Note that this SDK uses the system trust store to perform TLS certificate validation. If you want to use this SDK with + * self hosted servers using self-signed certificates, make sure to configure the Android Network Security Config correctly. + * We provide an example configuration in `languages/kotlin/app/src/main/res/xml/network_security_config.xml` + * https://developer.android.com/privacy-and-security/security-config */ const val SERVER_URL = "https://10.0.2.2:8080/" diff --git a/languages/kotlin/app/src/main/res/xml/network_security_config.xml b/languages/kotlin/app/src/main/res/xml/network_security_config.xml new file mode 100644 index 000000000..a164210ed --- /dev/null +++ b/languages/kotlin/app/src/main/res/xml/network_security_config.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + bitwarden.com + + + + + + + bitwarden.eu + + + + + + diff --git a/languages/kotlin/sdk/build.gradle b/languages/kotlin/sdk/build.gradle index 14f6f943c..c41bccac1 100644 --- a/languages/kotlin/sdk/build.gradle +++ b/languages/kotlin/sdk/build.gradle @@ -85,6 +85,7 @@ publishing { dependencies { implementation 'net.java.dev.jna:jna:5.14.0@aar' + implementation 'rustls:rustls-platform-verifier:latest.release' implementation 'androidx.core:core-ktx:1.13.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3' diff --git a/languages/kotlin/settings.gradle b/languages/kotlin/settings.gradle index fd45e3140..e82ac3727 100644 --- a/languages/kotlin/settings.gradle +++ b/languages/kotlin/settings.gradle @@ -10,8 +10,25 @@ dependencyResolutionManagement { repositories { google() mavenCentral() + + maven { + url = findRustlsPlatformVerifierProject() + metadataSources.artifact() + } } } + +String findRustlsPlatformVerifierProject() { + def dependencyText = providers.exec { + it.workingDir = new File("../../") + commandLine("cargo", "metadata", "--format-version", "1", "--manifest-path", "crates/bitwarden-uniffi/Cargo.toml") + }.standardOutput.asText.get() + + def dependencyJson = new groovy.json.JsonSlurper().parseText(dependencyText) + def manifestPath = file(dependencyJson.packages.find { it.name == "rustls-platform-verifier-android" }.manifest_path) + return new File(manifestPath.parentFile, "maven").path +} + rootProject.name = "My Application" include ':app' include ':sdk' From 38c352e92dddeba3d1eb9c3e74fe251ea7536db2 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Wed, 21 Aug 2024 18:17:53 +0200 Subject: [PATCH 110/214] Update api-bindings to 1a584b4 (#984) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective Update api bindings to server revision [server#1a584b4477fb24f0ab2c8d01bcf4096d07eebe31](https://github.com/bitwarden/server/commit/1a584b4477fb24f0ab2c8d01bcf4096d07eebe31) ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .../.openapi-generator/FILES | 33 +-- crates/bitwarden-api-api/README.md | 56 +++-- .../src/apis/access_policies_api.rs | 52 +++++ .../src/apis/accounts_api.rs | 150 +++++-------- .../bitwarden-api-api/src/apis/ciphers_api.rs | 49 ----- .../bitwarden-api-api/src/apis/counts_api.rs | 174 +++++++++++++++ .../bitwarden-api-api/src/apis/devices_api.rs | 46 ++++ crates/bitwarden-api-api/src/apis/mod.rs | 3 + .../apis/organization_auth_requests_api.rs | 56 +++++ .../src/apis/organization_billing_api.rs | 55 ++++- .../src/apis/organization_users_api.rs | 56 +++++ .../src/apis/organizations_api.rs | 51 ----- .../src/apis/provider_billing_api.rs | 157 ++++++++++++++ .../src/apis/request_sm_access_api.rs | 66 ++++++ .../bitwarden-api-api/src/apis/stripe_api.rs | 110 ++++++++++ .../src/apis/two_factor_api.rs | 54 +++++ .../src/models/billing_response_model.rs | 39 ---- .../models/bit_pay_invoice_request_model.rs | 3 + .../src/models/event_type.rs | 2 + ...licy_permission_details_response_model.rs} | 10 +- ...d_project_access_policy_response_model.rs} | 23 +- ... => group_access_policy_response_model.rs} | 20 +- .../models/group_details_response_model.rs | 3 - .../src/models/group_request_model.rs | 5 +- .../src/models/group_response_model.rs | 3 - ...ce_account_access_policy_response_model.rs | 57 ----- crates/bitwarden-api-api/src/models/mod.rs | 60 +++--- ..._auth_request_update_many_request_model.rs | 33 +++ .../organization_counts_response_model.rs | 36 ++++ .../src/models/organization_response_model.rs | 6 - ...rganization_subscription_response_model.rs | 6 - ...rganization_user_details_response_model.rs | 3 - .../organization_user_invite_request_model.rs | 3 - ...r_reset_password_details_response_model.rs | 3 + ...ails_response_model_list_response_model.rs | 33 +++ ...reset_password_enrollment_request_model.rs | 3 + .../src/models/organization_user_type.rs | 2 - .../organization_user_update_request_model.rs | 3 - ...zation_user_user_details_response_model.rs | 3 - ...rd_manager_plan_features_response_model.rs | 12 ++ .../src/models/plan_response_model.rs | 6 +- .../src/models/policy_type.rs | 2 + .../src/models/prelogin_request_model.rs | 25 --- .../src/models/prelogin_response_model.rs | 36 ---- .../{product_type.rs => product_tier_type.rs} | 8 +- .../profile_organization_response_model.rs | 15 +- ...le_provider_organization_response_model.rs | 15 +- .../models/project_counts_response_model.rs | 36 ++++ ...t_people_access_policies_response_model.rs | 4 +- ..._accounts_access_policies_request_model.rs | 11 +- ...accounts_access_policies_response_model.rs | 2 +- ...ion_organization_details_response_model.rs | 6 + .../provider_organization_response_model.rs | 6 + .../src/models/register_request_model.rs | 66 ------ .../src/models/register_response_model.rs | 30 --- .../models/request_sm_access_request_model.rs | 30 +++ ...eset_password_with_org_id_request_model.rs | 3 + .../secret_access_policies_requests_model.rs | 37 ++++ .../secret_access_policies_response_model.rs | 43 ++++ .../src/models/secret_create_request_model.rs | 6 + .../src/models/secret_update_request_model.rs | 6 + ...ce_account_access_policy_response_model.rs | 39 ++++ .../service_account_counts_response_model.rs | 36 ++++ ...icies_permission_details_response_model.rs | 2 +- ..._account_granted_policies_request_model.rs | 11 +- ...t_people_access_policies_response_model.rs | 4 +- .../models/tax_information_request_body.rs | 45 ++++ ...tor_authenticator_disable_request_model.rs | 52 +++++ ...two_factor_authenticator_response_model.rs | 6 + .../models/two_factor_duo_response_model.rs | 6 + .../src/models/update_key_request_model.rs | 3 + ..._tde_offboarding_password_request_model.rs | 36 ++++ ..._two_factor_authenticator_request_model.rs | 6 + .../update_two_factor_duo_request_model.rs | 24 ++- ...s => user_access_policy_response_model.rs} | 23 +- ...ce_account_access_policy_response_model.rs | 63 ------ .../web_authn_credential_response_model.rs | 6 + ...eb_authn_login_rotate_key_request_model.rs | 37 ++++ .../.openapi-generator/FILES | 6 + crates/bitwarden-api-identity/README.md | 34 +-- .../src/apis/accounts_api.rs | 201 ++++++++++++++++++ .../bitwarden-api-identity/src/models/mod.rs | 12 ++ .../src/models/product_tier_type.rs | 53 +++++ .../src/models/product_type.rs | 47 ++++ .../models/register_finish_request_model.rs | 70 ++++++ ...r_send_verification_email_request_model.rs | 36 ++++ ...erification_email_clicked_request_model.rs | 33 +++ ...l_send_verification_email_request_model.rs | 42 ++++ .../src/admin_console/policy.rs | 4 + crates/bitwarden-sm/src/secrets/create.rs | 1 + crates/bitwarden-sm/src/secrets/update.rs | 1 + 91 files changed, 2141 insertions(+), 730 deletions(-) create mode 100644 crates/bitwarden-api-api/src/apis/counts_api.rs create mode 100644 crates/bitwarden-api-api/src/apis/request_sm_access_api.rs create mode 100644 crates/bitwarden-api-api/src/apis/stripe_api.rs delete mode 100644 crates/bitwarden-api-api/src/models/billing_response_model.rs rename crates/bitwarden-api-api/src/models/{service_account_project_access_policy_permission_details_response_model.rs => granted_project_access_policy_permission_details_response_model.rs} (66%) rename crates/bitwarden-api-api/src/models/{service_account_project_access_policy_response_model.rs => granted_project_access_policy_response_model.rs} (52%) rename crates/bitwarden-api-api/src/models/{group_project_access_policy_response_model.rs => group_access_policy_response_model.rs} (60%) delete mode 100644 crates/bitwarden-api-api/src/models/group_service_account_access_policy_response_model.rs create mode 100644 crates/bitwarden-api-api/src/models/organization_auth_request_update_many_request_model.rs create mode 100644 crates/bitwarden-api-api/src/models/organization_counts_response_model.rs create mode 100644 crates/bitwarden-api-api/src/models/organization_user_reset_password_details_response_model_list_response_model.rs delete mode 100644 crates/bitwarden-api-api/src/models/prelogin_request_model.rs delete mode 100644 crates/bitwarden-api-api/src/models/prelogin_response_model.rs rename crates/bitwarden-api-api/src/models/{product_type.rs => product_tier_type.rs} (86%) create mode 100644 crates/bitwarden-api-api/src/models/project_counts_response_model.rs delete mode 100644 crates/bitwarden-api-api/src/models/register_request_model.rs delete mode 100644 crates/bitwarden-api-api/src/models/register_response_model.rs create mode 100644 crates/bitwarden-api-api/src/models/request_sm_access_request_model.rs create mode 100644 crates/bitwarden-api-api/src/models/secret_access_policies_requests_model.rs create mode 100644 crates/bitwarden-api-api/src/models/secret_access_policies_response_model.rs create mode 100644 crates/bitwarden-api-api/src/models/service_account_access_policy_response_model.rs create mode 100644 crates/bitwarden-api-api/src/models/service_account_counts_response_model.rs create mode 100644 crates/bitwarden-api-api/src/models/tax_information_request_body.rs create mode 100644 crates/bitwarden-api-api/src/models/two_factor_authenticator_disable_request_model.rs create mode 100644 crates/bitwarden-api-api/src/models/update_tde_offboarding_password_request_model.rs rename crates/bitwarden-api-api/src/models/{user_project_access_policy_response_model.rs => user_access_policy_response_model.rs} (58%) delete mode 100644 crates/bitwarden-api-api/src/models/user_service_account_access_policy_response_model.rs create mode 100644 crates/bitwarden-api-api/src/models/web_authn_login_rotate_key_request_model.rs create mode 100644 crates/bitwarden-api-identity/src/models/product_tier_type.rs create mode 100644 crates/bitwarden-api-identity/src/models/product_type.rs create mode 100644 crates/bitwarden-api-identity/src/models/register_finish_request_model.rs create mode 100644 crates/bitwarden-api-identity/src/models/register_send_verification_email_request_model.rs create mode 100644 crates/bitwarden-api-identity/src/models/register_verification_email_clicked_request_model.rs create mode 100644 crates/bitwarden-api-identity/src/models/trial_send_verification_email_request_model.rs diff --git a/crates/bitwarden-api-api/.openapi-generator/FILES b/crates/bitwarden-api-api/.openapi-generator/FILES index e9cae26d1..7ff73f0b3 100644 --- a/crates/bitwarden-api-api/.openapi-generator/FILES +++ b/crates/bitwarden-api-api/.openapi-generator/FILES @@ -9,6 +9,7 @@ src/apis/ciphers_api.rs src/apis/collections_api.rs src/apis/config_api.rs src/apis/configuration.rs +src/apis/counts_api.rs src/apis/devices_api.rs src/apis/emergency_access_api.rs src/apis/events_api.rs @@ -38,6 +39,7 @@ src/apis/provider_organizations_api.rs src/apis/provider_users_api.rs src/apis/providers_api.rs src/apis/push_api.rs +src/apis/request_sm_access_api.rs src/apis/secrets_api.rs src/apis/secrets_manager_events_api.rs src/apis/secrets_manager_porting_api.rs @@ -46,6 +48,7 @@ src/apis/self_hosted_organization_sponsorships_api.rs src/apis/sends_api.rs src/apis/service_accounts_api.rs src/apis/settings_api.rs +src/apis/stripe_api.rs src/apis/sync_api.rs src/apis/trash_api.rs src/apis/two_factor_api.rs @@ -84,7 +87,6 @@ src/models/billing_customer_discount.rs src/models/billing_history_response_model.rs src/models/billing_invoice.rs src/models/billing_payment_response_model.rs -src/models/billing_response_model.rs src/models/billing_source.rs src/models/billing_subscription.rs src/models/billing_subscription_item.rs @@ -178,14 +180,15 @@ src/models/get_secrets_request_model.rs src/models/global_domains.rs src/models/global_equivalent_domains_type.rs src/models/granted_access_policy_request.rs +src/models/granted_project_access_policy_permission_details_response_model.rs +src/models/granted_project_access_policy_response_model.rs src/models/group.rs +src/models/group_access_policy_response_model.rs src/models/group_bulk_request_model.rs src/models/group_details_response_model.rs src/models/group_details_response_model_list_response_model.rs -src/models/group_project_access_policy_response_model.rs src/models/group_request_model.rs src/models/group_response_model.rs -src/models/group_service_account_access_policy_response_model.rs src/models/import_ciphers_request_model.rs src/models/import_organization_ciphers_request_model.rs src/models/import_organization_users_request_model.rs @@ -212,12 +215,14 @@ src/models/organization_api_key_information.rs src/models/organization_api_key_information_list_response_model.rs src/models/organization_api_key_request_model.rs src/models/organization_api_key_type.rs +src/models/organization_auth_request_update_many_request_model.rs src/models/organization_auto_enroll_status_response_model.rs src/models/organization_billing_status_response_model.rs src/models/organization_collection_management_update_request_model.rs src/models/organization_connection_request_model.rs src/models/organization_connection_response_model.rs src/models/organization_connection_type.rs +src/models/organization_counts_response_model.rs src/models/organization_create_request_model.rs src/models/organization_domain_request_model.rs src/models/organization_domain_response_model.rs @@ -255,6 +260,7 @@ src/models/organization_user_invite_request_model.rs src/models/organization_user_public_key_response_model.rs src/models/organization_user_public_key_response_model_list_response_model.rs src/models/organization_user_reset_password_details_response_model.rs +src/models/organization_user_reset_password_details_response_model_list_response_model.rs src/models/organization_user_reset_password_enrollment_request_model.rs src/models/organization_user_reset_password_request_model.rs src/models/organization_user_status_type.rs @@ -285,14 +291,13 @@ src/models/policy_response_model_list_response_model.rs src/models/policy_type.rs src/models/potential_grantee_response_model.rs src/models/potential_grantee_response_model_list_response_model.rs -src/models/prelogin_request_model.rs -src/models/prelogin_response_model.rs -src/models/product_type.rs +src/models/product_tier_type.rs src/models/profile_organization_response_model.rs src/models/profile_organization_response_model_list_response_model.rs src/models/profile_provider_organization_response_model.rs src/models/profile_provider_response_model.rs src/models/profile_response_model.rs +src/models/project_counts_response_model.rs src/models/project_create_request_model.rs src/models/project_people_access_policies_response_model.rs src/models/project_response_model.rs @@ -337,14 +342,15 @@ src/models/push_registration_request_model.rs src/models/push_send_request_model.rs src/models/push_type.rs src/models/push_update_request_model.rs -src/models/register_request_model.rs -src/models/register_response_model.rs +src/models/request_sm_access_request_model.rs src/models/reset_password_with_org_id_request_model.rs src/models/response_data.rs src/models/revoke_access_tokens_request.rs src/models/saml2_binding_type.rs src/models/saml2_name_id_format.rs src/models/saml2_signing_behavior.rs +src/models/secret_access_policies_requests_model.rs +src/models/secret_access_policies_response_model.rs src/models/secret_create_request_model.rs src/models/secret_response_inner_project.rs src/models/secret_response_model.rs @@ -371,12 +377,12 @@ src/models/send_text_model.rs src/models/send_type.rs src/models/send_with_id_request_model.rs src/models/server_config_response_model.rs +src/models/service_account_access_policy_response_model.rs +src/models/service_account_counts_response_model.rs src/models/service_account_create_request_model.rs src/models/service_account_granted_policies_permission_details_response_model.rs src/models/service_account_granted_policies_request_model.rs src/models/service_account_people_access_policies_response_model.rs -src/models/service_account_project_access_policy_permission_details_response_model.rs -src/models/service_account_project_access_policy_response_model.rs src/models/service_account_response_model.rs src/models/service_account_secrets_details_response_model.rs src/models/service_account_secrets_details_response_model_list_response_model.rs @@ -395,9 +401,11 @@ src/models/subscription_response_model.rs src/models/sync_response_model.rs src/models/tax_info_response_model.rs src/models/tax_info_update_request_model.rs +src/models/tax_information_request_body.rs src/models/tax_rate_response_model.rs src/models/tax_rate_response_model_list_response_model.rs src/models/transaction_type.rs +src/models/two_factor_authenticator_disable_request_model.rs src/models/two_factor_authenticator_response_model.rs src/models/two_factor_duo_response_model.rs src/models/two_factor_email_request_model.rs @@ -418,6 +426,7 @@ src/models/update_devices_trust_request_model.rs src/models/update_domains_request_model.rs src/models/update_key_request_model.rs src/models/update_profile_request_model.rs +src/models/update_tde_offboarding_password_request_model.rs src/models/update_temp_password_request_model.rs src/models/update_two_factor_authenticator_request_model.rs src/models/update_two_factor_duo_request_model.rs @@ -425,10 +434,9 @@ src/models/update_two_factor_email_request_model.rs src/models/update_two_factor_yubico_otp_request_model.rs src/models/uri_match_type.rs src/models/user.rs +src/models/user_access_policy_response_model.rs src/models/user_key_response_model.rs src/models/user_license.rs -src/models/user_project_access_policy_response_model.rs -src/models/user_service_account_access_policy_response_model.rs src/models/user_verification_requirement.rs src/models/verify_delete_recover_request_model.rs src/models/verify_email_request_model.rs @@ -439,4 +447,5 @@ src/models/web_authn_credential_response_model_list_response_model.rs src/models/web_authn_login_assertion_options_response_model.rs src/models/web_authn_login_credential_create_request_model.rs src/models/web_authn_login_credential_update_request_model.rs +src/models/web_authn_login_rotate_key_request_model.rs src/models/web_authn_prf_status.rs diff --git a/crates/bitwarden-api-api/README.md b/crates/bitwarden-api-api/README.md index 84b3e478a..c3a05f846 100644 --- a/crates/bitwarden-api-api/README.md +++ b/crates/bitwarden-api-api/README.md @@ -27,8 +27,8 @@ bitwarden-api-api = { path = "./bitwarden-api-api" } All URIs are relative to _http://localhost_ -| Class | Method | HTTP request | Description | -| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Class | Method | HTTP request | Description | +| --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | | _AccessPoliciesApi_ | [**organizations_id_access_policies_people_potential_grantees_get**](docs/AccessPoliciesApi.md#organizations_id_access_policies_people_potential_grantees_get) | **GET** /organizations/{id}/access-policies/people/potential-grantees | | _AccessPoliciesApi_ | [**organizations_id_access_policies_projects_potential_grantees_get**](docs/AccessPoliciesApi.md#organizations_id_access_policies_projects_potential_grantees_get) | **GET** /organizations/{id}/access-policies/projects/potential-grantees | | _AccessPoliciesApi_ | [**organizations_id_access_policies_service_accounts_potential_grantees_get**](docs/AccessPoliciesApi.md#organizations_id_access_policies_service_accounts_potential_grantees_get) | **GET** /organizations/{id}/access-policies/service-accounts/potential-grantees | @@ -36,6 +36,7 @@ All URIs are relative to _http://localhost_ | _AccessPoliciesApi_ | [**projects_id_access_policies_people_put**](docs/AccessPoliciesApi.md#projects_id_access_policies_people_put) | **PUT** /projects/{id}/access-policies/people | | _AccessPoliciesApi_ | [**projects_id_access_policies_service_accounts_get**](docs/AccessPoliciesApi.md#projects_id_access_policies_service_accounts_get) | **GET** /projects/{id}/access-policies/service-accounts | | _AccessPoliciesApi_ | [**projects_id_access_policies_service_accounts_put**](docs/AccessPoliciesApi.md#projects_id_access_policies_service_accounts_put) | **PUT** /projects/{id}/access-policies/service-accounts | +| _AccessPoliciesApi_ | [**secrets_secret_id_access_policies_get**](docs/AccessPoliciesApi.md#secrets_secret_id_access_policies_get) | **GET** /secrets/{secretId}/access-policies | | _AccessPoliciesApi_ | [**service_accounts_id_access_policies_people_get**](docs/AccessPoliciesApi.md#service_accounts_id_access_policies_people_get) | **GET** /service-accounts/{id}/access-policies/people | | _AccessPoliciesApi_ | [**service_accounts_id_access_policies_people_put**](docs/AccessPoliciesApi.md#service_accounts_id_access_policies_people_put) | **PUT** /service-accounts/{id}/access-policies/people | | _AccessPoliciesApi_ | [**service_accounts_id_granted_policies_get**](docs/AccessPoliciesApi.md#service_accounts_id_granted_policies_get) | **GET** /service-accounts/{id}/granted-policies | @@ -60,12 +61,10 @@ All URIs are relative to _http://localhost_ | _AccountsApi_ | [**accounts_password_hint_post**](docs/AccountsApi.md#accounts_password_hint_post) | **POST** /accounts/password-hint | | _AccountsApi_ | [**accounts_password_post**](docs/AccountsApi.md#accounts_password_post) | **POST** /accounts/password | | _AccountsApi_ | [**accounts_payment_post**](docs/AccountsApi.md#accounts_payment_post) | **POST** /accounts/payment | -| _AccountsApi_ | [**accounts_prelogin_post**](docs/AccountsApi.md#accounts_prelogin_post) | **POST** /accounts/prelogin | | _AccountsApi_ | [**accounts_premium_post**](docs/AccountsApi.md#accounts_premium_post) | **POST** /accounts/premium | | _AccountsApi_ | [**accounts_profile_get**](docs/AccountsApi.md#accounts_profile_get) | **GET** /accounts/profile | | _AccountsApi_ | [**accounts_profile_post**](docs/AccountsApi.md#accounts_profile_post) | **POST** /accounts/profile | | _AccountsApi_ | [**accounts_profile_put**](docs/AccountsApi.md#accounts_profile_put) | **PUT** /accounts/profile | -| _AccountsApi_ | [**accounts_register_post**](docs/AccountsApi.md#accounts_register_post) | **POST** /accounts/register | | _AccountsApi_ | [**accounts_reinstate_premium_post**](docs/AccountsApi.md#accounts_reinstate_premium_post) | **POST** /accounts/reinstate-premium | | _AccountsApi_ | [**accounts_request_otp_post**](docs/AccountsApi.md#accounts_request_otp_post) | **POST** /accounts/request-otp | | _AccountsApi_ | [**accounts_revision_date_get**](docs/AccountsApi.md#accounts_revision_date_get) | **GET** /accounts/revision-date | @@ -79,6 +78,7 @@ All URIs are relative to _http://localhost_ | _AccountsApi_ | [**accounts_subscription_get**](docs/AccountsApi.md#accounts_subscription_get) | **GET** /accounts/subscription | | _AccountsApi_ | [**accounts_tax_get**](docs/AccountsApi.md#accounts_tax_get) | **GET** /accounts/tax | | _AccountsApi_ | [**accounts_tax_put**](docs/AccountsApi.md#accounts_tax_put) | **PUT** /accounts/tax | +| _AccountsApi_ | [**accounts_update_tde_offboarding_password_put**](docs/AccountsApi.md#accounts_update_tde_offboarding_password_put) | **PUT** /accounts/update-tde-offboarding-password | | _AccountsApi_ | [**accounts_update_temp_password_put**](docs/AccountsApi.md#accounts_update_temp_password_put) | **PUT** /accounts/update-temp-password | | _AccountsApi_ | [**accounts_verify_email_post**](docs/AccountsApi.md#accounts_verify_email_post) | **POST** /accounts/verify-email | | _AccountsApi_ | [**accounts_verify_email_token_post**](docs/AccountsApi.md#accounts_verify_email_token_post) | **POST** /accounts/verify-email-token | @@ -103,7 +103,6 @@ All URIs are relative to _http://localhost_ | _CiphersApi_ | [**ciphers_delete_post**](docs/CiphersApi.md#ciphers_delete_post) | **POST** /ciphers/delete | | _CiphersApi_ | [**ciphers_delete_put**](docs/CiphersApi.md#ciphers_delete_put) | **PUT** /ciphers/delete | | _CiphersApi_ | [**ciphers_get**](docs/CiphersApi.md#ciphers_get) | **GET** /ciphers | -| _CiphersApi_ | [**ciphers_has_unassigned_ciphers_get**](docs/CiphersApi.md#ciphers_has_unassigned_ciphers_get) | **GET** /ciphers/has-unassigned-ciphers | Returns true if the user is an admin or owner of an organization with unassigned ciphers (i.e. ciphers that are not assigned to a collection). | | _CiphersApi_ | [**ciphers_id_admin_delete**](docs/CiphersApi.md#ciphers_id_admin_delete) | **DELETE** /ciphers/{id}/admin | | _CiphersApi_ | [**ciphers_id_admin_get**](docs/CiphersApi.md#ciphers_id_admin_get) | **GET** /ciphers/{id}/admin | | _CiphersApi_ | [**ciphers_id_admin_post**](docs/CiphersApi.md#ciphers_id_admin_post) | **POST** /ciphers/{id}/admin | @@ -169,6 +168,9 @@ All URIs are relative to _http://localhost_ | _CollectionsApi_ | [**organizations_org_id_collections_id_users_put**](docs/CollectionsApi.md#organizations_org_id_collections_id_users_put) | **PUT** /organizations/{orgId}/collections/{id}/users | | _CollectionsApi_ | [**organizations_org_id_collections_post**](docs/CollectionsApi.md#organizations_org_id_collections_post) | **POST** /organizations/{orgId}/collections | | _ConfigApi_ | [**config_get**](docs/ConfigApi.md#config_get) | **GET** /config | +| _CountsApi_ | [**organizations_organization_id_sm_counts_get**](docs/CountsApi.md#organizations_organization_id_sm_counts_get) | **GET** /organizations/{organizationId}/sm-counts | +| _CountsApi_ | [**projects_project_id_sm_counts_get**](docs/CountsApi.md#projects_project_id_sm_counts_get) | **GET** /projects/{projectId}/sm-counts | +| _CountsApi_ | [**service_accounts_service_account_id_sm_counts_get**](docs/CountsApi.md#service_accounts_service_account_id_sm_counts_get) | **GET** /service-accounts/{serviceAccountId}/sm-counts | | _DevicesApi_ | [**devices_get**](docs/DevicesApi.md#devices_get) | **GET** /devices | | _DevicesApi_ | [**devices_id_delete**](docs/DevicesApi.md#devices_id_delete) | **DELETE** /devices/{id} | | _DevicesApi_ | [**devices_id_delete_post**](docs/DevicesApi.md#devices_id_delete_post) | **POST** /devices/{id}/delete | @@ -185,6 +187,7 @@ All URIs are relative to _http://localhost_ | _DevicesApi_ | [**devices_identifier_retrieve_keys_post**](docs/DevicesApi.md#devices_identifier_retrieve_keys_post) | **POST** /devices/{identifier}/retrieve-keys | | _DevicesApi_ | [**devices_knowndevice_email_identifier_get**](docs/DevicesApi.md#devices_knowndevice_email_identifier_get) | **GET** /devices/knowndevice/{email}/{identifier} | | _DevicesApi_ | [**devices_knowndevice_get**](docs/DevicesApi.md#devices_knowndevice_get) | **GET** /devices/knowndevice | +| _DevicesApi_ | [**devices_lost_trust_post**](docs/DevicesApi.md#devices_lost_trust_post) | **POST** /devices/lost-trust | | _DevicesApi_ | [**devices_post**](docs/DevicesApi.md#devices_post) | **POST** /devices | | _DevicesApi_ | [**devices_update_trust_post**](docs/DevicesApi.md#devices_update_trust_post) | **POST** /devices/update-trust | | _EmergencyAccessApi_ | [**emergency_access_granted_get**](docs/EmergencyAccessApi.md#emergency_access_granted_get) | **GET** /emergency-access/granted | @@ -241,14 +244,16 @@ All URIs are relative to _http://localhost_ | _InfoApi_ | [**version_get**](docs/InfoApi.md#version_get) | **GET** /version | | _InstallationsApi_ | [**installations_id_get**](docs/InstallationsApi.md#installations_id_get) | **GET** /installations/{id} | | _InstallationsApi_ | [**installations_post**](docs/InstallationsApi.md#installations_post) | **POST** /installations | -| _LicensesApi_ | [**licenses_organization_id_get**](docs/LicensesApi.md#licenses_organization_id_get) | **GET** /licenses/organization/{id} | Used by self-hosted installations to get an updated license file | +| _LicensesApi_ | [**licenses_organization_id_get**](docs/LicensesApi.md#licenses_organization_id_get) | **GET** /licenses/organization/{id} | Used by self-hosted installations to get an updated license file | | _LicensesApi_ | [**licenses_user_id_get**](docs/LicensesApi.md#licenses_user_id_get) | **GET** /licenses/user/{id} | | _MiscApi_ | [**bitpay_invoice_post**](docs/MiscApi.md#bitpay_invoice_post) | **POST** /bitpay-invoice | | _MiscApi_ | [**setup_payment_post**](docs/MiscApi.md#setup_payment_post) | **POST** /setup-payment | | _OrganizationAuthRequestsApi_ | [**organizations_org_id_auth_requests_deny_post**](docs/OrganizationAuthRequestsApi.md#organizations_org_id_auth_requests_deny_post) | **POST** /organizations/{orgId}/auth-requests/deny | | _OrganizationAuthRequestsApi_ | [**organizations_org_id_auth_requests_get**](docs/OrganizationAuthRequestsApi.md#organizations_org_id_auth_requests_get) | **GET** /organizations/{orgId}/auth-requests | +| _OrganizationAuthRequestsApi_ | [**organizations_org_id_auth_requests_post**](docs/OrganizationAuthRequestsApi.md#organizations_org_id_auth_requests_post) | **POST** /organizations/{orgId}/auth-requests | | _OrganizationAuthRequestsApi_ | [**organizations_org_id_auth_requests_request_id_post**](docs/OrganizationAuthRequestsApi.md#organizations_org_id_auth_requests_request_id_post) | **POST** /organizations/{orgId}/auth-requests/{requestId} | | _OrganizationBillingApi_ | [**organizations_organization_id_billing_get**](docs/OrganizationBillingApi.md#organizations_organization_id_billing_get) | **GET** /organizations/{organizationId}/billing | +| _OrganizationBillingApi_ | [**organizations_organization_id_billing_history_get**](docs/OrganizationBillingApi.md#organizations_organization_id_billing_history_get) | **GET** /organizations/{organizationId}/billing/history | | _OrganizationBillingApi_ | [**organizations_organization_id_billing_metadata_get**](docs/OrganizationBillingApi.md#organizations_organization_id_billing_metadata_get) | **GET** /organizations/{organizationId}/billing/metadata | | _OrganizationConnectionsApi_ | [**organizations_connections_enabled_get**](docs/OrganizationConnectionsApi.md#organizations_connections_enabled_get) | **GET** /organizations/connections/enabled | | _OrganizationConnectionsApi_ | [**organizations_connections_organization_connection_id_delete**](docs/OrganizationConnectionsApi.md#organizations_connections_organization_connection_id_delete) | **DELETE** /organizations/connections/{organizationConnectionId} | @@ -274,6 +279,7 @@ All URIs are relative to _http://localhost_ | _OrganizationSponsorshipsApi_ | [**organization_sponsorship_sponsoring_organization_id_delete_post**](docs/OrganizationSponsorshipsApi.md#organization_sponsorship_sponsoring_organization_id_delete_post) | **POST** /organization/sponsorship/{sponsoringOrganizationId}/delete | | _OrganizationSponsorshipsApi_ | [**organization_sponsorship_sync_post**](docs/OrganizationSponsorshipsApi.md#organization_sponsorship_sync_post) | **POST** /organization/sponsorship/sync | | _OrganizationSponsorshipsApi_ | [**organization_sponsorship_validate_token_post**](docs/OrganizationSponsorshipsApi.md#organization_sponsorship_validate_token_post) | **POST** /organization/sponsorship/validate-token | +| _OrganizationUsersApi_ | [**organizations_org_id_users_account_recovery_details_post**](docs/OrganizationUsersApi.md#organizations_org_id_users_account_recovery_details_post) | **POST** /organizations/{orgId}/users/account-recovery-details | | _OrganizationUsersApi_ | [**organizations_org_id_users_confirm_post**](docs/OrganizationUsersApi.md#organizations_org_id_users_confirm_post) | **POST** /organizations/{orgId}/users/confirm | | _OrganizationUsersApi_ | [**organizations_org_id_users_delete**](docs/OrganizationUsersApi.md#organizations_org_id_users_delete) | **DELETE** /organizations/{orgId}/users | | _OrganizationUsersApi_ | [**organizations_org_id_users_delete_post**](docs/OrganizationUsersApi.md#organizations_org_id_users_delete_post) | **POST** /organizations/{orgId}/users/delete | @@ -313,7 +319,6 @@ All URIs are relative to _http://localhost_ | _OrganizationsApi_ | [**organizations_id_delete**](docs/OrganizationsApi.md#organizations_id_delete) | **DELETE** /organizations/{id} | | _OrganizationsApi_ | [**organizations_id_delete_post**](docs/OrganizationsApi.md#organizations_id_delete_post) | **POST** /organizations/{id}/delete | | _OrganizationsApi_ | [**organizations_id_delete_recover_token_post**](docs/OrganizationsApi.md#organizations_id_delete_recover_token_post) | **POST** /organizations/{id}/delete-recover-token | -| _OrganizationsApi_ | [**organizations_id_enable_collection_enhancements_post**](docs/OrganizationsApi.md#organizations_id_enable_collection_enhancements_post) | **POST** /organizations/{id}/enable-collection-enhancements | Migrates user, collection, and group data to the new Flexible Collections permissions scheme, then sets organization.FlexibleCollections to true to enable these new features for the organization. This is irreversible. | | _OrganizationsApi_ | [**organizations_id_get**](docs/OrganizationsApi.md#organizations_id_get) | **GET** /organizations/{id} | | _OrganizationsApi_ | [**organizations_id_import_post**](docs/OrganizationsApi.md#organizations_id_import_post) | **POST** /organizations/{id}/import | | _OrganizationsApi_ | [**organizations_id_keys_get**](docs/OrganizationsApi.md#organizations_id_keys_get) | **GET** /organizations/{id}/keys | @@ -353,7 +358,10 @@ All URIs are relative to _http://localhost_ | _ProjectsApi_ | [**projects_delete_post**](docs/ProjectsApi.md#projects_delete_post) | **POST** /projects/delete | | _ProjectsApi_ | [**projects_id_get**](docs/ProjectsApi.md#projects_id_get) | **GET** /projects/{id} | | _ProjectsApi_ | [**projects_id_put**](docs/ProjectsApi.md#projects_id_put) | **PUT** /projects/{id} | +| _ProviderBillingApi_ | [**providers_provider_id_billing_invoices_get**](docs/ProviderBillingApi.md#providers_provider_id_billing_invoices_get) | **GET** /providers/{providerId}/billing/invoices | +| _ProviderBillingApi_ | [**providers_provider_id_billing_invoices_invoice_id_get**](docs/ProviderBillingApi.md#providers_provider_id_billing_invoices_invoice_id_get) | **GET** /providers/{providerId}/billing/invoices/{invoiceId} | | _ProviderBillingApi_ | [**providers_provider_id_billing_subscription_get**](docs/ProviderBillingApi.md#providers_provider_id_billing_subscription_get) | **GET** /providers/{providerId}/billing/subscription | +| _ProviderBillingApi_ | [**providers_provider_id_billing_tax_information_put**](docs/ProviderBillingApi.md#providers_provider_id_billing_tax_information_put) | **PUT** /providers/{providerId}/billing/tax-information | | _ProviderClientsApi_ | [**providers_provider_id_clients_post**](docs/ProviderClientsApi.md#providers_provider_id_clients_post) | **POST** /providers/{providerId}/clients | | _ProviderClientsApi_ | [**providers_provider_id_clients_provider_organization_id_put**](docs/ProviderClientsApi.md#providers_provider_id_clients_provider_organization_id_put) | **PUT** /providers/{providerId}/clients/{providerOrganizationId} | | _ProviderOrganizationsApi_ | [**providers_provider_id_organizations_add_post**](docs/ProviderOrganizationsApi.md#providers_provider_id_organizations_add_post) | **POST** /providers/{providerId}/organizations/add | @@ -388,6 +396,7 @@ All URIs are relative to _http://localhost_ | _PushApi_ | [**push_delete_post**](docs/PushApi.md#push_delete_post) | **POST** /push/delete | | _PushApi_ | [**push_register_post**](docs/PushApi.md#push_register_post) | **POST** /push/register | | _PushApi_ | [**push_send_post**](docs/PushApi.md#push_send_post) | **POST** /push/send | +| _RequestSmAccessApi_ | [**request_access_request_sm_access_post**](docs/RequestSmAccessApi.md#request_access_request_sm_access_post) | **POST** /request-access/request-sm-access | | _SecretsApi_ | [**organizations_organization_id_secrets_get**](docs/SecretsApi.md#organizations_organization_id_secrets_get) | **GET** /organizations/{organizationId}/secrets | | _SecretsApi_ | [**organizations_organization_id_secrets_post**](docs/SecretsApi.md#organizations_organization_id_secrets_post) | **POST** /organizations/{organizationId}/secrets | | _SecretsApi_ | [**organizations_organization_id_secrets_sync_get**](docs/SecretsApi.md#organizations_organization_id_secrets_sync_get) | **GET** /organizations/{organizationId}/secrets/sync | @@ -429,6 +438,8 @@ All URIs are relative to _http://localhost_ | _SettingsApi_ | [**settings_domains_get**](docs/SettingsApi.md#settings_domains_get) | **GET** /settings/domains | | _SettingsApi_ | [**settings_domains_post**](docs/SettingsApi.md#settings_domains_post) | **POST** /settings/domains | | _SettingsApi_ | [**settings_domains_put**](docs/SettingsApi.md#settings_domains_put) | **PUT** /settings/domains | +| _StripeApi_ | [**setup_intent_bank_account_post**](docs/StripeApi.md#setup_intent_bank_account_post) | **POST** /setup-intent/bank-account | +| _StripeApi_ | [**setup_intent_card_post**](docs/StripeApi.md#setup_intent_card_post) | **POST** /setup-intent/card | | _SyncApi_ | [**sync_get**](docs/SyncApi.md#sync_get) | **GET** /sync | | _TrashApi_ | [**secrets_organization_id_trash_empty_post**](docs/TrashApi.md#secrets_organization_id_trash_empty_post) | **POST** /secrets/{organizationId}/trash/empty | | _TrashApi_ | [**secrets_organization_id_trash_get**](docs/TrashApi.md#secrets_organization_id_trash_get) | **GET** /secrets/{organizationId}/trash | @@ -439,6 +450,7 @@ All URIs are relative to _http://localhost_ | _TwoFactorApi_ | [**organizations_id_two_factor_duo_put**](docs/TwoFactorApi.md#organizations_id_two_factor_duo_put) | **PUT** /organizations/{id}/two-factor/duo | | _TwoFactorApi_ | [**organizations_id_two_factor_get**](docs/TwoFactorApi.md#organizations_id_two_factor_get) | **GET** /organizations/{id}/two-factor | | _TwoFactorApi_ | [**organizations_id_two_factor_get_duo_post**](docs/TwoFactorApi.md#organizations_id_two_factor_get_duo_post) | **POST** /organizations/{id}/two-factor/get-duo | +| _TwoFactorApi_ | [**two_factor_authenticator_delete**](docs/TwoFactorApi.md#two_factor_authenticator_delete) | **DELETE** /two-factor/authenticator | | _TwoFactorApi_ | [**two_factor_authenticator_post**](docs/TwoFactorApi.md#two_factor_authenticator_post) | **POST** /two-factor/authenticator | | _TwoFactorApi_ | [**two_factor_authenticator_put**](docs/TwoFactorApi.md#two_factor_authenticator_put) | **PUT** /two-factor/authenticator | | _TwoFactorApi_ | [**two_factor_device_verification_settings_put**](docs/TwoFactorApi.md#two_factor_device_verification_settings_put) | **PUT** /two-factor/device-verification-settings | @@ -506,7 +518,6 @@ All URIs are relative to _http://localhost_ - [BillingHistoryResponseModel](docs/BillingHistoryResponseModel.md) - [BillingInvoice](docs/BillingInvoice.md) - [BillingPaymentResponseModel](docs/BillingPaymentResponseModel.md) -- [BillingResponseModel](docs/BillingResponseModel.md) - [BillingSource](docs/BillingSource.md) - [BillingSubscription](docs/BillingSubscription.md) - [BillingSubscriptionItem](docs/BillingSubscriptionItem.md) @@ -600,14 +611,15 @@ All URIs are relative to _http://localhost_ - [GlobalDomains](docs/GlobalDomains.md) - [GlobalEquivalentDomainsType](docs/GlobalEquivalentDomainsType.md) - [GrantedAccessPolicyRequest](docs/GrantedAccessPolicyRequest.md) +- [GrantedProjectAccessPolicyPermissionDetailsResponseModel](docs/GrantedProjectAccessPolicyPermissionDetailsResponseModel.md) +- [GrantedProjectAccessPolicyResponseModel](docs/GrantedProjectAccessPolicyResponseModel.md) - [Group](docs/Group.md) +- [GroupAccessPolicyResponseModel](docs/GroupAccessPolicyResponseModel.md) - [GroupBulkRequestModel](docs/GroupBulkRequestModel.md) - [GroupDetailsResponseModel](docs/GroupDetailsResponseModel.md) - [GroupDetailsResponseModelListResponseModel](docs/GroupDetailsResponseModelListResponseModel.md) -- [GroupProjectAccessPolicyResponseModel](docs/GroupProjectAccessPolicyResponseModel.md) - [GroupRequestModel](docs/GroupRequestModel.md) - [GroupResponseModel](docs/GroupResponseModel.md) -- [GroupServiceAccountAccessPolicyResponseModel](docs/GroupServiceAccountAccessPolicyResponseModel.md) - [ImportCiphersRequestModel](docs/ImportCiphersRequestModel.md) - [ImportOrganizationCiphersRequestModel](docs/ImportOrganizationCiphersRequestModel.md) - [ImportOrganizationUsersRequestModel](docs/ImportOrganizationUsersRequestModel.md) @@ -633,12 +645,14 @@ All URIs are relative to _http://localhost_ - [OrganizationApiKeyInformationListResponseModel](docs/OrganizationApiKeyInformationListResponseModel.md) - [OrganizationApiKeyRequestModel](docs/OrganizationApiKeyRequestModel.md) - [OrganizationApiKeyType](docs/OrganizationApiKeyType.md) +- [OrganizationAuthRequestUpdateManyRequestModel](docs/OrganizationAuthRequestUpdateManyRequestModel.md) - [OrganizationAutoEnrollStatusResponseModel](docs/OrganizationAutoEnrollStatusResponseModel.md) - [OrganizationBillingStatusResponseModel](docs/OrganizationBillingStatusResponseModel.md) - [OrganizationCollectionManagementUpdateRequestModel](docs/OrganizationCollectionManagementUpdateRequestModel.md) - [OrganizationConnectionRequestModel](docs/OrganizationConnectionRequestModel.md) - [OrganizationConnectionResponseModel](docs/OrganizationConnectionResponseModel.md) - [OrganizationConnectionType](docs/OrganizationConnectionType.md) +- [OrganizationCountsResponseModel](docs/OrganizationCountsResponseModel.md) - [OrganizationCreateRequestModel](docs/OrganizationCreateRequestModel.md) - [OrganizationDomainRequestModel](docs/OrganizationDomainRequestModel.md) - [OrganizationDomainResponseModel](docs/OrganizationDomainResponseModel.md) @@ -676,6 +690,7 @@ All URIs are relative to _http://localhost_ - [OrganizationUserPublicKeyResponseModel](docs/OrganizationUserPublicKeyResponseModel.md) - [OrganizationUserPublicKeyResponseModelListResponseModel](docs/OrganizationUserPublicKeyResponseModelListResponseModel.md) - [OrganizationUserResetPasswordDetailsResponseModel](docs/OrganizationUserResetPasswordDetailsResponseModel.md) +- [OrganizationUserResetPasswordDetailsResponseModelListResponseModel](docs/OrganizationUserResetPasswordDetailsResponseModelListResponseModel.md) - [OrganizationUserResetPasswordEnrollmentRequestModel](docs/OrganizationUserResetPasswordEnrollmentRequestModel.md) - [OrganizationUserResetPasswordRequestModel](docs/OrganizationUserResetPasswordRequestModel.md) - [OrganizationUserStatusType](docs/OrganizationUserStatusType.md) @@ -706,14 +721,13 @@ All URIs are relative to _http://localhost_ - [PolicyType](docs/PolicyType.md) - [PotentialGranteeResponseModel](docs/PotentialGranteeResponseModel.md) - [PotentialGranteeResponseModelListResponseModel](docs/PotentialGranteeResponseModelListResponseModel.md) -- [PreloginRequestModel](docs/PreloginRequestModel.md) -- [PreloginResponseModel](docs/PreloginResponseModel.md) -- [ProductType](docs/ProductType.md) +- [ProductTierType](docs/ProductTierType.md) - [ProfileOrganizationResponseModel](docs/ProfileOrganizationResponseModel.md) - [ProfileOrganizationResponseModelListResponseModel](docs/ProfileOrganizationResponseModelListResponseModel.md) - [ProfileProviderOrganizationResponseModel](docs/ProfileProviderOrganizationResponseModel.md) - [ProfileProviderResponseModel](docs/ProfileProviderResponseModel.md) - [ProfileResponseModel](docs/ProfileResponseModel.md) +- [ProjectCountsResponseModel](docs/ProjectCountsResponseModel.md) - [ProjectCreateRequestModel](docs/ProjectCreateRequestModel.md) - [ProjectPeopleAccessPoliciesResponseModel](docs/ProjectPeopleAccessPoliciesResponseModel.md) - [ProjectResponseModel](docs/ProjectResponseModel.md) @@ -758,14 +772,15 @@ All URIs are relative to _http://localhost_ - [PushSendRequestModel](docs/PushSendRequestModel.md) - [PushType](docs/PushType.md) - [PushUpdateRequestModel](docs/PushUpdateRequestModel.md) -- [RegisterRequestModel](docs/RegisterRequestModel.md) -- [RegisterResponseModel](docs/RegisterResponseModel.md) +- [RequestSmAccessRequestModel](docs/RequestSmAccessRequestModel.md) - [ResetPasswordWithOrgIdRequestModel](docs/ResetPasswordWithOrgIdRequestModel.md) - [ResponseData](docs/ResponseData.md) - [RevokeAccessTokensRequest](docs/RevokeAccessTokensRequest.md) - [Saml2BindingType](docs/Saml2BindingType.md) - [Saml2NameIdFormat](docs/Saml2NameIdFormat.md) - [Saml2SigningBehavior](docs/Saml2SigningBehavior.md) +- [SecretAccessPoliciesRequestsModel](docs/SecretAccessPoliciesRequestsModel.md) +- [SecretAccessPoliciesResponseModel](docs/SecretAccessPoliciesResponseModel.md) - [SecretCreateRequestModel](docs/SecretCreateRequestModel.md) - [SecretResponseInnerProject](docs/SecretResponseInnerProject.md) - [SecretResponseModel](docs/SecretResponseModel.md) @@ -792,12 +807,12 @@ All URIs are relative to _http://localhost_ - [SendType](docs/SendType.md) - [SendWithIdRequestModel](docs/SendWithIdRequestModel.md) - [ServerConfigResponseModel](docs/ServerConfigResponseModel.md) +- [ServiceAccountAccessPolicyResponseModel](docs/ServiceAccountAccessPolicyResponseModel.md) +- [ServiceAccountCountsResponseModel](docs/ServiceAccountCountsResponseModel.md) - [ServiceAccountCreateRequestModel](docs/ServiceAccountCreateRequestModel.md) - [ServiceAccountGrantedPoliciesPermissionDetailsResponseModel](docs/ServiceAccountGrantedPoliciesPermissionDetailsResponseModel.md) - [ServiceAccountGrantedPoliciesRequestModel](docs/ServiceAccountGrantedPoliciesRequestModel.md) - [ServiceAccountPeopleAccessPoliciesResponseModel](docs/ServiceAccountPeopleAccessPoliciesResponseModel.md) -- [ServiceAccountProjectAccessPolicyPermissionDetailsResponseModel](docs/ServiceAccountProjectAccessPolicyPermissionDetailsResponseModel.md) -- [ServiceAccountProjectAccessPolicyResponseModel](docs/ServiceAccountProjectAccessPolicyResponseModel.md) - [ServiceAccountResponseModel](docs/ServiceAccountResponseModel.md) - [ServiceAccountSecretsDetailsResponseModel](docs/ServiceAccountSecretsDetailsResponseModel.md) - [ServiceAccountSecretsDetailsResponseModelListResponseModel](docs/ServiceAccountSecretsDetailsResponseModelListResponseModel.md) @@ -816,9 +831,11 @@ All URIs are relative to _http://localhost_ - [SyncResponseModel](docs/SyncResponseModel.md) - [TaxInfoResponseModel](docs/TaxInfoResponseModel.md) - [TaxInfoUpdateRequestModel](docs/TaxInfoUpdateRequestModel.md) +- [TaxInformationRequestBody](docs/TaxInformationRequestBody.md) - [TaxRateResponseModel](docs/TaxRateResponseModel.md) - [TaxRateResponseModelListResponseModel](docs/TaxRateResponseModelListResponseModel.md) - [TransactionType](docs/TransactionType.md) +- [TwoFactorAuthenticatorDisableRequestModel](docs/TwoFactorAuthenticatorDisableRequestModel.md) - [TwoFactorAuthenticatorResponseModel](docs/TwoFactorAuthenticatorResponseModel.md) - [TwoFactorDuoResponseModel](docs/TwoFactorDuoResponseModel.md) - [TwoFactorEmailRequestModel](docs/TwoFactorEmailRequestModel.md) @@ -839,6 +856,7 @@ All URIs are relative to _http://localhost_ - [UpdateDomainsRequestModel](docs/UpdateDomainsRequestModel.md) - [UpdateKeyRequestModel](docs/UpdateKeyRequestModel.md) - [UpdateProfileRequestModel](docs/UpdateProfileRequestModel.md) +- [UpdateTdeOffboardingPasswordRequestModel](docs/UpdateTdeOffboardingPasswordRequestModel.md) - [UpdateTempPasswordRequestModel](docs/UpdateTempPasswordRequestModel.md) - [UpdateTwoFactorAuthenticatorRequestModel](docs/UpdateTwoFactorAuthenticatorRequestModel.md) - [UpdateTwoFactorDuoRequestModel](docs/UpdateTwoFactorDuoRequestModel.md) @@ -846,10 +864,9 @@ All URIs are relative to _http://localhost_ - [UpdateTwoFactorYubicoOtpRequestModel](docs/UpdateTwoFactorYubicoOtpRequestModel.md) - [UriMatchType](docs/UriMatchType.md) - [User](docs/User.md) +- [UserAccessPolicyResponseModel](docs/UserAccessPolicyResponseModel.md) - [UserKeyResponseModel](docs/UserKeyResponseModel.md) - [UserLicense](docs/UserLicense.md) -- [UserProjectAccessPolicyResponseModel](docs/UserProjectAccessPolicyResponseModel.md) -- [UserServiceAccountAccessPolicyResponseModel](docs/UserServiceAccountAccessPolicyResponseModel.md) - [UserVerificationRequirement](docs/UserVerificationRequirement.md) - [VerifyDeleteRecoverRequestModel](docs/VerifyDeleteRecoverRequestModel.md) - [VerifyEmailRequestModel](docs/VerifyEmailRequestModel.md) @@ -860,6 +877,7 @@ All URIs are relative to _http://localhost_ - [WebAuthnLoginAssertionOptionsResponseModel](docs/WebAuthnLoginAssertionOptionsResponseModel.md) - [WebAuthnLoginCredentialCreateRequestModel](docs/WebAuthnLoginCredentialCreateRequestModel.md) - [WebAuthnLoginCredentialUpdateRequestModel](docs/WebAuthnLoginCredentialUpdateRequestModel.md) +- [WebAuthnLoginRotateKeyRequestModel](docs/WebAuthnLoginRotateKeyRequestModel.md) - [WebAuthnPrfStatus](docs/WebAuthnPrfStatus.md) To get access to the crate's generated documentation, use: diff --git a/crates/bitwarden-api-api/src/apis/access_policies_api.rs b/crates/bitwarden-api-api/src/apis/access_policies_api.rs index 5ad67157c..e97a9d567 100644 --- a/crates/bitwarden-api-api/src/apis/access_policies_api.rs +++ b/crates/bitwarden-api-api/src/apis/access_policies_api.rs @@ -66,6 +66,13 @@ pub enum ProjectsIdAccessPoliciesServiceAccountsPutError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`secrets_secret_id_access_policies_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SecretsSecretIdAccessPoliciesGetError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`service_accounts_id_access_policies_people_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -432,6 +439,51 @@ pub async fn projects_id_access_policies_service_accounts_put( } } +pub async fn secrets_secret_id_access_policies_get( + configuration: &configuration::Configuration, + secret_id: uuid::Uuid, +) -> Result> +{ + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/secrets/{secretId}/access-policies", + local_var_configuration.base_path, + secretId = crate::apis::urlencode(secret_id.to_string()) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + pub async fn service_accounts_id_access_policies_people_get( configuration: &configuration::Configuration, id: uuid::Uuid, diff --git a/crates/bitwarden-api-api/src/apis/accounts_api.rs b/crates/bitwarden-api-api/src/apis/accounts_api.rs index da44cffea..d4a5321f1 100644 --- a/crates/bitwarden-api-api/src/apis/accounts_api.rs +++ b/crates/bitwarden-api-api/src/apis/accounts_api.rs @@ -154,13 +154,6 @@ pub enum AccountsPaymentPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`accounts_prelogin_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsPreloginPostError { - UnknownValue(serde_json::Value), -} - /// struct for typed errors of method [`accounts_premium_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -189,13 +182,6 @@ pub enum AccountsProfilePutError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`accounts_register_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum AccountsRegisterPostError { - UnknownValue(serde_json::Value), -} - /// struct for typed errors of method [`accounts_reinstate_premium_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -287,6 +273,13 @@ pub enum AccountsTaxPutError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`accounts_update_tde_offboarding_password_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsUpdateTdeOffboardingPasswordPutError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`accounts_update_temp_password_put`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -1156,47 +1149,6 @@ pub async fn accounts_payment_post( } } -pub async fn accounts_prelogin_post( - configuration: &configuration::Configuration, - prelogin_request_model: Option, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/accounts/prelogin", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = - local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); - } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); - }; - local_var_req_builder = local_var_req_builder.json(&prelogin_request_model); - - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; - - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; - - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) - } else { - let local_var_entity: Option = - serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { - status: local_var_status, - content: local_var_content, - entity: local_var_entity, - }; - Err(Error::ResponseError(local_var_error)) - } -} - pub async fn accounts_premium_post( configuration: &configuration::Configuration, payment_method_type: models::PaymentMethodType, @@ -1384,47 +1336,6 @@ pub async fn accounts_profile_put( } } -pub async fn accounts_register_post( - configuration: &configuration::Configuration, - register_request_model: Option, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!("{}/accounts/register", local_var_configuration.base_path); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = - local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); - } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); - }; - local_var_req_builder = local_var_req_builder.json(®ister_request_model); - - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; - - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; - - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) - } else { - let local_var_entity: Option = - serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { - status: local_var_status, - content: local_var_content, - entity: local_var_entity, - }; - Err(Error::ResponseError(local_var_error)) - } -} - pub async fn accounts_reinstate_premium_post( configuration: &configuration::Configuration, ) -> Result<(), Error> { @@ -1973,6 +1884,53 @@ pub async fn accounts_tax_put( } } +pub async fn accounts_update_tde_offboarding_password_put( + configuration: &configuration::Configuration, + update_tde_offboarding_password_request_model: Option< + models::UpdateTdeOffboardingPasswordRequestModel, + >, +) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/update-tde-offboarding-password", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&update_tde_offboarding_password_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + pub async fn accounts_update_temp_password_put( configuration: &configuration::Configuration, update_temp_password_request_model: Option, diff --git a/crates/bitwarden-api-api/src/apis/ciphers_api.rs b/crates/bitwarden-api-api/src/apis/ciphers_api.rs index ee9cb11b7..e0a522560 100644 --- a/crates/bitwarden-api-api/src/apis/ciphers_api.rs +++ b/crates/bitwarden-api-api/src/apis/ciphers_api.rs @@ -91,13 +91,6 @@ pub enum CiphersGetError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`ciphers_has_unassigned_ciphers_get`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum CiphersHasUnassignedCiphersGetError { - UnknownValue(serde_json::Value), -} - /// struct for typed errors of method [`ciphers_id_admin_delete`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -883,48 +876,6 @@ pub async fn ciphers_get( } } -pub async fn ciphers_has_unassigned_ciphers_get( - configuration: &configuration::Configuration, -) -> Result> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/ciphers/has-unassigned-ciphers", - local_var_configuration.base_path - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = - local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); - } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); - }; - - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; - - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; - - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) - } else { - let local_var_entity: Option = - serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { - status: local_var_status, - content: local_var_content, - entity: local_var_entity, - }; - Err(Error::ResponseError(local_var_error)) - } -} - pub async fn ciphers_id_admin_delete( configuration: &configuration::Configuration, id: &str, diff --git a/crates/bitwarden-api-api/src/apis/counts_api.rs b/crates/bitwarden-api-api/src/apis/counts_api.rs new file mode 100644 index 000000000..5331d91fa --- /dev/null +++ b/crates/bitwarden-api-api/src/apis/counts_api.rs @@ -0,0 +1,174 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use reqwest; +use serde::{Deserialize, Serialize}; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for typed errors of method [`organizations_organization_id_sm_counts_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum OrganizationsOrganizationIdSmCountsGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`projects_project_id_sm_counts_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ProjectsProjectIdSmCountsGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`service_accounts_service_account_id_sm_counts_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ServiceAccountsServiceAccountIdSmCountsGetError { + UnknownValue(serde_json::Value), +} + +pub async fn organizations_organization_id_sm_counts_get( + configuration: &configuration::Configuration, + organization_id: uuid::Uuid, +) -> Result< + models::OrganizationCountsResponseModel, + Error, +> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/sm-counts", + local_var_configuration.base_path, + organizationId = crate::apis::urlencode(organization_id.to_string()) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn projects_project_id_sm_counts_get( + configuration: &configuration::Configuration, + project_id: uuid::Uuid, +) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/projects/{projectId}/sm-counts", + local_var_configuration.base_path, + projectId = crate::apis::urlencode(project_id.to_string()) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn service_accounts_service_account_id_sm_counts_get( + configuration: &configuration::Configuration, + service_account_id: uuid::Uuid, +) -> Result< + models::ServiceAccountCountsResponseModel, + Error, +> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/service-accounts/{serviceAccountId}/sm-counts", + local_var_configuration.base_path, + serviceAccountId = crate::apis::urlencode(service_account_id.to_string()) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/bitwarden-api-api/src/apis/devices_api.rs b/crates/bitwarden-api-api/src/apis/devices_api.rs index c7f3d29a0..4b3b65980 100644 --- a/crates/bitwarden-api-api/src/apis/devices_api.rs +++ b/crates/bitwarden-api-api/src/apis/devices_api.rs @@ -126,6 +126,13 @@ pub enum DevicesKnowndeviceGetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`devices_lost_trust_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DevicesLostTrustPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`devices_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -856,6 +863,45 @@ pub async fn devices_knowndevice_get( } } +pub async fn devices_lost_trust_post( + configuration: &configuration::Configuration, +) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/devices/lost-trust", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + pub async fn devices_post( configuration: &configuration::Configuration, device_request_model: Option, diff --git a/crates/bitwarden-api-api/src/apis/mod.rs b/crates/bitwarden-api-api/src/apis/mod.rs index a7c22cd4e..0b0e68fde 100644 --- a/crates/bitwarden-api-api/src/apis/mod.rs +++ b/crates/bitwarden-api-api/src/apis/mod.rs @@ -98,6 +98,7 @@ pub mod auth_requests_api; pub mod ciphers_api; pub mod collections_api; pub mod config_api; +pub mod counts_api; pub mod devices_api; pub mod emergency_access_api; pub mod events_api; @@ -126,6 +127,7 @@ pub mod provider_organizations_api; pub mod provider_users_api; pub mod providers_api; pub mod push_api; +pub mod request_sm_access_api; pub mod secrets_api; pub mod secrets_manager_events_api; pub mod secrets_manager_porting_api; @@ -134,6 +136,7 @@ pub mod self_hosted_organization_sponsorships_api; pub mod sends_api; pub mod service_accounts_api; pub mod settings_api; +pub mod stripe_api; pub mod sync_api; pub mod trash_api; pub mod two_factor_api; diff --git a/crates/bitwarden-api-api/src/apis/organization_auth_requests_api.rs b/crates/bitwarden-api-api/src/apis/organization_auth_requests_api.rs index 946b79da0..44e4ca9e9 100644 --- a/crates/bitwarden-api-api/src/apis/organization_auth_requests_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_auth_requests_api.rs @@ -28,6 +28,13 @@ pub enum OrganizationsOrgIdAuthRequestsGetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`organizations_org_id_auth_requests_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum OrganizationsOrgIdAuthRequestsPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`organizations_org_id_auth_requests_request_id_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -130,6 +137,55 @@ pub async fn organizations_org_id_auth_requests_get( } } +pub async fn organizations_org_id_auth_requests_post( + configuration: &configuration::Configuration, + org_id: uuid::Uuid, + organization_auth_request_update_many_request_model: Option< + Vec, + >, +) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/auth-requests", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id.to_string()) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&organization_auth_request_update_many_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + pub async fn organizations_org_id_auth_requests_request_id_post( configuration: &configuration::Configuration, org_id: uuid::Uuid, diff --git a/crates/bitwarden-api-api/src/apis/organization_billing_api.rs b/crates/bitwarden-api-api/src/apis/organization_billing_api.rs index b8c2c959d..5ae42d921 100644 --- a/crates/bitwarden-api-api/src/apis/organization_billing_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_billing_api.rs @@ -21,6 +21,13 @@ pub enum OrganizationsOrganizationIdBillingGetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`organizations_organization_id_billing_history_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum OrganizationsOrganizationIdBillingHistoryGetError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`organizations_organization_id_billing_metadata_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -31,7 +38,7 @@ pub enum OrganizationsOrganizationIdBillingMetadataGetError { pub async fn organizations_organization_id_billing_get( configuration: &configuration::Configuration, organization_id: uuid::Uuid, -) -> Result> { +) -> Result<(), Error> { let local_var_configuration = configuration; let local_var_client = &local_var_configuration.client; @@ -59,7 +66,7 @@ pub async fn organizations_organization_id_billing_get( let local_var_content = local_var_resp.text().await?; if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - serde_json::from_str(&local_var_content).map_err(Error::from) + Ok(()) } else { let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); @@ -72,6 +79,50 @@ pub async fn organizations_organization_id_billing_get( } } +pub async fn organizations_organization_id_billing_history_get( + configuration: &configuration::Configuration, + organization_id: uuid::Uuid, +) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{organizationId}/billing/history", + local_var_configuration.base_path, + organizationId = crate::apis::urlencode(organization_id.to_string()) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + pub async fn organizations_organization_id_billing_metadata_get( configuration: &configuration::Configuration, organization_id: uuid::Uuid, diff --git a/crates/bitwarden-api-api/src/apis/organization_users_api.rs b/crates/bitwarden-api-api/src/apis/organization_users_api.rs index 3ede841fd..c5eafb9c9 100644 --- a/crates/bitwarden-api-api/src/apis/organization_users_api.rs +++ b/crates/bitwarden-api-api/src/apis/organization_users_api.rs @@ -14,6 +14,13 @@ use serde::{Deserialize, Serialize}; use super::{configuration, Error}; use crate::{apis::ResponseContent, models}; +/// struct for typed errors of method [`organizations_org_id_users_account_recovery_details_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum OrganizationsOrgIdUsersAccountRecoveryDetailsPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`organizations_org_id_users_confirm_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -227,6 +234,55 @@ pub enum OrganizationsOrgIdUsersUserIdResetPasswordEnrollmentPutError { UnknownValue(serde_json::Value), } +pub async fn organizations_org_id_users_account_recovery_details_post( + configuration: &configuration::Configuration, + org_id: uuid::Uuid, + organization_user_bulk_request_model: Option, +) -> Result< + models::OrganizationUserResetPasswordDetailsResponseModelListResponseModel, + Error, +> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/organizations/{orgId}/users/account-recovery-details", + local_var_configuration.base_path, + orgId = crate::apis::urlencode(org_id.to_string()) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&organization_user_bulk_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + pub async fn organizations_org_id_users_confirm_post( configuration: &configuration::Configuration, org_id: &str, diff --git a/crates/bitwarden-api-api/src/apis/organizations_api.rs b/crates/bitwarden-api-api/src/apis/organizations_api.rs index 026d37b10..fd88331dd 100644 --- a/crates/bitwarden-api-api/src/apis/organizations_api.rs +++ b/crates/bitwarden-api-api/src/apis/organizations_api.rs @@ -77,13 +77,6 @@ pub enum OrganizationsIdDeleteRecoverTokenPostError { UnknownValue(serde_json::Value), } -/// struct for typed errors of method [`organizations_id_enable_collection_enhancements_post`] -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(untagged)] -pub enum OrganizationsIdEnableCollectionEnhancementsPostError { - UnknownValue(serde_json::Value), -} - /// struct for typed errors of method [`organizations_id_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -679,50 +672,6 @@ pub async fn organizations_id_delete_recover_token_post( } } -pub async fn organizations_id_enable_collection_enhancements_post( - configuration: &configuration::Configuration, - id: uuid::Uuid, -) -> Result<(), Error> { - let local_var_configuration = configuration; - - let local_var_client = &local_var_configuration.client; - - let local_var_uri_str = format!( - "{}/organizations/{id}/enable-collection-enhancements", - local_var_configuration.base_path, - id = crate::apis::urlencode(id.to_string()) - ); - let mut local_var_req_builder = - local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); - - if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { - local_var_req_builder = - local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); - } - if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { - local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); - }; - - let local_var_req = local_var_req_builder.build()?; - let local_var_resp = local_var_client.execute(local_var_req).await?; - - let local_var_status = local_var_resp.status(); - let local_var_content = local_var_resp.text().await?; - - if !local_var_status.is_client_error() && !local_var_status.is_server_error() { - Ok(()) - } else { - let local_var_entity: Option = - serde_json::from_str(&local_var_content).ok(); - let local_var_error = ResponseContent { - status: local_var_status, - content: local_var_content, - entity: local_var_entity, - }; - Err(Error::ResponseError(local_var_error)) - } -} - pub async fn organizations_id_get( configuration: &configuration::Configuration, id: &str, diff --git a/crates/bitwarden-api-api/src/apis/provider_billing_api.rs b/crates/bitwarden-api-api/src/apis/provider_billing_api.rs index 2c56c5759..b34b885f8 100644 --- a/crates/bitwarden-api-api/src/apis/provider_billing_api.rs +++ b/crates/bitwarden-api-api/src/apis/provider_billing_api.rs @@ -14,6 +14,20 @@ use serde::{Deserialize, Serialize}; use super::{configuration, Error}; use crate::{apis::ResponseContent, models}; +/// struct for typed errors of method [`providers_provider_id_billing_invoices_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ProvidersProviderIdBillingInvoicesGetError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`providers_provider_id_billing_invoices_invoice_id_get`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ProvidersProviderIdBillingInvoicesInvoiceIdGetError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`providers_provider_id_billing_subscription_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -21,6 +35,103 @@ pub enum ProvidersProviderIdBillingSubscriptionGetError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`providers_provider_id_billing_tax_information_put`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ProvidersProviderIdBillingTaxInformationPutError { + UnknownValue(serde_json::Value), +} + +pub async fn providers_provider_id_billing_invoices_get( + configuration: &configuration::Configuration, + provider_id: uuid::Uuid, +) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/billing/invoices", + local_var_configuration.base_path, + providerId = crate::apis::urlencode(provider_id.to_string()) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn providers_provider_id_billing_invoices_invoice_id_get( + configuration: &configuration::Configuration, + provider_id: uuid::Uuid, + invoice_id: &str, +) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/billing/invoices/{invoiceId}", + local_var_configuration.base_path, + providerId = crate::apis::urlencode(provider_id.to_string()), + invoiceId = crate::apis::urlencode(invoice_id) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + pub async fn providers_provider_id_billing_subscription_get( configuration: &configuration::Configuration, provider_id: uuid::Uuid, @@ -64,3 +175,49 @@ pub async fn providers_provider_id_billing_subscription_get( Err(Error::ResponseError(local_var_error)) } } + +pub async fn providers_provider_id_billing_tax_information_put( + configuration: &configuration::Configuration, + provider_id: uuid::Uuid, + tax_information_request_body: Option, +) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/providers/{providerId}/billing/tax-information", + local_var_configuration.base_path, + providerId = crate::apis::urlencode(provider_id.to_string()) + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&tax_information_request_body); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/bitwarden-api-api/src/apis/request_sm_access_api.rs b/crates/bitwarden-api-api/src/apis/request_sm_access_api.rs new file mode 100644 index 000000000..c67de851d --- /dev/null +++ b/crates/bitwarden-api-api/src/apis/request_sm_access_api.rs @@ -0,0 +1,66 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use reqwest; +use serde::{Deserialize, Serialize}; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for typed errors of method [`request_access_request_sm_access_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum RequestAccessRequestSmAccessPostError { + UnknownValue(serde_json::Value), +} + +pub async fn request_access_request_sm_access_post( + configuration: &configuration::Configuration, + request_sm_access_request_model: Option, +) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/request-access/request-sm-access", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&request_sm_access_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/bitwarden-api-api/src/apis/stripe_api.rs b/crates/bitwarden-api-api/src/apis/stripe_api.rs new file mode 100644 index 000000000..8b186fbfb --- /dev/null +++ b/crates/bitwarden-api-api/src/apis/stripe_api.rs @@ -0,0 +1,110 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use reqwest; +use serde::{Deserialize, Serialize}; + +use super::{configuration, Error}; +use crate::{apis::ResponseContent, models}; + +/// struct for typed errors of method [`setup_intent_bank_account_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SetupIntentBankAccountPostError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`setup_intent_card_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SetupIntentCardPostError { + UnknownValue(serde_json::Value), +} + +pub async fn setup_intent_bank_account_post( + configuration: &configuration::Configuration, +) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/setup-intent/bank-account", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn setup_intent_card_post( + configuration: &configuration::Configuration, +) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/setup-intent/card", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/crates/bitwarden-api-api/src/apis/two_factor_api.rs b/crates/bitwarden-api-api/src/apis/two_factor_api.rs index 298dcb486..f012036dc 100644 --- a/crates/bitwarden-api-api/src/apis/two_factor_api.rs +++ b/crates/bitwarden-api-api/src/apis/two_factor_api.rs @@ -56,6 +56,13 @@ pub enum OrganizationsIdTwoFactorGetDuoPostError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`two_factor_authenticator_delete`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum TwoFactorAuthenticatorDeleteError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`two_factor_authenticator_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -510,6 +517,53 @@ pub async fn organizations_id_two_factor_get_duo_post( } } +pub async fn two_factor_authenticator_delete( + configuration: &configuration::Configuration, + two_factor_authenticator_disable_request_model: Option< + models::TwoFactorAuthenticatorDisableRequestModel, + >, +) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/two-factor/authenticator", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.oauth_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = + local_var_req_builder.json(&two_factor_authenticator_disable_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + pub async fn two_factor_authenticator_post( configuration: &configuration::Configuration, update_two_factor_authenticator_request_model: Option< diff --git a/crates/bitwarden-api-api/src/models/billing_response_model.rs b/crates/bitwarden-api-api/src/models/billing_response_model.rs deleted file mode 100644 index 0adc96a5c..000000000 --- a/crates/bitwarden-api-api/src/models/billing_response_model.rs +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Bitwarden Internal API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: latest - * - * Generated by: https://openapi-generator.tech - */ - -use serde::{Deserialize, Serialize}; - -use crate::models; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct BillingResponseModel { - #[serde(rename = "object", skip_serializing_if = "Option::is_none")] - pub object: Option, - #[serde(rename = "balance", skip_serializing_if = "Option::is_none")] - pub balance: Option, - #[serde(rename = "paymentSource", skip_serializing_if = "Option::is_none")] - pub payment_source: Option>, - #[serde(rename = "invoices", skip_serializing_if = "Option::is_none")] - pub invoices: Option>, - #[serde(rename = "transactions", skip_serializing_if = "Option::is_none")] - pub transactions: Option>, -} - -impl BillingResponseModel { - pub fn new() -> BillingResponseModel { - BillingResponseModel { - object: None, - balance: None, - payment_source: None, - invoices: None, - transactions: None, - } - } -} diff --git a/crates/bitwarden-api-api/src/models/bit_pay_invoice_request_model.rs b/crates/bitwarden-api-api/src/models/bit_pay_invoice_request_model.rs index 6e761baf9..42e71a66f 100644 --- a/crates/bitwarden-api-api/src/models/bit_pay_invoice_request_model.rs +++ b/crates/bitwarden-api-api/src/models/bit_pay_invoice_request_model.rs @@ -18,6 +18,8 @@ pub struct BitPayInvoiceRequestModel { pub user_id: Option, #[serde(rename = "organizationId", skip_serializing_if = "Option::is_none")] pub organization_id: Option, + #[serde(rename = "providerId", skip_serializing_if = "Option::is_none")] + pub provider_id: Option, #[serde(rename = "credit", skip_serializing_if = "Option::is_none")] pub credit: Option, #[serde(rename = "amount")] @@ -35,6 +37,7 @@ impl BitPayInvoiceRequestModel { BitPayInvoiceRequestModel { user_id: None, organization_id: None, + provider_id: None, credit: None, amount, return_url: None, diff --git a/crates/bitwarden-api-api/src/models/event_type.rs b/crates/bitwarden-api-api/src/models/event_type.rs index 366ed6c18..e4294452b 100644 --- a/crates/bitwarden-api-api/src/models/event_type.rs +++ b/crates/bitwarden-api-api/src/models/event_type.rs @@ -38,6 +38,7 @@ pub enum EventType { User_UpdatedTempPassword = 1008, User_MigratedKeyToKeyConnector = 1009, User_RequestedDeviceApproval = 1010, + User_TdeOffboardingPasswordSet = 1011, Cipher_Created = 1100, Cipher_Updated = 1101, Cipher_Deleted = 1102, @@ -117,6 +118,7 @@ impl std::fmt::Display for EventType { Self::User_UpdatedTempPassword => write!(f, "1008"), Self::User_MigratedKeyToKeyConnector => write!(f, "1009"), Self::User_RequestedDeviceApproval => write!(f, "1010"), + Self::User_TdeOffboardingPasswordSet => write!(f, "1011"), Self::Cipher_Created => write!(f, "1100"), Self::Cipher_Updated => write!(f, "1101"), Self::Cipher_Deleted => write!(f, "1102"), diff --git a/crates/bitwarden-api-api/src/models/service_account_project_access_policy_permission_details_response_model.rs b/crates/bitwarden-api-api/src/models/granted_project_access_policy_permission_details_response_model.rs similarity index 66% rename from crates/bitwarden-api-api/src/models/service_account_project_access_policy_permission_details_response_model.rs rename to crates/bitwarden-api-api/src/models/granted_project_access_policy_permission_details_response_model.rs index 1545c95b0..0f957d42f 100644 --- a/crates/bitwarden-api-api/src/models/service_account_project_access_policy_permission_details_response_model.rs +++ b/crates/bitwarden-api-api/src/models/granted_project_access_policy_permission_details_response_model.rs @@ -13,18 +13,18 @@ use serde::{Deserialize, Serialize}; use crate::models; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ServiceAccountProjectAccessPolicyPermissionDetailsResponseModel { +pub struct GrantedProjectAccessPolicyPermissionDetailsResponseModel { #[serde(rename = "object", skip_serializing_if = "Option::is_none")] pub object: Option, #[serde(rename = "accessPolicy", skip_serializing_if = "Option::is_none")] - pub access_policy: Option>, + pub access_policy: Option>, #[serde(rename = "hasPermission", skip_serializing_if = "Option::is_none")] pub has_permission: Option, } -impl ServiceAccountProjectAccessPolicyPermissionDetailsResponseModel { - pub fn new() -> ServiceAccountProjectAccessPolicyPermissionDetailsResponseModel { - ServiceAccountProjectAccessPolicyPermissionDetailsResponseModel { +impl GrantedProjectAccessPolicyPermissionDetailsResponseModel { + pub fn new() -> GrantedProjectAccessPolicyPermissionDetailsResponseModel { + GrantedProjectAccessPolicyPermissionDetailsResponseModel { object: None, access_policy: None, has_permission: None, diff --git a/crates/bitwarden-api-api/src/models/service_account_project_access_policy_response_model.rs b/crates/bitwarden-api-api/src/models/granted_project_access_policy_response_model.rs similarity index 52% rename from crates/bitwarden-api-api/src/models/service_account_project_access_policy_response_model.rs rename to crates/bitwarden-api-api/src/models/granted_project_access_policy_response_model.rs index 29369402d..d098fccea 100644 --- a/crates/bitwarden-api-api/src/models/service_account_project_access_policy_response_model.rs +++ b/crates/bitwarden-api-api/src/models/granted_project_access_policy_response_model.rs @@ -13,40 +13,25 @@ use serde::{Deserialize, Serialize}; use crate::models; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct ServiceAccountProjectAccessPolicyResponseModel { +pub struct GrantedProjectAccessPolicyResponseModel { #[serde(rename = "object", skip_serializing_if = "Option::is_none")] pub object: Option, - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - pub id: Option, #[serde(rename = "read", skip_serializing_if = "Option::is_none")] pub read: Option, #[serde(rename = "write", skip_serializing_if = "Option::is_none")] pub write: Option, - #[serde(rename = "creationDate", skip_serializing_if = "Option::is_none")] - pub creation_date: Option, - #[serde(rename = "revisionDate", skip_serializing_if = "Option::is_none")] - pub revision_date: Option, - #[serde(rename = "serviceAccountId", skip_serializing_if = "Option::is_none")] - pub service_account_id: Option, - #[serde(rename = "serviceAccountName", skip_serializing_if = "Option::is_none")] - pub service_account_name: Option, #[serde(rename = "grantedProjectId", skip_serializing_if = "Option::is_none")] pub granted_project_id: Option, #[serde(rename = "grantedProjectName", skip_serializing_if = "Option::is_none")] pub granted_project_name: Option, } -impl ServiceAccountProjectAccessPolicyResponseModel { - pub fn new() -> ServiceAccountProjectAccessPolicyResponseModel { - ServiceAccountProjectAccessPolicyResponseModel { +impl GrantedProjectAccessPolicyResponseModel { + pub fn new() -> GrantedProjectAccessPolicyResponseModel { + GrantedProjectAccessPolicyResponseModel { object: None, - id: None, read: None, write: None, - creation_date: None, - revision_date: None, - service_account_id: None, - service_account_name: None, granted_project_id: None, granted_project_name: None, } diff --git a/crates/bitwarden-api-api/src/models/group_project_access_policy_response_model.rs b/crates/bitwarden-api-api/src/models/group_access_policy_response_model.rs similarity index 60% rename from crates/bitwarden-api-api/src/models/group_project_access_policy_response_model.rs rename to crates/bitwarden-api-api/src/models/group_access_policy_response_model.rs index bfd7aec3e..943f2e11d 100644 --- a/crates/bitwarden-api-api/src/models/group_project_access_policy_response_model.rs +++ b/crates/bitwarden-api-api/src/models/group_access_policy_response_model.rs @@ -13,42 +13,30 @@ use serde::{Deserialize, Serialize}; use crate::models; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct GroupProjectAccessPolicyResponseModel { +pub struct GroupAccessPolicyResponseModel { #[serde(rename = "object", skip_serializing_if = "Option::is_none")] pub object: Option, - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - pub id: Option, #[serde(rename = "read", skip_serializing_if = "Option::is_none")] pub read: Option, #[serde(rename = "write", skip_serializing_if = "Option::is_none")] pub write: Option, - #[serde(rename = "creationDate", skip_serializing_if = "Option::is_none")] - pub creation_date: Option, - #[serde(rename = "revisionDate", skip_serializing_if = "Option::is_none")] - pub revision_date: Option, #[serde(rename = "groupId", skip_serializing_if = "Option::is_none")] pub group_id: Option, #[serde(rename = "groupName", skip_serializing_if = "Option::is_none")] pub group_name: Option, #[serde(rename = "currentUserInGroup", skip_serializing_if = "Option::is_none")] pub current_user_in_group: Option, - #[serde(rename = "grantedProjectId", skip_serializing_if = "Option::is_none")] - pub granted_project_id: Option, } -impl GroupProjectAccessPolicyResponseModel { - pub fn new() -> GroupProjectAccessPolicyResponseModel { - GroupProjectAccessPolicyResponseModel { +impl GroupAccessPolicyResponseModel { + pub fn new() -> GroupAccessPolicyResponseModel { + GroupAccessPolicyResponseModel { object: None, - id: None, read: None, write: None, - creation_date: None, - revision_date: None, group_id: None, group_name: None, current_user_in_group: None, - granted_project_id: None, } } } diff --git a/crates/bitwarden-api-api/src/models/group_details_response_model.rs b/crates/bitwarden-api-api/src/models/group_details_response_model.rs index 7fc890d14..e73cec876 100644 --- a/crates/bitwarden-api-api/src/models/group_details_response_model.rs +++ b/crates/bitwarden-api-api/src/models/group_details_response_model.rs @@ -22,8 +22,6 @@ pub struct GroupDetailsResponseModel { pub organization_id: Option, #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, - #[serde(rename = "accessAll", skip_serializing_if = "Option::is_none")] - pub access_all: Option, #[serde(rename = "externalId", skip_serializing_if = "Option::is_none")] pub external_id: Option, #[serde(rename = "collections", skip_serializing_if = "Option::is_none")] @@ -37,7 +35,6 @@ impl GroupDetailsResponseModel { id: None, organization_id: None, name: None, - access_all: None, external_id: None, collections: None, } diff --git a/crates/bitwarden-api-api/src/models/group_request_model.rs b/crates/bitwarden-api-api/src/models/group_request_model.rs index d986ebe13..e218a3fe6 100644 --- a/crates/bitwarden-api-api/src/models/group_request_model.rs +++ b/crates/bitwarden-api-api/src/models/group_request_model.rs @@ -16,8 +16,6 @@ use crate::models; pub struct GroupRequestModel { #[serde(rename = "name")] pub name: String, - #[serde(rename = "accessAll")] - pub access_all: bool, #[serde(rename = "collections", skip_serializing_if = "Option::is_none")] pub collections: Option>, #[serde(rename = "users", skip_serializing_if = "Option::is_none")] @@ -25,10 +23,9 @@ pub struct GroupRequestModel { } impl GroupRequestModel { - pub fn new(name: String, access_all: bool) -> GroupRequestModel { + pub fn new(name: String) -> GroupRequestModel { GroupRequestModel { name, - access_all, collections: None, users: None, } diff --git a/crates/bitwarden-api-api/src/models/group_response_model.rs b/crates/bitwarden-api-api/src/models/group_response_model.rs index 4e9da78ee..a3d6d6fd3 100644 --- a/crates/bitwarden-api-api/src/models/group_response_model.rs +++ b/crates/bitwarden-api-api/src/models/group_response_model.rs @@ -22,8 +22,6 @@ pub struct GroupResponseModel { pub organization_id: Option, #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, - #[serde(rename = "accessAll", skip_serializing_if = "Option::is_none")] - pub access_all: Option, #[serde(rename = "externalId", skip_serializing_if = "Option::is_none")] pub external_id: Option, } @@ -35,7 +33,6 @@ impl GroupResponseModel { id: None, organization_id: None, name: None, - access_all: None, external_id: None, } } diff --git a/crates/bitwarden-api-api/src/models/group_service_account_access_policy_response_model.rs b/crates/bitwarden-api-api/src/models/group_service_account_access_policy_response_model.rs deleted file mode 100644 index 9fcc03bea..000000000 --- a/crates/bitwarden-api-api/src/models/group_service_account_access_policy_response_model.rs +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Bitwarden Internal API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: latest - * - * Generated by: https://openapi-generator.tech - */ - -use serde::{Deserialize, Serialize}; - -use crate::models; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct GroupServiceAccountAccessPolicyResponseModel { - #[serde(rename = "object", skip_serializing_if = "Option::is_none")] - pub object: Option, - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - pub id: Option, - #[serde(rename = "read", skip_serializing_if = "Option::is_none")] - pub read: Option, - #[serde(rename = "write", skip_serializing_if = "Option::is_none")] - pub write: Option, - #[serde(rename = "creationDate", skip_serializing_if = "Option::is_none")] - pub creation_date: Option, - #[serde(rename = "revisionDate", skip_serializing_if = "Option::is_none")] - pub revision_date: Option, - #[serde(rename = "groupId", skip_serializing_if = "Option::is_none")] - pub group_id: Option, - #[serde(rename = "groupName", skip_serializing_if = "Option::is_none")] - pub group_name: Option, - #[serde( - rename = "grantedServiceAccountId", - skip_serializing_if = "Option::is_none" - )] - pub granted_service_account_id: Option, - #[serde(rename = "currentUserInGroup", skip_serializing_if = "Option::is_none")] - pub current_user_in_group: Option, -} - -impl GroupServiceAccountAccessPolicyResponseModel { - pub fn new() -> GroupServiceAccountAccessPolicyResponseModel { - GroupServiceAccountAccessPolicyResponseModel { - object: None, - id: None, - read: None, - write: None, - creation_date: None, - revision_date: None, - group_id: None, - group_name: None, - granted_service_account_id: None, - current_user_in_group: None, - } - } -} diff --git a/crates/bitwarden-api-api/src/models/mod.rs b/crates/bitwarden-api-api/src/models/mod.rs index 86365cd28..91998fb0c 100644 --- a/crates/bitwarden-api-api/src/models/mod.rs +++ b/crates/bitwarden-api-api/src/models/mod.rs @@ -62,8 +62,6 @@ pub mod billing_invoice; pub use self::billing_invoice::BillingInvoice; pub mod billing_payment_response_model; pub use self::billing_payment_response_model::BillingPaymentResponseModel; -pub mod billing_response_model; -pub use self::billing_response_model::BillingResponseModel; pub mod billing_source; pub use self::billing_source::BillingSource; pub mod billing_subscription; @@ -250,22 +248,24 @@ pub mod global_equivalent_domains_type; pub use self::global_equivalent_domains_type::GlobalEquivalentDomainsType; pub mod granted_access_policy_request; pub use self::granted_access_policy_request::GrantedAccessPolicyRequest; +pub mod granted_project_access_policy_permission_details_response_model; +pub use self::granted_project_access_policy_permission_details_response_model::GrantedProjectAccessPolicyPermissionDetailsResponseModel; +pub mod granted_project_access_policy_response_model; +pub use self::granted_project_access_policy_response_model::GrantedProjectAccessPolicyResponseModel; pub mod group; pub use self::group::Group; +pub mod group_access_policy_response_model; +pub use self::group_access_policy_response_model::GroupAccessPolicyResponseModel; pub mod group_bulk_request_model; pub use self::group_bulk_request_model::GroupBulkRequestModel; pub mod group_details_response_model; pub use self::group_details_response_model::GroupDetailsResponseModel; pub mod group_details_response_model_list_response_model; pub use self::group_details_response_model_list_response_model::GroupDetailsResponseModelListResponseModel; -pub mod group_project_access_policy_response_model; -pub use self::group_project_access_policy_response_model::GroupProjectAccessPolicyResponseModel; pub mod group_request_model; pub use self::group_request_model::GroupRequestModel; pub mod group_response_model; pub use self::group_response_model::GroupResponseModel; -pub mod group_service_account_access_policy_response_model; -pub use self::group_service_account_access_policy_response_model::GroupServiceAccountAccessPolicyResponseModel; pub mod import_ciphers_request_model; pub use self::import_ciphers_request_model::ImportCiphersRequestModel; pub mod import_organization_ciphers_request_model; @@ -316,6 +316,8 @@ pub mod organization_api_key_request_model; pub use self::organization_api_key_request_model::OrganizationApiKeyRequestModel; pub mod organization_api_key_type; pub use self::organization_api_key_type::OrganizationApiKeyType; +pub mod organization_auth_request_update_many_request_model; +pub use self::organization_auth_request_update_many_request_model::OrganizationAuthRequestUpdateManyRequestModel; pub mod organization_auto_enroll_status_response_model; pub use self::organization_auto_enroll_status_response_model::OrganizationAutoEnrollStatusResponseModel; pub mod organization_billing_status_response_model; @@ -328,6 +330,8 @@ pub mod organization_connection_response_model; pub use self::organization_connection_response_model::OrganizationConnectionResponseModel; pub mod organization_connection_type; pub use self::organization_connection_type::OrganizationConnectionType; +pub mod organization_counts_response_model; +pub use self::organization_counts_response_model::OrganizationCountsResponseModel; pub mod organization_create_request_model; pub use self::organization_create_request_model::OrganizationCreateRequestModel; pub mod organization_domain_request_model; @@ -402,6 +406,8 @@ pub mod organization_user_public_key_response_model_list_response_model; pub use self::organization_user_public_key_response_model_list_response_model::OrganizationUserPublicKeyResponseModelListResponseModel; pub mod organization_user_reset_password_details_response_model; pub use self::organization_user_reset_password_details_response_model::OrganizationUserResetPasswordDetailsResponseModel; +pub mod organization_user_reset_password_details_response_model_list_response_model; +pub use self::organization_user_reset_password_details_response_model_list_response_model::OrganizationUserResetPasswordDetailsResponseModelListResponseModel; pub mod organization_user_reset_password_enrollment_request_model; pub use self::organization_user_reset_password_enrollment_request_model::OrganizationUserResetPasswordEnrollmentRequestModel; pub mod organization_user_reset_password_request_model; @@ -462,12 +468,8 @@ pub mod potential_grantee_response_model; pub use self::potential_grantee_response_model::PotentialGranteeResponseModel; pub mod potential_grantee_response_model_list_response_model; pub use self::potential_grantee_response_model_list_response_model::PotentialGranteeResponseModelListResponseModel; -pub mod prelogin_request_model; -pub use self::prelogin_request_model::PreloginRequestModel; -pub mod prelogin_response_model; -pub use self::prelogin_response_model::PreloginResponseModel; -pub mod product_type; -pub use self::product_type::ProductType; +pub mod product_tier_type; +pub use self::product_tier_type::ProductTierType; pub mod profile_organization_response_model; pub use self::profile_organization_response_model::ProfileOrganizationResponseModel; pub mod profile_organization_response_model_list_response_model; @@ -478,6 +480,8 @@ pub mod profile_provider_response_model; pub use self::profile_provider_response_model::ProfileProviderResponseModel; pub mod profile_response_model; pub use self::profile_response_model::ProfileResponseModel; +pub mod project_counts_response_model; +pub use self::project_counts_response_model::ProjectCountsResponseModel; pub mod project_create_request_model; pub use self::project_create_request_model::ProjectCreateRequestModel; pub mod project_people_access_policies_response_model; @@ -566,10 +570,8 @@ pub mod push_type; pub use self::push_type::PushType; pub mod push_update_request_model; pub use self::push_update_request_model::PushUpdateRequestModel; -pub mod register_request_model; -pub use self::register_request_model::RegisterRequestModel; -pub mod register_response_model; -pub use self::register_response_model::RegisterResponseModel; +pub mod request_sm_access_request_model; +pub use self::request_sm_access_request_model::RequestSmAccessRequestModel; pub mod reset_password_with_org_id_request_model; pub use self::reset_password_with_org_id_request_model::ResetPasswordWithOrgIdRequestModel; pub mod response_data; @@ -582,6 +584,10 @@ pub mod saml2_name_id_format; pub use self::saml2_name_id_format::Saml2NameIdFormat; pub mod saml2_signing_behavior; pub use self::saml2_signing_behavior::Saml2SigningBehavior; +pub mod secret_access_policies_requests_model; +pub use self::secret_access_policies_requests_model::SecretAccessPoliciesRequestsModel; +pub mod secret_access_policies_response_model; +pub use self::secret_access_policies_response_model::SecretAccessPoliciesResponseModel; pub mod secret_create_request_model; pub use self::secret_create_request_model::SecretCreateRequestModel; pub mod secret_response_inner_project; @@ -634,6 +640,10 @@ pub mod send_with_id_request_model; pub use self::send_with_id_request_model::SendWithIdRequestModel; pub mod server_config_response_model; pub use self::server_config_response_model::ServerConfigResponseModel; +pub mod service_account_access_policy_response_model; +pub use self::service_account_access_policy_response_model::ServiceAccountAccessPolicyResponseModel; +pub mod service_account_counts_response_model; +pub use self::service_account_counts_response_model::ServiceAccountCountsResponseModel; pub mod service_account_create_request_model; pub use self::service_account_create_request_model::ServiceAccountCreateRequestModel; pub mod service_account_granted_policies_permission_details_response_model; @@ -642,10 +652,6 @@ pub mod service_account_granted_policies_request_model; pub use self::service_account_granted_policies_request_model::ServiceAccountGrantedPoliciesRequestModel; pub mod service_account_people_access_policies_response_model; pub use self::service_account_people_access_policies_response_model::ServiceAccountPeopleAccessPoliciesResponseModel; -pub mod service_account_project_access_policy_permission_details_response_model; -pub use self::service_account_project_access_policy_permission_details_response_model::ServiceAccountProjectAccessPolicyPermissionDetailsResponseModel; -pub mod service_account_project_access_policy_response_model; -pub use self::service_account_project_access_policy_response_model::ServiceAccountProjectAccessPolicyResponseModel; pub mod service_account_response_model; pub use self::service_account_response_model::ServiceAccountResponseModel; pub mod service_account_secrets_details_response_model; @@ -682,12 +688,16 @@ pub mod tax_info_response_model; pub use self::tax_info_response_model::TaxInfoResponseModel; pub mod tax_info_update_request_model; pub use self::tax_info_update_request_model::TaxInfoUpdateRequestModel; +pub mod tax_information_request_body; +pub use self::tax_information_request_body::TaxInformationRequestBody; pub mod tax_rate_response_model; pub use self::tax_rate_response_model::TaxRateResponseModel; pub mod tax_rate_response_model_list_response_model; pub use self::tax_rate_response_model_list_response_model::TaxRateResponseModelListResponseModel; pub mod transaction_type; pub use self::transaction_type::TransactionType; +pub mod two_factor_authenticator_disable_request_model; +pub use self::two_factor_authenticator_disable_request_model::TwoFactorAuthenticatorDisableRequestModel; pub mod two_factor_authenticator_response_model; pub use self::two_factor_authenticator_response_model::TwoFactorAuthenticatorResponseModel; pub mod two_factor_duo_response_model; @@ -728,6 +738,8 @@ pub mod update_key_request_model; pub use self::update_key_request_model::UpdateKeyRequestModel; pub mod update_profile_request_model; pub use self::update_profile_request_model::UpdateProfileRequestModel; +pub mod update_tde_offboarding_password_request_model; +pub use self::update_tde_offboarding_password_request_model::UpdateTdeOffboardingPasswordRequestModel; pub mod update_temp_password_request_model; pub use self::update_temp_password_request_model::UpdateTempPasswordRequestModel; pub mod update_two_factor_authenticator_request_model; @@ -742,14 +754,12 @@ pub mod uri_match_type; pub use self::uri_match_type::UriMatchType; pub mod user; pub use self::user::User; +pub mod user_access_policy_response_model; +pub use self::user_access_policy_response_model::UserAccessPolicyResponseModel; pub mod user_key_response_model; pub use self::user_key_response_model::UserKeyResponseModel; pub mod user_license; pub use self::user_license::UserLicense; -pub mod user_project_access_policy_response_model; -pub use self::user_project_access_policy_response_model::UserProjectAccessPolicyResponseModel; -pub mod user_service_account_access_policy_response_model; -pub use self::user_service_account_access_policy_response_model::UserServiceAccountAccessPolicyResponseModel; pub mod user_verification_requirement; pub use self::user_verification_requirement::UserVerificationRequirement; pub mod verify_delete_recover_request_model; @@ -770,5 +780,7 @@ pub mod web_authn_login_credential_create_request_model; pub use self::web_authn_login_credential_create_request_model::WebAuthnLoginCredentialCreateRequestModel; pub mod web_authn_login_credential_update_request_model; pub use self::web_authn_login_credential_update_request_model::WebAuthnLoginCredentialUpdateRequestModel; +pub mod web_authn_login_rotate_key_request_model; +pub use self::web_authn_login_rotate_key_request_model::WebAuthnLoginRotateKeyRequestModel; pub mod web_authn_prf_status; pub use self::web_authn_prf_status::WebAuthnPrfStatus; diff --git a/crates/bitwarden-api-api/src/models/organization_auth_request_update_many_request_model.rs b/crates/bitwarden-api-api/src/models/organization_auth_request_update_many_request_model.rs new file mode 100644 index 000000000..cccb1b9ed --- /dev/null +++ b/crates/bitwarden-api-api/src/models/organization_auth_request_update_many_request_model.rs @@ -0,0 +1,33 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct OrganizationAuthRequestUpdateManyRequestModel { + #[serde(rename = "id", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "key", skip_serializing_if = "Option::is_none")] + pub key: Option, + #[serde(rename = "approved", skip_serializing_if = "Option::is_none")] + pub approved: Option, +} + +impl OrganizationAuthRequestUpdateManyRequestModel { + pub fn new() -> OrganizationAuthRequestUpdateManyRequestModel { + OrganizationAuthRequestUpdateManyRequestModel { + id: None, + key: None, + approved: None, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/organization_counts_response_model.rs b/crates/bitwarden-api-api/src/models/organization_counts_response_model.rs new file mode 100644 index 000000000..4ba9203c0 --- /dev/null +++ b/crates/bitwarden-api-api/src/models/organization_counts_response_model.rs @@ -0,0 +1,36 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct OrganizationCountsResponseModel { + #[serde(rename = "object", skip_serializing_if = "Option::is_none")] + pub object: Option, + #[serde(rename = "projects", skip_serializing_if = "Option::is_none")] + pub projects: Option, + #[serde(rename = "secrets", skip_serializing_if = "Option::is_none")] + pub secrets: Option, + #[serde(rename = "serviceAccounts", skip_serializing_if = "Option::is_none")] + pub service_accounts: Option, +} + +impl OrganizationCountsResponseModel { + pub fn new() -> OrganizationCountsResponseModel { + OrganizationCountsResponseModel { + object: None, + projects: None, + secrets: None, + service_accounts: None, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/organization_response_model.rs b/crates/bitwarden-api-api/src/models/organization_response_model.rs index b696cce7e..31aed69c4 100644 --- a/crates/bitwarden-api-api/src/models/organization_response_model.rs +++ b/crates/bitwarden-api-api/src/models/organization_response_model.rs @@ -112,11 +112,6 @@ pub struct OrganizationResponseModel { skip_serializing_if = "Option::is_none" )] pub allow_admin_access_to_all_collection_items: Option, - #[serde( - rename = "flexibleCollections", - skip_serializing_if = "Option::is_none" - )] - pub flexible_collections: Option, } impl OrganizationResponseModel { @@ -162,7 +157,6 @@ impl OrganizationResponseModel { max_autoscale_sm_service_accounts: None, limit_collection_creation_deletion: None, allow_admin_access_to_all_collection_items: None, - flexible_collections: None, } } } diff --git a/crates/bitwarden-api-api/src/models/organization_subscription_response_model.rs b/crates/bitwarden-api-api/src/models/organization_subscription_response_model.rs index 4eb316ba0..b2c3acb0a 100644 --- a/crates/bitwarden-api-api/src/models/organization_subscription_response_model.rs +++ b/crates/bitwarden-api-api/src/models/organization_subscription_response_model.rs @@ -112,11 +112,6 @@ pub struct OrganizationSubscriptionResponseModel { skip_serializing_if = "Option::is_none" )] pub allow_admin_access_to_all_collection_items: Option, - #[serde( - rename = "flexibleCollections", - skip_serializing_if = "Option::is_none" - )] - pub flexible_collections: Option, #[serde(rename = "storageName", skip_serializing_if = "Option::is_none")] pub storage_name: Option, #[serde(rename = "storageGb", skip_serializing_if = "Option::is_none")] @@ -181,7 +176,6 @@ impl OrganizationSubscriptionResponseModel { max_autoscale_sm_service_accounts: None, limit_collection_creation_deletion: None, allow_admin_access_to_all_collection_items: None, - flexible_collections: None, storage_name: None, storage_gb: None, customer_discount: None, diff --git a/crates/bitwarden-api-api/src/models/organization_user_details_response_model.rs b/crates/bitwarden-api-api/src/models/organization_user_details_response_model.rs index f10c7b10b..b9ea3c152 100644 --- a/crates/bitwarden-api-api/src/models/organization_user_details_response_model.rs +++ b/crates/bitwarden-api-api/src/models/organization_user_details_response_model.rs @@ -24,8 +24,6 @@ pub struct OrganizationUserDetailsResponseModel { pub r#type: Option, #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, - #[serde(rename = "accessAll", skip_serializing_if = "Option::is_none")] - pub access_all: Option, #[serde(rename = "externalId", skip_serializing_if = "Option::is_none")] pub external_id: Option, #[serde( @@ -58,7 +56,6 @@ impl OrganizationUserDetailsResponseModel { user_id: None, r#type: None, status: None, - access_all: None, external_id: None, access_secrets_manager: None, permissions: None, diff --git a/crates/bitwarden-api-api/src/models/organization_user_invite_request_model.rs b/crates/bitwarden-api-api/src/models/organization_user_invite_request_model.rs index 2e66bd7f2..0a6f2d4c7 100644 --- a/crates/bitwarden-api-api/src/models/organization_user_invite_request_model.rs +++ b/crates/bitwarden-api-api/src/models/organization_user_invite_request_model.rs @@ -18,8 +18,6 @@ pub struct OrganizationUserInviteRequestModel { pub emails: Vec, #[serde(rename = "type")] pub r#type: models::OrganizationUserType, - #[serde(rename = "accessAll", skip_serializing_if = "Option::is_none")] - pub access_all: Option, #[serde( rename = "accessSecretsManager", skip_serializing_if = "Option::is_none" @@ -41,7 +39,6 @@ impl OrganizationUserInviteRequestModel { OrganizationUserInviteRequestModel { emails, r#type, - access_all: None, access_secrets_manager: None, permissions: None, collections: None, diff --git a/crates/bitwarden-api-api/src/models/organization_user_reset_password_details_response_model.rs b/crates/bitwarden-api-api/src/models/organization_user_reset_password_details_response_model.rs index eb999f06c..1dabdd642 100644 --- a/crates/bitwarden-api-api/src/models/organization_user_reset_password_details_response_model.rs +++ b/crates/bitwarden-api-api/src/models/organization_user_reset_password_details_response_model.rs @@ -16,6 +16,8 @@ use crate::models; pub struct OrganizationUserResetPasswordDetailsResponseModel { #[serde(rename = "object", skip_serializing_if = "Option::is_none")] pub object: Option, + #[serde(rename = "organizationUserId", skip_serializing_if = "Option::is_none")] + pub organization_user_id: Option, #[serde(rename = "kdf", skip_serializing_if = "Option::is_none")] pub kdf: Option, #[serde(rename = "kdfIterations", skip_serializing_if = "Option::is_none")] @@ -37,6 +39,7 @@ impl OrganizationUserResetPasswordDetailsResponseModel { pub fn new() -> OrganizationUserResetPasswordDetailsResponseModel { OrganizationUserResetPasswordDetailsResponseModel { object: None, + organization_user_id: None, kdf: None, kdf_iterations: None, kdf_memory: None, diff --git a/crates/bitwarden-api-api/src/models/organization_user_reset_password_details_response_model_list_response_model.rs b/crates/bitwarden-api-api/src/models/organization_user_reset_password_details_response_model_list_response_model.rs new file mode 100644 index 000000000..600973567 --- /dev/null +++ b/crates/bitwarden-api-api/src/models/organization_user_reset_password_details_response_model_list_response_model.rs @@ -0,0 +1,33 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct OrganizationUserResetPasswordDetailsResponseModelListResponseModel { + #[serde(rename = "object", skip_serializing_if = "Option::is_none")] + pub object: Option, + #[serde(rename = "data", skip_serializing_if = "Option::is_none")] + pub data: Option>, + #[serde(rename = "continuationToken", skip_serializing_if = "Option::is_none")] + pub continuation_token: Option, +} + +impl OrganizationUserResetPasswordDetailsResponseModelListResponseModel { + pub fn new() -> OrganizationUserResetPasswordDetailsResponseModelListResponseModel { + OrganizationUserResetPasswordDetailsResponseModelListResponseModel { + object: None, + data: None, + continuation_token: None, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/organization_user_reset_password_enrollment_request_model.rs b/crates/bitwarden-api-api/src/models/organization_user_reset_password_enrollment_request_model.rs index edd45ea80..a61256ca3 100644 --- a/crates/bitwarden-api-api/src/models/organization_user_reset_password_enrollment_request_model.rs +++ b/crates/bitwarden-api-api/src/models/organization_user_reset_password_enrollment_request_model.rs @@ -16,12 +16,15 @@ use crate::models; pub struct OrganizationUserResetPasswordEnrollmentRequestModel { #[serde(rename = "resetPasswordKey", skip_serializing_if = "Option::is_none")] pub reset_password_key: Option, + #[serde(rename = "masterPasswordHash", skip_serializing_if = "Option::is_none")] + pub master_password_hash: Option, } impl OrganizationUserResetPasswordEnrollmentRequestModel { pub fn new() -> OrganizationUserResetPasswordEnrollmentRequestModel { OrganizationUserResetPasswordEnrollmentRequestModel { reset_password_key: None, + master_password_hash: None, } } } diff --git a/crates/bitwarden-api-api/src/models/organization_user_type.rs b/crates/bitwarden-api-api/src/models/organization_user_type.rs index a87ea0960..cf79c2a38 100644 --- a/crates/bitwarden-api-api/src/models/organization_user_type.rs +++ b/crates/bitwarden-api-api/src/models/organization_user_type.rs @@ -30,7 +30,6 @@ pub enum OrganizationUserType { Owner = 0, Admin = 1, User = 2, - Manager = 3, Custom = 4, } @@ -40,7 +39,6 @@ impl std::fmt::Display for OrganizationUserType { Self::Owner => write!(f, "0"), Self::Admin => write!(f, "1"), Self::User => write!(f, "2"), - Self::Manager => write!(f, "3"), Self::Custom => write!(f, "4"), } } diff --git a/crates/bitwarden-api-api/src/models/organization_user_update_request_model.rs b/crates/bitwarden-api-api/src/models/organization_user_update_request_model.rs index 1d6fa833f..983177357 100644 --- a/crates/bitwarden-api-api/src/models/organization_user_update_request_model.rs +++ b/crates/bitwarden-api-api/src/models/organization_user_update_request_model.rs @@ -16,8 +16,6 @@ use crate::models; pub struct OrganizationUserUpdateRequestModel { #[serde(rename = "type")] pub r#type: models::OrganizationUserType, - #[serde(rename = "accessAll", skip_serializing_if = "Option::is_none")] - pub access_all: Option, #[serde( rename = "accessSecretsManager", skip_serializing_if = "Option::is_none" @@ -35,7 +33,6 @@ impl OrganizationUserUpdateRequestModel { pub fn new(r#type: models::OrganizationUserType) -> OrganizationUserUpdateRequestModel { OrganizationUserUpdateRequestModel { r#type, - access_all: None, access_secrets_manager: None, permissions: None, collections: None, diff --git a/crates/bitwarden-api-api/src/models/organization_user_user_details_response_model.rs b/crates/bitwarden-api-api/src/models/organization_user_user_details_response_model.rs index 60cc46053..37b04edde 100644 --- a/crates/bitwarden-api-api/src/models/organization_user_user_details_response_model.rs +++ b/crates/bitwarden-api-api/src/models/organization_user_user_details_response_model.rs @@ -24,8 +24,6 @@ pub struct OrganizationUserUserDetailsResponseModel { pub r#type: Option, #[serde(rename = "status", skip_serializing_if = "Option::is_none")] pub status: Option, - #[serde(rename = "accessAll", skip_serializing_if = "Option::is_none")] - pub access_all: Option, #[serde(rename = "externalId", skip_serializing_if = "Option::is_none")] pub external_id: Option, #[serde( @@ -68,7 +66,6 @@ impl OrganizationUserUserDetailsResponseModel { user_id: None, r#type: None, status: None, - access_all: None, external_id: None, access_secrets_manager: None, permissions: None, diff --git a/crates/bitwarden-api-api/src/models/password_manager_plan_features_response_model.rs b/crates/bitwarden-api-api/src/models/password_manager_plan_features_response_model.rs index 618a85cb0..d7e9514dd 100644 --- a/crates/bitwarden-api-api/src/models/password_manager_plan_features_response_model.rs +++ b/crates/bitwarden-api-api/src/models/password_manager_plan_features_response_model.rs @@ -18,10 +18,20 @@ pub struct PasswordManagerPlanFeaturesResponseModel { pub stripe_plan_id: Option, #[serde(rename = "stripeSeatPlanId", skip_serializing_if = "Option::is_none")] pub stripe_seat_plan_id: Option, + #[serde( + rename = "stripeProviderPortalSeatPlanId", + skip_serializing_if = "Option::is_none" + )] + pub stripe_provider_portal_seat_plan_id: Option, #[serde(rename = "basePrice", skip_serializing_if = "Option::is_none")] pub base_price: Option, #[serde(rename = "seatPrice", skip_serializing_if = "Option::is_none")] pub seat_price: Option, + #[serde( + rename = "providerPortalSeatPrice", + skip_serializing_if = "Option::is_none" + )] + pub provider_portal_seat_price: Option, #[serde(rename = "allowSeatAutoscale", skip_serializing_if = "Option::is_none")] pub allow_seat_autoscale: Option, #[serde( @@ -81,8 +91,10 @@ impl PasswordManagerPlanFeaturesResponseModel { PasswordManagerPlanFeaturesResponseModel { stripe_plan_id: None, stripe_seat_plan_id: None, + stripe_provider_portal_seat_plan_id: None, base_price: None, seat_price: None, + provider_portal_seat_price: None, allow_seat_autoscale: None, has_additional_seats_option: None, max_additional_seats: None, diff --git a/crates/bitwarden-api-api/src/models/plan_response_model.rs b/crates/bitwarden-api-api/src/models/plan_response_model.rs index d475ea3c5..e6d3a34d4 100644 --- a/crates/bitwarden-api-api/src/models/plan_response_model.rs +++ b/crates/bitwarden-api-api/src/models/plan_response_model.rs @@ -18,8 +18,8 @@ pub struct PlanResponseModel { pub object: Option, #[serde(rename = "type", skip_serializing_if = "Option::is_none")] pub r#type: Option, - #[serde(rename = "product", skip_serializing_if = "Option::is_none")] - pub product: Option, + #[serde(rename = "productTier", skip_serializing_if = "Option::is_none")] + pub product_tier: Option, #[serde(rename = "name", skip_serializing_if = "Option::is_none")] pub name: Option, #[serde(rename = "isAnnual", skip_serializing_if = "Option::is_none")] @@ -82,7 +82,7 @@ impl PlanResponseModel { PlanResponseModel { object: None, r#type: None, - product: None, + product_tier: None, name: None, is_annual: None, name_localization_key: None, diff --git a/crates/bitwarden-api-api/src/models/policy_type.rs b/crates/bitwarden-api-api/src/models/policy_type.rs index b20dfeb42..75f35b0ca 100644 --- a/crates/bitwarden-api-api/src/models/policy_type.rs +++ b/crates/bitwarden-api-api/src/models/policy_type.rs @@ -39,6 +39,7 @@ pub enum PolicyType { MaximumVaultTimeout = 9, DisablePersonalVaultExport = 10, ActivateAutofill = 11, + AutomaticAppLogIn = 12, } impl std::fmt::Display for PolicyType { @@ -56,6 +57,7 @@ impl std::fmt::Display for PolicyType { Self::MaximumVaultTimeout => write!(f, "9"), Self::DisablePersonalVaultExport => write!(f, "10"), Self::ActivateAutofill => write!(f, "11"), + Self::AutomaticAppLogIn => write!(f, "12"), } } } diff --git a/crates/bitwarden-api-api/src/models/prelogin_request_model.rs b/crates/bitwarden-api-api/src/models/prelogin_request_model.rs deleted file mode 100644 index 3fc815e5c..000000000 --- a/crates/bitwarden-api-api/src/models/prelogin_request_model.rs +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Bitwarden Internal API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: latest - * - * Generated by: https://openapi-generator.tech - */ - -use serde::{Deserialize, Serialize}; - -use crate::models; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct PreloginRequestModel { - #[serde(rename = "email")] - pub email: String, -} - -impl PreloginRequestModel { - pub fn new(email: String) -> PreloginRequestModel { - PreloginRequestModel { email } - } -} diff --git a/crates/bitwarden-api-api/src/models/prelogin_response_model.rs b/crates/bitwarden-api-api/src/models/prelogin_response_model.rs deleted file mode 100644 index 8bf4aaf76..000000000 --- a/crates/bitwarden-api-api/src/models/prelogin_response_model.rs +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Bitwarden Internal API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: latest - * - * Generated by: https://openapi-generator.tech - */ - -use serde::{Deserialize, Serialize}; - -use crate::models; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct PreloginResponseModel { - #[serde(rename = "kdf", skip_serializing_if = "Option::is_none")] - pub kdf: Option, - #[serde(rename = "kdfIterations", skip_serializing_if = "Option::is_none")] - pub kdf_iterations: Option, - #[serde(rename = "kdfMemory", skip_serializing_if = "Option::is_none")] - pub kdf_memory: Option, - #[serde(rename = "kdfParallelism", skip_serializing_if = "Option::is_none")] - pub kdf_parallelism: Option, -} - -impl PreloginResponseModel { - pub fn new() -> PreloginResponseModel { - PreloginResponseModel { - kdf: None, - kdf_iterations: None, - kdf_memory: None, - kdf_parallelism: None, - } - } -} diff --git a/crates/bitwarden-api-api/src/models/product_type.rs b/crates/bitwarden-api-api/src/models/product_tier_type.rs similarity index 86% rename from crates/bitwarden-api-api/src/models/product_type.rs rename to crates/bitwarden-api-api/src/models/product_tier_type.rs index 38512819c..825de4856 100644 --- a/crates/bitwarden-api-api/src/models/product_type.rs +++ b/crates/bitwarden-api-api/src/models/product_tier_type.rs @@ -26,7 +26,7 @@ use crate::models; serde_repr::Serialize_repr, serde_repr::Deserialize_repr, )] -pub enum ProductType { +pub enum ProductTierType { Free = 0, Families = 1, Teams = 2, @@ -34,7 +34,7 @@ pub enum ProductType { TeamsStarter = 4, } -impl std::fmt::Display for ProductType { +impl std::fmt::Display for ProductTierType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match self { Self::Free => write!(f, "0"), @@ -46,8 +46,8 @@ impl std::fmt::Display for ProductType { } } -impl Default for ProductType { - fn default() -> ProductType { +impl Default for ProductTierType { + fn default() -> ProductTierType { Self::Free } } diff --git a/crates/bitwarden-api-api/src/models/profile_organization_response_model.rs b/crates/bitwarden-api-api/src/models/profile_organization_response_model.rs index fc11b8284..42c22f998 100644 --- a/crates/bitwarden-api-api/src/models/profile_organization_response_model.rs +++ b/crates/bitwarden-api-api/src/models/profile_organization_response_model.rs @@ -87,6 +87,8 @@ pub struct ProfileOrganizationResponseModel { pub reset_password_enrolled: Option, #[serde(rename = "userId", skip_serializing_if = "Option::is_none")] pub user_id: Option, + #[serde(rename = "organizationUserId", skip_serializing_if = "Option::is_none")] + pub organization_user_id: Option, #[serde( rename = "hasPublicAndPrivateKeys", skip_serializing_if = "Option::is_none" @@ -108,8 +110,8 @@ pub struct ProfileOrganizationResponseModel { skip_serializing_if = "Option::is_none" )] pub family_sponsorship_available: Option, - #[serde(rename = "planProductType", skip_serializing_if = "Option::is_none")] - pub plan_product_type: Option, + #[serde(rename = "productTierType", skip_serializing_if = "Option::is_none")] + pub product_tier_type: Option, #[serde( rename = "keyConnectorEnabled", skip_serializing_if = "Option::is_none" @@ -147,11 +149,6 @@ pub struct ProfileOrganizationResponseModel { skip_serializing_if = "Option::is_none" )] pub allow_admin_access_to_all_collection_items: Option, - #[serde( - rename = "flexibleCollections", - skip_serializing_if = "Option::is_none" - )] - pub flexible_collections: Option, } impl ProfileOrganizationResponseModel { @@ -189,13 +186,14 @@ impl ProfileOrganizationResponseModel { permissions: None, reset_password_enrolled: None, user_id: None, + organization_user_id: None, has_public_and_private_keys: None, provider_id: None, provider_name: None, provider_type: None, family_sponsorship_friendly_name: None, family_sponsorship_available: None, - plan_product_type: None, + product_tier_type: None, key_connector_enabled: None, key_connector_url: None, family_sponsorship_last_sync_date: None, @@ -204,7 +202,6 @@ impl ProfileOrganizationResponseModel { access_secrets_manager: None, limit_collection_creation_deletion: None, allow_admin_access_to_all_collection_items: None, - flexible_collections: None, } } } diff --git a/crates/bitwarden-api-api/src/models/profile_provider_organization_response_model.rs b/crates/bitwarden-api-api/src/models/profile_provider_organization_response_model.rs index dc102a396..92cfbd46b 100644 --- a/crates/bitwarden-api-api/src/models/profile_provider_organization_response_model.rs +++ b/crates/bitwarden-api-api/src/models/profile_provider_organization_response_model.rs @@ -87,6 +87,8 @@ pub struct ProfileProviderOrganizationResponseModel { pub reset_password_enrolled: Option, #[serde(rename = "userId", skip_serializing_if = "Option::is_none")] pub user_id: Option, + #[serde(rename = "organizationUserId", skip_serializing_if = "Option::is_none")] + pub organization_user_id: Option, #[serde( rename = "hasPublicAndPrivateKeys", skip_serializing_if = "Option::is_none" @@ -108,8 +110,8 @@ pub struct ProfileProviderOrganizationResponseModel { skip_serializing_if = "Option::is_none" )] pub family_sponsorship_available: Option, - #[serde(rename = "planProductType", skip_serializing_if = "Option::is_none")] - pub plan_product_type: Option, + #[serde(rename = "productTierType", skip_serializing_if = "Option::is_none")] + pub product_tier_type: Option, #[serde( rename = "keyConnectorEnabled", skip_serializing_if = "Option::is_none" @@ -147,11 +149,6 @@ pub struct ProfileProviderOrganizationResponseModel { skip_serializing_if = "Option::is_none" )] pub allow_admin_access_to_all_collection_items: Option, - #[serde( - rename = "flexibleCollections", - skip_serializing_if = "Option::is_none" - )] - pub flexible_collections: Option, } impl ProfileProviderOrganizationResponseModel { @@ -189,13 +186,14 @@ impl ProfileProviderOrganizationResponseModel { permissions: None, reset_password_enrolled: None, user_id: None, + organization_user_id: None, has_public_and_private_keys: None, provider_id: None, provider_name: None, provider_type: None, family_sponsorship_friendly_name: None, family_sponsorship_available: None, - plan_product_type: None, + product_tier_type: None, key_connector_enabled: None, key_connector_url: None, family_sponsorship_last_sync_date: None, @@ -204,7 +202,6 @@ impl ProfileProviderOrganizationResponseModel { access_secrets_manager: None, limit_collection_creation_deletion: None, allow_admin_access_to_all_collection_items: None, - flexible_collections: None, } } } diff --git a/crates/bitwarden-api-api/src/models/project_counts_response_model.rs b/crates/bitwarden-api-api/src/models/project_counts_response_model.rs new file mode 100644 index 000000000..adcc97c82 --- /dev/null +++ b/crates/bitwarden-api-api/src/models/project_counts_response_model.rs @@ -0,0 +1,36 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ProjectCountsResponseModel { + #[serde(rename = "object", skip_serializing_if = "Option::is_none")] + pub object: Option, + #[serde(rename = "secrets", skip_serializing_if = "Option::is_none")] + pub secrets: Option, + #[serde(rename = "people", skip_serializing_if = "Option::is_none")] + pub people: Option, + #[serde(rename = "serviceAccounts", skip_serializing_if = "Option::is_none")] + pub service_accounts: Option, +} + +impl ProjectCountsResponseModel { + pub fn new() -> ProjectCountsResponseModel { + ProjectCountsResponseModel { + object: None, + secrets: None, + people: None, + service_accounts: None, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/project_people_access_policies_response_model.rs b/crates/bitwarden-api-api/src/models/project_people_access_policies_response_model.rs index 43a5e71ff..83ba39e22 100644 --- a/crates/bitwarden-api-api/src/models/project_people_access_policies_response_model.rs +++ b/crates/bitwarden-api-api/src/models/project_people_access_policies_response_model.rs @@ -17,12 +17,12 @@ pub struct ProjectPeopleAccessPoliciesResponseModel { #[serde(rename = "object", skip_serializing_if = "Option::is_none")] pub object: Option, #[serde(rename = "userAccessPolicies", skip_serializing_if = "Option::is_none")] - pub user_access_policies: Option>, + pub user_access_policies: Option>, #[serde( rename = "groupAccessPolicies", skip_serializing_if = "Option::is_none" )] - pub group_access_policies: Option>, + pub group_access_policies: Option>, } impl ProjectPeopleAccessPoliciesResponseModel { diff --git a/crates/bitwarden-api-api/src/models/project_service_accounts_access_policies_request_model.rs b/crates/bitwarden-api-api/src/models/project_service_accounts_access_policies_request_model.rs index 5356de2a5..3c54b4062 100644 --- a/crates/bitwarden-api-api/src/models/project_service_accounts_access_policies_request_model.rs +++ b/crates/bitwarden-api-api/src/models/project_service_accounts_access_policies_request_model.rs @@ -14,17 +14,16 @@ use crate::models; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ProjectServiceAccountsAccessPoliciesRequestModel { - #[serde( - rename = "serviceAccountAccessPolicyRequests", - skip_serializing_if = "Option::is_none" - )] + #[serde(rename = "serviceAccountAccessPolicyRequests")] pub service_account_access_policy_requests: Option>, } impl ProjectServiceAccountsAccessPoliciesRequestModel { - pub fn new() -> ProjectServiceAccountsAccessPoliciesRequestModel { + pub fn new( + service_account_access_policy_requests: Option>, + ) -> ProjectServiceAccountsAccessPoliciesRequestModel { ProjectServiceAccountsAccessPoliciesRequestModel { - service_account_access_policy_requests: None, + service_account_access_policy_requests, } } } diff --git a/crates/bitwarden-api-api/src/models/project_service_accounts_access_policies_response_model.rs b/crates/bitwarden-api-api/src/models/project_service_accounts_access_policies_response_model.rs index 74c883c08..e5899817f 100644 --- a/crates/bitwarden-api-api/src/models/project_service_accounts_access_policies_response_model.rs +++ b/crates/bitwarden-api-api/src/models/project_service_accounts_access_policies_response_model.rs @@ -21,7 +21,7 @@ pub struct ProjectServiceAccountsAccessPoliciesResponseModel { skip_serializing_if = "Option::is_none" )] pub service_account_access_policies: - Option>, + Option>, } impl ProjectServiceAccountsAccessPoliciesResponseModel { diff --git a/crates/bitwarden-api-api/src/models/provider_organization_organization_details_response_model.rs b/crates/bitwarden-api-api/src/models/provider_organization_organization_details_response_model.rs index 9ea18d08a..c721d02de 100644 --- a/crates/bitwarden-api-api/src/models/provider_organization_organization_details_response_model.rs +++ b/crates/bitwarden-api-api/src/models/provider_organization_organization_details_response_model.rs @@ -34,6 +34,10 @@ pub struct ProviderOrganizationOrganizationDetailsResponseModel { pub user_count: Option, #[serde(rename = "seats", skip_serializing_if = "Option::is_none")] pub seats: Option, + #[serde(rename = "occupiedSeats", skip_serializing_if = "Option::is_none")] + pub occupied_seats: Option, + #[serde(rename = "remainingSeats", skip_serializing_if = "Option::is_none")] + pub remaining_seats: Option, #[serde(rename = "plan", skip_serializing_if = "Option::is_none")] pub plan: Option, #[serde(rename = "organizationName", skip_serializing_if = "Option::is_none")] @@ -53,6 +57,8 @@ impl ProviderOrganizationOrganizationDetailsResponseModel { revision_date: None, user_count: None, seats: None, + occupied_seats: None, + remaining_seats: None, plan: None, organization_name: None, } diff --git a/crates/bitwarden-api-api/src/models/provider_organization_response_model.rs b/crates/bitwarden-api-api/src/models/provider_organization_response_model.rs index 387189e4b..14342f584 100644 --- a/crates/bitwarden-api-api/src/models/provider_organization_response_model.rs +++ b/crates/bitwarden-api-api/src/models/provider_organization_response_model.rs @@ -34,6 +34,10 @@ pub struct ProviderOrganizationResponseModel { pub user_count: Option, #[serde(rename = "seats", skip_serializing_if = "Option::is_none")] pub seats: Option, + #[serde(rename = "occupiedSeats", skip_serializing_if = "Option::is_none")] + pub occupied_seats: Option, + #[serde(rename = "remainingSeats", skip_serializing_if = "Option::is_none")] + pub remaining_seats: Option, #[serde(rename = "plan", skip_serializing_if = "Option::is_none")] pub plan: Option, } @@ -51,6 +55,8 @@ impl ProviderOrganizationResponseModel { revision_date: None, user_count: None, seats: None, + occupied_seats: None, + remaining_seats: None, plan: None, } } diff --git a/crates/bitwarden-api-api/src/models/register_request_model.rs b/crates/bitwarden-api-api/src/models/register_request_model.rs deleted file mode 100644 index 714b5bb06..000000000 --- a/crates/bitwarden-api-api/src/models/register_request_model.rs +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Bitwarden Internal API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: latest - * - * Generated by: https://openapi-generator.tech - */ - -use serde::{Deserialize, Serialize}; - -use crate::models; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct RegisterRequestModel { - #[serde(rename = "name", skip_serializing_if = "Option::is_none")] - pub name: Option, - #[serde(rename = "email")] - pub email: String, - #[serde(rename = "masterPasswordHash")] - pub master_password_hash: String, - #[serde(rename = "masterPasswordHint", skip_serializing_if = "Option::is_none")] - pub master_password_hint: Option, - #[serde(rename = "captchaResponse", skip_serializing_if = "Option::is_none")] - pub captcha_response: Option, - #[serde(rename = "key", skip_serializing_if = "Option::is_none")] - pub key: Option, - #[serde(rename = "keys", skip_serializing_if = "Option::is_none")] - pub keys: Option>, - #[serde(rename = "token", skip_serializing_if = "Option::is_none")] - pub token: Option, - #[serde(rename = "organizationUserId", skip_serializing_if = "Option::is_none")] - pub organization_user_id: Option, - #[serde(rename = "kdf", skip_serializing_if = "Option::is_none")] - pub kdf: Option, - #[serde(rename = "kdfIterations", skip_serializing_if = "Option::is_none")] - pub kdf_iterations: Option, - #[serde(rename = "kdfMemory", skip_serializing_if = "Option::is_none")] - pub kdf_memory: Option, - #[serde(rename = "kdfParallelism", skip_serializing_if = "Option::is_none")] - pub kdf_parallelism: Option, - #[serde(rename = "referenceData", skip_serializing_if = "Option::is_none")] - pub reference_data: Option>, -} - -impl RegisterRequestModel { - pub fn new(email: String, master_password_hash: String) -> RegisterRequestModel { - RegisterRequestModel { - name: None, - email, - master_password_hash, - master_password_hint: None, - captcha_response: None, - key: None, - keys: None, - token: None, - organization_user_id: None, - kdf: None, - kdf_iterations: None, - kdf_memory: None, - kdf_parallelism: None, - reference_data: None, - } - } -} diff --git a/crates/bitwarden-api-api/src/models/register_response_model.rs b/crates/bitwarden-api-api/src/models/register_response_model.rs deleted file mode 100644 index 560f2409a..000000000 --- a/crates/bitwarden-api-api/src/models/register_response_model.rs +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Bitwarden Internal API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: latest - * - * Generated by: https://openapi-generator.tech - */ - -use serde::{Deserialize, Serialize}; - -use crate::models; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct RegisterResponseModel { - #[serde(rename = "object", skip_serializing_if = "Option::is_none")] - pub object: Option, - #[serde(rename = "captchaBypassToken", skip_serializing_if = "Option::is_none")] - pub captcha_bypass_token: Option, -} - -impl RegisterResponseModel { - pub fn new() -> RegisterResponseModel { - RegisterResponseModel { - object: None, - captcha_bypass_token: None, - } - } -} diff --git a/crates/bitwarden-api-api/src/models/request_sm_access_request_model.rs b/crates/bitwarden-api-api/src/models/request_sm_access_request_model.rs new file mode 100644 index 000000000..6ff8811db --- /dev/null +++ b/crates/bitwarden-api-api/src/models/request_sm_access_request_model.rs @@ -0,0 +1,30 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct RequestSmAccessRequestModel { + #[serde(rename = "organizationId")] + pub organization_id: uuid::Uuid, + #[serde(rename = "emailContent")] + pub email_content: String, +} + +impl RequestSmAccessRequestModel { + pub fn new(organization_id: uuid::Uuid, email_content: String) -> RequestSmAccessRequestModel { + RequestSmAccessRequestModel { + organization_id, + email_content, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/reset_password_with_org_id_request_model.rs b/crates/bitwarden-api-api/src/models/reset_password_with_org_id_request_model.rs index 3bc06379f..a3ce5927f 100644 --- a/crates/bitwarden-api-api/src/models/reset_password_with_org_id_request_model.rs +++ b/crates/bitwarden-api-api/src/models/reset_password_with_org_id_request_model.rs @@ -16,6 +16,8 @@ use crate::models; pub struct ResetPasswordWithOrgIdRequestModel { #[serde(rename = "resetPasswordKey", skip_serializing_if = "Option::is_none")] pub reset_password_key: Option, + #[serde(rename = "masterPasswordHash", skip_serializing_if = "Option::is_none")] + pub master_password_hash: Option, #[serde(rename = "organizationId")] pub organization_id: uuid::Uuid, } @@ -24,6 +26,7 @@ impl ResetPasswordWithOrgIdRequestModel { pub fn new(organization_id: uuid::Uuid) -> ResetPasswordWithOrgIdRequestModel { ResetPasswordWithOrgIdRequestModel { reset_password_key: None, + master_password_hash: None, organization_id, } } diff --git a/crates/bitwarden-api-api/src/models/secret_access_policies_requests_model.rs b/crates/bitwarden-api-api/src/models/secret_access_policies_requests_model.rs new file mode 100644 index 000000000..6eaf09b36 --- /dev/null +++ b/crates/bitwarden-api-api/src/models/secret_access_policies_requests_model.rs @@ -0,0 +1,37 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SecretAccessPoliciesRequestsModel { + #[serde(rename = "userAccessPolicyRequests")] + pub user_access_policy_requests: Option>, + #[serde(rename = "groupAccessPolicyRequests")] + pub group_access_policy_requests: Option>, + #[serde(rename = "serviceAccountAccessPolicyRequests")] + pub service_account_access_policy_requests: Option>, +} + +impl SecretAccessPoliciesRequestsModel { + pub fn new( + user_access_policy_requests: Option>, + group_access_policy_requests: Option>, + service_account_access_policy_requests: Option>, + ) -> SecretAccessPoliciesRequestsModel { + SecretAccessPoliciesRequestsModel { + user_access_policy_requests, + group_access_policy_requests, + service_account_access_policy_requests, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/secret_access_policies_response_model.rs b/crates/bitwarden-api-api/src/models/secret_access_policies_response_model.rs new file mode 100644 index 000000000..947926ad6 --- /dev/null +++ b/crates/bitwarden-api-api/src/models/secret_access_policies_response_model.rs @@ -0,0 +1,43 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SecretAccessPoliciesResponseModel { + #[serde(rename = "object", skip_serializing_if = "Option::is_none")] + pub object: Option, + #[serde(rename = "userAccessPolicies", skip_serializing_if = "Option::is_none")] + pub user_access_policies: Option>, + #[serde( + rename = "groupAccessPolicies", + skip_serializing_if = "Option::is_none" + )] + pub group_access_policies: Option>, + #[serde( + rename = "serviceAccountAccessPolicies", + skip_serializing_if = "Option::is_none" + )] + pub service_account_access_policies: + Option>, +} + +impl SecretAccessPoliciesResponseModel { + pub fn new() -> SecretAccessPoliciesResponseModel { + SecretAccessPoliciesResponseModel { + object: None, + user_access_policies: None, + group_access_policies: None, + service_account_access_policies: None, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/secret_create_request_model.rs b/crates/bitwarden-api-api/src/models/secret_create_request_model.rs index 7325ba8e0..91b55cceb 100644 --- a/crates/bitwarden-api-api/src/models/secret_create_request_model.rs +++ b/crates/bitwarden-api-api/src/models/secret_create_request_model.rs @@ -22,6 +22,11 @@ pub struct SecretCreateRequestModel { pub note: String, #[serde(rename = "projectIds", skip_serializing_if = "Option::is_none")] pub project_ids: Option>, + #[serde( + rename = "accessPoliciesRequests", + skip_serializing_if = "Option::is_none" + )] + pub access_policies_requests: Option>, } impl SecretCreateRequestModel { @@ -31,6 +36,7 @@ impl SecretCreateRequestModel { value, note, project_ids: None, + access_policies_requests: None, } } } diff --git a/crates/bitwarden-api-api/src/models/secret_update_request_model.rs b/crates/bitwarden-api-api/src/models/secret_update_request_model.rs index c0f11a8a1..878fb7875 100644 --- a/crates/bitwarden-api-api/src/models/secret_update_request_model.rs +++ b/crates/bitwarden-api-api/src/models/secret_update_request_model.rs @@ -22,6 +22,11 @@ pub struct SecretUpdateRequestModel { pub note: String, #[serde(rename = "projectIds", skip_serializing_if = "Option::is_none")] pub project_ids: Option>, + #[serde( + rename = "accessPoliciesRequests", + skip_serializing_if = "Option::is_none" + )] + pub access_policies_requests: Option>, } impl SecretUpdateRequestModel { @@ -31,6 +36,7 @@ impl SecretUpdateRequestModel { value, note, project_ids: None, + access_policies_requests: None, } } } diff --git a/crates/bitwarden-api-api/src/models/service_account_access_policy_response_model.rs b/crates/bitwarden-api-api/src/models/service_account_access_policy_response_model.rs new file mode 100644 index 000000000..5418235f6 --- /dev/null +++ b/crates/bitwarden-api-api/src/models/service_account_access_policy_response_model.rs @@ -0,0 +1,39 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ServiceAccountAccessPolicyResponseModel { + #[serde(rename = "object", skip_serializing_if = "Option::is_none")] + pub object: Option, + #[serde(rename = "read", skip_serializing_if = "Option::is_none")] + pub read: Option, + #[serde(rename = "write", skip_serializing_if = "Option::is_none")] + pub write: Option, + #[serde(rename = "serviceAccountId", skip_serializing_if = "Option::is_none")] + pub service_account_id: Option, + #[serde(rename = "serviceAccountName", skip_serializing_if = "Option::is_none")] + pub service_account_name: Option, +} + +impl ServiceAccountAccessPolicyResponseModel { + pub fn new() -> ServiceAccountAccessPolicyResponseModel { + ServiceAccountAccessPolicyResponseModel { + object: None, + read: None, + write: None, + service_account_id: None, + service_account_name: None, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/service_account_counts_response_model.rs b/crates/bitwarden-api-api/src/models/service_account_counts_response_model.rs new file mode 100644 index 000000000..fd382406e --- /dev/null +++ b/crates/bitwarden-api-api/src/models/service_account_counts_response_model.rs @@ -0,0 +1,36 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct ServiceAccountCountsResponseModel { + #[serde(rename = "object", skip_serializing_if = "Option::is_none")] + pub object: Option, + #[serde(rename = "projects", skip_serializing_if = "Option::is_none")] + pub projects: Option, + #[serde(rename = "people", skip_serializing_if = "Option::is_none")] + pub people: Option, + #[serde(rename = "accessTokens", skip_serializing_if = "Option::is_none")] + pub access_tokens: Option, +} + +impl ServiceAccountCountsResponseModel { + pub fn new() -> ServiceAccountCountsResponseModel { + ServiceAccountCountsResponseModel { + object: None, + projects: None, + people: None, + access_tokens: None, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/service_account_granted_policies_permission_details_response_model.rs b/crates/bitwarden-api-api/src/models/service_account_granted_policies_permission_details_response_model.rs index d55f2bec7..8d7458867 100644 --- a/crates/bitwarden-api-api/src/models/service_account_granted_policies_permission_details_response_model.rs +++ b/crates/bitwarden-api-api/src/models/service_account_granted_policies_permission_details_response_model.rs @@ -21,7 +21,7 @@ pub struct ServiceAccountGrantedPoliciesPermissionDetailsResponseModel { skip_serializing_if = "Option::is_none" )] pub granted_project_policies: - Option>, + Option>, } impl ServiceAccountGrantedPoliciesPermissionDetailsResponseModel { diff --git a/crates/bitwarden-api-api/src/models/service_account_granted_policies_request_model.rs b/crates/bitwarden-api-api/src/models/service_account_granted_policies_request_model.rs index d9f87b85f..7fe6a0d26 100644 --- a/crates/bitwarden-api-api/src/models/service_account_granted_policies_request_model.rs +++ b/crates/bitwarden-api-api/src/models/service_account_granted_policies_request_model.rs @@ -14,17 +14,16 @@ use crate::models; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] pub struct ServiceAccountGrantedPoliciesRequestModel { - #[serde( - rename = "projectGrantedPolicyRequests", - skip_serializing_if = "Option::is_none" - )] + #[serde(rename = "projectGrantedPolicyRequests")] pub project_granted_policy_requests: Option>, } impl ServiceAccountGrantedPoliciesRequestModel { - pub fn new() -> ServiceAccountGrantedPoliciesRequestModel { + pub fn new( + project_granted_policy_requests: Option>, + ) -> ServiceAccountGrantedPoliciesRequestModel { ServiceAccountGrantedPoliciesRequestModel { - project_granted_policy_requests: None, + project_granted_policy_requests, } } } diff --git a/crates/bitwarden-api-api/src/models/service_account_people_access_policies_response_model.rs b/crates/bitwarden-api-api/src/models/service_account_people_access_policies_response_model.rs index 84cf3ac18..affba169a 100644 --- a/crates/bitwarden-api-api/src/models/service_account_people_access_policies_response_model.rs +++ b/crates/bitwarden-api-api/src/models/service_account_people_access_policies_response_model.rs @@ -17,12 +17,12 @@ pub struct ServiceAccountPeopleAccessPoliciesResponseModel { #[serde(rename = "object", skip_serializing_if = "Option::is_none")] pub object: Option, #[serde(rename = "userAccessPolicies", skip_serializing_if = "Option::is_none")] - pub user_access_policies: Option>, + pub user_access_policies: Option>, #[serde( rename = "groupAccessPolicies", skip_serializing_if = "Option::is_none" )] - pub group_access_policies: Option>, + pub group_access_policies: Option>, } impl ServiceAccountPeopleAccessPoliciesResponseModel { diff --git a/crates/bitwarden-api-api/src/models/tax_information_request_body.rs b/crates/bitwarden-api-api/src/models/tax_information_request_body.rs new file mode 100644 index 000000000..539608881 --- /dev/null +++ b/crates/bitwarden-api-api/src/models/tax_information_request_body.rs @@ -0,0 +1,45 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct TaxInformationRequestBody { + #[serde(rename = "country")] + pub country: String, + #[serde(rename = "postalCode")] + pub postal_code: String, + #[serde(rename = "taxId", skip_serializing_if = "Option::is_none")] + pub tax_id: Option, + #[serde(rename = "line1", skip_serializing_if = "Option::is_none")] + pub line1: Option, + #[serde(rename = "line2", skip_serializing_if = "Option::is_none")] + pub line2: Option, + #[serde(rename = "city", skip_serializing_if = "Option::is_none")] + pub city: Option, + #[serde(rename = "state", skip_serializing_if = "Option::is_none")] + pub state: Option, +} + +impl TaxInformationRequestBody { + pub fn new(country: String, postal_code: String) -> TaxInformationRequestBody { + TaxInformationRequestBody { + country, + postal_code, + tax_id: None, + line1: None, + line2: None, + city: None, + state: None, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/two_factor_authenticator_disable_request_model.rs b/crates/bitwarden-api-api/src/models/two_factor_authenticator_disable_request_model.rs new file mode 100644 index 000000000..6d05df555 --- /dev/null +++ b/crates/bitwarden-api-api/src/models/two_factor_authenticator_disable_request_model.rs @@ -0,0 +1,52 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct TwoFactorAuthenticatorDisableRequestModel { + #[serde(rename = "masterPasswordHash", skip_serializing_if = "Option::is_none")] + pub master_password_hash: Option, + #[serde(rename = "otp", skip_serializing_if = "Option::is_none")] + pub otp: Option, + #[serde( + rename = "authRequestAccessCode", + skip_serializing_if = "Option::is_none" + )] + pub auth_request_access_code: Option, + #[serde(rename = "secret", skip_serializing_if = "Option::is_none")] + pub secret: Option, + #[serde(rename = "type")] + pub r#type: models::TwoFactorProviderType, + #[serde(rename = "userVerificationToken")] + pub user_verification_token: String, + #[serde(rename = "key")] + pub key: String, +} + +impl TwoFactorAuthenticatorDisableRequestModel { + pub fn new( + r#type: models::TwoFactorProviderType, + user_verification_token: String, + key: String, + ) -> TwoFactorAuthenticatorDisableRequestModel { + TwoFactorAuthenticatorDisableRequestModel { + master_password_hash: None, + otp: None, + auth_request_access_code: None, + secret: None, + r#type, + user_verification_token, + key, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/two_factor_authenticator_response_model.rs b/crates/bitwarden-api-api/src/models/two_factor_authenticator_response_model.rs index bc4eaa339..dba1dc0fa 100644 --- a/crates/bitwarden-api-api/src/models/two_factor_authenticator_response_model.rs +++ b/crates/bitwarden-api-api/src/models/two_factor_authenticator_response_model.rs @@ -20,6 +20,11 @@ pub struct TwoFactorAuthenticatorResponseModel { pub enabled: Option, #[serde(rename = "key", skip_serializing_if = "Option::is_none")] pub key: Option, + #[serde( + rename = "userVerificationToken", + skip_serializing_if = "Option::is_none" + )] + pub user_verification_token: Option, } impl TwoFactorAuthenticatorResponseModel { @@ -28,6 +33,7 @@ impl TwoFactorAuthenticatorResponseModel { object: None, enabled: None, key: None, + user_verification_token: None, } } } diff --git a/crates/bitwarden-api-api/src/models/two_factor_duo_response_model.rs b/crates/bitwarden-api-api/src/models/two_factor_duo_response_model.rs index c1afa6b1f..35574f821 100644 --- a/crates/bitwarden-api-api/src/models/two_factor_duo_response_model.rs +++ b/crates/bitwarden-api-api/src/models/two_factor_duo_response_model.rs @@ -24,6 +24,10 @@ pub struct TwoFactorDuoResponseModel { pub secret_key: Option, #[serde(rename = "integrationKey", skip_serializing_if = "Option::is_none")] pub integration_key: Option, + #[serde(rename = "clientSecret", skip_serializing_if = "Option::is_none")] + pub client_secret: Option, + #[serde(rename = "clientId", skip_serializing_if = "Option::is_none")] + pub client_id: Option, } impl TwoFactorDuoResponseModel { @@ -34,6 +38,8 @@ impl TwoFactorDuoResponseModel { host: None, secret_key: None, integration_key: None, + client_secret: None, + client_id: None, } } } diff --git a/crates/bitwarden-api-api/src/models/update_key_request_model.rs b/crates/bitwarden-api-api/src/models/update_key_request_model.rs index e721fbecb..179c0fddd 100644 --- a/crates/bitwarden-api-api/src/models/update_key_request_model.rs +++ b/crates/bitwarden-api-api/src/models/update_key_request_model.rs @@ -33,6 +33,8 @@ pub struct UpdateKeyRequestModel { pub emergency_access_keys: Option>, #[serde(rename = "resetPasswordKeys", skip_serializing_if = "Option::is_none")] pub reset_password_keys: Option>, + #[serde(rename = "webAuthnKeys", skip_serializing_if = "Option::is_none")] + pub web_authn_keys: Option>, } impl UpdateKeyRequestModel { @@ -50,6 +52,7 @@ impl UpdateKeyRequestModel { sends: None, emergency_access_keys: None, reset_password_keys: None, + web_authn_keys: None, } } } diff --git a/crates/bitwarden-api-api/src/models/update_tde_offboarding_password_request_model.rs b/crates/bitwarden-api-api/src/models/update_tde_offboarding_password_request_model.rs new file mode 100644 index 000000000..aeb1f424b --- /dev/null +++ b/crates/bitwarden-api-api/src/models/update_tde_offboarding_password_request_model.rs @@ -0,0 +1,36 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct UpdateTdeOffboardingPasswordRequestModel { + #[serde(rename = "newMasterPasswordHash")] + pub new_master_password_hash: String, + #[serde(rename = "key")] + pub key: String, + #[serde(rename = "masterPasswordHint", skip_serializing_if = "Option::is_none")] + pub master_password_hint: Option, +} + +impl UpdateTdeOffboardingPasswordRequestModel { + pub fn new( + new_master_password_hash: String, + key: String, + ) -> UpdateTdeOffboardingPasswordRequestModel { + UpdateTdeOffboardingPasswordRequestModel { + new_master_password_hash, + key, + master_password_hint: None, + } + } +} diff --git a/crates/bitwarden-api-api/src/models/update_two_factor_authenticator_request_model.rs b/crates/bitwarden-api-api/src/models/update_two_factor_authenticator_request_model.rs index af4d177b5..314699a72 100644 --- a/crates/bitwarden-api-api/src/models/update_two_factor_authenticator_request_model.rs +++ b/crates/bitwarden-api-api/src/models/update_two_factor_authenticator_request_model.rs @@ -29,6 +29,11 @@ pub struct UpdateTwoFactorAuthenticatorRequestModel { pub token: String, #[serde(rename = "key")] pub key: String, + #[serde( + rename = "userVerificationToken", + skip_serializing_if = "Option::is_none" + )] + pub user_verification_token: Option, } impl UpdateTwoFactorAuthenticatorRequestModel { @@ -40,6 +45,7 @@ impl UpdateTwoFactorAuthenticatorRequestModel { secret: None, token, key, + user_verification_token: None, } } } diff --git a/crates/bitwarden-api-api/src/models/update_two_factor_duo_request_model.rs b/crates/bitwarden-api-api/src/models/update_two_factor_duo_request_model.rs index 61bf2c446..5a4989c52 100644 --- a/crates/bitwarden-api-api/src/models/update_two_factor_duo_request_model.rs +++ b/crates/bitwarden-api-api/src/models/update_two_factor_duo_request_model.rs @@ -25,27 +25,29 @@ pub struct UpdateTwoFactorDuoRequestModel { pub auth_request_access_code: Option, #[serde(rename = "secret", skip_serializing_if = "Option::is_none")] pub secret: Option, - #[serde(rename = "integrationKey")] - pub integration_key: String, - #[serde(rename = "secretKey")] - pub secret_key: String, + #[serde(rename = "clientId", skip_serializing_if = "Option::is_none")] + pub client_id: Option, + #[serde(rename = "clientSecret", skip_serializing_if = "Option::is_none")] + pub client_secret: Option, + #[serde(rename = "integrationKey", skip_serializing_if = "Option::is_none")] + pub integration_key: Option, + #[serde(rename = "secretKey", skip_serializing_if = "Option::is_none")] + pub secret_key: Option, #[serde(rename = "host")] pub host: String, } impl UpdateTwoFactorDuoRequestModel { - pub fn new( - integration_key: String, - secret_key: String, - host: String, - ) -> UpdateTwoFactorDuoRequestModel { + pub fn new(host: String) -> UpdateTwoFactorDuoRequestModel { UpdateTwoFactorDuoRequestModel { master_password_hash: None, otp: None, auth_request_access_code: None, secret: None, - integration_key, - secret_key, + client_id: None, + client_secret: None, + integration_key: None, + secret_key: None, host, } } diff --git a/crates/bitwarden-api-api/src/models/user_project_access_policy_response_model.rs b/crates/bitwarden-api-api/src/models/user_access_policy_response_model.rs similarity index 58% rename from crates/bitwarden-api-api/src/models/user_project_access_policy_response_model.rs rename to crates/bitwarden-api-api/src/models/user_access_policy_response_model.rs index c06deebde..5585a9c4f 100644 --- a/crates/bitwarden-api-api/src/models/user_project_access_policy_response_model.rs +++ b/crates/bitwarden-api-api/src/models/user_access_policy_response_model.rs @@ -13,19 +13,13 @@ use serde::{Deserialize, Serialize}; use crate::models; #[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct UserProjectAccessPolicyResponseModel { +pub struct UserAccessPolicyResponseModel { #[serde(rename = "object", skip_serializing_if = "Option::is_none")] pub object: Option, - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - pub id: Option, #[serde(rename = "read", skip_serializing_if = "Option::is_none")] pub read: Option, #[serde(rename = "write", skip_serializing_if = "Option::is_none")] pub write: Option, - #[serde(rename = "creationDate", skip_serializing_if = "Option::is_none")] - pub creation_date: Option, - #[serde(rename = "revisionDate", skip_serializing_if = "Option::is_none")] - pub revision_date: Option, #[serde(rename = "organizationUserId", skip_serializing_if = "Option::is_none")] pub organization_user_id: Option, #[serde( @@ -33,27 +27,18 @@ pub struct UserProjectAccessPolicyResponseModel { skip_serializing_if = "Option::is_none" )] pub organization_user_name: Option, - #[serde(rename = "userId", skip_serializing_if = "Option::is_none")] - pub user_id: Option, - #[serde(rename = "grantedProjectId", skip_serializing_if = "Option::is_none")] - pub granted_project_id: Option, #[serde(rename = "currentUser", skip_serializing_if = "Option::is_none")] pub current_user: Option, } -impl UserProjectAccessPolicyResponseModel { - pub fn new() -> UserProjectAccessPolicyResponseModel { - UserProjectAccessPolicyResponseModel { +impl UserAccessPolicyResponseModel { + pub fn new() -> UserAccessPolicyResponseModel { + UserAccessPolicyResponseModel { object: None, - id: None, read: None, write: None, - creation_date: None, - revision_date: None, organization_user_id: None, organization_user_name: None, - user_id: None, - granted_project_id: None, current_user: None, } } diff --git a/crates/bitwarden-api-api/src/models/user_service_account_access_policy_response_model.rs b/crates/bitwarden-api-api/src/models/user_service_account_access_policy_response_model.rs deleted file mode 100644 index 1eaf94cda..000000000 --- a/crates/bitwarden-api-api/src/models/user_service_account_access_policy_response_model.rs +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Bitwarden Internal API - * - * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - * - * The version of the OpenAPI document: latest - * - * Generated by: https://openapi-generator.tech - */ - -use serde::{Deserialize, Serialize}; - -use crate::models; - -#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] -pub struct UserServiceAccountAccessPolicyResponseModel { - #[serde(rename = "object", skip_serializing_if = "Option::is_none")] - pub object: Option, - #[serde(rename = "id", skip_serializing_if = "Option::is_none")] - pub id: Option, - #[serde(rename = "read", skip_serializing_if = "Option::is_none")] - pub read: Option, - #[serde(rename = "write", skip_serializing_if = "Option::is_none")] - pub write: Option, - #[serde(rename = "creationDate", skip_serializing_if = "Option::is_none")] - pub creation_date: Option, - #[serde(rename = "revisionDate", skip_serializing_if = "Option::is_none")] - pub revision_date: Option, - #[serde(rename = "organizationUserId", skip_serializing_if = "Option::is_none")] - pub organization_user_id: Option, - #[serde( - rename = "organizationUserName", - skip_serializing_if = "Option::is_none" - )] - pub organization_user_name: Option, - #[serde(rename = "userId", skip_serializing_if = "Option::is_none")] - pub user_id: Option, - #[serde( - rename = "grantedServiceAccountId", - skip_serializing_if = "Option::is_none" - )] - pub granted_service_account_id: Option, - #[serde(rename = "currentUser", skip_serializing_if = "Option::is_none")] - pub current_user: Option, -} - -impl UserServiceAccountAccessPolicyResponseModel { - pub fn new() -> UserServiceAccountAccessPolicyResponseModel { - UserServiceAccountAccessPolicyResponseModel { - object: None, - id: None, - read: None, - write: None, - creation_date: None, - revision_date: None, - organization_user_id: None, - organization_user_name: None, - user_id: None, - granted_service_account_id: None, - current_user: None, - } - } -} diff --git a/crates/bitwarden-api-api/src/models/web_authn_credential_response_model.rs b/crates/bitwarden-api-api/src/models/web_authn_credential_response_model.rs index 56534214f..fb1f9004f 100644 --- a/crates/bitwarden-api-api/src/models/web_authn_credential_response_model.rs +++ b/crates/bitwarden-api-api/src/models/web_authn_credential_response_model.rs @@ -22,6 +22,10 @@ pub struct WebAuthnCredentialResponseModel { pub name: Option, #[serde(rename = "prfStatus", skip_serializing_if = "Option::is_none")] pub prf_status: Option, + #[serde(rename = "encryptedUserKey", skip_serializing_if = "Option::is_none")] + pub encrypted_user_key: Option, + #[serde(rename = "encryptedPublicKey", skip_serializing_if = "Option::is_none")] + pub encrypted_public_key: Option, } impl WebAuthnCredentialResponseModel { @@ -31,6 +35,8 @@ impl WebAuthnCredentialResponseModel { id: None, name: None, prf_status: None, + encrypted_user_key: None, + encrypted_public_key: None, } } } diff --git a/crates/bitwarden-api-api/src/models/web_authn_login_rotate_key_request_model.rs b/crates/bitwarden-api-api/src/models/web_authn_login_rotate_key_request_model.rs new file mode 100644 index 000000000..b1beddeaa --- /dev/null +++ b/crates/bitwarden-api-api/src/models/web_authn_login_rotate_key_request_model.rs @@ -0,0 +1,37 @@ +/* + * Bitwarden Internal API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: latest + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct WebAuthnLoginRotateKeyRequestModel { + #[serde(rename = "id")] + pub id: uuid::Uuid, + #[serde(rename = "encryptedUserKey")] + pub encrypted_user_key: String, + #[serde(rename = "encryptedPublicKey")] + pub encrypted_public_key: String, +} + +impl WebAuthnLoginRotateKeyRequestModel { + pub fn new( + id: uuid::Uuid, + encrypted_user_key: String, + encrypted_public_key: String, + ) -> WebAuthnLoginRotateKeyRequestModel { + WebAuthnLoginRotateKeyRequestModel { + id, + encrypted_user_key, + encrypted_public_key, + } + } +} diff --git a/crates/bitwarden-api-identity/.openapi-generator/FILES b/crates/bitwarden-api-identity/.openapi-generator/FILES index 968fd8fe4..43c2edd75 100644 --- a/crates/bitwarden-api-identity/.openapi-generator/FILES +++ b/crates/bitwarden-api-identity/.openapi-generator/FILES @@ -15,9 +15,15 @@ src/models/keys_request_model.rs src/models/mod.rs src/models/prelogin_request_model.rs src/models/prelogin_response_model.rs +src/models/product_tier_type.rs +src/models/product_type.rs src/models/public_key_credential_descriptor.rs src/models/public_key_credential_type.rs +src/models/register_finish_request_model.rs src/models/register_request_model.rs src/models/register_response_model.rs +src/models/register_send_verification_email_request_model.rs +src/models/register_verification_email_clicked_request_model.rs +src/models/trial_send_verification_email_request_model.rs src/models/user_verification_requirement.rs src/models/web_authn_login_assertion_options_response_model.rs diff --git a/crates/bitwarden-api-identity/README.md b/crates/bitwarden-api-identity/README.md index 16339f7a9..ec789a3fb 100644 --- a/crates/bitwarden-api-identity/README.md +++ b/crates/bitwarden-api-identity/README.md @@ -27,18 +27,22 @@ bitwarden-api-identity = { path = "./bitwarden-api-identity" } All URIs are relative to _http://localhost_ -| Class | Method | HTTP request | Description | -| ------------- | ---------------------------------------------------------------------------------------------------------- | -------------------------------------------- | ----------- | -| _AccountsApi_ | [**accounts_prelogin_post**](docs/AccountsApi.md#accounts_prelogin_post) | **POST** /accounts/prelogin | -| _AccountsApi_ | [**accounts_register_post**](docs/AccountsApi.md#accounts_register_post) | **POST** /accounts/register | -| _AccountsApi_ | [**accounts_webauthn_assertion_options_get**](docs/AccountsApi.md#accounts_webauthn_assertion_options_get) | **GET** /accounts/webauthn/assertion-options | -| _InfoApi_ | [**alive_get**](docs/InfoApi.md#alive_get) | **GET** /alive | -| _InfoApi_ | [**now_get**](docs/InfoApi.md#now_get) | **GET** /now | -| _InfoApi_ | [**version_get**](docs/InfoApi.md#version_get) | **GET** /version | -| _SsoApi_ | [**sso_external_callback_get**](docs/SsoApi.md#sso_external_callback_get) | **GET** /sso/ExternalCallback | -| _SsoApi_ | [**sso_external_challenge_get**](docs/SsoApi.md#sso_external_challenge_get) | **GET** /sso/ExternalChallenge | -| _SsoApi_ | [**sso_login_get**](docs/SsoApi.md#sso_login_get) | **GET** /sso/Login | -| _SsoApi_ | [**sso_pre_validate_get**](docs/SsoApi.md#sso_pre_validate_get) | **GET** /sso/PreValidate | +| Class | Method | HTTP request | Description | +| ------------- | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------ | ----------- | +| _AccountsApi_ | [**accounts_prelogin_post**](docs/AccountsApi.md#accounts_prelogin_post) | **POST** /accounts/prelogin | +| _AccountsApi_ | [**accounts_register_finish_post**](docs/AccountsApi.md#accounts_register_finish_post) | **POST** /accounts/register/finish | +| _AccountsApi_ | [**accounts_register_post**](docs/AccountsApi.md#accounts_register_post) | **POST** /accounts/register | +| _AccountsApi_ | [**accounts_register_send_verification_email_post**](docs/AccountsApi.md#accounts_register_send_verification_email_post) | **POST** /accounts/register/send-verification-email | +| _AccountsApi_ | [**accounts_register_verification_email_clicked_post**](docs/AccountsApi.md#accounts_register_verification_email_clicked_post) | **POST** /accounts/register/verification-email-clicked | +| _AccountsApi_ | [**accounts_trial_send_verification_email_post**](docs/AccountsApi.md#accounts_trial_send_verification_email_post) | **POST** /accounts/trial/send-verification-email | +| _AccountsApi_ | [**accounts_webauthn_assertion_options_get**](docs/AccountsApi.md#accounts_webauthn_assertion_options_get) | **GET** /accounts/webauthn/assertion-options | +| _InfoApi_ | [**alive_get**](docs/InfoApi.md#alive_get) | **GET** /alive | +| _InfoApi_ | [**now_get**](docs/InfoApi.md#now_get) | **GET** /now | +| _InfoApi_ | [**version_get**](docs/InfoApi.md#version_get) | **GET** /version | +| _SsoApi_ | [**sso_external_callback_get**](docs/SsoApi.md#sso_external_callback_get) | **GET** /sso/ExternalCallback | +| _SsoApi_ | [**sso_external_challenge_get**](docs/SsoApi.md#sso_external_challenge_get) | **GET** /sso/ExternalChallenge | +| _SsoApi_ | [**sso_login_get**](docs/SsoApi.md#sso_login_get) | **GET** /sso/Login | +| _SsoApi_ | [**sso_pre_validate_get**](docs/SsoApi.md#sso_pre_validate_get) | **GET** /sso/PreValidate | ## Documentation For Models @@ -49,10 +53,16 @@ All URIs are relative to _http://localhost_ - [KeysRequestModel](docs/KeysRequestModel.md) - [PreloginRequestModel](docs/PreloginRequestModel.md) - [PreloginResponseModel](docs/PreloginResponseModel.md) +- [ProductTierType](docs/ProductTierType.md) +- [ProductType](docs/ProductType.md) - [PublicKeyCredentialDescriptor](docs/PublicKeyCredentialDescriptor.md) - [PublicKeyCredentialType](docs/PublicKeyCredentialType.md) +- [RegisterFinishRequestModel](docs/RegisterFinishRequestModel.md) - [RegisterRequestModel](docs/RegisterRequestModel.md) - [RegisterResponseModel](docs/RegisterResponseModel.md) +- [RegisterSendVerificationEmailRequestModel](docs/RegisterSendVerificationEmailRequestModel.md) +- [RegisterVerificationEmailClickedRequestModel](docs/RegisterVerificationEmailClickedRequestModel.md) +- [TrialSendVerificationEmailRequestModel](docs/TrialSendVerificationEmailRequestModel.md) - [UserVerificationRequirement](docs/UserVerificationRequirement.md) - [WebAuthnLoginAssertionOptionsResponseModel](docs/WebAuthnLoginAssertionOptionsResponseModel.md) diff --git a/crates/bitwarden-api-identity/src/apis/accounts_api.rs b/crates/bitwarden-api-identity/src/apis/accounts_api.rs index 420326cfc..25474d97e 100644 --- a/crates/bitwarden-api-identity/src/apis/accounts_api.rs +++ b/crates/bitwarden-api-identity/src/apis/accounts_api.rs @@ -21,6 +21,13 @@ pub enum AccountsPreloginPostError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`accounts_register_finish_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsRegisterFinishPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`accounts_register_post`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -28,6 +35,27 @@ pub enum AccountsRegisterPostError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`accounts_register_send_verification_email_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsRegisterSendVerificationEmailPostError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`accounts_register_verification_email_clicked_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsRegisterVerificationEmailClickedPostError { + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`accounts_trial_send_verification_email_post`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum AccountsTrialSendVerificationEmailPostError { + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`accounts_webauthn_assertion_options_get`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -73,6 +101,47 @@ pub async fn accounts_prelogin_post( } } +pub async fn accounts_register_finish_post( + configuration: &configuration::Configuration, + register_finish_request_model: Option, +) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/register/finish", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + local_var_req_builder = local_var_req_builder.json(®ister_finish_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + pub async fn accounts_register_post( configuration: &configuration::Configuration, register_request_model: Option, @@ -111,6 +180,138 @@ pub async fn accounts_register_post( } } +pub async fn accounts_register_send_verification_email_post( + configuration: &configuration::Configuration, + register_send_verification_email_request_model: Option< + models::RegisterSendVerificationEmailRequestModel, + >, +) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/register/send-verification-email", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + local_var_req_builder = + local_var_req_builder.json(®ister_send_verification_email_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn accounts_register_verification_email_clicked_post( + configuration: &configuration::Configuration, + register_verification_email_clicked_request_model: Option< + models::RegisterVerificationEmailClickedRequestModel, + >, +) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/register/verification-email-clicked", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + local_var_req_builder = + local_var_req_builder.json(®ister_verification_email_clicked_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn accounts_trial_send_verification_email_post( + configuration: &configuration::Configuration, + trial_send_verification_email_request_model: Option< + models::TrialSendVerificationEmailRequestModel, + >, +) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!( + "{}/accounts/trial/send-verification-email", + local_var_configuration.base_path + ); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + local_var_req_builder = + local_var_req_builder.json(&trial_send_verification_email_request_model); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} + pub async fn accounts_webauthn_assertion_options_get( configuration: &configuration::Configuration, ) -> Result< diff --git a/crates/bitwarden-api-identity/src/models/mod.rs b/crates/bitwarden-api-identity/src/models/mod.rs index 715e29686..00203b714 100644 --- a/crates/bitwarden-api-identity/src/models/mod.rs +++ b/crates/bitwarden-api-identity/src/models/mod.rs @@ -12,14 +12,26 @@ pub mod prelogin_request_model; pub use self::prelogin_request_model::PreloginRequestModel; pub mod prelogin_response_model; pub use self::prelogin_response_model::PreloginResponseModel; +pub mod product_tier_type; +pub use self::product_tier_type::ProductTierType; +pub mod product_type; +pub use self::product_type::ProductType; pub mod public_key_credential_descriptor; pub use self::public_key_credential_descriptor::PublicKeyCredentialDescriptor; pub mod public_key_credential_type; pub use self::public_key_credential_type::PublicKeyCredentialType; +pub mod register_finish_request_model; +pub use self::register_finish_request_model::RegisterFinishRequestModel; pub mod register_request_model; pub use self::register_request_model::RegisterRequestModel; pub mod register_response_model; pub use self::register_response_model::RegisterResponseModel; +pub mod register_send_verification_email_request_model; +pub use self::register_send_verification_email_request_model::RegisterSendVerificationEmailRequestModel; +pub mod register_verification_email_clicked_request_model; +pub use self::register_verification_email_clicked_request_model::RegisterVerificationEmailClickedRequestModel; +pub mod trial_send_verification_email_request_model; +pub use self::trial_send_verification_email_request_model::TrialSendVerificationEmailRequestModel; pub mod user_verification_requirement; pub use self::user_verification_requirement::UserVerificationRequirement; pub mod web_authn_login_assertion_options_response_model; diff --git a/crates/bitwarden-api-identity/src/models/product_tier_type.rs b/crates/bitwarden-api-identity/src/models/product_tier_type.rs new file mode 100644 index 000000000..1673f0f68 --- /dev/null +++ b/crates/bitwarden-api-identity/src/models/product_tier_type.rs @@ -0,0 +1,53 @@ +/* + * Bitwarden Identity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +/// +#[repr(i64)] +#[derive( + Clone, + Copy, + Debug, + Eq, + PartialEq, + Ord, + PartialOrd, + Hash, + serde_repr::Serialize_repr, + serde_repr::Deserialize_repr, +)] +pub enum ProductTierType { + Free = 0, + Families = 1, + Teams = 2, + Enterprise = 3, + TeamsStarter = 4, +} + +impl std::fmt::Display for ProductTierType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::Free => write!(f, "0"), + Self::Families => write!(f, "1"), + Self::Teams => write!(f, "2"), + Self::Enterprise => write!(f, "3"), + Self::TeamsStarter => write!(f, "4"), + } + } +} + +impl Default for ProductTierType { + fn default() -> ProductTierType { + Self::Free + } +} diff --git a/crates/bitwarden-api-identity/src/models/product_type.rs b/crates/bitwarden-api-identity/src/models/product_type.rs new file mode 100644 index 000000000..ade8bd227 --- /dev/null +++ b/crates/bitwarden-api-identity/src/models/product_type.rs @@ -0,0 +1,47 @@ +/* + * Bitwarden Identity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +/// +#[repr(i64)] +#[derive( + Clone, + Copy, + Debug, + Eq, + PartialEq, + Ord, + PartialOrd, + Hash, + serde_repr::Serialize_repr, + serde_repr::Deserialize_repr, +)] +pub enum ProductType { + PasswordManager = 0, + SecretsManager = 1, +} + +impl std::fmt::Display for ProductType { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::PasswordManager => write!(f, "0"), + Self::SecretsManager => write!(f, "1"), + } + } +} + +impl Default for ProductType { + fn default() -> ProductType { + Self::PasswordManager + } +} diff --git a/crates/bitwarden-api-identity/src/models/register_finish_request_model.rs b/crates/bitwarden-api-identity/src/models/register_finish_request_model.rs new file mode 100644 index 000000000..d1afeea48 --- /dev/null +++ b/crates/bitwarden-api-identity/src/models/register_finish_request_model.rs @@ -0,0 +1,70 @@ +/* + * Bitwarden Identity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct RegisterFinishRequestModel { + #[serde(rename = "email")] + pub email: Option, + #[serde( + rename = "emailVerificationToken", + skip_serializing_if = "Option::is_none" + )] + pub email_verification_token: Option, + #[serde(rename = "masterPasswordHash")] + pub master_password_hash: Option, + #[serde(rename = "masterPasswordHint", skip_serializing_if = "Option::is_none")] + pub master_password_hint: Option, + #[serde(rename = "userSymmetricKey")] + pub user_symmetric_key: Option, + #[serde(rename = "userAsymmetricKeys")] + pub user_asymmetric_keys: Box, + #[serde(rename = "kdf")] + pub kdf: models::KdfType, + #[serde(rename = "kdfIterations")] + pub kdf_iterations: i32, + #[serde(rename = "kdfMemory", skip_serializing_if = "Option::is_none")] + pub kdf_memory: Option, + #[serde(rename = "kdfParallelism", skip_serializing_if = "Option::is_none")] + pub kdf_parallelism: Option, + #[serde(rename = "organizationUserId", skip_serializing_if = "Option::is_none")] + pub organization_user_id: Option, + #[serde(rename = "orgInviteToken", skip_serializing_if = "Option::is_none")] + pub org_invite_token: Option, +} + +impl RegisterFinishRequestModel { + pub fn new( + email: Option, + master_password_hash: Option, + user_symmetric_key: Option, + user_asymmetric_keys: models::KeysRequestModel, + kdf: models::KdfType, + kdf_iterations: i32, + ) -> RegisterFinishRequestModel { + RegisterFinishRequestModel { + email, + email_verification_token: None, + master_password_hash, + master_password_hint: None, + user_symmetric_key, + user_asymmetric_keys: Box::new(user_asymmetric_keys), + kdf, + kdf_iterations, + kdf_memory: None, + kdf_parallelism: None, + organization_user_id: None, + org_invite_token: None, + } + } +} diff --git a/crates/bitwarden-api-identity/src/models/register_send_verification_email_request_model.rs b/crates/bitwarden-api-identity/src/models/register_send_verification_email_request_model.rs new file mode 100644 index 000000000..eca497c72 --- /dev/null +++ b/crates/bitwarden-api-identity/src/models/register_send_verification_email_request_model.rs @@ -0,0 +1,36 @@ +/* + * Bitwarden Identity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct RegisterSendVerificationEmailRequestModel { + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, + #[serde(rename = "email")] + pub email: Option, + #[serde( + rename = "receiveMarketingEmails", + skip_serializing_if = "Option::is_none" + )] + pub receive_marketing_emails: Option, +} + +impl RegisterSendVerificationEmailRequestModel { + pub fn new(email: Option) -> RegisterSendVerificationEmailRequestModel { + RegisterSendVerificationEmailRequestModel { + name: None, + email, + receive_marketing_emails: None, + } + } +} diff --git a/crates/bitwarden-api-identity/src/models/register_verification_email_clicked_request_model.rs b/crates/bitwarden-api-identity/src/models/register_verification_email_clicked_request_model.rs new file mode 100644 index 000000000..1c5dff25f --- /dev/null +++ b/crates/bitwarden-api-identity/src/models/register_verification_email_clicked_request_model.rs @@ -0,0 +1,33 @@ +/* + * Bitwarden Identity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct RegisterVerificationEmailClickedRequestModel { + #[serde(rename = "email")] + pub email: Option, + #[serde(rename = "emailVerificationToken")] + pub email_verification_token: Option, +} + +impl RegisterVerificationEmailClickedRequestModel { + pub fn new( + email: Option, + email_verification_token: Option, + ) -> RegisterVerificationEmailClickedRequestModel { + RegisterVerificationEmailClickedRequestModel { + email, + email_verification_token, + } + } +} diff --git a/crates/bitwarden-api-identity/src/models/trial_send_verification_email_request_model.rs b/crates/bitwarden-api-identity/src/models/trial_send_verification_email_request_model.rs new file mode 100644 index 000000000..547bfc06b --- /dev/null +++ b/crates/bitwarden-api-identity/src/models/trial_send_verification_email_request_model.rs @@ -0,0 +1,42 @@ +/* + * Bitwarden Identity + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: v1 + * + * Generated by: https://openapi-generator.tech + */ + +use serde::{Deserialize, Serialize}; + +use crate::models; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct TrialSendVerificationEmailRequestModel { + #[serde(rename = "name", skip_serializing_if = "Option::is_none")] + pub name: Option, + #[serde(rename = "email")] + pub email: Option, + #[serde( + rename = "receiveMarketingEmails", + skip_serializing_if = "Option::is_none" + )] + pub receive_marketing_emails: Option, + #[serde(rename = "productTier", skip_serializing_if = "Option::is_none")] + pub product_tier: Option, + #[serde(rename = "products", skip_serializing_if = "Option::is_none")] + pub products: Option>, +} + +impl TrialSendVerificationEmailRequestModel { + pub fn new(email: Option) -> TrialSendVerificationEmailRequestModel { + TrialSendVerificationEmailRequestModel { + name: None, + email, + receive_marketing_emails: None, + product_tier: None, + products: None, + } + } +} diff --git a/crates/bitwarden-core/src/admin_console/policy.rs b/crates/bitwarden-core/src/admin_console/policy.rs index cde09c24c..2cf6a5530 100644 --- a/crates/bitwarden-core/src/admin_console/policy.rs +++ b/crates/bitwarden-core/src/admin_console/policy.rs @@ -37,6 +37,7 @@ pub enum PolicyType { MaximumVaultTimeout = 9, // Sets the maximum allowed vault timeout DisablePersonalVaultExport = 10, // Disable personal vault export ActivateAutofill = 11, // Activates autofill with page load on the browser extension + AutomaticAppLogIn = 12, } impl TryFrom for Policy { @@ -78,6 +79,9 @@ impl From for PolicyType { PolicyType::DisablePersonalVaultExport } bitwarden_api_api::models::PolicyType::ActivateAutofill => PolicyType::ActivateAutofill, + bitwarden_api_api::models::PolicyType::AutomaticAppLogIn => { + PolicyType::AutomaticAppLogIn + } } } } diff --git a/crates/bitwarden-sm/src/secrets/create.rs b/crates/bitwarden-sm/src/secrets/create.rs index dedd6c57f..efd813877 100644 --- a/crates/bitwarden-sm/src/secrets/create.rs +++ b/crates/bitwarden-sm/src/secrets/create.rs @@ -39,6 +39,7 @@ pub(crate) async fn create_secret( value: input.value.clone().encrypt_with_key(key)?.to_string(), note: input.note.clone().trim().encrypt_with_key(key)?.to_string(), project_ids: input.project_ids.clone(), + access_policies_requests: None, }); let config = client.internal.get_api_configurations().await; diff --git a/crates/bitwarden-sm/src/secrets/update.rs b/crates/bitwarden-sm/src/secrets/update.rs index f2ab7dd12..b80c57234 100644 --- a/crates/bitwarden-sm/src/secrets/update.rs +++ b/crates/bitwarden-sm/src/secrets/update.rs @@ -38,6 +38,7 @@ pub(crate) async fn update_secret( value: input.value.clone().encrypt_with_key(key)?.to_string(), note: input.note.clone().trim().encrypt_with_key(key)?.to_string(), project_ids: input.project_ids.clone(), + access_policies_requests: None, }); let config = client.internal.get_api_configurations().await; From 4b17741ccaa72081d9fefbff1c1112313e0d10fd Mon Sep 17 00:00:00 2001 From: Bitwarden DevOps <106330231+bitwarden-devops-bot@users.noreply.github.com> Date: Thu, 22 Aug 2024 07:02:36 -0400 Subject: [PATCH 111/214] Bump version to 0.1.1 (#989) ## Type of change - [ ] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [X] Other ## Objective Automated python-sdk version bump to 0.1.1 --- languages/python/bitwarden_sdk/__init__.py | 2 +- languages/python/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/languages/python/bitwarden_sdk/__init__.py b/languages/python/bitwarden_sdk/__init__.py index b2aeffea1..067ed3aa5 100644 --- a/languages/python/bitwarden_sdk/__init__.py +++ b/languages/python/bitwarden_sdk/__init__.py @@ -1,6 +1,6 @@ """The official Bitwarden client library for Python.""" -__version__ = "0.1.0" +__version__ = "0.1.1" from .bitwarden_client import * from .schemas import * diff --git a/languages/python/pyproject.toml b/languages/python/pyproject.toml index 28bb22507..0ce9a96b2 100644 --- a/languages/python/pyproject.toml +++ b/languages/python/pyproject.toml @@ -17,7 +17,7 @@ description = "A Bitwarden Client for python" name = "bitwarden_sdk" readme = "README.md" requires-python = ">=3.0" -version = "0.1.0" +version = "0.1.1" [tool.maturin] bindings = "pyo3" From aab991f9a43a698bd3a9df7a6174c8b0f08f1ca9 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Thu, 22 Aug 2024 10:49:21 -0400 Subject: [PATCH 112/214] [SM-1407] Use rustls-tls-native-roots on Windows (#990) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1407 ## 📔 Objective We are having TLS runtime issues for GitHub artifacts built on Windows when using `rustls-platform-verifier`. There is a repository with a simplified example showcasing this bug here: https://github.com/Thomas-Avery/test-rustls-platform-verifier The goal of this PR is to use a work-around on Windows until the bug is fixed. A GitHub issue for this has been created: https://github.com/rustls/rustls-platform-verifier/issues/126 ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- Cargo.lock | 2 ++ crates/bitwarden-core/Cargo.toml | 8 +++++++- crates/bitwarden-core/src/client/client.rs | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8ec312beb..807e5011a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1997,6 +1997,7 @@ dependencies = [ "hyper", "hyper-util", "rustls", + "rustls-native-certs", "rustls-pki-types", "tokio", "tokio-rustls", @@ -3179,6 +3180,7 @@ dependencies = [ "pin-project-lite", "quinn", "rustls", + "rustls-native-certs", "rustls-pemfile", "rustls-pki-types", "serde", diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml index 07a7ba426..d6f6131ee 100644 --- a/crates/bitwarden-core/Cargo.toml +++ b/crates/bitwarden-core/Cargo.toml @@ -64,7 +64,7 @@ validator = { version = "0.18.1", features = ["derive"] } zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } zxcvbn = ">=3.0.1, <4.0" -[target.'cfg(not(target_arch="wasm32"))'.dependencies] +[target.'cfg(all(not(target_arch="wasm32"), not(windows)))'.dependencies] # By default, we use rustls as the TLS stack and rust-platform-verifier to support user-installed root certificates # The only exception is WASM, as it just uses the browsers/node fetch reqwest = { version = ">=0.12.5, <0.13", features = [ @@ -72,6 +72,12 @@ reqwest = { version = ">=0.12.5, <0.13", features = [ ], default-features = false } rustls-platform-verifier = "0.3.3" +[target.'cfg(windows)'.dependencies] +# We are having issues with rustls-platform-verifier on Windows GitHub runners +reqwest = { version = ">=0.12.5, <0.13", features = [ + "rustls-tls-native-roots", +], default-features = false } + [dev-dependencies] bitwarden-crypto = { workspace = true } rand_chacha = "0.3.1" diff --git a/crates/bitwarden-core/src/client/client.rs b/crates/bitwarden-core/src/client/client.rs index e736d8c99..5f73fcd8a 100644 --- a/crates/bitwarden-core/src/client/client.rs +++ b/crates/bitwarden-core/src/client/client.rs @@ -25,7 +25,7 @@ impl Client { #[allow(unused_mut)] let mut client_builder = reqwest::Client::builder(); - #[cfg(not(target_arch = "wasm32"))] + #[cfg(all(not(target_arch = "wasm32"), not(windows)))] { client_builder = client_builder.use_preconfigured_tls(rustls_platform_verifier::tls_config()); @@ -86,6 +86,7 @@ impl Client { #[cfg(test)] mod tests { + #[cfg(all(not(target_arch = "wasm32"), not(windows)))] #[test] fn test_reqwest_rustls_platform_verifier_are_compatible() { // rustls-platform-verifier is generating a rustls::ClientConfig, From 723ef32701a56ceb7dd2c849ceea26384e745c79 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Thu, 22 Aug 2024 11:03:00 -0400 Subject: [PATCH 113/214] [SM-1422] C++ Binding Breaking Fixes (#991) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1422 ## 📔 Objective This PR fixes a pointer bug in the `free()` function. This PR also updates the C++ binding to use the new `loginAccessToken` naming instead of the old style. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-c/src/c.rs | 2 +- languages/cpp/examples/Wrapper.cpp | 2 +- languages/cpp/src/BitwardenClient.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/bitwarden-c/src/c.rs b/crates/bitwarden-c/src/c.rs index bd10f7d88..158c38025 100644 --- a/crates/bitwarden-c/src/c.rs +++ b/crates/bitwarden-c/src/c.rs @@ -53,6 +53,6 @@ pub extern "C" fn init(c_str_ptr: *const c_char) -> *mut CClient { // Free mem #[no_mangle] -pub extern "C" fn free_mem(client_ptr: *mut Client) { +pub extern "C" fn free_mem(client_ptr: *mut CClient) { std::mem::drop(unsafe { Box::from_raw(client_ptr) }); } diff --git a/languages/cpp/examples/Wrapper.cpp b/languages/cpp/examples/Wrapper.cpp index e94980698..bb53bf0c4 100644 --- a/languages/cpp/examples/Wrapper.cpp +++ b/languages/cpp/examples/Wrapper.cpp @@ -26,7 +26,7 @@ int main() { // Create a Bitwarden client instance BitwardenClient bitwardenClient = BitwardenClient(bitwardenSettings); // // Access token login - bitwardenClient.accessTokenLogin(accessToken); + bitwardenClient.loginAccessToken(accessToken); // Organization ID boost::uuids::uuid organizationUuid = boost::uuids::string_generator()(organizationId); diff --git a/languages/cpp/src/BitwardenClient.cpp b/languages/cpp/src/BitwardenClient.cpp index fef9ea267..ce161a2bf 100644 --- a/languages/cpp/src/BitwardenClient.cpp +++ b/languages/cpp/src/BitwardenClient.cpp @@ -50,11 +50,11 @@ BitwardenClient::~BitwardenClient() { } } -void BitwardenClient::accessTokenLogin(const std::string& accessToken) { +void BitwardenClient::loginAccessToken(const std::string& accessToken) { Command command; AccessTokenLoginRequest accessTokenLoginRequest; accessTokenLoginRequest.set_access_token(accessToken); - command.set_access_token_login(accessTokenLoginRequest); + command.set_login_access_token(accessTokenLoginRequest); auto deserializer = [](const char* response) -> ResponseForApiKeyLoginResponse { nlohmann::json jsonResponse = nlohmann::json::parse(response); From 5afe12b3c9ec58c25c38cda27500d6eabb29e3ae Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Fri, 23 Aug 2024 09:54:45 -0400 Subject: [PATCH 114/214] [SM-1371] Expose a new generate_secret function (#986) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1371 ## 📔 Objective Exposes the `password` generator function for generating secrets. This PR also fixes typos in `crates/bitwarden-generators/src/password.rs`. Alternate solution with an abstraction layer between SM and Bitwarden core generation functionality: https://github.com/bitwarden/sdk/pull/936 ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-generators/src/password.rs | 8 ++++---- crates/bitwarden-json/src/client.rs | 13 +++++++++++-- crates/bitwarden-json/src/command.rs | 13 +++++++++++++ crates/bitwarden/Cargo.toml | 2 +- crates/bitwarden/src/lib.rs | 6 ++++++ crates/sdk-schemas/src/main.rs | 1 + 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/crates/bitwarden-generators/src/password.rs b/crates/bitwarden-generators/src/password.rs index 9865ffd4e..6121c7597 100644 --- a/crates/bitwarden-generators/src/password.rs +++ b/crates/bitwarden-generators/src/password.rs @@ -36,16 +36,16 @@ pub struct PasswordGeneratorRequest { pub avoid_ambiguous: bool, // TODO: Should we rename this to include_all_characters? /// The minimum number of lowercase characters in the generated password. - /// When set, the value must be between 1 and 9. This value is ignored is lowercase is false + /// When set, the value must be between 1 and 9. This value is ignored if lowercase is false. pub min_lowercase: Option, /// The minimum number of uppercase characters in the generated password. - /// When set, the value must be between 1 and 9. This value is ignored is uppercase is false + /// When set, the value must be between 1 and 9. This value is ignored if uppercase is false. pub min_uppercase: Option, /// The minimum number of numbers in the generated password. - /// When set, the value must be between 1 and 9. This value is ignored is numbers is false + /// When set, the value must be between 1 and 9. This value is ignored if numbers is false. pub min_number: Option, /// The minimum number of special characters in the generated password. - /// When set, the value must be between 1 and 9. This value is ignored is special is false + /// When set, the value must be between 1 and 9. This value is ignored if special is false. pub min_special: Option, } diff --git a/crates/bitwarden-json/src/client.rs b/crates/bitwarden-json/src/client.rs index 81956bf57..50e46f6ce 100644 --- a/crates/bitwarden-json/src/client.rs +++ b/crates/bitwarden-json/src/client.rs @@ -1,11 +1,13 @@ #[cfg(feature = "secrets")] -use bitwarden::secrets_manager::{ClientProjectsExt, ClientSecretsExt}; +use bitwarden::secrets_manager::{ + generators::ClientGeneratorExt, ClientProjectsExt, ClientSecretsExt, +}; #[cfg(feature = "internal")] use bitwarden::vault::ClientVaultExt; use bitwarden::ClientSettings; #[cfg(feature = "secrets")] -use crate::command::{ProjectsCommand, SecretsCommand}; +use crate::command::{GeneratorsCommand, ProjectsCommand, SecretsCommand}; use crate::{ command::Command, response::{Response, ResponseIntoString}, @@ -89,6 +91,13 @@ impl Client { ProjectsCommand::Update(req) => client.projects().update(&req).await.into_string(), ProjectsCommand::Delete(req) => client.projects().delete(req).await.into_string(), }, + + #[cfg(feature = "secrets")] + Command::Generators(cmd) => match cmd { + GeneratorsCommand::GeneratePassword(req) => { + client.generator().password(req).into_string() + } + }, } } diff --git a/crates/bitwarden-json/src/command.rs b/crates/bitwarden-json/src/command.rs index 8c0f2a2ca..29dc79538 100644 --- a/crates/bitwarden-json/src/command.rs +++ b/crates/bitwarden-json/src/command.rs @@ -2,6 +2,7 @@ use bitwarden::{ auth::login::AccessTokenLoginRequest, secrets_manager::{ + generators::PasswordGeneratorRequest, projects::{ ProjectCreateRequest, ProjectGetRequest, ProjectPutRequest, ProjectsDeleteRequest, ProjectsListRequest, @@ -76,6 +77,8 @@ pub enum Command { Secrets(SecretsCommand), #[cfg(feature = "secrets")] Projects(ProjectsCommand), + #[cfg(feature = "secrets")] + Generators(GeneratorsCommand), } #[cfg(feature = "secrets")] @@ -175,3 +178,13 @@ pub enum ProjectsCommand { /// Returns: [ProjectsDeleteResponse](bitwarden::secrets_manager::projects::ProjectsDeleteResponse) Delete(ProjectsDeleteRequest), } + +#[cfg(feature = "secrets")] +#[derive(Serialize, Deserialize, JsonSchema, Debug)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub enum GeneratorsCommand { + /// Generate a password + /// + /// Returns: [String] + GeneratePassword(PasswordGeneratorRequest), +} diff --git a/crates/bitwarden/Cargo.toml b/crates/bitwarden/Cargo.toml index 3bd1f02fa..f927564cf 100644 --- a/crates/bitwarden/Cargo.toml +++ b/crates/bitwarden/Cargo.toml @@ -35,7 +35,7 @@ uniffi = [ "bitwarden-send/uniffi", "bitwarden-vault/uniffi", ] # Uniffi bindings -secrets = ["bitwarden-core/secrets", "dep:bitwarden-sm"] # Secrets manager API +secrets = ["bitwarden-core/secrets", "dep:bitwarden-sm", "dep:bitwarden-generators"] # Secrets manager API [dependencies] bitwarden-api-api = { workspace = true } diff --git a/crates/bitwarden/src/lib.rs b/crates/bitwarden/src/lib.rs index 40168761c..b8d8a0bda 100644 --- a/crates/bitwarden/src/lib.rs +++ b/crates/bitwarden/src/lib.rs @@ -90,4 +90,10 @@ pub use internal::*; #[cfg(feature = "secrets")] pub mod secrets_manager { pub use bitwarden_sm::*; + + pub mod generators { + pub use bitwarden_generators::{ + password, ClientGeneratorExt, PasswordError, PasswordGeneratorRequest, + }; + } } diff --git a/crates/sdk-schemas/src/main.rs b/crates/sdk-schemas/src/main.rs index 36478fbd7..94959fa69 100644 --- a/crates/sdk-schemas/src/main.rs +++ b/crates/sdk-schemas/src/main.rs @@ -108,6 +108,7 @@ struct SchemaTypes { project: Response, projects: Response, projects_delete: Response, + password: Response, #[cfg(feature = "internal")] fingerprint: Response, From f68255448d9eebb80251563bc4a005f7be278102 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Fri, 23 Aug 2024 10:13:06 -0400 Subject: [PATCH 115/214] [SM-1371] Add GenerateSecret to the Go SDK (#992) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1371 ## 📔 Objective Add a `GenerateSecret` function to the Go SDK. **Note** this depends on the https://github.com/bitwarden/sdk/pull/986 PR, which should be merged first. This PR is parallel to this: https://github.com/bitwarden/sdk/pull/937. One will be merged and the other closed based on the decided approach. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- languages/go/bitwarden_client.go | 7 +++++++ languages/go/example/example.go | 21 +++++++++++++++++++ languages/go/generators.go | 35 ++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 languages/go/generators.go diff --git a/languages/go/bitwarden_client.go b/languages/go/bitwarden_client.go index 5e951ecd1..121eda0a5 100644 --- a/languages/go/bitwarden_client.go +++ b/languages/go/bitwarden_client.go @@ -10,6 +10,7 @@ type BitwardenClientInterface interface { AccessTokenLogin(accessToken string, stateFile *string) error Projects() ProjectsInterface Secrets() SecretsInterface + Generators() GeneratorsInterface Close() } @@ -19,6 +20,7 @@ type BitwardenClient struct { commandRunner CommandRunnerInterface projects ProjectsInterface secrets SecretsInterface + generators GeneratorsInterface } func NewBitwardenClient(apiURL *string, identityURL *string) (BitwardenClientInterface, error) { @@ -49,6 +51,7 @@ func NewBitwardenClient(apiURL *string, identityURL *string) (BitwardenClientInt commandRunner: runner, projects: NewProjects(runner), secrets: NewSecrets(runner), + generators: NewGenerators(runner), }, nil } @@ -73,6 +76,10 @@ func (c *BitwardenClient) Secrets() SecretsInterface { return c.secrets } +func (c *BitwardenClient) Generators() GeneratorsInterface { + return c.generators +} + func (c *BitwardenClient) Close() { c.lib.FreeMem(c.client) } diff --git a/languages/go/example/example.go b/languages/go/example/example.go index b97645db6..06cfcd48c 100644 --- a/languages/go/example/example.go +++ b/languages/go/example/example.go @@ -112,5 +112,26 @@ func main() { fmt.Println(string(jsonSecrets)) + // Generate a password which can be used as a secret value + request := sdk.PasswordGeneratorRequest{ + AvoidAmbiguous: true, + Length: 64, + Lowercase: true, + MinLowercase: new(int64), + MinNumber: new(int64), + MinSpecial: new(int64), + MinUppercase: new(int64), + Numbers: true, + Special: true, + Uppercase: true, + } + password, err := bitwardenClient.Generators().GeneratePassword(request) + + if err != nil { + panic(err) + } + + fmt.Println(*password) + defer bitwardenClient.Close() } diff --git a/languages/go/generators.go b/languages/go/generators.go new file mode 100644 index 000000000..8d72c9aa5 --- /dev/null +++ b/languages/go/generators.go @@ -0,0 +1,35 @@ +package sdk + +type GeneratorsInterface interface { + GeneratePassword(request PasswordGeneratorRequest) (*string, error) +} + +type Generators struct { + CommandRunner CommandRunnerInterface +} + +func NewGenerators(commandRunner CommandRunnerInterface) *Generators { + return &Generators{CommandRunner: commandRunner} +} + +func (s *Generators) executeCommand(command Command, target interface{}) error { + responseStr, err := s.CommandRunner.RunCommand(command) + if err != nil { + return err + } + return checkSuccessAndError(responseStr, target) +} + +func (s *Generators) GeneratePassword(request PasswordGeneratorRequest) (*string, error) { + command := Command{ + Generators: &GeneratorsCommand{ + GeneratePassword: request, + }, + } + + var response string + if err := s.executeCommand(command, &response); err != nil { + return nil, err + } + return &response, nil +} From 17eda3f387051b24d53ad8e7afc155384573be5c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2024 12:33:11 +0200 Subject: [PATCH 116/214] [deps]: Lock file maintenance (#995) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. đŸ‘ģ **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://togithub.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 190 +++++++++++++--------- languages/js/sdk-client/package-lock.json | 6 +- package-lock.json | 18 +- 3 files changed, 126 insertions(+), 88 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 807e5011a..2738e3ef8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + [[package]] name = "aes" version = "0.8.4" @@ -182,7 +188,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -231,7 +237,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -256,7 +262,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.7.4", "object", "rustc-demangle", ] @@ -848,9 +854,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.13" +version = "1.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72db2f7947ecee9b03b510377e8bb9077afa27176fdbff55c51027e976fdcc48" +checksum = "50d2eb3cd3d1bf4529e31c215ee6f93ec5a3d536d9f578f93d9d33ee19562932" dependencies = [ "shlex", ] @@ -944,9 +950,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.19" +version = "4.5.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eddf1c00919f37952199f7dbc834789cd33356ed10278ee40c8572b8fb88cf2" +checksum = "531d7959c5bbb6e266cecdd0f20213639c3a5c3e4d615f97db87661745f781ff" dependencies = [ "clap", ] @@ -960,7 +966,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -1303,7 +1309,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -1327,7 +1333,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -1338,7 +1344,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -1417,7 +1423,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -1427,7 +1433,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" dependencies = [ "derive_builder_core", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -1589,9 +1595,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.1.0" +version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" +checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "ff" @@ -1605,12 +1611,12 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.31" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f211bbe8e69bbd0cfdea405084f128ae8b4aaa6b0b522fc8f2b009084797920" +checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.8.0", ] [[package]] @@ -1693,7 +1699,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -1817,9 +1823,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" dependencies = [ "atomic-waker", "bytes", @@ -2217,9 +2223,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.157" +version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374af5f94e54fa97cf75e945cce8a6b201e88a1a07e688b47dfd2a59c66dbd86" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libloading" @@ -2228,7 +2234,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -2337,6 +2343,15 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1" +dependencies = [ + "adler2", +] + [[package]] name = "mio" version = "0.8.11" @@ -2392,7 +2407,7 @@ dependencies = [ "napi-derive-backend", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -2407,7 +2422,7 @@ dependencies = [ "quote", "regex", "semver", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -2757,7 +2772,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -2972,7 +2987,7 @@ dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -2985,7 +3000,7 @@ dependencies = [ "proc-macro2", "pyo3-build-config", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -3047,9 +3062,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.36" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] @@ -3115,9 +3130,9 @@ dependencies = [ [[package]] name = "redox_users" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" dependencies = [ "getrandom", "libredox", @@ -3155,9 +3170,9 @@ checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" [[package]] name = "reqwest" -version = "0.12.5" +version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37" +checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" dependencies = [ "base64 0.22.1", "bytes", @@ -3194,7 +3209,7 @@ dependencies = [ "wasm-bindgen", "wasm-bindgen-futures", "web-sys", - "winreg", + "windows-registry", ] [[package]] @@ -3298,9 +3313,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.1" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a88d6d420651b496bdd98684116959239430022a115c1240e6c3993be0b15fba" +checksum = "04182dffc9091a404e0fc069ea5cd60e5b866c3adf881eff99a32d048242dffa" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -3327,9 +3342,9 @@ checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" [[package]] name = "rustls-platform-verifier" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93bda3f493b9abe5b93b3e7e3ecde0df292f2bd28c0296b90586ee0055ff5123" +checksum = "afbb878bdfdf63a336a5e63561b1835e7a8c91524f51621db870169eac84b490" dependencies = [ "core-foundation", "core-foundation-sys", @@ -3417,7 +3432,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -3449,7 +3464,7 @@ checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -3515,22 +3530,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.208" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff085d2cb684faa248efb494c39b68e522822ac0de72ccf08109abde717cfb2" +checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.208" +version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24008e81ff7613ed8e5ba0cfaf24e2c2f1e5b8a0495711e44fcd4882fca62bcf" +checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -3541,14 +3556,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] name = "serde_json" -version = "1.0.125" +version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83c8e735a073ccf5be70aa8066aa984eaf2fa000db6c8d0100ae605b366d31ed" +checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ "indexmap 2.4.0", "itoa", @@ -3576,7 +3591,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -3627,7 +3642,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -3826,7 +3841,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -3839,7 +3854,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -3869,9 +3884,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.75" +version = "2.0.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6af063034fc1935ede7be0122941bafa9bacb949334d090b77ca98b5817c7d9" +checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" dependencies = [ "proc-macro2", "quote", @@ -3883,6 +3898,9 @@ name = "sync_wrapper" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] [[package]] name = "syntect" @@ -3949,7 +3967,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -4042,7 +4060,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -4298,7 +4316,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a22dbe67c1c957ac6e7611bdf605a6218aa86b0eebeb8be58b70ae85ad7d73dc" dependencies = [ "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -4330,7 +4348,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.75", + "syn 2.0.76", "toml 0.5.11", "uniffi_meta", ] @@ -4445,7 +4463,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -4509,7 +4527,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", "wasm-bindgen-shared", ] @@ -4543,7 +4561,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4577,7 +4595,7 @@ checksum = "4b8220be1fa9e4c889b30fd207d4906657e7e90b12e0e6b0c8b8d8709f5de021" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -4660,6 +4678,36 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -4817,16 +4865,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "winreg" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" -dependencies = [ - "cfg-if", - "windows-sys 0.48.0", -] - [[package]] name = "winsafe" version = "0.0.19" @@ -4875,7 +4913,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] @@ -4896,7 +4934,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.75", + "syn 2.0.76", ] [[package]] diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index 035fc1cbc..225522f86 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -464,9 +464,9 @@ } }, "node_modules/undici-types": { - "version": "6.19.6", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.6.tgz", - "integrity": "sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==", + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", "dev": true, "license": "MIT" }, diff --git a/package-lock.json b/package-lock.json index eb615f178..4b5b6285b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,9 +19,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.25.0", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.0.tgz", - "integrity": "sha512-7dRy4DwXwtzBrPbZflqxnvfxLF8kdZXPkhymtDeFoFqE6ldzjQFgYTtYIFARcLEYDrqfBfYcZt1WqFxRoyC9Rw==", + "version": "7.25.4", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.4.tgz", + "integrity": "sha512-DSgLeL/FNcpXuzav5wfYvHCGvynXkJbn3Zvc3823AEe9nPwW9IK4UoCSS5yGymmQzN0pCPvivtgS6/8U2kkm1w==", "dev": true, "license": "MIT", "dependencies": { @@ -370,9 +370,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.4.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.4.0.tgz", - "integrity": "sha512-49AbMDwYUz7EXxKU/r7mXOsxwFr4BYbvB7tWYxVuLdb2ibd30ijjXINSMAHiEEZk5PCRBmW1gUeisn2VMKt3cQ==", + "version": "22.5.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.0.tgz", + "integrity": "sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==", "dev": true, "license": "MIT", "peer": true, @@ -2200,9 +2200,9 @@ } }, "node_modules/undici-types": { - "version": "6.19.6", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.6.tgz", - "integrity": "sha512-e/vggGopEfTKSvj4ihnOLTsqhrKRN3LeO6qSN/GxohhuRv8qH9bNQ4B8W7e/vFL+0XTnmHPB4/kegunZGA4Org==", + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", "dev": true, "license": "MIT", "peer": true From 5ff95a8a6bc858dcd698bdda4274c863911677e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ch=C4=99ci=C5=84ski?= Date: Mon, 26 Aug 2024 15:34:57 +0200 Subject: [PATCH 117/214] [BRE-113] Publish SWIFT sdk releases to bitwarden/sdk-swift (#956) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/BRE-113 ## 📔 Objective Automate publishing SWIFT SDK to [bitwarden/sdk-swift](https://github.com/bitwarden/sdk-swift) repo. Thanks @mimartin12 for the initial work on that! ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --------- Co-authored-by: Micaiah Martin Co-authored-by: MtnBurrit0 <77340197+mimartin12@users.noreply.github.com> Co-authored-by: Vince Grassia <593223+vgrassia@users.noreply.github.com> --- .github/workflows/build-swift.yml | 102 +++++++++++++ .github/workflows/release-swift.yml | 223 ++++++++++++++++++++++++++++ 2 files changed, 325 insertions(+) create mode 100644 .github/workflows/build-swift.yml create mode 100644 .github/workflows/release-swift.yml diff --git a/.github/workflows/build-swift.yml b/.github/workflows/build-swift.yml new file mode 100644 index 000000000..92be9a456 --- /dev/null +++ b/.github/workflows/build-swift.yml @@ -0,0 +1,102 @@ +--- +name: Build Swift Package + +on: + push: + branches: + - "rc" + - "hotfix-rc" + - "main" + +jobs: + version: + name: Get Version + runs-on: ubuntu-22.04 + outputs: + package_version: ${{ steps.retrieve-version.outputs.package_version }} + steps: + - name: Checkout repo + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + + - name: Get Package Version + id: retrieve-version + run: | + VERSION=$(grep -o '^version = ".*"' Cargo.toml | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+") + echo "package_version=$VERSION" >> $GITHUB_OUTPUT + + build: + name: Build + runs-on: macos-13 + needs: version + env: + _VERSION: ${{ needs.version.outputs.package_version }} + steps: + - name: Checkout repo + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + + - name: Install rust + uses: dtolnay/rust-toolchain@bb45937a053e097f8591208d8e74c90db1873d07 # stable + with: + toolchain: stable + + - name: Cache cargo registry + uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 + with: + key: sdk-swift-cargo + + - name: Rustup target + run: | + rustup target install aarch64-apple-ios-sim + rustup target install aarch64-apple-ios + rustup target install x86_64-apple-ios + + - name: Build + shell: bash + working-directory: languages/swift + id: build + run: | + ./build.sh + + # SHA Short + echo "short-sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + + - name: Upload BitwardenFFI.xcframework artifact + uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + with: + name: BitwardenFFI-${{ env._VERSION }}-${{ steps.build.outputs.short-sha }}.xcframework + path: languages/swift/BitwardenFFI.xcframework + if-no-files-found: error + + trigger-swift-release: + name: Trigger Swift release + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-22.04 + needs: build + steps: + - name: Login to Azure - CI Subscription + uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 + with: + creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve github PAT secrets + id: retrieve-secret-pat + uses: bitwarden/gh-actions/get-keyvault-secrets@main + with: + keyvault: "bitwarden-ci" + secrets: "github-pat-bitwarden-devops-bot-repo-scope" + + - name: Trigger Swift release + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + github-token: ${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }} + script: | + await github.rest.actions.createWorkflowDispatch({ + owner: 'bitwarden', + repo: 'sdk', + workflow_id: 'release-swift.yml', + ref: 'main', + inputs: { + 'build-run-id': '${{ github.run_id }}', + 'pre-release': 'true' + } + }) diff --git a/.github/workflows/release-swift.yml b/.github/workflows/release-swift.yml new file mode 100644 index 000000000..954480365 --- /dev/null +++ b/.github/workflows/release-swift.yml @@ -0,0 +1,223 @@ +--- +name: Release Swift Package + +on: + workflow_call: + inputs: + build-run-id: + description: "Workflow Run ID to use for artifact download. If not provided the latest build from the selected branch will be used." + type: string + required: false + pre-release: + description: "Create a pre-release" + type: boolean + required: false + default: false + + workflow_dispatch: + inputs: + pre-release: + description: "Create a pre-release" + type: boolean + required: false + default: false + +env: + _KEY_VAULT: "bitwarden-ci" + +jobs: + validate: + name: Set Version and SHA + runs-on: ubuntu-22.04 + outputs: + version: ${{ steps.version.outputs.version }} + sha: ${{ steps.set-sha.outputs.sha }} + short_sha: ${{ steps.set-sha.outputs.short_sha }} + release_name: ${{ steps.set-release-name.outputs.release_name }} + run_id: ${{ steps.get-run-id.outputs.build-run-id }} + swift_checksum: ${{ steps.calculate-swift-checksum.outputs.checksum }} + steps: + - name: Checkout repo + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + + - name: Get version + id: version + run: | + VERSION=$(grep -o '^version = ".*"' crates/bitwarden/Cargo.toml | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+") + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Get run id + id: get-run-id + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + OWNER: ${{ github.repository_owner }} + REPO: ${{ github.event.repository.name }} + run: | + if [[ -z ${{ inputs.build-run-id }} ]]; then + BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} + RUN_ID=$(gh api \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/$OWNER/$REPO/actions/workflows/build-swift.yml/runs \ + | jq -r ".workflow_runs[] | select(.head_branch == \"$BRANCH\") | .id") + else + RUN_ID=${{ inputs.build-run-id }} + fi + + echo "build-run-id=$RUN_ID" >> $GITHUB_OUTPUT + + - name: Download BitwardenEFI artifact + uses: bitwarden/gh-actions/download-artifacts@main + id: download-artifact + with: + workflow: build-swift.yml + workflow_conclusion: success + skip_unpack: true + run_id: ${{ steps.get-run-id.outputs.build-run-id }} + + - name: Set SHA + id: set-sha + run: | + echo "sha=$(${{ steps.download-artifact.outputs.artifact-build-commit }})" >> $GITHUB_OUTPUT + echo "short_sha=$(echo ${{ steps.download-artifact.outputs.artifact-build-commit }} | cut -c1-7)" >> $GITHUB_OUTPUT + + - name: Set release name + id: set-release-name + run: | + if [[ ${{ inputs.pre-release }} == true ]]; then + echo "release_name=${{ steps.version.outputs.version }}-unstable-${{ steps.set-sha.outputs.short_sha }}" >> $GITHUB_OUTPUT + else + echo "release_name=${{ steps.version.outputs.version }}" >> $GITHUB_OUTPUT + fi + + - name: Calculate swift file checksum + id: calculate-swift-checksum + run: | + CHECKSUM=$(swift package compute-checksum BitwardenFFI-${{ steps.version.outputs.version }}-${{ steps.set-sha.outputs.short_sha }}.xcframework.zip) + echo "checksum=$CHECKSUM" >> $GITHUB_OUTPUT + + repo-sync: + name: Push changed files to SDK Swift repo + runs-on: ubuntu-22.04 + needs: validate + env: + _BOT_EMAIL: 106330231+bitwarden-devops-bot@users.noreply.github.com + _BOT_NAME: bitwarden-devops-bot + _PKG_VERSION: ${{ needs.validate.outputs.version }} + _PRE_RELEASE: ${{ inputs.pre-release }} + _RELEASE_NAME: ${{ needs.validate.outputs.release_name }} + _SWIFT_CHECKSUM: ${{ needs.validate.outputs.swift_checksum }} + steps: + - name: Checkout SDK repo + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + with: + path: sdk + + - name: Get ref from SDK repo + id: get-ref + run: | + if [[ $_PRE_RELEASE == true ]]; then + echo "ref=unstable" >> $GITHUB_OUTPUT + else + echo "ref=main" >> $GITHUB_OUTPUT + fi + + - name: Checkout SDK-Swift repo + uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + with: + repository: bitwarden/sdk-swift + path: sdk-swift + ref: ${{ steps.get-ref.outputs.ref }} + + - name: Login to Azure - Prod Subscription + uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 + with: + creds: ${{ secrets.AZURE_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve secrets + id: retrieve-secrets + uses: bitwarden/gh-actions/get-keyvault-secrets@main + with: + keyvault: ${{ env._KEY_VAULT }} + secrets: "github-pat-bitwarden-devops-bot-repo-scope" + + - name: Setup Git + working-directory: sdk-swift + run: | + git config --local user.email "${{ env._BOT_EMAIL }}" + git config --local user.name "${{ env._BOT_NAME }}" + + - name: Update files + run: | + # Update BitwardenFFI path + sed -i '' 's|.binaryTarget(name: "BitwardenFFI", path: "BitwardenFFI.xcframework")|.binaryTarget(\ + name: "BitwardenFFI",\ + url: "https://github.com/bitwarden/sdk-swift/releases/download/v${{ env._RELEASE_NAME }}/BitwardenFFI-${{ env._PKG_VERSION }}-${{ needs.validate.outputs.short_sha }}.xcframework.zip",\ + checksum: "${{ env._SWIFT_CHECKSUM }}"|' sdk/languages/swift/Package.swift + + # Run swiftformat + swiftformat sdk/languages/swift/Package.swift + + # Copy files to local sdk-swift repo path + cp --verbose -rf sdk/languages/swift/README.md sdk-swift/README.md + cp --verbose -rf sdk/languages/swift/Package.swift sdk-swift/Package.swift + cp --verbose -rf sdk/languages/swift/Sources sdk-swift/Sources + cp --verbose -rf sdk/languages/swift/Tests sdk-swift/Tests + + - name: Push changes + working-directory: sdk-swift + run: | + git add . + git commit -m "Update Swift SDK to ${{ needs.validate.outputs.sha }}" + git push origin ${{ steps.get-ref.outputs.ref }} + + - name: Create release tag on SDK Swift repo + working-directory: sdk-swift + run: | + git tag v${{ env._RELEASE_NAME }} + git push origin v${{ env._RELEASE_NAME }} + + github-release: + name: GitHub Release + runs-on: ubuntu-22.04 + needs: + - validate + - repo-sync + env: + _PKG_VERSION: ${{ needs.validate.outputs.version }} + _RELEASE_NAME: ${{ needs.validate.outputs.release_name }} + _BUILD_RUN_ID: ${{ needs.validate.outputs.run_id }} + steps: + - name: Login to Azure - Prod Subscription + uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 + with: + creds: ${{ secrets.AZURE_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve secrets + id: retrieve-secrets + uses: bitwarden/gh-actions/get-keyvault-secrets@main + with: + keyvault: ${{ env._KEY_VAULT }} + secrets: "github-pat-bitwarden-devops-bot-repo-scope" + + - name: Download BitwardenEFI artifact + uses: bitwarden/gh-actions/download-artifacts@main + id: download-artifact + with: + workflow: build-swift.yml + workflow_conclusion: success + artifacts: "BitwardenFFI-${{ env._PKG_VERSION }}-${{ needs.validate.outputs.short_sha }}.xcframework" + run_id: ${{ env._BUILD_RUN_ID }} + + - name: Create release + uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5 # v1.13.0 + with: + tag: v${{ env._RELEASE_NAME }} + name: v${{ env._RELEASE_NAME }} + body: "" + token: ${{ steps.retrieve-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }} + draft: false + repo: sdk-swift + owner: bitwarden + artifacts: "BitwardenFFI-${{ env._PKG_VERSION }}-${{ needs.validate.outputs.short_sha }}.xcframework" + prerelease: ${{ inputs.pre-release }} From e182976b24847b9614c310771279cd03116f0c4c Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Mon, 26 Aug 2024 12:15:54 -0700 Subject: [PATCH 118/214] breaking: Review and update Python sdk (#964) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1405 ## 📔 Objective Update the Python wrapper to use bindings that are consistent. This will be a breaking change, as it does the following: - replaces `access_token_login()` with `auth().login_access_token()` to be more consistent with the newer auth method we use in the base SDK. - reorders the `create()` and `update()` args for secrets and projects, with arguments that are most consistently required between methods (eg. `organization_id`) first. - `secrets.create(key, note, organization_id, value, project_ids)` -> `secrets.create(organization_id, key, value, note, project_ids)` - `secrets.update(id, key, note, organization_id, value, project_ids)` -> `secrets.create(organization_id, id, key, value, note, project_ids)` - `projects.create(name, organization_id)` -> `projects.create(organization_id, name)` - `projects.update(id, name, organization_id)` -> `projects.update(organization_id, id, name)` This change also exposes `secrets.get_by_ids()` and `secrets.sync()`. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .../python/bitwarden_sdk/bitwarden_client.py | 95 ++++++++++++++----- languages/python/example.py | 34 ++++--- 2 files changed, 92 insertions(+), 37 deletions(-) diff --git a/languages/python/bitwarden_sdk/bitwarden_client.py b/languages/python/bitwarden_sdk/bitwarden_client.py index e8f12d963..ac51e8dd9 100644 --- a/languages/python/bitwarden_sdk/bitwarden_client.py +++ b/languages/python/bitwarden_sdk/bitwarden_client.py @@ -2,7 +2,16 @@ from typing import Any, List, Optional from uuid import UUID import bitwarden_py -from .schemas import ClientSettings, Command, ResponseForSecretIdentifiersResponse, ResponseForSecretResponse, ResponseForSecretsDeleteResponse, SecretCreateRequest, SecretGetRequest, SecretIdentifiersRequest, SecretIdentifiersResponse, SecretPutRequest, SecretResponse, SecretsCommand, SecretsDeleteRequest, SecretsDeleteResponse, AccessTokenLoginRequest, AccessTokenLoginResponse, ResponseForAccessTokenLoginResponse, ResponseForProjectResponse, ProjectsCommand, ProjectCreateRequest, ProjectGetRequest, ProjectPutRequest, ProjectsListRequest, ResponseForProjectsResponse, ResponseForProjectsDeleteResponse, ProjectsDeleteRequest + +from .schemas import (ClientSettings, Command, ResponseForSecretIdentifiersResponse, ResponseForSecretResponse, + ResponseForSecretsResponse, ResponseForSecretsDeleteResponse, SecretCreateRequest, + SecretGetRequest, SecretsGetRequest, SecretIdentifiersRequest, SecretPutRequest, + SecretsCommand, SecretsDeleteRequest, SecretsSyncRequest, AccessTokenLoginRequest, + ResponseForSecretsSyncResponse, ResponseForAccessTokenLoginResponse, + ResponseForProjectResponse, ProjectsCommand, ProjectCreateRequest, ProjectGetRequest, + ProjectPutRequest, ProjectsListRequest, ResponseForProjectsResponse, + ResponseForProjectsDeleteResponse, ProjectsDeleteRequest) + class BitwardenClient: def __init__(self, settings: ClientSettings = None): @@ -12,11 +21,8 @@ def __init__(self, settings: ClientSettings = None): settings_json = json.dumps(settings.to_dict()) self.inner = bitwarden_py.BitwardenClient(settings_json) - def access_token_login(self, access_token: str, - state_file: str = None): - self._run_command( - Command(access_token_login=AccessTokenLoginRequest(access_token, state_file)) - ) + def auth(self): + return AuthClient(self) def secrets(self): return SecretsClient(self) @@ -30,9 +36,22 @@ def _run_command(self, command: Command) -> Any: if response["success"] == False: raise Exception(response["errorMessage"]) - + return response + +class AuthClient: + def __init__(self, client: BitwardenClient): + self.client = client + + def login_access_token(self, access_token: str, + state_file: str = None) -> ResponseForAccessTokenLoginResponse: + result = self.client._run_command( + Command(login_access_token=AccessTokenLoginRequest(access_token, state_file)) + ) + return ResponseForAccessTokenLoginResponse.from_dict(result) + + class SecretsClient: def __init__(self, client: BitwardenClient): self.client = client @@ -43,12 +62,24 @@ def get(self, id: str) -> ResponseForSecretResponse: ) return ResponseForSecretResponse.from_dict(result) - def create(self, key: str, - note: str, - organization_id: str, - value: str, - project_ids: Optional[List[UUID]] = None - ) -> ResponseForSecretResponse: + def get_by_ids(self, ids: List[UUID]) -> ResponseForSecretsResponse: + result = self.client._run_command( + Command(secrets=SecretsCommand( + get_by_ids=SecretsGetRequest(ids)) + )) + return ResponseForSecretsResponse.from_dict(result) + + def create( + self, + organization_id: UUID, + key: str, + value: str, + note: Optional[str], + project_ids: Optional[List[UUID]] = None, + ) -> ResponseForSecretResponse: + if note is None: + # secrets api does not accept empty notes + note = "" result = self.client._run_command( Command(secrets=SecretsCommand( create=SecretCreateRequest(key, note, organization_id, value, project_ids))) @@ -62,13 +93,18 @@ def list(self, organization_id: str) -> ResponseForSecretIdentifiersResponse: ) return ResponseForSecretIdentifiersResponse.from_dict(result) - def update(self, id: str, - key: str, - note: str, - organization_id: str, - value: str, - project_ids: Optional[List[UUID]] = None - ) -> ResponseForSecretResponse: + def update( + self, + organization_id: str, + id: str, + key: str, + value: str, + note: Optional[str], + project_ids: Optional[List[UUID]] = None, + ) -> ResponseForSecretResponse: + if note is None: + # secrets api does not accept empty notes + note = "" result = self.client._run_command( Command(secrets=SecretsCommand(update=SecretPutRequest( id, key, note, organization_id, value, project_ids))) @@ -81,6 +117,13 @@ def delete(self, ids: List[str]) -> ResponseForSecretsDeleteResponse: ) return ResponseForSecretsDeleteResponse.from_dict(result) + def sync(self, organization_id: str, last_synced_date: Optional[str]) -> ResponseForSecretsSyncResponse: + result = self.client._run_command( + Command(secrets=SecretsCommand(sync=SecretsSyncRequest(organization_id, last_synced_date))) + ) + return ResponseForSecretsSyncResponse.from_dict(result) + + class ProjectsClient: def __init__(self, client: BitwardenClient): self.client = client @@ -92,8 +135,8 @@ def get(self, id: str) -> ResponseForProjectResponse: return ResponseForProjectResponse.from_dict(result) def create(self, - name: str, organization_id: str, + name: str, ) -> ResponseForProjectResponse: result = self.client._run_command( Command(projects=ProjectsCommand( @@ -108,10 +151,12 @@ def list(self, organization_id: str) -> ResponseForProjectsResponse: ) return ResponseForProjectsResponse.from_dict(result) - def update(self, id: str, - name: str, - organization_id: str, - ) -> ResponseForProjectResponse: + def update( + self, + organization_id: str, + id: str, + name: str, + ) -> ResponseForProjectResponse: result = self.client._run_command( Command(projects=ProjectsCommand(update=ProjectPutRequest( id, name, organization_id))) diff --git a/languages/python/example.py b/languages/python/example.py index 16367a0c5..e128e0dd9 100755 --- a/languages/python/example.py +++ b/languages/python/example.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import logging import os +from datetime import datetime, timezone from bitwarden_sdk import BitwardenClient, DeviceType, client_settings_from_dict @@ -21,14 +22,14 @@ organization_id = os.getenv("ORGANIZATION_ID") # Attempt to authenticate with the Secrets Manager Access Token -client.access_token_login(os.getenv("ACCESS_TOKEN")) +client.auth().login_access_token(os.getenv("ACCESS_TOKEN")) # -- Example Project Commands -- -project = client.projects().create("ProjectName", organization_id) -project2 = client.projects().create("Project - Don't Delete Me!", organization_id) +project = client.projects().create(organization_id, "ProjectName") +project2 = client.projects().create(organization_id, "AnotherProject") updated_project = client.projects().update( - project.data.id, "Cool New Project Name", organization_id + organization_id, project.data.id, "Cool New Project Name" ) get_that_project = client.projects().get(project.data.id) @@ -39,31 +40,40 @@ # -- Example Secret Commands -- +if client.secrets().sync(organization_id, None).data.has_changes is True: + print("There are changes to sync") +else: + print("No changes to sync") + +last_synced_date = datetime.now(tz=timezone.utc) +print(client.secrets().sync(organization_id, last_synced_date)) + secret = client.secrets().create( + organization_id, "TEST_SECRET", "This is a test secret", - organization_id, "Secret1234!", [project2.data.id], ) secret2 = client.secrets().create( - "Secret - Don't Delete Me!", - "This is a test secret that will stay", organization_id, + "ANOTHER_SECRET", "Secret1234!", + None, [project2.data.id], ) secret_updated = client.secrets().update( + organization_id, secret.data.id, "TEST_SECRET_UPDATED", "This as an updated test secret", - organization_id, "Secret1234!_updated", [project2.data.id], ) -secret_retrieved = client.secrets().get(secret.data.id) +secrets_retrieved = client.secrets().get_by_ids([secret.data.id, secret2.data.id]) -input("Press Enter to delete the secret...") -client.secrets().delete([secret.data.id]) +# cleanup +input("Press Enter to cleanup secrets and projects...") +client.secrets().delete([secret.id for secret in secrets_retrieved.data.data]) -print(client.secrets().list(organization_id)) +client.projects().delete([project2.data.id]) From 78efb5fc277e200290e94d83576f33c081354cac Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:49:05 -0400 Subject: [PATCH 119/214] [deps]: Update gh minor (#974) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/build-swift.yml | 6 +++--- .github/workflows/lint.yml | 2 +- .github/workflows/release-swift.yml | 12 ++++++------ .github/workflows/scan.yml | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-swift.yml b/.github/workflows/build-swift.yml index 92be9a456..4d0293dd1 100644 --- a/.github/workflows/build-swift.yml +++ b/.github/workflows/build-swift.yml @@ -16,7 +16,7 @@ jobs: package_version: ${{ steps.retrieve-version.outputs.package_version }} steps: - name: Checkout repo - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Get Package Version id: retrieve-version @@ -32,7 +32,7 @@ jobs: _VERSION: ${{ needs.version.outputs.package_version }} steps: - name: Checkout repo - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust uses: dtolnay/rust-toolchain@bb45937a053e097f8591208d8e74c90db1873d07 # stable @@ -40,7 +40,7 @@ jobs: toolchain: stable - name: Cache cargo registry - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2.7.0 + uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 with: key: sdk-swift-cargo diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c5d530b6b..761c564cd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -45,7 +45,7 @@ jobs: RUSTFLAGS: "-D warnings" - name: Upload Clippy results to GitHub - uses: github/codeql-action/upload-sarif@eb055d739abdc2e8de2e5f4ba1a8b246daa779aa # v3.26.0 + uses: github/codeql-action/upload-sarif@2c779ab0d087cd7fe7b826087247c2c81f27bfa6 # v3.26.5 with: sarif_file: clippy_result.sarif diff --git a/.github/workflows/release-swift.yml b/.github/workflows/release-swift.yml index 954480365..da1f870cf 100644 --- a/.github/workflows/release-swift.yml +++ b/.github/workflows/release-swift.yml @@ -38,7 +38,7 @@ jobs: swift_checksum: ${{ steps.calculate-swift-checksum.outputs.checksum }} steps: - name: Checkout repo - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Get version id: version @@ -109,7 +109,7 @@ jobs: _SWIFT_CHECKSUM: ${{ needs.validate.outputs.swift_checksum }} steps: - name: Checkout SDK repo - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: path: sdk @@ -123,14 +123,14 @@ jobs: fi - name: Checkout SDK-Swift repo - uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: repository: bitwarden/sdk-swift path: sdk-swift ref: ${{ steps.get-ref.outputs.ref }} - name: Login to Azure - Prod Subscription - uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 + uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 with: creds: ${{ secrets.AZURE_CI_SERVICE_PRINCIPAL }} @@ -189,7 +189,7 @@ jobs: _BUILD_RUN_ID: ${{ needs.validate.outputs.run_id }} steps: - name: Login to Azure - Prod Subscription - uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 + uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 with: creds: ${{ secrets.AZURE_CI_SERVICE_PRINCIPAL }} @@ -210,7 +210,7 @@ jobs: run_id: ${{ env._BUILD_RUN_ID }} - name: Create release - uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5 # v1.13.0 + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 with: tag: v${{ env._RELEASE_NAME }} name: v${{ env._RELEASE_NAME }} diff --git a/.github/workflows/scan.yml b/.github/workflows/scan.yml index aecb18356..2df3b61b7 100644 --- a/.github/workflows/scan.yml +++ b/.github/workflows/scan.yml @@ -46,7 +46,7 @@ jobs: --output-path . ${{ env.INCREMENTAL }} - name: Upload Checkmarx results to GitHub - uses: github/codeql-action/upload-sarif@eb055d739abdc2e8de2e5f4ba1a8b246daa779aa # v3.26.0 + uses: github/codeql-action/upload-sarif@2c779ab0d087cd7fe7b826087247c2c81f27bfa6 # v3.26.5 with: sarif_file: cx_result.sarif From ab760ba55fb88076ee347f1d62317e0b0971f249 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 27 Aug 2024 15:31:34 +0200 Subject: [PATCH 120/214] [PM-11247] Publish SDK api documentation (#997) Workflow for publishing rust api documentation. --- .github/workflows/rustdoc.yml | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/rustdoc.yml diff --git a/.github/workflows/rustdoc.yml b/.github/workflows/rustdoc.yml new file mode 100644 index 000000000..a2a07490c --- /dev/null +++ b/.github/workflows/rustdoc.yml @@ -0,0 +1,50 @@ +name: Rustdoc + +on: + push: + branches: ["main"] + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + rustdoc: + name: Rustdoc + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Install rust + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable + with: + toolchain: nightly + + - name: Build documentation + env: + RUSTDOCFLAGS: "--enable-index-page -Zunstable-options" + run: cargo +nightly doc --no-deps --all-features --document-private-items + + - name: Deploy to GitHub Pages + uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 + with: + path: ./target/doc + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: rustdoc + name: Deploy + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 From 3ecee08c0f446b086d1243f840c77fe3968a3b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ch=C4=99ci=C5=84ski?= Date: Tue, 27 Aug 2024 15:42:13 +0200 Subject: [PATCH 121/214] Fix swift build & release (#999) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective Fix SWIFT build & release workflows. ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/release-swift.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/release-swift.yml b/.github/workflows/release-swift.yml index da1f870cf..8a0bf865e 100644 --- a/.github/workflows/release-swift.yml +++ b/.github/workflows/release-swift.yml @@ -16,6 +16,10 @@ on: workflow_dispatch: inputs: + build-run-id: + description: "Workflow Run ID to use for artifact download. If not provided the latest build from the selected branch will be used." + type: string + required: false pre-release: description: "Create a pre-release" type: boolean From 7c51d54376d3d80c372d12e666b431f04591edec Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Wed, 28 Aug 2024 09:14:20 -0400 Subject: [PATCH 122/214] Update Python Binding with state_file Example (#1000) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking n/a ## 📔 Objective Update the Python binding with a state_file example. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- languages/python/example.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/languages/python/example.py b/languages/python/example.py index e128e0dd9..ee3690dd0 100755 --- a/languages/python/example.py +++ b/languages/python/example.py @@ -21,8 +21,12 @@ logging.basicConfig(level=logging.DEBUG) organization_id = os.getenv("ORGANIZATION_ID") +# Set the state file location +# Note: the path must exist, the file will be created & managed by the sdk +state_path = os.getenv("STATE_FILE") + # Attempt to authenticate with the Secrets Manager Access Token -client.auth().login_access_token(os.getenv("ACCESS_TOKEN")) +client.auth().login_access_token(os.getenv("ACCESS_TOKEN"), state_path) # -- Example Project Commands -- From 6f636398f00c2db8891f9fef1cb81ea17d1646bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Thu, 29 Aug 2024 16:52:10 +0200 Subject: [PATCH 123/214] Update rust-version in a couple of missed spots (#1001) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📔 Objective These two were missed on the recent update to 1.75 #980 ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- Cargo.toml | 2 +- crates/bitwarden/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e721d9090..d64aa04fc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ version = "0.5.0" authors = ["Bitwarden Inc"] edition = "2021" # Note: Changing rust-version should be considered a breaking change -rust-version = "1.71" +rust-version = "1.75" homepage = "https://bitwarden.com" repository = "https://github.com/bitwarden/sdk" license-file = "LICENSE" diff --git a/crates/bitwarden/README.md b/crates/bitwarden/README.md index b0364a19e..010a64627 100644 --- a/crates/bitwarden/README.md +++ b/crates/bitwarden/README.md @@ -13,7 +13,7 @@ bitwarden = { "*", features = ["secrets"] } ## Minimum Supported Rust Version -Rust **1.71** or higher. +Rust **1.75** or higher. ## Example From 388f9eee67c6d0b9687785616c0af7b1b96a1e60 Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Fri, 30 Aug 2024 07:13:41 -0700 Subject: [PATCH 124/214] fix: broken python wheels (#1003) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective #947 included an update to PYO3/maturin, which has changed how the Python wheels are packaged. The newer packages are producing a `not a supported wheel on this platform` error when we attempt to install them. This PR reverts to a known-working version of the PYO3/maturin action in order to resolve the breakage to the wheel package. ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/build-python-wheels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-python-wheels.yml b/.github/workflows/build-python-wheels.yml index f6899023d..0f9e2d8bf 100644 --- a/.github/workflows/build-python-wheels.yml +++ b/.github/workflows/build-python-wheels.yml @@ -89,7 +89,7 @@ jobs: - name: Build wheels if: ${{ matrix.settings.target != 'x86_64-unknown-linux-gnu' }} - uses: PyO3/maturin-action@2c5c1560848aaa364c3545136054932db5fa27b7 # v1.44.0 + uses: PyO3/maturin-action@52b28abb0c6729beb388babfc348bf6ff5aaff31 # v1.42.2 with: target: ${{ matrix.settings.target }} args: --release --find-interpreter --sdist @@ -99,7 +99,7 @@ jobs: - name: Build wheels (Linux - x86_64) if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }} - uses: PyO3/maturin-action@2c5c1560848aaa364c3545136054932db5fa27b7 # v1.44.0 + uses: PyO3/maturin-action@52b28abb0c6729beb388babfc348bf6ff5aaff31 # v1.42.2 with: target: ${{ matrix.settings.target }} args: --release --find-interpreter --sdist From 30f4e0cc92c6a4adeb2689128093e2d352e9c221 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Fri, 30 Aug 2024 13:20:23 -0400 Subject: [PATCH 125/214] [SM-1400] Update the C# SDK (#1004) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1400 ## 📔 Objective Update the C# SDK. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .../csharp/Bitwarden.Sdk.Samples/Program.cs | 87 ++++++++++++++----- languages/csharp/Bitwarden.Sdk/AuthClient.cs | 21 +++++ .../csharp/Bitwarden.Sdk/BitwardenClient.cs | 13 +-- .../csharp/Bitwarden.Sdk/ProjectsClient.cs | 2 +- .../csharp/Bitwarden.Sdk/SecretsClient.cs | 43 ++++++++- languages/csharp/README.md | 33 +++++-- 6 files changed, 155 insertions(+), 44 deletions(-) create mode 100644 languages/csharp/Bitwarden.Sdk/AuthClient.cs diff --git a/languages/csharp/Bitwarden.Sdk.Samples/Program.cs b/languages/csharp/Bitwarden.Sdk.Samples/Program.cs index ee6834979..e80d12017 100644 --- a/languages/csharp/Bitwarden.Sdk.Samples/Program.cs +++ b/languages/csharp/Bitwarden.Sdk.Samples/Program.cs @@ -1,30 +1,73 @@ īģŋusing Bitwarden.Sdk; -// Configure secrets +// Get environment variables +var identityUrl = Environment.GetEnvironmentVariable("IDENTITY_URL")!; +var apiUrl = Environment.GetEnvironmentVariable("API_URL")!; +var organizationId = Guid.Parse(Environment.GetEnvironmentVariable("ORGANIZATION_ID")!); var accessToken = Environment.GetEnvironmentVariable("ACCESS_TOKEN")!; -var organizationIdString = Environment.GetEnvironmentVariable("ORGANIZATION_ID")!; -var organizationId = Guid.Parse(organizationIdString); +var stateFile = Environment.GetEnvironmentVariable("STATE_FILE")!; -// Create SDK Client -using var bitwardenClient = new BitwardenClient(); +// Create the SDK Client +using var bitwardenClient = new BitwardenClient(new BitwardenSettings +{ + ApiUrl = apiUrl, + IdentityUrl = identityUrl +}); // Authenticate -bitwardenClient.AccessTokenLogin(accessToken); +bitwardenClient.Auth.LoginAccessToken(accessToken, stateFile); -// Project operations +// Projects List +var projectsList = bitwardenClient.Projects.List(organizationId).Data; +Console.WriteLine("A list of all projects:"); +foreach (ProjectResponse pr in projectsList) +{ + Console.WriteLine(" Project: " + pr.Name); +} + +Console.Write("Press enter to continue..."); +Console.ReadLine(); + +// Projects Create, Update, & Get +Console.WriteLine("Creating and updating a project"); var projectResponse = bitwardenClient.Projects.Create(organizationId, "NewTestProject"); -var projectsResponse = bitwardenClient.Projects.List(organizationId); -var projectId = projectResponse.Id; -projectResponse = bitwardenClient.Projects.Get(projectId); -projectResponse = bitwardenClient.Projects.Update(projectId, organizationId, "NewTestProject2"); - -// Secret operations -var secretResponse = - bitwardenClient.Secrets.Create("key", "value", "note", organizationId, new[] { projectId }); -var secretId = secretResponse.Id; -var secretIdentifiersResponse = bitwardenClient.Secrets.List(organizationId); -secretResponse = bitwardenClient.Secrets.Get(secretId); -secretResponse = bitwardenClient.Secrets - .Update(secretId, "key2", "value2", "note2", organizationId, new[] { projectId }); -bitwardenClient.Secrets.Delete(new[] { secretId }); -bitwardenClient.Projects.Delete(new[] { projectId }); +projectResponse = bitwardenClient.Projects.Update(organizationId, projectResponse.Id, "NewTestProject Renamed"); +projectResponse = bitwardenClient.Projects.Get(projectResponse.Id); +Console.WriteLine("Here is the project we created and updated:"); +Console.WriteLine(projectResponse.Name); + +Console.Write("Press enter to continue..."); +Console.ReadLine(); + +// Secrets list +var secretsList = bitwardenClient.Secrets.List(organizationId).Data; +Console.WriteLine("A list of all secrets:"); +foreach (SecretIdentifierResponse sr in secretsList) +{ + Console.WriteLine(" Secret: " + sr.Key); +} + +Console.Write("Press enter to continue..."); +Console.ReadLine(); + +// Secrets Create, Update, Get +Console.WriteLine("Creating and updating a secret"); +var secretResponse = bitwardenClient.Secrets.Create(organizationId, "New Secret", "the secret value", "the secret note", new[] { projectResponse.Id }); +secretResponse = bitwardenClient.Secrets.Update(organizationId, secretResponse.Id, "New Secret Name", "the secret value", "the secret note", new[] { projectResponse.Id }); +secretResponse = bitwardenClient.Secrets.Get(secretResponse.Id); +Console.WriteLine("Here is the secret we created and updated:"); +Console.WriteLine(secretResponse.Key); + +Console.Write("Press enter to continue..."); +Console.ReadLine(); + +// Secrets GetByIds +var secretsResponse = bitwardenClient.Secrets.GetByIds(new[] { secretResponse.Id }); + +// Secrets Sync +var syncResponse = bitwardenClient.Secrets.Sync(organizationId, null); + +// Secrets & Projects Delete +Console.WriteLine("Deleting our secret and project"); +bitwardenClient.Secrets.Delete(new[] { secretResponse.Id }); +bitwardenClient.Projects.Delete(new[] { projectResponse.Id }); diff --git a/languages/csharp/Bitwarden.Sdk/AuthClient.cs b/languages/csharp/Bitwarden.Sdk/AuthClient.cs new file mode 100644 index 000000000..e801f2aee --- /dev/null +++ b/languages/csharp/Bitwarden.Sdk/AuthClient.cs @@ -0,0 +1,21 @@ +īģŋnamespace Bitwarden.Sdk; + +public class AuthClient +{ + private readonly CommandRunner _commandRunner; + + internal AuthClient(CommandRunner commandRunner) + { + _commandRunner = commandRunner; + } + + public void LoginAccessToken(string accessToken, string stateFile = "") + { + var command = new Command { LoginAccessToken = new AccessTokenLoginRequest { AccessToken = accessToken, StateFile = stateFile } }; + var response = _commandRunner.RunCommand(command); + if (response is not { Success: true }) + { + throw new BitwardenAuthException(response != null ? response.ErrorMessage : "Login failed"); + } + } +} diff --git a/languages/csharp/Bitwarden.Sdk/BitwardenClient.cs b/languages/csharp/Bitwarden.Sdk/BitwardenClient.cs index cb352d84f..2f10e0cf9 100644 --- a/languages/csharp/Bitwarden.Sdk/BitwardenClient.cs +++ b/languages/csharp/Bitwarden.Sdk/BitwardenClient.cs @@ -18,21 +18,14 @@ public BitwardenClient(BitwardenSettings? settings = null) _commandRunner = new CommandRunner(_handle); Projects = new ProjectsClient(_commandRunner); Secrets = new SecretsClient(_commandRunner); - } - - public void AccessTokenLogin(string accessToken) - { - var command = new Command { AccessTokenLogin = new AccessTokenLoginRequest { AccessToken = accessToken } }; - var response = _commandRunner.RunCommand(command); - if (response is not { Success: true }) - { - throw new BitwardenAuthException(response != null ? response.ErrorMessage : "Login failed"); - } + Auth = new AuthClient(_commandRunner); } public ProjectsClient Projects { get; } public SecretsClient Secrets { get; } + public AuthClient Auth { get; set; } + public void Dispose() => _handle.Dispose(); } diff --git a/languages/csharp/Bitwarden.Sdk/ProjectsClient.cs b/languages/csharp/Bitwarden.Sdk/ProjectsClient.cs index 54649b989..47a419364 100644 --- a/languages/csharp/Bitwarden.Sdk/ProjectsClient.cs +++ b/languages/csharp/Bitwarden.Sdk/ProjectsClient.cs @@ -41,7 +41,7 @@ public ProjectResponse Create(Guid organizationId, string name) throw new BitwardenException(result != null ? result.ErrorMessage : "Project create failed"); } - public ProjectResponse Update(Guid id, Guid organizationId, string name) + public ProjectResponse Update(Guid organizationId, Guid id, string name) { var command = new Command { diff --git a/languages/csharp/Bitwarden.Sdk/SecretsClient.cs b/languages/csharp/Bitwarden.Sdk/SecretsClient.cs index fafdca2ab..5dd77fc6b 100644 --- a/languages/csharp/Bitwarden.Sdk/SecretsClient.cs +++ b/languages/csharp/Bitwarden.Sdk/SecretsClient.cs @@ -22,8 +22,20 @@ public SecretResponse Get(Guid id) throw new BitwardenException(result != null ? result.ErrorMessage : "Secret not found"); } - public SecretResponse Create(string key, string value, string note, Guid organizationId, - Guid[] projectIds) + public SecretsResponse GetByIds(Guid[] ids) + { + var command = new Command { Secrets = new SecretsCommand { GetByIds = new SecretsGetRequest { Ids = ids } } }; + var result = _commandRunner.RunCommand(command); + + if (result is { Success: true }) + { + return result.Data; + } + + throw new BitwardenException(result != null ? result.ErrorMessage : "Secret not found"); + } + + public SecretResponse Create(Guid organizationId, string key, string value, string note, Guid[] projectIds) { var command = new Command { @@ -50,8 +62,7 @@ public SecretResponse Create(string key, string value, string note, Guid organiz throw new BitwardenException(result != null ? result.ErrorMessage : "Secret create failed"); } - public SecretResponse Update(Guid id, string key, string value, string note, Guid organizationId, - Guid[] projectIds) + public SecretResponse Update(Guid organizationId, Guid id, string key, string value, string note, Guid[] projectIds) { var command = new Command { @@ -107,4 +118,28 @@ public SecretIdentifiersResponse List(Guid organizationId) throw new BitwardenException(result != null ? result.ErrorMessage : "No secrets for given organization"); } + + public SecretsSyncResponse Sync(Guid organizationId, DateTimeOffset? lastSyncedDate) + { + var command = new Command + { + Secrets = new SecretsCommand + { + Sync = new SecretsSyncRequest + { + OrganizationId = organizationId, + LastSyncedDate = lastSyncedDate + } + } + }; + + var result = _commandRunner.RunCommand(command); + + if (result is { Success: true }) + { + return result.Data; + } + + throw new BitwardenException(result != null ? result.ErrorMessage : "Secret update failed"); + } } diff --git a/languages/csharp/README.md b/languages/csharp/README.md index dea2d1d22..ece863fa3 100644 --- a/languages/csharp/README.md +++ b/languages/csharp/README.md @@ -12,8 +12,15 @@ Review the help documentation on [Access Tokens] ```csharp const string accessToken = ""; -using var bitwardenClient = new BitwardenClient(); -bitwardenClient.AccessTokenLogin(accessToken); +const string stateFile = ""; + +using var bitwardenClient = new BitwardenClient(new BitwardenSettings +{ + ApiUrl = apiUrl, + IdentityUrl = identityUrl +}); + +bitwardenClient.LoginAccessToken(accessToken, stateFile); ``` ### Create new project @@ -34,7 +41,7 @@ var response = bitwardenClient.Projects.List(organizationId); ```csharp var projectId = projectResponse.Id; projectResponse = bitwardenClient.Projects.Get(projectId); -projectResponse = bitwardenClient.Projects.Update(projectId, organizationId, "TestProjectUpdated"); +projectResponse = bitwardenClient.Projects.Update(organizationId, projectId, "TestProjectUpdated"); ``` ### Add new secret @@ -43,14 +50,20 @@ projectResponse = bitwardenClient.Projects.Update(projectId, organizationId, "Te var key = "key"; var value = "value"; var note = "note"; -var secretResponse = bitwardenClient.Secrets.Create(key, value, note, organizationId, new[] { projectId }); -var secretId = secretResponse.Id; +var secretResponse = bitwardenClient.Secrets.Create(organizationId, key, value, note, new[] { projectId }); ``` ### Update secret ```csharp -secretResponse = bitwardenClient.Secrets - .Update(secretId, "key2", "value2", "note2", organizationId, new[] { projectId }); +var secretId = secretResponse.Id; +secretResponse = bitwardenClient.Secrets.Get(secretId); +secretResponse = bitwardenClient.Secrets.Update(organizationId, secretId, "key2", "value2", "note2", new[] { projectId }); +``` + +### Secret GetByIds + +```csharp +var secretsResponse = bitwardenClient.Secrets.GetByIds(new[] { secretResponse.Id }); ``` ### List secrets @@ -59,6 +72,12 @@ secretResponse = bitwardenClient.Secrets var secretIdentifiersResponse = bitwardenClient.Secrets.List(organizationId); ``` +### Sync secrets + +```csharp +var syncResponse = bitwardenClient.Secrets.Sync(organizationId, null); +``` + # Delete secret or project ```csharp From 740c2ae3ad2946307f396d590833d1191ac2b260 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 2 Sep 2024 15:14:06 +0200 Subject: [PATCH 126/214] [deps]: Lock file maintenance (#1013) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. đŸ‘ģ **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 138 +++++++++++----------- languages/js/sdk-client/package-lock.json | 6 +- package-lock.json | 24 ++-- 3 files changed, 84 insertions(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2738e3ef8..b615b9061 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,7 +188,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -237,7 +237,7 @@ checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -783,9 +783,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fd4c6dcc3b0aea2f5c0b4b82c2b15fe39ddbc76041a310848f4706edf76bb31" +checksum = "773d90827bc3feecfb67fab12e24de0749aad83c74b9504ecde46237b5cd24e2" [[package]] name = "byteorder" @@ -854,9 +854,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.14" +version = "1.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d2eb3cd3d1bf4529e31c215ee6f93ec5a3d536d9f578f93d9d33ee19562932" +checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" dependencies = [ "shlex", ] @@ -950,9 +950,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.23" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "531d7959c5bbb6e266cecdd0f20213639c3a5c3e4d615f97db87661745f781ff" +checksum = "6d7db6eca8c205649e8d3ccd05aa5042b1800a784e56bc7c43524fde8abbfa9b" dependencies = [ "clap", ] @@ -966,7 +966,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1309,7 +1309,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1333,7 +1333,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1344,7 +1344,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1407,33 +1407,33 @@ dependencies = [ [[package]] name = "derive_builder" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0350b5cb0331628a5916d6c5c0b72e97393b8b6b03b47a9284f4e7f5a405ffd7" +checksum = "cd33f37ee6a119146a1781d3356a7c26028f83d779b2e04ecd45fdc75c76877b" dependencies = [ "derive_builder_macro", ] [[package]] name = "derive_builder_core" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d48cda787f839151732d396ac69e3473923d54312c070ee21e9effcaa8ca0b1d" +checksum = "7431fa049613920234f22c47fdc33e6cf3ee83067091ea4277a3f8c4587aae38" dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] name = "derive_builder_macro" -version = "0.20.0" +version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "206868b8242f27cecce124c19fd88157fbd0dd334df2587f36417bafbc85097b" +checksum = "4abae7035bf79b9877b779505d8cf3749285b80c43941eda66604841889451dc" dependencies = [ "derive_builder_core", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1699,7 +1699,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -1833,7 +1833,7 @@ dependencies = [ "futures-core", "futures-sink", "http", - "indexmap 2.4.0", + "indexmap 2.5.0", "slab", "tokio", "tokio-util", @@ -2088,9 +2088,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93ead53efc7ea8ed3cfb0c79fc8023fbb782a5432b52830b6518941cebe6505c" +checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", "hashbrown 0.14.5", @@ -2407,7 +2407,7 @@ dependencies = [ "napi-derive-backend", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -2422,7 +2422,7 @@ dependencies = [ "quote", "regex", "semver", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -2697,7 +2697,7 @@ dependencies = [ "coset", "data-encoding", "getrandom", - "indexmap 2.4.0", + "indexmap 2.5.0", "rand", "serde", "serde_json", @@ -2772,7 +2772,7 @@ checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -2827,7 +2827,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" dependencies = [ "base64 0.22.1", - "indexmap 2.4.0", + "indexmap 2.5.0", "quick-xml", "serde", "time", @@ -2987,7 +2987,7 @@ dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3000,7 +3000,7 @@ dependencies = [ "proc-macro2", "pyo3-build-config", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3224,9 +3224,9 @@ dependencies = [ [[package]] name = "rgb" -version = "0.8.48" +version = "0.8.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f86ae463694029097b846d8f99fd5536740602ae00022c0c50c5600720b2f71" +checksum = "57397d16646700483b67d2dd6511d79318f9d057fdbd21a4066aeac8b41d310a" dependencies = [ "bytemuck", ] @@ -3286,9 +3286,9 @@ checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustix" -version = "0.38.34" +version = "0.38.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" dependencies = [ "bitflags 2.6.0", "errno", @@ -3313,9 +3313,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04182dffc9091a404e0fc069ea5cd60e5b866c3adf881eff99a32d048242dffa" +checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" dependencies = [ "openssl-probe", "rustls-pemfile", @@ -3369,9 +3369,9 @@ checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" [[package]] name = "rustls-webpki" -version = "0.102.6" +version = "0.102.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e6b52d4fda176fd835fdc55a835d4a89b8499cad995885a21149d5ad62f852e" +checksum = "84678086bd54edf2b415183ed7a94d0efb049f1b646a33e22a36f3794be6ae56" dependencies = [ "ring", "rustls-pki-types", @@ -3432,7 +3432,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3464,7 +3464,7 @@ checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3545,7 +3545,7 @@ checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3556,7 +3556,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3565,7 +3565,7 @@ version = "1.0.127" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.5.0", "itoa", "memchr", "ryu", @@ -3591,7 +3591,7 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3625,7 +3625,7 @@ dependencies = [ "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.4.0", + "indexmap 2.5.0", "serde", "serde_derive", "serde_json", @@ -3642,7 +3642,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3651,7 +3651,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.5.0", "itoa", "ryu", "serde", @@ -3841,7 +3841,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3854,7 +3854,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -3884,9 +3884,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.76" +version = "2.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578e081a14e0cefc3279b0472138c513f37b41a08d5a3cca9b6e4e8ceb6cd525" +checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", @@ -3967,7 +3967,7 @@ checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4038,9 +4038,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.3" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -4060,7 +4060,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4123,7 +4123,7 @@ version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ - "indexmap 2.4.0", + "indexmap 2.5.0", "serde", "serde_spanned", "toml_datetime", @@ -4316,7 +4316,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a22dbe67c1c957ac6e7611bdf605a6218aa86b0eebeb8be58b70ae85ad7d73dc" dependencies = [ "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4348,7 +4348,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.76", + "syn 2.0.77", "toml 0.5.11", "uniffi_meta", ] @@ -4454,16 +4454,16 @@ dependencies = [ [[package]] name = "validator_derive" -version = "0.18.1" +version = "0.18.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55591299b7007f551ed1eb79a684af7672c19c3193fb9e0a31936987bb2438ec" +checksum = "df0bcf92720c40105ac4b2dda2a4ea3aa717d4d6a862cc217da653a4bd5c6b10" dependencies = [ "darling", "once_cell", "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4527,7 +4527,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", "wasm-bindgen-shared", ] @@ -4561,7 +4561,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4595,7 +4595,7 @@ checksum = "4b8220be1fa9e4c889b30fd207d4906657e7e90b12e0e6b0c8b8d8709f5de021" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4610,9 +4610,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.3" +version = "0.26.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd7c23921eeb1713a4e851530e9b9756e4fb0e89978582942612524cf09f01cd" +checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a" dependencies = [ "rustls-pki-types", ] @@ -4913,7 +4913,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] @@ -4934,7 +4934,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.76", + "syn 2.0.77", ] [[package]] diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index 225522f86..eb2b74671 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -41,9 +41,9 @@ } }, "node_modules/@types/node": { - "version": "20.16.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.1.tgz", - "integrity": "sha512-zJDo7wEadFtSyNz5QITDfRcrhqDvQI1xQNQ0VoizPjM/dVAODqqIUWbJPkvsxmTI0MYRGRikcdjMPhOssnPejQ==", + "version": "20.16.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.3.tgz", + "integrity": "sha512-/wdGiWRkMOm53gAsSyFMXFZHbVg7C6CbkrzHNpaHoYfsUWPg7m6ZRKtvQjgvQ9i8WT540a3ydRlRQbxjY30XxQ==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package-lock.json b/package-lock.json index 4b5b6285b..bb89e32d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,9 +19,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.25.4", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.4.tgz", - "integrity": "sha512-DSgLeL/FNcpXuzav5wfYvHCGvynXkJbn3Zvc3823AEe9nPwW9IK4UoCSS5yGymmQzN0pCPvivtgS6/8U2kkm1w==", + "version": "7.25.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.6.tgz", + "integrity": "sha512-VBj9MYyDb9tuLq7yzqjgzt6Q+IBQLrGZfdjOekyEirZPHxXWoTSGUTMrpsfi58Up73d13NfYLv8HT9vmznjzhQ==", "dev": true, "license": "MIT", "dependencies": { @@ -370,9 +370,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.5.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.0.tgz", - "integrity": "sha512-DkFrJOe+rfdHTqqMg0bSNlGlQ85hSoh2TPzZyhHsXnMtligRWpxUySiyw8FY14ITt24HVCiQPWxS3KO/QlGmWg==", + "version": "22.5.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.2.tgz", + "integrity": "sha512-acJsPTEqYqulZS/Yp/S3GgeE6GZ0qYODUR8aVr/DkhHQ8l9nd4j5x1/ZJy9/gHrRlFMqkO6i0I3E27Alu4jjPg==", "dev": true, "license": "MIT", "peer": true, @@ -951,9 +951,9 @@ "license": "MIT" }, "node_modules/escalade": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", - "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", "dev": true, "license": "MIT", "engines": { @@ -2173,9 +2173,9 @@ } }, "node_modules/uglify-js": { - "version": "3.19.2", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.2.tgz", - "integrity": "sha512-S8KA6DDI47nQXJSi2ctQ629YzwOVs+bQML6DAtvy0wgNdpi+0ySpQK0g2pxBq2xfF2z3YCscu7NNA8nXT9PlIQ==", + "version": "3.19.3", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz", + "integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==", "dev": true, "license": "BSD-2-Clause", "optional": true, From 0b6d118a3803fcb2ef8fef24d90a6c69b1a9568b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ch=C4=99ci=C5=84ski?= Date: Tue, 3 Sep 2024 12:19:32 +0200 Subject: [PATCH 127/214] [BRE-113] Fix release swift (#1014) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/BRE-113 ## 📔 Objective Fix `release-swift.yml` workflow. ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/release-swift.yml | 46 +++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release-swift.yml b/.github/workflows/release-swift.yml index 8a0bf865e..dcae5b5d2 100644 --- a/.github/workflows/release-swift.yml +++ b/.github/workflows/release-swift.yml @@ -47,7 +47,7 @@ jobs: - name: Get version id: version run: | - VERSION=$(grep -o '^version = ".*"' crates/bitwarden/Cargo.toml | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+") + VERSION=$(grep -o '^version = ".*"' Cargo.toml | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+") echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Get run id @@ -57,7 +57,7 @@ jobs: OWNER: ${{ github.repository_owner }} REPO: ${{ github.event.repository.name }} run: | - if [[ -z ${{ inputs.build-run-id }} ]]; then + if [ -z ${{ inputs.build-run-id }} ]; then BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} RUN_ID=$(gh api \ -H "Accept: application/vnd.github+json" \ @@ -126,13 +126,6 @@ jobs: echo "ref=main" >> $GITHUB_OUTPUT fi - - name: Checkout SDK-Swift repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - with: - repository: bitwarden/sdk-swift - path: sdk-swift - ref: ${{ steps.get-ref.outputs.ref }} - - name: Login to Azure - Prod Subscription uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 with: @@ -142,8 +135,27 @@ jobs: id: retrieve-secrets uses: bitwarden/gh-actions/get-keyvault-secrets@main with: - keyvault: ${{ env._KEY_VAULT }} - secrets: "github-pat-bitwarden-devops-bot-repo-scope" + keyvault: "bitwarden-ci" + secrets: "github-gpg-private-key, + github-gpg-private-key-passphrase, + github-pat-bitwarden-devops-bot-repo-scope" + + - name: Checkout SDK-Swift repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + repository: bitwarden/sdk-swift + path: sdk-swift + ref: ${{ steps.get-ref.outputs.ref }} + token: ${{ steps.retrieve-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }} + + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0 + with: + gpg_private_key: ${{ steps.retrieve-secrets.outputs.github-gpg-private-key }} + passphrase: ${{ steps.retrieve-secrets.outputs.github-gpg-private-key-passphrase }} + git_user_signingkey: true + git_commit_gpgsign: true + workdir: sdk-swift - name: Setup Git working-directory: sdk-swift @@ -151,13 +163,20 @@ jobs: git config --local user.email "${{ env._BOT_EMAIL }}" git config --local user.name "${{ env._BOT_NAME }}" + - name: Install Swift formatter + run: | + git clone https://github.com/nicklockwood/SwiftFormat + cd SwiftFormat + swift build -c release + cp -f .build/release/swiftformat /usr/local/bin/swiftformat + - name: Update files run: | # Update BitwardenFFI path - sed -i '' 's|.binaryTarget(name: "BitwardenFFI", path: "BitwardenFFI.xcframework")|.binaryTarget(\ + sed -i 's|.binaryTarget(name: "BitwardenFFI", path: "BitwardenFFI.xcframework")|.binaryTarget(\ name: "BitwardenFFI",\ url: "https://github.com/bitwarden/sdk-swift/releases/download/v${{ env._RELEASE_NAME }}/BitwardenFFI-${{ env._PKG_VERSION }}-${{ needs.validate.outputs.short_sha }}.xcframework.zip",\ - checksum: "${{ env._SWIFT_CHECKSUM }}"|' sdk/languages/swift/Package.swift + checksum: "${{ env._SWIFT_CHECKSUM }}" )|' sdk/languages/swift/Package.swift # Run swiftformat swiftformat sdk/languages/swift/Package.swift @@ -212,6 +231,7 @@ jobs: workflow_conclusion: success artifacts: "BitwardenFFI-${{ env._PKG_VERSION }}-${{ needs.validate.outputs.short_sha }}.xcframework" run_id: ${{ env._BUILD_RUN_ID }} + skip_unpack: true - name: Create release uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 From ed15aa36846b23cf0184e0d75a0f69539bd1a9bb Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 3 Sep 2024 13:36:42 +0200 Subject: [PATCH 128/214] Remove unused dependencies (#1015) --- Cargo.lock | 4 ---- crates/bitwarden-core/Cargo.toml | 16 +++------------- crates/sdk-schemas/Cargo.toml | 2 +- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b615b9061..885aad0cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -431,18 +431,14 @@ dependencies = [ name = "bitwarden-core" version = "0.5.0" dependencies = [ - "async-trait", "base64 0.22.1", "bitwarden-api-api", "bitwarden-api-identity", "bitwarden-crypto", "chrono", - "coset", "getrandom", "hmac", "log", - "p256", - "passkey", "rand", "rand_chacha", "reqwest", diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml index d6f6131ee..bb7a9b15e 100644 --- a/crates/bitwarden-core/Cargo.toml +++ b/crates/bitwarden-core/Cargo.toml @@ -14,21 +14,14 @@ repository.workspace = true license-file.workspace = true [features] -internal = [] # Internal testing methods +internal = ["dep:zxcvbn"] no-memory-hardening = [ "bitwarden-crypto/no-memory-hardening", ] # Disable memory hardening features -uniffi = [ - "bitwarden-crypto/uniffi", - "dep:uniffi", - "dep:passkey", - "dep:coset", - "dep:p256", -] # Uniffi bindings +uniffi = ["bitwarden-crypto/uniffi", "dep:uniffi"] # Uniffi bindings secrets = [] # Secrets manager API [dependencies] -async-trait = ">=0.1.80, <0.2" base64 = ">=0.22.1, <0.23" bitwarden-api-api = { workspace = true } bitwarden-api-identity = { workspace = true } @@ -38,13 +31,10 @@ chrono = { version = ">=0.4.26, <0.5", features = [ "serde", "std", ], default-features = false } -coset = { version = "0.3.7", optional = true } # 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"] } hmac = ">=0.12.1, <0.13" log = ">=0.4.18, <0.5" -p256 = { version = ">=0.13.2, <0.14", optional = true } -passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "ae08e2cb7dd3d44d915caed395c0cdc56b50fa27", optional = true } rand = ">=0.8.5, <0.9" reqwest = { version = ">=0.12.5, <0.13", features = [ "http2", @@ -62,7 +52,7 @@ uniffi = { version = "=0.28.1", optional = true, features = ["tokio"] } uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } validator = { version = "0.18.1", features = ["derive"] } zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } -zxcvbn = ">=3.0.1, <4.0" +zxcvbn = { version = ">=3.0.1, <4.0", optional = true } [target.'cfg(all(not(target_arch="wasm32"), not(windows)))'.dependencies] # By default, we use rustls as the TLS stack and rust-platform-verifier to support user-installed root certificates diff --git a/crates/sdk-schemas/Cargo.toml b/crates/sdk-schemas/Cargo.toml index 05c7f24b3..9982e47fe 100644 --- a/crates/sdk-schemas/Cargo.toml +++ b/crates/sdk-schemas/Cargo.toml @@ -22,7 +22,7 @@ internal = [ anyhow = "1.0.82" bitwarden = { workspace = true } bitwarden-json = { path = "../bitwarden-json" } -bitwarden-uniffi = { path = "../bitwarden-uniffi" } +bitwarden-uniffi = { path = "../bitwarden-uniffi", optional = true } itertools = "0.13.0" schemars = { version = "0.8.16", features = ["preserve_order"] } serde_json = "1.0.113" From b4debfd88f1e7f90c3d1a06f5095537da8ebeb1d Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 3 Sep 2024 15:42:25 +0200 Subject: [PATCH 129/214] Improve docs for crypto crate, hide private functions (#1016) Improve docs for crypto crate, hide private functions. I believe only the traits in `key_encryptable` remains and @dani-garcia is planning on rewriting those which means they will be documented at that time. --- .vscode/settings.json | 2 ++ crates/bitwarden-crypto/src/aes.rs | 2 +- crates/bitwarden-crypto/src/enc_string/mod.rs | 9 ++++++++- crates/bitwarden-crypto/src/enc_string/symmetric.rs | 2 +- .../bitwarden-crypto/src/keys/asymmetric_crypto_key.rs | 2 +- crates/bitwarden-crypto/src/keys/utils.rs | 1 + crates/bitwarden-crypto/src/lib.rs | 5 +++-- crates/bitwarden-crypto/src/util.rs | 1 + 8 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index dcef4bc17..f75a2e3f5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,6 +5,7 @@ "Cdecl", "chrono", "cloc", + "dealloc", "decryptable", "dylib", "encryptable", @@ -22,6 +23,7 @@ "uniffi", "wordlist", "Zeroize", + "Zeroizing", "zxcvbn" ], "rust-analyzer.cargo.targetDir": true diff --git a/crates/bitwarden-crypto/src/aes.rs b/crates/bitwarden-crypto/src/aes.rs index dde588563..14393dfae 100644 --- a/crates/bitwarden-crypto/src/aes.rs +++ b/crates/bitwarden-crypto/src/aes.rs @@ -133,7 +133,7 @@ fn decrypt_aes128(iv: &[u8; 16], data: Vec, key: &GenericArray) -> /// Decrypt using AES-128 in CBC mode with MAC. /// /// Behaves similar to [decrypt_aes128], but also validates the MAC. -pub fn decrypt_aes128_hmac( +pub(crate) fn decrypt_aes128_hmac( iv: &[u8; 16], mac: &[u8; 32], data: Vec, diff --git a/crates/bitwarden-crypto/src/enc_string/mod.rs b/crates/bitwarden-crypto/src/enc_string/mod.rs index 3250c1a58..3278b8064 100644 --- a/crates/bitwarden-crypto/src/enc_string/mod.rs +++ b/crates/bitwarden-crypto/src/enc_string/mod.rs @@ -1,4 +1,11 @@ -/// Encrypted string types +//! Encrypted string types +//! +//! [EncString] and [AsymmetricEncString] are Bitwarden specific primitive that represents a +//! encrypted string. They are are used together with the [KeyDecryptable][crate::KeyDecryptable] +//! and [KeyEncryptable][crate::KeyEncryptable] traits to encrypt and decrypt data using +//! [SymmetricCryptoKey][crate::SymmetricCryptoKey] and +//! [AsymmetricCryptoKey][crate::AsymmetricCryptoKey]s. + mod asymmetric; mod symmetric; diff --git a/crates/bitwarden-crypto/src/enc_string/symmetric.rs b/crates/bitwarden-crypto/src/enc_string/symmetric.rs index 093ab9f62..eb1220e29 100644 --- a/crates/bitwarden-crypto/src/enc_string/symmetric.rs +++ b/crates/bitwarden-crypto/src/enc_string/symmetric.rs @@ -203,7 +203,7 @@ impl serde::Serialize for EncString { } impl EncString { - pub fn encrypt_aes256_hmac( + pub(crate) fn encrypt_aes256_hmac( data_dec: &[u8], mac_key: &GenericArray, key: &GenericArray, diff --git a/crates/bitwarden-crypto/src/keys/asymmetric_crypto_key.rs b/crates/bitwarden-crypto/src/keys/asymmetric_crypto_key.rs index 9a2bb43e3..a00a1f842 100644 --- a/crates/bitwarden-crypto/src/keys/asymmetric_crypto_key.rs +++ b/crates/bitwarden-crypto/src/keys/asymmetric_crypto_key.rs @@ -15,7 +15,7 @@ pub trait AsymmetricEncryptable { /// [AsymmetricEncString](crate::AsymmetricEncString), usually accompanied by a /// [AsymmetricCryptoKey] pub struct AsymmetricPublicCryptoKey { - pub(crate) key: RsaPublicKey, + key: RsaPublicKey, } impl AsymmetricPublicCryptoKey { diff --git a/crates/bitwarden-crypto/src/keys/utils.rs b/crates/bitwarden-crypto/src/keys/utils.rs index 559234125..8564a7c9f 100644 --- a/crates/bitwarden-crypto/src/keys/utils.rs +++ b/crates/bitwarden-crypto/src/keys/utils.rs @@ -47,6 +47,7 @@ pub(super) fn derive_kdf_key(secret: &[u8], salt: &[u8], kdf: &Kdf) -> Result Result { let key: Pin>> = hkdf_expand(&k.key, Some("enc"))?; let mac_key: Pin>> = hkdf_expand(&k.key, Some("mac"))?; diff --git a/crates/bitwarden-crypto/src/lib.rs b/crates/bitwarden-crypto/src/lib.rs index 4c71b0029..44efaac30 100644 --- a/crates/bitwarden-crypto/src/lib.rs +++ b/crates/bitwarden-crypto/src/lib.rs @@ -56,8 +56,9 @@ //! ## Crate features //! //! - `no-memory-hardening` - Disables memory hardening which ensures that allocated memory is -//! zeroed on drop. This feature primarily exists in case you do not want to use the standard -//! allocator, and we advise to still define a `global_allocator` using the [`ZeroizingAllocator`]. +//! zeroed on drop. This feature primarily exists in case you do not want to use the standard +//! allocator, and we advise to still define a `global_allocator` using the +//! [`ZeroizingAllocator`]. #[cfg(not(feature = "no-memory-hardening"))] #[global_allocator] diff --git a/crates/bitwarden-crypto/src/util.rs b/crates/bitwarden-crypto/src/util.rs index 72036c615..d1ba5cdad 100644 --- a/crates/bitwarden-crypto/src/util.rs +++ b/crates/bitwarden-crypto/src/util.rs @@ -47,6 +47,7 @@ pub fn generate_random_alphanumeric(len: usize) -> String { Alphanumeric.sample_string(&mut rand::thread_rng(), len) } +/// Derive pbkdf2 of a given password and salt pub fn pbkdf2(password: &[u8], salt: &[u8], rounds: u32) -> [u8; PBKDF_SHA256_HMAC_OUT_SIZE] { pbkdf2::pbkdf2_array::(password, salt, rounds) .expect("hash is a valid fixed size") From 1b760a47986fe239c05558ef2255387de4a74519 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:28:41 -0400 Subject: [PATCH 130/214] [deps]: Update actions/upload-artifact action to v4 (#1011) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/build-swift.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-swift.yml b/.github/workflows/build-swift.yml index 4d0293dd1..ffd799afe 100644 --- a/.github/workflows/build-swift.yml +++ b/.github/workflows/build-swift.yml @@ -61,7 +61,7 @@ jobs: echo "short-sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - name: Upload BitwardenFFI.xcframework artifact - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: BitwardenFFI-${{ env._VERSION }}-${{ steps.build.outputs.short-sha }}.xcframework path: languages/swift/BitwardenFFI.xcframework From 655de24d394a7e3b4bf27cc289387db8dba70bb6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 3 Sep 2024 15:29:38 -0400 Subject: [PATCH 131/214] [deps]: Update dtolnay/rust-toolchain digest to 7b1c307 (#1006) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/build-swift.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-swift.yml b/.github/workflows/build-swift.yml index ffd799afe..b37c62811 100644 --- a/.github/workflows/build-swift.yml +++ b/.github/workflows/build-swift.yml @@ -35,7 +35,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Install rust - uses: dtolnay/rust-toolchain@bb45937a053e097f8591208d8e74c90db1873d07 # stable + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable From a41625e886e85c0594541c28ee67dddbc9a0c968 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 4 Sep 2024 09:44:58 -0400 Subject: [PATCH 132/214] [deps]: Update gh minor (#1010) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/build-android.yml | 4 ++-- .github/workflows/build-cli.yml | 12 ++++++------ .github/workflows/build-cpp.yml | 2 +- .github/workflows/build-dotnet.yml | 2 +- .github/workflows/build-napi.yml | 2 +- .github/workflows/build-python-wheels.yml | 8 ++++---- .github/workflows/build-rust-cross-platform.yml | 2 +- .github/workflows/build-wasm.yml | 2 +- .github/workflows/generate_schemas.yml | 16 ++++++++-------- .github/workflows/lint.yml | 2 +- .github/workflows/publish-java.yml | 2 +- .github/workflows/publish-python.yml | 2 +- .github/workflows/publish-ruby.yml | 2 +- .github/workflows/scan.yml | 2 +- 14 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index 9de6883f5..909e689c4 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -46,7 +46,7 @@ jobs: run: cross build -p bitwarden-uniffi --release --target=${{ matrix.settings.target }} - name: Upload artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: android-${{ matrix.settings.target }} path: ./target/${{ matrix.settings.target }}/release/libbitwarden_uniffi.so @@ -102,7 +102,7 @@ jobs: run: ./build-schemas.sh - name: Setup gradle - uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 + uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4.0.1 - name: Publish run: ./gradlew sdk:publish diff --git a/.github/workflows/build-cli.yml b/.github/workflows/build-cli.yml index 6dd683142..7620ced50 100644 --- a/.github/workflows/build-cli.yml +++ b/.github/workflows/build-cli.yml @@ -123,7 +123,7 @@ jobs: run: 7z a ./bws-${{ matrix.settings.target }}-%_PACKAGE_VERSION%.zip ./target/${{ matrix.settings.target }}/release/bws.exe - name: Upload artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip path: ./bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip @@ -233,7 +233,7 @@ jobs: xcrun notarytool submit ./bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip --keychain-profile "notarytool-profile" --wait - name: Upload artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip path: ./bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip @@ -292,7 +292,7 @@ jobs: run: zip -j ./bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip ./target/${{ matrix.settings.target }}/release/bws - name: Upload artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip path: ./bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip @@ -397,7 +397,7 @@ jobs: xcrun notarytool submit ./bws-macos-universal-${{ env._PACKAGE_VERSION }}.zip --keychain-profile "notarytool-profile" --wait - name: Upload artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: bws-macos-universal-${{ env._PACKAGE_VERSION }}.zip path: ./bws-macos-universal-${{ env._PACKAGE_VERSION }}.zip @@ -432,7 +432,7 @@ jobs: sed -i.bak 's/\$NAME\$/Bitwarden Secrets Manager CLI/g' THIRDPARTY.html - name: Upload artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: THIRDPARTY.html path: ./crates/bws/THIRDPARTY.html @@ -464,7 +464,7 @@ jobs: mv $OUT_DIR/manpages . - name: Upload artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: manpages path: ./manpages/* diff --git a/.github/workflows/build-cpp.yml b/.github/workflows/build-cpp.yml index d26d22254..e95e6cbf2 100644 --- a/.github/workflows/build-cpp.yml +++ b/.github/workflows/build-cpp.yml @@ -159,7 +159,7 @@ jobs: cp libBitwardenClient.* artifacts - name: Upload C++ package for ${{ matrix.settings.target }} - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: libbitwarden_cpp-${{ matrix.settings.target }} path: languages/cpp/build/artifacts diff --git a/.github/workflows/build-dotnet.yml b/.github/workflows/build-dotnet.yml index cd6441d77..97d43dfbe 100644 --- a/.github/workflows/build-dotnet.yml +++ b/.github/workflows/build-dotnet.yml @@ -92,7 +92,7 @@ jobs: working-directory: languages/csharp/Bitwarden.Sdk - name: Upload NuGet package - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: Bitwarden.Sdk.${{ needs.version.outputs.version }}.nupkg path: | diff --git a/.github/workflows/build-napi.yml b/.github/workflows/build-napi.yml index 5ad1ebd54..e950b5e7a 100644 --- a/.github/workflows/build-napi.yml +++ b/.github/workflows/build-napi.yml @@ -84,7 +84,7 @@ jobs: run: ${{ matrix.settings.build }} - name: Upload artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: sdk-bitwarden-napi-${{ matrix.settings.target }} path: ${{ github.workspace }}/crates/bitwarden-napi/sdk-napi.*.node diff --git a/.github/workflows/build-python-wheels.yml b/.github/workflows/build-python-wheels.yml index 0f9e2d8bf..943177d69 100644 --- a/.github/workflows/build-python-wheels.yml +++ b/.github/workflows/build-python-wheels.yml @@ -89,7 +89,7 @@ jobs: - name: Build wheels if: ${{ matrix.settings.target != 'x86_64-unknown-linux-gnu' }} - uses: PyO3/maturin-action@52b28abb0c6729beb388babfc348bf6ff5aaff31 # v1.42.2 + uses: PyO3/maturin-action@2c5c1560848aaa364c3545136054932db5fa27b7 # v1.44.0 with: target: ${{ matrix.settings.target }} args: --release --find-interpreter --sdist @@ -99,7 +99,7 @@ jobs: - name: Build wheels (Linux - x86_64) if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }} - uses: PyO3/maturin-action@52b28abb0c6729beb388babfc348bf6ff5aaff31 # v1.42.2 + uses: PyO3/maturin-action@2c5c1560848aaa364c3545136054932db5fa27b7 # v1.44.0 with: target: ${{ matrix.settings.target }} args: --release --find-interpreter --sdist @@ -109,14 +109,14 @@ jobs: working-directory: ${{ github.workspace }}/languages/python - name: Upload wheels - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: bitwarden_sdk-${{ env._PACKAGE_VERSION }}-${{ matrix.settings.target }} path: ${{ github.workspace }}/target/wheels/bitwarden_sdk*.whl - name: Upload sdists if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }} # we only need one sdist - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: bitwarden_sdk-${{ env._PACKAGE_VERSION }}-sdist path: ${{ github.workspace }}/target/wheels/bitwarden_sdk-*.tar.gz diff --git a/.github/workflows/build-rust-cross-platform.yml b/.github/workflows/build-rust-cross-platform.yml index 92ed526f2..31347a9a9 100644 --- a/.github/workflows/build-rust-cross-platform.yml +++ b/.github/workflows/build-rust-cross-platform.yml @@ -70,7 +70,7 @@ jobs: run: cargo build -p bitwarden-c --target ${{ matrix.settings.target }} --release - name: Upload Artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: libbitwarden_c_files-${{ matrix.settings.target }} path: | diff --git a/.github/workflows/build-wasm.yml b/.github/workflows/build-wasm.yml index 62be51d79..c2c79d3ad 100644 --- a/.github/workflows/build-wasm.yml +++ b/.github/workflows/build-wasm.yml @@ -52,7 +52,7 @@ jobs: run: ./build.sh -r - name: Upload artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: sdk-bitwarden-wasm path: ${{ github.workspace }}/languages/js/wasm/* diff --git a/.github/workflows/generate_schemas.yml b/.github/workflows/generate_schemas.yml index 87f4dd988..9f3e6743c 100644 --- a/.github/workflows/generate_schemas.yml +++ b/.github/workflows/generate_schemas.yml @@ -43,55 +43,55 @@ jobs: run: npm run schemas - name: Upload ts schemas artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: schemas.ts path: ${{ github.workspace }}/languages/js/sdk-client/src/schemas.ts if-no-files-found: error - name: Upload c# schemas artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: schemas.cs path: ${{ github.workspace }}/languages/csharp/Bitwarden.Sdk/schemas.cs if-no-files-found: error - name: Upload python schemas artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: schemas.py path: ${{ github.workspace }}/languages/python/bitwarden_sdk/schemas.py if-no-files-found: error - name: Upload ruby schemas artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: schemas.rb path: ${{ github.workspace }}/languages/ruby/bitwarden_sdk_secrets/lib/schemas.rb if-no-files-found: error - name: Upload json schemas artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: sdk-schemas-json path: ${{ github.workspace }}/support/schemas/* if-no-files-found: error - name: Upload Go schemas artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: schemas.go path: ${{ github.workspace }}/languages/go/schema.go - name: Upload java schemas artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: sdk-schemas-java path: ${{ github.workspace }}/languages/java/src/main/java/com/bitwarden/sdk/schema/* if-no-files-found: error - name: Upload cpp schemas artifact - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: sdk-schemas-cpp path: ${{ github.workspace }}/languages/cpp/include/schemas.hpp diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 761c564cd..686b5775a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -45,7 +45,7 @@ jobs: RUSTFLAGS: "-D warnings" - name: Upload Clippy results to GitHub - uses: github/codeql-action/upload-sarif@2c779ab0d087cd7fe7b826087247c2c81f27bfa6 # v3.26.5 + uses: github/codeql-action/upload-sarif@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6 with: sarif_file: clippy_result.sarif diff --git a/.github/workflows/publish-java.yml b/.github/workflows/publish-java.yml index c50080728..fdf0be986 100644 --- a/.github/workflows/publish-java.yml +++ b/.github/workflows/publish-java.yml @@ -70,7 +70,7 @@ jobs: java-version: 17 - name: Setup Gradle - uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0 + uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4.0.1 - name: Publish package to GitHub Packages if: ${{ inputs.release_type != 'Dry Run' }} diff --git a/.github/workflows/publish-python.yml b/.github/workflows/publish-python.yml index 343fadd8a..3a9c08aac 100644 --- a/.github/workflows/publish-python.yml +++ b/.github/workflows/publish-python.yml @@ -42,7 +42,7 @@ jobs: needs: setup steps: - name: Install Python - uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1 + uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 with: python-version: "3.9" diff --git a/.github/workflows/publish-ruby.yml b/.github/workflows/publish-ruby.yml index 6dd3e4064..9e2fc6d93 100644 --- a/.github/workflows/publish-ruby.yml +++ b/.github/workflows/publish-ruby.yml @@ -44,7 +44,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Set up Ruby - uses: ruby/setup-ruby@a6e6f86333f0a2523ece813039b8b4be04560854 # v1.190.0 + uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # v1.191.0 with: ruby-version: 3.2 diff --git a/.github/workflows/scan.yml b/.github/workflows/scan.yml index 2df3b61b7..ae4a1913d 100644 --- a/.github/workflows/scan.yml +++ b/.github/workflows/scan.yml @@ -46,7 +46,7 @@ jobs: --output-path . ${{ env.INCREMENTAL }} - name: Upload Checkmarx results to GitHub - uses: github/codeql-action/upload-sarif@2c779ab0d087cd7fe7b826087247c2c81f27bfa6 # v3.26.5 + uses: github/codeql-action/upload-sarif@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6 with: sarif_file: cx_result.sarif From 7ee604f9a01cb6d3c4ea18d7048151ff4ececfbe Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 4 Sep 2024 11:23:22 -0400 Subject: [PATCH 133/214] [deps]: Update sonarsource/sonarcloud-github-action action to v3 (#1012) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scan.yml b/.github/workflows/scan.yml index ae4a1913d..5595316de 100644 --- a/.github/workflows/scan.yml +++ b/.github/workflows/scan.yml @@ -66,7 +66,7 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: Scan with SonarCloud - uses: sonarsource/sonarcloud-github-action@e44258b109568baa0df60ed515909fc6c72cba92 # v2.3.0 + uses: sonarsource/sonarcloud-github-action@eb211723266fe8e83102bac7361f0a05c3ac1d1b # v3.0.0 env: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 80a7d84d2f6fd1679af8d2522e5c33d0f7a901f2 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 5 Sep 2024 12:01:04 +0200 Subject: [PATCH 134/214] Add explicit error about invalid private key (#1020) Add an explicit error about private key being invalid. --- .../bitwarden-core/src/auth/auth_request.rs | 6 +++-- .../src/client/encryption_settings.rs | 22 ++++++++++++++++--- crates/bitwarden-core/src/client/internal.rs | 18 ++++++++------- crates/bitwarden-core/src/error.rs | 7 ++++++ .../src/mobile/client_crypto.rs | 7 ++++-- crates/bitwarden-core/src/mobile/crypto.rs | 7 ++++-- crates/bitwarden-uniffi/src/crypto.rs | 17 ++++++++++---- 7 files changed, 63 insertions(+), 21 deletions(-) diff --git a/crates/bitwarden-core/src/auth/auth_request.rs b/crates/bitwarden-core/src/auth/auth_request.rs index dc9be1b90..1d6ce1802 100644 --- a/crates/bitwarden-core/src/auth/auth_request.rs +++ b/crates/bitwarden-core/src/auth/auth_request.rs @@ -6,6 +6,8 @@ use bitwarden_crypto::{ #[cfg(feature = "internal")] use bitwarden_crypto::{EncString, KeyDecryptable, SymmetricCryptoKey}; +#[cfg(feature = "internal")] +use crate::client::encryption_settings::EncryptionSettingsError; use crate::{error::Error, Client}; #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] @@ -49,7 +51,7 @@ pub(crate) fn new_auth_request(email: &str) -> Result Result { +) -> Result { let key = AsymmetricCryptoKey::from_der(&STANDARD.decode(private_key)?)?; let mut key: Vec = user_key.decrypt_with_key(&key)?; @@ -62,7 +64,7 @@ pub(crate) fn auth_request_decrypt_master_key( private_key: String, master_key: AsymmetricEncString, user_key: EncString, -) -> Result { +) -> Result { use bitwarden_crypto::MasterKey; let key = AsymmetricCryptoKey::from_der(&STANDARD.decode(private_key)?)?; diff --git a/crates/bitwarden-core/src/client/encryption_settings.rs b/crates/bitwarden-core/src/client/encryption_settings.rs index 828a97139..41bd07dcf 100644 --- a/crates/bitwarden-core/src/client/encryption_settings.rs +++ b/crates/bitwarden-core/src/client/encryption_settings.rs @@ -3,11 +3,24 @@ use std::collections::HashMap; use bitwarden_crypto::{AsymmetricCryptoKey, CryptoError, KeyContainer, SymmetricCryptoKey}; #[cfg(feature = "internal")] use bitwarden_crypto::{AsymmetricEncString, EncString, MasterKey}; +use thiserror::Error; use uuid::Uuid; #[cfg(feature = "internal")] use crate::error::Result; +#[derive(Debug, Error)] +pub enum EncryptionSettingsError { + #[error("Cryptography error, {0}")] + Crypto(#[from] bitwarden_crypto::CryptoError), + + #[error(transparent)] + InvalidBase64(#[from] base64::DecodeError), + + #[error("Invalid private key")] + InvalidPrivateKey, +} + #[derive(Clone)] pub struct EncryptionSettings { user_key: SymmetricCryptoKey, @@ -28,7 +41,7 @@ impl EncryptionSettings { master_key: MasterKey, user_key: EncString, private_key: EncString, - ) -> Result { + ) -> Result { // Decrypt the user key let user_key = master_key.decrypt_user_key(user_key)?; Self::new_decrypted_key(user_key, private_key) @@ -42,12 +55,15 @@ impl EncryptionSettings { pub(crate) fn new_decrypted_key( user_key: SymmetricCryptoKey, private_key: EncString, - ) -> Result { + ) -> Result { use bitwarden_crypto::KeyDecryptable; let private_key = { let dec: Vec = private_key.decrypt_with_key(&user_key)?; - Some(AsymmetricCryptoKey::from_der(&dec)?) + Some( + AsymmetricCryptoKey::from_der(&dec) + .map_err(|_| EncryptionSettingsError::InvalidPrivateKey)?, + ) }; Ok(EncryptionSettings { diff --git a/crates/bitwarden-core/src/client/internal.rs b/crates/bitwarden-core/src/client/internal.rs index 199e35459..76951969c 100644 --- a/crates/bitwarden-core/src/client/internal.rs +++ b/crates/bitwarden-core/src/client/internal.rs @@ -9,16 +9,18 @@ use uuid::Uuid; #[cfg(feature = "secrets")] use super::login_method::ServiceAccountLoginMethod; -use super::{encryption_settings::EncryptionSettings, login_method::LoginMethod}; -#[cfg(feature = "internal")] -use super::{flags::Flags, login_method::UserLoginMethod}; -#[cfg(feature = "internal")] -use crate::error::Error; use crate::{ auth::renew::renew_token, + client::{encryption_settings::EncryptionSettings, login_method::LoginMethod}, error::{Result, VaultLocked}, DeviceType, }; +#[cfg(feature = "internal")] +use crate::{ + client::encryption_settings::EncryptionSettingsError, + client::{flags::Flags, login_method::UserLoginMethod}, + error::Error, +}; #[derive(Debug, Clone)] pub struct ApiConfigurations { @@ -179,7 +181,7 @@ impl InternalClient { master_key: MasterKey, user_key: EncString, private_key: EncString, - ) -> Result<()> { + ) -> Result<(), EncryptionSettingsError> { *self .encryption_settings .write() @@ -197,7 +199,7 @@ impl InternalClient { &self, user_key: SymmetricCryptoKey, private_key: EncString, - ) -> Result<()> { + ) -> Result<(), EncryptionSettingsError> { *self .encryption_settings .write() @@ -214,7 +216,7 @@ impl InternalClient { pin_key: PinKey, pin_protected_user_key: EncString, private_key: EncString, - ) -> Result<()> { + ) -> Result<(), EncryptionSettingsError> { let decrypted_user_key = pin_key.decrypt_user_key(pin_protected_user_key)?; self.initialize_user_crypto_decrypted_key(decrypted_user_key, private_key) } diff --git a/crates/bitwarden-core/src/error.rs b/crates/bitwarden-core/src/error.rs index 300aba452..697ca6c99 100644 --- a/crates/bitwarden-core/src/error.rs +++ b/crates/bitwarden-core/src/error.rs @@ -9,6 +9,9 @@ use reqwest::StatusCode; use thiserror::Error; use validator::ValidationErrors; +#[cfg(feature = "internal")] +use crate::client::encryption_settings::EncryptionSettingsError; + #[derive(Debug, Error)] pub enum Error { #[error(transparent)] @@ -56,6 +59,10 @@ pub enum Error { #[error("Internal error: {0}")] Internal(Cow<'static, str>), + + #[cfg(feature = "internal")] + #[error(transparent)] + EncryptionSettings(#[from] EncryptionSettingsError), } impl From for Error { diff --git a/crates/bitwarden-core/src/mobile/client_crypto.rs b/crates/bitwarden-core/src/mobile/client_crypto.rs index 293b8f9b3..4c9a4c6a4 100644 --- a/crates/bitwarden-core/src/mobile/client_crypto.rs +++ b/crates/bitwarden-core/src/mobile/client_crypto.rs @@ -2,7 +2,7 @@ use bitwarden_crypto::{AsymmetricEncString, EncString}; use super::crypto::{derive_key_connector, DeriveKeyConnectorRequest}; -use crate::Client; +use crate::{client::encryption_settings::EncryptionSettingsError, Client}; #[cfg(feature = "internal")] use crate::{ error::Result, @@ -18,7 +18,10 @@ pub struct ClientCrypto<'a> { } impl<'a> ClientCrypto<'a> { - pub async fn initialize_user_crypto(&self, req: InitUserCryptoRequest) -> Result<()> { + pub async fn initialize_user_crypto( + &self, + req: InitUserCryptoRequest, + ) -> Result<(), EncryptionSettingsError> { initialize_user_crypto(self.client, req).await } diff --git a/crates/bitwarden-core/src/mobile/crypto.rs b/crates/bitwarden-core/src/mobile/crypto.rs index 15ddeb9b7..a9fde51df 100644 --- a/crates/bitwarden-core/src/mobile/crypto.rs +++ b/crates/bitwarden-core/src/mobile/crypto.rs @@ -8,7 +8,7 @@ use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::{ - client::{LoginMethod, UserLoginMethod}, + client::{encryption_settings::EncryptionSettingsError, LoginMethod, UserLoginMethod}, error::{Error, Result}, Client, }; @@ -86,7 +86,10 @@ pub enum AuthRequestMethod { }, } -pub async fn initialize_user_crypto(client: &Client, req: InitUserCryptoRequest) -> Result<()> { +pub async fn initialize_user_crypto( + client: &Client, + req: InitUserCryptoRequest, +) -> Result<(), EncryptionSettingsError> { use bitwarden_crypto::{DeviceKey, PinKey}; use crate::auth::{auth_request_decrypt_master_key, auth_request_decrypt_user_key}; diff --git a/crates/bitwarden-uniffi/src/crypto.rs b/crates/bitwarden-uniffi/src/crypto.rs index 8a089404a..37d14c896 100644 --- a/crates/bitwarden-uniffi/src/crypto.rs +++ b/crates/bitwarden-uniffi/src/crypto.rs @@ -1,8 +1,11 @@ use std::sync::Arc; -use bitwarden::mobile::crypto::{ - DeriveKeyConnectorRequest, DerivePinKeyResponse, InitOrgCryptoRequest, InitUserCryptoRequest, - UpdatePasswordResponse, +use bitwarden::{ + mobile::crypto::{ + DeriveKeyConnectorRequest, DerivePinKeyResponse, InitOrgCryptoRequest, + InitUserCryptoRequest, UpdatePasswordResponse, + }, + Error, }; use bitwarden_crypto::{AsymmetricEncString, EncString}; @@ -16,7 +19,13 @@ impl ClientCrypto { /// Initialization method for the user crypto. Needs to be called before any other crypto /// operations. pub async fn initialize_user_crypto(&self, req: InitUserCryptoRequest) -> Result<()> { - Ok(self.0 .0.crypto().initialize_user_crypto(req).await?) + Ok(self + .0 + .0 + .crypto() + .initialize_user_crypto(req) + .await + .map_err(Error::EncryptionSettings)?) } /// Initialization method for the organization crypto. Needs to be called after From 3930d5e50140daadc790a794b2371b11cdee02be Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Thu, 5 Sep 2024 07:08:14 -0400 Subject: [PATCH 135/214] BRE-289 - Fix Publish Python SDK workflow (#1018) --- .github/workflows/publish-python.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-python.yml b/.github/workflows/publish-python.yml index 3a9c08aac..ef30d6598 100644 --- a/.github/workflows/publish-python.yml +++ b/.github/workflows/publish-python.yml @@ -27,7 +27,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Branch check - if: ${{ github.event.inputs.release_type != 'Dry Run' }} + if: ${{ inputs.release_type != 'Dry Run' }} run: | if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then echo "===================================" @@ -50,12 +50,12 @@ jobs: run: pip install twine - name: Download artifacts - uses: bitwarden/gh-actions/download-artifacts@main + uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 # v6 with: workflow: build-python-wheels.yml path: ${{ github.workspace }}/target/wheels/dist workflow_conclusion: success - branch: ${{ github.event.inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} + branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} name: bitwarden_sdk(.*) name_is_regexp: true @@ -83,7 +83,7 @@ jobs: run: twine check dist/* - name: Publish - if: ${{ github.event.inputs.release_type != 'Dry Run' }} + if: ${{ inputs.release_type != 'Dry Run' }} working-directory: ${{ github.workspace }}/target/wheels env: TWINE_USERNAME: __token__ @@ -91,7 +91,7 @@ jobs: run: twine upload --repository pypi dist/* - name: Dry Run - Publish - if: ${{ github.event.inputs.release_type == 'Dry Run' }} + if: ${{ inputs.release_type == 'Dry Run' }} working-directory: ${{ github.workspace }}/target/wheels env: TWINE_USERNAME: __token__ From 4c651b7831c85527f51eb1d57a53117e6b09db88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ch=C4=99ci=C5=84ski?= Date: Thu, 5 Sep 2024 15:25:54 +0200 Subject: [PATCH 136/214] Fix swift release (#1022) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective Fix SWIFT release commit SHA and artifact upload to GitHub release. ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/release-swift.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-swift.yml b/.github/workflows/release-swift.yml index dcae5b5d2..bb64dc944 100644 --- a/.github/workflows/release-swift.yml +++ b/.github/workflows/release-swift.yml @@ -82,7 +82,7 @@ jobs: - name: Set SHA id: set-sha run: | - echo "sha=$(${{ steps.download-artifact.outputs.artifact-build-commit }})" >> $GITHUB_OUTPUT + echo "sha=${{ steps.download-artifact.outputs.artifact-build-commit }}" >> $GITHUB_OUTPUT echo "short_sha=$(echo ${{ steps.download-artifact.outputs.artifact-build-commit }} | cut -c1-7)" >> $GITHUB_OUTPUT - name: Set release name @@ -243,5 +243,5 @@ jobs: draft: false repo: sdk-swift owner: bitwarden - artifacts: "BitwardenFFI-${{ env._PKG_VERSION }}-${{ needs.validate.outputs.short_sha }}.xcframework" + artifacts: "BitwardenFFI-${{ env._PKG_VERSION }}-${{ needs.validate.outputs.short_sha }}.xcframework.zip" prerelease: ${{ inputs.pre-release }} From 3065a03c8703c6c6f6f743a1ef37f3526c2d404d Mon Sep 17 00:00:00 2001 From: Bitwarden DevOps <106330231+bitwarden-devops-bot@users.noreply.github.com> Date: Thu, 5 Sep 2024 09:34:44 -0400 Subject: [PATCH 137/214] Bump version to 1.0.0 (#1023) ## Type of change - [ ] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [X] Other ## Objective Automated go-sdk version bump to 1.0.0 --- languages/go/.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/go/.version b/languages/go/.version index 6da28dde7..afaf360d3 100644 --- a/languages/go/.version +++ b/languages/go/.version @@ -1 +1 @@ -0.1.1 \ No newline at end of file +1.0.0 \ No newline at end of file From 6d4f952b7ab63cd67f3933f1c42bf6acae222890 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 5 Sep 2024 18:47:09 +0200 Subject: [PATCH 138/214] Temporarily disable private key validation (#1024) --- .../src/client/encryption_settings.rs | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/crates/bitwarden-core/src/client/encryption_settings.rs b/crates/bitwarden-core/src/client/encryption_settings.rs index 41bd07dcf..0df1bd90b 100644 --- a/crates/bitwarden-core/src/client/encryption_settings.rs +++ b/crates/bitwarden-core/src/client/encryption_settings.rs @@ -57,13 +57,23 @@ impl EncryptionSettings { private_key: EncString, ) -> Result { use bitwarden_crypto::KeyDecryptable; + use log::warn; let private_key = { let dec: Vec = private_key.decrypt_with_key(&user_key)?; - Some( - AsymmetricCryptoKey::from_der(&dec) - .map_err(|_| EncryptionSettingsError::InvalidPrivateKey)?, - ) + + // FIXME: [PM-11690] - Temporarily ignore invalid private keys until we have a recovery + // process in place. + AsymmetricCryptoKey::from_der(&dec) + .map_err(|_| { + warn!("Invalid private key"); + }) + .ok() + + // Some( + // AsymmetricCryptoKey::from_der(&dec) + // .map_err(|_| EncryptionSettingsError::InvalidPrivateKey)?, + // ) }; Ok(EncryptionSettings { @@ -93,12 +103,17 @@ impl EncryptionSettings { use crate::VaultLocked; - let private_key = self.private_key.as_ref().ok_or(VaultLocked)?; - // Make sure we only keep the keys given in the arguments and not any of the previous // ones, which might be from organizations that the user is no longer a part of anymore self.org_keys.clear(); + // FIXME: [PM-11690] - Early abort to handle private key being corrupt + if org_enc_keys.is_empty() { + return Ok(self); + } + + let private_key = self.private_key.as_ref().ok_or(VaultLocked)?; + // Decrypt the org keys with the private key for (org_id, org_enc_key) in org_enc_keys { let mut dec: Vec = org_enc_key.decrypt_with_key(private_key)?; From 4238faf6ce9cf6608ca43069e6218b31cb7a4551 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Thu, 5 Sep 2024 20:54:59 -0400 Subject: [PATCH 139/214] [SM-1431] Update rustls-platform-verifier (#1017) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1431 ## 📔 Objective Follow-up to: https://github.com/bitwarden/sdk/pull/990 ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- Cargo.lock | 2 -- crates/bitwarden-core/Cargo.toml | 10 ++-------- crates/bitwarden-core/src/client/client.rs | 4 ++-- crates/bitwarden-uniffi/Cargo.toml | 2 +- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 885aad0cb..9becb26f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1999,7 +1999,6 @@ dependencies = [ "hyper", "hyper-util", "rustls", - "rustls-native-certs", "rustls-pki-types", "tokio", "tokio-rustls", @@ -3191,7 +3190,6 @@ dependencies = [ "pin-project-lite", "quinn", "rustls", - "rustls-native-certs", "rustls-pemfile", "rustls-pki-types", "serde", diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml index bb7a9b15e..7059e26c3 100644 --- a/crates/bitwarden-core/Cargo.toml +++ b/crates/bitwarden-core/Cargo.toml @@ -54,19 +54,13 @@ validator = { version = "0.18.1", features = ["derive"] } zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } zxcvbn = { version = ">=3.0.1, <4.0", optional = true } -[target.'cfg(all(not(target_arch="wasm32"), not(windows)))'.dependencies] +[target.'cfg(not(target_arch="wasm32"))'.dependencies] # By default, we use rustls as the TLS stack and rust-platform-verifier to support user-installed root certificates # The only exception is WASM, as it just uses the browsers/node fetch reqwest = { version = ">=0.12.5, <0.13", features = [ "rustls-tls-manual-roots", ], default-features = false } -rustls-platform-verifier = "0.3.3" - -[target.'cfg(windows)'.dependencies] -# We are having issues with rustls-platform-verifier on Windows GitHub runners -reqwest = { version = ">=0.12.5, <0.13", features = [ - "rustls-tls-native-roots", -], default-features = false } +rustls-platform-verifier = "0.3.4" [dev-dependencies] bitwarden-crypto = { workspace = true } diff --git a/crates/bitwarden-core/src/client/client.rs b/crates/bitwarden-core/src/client/client.rs index 5f73fcd8a..b9bf4c516 100644 --- a/crates/bitwarden-core/src/client/client.rs +++ b/crates/bitwarden-core/src/client/client.rs @@ -25,7 +25,7 @@ impl Client { #[allow(unused_mut)] let mut client_builder = reqwest::Client::builder(); - #[cfg(all(not(target_arch = "wasm32"), not(windows)))] + #[cfg(not(target_arch = "wasm32"))] { client_builder = client_builder.use_preconfigured_tls(rustls_platform_verifier::tls_config()); @@ -86,7 +86,7 @@ impl Client { #[cfg(test)] mod tests { - #[cfg(all(not(target_arch = "wasm32"), not(windows)))] + #[cfg(not(target_arch = "wasm32"))] #[test] fn test_reqwest_rustls_platform_verifier_are_compatible() { // rustls-platform-verifier is generating a rustls::ClientConfig, diff --git a/crates/bitwarden-uniffi/Cargo.toml b/crates/bitwarden-uniffi/Cargo.toml index 414948d4d..5737d3559 100644 --- a/crates/bitwarden-uniffi/Cargo.toml +++ b/crates/bitwarden-uniffi/Cargo.toml @@ -44,7 +44,7 @@ android_logger = "0.14" # The use of rustls-platform-verifier requires some extra support to communicate with the Android platform jni = ">=0.19, <0.20" libloading = ">=0.8.1, <0.9" -rustls-platform-verifier = "0.3.3" +rustls-platform-verifier = "0.3.4" [target.'cfg(target_os = "ios")'.dependencies] oslog = "0.2.0" From fdb4308408151defad693bff3253f536baf9da5e Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 6 Sep 2024 10:13:00 +0200 Subject: [PATCH 140/214] Exclude bitwarden-napo from tests (#1025) Napi broke tests for some reason, this seems unrelated to the code changes as I now get the same error on older branches. I believe this is related to the recent runner image update on github. --- .github/workflows/rust-test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust-test.yml b/.github/workflows/rust-test.yml index 514e2a310..8d8b136b2 100644 --- a/.github/workflows/rust-test.yml +++ b/.github/workflows/rust-test.yml @@ -47,7 +47,8 @@ jobs: uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 - name: Test - run: cargo test --all-features + # Termporarily exclude NAPI due to a test error on windows + run: cargo test --workspace --exclude bitwarden-napi --all-features coverage: name: Coverage From 59cee6ee206ff97a58b0102195c0b0a81e6bf67d Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 6 Sep 2024 12:17:19 +0200 Subject: [PATCH 141/214] Add explicit error for no private key (#1026) Follow up to #1024, which improves the error message when missing a private key. --- .../src/client/encryption_settings.rs | 16 ++++++++++++---- crates/bitwarden-core/src/client/internal.rs | 2 +- .../bitwarden-core/src/mobile/client_crypto.rs | 5 ++++- crates/bitwarden-core/src/mobile/crypto.rs | 5 ++++- crates/bitwarden-uniffi/src/crypto.rs | 8 +++++++- crates/bitwarden-vault/src/sync.rs | 5 ++++- 6 files changed, 32 insertions(+), 9 deletions(-) diff --git a/crates/bitwarden-core/src/client/encryption_settings.rs b/crates/bitwarden-core/src/client/encryption_settings.rs index 0df1bd90b..9d9549021 100644 --- a/crates/bitwarden-core/src/client/encryption_settings.rs +++ b/crates/bitwarden-core/src/client/encryption_settings.rs @@ -8,6 +8,7 @@ use uuid::Uuid; #[cfg(feature = "internal")] use crate::error::Result; +use crate::VaultLocked; #[derive(Debug, Error)] pub enum EncryptionSettingsError { @@ -17,8 +18,14 @@ pub enum EncryptionSettingsError { #[error(transparent)] InvalidBase64(#[from] base64::DecodeError), + #[error(transparent)] + VaultLocked(#[from] VaultLocked), + #[error("Invalid private key")] InvalidPrivateKey, + + #[error("Missing private key")] + MissingPrivateKey, } #[derive(Clone)] @@ -98,11 +105,9 @@ impl EncryptionSettings { pub(crate) fn set_org_keys( &mut self, org_enc_keys: Vec<(Uuid, AsymmetricEncString)>, - ) -> Result<&Self> { + ) -> Result<&Self, EncryptionSettingsError> { use bitwarden_crypto::KeyDecryptable; - use crate::VaultLocked; - // Make sure we only keep the keys given in the arguments and not any of the previous // ones, which might be from organizations that the user is no longer a part of anymore self.org_keys.clear(); @@ -112,7 +117,10 @@ impl EncryptionSettings { return Ok(self); } - let private_key = self.private_key.as_ref().ok_or(VaultLocked)?; + let private_key = self + .private_key + .as_ref() + .ok_or(EncryptionSettingsError::MissingPrivateKey)?; // Decrypt the org keys with the private key for (org_id, org_enc_key) in org_enc_keys { diff --git a/crates/bitwarden-core/src/client/internal.rs b/crates/bitwarden-core/src/client/internal.rs index 76951969c..d64ac75be 100644 --- a/crates/bitwarden-core/src/client/internal.rs +++ b/crates/bitwarden-core/src/client/internal.rs @@ -234,7 +234,7 @@ impl InternalClient { pub fn initialize_org_crypto( &self, org_keys: Vec<(Uuid, AsymmetricEncString)>, - ) -> Result> { + ) -> Result, EncryptionSettingsError> { let mut guard = self .encryption_settings .write() diff --git a/crates/bitwarden-core/src/mobile/client_crypto.rs b/crates/bitwarden-core/src/mobile/client_crypto.rs index 4c9a4c6a4..0175f2712 100644 --- a/crates/bitwarden-core/src/mobile/client_crypto.rs +++ b/crates/bitwarden-core/src/mobile/client_crypto.rs @@ -25,7 +25,10 @@ impl<'a> ClientCrypto<'a> { initialize_user_crypto(self.client, req).await } - pub async fn initialize_org_crypto(&self, req: InitOrgCryptoRequest) -> Result<()> { + pub async fn initialize_org_crypto( + &self, + req: InitOrgCryptoRequest, + ) -> Result<(), EncryptionSettingsError> { initialize_org_crypto(self.client, req).await } diff --git a/crates/bitwarden-core/src/mobile/crypto.rs b/crates/bitwarden-core/src/mobile/crypto.rs index a9fde51df..2aae903c5 100644 --- a/crates/bitwarden-core/src/mobile/crypto.rs +++ b/crates/bitwarden-core/src/mobile/crypto.rs @@ -190,7 +190,10 @@ pub struct InitOrgCryptoRequest { pub organization_keys: HashMap, } -pub async fn initialize_org_crypto(client: &Client, req: InitOrgCryptoRequest) -> Result<()> { +pub async fn initialize_org_crypto( + client: &Client, + req: InitOrgCryptoRequest, +) -> Result<(), EncryptionSettingsError> { let organization_keys = req.organization_keys.into_iter().collect(); client.internal.initialize_org_crypto(organization_keys)?; Ok(()) diff --git a/crates/bitwarden-uniffi/src/crypto.rs b/crates/bitwarden-uniffi/src/crypto.rs index 37d14c896..608698fc6 100644 --- a/crates/bitwarden-uniffi/src/crypto.rs +++ b/crates/bitwarden-uniffi/src/crypto.rs @@ -31,7 +31,13 @@ impl ClientCrypto { /// Initialization method for the organization crypto. Needs to be called after /// `initialize_user_crypto` but before any other crypto operations. pub async fn initialize_org_crypto(&self, req: InitOrgCryptoRequest) -> Result<()> { - Ok(self.0 .0.crypto().initialize_org_crypto(req).await?) + Ok(self + .0 + .0 + .crypto() + .initialize_org_crypto(req) + .await + .map_err(Error::EncryptionSettings)?) } /// Get the uses's decrypted encryption key. Note: It's very important diff --git a/crates/bitwarden-vault/src/sync.rs b/crates/bitwarden-vault/src/sync.rs index 6b4845d35..be4c3b169 100644 --- a/crates/bitwarden-vault/src/sync.rs +++ b/crates/bitwarden-vault/src/sync.rs @@ -44,7 +44,10 @@ pub(crate) async fn sync(client: &Client, input: &SyncRequest) -> Result Date: Fri, 6 Sep 2024 15:22:16 +0200 Subject: [PATCH 142/214] Remove screenshot from pull request template (#1027) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective We almost never use the screenshot field, removing it since adding it should be less effort. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/PULL_REQUEST_TEMPLATE.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index a5e6b294d..e43ad29df 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -6,10 +6,6 @@ -## 📸 Screenshots - - - ## ⏰ Reminders before review - Contributor guidelines followed From 625314d05c7337a7b8021937c4a4b17cc12e31c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ch=C4=99ci=C5=84ski?= Date: Fri, 6 Sep 2024 15:26:16 +0200 Subject: [PATCH 143/214] Add workflow_dispatch trigger to build-swift workflow (#1029) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective Add workflow_dispatch trigger to build-swift workflow. ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/build-swift.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-swift.yml b/.github/workflows/build-swift.yml index b37c62811..867f03dda 100644 --- a/.github/workflows/build-swift.yml +++ b/.github/workflows/build-swift.yml @@ -7,6 +7,7 @@ on: - "rc" - "hotfix-rc" - "main" + workflow_dispatch: jobs: version: From 82065b15c3a3cac1913e3394ae0e14b21d538440 Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Fri, 6 Sep 2024 12:57:45 -0700 Subject: [PATCH 144/214] SM-1404 review and update ruby sdk (#998) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1404 ## 📔 Objective Update the Ruby wrapper to use bindings that are consistent. This will be a breaking change, as it does the following: - replaces `access_token_login()` with `auth.login_access_token()` to be more consistent with the newer auth method we use in the base SDK. - Refactors secret and project clients. - `secrets_client` -> `secrets` - `project_client` -> `projects` - reorders the `create()` and `update()` args for secrets and projects, with arguments that are most consistently required between methods (eg. `organization_id`) first. - `secrets_client.create(key, note, organization_id, value, project_ids)` -> `secrets.create(organization_id, key, value, note, project_ids)` - `secrets_client.update(id, key, note, organization_id, value, project_ids)` -> `secrets.create(organization_id, id, key, value, note, project_ids)` - `project_client.create(name, organization_id)` -> `projects.create(organization_id, name)` - `project_client.update(id, name, organization_id)` -> `projects.update(organization_id, id, name)` This change also exposes `secrets.sync()`. Because this change refactored the aforementioned methods, updating the Ruby typedefs (`.rbs` files) was also required. I wrote a script to generate the typedefs using the `rbs` CLI. We have an [internal ticket](https://bitwarden.atlassian.net/browse/SM-1426) to add explicit types to the rbs files in the future. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --------- Co-authored-by: Colton Hurst Co-authored-by: Colton Hurst --- languages/ruby/README.md | 34 +++++++++------- .../ruby/bitwarden_sdk_secrets/lib/auth.rb | 16 ++++++++ .../lib/bitwarden-sdk-secrets.rb | 14 +++---- .../lib/extended_schemas/schemas.rb | 18 ++++++++- .../bitwarden_sdk_secrets/lib/projects.rb | 8 ++-- .../ruby/bitwarden_sdk_secrets/lib/secrets.rb | 22 +++++++++-- .../ruby/bitwarden_sdk_secrets/sig/auth.rbs | 9 +++++ .../sig/bitwarden-sdk-secrets.rbs | 39 +++++++++++++++++++ .../sig/bitwarden-sdk.rbs | 13 ------- .../sig/bitwarden_error.rbs | 5 +++ .../sig/bitwarden_lib.rbs | 7 ++++ .../sig/bitwarden_settings.rbs | 8 ---- .../sig/command_runner.rbs | 14 +++++-- .../bitwarden_sdk_secrets/sig/projects.rbs | 25 ++++++++++++ .../sig/projects_client.rbs | 17 -------- .../ruby/bitwarden_sdk_secrets/sig/sdk.rbs | 3 -- .../bitwarden_sdk_secrets/sig/secrets.rbs | 29 ++++++++++++++ .../sig/secrets_client.rbs | 18 --------- .../bitwarden_sdk_secrets/sig/version.rbs | 3 ++ languages/ruby/examples/example.rb | 32 +++++++++------ languages/ruby/gen_ruby_typedefs.sh | 26 +++++++++++++ 21 files changed, 255 insertions(+), 105 deletions(-) create mode 100644 languages/ruby/bitwarden_sdk_secrets/lib/auth.rb create mode 100644 languages/ruby/bitwarden_sdk_secrets/sig/auth.rbs create mode 100644 languages/ruby/bitwarden_sdk_secrets/sig/bitwarden-sdk-secrets.rbs delete mode 100644 languages/ruby/bitwarden_sdk_secrets/sig/bitwarden-sdk.rbs create mode 100644 languages/ruby/bitwarden_sdk_secrets/sig/bitwarden_error.rbs create mode 100644 languages/ruby/bitwarden_sdk_secrets/sig/bitwarden_lib.rbs delete mode 100644 languages/ruby/bitwarden_sdk_secrets/sig/bitwarden_settings.rbs create mode 100644 languages/ruby/bitwarden_sdk_secrets/sig/projects.rbs delete mode 100644 languages/ruby/bitwarden_sdk_secrets/sig/projects_client.rbs delete mode 100644 languages/ruby/bitwarden_sdk_secrets/sig/sdk.rbs create mode 100644 languages/ruby/bitwarden_sdk_secrets/sig/secrets.rbs delete mode 100644 languages/ruby/bitwarden_sdk_secrets/sig/secrets_client.rbs create mode 100644 languages/ruby/bitwarden_sdk_secrets/sig/version.rbs create mode 100755 languages/ruby/gen_ruby_typedefs.sh diff --git a/languages/ruby/README.md b/languages/ruby/README.md index a02b1b53e..790008b38 100644 --- a/languages/ruby/README.md +++ b/languages/ruby/README.md @@ -9,7 +9,7 @@ Requirements: Ruby >= 3.0 Install gem: `gem install bitwarden-sdk-secrets` -Import it: require 'bitwarden-sdk-secrets' +Import it: `require 'bitwarden-sdk-secrets'` ## Usage @@ -28,7 +28,7 @@ bitwarden_settings = BitwardenSDK::BitwardenSettings.new( # By passing these setting you can initialize BitwardenClient bw_client = BitwardenSDK::BitwardenClient.new(bitwarden_settings) -response = bw_client.access_token_login(token) +response = bw_client.auth.login_access_token(token, state_file) puts response ``` @@ -38,25 +38,25 @@ After successful authorization you can interact with client to manage your proje # CREATE project project_name = 'Test project 1' -response = bw_client.project_client.create_project(project_name, organization_id) +response = bw_client.projects.create(organization_id, project_name) puts response project_id = response['id'] # GET project -response = bw_client.project_client.get(project_id) +response = bw_client.projects.get(project_id) puts response # LIST projects -response = bw_client.project_client.list_projects(organization_id) +response = bw_client.projects.list(organization_id) puts response # UPDATE projects name = 'Updated test project 1' -response = bw_client.project_client.update_project(project_id, name, organization_id) +response = bw_client.projects.update(organization_id, project_id, name) puts response # DELETE project -response = bw_client.project_client.delete_projects([project_id]) +response = bw_client.projects.delete_projects([project_id]) puts response ``` @@ -67,30 +67,38 @@ Similarly, you interact with secrets: key = 'AWS-SES' note = 'Private account' value = '8t27.dfj;' -response = bw_client.secrets_client.create(key, note, organization_id, [project_id], value) +response = bw_client.secrets.create(organization_id, key, value, note, [project_id]) puts response secret_id = response['id'] # GET secret -response = bw_client.secrets_client.get(secret_id) +response = bw_client.secrets.get(secret_id) puts response # GET secret by ids -response = bw_client.secrets_client.get_by_ids([secret_id]) +response = bw_client.secrets.get_by_ids([secret_id]) puts response # LIST secrets -response = bw_client.secrets_client.list(organization_id) +response = bw_client.secrets.list(organization_id) +puts response + +# SYNC secrets +response = bw_client.secrets.sync(organization_id, nil) +last_synced_date = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%S.%6NZ') +puts response + +response = bw_client.secrets.sync(organization_id, last_synced_date) puts response # UPDATE secret note = 'updated password' value = '7I.ert10AjK' -response = bw_client.secrets_client.update(secret_id, key, note,organization_id, [project_id], value) +response = bw_client.secrets.update(organization_id, secret_id, key, value, note, [project_id]) puts response # DELETE secret -response = bw_client.secrets_client.delete_secret([secret_id]) +response = bw_client.secrets.delete([secret_id]) puts response ``` diff --git a/languages/ruby/bitwarden_sdk_secrets/lib/auth.rb b/languages/ruby/bitwarden_sdk_secrets/lib/auth.rb new file mode 100644 index 000000000..481f30257 --- /dev/null +++ b/languages/ruby/bitwarden_sdk_secrets/lib/auth.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true +require_relative 'bitwarden_error' + +module BitwardenSDKSecrets + class AuthClient + def initialize(command_runner) + @command_runner = command_runner + end + + def login_access_token(access_token, state_file = nil) + access_token_request = AccessTokenLoginRequest.new(access_token: access_token, state_file: state_file) + @command_runner.run(SelectiveCommand.new(login_access_token: access_token_request)) + nil + end + end +end diff --git a/languages/ruby/bitwarden_sdk_secrets/lib/bitwarden-sdk-secrets.rb b/languages/ruby/bitwarden_sdk_secrets/lib/bitwarden-sdk-secrets.rb index 15cd115d1..4cd1c2597 100644 --- a/languages/ruby/bitwarden_sdk_secrets/lib/bitwarden-sdk-secrets.rb +++ b/languages/ruby/bitwarden_sdk_secrets/lib/bitwarden-sdk-secrets.rb @@ -10,6 +10,7 @@ require_relative 'bitwarden_error' require_relative 'projects' require_relative 'secrets' +require_relative 'auth' module BitwardenSDKSecrets class BitwardenSettings @@ -26,7 +27,7 @@ def initialize(api_url, identity_url) end class BitwardenClient - attr_reader :bitwarden, :project_client, :secrets_client + attr_reader :bitwarden, :projects, :secrets, :auth def initialize(bitwarden_settings) client_settings = ClientSettings.new( @@ -39,14 +40,9 @@ def initialize(bitwarden_settings) @bitwarden = BitwardenLib @handle = @bitwarden.init(client_settings.to_dynamic.compact.to_json) @command_runner = CommandRunner.new(@bitwarden, @handle) - @project_client = ProjectsClient.new(@command_runner) - @secrets_client = SecretsClient.new(@command_runner) - end - - def access_token_login(access_token, state_file = nil) - access_token_request = AccessTokenLoginRequest.new(access_token: access_token, state_file: state_file) - @command_runner.run(SelectiveCommand.new(access_token_login: access_token_request)) - nil + @projects = ProjectsClient.new(@command_runner) + @secrets = SecretsClient.new(@command_runner) + @auth = AuthClient.new(@command_runner) end def free_mem diff --git a/languages/ruby/bitwarden_sdk_secrets/lib/extended_schemas/schemas.rb b/languages/ruby/bitwarden_sdk_secrets/lib/extended_schemas/schemas.rb index e2352237f..bcdfa5e5f 100644 --- a/languages/ruby/bitwarden_sdk_secrets/lib/extended_schemas/schemas.rb +++ b/languages/ruby/bitwarden_sdk_secrets/lib/extended_schemas/schemas.rb @@ -3,23 +3,25 @@ module BitwardenSDKSecrets class SelectiveCommand < Command attribute :password_login, PasswordLoginRequest.optional.default(nil) attribute :api_key_login, APIKeyLoginRequest.optional.default(nil) - attribute :access_token_login, AccessTokenLoginRequest.optional.default(nil) + attribute :login_access_token, AccessTokenLoginRequest.optional.default(nil) attribute :get_user_api_key, SecretVerificationRequest.optional.default(nil) attribute :fingerprint, FingerprintRequest.optional.default(nil) attribute :sync, SyncRequest.optional.default(nil) attribute :secrets, SecretsCommand.optional.default(nil) attribute :projects, ProjectsCommand.optional.default(nil) + attribute :generators, GeneratorsCommand.optional.default(nil) def to_dynamic { "passwordLogin" => password_login&.to_dynamic, "apiKeyLogin" => api_key_login&.to_dynamic, - "accessTokenLogin" => access_token_login&.to_dynamic, + "loginAccessToken" => login_access_token&.to_dynamic, "getUserApiKey" => get_user_api_key&.to_dynamic, "fingerprint" => fingerprint&.to_dynamic, "sync" => sync&.to_dynamic, "secrets" => secrets&.to_dynamic, "projects" => projects&.to_dynamic, + "generators" => generators&.to_dynamic, }.compact end end @@ -49,6 +51,7 @@ class SelectiveSecretsCommand < SecretsCommand attribute :list, SecretIdentifiersRequest.optional.default(nil) attribute :update, SecretPutRequest.optional.default(nil) attribute :delete, SecretsDeleteRequest.optional.default(nil) + attribute :sync, SecretsSyncRequest.optional.default(nil) def to_dynamic { @@ -58,7 +61,18 @@ def to_dynamic "list" => list&.to_dynamic, "update" => update&.to_dynamic, "delete" => delete&.to_dynamic, + "sync" => sync&.to_dynamic, }.compact end end + + class SelectiveGeneratorsCommand < GeneratorsCommand + attribute :generate_password, PasswordGeneratorRequest.optional.default(nil) + + def to_dynamic + { + "generate_password" => generate_password&.to_dynamic, + }.compact + end + end end diff --git a/languages/ruby/bitwarden_sdk_secrets/lib/projects.rb b/languages/ruby/bitwarden_sdk_secrets/lib/projects.rb index 957a7d31d..bf4e903ca 100644 --- a/languages/ruby/bitwarden_sdk_secrets/lib/projects.rb +++ b/languages/ruby/bitwarden_sdk_secrets/lib/projects.rb @@ -8,7 +8,7 @@ def initialize(command_runner) @command_runner = command_runner end - def create_project(project_name, organization_id) + def create(organization_id, project_name) project_create_request = ProjectCreateRequest.new( project_create_request_name: project_name, organization_id: organization_id @@ -43,7 +43,7 @@ def get(project_id) error_response(projects_response) end - def list_projects(organization_id) + def list(organization_id) project_list_request = ProjectsListRequest.new(organization_id: organization_id) command = create_command(list: project_list_request) response = parse_response(command) @@ -58,7 +58,7 @@ def list_projects(organization_id) error_response(projects_response) end - def update_project(id, project_put_request_name, organization_id) + def update(organization_id, id, project_put_request_name) project_put_request = ProjectPutRequest.new( id: id, project_put_request_name: project_put_request_name, @@ -79,7 +79,7 @@ def update_project(id, project_put_request_name, organization_id) error_response(projects_response) end - def delete_projects(ids) + def delete(ids) project_delete_request = ProjectsDeleteRequest.new(ids: ids) command = create_command(delete: project_delete_request) response = parse_response(command) diff --git a/languages/ruby/bitwarden_sdk_secrets/lib/secrets.rb b/languages/ruby/bitwarden_sdk_secrets/lib/secrets.rb index 709d8f8b1..5dda98830 100644 --- a/languages/ruby/bitwarden_sdk_secrets/lib/secrets.rb +++ b/languages/ruby/bitwarden_sdk_secrets/lib/secrets.rb @@ -36,7 +36,23 @@ def get_by_ids(ids) error_response(secrets_response) end - def create(key, note, organization_id, project_ids, value) + def sync(organization_id, last_synced_date) + command = create_command( + sync: SecretsSyncRequest.new(organization_id: organization_id, last_synced_date: last_synced_date) + ) + response = run_command(command) + + secrets_response = ResponseForSecretsSyncResponse.from_json!(response).to_dynamic + + if secrets_response.key?('success') && secrets_response['success'] == true && + secrets_response.key?('data') + return secrets_response['data'] + end + + error_response(secrets_response) + end + + def create(organization_id, key, value, note, project_ids) command = create_command( create: SecretCreateRequest.new( key: key, note: note, organization_id: organization_id, project_ids: project_ids, value: value @@ -68,7 +84,7 @@ def list(organization_id) error_response(secrets_response) end - def update(id, key, note, organization_id, project_ids, value) + def update(organization_id, id, key, value, note, project_ids) command = create_command( update: SecretPutRequest.new( id: id, key: key, note: note, organization_id: organization_id, project_ids: project_ids, value: value @@ -86,7 +102,7 @@ def update(id, key, note, organization_id, project_ids, value) error_response(secrets_response) end - def delete_secret(ids) + def delete(ids) command = create_command(delete: SecretsDeleteRequest.new(ids: ids)) response = run_command(command) diff --git a/languages/ruby/bitwarden_sdk_secrets/sig/auth.rbs b/languages/ruby/bitwarden_sdk_secrets/sig/auth.rbs new file mode 100644 index 000000000..4e75cf4c4 --- /dev/null +++ b/languages/ruby/bitwarden_sdk_secrets/sig/auth.rbs @@ -0,0 +1,9 @@ +module BitwardenSDKSecrets + class AuthClient + @command_runner: untyped + + def initialize: (untyped command_runner) -> void + + def login_access_token: (untyped access_token, ?untyped? state_file) -> nil + end +end diff --git a/languages/ruby/bitwarden_sdk_secrets/sig/bitwarden-sdk-secrets.rbs b/languages/ruby/bitwarden_sdk_secrets/sig/bitwarden-sdk-secrets.rbs new file mode 100644 index 000000000..ffca59e61 --- /dev/null +++ b/languages/ruby/bitwarden_sdk_secrets/sig/bitwarden-sdk-secrets.rbs @@ -0,0 +1,39 @@ +module BitwardenSDKSecrets + class BitwardenSettings + @api_url: untyped + + @identity_url: untyped + + attr_accessor api_url: untyped + + attr_accessor identity_url: untyped + + def initialize: (untyped api_url, untyped identity_url) -> void + end + + class BitwardenClient + @bitwarden: untyped + + @handle: untyped + + @command_runner: untyped + + @projects: untyped + + @secrets: untyped + + @auth: untyped + + attr_reader bitwarden: untyped + + attr_reader projects: untyped + + attr_reader secrets: untyped + + attr_reader auth: untyped + + def initialize: (untyped bitwarden_settings) -> void + + def free_mem: () -> untyped + end +end diff --git a/languages/ruby/bitwarden_sdk_secrets/sig/bitwarden-sdk.rbs b/languages/ruby/bitwarden_sdk_secrets/sig/bitwarden-sdk.rbs deleted file mode 100644 index 3f6a73f6a..000000000 --- a/languages/ruby/bitwarden_sdk_secrets/sig/bitwarden-sdk.rbs +++ /dev/null @@ -1,13 +0,0 @@ -require_relative '../lib/schemas' - -class BitwardenClient - @command_runner: CommandRunner - - attr_reader bitwarden: Module - attr_reader project_client: ProjectsClient - attr_reader secrets_client: SecretsClient - - def initialize: (BitwardenSettings) -> void - def access_token_login: (String) -> JSON - def free_mem: () -> nil -end diff --git a/languages/ruby/bitwarden_sdk_secrets/sig/bitwarden_error.rbs b/languages/ruby/bitwarden_sdk_secrets/sig/bitwarden_error.rbs new file mode 100644 index 000000000..99c60f48d --- /dev/null +++ b/languages/ruby/bitwarden_sdk_secrets/sig/bitwarden_error.rbs @@ -0,0 +1,5 @@ +module BitwardenSDKSecrets + class BitwardenError < StandardError + def initialize: (?::String message) -> void + end +end diff --git a/languages/ruby/bitwarden_sdk_secrets/sig/bitwarden_lib.rbs b/languages/ruby/bitwarden_sdk_secrets/sig/bitwarden_lib.rbs new file mode 100644 index 000000000..6038fbf03 --- /dev/null +++ b/languages/ruby/bitwarden_sdk_secrets/sig/bitwarden_lib.rbs @@ -0,0 +1,7 @@ +module BitwardenSDKSecrets + module BitwardenLib + extend FFI::Library + + def self.mac_with_intel?: () -> untyped + end +end diff --git a/languages/ruby/bitwarden_sdk_secrets/sig/bitwarden_settings.rbs b/languages/ruby/bitwarden_sdk_secrets/sig/bitwarden_settings.rbs deleted file mode 100644 index 154ee16e5..000000000 --- a/languages/ruby/bitwarden_sdk_secrets/sig/bitwarden_settings.rbs +++ /dev/null @@ -1,8 +0,0 @@ -require_relative '../lib/schemas' - -class BitwardenSettings - attr_accessor api_url: String - attr_accessor identity_url: String - - def initialize: (String, String) -> void -end diff --git a/languages/ruby/bitwarden_sdk_secrets/sig/command_runner.rbs b/languages/ruby/bitwarden_sdk_secrets/sig/command_runner.rbs index 7a7a17dd9..483679076 100644 --- a/languages/ruby/bitwarden_sdk_secrets/sig/command_runner.rbs +++ b/languages/ruby/bitwarden_sdk_secrets/sig/command_runner.rbs @@ -1,4 +1,12 @@ -class CommandRunner - @bitwarden_sdk: Module - def run: -> String +module BitwardenSDKSecrets + class CommandRunner + @bitwarden_sdk: untyped + + @handle: untyped + + def initialize: (untyped bitwarden_sdk, untyped handle) -> void + + # @param [Dry-Struct] cmd + def run: (untyped cmd) -> untyped + end end diff --git a/languages/ruby/bitwarden_sdk_secrets/sig/projects.rbs b/languages/ruby/bitwarden_sdk_secrets/sig/projects.rbs new file mode 100644 index 000000000..e68df3d59 --- /dev/null +++ b/languages/ruby/bitwarden_sdk_secrets/sig/projects.rbs @@ -0,0 +1,25 @@ +module BitwardenSDKSecrets + class ProjectsClient + @command_runner: untyped + + def initialize: (untyped command_runner) -> void + + def create: (untyped organization_id, untyped project_name) -> untyped + + def get: (untyped project_id) -> untyped + + def list: (untyped organization_id) -> untyped + + def update: (untyped organization_id, untyped id, untyped project_put_request_name) -> untyped + + def delete: (untyped ids) -> untyped + + private + + def error_response: (untyped response) -> untyped + + def create_command: (untyped commands) -> untyped + + def parse_response: (untyped command) -> untyped + end +end diff --git a/languages/ruby/bitwarden_sdk_secrets/sig/projects_client.rbs b/languages/ruby/bitwarden_sdk_secrets/sig/projects_client.rbs deleted file mode 100644 index 00c9e578d..000000000 --- a/languages/ruby/bitwarden_sdk_secrets/sig/projects_client.rbs +++ /dev/null @@ -1,17 +0,0 @@ -require_once '../lib/extended_schemas/schemas.rbs' -require_once '../schemas.rbs' - -class ProjectsClient - @command_runner: CommandRunner - def initialize: (command_runner: CommandRunner) -> void - def create_project: (project_name: String, organization_id: String) -> ProjectsResponse - def get: (project_id: String) -> ProjectsResponse - def list_projects: (organization_id: String) -> Array(DatumElement) - def update_project: (id: String, project_put_request_name: String, organization_id: String) -> ProjectsResponse - def delete_projects: (ids: Array[String]) -> Array(ProjectDeleteResponse) - - private - - def create_command: (SelectiveProjectsCommand) -> SelectiveCommand - def parse_response: (ResponseForProjectResponse) -> ResponseForProjectResponse -end diff --git a/languages/ruby/bitwarden_sdk_secrets/sig/sdk.rbs b/languages/ruby/bitwarden_sdk_secrets/sig/sdk.rbs deleted file mode 100644 index 260fa1420..000000000 --- a/languages/ruby/bitwarden_sdk_secrets/sig/sdk.rbs +++ /dev/null @@ -1,3 +0,0 @@ -module BitwardenSDK - VERSION: String -end diff --git a/languages/ruby/bitwarden_sdk_secrets/sig/secrets.rbs b/languages/ruby/bitwarden_sdk_secrets/sig/secrets.rbs new file mode 100644 index 000000000..8590fd82b --- /dev/null +++ b/languages/ruby/bitwarden_sdk_secrets/sig/secrets.rbs @@ -0,0 +1,29 @@ +module BitwardenSDKSecrets + class SecretsClient + @command_runner: untyped + + def initialize: (untyped command_runner) -> void + + def get: (untyped id) -> untyped + + def get_by_ids: (untyped ids) -> untyped + + def sync: (untyped organization_id, untyped last_synced_date) -> untyped + + def create: (untyped organization_id, untyped key, untyped value, untyped note, untyped project_ids) -> untyped + + def list: (untyped organization_id) -> untyped + + def update: (untyped organization_id, untyped id, untyped key, untyped value, untyped note, untyped project_ids) -> untyped + + def delete: (untyped ids) -> untyped + + private + + def error_response: (untyped response) -> (untyped | nil | untyped) + + def create_command: (untyped commands) -> untyped + + def run_command: (untyped command) -> untyped + end +end diff --git a/languages/ruby/bitwarden_sdk_secrets/sig/secrets_client.rbs b/languages/ruby/bitwarden_sdk_secrets/sig/secrets_client.rbs deleted file mode 100644 index ccebcecd8..000000000 --- a/languages/ruby/bitwarden_sdk_secrets/sig/secrets_client.rbs +++ /dev/null @@ -1,18 +0,0 @@ -require_once '../lib/extended_schemas/schemas.rbs' -require_once '../schemas.rbs' - -class SecretsClient - # @command_runner: CommandRunner - def initialize: (command_runner: CommandRunner) -> void - def get: (id: String) -> SecretResponse - def get_by_ids: (ids: Array[String]) -> Array(SecretIdentifierResponse) - def create: (key: String, note: String, organization_id: String, project_ids: Array[String], value: String) -> SecretResponse - def list: (organization_id: String) -> Array(SecretIdentifierResponse) - def update: (id: String, key: String, note: String, organization_id: String, project_ids: Array[String], value: String) -> SecretResponse - def delete_secret: (ids: Array[String]) -> Array(SecretDeleteResponse) - - private - - def create_command: (SelectiveSecretsCommand) -> SelectiveCommand - def parse_response: (SelectiveSecretCommand) -> ResponseForSecretResponse -end diff --git a/languages/ruby/bitwarden_sdk_secrets/sig/version.rbs b/languages/ruby/bitwarden_sdk_secrets/sig/version.rbs new file mode 100644 index 000000000..869b679db --- /dev/null +++ b/languages/ruby/bitwarden_sdk_secrets/sig/version.rbs @@ -0,0 +1,3 @@ +module BitwardenSDKSecrets + VERSION: "0.2.0" +end diff --git a/languages/ruby/examples/example.rb b/languages/ruby/examples/example.rb index 475e52089..29a686708 100644 --- a/languages/ruby/examples/example.rb +++ b/languages/ruby/examples/example.rb @@ -12,58 +12,66 @@ bitwarden_settings = BitwardenSDKSecrets::BitwardenSettings.new(api_url, identity_url) bw_client = BitwardenSDKSecrets::BitwardenClient.new(bitwarden_settings) -response = bw_client.access_token_login(token, state_file) +response = bw_client.auth.login_access_token(token, state_file) puts response # CREATE project project_name = 'Test project 1' -response = bw_client.project_client.create_project(project_name, organization_id) +response = bw_client.projects.create(organization_id, project_name) puts response project_id = response['id'] # GET project -response = bw_client.project_client.get(project_id) +response = bw_client.projects.get(project_id) puts response # LIST projects -response = bw_client.project_client.list_projects(organization_id) +response = bw_client.projects.list(organization_id) puts response # UPDATE projects name = 'Updated test project 1' -response = bw_client.project_client.update_project(project_id, name, organization_id) +response = bw_client.projects.update(organization_id, project_id, name) puts response # CREATE secret key = 'AWS-SES' note = 'Private account' value = '8t27.dfj;' -response = bw_client.secrets_client.create(key, note, organization_id, [project_id], value) +response = bw_client.secrets.create(organization_id, key, value, note, [project_id]) puts response secret_id = response['id'] # GET secret -response = bw_client.secrets_client.get(secret_id) +response = bw_client.secrets.get(secret_id) puts response # GET secret by ids -response = bw_client.secrets_client.get_by_ids([secret_id]) +response = bw_client.secrets.get_by_ids([secret_id]) puts response # LIST secrets -response = bw_client.secrets_client.list(organization_id) +response = bw_client.secrets.list(organization_id) +puts response + +# SYNC secrets +response = bw_client.secrets.sync(organization_id, nil) +last_synced_date = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%S.%6NZ') +puts response + +response = bw_client.secrets.sync(organization_id, last_synced_date) puts response # UPDATE secret note = 'updated password' value = '7I.ert10AjK' -response = bw_client.secrets_client.update(secret_id, key, note,organization_id, [project_id], value) +response = bw_client.secrets.update(organization_id, secret_id, key, value, note, [project_id]) puts response # DELETE secret -response = bw_client.secrets_client.delete_secret([secret_id]) +response = bw_client.secrets.delete([secret_id]) puts response # DELETE project -response = bw_client.project_client.delete_projects([project_id]) +response = bw_client.projects.delete([project_id]) puts response diff --git a/languages/ruby/gen_ruby_typedefs.sh b/languages/ruby/gen_ruby_typedefs.sh new file mode 100755 index 000000000..acd2bcc3c --- /dev/null +++ b/languages/ruby/gen_ruby_typedefs.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# shellcheck disable=SC3044,SC3020 + +# bail if rbs is not installed +if ! command -v rbs &>/dev/null; then + echo "rbs could not be found" + exit +fi + +# use consistent repository root to avoid relative paths +REPO_ROOT="$(git rev-parse --show-toplevel)" +pushd "$REPO_ROOT"/languages/ruby || exit + +# delete existing typedefs +rm -rf bitwarden_sdk_secrets/sig/* +mkdir -p bitwarden_sdk_secrets/sig + +# generate typedefs +RUBY_LIB_FILES="$(find bitwarden_sdk_secrets/lib -name "*.rb")" + +for file in $RUBY_LIB_FILES; do + rbs prototype rb "$file" >bitwarden_sdk_secrets/sig/"$(basename "$file" .rb).rbs" + rm -f bitwarden_sdk_secrets/sig/schemas.rbs +done + +popd || exit From 3f376b53ec66a9f53aaa01bb61672c68ae36d461 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 9 Sep 2024 10:53:54 +0200 Subject: [PATCH 145/214] Tweak secrets manager export of password generator (#1021) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective - Change generators export to not live under `secrets_manager` namespace. - Since we now provide a `client_generators` we can stop exporting the generators. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .../bitwarden-generators/src/client_generator.rs | 5 +++-- crates/bitwarden-generators/src/lib.rs | 16 ++++++++-------- crates/bitwarden-generators/src/passphrase.rs | 2 +- crates/bitwarden-generators/src/password.rs | 2 +- crates/bitwarden-generators/src/username.rs | 2 +- crates/bitwarden-json/src/client.rs | 9 +++++---- crates/bitwarden-json/src/command.rs | 2 +- crates/bitwarden/CHANGELOG.md | 1 + crates/bitwarden/src/lib.rs | 12 ++++++------ 9 files changed, 27 insertions(+), 24 deletions(-) diff --git a/crates/bitwarden-generators/src/client_generator.rs b/crates/bitwarden-generators/src/client_generator.rs index e5bad6f29..d2e2b7483 100644 --- a/crates/bitwarden-generators/src/client_generator.rs +++ b/crates/bitwarden-generators/src/client_generator.rs @@ -1,8 +1,9 @@ use bitwarden_core::Client; use crate::{ - passphrase, password, username, PassphraseError, PassphraseGeneratorRequest, PasswordError, - PasswordGeneratorRequest, UsernameError, UsernameGeneratorRequest, + passphrase::passphrase, password::password, username::username, PassphraseError, + PassphraseGeneratorRequest, PasswordError, PasswordGeneratorRequest, UsernameError, + UsernameGeneratorRequest, }; pub struct ClientGenerator<'a> { diff --git a/crates/bitwarden-generators/src/lib.rs b/crates/bitwarden-generators/src/lib.rs index 0ebd20295..6455a759a 100644 --- a/crates/bitwarden-generators/src/lib.rs +++ b/crates/bitwarden-generators/src/lib.rs @@ -1,13 +1,13 @@ -mod passphrase; -pub use passphrase::{passphrase, PassphraseError, PassphraseGeneratorRequest}; -mod password; -mod util; -pub use password::{password, PasswordError, PasswordGeneratorRequest}; -mod username; -pub use username::{username, ForwarderServiceType, UsernameError, UsernameGeneratorRequest}; mod client_generator; -pub use client_generator::{ClientGenerator, ClientGeneratorExt}; mod username_forwarders; +pub use client_generator::{ClientGenerator, ClientGeneratorExt}; +pub(crate) mod passphrase; +pub use passphrase::{PassphraseError, PassphraseGeneratorRequest}; +pub(crate) mod password; +pub use password::{PasswordError, PasswordGeneratorRequest}; +pub(crate) mod username; +pub use username::{ForwarderServiceType, UsernameError, UsernameGeneratorRequest}; +mod util; #[cfg(feature = "uniffi")] uniffi::setup_scaffolding!(); diff --git a/crates/bitwarden-generators/src/passphrase.rs b/crates/bitwarden-generators/src/passphrase.rs index 94b2c0acd..1fb83422e 100644 --- a/crates/bitwarden-generators/src/passphrase.rs +++ b/crates/bitwarden-generators/src/passphrase.rs @@ -77,7 +77,7 @@ impl PassphraseGeneratorRequest { } /// Implementation of the random passphrase generator. -pub fn passphrase(request: PassphraseGeneratorRequest) -> Result { +pub(crate) fn passphrase(request: PassphraseGeneratorRequest) -> Result { let options = request.validate_options()?; Ok(passphrase_with_rng(rand::thread_rng(), options)) } diff --git a/crates/bitwarden-generators/src/password.rs b/crates/bitwarden-generators/src/password.rs index 6121c7597..9821f8bbe 100644 --- a/crates/bitwarden-generators/src/password.rs +++ b/crates/bitwarden-generators/src/password.rs @@ -219,7 +219,7 @@ impl PasswordGeneratorRequest { } /// Implementation of the random password generator. -pub fn password(input: PasswordGeneratorRequest) -> Result { +pub(crate) fn password(input: PasswordGeneratorRequest) -> Result { let options = input.validate_options()?; Ok(password_with_rng(rand::thread_rng(), options)) } diff --git a/crates/bitwarden-generators/src/username.rs b/crates/bitwarden-generators/src/username.rs index 830cb5b04..0140f77fb 100644 --- a/crates/bitwarden-generators/src/username.rs +++ b/crates/bitwarden-generators/src/username.rs @@ -131,7 +131,7 @@ impl ForwarderServiceType { /// /// Note: The HTTP client is passed in as a required parameter for convenience, /// as some username generators require making API calls. -pub async fn username( +pub(crate) async fn username( input: UsernameGeneratorRequest, http: &reqwest::Client, ) -> Result { diff --git a/crates/bitwarden-json/src/client.rs b/crates/bitwarden-json/src/client.rs index 50e46f6ce..dc84c559d 100644 --- a/crates/bitwarden-json/src/client.rs +++ b/crates/bitwarden-json/src/client.rs @@ -1,10 +1,11 @@ -#[cfg(feature = "secrets")] -use bitwarden::secrets_manager::{ - generators::ClientGeneratorExt, ClientProjectsExt, ClientSecretsExt, -}; #[cfg(feature = "internal")] use bitwarden::vault::ClientVaultExt; use bitwarden::ClientSettings; +#[cfg(feature = "secrets")] +use bitwarden::{ + generators::ClientGeneratorExt, + secrets_manager::{ClientProjectsExt, ClientSecretsExt}, +}; #[cfg(feature = "secrets")] use crate::command::{GeneratorsCommand, ProjectsCommand, SecretsCommand}; diff --git a/crates/bitwarden-json/src/command.rs b/crates/bitwarden-json/src/command.rs index 29dc79538..7483b90cf 100644 --- a/crates/bitwarden-json/src/command.rs +++ b/crates/bitwarden-json/src/command.rs @@ -1,8 +1,8 @@ #[cfg(feature = "secrets")] use bitwarden::{ auth::login::AccessTokenLoginRequest, + generators::PasswordGeneratorRequest, secrets_manager::{ - generators::PasswordGeneratorRequest, projects::{ ProjectCreateRequest, ProjectGetRequest, ProjectPutRequest, ProjectsDeleteRequest, ProjectsListRequest, diff --git a/crates/bitwarden/CHANGELOG.md b/crates/bitwarden/CHANGELOG.md index 689b58e72..5d3eefa95 100644 --- a/crates/bitwarden/CHANGELOG.md +++ b/crates/bitwarden/CHANGELOG.md @@ -10,6 +10,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Added - Support for secrets sync (#678) +- Password generator (#986) ### Changed diff --git a/crates/bitwarden/src/lib.rs b/crates/bitwarden/src/lib.rs index b8d8a0bda..c87693ce7 100644 --- a/crates/bitwarden/src/lib.rs +++ b/crates/bitwarden/src/lib.rs @@ -87,13 +87,13 @@ pub mod internal { #[cfg(feature = "internal")] pub use internal::*; +// Re-export generators used for secrets-manager, internal flag already exports all generators +#[cfg(all(feature = "secrets", not(feature = "internal")))] +pub mod generators { + pub use bitwarden_generators::{ClientGeneratorExt, PasswordError, PasswordGeneratorRequest}; +} + #[cfg(feature = "secrets")] pub mod secrets_manager { pub use bitwarden_sm::*; - - pub mod generators { - pub use bitwarden_generators::{ - password, ClientGeneratorExt, PasswordError, PasswordGeneratorRequest, - }; - } } From 05b2620893e6dee8af1b1a96909420f951c5ec31 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 14:09:27 +0200 Subject: [PATCH 146/214] [deps]: Lock file maintenance (#1030) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. đŸ‘ģ **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 132 +++++++++++----------- languages/js/sdk-client/package-lock.json | 12 +- package-lock.json | 44 ++++---- 3 files changed, 91 insertions(+), 97 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9becb26f1..e9c74e8a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -142,9 +142,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" +checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8" [[package]] name = "arc-swap" @@ -231,9 +231,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" dependencies = [ "proc-macro2", "quote", @@ -273,12 +273,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - [[package]] name = "base64" version = "0.22.1" @@ -431,7 +425,7 @@ dependencies = [ name = "bitwarden-core" version = "0.5.0" dependencies = [ - "base64 0.22.1", + "base64", "bitwarden-api-api", "bitwarden-api-identity", "bitwarden-crypto", @@ -466,7 +460,7 @@ version = "0.5.0" dependencies = [ "aes", "argon2", - "base64 0.22.1", + "base64", "cbc", "criterion", "generic-array", @@ -495,7 +489,7 @@ dependencies = [ name = "bitwarden-exporters" version = "0.5.0" dependencies = [ - "base64 0.22.1", + "base64", "bitwarden-core", "bitwarden-crypto", "bitwarden-vault", @@ -514,7 +508,7 @@ name = "bitwarden-fido" version = "0.5.0" dependencies = [ "async-trait", - "base64 0.22.1", + "base64", "bitwarden-core", "bitwarden-crypto", "bitwarden-vault", @@ -589,7 +583,7 @@ dependencies = [ name = "bitwarden-send" version = "0.5.0" dependencies = [ - "base64 0.22.1", + "base64", "bitwarden-api-api", "bitwarden-core", "bitwarden-crypto", @@ -651,7 +645,7 @@ dependencies = [ name = "bitwarden-vault" version = "0.5.0" dependencies = [ - "base64 0.22.1", + "base64", "bitwarden-api-api", "bitwarden-core", "bitwarden-crypto", @@ -779,9 +773,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "773d90827bc3feecfb67fab12e24de0749aad83c74b9504ecde46237b5cd24e2" +checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" [[package]] name = "byteorder" @@ -850,9 +844,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.15" +version = "1.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" +checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" dependencies = [ "shlex", ] @@ -924,9 +918,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.16" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed6719fffa43d0d87e5fd8caeab59be1554fb028cd30edc88fc4369b17971019" +checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" dependencies = [ "clap_builder", "clap_derive", @@ -934,9 +928,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.15" +version = "4.5.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "216aec2b177652e3846684cbfe25c9964d18ec45234f0f5da5157b207ed1aab6" +checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" dependencies = [ "anstream", "anstyle", @@ -946,9 +940,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.24" +version = "4.5.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d7db6eca8c205649e8d3ccd05aa5042b1800a784e56bc7c43524fde8abbfa9b" +checksum = "205d5ef6d485fa47606b98b0ddc4ead26eb850aaa86abfb562a94fb3280ecba0" dependencies = [ "clap", ] @@ -1134,9 +1128,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.13" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" +checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" dependencies = [ "libc", ] @@ -1784,9 +1778,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" +checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" dependencies = [ "aho-corasick", "bstr", @@ -1990,9 +1984,9 @@ dependencies = [ [[package]] name = "hyper-rustls" -version = "0.27.2" +version = "0.27.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http", @@ -2127,9 +2121,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" [[package]] name = "is-terminal" @@ -2821,7 +2815,7 @@ version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" dependencies = [ - "base64 0.22.1", + "base64", "indexmap 2.5.0", "quick-xml", "serde", @@ -2830,9 +2824,9 @@ dependencies = [ [[package]] name = "plotters" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" dependencies = [ "num-traits", "plotters-backend", @@ -2843,15 +2837,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" [[package]] name = "plotters-svg" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" dependencies = [ "plotters-backend", ] @@ -3009,9 +3003,9 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.3" +version = "0.11.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b22d8e7369034b9a7132bc2008cac12f2013c8132b45e0554e6e20e2617f2156" +checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" dependencies = [ "bytes", "pin-project-lite", @@ -3027,9 +3021,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.6" +version = "0.11.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba92fb39ec7ad06ca2582c0ca834dfeadcaf06ddfc8e635c80aa7e1c05315fdd" +checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" dependencies = [ "bytes", "rand", @@ -3044,15 +3038,15 @@ dependencies = [ [[package]] name = "quinn-udp" -version = "0.5.4" +version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285" +checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" dependencies = [ "libc", "once_cell", "socket2", "tracing", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3169,7 +3163,7 @@ version = "0.12.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" dependencies = [ - "base64 0.22.1", + "base64", "bytes", "futures-core", "futures-util", @@ -3280,9 +3274,9 @@ checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustix" -version = "0.38.35" +version = "0.38.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" +checksum = "3f55e80d50763938498dd5ebb18647174e0c76dc38c5505294bb224624f30f36" dependencies = [ "bitflags 2.6.0", "errno", @@ -3324,7 +3318,7 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" dependencies = [ - "base64 0.22.1", + "base64", "rustls-pki-types", ] @@ -3395,11 +3389,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3524,18 +3518,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.209" +version = "1.0.210" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", @@ -3555,9 +3549,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.127" +version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8043c06d9f82bd7271361ed64f415fe5e12a77fdb52e573e7f06a516dea329ad" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ "indexmap 2.5.0", "itoa", @@ -3615,7 +3609,7 @@ version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" dependencies = [ - "base64 0.22.1", + "base64", "chrono", "hex", "indexmap 1.9.3", @@ -3859,9 +3853,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "supports-color" -version = "3.0.0" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9829b314621dfc575df4e409e79f9d6a66a3bd707ab73f23cb4aa3a854ac854f" +checksum = "8775305acf21c96926c900ad056abeef436701108518cf890020387236ac5a77" dependencies = [ "is_ci", ] @@ -4070,9 +4064,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -4867,13 +4861,13 @@ checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" [[package]] name = "wiremock" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a59f8ae78a4737fb724f20106fb35ccb7cfe61ff335665d3042b3aa98e34717" +checksum = "7fff469918e7ca034884c7fd8f93fe27bacb7fcb599fd879df6c7b429a29b646" dependencies = [ "assert-json-diff", "async-trait", - "base64 0.21.7", + "base64", "deadpool", "futures", "http", diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index eb2b74671..7a9fe313a 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -41,9 +41,9 @@ } }, "node_modules/@types/node": { - "version": "20.16.3", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.3.tgz", - "integrity": "sha512-/wdGiWRkMOm53gAsSyFMXFZHbVg7C6CbkrzHNpaHoYfsUWPg7m6ZRKtvQjgvQ9i8WT540a3ydRlRQbxjY30XxQ==", + "version": "20.16.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.5.tgz", + "integrity": "sha512-VwYCweNo3ERajwy0IUlqqcyZ8/A7Zwa9ZP3MnENWcB11AejO+tLy3pu850goUW2FC/IJMdZUfKpX/yxL1gymCA==", "dev": true, "license": "MIT", "dependencies": { @@ -220,9 +220,9 @@ } }, "node_modules/lru-cache": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.0.tgz", - "integrity": "sha512-Qv32eSV1RSCfhY3fpPE2GNZ8jgM9X7rdAfemLWqTUxwiyIC4jJ6Sy0fZ8H+oLWevO6i4/bizg7c8d8i6bxrzbA==", + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.1.tgz", + "integrity": "sha512-CgeuL5uom6j/ZVrg7G/+1IXqRY8JXX4Hghfy5YE0EhoYQWvndP1kufu58cmZLNIDKnRhZrXfdS9urVWx98AipQ==", "dev": true, "license": "ISC", "engines": { diff --git a/package-lock.json b/package-lock.json index bb89e32d2..08ad37f65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -370,9 +370,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.5.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.2.tgz", - "integrity": "sha512-acJsPTEqYqulZS/Yp/S3GgeE6GZ0qYODUR8aVr/DkhHQ8l9nd4j5x1/ZJy9/gHrRlFMqkO6i0I3E27Alu4jjPg==", + "version": "22.5.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.4.tgz", + "integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==", "dev": true, "license": "MIT", "peer": true, @@ -407,9 +407,9 @@ } }, "node_modules/acorn-walk": { - "version": "8.3.3", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz", - "integrity": "sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==", + "version": "8.3.4", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", + "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", "dev": true, "license": "MIT", "dependencies": { @@ -876,13 +876,13 @@ } }, "node_modules/debug": { - "version": "4.3.6", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz", - "integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==", + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", "dev": true, "license": "MIT", "dependencies": { - "ms": "2.1.2" + "ms": "^2.1.3" }, "engines": { "node": ">=6.0" @@ -1029,9 +1029,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", - "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", "dev": true, "funding": [ { @@ -1402,9 +1402,9 @@ } }, "node_modules/lru-cache": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.0.tgz", - "integrity": "sha512-Qv32eSV1RSCfhY3fpPE2GNZ8jgM9X7rdAfemLWqTUxwiyIC4jJ6Sy0fZ8H+oLWevO6i4/bizg7c8d8i6bxrzbA==", + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.1.tgz", + "integrity": "sha512-CgeuL5uom6j/ZVrg7G/+1IXqRY8JXX4Hghfy5YE0EhoYQWvndP1kufu58cmZLNIDKnRhZrXfdS9urVWx98AipQ==", "dev": true, "license": "ISC", "engines": { @@ -1485,9 +1485,9 @@ } }, "node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true, "license": "MIT" }, @@ -2370,9 +2370,9 @@ } }, "node_modules/yaml": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz", - "integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.1.tgz", + "integrity": "sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==", "dev": true, "license": "ISC", "bin": { From c0859c4e256460896dff2dfe7572328fb39831c5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 23:51:45 +0200 Subject: [PATCH 147/214] [deps]: Update rust Docker tag to v1.81 (#948) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | rust | stage | minor | `1.76` -> `1.81` | | rust | final | minor | `1.76` -> `1.81` | --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- crates/bws/Dockerfile | 2 +- crates/memory-testing/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bws/Dockerfile b/crates/bws/Dockerfile index 1f3542e52..07f9f3a79 100644 --- a/crates/bws/Dockerfile +++ b/crates/bws/Dockerfile @@ -1,7 +1,7 @@ ############################################### # Build stage # ############################################### -FROM --platform=$BUILDPLATFORM rust:1.76 AS build +FROM --platform=$BUILDPLATFORM rust:1.81 AS build # Docker buildx supplies the value for this arg ARG TARGETPLATFORM diff --git a/crates/memory-testing/Dockerfile b/crates/memory-testing/Dockerfile index 3804f59e0..3df22466d 100644 --- a/crates/memory-testing/Dockerfile +++ b/crates/memory-testing/Dockerfile @@ -1,7 +1,7 @@ ############################################### # Build stage # ############################################### -FROM rust:1.76 AS build +FROM rust:1.81 AS build WORKDIR /app From c04b9a0e950fc79bd14464156030a169f0db14ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ch=C4=99ci=C5=84ski?= Date: Tue, 10 Sep 2024 16:04:36 +0200 Subject: [PATCH 148/214] [BRE-296] Fix release-swift workflow (#1035) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/BRE-296 ## 📔 Objective Fix `release-swift.yml` workflow ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/build-swift.yml | 7 +++++++ .github/workflows/release-swift.yml | 22 +++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-swift.yml b/.github/workflows/build-swift.yml index 867f03dda..4192662bf 100644 --- a/.github/workflows/build-swift.yml +++ b/.github/workflows/build-swift.yml @@ -68,6 +68,13 @@ jobs: path: languages/swift/BitwardenFFI.xcframework if-no-files-found: error + - name: Upload BitwardenSdk sources + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + name: BitwardenSdk-${{ env._VERSION }}-${{ steps.build.outputs.short-sha }}-sources + path: languages/swift/Sources/BitwardenSdk + if-no-files-found: error + trigger-swift-release: name: Trigger Swift release if: github.ref == 'refs/heads/main' diff --git a/.github/workflows/release-swift.yml b/.github/workflows/release-swift.yml index bb64dc944..a9ab213a6 100644 --- a/.github/workflows/release-swift.yml +++ b/.github/workflows/release-swift.yml @@ -63,7 +63,7 @@ jobs: -H "Accept: application/vnd.github+json" \ -H "X-GitHub-Api-Version: 2022-11-28" \ /repos/$OWNER/$REPO/actions/workflows/build-swift.yml/runs \ - | jq -r ".workflow_runs[] | select(.head_branch == \"$BRANCH\") | .id") + | jq -r "[.workflow_runs[] | select(.head_branch == \"$BRANCH\").id ] | first") else RUN_ID=${{ inputs.build-run-id }} fi @@ -111,6 +111,7 @@ jobs: _PRE_RELEASE: ${{ inputs.pre-release }} _RELEASE_NAME: ${{ needs.validate.outputs.release_name }} _SWIFT_CHECKSUM: ${{ needs.validate.outputs.swift_checksum }} + _BUILD_RUN_ID: ${{ needs.validate.outputs.run_id }} steps: - name: Checkout SDK repo uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 @@ -163,6 +164,16 @@ jobs: git config --local user.email "${{ env._BOT_EMAIL }}" git config --local user.name "${{ env._BOT_NAME }}" + - name: Download BitwardenSdk sources artifact + uses: bitwarden/gh-actions/download-artifacts@main + id: download-artifact + with: + workflow: build-swift.yml + workflow_conclusion: success + artifacts: "BitwardenSdk-${{ env._PKG_VERSION }}-${{ needs.validate.outputs.short_sha }}-sources" + run_id: ${{ env._BUILD_RUN_ID }} + path: sdk/languages/swift/Sources/BitwardenSdk + - name: Install Swift formatter run: | git clone https://github.com/nicklockwood/SwiftFormat @@ -181,11 +192,16 @@ jobs: # Run swiftformat swiftformat sdk/languages/swift/Package.swift + find sdk/languages/swift/Sources/ -name ".gitignore" -exec rm -f {} \; + + rm -rf sdk-swift/Sources + rm -rf sdk-swift/Tests + # Copy files to local sdk-swift repo path cp --verbose -rf sdk/languages/swift/README.md sdk-swift/README.md cp --verbose -rf sdk/languages/swift/Package.swift sdk-swift/Package.swift - cp --verbose -rf sdk/languages/swift/Sources sdk-swift/Sources - cp --verbose -rf sdk/languages/swift/Tests sdk-swift/Tests + cp --verbose -rf sdk/languages/swift/Sources sdk-swift + cp --verbose -rf sdk/languages/swift/Tests sdk-swift - name: Push changes working-directory: sdk-swift From b00d33767a9a14c2093875f9d2c6afb79e6b4316 Mon Sep 17 00:00:00 2001 From: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com> Date: Thu, 12 Sep 2024 13:53:49 -0500 Subject: [PATCH 149/214] [SM-1384] Fix panic on re-registering logger | WASM (#935) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1384 ## 📔 Objective When creating multiple WASM clients, a panic occurs `failed to initialize logger: SetLoggerError())`. Looks to be the same thing we fixed: https://github.com/bitwarden/sdk/pull/181 https://github.com/bitwarden/sdk/pull/676 ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-wasm/src/client.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/bitwarden-wasm/src/client.rs b/crates/bitwarden-wasm/src/client.rs index bca8c2383..e130705c1 100644 --- a/crates/bitwarden-wasm/src/client.rs +++ b/crates/bitwarden-wasm/src/client.rs @@ -4,7 +4,7 @@ use std::rc::Rc; use argon2::{Algorithm, Argon2, Params, Version}; use bitwarden_json::client::Client as JsonClient; use js_sys::Promise; -use log::Level; +use log::{set_max_level, Level}; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::future_to_promise; @@ -37,10 +37,9 @@ impl BitwardenClient { #[wasm_bindgen(constructor)] pub fn new(settings_input: Option, log_level: Option) -> Self { console_error_panic_hook::set_once(); - if let Err(e) = - console_log::init_with_level(convert_level(log_level.unwrap_or(LogLevel::Info))) - { - panic!("failed to initialize logger: {:?}", e); + let log_level = convert_level(log_level.unwrap_or(LogLevel::Info)); + if let Err(_e) = console_log::init_with_level(log_level) { + set_max_level(log_level.to_level_filter()) } Self(Rc::new(bitwarden_json::client::Client::new(settings_input))) From bb1f5a6e9e32f3a80cd2b70737f6199ed4661a63 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:39:28 +0200 Subject: [PATCH 150/214] [deps]: Lock file maintenance (#1051) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. đŸ‘ģ **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 72 +++++++++++------------ languages/js/sdk-client/package-lock.json | 12 ++-- package-lock.json | 12 ++-- 3 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e9c74e8a6..57aa79565 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -142,9 +142,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.87" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" [[package]] name = "arc-swap" @@ -844,9 +844,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.18" +version = "1.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b62ac837cdb5cb22e10a256099b4fc502b1dfe560cb282963a974d7abd80e476" +checksum = "2d74707dde2ba56f86ae90effb3b43ddd369504387e718014de010cec7959800" dependencies = [ "shlex", ] @@ -2001,9 +2001,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.7" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde7055719c54e36e95e8719f95883f22072a48ede39db7fc17a4e1d5281e9b9" +checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" dependencies = [ "bytes", "futures-channel", @@ -2367,9 +2367,9 @@ dependencies = [ [[package]] name = "napi" -version = "2.16.9" +version = "2.16.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1277600d452e570cc83cf5f4e8efb389cc21e5cbefadcfba7239f4551e2e3e99" +checksum = "04409e8c2d61995696e44d2181b79b68c1dd41f7e24a17cde60bbd9f54ddddef" dependencies = [ "bitflags 2.6.0", "ctor", @@ -2387,9 +2387,9 @@ checksum = "e1c0f5d67ee408a4685b61f5ab7e58605c8ae3f2b4189f0127d804ff13d5560a" [[package]] name = "napi-derive" -version = "2.16.11" +version = "2.16.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "150d87c4440b9f4815cb454918db498b5aae9a57aa743d20783fe75381181d01" +checksum = "17435f7a00bfdab20b0c27d9c56f58f6499e418252253081bfff448099da31d1" dependencies = [ "cfg-if", "convert_case", @@ -2401,9 +2401,9 @@ dependencies = [ [[package]] name = "napi-derive-backend" -version = "1.0.73" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cd81b794fc1d6051acf8c4f3cb4f82833b0621272a232b4ff0cf3df1dbddb61" +checksum = "967c485e00f0bf3b1bdbe510a38a4606919cf1d34d9a37ad41f25a81aa077abe" dependencies = [ "convert_case", "once_cell", @@ -2535,9 +2535,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe" [[package]] name = "onig" @@ -2920,9 +2920,9 @@ source = "git+https://github.com/bitwarden/passkey-rs?rev=ae08e2cb7dd3d44d915cae [[package]] name = "pyo3" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "831e8e819a138c36e212f3af3fd9eeffed6bf1510a805af35b0edee5ffa59433" +checksum = "15ee168e30649f7f234c3d49ef5a7a6cbf5134289bc46c29ff3155fa3221c225" dependencies = [ "cfg-if", "indoc", @@ -2938,9 +2938,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e8730e591b14492a8945cdff32f089250b05f5accecf74aeddf9e8272ce1fa8" +checksum = "e61cef80755fe9e46bb8a0b8f20752ca7676dcc07a5277d8b7768c6172e529b3" dependencies = [ "once_cell", "target-lexicon", @@ -2948,9 +2948,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e97e919d2df92eb88ca80a037969f44e5e70356559654962cbb3316d00300c6" +checksum = "67ce096073ec5405f5ee2b8b31f03a68e02aa10d5d4f565eca04acc41931fa1c" dependencies = [ "libc", "pyo3-build-config", @@ -2969,9 +2969,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb57983022ad41f9e683a599f2fd13c3664d7063a3ac5714cae4b7bee7d3f206" +checksum = "2440c6d12bc8f3ae39f1e775266fa5122fd0c8891ce7520fa6048e683ad3de28" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -2981,9 +2981,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.22.2" +version = "0.22.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec480c0c51ddec81019531705acac51bcdbeae563557c982aa8263bb96880372" +checksum = "1be962f0e06da8f8465729ea2cb71a416d2257dff56cbe40a70d3e62a93ae5d1" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -3110,9 +3110,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" dependencies = [ "bitflags 2.6.0", ] @@ -3274,9 +3274,9 @@ checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" [[package]] name = "rustix" -version = "0.38.36" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f55e80d50763938498dd5ebb18647174e0c76dc38c5505294bb224624f30f36" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags 2.6.0", "errno", @@ -3287,9 +3287,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.12" +version = "0.23.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044" +checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" dependencies = [ "once_cell", "ring", @@ -3357,9 +3357,9 @@ checksum = "f87165f0995f63a9fbeea62b64d10b4d9d8e78ec6d7d51fb2125fda7bb36788f" [[package]] name = "rustls-webpki" -version = "0.102.7" +version = "0.102.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84678086bd54edf2b415183ed7a94d0efb049f1b646a33e22a36f3794be6ae56" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" dependencies = [ "ring", "rustls-pki-types", @@ -4215,9 +4215,9 @@ checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" [[package]] name = "unicode-ident" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" @@ -4230,9 +4230,9 @@ dependencies = [ [[package]] name = "unicode-segmentation" -version = "1.11.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index 7a9fe313a..e81afb713 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -51,9 +51,9 @@ } }, "node_modules/ansi-regex": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", "dev": true, "license": "MIT", "engines": { @@ -450,9 +450,9 @@ } }, "node_modules/typescript": { - "version": "5.5.4", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", - "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", + "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/package-lock.json b/package-lock.json index 08ad37f65..859e169ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -70,9 +70,9 @@ } }, "node_modules/@isaacs/cliui/node_modules/ansi-regex": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", - "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", "dev": true, "license": "MIT", "engines": { @@ -370,9 +370,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.5.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.4.tgz", - "integrity": "sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg==", + "version": "22.5.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.5.tgz", + "integrity": "sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==", "dev": true, "license": "MIT", "peer": true, From 4717353c71b9b1e12b9bd6bfe12117e01b7a3ae9 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Mon, 16 Sep 2024 10:59:56 -0400 Subject: [PATCH 151/214] [SM-1401] Update the Java SDK (#1005) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1401 ## 📔 Objective Update the Java SDK for Secrets Manager. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- languages/java/README.md | 30 +++++++++++-- languages/java/build.gradle | 1 + languages/java/example/Example.java | 41 +++++++++++++----- .../java/com/bitwarden/sdk/AuthClient.java | 32 ++++++++++++++ .../com/bitwarden/sdk/BitwardenClient.java | 26 ++++------- .../sdk/BitwardenClientException.java | 4 ++ .../com/bitwarden/sdk/ProjectsClient.java | 2 +- .../java/com/bitwarden/sdk/SecretsClient.java | 43 +++++++++++++++++-- 8 files changed, 143 insertions(+), 36 deletions(-) create mode 100644 languages/java/src/main/java/com/bitwarden/sdk/AuthClient.java diff --git a/languages/java/README.md b/languages/java/README.md index 02cbc4aaf..b4db4475e 100644 --- a/languages/java/README.md +++ b/languages/java/README.md @@ -13,12 +13,19 @@ Review the help documentation on [Access Tokens] ```java import com.bitwarden.sdk.*; +import com.bitwarden.sdk.schema.*; + +import java.lang.System; +import java.util.UUID; +import java.time.OffsetDateTime; + +String stateFile = System.getenv("STATE_FILE"); BitwardenSettings bitwardenSettings = new BitwardenSettings(); bitwardenSettings.setApiUrl("https://api.bitwarden.com"); bitwardenSettings.setIdentityUrl("https://identity.bitwarden.com"); BitwardenClient bitwardenClient = new BitwardenClient(bitwardenSettings); -bitwardenClient.accessTokenLogin(""); +bitwardenClient.auth().loginAccessToken("", stateFile); ``` ### Create new project @@ -44,7 +51,7 @@ var projectsResponse = bitwardenClient.projects().list(organizationId); ### Update project ```java -var projectResponse = bitwardenClient.projects().update(projectId, organizationId, "TestProjectUpdated"); +var projectResponse = bitwardenClient.projects().update(organizationId, projectId, "TestProjectUpdated"); ``` ### Add new secret @@ -53,7 +60,7 @@ var projectResponse = bitwardenClient.projects().update(projectId, organizationI String key = "key"; String value = "value"; String note = "note"; -var secretResponse = bitwardenClient.secrets().create(key, value, note, organizationId, new UUID[]{projectId}); +var secretResponse = bitwardenClient.secrets().create(organizationId, key, value, note, new UUID[]{projectId}); UUID secretId = secretResponse.getID(); ``` @@ -63,10 +70,19 @@ UUID secretId = secretResponse.getID(); var secretResponse = bitwardenClient.secrets().get(secretId); ``` +### Get secrets by ids + +```java +SecretsResponse secretsByIds = bitwardenClient.secrets().getByIds(new UUID[]{secretId}); +for (SecretResponse sr : secretsByIds.getData()) { + System.out.println(sr.getKey()); +} +``` + ### Update secret ```java -var secretResponse = bitwardenClient.secrets().update(secretId, key2, value2, note2, organizationId, new UUID[]{projectId}); +var secretResponse = bitwardenClient.secrets().update(organizationId, secretId, key2, value2, note2, new UUID[]{projectId}); ``` ### List secrets @@ -75,6 +91,12 @@ var secretResponse = bitwardenClient.secrets().update(secretId, key2, value2, no var secretIdentifiersResponse = bitwardenClient.secrets().list(organizationId); ``` +### Secrets sync +```java +SecretsSyncResponse syncResponse = bitwardenClient.secrets().sync(organizationId, OffsetDateTime.now()); +System.out.println("Has changes: " + syncResponse.getHasChanges()); +``` + ### Delete secret or project ```java diff --git a/languages/java/build.gradle b/languages/java/build.gradle index 2363d3a32..6f24369d7 100644 --- a/languages/java/build.gradle +++ b/languages/java/build.gradle @@ -74,6 +74,7 @@ tasks.withType(JavaCompile) { tasks.withType(Javadoc) { options.encoding = 'UTF-8' + failOnError = false } java { diff --git a/languages/java/example/Example.java b/languages/java/example/Example.java index 2460d76b5..cc34c2a29 100644 --- a/languages/java/example/Example.java +++ b/languages/java/example/Example.java @@ -1,5 +1,6 @@ import java.lang.System; import java.util.UUID; +import java.time.OffsetDateTime; import com.bitwarden.sdk.*; import com.bitwarden.sdk.schema.*; @@ -13,8 +14,10 @@ public static void main(String[] args) { String accessToken = System.getenv("ACCESS_TOKEN"); UUID organizationId = UUID.fromString(System.getenv("ORGANIZATION_ID")); + String apiUrl = System.getenv("API_URL"); String identityUrl = System.getenv("IDENTITY_URL"); + String stateFile = System.getenv("STATE_FILE"); // Configuring the URLS is optional, remove them to use the default values BitwardenSettings bitwardenSettings = new BitwardenSettings(); @@ -22,31 +25,49 @@ public static void main(String[] args) { bitwardenSettings.setIdentityUrl(identityUrl); try (BitwardenClient client = new BitwardenClient(bitwardenSettings)) { - client.accessTokenLogin(accessToken); + client.auth().loginAccessToken(accessToken, stateFile); - ProjectResponse project = client.projects().create(organizationId, "Test Project"); - System.out.println("Project id: " + project.getID()); + ProjectResponse project = client.projects().create(organizationId, "Test Project from Java SDK"); + System.out.println("Project CREATE, id: " + project.getID()); project = client.projects().get(project.getID()); + System.out.println("Project GET, id: " + project.getID()); ProjectsResponse projects = client.projects().list(organizationId); - System.out.println("Projects count: " + projects.getData().length); + System.out.println("Projects LIST, count: " + projects.getData().length); - client.projects().update(project.getID(), organizationId, "Updated Test Project"); + client.projects().update(organizationId, project.getID(), "Updated Test Project"); + project = client.projects().get(project.getID()); + System.out.println("Project UPDATE, new name: " + project.getName()); - SecretResponse secret = client.secrets().create("Secret Key", "Secret Value", "Secret Note", - organizationId, new UUID[]{project.getID()}); - System.out.println("Secret id: " + secret.getID()); + SecretResponse secret = client.secrets().create(organizationId, "Secret Key", "Secret Value", "Secret Note", new UUID[]{project.getID()}); + System.out.println("Secret CREATE, id: " + secret.getID()); secret = client.secrets().get(secret.getID()); + System.out.println("Secret GET, id: " + secret.getID()); SecretIdentifiersResponse secrets = client.secrets().list(organizationId); - System.out.println("Secrets count: " + secrets.getData().length); + System.out.println("Secrets LIST, count: " + secrets.getData().length); + + client.secrets().update(organizationId, secret.getID(), "Updated Key", "Updated Value", "Updated Note", new UUID[]{project.getID()}); + secret = client.secrets().get(secret.getID()); + System.out.println("Secret UPDATE, new key: " + secret.getKey()); + + SecretsResponse secretsByIds = client.secrets().getByIds(new UUID[]{secret.getID()}); + System.out.println("Getting secrets by ids, here are the keys of the retrieved secrets..."); + for (SecretResponse sr : secretsByIds.getData()) { + System.out.println(" " + sr.getKey()); + } - client.secrets().update(secret.getID(), "Updated Key", "Updated Value", "Updated Noye", organizationId, new UUID[]{project.getID()}); + SecretsSyncResponse syncResponse = client.secrets().sync(organizationId, OffsetDateTime.now()); + System.out.println("Running a secrets sync request based on the current time..."); + System.out.println("Has changes: " + syncResponse.getHasChanges()); + System.out.println("Deleting the created secret and project..."); client.secrets().delete(new UUID[]{secret.getID()}); client.projects().delete(new UUID[]{project.getID()}); + + System.out.println("Execution complete."); } } } diff --git a/languages/java/src/main/java/com/bitwarden/sdk/AuthClient.java b/languages/java/src/main/java/com/bitwarden/sdk/AuthClient.java new file mode 100644 index 000000000..b4c26eb75 --- /dev/null +++ b/languages/java/src/main/java/com/bitwarden/sdk/AuthClient.java @@ -0,0 +1,32 @@ +package com.bitwarden.sdk; + +import com.bitwarden.sdk.schema.*; + +import java.util.function.Function; + +public class AuthClient { + + private final CommandRunner commandRunner; + + AuthClient(CommandRunner commandRunner) { + this.commandRunner = commandRunner; + } + + public APIKeyLoginResponse loginAccessToken(String accessToken, String stateFile) { + Command command = new Command(); + AccessTokenLoginRequest accessTokenLoginRequest = new AccessTokenLoginRequest(); + accessTokenLoginRequest.setAccessToken(accessToken); + accessTokenLoginRequest.setStateFile(stateFile); + + command.setLoginAccessToken(accessTokenLoginRequest); + + ResponseForAPIKeyLoginResponse response = commandRunner.runCommand(command, + BitwardenClient.throwingFunctionWrapper(Converter::ResponseForAPIKeyLoginResponseFromJsonString)); + + if (response == null || !response.getSuccess()) { + throw new BitwardenClientException(response != null ? response.getErrorMessage() : "Login failed"); + } + + return response.getData(); + } +} diff --git a/languages/java/src/main/java/com/bitwarden/sdk/BitwardenClient.java b/languages/java/src/main/java/com/bitwarden/sdk/BitwardenClient.java index 9e1948184..bed29982d 100644 --- a/languages/java/src/main/java/com/bitwarden/sdk/BitwardenClient.java +++ b/languages/java/src/main/java/com/bitwarden/sdk/BitwardenClient.java @@ -21,6 +21,8 @@ public class BitwardenClient implements AutoCloseable { private final SecretsClient secrets; + private final AuthClient auth; + public BitwardenClient(BitwardenSettings bitwardenSettings) { ClientSettings clientSettings = new ClientSettings(); clientSettings.setAPIURL(bitwardenSettings.getApiUrl()); @@ -39,36 +41,20 @@ public BitwardenClient(BitwardenSettings bitwardenSettings) { commandRunner = new CommandRunner(library, client); projects = new ProjectsClient(commandRunner); secrets = new SecretsClient(commandRunner); + auth = new AuthClient(commandRunner); isClientOpen = true; } static Function throwingFunctionWrapper(ThrowingFunction throwingFunction) { - return i -> { try { return throwingFunction.accept(i); } catch (Exception ex) { - throw new BitwardenClientException("Response deserialization failed"); + throw new BitwardenClientException("Response failed", ex); } }; } - public APIKeyLoginResponse accessTokenLogin(String accessToken) { - Command command = new Command(); - AccessTokenLoginRequest accessTokenLoginRequest = new AccessTokenLoginRequest(); - accessTokenLoginRequest.setAccessToken(accessToken); - command.setAccessTokenLogin(accessTokenLoginRequest); - - ResponseForAPIKeyLoginResponse response = commandRunner.runCommand(command, - throwingFunctionWrapper(Converter::ResponseForAPIKeyLoginResponseFromJsonString)); - - if (response == null || !response.getSuccess()) { - throw new BitwardenClientException(response != null ? response.getErrorMessage() : "Login failed"); - } - - return response.getData(); - } - public ProjectsClient projects() { return projects; } @@ -77,6 +63,10 @@ public SecretsClient secrets() { return secrets; } + public AuthClient auth() { + return auth; + } + @Override public void close() { if (isClientOpen) { diff --git a/languages/java/src/main/java/com/bitwarden/sdk/BitwardenClientException.java b/languages/java/src/main/java/com/bitwarden/sdk/BitwardenClientException.java index 7b6025be8..e1bc9d477 100644 --- a/languages/java/src/main/java/com/bitwarden/sdk/BitwardenClientException.java +++ b/languages/java/src/main/java/com/bitwarden/sdk/BitwardenClientException.java @@ -5,4 +5,8 @@ public class BitwardenClientException extends RuntimeException { public BitwardenClientException(String message) { super(message); } + + public BitwardenClientException(String message, Exception ex) { + super(message, ex); + } } diff --git a/languages/java/src/main/java/com/bitwarden/sdk/ProjectsClient.java b/languages/java/src/main/java/com/bitwarden/sdk/ProjectsClient.java index 73b87440c..eb96b8286 100644 --- a/languages/java/src/main/java/com/bitwarden/sdk/ProjectsClient.java +++ b/languages/java/src/main/java/com/bitwarden/sdk/ProjectsClient.java @@ -49,7 +49,7 @@ public ProjectResponse create(UUID organizationId, String name) { return response.getData(); } - public ProjectResponse update(UUID id, UUID organizationId, String name) { + public ProjectResponse update(UUID organizationId, UUID id, String name) { Command command = new Command(); ProjectsCommand projectsCommand = new ProjectsCommand(); ProjectPutRequest projectPutRequest = new ProjectPutRequest(); diff --git a/languages/java/src/main/java/com/bitwarden/sdk/SecretsClient.java b/languages/java/src/main/java/com/bitwarden/sdk/SecretsClient.java index f1a97fdc7..63324449f 100644 --- a/languages/java/src/main/java/com/bitwarden/sdk/SecretsClient.java +++ b/languages/java/src/main/java/com/bitwarden/sdk/SecretsClient.java @@ -3,6 +3,7 @@ import com.bitwarden.sdk.schema.*; import java.util.UUID; +import java.time.OffsetDateTime; public class SecretsClient { @@ -30,7 +31,7 @@ public SecretResponse get(UUID id) { return response.getData(); } - public SecretResponse create(String key, String value, String note, UUID organizationId, UUID[] projectIds) { + public SecretResponse create(UUID organizationId, String key, String value, String note, UUID[] projectIds) { Command command = new Command(); SecretsCommand secretsCommand = new SecretsCommand(); SecretCreateRequest secretCreateRequest = new SecretCreateRequest(); @@ -52,8 +53,7 @@ public SecretResponse create(String key, String value, String note, UUID organiz return response.getData(); } - public SecretResponse update(UUID id, String key, String value, String note, UUID organizationId, - UUID[] projectIds) { + public SecretResponse update(UUID organizationId, UUID id, String key, String value, String note, UUID[] projectIds) { Command command = new Command(); SecretsCommand secretsCommand = new SecretsCommand(); SecretPutRequest secretPutRequest = new SecretPutRequest(); @@ -112,4 +112,41 @@ public SecretIdentifiersResponse list(UUID organizationId) { return response.getData(); } + + public SecretsResponse getByIds(UUID[] ids) { + Command command = new Command(); + SecretsCommand secretsCommand = new SecretsCommand(); + SecretsGetRequest secretsGetRequest = new SecretsGetRequest(); + secretsGetRequest.setIDS(ids); + secretsCommand.setGetByIDS(secretsGetRequest); + command.setSecrets(secretsCommand); + + ResponseForSecretsResponse response = commandRunner.runCommand(command, + BitwardenClient.throwingFunctionWrapper(Converter::ResponseForSecretsResponseFromJsonString)); + + if (response == null || !response.getSuccess()) { + throw new BitwardenClientException(response != null ? response.getErrorMessage() : "Secret(s) not found"); + } + + return response.getData(); + } + + public SecretsSyncResponse sync(UUID organizationId, OffsetDateTime lastSyncedDate) { + Command command = new Command(); + SecretsCommand secretsCommand = new SecretsCommand(); + SecretsSyncRequest secretsSyncRequest = new SecretsSyncRequest(); + secretsSyncRequest.setOrganizationID(organizationId); + secretsSyncRequest.setLastSyncedDate(lastSyncedDate); + secretsCommand.setSync(secretsSyncRequest); + command.setSecrets(secretsCommand); + + ResponseForSecretsSyncResponse response = commandRunner.runCommand(command, + BitwardenClient.throwingFunctionWrapper(Converter::ResponseForSecretsSyncResponseFromJsonString)); + + if (response == null || !response.getSuccess()) { + throw new BitwardenClientException(response != null ? response.getErrorMessage() : "Secrets sync failed"); + } + + return response.getData(); + } } From 7e46d9dd104be9ac5c6d549240f78596aa433b39 Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Mon, 16 Sep 2024 09:04:43 -0700 Subject: [PATCH 152/214] [SM-1434] - Dynamically-linked bitwarden-c not working for older supported OS versions (#1034) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [//]: # (https://bitwarden.atlassian.net/browse/SM-1434) ## 📔 Objective The bitwarden-c lib is dynamically-linked with the version of GCC/Clang that is installed on the GitHub runner. Using newer runners will result in errors like this, for those that are running older, but still-supported versions of macOS: ``` object file (/Users/user/go/pkg/mod/github.com/bitwarden/sdk-go@v1.0.0/internal/cinterface/lib/darwin-x64/libbitwarden_c.a[216](8912af01511d326c-sha256-x86_64-macosx.o)) was built for newer 'macOS' version (14.2) than being linked (14.0) ``` This PR uses `MACOSX_DEPLOYMENT_TARGET` to support older versions of macOS. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/build-rust-cross-platform.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build-rust-cross-platform.yml b/.github/workflows/build-rust-cross-platform.yml index 31347a9a9..a8c626d2c 100644 --- a/.github/workflows/build-rust-cross-platform.yml +++ b/.github/workflows/build-rust-cross-platform.yml @@ -26,6 +26,9 @@ jobs: target: x86_64-pc-windows-msvc - os: windows-2022 target: x86_64-pc-windows-gnu + # caution: updating the linux runner OS version for GNU + # targets will likely break libbitwarden_c for older OS versions. + # prefer using oldest supported runner for for these targets - os: ubuntu-22.04 target: x86_64-unknown-linux-gnu - os: ubuntu-22.04 @@ -67,6 +70,7 @@ jobs: if: ${{ !contains(matrix.settings.target, 'musl') }} env: RUSTFLAGS: "-D warnings" + MACOSX_DEPLOYMENT_TARGET: "10.14" # allows using new macos runner versions while still supporting older systems run: cargo build -p bitwarden-c --target ${{ matrix.settings.target }} --release - name: Upload Artifact From d23ec731d1aa5e63ddcf7decbac6ef20107c508a Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:29:41 -0400 Subject: [PATCH 153/214] BRE-314 - Fix Universal CLI Build (#1052) --- .github/workflows/build-cli.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-cli.yml b/.github/workflows/build-cli.yml index 7620ced50..a54a669bb 100644 --- a/.github/workflows/build-cli.yml +++ b/.github/workflows/build-cli.yml @@ -74,7 +74,7 @@ jobs: - name: Build env: TARGET: ${{ matrix.settings.target }} - run: cargo build ${{ matrix.features }} -p bws --release --target=${{ matrix.settings.target }} + run: cargo build -p bws --release --target=${{ matrix.settings.target }} - name: Login to Azure if: ${{ needs.setup.outputs.sign == 'true' }} @@ -164,7 +164,7 @@ jobs: - name: Build env: TARGET: ${{ matrix.settings.target }} - run: cargo build ${{ matrix.features }} -p bws --release --target=${{ matrix.settings.target }} + run: cargo build -p bws --release --target=${{ matrix.settings.target }} - name: Login to Azure uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 @@ -286,7 +286,7 @@ jobs: - name: Build env: TARGET: ${{ matrix.settings.target }} - run: cargo zigbuild ${{ matrix.features }} -p bws --release --target=${{ matrix.settings.target }} + run: cargo zigbuild -p bws --release --target=${{ matrix.settings.target }} - name: Zip linux run: zip -j ./bws-${{ matrix.settings.target }}-${{ env._PACKAGE_VERSION }}.zip ./target/${{ matrix.settings.target }}/release/bws @@ -375,7 +375,7 @@ jobs: - name: Sign binary env: MACOS_CERTIFICATE_NAME: ${{ steps.retrieve-secrets-macos.outputs.macos-bws-certificate-name }} - run: codesign --sign "$MACOS_CERTIFICATE_NAME" --verbose=3 --force --options=runtime --timestamp ./bws-aarch64-apple-darwin/bws + run: codesign --sign "$MACOS_CERTIFICATE_NAME" --verbose=3 --force --options=runtime --timestamp ./bws-macos-universal/bws - name: Notarize app env: @@ -389,7 +389,7 @@ jobs: xcrun notarytool store-credentials "notarytool-profile" --apple-id "$MACOS_NOTARIZATION_APPLE_ID" --team-id "$MACOS_NOTARIZATION_TEAM_ID" --password "$MACOS_NOTARIZATION_PWD" echo "Creating notarization archive" - zip -j ./bws-macos-universal-${{ env._PACKAGE_VERSION }}.zip ./bws-aarch64-apple-darwin/bws + zip -j ./bws-macos-universal-${{ env._PACKAGE_VERSION }}.zip ./bws-macos-universal/bws codesign --sign "$MACOS_CERTIFICATE_NAME" --verbose=3 --force --options=runtime --timestamp ./bws-macos-universal-${{ env._PACKAGE_VERSION }}.zip From c57e3a7d4b25c05cd7b68cf515520dbaf24b3dbe Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Tue, 17 Sep 2024 13:39:26 +0200 Subject: [PATCH 154/214] [PM-12023] Enforce hmac when mac key is present (#1041) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/issues/PM-12023 (https://bitwarden.atlassian.net/issues/PM-4185) ## 📔 Objective Prevent downgrading of encstring types to hmac-less by enforcing hmac when the symmetric key used has a mac key. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --------- Co-authored-by: Oscar Hinton --- .../src/enc_string/symmetric.rs | 26 ++++++++++++++++++- crates/bitwarden-crypto/src/error.rs | 2 ++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/crates/bitwarden-crypto/src/enc_string/symmetric.rs b/crates/bitwarden-crypto/src/enc_string/symmetric.rs index eb1220e29..1fc9b3a9d 100644 --- a/crates/bitwarden-crypto/src/enc_string/symmetric.rs +++ b/crates/bitwarden-crypto/src/enc_string/symmetric.rs @@ -237,6 +237,10 @@ impl KeyDecryptable> for EncString { fn decrypt_with_key(&self, key: &SymmetricCryptoKey) -> Result> { match self { EncString::AesCbc256_B64 { iv, data } => { + if key.mac_key.is_some() { + return Err(CryptoError::MacNotProvided); + } + let dec = crate::aes::decrypt_aes256(iv, data.clone(), &key.key)?; Ok(dec) } @@ -296,7 +300,9 @@ mod tests { use schemars::schema_for; use super::EncString; - use crate::{derive_symmetric_key, KeyDecryptable, KeyEncryptable, SymmetricCryptoKey}; + use crate::{ + derive_symmetric_key, CryptoError, KeyDecryptable, KeyEncryptable, SymmetricCryptoKey, + }; #[test] fn test_enc_string_roundtrip() { @@ -418,6 +424,24 @@ mod tests { assert_eq!(dec_str, "EncryptMe!"); } + #[test] + fn test_decrypt_downgrade_encstring_prevention() { + // Simulate a potential downgrade attack by removing the mac portion of the `EncString` and + // attempt to decrypt it using a `SymmetricCryptoKey` with a mac key. + let key = "hvBMMb1t79YssFZkpetYsM3deyVuQv4r88Uj9gvYe0+G8EwxvW3v1iywVmSl61iwzd17JW5C/ivzxSP2C9h7Tw==".to_string(); + let key = SymmetricCryptoKey::try_from(key).unwrap(); + + // A "downgraded" `EncString` from `EncString::AesCbc256_HmacSha256_B64` (2) to + // `EncString::AesCbc256_B64` (0), with the mac portion removed. + // + let enc_str = "0.NQfjHLr6za7VQVAbrpL81w==|wfrjmyJ0bfwkQlySrhw8dA=="; + let enc_string: EncString = enc_str.parse().unwrap(); + assert_eq!(enc_string.enc_type(), 0); + + let result: Result = enc_string.decrypt_with_key(&key); + assert!(matches!(result, Err(CryptoError::MacNotProvided))); + } + #[test] fn test_decrypt_cbc128_hmac() { let key = "Gt1aZ8kTTgkF80bLtb7LiMZBcxEA2FA5mbvV4x7K208=".to_string(); diff --git a/crates/bitwarden-crypto/src/error.rs b/crates/bitwarden-crypto/src/error.rs index 2fc4d2591..cd2ef9ac0 100644 --- a/crates/bitwarden-crypto/src/error.rs +++ b/crates/bitwarden-crypto/src/error.rs @@ -11,6 +11,8 @@ pub enum CryptoError { InvalidKey, #[error("The cipher's MAC doesn't match the expected value")] InvalidMac, + #[error("The key provided expects mac protected encstrings, but the mac is missing")] + MacNotProvided, #[error("Error while decrypting EncString")] KeyDecrypt, #[error("The cipher key has an invalid length")] From 74a9e30dbf35cbfc4d1d6b88847504d789d8431e Mon Sep 17 00:00:00 2001 From: Bitwarden DevOps <106330231+bitwarden-devops-bot@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:27:57 -0600 Subject: [PATCH 155/214] Bump version to 1.0.0 (#1054) ## Type of change - [ ] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [X] Other ## Objective Automated ruby-sdk version bump to 1.0.0 --- languages/ruby/bitwarden_sdk_secrets/lib/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/ruby/bitwarden_sdk_secrets/lib/version.rb b/languages/ruby/bitwarden_sdk_secrets/lib/version.rb index 3103642a1..39b47b47b 100644 --- a/languages/ruby/bitwarden_sdk_secrets/lib/version.rb +++ b/languages/ruby/bitwarden_sdk_secrets/lib/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module BitwardenSDKSecrets - VERSION = '0.2.0' + VERSION = '1.0.0' end From fb2053d2529e896f3d4d5f4852f855b1f7256bef Mon Sep 17 00:00:00 2001 From: Bitwarden DevOps <106330231+bitwarden-devops-bot@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:01:32 -0600 Subject: [PATCH 156/214] Bump version to 1.0.0 (#1056) ## Type of change - [ ] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [X] Other ## Objective Automated bitwarden version bump to 1.0.0 --- Cargo.lock | 24 ++++++++++++------------ Cargo.toml | 26 +++++++++++++------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 57aa79565..e2ad1f04f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -360,7 +360,7 @@ checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bitwarden" -version = "0.5.0" +version = "1.0.0" dependencies = [ "bitwarden-api-api", "bitwarden-api-identity", @@ -378,7 +378,7 @@ dependencies = [ [[package]] name = "bitwarden-api-api" -version = "0.5.0" +version = "1.0.0" dependencies = [ "reqwest", "serde", @@ -391,7 +391,7 @@ dependencies = [ [[package]] name = "bitwarden-api-identity" -version = "0.5.0" +version = "1.0.0" dependencies = [ "reqwest", "serde", @@ -413,7 +413,7 @@ dependencies = [ [[package]] name = "bitwarden-cli" -version = "0.5.0" +version = "1.0.0" dependencies = [ "clap", "color-eyre", @@ -423,7 +423,7 @@ dependencies = [ [[package]] name = "bitwarden-core" -version = "0.5.0" +version = "1.0.0" dependencies = [ "base64", "bitwarden-api-api", @@ -456,7 +456,7 @@ dependencies = [ [[package]] name = "bitwarden-crypto" -version = "0.5.0" +version = "1.0.0" dependencies = [ "aes", "argon2", @@ -487,7 +487,7 @@ dependencies = [ [[package]] name = "bitwarden-exporters" -version = "0.5.0" +version = "1.0.0" dependencies = [ "base64", "bitwarden-core", @@ -505,7 +505,7 @@ dependencies = [ [[package]] name = "bitwarden-fido" -version = "0.5.0" +version = "1.0.0" dependencies = [ "async-trait", "base64", @@ -529,7 +529,7 @@ dependencies = [ [[package]] name = "bitwarden-generators" -version = "0.5.0" +version = "1.0.0" dependencies = [ "bitwarden-core", "bitwarden-crypto", @@ -581,7 +581,7 @@ dependencies = [ [[package]] name = "bitwarden-send" -version = "0.5.0" +version = "1.0.0" dependencies = [ "base64", "bitwarden-api-api", @@ -599,7 +599,7 @@ dependencies = [ [[package]] name = "bitwarden-sm" -version = "0.5.0" +version = "1.0.0" dependencies = [ "bitwarden-api-api", "bitwarden-core", @@ -643,7 +643,7 @@ dependencies = [ [[package]] name = "bitwarden-vault" -version = "0.5.0" +version = "1.0.0" dependencies = [ "base64", "bitwarden-api-api", diff --git a/Cargo.toml b/Cargo.toml index d64aa04fc..7d452869c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ members = ["crates/*"] # Global settings for all crates should be defined here [workspace.package] # Update using `cargo set-version -p bitwarden ` -version = "0.5.0" +version = "1.0.0" authors = ["Bitwarden Inc"] edition = "2021" # Note: Changing rust-version should be considered a breaking change @@ -17,18 +17,18 @@ keywords = ["bitwarden"] # Define dependencies that are expected to be consistent across all crates [workspace.dependencies] -bitwarden = { path = "crates/bitwarden", version = "=0.5.0" } -bitwarden-api-api = { path = "crates/bitwarden-api-api", version = "=0.5.0" } -bitwarden-api-identity = { path = "crates/bitwarden-api-identity", version = "=0.5.0" } -bitwarden-cli = { path = "crates/bitwarden-cli", version = "=0.5.0" } -bitwarden-core = { path = "crates/bitwarden-core", version = "=0.5.0" } -bitwarden-crypto = { path = "crates/bitwarden-crypto", version = "=0.5.0" } -bitwarden-exporters = { path = "crates/bitwarden-exporters", version = "=0.5.0" } -bitwarden-fido = { path = "crates/bitwarden-fido", version = "=0.5.0" } -bitwarden-generators = { path = "crates/bitwarden-generators", version = "=0.5.0" } -bitwarden-send = { path = "crates/bitwarden-send", version = "=0.5.0" } -bitwarden-sm = { path = "crates/bitwarden-sm", version = "=0.5.0" } -bitwarden-vault = { path = "crates/bitwarden-vault", version = "=0.5.0" } +bitwarden = { path = "crates/bitwarden", version = "=1.0.0" } +bitwarden-api-api = { path = "crates/bitwarden-api-api", version = "=1.0.0" } +bitwarden-api-identity = { path = "crates/bitwarden-api-identity", version = "=1.0.0" } +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-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" } +bitwarden-send = { path = "crates/bitwarden-send", version = "=1.0.0" } +bitwarden-sm = { path = "crates/bitwarden-sm", version = "=1.0.0" } +bitwarden-vault = { path = "crates/bitwarden-vault", version = "=1.0.0" } [workspace.lints.clippy] unused_async = "deny" From c3b8c8dc3fb23ffd47c590611d04a55b3a29190e Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Tue, 17 Sep 2024 12:44:24 -0400 Subject: [PATCH 157/214] BRE-330 - Update CODEOWNERS for automation users (#1060) --- .github/CODEOWNERS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 6bb362e8c..10c8bdeb8 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -11,3 +11,8 @@ # Secrets Manager team crates/bitwarden-sm @bitwarden/team-secrets-manager-dev crates/bws @bitwarden/team-secrets-manager-dev + +# BRE Automation +crates/bws/Cargo.toml @bitwarden/team-secrets-manager-dev @bitwarden/automation-users +crates/bws/scripts/install.ps1 @bitwarden/team-secrets-manager-dev @bitwarden/automation-users +crates/bws/scripts/install.sh @bitwarden/team-secrets-manager-dev @bitwarden/automation-users From 3de7906cff98b9c8d5c0b8cc4fc2e40d1a447172 Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Tue, 17 Sep 2024 12:48:24 -0400 Subject: [PATCH 158/214] BRE-330 - Update Rust crate workflows (#1057) --- .github/workflows/build-cli-docker.yml | 6 ++--- .github/workflows/build-rust-crates.yml | 11 +++----- .github/workflows/publish-rust-crates.yml | 33 +++++++---------------- .github/workflows/rust-test.yml | 4 +-- .github/workflows/version-bump.yml | 6 ++--- 5 files changed, 20 insertions(+), 40 deletions(-) diff --git a/.github/workflows/build-cli-docker.yml b/.github/workflows/build-cli-docker.yml index 8302529c8..a54086b9b 100644 --- a/.github/workflows/build-cli-docker.yml +++ b/.github/workflows/build-cli-docker.yml @@ -23,7 +23,7 @@ jobs: - name: Check Branch to Publish env: - PUBLISH_BRANCHES: "master,rc,hotfix-rc" + PUBLISH_BRANCHES: "main,rc,hotfix-rc" id: publish-branch-check run: | REF=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} @@ -77,7 +77,7 @@ jobs: run: | REF=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} IMAGE_TAG=$(echo "${REF}" | sed "s#/#-#g") # slash safe branch name - if [[ "${IMAGE_TAG}" == "master" ]]; then + if [[ "${IMAGE_TAG}" == "main" ]]; then IMAGE_TAG=dev elif [[ ("${IMAGE_TAG}" == "rc") || ("${IMAGE_TAG}" == "hotfix-rc") ]]; then IMAGE_TAG=rc @@ -124,7 +124,7 @@ jobs: steps: - name: Check if any job failed if: | - github.ref == 'refs/heads/master' + github.ref == 'refs/heads/main' || github.ref == 'refs/heads/rc' || github.ref == 'refs/heads/hotfix-rc' env: diff --git a/.github/workflows/build-rust-crates.yml b/.github/workflows/build-rust-crates.yml index 068bb9bbd..b7d0832fb 100644 --- a/.github/workflows/build-rust-crates.yml +++ b/.github/workflows/build-rust-crates.yml @@ -7,8 +7,6 @@ on: push: branches: - "main" - - "rc" - - "hotfix-rc" env: CARGO_TERM_COLOR: always @@ -17,7 +15,7 @@ jobs: build: name: Building ${{matrix.package}} for - ${{ matrix.os }} - runs-on: ${{ matrix.settings.os || 'ubuntu-latest' }} + runs-on: ${{ matrix.os || 'ubuntu-latest' }} strategy: fail-fast: false @@ -42,7 +40,6 @@ jobs: uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable - targets: ${{ matrix.settings.target }} - name: Cache cargo registry uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 @@ -61,9 +58,8 @@ jobs: release-dry-run: name: Release dry-run runs-on: ubuntu-latest - if: ${{ github.ref == 'refs/head/main' || github.ref == 'refs/head/rc' || github.ref == 'refs/head/hotfix-rc' }} - needs: - - build + if: ${{ github.ref == 'refs/head/main' }} + needs: build steps: - name: Checkout uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 @@ -72,7 +68,6 @@ jobs: uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable with: toolchain: stable - targets: ${{ matrix.settings.target }} - name: Cache cargo registry uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 diff --git a/.github/workflows/publish-rust-crates.yml b/.github/workflows/publish-rust-crates.yml index 3931e9e2a..bdb39d9b7 100644 --- a/.github/workflows/publish-rust-crates.yml +++ b/.github/workflows/publish-rust-crates.yml @@ -15,37 +15,24 @@ on: - Redeploy - Dry Run -defaults: - run: - shell: bash - jobs: - setup: - name: Setup + publish: + name: Publish runs-on: ubuntu-22.04 steps: - - name: Checkout repo + - name: Checkout uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Branch check - if: ${{ github.event.inputs.release_type != 'Dry Run' }} + if: ${{ inputs.release_type != 'Dry Run' }} run: | - if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then echo "===================================" - echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches" + echo "[!] Can only release from the 'main' branch" echo "===================================" exit 1 fi - publish: - name: Publish - runs-on: ubuntu-latest - needs: - - setup - steps: - - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - name: Login to Azure uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 with: @@ -70,7 +57,7 @@ jobs: run: cargo install cargo-release - name: Create GitHub deployment - if: ${{ github.event.inputs.release_type != 'Dry Run' }} + if: ${{ inputs.release_type != 'Dry Run' }} uses: chrnorm/deployment-action@55729fcebec3d284f60f5bcabbd8376437d696b1 # v2.0.7 id: deployment with: @@ -81,14 +68,14 @@ jobs: task: release - name: Cargo release - if: ${{ github.event.inputs.release_type != 'Dry Run' }} + if: ${{ inputs.release_type != 'Dry Run' }} env: PUBLISH_GRACE_SLEEP: 10 CARGO_REGISTRY_TOKEN: ${{ steps.retrieve-secrets.outputs.cratesio-api-token }} run: cargo-release release publish --exclude bw --exclude bws --execute --no-confirm - name: Update deployment status to Success - if: ${{ github.event.inputs.release_type != 'Dry Run' && success() }} + if: ${{ inputs.release_type != 'Dry Run' && success() }} uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 with: token: "${{ secrets.GITHUB_TOKEN }}" @@ -96,7 +83,7 @@ jobs: deployment-id: ${{ steps.deployment.outputs.deployment_id }} - name: Update deployment status to Failure - if: ${{ github.event.inputs.release_type != 'Dry Run' && failure() }} + if: ${{ inputs.release_type != 'Dry Run' && failure() }} uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 with: token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/rust-test.yml b/.github/workflows/rust-test.yml index 8d8b136b2..3d9ed6f00 100644 --- a/.github/workflows/rust-test.yml +++ b/.github/workflows/rust-test.yml @@ -5,8 +5,6 @@ on: push: branches: - "main" - - "rc" - - "hotfix-rc" pull_request: env: @@ -23,7 +21,7 @@ jobs: - run: exit 0 test: - name: ${{ matrix.os }} / ${{matrix.target || 'default' }} + name: ${{ matrix.os }} / default runs-on: ${{ matrix.os || 'ubuntu-22.04' }} diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index 3536c96ce..8357d49bd 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -1,6 +1,6 @@ --- name: Version Bump -run-name: Version Bump - v${{ inputs.version_number }} +run-name: Version Bump - ${{ inputs.project }} - v${{ inputs.version_number }} on: workflow_dispatch: @@ -25,7 +25,7 @@ on: required: true cut_rc_branch: description: "Cut RC branch?" - default: true + default: false type: boolean jobs: @@ -198,7 +198,7 @@ jobs: env: GH_TOKEN: ${{ steps.retrieve-secrets.outputs.github-pat-bitwarden-devops-bot-repo-scope }} PR_BRANCH: ${{ steps.create-branch.outputs.name }} - TITLE: "Bump version to ${{ inputs.version_number }}" + TITLE: "Bump ${{ inputs.project }} version to ${{ inputs.version_number }}" run: | PR_URL=$(gh pr create --title "$TITLE" \ --base "main" \ From e535cc29175e70d2d31a03c50ac79c075682e7a5 Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Tue, 17 Sep 2024 12:50:12 -0400 Subject: [PATCH 159/214] BRE-328 - Simplify logic and apply linting suggestions in Publish Ruby workflow (#1055) --- .github/workflows/publish-ruby.yml | 33 ++++++++++++------------------ 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/.github/workflows/publish-ruby.yml b/.github/workflows/publish-ruby.yml index 9e2fc6d93..8df5dd390 100644 --- a/.github/workflows/publish-ruby.yml +++ b/.github/workflows/publish-ruby.yml @@ -18,31 +18,23 @@ permissions: id-token: write jobs: - setup: - name: Setup + publish_ruby: + name: Publish Ruby runs-on: ubuntu-22.04 steps: - - name: Checkout repo + - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - + - name: Branch check - if: ${{ github.event.inputs.release_type != 'Dry Run' }} + if: ${{ inputs.release_type != 'Dry Run' }} run: | - if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then echo "===================================" - echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches" + echo "[!] Can only release from the 'main' branch" echo "===================================" exit 1 fi - publish_ruby: - name: Publish Ruby - runs-on: ubuntu-22.04 - needs: setup - steps: - - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - name: Set up Ruby uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # v1.191.0 with: @@ -54,7 +46,7 @@ jobs: workflow: generate_schemas.yml path: languages/ruby/bitwarden_sdk_secrets/lib workflow_conclusion: success - branch: ${{ github.event.inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} + branch: main artifacts: schemas.rb - name: Download x86_64-apple-darwin artifact @@ -63,7 +55,7 @@ jobs: workflow: build-rust-cross-platform.yml path: temp/macos-x64 workflow_conclusion: success - branch: ${{ github.event.inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} + branch: main artifacts: libbitwarden_c_files-x86_64-apple-darwin - name: Download aarch64-apple-darwin artifact @@ -71,7 +63,7 @@ jobs: with: workflow: build-rust-cross-platform.yml workflow_conclusion: success - branch: ${{ github.event.inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} + branch: main artifacts: libbitwarden_c_files-aarch64-apple-darwin path: temp/macos-arm64 @@ -80,7 +72,7 @@ jobs: with: workflow: build-rust-cross-platform.yml workflow_conclusion: success - branch: ${{ github.event.inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} + branch: main artifacts: libbitwarden_c_files-x86_64-unknown-linux-gnu path: temp/linux-x64 @@ -89,7 +81,7 @@ jobs: with: workflow: build-rust-cross-platform.yml workflow_conclusion: success - branch: ${{ github.event.inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} + branch: main artifacts: libbitwarden_c_files-x86_64-pc-windows-msvc path: temp/windows-x64 @@ -128,6 +120,7 @@ jobs: working-directory: languages/ruby/bitwarden_sdk_secrets - name: Push gem to Rubygems + if: ${{ inputs.release_type != 'Dry Run' }} run: | mkdir -p $HOME/.gem touch $HOME/.gem/credentials From 1309527074f926a7c5792d3a354b2f1be238c28a Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:32:16 -0400 Subject: [PATCH 160/214] BRE-330 - Update CODEOWNERS for Version Bumps (#1062) --- .github/CODEOWNERS | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 10c8bdeb8..e4fbb97b9 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -12,7 +12,7 @@ crates/bitwarden-sm @bitwarden/team-secrets-manager-dev crates/bws @bitwarden/team-secrets-manager-dev -# BRE Automation -crates/bws/Cargo.toml @bitwarden/team-secrets-manager-dev @bitwarden/automation-users -crates/bws/scripts/install.ps1 @bitwarden/team-secrets-manager-dev @bitwarden/automation-users -crates/bws/scripts/install.sh @bitwarden/team-secrets-manager-dev @bitwarden/automation-users +# BRE Automations +crates/bws/Cargo.toml +crates/bws/scripts/install.ps1 +crates/bws/scripts/install.sh From f89ffb0b9cdda567ef71fb1c20727a44102bd0fc Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Wed, 18 Sep 2024 08:10:43 -0400 Subject: [PATCH 161/214] Update CLI workflows to be able to release from main branch (#1063) --- .github/workflows/build-cli-docker.yml | 20 +++------------ .github/workflows/build-cli.yml | 16 +++++------- .github/workflows/publish-ruby.yml | 2 +- .github/workflows/release-cli.yml | 35 ++++++++------------------ 4 files changed, 20 insertions(+), 53 deletions(-) diff --git a/.github/workflows/build-cli-docker.yml b/.github/workflows/build-cli-docker.yml index a54086b9b..eaf2299ff 100644 --- a/.github/workflows/build-cli-docker.yml +++ b/.github/workflows/build-cli-docker.yml @@ -5,8 +5,6 @@ on: push: branches: - "main" - - "rc" - - "hotfix-rc" workflow_dispatch: pull_request: @@ -22,15 +20,9 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Check Branch to Publish - env: - PUBLISH_BRANCHES: "main,rc,hotfix-rc" id: publish-branch-check run: | - REF=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} - - IFS="," read -a publish_branches <<< $PUBLISH_BRANCHES - - if [[ "${publish_branches[*]}" =~ "${REF}" ]]; then + if [[ "$GITHUB_REF" == "refs/heads/main" ]]; then echo "is_publish_branch=true" >> $GITHUB_ENV else echo "is_publish_branch=false" >> $GITHUB_ENV @@ -79,8 +71,6 @@ jobs: IMAGE_TAG=$(echo "${REF}" | sed "s#/#-#g") # slash safe branch name if [[ "${IMAGE_TAG}" == "main" ]]; then IMAGE_TAG=dev - elif [[ ("${IMAGE_TAG}" == "rc") || ("${IMAGE_TAG}" == "hotfix-rc") ]]; then - IMAGE_TAG=rc fi echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT @@ -89,9 +79,8 @@ jobs: id: tag-list env: IMAGE_TAG: ${{ steps.tag.outputs.image_tag }} - IS_PUBLISH_BRANCH: ${{ env.is_publish_branch }} run: | - if [[ ("${IMAGE_TAG}" == "dev" || "${IMAGE_TAG}" == "rc") && "${IS_PUBLISH_BRANCH}" == "true" ]]; then + if [[ "${IMAGE_TAG}" == "dev" ]]; then echo "tags=$_AZ_REGISTRY/bws:${IMAGE_TAG},bitwarden/bws:${IMAGE_TAG}" >> $GITHUB_OUTPUT else echo "tags=$_AZ_REGISTRY/bws:${IMAGE_TAG}" >> $GITHUB_OUTPUT @@ -123,10 +112,7 @@ jobs: needs: build-docker steps: - name: Check if any job failed - if: | - github.ref == 'refs/heads/main' - || github.ref == 'refs/heads/rc' - || github.ref == 'refs/heads/hotfix-rc' + if: github.ref == 'refs/heads/main' env: BUILD_DOCKER_STATUS: ${{ needs.build-docker.result }} run: | diff --git a/.github/workflows/build-cli.yml b/.github/workflows/build-cli.yml index a54a669bb..355575716 100644 --- a/.github/workflows/build-cli.yml +++ b/.github/workflows/build-cli.yml @@ -6,8 +6,6 @@ on: push: branches: - "main" - - "rc" - - "hotfix-rc" workflow_dispatch: defaults: @@ -132,8 +130,7 @@ jobs: build-macos: name: Building CLI for - ${{ matrix.settings.os }} - ${{ matrix.settings.target }} runs-on: ${{ matrix.settings.os || 'ubuntu-latest' }} - needs: - - setup + needs: setup env: _PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }} strategy: @@ -242,8 +239,7 @@ jobs: build-linux: name: Building CLI for - ${{ matrix.settings.os }} - ${{ matrix.settings.target }} runs-on: ${{ matrix.settings.os || 'ubuntu-latest' }} - needs: - - setup + needs: setup env: _PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }} strategy: @@ -271,7 +267,8 @@ jobs: toolchain: stable targets: ${{ matrix.settings.target }} - - uses: goto-bus-stop/setup-zig@7ab2955eb728f5440978d5824358023be3a2802d # v2.2.0 + - name: Set up Zig + uses: goto-bus-stop/setup-zig@7ab2955eb728f5440978d5824358023be3a2802d # v2.2.0 with: version: 0.12.0 @@ -325,7 +322,7 @@ jobs: unzip bws-x86_64-apple-darwin-${{ env._PACKAGE_VERSION }}.zip -d ./bws-x86_64-apple-darwin unzip bws-aarch64-apple-darwin-${{ env._PACKAGE_VERSION }}.zip -d ./bws-aarch64-apple-darwin - - name: lipo create universal package + - name: Create universal package with lipo run: | mkdir ./bws-macos-universal @@ -441,8 +438,7 @@ jobs: manpages: name: Generate manpages runs-on: ubuntu-22.04 - needs: - - setup + needs: setup steps: - name: Checkout repo uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 diff --git a/.github/workflows/publish-ruby.yml b/.github/workflows/publish-ruby.yml index 8df5dd390..a2390953e 100644 --- a/.github/workflows/publish-ruby.yml +++ b/.github/workflows/publish-ruby.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - + - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} run: | diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index 009dc9359..80c09142e 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -14,10 +14,6 @@ on: - Release - Dry Run -defaults: - run: - shell: bash - env: _AZ_REGISTRY: bitwardenprod.azurecr.io @@ -32,11 +28,11 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Branch check - if: ${{ github.event.inputs.release_type != 'Dry Run' }} + if: ${{ inputs.release_type != 'Dry Run' }} run: | - if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc-cli" ]]; then + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then echo "===================================" - echo "[!] Can only release from the 'rc' or 'hotfix-rc-cli' branches" + echo "[!] Can only release from the 'main' branch" echo "===================================" exit 1 fi @@ -48,7 +44,7 @@ jobs: echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Create GitHub deployment - if: ${{ github.event.inputs.release_type != 'Dry Run' }} + if: ${{ inputs.release_type != 'Dry Run' }} uses: chrnorm/deployment-action@55729fcebec3d284f60f5bcabbd8376437d696b1 # v2.0.7 id: deployment with: @@ -59,7 +55,6 @@ jobs: task: release - name: Download all Release artifacts - if: ${{ github.event.inputs.release_type != 'Dry Run' }} uses: bitwarden/gh-actions/download-artifacts@main with: workflow: build-cli.yml @@ -67,15 +62,6 @@ jobs: workflow_conclusion: success branch: ${{ github.ref_name }} - - name: Dry Run - Download all artifacts - if: ${{ github.event.inputs.release_type == 'Dry Run' }} - uses: bitwarden/gh-actions/download-artifacts@main - with: - workflow: build-cli.yml - path: packages - workflow_conclusion: success - branch: main - - name: Get checksum files uses: bitwarden/gh-actions/get-checksum@main with: @@ -83,7 +69,7 @@ jobs: file_path: "packages/bws-sha256-checksums-${{ steps.version.outputs.version }}.txt" - name: Create release - if: ${{ github.event.inputs.release_type != 'Dry Run' }} + if: ${{ inputs.release_type != 'Dry Run' }} uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 env: PKG_VERSION: ${{ steps.version.outputs.version }} @@ -105,7 +91,7 @@ jobs: draft: true - name: Update deployment status to Success - if: ${{ github.event.inputs.release_type != 'Dry Run' && success() }} + if: ${{ inputs.release_type != 'Dry Run' && success() }} uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 with: token: "${{ secrets.GITHUB_TOKEN }}" @@ -113,7 +99,7 @@ jobs: deployment-id: ${{ steps.deployment.outputs.deployment_id }} - name: Update deployment status to Failure - if: ${{ github.event.inputs.release_type != 'Dry Run' && failure() }} + if: ${{ inputs.release_type != 'Dry Run' && failure() }} uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 with: token: "${{ secrets.GITHUB_TOKEN }}" @@ -123,8 +109,7 @@ jobs: publish: name: Publish bws to crates.io runs-on: ubuntu-22.04 - needs: - - setup + needs: setup steps: - name: Checkout uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 @@ -153,7 +138,7 @@ jobs: run: cargo install cargo-release - name: Cargo release - if: ${{ github.event.inputs.release_type != 'Dry Run' }} + if: ${{ inputs.release_type != 'Dry Run' }} env: PUBLISH_GRACE_SLEEP: 10 CARGO_REGISTRY_TOKEN: ${{ steps.retrieve-secrets.outputs.cratesio-api-token }} @@ -229,7 +214,7 @@ jobs: "GH_PAT=${{ steps.retrieve-secret-pat.outputs.github-pat-bitwarden-devops-bot-repo-scope }}" - name: Log out of Docker and disable Docker Notary - if: ${{ github.event.inputs.release_type != 'Dry Run' }} + if: ${{ inputs.release_type != 'Dry Run' }} run: | docker logout echo "DOCKER_CONTENT_TRUST=0" >> $GITHUB_ENV From 220cbcb925bf7e1fc8e273cf005a35cb9f913d04 Mon Sep 17 00:00:00 2001 From: Bitwarden DevOps <106330231+bitwarden-devops-bot@users.noreply.github.com> Date: Wed, 18 Sep 2024 06:17:48 -0600 Subject: [PATCH 162/214] Bump bws version to 1.0.0 (#1066) ## Type of change - [ ] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [X] Other ## Objective Automated bws version bump to 1.0.0 --- Cargo.lock | 2 +- crates/bws/Cargo.toml | 2 +- crates/bws/scripts/install.ps1 | 2 +- crates/bws/scripts/install.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e2ad1f04f..6dd102c50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -743,7 +743,7 @@ dependencies = [ [[package]] name = "bws" -version = "0.5.0" +version = "1.0.0" dependencies = [ "bat", "bitwarden", diff --git a/crates/bws/Cargo.toml b/crates/bws/Cargo.toml index 1b13c68a1..c6ef58396 100644 --- a/crates/bws/Cargo.toml +++ b/crates/bws/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bws" -version = "0.5.0" +version = "1.0.0" description = """ Bitwarden Secrets Manager CLI """ diff --git a/crates/bws/scripts/install.ps1 b/crates/bws/scripts/install.ps1 index f39846c20..daa5cf9d1 100755 --- a/crates/bws/scripts/install.ps1 +++ b/crates/bws/scripts/install.ps1 @@ -4,7 +4,7 @@ param ( $ErrorActionPreference = "Stop" -$defaultBwsVersion = "0.5.0" +$defaultBwsVersion = "1.0.0" $bwsVersion = if ($env:bwsVersion) { $env:bwsVersion } else { $defaultBwsVersion } $installDir = [Environment]::GetFolderPath([Environment+SpecialFolder]::LocalApplicationData) | Join-Path -ChildPath "Programs" | Join-Path -ChildPath "Bitwarden" diff --git a/crates/bws/scripts/install.sh b/crates/bws/scripts/install.sh index 126ae9e22..6cd7fe01f 100755 --- a/crates/bws/scripts/install.sh +++ b/crates/bws/scripts/install.sh @@ -4,7 +4,7 @@ # An installer for the bws command line utility. # ################################################## -DEFAULT_BWS_VERSION="0.5.0" +DEFAULT_BWS_VERSION="1.0.0" BWS_VERSION="${BWS_VERSION:-$DEFAULT_BWS_VERSION}" main() { From 5eebbfd4d0e5ef68a7bc5329a872342af55f9375 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Wed, 18 Sep 2024 09:16:43 -0400 Subject: [PATCH 163/214] Fix Linting Issue (#1064) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📔 Objective Fix the failing linting CI introduced [here](https://github.com/bitwarden/sdk/commit/e535cc29175e70d2d31a03c50ac79c075682e7a5). ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes From 08859a350c83a3aae3fa78cc09704514cfe92679 Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Wed, 18 Sep 2024 15:23:59 +0200 Subject: [PATCH 164/214] [PM-11922] Handle apk key hash as origin (#1042) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective Add support for the new `Origin` type in `passkey-rs` Points to: https://github.com/bitwarden/passkey-rs/pull/16 ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- Cargo.lock | 20 +++--- crates/bitwarden-fido/Cargo.toml | 5 +- crates/bitwarden-fido/src/client.rs | 22 +++---- crates/bitwarden-fido/src/lib.rs | 4 +- crates/bitwarden-fido/src/types.rs | 64 +++++++++++++++++++ crates/bitwarden-uniffi/src/platform/fido2.rs | 6 +- 6 files changed, 92 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6dd102c50..068df1254 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -518,6 +518,7 @@ dependencies = [ "log", "p256", "passkey", + "passkey-client", "reqwest", "schemars", "serde", @@ -2633,8 +2634,8 @@ dependencies = [ [[package]] name = "passkey" -version = "0.3.1" -source = "git+https://github.com/bitwarden/passkey-rs?rev=ae08e2cb7dd3d44d915caed395c0cdc56b50fa27#ae08e2cb7dd3d44d915caed395c0cdc56b50fa27" +version = "0.2.0" +source = "git+https://github.com/bitwarden/passkey-rs?rev=29bb052eb15a42e369728ded3cfb2aa7c91213df#29bb052eb15a42e369728ded3cfb2aa7c91213df" dependencies = [ "passkey-authenticator", "passkey-client", @@ -2644,8 +2645,8 @@ dependencies = [ [[package]] name = "passkey-authenticator" -version = "0.3.0" -source = "git+https://github.com/bitwarden/passkey-rs?rev=ae08e2cb7dd3d44d915caed395c0cdc56b50fa27#ae08e2cb7dd3d44d915caed395c0cdc56b50fa27" +version = "0.2.0" +source = "git+https://github.com/bitwarden/passkey-rs?rev=29bb052eb15a42e369728ded3cfb2aa7c91213df#29bb052eb15a42e369728ded3cfb2aa7c91213df" dependencies = [ "async-trait", "coset", @@ -2657,12 +2658,13 @@ dependencies = [ [[package]] name = "passkey-client" -version = "0.3.1" -source = "git+https://github.com/bitwarden/passkey-rs?rev=ae08e2cb7dd3d44d915caed395c0cdc56b50fa27#ae08e2cb7dd3d44d915caed395c0cdc56b50fa27" +version = "0.2.0" +source = "git+https://github.com/bitwarden/passkey-rs?rev=29bb052eb15a42e369728ded3cfb2aa7c91213df#29bb052eb15a42e369728ded3cfb2aa7c91213df" dependencies = [ "ciborium", "coset", "idna", + "nom", "passkey-authenticator", "passkey-types", "public-suffix", @@ -2674,12 +2676,12 @@ dependencies = [ [[package]] name = "passkey-transports" version = "0.1.0" -source = "git+https://github.com/bitwarden/passkey-rs?rev=ae08e2cb7dd3d44d915caed395c0cdc56b50fa27#ae08e2cb7dd3d44d915caed395c0cdc56b50fa27" +source = "git+https://github.com/bitwarden/passkey-rs?rev=29bb052eb15a42e369728ded3cfb2aa7c91213df#29bb052eb15a42e369728ded3cfb2aa7c91213df" [[package]] name = "passkey-types" version = "0.2.1" -source = "git+https://github.com/bitwarden/passkey-rs?rev=ae08e2cb7dd3d44d915caed395c0cdc56b50fa27#ae08e2cb7dd3d44d915caed395c0cdc56b50fa27" +source = "git+https://github.com/bitwarden/passkey-rs?rev=29bb052eb15a42e369728ded3cfb2aa7c91213df#29bb052eb15a42e369728ded3cfb2aa7c91213df" dependencies = [ "bitflags 2.6.0", "ciborium", @@ -2916,7 +2918,7 @@ dependencies = [ [[package]] name = "public-suffix" version = "0.1.1" -source = "git+https://github.com/bitwarden/passkey-rs?rev=ae08e2cb7dd3d44d915caed395c0cdc56b50fa27#ae08e2cb7dd3d44d915caed395c0cdc56b50fa27" +source = "git+https://github.com/bitwarden/passkey-rs?rev=29bb052eb15a42e369728ded3cfb2aa7c91213df#29bb052eb15a42e369728ded3cfb2aa7c91213df" [[package]] name = "pyo3" diff --git a/crates/bitwarden-fido/Cargo.toml b/crates/bitwarden-fido/Cargo.toml index e85e56a19..6b04bd796 100644 --- a/crates/bitwarden-fido/Cargo.toml +++ b/crates/bitwarden-fido/Cargo.toml @@ -30,7 +30,10 @@ coset = { version = "0.3.7" } itertools = "0.13.0" log = ">=0.4.18, <0.5" p256 = { version = ">=0.13.2, <0.14" } -passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "ae08e2cb7dd3d44d915caed395c0cdc56b50fa27" } +passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "ff757604cd7b4e8f321ed1616fef7e40e21ac5df" } +passkey-client = { git = "https://github.com/bitwarden/passkey-rs", rev = "ff757604cd7b4e8f321ed1616fef7e40e21ac5df", features = [ + "android-asset-validation", +] } reqwest = { version = ">=0.12.5, <0.13", default-features = false } schemars = { version = "0.8.21", features = ["uuid1", "chrono"] } serde = { version = ">=1.0, <2.0", features = ["derive"] } diff --git a/crates/bitwarden-fido/src/client.rs b/crates/bitwarden-fido/src/client.rs index a72dae6f5..ac4330be7 100644 --- a/crates/bitwarden-fido/src/client.rs +++ b/crates/bitwarden-fido/src/client.rs @@ -1,5 +1,4 @@ use passkey::client::WebauthnError; -use reqwest::Url; use thiserror::Error; use super::{ @@ -7,15 +6,12 @@ use super::{ get_string_name_from_enum, types::{ AuthenticatorAssertionResponse, AuthenticatorAttestationResponse, ClientData, - ClientExtensionResults, CredPropsResult, + ClientExtensionResults, CredPropsResult, Origin, }, Fido2Authenticator, PublicKeyCredentialAuthenticatorAssertionResponse, PublicKeyCredentialAuthenticatorAttestationResponse, }; - -#[derive(Debug, Error)] -#[error("Invalid origin: {0}")] -pub struct InvalidOriginError(String); +use crate::types::InvalidOriginError; #[derive(Debug, Error)] pub enum Fido2ClientError { @@ -43,12 +39,11 @@ pub struct Fido2Client<'a> { impl<'a> Fido2Client<'a> { pub async fn register( &mut self, - origin: String, + origin: Origin, request: String, client_data: ClientData, ) -> Result { - let origin = Url::parse(&origin).map_err(|e| InvalidOriginError(format!("{}", e)))?; - + let origin: passkey::client::Origin = origin.try_into()?; let request: passkey::types::webauthn::CredentialCreationOptions = serde_json::from_str(&request)?; @@ -67,7 +62,7 @@ impl<'a> Fido2Client<'a> { let rp_id = request.public_key.rp.id.clone(); let mut client = passkey::client::Client::new(self.authenticator.get_authenticator(true)); - let result = client.register(&origin, request, client_data).await?; + let result = client.register(origin, request, client_data).await?; Ok(PublicKeyCredentialAuthenticatorAttestationResponse { id: result.id, @@ -98,12 +93,11 @@ impl<'a> Fido2Client<'a> { pub async fn authenticate( &mut self, - origin: String, + origin: Origin, request: String, client_data: ClientData, ) -> Result { - let origin = Url::parse(&origin).map_err(|e| InvalidOriginError(format!("{}", e)))?; - + let origin: passkey::client::Origin = origin.try_into()?; let request: passkey::types::webauthn::CredentialRequestOptions = serde_json::from_str(&request)?; @@ -116,7 +110,7 @@ impl<'a> Fido2Client<'a> { .replace(uv); let mut client = passkey::client::Client::new(self.authenticator.get_authenticator(false)); - let result = client.authenticate(&origin, request, client_data).await?; + let result = client.authenticate(origin, request, client_data).await?; Ok(PublicKeyCredentialAuthenticatorAssertionResponse { id: result.id, diff --git a/crates/bitwarden-fido/src/lib.rs b/crates/bitwarden-fido/src/lib.rs index 991828eb3..be1dfdb53 100644 --- a/crates/bitwarden-fido/src/lib.rs +++ b/crates/bitwarden-fido/src/lib.rs @@ -32,10 +32,10 @@ pub use traits::{ pub use types::{ AuthenticatorAssertionResponse, AuthenticatorAttestationResponse, ClientData, Fido2CredentialAutofillView, Fido2CredentialAutofillViewError, GetAssertionRequest, - GetAssertionResult, MakeCredentialRequest, MakeCredentialResult, Options, + GetAssertionResult, MakeCredentialRequest, MakeCredentialResult, Options, Origin, PublicKeyCredentialAuthenticatorAssertionResponse, PublicKeyCredentialAuthenticatorAttestationResponse, PublicKeyCredentialRpEntity, - PublicKeyCredentialUserEntity, + PublicKeyCredentialUserEntity, UnverifiedAssetLink, }; use self::crypto::{cose_key_to_pkcs8, pkcs8_to_cose_key}; diff --git a/crates/bitwarden-fido/src/types.rs b/crates/bitwarden-fido/src/types.rs index 8bc8ae42c..409db7a98 100644 --- a/crates/bitwarden-fido/src/types.rs +++ b/crates/bitwarden-fido/src/types.rs @@ -1,7 +1,10 @@ +use std::borrow::Cow; + use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine}; use bitwarden_crypto::KeyContainer; use bitwarden_vault::{CipherError, CipherView}; use passkey::types::webauthn::UserVerificationRequirement; +use reqwest::Url; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use thiserror::Error; @@ -359,6 +362,67 @@ pub struct AuthenticatorAssertionResponse { pub user_handle: Vec, } +#[derive(Debug, Error)] +#[error("Invalid origin: {0}")] +pub struct InvalidOriginError(String); + +#[cfg_attr(feature = "uniffi", derive(uniffi::Record))] +/// An Unverified asset link. +pub struct UnverifiedAssetLink { + /// Application package name. + package_name: String, + /// Fingerprint to compare. + sha256_cert_fingerprint: String, + /// Host to lookup the well known asset link. + host: String, + /// When sourced from the application statement list or parsed from host for passkeys. + /// Will be generated from `host` if not provided. + asset_link_url: Option, +} + +#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))] +/// The origin of a WebAuthn request. +pub enum Origin { + /// A Url, meant for a request in the web browser. + Web(String), + /// An android digital asset fingerprint. + /// Meant for a request coming from an android application. + Android(UnverifiedAssetLink), +} + +impl<'a> TryFrom for passkey::client::Origin<'a> { + type Error = InvalidOriginError; + + fn try_from(value: Origin) -> Result { + Ok(match value { + Origin::Web(url) => { + let url = Url::parse(&url).map_err(|e| InvalidOriginError(format!("{}", e)))?; + passkey::client::Origin::Web(Cow::Owned(url)) + } + Origin::Android(link) => passkey::client::Origin::Android(link.try_into()?), + }) + } +} + +impl<'a> TryFrom for passkey::client::UnverifiedAssetLink<'a> { + type Error = InvalidOriginError; + + fn try_from(value: UnverifiedAssetLink) -> Result { + let asset_link_url = match value.asset_link_url { + Some(url) => Some(Url::parse(&url).map_err(|e| InvalidOriginError(format!("{}", e)))?), + None => None, + }; + + passkey::client::UnverifiedAssetLink::new( + Cow::from(value.package_name), + value.sha256_cert_fingerprint.as_str(), + Cow::from(value.host), + asset_link_url, + ) + .map_err(|e| InvalidOriginError(format!("{:?}", e))) + } +} + #[cfg(test)] mod tests { use serde::{Deserialize, Serialize}; diff --git a/crates/bitwarden-uniffi/src/platform/fido2.rs b/crates/bitwarden-uniffi/src/platform/fido2.rs index 3018d7beb..f483ff346 100644 --- a/crates/bitwarden-uniffi/src/platform/fido2.rs +++ b/crates/bitwarden-uniffi/src/platform/fido2.rs @@ -11,7 +11,7 @@ use bitwarden::{ }, vault::{Cipher, CipherView, Fido2CredentialNewView}, }; -use bitwarden_fido::Fido2CredentialAutofillView; +use bitwarden_fido::{Fido2CredentialAutofillView, Origin}; use crate::{error::Result, Client}; @@ -135,7 +135,7 @@ pub struct ClientFido2Client(pub(crate) ClientFido2Authenticator); impl ClientFido2Client { pub async fn register( &self, - origin: String, + origin: Origin, request: String, client_data: ClientData, ) -> Result { @@ -153,7 +153,7 @@ impl ClientFido2Client { pub async fn authenticate( &self, - origin: String, + origin: Origin, request: String, client_data: ClientData, ) -> Result { From 2f1717d3b08e34430b00b6be1af963d48a3c5e21 Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Wed, 18 Sep 2024 06:47:32 -0700 Subject: [PATCH 165/214] SM-1402 - review and update php sdk (#1032) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1402 ## 📔 Objective Update PHP bindings in accordance with our other wrappers. This renames any "put" methods to "update", refactors `access_token_login` to `auth().login_access_token`, re-orders function args for `create` and `update`, and adds secret syncing. This update required quite a few changes to the schemas. However, since we cannot auto-generate them with `quicktype` (see the error referenced in glideapps/quicktype/pull/2407), schemas were generated with the swaggest/json-cli: ```sh json-cli gen-php ../../support/schemas/schema_types/SchemaTypes.json --ns '\Bitwarden\Sdk\Schemas' --ns-path ./src/schemas/ ``` The generated schemas still required hand modification to get human-readable class names for things like `ProjectCommand`, `SecretCommand`, etc. To validate the changes, I've run the `example.php` file after updating the schemas. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --------- Co-authored-by: Maciej Zieniuk Co-authored-by: vphan916 <95309255+vphan916@users.noreply.github.com> Co-authored-by: Maciej Zieniuk <167752252+mzieniukbw@users.noreply.github.com> --- languages/php/.gitignore | 2 + languages/php/INSTALL.md | 56 +++++ languages/php/README.md | 133 +++++----- languages/php/composer.json | 4 +- languages/php/composer.lock | 230 +----------------- languages/php/example.php | 106 ++++++-- languages/php/src/AuthClient.php | 35 +++ languages/php/src/BitwardenClient.php | 55 ++--- languages/php/src/BitwardenLib.php | 75 ++++-- languages/php/src/CommandRunner.php | 22 +- languages/php/src/ProjectsClient.php | 75 +++--- languages/php/src/SecretsClient.php | 113 +++++---- .../src/schemas/AccessTokenLoginRequest.php | 39 --- .../src/schemas/BitwardenClassStructure.php | 11 - .../schemas/BitwardenClassStructureTrait.php | 189 -------------- languages/php/src/schemas/ClientSettings.php | 133 ---------- languages/php/src/schemas/Command.php | 44 ---- .../php/src/schemas/ProjectCreateRequest.php | 43 ---- .../php/src/schemas/ProjectGetRequest.php | 37 --- .../php/src/schemas/ProjectPutRequest.php | 50 ---- languages/php/src/schemas/ProjectsCommand.php | 55 ----- .../php/src/schemas/ProjectsDeleteRequest.php | 39 --- .../php/src/schemas/ProjectsListRequest.php | 38 --- .../php/src/schemas/SecretCreateRequest.php | 58 ----- .../php/src/schemas/SecretGetRequest.php | 38 --- .../src/schemas/SecretIdentifiersRequest.php | 38 --- .../php/src/schemas/SecretPutRequest.php | 64 ----- .../src/schemas/SecretVerificationRequest.php | 35 --- languages/php/src/schemas/SecretsCommand.php | 56 ----- .../php/src/schemas/SecretsDeleteRequest.php | 39 --- .../php/src/schemas/SecretsGetRequest.php | 39 --- support/scripts/schemas.ts | 21 ++ 32 files changed, 471 insertions(+), 1501 deletions(-) create mode 100644 languages/php/INSTALL.md create mode 100644 languages/php/src/AuthClient.php delete mode 100644 languages/php/src/schemas/AccessTokenLoginRequest.php delete mode 100644 languages/php/src/schemas/BitwardenClassStructure.php delete mode 100644 languages/php/src/schemas/BitwardenClassStructureTrait.php delete mode 100644 languages/php/src/schemas/ClientSettings.php delete mode 100644 languages/php/src/schemas/Command.php delete mode 100644 languages/php/src/schemas/ProjectCreateRequest.php delete mode 100644 languages/php/src/schemas/ProjectGetRequest.php delete mode 100644 languages/php/src/schemas/ProjectPutRequest.php delete mode 100644 languages/php/src/schemas/ProjectsCommand.php delete mode 100644 languages/php/src/schemas/ProjectsDeleteRequest.php delete mode 100644 languages/php/src/schemas/ProjectsListRequest.php delete mode 100644 languages/php/src/schemas/SecretCreateRequest.php delete mode 100644 languages/php/src/schemas/SecretGetRequest.php delete mode 100644 languages/php/src/schemas/SecretIdentifiersRequest.php delete mode 100644 languages/php/src/schemas/SecretPutRequest.php delete mode 100644 languages/php/src/schemas/SecretVerificationRequest.php delete mode 100644 languages/php/src/schemas/SecretsCommand.php delete mode 100644 languages/php/src/schemas/SecretsDeleteRequest.php delete mode 100644 languages/php/src/schemas/SecretsGetRequest.php diff --git a/languages/php/.gitignore b/languages/php/.gitignore index b2a69e9a0..5d6ed424e 100644 --- a/languages/php/.gitignore +++ b/languages/php/.gitignore @@ -1,2 +1,4 @@ .DS_Store vendor +src/lib/ +src/Schemas/ diff --git a/languages/php/INSTALL.md b/languages/php/INSTALL.md new file mode 100644 index 000000000..299053389 --- /dev/null +++ b/languages/php/INSTALL.md @@ -0,0 +1,56 @@ +# PHP Installation + +## Introduction + +Composer is used to build the PHP Bitwarden client library. + +## Prerequisites + +- PHP >= 8.0 +- FFI extension enabled in PHP configuration +- Composer +- Bitwarden SDK native library. + - Expected in one of below locations, depending on the OS and architecture. + The `src` is relative path to the [src](./src) directory. + - Windows x86_64: `src\lib\windows-x64\bitwarden_c.dll` + - Linux x86_64: `src/lib/linux-x64/libbitwarden_c.so` + - macOS x86_64: `src/lib/macos-x64/libbitwarden_c.dylib` + - macOS aarch64: `src/lib/macos-arm64/libbitwarden_c.dylib` + - If you prefer to build the SDK yourself, see the [SDK README.md](../../README.md) for instructions. + +## Build Commands + +```shell +composer install +``` + +## Example + +### macOS + +#### Install Prerequisites + +Use brew Composer and PHP + +```shell +brew install php +brew install composer +``` + +#### Build Commands + +```shell +composer install +``` + +## Example SDK Usage Project + +```shell +export ACCESS_TOKEN="" +export STATE_FILE="" +export ORGANIZATION_ID="" +export API_URL="https://api.bitwarden.com" +export IDENTITY_URL="https://identity.bitwarden.com" + +php example.php +``` diff --git a/languages/php/README.md b/languages/php/README.md index 9e4a9385d..61991bd0e 100644 --- a/languages/php/README.md +++ b/languages/php/README.md @@ -1,100 +1,121 @@ # Bitwarden Secrets Manager SDK wrapper for PHP PHP bindings for interacting with the [Bitwarden Secrets Manager]. This is a beta release and might be missing some functionality. -Supported are CRUD operations on project and secret entities. ## Installation -Requirements: -- PHP >= 8.0 -- Composer -- Bitwarden C libraries which you can generate using BitwardenSDK and following instructions in its readme (requires Rust). https://github.com/bitwarden/sdk -If you are not using the standalone version of this library, file will be placed in `target/debug` folder if you are using from BitwardenSDK repository. -- Access token for the Bitwarden account - +See the [installation instructions](./INSTALL.md) ## Usage -To interact with the client first you need to obtain the access token from Bitwarden. -You can then initialize BitwardenSettings passing $api_url and $identity_url if needed. These parameteres are -optional and if they are not defined, BitwardenSettings instance will try to get these values from ENV, and -if they are not defined there as well, it will use defaults: `https://api.bitwarden.com` as api_url and -`https://identity.bitwarden.com` as identity_url. You can also pass device type as argument but that is entirely -optional. +### Create access token -Passing BitwardenSettings instance to BitwardenClient will initialize it. Before using the client you must -be authorized by calling the access_token_login method passing your Bitwarden access token to it. +To interact with the client first you need to obtain the access token from Bitwarden. +Review the help documentation on [Access Tokens]. +### Create new Bitwarden client ```php -$access_token = ''; -$api_url = ""; -$identity_url = ""; +require_once 'vendor/autoload.php'; + +$access_token = ""; +$state_file = ""; +$organization_id = ""; +$api_url = "https://api.bitwarden.com"; +$identity_url = "https://identity.bitwarden.com"; + $bitwarden_settings = new \Bitwarden\Sdk\BitwardenSettings($api_url, $identity_url); $bitwarden_client = new \Bitwarden\Sdk\BitwardenClient($bitwarden_settings); -$bitwarden_client->access_token_login($access_token); +$bitwarden_client->auth->login_access_token($access_token, $state_file); ``` -After successful authorization you can interact with client to manage your projects and secrets. -```php -$organization_id = ""; +Initialize `BitwardenSettings` by passing `$api_url` and `$identity_url` or set to null to use the defaults. +The default for `api_url` is `https://api.bitwarden.com` and for `identity_url` is `https://identity.bitwarden.com`. -$bitwarden_client = new \Bitwarden\Sdk\BitwardenClient($bitwarden_settings); -$res = $bitwarden_client->access_token_login($access_token); +### Create new project -// create project -$name = "PHP project" -$res = $bitwarden_client->projects->create($name, $organization_id); +```php +$name = "PHP project"; +$res = $bitwarden_client->projects->create($organization_id, $name); $project_id = $res->id; +``` -// get project +### Get project + +```php $res = $bitwarden_client->projects->get($project_id); +``` + +### List all projects -// list projects +```php $res = $bitwarden_client->projects->list($organization_id); +``` -// update project -$name = "Updated PHP project" -$res = $bitwarden_client->projects->put($project_id, $name, $organization_id); +### Update project -// get secret -$res = $bitwarden_client->secrets->get($secret_id); +```php +$name = "Updated PHP project"; +$res = $bitwarden_client->projects->update($organization_id, $project_id, $name); +``` -// list secrets -$res = $bitwarden_client->secrets->list($organization_id); +### Delete project -// delete project +```php $res = $bitwarden_client->projects->delete([$project_id]); +``` +### Create new secret + +```php +$key = "Secret key"; +$note = "Secret note"; +$value = "Secret value"; +$res = $bitwarden_client->secrets->create($organization_id, $key, $value, $note, [$project_id]); +$secret_id = $res->id; ``` -Similarly, you interact with secrets: +### Get secret + ```php -$organization_id = ""; +$res = $bitwarden_client->secrets->get($secret_id); +``` -// create secret -$key = "AWS secret key"; -$note = "Private account"; -$secret = "76asaj,Is_)" -$res = $bitwarden_client->secrets->create($key, $note, $organization_id, [$project_id], $secret); -$secret_id = $res->id; +### Get multiple secrets -// get secret -$res = $bitwarden_sdk->secrets->get($secret_id); +```php +$res = $bitwarden_client->secrets->get_by_ids([$secret_id]); +``` -// list secrets +### List all secrets + +```php $res = $bitwarden_client->secrets->list($organization_id); +``` + +### Update secret + +```php +$key = "Updated key"; +$note = "Updated note"; +$value = "Updated value"; +$res = $bitwarden_client->secrets->update($organization_id, $secret_id, $key, $value, $note, [$project_id]); +``` -// update secret -$note = "Updated account"; -$key = "AWS private updated" -$secret = "7uYTE,:Aer" -$res = $bitwarden_client->secrets->update($secret_id, $key, $note, $organization_id, [$project_id], $secret); +### Sync secrets -// delete secret -$res = $bitwarden_sdk->secrets->delete([$secret_id]); +```php +$last_synced_date = "2024-09-01T00:00:00Z"; +$res = $bitwarden_client->secrets->sync($organization_id, $last_synced_date); +``` + +### Delete secret + +```php +$res = $bitwarden_client->secrets->delete([$secret_id]); ``` +[Access Tokens]: https://bitwarden.com/help/access-tokens/ [Bitwarden Secrets Manager]: https://bitwarden.com/products/secrets-manager/ diff --git a/languages/php/composer.json b/languages/php/composer.json index 85447e72a..fce61f890 100644 --- a/languages/php/composer.json +++ b/languages/php/composer.json @@ -7,13 +7,13 @@ "version": "0.1.0", "require": { "php": "^8.0", - "swaggest/json-schema": "^0.12.42", "ext-ffi": "*" }, "autoload": { "psr-4": { "Bitwarden\\Sdk\\": "src/" - } + }, + "files": ["src/Schemas/Schemas.php"] }, "authors": [ { diff --git a/languages/php/composer.lock b/languages/php/composer.lock index fc6b42c4f..187511304 100644 --- a/languages/php/composer.lock +++ b/languages/php/composer.lock @@ -4,234 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7081b1bfe099982a63ad06d5ab9fa66d", - "packages": [ - { - "name": "phplang/scope-exit", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/phplang/scope-exit.git", - "reference": "239b73abe89f9414aa85a7ca075ec9445629192b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phplang/scope-exit/zipball/239b73abe89f9414aa85a7ca075ec9445629192b", - "reference": "239b73abe89f9414aa85a7ca075ec9445629192b", - "shasum": "" - }, - "require-dev": { - "phpunit/phpunit": "*" - }, - "type": "library", - "autoload": { - "psr-4": { - "PhpLang\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD" - ], - "authors": [ - { - "name": "Sara Golemon", - "email": "pollita@php.net", - "homepage": "https://twitter.com/SaraMG", - "role": "Developer" - } - ], - "description": "Emulation of SCOPE_EXIT construct from C++", - "homepage": "https://github.com/phplang/scope-exit", - "keywords": [ - "cleanup", - "exit", - "scope" - ], - "support": { - "issues": "https://github.com/phplang/scope-exit/issues", - "source": "https://github.com/phplang/scope-exit/tree/master" - }, - "time": "2016-09-17T00:15:18+00:00" - }, - { - "name": "swaggest/json-diff", - "version": "v3.10.4", - "source": { - "type": "git", - "url": "https://github.com/swaggest/json-diff.git", - "reference": "f4e511708060ff7511a3743fab4aa484a062bcfb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/swaggest/json-diff/zipball/f4e511708060ff7511a3743fab4aa484a062bcfb", - "reference": "f4e511708060ff7511a3743fab4aa484a062bcfb", - "shasum": "" - }, - "require": { - "ext-json": "*" - }, - "require-dev": { - "phperf/phpunit": "4.8.37" - }, - "type": "library", - "autoload": { - "psr-4": { - "Swaggest\\JsonDiff\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Viacheslav Poturaev", - "email": "vearutop@gmail.com" - } - ], - "description": "JSON diff/rearrange/patch/pointer library for PHP", - "support": { - "issues": "https://github.com/swaggest/json-diff/issues", - "source": "https://github.com/swaggest/json-diff/tree/v3.10.4" - }, - "time": "2022-11-09T13:21:05+00:00" - }, - { - "name": "swaggest/json-schema", - "version": "v0.12.42", - "source": { - "type": "git", - "url": "https://github.com/swaggest/php-json-schema.git", - "reference": "d23adb53808b8e2da36f75bc0188546e4cbe3b45" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/swaggest/php-json-schema/zipball/d23adb53808b8e2da36f75bc0188546e4cbe3b45", - "reference": "d23adb53808b8e2da36f75bc0188546e4cbe3b45", - "shasum": "" - }, - "require": { - "ext-json": "*", - "php": ">=5.4", - "phplang/scope-exit": "^1.0", - "swaggest/json-diff": "^3.8.2", - "symfony/polyfill-mbstring": "^1.19" - }, - "require-dev": { - "phperf/phpunit": "4.8.37" - }, - "suggest": { - "ext-mbstring": "For better performance" - }, - "type": "library", - "autoload": { - "psr-4": { - "Swaggest\\JsonSchema\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Viacheslav Poturaev", - "email": "vearutop@gmail.com" - } - ], - "description": "High definition PHP structures with JSON-schema based validation", - "support": { - "email": "vearutop@gmail.com", - "issues": "https://github.com/swaggest/php-json-schema/issues", - "source": "https://github.com/swaggest/php-json-schema/tree/v0.12.42" - }, - "time": "2023-09-12T14:43:42+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.28.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "42292d99c55abe617799667f454222c54c60e229" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/42292d99c55abe617799667f454222c54c60e229", - "reference": "42292d99c55abe617799667f454222c54c60e229", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "provide": { - "ext-mbstring": "*" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.28-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.28.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2023-07-28T09:04:16+00:00" - } - ], + "content-hash": "1769eb8cdcb42d17f993aa0ef123895b", + "packages": [], "packages-dev": [], "aliases": [], "minimum-stability": "stable", diff --git a/languages/php/example.php b/languages/php/example.php index 7eafcb96a..864a4ca23 100644 --- a/languages/php/example.php +++ b/languages/php/example.php @@ -3,45 +3,101 @@ require_once 'vendor/autoload.php'; $access_token = getenv('ACCESS_TOKEN'); +$state_file = getenv('STATE_FILE'); $organization_id = getenv('ORGANIZATION_ID'); // Configuring the URLS is optional, set them to null to use the default values $api_url = getenv('API_URL'); $identity_url = getenv('IDENTITY_URL'); -$client_settings = new \Bitwarden\Sdk\BitwardenSettings($api_url, $identity_url); +try { + $client_settings = new \Bitwarden\Sdk\BitwardenSettings($api_url, $identity_url); -$bitwarden_client = new \Bitwarden\Sdk\BitwardenClient($client_settings); -$bitwarden_client->access_token_login($access_token); + $bitwarden_client = new \Bitwarden\Sdk\BitwardenClient($client_settings); -// create project -$res = $bitwarden_client->projects->create('php project', $organization_id); -$project_id = $res->id; + $bitwarden_client->auth->login_access_token($access_token, $state_file); -// get project -$res = $bitwarden_client->projects->get($project_id); + // create project + print("Projects:\n"); + $res = $bitwarden_client->projects->create($organization_id, 'php project'); + $project_id = $res->id; + print("\tcreate: '" . $project_id . "'\n\n"); -// list projects -$res = $bitwarden_client->projects->list($organization_id); + // get project + $res = $bitwarden_client->projects->get($project_id); + print("\tget: '" . $res->name . "'\n\n"); -// update project -$res = $bitwarden_client->projects->put($project_id, 'php test awesome', $organization_id); + // list projects + $res = $bitwarden_client->projects->list($organization_id); + print("\tlist:\n"); + foreach ($res->data as $project) { + print("\t\tID: '" . $project->id . "', Name: '" . $project->name . "'\n"); + } + print("\n"); -// create secret -$res = $bitwarden_client->secrets->create("New Key", "hello world", $organization_id, [$project_id], "123"); -$secret_id = $res->id; + // update project + $res = $bitwarden_client->projects->update($organization_id, $project_id, 'php test project'); + print("\tupdate: '" . $res->name . "'\n\n"); -// get secret -$res = $bitwarden_client->secrets->get($secret_id); + // sync secrets + print("Secrets:\n"); + print("\tSyncing secrets...\n"); + $res = $bitwarden_client->secrets->sync($organization_id, null); + $now = new DateTime(); + $now_string = $now->format('Y-m-d\TH:i:s.u\Z'); + print("\t\tSync has changes: " . ($res->hasChanges ? 'true' : 'false') . "\n\n"); -// list secrets -$res = $bitwarden_client->secrets->list($organization_id); + print("\tSyncing again to ensure no changes since last sync...\n"); + $res = $bitwarden_client->secrets->sync($organization_id, $now_string); + print("\t\tSync has changes: " . ($res->hasChanges ? 'true' : 'false') . "\n\n"); -// update secret -$res = $bitwarden_client->secrets->update($secret_id, "hello world 2", "hello", $organization_id, [$project_id], "123"); + // create secret + $res = $bitwarden_client->secrets->create($organization_id, "New Key", "New value", "New note", [$project_id]); + $secret_id = $res->id; + print("\tcreate: '" . $secret_id . "'\n\n"); -// delete secret -$res = $bitwarden_client->secrets->delete([$secret_id]); + // get secret + $res = $bitwarden_client->secrets->get($secret_id); + print("\tget: '" . $res->key . "'\n\n"); -// delete project -$res = $bitwarden_client->projects->delete([$project_id]); + // get multiple secrets by ids + $res = $bitwarden_client->secrets->get_by_ids([$secret_id]); + print("\tget_by_ids:\n"); + foreach ($res->data as $secret) { + print("\t\tID: '" . $secret->id . "', Key: '" . $secret->key . "'\n"); + } + print("\n"); + + // list secrets + $res = $bitwarden_client->secrets->list($organization_id); + print("\tlist:\n"); + foreach ($res->data as $secret) { + print("\t\tID: '" . $secret->id . "', Key: '" . $secret->key . "'\n"); + } + print("\n"); + + // update secret + $res = $bitwarden_client->secrets->update($organization_id, $secret_id, "Updated key", "Updated value", "Updated note", [$project_id]); + print("\tupdate: '" . $res->key . "'\n\n"); + + // delete secret + print("Cleaning up secrets and projects:\n"); + $res = $bitwarden_client->secrets->delete([$secret_id]); + print("\tdelete:\n"); + foreach ($res->data as $secret) { + print("\t\tdeleted secret: '" . $secret->id . "'\n"); + } + print("\n"); + + // delete project + $res = $bitwarden_client->projects->delete([$project_id]); + print("\tdelete:\n"); + foreach ($res->data as $project) { + print("\t\tdeleted project: '" . $project->id . "'\n"); + } + print("\n"); + +} catch (Exception $e) { + print("Error: " . $e->getMessage() . "\n"); + exit(1); +} diff --git a/languages/php/src/AuthClient.php b/languages/php/src/AuthClient.php new file mode 100644 index 000000000..449c76905 --- /dev/null +++ b/languages/php/src/AuthClient.php @@ -0,0 +1,35 @@ +commandRunner = $commandRunner; + } + + /** + * @throws Exception + */ + public function login_access_token(string $access_token, ?string $state_file): void + { + $access_token_request = new AccessTokenLoginRequest($access_token, $state_file); + $command = new Command(passwordLogin: null, apiKeyLogin: null, loginAccessToken: $access_token_request, + getUserApiKey: null, fingerprint: null, sync: null, secrets: null, projects: null, generators: null); + try { + $result = $this->commandRunner->run($command); + if (!isset($result->authenticated) || !$result->authenticated) { + throw new Exception("Unauthorized"); + } + } catch (Exception $exception) { + throw new Exception("Authorization error: " . $exception->getMessage()); + } + } +} diff --git a/languages/php/src/BitwardenClient.php b/languages/php/src/BitwardenClient.php index 79fccdf9c..c125b6aa7 100644 --- a/languages/php/src/BitwardenClient.php +++ b/languages/php/src/BitwardenClient.php @@ -2,59 +2,40 @@ namespace Bitwarden\Sdk; -use Bitwarden\Sdk\Schemas\AccessTokenLoginRequest; -use Bitwarden\Sdk\schemas\ClientSettings; -use Bitwarden\Sdk\Schemas\Command; -use FFI; -use Swaggest\JsonDiff\Exception; - +use Bitwarden\Sdk\Schemas\ClientSettings; +use Bitwarden\Sdk\Schemas\DeviceType; +use JsonException; class BitwardenClient { - private BitwardenLib $bitwarden_lib; - - private ClientSettings $clientSettings; - public ProjectsClient $projects; public SecretsClient $secrets; - private CommandRunner $commandRunner; + public AuthClient $auth; - private FFI\CData $handle; + private BitwardenLib $bitwarden_lib; + private ClientSettings $clientSettings; + + private CommandRunner $commandRunner; + + /** + * @throws JsonException + */ public function __construct(BitwardenSettings $bitwardenSettings) { - $this->clientSettings = new ClientSettings(); - $this->clientSettings->apiUrl = $bitwardenSettings->get_api_url(); - $this->clientSettings->identityUrl = $bitwardenSettings->get_identity_url(); - $this->clientSettings->userAgent = "Bitwarden PHP-SDK"; + $this->clientSettings = new ClientSettings(apiUrl: $bitwardenSettings->get_api_url(), + deviceType: DeviceType::$SDK, identityUrl: $bitwardenSettings->get_identity_url(), + userAgent: "Bitwarden PHP-SDK"); $this->bitwarden_lib = new BitwardenLib(); - $this->handle = $this->bitwarden_lib->init($this->clientSettings); + $this->bitwarden_lib->init($this->clientSettings); - $this->commandRunner = new CommandRunner($this->bitwarden_lib, $this->handle); + $this->commandRunner = new CommandRunner($this->bitwarden_lib); $this->projects = new ProjectsClient($this->commandRunner); $this->secrets = new SecretsClient($this->commandRunner); - } - - /** - * @throws \Exception - */ - public function access_token_login(string $access_token) - { - $access_token_request = new AccessTokenLoginRequest(); - $access_token_request->accessToken = $access_token; - $command = new Command(); - $command->accessTokenLogin = $access_token_request->jsonSerialize(); - $result = $this->commandRunner->run($command); - if (!isset($result->authenticated)) { - throw new \Exception("Authorization error"); - } - - if ($result->authenticated == False) { - throw new \Exception("Unauthorized"); - } + $this->auth = new AuthClient($this->commandRunner); } public function __destruct() diff --git a/languages/php/src/BitwardenLib.php b/languages/php/src/BitwardenLib.php index 351728986..53be3299b 100644 --- a/languages/php/src/BitwardenLib.php +++ b/languages/php/src/BitwardenLib.php @@ -4,10 +4,11 @@ use Bitwarden\Sdk\Schemas\ClientSettings; use Bitwarden\Sdk\Schemas\Command; +use Exception; use FFI; -use Swaggest\JsonDiff\Exception; -use Swaggest\JsonSchema\JsonSchema; - +use JsonException; +use RuntimeException; +use stdClass; class BitwardenLib { @@ -15,36 +16,36 @@ class BitwardenLib public FFI\CData $handle; /** - * @throws \Exception + * @throws Exception */ public function __construct() { $lib_file = null; if (PHP_OS === 'WINNT') { - $lib_file = '/lib/windows-x64/bitwarden_c.dll'; - if (file_exists($lib_file) == false) { - $lib_file = __DIR__.'/../../../target/debug/bitwarden_c.dll'; + $lib_file = __DIR__ . '/lib/windows-x64/bitwarden_c.dll'; + if (!file_exists($lib_file)) { + $lib_file = __DIR__ . '/../../../target/debug/bitwarden_c.dll'; } } elseif (PHP_OS === 'Linux') { - $lib_file = '/lib/linux-x64/libbitwarden_c.so'; - if (file_exists($lib_file) == false) { - $lib_file = __DIR__.'/../../../target/debug/libbitwarden_c.so'; + $lib_file = __DIR__ . '/lib/linux-x64/libbitwarden_c.so'; + if (!file_exists($lib_file)) { + $lib_file = __DIR__ . '/../../../target/debug/libbitwarden_c.so'; } } elseif (PHP_OS === 'Darwin') { $architecture = trim(exec('uname -m')); if ($architecture === 'x86_64' || $architecture === 'amd64') { - $lib_file = __DIR__.'/lib/macos-x64/libbitwarden_c.dylib'; + $lib_file = __DIR__ . '/lib/macos-x64/libbitwarden_c.dylib'; } elseif ($architecture === 'arm64') { - $lib_file = __DIR__.'/lib/macos-arm64/libbitwarden_c.dylib'; + $lib_file = __DIR__ . '/lib/macos-arm64/libbitwarden_c.dylib'; } - if (file_exists($lib_file) == false) { - $lib_file = __DIR__.'/../../../target/debug/libbitwarden_c.dylib'; + if (!file_exists($lib_file)) { + $lib_file = __DIR__ . '/../../../target/debug/libbitwarden_c.dylib'; } } - if ($lib_file == null || is_file($lib_file) == false) { - throw new \Exception("Lib file not found"); + if ($lib_file == null || !is_file($lib_file)) { + throw new Exception("Lib file not found"); } $this->ffi = FFI::cdef(' @@ -55,20 +56,29 @@ public function __construct() ); } + /** + * @throws JsonException + * @throws Exception + */ public function init(ClientSettings $client_settings): FFI\CData { - $this->handle = $this->ffi->init(json_encode($client_settings->jsonSerialize())); + $encoded_json = $this::json_encode_sdk_format($client_settings->to()); + $this->handle = $this->ffi->init($encoded_json); return $this->handle; } - public function run_command(Command $command): \stdClass + /** + * @throws JsonException + * @throws Exception + */ + public function run_command(Command $command): stdClass { - $encoded_json = json_encode($command->jsonSerialize()); + $encoded_json = $this::json_encode_sdk_format($command->to()); try { $result = $this->ffi->run_command($encoded_json, $this->handle); return json_decode(FFI::string($result)); - } catch (\FFI\Exception $e) { - throw new \RuntimeException('Error occurred during FFI operation: ' . $e->getMessage()); + } catch (FFI\Exception $e) { + throw new RuntimeException('Error occurred during FFI operation: ' . $e->getMessage()); } } @@ -76,4 +86,27 @@ public function free_mem(): void { $this->ffi->free_mem($this->handle); } + + /** + * @throws JsonException + */ + private static function json_encode_sdk_format($object): string + { + $withoutNull = function ($a) use (&$withoutNull) { + if (is_object($a)) { + $a = array_filter((array)$a); + foreach ($a as $k => $v) { + $a[$k] = $withoutNull($v); + } + + return (object)$a; + } + + return $a; + }; + + $object_no_nulls = $withoutNull($object); + + return json_encode($object_no_nulls, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES); + } } diff --git a/languages/php/src/CommandRunner.php b/languages/php/src/CommandRunner.php index 9eec68b2d..532b9625e 100644 --- a/languages/php/src/CommandRunner.php +++ b/languages/php/src/CommandRunner.php @@ -2,36 +2,32 @@ namespace Bitwarden\Sdk; - use Bitwarden\Sdk\Schemas\Command; -use FFI; +use Exception; +use stdClass; class CommandRunner { - private FFI\CData $handle; - private BitwardenLib $bitwardenLib; - public function __construct(BitwardenLib $bitwardenLib, $handle) + public function __construct(BitwardenLib $bitwardenLib) { $this->bitwardenLib = $bitwardenLib; - $this->handle = $handle; } /** - * @throws \Exception + * @throws Exception */ - public function run(Command $command): \stdClass + public function run(Command $command): stdClass { $result = $this->bitwardenLib->run_command($command); - if ($result->success == true) { + if ($result->success) { return $result->data; } - if (isset($result->errorMessage)) - { - throw new \Exception($result->errorMessage); + if (isset($result->errorMessage)) { + throw new Exception($result->errorMessage); } - throw new \Exception("Unknown error occurred"); + throw new Exception("Unknown error occurred"); } } diff --git a/languages/php/src/ProjectsClient.php b/languages/php/src/ProjectsClient.php index 6b6f9fb6a..cca44f1e6 100644 --- a/languages/php/src/ProjectsClient.php +++ b/languages/php/src/ProjectsClient.php @@ -9,6 +9,8 @@ use Bitwarden\Sdk\Schemas\ProjectsCommand; use Bitwarden\Sdk\Schemas\ProjectsDeleteRequest; use Bitwarden\Sdk\Schemas\ProjectsListRequest; +use Exception; +use stdClass; class ProjectsClient { @@ -19,63 +21,74 @@ public function __construct(CommandRunner $commandRunner) $this->commandRunner = $commandRunner; } - public function get(string $project_id): \stdClass + /** + * @throws Exception + */ + public function get(string $project_id): stdClass { - $project_get_request = new ProjectGetRequest(); - $project_get_request->id = $project_id; + $project_get_request = new ProjectGetRequest($project_id); $project_get_request->validate(); - $project_command = new ProjectsCommand(); - $project_command->get = $project_get_request->jsonSerialize(); + $project_command = new ProjectsCommand(get: $project_get_request, create: null, list: null, update: null, + delete: null); return $this->run_project_command($project_command); } - public function list(string $organization_id): \stdClass + /** + * @throws Exception + */ + public function list(string $organization_id): stdClass { - $project_list_request = new ProjectsListRequest(); - $project_list_request->organizationId = $organization_id; + $project_list_request = new ProjectsListRequest($organization_id); $project_list_request->validate(); - $project_command = new ProjectsCommand(); - $project_command->list = $project_list_request->jsonSerialize(); + $project_command = new ProjectsCommand(get: null, create: null, list: $project_list_request, update: null, + delete: null); return $this->run_project_command($project_command); } - public function create(string $project_name, string $organization_id): \stdClass + /** + * @throws Exception + */ + public function create(string $organization_id, string $project_name): stdClass { - $project_create_request = new ProjectCreateRequest(); - $project_create_request->name = $project_name; - $project_create_request->organizationId = $organization_id; + $project_create_request = new ProjectCreateRequest(name: $project_name, organizationId: $organization_id); $project_create_request->validate(); - $project_command = new ProjectsCommand(); - $project_command->create = $project_create_request->jsonSerialize(); + $project_command = new ProjectsCommand(get: null, create: $project_create_request, list: null, update: null, + delete: null); return $this->run_project_command($project_command); } - public function put(string $project_id, string $project_name, string $organization_id): \stdClass + /** + * @throws Exception + */ + public function update(string $organization_id, string $project_id, string $project_name): stdClass { - $project_put_request = new ProjectPutRequest(); - $project_put_request->organizationId = $organization_id; - $project_put_request->name = $project_name; - $project_put_request->id = $project_id; + $project_put_request = new ProjectPutRequest(id: $project_id, name: $project_name, + organizationId: $organization_id); $project_put_request->validate(); - $project_command = new ProjectsCommand(); - $project_command->update = $project_put_request->jsonSerialize(); + $project_command = new ProjectsCommand(get: null, create: null, list: null, update: $project_put_request, + delete: null); return $this->run_project_command($project_command); } - public function delete(array $ids): \stdClass + /** + * @throws Exception + */ + public function delete(array $ids): stdClass { - $projects_delete_request = new ProjectsDeleteRequest(); - $projects_delete_request->ids = $ids; + $projects_delete_request = new ProjectsDeleteRequest($ids); $projects_delete_request->validate(); - $project_command = new ProjectsCommand(); - $project_command->delete = $projects_delete_request->jsonSerialize(); + $project_command = new ProjectsCommand(get: null, create: null, list: null, update: null, + delete: $projects_delete_request); return $this->run_project_command($project_command); } - public function run_project_command($projectCommand): \stdClass + /** + * @throws Exception + */ + public function run_project_command($projectCommand): stdClass { - $command = new Command(); - $command->projects = $projectCommand; + $command = new Command(passwordLogin: null, apiKeyLogin: null, loginAccessToken: null, getUserApiKey: null, + fingerprint: null, sync: null, secrets: null, projects: $projectCommand, generators: null); return $this->commandRunner->run($command); } } diff --git a/languages/php/src/SecretsClient.php b/languages/php/src/SecretsClient.php index d5c0b0cef..85bc334d5 100644 --- a/languages/php/src/SecretsClient.php +++ b/languages/php/src/SecretsClient.php @@ -10,6 +10,9 @@ use Bitwarden\Sdk\Schemas\SecretsCommand; use Bitwarden\Sdk\Schemas\SecretsDeleteRequest; use Bitwarden\Sdk\Schemas\SecretsGetRequest; +use Bitwarden\Sdk\Schemas\SecretsSyncRequest; +use Exception; +use stdClass; class SecretsClient { @@ -20,79 +23,103 @@ public function __construct(CommandRunner $commandRunner) $this->commandRunner = $commandRunner; } - public function get(string $secret_id): \stdClass + /** + * @throws Exception + */ + public function get(string $secret_id): stdClass { - $secret_get_request = new SecretGetRequest(); - $secret_get_request->id = $secret_id; + $secret_get_request = new SecretGetRequest($secret_id); $secret_get_request->validate(); - $secret_command = new SecretsCommand(); - $secret_command->get = $secret_get_request->jsonSerialize(); - return $this->run_secret_command($secret_command); + $secrets_command = new SecretsCommand(get: $secret_get_request, getByIds: null, create: null, list: null, + update: null, delete: null, sync: null); + return $this->run_secret_command($secrets_command); } - public function get_by_ids(array $secret_ids): \stdClass + /** + * @throws Exception + */ + public function get_by_ids(array $secret_ids): stdClass { - $project_get_by_ids_request = new SecretsGetRequest(); - $project_get_by_ids_request->ids = $secret_ids; + $project_get_by_ids_request = new SecretsGetRequest($secret_ids); $project_get_by_ids_request->validate(); - $secrets_command = new SecretsCommand(); - $secrets_command->get_by_ids = $project_get_by_ids_request->jsonSerialize(); + $secrets_command = new SecretsCommand(get: null, getByIds: $project_get_by_ids_request, create: null, list: null, + update: null, delete: null, sync: null); return $this->run_secret_command($secrets_command); } - public function list(string $organization_id): \stdClass + /** + * @throws Exception + */ + public function list(string $organization_id): stdClass { - $secrets_list_request = new SecretIdentifiersRequest(); - $secrets_list_request->organizationId = $organization_id; + $secrets_list_request = new SecretIdentifiersRequest($organization_id); $secrets_list_request->validate(); - $secrets_command = new SecretsCommand(); - $secrets_command->list = $secrets_list_request->jsonSerialize(); + $secrets_command = new SecretsCommand(get: null, getByIds: null, create: null, list: $secrets_list_request, + update: null, delete: null, sync: null); return $this->run_secret_command($secrets_command); } - public function create(string $key, string $note, string $organization_id, array $project_ids, string $value): \stdClass + /** + * @throws Exception + */ + public function create(string $organization_id, string $key, string $value, string $note, array $project_ids): stdClass { - $secrets_create_request = new SecretCreateRequest(); - $secrets_create_request->organizationId = $organization_id; - $secrets_create_request->projectIds = $project_ids; - $secrets_create_request->key = $key; - $secrets_create_request->note = $note; - $secrets_create_request->value = $value; + $secrets_create_request = new SecretCreateRequest(key: $key, note: $note, organizationId: $organization_id, + projectIds: $project_ids, value: $value); $secrets_create_request->validate(); - $secrets_command = new SecretsCommand(); - $secrets_command->create = $secrets_create_request->jsonSerialize(); + $secrets_command = new SecretsCommand(get: null, getByIds: null, create: $secrets_create_request, list: null, + update: null, delete: null, sync: null); return $this->run_secret_command($secrets_command); } - public function update(string $id, string $key, string $note, string $organization_id, array $project_ids, string $value): \stdClass + /** + * @throws Exception + */ + public function update(string $organization_id, string $id, string $key, string $value, string $note, array $project_ids): stdClass { - $secrets_put_request = new SecretPutRequest(); - $secrets_put_request->id = $id; - $secrets_put_request->organizationId = $organization_id; - $secrets_put_request->projectIds = $project_ids; - $secrets_put_request->key = $key; - $secrets_put_request->note = $note; - $secrets_put_request->value = $value; + $secrets_put_request = new SecretPutRequest(id: $id, key: $key, note: $note, organizationId: $organization_id, + projectIds: $project_ids, value: $value); $secrets_put_request->validate(); - $secrets_command = new SecretsCommand(); - $secrets_command->update = $secrets_put_request->jsonSerialize(); + $secrets_command = new SecretsCommand(get: null, getByIds: null, create: null, list: null, + update: $secrets_put_request, delete: null, sync: null); return $this->run_secret_command($secrets_command); } - public function delete(array $secrets_ids): \stdClass + /** + * @throws Exception + */ + public function delete(array $secrets_ids): stdClass { - $secrets_delete_request = new SecretsDeleteRequest(); - $secrets_delete_request->ids = $secrets_ids; + $secrets_delete_request = new SecretsDeleteRequest($secrets_ids); $secrets_delete_request->validate(); - $secrets_command = new SecretsCommand(); - $secrets_command->delete = $secrets_delete_request->jsonSerialize(); + $secrets_command = new SecretsCommand(get: null, getByIds: null, create: null, list: null, + update: null, delete: $secrets_delete_request, sync: null); + return $this->run_secret_command($secrets_command); + } + + /** + * @throws Exception + */ + public function sync(string $organization_id, ?string $last_synced_date): stdClass + { + if (empty($last_synced_date)) { + $last_synced_date = "1970-01-01T00:00:00.000Z"; + } + + $secrets_sync_request = new SecretsSyncRequest(lastSyncedDate: $last_synced_date, organizationId: $organization_id); + $secrets_sync_request->validate(); + $secrets_command = new SecretsCommand(get: null, getByIds: null, create: null, list: null, + update: null, delete: null, sync: $secrets_sync_request); return $this->run_secret_command($secrets_command); } - public function run_secret_command($secretsCommand): \stdClass + /** + * @throws Exception + */ + public function run_secret_command($secretsCommand): stdClass { - $command = new Command(); - $command->secrets = $secretsCommand; + $command = new Command(passwordLogin: null, apiKeyLogin: null, loginAccessToken: null, getUserApiKey: null, + fingerprint: null, sync: null, secrets: $secretsCommand, projects: null, generators: null); return $this->commandRunner->run($command); } } diff --git a/languages/php/src/schemas/AccessTokenLoginRequest.php b/languages/php/src/schemas/AccessTokenLoginRequest.php deleted file mode 100644 index a08805f92..000000000 --- a/languages/php/src/schemas/AccessTokenLoginRequest.php +++ /dev/null @@ -1,39 +0,0 @@ -accessToken = Schema::string(); - $properties->accessToken->description = "Bitwarden service API access token"; - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - $ownerSchema->description = "Login to Bitwarden with access token"; - $ownerSchema->required = array( - self::names()->accessToken, - ); - $ownerSchema->setFromRef('#/definitions/AccessTokenLoginRequest'); - } -} diff --git a/languages/php/src/schemas/BitwardenClassStructure.php b/languages/php/src/schemas/BitwardenClassStructure.php deleted file mode 100644 index fd50354d4..000000000 --- a/languages/php/src/schemas/BitwardenClassStructure.php +++ /dev/null @@ -1,11 +0,0 @@ -properties = $properties; - $schema->objectItemClass = $className; - $schemaWrapper = new Wrapper($schema); - static::setUpProperties($properties, $schema); - if (null === $schema->getFromRefs()) { - $schema->setFromRef('#/definitions/' . $className); - } - if ($properties->isEmpty()) { - $schema->properties = null; - } - $properties->lock(); - } - - return $schemaWrapper; - } - - /** - * @return Properties|static|null - */ - public static function properties() - { - return static::schema()->getProperties(); - } - - /** - * @param mixed $data - * @param Context $options - * @return static|mixed - * @throws \Swaggest\JsonSchema\Exception - * @throws \Swaggest\JsonSchema\InvalidValue - */ - public static function import($data, Context $options = null) - { - return static::schema()->in($data, $options); - } - - /** - * @param mixed $data - * @param Context $options - * @return mixed - * @throws \Swaggest\JsonSchema\InvalidValue - * @throws \Exception - */ - public static function export($data, Context $options = null) - { - return static::schema()->out($data, $options); - } - - /** - * @param ObjectItemContract $objectItem - * @return static - */ - public static function pick(ObjectItemContract $objectItem) - { - $className = get_called_class(); - return $objectItem->getNestedObject($className); - } - - /** - * @return static - */ - public static function create() - { - return new static; - } - - protected $__validateOnSet = true; // todo skip validation during import - - /** - * @return \stdClass - */ - #[\ReturnTypeWillChange] - public function jsonSerialize() - { - $result = new \stdClass(); - $schema = static::schema(); - $properties = $schema->getProperties(); - $processed = array(); - if (null !== $properties) { - foreach ($properties->getDataKeyMap() as $propertyName => $dataName) { - $value = $this->$propertyName ?? null; - - // Value is exported if exists. - if (null !== $value || array_key_exists($propertyName, $this->__arrayOfData)) { - $result->$dataName = $value; - $processed[$propertyName] = true; - continue; - } - - // Non-existent value is only exported if belongs to nullable property (having 'null' in type array). - $property = $schema->getProperty($propertyName); - if ($property instanceof Schema) { - $types = $property->type; - if ($types === Schema::NULL || (is_array($types) && in_array(Schema::NULL, $types))) { - $result->$dataName = $value; - } - } - } - } - foreach ($schema->getNestedPropertyNames() as $name) { - /** @var ObjectItem $nested */ - $nested = $this->$name; - if (null !== $nested) { - foreach ((array)$nested->jsonSerialize() as $key => $value) { - $result->$key = $value; - } - } - } - - if (!empty($this->__arrayOfData)) { - foreach ($this->__arrayOfData as $name => $value) { - if (!isset($processed[$name])) { - $result->$name = $this->{$name}; - } - } - } - - return $result; - } - - /** - * @return static|NameMirror - */ - public static function names(Properties $properties = null, $mapping = Schema::DEFAULT_MAPPING) - { - if ($properties !== null) { - return new NameMirror($properties->getDataKeyMap($mapping)); - } - - static $nameflector = null; - if (null === $nameflector) { - $nameflector = new NameMirror(); - } - return $nameflector; - } - - public function __set($name, $column) // todo nested schemas - { - if ($this->__validateOnSet) { - if ($property = static::schema()->getProperty($name)) { - $property->out($column); - } - } - $this->__arrayOfData[$name] = $column; - return $this; - } - - public static function className() - { - return get_called_class(); - } - - /** - * @throws \Exception - * @throws \Swaggest\JsonSchema\InvalidValue - */ - public function validate() - { - static::schema()->out($this); - } -} - diff --git a/languages/php/src/schemas/ClientSettings.php b/languages/php/src/schemas/ClientSettings.php deleted file mode 100644 index c27cc3322..000000000 --- a/languages/php/src/schemas/ClientSettings.php +++ /dev/null @@ -1,133 +0,0 @@ -identityUrl = Schema::string(); - $properties->identityUrl->description = "The identity url of the targeted Bitwarden instance. Defaults to `https://identity.bitwarden.com`"; - $properties->identityUrl->default = "https://identity.bitwarden.com"; - $properties->apiUrl = Schema::string(); - $properties->apiUrl->description = "The api url of the targeted Bitwarden instance. Defaults to `https://api.bitwarden.com`"; - $properties->apiUrl->default = "https://api.bitwarden.com"; - $properties->userAgent = Schema::string(); - $properties->userAgent->description = "The user_agent to sent to Bitwarden. Defaults to `Bitwarden Rust-SDK`"; - $properties->userAgent->default = "Bitwarden Rust-SDK"; - $properties->deviceType = new Schema(); - $propertiesDeviceTypeAllOf0 = Schema::string(); - $propertiesDeviceTypeAllOf0->enum = array( - self::ANDROID, - self::I_OS, - self::CHROME_EXTENSION, - self::FIREFOX_EXTENSION, - self::OPERA_EXTENSION, - self::EDGE_EXTENSION, - self::WINDOWS_DESKTOP, - self::MAC_OS_DESKTOP, - self::LINUX_DESKTOP, - self::CHROME_BROWSER, - self::FIREFOX_BROWSER, - self::OPERA_BROWSER, - self::EDGE_BROWSER, - self::IE_BROWSER, - self::UNKNOWN_BROWSER, - self::ANDROID_AMAZON, - self::UWP, - self::SAFARI_BROWSER, - self::VIVALDI_BROWSER, - self::VIVALDI_EXTENSION, - self::SAFARI_EXTENSION, - self::SDK, - ); - $propertiesDeviceTypeAllOf0->setFromRef('#/definitions/DeviceType'); - $properties->deviceType->allOf[0] = $propertiesDeviceTypeAllOf0; - $properties->deviceType->description = "Device type to send to Bitwarden. Defaults to SDK"; - $properties->deviceType->default = "SDK"; - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - $ownerSchema->schema = "http://json-schema.org/draft-07/schema#"; - $ownerSchema->title = "ClientSettings"; - $ownerSchema->description = "Basic client behavior settings. These settings specify the various targets and behavior of the Bitwarden Client. They are optional and uneditable once the client is initialized.\n\nDefaults to\n\n``` # use bitwarden::client::client_settings::{ClientSettings, DeviceType}; # use assert_matches::assert_matches; let settings = ClientSettings { identity_url: \"https://identity.bitwarden.com\".to_string(), api_url: \"https://api.bitwarden.com\".to_string(), user_agent: \"Bitwarden Rust-SDK\".to_string(), device_type: DeviceType::SDK, }; let default = ClientSettings::default(); assert_matches!(settings, default); ```\n\nTargets `localhost:8080` for debug builds."; - } -} diff --git a/languages/php/src/schemas/Command.php b/languages/php/src/schemas/Command.php deleted file mode 100644 index cbd649c2f..000000000 --- a/languages/php/src/schemas/Command.php +++ /dev/null @@ -1,44 +0,0 @@ -projects = ProjectsCommand::schema(); - $properties->secrets = SecretsCommand::schema(); - $properties->accessTokenLogin = AccessTokenLoginRequest::schema(); - - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - - $ownerSchema->oneOf = array( - self::names()->projects, - self::names()->secrets, - self::names()->accessTokenLogin, - ); - } -} diff --git a/languages/php/src/schemas/ProjectCreateRequest.php b/languages/php/src/schemas/ProjectCreateRequest.php deleted file mode 100644 index 6a4e0f082..000000000 --- a/languages/php/src/schemas/ProjectCreateRequest.php +++ /dev/null @@ -1,43 +0,0 @@ -organizationId = Schema::string(); - $properties->organizationId->description = "Organization where the project will be created"; - $properties->organizationId->format = "uuid"; - $properties->name = Schema::string(); - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - $ownerSchema->required = array( - self::names()->name, - self::names()->organizationId, - ); - $ownerSchema->setFromRef('#/definitions/ProjectCreateRequest'); - } -} diff --git a/languages/php/src/schemas/ProjectGetRequest.php b/languages/php/src/schemas/ProjectGetRequest.php deleted file mode 100644 index 972bf18ec..000000000 --- a/languages/php/src/schemas/ProjectGetRequest.php +++ /dev/null @@ -1,37 +0,0 @@ -id = Schema::string(); - $properties->id->description = "ID of the project to retrieve"; - $properties->id->format = "uuid"; - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - $ownerSchema->required = array( - self::names()->id, - ); - $ownerSchema->setFromRef('#/definitions/ProjectGetRequest'); - } -} diff --git a/languages/php/src/schemas/ProjectPutRequest.php b/languages/php/src/schemas/ProjectPutRequest.php deleted file mode 100644 index 96b9705e7..000000000 --- a/languages/php/src/schemas/ProjectPutRequest.php +++ /dev/null @@ -1,50 +0,0 @@ -id = Schema::string(); - $properties->id->description = "ID of the project to modify"; - $properties->id->format = "uuid"; - $properties->organizationId = Schema::string(); - $properties->organizationId->description = "Organization ID of the project to modify"; - $properties->organizationId->format = "uuid"; - $properties->name = Schema::string(); - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - $ownerSchema->required = array( - self::names()->id, - self::names()->name, - self::names()->organizationId, - ); - $ownerSchema->setFromRef('#/definitions/ProjectPutRequest'); - } -} diff --git a/languages/php/src/schemas/ProjectsCommand.php b/languages/php/src/schemas/ProjectsCommand.php deleted file mode 100644 index 22645db3c..000000000 --- a/languages/php/src/schemas/ProjectsCommand.php +++ /dev/null @@ -1,55 +0,0 @@ - Requires Authentication > Requires using an Access Token for login or calling Sync at least once Deletes all the projects whose IDs match the provided ones - * - * Returns: [ProjectsDeleteResponse](bitwarden::secrets_manager::projects::ProjectsDeleteResponse) - */ -class ProjectsCommand extends BitwardenClassStructure -{ - public ?\stdClass $delete; - - public ?\stdClass $get; - - public ?\stdClass $list; - - public ?\stdClass $create; - - public ?\stdClass $update; - - - /** - * @param Properties|static $properties - * @param Schema $ownerSchema - */ - public static function setUpProperties($properties, Schema $ownerSchema) - { - $properties->delete = ProjectsDeleteRequest::schema() ? ProjectsDeleteRequest::schema() : null; - $properties->get = ProjectGetRequest::schema() ? ProjectGetRequest::schema() : null; - $properties->list = ProjectsListRequest::schema() ? ProjectsListRequest::schema() : null; - $properties->update = ProjectPutRequest::schema() ? ProjectPutRequest::schema() : null; - $properties->create = ProjectCreateRequest::schema() ? ProjectCreateRequest::schema() : null; - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - $ownerSchema->description = "> Requires Authentication > Requires using an Access Token for login or calling Sync at least once Deletes all the projects whose IDs match the provided ones\n\nReturns: [ProjectsDeleteResponse](bitwarden::secrets_manager::projects::ProjectsDeleteResponse)"; - - $ownerSchema->oneOf = array( - self::names()->create, - self::names()->delete, - self::names()->get, - self::names()->list, - self::names()->update, - ); - } -} diff --git a/languages/php/src/schemas/ProjectsDeleteRequest.php b/languages/php/src/schemas/ProjectsDeleteRequest.php deleted file mode 100644 index 87a7cfad7..000000000 --- a/languages/php/src/schemas/ProjectsDeleteRequest.php +++ /dev/null @@ -1,39 +0,0 @@ -ids = Schema::arr(); - $properties->ids->items = Schema::string(); - $properties->ids->items->format = "uuid"; - $properties->ids->description = "IDs of the projects to delete"; - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - $ownerSchema->required = array( - self::names()->ids, - ); - $ownerSchema->setFromRef('#/definitions/ProjectsDeleteRequest'); - } -} diff --git a/languages/php/src/schemas/ProjectsListRequest.php b/languages/php/src/schemas/ProjectsListRequest.php deleted file mode 100644 index cc1a9474f..000000000 --- a/languages/php/src/schemas/ProjectsListRequest.php +++ /dev/null @@ -1,38 +0,0 @@ -organizationId = Schema::string(); - $properties->organizationId->description = "Organization to retrieve all the projects from"; - $properties->organizationId->format = "uuid"; - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - $ownerSchema->required = array( - self::names()->organizationId, - ); - $ownerSchema->setFromRef('#/definitions/ProjectsListRequest'); - } -} diff --git a/languages/php/src/schemas/SecretCreateRequest.php b/languages/php/src/schemas/SecretCreateRequest.php deleted file mode 100644 index d34b36e98..000000000 --- a/languages/php/src/schemas/SecretCreateRequest.php +++ /dev/null @@ -1,58 +0,0 @@ -organizationId = Schema::string(); - $properties->organizationId->description = "Organization where the secret will be created"; - $properties->organizationId->format = "uuid"; - $properties->key = Schema::string(); - $properties->value = Schema::string(); - $properties->note = Schema::string(); - $properties->projectIds = (new Schema())->setType([Schema::_ARRAY, Schema::NULL]); - $properties->projectIds->items = Schema::string(); - $properties->projectIds->items->format = "uuid"; - $properties->projectIds->description = "IDs of the projects that this secret will belong to"; - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - $ownerSchema->required = array( - self::names()->key, - self::names()->note, - self::names()->organizationId, - self::names()->value, - ); - $ownerSchema->setFromRef('#/definitions/SecretCreateRequest'); - } -} diff --git a/languages/php/src/schemas/SecretGetRequest.php b/languages/php/src/schemas/SecretGetRequest.php deleted file mode 100644 index f31f7cad3..000000000 --- a/languages/php/src/schemas/SecretGetRequest.php +++ /dev/null @@ -1,38 +0,0 @@ -id = Schema::string(); - $properties->id->description = "ID of the secret to retrieve"; - $properties->id->format = "uuid"; - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - $ownerSchema->required = array( - self::names()->id, - ); - $ownerSchema->setFromRef('#/definitions/SecretGetRequest'); - } -} diff --git a/languages/php/src/schemas/SecretIdentifiersRequest.php b/languages/php/src/schemas/SecretIdentifiersRequest.php deleted file mode 100644 index b4e75b801..000000000 --- a/languages/php/src/schemas/SecretIdentifiersRequest.php +++ /dev/null @@ -1,38 +0,0 @@ -organizationId = Schema::string(); - $properties->organizationId->description = "Organization to retrieve all the secrets from"; - $properties->organizationId->format = "uuid"; - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - $ownerSchema->required = array( - self::names()->organizationId, - ); - $ownerSchema->setFromRef('#/definitions/SecretIdentifiersRequest'); - } -} diff --git a/languages/php/src/schemas/SecretPutRequest.php b/languages/php/src/schemas/SecretPutRequest.php deleted file mode 100644 index d890a909d..000000000 --- a/languages/php/src/schemas/SecretPutRequest.php +++ /dev/null @@ -1,64 +0,0 @@ -id = Schema::string(); - $properties->id->description = "ID of the secret to modify"; - $properties->id->format = "uuid"; - $properties->organizationId = Schema::string(); - $properties->organizationId->description = "Organization ID of the secret to modify"; - $properties->organizationId->format = "uuid"; - $properties->key = Schema::string(); - $properties->value = Schema::string(); - $properties->note = Schema::string(); - $properties->projectIds = (new Schema())->setType([Schema::_ARRAY, Schema::NULL]); - $properties->projectIds->items = Schema::string(); - $properties->projectIds->items->format = "uuid"; - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - $ownerSchema->required = array( - self::names()->id, - self::names()->key, - self::names()->note, - self::names()->organizationId, - self::names()->value, - ); - $ownerSchema->setFromRef('#/definitions/SecretPutRequest'); - } -} diff --git a/languages/php/src/schemas/SecretVerificationRequest.php b/languages/php/src/schemas/SecretVerificationRequest.php deleted file mode 100644 index 95cfd1e15..000000000 --- a/languages/php/src/schemas/SecretVerificationRequest.php +++ /dev/null @@ -1,35 +0,0 @@ -masterPassword = (new Schema())->setType([Schema::STRING, Schema::NULL]); - $properties->masterPassword->description = "The user's master password to use for user verification. If supplied, this will be used for verification purposes."; - $properties->otp = (new Schema())->setType([Schema::STRING, Schema::NULL]); - $properties->otp->description = "Alternate user verification method through OTP. This is provided for users who have no master password due to use of Customer Managed Encryption. Must be present and valid if master_password is absent."; - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - $ownerSchema->setFromRef('#/definitions/SecretVerificationRequest'); - } -} diff --git a/languages/php/src/schemas/SecretsCommand.php b/languages/php/src/schemas/SecretsCommand.php deleted file mode 100644 index 1ed8c97c5..000000000 --- a/languages/php/src/schemas/SecretsCommand.php +++ /dev/null @@ -1,56 +0,0 @@ - Requires Authentication > Requires using an Access Token for login or calling Sync at least once Deletes all the secrets whose IDs match the provided ones - * - * Returns: [SecretsDeleteResponse](bitwarden::secrets_manager::secrets::SecretsDeleteResponse) - */ -class SecretsCommand extends BitwardenClassStructure -{ - public ?\stdClass $delete; - - public ?\stdClass $get; - - public ?\stdClass $getByIds; - - public ?\stdClass $list; - - public ?\stdClass $create; - - public ?\stdClass $put; - - /** - * @param Properties|static $properties - * @param Schema $ownerSchema - */ - public static function setUpProperties($properties, Schema $ownerSchema) - { - $properties->delete = SecretsDeleteRequest::schema() ? SecretsDeleteRequest::schema() : null; - $properties->getByIds = SecretsGetRequest::schema() ? SecretGetRequest::schema() : null; - $properties->create = SecretCreateRequest::schema() ? SecretCreateRequest::schema() : null; - $properties->put = SecretPutRequest::schema() ? SecretPutRequest::schema() : null; - $properties->list = SecretIdentifiersRequest::schema() ? SecretIdentifiersRequest::schema() : null; - $properties->get = SecretsGetRequest::schema() ? SecretGetRequest::schema() : null; - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - $ownerSchema->description = "> Requires Authentication > Requires using an Access Token for login or calling Sync at least once Deletes all the secrets whose IDs match the provided ones\n\nReturns: [SecretsDeleteResponse](bitwarden::secrets_manager::secrets::SecretsDeleteResponse)"; - $ownerSchema->oneOf = array( - self::names()->create, - self::names()->put, - self::names()->list, - self::names()->getByIds, - self::names()->delete, - ); - } -} diff --git a/languages/php/src/schemas/SecretsDeleteRequest.php b/languages/php/src/schemas/SecretsDeleteRequest.php deleted file mode 100644 index 35138fcb1..000000000 --- a/languages/php/src/schemas/SecretsDeleteRequest.php +++ /dev/null @@ -1,39 +0,0 @@ -ids = Schema::arr(); - $properties->ids->items = Schema::string(); - $properties->ids->items->format = "uuid"; - $properties->ids->description = "IDs of the secrets to delete"; - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - $ownerSchema->required = array( - self::names()->ids, - ); - $ownerSchema->setFromRef('#/definitions/SecretsDeleteRequest'); - } -} diff --git a/languages/php/src/schemas/SecretsGetRequest.php b/languages/php/src/schemas/SecretsGetRequest.php deleted file mode 100644 index 4758dabf4..000000000 --- a/languages/php/src/schemas/SecretsGetRequest.php +++ /dev/null @@ -1,39 +0,0 @@ -ids = Schema::arr(); - $properties->ids->items = Schema::string(); - $properties->ids->items->format = "uuid"; - $properties->ids->description = "IDs of the secrets to retrieve"; - $ownerSchema->type = Schema::OBJECT; - $ownerSchema->additionalProperties = false; - $ownerSchema->required = array( - self::names()->ids, - ); - $ownerSchema->setFromRef('#/definitions/SecretsGetRequest'); - } -} diff --git a/support/scripts/schemas.ts b/support/scripts/schemas.ts index 5ea71408c..3eaad1903 100644 --- a/support/scripts/schemas.ts +++ b/support/scripts/schemas.ts @@ -117,9 +117,30 @@ async function main() { java.forEach((file, path) => { writeToFile(javaDir + path, file.lines); }); + + const php = await quicktype({ + inputData, + lang: "php", + inferUuids: false, + inferDateTimes: false, + rendererOptions: { + "acronym-style": "camel", + "with-get": false, + }, + }); + + const phpDir = "./languages/php/src/Schemas/"; + if (!fs.existsSync(phpDir)) { + fs.mkdirSync(phpDir); + } + + php.lines.splice(1, 0, "namespace Bitwarden\\Sdk\\Schemas;", "use stdClass;", "use Exception;"); + + writeToFile("./languages/php/src/Schemas/Schemas.php", php.lines); } main(); + function writeToFile(filename: string, lines: string[]) { const output = fs.createWriteStream(filename); lines.forEach((line) => { From 76417172489d5790babbe14bb8c6ad8b3aac2a33 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Thu, 19 Sep 2024 08:13:37 -0400 Subject: [PATCH 166/214] [SM-1444] Fix Windows GNU Builds (#1053) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1444 ## 📔 Objective Windows GNU builds are currently broken due to a bug in [rustls-platform-verifier](https://github.com/rustls/rustls-platform-verifier) when LTO is turned on. I have submitted a GH Issue for this here: https://github.com/rustls/rustls-platform-verifier/issues/141 ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/build-rust-cross-platform.yml | 12 +++++++++++- Cargo.toml | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-rust-cross-platform.yml b/.github/workflows/build-rust-cross-platform.yml index a8c626d2c..7c567135b 100644 --- a/.github/workflows/build-rust-cross-platform.yml +++ b/.github/workflows/build-rust-cross-platform.yml @@ -60,14 +60,23 @@ jobs: - name: Add build architecture run: rustup target add ${{ matrix.settings.target }} + # Build Rust for musl - name: Build Rust for - ${{ matrix.settings.target }} if: ${{ contains(matrix.settings.target, 'musl') }} env: RUSTFLAGS: "-D warnings" run: cargo zigbuild -p bitwarden-c --target ${{ matrix.settings.target }} --release + # Build Rust for windows-gnu - name: Build Rust for - ${{ matrix.settings.target }} - if: ${{ !contains(matrix.settings.target, 'musl') }} + if: ${{ matrix.settings.target == 'x86_64-pc-windows-gnu' }} + env: + RUSTFLAGS: "-D warnings" + run: cargo build -p bitwarden-c --target ${{ matrix.settings.target }} --profile=release-windows + + # Build Rust for !musl && !windows-gnu + - name: Build Rust for - ${{ matrix.settings.target }} + if: ${{ !contains(matrix.settings.target, 'musl') && matrix.settings.target != 'x86_64-pc-windows-gnu' }} env: RUSTFLAGS: "-D warnings" MACOSX_DEPLOYMENT_TARGET: "10.14" # allows using new macos runner versions while still supporting older systems @@ -79,3 +88,4 @@ jobs: name: libbitwarden_c_files-${{ matrix.settings.target }} path: | target/${{ matrix.settings.target }}/release/*bitwarden_c* + target/${{ matrix.settings.target }}/release-windows/*bitwarden_c* diff --git a/Cargo.toml b/Cargo.toml index 7d452869c..8c978819b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,13 @@ opt-level = 1 [profile.release] lto = "thin" codegen-units = 1 + +# Turn off LTO on release mode for windows +# This is a workaround until this is fixed: https://github.com/rustls/rustls-platform-verifier/issues/141 +[profile.release-windows] +inherits = "release" +lto = "off" + # Stripping the binary reduces the size by ~30%, but the stacktraces won't be usable anymore. # This is fine as long as we don't have any unhandled panics, but let's keep it disabled for now # strip = true From 3ab4eefdc6b20e5f87410b967a3264ea44226422 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Thu, 19 Sep 2024 12:37:57 -0400 Subject: [PATCH 167/214] [SM-1445] Fix Go build on Windows (#1059) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1445 ## 📔 Objective Go builds on Windows are failing, this PR adds the needed libraries that are missing. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- languages/go/internal/cinterface/bitwarden_library.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/go/internal/cinterface/bitwarden_library.go b/languages/go/internal/cinterface/bitwarden_library.go index 3a63be61b..69d752716 100644 --- a/languages/go/internal/cinterface/bitwarden_library.go +++ b/languages/go/internal/cinterface/bitwarden_library.go @@ -11,7 +11,7 @@ import ( #cgo linux,arm64 LDFLAGS: -L ./lib/linux-arm64 #cgo darwin,amd64 LDFLAGS: -L ./lib/darwin-x64 -framework Security -framework SystemConfiguration #cgo darwin,arm64 LDFLAGS: -L ./lib/darwin-arm64 -framework Security -framework SystemConfiguration -#cgo windows,amd64 LDFLAGS: -L ./lib/windows-x64 -lbitwarden_c -ladvapi32 -lbcrypt -lcrypt32 -lcryptnet -lkernel32 -lncrypt -lntdll -luserenv -lws2_32 -lmsvcrt +#cgo windows,amd64 LDFLAGS: -L ./lib/windows-x64 -lbitwarden_c -ladvapi32 -lbcrypt -lcrypt32 -lcryptnet -lkernel32 -lncrypt -lntdll -luserenv -lws2_32 -lmsvcrt -loleaut32 -lruntimeobject #include typedef void* ClientPtr; extern char* run_command(const char *command, ClientPtr client); From 2e506f735ba9e34e39c5e6efb9126a6314694028 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Thu, 19 Sep 2024 14:57:35 -0400 Subject: [PATCH 168/214] [SM-1425] Update Napi SDK (#1045) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1425 ## 📔 Objective Update the Napi SDK to include the SM updates. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-napi/README.md | 3 +- .../src-ts/bitwarden_client/index.ts | 46 ++++++++++++------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/crates/bitwarden-napi/README.md b/crates/bitwarden-napi/README.md index e9c3d0a71..6fce8d069 100644 --- a/crates/bitwarden-napi/README.md +++ b/crates/bitwarden-napi/README.md @@ -17,11 +17,12 @@ const settings: ClientSettings = { }; const accessToken = "-- REDACTED --"; +const stateFile = "some/path/to/state/file"; const client = new BitwardenClient(settings, LogLevel.Info); // Authenticating using a machine account access token -await client.accessTokenLogin(accessToken); +await client.auth().loginAccessToken(accessToken, stateFile); // List secrets const secrets = await client.secrets().list(); diff --git a/crates/bitwarden-napi/src-ts/bitwarden_client/index.ts b/crates/bitwarden-napi/src-ts/bitwarden_client/index.ts index 52a53ef4f..3a3765a12 100644 --- a/crates/bitwarden-napi/src-ts/bitwarden_client/index.ts +++ b/crates/bitwarden-napi/src-ts/bitwarden_client/index.ts @@ -37,19 +37,6 @@ export class BitwardenClient { this.client = new rust.BitwardenClient(settingsJson, loggingLevel ?? LogLevel.Info); } - async accessTokenLogin(accessToken: string, stateFile?: string): Promise { - const response = await this.client.runCommand( - Convert.commandToJson({ - accessTokenLogin: { - accessToken, - stateFile, - }, - }), - ); - - handleResponse(Convert.toResponseForAccessTokenLoginResponse(response)); - } - secrets(): SecretsClient { return new SecretsClient(this.client); } @@ -57,6 +44,10 @@ export class BitwardenClient { projects(): ProjectsClient { return new ProjectsClient(this.client); } + + auth(): AuthClient { + return new AuthClient(this.client); + } } export class SecretsClient { @@ -91,11 +82,11 @@ export class SecretsClient { } async create( + organizationId: string, key: string, value: string, note: string, projectIds: string[], - organizationId: string, ): Promise { const response = await this.client.runCommand( Convert.commandToJson({ @@ -121,12 +112,12 @@ export class SecretsClient { } async update( + organizationId: string, id: string, key: string, value: string, note: string, projectIds: string[], - organizationId: string, ): Promise { const response = await this.client.runCommand( Convert.commandToJson({ @@ -183,7 +174,7 @@ export class ProjectsClient { return handleResponse(Convert.toResponseForProjectResponse(response)); } - async create(name: string, organizationId: string): Promise { + async create(organizationId: string, name: string): Promise { const response = await this.client.runCommand( Convert.commandToJson({ projects: { @@ -207,7 +198,7 @@ export class ProjectsClient { return handleResponse(Convert.toResponseForProjectsResponse(response)); } - async update(id: string, name: string, organizationId: string): Promise { + async update(organizationId: string, id: string, name: string): Promise { const response = await this.client.runCommand( Convert.commandToJson({ projects: { @@ -231,3 +222,24 @@ export class ProjectsClient { return handleResponse(Convert.toResponseForProjectsDeleteResponse(response)); } } + +export class AuthClient { + client: rust.BitwardenClient; + + constructor(client: rust.BitwardenClient) { + this.client = client; + } + + async loginAccessToken(accessToken: string, stateFile?: string): Promise { + const response = await this.client.runCommand( + Convert.commandToJson({ + loginAccessToken: { + accessToken, + stateFile, + }, + }), + ); + + handleResponse(Convert.toResponseForAccessTokenLoginResponse(response)); + } +} From 88537a838cb57c702172a74949a9419a0b99620b Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 20 Sep 2024 11:20:13 +0200 Subject: [PATCH 169/214] Bundle platform-verifier (#1039) We've run into some issues related to rustls-platform-verifier distributing an android library through their crate, which works great if you use platform-verifier within an application. However since we distribute an sdk, the application have difficulties locating the android specific platform-verifier library. To resolve this we follow the method established in https://github.com/rustls/rustls-platform-verifier/issues/115 and bundle the classes with the library. --- crates/bitwarden-uniffi/src/lib.rs | 14 ++++++++++- languages/kotlin/sdk/build.gradle | 39 ++++++++++++++++++++++-------- languages/kotlin/settings.gradle | 18 +------------- 3 files changed, 43 insertions(+), 28 deletions(-) diff --git a/crates/bitwarden-uniffi/src/lib.rs b/crates/bitwarden-uniffi/src/lib.rs index d0209de01..0d89ffdb8 100644 --- a/crates/bitwarden-uniffi/src/lib.rs +++ b/crates/bitwarden-uniffi/src/lib.rs @@ -28,7 +28,7 @@ use vault::ClientVault; #[derive(uniffi::Object)] pub struct Client(bitwarden::Client); -#[uniffi::export] +#[uniffi::export(async_runtime = "tokio")] impl Client { /// Initialize a new instance of the SDK client #[uniffi::constructor] @@ -79,6 +79,18 @@ impl Client { pub fn echo(&self, msg: String) -> String { msg } + + /// Test method, calls http endpoint + pub async fn http_get(&self, url: String) -> Result { + let client = self.0.internal.get_http_client(); + let res = client + .get(&url) + .send() + .await + .map_err(bitwarden::Error::Reqwest)?; + + Ok(res.text().await.map_err(bitwarden::Error::Reqwest)?) + } } fn init_logger() { diff --git a/languages/kotlin/sdk/build.gradle b/languages/kotlin/sdk/build.gradle index c41bccac1..d3ea098e3 100644 --- a/languages/kotlin/sdk/build.gradle +++ b/languages/kotlin/sdk/build.gradle @@ -12,8 +12,8 @@ android { minSdk 28 targetSdk 34 - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - consumerProguardFiles "consumer-rules.pro" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' + consumerProguardFiles 'consumer-rules.pro' } buildTypes { @@ -31,7 +31,7 @@ android { } lint { - baseline = file("lint-baseline.xml") + baseline = file('lint-baseline.xml') } publishing { @@ -52,9 +52,9 @@ publishing { // PRs: use the branch name. // Main: Grab it from `crates/bitwarden/Cargo.toml` - def branchName = "git branch --show-current".execute().text.trim() + def branchName = 'git branch --show-current'.execute().text.trim() - if (branchName == "main") { + if (branchName == 'main') { def content = ['grep', '-o', '^version = ".*"', '../../Cargo.toml'].execute().text.trim() def match = ~/version = "(.*)"/ def matcher = match.matcher(content) @@ -73,19 +73,38 @@ publishing { } repositories { maven { - name = "GitHubPackages" - url = "https://maven.pkg.github.com/bitwarden/sdk" + name = 'GitHubPackages' + url = 'https://maven.pkg.github.com/bitwarden/sdk' credentials { - username = System.getenv("GITHUB_ACTOR") - password = System.getenv("GITHUB_TOKEN") + username = System.getenv('GITHUB_ACTOR') + password = System.getenv('GITHUB_TOKEN') } } } } +// Find and include the classes.jar from platform-verifier. +// +// Based on the instructions from the readme in https://github.com/rustls/rustls-platform-verifier +// and issue details from https://github.com/rustls/rustls-platform-verifier/issues/115. +File findRustlsPlatformVerifierClassesJar() { + def dependencyText = providers.exec { + it.workingDir = new File('../../') + commandLine('cargo', 'metadata', '--format-version', '1', '--manifest-path', 'crates/bitwarden-uniffi/Cargo.toml') + }.standardOutput.asText.get() + + def dependencyJson = new groovy.json.JsonSlurper().parseText(dependencyText) + def manifestPath = file(dependencyJson.packages.find { it.name == "rustls-platform-verifier-android" }.manifest_path) + + def aar = fileTree(manifestPath.parentFile).matching { + include "maven/rustls/rustls-platform-verifier/*/rustls-platform-verifier-*.aar" + }.getSingleFile() + return zipTree(aar).matching { include 'classes.jar'}.getSingleFile() +} + dependencies { implementation 'net.java.dev.jna:jna:5.14.0@aar' - implementation 'rustls:rustls-platform-verifier:latest.release' + implementation files(findRustlsPlatformVerifierClassesJar()) implementation 'androidx.core:core-ktx:1.13.0' implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3' diff --git a/languages/kotlin/settings.gradle b/languages/kotlin/settings.gradle index e82ac3727..fac8f3fae 100644 --- a/languages/kotlin/settings.gradle +++ b/languages/kotlin/settings.gradle @@ -10,25 +10,9 @@ dependencyResolutionManagement { repositories { google() mavenCentral() - - maven { - url = findRustlsPlatformVerifierProject() - metadataSources.artifact() - } } } -String findRustlsPlatformVerifierProject() { - def dependencyText = providers.exec { - it.workingDir = new File("../../") - commandLine("cargo", "metadata", "--format-version", "1", "--manifest-path", "crates/bitwarden-uniffi/Cargo.toml") - }.standardOutput.asText.get() - - def dependencyJson = new groovy.json.JsonSlurper().parseText(dependencyText) - def manifestPath = file(dependencyJson.packages.find { it.name == "rustls-platform-verifier-android" }.manifest_path) - return new File(manifestPath.parentFile, "maven").path -} - -rootProject.name = "My Application" +rootProject.name = 'My Application' include ':app' include ':sdk' From 3cb295c438c5abffd45fb55724019fc1c3ba75d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ch=C4=99ci=C5=84ski?= Date: Fri, 20 Sep 2024 17:38:29 +0200 Subject: [PATCH 170/214] [BRE-339] Fix Swift release workflow - artifact zip (#1071) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/BRE-339 ## 📔 Objective When unpack the created artifact it takes the name of the zip file. It should unpack as `BitwardenFFI.xcframework`. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/build-swift.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-swift.yml b/.github/workflows/build-swift.yml index 4192662bf..22da084ed 100644 --- a/.github/workflows/build-swift.yml +++ b/.github/workflows/build-swift.yml @@ -61,11 +61,16 @@ jobs: # SHA Short echo "short-sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + - name: Zip BitwardenFFI.xcframework + run: | + mkdir artifacts + cp -rf languages/swift/BitwardenFFI.xcframework artifacts + - name: Upload BitwardenFFI.xcframework artifact uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: BitwardenFFI-${{ env._VERSION }}-${{ steps.build.outputs.short-sha }}.xcframework - path: languages/swift/BitwardenFFI.xcframework + path: artifacts if-no-files-found: error - name: Upload BitwardenSdk sources From dd555ce500d3e8ef6ec497a76aa1c368d6ae7292 Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Fri, 20 Sep 2024 09:34:05 -0700 Subject: [PATCH 171/214] breaking: SM-1403 review and update cpp sdk (#1002) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1403 ## 📔 Objective Update the C++ bindings to include the features we support and make the function parameters consistent with the other wrappers. - `accessTokenLogin(token)` -> `loginAccessToken(token, stateFile)` - `updateProject(projectId, orgId, name)` -> `updateProject(orgId, projectId, name)` - `createSecret(key, value, note, orgId, {projectId})` -> `createSecret(orgId, key, value, note, {projectId})` - `updateSecret(id, key, value, note, orgId, {projectId})` -> `createSecret(orgId, id, key, value, note, {projectId})` - add secret syncing - add `getByIds` - update the example wrapper to use the newer bindings as well as produce output for each project/secret operation ## 📸 Screenshots ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --------- Co-authored-by: Colton Hurst --- .gitignore | 3 + languages/cpp/CMakeBuild.md | 14 +++- languages/cpp/README.md | 33 ++++++--- languages/cpp/examples/Wrapper.cpp | 99 +++++++++++++++++++------ languages/cpp/include/BitwardenClient.h | 14 ++-- languages/cpp/include/Projects.h | 2 +- languages/cpp/include/Secrets.h | 8 +- languages/cpp/src/BitwardenClient.cpp | 29 ++++++-- languages/cpp/src/Projects.cpp | 2 +- languages/cpp/src/Secrets.cpp | 89 +++++++++++++++++++++- 10 files changed, 240 insertions(+), 53 deletions(-) diff --git a/.gitignore b/.gitignore index b13651d19..4a1d79fca 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,6 @@ languages/java/src/main/java/com/bitwarden/sdk/schema languages/js/sdk-client/src/schemas.ts languages/python/bitwarden_sdk/schemas.py support/schemas + +# Cmake build files +languages/cpp/cmake-build-debug diff --git a/languages/cpp/CMakeBuild.md b/languages/cpp/CMakeBuild.md index cb148069e..b75da5c17 100644 --- a/languages/cpp/CMakeBuild.md +++ b/languages/cpp/CMakeBuild.md @@ -3,7 +3,6 @@ ## Introduction Cmake is used to build the C++ Bitwarden client library. Output should be placed in the build directory. - The output contains two dynamic libraries: - The C++ client `BitwardenClient` @@ -20,7 +19,8 @@ See how to use these libraries in the [example use guide](./examples/ExampleUse. ## Build Commands -One should be in the root directory of the C++ wrapper (the same level where is CMakeLists.txt placed). Paths of the three libraries should be placed inside the cmake build command: +One should be in the root directory of the C++ wrapper (the same level where is CMakeLists.txt placed). Paths of the +three libraries should be placed inside the cmake build command: ```bash mkdir -p build @@ -29,6 +29,16 @@ cmake .. -DNLOHMANN=/path/to/include/nlohmann -DBOOST=/path/to/include/boost -DT cmake --build . ``` +## IDE Support + +You may need to manually set the CMake `TARGET` variable for your IDE. For CLion, add the following to the CMake options +settings: + +```bash +# macOS example +-DTARGET=../../target/release/libbitwarden_c.dylib +``` + ## Example ### macOS diff --git a/languages/cpp/README.md b/languages/cpp/README.md index 23b59ac76..fb714a20e 100644 --- a/languages/cpp/README.md +++ b/languages/cpp/README.md @@ -22,9 +22,10 @@ bitwardenSettings.set_identity_url(""); ```c++ std::string accessToken = ""; +std::string stateFile = ""; // Optional - argument in BitwardenClient BitwardenClient bitwardenClient = BitwardenClient(bitwardenSettings); -bitwardenClient.accessTokenLogin(accessToken); +bitwardenClient.loginAccessToken(accessToken, stateFile); ``` ### Create new project @@ -32,6 +33,7 @@ bitwardenClient.accessTokenLogin(accessToken); ```c++ boost::uuids::uuid organizationUuid = boost::uuids::string_generator()(""); ProjectResponse projectResponseCreate = bitwardenClient.createProject(organizationUuid, "TestProject"); +boost::uuids::uuid projectId = boost::uuids::string_generator()(projectResponseCreate.get_id()); ``` ### List all projects @@ -43,21 +45,19 @@ ProjectsResponse projectResponseList = bitwardenClient.listProjects(organization ### Get project details ```c++ -boost::uuids::uuid projectId = boost::uuids::string_generator()(projectResponseCreate.get_id()); ProjectResponse projectResponseGet = bitwardenClient.getProject(projectId); ``` ### Update project ```c++ -boost::uuids::uuid projectId = boost::uuids::string_generator()(projectResponseCreate.get_id()); -ProjectResponse projectResponseUpdate = bitwardenClient.updateProject(projectId, organizationUuid, "TestProjectUpdated"); +ProjectResponse projectResponseUpdate = bitwardenClient.updateProject(organizationUuid, projectId, "TestProjectUpdated"); ``` ### Delete projects ```c++ -SecretsDeleteResponse secretsDeleteResponse = bitwardenClient.deleteSecrets({secretId}); +ProjectsDeleteResponse projectsDeleteResponse = bitwardenClient.deleteProjects({projectId}); ``` ### Add new secret @@ -66,7 +66,8 @@ SecretsDeleteResponse secretsDeleteResponse = bitwardenClient.deleteSecrets({sec std::string key = "key"; std::string value = "value"; std::string note = "note"; -SecretResponse secretResponseCreate = bitwardenClient.createSecret(key, value, note, organizationUuid, {projectId}); +SecretResponse secretResponseCreate = bitwardenClient.createSecret(organizationUuid, key, value, note, {projectId}); +boost::uuids::uuid secretId = boost::uuids::string_generator()(secretResponseCreate.get_id()); ``` ### List secrets @@ -77,14 +78,28 @@ SecretIdentifiersResponse secretIdentifiersResponse = bitwardenClient.listSecret ### Get secret details -``` -boost::uuids::uuid secretId = boost::uuids::string_generator()(secretResponseCreate.get_id()); +```c++ SecretResponse secretResponseGet = bitwardenClient.getSecret(secretId); ``` +### Get multiple secrets by ids + +```c++ +std::vector secretIds = {secretId, secretId2}; +SecretsResponse secretsResponseGet = bitwardenClient.getSecrets(secretIds); +``` + ### Update secret + +```c++ +SecretResponse secretResponseUpdate = bitwardenClient.updateSecret(organizationUuid, secretId, "key2", "value2", "note2", {projectId}); +``` + +### Sync secrets + ```c++ -SecretResponse secretResponseUpdate = bitwardenClient.updateSecret(secretId, "key2", "value2", "note2", organizationUuid, {projectId}); +std::chrono::system_clock::time_point lastSyncedDate = std::chrono::system_clock::now(); +SecretsSyncResponse secretsSyncResponse = bitwardenClient.sync(orgnizationUuid, lastSyncedDate); ``` # Delete secrets diff --git a/languages/cpp/examples/Wrapper.cpp b/languages/cpp/examples/Wrapper.cpp index bb53bf0c4..7790adfb0 100644 --- a/languages/cpp/examples/Wrapper.cpp +++ b/languages/cpp/examples/Wrapper.cpp @@ -1,14 +1,18 @@ #include "BitwardenClient.h" #include #include +#include int main() { // Retrieve access token and organization ID from environment variables - const char* accessTokenEnv = std::getenv("ACCESS_TOKEN"); - const char* organizationIdEnv = std::getenv("ORGANIZATION_ID"); + const char *accessTokenEnv = std::getenv("ACCESS_TOKEN"); + const char *organizationIdEnv = std::getenv("ORGANIZATION_ID"); - const char* apiUrl = std::getenv("API_URL"); - const char* identityUrl = std::getenv("IDENTITY_URL"); + // Use optional state file for authentication + const char *stateFile = std::getenv("STATE_FILE"); + + const char *apiUrl = std::getenv("API_URL"); + const char *identityUrl = std::getenv("IDENTITY_URL"); if (!accessTokenEnv || !organizationIdEnv) { std::cerr << "Error: Environment variables ACCESS_TOKEN or ORGANIZATION_ID not set." << std::endl; @@ -18,57 +22,110 @@ int main() { std::string accessToken = accessTokenEnv; std::string organizationId = organizationIdEnv; - // Configuring the URLS is optional, remove them to use the default values + // Configuring the URLS is optional; if unset, use bitwarden.com BitwardenSettings bitwardenSettings; - bitwardenSettings.set_api_url(apiUrl); - bitwardenSettings.set_identity_url(identityUrl); + if (apiUrl != nullptr && identityUrl != nullptr) { + bitwardenSettings.set_api_url(apiUrl); + bitwardenSettings.set_identity_url(identityUrl); + } else { + std::cerr << "Info: API_URL and IDENTITY_URL are not set, using default values..." << std::endl; + } // Create a Bitwarden client instance - BitwardenClient bitwardenClient = BitwardenClient(bitwardenSettings); - // // Access token login - bitwardenClient.loginAccessToken(accessToken); - // Organization ID - boost::uuids::uuid organizationUuid = boost::uuids::string_generator()(organizationId); - - // // Create a new project + BitwardenClient bitwardenClient(bitwardenSettings); + + // Access token login + if (stateFile != nullptr) { + bitwardenClient.loginAccessToken(accessToken, stateFile); + } else { + bitwardenClient.loginAccessToken(accessToken); + } + + // Convert organization ID to UUID + boost::uuids::uuid organizationUuid = boost::uuids::string_generator()(organizationId); + + // Create a new project + std::cout << "Projects:\n"; ProjectResponse projectResponseCreate = bitwardenClient.createProject(organizationUuid, "NewTestProject"); boost::uuids::uuid projectId = boost::uuids::string_generator()(projectResponseCreate.get_id()); - + + std::cout << "\tcreateProject: '" << projectResponseCreate.get_name() << "'\n\n"; + // List projects ProjectsResponse projectResponseList = bitwardenClient.listProjects(organizationUuid); + std::cout << "\tlistProjects:\n"; + for (const ProjectResponse& project : projectResponseList.get_data()) { + std::cout << "\t\tID: '" << project.get_id() << "', Name: '" << project.get_name() << "'\n"; + } + std::cout << '\n'; // Get project details ProjectResponse projectResponseGet = bitwardenClient.getProject(projectId); + std::cout << "\tgetProject:\n\t\tID: '" << projectResponseGet.get_id() << "', Name: '" << projectResponseGet.get_name() << "'\n\n"; // Update project - ProjectResponse ProjectResponseUpdate = bitwardenClient.updateProject(projectId, organizationUuid, "NewTestProject2"); + ProjectResponse projectResponseUpdate = bitwardenClient.updateProject(organizationUuid, projectId, "NewTestProject2"); + std::cout << "\tupdateProject: '" << projectResponseUpdate.get_name() << "'\n\n"; // Secrets std::string key = "key"; std::string value = "value"; std::string note = "note"; + // Sync secrets + std::cout << "Secrets:\n"; + std::cout << "\tSyncing secrets...\n"; + SecretsSyncResponse secretsSyncResponse = bitwardenClient.sync(organizationUuid, {}); + std::chrono::system_clock::time_point lastSyncedDate = std::chrono::system_clock::now(); + std::cout << "\t\tSync has changes: '" << (secretsSyncResponse.get_has_changes() ? "true" : "false") << "'\n\n"; + + std::cout << "\tSyncing again to ensure no changes since last sync...\n"; + secretsSyncResponse = bitwardenClient.sync(organizationUuid, lastSyncedDate); + std::cout << "\t\tSync has changes: '" << (secretsSyncResponse.get_has_changes() ? "true" : "false") << "'\n\n"; + // Create a new secret - SecretResponse secretResponseCreate = bitwardenClient.createSecret(key, value, note, organizationUuid, {projectId}); + SecretResponse secretResponseCreate = bitwardenClient.createSecret(organizationUuid, key, value, note, {projectId}); boost::uuids::uuid secretId = boost::uuids::string_generator()(secretResponseCreate.get_id()); + std::cout << "\tcreateSecret: '" << secretResponseCreate.get_key() << "'\n\n"; + // List secrets SecretIdentifiersResponse secretIdentifiersResponse = bitwardenClient.listSecrets(organizationUuid); + std::cout << "\tlistSecrets:\n"; + for (const SecretIdentifierResponse& secretIdentifier : secretIdentifiersResponse.get_data()) { + std::cout << "\t\tID: '" << secretIdentifier.get_id() << "'\n"; + } + std::cout << '\n'; // Get secret details SecretResponse secretResponseGet = bitwardenClient.getSecret(secretId); + std::cout << "\tgetSecret: '" << secretResponseGet.get_key() << "'\n\n"; + + // Get secrets by IDs + std::cout << "\tgetSecretsByIds:\n"; + SecretsResponse secretsResponseGetByIds = bitwardenClient.getSecretsByIds({secretId}); + for (const SecretResponse& secret : secretsResponseGetByIds.get_data()) { + std::cout << "\t\tID: '" << secret.get_id() << "', Key: '" << secret.get_key() << "'\n"; + } + std::cout << '\n'; // Update secret - key = "key2"; - value = "value2"; - note = "note2"; - SecretResponse responseForSecretResponseUpdate = bitwardenClient.updateSecret(secretId, key, value, note, organizationUuid, {projectId}); + key = "updated-key"; + value = "updated-value"; + note = "updated-note"; + SecretResponse responseForSecretResponseUpdate = bitwardenClient.updateSecret( + organizationUuid, secretId, key, value, note, {projectId}); + + std::cout << "\tupdateSecret: '" << responseForSecretResponseUpdate.get_key() << "'\n\n"; // Delete secrets + std::cout << "Deleting projects and secrets...\n"; SecretsDeleteResponse secretsDeleteResponse = bitwardenClient.deleteSecrets({secretId}); + std::cout << "\tdeleteSecrets: '" << secretsDeleteResponse.get_data()[0].get_id() << "'\n\n"; // Delete projects ProjectsDeleteResponse projectsDeleteResponse = bitwardenClient.deleteProjects({projectId}); + std::cout << "\tdeleteProjects: '" << projectsDeleteResponse.get_data()[0].get_id() << "'\n\n"; return 0; } diff --git a/languages/cpp/include/BitwardenClient.h b/languages/cpp/include/BitwardenClient.h index a5cf72475..2910c49b7 100644 --- a/languages/cpp/include/BitwardenClient.h +++ b/languages/cpp/include/BitwardenClient.h @@ -9,20 +9,22 @@ class BitwardenClient { public: - BitwardenClient(const BitwardenSettings& bitwardenSettings = BitwardenSettings()); + explicit BitwardenClient(const BitwardenSettings& bitwardenSettings = BitwardenSettings()); ~BitwardenClient(); - - void accessTokenLogin(const std::string& accessToken); + + void loginAccessToken(const std::string& accessToken, const std::string& stateFile = ""); ProjectResponse getProject(const boost::uuids::uuid& id); ProjectResponse createProject(const boost::uuids::uuid& organizationId, const std::string& name); - ProjectResponse updateProject(const boost::uuids::uuid& id, const boost::uuids::uuid& organizationId, const std::string& name); + ProjectResponse updateProject(const boost::uuids::uuid& organizationId, const boost::uuids::uuid& id, const std::string& name); ProjectsDeleteResponse deleteProjects(const std::vector& ids); ProjectsResponse listProjects(const boost::uuids::uuid &organizationId); SecretResponse getSecret(const boost::uuids::uuid& id); - SecretResponse createSecret(const std::string& key, const std::string& value, const std::string& note, const boost::uuids::uuid& organizationId, const std::vector& projectIds); - SecretResponse updateSecret(const boost::uuids::uuid& id, const std::string& key, const std::string& value, const std::string& note, const boost::uuids::uuid& organizationId, const std::vector& projectIds); + SecretsResponse getSecretsByIds(const std::vector& ids); + SecretResponse createSecret(const boost::uuids::uuid& organizationId, const std::string& key, const std::string& value, const std::string& note, const std::vector& projectIds); + SecretResponse updateSecret(const boost::uuids::uuid& organizationId, const boost::uuids::uuid& id, const std::string& key, const std::string& value, const std::string& note, const std::vector& projectIds); SecretsDeleteResponse deleteSecrets(const std::vector& ids); SecretIdentifiersResponse listSecrets(const boost::uuids::uuid& organizationId); + SecretsSyncResponse sync(const boost::uuids::uuid &organizationId, const std::chrono::system_clock::time_point &lastSyncedDate); private: BitwardenLibrary* library; diff --git a/languages/cpp/include/Projects.h b/languages/cpp/include/Projects.h index 9bef19b9c..27511c327 100644 --- a/languages/cpp/include/Projects.h +++ b/languages/cpp/include/Projects.h @@ -10,7 +10,7 @@ class Projects { ProjectResponse get(const boost::uuids::uuid& id); ProjectResponse create(const boost::uuids::uuid& organizationId, const std::string& name); - ProjectResponse update(const boost::uuids::uuid& id, const boost::uuids::uuid& organizationId, const std::string& name); + ProjectResponse update(const boost::uuids::uuid& organizationId, const boost::uuids::uuid& id, const std::string& name); ProjectsDeleteResponse deleteProjects(const std::vector& ids); ProjectsResponse list(const boost::uuids::uuid& organizationId); diff --git a/languages/cpp/include/Secrets.h b/languages/cpp/include/Secrets.h index 024ec3692..5c5a3275c 100644 --- a/languages/cpp/include/Secrets.h +++ b/languages/cpp/include/Secrets.h @@ -1,6 +1,8 @@ #pragma once #include +#include +#include #include #include "CommandRunner.h" @@ -9,10 +11,12 @@ class Secrets { Secrets(CommandRunner* commandRunner); SecretResponse get(const boost::uuids::uuid& id); - SecretResponse create(const std::string& key, const std::string& value, const std::string& note, const boost::uuids::uuid& organizationId, const std::vector& projectIds); - SecretResponse update(const boost::uuids::uuid& id, const std::string& key, const std::string& value, const std::string& note, const boost::uuids::uuid& organizationId, const std::vector& projectIds); + SecretsResponse getByIds(const std::vector &ids); + SecretResponse create(const boost::uuids::uuid& organizationId, const std::string& key, const std::string& value, const std::string& note, const std::vector& projectIds); + SecretResponse update(const boost::uuids::uuid& organizationId, const boost::uuids::uuid& id, const std::string& key, const std::string& value, const std::string& note, const std::vector& projectIds); SecretsDeleteResponse deleteSecrets(const std::vector& ids); SecretIdentifiersResponse list(const boost::uuids::uuid& organizationId); + SecretsSyncResponse sync(const boost::uuids::uuid& organizationId, const boost::optional& lastSyncedDate); private: CommandRunner* commandRunner; diff --git a/languages/cpp/src/BitwardenClient.cpp b/languages/cpp/src/BitwardenClient.cpp index ce161a2bf..2d11977d4 100644 --- a/languages/cpp/src/BitwardenClient.cpp +++ b/languages/cpp/src/BitwardenClient.cpp @@ -50,10 +50,11 @@ BitwardenClient::~BitwardenClient() { } } -void BitwardenClient::loginAccessToken(const std::string& accessToken) { +void BitwardenClient::loginAccessToken(const std::string& accessToken, const std::string& stateFile) { Command command; AccessTokenLoginRequest accessTokenLoginRequest; accessTokenLoginRequest.set_access_token(accessToken); + accessTokenLoginRequest.set_state_file(stateFile); command.set_login_access_token(accessTokenLoginRequest); auto deserializer = [](const char* response) -> ResponseForApiKeyLoginResponse { @@ -84,11 +85,11 @@ ProjectResponse BitwardenClient::createProject(const boost::uuids::uuid& organiz return projects.create(organizationId, name); } -ProjectResponse BitwardenClient::updateProject(const boost::uuids::uuid& id, const boost::uuids::uuid& organizationId, const std::string& name){ +ProjectResponse BitwardenClient::updateProject(const boost::uuids::uuid& organizationId, const boost::uuids::uuid& id, const std::string& name){ if (!isClientOpen) { throw std::runtime_error("Client is not open."); } - return projects.update(id, organizationId, name); + return projects.update(organizationId, id, name); } ProjectsDeleteResponse BitwardenClient::deleteProjects(const std::vector& ids) { @@ -114,18 +115,25 @@ SecretResponse BitwardenClient::getSecret(const boost::uuids::uuid& id){ return secrets.get(id); } -SecretResponse BitwardenClient::createSecret(const std::string& key, const std::string& value, const std::string& note, const boost::uuids::uuid& organizationId, const std::vector& projectIds){ +SecretsResponse BitwardenClient::getSecretsByIds(const std::vector& ids){ if (!isClientOpen) { throw std::runtime_error("Client is not open."); } - return secrets.create(key, value, note, organizationId, projectIds); + return secrets.getByIds(ids); } -SecretResponse BitwardenClient::updateSecret(const boost::uuids::uuid& id, const std::string& key, const std::string& value, const std::string& note, const boost::uuids::uuid& organizationId, const std::vector& projectIds){ +SecretResponse BitwardenClient::createSecret(const boost::uuids::uuid& organizationId, const std::string& key, const std::string& value, const std::string& note, const std::vector& projectIds){ if (!isClientOpen) { throw std::runtime_error("Client is not open."); } - return secrets.update(id, key, value, note, organizationId, projectIds); + return secrets.create(organizationId, key, value, note, projectIds); +} + +SecretResponse BitwardenClient::updateSecret(const boost::uuids::uuid& organizationId, const boost::uuids::uuid& id, const std::string& key, const std::string& value, const std::string& note, const std::vector& projectIds){ + if (!isClientOpen) { + throw std::runtime_error("Client is not open."); + } + return secrets.update(organizationId, id, key, value, note, projectIds); } SecretsDeleteResponse BitwardenClient::deleteSecrets(const std::vector& ids) { @@ -143,3 +151,10 @@ SecretIdentifiersResponse BitwardenClient::listSecrets(const boost::uuids::uuid return secrets.list(organizationId); } + +SecretsSyncResponse BitwardenClient::sync(const boost::uuids::uuid &organizationId, const std::chrono::system_clock::time_point &lastSyncedDate) { + if (!isClientOpen) { + throw std::runtime_error("Client is not open."); + } + return secrets.sync(organizationId, lastSyncedDate); +} diff --git a/languages/cpp/src/Projects.cpp b/languages/cpp/src/Projects.cpp index d0aa6ed49..b2fa1c688 100644 --- a/languages/cpp/src/Projects.cpp +++ b/languages/cpp/src/Projects.cpp @@ -67,7 +67,7 @@ ProjectResponse Projects::create(const boost::uuids::uuid& organizationId, const } } -ProjectResponse Projects::update(const boost::uuids::uuid& id, const boost::uuids::uuid& organizationId, const std::string& name) { +ProjectResponse Projects::update(const boost::uuids::uuid& organizationId, const boost::uuids::uuid& id, const std::string& name) { Command command; ProjectsCommand projectsCommand; ProjectPutRequest projectPutRequest; diff --git a/languages/cpp/src/Secrets.cpp b/languages/cpp/src/Secrets.cpp index e153ea7f1..1fff9441f 100644 --- a/languages/cpp/src/Secrets.cpp +++ b/languages/cpp/src/Secrets.cpp @@ -1,8 +1,8 @@ #include "Secrets.h" #include #include -#include -#include +#include +#include Secrets::Secrets(CommandRunner* commandRunner) : commandRunner(commandRunner) {} @@ -13,6 +13,13 @@ auto secretsDeserializer = [](const std::string& response) -> ResponseForSecretR return secretResponse; }; +auto secretsByIdsDeserializer = [](const std::string& response) -> ResponseForSecretsResponse { + nlohmann::json jsonResponse = nlohmann::json::parse(response); + ResponseForSecretsResponse secretsResponse; + Bitwarden::Sdk::from_json(jsonResponse, secretsResponse); + return secretsResponse; +}; + auto deleteSecretsDeserializer = [](const std::string& response) -> ResponseForSecretsDeleteResponse { nlohmann::json jsonResponse = nlohmann::json::parse(response); ResponseForSecretsDeleteResponse deleteSecretsResponse; @@ -27,6 +34,13 @@ auto secretListDeserializer = [](const std::string& response) -> ResponseForSecr return listResponse; }; +auto secretsSyncDeserializer = [](const std::string& response) -> ResponseForSecretsSyncResponse { + nlohmann::json jsonResponse = nlohmann::json::parse(response); + ResponseForSecretsSyncResponse syncResponse; + Bitwarden::Sdk::from_json(jsonResponse, syncResponse); + return syncResponse; +}; + SecretResponse Secrets::get(const boost::uuids::uuid& id) { Command command; SecretsCommand secretsCommand; @@ -46,7 +60,29 @@ SecretResponse Secrets::get(const boost::uuids::uuid& id) { } } -SecretResponse Secrets::create(const std::string& key, const std::string& value, const std::string& note, const boost::uuids::uuid& organizationId, const std::vector& projectIds) { +SecretsResponse Secrets::getByIds(const std::vector& ids) { + Command command; + SecretsCommand secretsCommand; + SecretsGetRequest secretsGetRequest; + + std::vector idsStr; + for (const auto& id : ids) { + idsStr.push_back(boost::uuids::to_string(id)); + } + secretsGetRequest.set_ids(idsStr); + + secretsCommand.set_get_by_ids(secretsGetRequest); + command.set_secrets(secretsCommand); + + try { + return commandRunner->runCommand(command, secretsByIdsDeserializer); + } catch (const std::exception& ex) { + std::cerr << "Error in getSecretsByIds: " << ex.what() << std::endl; + throw ex; + } +} + +SecretResponse Secrets::create(const boost::uuids::uuid& organizationId, const std::string& key, const std::string& value, const std::string& note, const std::vector& projectIds) { Command command; SecretsCommand secretsCommand; SecretCreateRequest secretCreateRequest; @@ -75,7 +111,7 @@ SecretResponse Secrets::create(const std::string& key, const std::string& value, } } -SecretResponse Secrets::update(const boost::uuids::uuid& id, const std::string& key, const std::string& value, const std::string& note, const boost::uuids::uuid& organizationId, const std::vector& projectIds) { +SecretResponse Secrets::update(const boost::uuids::uuid& organizationId, const boost::uuids::uuid& id, const std::string& key, const std::string& value, const std::string& note, const std::vector& projectIds) { Command command; SecretsCommand secretsCommand; SecretPutRequest secretPutRequest; @@ -147,3 +183,48 @@ SecretIdentifiersResponse Secrets::list(const boost::uuids::uuid& organizationId throw ex; } } + +SecretsSyncResponse Secrets::sync(const boost::uuids::uuid& organizationId, const boost::optional& lastSyncedDate) { + Command command; + SecretsCommand secretsCommand; + SecretsSyncRequest secretsSyncRequest; + + std::string orgIdStr = boost::uuids::to_string(organizationId); + secretsSyncRequest.set_organization_id(orgIdStr); + + if (lastSyncedDate.has_value()) { + auto timePoint = lastSyncedDate.value(); + + // Get time as time_t and milliseconds + auto timeT = std::chrono::system_clock::to_time_t(timePoint); + auto milliseconds = std::chrono::duration_cast(timePoint.time_since_epoch()) % 1000; + + // Convert to a tm struct + std::tm tm = *std::gmtime(&timeT); + + // Create a string stream to format the date and time + std::stringstream dateStream; + dateStream << std::put_time(&tm, "%Y-%m-%dT%H:%M:%S"); + + // Add milliseconds + dateStream << '.' << std::setw(3) << std::setfill('0') << milliseconds.count() << 'Z'; + + // Convert to string + std::string dateStr = dateStream.str(); + + // Set the last synced date + secretsSyncRequest.set_last_synced_date(dateStr); + } else { + secretsSyncRequest.set_last_synced_date(boost::none); + } + + secretsCommand.set_sync(secretsSyncRequest); + command.set_secrets(secretsCommand); + + try { + return commandRunner->runCommand(command, secretsSyncDeserializer); + } catch (const std::exception& ex) { + std::cerr << "Error in syncSecrets: " << ex.what() << std::endl; + throw ex; + } +} From eeda46230de545de12ca2ebd183871d376af8716 Mon Sep 17 00:00:00 2001 From: tangowithfoxtrot <5676771+tangowithfoxtrot@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:30:41 -0700 Subject: [PATCH 172/214] Fix C++ build workflow (#1065) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/SM-1446 ## 📔 Objective Fix the C++ build workflow. Relies on changes from #1002, which will need to be merged first. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --------- Co-authored-by: Colton Hurst Co-authored-by: Colton Hurst Co-authored-by: Maciej Zieniuk --- .github/workflows/build-cpp.yml | 69 +++++++++++++++------------------ languages/cpp/CMakeLists.txt | 1 + languages/cpp/vcpkg.json | 17 ++++---- 3 files changed, 42 insertions(+), 45 deletions(-) diff --git a/.github/workflows/build-cpp.yml b/.github/workflows/build-cpp.yml index e95e6cbf2..606cefdee 100644 --- a/.github/workflows/build-cpp.yml +++ b/.github/workflows/build-cpp.yml @@ -30,8 +30,11 @@ jobs: - os: macos-13 target: x86_64-apple-darwin - # - os: windows-2022 - # target: x86_64-pc-windows-msvc + - os: macos-13 + target: aarch64-apple-darwin + + - os: windows-2022 + target: x86_64-pc-windows-msvc - os: ubuntu-22.04 target: x86_64-unknown-linux-gnu @@ -52,16 +55,6 @@ jobs: brew install nlohmann-json brew install boost - - name: Cache vcpkg - if: runner.os == 'Windows' - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - path: C:/vcpkg/ - key: vcpkg-${{ runner.os }}-${{ matrix.settings.target }} - restore-keys: | - vcpkg-${{ runner.os }}- - vcpkg- - - name: Export GitHub Actions cache environment variables if: runner.os == 'Windows' uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 @@ -70,22 +63,6 @@ jobs: core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); - - name: Install libraries for Windows - if: runner.os == 'Windows' && steps.cache.outputs.cache-hit != 'true' - env: - VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" - run: | - vcpkg install boost --binarysource="clear;x-gha,readwrite" - vcpkg install nlohmann-json --binarysource="clear;x-gha,readwrite" - shell: pwsh - - - name: Save cache - if: runner.os == 'Windows' - uses: actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 - with: - path: C:/vcpkg/ - key: vcpkg-${{ runner.os }}-${{ matrix.settings.target }} - - name: Download schemas uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 with: @@ -114,6 +91,20 @@ jobs: Get-Acl languages/cpp/include/* | Format-List + - name: Ensure bitwarden-c is in include folder + working-directory: languages/cpp + shell: bash + run: | + mv include/release/* include/ + if [[ '${{ runner.os }}' == 'macOS' || '${{ runner.os }}' == 'Linux' ]]; then + ls include/libbitwarden_c.* || { echo "Missing libbitwarden_c.*"; exit 1; } + fi + if [[ '${{ runner.os }}' == 'Windows' ]]; then + ls include/bitwarden_c.dll || { echo "Missing bitwarden_c.dll"; exit 1; } + ls include/bitwarden_c.dll.lib || { echo "Missing bitwarden_c.dll.lib"; exit 1; } + fi + rmdir include/release + - name: Build unix working-directory: languages/cpp if: runner.os == 'macOS' || runner.os == 'Linux' @@ -139,24 +130,28 @@ jobs: if: runner.os == 'Windows' working-directory: languages/cpp env: - BOOST_INCLUDE_DIR: C:\vcpkg\installed\x64-windows\include\boost - NLOHMANN_JSON_INCLUDE_DIR: C:\vcpkg\installed\x64-windows\include\nlohmann-json + VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" run: | mkdir build cd build - $DNLOHMANN_PATH="C:\vcpkg\installed\x64-windows\include\nlohmann-json" - $DBOOST_PATH="C:\vcpkg\installed\x64-windows\include\boost" - $DTARGET="include/libbitwarden_c.dll" - cmake .. -DNLOHMANN=$DNLOHMANN_PATH -DBOOST=$DBOOST_PATH -DTARGET="include/libbitwarden_c.dll" -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/languages/cpp/ -DBUILD_TESTING=OFF - cmake --build . + $env:DTARGET="include\bitwarden_c.dll.lib" + cmake .. -DTARGET="$env:DTARGET" -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake" + cmake --build . --config Release shell: pwsh - name: Copy artifacts working-directory: languages/cpp/build + shell: bash run: | mkdir artifacts - cp libbitwarden_c.* artifacts - cp libBitwardenClient.* artifacts + if [[ '${{ runner.os }}' == 'macOS' || '${{ runner.os }}' == 'Linux' ]]; then + cp libbitwarden_c.* artifacts + cp libBitwardenClient.* artifacts + fi + if [[ '${{ runner.os }}' == 'Windows' ]]; then + cp */BitwardenClient.* artifacts + cp ../include/bitwarden_c.{lib,dll.lib,dll} artifacts + fi - name: Upload C++ package for ${{ matrix.settings.target }} uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 diff --git a/languages/cpp/CMakeLists.txt b/languages/cpp/CMakeLists.txt index e513a32ed..e6ad7f4f3 100644 --- a/languages/cpp/CMakeLists.txt +++ b/languages/cpp/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.15) project(BitwardenClient) set(CMAKE_CXX_STANDARD 20) +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # Set placeholders to be passed from command line set(NLOHMANN_JSON_INCLUDE_DIR_PLACEHOLDER ${NLOHMANN}) diff --git a/languages/cpp/vcpkg.json b/languages/cpp/vcpkg.json index 06a7b968c..8e5b968b9 100644 --- a/languages/cpp/vcpkg.json +++ b/languages/cpp/vcpkg.json @@ -1,10 +1,11 @@ { - "name": "bitwarden-sdk-secrets", - "version": "0.1.0", - "homepage": "https://github.com/bitwarden/sdk/tree/languages/cpp", - "description": "Bitwarden Secrets Manager SDK for C++", - "dependencies": [ - "boost", - "nlohmann-json" - ] + "name": "bitwarden-sdk-secrets", + "version": "0.1.0", + "homepage": "https://github.com/bitwarden/sdk/tree/languages/cpp", + "description": "Bitwarden Secrets Manager SDK for C++", + "dependencies": [ + "boost-uuid", + "boost-optional", + "nlohmann-json" + ] } From 7ff270d976d89c4467123bddf24aa579d5d37a2b Mon Sep 17 00:00:00 2001 From: Aaron Feickert <66188213+AaronFeickert@users.noreply.github.com> Date: Mon, 23 Sep 2024 03:43:44 -0500 Subject: [PATCH 173/214] Improve zeroization of key buffer (#1069) Currently, the temporary buffer used for deriving shareable keys is [manually zeroized](https://github.com/bitwarden/sdk/blob/76417172489d5790babbe14bb8c6ad8b3aac2a33/crates/bitwarden-crypto/src/keys/shareable_key.rs#L32-L33). While documentation indicates that preceding `expect` calls cannot fail, this still seems brittle to future changes. This PR places the buffer into a `Zeroizing` wrapper. It is still the case that zeroization may not occur on a panic, but this was already the case with the existing implementation, which would never zeroize in such a case. --- .../bitwarden-crypto/src/keys/shareable_key.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/crates/bitwarden-crypto/src/keys/shareable_key.rs b/crates/bitwarden-crypto/src/keys/shareable_key.rs index 556432aea..c6a44405c 100644 --- a/crates/bitwarden-crypto/src/keys/shareable_key.rs +++ b/crates/bitwarden-crypto/src/keys/shareable_key.rs @@ -3,7 +3,7 @@ use std::pin::Pin; use aes::cipher::typenum::U64; use generic_array::GenericArray; use hmac::Mac; -use zeroize::{Zeroize, Zeroizing}; +use zeroize::Zeroizing; use crate::{ keys::SymmetricCryptoKey, @@ -20,18 +20,17 @@ pub fn derive_shareable_key( info: Option<&str>, ) -> SymmetricCryptoKey { // Because all inputs are fixed size, we can unwrap all errors here without issue - let mut res = PbkdfSha256Hmac::new_from_slice(format!("bitwarden-{}", name).as_bytes()) - .expect("hmac new_from_slice should not fail") - .chain_update(secret) - .finalize() - .into_bytes(); + let res = Zeroizing::new( + PbkdfSha256Hmac::new_from_slice(format!("bitwarden-{}", name).as_bytes()) + .expect("hmac new_from_slice should not fail") + .chain_update(secret) + .finalize() + .into_bytes(), + ); let mut key: Pin>> = hkdf_expand(&res, info).expect("Input is a valid size"); - // Zeroize the temporary buffer - res.zeroize(); - SymmetricCryptoKey::try_from(key.as_mut_slice()).expect("Key is a valid size") } From 56fc75da9e94f0de4118cd89b6b24296ab76a682 Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Mon, 23 Sep 2024 09:48:06 -0400 Subject: [PATCH 174/214] BRE-341 - Update Publish PHP workflow (#1074) --- .github/workflows/publish-php.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish-php.yml b/.github/workflows/publish-php.yml index 0cf7c59b0..74939ec58 100644 --- a/.github/workflows/publish-php.yml +++ b/.github/workflows/publish-php.yml @@ -1,3 +1,4 @@ +--- name: Publish PHP SDK run-name: Publish PHP SDK ${{ inputs.release_type }} @@ -29,9 +30,9 @@ jobs: - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} run: | - if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then echo "===================================" - echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches" + echo "[!] Can only release from the 'main' branch" echo "===================================" exit 1 fi @@ -123,7 +124,7 @@ jobs: working-directory: sm-sdk-php run: | git add . - git commit -m "Update Go SDK to ${{ github.sha }}" + git commit -m "Update PHP SDK to ${{ github.sha }}" if [[ "${{ inputs.release_type }}" == "Dry Run" ]]; then echo "===================================" @@ -135,7 +136,7 @@ jobs: git push origin main fi - - name: Create release tag on SDK Go repo + - name: Create release tag on PHP SDK repo if: ${{ inputs.release_type != 'Dry Run' }} working-directory: sm-sdk-php run: | @@ -177,7 +178,7 @@ jobs: with: workflow: build-rust-cross-platform.yml workflow_conclusion: success - branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} + branch: main artifacts: libbitwarden_c_files-x86_64-apple-darwin skip_unpack: true @@ -186,7 +187,7 @@ jobs: with: workflow: build-rust-cross-platform.yml workflow_conclusion: success - branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} + branch: main artifacts: libbitwarden_c_files-aarch64-apple-darwin skip_unpack: true @@ -195,7 +196,7 @@ jobs: with: workflow: build-rust-cross-platform.yml workflow_conclusion: success - branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} + branch: main artifacts: libbitwarden_c_files-x86_64-unknown-linux-gnu skip_unpack: true @@ -204,7 +205,7 @@ jobs: with: workflow: build-rust-cross-platform.yml workflow_conclusion: success - branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} + branch: main artifacts: libbitwarden_c_files-x86_64-pc-windows-msvc skip_unpack: true From f62ed98e61d529a9a6270109814c23ee776da6ee Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2024 12:26:35 +0200 Subject: [PATCH 175/214] [deps]: Lock file maintenance (#1075) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. đŸ‘ģ **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 84 +++++++++++------------ languages/js/sdk-client/package-lock.json | 26 ++----- package-lock.json | 26 ++----- 3 files changed, 54 insertions(+), 82 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 068df1254..133750786 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -786,9 +786,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "bytesize" @@ -845,9 +845,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.19" +version = "1.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d74707dde2ba56f86ae90effb3b43ddd369504387e718014de010cec7959800" +checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" dependencies = [ "shlex", ] @@ -919,9 +919,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.17" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" +checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" dependencies = [ "clap_builder", "clap_derive", @@ -929,9 +929,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.17" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" +checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" dependencies = [ "anstream", "anstyle", @@ -941,18 +941,18 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.26" +version = "4.5.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "205d5ef6d485fa47606b98b0ddc4ead26eb850aaa86abfb562a94fb3280ecba0" +checksum = "8937760c3f4c60871870b8c3ee5f9b30771f792a7045c48bcbba999d7d6b3b8e" dependencies = [ "clap", ] [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -2022,9 +2022,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -2368,9 +2368,9 @@ dependencies = [ [[package]] name = "napi" -version = "2.16.10" +version = "2.16.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04409e8c2d61995696e44d2181b79b68c1dd41f7e24a17cde60bbd9f54ddddef" +checksum = "53575dfa17f208dd1ce3a2da2da4659aae393b256a472f2738a8586a6c4107fd" dependencies = [ "bitflags 2.6.0", "ctor", @@ -2536,9 +2536,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "onig" @@ -2635,7 +2635,7 @@ dependencies = [ [[package]] name = "passkey" version = "0.2.0" -source = "git+https://github.com/bitwarden/passkey-rs?rev=29bb052eb15a42e369728ded3cfb2aa7c91213df#29bb052eb15a42e369728ded3cfb2aa7c91213df" +source = "git+https://github.com/bitwarden/passkey-rs?rev=ff757604cd7b4e8f321ed1616fef7e40e21ac5df#ff757604cd7b4e8f321ed1616fef7e40e21ac5df" dependencies = [ "passkey-authenticator", "passkey-client", @@ -2646,7 +2646,7 @@ dependencies = [ [[package]] name = "passkey-authenticator" version = "0.2.0" -source = "git+https://github.com/bitwarden/passkey-rs?rev=29bb052eb15a42e369728ded3cfb2aa7c91213df#29bb052eb15a42e369728ded3cfb2aa7c91213df" +source = "git+https://github.com/bitwarden/passkey-rs?rev=ff757604cd7b4e8f321ed1616fef7e40e21ac5df#ff757604cd7b4e8f321ed1616fef7e40e21ac5df" dependencies = [ "async-trait", "coset", @@ -2659,7 +2659,7 @@ dependencies = [ [[package]] name = "passkey-client" version = "0.2.0" -source = "git+https://github.com/bitwarden/passkey-rs?rev=29bb052eb15a42e369728ded3cfb2aa7c91213df#29bb052eb15a42e369728ded3cfb2aa7c91213df" +source = "git+https://github.com/bitwarden/passkey-rs?rev=ff757604cd7b4e8f321ed1616fef7e40e21ac5df#ff757604cd7b4e8f321ed1616fef7e40e21ac5df" dependencies = [ "ciborium", "coset", @@ -2676,12 +2676,12 @@ dependencies = [ [[package]] name = "passkey-transports" version = "0.1.0" -source = "git+https://github.com/bitwarden/passkey-rs?rev=29bb052eb15a42e369728ded3cfb2aa7c91213df#29bb052eb15a42e369728ded3cfb2aa7c91213df" +source = "git+https://github.com/bitwarden/passkey-rs?rev=ff757604cd7b4e8f321ed1616fef7e40e21ac5df#ff757604cd7b4e8f321ed1616fef7e40e21ac5df" [[package]] name = "passkey-types" version = "0.2.1" -source = "git+https://github.com/bitwarden/passkey-rs?rev=29bb052eb15a42e369728ded3cfb2aa7c91213df#29bb052eb15a42e369728ded3cfb2aa7c91213df" +source = "git+https://github.com/bitwarden/passkey-rs?rev=ff757604cd7b4e8f321ed1616fef7e40e21ac5df#ff757604cd7b4e8f321ed1616fef7e40e21ac5df" dependencies = [ "bitflags 2.6.0", "ciborium", @@ -2801,9 +2801,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "plain" @@ -2854,9 +2854,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.7.0" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" +checksum = "d30538d42559de6b034bc76fd6dd4c38961b1ee5c6c56e3808c50128fdbc22ce" [[package]] name = "powerfmt" @@ -2918,7 +2918,7 @@ dependencies = [ [[package]] name = "public-suffix" version = "0.1.1" -source = "git+https://github.com/bitwarden/passkey-rs?rev=29bb052eb15a42e369728ded3cfb2aa7c91213df#29bb052eb15a42e369728ded3cfb2aa7c91213df" +source = "git+https://github.com/bitwarden/passkey-rs?rev=ff757604cd7b4e8f321ed1616fef7e40e21ac5df#ff757604cd7b4e8f321ed1616fef7e40e21ac5df" [[package]] name = "pyo3" @@ -3501,9 +3501,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -3942,18 +3942,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", @@ -4109,9 +4109,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.20" +version = "0.22.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" +checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" dependencies = [ "indexmap 2.5.0", "serde", @@ -4223,9 +4223,9 @@ checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] name = "unicode-normalization" -version = "0.1.23" +version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" dependencies = [ "tinyvec", ] @@ -4238,9 +4238,9 @@ checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "uniffi" @@ -4600,9 +4600,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "0.26.5" +version = "0.26.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a" +checksum = "841c67bff177718f1d4dfefde8d8f0e78f9b6589319ba88312f567fc5841a958" dependencies = [ "rustls-pki-types", ] diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index e81afb713..ab7809936 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -29,21 +29,10 @@ "node": ">=12" } }, - "node_modules/@pkgjs/parseargs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", - "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=14" - } - }, "node_modules/@types/node": { - "version": "20.16.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.5.tgz", - "integrity": "sha512-VwYCweNo3ERajwy0IUlqqcyZ8/A7Zwa9ZP3MnENWcB11AejO+tLy3pu850goUW2FC/IJMdZUfKpX/yxL1gymCA==", + "version": "20.16.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.6.tgz", + "integrity": "sha512-T7PpxM/6yeDE+AdlVysT62BX6/bECZOmQAgiFg5NoBd5MQheZ3tzal7f1wvzfiEcmrcJNRi2zRr2nY2zF+0uqw==", "dev": true, "license": "MIT", "dependencies": { @@ -201,9 +190,9 @@ "license": "ISC" }, "node_modules/jackspeak": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.1.tgz", - "integrity": "sha512-cub8rahkh0Q/bw1+GxP7aeSe29hHHn2V4m29nnDlvCdlgU+3UGxkZp7Z53jLUdpX3jdTO0nJZUDl3xvbWc2Xog==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.2.tgz", + "integrity": "sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -214,9 +203,6 @@ }, "funding": { "url": "https://github.com/sponsors/isaacs" - }, - "optionalDependencies": { - "@pkgjs/parseargs": "^0.11.0" } }, "node_modules/lru-cache": { diff --git a/package-lock.json b/package-lock.json index 859e169ff..59b48116d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -330,17 +330,6 @@ "url": "https://opencollective.com/openapi_generator" } }, - "node_modules/@pkgjs/parseargs": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", - "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", - "dev": true, - "license": "MIT", - "optional": true, - "engines": { - "node": ">=14" - } - }, "node_modules/@tsconfig/node10": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", @@ -370,9 +359,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.5.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.5.tgz", - "integrity": "sha512-Xjs4y5UPO/CLdzpgR6GirZJx36yScjh73+2NlLlkFRSoQN8B0DpfXPdZGnvVmLRLOsqDpOfTNv7D9trgGhmOIA==", + "version": "22.6.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.6.1.tgz", + "integrity": "sha512-V48tCfcKb/e6cVUigLAaJDAILdMP0fUW6BidkPK4GpGjXcfbnoHasCZDwz3N3yVt5we2RHm4XTQCpv0KJz9zqw==", "dev": true, "license": "MIT", "peer": true, @@ -1339,9 +1328,9 @@ } }, "node_modules/jackspeak": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.1.tgz", - "integrity": "sha512-cub8rahkh0Q/bw1+GxP7aeSe29hHHn2V4m29nnDlvCdlgU+3UGxkZp7Z53jLUdpX3jdTO0nJZUDl3xvbWc2Xog==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.2.tgz", + "integrity": "sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==", "dev": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -1352,9 +1341,6 @@ }, "funding": { "url": "https://github.com/sponsors/isaacs" - }, - "optionalDependencies": { - "@pkgjs/parseargs": "^0.11.0" } }, "node_modules/js-base64": { From 074762124ab1e182455deacc5f65956723913b7b Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 24 Sep 2024 13:21:32 +0200 Subject: [PATCH 176/214] [PM-12576] Support publishing gradle to local maven repository (#1076) Support publishing to local maven repository. --- languages/kotlin/publish-local.sh | 16 ++++++++++++++ languages/kotlin/sdk/build.gradle | 36 ++++++++++++++++--------------- 2 files changed, 35 insertions(+), 17 deletions(-) create mode 100755 languages/kotlin/publish-local.sh diff --git a/languages/kotlin/publish-local.sh b/languages/kotlin/publish-local.sh new file mode 100755 index 000000000..68e67455f --- /dev/null +++ b/languages/kotlin/publish-local.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -e + +cd "$(dirname "$0")" + +mkdir -p ./sdk/src/main/jniLibs/{arm64-v8a,armeabi-v7a,x86_64,x86} + +# Build arm64 for emulator +cross build -p bitwarden-uniffi --release --target=aarch64-linux-android +mv ../../target/aarch64-linux-android/release/libbitwarden_uniffi.so ./sdk/src/main/jniLibs/arm64-v8a/libbitwarden_uniffi.so + +# Generate latest bindings +./build-schemas.sh + +# Publish to local maven +./gradlew sdk:publishToMavenLocal -Pversion=LOCAL diff --git a/languages/kotlin/sdk/build.gradle b/languages/kotlin/sdk/build.gradle index d3ea098e3..2006e4673 100644 --- a/languages/kotlin/sdk/build.gradle +++ b/languages/kotlin/sdk/build.gradle @@ -47,23 +47,25 @@ publishing { groupId = 'com.bitwarden' artifactId = 'sdk-android' - // Determine the version from the git history. - // - // PRs: use the branch name. - // Main: Grab it from `crates/bitwarden/Cargo.toml` - - def branchName = 'git branch --show-current'.execute().text.trim() - - if (branchName == 'main') { - def content = ['grep', '-o', '^version = ".*"', '../../Cargo.toml'].execute().text.trim() - def match = ~/version = "(.*)"/ - def matcher = match.matcher(content) - matcher.find() - - version = "${matcher.group(1)}-SNAPSHOT" - } else { - // branchName-SNAPSHOT - version = "${branchName.replaceAll('/', '-')}-SNAPSHOT" + if (findProperty('version') == 'unspecified') { + // Determine the version from the git history. + // + // PRs: use the branch name. + // Main: Grab it from `crates/bitwarden/Cargo.toml` + + def branchName = 'git branch --show-current'.execute().text.trim() + + if (branchName == 'main') { + def content = ['grep', '-o', '^version = ".*"', '../../Cargo.toml'].execute().text.trim() + def match = ~/version = "(.*)"/ + def matcher = match.matcher(content) + matcher.find() + + version = "${matcher.group(1)}-SNAPSHOT" + } else { + // branchName-SNAPSHOT + version = "${branchName.replaceAll('/', '-')}-SNAPSHOT" + } } afterEvaluate { From ae05bd000e8fb2182d05ac9d6e6cb879dc39c92a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 24 Sep 2024 11:34:45 -0400 Subject: [PATCH 177/214] [deps]: Update gh minor (#1047) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/build-android.yml | 4 ++-- .github/workflows/build-java.yml | 2 +- .github/workflows/build-napi.yml | 2 +- .github/workflows/build-python-wheels.yml | 2 +- .github/workflows/build-wasm.yml | 2 +- .github/workflows/generate_schemas.yml | 2 +- .github/workflows/lint.yml | 4 ++-- .github/workflows/publish-java.yml | 4 ++-- .github/workflows/publish-ruby.yml | 2 +- .github/workflows/release-napi.yml | 2 +- .github/workflows/release-wasm.yml | 2 +- .github/workflows/scan.yml | 4 ++-- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index 909e689c4..e94bfd7a9 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -80,7 +80,7 @@ jobs: key: cargo-combine-cache - name: Setup Java - uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 + uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0 with: distribution: temurin java-version: 17 @@ -102,7 +102,7 @@ jobs: run: ./build-schemas.sh - name: Setup gradle - uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4.0.1 + uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0 - name: Publish run: ./gradlew sdk:publish diff --git a/.github/workflows/build-java.yml b/.github/workflows/build-java.yml index a42663e3f..7f5713087 100644 --- a/.github/workflows/build-java.yml +++ b/.github/workflows/build-java.yml @@ -34,7 +34,7 @@ jobs: path: languages/java/src/main/java/bit/sdk/schema/ - name: Setup Java - uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 + uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0 with: distribution: temurin java-version: 17 diff --git a/.github/workflows/build-napi.yml b/.github/workflows/build-napi.yml index e950b5e7a..a7d8f7bca 100644 --- a/.github/workflows/build-napi.yml +++ b/.github/workflows/build-napi.yml @@ -54,7 +54,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Node - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 + uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 18 cache: "npm" diff --git a/.github/workflows/build-python-wheels.yml b/.github/workflows/build-python-wheels.yml index 943177d69..ed07bbb94 100644 --- a/.github/workflows/build-python-wheels.yml +++ b/.github/workflows/build-python-wheels.yml @@ -66,7 +66,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Node - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 + uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 18 diff --git a/.github/workflows/build-wasm.yml b/.github/workflows/build-wasm.yml index c2c79d3ad..996ff0ade 100644 --- a/.github/workflows/build-wasm.yml +++ b/.github/workflows/build-wasm.yml @@ -25,7 +25,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Node - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 + uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 18 registry-url: "https://npm.pkg.github.com" diff --git a/.github/workflows/generate_schemas.yml b/.github/workflows/generate_schemas.yml index 9f3e6743c..c1db37d5d 100644 --- a/.github/workflows/generate_schemas.yml +++ b/.github/workflows/generate_schemas.yml @@ -27,7 +27,7 @@ jobs: toolchain: stable - name: Set up Node - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 + uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: cache: "npm" cache-dependency-path: "package-lock.json" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 686b5775a..951c8fcba 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -45,12 +45,12 @@ jobs: RUSTFLAGS: "-D warnings" - name: Upload Clippy results to GitHub - uses: github/codeql-action/upload-sarif@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6 + uses: github/codeql-action/upload-sarif@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8 with: sarif_file: clippy_result.sarif - name: Set up Node - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 + uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: cache: "npm" cache-dependency-path: "package-lock.json" diff --git a/.github/workflows/publish-java.yml b/.github/workflows/publish-java.yml index fdf0be986..2daeffe5a 100644 --- a/.github/workflows/publish-java.yml +++ b/.github/workflows/publish-java.yml @@ -64,13 +64,13 @@ jobs: maven-sonartype-ossrh-password" - name: Setup java - uses: actions/setup-java@6a0805fcefea3d4657a47ac4c165951e33482018 # v4.2.2 + uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4.4.0 with: distribution: temurin java-version: 17 - name: Setup Gradle - uses: gradle/actions/setup-gradle@16bf8bc8fe830fa669c3c9f914d3eb147c629707 # v4.0.1 + uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0 - name: Publish package to GitHub Packages if: ${{ inputs.release_type != 'Dry Run' }} diff --git a/.github/workflows/publish-ruby.yml b/.github/workflows/publish-ruby.yml index a2390953e..c372a476d 100644 --- a/.github/workflows/publish-ruby.yml +++ b/.github/workflows/publish-ruby.yml @@ -36,7 +36,7 @@ jobs: fi - name: Set up Ruby - uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # v1.191.0 + uses: ruby/setup-ruby@f321cf5a4d1533575411f8752cf25b86478b0442 # v1.193.0 with: ruby-version: 3.2 diff --git a/.github/workflows/release-napi.yml b/.github/workflows/release-napi.yml index bdb579ec2..fc4eaa367 100644 --- a/.github/workflows/release-napi.yml +++ b/.github/workflows/release-napi.yml @@ -93,7 +93,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Node - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 + uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 18 cache: "npm" diff --git a/.github/workflows/release-wasm.yml b/.github/workflows/release-wasm.yml index 268dd1ce2..dac64a6ce 100644 --- a/.github/workflows/release-wasm.yml +++ b/.github/workflows/release-wasm.yml @@ -92,7 +92,7 @@ jobs: uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Setup Node - uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 + uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 with: node-version: 18 cache: "npm" diff --git a/.github/workflows/scan.yml b/.github/workflows/scan.yml index 5595316de..364298f98 100644 --- a/.github/workflows/scan.yml +++ b/.github/workflows/scan.yml @@ -31,7 +31,7 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} - name: Scan with Checkmarx - uses: checkmarx/ast-github-action@1fe318de2993222574e6249750ba9000a4e2a6cd # 2.0.33 + uses: checkmarx/ast-github-action@9fda5a4a2c297608117a5a56af424502a9192e57 # 2.0.34 env: INCREMENTAL: "${{ contains(github.event_name, 'pull_request') && '--sast-incremental' || '' }}" with: @@ -46,7 +46,7 @@ jobs: --output-path . ${{ env.INCREMENTAL }} - name: Upload Checkmarx results to GitHub - uses: github/codeql-action/upload-sarif@4dd16135b69a43b6c8efb853346f8437d92d3c93 # v3.26.6 + uses: github/codeql-action/upload-sarif@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8 with: sarif_file: cx_result.sarif From 5b5b36eb18f01c023cba66decb8d53257f9898a9 Mon Sep 17 00:00:00 2001 From: Bitwarden DevOps <106330231+bitwarden-devops-bot@users.noreply.github.com> Date: Wed, 25 Sep 2024 10:53:49 -0600 Subject: [PATCH 178/214] Bump java-sdk version to 1.0.0 (#1079) ## Type of change - [ ] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [X] Other ## Objective Automated java-sdk version bump to 1.0.0 --- languages/java/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/java/build.gradle b/languages/java/build.gradle index 6f24369d7..52337a447 100644 --- a/languages/java/build.gradle +++ b/languages/java/build.gradle @@ -36,7 +36,7 @@ repositories { def branchName = "git branch --show-current".execute().text.trim() if (branchName == "main" || branchName == "rc" || branchName == "hotfix-rc") { - version = "0.1.0" + version = "1.0.0" } else { // branchName-SNAPSHOT version = "${branchName.replaceAll('/', '-')}-SNAPSHOT" From 605ebf67780b18203c21b1ea7853c8ad0f0dcb51 Mon Sep 17 00:00:00 2001 From: Bitwarden DevOps <106330231+bitwarden-devops-bot@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:49:20 -0600 Subject: [PATCH 179/214] Bump go-sdk version to 1.0.1 (#1080) ## Type of change - [ ] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [X] Other ## Objective Automated go-sdk version bump to 1.0.1 --- languages/go/.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/go/.version b/languages/go/.version index afaf360d3..7f207341d 100644 --- a/languages/go/.version +++ b/languages/go/.version @@ -1 +1 @@ -1.0.0 \ No newline at end of file +1.0.1 \ No newline at end of file From 1a991965896d50b95a413c31aacade8dfb464e96 Mon Sep 17 00:00:00 2001 From: Bitwarden DevOps <106330231+bitwarden-devops-bot@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:52:24 -0600 Subject: [PATCH 180/214] Bump python-sdk version to 1.0.0 (#1081) ## Type of change - [ ] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [X] Other ## Objective Automated python-sdk version bump to 1.0.0 --- languages/python/bitwarden_sdk/__init__.py | 2 +- languages/python/pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/languages/python/bitwarden_sdk/__init__.py b/languages/python/bitwarden_sdk/__init__.py index 067ed3aa5..f1712c77b 100644 --- a/languages/python/bitwarden_sdk/__init__.py +++ b/languages/python/bitwarden_sdk/__init__.py @@ -1,6 +1,6 @@ """The official Bitwarden client library for Python.""" -__version__ = "0.1.1" +__version__ = "1.0.0" from .bitwarden_client import * from .schemas import * diff --git a/languages/python/pyproject.toml b/languages/python/pyproject.toml index 0ce9a96b2..a4ab1f693 100644 --- a/languages/python/pyproject.toml +++ b/languages/python/pyproject.toml @@ -17,7 +17,7 @@ description = "A Bitwarden Client for python" name = "bitwarden_sdk" readme = "README.md" requires-python = ">=3.0" -version = "0.1.1" +version = "1.0.0" [tool.maturin] bindings = "pyo3" From ae2a7c0447e70c8c5510fe14d57a8b949abee05d Mon Sep 17 00:00:00 2001 From: Bitwarden DevOps <106330231+bitwarden-devops-bot@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:54:34 -0600 Subject: [PATCH 181/214] Bump php-sdk version to 1.0.0 (#1082) ## Type of change - [ ] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [X] Other ## Objective Automated php-sdk version bump to 1.0.0 --- languages/php/composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/php/composer.json b/languages/php/composer.json index fce61f890..6df44ed0b 100644 --- a/languages/php/composer.json +++ b/languages/php/composer.json @@ -4,7 +4,7 @@ "type": "library", "keywords": ["bitwarden","sdk","password-manager"], "homepage": "https://github.com/bitwarden/sdk", - "version": "0.1.0", + "version": "1.0.0", "require": { "php": "^8.0", "ext-ffi": "*" From 4d5b713089ffa9310255b1cd7f1779b610d8eb95 Mon Sep 17 00:00:00 2001 From: Bitwarden DevOps <106330231+bitwarden-devops-bot@users.noreply.github.com> Date: Wed, 25 Sep 2024 11:59:20 -0600 Subject: [PATCH 182/214] Bump napi version to 1.0.0 (#1083) ## Type of change - [ ] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [X] Other ## Objective Automated napi version bump to 1.0.0 --- Cargo.lock | 2 +- crates/bitwarden-napi/Cargo.toml | 2 +- crates/bitwarden-napi/npm/darwin-arm64/package.json | 2 +- crates/bitwarden-napi/npm/darwin-x64/package.json | 2 +- crates/bitwarden-napi/npm/linux-x64-gnu/package.json | 2 +- crates/bitwarden-napi/npm/win32-x64-msvc/package.json | 2 +- crates/bitwarden-napi/package-lock.json | 4 ++-- crates/bitwarden-napi/package.json | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 133750786..a1a9bcd23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -559,7 +559,7 @@ dependencies = [ [[package]] name = "bitwarden-napi" -version = "0.3.1" +version = "1.0.0" dependencies = [ "bitwarden-json", "env_logger", diff --git a/crates/bitwarden-napi/Cargo.toml b/crates/bitwarden-napi/Cargo.toml index 7bcd54aad..59ca137aa 100644 --- a/crates/bitwarden-napi/Cargo.toml +++ b/crates/bitwarden-napi/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bitwarden-napi" -version = "0.3.1" +version = "1.0.0" description = """ N-API bindings for the Bitwarden Secrets Manager SDK """ diff --git a/crates/bitwarden-napi/npm/darwin-arm64/package.json b/crates/bitwarden-napi/npm/darwin-arm64/package.json index 52d785d87..88e3122c5 100644 --- a/crates/bitwarden-napi/npm/darwin-arm64/package.json +++ b/crates/bitwarden-napi/npm/darwin-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@bitwarden/sdk-napi-darwin-arm64", - "version": "0.3.1", + "version": "1.0.0", "homepage": "https://github.com/bitwarden/sdk#readme", "bugs": { "url": "https://github.com/bitwarden/sdk/issues" diff --git a/crates/bitwarden-napi/npm/darwin-x64/package.json b/crates/bitwarden-napi/npm/darwin-x64/package.json index 0a1b06423..4650654ce 100644 --- a/crates/bitwarden-napi/npm/darwin-x64/package.json +++ b/crates/bitwarden-napi/npm/darwin-x64/package.json @@ -1,6 +1,6 @@ { "name": "@bitwarden/sdk-napi-darwin-x64", - "version": "0.3.1", + "version": "1.0.0", "homepage": "https://github.com/bitwarden/sdk#readme", "bugs": { "url": "https://github.com/bitwarden/sdk/issues" diff --git a/crates/bitwarden-napi/npm/linux-x64-gnu/package.json b/crates/bitwarden-napi/npm/linux-x64-gnu/package.json index 2284d8415..ed3b62f80 100644 --- a/crates/bitwarden-napi/npm/linux-x64-gnu/package.json +++ b/crates/bitwarden-napi/npm/linux-x64-gnu/package.json @@ -1,6 +1,6 @@ { "name": "@bitwarden/sdk-napi-linux-x64-gnu", - "version": "0.3.1", + "version": "1.0.0", "homepage": "https://github.com/bitwarden/sdk#readme", "bugs": { "url": "https://github.com/bitwarden/sdk/issues" diff --git a/crates/bitwarden-napi/npm/win32-x64-msvc/package.json b/crates/bitwarden-napi/npm/win32-x64-msvc/package.json index 261554e93..5b2a93121 100644 --- a/crates/bitwarden-napi/npm/win32-x64-msvc/package.json +++ b/crates/bitwarden-napi/npm/win32-x64-msvc/package.json @@ -1,6 +1,6 @@ { "name": "@bitwarden/sdk-napi-win32-x64-msvc", - "version": "0.3.1", + "version": "1.0.0", "homepage": "https://github.com/bitwarden/sdk#readme", "bugs": { "url": "https://github.com/bitwarden/sdk/issues" diff --git a/crates/bitwarden-napi/package-lock.json b/crates/bitwarden-napi/package-lock.json index 8082a7a80..eaa8d3473 100644 --- a/crates/bitwarden-napi/package-lock.json +++ b/crates/bitwarden-napi/package-lock.json @@ -1,12 +1,12 @@ { "name": "@bitwarden/sdk-napi", - "version": "0.3.1", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@bitwarden/sdk-napi", - "version": "0.3.1", + "version": "1.0.0", "license": "SEE LICENSE IN LICENSE", "devDependencies": { "@napi-rs/cli": "2.18.4", diff --git a/crates/bitwarden-napi/package.json b/crates/bitwarden-napi/package.json index 9f1048d18..31cee632b 100644 --- a/crates/bitwarden-napi/package.json +++ b/crates/bitwarden-napi/package.json @@ -1,6 +1,6 @@ { "name": "@bitwarden/sdk-napi", - "version": "0.3.1", + "version": "1.0.0", "homepage": "https://github.com/bitwarden/sdk#readme", "bugs": { "url": "https://github.com/bitwarden/sdk/issues" From 73d3ce83cebb68e156955fe6eee8e98b13a5a0bd Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Thu, 26 Sep 2024 12:05:17 -0400 Subject: [PATCH 183/214] [PM-12431] Temporarily un-export bitwarden_fido (#1072) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/PM-12431 ## 📔 Objective Temporarily un-export `bitwarden-fido`. We can't release crates for `1.0` because: - `bitwarden-fido` currently relies on dependencies that are GitHub repositories ([reference](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#specifying-dependencies-from-other-registries)) - `bitwarden-fido` is not yet released (same with the aforementioned dependencies) This PR also includes the auto-updates to the `Cargo.lock file`, which should be fine. ⭐ī¸**NOTE**⭐ī¸: This will break CI, this should only be merged when we are ready to do 1.0 releases of `bitwarden`, `bws`, etc. It should quickly be followed up a PR, after release, which reverses this. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/publish-rust-crates.yml | 2 +- Cargo.lock | 1 - crates/bitwarden/Cargo.toml | 6 ++++-- crates/bitwarden/src/error.rs | 4 +++- crates/bitwarden/src/lib.rs | 16 ++++++++++++---- 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/workflows/publish-rust-crates.yml b/.github/workflows/publish-rust-crates.yml index bdb39d9b7..ec9848127 100644 --- a/.github/workflows/publish-rust-crates.yml +++ b/.github/workflows/publish-rust-crates.yml @@ -72,7 +72,7 @@ jobs: env: PUBLISH_GRACE_SLEEP: 10 CARGO_REGISTRY_TOKEN: ${{ steps.retrieve-secrets.outputs.cratesio-api-token }} - run: cargo-release release publish --exclude bw --exclude bws --execute --no-confirm + run: cargo-release release publish --exclude bw --exclude bws --exclude bitwarden-fido --execute --no-confirm - name: Update deployment status to Success if: ${{ inputs.release_type != 'Dry Run' && success() }} diff --git a/Cargo.lock b/Cargo.lock index a1a9bcd23..9bfdbe70c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -367,7 +367,6 @@ dependencies = [ "bitwarden-core", "bitwarden-crypto", "bitwarden-exporters", - "bitwarden-fido", "bitwarden-generators", "bitwarden-send", "bitwarden-sm", diff --git a/crates/bitwarden/Cargo.toml b/crates/bitwarden/Cargo.toml index f927564cf..31d84b877 100644 --- a/crates/bitwarden/Cargo.toml +++ b/crates/bitwarden/Cargo.toml @@ -30,7 +30,8 @@ uniffi = [ "bitwarden-core/uniffi", "bitwarden-crypto/uniffi", "bitwarden-exporters/uniffi", - "bitwarden-fido/uniffi", + # PR #1072 + # "bitwarden-fido/uniffi", "bitwarden-generators/uniffi", "bitwarden-send/uniffi", "bitwarden-vault/uniffi", @@ -43,7 +44,8 @@ bitwarden-api-identity = { workspace = true } bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } bitwarden-exporters = { workspace = true, optional = true } -bitwarden-fido = { workspace = true, optional = true } +# PR #1072 +# bitwarden-fido = { workspace = true, optional = true } bitwarden-generators = { workspace = true, optional = true } bitwarden-send = { workspace = true, optional = true } bitwarden-sm = { workspace = true, optional = true } diff --git a/crates/bitwarden/src/error.rs b/crates/bitwarden/src/error.rs index 06ef09648..a6f6c09de 100644 --- a/crates/bitwarden/src/error.rs +++ b/crates/bitwarden/src/error.rs @@ -37,6 +37,8 @@ pub enum Error { ExportError(#[from] ExportError), // Fido + /* + # PR #1072 #[cfg(all(feature = "uniffi", feature = "internal"))] #[error(transparent)] MakeCredential(#[from] bitwarden_fido::MakeCredentialError), @@ -57,7 +59,7 @@ pub enum Error { #[cfg(all(feature = "uniffi", feature = "internal"))] #[error(transparent)] Fido2Client(#[from] bitwarden_fido::Fido2ClientError), - + */ #[error("Internal error: {0}")] Internal(Cow<'static, str>), } diff --git a/crates/bitwarden/src/lib.rs b/crates/bitwarden/src/lib.rs index c87693ce7..5751c313b 100644 --- a/crates/bitwarden/src/lib.rs +++ b/crates/bitwarden/src/lib.rs @@ -79,10 +79,18 @@ pub mod internal { pub use bitwarden_vault::*; } - #[cfg(feature = "uniffi")] - pub mod fido { - pub use bitwarden_fido::*; - } + /* + PM-12431 + # PR #1072 + + Temporarily un-export bitwarden_fido, as bitwarden_fido + is not ready for release yet. This will unblock the + 1.0 releases. + */ + // #[cfg(feature = "uniffi")] + // pub mod fido { + // pub use bitwarden_fido::*; + // } } #[cfg(feature = "internal")] pub use internal::*; From 5069409e1c043488543d5e0663a8d06cc17edc35 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Thu, 26 Sep 2024 12:51:49 -0400 Subject: [PATCH 184/214] Revert "[PM-12431] Temporarily un-export bitwarden_fido" (#1086) Reverts bitwarden/sdk#1072 --- .github/workflows/publish-rust-crates.yml | 2 +- Cargo.lock | 1 + crates/bitwarden/Cargo.toml | 6 ++---- crates/bitwarden/src/error.rs | 4 +--- crates/bitwarden/src/lib.rs | 16 ++++------------ 5 files changed, 9 insertions(+), 20 deletions(-) diff --git a/.github/workflows/publish-rust-crates.yml b/.github/workflows/publish-rust-crates.yml index ec9848127..bdb39d9b7 100644 --- a/.github/workflows/publish-rust-crates.yml +++ b/.github/workflows/publish-rust-crates.yml @@ -72,7 +72,7 @@ jobs: env: PUBLISH_GRACE_SLEEP: 10 CARGO_REGISTRY_TOKEN: ${{ steps.retrieve-secrets.outputs.cratesio-api-token }} - run: cargo-release release publish --exclude bw --exclude bws --exclude bitwarden-fido --execute --no-confirm + run: cargo-release release publish --exclude bw --exclude bws --execute --no-confirm - name: Update deployment status to Success if: ${{ inputs.release_type != 'Dry Run' && success() }} diff --git a/Cargo.lock b/Cargo.lock index 9bfdbe70c..a1a9bcd23 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -367,6 +367,7 @@ dependencies = [ "bitwarden-core", "bitwarden-crypto", "bitwarden-exporters", + "bitwarden-fido", "bitwarden-generators", "bitwarden-send", "bitwarden-sm", diff --git a/crates/bitwarden/Cargo.toml b/crates/bitwarden/Cargo.toml index 31d84b877..f927564cf 100644 --- a/crates/bitwarden/Cargo.toml +++ b/crates/bitwarden/Cargo.toml @@ -30,8 +30,7 @@ uniffi = [ "bitwarden-core/uniffi", "bitwarden-crypto/uniffi", "bitwarden-exporters/uniffi", - # PR #1072 - # "bitwarden-fido/uniffi", + "bitwarden-fido/uniffi", "bitwarden-generators/uniffi", "bitwarden-send/uniffi", "bitwarden-vault/uniffi", @@ -44,8 +43,7 @@ bitwarden-api-identity = { workspace = true } bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } bitwarden-exporters = { workspace = true, optional = true } -# PR #1072 -# bitwarden-fido = { workspace = true, optional = true } +bitwarden-fido = { workspace = true, optional = true } bitwarden-generators = { workspace = true, optional = true } bitwarden-send = { workspace = true, optional = true } bitwarden-sm = { workspace = true, optional = true } diff --git a/crates/bitwarden/src/error.rs b/crates/bitwarden/src/error.rs index a6f6c09de..06ef09648 100644 --- a/crates/bitwarden/src/error.rs +++ b/crates/bitwarden/src/error.rs @@ -37,8 +37,6 @@ pub enum Error { ExportError(#[from] ExportError), // Fido - /* - # PR #1072 #[cfg(all(feature = "uniffi", feature = "internal"))] #[error(transparent)] MakeCredential(#[from] bitwarden_fido::MakeCredentialError), @@ -59,7 +57,7 @@ pub enum Error { #[cfg(all(feature = "uniffi", feature = "internal"))] #[error(transparent)] Fido2Client(#[from] bitwarden_fido::Fido2ClientError), - */ + #[error("Internal error: {0}")] Internal(Cow<'static, str>), } diff --git a/crates/bitwarden/src/lib.rs b/crates/bitwarden/src/lib.rs index 5751c313b..c87693ce7 100644 --- a/crates/bitwarden/src/lib.rs +++ b/crates/bitwarden/src/lib.rs @@ -79,18 +79,10 @@ pub mod internal { pub use bitwarden_vault::*; } - /* - PM-12431 - # PR #1072 - - Temporarily un-export bitwarden_fido, as bitwarden_fido - is not ready for release yet. This will unblock the - 1.0 releases. - */ - // #[cfg(feature = "uniffi")] - // pub mod fido { - // pub use bitwarden_fido::*; - // } + #[cfg(feature = "uniffi")] + pub mod fido { + pub use bitwarden_fido::*; + } } #[cfg(feature = "internal")] pub use internal::*; From 2d1c6872eaac4405bf74efa011156a5d49a0bff3 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 26 Sep 2024 19:12:43 +0200 Subject: [PATCH 185/214] Add links to documentation (#1085) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📔 Objective Add links to documentation. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 497af6547..14ca1f667 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,19 @@ To build, you will need the following in your PATH: - We recommend installing this via the [Visual Studio Build Tools](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) +## Documentation + +Please refer to our [Contributing Docs](https://contributing.bitwarden.com/) for +[getting started](https://contributing.bitwarden.com/getting-started/sdk/) instructions and +[architectural documentation](https://contributing.bitwarden.com/architecture/sdk/). + +You can also browse the latest published documentation: + +- [docs.rs](https://docs.rs/bitwarden/latest/bitwarden/) for the public SDK. +- Or for developers of the SDK, view the internal + [API documentation](https://sdk-api-docs.bitwarden.com/bitwarden/index.html) which includes + private items. + ## Crates The project is structured as a monorepo using cargo workspaces. Some of the more noteworthy crates From 42b536a1af65e3877e811c1420fa93055261ce32 Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Fri, 27 Sep 2024 08:56:01 -0400 Subject: [PATCH 186/214] BRE-345 - Update Java workflows (#1087) --- .github/workflows/build-java.yml | 24 ++++++++++++++++++-- .github/workflows/publish-java.yml | 36 +++++++++++++++++++++++++++--- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-java.yml b/.github/workflows/build-java.yml index 7f5713087..98880e52b 100644 --- a/.github/workflows/build-java.yml +++ b/.github/workflows/build-java.yml @@ -1,11 +1,10 @@ +--- name: Build Java SDK on: push: branches: - main - - rc - - hotfix-rc pull_request: workflow_dispatch: @@ -66,3 +65,24 @@ jobs: - name: Build Maven run: ./gradlew build working-directory: languages/java + + - name: Upload Java SDK Build + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + name: build + path: ${{ github.workspace }}/languages/java/build + if-no-files-found: error + + - name: Upload Java SDK Build + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + name: resources + path: ${{ github.workspace }}/languages/java/src/main/resources + if-no-files-found: error + + - name: Upload Java SDK Build + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + name: schemas + path: languages/java/src/main/java/bit/sdk/schema + if-no-files-found: error diff --git a/.github/workflows/publish-java.yml b/.github/workflows/publish-java.yml index 2daeffe5a..65e0b0abe 100644 --- a/.github/workflows/publish-java.yml +++ b/.github/workflows/publish-java.yml @@ -1,3 +1,4 @@ +--- name: Publish Java SDK run-name: Publish Java SDK ${{ inputs.release_type }} @@ -13,6 +14,11 @@ on: - Release - Dry Run +defaults: + run: + shell: bash + working-directory: languages/java + env: _KEY_VAULT: "bitwarden-ci" @@ -29,9 +35,9 @@ jobs: - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} run: | - if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then echo "===================================" - echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches" + echo "[!] Can only release from the 'main' branch" echo "===================================" exit 1 fi @@ -39,7 +45,7 @@ jobs: - name: Get version id: version run: | - VERSION=$(cat languages/java/build.gradle | grep -Eo 'version = "[0-9]+\.[0-9]+\.[0-9]+"' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+') + VERSION=$(cat build.gradle | grep -Eo 'version = "[0-9]+\.[0-9]+\.[0-9]+"' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+') echo "version=$VERSION" >> $GITHUB_OUTPUT publish: @@ -72,6 +78,30 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4.1.0 + - name: Download Java SDK Build + uses: bitwarden/gh-actions/download-artifacts@main + with: + workflow: build-java.yml + workflow_conclusion: success + artifacts: build + path: languages/java/build + + - name: Download Java Resources + uses: bitwarden/gh-actions/download-artifacts@main + with: + workflow: build-java.yml + workflow_conclusion: success + artifacts: resources + path: languages/java/src/main/resources + + - name: Download Java Resources + uses: bitwarden/gh-actions/download-artifacts@main + with: + workflow: build-java.yml + workflow_conclusion: success + artifacts: schemas + path: languages/java/src/main/java/bit/sdk/schema + - name: Publish package to GitHub Packages if: ${{ inputs.release_type != 'Dry Run' }} run: ./gradlew publish From 90f8a5461e5e7ed07b1f5a13fc2fb793994a6fb5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 10:36:55 +0200 Subject: [PATCH 187/214] [deps]: Lock file maintenance (#1099) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. đŸ‘ģ **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 179 +++++++++------------- languages/js/sdk-client/package-lock.json | 12 +- package-lock.json | 12 +- 3 files changed, 82 insertions(+), 121 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a1a9bcd23..27eddfa65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -188,7 +188,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -231,13 +231,13 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.82" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -248,9 +248,9 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backtrace" @@ -845,9 +845,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.21" +version = "1.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" dependencies = [ "shlex", ] @@ -957,7 +957,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1300,7 +1300,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edb49164822f3ee45b17acd4a208cfc1251410cf0cad9a833234c9890774dd9f" dependencies = [ "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1324,7 +1324,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1335,7 +1335,7 @@ checksum = "d336a2a514f6ccccaa3e09b02d41d35330c07ddf03a62165fcec10bb561c7806" dependencies = [ "darling_core", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1414,7 +1414,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1424,7 +1424,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4abae7035bf79b9877b779505d8cf3749285b80c43941eda66604841889451dc" dependencies = [ "derive_builder_core", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -1602,9 +1602,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.33" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", "miniz_oxide 0.8.0", @@ -1690,7 +1690,7 @@ checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2002,9 +2002,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da62f120a8a37763efb0cf8fdf264b884c7b8b9ac8660b900c8661030c00e6ba" +checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" dependencies = [ "bytes", "futures-channel", @@ -2015,7 +2015,6 @@ dependencies = [ "pin-project-lite", "socket2", "tokio", - "tower", "tower-service", "tracing", ] @@ -2213,9 +2212,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.158" +version = "0.2.159" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" [[package]] name = "libloading" @@ -2397,7 +2396,7 @@ dependencies = [ "napi-derive-backend", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2412,7 +2411,7 @@ dependencies = [ "quote", "regex", "semver", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2536,9 +2535,12 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" +dependencies = [ + "portable-atomic", +] [[package]] name = "onig" @@ -2746,26 +2748,6 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" -[[package]] -name = "pin-project" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" -dependencies = [ - "pin-project-internal", -] - -[[package]] -name = "pin-project-internal" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.77", -] - [[package]] name = "pin-project-lite" version = "0.2.14" @@ -2854,9 +2836,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d30538d42559de6b034bc76fd6dd4c38961b1ee5c6c56e3808c50128fdbc22ce" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "powerfmt" @@ -2978,7 +2960,7 @@ dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -2991,7 +2973,7 @@ dependencies = [ "proc-macro2", "pyo3-build-config", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -3112,9 +3094,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.4" +version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" dependencies = [ "bitflags 2.6.0", ] @@ -3132,9 +3114,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" dependencies = [ "aho-corasick", "memchr", @@ -3144,9 +3126,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" dependencies = [ "aho-corasick", "memchr", @@ -3155,9 +3137,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" @@ -3326,9 +3308,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc0a2ce646f8655401bb81e7927b812614bd5d91dbc968696be50603510fcaf0" +checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55" [[package]] name = "rustls-platform-verifier" @@ -3422,7 +3404,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -3454,7 +3436,7 @@ checksum = "7f81c2fde025af7e69b1d1420531c8a8811ca898919db177141a85313b1cb932" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -3535,7 +3517,7 @@ checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -3546,7 +3528,7 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -3581,14 +3563,14 @@ checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] name = "serde_spanned" -version = "0.6.7" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" dependencies = [ "serde", ] @@ -3632,7 +3614,7 @@ dependencies = [ "darling", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -3831,7 +3813,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -3844,7 +3826,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -3874,9 +3856,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" dependencies = [ "proc-macro2", "quote", @@ -3920,9 +3902,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", @@ -3957,7 +3939,7 @@ checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4050,7 +4032,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4109,9 +4091,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.22.21" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap 2.5.0", "serde", @@ -4120,27 +4102,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "tower" -version = "0.4.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" -dependencies = [ - "futures-core", - "futures-util", - "pin-project", - "pin-project-lite", - "tokio", - "tower-layer", - "tower-service", -] - -[[package]] -name = "tower-layer" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" - [[package]] name = "tower-service" version = "0.3.3" @@ -4306,7 +4267,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a22dbe67c1c957ac6e7611bdf605a6218aa86b0eebeb8be58b70ae85ad7d73dc" dependencies = [ "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4338,7 +4299,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.77", + "syn 2.0.79", "toml 0.5.11", "uniffi_meta", ] @@ -4453,7 +4414,7 @@ dependencies = [ "proc-macro-error", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4517,7 +4478,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-shared", ] @@ -4551,7 +4512,7 @@ checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -4585,7 +4546,7 @@ checksum = "4b8220be1fa9e4c889b30fd207d4906657e7e90b12e0e6b0c8b8d8709f5de021" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4848,9 +4809,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -4903,7 +4864,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] @@ -4924,7 +4885,7 @@ checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.79", ] [[package]] diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index ab7809936..f5b6f590b 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -30,9 +30,9 @@ } }, "node_modules/@types/node": { - "version": "20.16.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.6.tgz", - "integrity": "sha512-T7PpxM/6yeDE+AdlVysT62BX6/bECZOmQAgiFg5NoBd5MQheZ3tzal7f1wvzfiEcmrcJNRi2zRr2nY2zF+0uqw==", + "version": "20.16.10", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.10.tgz", + "integrity": "sha512-vQUKgWTjEIRFCvK6CyriPH3MZYiYlNy0fKiEYHWbcoWLEgs4opurGGKlebrTLqdSMIbXImH6XExNiIyNUv3WpA==", "dev": true, "license": "MIT", "dependencies": { @@ -242,9 +242,9 @@ } }, "node_modules/package-json-from-dist": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz", - "integrity": "sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", "dev": true, "license": "BlueOak-1.0.0" }, diff --git a/package-lock.json b/package-lock.json index 59b48116d..9ceb5ffed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -359,9 +359,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.6.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.6.1.tgz", - "integrity": "sha512-V48tCfcKb/e6cVUigLAaJDAILdMP0fUW6BidkPK4GpGjXcfbnoHasCZDwz3N3yVt5we2RHm4XTQCpv0KJz9zqw==", + "version": "22.7.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.4.tgz", + "integrity": "sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg==", "dev": true, "license": "MIT", "peer": true, @@ -1573,9 +1573,9 @@ } }, "node_modules/package-json-from-dist": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz", - "integrity": "sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", "dev": true, "license": "BlueOak-1.0.0" }, From 2868f26058ddce9709bed2a8f31b967475dd80e4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 11:44:51 +0200 Subject: [PATCH 188/214] [deps]: Update gh minor (#1097) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [actions/checkout](https://redirect.github.com/actions/checkout) | action | minor | `v4.1.7` -> `v4.2.0` | | [docker/build-push-action](https://redirect.github.com/docker/build-push-action) | action | minor | `v6.7.0` -> `v6.8.0` | | [github/codeql-action](https://redirect.github.com/github/codeql-action) | action | patch | `v3.26.8` -> `v3.26.9` | | [goto-bus-stop/setup-zig](https://redirect.github.com/goto-bus-stop/setup-zig) | action | patch | `v2.2.0` -> `v2.2.1` | | [ruby/setup-ruby](https://redirect.github.com/ruby/setup-ruby) | action | minor | `v1.193.0` -> `v1.194.0` | --- ### Release Notes
actions/checkout (actions/checkout) ### [`v4.2.0`](https://redirect.github.com/actions/checkout/blob/HEAD/CHANGELOG.md#v420) [Compare Source](https://redirect.github.com/actions/checkout/compare/v4.1.7...v4.2.0) - Add Ref and Commit outputs by [@​lucacome](https://redirect.github.com/lucacome) in [https://github.com/actions/checkout/pull/1180](https://redirect.github.com/actions/checkout/pull/1180) - Dependency updates by [@​dependabot-](https://redirect.github.com/dependabot-) [https://github.com/actions/checkout/pull/1777](https://redirect.github.com/actions/checkout/pull/1777), [https://github.com/actions/checkout/pull/1872](https://redirect.github.com/actions/checkout/pull/1872)
docker/build-push-action (docker/build-push-action) ### [`v6.8.0`](https://redirect.github.com/docker/build-push-action/releases/tag/v6.8.0) [Compare Source](https://redirect.github.com/docker/build-push-action/compare/v6.7.0...v6.8.0) - Bump [@​docker/actions-toolkit](https://redirect.github.com/docker/actions-toolkit) from 0.37.1 to 0.38.0 in [https://github.com/docker/build-push-action/pull/1230](https://redirect.github.com/docker/build-push-action/pull/1230) **Full Changelog**: https://github.com/docker/build-push-action/compare/v6.7.0...v6.8.0
github/codeql-action (github/codeql-action) ### [`v3.26.9`](https://redirect.github.com/github/codeql-action/compare/v3.26.8...v3.26.9) [Compare Source](https://redirect.github.com/github/codeql-action/compare/v3.26.8...v3.26.9)
goto-bus-stop/setup-zig (goto-bus-stop/setup-zig) ### [`v2.2.1`](https://redirect.github.com/goto-bus-stop/setup-zig/releases/tag/v2.2.1) [Compare Source](https://redirect.github.com/goto-bus-stop/setup-zig/compare/v2.2.0...v2.2.1) This will be the final release in this repository. Please see [#​88](https://redirect.github.com/goto-bus-stop/setup-zig/issues/88) for an upgrade guide. Thanks for using setup-zig! - Fix Apple Silicon. [#​68](https://redirect.github.com/goto-bus-stop/setup-zig/pull/68) - Deprecate in favour of [mlugg/setup-zig](https://redirect.github.com/mlugg/setup-zig). [#​89](https://redirect.github.com/goto-bus-stop/setup-zig/pull/89) Thanks [@​davidgm94](https://redirect.github.com/davidgm94) and [@​mlugg](https://redirect.github.com/mlugg)!
ruby/setup-ruby (ruby/setup-ruby) ### [`v1.194.0`](https://redirect.github.com/ruby/setup-ruby/releases/tag/v1.194.0) [Compare Source](https://redirect.github.com/ruby/setup-ruby/compare/v1.193.0...v1.194.0) **Full Changelog**: https://github.com/ruby/setup-ruby/compare/v1.193.0...v1.194.0
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. đŸ‘ģ **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/build-android.yml | 6 +++--- .github/workflows/build-cli-docker.yml | 4 ++-- .github/workflows/build-cli.yml | 16 ++++++++-------- .github/workflows/build-cpp.yml | 2 +- .github/workflows/build-dotnet.yml | 4 ++-- .github/workflows/build-go.yaml | 2 +- .github/workflows/build-java.yml | 2 +- .github/workflows/build-napi.yml | 2 +- .github/workflows/build-python-wheels.yml | 4 ++-- .github/workflows/build-rust-crates.yml | 4 ++-- .github/workflows/build-rust-cross-platform.yml | 4 ++-- .github/workflows/build-swift.yml | 4 ++-- .github/workflows/build-wasm.yml | 2 +- .github/workflows/cloc.yml | 2 +- .github/workflows/direct-minimal-versions.yml | 2 +- .github/workflows/generate_schemas.yml | 2 +- .github/workflows/lint.yml | 4 ++-- .github/workflows/memory-testing.yml | 2 +- .github/workflows/minimum-rust-version.yml | 2 +- .github/workflows/publish-dotnet.yml | 2 +- .github/workflows/publish-java.yml | 4 ++-- .github/workflows/publish-php.yml | 10 +++++----- .github/workflows/publish-python.yml | 2 +- .github/workflows/publish-ruby.yml | 4 ++-- .github/workflows/publish-rust-crates.yml | 2 +- .github/workflows/release-cli.yml | 8 ++++---- .github/workflows/release-cpp.yml | 2 +- .github/workflows/release-go.yml | 6 +++--- .github/workflows/release-napi.yml | 4 ++-- .github/workflows/release-swift.yml | 6 +++--- .github/workflows/release-wasm.yml | 4 ++-- .github/workflows/rust-test.yml | 6 +++--- .github/workflows/rustdoc.yml | 2 +- .github/workflows/scan.yml | 6 +++--- .github/workflows/version-bump.yml | 4 ++-- 35 files changed, 71 insertions(+), 71 deletions(-) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index e94bfd7a9..7607d530d 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -25,7 +25,7 @@ jobs: - target: i686-linux-android steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -57,14 +57,14 @@ jobs: needs: build steps: - name: Checkout repo (PR) - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 if: github.event_name == 'pull_request' with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.ref }} - name: Checkout repo (Push) - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 if: github.event_name == 'push' with: fetch-depth: 0 diff --git a/.github/workflows/build-cli-docker.yml b/.github/workflows/build-cli-docker.yml index eaf2299ff..83daabf2d 100644 --- a/.github/workflows/build-cli-docker.yml +++ b/.github/workflows/build-cli-docker.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Check Branch to Publish id: publish-branch-check @@ -87,7 +87,7 @@ jobs: fi - name: Build and push Docker image - uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0 + uses: docker/build-push-action@32945a339266b759abcbdc89316275140b0fc960 # v6.8.0 with: context: . file: crates/bws/Dockerfile diff --git a/.github/workflows/build-cli.yml b/.github/workflows/build-cli.yml index 355575716..9ffb3bdea 100644 --- a/.github/workflows/build-cli.yml +++ b/.github/workflows/build-cli.yml @@ -21,7 +21,7 @@ jobs: sign: ${{ steps.sign.outputs.sign }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Get Package Version id: retrieve-version @@ -56,7 +56,7 @@ jobs: target: aarch64-pc-windows-msvc steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -145,7 +145,7 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -259,7 +259,7 @@ jobs: target: aarch64-unknown-linux-gnu steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -268,7 +268,7 @@ jobs: targets: ${{ matrix.settings.target }} - name: Set up Zig - uses: goto-bus-stop/setup-zig@7ab2955eb728f5440978d5824358023be3a2802d # v2.2.0 + uses: goto-bus-stop/setup-zig@abea47f85e598557f500fa1fd2ab7464fcb39406 # v2.2.1 with: version: 0.12.0 @@ -305,7 +305,7 @@ jobs: _PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Download x86_64-apple-darwin artifact uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 @@ -407,7 +407,7 @@ jobs: - setup steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -441,7 +441,7 @@ jobs: needs: setup steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable diff --git a/.github/workflows/build-cpp.yml b/.github/workflows/build-cpp.yml index 606cefdee..01222aac9 100644 --- a/.github/workflows/build-cpp.yml +++ b/.github/workflows/build-cpp.yml @@ -41,7 +41,7 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: install dependencies linux if: runner.os == 'Linux' diff --git a/.github/workflows/build-dotnet.yml b/.github/workflows/build-dotnet.yml index 97d43dfbe..bb5d56b6b 100644 --- a/.github/workflows/build-dotnet.yml +++ b/.github/workflows/build-dotnet.yml @@ -23,7 +23,7 @@ jobs: version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install xmllint run: sudo apt-get install -y libxml2-utils @@ -44,7 +44,7 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Download C# schemas artifact uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 diff --git a/.github/workflows/build-go.yaml b/.github/workflows/build-go.yaml index 4ad7d0345..ffb4d6693 100644 --- a/.github/workflows/build-go.yaml +++ b/.github/workflows/build-go.yaml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Setup Go environment uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 diff --git a/.github/workflows/build-java.yml b/.github/workflows/build-java.yml index 98880e52b..6994a5a61 100644 --- a/.github/workflows/build-java.yml +++ b/.github/workflows/build-java.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Download Java schemas artifact uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 diff --git a/.github/workflows/build-napi.yml b/.github/workflows/build-napi.yml index a7d8f7bca..41ed1d17d 100644 --- a/.github/workflows/build-napi.yml +++ b/.github/workflows/build-napi.yml @@ -51,7 +51,7 @@ jobs: strip *.node steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Setup Node uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 diff --git a/.github/workflows/build-python-wheels.yml b/.github/workflows/build-python-wheels.yml index ed07bbb94..b39195679 100644 --- a/.github/workflows/build-python-wheels.yml +++ b/.github/workflows/build-python-wheels.yml @@ -26,7 +26,7 @@ jobs: package_version: ${{ steps.retrieve-version.outputs.package_version }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Get Package Version id: retrieve-version @@ -63,7 +63,7 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Setup Node uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 diff --git a/.github/workflows/build-rust-crates.yml b/.github/workflows/build-rust-crates.yml index b7d0832fb..d4116bcf9 100644 --- a/.github/workflows/build-rust-crates.yml +++ b/.github/workflows/build-rust-crates.yml @@ -34,7 +34,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -62,7 +62,7 @@ jobs: needs: build steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable diff --git a/.github/workflows/build-rust-cross-platform.yml b/.github/workflows/build-rust-cross-platform.yml index 7c567135b..fab7df991 100644 --- a/.github/workflows/build-rust-cross-platform.yml +++ b/.github/workflows/build-rust-cross-platform.yml @@ -38,7 +38,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -48,7 +48,7 @@ jobs: - name: Cache cargo registry uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 - - uses: goto-bus-stop/setup-zig@7ab2955eb728f5440978d5824358023be3a2802d # v2.2.0 + - uses: goto-bus-stop/setup-zig@abea47f85e598557f500fa1fd2ab7464fcb39406 # v2.2.1 if: ${{ contains(matrix.settings.target, 'musl') }} with: version: 0.12.0 diff --git a/.github/workflows/build-swift.yml b/.github/workflows/build-swift.yml index 22da084ed..372241348 100644 --- a/.github/workflows/build-swift.yml +++ b/.github/workflows/build-swift.yml @@ -17,7 +17,7 @@ jobs: package_version: ${{ steps.retrieve-version.outputs.package_version }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Get Package Version id: retrieve-version @@ -33,7 +33,7 @@ jobs: _VERSION: ${{ needs.version.outputs.package_version }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable diff --git a/.github/workflows/build-wasm.yml b/.github/workflows/build-wasm.yml index 996ff0ade..35c0ca6b6 100644 --- a/.github/workflows/build-wasm.yml +++ b/.github/workflows/build-wasm.yml @@ -22,7 +22,7 @@ jobs: steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Setup Node uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 diff --git a/.github/workflows/cloc.yml b/.github/workflows/cloc.yml index 120aeb511..644dc0bfd 100644 --- a/.github/workflows/cloc.yml +++ b/.github/workflows/cloc.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Set up cloc run: | diff --git a/.github/workflows/direct-minimal-versions.yml b/.github/workflows/direct-minimal-versions.yml index 3cfec8a48..22feb04cf 100644 --- a/.github/workflows/direct-minimal-versions.yml +++ b/.github/workflows/direct-minimal-versions.yml @@ -36,7 +36,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable diff --git a/.github/workflows/generate_schemas.yml b/.github/workflows/generate_schemas.yml index c1db37d5d..434174c7b 100644 --- a/.github/workflows/generate_schemas.yml +++ b/.github/workflows/generate_schemas.yml @@ -19,7 +19,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 951c8fcba..a12e263c4 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -45,7 +45,7 @@ jobs: RUSTFLAGS: "-D warnings" - name: Upload Clippy results to GitHub - uses: github/codeql-action/upload-sarif@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8 + uses: github/codeql-action/upload-sarif@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9 with: sarif_file: clippy_result.sarif diff --git a/.github/workflows/memory-testing.yml b/.github/workflows/memory-testing.yml index a9635bc68..41b158536 100644 --- a/.github/workflows/memory-testing.yml +++ b/.github/workflows/memory-testing.yml @@ -22,7 +22,7 @@ jobs: steps: - name: Check out repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Set up gdb run: | diff --git a/.github/workflows/minimum-rust-version.yml b/.github/workflows/minimum-rust-version.yml index 19b81de63..fa95eb0bb 100644 --- a/.github/workflows/minimum-rust-version.yml +++ b/.github/workflows/minimum-rust-version.yml @@ -27,7 +27,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable diff --git a/.github/workflows/publish-dotnet.yml b/.github/workflows/publish-dotnet.yml index 1c4cf5840..28a57e683 100644 --- a/.github/workflows/publish-dotnet.yml +++ b/.github/workflows/publish-dotnet.yml @@ -24,7 +24,7 @@ jobs: version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} diff --git a/.github/workflows/publish-java.yml b/.github/workflows/publish-java.yml index 65e0b0abe..98f6fadd2 100644 --- a/.github/workflows/publish-java.yml +++ b/.github/workflows/publish-java.yml @@ -30,7 +30,7 @@ jobs: version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} @@ -54,7 +54,7 @@ jobs: needs: validate steps: - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Azure login uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 diff --git a/.github/workflows/publish-php.yml b/.github/workflows/publish-php.yml index 74939ec58..986923ab5 100644 --- a/.github/workflows/publish-php.yml +++ b/.github/workflows/publish-php.yml @@ -25,7 +25,7 @@ jobs: version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} @@ -48,7 +48,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Setup PHP with PECL extension uses: shivammathur/setup-php@c541c155eee45413f5b09a52248675b1a2575231 # 2.31.1 @@ -76,7 +76,7 @@ jobs: _PKG_VERSION: ${{ needs.validate.outputs.version }} steps: - name: Checkout SDK repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 with: path: sdk @@ -93,7 +93,7 @@ jobs: secrets: "github-pat-bitwarden-devops-bot-repo-scope" - name: Checkout SDK-PHP repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 with: repository: bitwarden/sm-sdk-php path: sm-sdk-php @@ -255,7 +255,7 @@ jobs: packagist-key" - name: Checkout SDK-PHP repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 with: repository: bitwarden/sm-sdk-php path: sm-sdk-php diff --git a/.github/workflows/publish-python.yml b/.github/workflows/publish-python.yml index ef30d6598..dcbfee22f 100644 --- a/.github/workflows/publish-python.yml +++ b/.github/workflows/publish-python.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} diff --git a/.github/workflows/publish-ruby.yml b/.github/workflows/publish-ruby.yml index c372a476d..6184586a1 100644 --- a/.github/workflows/publish-ruby.yml +++ b/.github/workflows/publish-ruby.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout Repository - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} @@ -36,7 +36,7 @@ jobs: fi - name: Set up Ruby - uses: ruby/setup-ruby@f321cf5a4d1533575411f8752cf25b86478b0442 # v1.193.0 + uses: ruby/setup-ruby@c04af2bb7258bb6a03df1d3c1865998ac9390972 # v1.194.0 with: ruby-version: 3.2 diff --git a/.github/workflows/publish-rust-crates.yml b/.github/workflows/publish-rust-crates.yml index bdb39d9b7..a614608f9 100644 --- a/.github/workflows/publish-rust-crates.yml +++ b/.github/workflows/publish-rust-crates.yml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index 80c09142e..30f0dfd93 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -25,7 +25,7 @@ jobs: release-version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} @@ -112,7 +112,7 @@ jobs: needs: setup steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Login to Azure uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 @@ -150,7 +150,7 @@ jobs: needs: setup steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Generate tag list id: tag-list @@ -201,7 +201,7 @@ jobs: azure-keyvault-name: "bitwarden-ci" - name: Build and push Docker image - uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0 + uses: docker/build-push-action@32945a339266b759abcbdc89316275140b0fc960 # v6.8.0 with: context: . file: crates/bws/Dockerfile diff --git a/.github/workflows/release-cpp.yml b/.github/workflows/release-cpp.yml index c96b8e088..aa4d37f62 100644 --- a/.github/workflows/release-cpp.yml +++ b/.github/workflows/release-cpp.yml @@ -24,7 +24,7 @@ jobs: version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} diff --git a/.github/workflows/release-go.yml b/.github/workflows/release-go.yml index 2c2aea4e4..f88e52af5 100644 --- a/.github/workflows/release-go.yml +++ b/.github/workflows/release-go.yml @@ -26,7 +26,7 @@ jobs: version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} @@ -55,7 +55,7 @@ jobs: steps: - name: Checkout SDK repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 with: path: sdk @@ -72,7 +72,7 @@ jobs: secrets: "github-pat-bitwarden-devops-bot-repo-scope" - name: Checkout SDK-Go repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 with: repository: bitwarden/sdk-go path: sdk-go diff --git a/.github/workflows/release-napi.yml b/.github/workflows/release-napi.yml index fc4eaa367..fb99cc1cf 100644 --- a/.github/workflows/release-napi.yml +++ b/.github/workflows/release-napi.yml @@ -33,7 +33,7 @@ jobs: release-version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Branch check if: ${{ github.event.inputs.release_type != 'Dry Run' }} @@ -90,7 +90,7 @@ jobs: _PKG_VERSION: ${{ needs.setup.outputs.release-version }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Setup Node uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 diff --git a/.github/workflows/release-swift.yml b/.github/workflows/release-swift.yml index a9ab213a6..351581a7a 100644 --- a/.github/workflows/release-swift.yml +++ b/.github/workflows/release-swift.yml @@ -42,7 +42,7 @@ jobs: swift_checksum: ${{ steps.calculate-swift-checksum.outputs.checksum }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Get version id: version @@ -114,7 +114,7 @@ jobs: _BUILD_RUN_ID: ${{ needs.validate.outputs.run_id }} steps: - name: Checkout SDK repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 with: path: sdk @@ -142,7 +142,7 @@ jobs: github-pat-bitwarden-devops-bot-repo-scope" - name: Checkout SDK-Swift repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 with: repository: bitwarden/sdk-swift path: sdk-swift diff --git a/.github/workflows/release-wasm.yml b/.github/workflows/release-wasm.yml index dac64a6ce..b6476e833 100644 --- a/.github/workflows/release-wasm.yml +++ b/.github/workflows/release-wasm.yml @@ -32,7 +32,7 @@ jobs: release-version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Branch check if: ${{ github.event.inputs.release_type != 'Dry Run' }} @@ -89,7 +89,7 @@ jobs: _PKG_VERSION: ${{ needs.setup.outputs.release-version }} steps: - name: Checkout repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Setup Node uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 diff --git a/.github/workflows/rust-test.yml b/.github/workflows/rust-test.yml index 3d9ed6f00..5e7703e84 100644 --- a/.github/workflows/rust-test.yml +++ b/.github/workflows/rust-test.yml @@ -34,7 +34,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -54,7 +54,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable @@ -83,7 +83,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable diff --git a/.github/workflows/rustdoc.yml b/.github/workflows/rustdoc.yml index a2a07490c..45ab6d07d 100644 --- a/.github/workflows/rustdoc.yml +++ b/.github/workflows/rustdoc.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Install rust uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable diff --git a/.github/workflows/scan.yml b/.github/workflows/scan.yml index 364298f98..193c9fcf6 100644 --- a/.github/workflows/scan.yml +++ b/.github/workflows/scan.yml @@ -26,7 +26,7 @@ jobs: steps: - name: Check out repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 with: ref: ${{ github.event.pull_request.head.sha }} @@ -46,7 +46,7 @@ jobs: --output-path . ${{ env.INCREMENTAL }} - name: Upload Checkmarx results to GitHub - uses: github/codeql-action/upload-sarif@294a9d92911152fe08befb9ec03e240add280cb3 # v3.26.8 + uses: github/codeql-action/upload-sarif@461ef6c76dfe95d5c364de2f431ddbd31a417628 # v3.26.9 with: sarif_file: cx_result.sarif @@ -60,7 +60,7 @@ jobs: steps: - name: Check out repo - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index 8357d49bd..7053181eb 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -59,7 +59,7 @@ jobs: github-pat-bitwarden-devops-bot-repo-scope" - name: Checkout Branch - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 with: ref: main repository: bitwarden/sdk @@ -236,7 +236,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout Branch - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 with: ref: main From a6fd484c31aead9f8bbdc0576cc2be3a069c9891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ch=C4=99ci=C5=84ski?= Date: Mon, 30 Sep 2024 15:12:34 +0200 Subject: [PATCH 189/214] [BRE-224] Create a GitHub release workflows for sdk (#1078) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/BRE-224 ## 📔 Objective Create and/or split workflow to create a GitHub Release for SDK parts. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --------- Co-authored-by: Vince Grassia <593223+vgrassia@users.noreply.github.com> --- .github/workflows/build-ruby.yml | 95 +++++++++++ .../{release-cli.yml => publish-bws.yml} | 116 +++++++------ .github/workflows/publish-dotnet.yml | 69 ++++++-- .github/workflows/publish-java.yml | 27 ++- .github/workflows/publish-napi.yml | 155 ++++++++++++++++++ .github/workflows/publish-python.yml | 55 +++++-- .github/workflows/publish-ruby.yml | 130 +++++++-------- .github/workflows/publish-rust-crates.yml | 38 ++++- .github/workflows/publish-wasm.yml | 138 ++++++++++++++++ .github/workflows/release-bws.yml | 77 +++++++++ .github/workflows/release-cpp.yml | 8 +- .github/workflows/release-dotnet.yml | 76 +++++++++ .github/workflows/release-java.yml | 61 +++++++ .github/workflows/release-napi.yml | 142 ++++------------ .github/workflows/release-python.yml | 74 +++++++++ .github/workflows/release-ruby.yml | 71 ++++++++ .github/workflows/release-rust-crates.yml | 53 ++++++ .github/workflows/release-wasm.yml | 96 +++-------- 18 files changed, 1128 insertions(+), 353 deletions(-) create mode 100644 .github/workflows/build-ruby.yml rename .github/workflows/{release-cli.yml => publish-bws.yml} (72%) create mode 100644 .github/workflows/publish-napi.yml create mode 100644 .github/workflows/publish-wasm.yml create mode 100644 .github/workflows/release-bws.yml create mode 100644 .github/workflows/release-dotnet.yml create mode 100644 .github/workflows/release-java.yml create mode 100644 .github/workflows/release-python.yml create mode 100644 .github/workflows/release-ruby.yml create mode 100644 .github/workflows/release-rust-crates.yml diff --git a/.github/workflows/build-ruby.yml b/.github/workflows/build-ruby.yml new file mode 100644 index 000000000..5a3f1a016 --- /dev/null +++ b/.github/workflows/build-ruby.yml @@ -0,0 +1,95 @@ +--- +name: Build Ruby + +on: + pull_request: + push: + branches: + - "main" + workflow_dispatch: + +jobs: + build: + name: Build Ruby + runs-on: ubuntu-22.04 + steps: + - name: Checkout Repository + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Set up Ruby + uses: ruby/setup-ruby@52753b7da854d5c07df37391a986c76ab4615999 # v1.191.0 + with: + ruby-version: 3.2 + + - name: Download artifacts + uses: bitwarden/gh-actions/download-artifacts@main + with: + workflow: generate_schemas.yml + path: languages/ruby/bitwarden_sdk_secrets/lib + workflow_conclusion: success + branch: ${{ github.ref_name }} + artifacts: schemas.rb + + - name: Download x86_64-apple-darwin artifact + uses: bitwarden/gh-actions/download-artifacts@main + with: + workflow: build-rust-cross-platform.yml + path: temp/macos-x64 + workflow_conclusion: success + branch: ${{ github.ref_name }} + artifacts: libbitwarden_c_files-x86_64-apple-darwin + + - name: Download aarch64-apple-darwin artifact + uses: bitwarden/gh-actions/download-artifacts@main + with: + workflow: build-rust-cross-platform.yml + workflow_conclusion: success + branch: ${{ github.ref_name }} + artifacts: libbitwarden_c_files-aarch64-apple-darwin + path: temp/macos-arm64 + + - name: Download x86_64-unknown-linux-gnu artifact + uses: bitwarden/gh-actions/download-artifacts@main + with: + workflow: build-rust-cross-platform.yml + workflow_conclusion: success + branch: ${{ github.ref_name }} + artifacts: libbitwarden_c_files-x86_64-unknown-linux-gnu + path: temp/linux-x64 + + - name: Download x86_64-pc-windows-msvc artifact + uses: bitwarden/gh-actions/download-artifacts@main + with: + workflow: build-rust-cross-platform.yml + workflow_conclusion: success + branch: ${{ github.ref_name }} + artifacts: libbitwarden_c_files-x86_64-pc-windows-msvc + path: temp/windows-x64 + + - name: Copy lib files + run: | + mkdir -p languages/ruby/bitwarden_sdk_secrets/lib/macos-arm64 + mkdir -p languages/ruby/bitwarden_sdk_secrets/lib/linux-x64 + mkdir -p languages/ruby/bitwarden_sdk_secrets/lib/macos-x64 + mkdir -p languages/ruby/bitwarden_sdk_secrets/lib/windows-x64 + + platforms=("macos-arm64" "linux-x64" "macos-x64" "windows-x64") + files=("libbitwarden_c.dylib" "libbitwarden_c.so" "libbitwarden_c.dylib" "bitwarden_c.dll") + + for ((i=0; i<${#platforms[@]}; i++)); do + cp "temp/${platforms[$i]}/${files[$i]}" "languages/ruby/bitwarden_sdk_secrets/lib/${platforms[$i]}/${files[$i]}" + done + + - name: bundle install + run: bundle install + working-directory: languages/ruby/bitwarden_sdk_secrets + + - name: Build gem + run: gem build bitwarden-sdk-secrets.gemspec + working-directory: languages/ruby/bitwarden_sdk_secrets + + - name: Upload artifact + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + path: bitwarden-sdk-secrets-*.gem + name: bitwarden-sdk-secrets diff --git a/.github/workflows/release-cli.yml b/.github/workflows/publish-bws.yml similarity index 72% rename from .github/workflows/release-cli.yml rename to .github/workflows/publish-bws.yml index 30f0dfd93..506427faa 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/publish-bws.yml @@ -1,6 +1,6 @@ --- -name: Release CLI -run-name: Release CLI ${{ inputs.release_type }} +name: Publish bws CLI +run-name: Publish bws CLI ${{ inputs.release_type }} on: workflow_dispatch: @@ -13,6 +13,11 @@ on: options: - Release - Dry Run + version: + description: 'Version to publish (default: latest bws cli release)' + required: true + type: string + default: latest env: _AZ_REGISTRY: bitwardenprod.azurecr.io @@ -22,7 +27,9 @@ jobs: name: Setup runs-on: ubuntu-22.04 outputs: - release-version: ${{ steps.version.outputs.version }} + release-version: ${{ steps.version-output.outputs.version }} + release-tag: ${{ steps.version-output.outputs.tag_name }} + deployment-id: ${{ steps.deployment.outputs.deployment_id }} steps: - name: Checkout repo uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 @@ -37,11 +44,21 @@ jobs: exit 1 fi - - name: Check Release Version - id: version + - name: Version output + id: version-output run: | - VERSION=$(grep -o '^version = ".*"' crates/bws/Cargo.toml | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+") - echo "version=$VERSION" >> $GITHUB_OUTPUT + if [[ "${{ inputs.version }}" == "latest" || "${{ inputs.version }}" == "" ]]; then + TAG_NAME=$(curl "https://api.github.com/repos/bitwarden/sdk/releases" | jq -c '.[] | select(.tag_name | contains("bws")) | .tag_name' | head -1) + VERSION=$(echo $TAG_NAME | grep -ohE '20[0-9]{2}\.([1-9]|1[0-2])\.[0-9]+') + echo "Latest Released Version: $VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + + echo "Latest Released Tag name: $TAG_NAME" + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT + else + echo "Release Version: ${{ inputs.version }}" + echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT + fi - name: Create GitHub deployment if: ${{ inputs.release_type != 'Dry Run' }} @@ -50,66 +67,18 @@ jobs: with: token: "${{ secrets.GITHUB_TOKEN }}" initial-status: "in_progress" - environment: "CLI - Production" - description: "Deployment ${{ steps.version.outputs.version }} from branch ${{ github.ref_name }}" + environment: "bws CLI - Production" + description: "Deployment ${{ steps.version-output.outputs.version }} from branch ${{ github.ref_name }}" task: release - - name: Download all Release artifacts - uses: bitwarden/gh-actions/download-artifacts@main - with: - workflow: build-cli.yml - path: packages - workflow_conclusion: success - branch: ${{ github.ref_name }} - - - name: Get checksum files - uses: bitwarden/gh-actions/get-checksum@main - with: - packages_dir: "packages" - file_path: "packages/bws-sha256-checksums-${{ steps.version.outputs.version }}.txt" - - - name: Create release - if: ${{ inputs.release_type != 'Dry Run' }} - uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 - env: - PKG_VERSION: ${{ steps.version.outputs.version }} - with: - artifacts: "packages/bws-x86_64-apple-darwin-${{ env.PKG_VERSION }}.zip, - packages/bws-aarch64-apple-darwin-${{ env.PKG_VERSION }}.zip, - packages/bws-macos-universal-${{ env.PKG_VERSION }}.zip, - packages/bws-x86_64-pc-windows-msvc-${{ env.PKG_VERSION }}.zip, - packages/bws-aarch64-pc-windows-msvc-${{ env.PKG_VERSION }}.zip, - packages/bws-x86_64-unknown-linux-gnu-${{ env.PKG_VERSION }}.zip, - packages/bws-aarch64-unknown-linux-gnu-${{ env.PKG_VERSION }}.zip, - packages/THIRDPARTY.html, - packages/bws-sha256-checksums-${{ env.PKG_VERSION }}.txt" - commit: ${{ github.sha }} - tag: bws-v${{ env.PKG_VERSION }} - name: bws CLI v${{ env.PKG_VERSION }} - body: "" - token: ${{ secrets.GITHUB_TOKEN }} - draft: true - - - name: Update deployment status to Success - if: ${{ inputs.release_type != 'Dry Run' && success() }} - uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 - with: - token: "${{ secrets.GITHUB_TOKEN }}" - state: "success" - deployment-id: ${{ steps.deployment.outputs.deployment_id }} - - - name: Update deployment status to Failure - if: ${{ inputs.release_type != 'Dry Run' && failure() }} - uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 - with: - token: "${{ secrets.GITHUB_TOKEN }}" - state: "failure" - deployment-id: ${{ steps.deployment.outputs.deployment_id }} publish: name: Publish bws to crates.io runs-on: ubuntu-22.04 needs: setup + env: + _VERSION: ${{ needs.setup.outputs.release-version }} + _TAG_NAME: ${{ needs.setup.outputs.release-tag }} steps: - name: Checkout uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 @@ -118,6 +87,7 @@ jobs: uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 with: creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} + ref: ${{ env._TAG_NAME }} - name: Retrieve secrets id: retrieve-secrets @@ -151,6 +121,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + with: + ref: ${{ env._TAG_NAME }} - name: Generate tag list id: tag-list @@ -218,3 +190,27 @@ jobs: run: | docker logout echo "DOCKER_CONTENT_TRUST=0" >> $GITHUB_ENV + + update_release_status: + name: Update GitHub deployment status + runs-on: ubuntu-22.04 + needs: setup + if: ${{ inputs.release_type != 'Dry Run' }} + env: + _DEPLOYMENT_ID: ${{ needs.setup.outputs.deployment-id }} + steps: + - name: Update deployment status to Success + if: ${{ inputs.release_type != 'Dry Run' && success() }} + uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 + with: + token: "${{ secrets.GITHUB_TOKEN }}" + state: "success" + deployment-id: ${{ env._DEPLOYMENT_ID }} + + - name: Update deployment status to Failure + if: ${{ inputs.release_type != 'Dry Run' && failure() }} + uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 + with: + token: "${{ secrets.GITHUB_TOKEN }}" + state: "failure" + deployment-id: ${{ env._DEPLOYMENT_ID }} diff --git a/.github/workflows/publish-dotnet.yml b/.github/workflows/publish-dotnet.yml index 28a57e683..baafcc522 100644 --- a/.github/workflows/publish-dotnet.yml +++ b/.github/workflows/publish-dotnet.yml @@ -12,6 +12,10 @@ on: options: - Release - Dry Run + version: + description: "Release Version" + required: false + default: "latest" env: _KEY_VAULT: "bitwarden-ci" @@ -21,7 +25,7 @@ jobs: name: Setup runs-on: ubuntu-22.04 outputs: - version: ${{ steps.version.outputs.version }} + version: ${{ steps.version-output.outputs.version }} steps: - name: Checkout repo uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 @@ -29,35 +33,50 @@ jobs: - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} run: | - if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then echo "===================================" - echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches" + echo "[!] Can only release from the 'main' branch" echo "===================================" exit 1 fi - - name: Install xmllint - run: sudo apt-get install -y libxml2-utils - - - name: Get version - id: version + - name: Version output + id: version-output run: | - VERSION=$(xmllint --xpath 'string(/Project/PropertyGroup/Version)' languages/csharp/Bitwarden.Sdk/Bitwarden.Sdk.csproj) - echo "version=$VERSION" >> $GITHUB_OUTPUT + if [[ "${{ inputs.version }}" == "latest" || "${{ inputs.version }}" == "" ]]; then + TAG_NAME=$(curl "https://api.github.com/repos/bitwarden/sdk/releases" | jq -c '.[] | select(.tag_name | contains("dotnet")) | .tag_name' | head -1) + VERSION=$(echo $TAG_NAME | grep -ohE '20[0-9]{2}\.([1-9]|1[0-2])\.[0-9]+') + echo "Latest Released Version: $VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + + echo "Latest Released Tag name: $TAG_NAME" + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT + else + echo "Release Version: ${{ inputs.version }}" + echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT + fi deploy: name: Deploy runs-on: ubuntu-22.04 needs: validate steps: - - name: Download NuGet package - uses: bitwarden/gh-actions/download-artifacts@main + - name: Create GitHub deployment + if: ${{ inputs.release_type != 'Dry Run' }} + uses: chrnorm/deployment-action@55729fcebec3d284f60f5bcabbd8376437d696b1 # v2.0.7 + id: deployment with: - workflow: build-dotnet.yml - workflow_conclusion: success - branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} - artifacts: Bitwarden.Sdk.${{ needs.validate.outputs.version }}.nupkg - path: ./nuget-output + token: '${{ secrets.GITHUB_TOKEN }}' + initial-status: 'in_progress' + environment: 'dotnet - Production' + description: 'Deployment ${{ needs.validate.outputs.version }} from branch ${{ github.ref_name }}' + task: release + + - name: Download artifact + run: | + mkdir -p nuget-output + cd nuget-output + wget https://github.com/bitwarden/sdk/releases/download/dotnet-v${{ needs.validate.outputs.version }}/Bitwarden.Sdk.${{ needs.validate.outputs.version }}.nupkg - name: Login to Azure - Prod Subscription uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 @@ -76,3 +95,19 @@ jobs: env: NUGET_API_KEY: ${{ steps.retrieve-secrets.outputs.nuget-api-key }} run: dotnet nuget push ./nuget-output/*.nupkg -k ${{ env.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json + + - name: Update deployment status to Success + if: ${{ inputs.release_type != 'Dry Run' && success() }} + uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 + with: + token: '${{ secrets.GITHUB_TOKEN }}' + state: 'success' + deployment-id: ${{ steps.deployment.outputs.deployment_id }} + + - name: Update deployment status to Failure + if: ${{ inputs.release_type != 'Dry Run' && failure() }} + uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 + with: + token: '${{ secrets.GITHUB_TOKEN }}' + state: 'failure' + deployment-id: ${{ steps.deployment.outputs.deployment_id }} diff --git a/.github/workflows/publish-java.yml b/.github/workflows/publish-java.yml index 98f6fadd2..002a61ee4 100644 --- a/.github/workflows/publish-java.yml +++ b/.github/workflows/publish-java.yml @@ -13,6 +13,10 @@ on: options: - Release - Dry Run + version: + description: "Release Version" + required: false + default: "latest" defaults: run: @@ -27,7 +31,8 @@ jobs: name: Setup runs-on: ubuntu-22.04 outputs: - version: ${{ steps.version.outputs.version }} + version: ${{ steps.version-output.outputs.version }} + tag_name: ${{ steps.version-output.outputs.tag_name }} steps: - name: Checkout repo uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 @@ -42,11 +47,21 @@ jobs: exit 1 fi - - name: Get version - id: version + - name: Version output + id: version-output run: | - VERSION=$(cat build.gradle | grep -Eo 'version = "[0-9]+\.[0-9]+\.[0-9]+"' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+') - echo "version=$VERSION" >> $GITHUB_OUTPUT + if [[ "${{ inputs.version }}" == "latest" || "${{ inputs.version }}" == "" ]]; then + TAG_NAME=$(curl "https://api.github.com/repos/bitwarden/sdk/releases" | jq -c '.[] | select(.tag_name | contains("java")) | .tag_name' | head -1) + VERSION=$(echo $TAG_NAME | grep -ohE '20[0-9]{2}\.([1-9]|1[0-2])\.[0-9]+') + echo "Latest Released Version: $VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + + echo "Latest Released Tag name: $TAG_NAME" + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT + else + echo "Release Version: ${{ inputs.version }}" + echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT + fi publish: name: Publish @@ -55,6 +70,8 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 + with: + ref: ${{ needs.validate.outputs.tag_name }} - name: Azure login uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 diff --git a/.github/workflows/publish-napi.yml b/.github/workflows/publish-napi.yml new file mode 100644 index 000000000..6a284d4a4 --- /dev/null +++ b/.github/workflows/publish-napi.yml @@ -0,0 +1,155 @@ +--- +name: Publish @bitwarden/sdk-napi +run-name: Publish @bitwarden/sdk-napi ${{ inputs.release_type }} + +on: + workflow_dispatch: + inputs: + release_type: + description: "Release Options" + required: true + default: "Release" + type: choice + options: + - Release + - Dry Run + version: + description: "Release Version" + required: false + default: "latest" + +defaults: + run: + working-directory: crates/bitwarden-napi + +jobs: + setup: + name: Setup + runs-on: ubuntu-22.04 + outputs: + release-version: ${{ steps.version-output.outputs.version }} + tag-name: ${{ steps.version-output.outputs.tag_name }} + steps: + - name: Checkout repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Branch check + if: ${{ inputs.release_type != 'Dry Run' }} + run: | + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then + echo "===================================" + echo "[!] Can only release from the 'main' branch" + echo "===================================" + exit 1 + fi + + - name: Version output + id: version-output + run: | + if [[ "${{ inputs.version }}" == "latest" || "${{ inputs.version }}" == "" ]]; then + TAG_NAME=$(curl "https://api.github.com/repos/bitwarden/sdk/releases" | jq -c '.[] | select(.tag_name | contains("napi")) | .tag_name' | head -1) + VERSION=$(echo $TAG_NAME | grep -ohE '20[0-9]{2}\.([1-9]|1[0-2])\.[0-9]+') + echo "Latest Released Version: $VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + + echo "Latest Released Tag name: $TAG_NAME" + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT + else + echo "Release Version: ${{ inputs.version }}" + echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT + fi + + npm: + name: Publish NPM + runs-on: ubuntu-22.04 + needs: setup + env: + _PKG_VERSION: ${{ needs.setup.outputs.release-version }} + _TAG_NAME: ${{ needs.setup.outputs.tag-name }} + steps: + - name: Checkout repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + ref: ${{ env._TAG_NAME }} + + - name: Create GitHub deployment + if: ${{ inputs.release_type != 'Dry Run' }} + uses: chrnorm/deployment-action@55729fcebec3d284f60f5bcabbd8376437d696b1 # v2.0.7 + id: deployment + with: + token: "${{ secrets.GITHUB_TOKEN }}" + initial-status: "in_progress" + environment: "Bitwarden SDK NAPI - Production" + description: "Deployment ${{ env._PKG_VERSION }} from branch ${{ github.ref_name }}" + task: release + + - name: Setup Node + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 + with: + node-version: 18 + cache: "npm" + cache-dependency-path: crates/bitwarden-napi/package-lock.json + + - name: Download schemas.ts artifact + run: | + wget https://github.com/bitwarden/sdk/releases/download/napi-v${{ env._PKG_VERSION }}/schemas.ts + mv schemas.ts ${{ github.workspace }}/crates/bitwarden-napi/src-ts/bitwarden_client/schemas.ts + + - name: Install dependencies + run: npm ci + + - name: Run tsc + run: npm run tsc + + - name: Login to Azure + uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 + with: + creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve secrets + id: retrieve-secrets + uses: bitwarden/gh-actions/get-keyvault-secrets@main + with: + keyvault: "bitwarden-ci" + secrets: "npm-api-key" + + - name: Download sdk-napi artifacts + run: | + wget https://github.com/bitwarden/sdk/releases/download/napi-v${{ env._PKG_VERSION }}/sdk-napi.darwin-arm64.node + wget https://github.com/bitwarden/sdk/releases/download/napi-v${{ env._PKG_VERSION }}/sdk-napi.darwin-x64.node + wget https://github.com/bitwarden/sdk/releases/download/napi-v${{ env._PKG_VERSION }}/sdk-napi.win32-x64-msvc.node + wget https://github.com/bitwarden/sdk/releases/download/napi-v${{ env._PKG_VERSION }}/sdk-napi.linux-x64-gnu.node + mv sdk-napi.*.node ${{ github.workspace }}/crates/bitwarden-napi/artifacts + + - name: Move artifacts + run: npm run artifacts + + - name: Setup NPM + run: | + echo 'registry="https://registry.npmjs.org/"' > ./.npmrc + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ./.npmrc + + echo 'registry="https://registry.npmjs.org/"' > ~/.npmrc + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc + env: + NPM_TOKEN: ${{ steps.retrieve-secrets.outputs.npm-api-key }} + + - name: Publish NPM + if: ${{ inputs.release_type != 'Dry Run' }} + run: npm publish --access public --registry=https://registry.npmjs.org/ --userconfig=./.npmrc + + - name: Update deployment status to Success + if: ${{ inputs.release_type != 'Dry Run' && success() }} + uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 + with: + token: "${{ secrets.GITHUB_TOKEN }}" + state: "success" + deployment-id: ${{ steps.deployment.outputs.deployment_id }} + + - name: Update deployment status to Failure + if: ${{ inputs.release_type != 'Dry Run' && failure() }} + uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 + with: + token: "${{ secrets.GITHUB_TOKEN }}" + state: "failure" + deployment-id: ${{ steps.deployment.outputs.deployment_id }} diff --git a/.github/workflows/publish-python.yml b/.github/workflows/publish-python.yml index dcbfee22f..7e3395093 100644 --- a/.github/workflows/publish-python.yml +++ b/.github/workflows/publish-python.yml @@ -13,6 +13,10 @@ on: options: - Release - Dry Run + version: + description: "Release Version" + required: false + default: "latest" defaults: run: @@ -22,6 +26,9 @@ jobs: setup: name: Setup runs-on: ubuntu-22.04 + outputs: + version: ${{ steps.version-output.outputs.version }} + tag_name: ${{ steps.version-output.outputs.tag_name }} steps: - name: Checkout repo uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 @@ -29,18 +36,39 @@ jobs: - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} run: | - if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then echo "===================================" - echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches" + echo "[!] Can only release from the 'main' branch" echo "===================================" exit 1 fi + - name: Version output + id: version-output + run: | + if [[ "${{ inputs.version }}" == "latest" || "${{ inputs.version }}" == "" ]]; then + TAG_NAME=$(curl "https://api.github.com/repos/bitwarden/sdk/releases" | jq -c '.[] | select(.tag_name | contains("python")) | .tag_name' | head -1) + VERSION=$(echo $TAG_NAME | grep -ohE '20[0-9]{2}\.([1-9]|1[0-2])\.[0-9]+') + echo "Latest Released Version: $VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + + echo "Latest Released Tag name: $TAG_NAME" + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT + else + echo "Release Version: ${{ inputs.version }}" + echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT + fi + publish: name: Publish runs-on: ubuntu-22.04 needs: setup steps: + - name: Checkout repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + ref: ${{ needs.setup.outputs.tag_name }} + - name: Install Python uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.0 with: @@ -49,15 +77,20 @@ jobs: - name: Install twine run: pip install twine - - name: Download artifacts - uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 # v6 - with: - workflow: build-python-wheels.yml - path: ${{ github.workspace }}/target/wheels/dist - workflow_conclusion: success - branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} - name: bitwarden_sdk(.*) - name_is_regexp: true + - name: Get release assets + working-directory: ${{ github.workspace }}/target/wheels/dist + run: | + ARTIFACT_URLS=$(curl -sSL https://api.github.com/repos/bitwarden/sdk/releases/tags/${{ needs.setup.outputs.tag_name }} | jq -r '.assets[].browser_download_url') + for url in $ARTIFACT_URLS; do + wget $url + done + + - name: Unpack release assets + working-directory: ${{ github.workspace }}/target/wheels/dist + run: | + for file in *.zip; do + unzip $file + done - name: Move files working-directory: ${{ github.workspace }}/target/wheels/dist diff --git a/.github/workflows/publish-ruby.yml b/.github/workflows/publish-ruby.yml index 6184586a1..875def064 100644 --- a/.github/workflows/publish-ruby.yml +++ b/.github/workflows/publish-ruby.yml @@ -12,15 +12,22 @@ on: options: - Release - Dry Run + version: + description: "Release Version" + required: false + default: "latest" permissions: contents: read id-token: write jobs: - publish_ruby: - name: Publish Ruby + setup: + name: Setup runs-on: ubuntu-22.04 + outputs: + release-version: ${{ steps.version-output.outputs.version }} + tag-name: ${{ steps.version-output.outputs.tag_name }} steps: - name: Checkout Repository uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 @@ -35,69 +42,45 @@ jobs: exit 1 fi - - name: Set up Ruby - uses: ruby/setup-ruby@c04af2bb7258bb6a03df1d3c1865998ac9390972 # v1.194.0 - with: - ruby-version: 3.2 - - - name: Download artifacts - uses: bitwarden/gh-actions/download-artifacts@main - with: - workflow: generate_schemas.yml - path: languages/ruby/bitwarden_sdk_secrets/lib - workflow_conclusion: success - branch: main - artifacts: schemas.rb - - - name: Download x86_64-apple-darwin artifact - uses: bitwarden/gh-actions/download-artifacts@main - with: - workflow: build-rust-cross-platform.yml - path: temp/macos-x64 - workflow_conclusion: success - branch: main - artifacts: libbitwarden_c_files-x86_64-apple-darwin - - - name: Download aarch64-apple-darwin artifact - uses: bitwarden/gh-actions/download-artifacts@main - with: - workflow: build-rust-cross-platform.yml - workflow_conclusion: success - branch: main - artifacts: libbitwarden_c_files-aarch64-apple-darwin - path: temp/macos-arm64 + - name: Version output + id: version-output + run: | + if [[ "${{ inputs.version }}" == "latest" || "${{ inputs.version }}" == "" ]]; then + TAG_NAME=$(curl "https://api.github.com/repos/bitwarden/sdk/releases" | jq -c '.[] | select(.tag_name | contains("ruby")) | .tag_name' | head -1) + VERSION=$(echo $TAG_NAME | grep -ohE '20[0-9]{2}\.([1-9]|1[0-2])\.[0-9]+') + echo "Latest Released Version: $VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + + echo "Latest Released Tag name: $TAG_NAME" + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT + else + echo "Release Version: ${{ inputs.version }}" + echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT + fi - - name: Download x86_64-unknown-linux-gnu artifact - uses: bitwarden/gh-actions/download-artifacts@main + publish: + name: Publish + runs-on: ubuntu-22.04 + needs: setup + env: + _VERSION: ${{ needs.setup.outputs.release-version }} + _TAG_NAME: ${{ needs.setup.outputs.tag-name }} + steps: + - name: Checkout Repository + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: - workflow: build-rust-cross-platform.yml - workflow_conclusion: success - branch: main - artifacts: libbitwarden_c_files-x86_64-unknown-linux-gnu - path: temp/linux-x64 + ref: ${{ env._TAG_NAME }} - - name: Download x86_64-pc-windows-msvc artifact - uses: bitwarden/gh-actions/download-artifacts@main + - name: Create GitHub deployment + if: ${{ inputs.release_type != 'Dry Run' }} + uses: chrnorm/deployment-action@55729fcebec3d284f60f5bcabbd8376437d696b1 # v2.0.7 + id: deployment with: - workflow: build-rust-cross-platform.yml - workflow_conclusion: success - branch: main - artifacts: libbitwarden_c_files-x86_64-pc-windows-msvc - path: temp/windows-x64 - - - name: Copy lib files - run: | - mkdir -p languages/ruby/bitwarden_sdk_secrets/lib/macos-arm64 - mkdir -p languages/ruby/bitwarden_sdk_secrets/lib/linux-x64 - mkdir -p languages/ruby/bitwarden_sdk_secrets/lib/macos-x64 - mkdir -p languages/ruby/bitwarden_sdk_secrets/lib/windows-x64 - - platforms=("macos-arm64" "linux-x64" "macos-x64" "windows-x64") - files=("libbitwarden_c.dylib" "libbitwarden_c.so" "libbitwarden_c.dylib" "bitwarden_c.dll") - - for ((i=0; i<${#platforms[@]}; i++)); do - cp "temp/${platforms[$i]}/${files[$i]}" "languages/ruby/bitwarden_sdk_secrets/lib/${platforms[$i]}/${files[$i]}" - done + token: "${{ secrets.GITHUB_TOKEN }}" + initial-status: "in_progress" + environment: "Bitwarden Ruby SDK - Production" + description: "Deployment ${{ env._VERSION }} from branch ${{ github.ref_name }}" + task: release - name: Login to Azure uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 @@ -111,13 +94,8 @@ jobs: keyvault: "bitwarden-ci" secrets: "rubygem-api-key" - - name: bundle install - run: bundle install - working-directory: languages/ruby/bitwarden_sdk_secrets - - - name: Build gem - run: gem build bitwarden-sdk-secrets.gemspec - working-directory: languages/ruby/bitwarden_sdk_secrets + - name: Download ruby artifact + run: wget https://github.com/bitwarden/sdk/releases/download/ruby-v${{ env._VERSION }}/bitwarden-sdk-secrets-${{ env._VERSION }}.gem - name: Push gem to Rubygems if: ${{ inputs.release_type != 'Dry Run' }} @@ -130,3 +108,19 @@ jobs: env: GEM_HOST_API_KEY: ${{ steps.retrieve-secrets.outputs.rubygem-api-key }} working-directory: languages/ruby/bitwarden_sdk_secrets + + - name: Update deployment status to Success + if: ${{ inputs.release_type != 'Dry Run' && success() }} + uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 + with: + token: "${{ secrets.GITHUB_TOKEN }}" + state: "success" + deployment-id: ${{ steps.deployment.outputs.deployment_id }} + + - name: Update deployment status to Failure + if: ${{ inputs.release_type != 'Dry Run' && failure() }} + uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 + with: + token: "${{ secrets.GITHUB_TOKEN }}" + state: "failure" + deployment-id: ${{ steps.deployment.outputs.deployment_id }} diff --git a/.github/workflows/publish-rust-crates.yml b/.github/workflows/publish-rust-crates.yml index a614608f9..43f19323a 100644 --- a/.github/workflows/publish-rust-crates.yml +++ b/.github/workflows/publish-rust-crates.yml @@ -14,11 +14,19 @@ on: - Initial Release - Redeploy - Dry Run + version: + description: 'Version to publish (default: latest rust crates release)' + required: true + type: string + default: latest jobs: - publish: - name: Publish + setup: + name: setup runs-on: ubuntu-22.04 + outputs: + release-version: ${{ steps.version-output.outputs.version }} + release-tag: ${{ steps.version-output.outputs.tag_name }} steps: - name: Checkout uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 @@ -33,6 +41,32 @@ jobs: exit 1 fi + - name: Version output + id: version-output + run: | + if [[ "${{ inputs.version }}" == "latest" || "${{ inputs.version }}" == "" ]]; then + TAG_NAME=$(curl "https://api.github.com/repos/bitwarden/sdk/releases" | jq -c '.[] | select(.tag_name | contains("rust")) | .tag_name' | head -1) + VERSION=$(echo $TAG_NAME | grep -ohE '20[0-9]{2}\.([1-9]|1[0-2])\.[0-9]+') + echo "Latest Released Version: $VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + + echo "Latest Released Tag name: $TAG_NAME" + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT + else + echo "Release Version: ${{ inputs.version }}" + echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT + fi + + publish: + name: Publish + runs-on: ubuntu-22.04 + needs: setup + steps: + - name: Checkout + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + ref: ${{ needs.setup.outputs.release-tag }} + - name: Login to Azure uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 with: diff --git a/.github/workflows/publish-wasm.yml b/.github/workflows/publish-wasm.yml new file mode 100644 index 000000000..95a86a0c4 --- /dev/null +++ b/.github/workflows/publish-wasm.yml @@ -0,0 +1,138 @@ +--- +name: Publish @bitwarden/sdk-wasm +run-name: Publish @bitwarden/sdk-wasm ${{ inputs.release_type }} + +on: + workflow_dispatch: + inputs: + release_type: + description: "Release Options" + required: true + default: "Release" + type: choice + options: + - Release + - Dry Run + version: + description: "Release Version" + required: false + default: "latest" + +defaults: + run: + working-directory: languages/js/wasm + +jobs: + setup: + name: Setup + runs-on: ubuntu-22.04 + outputs: + release-version: ${{ steps.version-output.outputs.version }} + tag_name: ${{ steps.version-output.outputs.tag_name }} + steps: + - name: Checkout repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Branch check + if: ${{ inputs.release_type != 'Dry Run' }} + run: | + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then + echo "===================================" + echo "[!] Can only release from the 'main' branch" + echo "===================================" + exit 1 + fi + + - name: Version output + id: version-output + run: | + if [[ "${{ inputs.version }}" == "latest" || "${{ inputs.version }}" == "" ]]; then + TAG_NAME=$(curl "https://api.github.com/repos/bitwarden/sdk/releases" | jq -c '.[] | select(.tag_name | contains("napi")) | .tag_name' | head -1) + VERSION=$(echo $TAG_NAME | grep -ohE '20[0-9]{2}\.([1-9]|1[0-2])\.[0-9]+') + echo "Latest Released Version: $VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + + echo "Latest Released Tag name: $TAG_NAME" + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT + else + echo "Release Version: ${{ inputs.version }}" + echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT + fi + + npm: + name: Publish NPM + runs-on: ubuntu-22.04 + needs: setup + env: + _VERSION: ${{ needs.setup.outputs.release-version }} + steps: + - name: Checkout repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + ref: ${{ needs.setup.outputs.tag_name }} + + - name: Setup Node + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 + with: + node-version: 18 + cache: "npm" + + - name: Login to Azure + uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 + with: + creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve secrets + id: retrieve-secrets + uses: bitwarden/gh-actions/get-keyvault-secrets@main + with: + keyvault: "bitwarden-ci" + secrets: "npm-api-key" + + - name: Download artifact + run: | + cd ${{ github.workspace }}/languages/js/wasm + wget https://github.com/bitwarden/sdk/releases/download/wasm-v${{ env._VERSION }}/sdk-bitwarden-wasm.zip + unzip sdk-bitwarden-wasm.zip + rm sdk-bitwarden-wasm.zip + + - name: Create GitHub deployment + if: ${{ inputs.release_type != 'Dry Run' }} + uses: chrnorm/deployment-action@55729fcebec3d284f60f5bcabbd8376437d696b1 # v2.0.7 + id: deployment + with: + token: "${{ secrets.GITHUB_TOKEN }}" + initial-status: "in_progress" + environment: "Bitwarden SDK WASM - Production" + description: "Deployment ${{ env._VERSION }} from branch ${{ github.ref_name }}" + task: release + + - name: Setup NPM + run: | + echo 'registry="https://registry.npmjs.org/"' > ./.npmrc + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ./.npmrc + + echo 'registry="https://registry.npmjs.org/"' > ~/.npmrc + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc + env: + NPM_TOKEN: ${{ steps.retrieve-secrets.outputs.npm-api-key }} + + - name: Publish NPM + if: ${{ inputs.release_type != 'Dry Run' }} + run: npm publish --access public --registry=https://registry.npmjs.org/ --userconfig=./.npmrc + + - name: Update deployment status to Success + if: ${{ inputs.release_type != 'Dry Run' && success() }} + uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 + with: + token: "${{ secrets.GITHUB_TOKEN }}" + state: "success" + deployment-id: ${{ steps.deployment.outputs.deployment_id }} + + - name: Update deployment status to Failure + if: ${{ inputs.release_type != 'Dry Run' && failure() }} + uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 + with: + token: "${{ secrets.GITHUB_TOKEN }}" + state: "failure" + deployment-id: ${{ steps.deployment.outputs.deployment_id }} diff --git a/.github/workflows/release-bws.yml b/.github/workflows/release-bws.yml new file mode 100644 index 000000000..92a8544b8 --- /dev/null +++ b/.github/workflows/release-bws.yml @@ -0,0 +1,77 @@ +--- +name: Release bws CLI +run-name: Release bws CLI ${{ inputs.release_type }} + +on: + workflow_dispatch: + inputs: + release_type: + description: "Release Options" + required: true + default: "Release" + type: choice + options: + - Release + - Dry Run + +jobs: + setup: + name: Setup + runs-on: ubuntu-22.04 + outputs: + release-version: ${{ steps.version.outputs.version }} + steps: + - name: Checkout repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Branch check + if: ${{ inputs.release_type != 'Dry Run' }} + run: | + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then + echo "===================================" + echo "[!] Can only release from the 'main' branch" + echo "===================================" + exit 1 + fi + + - name: Check Release Version + id: version + run: | + VERSION=$(grep -o '^version = ".*"' crates/bws/Cargo.toml | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+") + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Download all Release artifacts + uses: bitwarden/gh-actions/download-artifacts@main + with: + workflow: build-cli.yml + path: packages + workflow_conclusion: success + branch: ${{ github.ref_name }} + + - name: Get checksum files + uses: bitwarden/gh-actions/get-checksum@main + with: + packages_dir: "packages" + file_path: "packages/bws-sha256-checksums-${{ steps.version.outputs.version }}.txt" + + - name: Create release + if: ${{ inputs.release_type != 'Dry Run' }} + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 + env: + PKG_VERSION: ${{ steps.version.outputs.version }} + with: + artifacts: "packages/bws-x86_64-apple-darwin-${{ env.PKG_VERSION }}.zip, + packages/bws-aarch64-apple-darwin-${{ env.PKG_VERSION }}.zip, + packages/bws-macos-universal-${{ env.PKG_VERSION }}.zip, + packages/bws-x86_64-pc-windows-msvc-${{ env.PKG_VERSION }}.zip, + packages/bws-aarch64-pc-windows-msvc-${{ env.PKG_VERSION }}.zip, + packages/bws-x86_64-unknown-linux-gnu-${{ env.PKG_VERSION }}.zip, + packages/bws-aarch64-unknown-linux-gnu-${{ env.PKG_VERSION }}.zip, + packages/THIRDPARTY.html, + packages/bws-sha256-checksums-${{ env.PKG_VERSION }}.txt" + commit: ${{ github.sha }} + tag: bws-v${{ env.PKG_VERSION }} + name: bws CLI v${{ env.PKG_VERSION }} + body: "" + token: ${{ secrets.GITHUB_TOKEN }} + draft: true diff --git a/.github/workflows/release-cpp.yml b/.github/workflows/release-cpp.yml index aa4d37f62..47199a99f 100644 --- a/.github/workflows/release-cpp.yml +++ b/.github/workflows/release-cpp.yml @@ -29,9 +29,9 @@ jobs: - name: Branch check if: ${{ inputs.release_type != 'Dry Run' }} run: | - if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then + if [[ "$GITHUB_REF" != "refs/heads/main" ]] ; then echo "===================================" - echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches" + echo "[!] Can only release from the 'main' branches" echo "===================================" exit 1 fi @@ -45,9 +45,7 @@ jobs: github-release: name: GitHub Release runs-on: ubuntu-22.04 - needs: - - repo-sync - - validate + needs: validate env: _PKG_VERSION: ${{ needs.validate.outputs.version }} steps: diff --git a/.github/workflows/release-dotnet.yml b/.github/workflows/release-dotnet.yml new file mode 100644 index 000000000..2e08e8a76 --- /dev/null +++ b/.github/workflows/release-dotnet.yml @@ -0,0 +1,76 @@ +name: Release .NET NuGet +run-name: Release .NET NuGet Package ${{ inputs.release_type }} + +on: + workflow_dispatch: + inputs: + release_type: + description: "Release Options" + required: true + default: "Release" + type: choice + options: + - Release + - Dry Run + + +jobs: + setup: + name: Setup + runs-on: ubuntu-22.04 + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - name: Checkout repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Branch check + if: ${{ inputs.release_type != 'Dry Run' }} + run: | + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then + echo "===================================" + echo "[!] Can only release from the 'main' branch" + echo "===================================" + exit 1 + fi + + - name: Install xmllint + run: sudo apt-get install -y libxml2-utils + + - name: Get version + id: version + run: | + VERSION=$(xmllint --xpath 'string(/Project/PropertyGroup/Version)' languages/csharp/Bitwarden.Sdk/Bitwarden.Sdk.csproj) + echo "version=$VERSION" >> $GITHUB_OUTPUT + + release: + name: Create GitHub release + runs-on: ubuntu-22.04 + needs: setup + steps: + - name: Checkout Repository + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Download NuGet package + uses: bitwarden/gh-actions/download-artifacts@main + with: + workflow: build-dotnet.yml + workflow_conclusion: success + branch: main + artifacts: Bitwarden.Sdk.${{ needs.setup.outputs.version }}.nupkg + path: ./nuget-output + + - name: Create release + if: ${{ inputs.release_type != 'Dry Run' }} + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 + env: + PKG_VERSION: ${{ needs.setup.outputs.version }} + with: + commit: ${{ github.sha }} + tag: dotnet-v${{ env.PKG_VERSION }} + name: .NET NuGet v${{ env.PKG_VERSION }} + body: "" + token: ${{ secrets.GITHUB_TOKEN }} + draft: true + artifacts: | + ./nuget-output/Bitwarden.Sdk.${{ needs.setup.outputs.version }}.nupkg diff --git a/.github/workflows/release-java.yml b/.github/workflows/release-java.yml new file mode 100644 index 000000000..6898932d5 --- /dev/null +++ b/.github/workflows/release-java.yml @@ -0,0 +1,61 @@ +name: Release Java SDK +run-name: Release Java SDK ${{ inputs.release_type }} + +on: + workflow_dispatch: + inputs: + release_type: + description: "Release Options" + required: true + default: "Release" + type: choice + options: + - Release + - Dry Run + +jobs: + setup: + name: Setup + runs-on: ubuntu-22.04 + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - name: Checkout repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Branch check + if: ${{ inputs.release_type != 'Dry Run' }} + run: | + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then + echo "===================================" + echo "[!] Can only release from the 'main' branch" + echo "===================================" + exit 1 + fi + + - name: Get version + id: version + run: | + VERSION=$(cat languages/java/build.gradle | grep -Eo 'version = "[0-9]+\.[0-9]+\.[0-9]+"' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+') + echo "version=$VERSION" >> $GITHUB_OUTPUT + + release: + name: Release + runs-on: ubuntu-22.04 + needs: setup + steps: + - name: Checkout Repository + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Create release + if: ${{ inputs.release_type != 'Dry Run' }} + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 + env: + PKG_VERSION: ${{ needs.setup.outputs.version }} + with: + commit: ${{ github.sha }} + tag: java-v${{ env.PKG_VERSION }} + name: Java SDK v${{ env.PKG_VERSION }} + body: "" + token: ${{ secrets.GITHUB_TOKEN }} + draft: true diff --git a/.github/workflows/release-napi.yml b/.github/workflows/release-napi.yml index fb99cc1cf..e8be69f99 100644 --- a/.github/workflows/release-napi.yml +++ b/.github/workflows/release-napi.yml @@ -30,17 +30,17 @@ jobs: name: Setup runs-on: ubuntu-22.04 outputs: - release-version: ${{ steps.version.outputs.version }} + version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Branch check - if: ${{ github.event.inputs.release_type != 'Dry Run' }} + if: ${{ inputs.release_type != 'Dry Run' }} run: | - if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then echo "===================================" - echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches" + echo "[!] Can only release from the 'main' branch" echo "===================================" exit 1 fi @@ -49,125 +49,47 @@ jobs: id: version uses: bitwarden/gh-actions/release-version-check@main with: - release-type: ${{ github.event.inputs.release_type }} + release-type: ${{ inputs.release_type }} project-type: ts file: crates/bitwarden-napi/package.json monorepo: false - - name: Create GitHub deployment - if: ${{ github.event.inputs.release_type != 'Dry Run' }} - uses: chrnorm/deployment-action@55729fcebec3d284f60f5bcabbd8376437d696b1 # v2.0.7 - id: deployment - with: - token: "${{ secrets.GITHUB_TOKEN }}" - initial-status: "in_progress" - environment: "Bitwarden SDK NAPI - Production" - description: "Deployment ${{ steps.version.outputs.version }} from branch ${{ github.ref_name }}" - task: release - - - name: Update deployment status to Success - if: ${{ github.event.inputs.release_type != 'Dry Run' && success() }} - uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 - with: - token: "${{ secrets.GITHUB_TOKEN }}" - state: "success" - deployment-id: ${{ steps.deployment.outputs.deployment_id }} - - - name: Update deployment status to Failure - if: ${{ github.event.inputs.release_type != 'Dry Run' && failure() }} - uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 - with: - token: "${{ secrets.GITHUB_TOKEN }}" - state: "failure" - deployment-id: ${{ steps.deployment.outputs.deployment_id }} - - npm: - name: Publish NPM + release: + name: Create GitHub release runs-on: ubuntu-22.04 needs: setup - if: inputs.npm_publish - env: - _PKG_VERSION: ${{ needs.setup.outputs.release-version }} steps: - - name: Checkout repo + - name: Checkout Repository uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - - name: Setup Node - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 - with: - node-version: 18 - cache: "npm" - cache-dependency-path: crates/bitwarden-napi/package-lock.json - - - name: Download schemas - if: ${{ github.event.inputs.release_type != 'Dry Run' }} - uses: bitwarden/gh-actions/download-artifacts@main - with: - workflow: build-napi.yml - artifacts: schemas.ts - path: ${{ github.workspace }}/crates/bitwarden-napi/src-ts/bitwarden_client/ - workflow_conclusion: success - branch: ${{ github.ref_name }} - - - name: Dry Run - Download schemas - if: ${{ github.event.inputs.release_type == 'Dry Run' }} - uses: bitwarden/gh-actions/download-artifacts@main - with: - workflow: build-napi.yml - artifacts: schemas.ts - path: ${{ github.workspace }}/crates/bitwarden-napi/src-ts/bitwarden_client/ - workflow_conclusion: success - branch: main - - - name: Install dependencies - run: npm ci - - - name: Run tsc - run: npm run tsc - - - name: Login to Azure - uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 - with: - creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} - - - name: Retrieve secrets - id: retrieve-secrets - uses: bitwarden/gh-actions/get-keyvault-secrets@main - with: - keyvault: "bitwarden-ci" - secrets: "npm-api-key" - - name: Download artifacts - if: ${{ github.event.inputs.release_type != 'Dry Run' }} - uses: bitwarden/gh-actions/download-artifacts@main - with: - workflow: build-napi.yml - path: ${{ github.workspace }}/crates/bitwarden-napi/artifacts - workflow_conclusion: success - branch: ${{ github.ref_name }} - - - name: Dry Run - Download artifacts - if: ${{ github.event.inputs.release_type == 'Dry Run' }} uses: bitwarden/gh-actions/download-artifacts@main with: workflow: build-napi.yml - path: ${{ github.workspace }}/crates/bitwarden-napi/artifacts workflow_conclusion: success branch: main - - - name: Move artifacts - run: npm run artifacts - - - name: Setup NPM - run: | - echo 'registry="https://registry.npmjs.org/"' > ./.npmrc - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ./.npmrc - - echo 'registry="https://registry.npmjs.org/"' > ~/.npmrc - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc + artifacts: | + sdk-bitwarden-napi-aarch64-apple-darwin + sdk-bitwarden-napi-x86_64-apple-darwin + sdk-bitwarden-napi-x86_64-pc-windows-msvc + sdk-bitwarden-napi-x86_64-unknown-linux-gnu + schemas.ts + + - name: Create release + if: ${{ inputs.release_type != 'Dry Run' }} + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 env: - NPM_TOKEN: ${{ steps.retrieve-secrets.outputs.npm-api-key }} - - - name: Publish NPM - if: ${{ github.event.inputs.release_type != 'Dry Run' }} - run: npm publish --access public --registry=https://registry.npmjs.org/ --userconfig=./.npmrc + _VERSION: ${{ needs.setup.outputs.version }} + with: + commit: ${{ github.sha }} + tag: napi-v${{ env._VERSION }} + name: napi v${{ env._VERSION }} + body: "" + token: ${{ secrets.GITHUB_TOKEN }} + draft: true + artifacts: | + sdk-napi.darwin-arm64.node + sdk-napi.darwin-x64.node + sdk-napi.win32-x64-msvc.node + sdk-napi.linux-x64-gnu.node + schemas.ts diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml new file mode 100644 index 000000000..10b451fc5 --- /dev/null +++ b/.github/workflows/release-python.yml @@ -0,0 +1,74 @@ +--- +name: Release Python SDK +run-name: Release Python SDK ${{ inputs.release_type }} + +on: + workflow_dispatch: + inputs: + release_type: + description: "Release Options" + required: true + default: "Release" + type: choice + options: + - Release + - Dry Run + +jobs: + setup: + name: Setup + runs-on: ubuntu-22.04 + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - name: Checkout repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Branch check + if: ${{ inputs.release_type != 'Dry Run' }} + run: | + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then + echo "===================================" + echo "[!] Can only release from the 'main' branch" + echo "===================================" + exit 1 + fi + + - name: Get version + id: version + run: | + VERSION=$(cat languages/python/pyproject.toml | grep -Eo 'version = "[0-9]+\.[0-9]+\.[0-9]+"' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+') + echo "version=$VERSION" >> $GITHUB_ENV + + release: + name: Release + runs-on: ubuntu-22.04 + needs: setup + steps: + - name: Checkout repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Download artifacts + uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 # v6 + with: + workflow: build-python-wheels.yml + path: ${{ github.workspace }}/target/wheels/dist + workflow_conclusion: success + branch: main + name: bitwarden_sdk(.*) + name_is_regexp: true + + - name: Create GitHub release + if: ${{ inputs.release_type != 'Dry Run' }} + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 + env: + PKG_VERSION: ${{ needs.setup.outputs.version }} + with: + commit: ${{ github.sha }} + tag: python-v${{ env.PKG_VERSION }} + name: Python v${{ env.PKG_VERSION }} + body: "" + token: ${{ secrets.GITHUB_TOKEN }} + draft: true + artifacts: | + ${{ github.workspace }}/target/wheels/dist/bitwarden_sdk-*.whl diff --git a/.github/workflows/release-ruby.yml b/.github/workflows/release-ruby.yml new file mode 100644 index 000000000..9c3e82b77 --- /dev/null +++ b/.github/workflows/release-ruby.yml @@ -0,0 +1,71 @@ +name: Release Ruby SDK +run-name: Release Ruby SDK ${{ inputs.release_type }} + +on: + workflow_dispatch: + inputs: + release_type: + description: "Release Options" + required: true + default: "Release" + type: choice + options: + - Release + - Dry Run + +jobs: + setup: + name: Setup + runs-on: ubuntu-22.04 + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - name: Checkout repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Branch check + if: ${{ inputs.release_type != 'Dry Run' }} + run: | + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then + echo "===================================" + echo "[!] Can only release from the 'main' branch" + echo "===================================" + exit 1 + fi + + - name: Get version + id: version + run: | + VERSION=$(cat languages/ruby/lib/version.rb | grep -Eo 'VERSION = "[0-9]+\.[0-9]+\.[0-9]+"' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+') + echo "version=$VERSION" >> $GITHUB_OUTPUT + + release: + name: Create GitHub release + runs-on: ubuntu-22.04 + needs: setup + steps: + - name: Checkout Repository + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Download ruby artifact + uses: bitwarden/gh-actions/download-artifacts@main + with: + workflow: build-ruby.yml + workflow_conclusion: success + branch: main + artifacts: bitwarden-sdk-secrets + + - name: Create release + if: ${{ inputs.release_type != 'Dry Run' }} + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 + env: + PKG_VERSION: ${{ needs.setup.outputs.version }} + with: + commit: ${{ github.sha }} + tag: ruby-v${{ env.PKG_VERSION }} + name: Ruby v${{ env.PKG_VERSION }} + body: "" + token: ${{ secrets.GITHUB_TOKEN }} + draft: true + artifacts: | + bitwarden-sdk-secrets-${{ env.PKG_VERSION }}.gem diff --git a/.github/workflows/release-rust-crates.yml b/.github/workflows/release-rust-crates.yml new file mode 100644 index 000000000..54845e148 --- /dev/null +++ b/.github/workflows/release-rust-crates.yml @@ -0,0 +1,53 @@ +name: Release Rust crates +run-name: Release Rust crates ${{ inputs.release_type }} + +on: + workflow_dispatch: + inputs: + release_type: + description: "Release Options" + required: true + default: "Release" + type: choice + options: + - Release + - Dry Run + +jobs: + setup: + name: Setup + runs-on: ubuntu-22.04 + outputs: + release-version: ${{ steps.version.outputs.version }} + steps: + - name: Checkout repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Branch check + if: ${{ inputs.release_type != 'Dry Run' }} + run: | + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then + echo "===================================" + echo "[!] Can only release from the 'main' branch" + echo "===================================" + exit 1 + fi + + - name: Get version + id: version + run: | + VERSION=$(grep -o '^version = ".*"' Cargo.toml | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+") + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Create release + if: ${{ inputs.release_type != 'Dry Run' }} + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 + env: + PKG_VERSION: ${{ steps.version.outputs.version }} + with: + commit: ${{ github.sha }} + tag: rust-v${{ env.PKG_VERSION }} + name: Rust crates v${{ env.PKG_VERSION }} + body: "" + token: ${{ secrets.GITHUB_TOKEN }} + draft: true diff --git a/.github/workflows/release-wasm.yml b/.github/workflows/release-wasm.yml index b6476e833..97b2c34dd 100644 --- a/.github/workflows/release-wasm.yml +++ b/.github/workflows/release-wasm.yml @@ -13,15 +13,9 @@ on: options: - Release - Dry Run - npm_publish: - description: "Publish to NPM registry" - required: true - default: true - type: boolean defaults: run: - shell: bash working-directory: languages/js/wasm jobs: @@ -35,11 +29,11 @@ jobs: uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Branch check - if: ${{ github.event.inputs.release_type != 'Dry Run' }} + if: ${{ inputs.release_type != 'Dry Run' }} run: | - if [[ "$GITHUB_REF" != "refs/heads/rc" ]] && [[ "$GITHUB_REF" != "refs/heads/hotfix-rc" ]]; then + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then echo "===================================" - echo "[!] Can only release from the 'rc' or 'hotfix-rc' branches" + echo "[!] Can only release from the 'main' branch" echo "===================================" exit 1 fi @@ -48,85 +42,37 @@ jobs: id: version uses: bitwarden/gh-actions/release-version-check@main with: - release-type: ${{ github.event.inputs.release_type }} + release-type: ${{ inputs.release_type }} project-type: ts file: languages/js/wasm/package.json monorepo: false - - name: Create GitHub deployment - if: ${{ github.event.inputs.release_type != 'Dry Run' }} - uses: chrnorm/deployment-action@55729fcebec3d284f60f5bcabbd8376437d696b1 # v2.0.7 - id: deployment - with: - token: "${{ secrets.GITHUB_TOKEN }}" - initial-status: "in_progress" - environment: "Bitwarden SDK WASM - Production" - description: "Deployment ${{ steps.version.outputs.version }} from branch ${{ github.ref_name }}" - task: release - - - name: Update deployment status to Success - if: ${{ github.event.inputs.release_type != 'Dry Run' && success() }} - uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 - with: - token: "${{ secrets.GITHUB_TOKEN }}" - state: "success" - deployment-id: ${{ steps.deployment.outputs.deployment_id }} - - - name: Update deployment status to Failure - if: ${{ github.event.inputs.release_type != 'Dry Run' && failure() }} - uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 - with: - token: "${{ secrets.GITHUB_TOKEN }}" - state: "failure" - deployment-id: ${{ steps.deployment.outputs.deployment_id }} - - npm: - name: Publish NPM + release: + name: Release runs-on: ubuntu-22.04 needs: setup - if: inputs.npm_publish - env: - _PKG_VERSION: ${{ needs.setup.outputs.release-version }} steps: - name: Checkout repo uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - - name: Setup Node - uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 - with: - node-version: 18 - cache: "npm" - - - name: Login to Azure - uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 - with: - creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} - - - name: Retrieve secrets - id: retrieve-secrets - uses: bitwarden/gh-actions/get-keyvault-secrets@main - with: - keyvault: "bitwarden-ci" - secrets: "npm-api-key" - - name: Download artifacts - uses: bitwarden/gh-actions/download-artifacts@main + uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 # v6 with: workflow: build-wasm.yml - path: ${{ github.workspace }}/languages/js/wasm + skip_unpack: true workflow_conclusion: success - branch: ${{ github.event.inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} + branch: main - - name: Setup NPM - run: | - echo 'registry="https://registry.npmjs.org/"' > ./.npmrc - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ./.npmrc - - echo 'registry="https://registry.npmjs.org/"' > ~/.npmrc - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc + - name: Create GitHub release + if: ${{ inputs.release_type != 'Dry Run' }} + uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 env: - NPM_TOKEN: ${{ steps.retrieve-secrets.outputs.npm-api-key }} - - - name: Publish NPM - if: ${{ github.event.inputs.release_type != 'Dry Run' }} - run: npm publish --access public --registry=https://registry.npmjs.org/ --userconfig=./.npmrc + PKG_VERSION: ${{ needs.setup.outputs.release-version }} + with: + commit: ${{ github.sha }} + tag: wasm-v${{ env.PKG_VERSION }} + name: WASM v${{ env.PKG_VERSION }} + body: "" + token: ${{ secrets.GITHUB_TOKEN }} + draft: true + artifacts: sdk-bitwarden-wasm.zip From c33f82aec8e26e861830a4f65a7352dfc69f349c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Mon, 30 Sep 2024 17:27:01 +0200 Subject: [PATCH 190/214] Validate minimum KDF settings (#1100) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective Previously we weren't validating the KDF settings that we got from the server prelogin message. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-crypto/src/error.rs | 3 + crates/bitwarden-crypto/src/keys/utils.rs | 79 +++++++++++++++++++---- 2 files changed, 70 insertions(+), 12 deletions(-) diff --git a/crates/bitwarden-crypto/src/error.rs b/crates/bitwarden-crypto/src/error.rs index cd2ef9ac0..2f9a58b8b 100644 --- a/crates/bitwarden-crypto/src/error.rs +++ b/crates/bitwarden-crypto/src/error.rs @@ -24,6 +24,9 @@ pub enum CryptoError { #[error("The item was missing a required field: {0}")] MissingField(&'static str), + #[error("Insufficient KDF parameters")] + InsufficientKdfParameters, + #[error("EncString error, {0}")] EncString(#[from] EncStringParseError), diff --git a/crates/bitwarden-crypto/src/keys/utils.rs b/crates/bitwarden-crypto/src/keys/utils.rs index 8564a7c9f..4b2c4c8cd 100644 --- a/crates/bitwarden-crypto/src/keys/utils.rs +++ b/crates/bitwarden-crypto/src/keys/utils.rs @@ -3,30 +3,45 @@ use std::pin::Pin; use generic_array::{typenum::U32, GenericArray}; use sha2::Digest; -use crate::{util::hkdf_expand, Kdf, Result, SymmetricCryptoKey}; +use crate::{util::hkdf_expand, CryptoError, Kdf, Result, SymmetricCryptoKey}; + +const PBKDF2_MIN_ITERATIONS: u32 = 5000; + +const ARGON2ID_MIN_MEMORY: u32 = 16 * 1024; +const ARGON2ID_MIN_ITERATIONS: u32 = 2; +const ARGON2ID_MIN_PARALLELISM: u32 = 1; /// Derive a generic key from a secret and salt using the provided KDF. pub(super) fn derive_kdf_key(secret: &[u8], salt: &[u8], kdf: &Kdf) -> Result { let mut hash = match kdf { - Kdf::PBKDF2 { iterations } => crate::util::pbkdf2(secret, salt, iterations.get()), + Kdf::PBKDF2 { iterations } => { + let iterations = iterations.get(); + if iterations < PBKDF2_MIN_ITERATIONS { + return Err(CryptoError::InsufficientKdfParameters); + } + crate::util::pbkdf2(secret, salt, iterations) + } Kdf::Argon2id { iterations, memory, parallelism, } => { + let memory = memory.get() * 1024; // Convert MiB to KiB; + let iterations = iterations.get(); + let parallelism = parallelism.get(); + + if memory < ARGON2ID_MIN_MEMORY + || iterations < ARGON2ID_MIN_ITERATIONS + || parallelism < ARGON2ID_MIN_PARALLELISM + { + return Err(CryptoError::InsufficientKdfParameters); + } + use argon2::*; - let argon = Argon2::new( - Algorithm::Argon2id, - Version::V0x13, - Params::new( - memory.get() * 1024, // Convert MiB to KiB - iterations.get(), - parallelism.get(), - Some(32), - )?, - ); + let params = Params::new(memory, iterations, parallelism, Some(32))?; + let argon = Argon2::new(Algorithm::Argon2id, Version::V0x13, params); let salt_sha = sha2::Sha256::new().chain_update(salt).finalize(); @@ -57,6 +72,8 @@ pub(super) fn stretch_kdf_key(k: &SymmetricCryptoKey) -> Result NonZero { + NonZero::new(n).unwrap() + } + + let secret = [0u8; 32]; + let salt = [0u8; 32]; + + for kdf in [ + Kdf::PBKDF2 { + iterations: nz(4999), + }, + Kdf::Argon2id { + iterations: nz(1), + memory: nz(16), + parallelism: nz(1), + }, + Kdf::Argon2id { + iterations: nz(2), + memory: nz(15), + parallelism: nz(1), + }, + Kdf::Argon2id { + iterations: nz(1), + memory: nz(15), + parallelism: nz(1), + }, + ] { + assert_eq!( + derive_kdf_key(&secret, &salt, &kdf) + .unwrap_err() + .to_string(), + "Insufficient KDF parameters" + ); + } + } } From fa7a02c6131ecf674b8d6cb6fbd3adc79d6291aa Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Mon, 30 Sep 2024 12:19:15 -0400 Subject: [PATCH 191/214] Release Python Workflow - Fix logic (#1102) --- .github/workflows/release-python.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release-python.yml b/.github/workflows/release-python.yml index 10b451fc5..5be1a12fc 100644 --- a/.github/workflows/release-python.yml +++ b/.github/workflows/release-python.yml @@ -38,7 +38,7 @@ jobs: id: version run: | VERSION=$(cat languages/python/pyproject.toml | grep -Eo 'version = "[0-9]+\.[0-9]+\.[0-9]+"' | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+') - echo "version=$VERSION" >> $GITHUB_ENV + echo "version=$VERSION" >> $GITHUB_OUTPUT release: name: Release @@ -58,6 +58,12 @@ jobs: name: bitwarden_sdk(.*) name_is_regexp: true + - name: Move all whl files to single directory + run: | + shopt -s globstar + mv **/*.whl . + working-directory: ${{ github.workspace }}/target/wheels/dist + - name: Create GitHub release if: ${{ inputs.release_type != 'Dry Run' }} uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 # v1.14.0 From 6c22e061c7d9e03906bbc24c3fdb1dccf53a2cef Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 1 Oct 2024 10:25:19 +0200 Subject: [PATCH 192/214] Move common dependencies to the root cargo.toml (#1090) To ensure we use consistent version ranges we should concentrate common dependencies to the root cargo.toml. This should make it easier to maintain the SM dependency ranges. --- Cargo.toml | 25 +++++++++++++++++ crates/bitwarden-api-api/Cargo.toml | 16 +++++++---- crates/bitwarden-api-identity/Cargo.toml | 16 +++++++---- crates/bitwarden-core/Cargo.toml | 35 +++++++++--------------- crates/bitwarden-crypto/Cargo.toml | 12 ++++---- crates/bitwarden-exporters/Cargo.toml | 18 +++++------- crates/bitwarden-fido/Cargo.toml | 19 ++++++------- crates/bitwarden-generators/Cargo.toml | 17 +++++------- crates/bitwarden-json/Cargo.toml | 6 ++-- crates/bitwarden-napi/Cargo.toml | 2 +- crates/bitwarden-py/Cargo.toml | 2 +- crates/bitwarden-send/Cargo.toml | 17 +++++------- crates/bitwarden-sm/Cargo.toml | 19 ++++++------- crates/bitwarden-uniffi/Cargo.toml | 17 +++++------- crates/bitwarden-vault/Cargo.toml | 21 ++++++-------- crates/bitwarden/Cargo.toml | 10 +++++-- crates/bw/Cargo.toml | 2 +- crates/bws/Cargo.toml | 2 +- crates/sdk-schemas/Cargo.toml | 2 +- crates/uniffi-bindgen/Cargo.toml | 2 +- 20 files changed, 133 insertions(+), 127 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8c978819b..190341a7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,31 @@ bitwarden-send = { path = "crates/bitwarden-send", version = "=1.0.0" } bitwarden-sm = { path = "crates/bitwarden-sm", version = "=1.0.0" } bitwarden-vault = { path = "crates/bitwarden-vault", 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 } +log = "0.4.20" +reqwest = { version = ">=0.12.5, <0.13", features = [ + "json", + "multipart", + "http2", +], default-features = false } +schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } +serde = { version = ">=1.0, <2.0", features = ["derive"] } +serde_json = ">=1.0.96, <2.0" +serde_qs = ">=0.12.0, <0.14" +serde_repr = ">=0.1.12, <0.2" +thiserror = ">=1.0.40, <2.0" +tokio = { version = "1.36.0", features = ["macros"] } +uniffi = "=0.28.1" +uuid = { version = ">=1.3.3, <2.0", features = ["serde", "v4"] } +validator = { version = "0.18.1", features = ["derive"] } +wasm-bindgen = { version = "0.2.91", features = ["serde-serialize"] } +wasm-bindgen-futures = "0.4.41" + [workspace.lints.clippy] unused_async = "deny" unwrap_used = "deny" diff --git a/crates/bitwarden-api-api/Cargo.toml b/crates/bitwarden-api-api/Cargo.toml index bd4ec05c0..43ec79ff0 100644 --- a/crates/bitwarden-api-api/Cargo.toml +++ b/crates/bitwarden-api-api/Cargo.toml @@ -13,10 +13,14 @@ license-file.workspace = true keywords.workspace = true [dependencies] -serde = { version = ">=1.0.163, <2", features = ["derive"] } -serde_with = { version = ">=3.8, <4", default-features = false, features = ["base64", "std", "macros"] } -serde_json = ">=1.0.96, <2" -serde_repr = ">=0.1.12, <0.2" +serde = { workspace = true } +serde_with = { version = ">=3.8, <4", default-features = false, features = [ + "base64", + "std", + "macros", +] } +serde_json = { workspace = true } +serde_repr = { workspace = true } url = ">=2.5, <3" -uuid = { version = ">=1.3.3, <2", features = ["serde", "v4"] } -reqwest = { version = ">=0.12.5, <0.13", features = ["json", "multipart", "http2"], default-features = false } +uuid = { workspace = true } +reqwest = { workspace = true } diff --git a/crates/bitwarden-api-identity/Cargo.toml b/crates/bitwarden-api-identity/Cargo.toml index d101e9a9e..9d4d81a0d 100644 --- a/crates/bitwarden-api-identity/Cargo.toml +++ b/crates/bitwarden-api-identity/Cargo.toml @@ -13,10 +13,14 @@ license-file.workspace = true keywords.workspace = true [dependencies] -serde = { version = ">=1.0.163, <2", features = ["derive"] } -serde_with = { version = ">=3.8, <4", default-features = false, features = ["base64", "std", "macros"] } -serde_json = ">=1.0.96, <2" -serde_repr = ">=0.1.12, <0.2" +serde = { workspace = true } +serde_with = { version = ">=3.8, <4", default-features = false, features = [ + "base64", + "std", + "macros", +] } +serde_json = { workspace = true } +serde_repr = { workspace = true } url = ">=2.5, <3" -uuid = { version = ">=1.3.3, <2", features = ["serde", "v4"] } -reqwest = { version = ">=0.12.5, <0.13", features = ["json", "multipart", "http2"], default-features = false } +uuid = { workspace = true } +reqwest = { workspace = true } diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml index 7059e26c3..f4b6ec423 100644 --- a/crates/bitwarden-core/Cargo.toml +++ b/crates/bitwarden-core/Cargo.toml @@ -26,46 +26,37 @@ base64 = ">=0.22.1, <0.23" bitwarden-api-api = { workspace = true } bitwarden-api-identity = { workspace = true } bitwarden-crypto = { workspace = true } -chrono = { version = ">=0.4.26, <0.5", features = [ - "clock", - "serde", - "std", -], default-features = false } +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"] } hmac = ">=0.12.1, <0.13" log = ">=0.4.18, <0.5" rand = ">=0.8.5, <0.9" -reqwest = { version = ">=0.12.5, <0.13", features = [ - "http2", - "json", -], default-features = false } -schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } -serde = { version = ">=1.0, <2.0", features = ["derive"] } -serde_json = ">=1.0.96, <2.0" -serde_qs = ">=0.12.0, <0.14" -serde_repr = ">=0.1.12, <0.2" +reqwest = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +serde_qs = { workspace = true } +serde_repr = { workspace = true } sha1 = ">=0.10.5, <0.11" sha2 = ">=0.10.6, <0.11" -thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.28.1", optional = true, features = ["tokio"] } -uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } -validator = { version = "0.18.1", features = ["derive"] } +thiserror = { workspace = true } +uniffi = { workspace = true, optional = true, features = ["tokio"] } +uuid = { workspace = true } +validator = { workspace = true } zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } zxcvbn = { version = ">=3.0.1, <4.0", optional = true } [target.'cfg(not(target_arch="wasm32"))'.dependencies] # By default, we use rustls as the TLS stack and rust-platform-verifier to support user-installed root certificates # The only exception is WASM, as it just uses the browsers/node fetch -reqwest = { version = ">=0.12.5, <0.13", features = [ - "rustls-tls-manual-roots", -], default-features = false } +reqwest = { workspace = true, features = ["rustls-tls-manual-roots"] } rustls-platform-verifier = "0.3.4" [dev-dependencies] bitwarden-crypto = { workspace = true } rand_chacha = "0.3.1" -tokio = { version = "1.36.0", features = ["rt", "macros"] } +tokio = { workspace = true, features = ["rt"] } wiremock = "0.6.0" zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } diff --git a/crates/bitwarden-crypto/Cargo.toml b/crates/bitwarden-crypto/Cargo.toml index b071b4ee9..3254640fe 100644 --- a/crates/bitwarden-crypto/Cargo.toml +++ b/crates/bitwarden-crypto/Cargo.toml @@ -36,20 +36,20 @@ pbkdf2 = { version = ">=0.12.1, <0.13", default-features = false } rand = ">=0.8.5, <0.9" rayon = ">=1.8.1, <2.0" rsa = ">=0.9.2, <0.10" -schemars = { version = ">=0.8, <0.9", features = ["uuid1"] } -serde = { version = ">=1.0, <2.0", features = ["derive"] } +schemars = { workspace = true } +serde = { workspace = true } sha1 = ">=0.10.5, <0.11" sha2 = ">=0.10.6, <0.11" subtle = ">=2.5.0, <3.0" -thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.28.1", optional = true } -uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } +thiserror = { workspace = true } +uniffi = { workspace = true, optional = true } +uuid = { workspace = true } zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } [dev-dependencies] criterion = "0.5.1" rand_chacha = "0.3.1" -serde_json = ">=1.0.96, <2.0" +serde_json = { workspace = true } [[bench]] name = "default_allocator" diff --git a/crates/bitwarden-exporters/Cargo.toml b/crates/bitwarden-exporters/Cargo.toml index 858e9f522..38cf49953 100644 --- a/crates/bitwarden-exporters/Cargo.toml +++ b/crates/bitwarden-exporters/Cargo.toml @@ -22,18 +22,14 @@ base64 = ">=0.22.1, <0.23" bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } bitwarden-vault = { workspace = true } -chrono = { version = ">=0.4.26, <0.5", features = [ - "clock", - "serde", - "std", -], default-features = false } +chrono = { workspace = true, features = ["std"] } csv = "1.3.0" -schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } -serde = { version = ">=1.0, <2.0", features = ["derive"] } -serde_json = ">=1.0.96, <2.0" -thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.28.1", optional = true } -uuid = { version = ">=1.3.3, <2.0", features = ["serde", "v4"] } +schemars = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +thiserror = { workspace = true } +uniffi = { workspace = true, optional = true } +uuid = { workspace = true } [lints] workspace = true diff --git a/crates/bitwarden-fido/Cargo.toml b/crates/bitwarden-fido/Cargo.toml index 6b04bd796..20f5cdaf6 100644 --- a/crates/bitwarden-fido/Cargo.toml +++ b/crates/bitwarden-fido/Cargo.toml @@ -22,10 +22,7 @@ base64 = ">=0.22.1, <0.23" bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } bitwarden-vault = { workspace = true } -chrono = { version = ">=0.4.26, <0.5", features = [ - "clock", - "serde", -], default-features = false } +chrono = { workspace = true } coset = { version = "0.3.7" } itertools = "0.13.0" log = ">=0.4.18, <0.5" @@ -34,13 +31,13 @@ passkey = { git = "https://github.com/bitwarden/passkey-rs", rev = "ff757604cd7b passkey-client = { git = "https://github.com/bitwarden/passkey-rs", rev = "ff757604cd7b4e8f321ed1616fef7e40e21ac5df", features = [ "android-asset-validation", ] } -reqwest = { version = ">=0.12.5, <0.13", default-features = false } -schemars = { version = "0.8.21", features = ["uuid1", "chrono"] } -serde = { version = ">=1.0, <2.0", features = ["derive"] } -serde_json = ">=1.0.96, <2.0" -thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.28.1", optional = true } -uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } +reqwest = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +thiserror = { workspace = true } +uniffi = { workspace = true, optional = true } +uuid = { workspace = true } [lints] workspace = true diff --git a/crates/bitwarden-generators/Cargo.toml b/crates/bitwarden-generators/Cargo.toml index 442e00c08..24e5d5ebc 100644 --- a/crates/bitwarden-generators/Cargo.toml +++ b/crates/bitwarden-generators/Cargo.toml @@ -20,19 +20,16 @@ uniffi = ["dep:uniffi"] # Uniffi bindings bitwarden-core = { workspace = true, features = ["internal"] } bitwarden-crypto = { workspace = true } rand = ">=0.8.5, <0.9" -reqwest = { version = ">=0.12.5, <0.13", features = [ - "http2", - "json", -], default-features = false } -schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } -serde = { version = ">=1.0, <2.0", features = ["derive"] } -serde_json = ">=1.0.96, <2.0" -thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.28.1", optional = true } +reqwest = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +thiserror = { workspace = true } +uniffi = { workspace = true, optional = true } [dev-dependencies] rand_chacha = "0.3.1" -tokio = { version = "1.36.0", features = ["rt", "macros"] } +tokio = { workspace = true, features = ["rt"] } wiremock = "0.6.0" [lints] diff --git a/crates/bitwarden-json/Cargo.toml b/crates/bitwarden-json/Cargo.toml index 69ca8e6ab..ed1b39580 100644 --- a/crates/bitwarden-json/Cargo.toml +++ b/crates/bitwarden-json/Cargo.toml @@ -22,9 +22,9 @@ secrets = ["bitwarden/secrets"] # Secrets manager API [dependencies] bitwarden = { workspace = true } log = ">=0.4.18, <0.5" -schemars = ">=0.8.12, <0.9" -serde = { version = ">=1.0, <2.0", features = ["derive"] } -serde_json = ">=1.0.96, <2.0" +schemars = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } [lints] workspace = true diff --git a/crates/bitwarden-napi/Cargo.toml b/crates/bitwarden-napi/Cargo.toml index 59ca137aa..7a9deeb8f 100644 --- a/crates/bitwarden-napi/Cargo.toml +++ b/crates/bitwarden-napi/Cargo.toml @@ -22,7 +22,7 @@ bitwarden-json = { path = "../bitwarden-json", version = "0.3.0", features = [ "secrets", ] } env_logger = "0.11.1" -log = "0.4.20" +log = { workspace = true } napi = { version = "2", features = ["async"] } napi-derive = "2" diff --git a/crates/bitwarden-py/Cargo.toml b/crates/bitwarden-py/Cargo.toml index c66a35889..b637d5faa 100644 --- a/crates/bitwarden-py/Cargo.toml +++ b/crates/bitwarden-py/Cargo.toml @@ -24,7 +24,7 @@ pyo3-log = "0.11.0" pyo3-build-config = { version = "0.22.1" } [target.'cfg(not(target_arch="wasm32"))'.dependencies] -tokio = { version = "1.36.0", features = ["rt-multi-thread", "macros"] } +tokio = { workspace = true, features = ["rt-multi-thread"] } [lints] workspace = true diff --git a/crates/bitwarden-send/Cargo.toml b/crates/bitwarden-send/Cargo.toml index 417cac89e..33c0b76c6 100644 --- a/crates/bitwarden-send/Cargo.toml +++ b/crates/bitwarden-send/Cargo.toml @@ -25,16 +25,13 @@ base64 = ">=0.22.1, <0.23" bitwarden-api-api = { workspace = true } bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } -chrono = { version = ">=0.4.26, <0.5", features = [ - "clock", - "serde", -], default-features = false } -schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } -serde = { version = ">=1.0, <2.0", features = ["derive"] } -serde_repr = ">=0.1.12, <0.2" -thiserror = ">=1.0.40, <2.0" -uniffi = { version = "=0.28.1", optional = true } -uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } +chrono = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } +serde_repr = { workspace = true } +thiserror = { workspace = true } +uniffi = { workspace = true, optional = true } +uuid = { workspace = true } zeroize = { version = ">=1.7.0, <2.0" } [lints] diff --git a/crates/bitwarden-sm/Cargo.toml b/crates/bitwarden-sm/Cargo.toml index 882780001..77fa9d7c1 100644 --- a/crates/bitwarden-sm/Cargo.toml +++ b/crates/bitwarden-sm/Cargo.toml @@ -17,19 +17,16 @@ keywords.workspace = true bitwarden-api-api = { workspace = true } bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } -chrono = { version = ">=0.4.26, <0.5", features = [ - "clock", - "serde", -], default-features = false } -schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } -serde = { version = ">=1.0, <2.0", features = ["derive"] } -serde_json = ">=1.0.96, <2.0" -thiserror = ">=1.0.40, <2.0" -uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } -validator = { version = "0.18.1", features = ["derive"] } +chrono = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +thiserror = { workspace = true } +uuid = { workspace = true } +validator = { workspace = true } [dev-dependencies] -tokio = { version = "1.36.0", features = ["rt", "macros"] } +tokio = { workspace = true, features = ["rt"] } [lints] workspace = true diff --git a/crates/bitwarden-uniffi/Cargo.toml b/crates/bitwarden-uniffi/Cargo.toml index 5737d3559..822ed0d38 100644 --- a/crates/bitwarden-uniffi/Cargo.toml +++ b/crates/bitwarden-uniffi/Cargo.toml @@ -27,16 +27,13 @@ bitwarden-fido = { workspace = true, features = ["uniffi"] } bitwarden-generators = { workspace = true, features = ["uniffi"] } bitwarden-send = { workspace = true, features = ["uniffi"] } bitwarden-vault = { workspace = true, features = ["uniffi"] } -chrono = { version = ">=0.4.26, <0.5", features = [ - "serde", - "std", -], default-features = false } -log = "0.4.20" +chrono = { workspace = true, features = ["std"] } +log = { workspace = true } env_logger = "0.11.1" -schemars = { version = ">=0.8, <0.9", optional = true } -thiserror = ">=1.0.40, <2.0" -uniffi = "=0.28.1" -uuid = ">=1.3.3, <2" +schemars = { workspace = true, optional = true } +thiserror = { workspace = true } +uniffi = { workspace = true } +uuid = { workspace = true } [target.'cfg(target_os = "android")'.dependencies] android_logger = "0.14" @@ -50,7 +47,7 @@ rustls-platform-verifier = "0.3.4" oslog = "0.2.0" [build-dependencies] -uniffi = { version = "=0.28.1", features = ["build"] } +uniffi = { workspace = true, features = ["build"] } [lints] workspace = true diff --git a/crates/bitwarden-vault/Cargo.toml b/crates/bitwarden-vault/Cargo.toml index 04a64078f..4c41e139c 100644 --- a/crates/bitwarden-vault/Cargo.toml +++ b/crates/bitwarden-vault/Cargo.toml @@ -25,25 +25,22 @@ base64 = ">=0.22.1, <0.23" bitwarden-api-api = { workspace = true } bitwarden-core = { workspace = true, features = ["internal"] } bitwarden-crypto = { workspace = true } -chrono = { version = ">=0.4.26, <0.5", features = [ - "clock", - "serde", -], default-features = false } +chrono = { workspace = true } rand = ">=0.8.5, <0.9" hmac = ">=0.12.1, <0.13" -reqwest = { version = ">=0.12.5, <0.13", default-features = false } -schemars = { version = ">=0.8.9, <0.9", features = ["uuid1", "chrono"] } -serde = { version = ">=1.0, <2.0", features = ["derive"] } -serde_json = ">=1.0.96, <2.0" -serde_repr = ">=0.1.12, <0.2" +reqwest = { workspace = true } +schemars = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +serde_repr = { workspace = true } sha1 = ">=0.10.5, <0.11" sha2 = ">=0.10.6, <0.11" -thiserror = ">=1.0.40, <2.0" +thiserror = { workspace = true } uniffi = { version = "=0.28.1", optional = true } -uuid = { version = ">=1.3.3, <2.0", features = ["serde"] } +uuid = { workspace = true } [dev-dependencies] -tokio = { version = "1.36.0", features = ["rt", "macros"] } +tokio = { workspace = true, features = ["rt"] } [lints] workspace = true diff --git a/crates/bitwarden/Cargo.toml b/crates/bitwarden/Cargo.toml index f927564cf..9fa5c0cb3 100644 --- a/crates/bitwarden/Cargo.toml +++ b/crates/bitwarden/Cargo.toml @@ -35,7 +35,11 @@ uniffi = [ "bitwarden-send/uniffi", "bitwarden-vault/uniffi", ] # Uniffi bindings -secrets = ["bitwarden-core/secrets", "dep:bitwarden-sm", "dep:bitwarden-generators"] # Secrets manager API +secrets = [ + "bitwarden-core/secrets", + "dep:bitwarden-sm", + "dep:bitwarden-generators", +] # Secrets manager API [dependencies] bitwarden-api-api = { workspace = true } @@ -48,10 +52,10 @@ bitwarden-generators = { workspace = true, optional = true } bitwarden-send = { workspace = true, optional = true } bitwarden-sm = { workspace = true, optional = true } bitwarden-vault = { workspace = true, optional = true } -thiserror = ">=1.0.40, <2.0" +thiserror = { workspace = true } [dev-dependencies] -uuid = { version = ">=1.3.3, <2.0" } +uuid = { workspace = true } [lints] workspace = true diff --git a/crates/bw/Cargo.toml b/crates/bw/Cargo.toml index 7361f15b6..cb8e02ba1 100644 --- a/crates/bw/Cargo.toml +++ b/crates/bw/Cargo.toml @@ -22,7 +22,7 @@ color-eyre = "0.6.3" env_logger = "0.11.1" inquire = "0.7.0" log = "0.4.20" -tokio = { version = "1.36.0", features = ["rt-multi-thread", "macros"] } +tokio = { workspace = true, features = ["rt-multi-thread"] } [dev-dependencies] tempfile = "3.10.0" diff --git a/crates/bws/Cargo.toml b/crates/bws/Cargo.toml index c6ef58396..08e3941f2 100644 --- a/crates/bws/Cargo.toml +++ b/crates/bws/Cargo.toml @@ -41,7 +41,7 @@ serde_json = "1.0.113" serde_yaml = "0.9" supports-color = "3.0.0" thiserror = "1.0.57" -tokio = { version = "1.36.0", features = ["rt-multi-thread", "macros"] } +tokio = { workspace = true, features = ["rt-multi-thread"] } toml = "0.8.10" uuid = { version = "1.7.0", features = ["serde"] } which = "6.0.1" diff --git a/crates/sdk-schemas/Cargo.toml b/crates/sdk-schemas/Cargo.toml index 9982e47fe..8d48cd691 100644 --- a/crates/sdk-schemas/Cargo.toml +++ b/crates/sdk-schemas/Cargo.toml @@ -24,5 +24,5 @@ bitwarden = { workspace = true } bitwarden-json = { path = "../bitwarden-json" } bitwarden-uniffi = { path = "../bitwarden-uniffi", optional = true } itertools = "0.13.0" -schemars = { version = "0.8.16", features = ["preserve_order"] } +schemars = { workspace = true, features = ["preserve_order"] } serde_json = "1.0.113" diff --git a/crates/uniffi-bindgen/Cargo.toml b/crates/uniffi-bindgen/Cargo.toml index 042ea8b65..b5401afb9 100644 --- a/crates/uniffi-bindgen/Cargo.toml +++ b/crates/uniffi-bindgen/Cargo.toml @@ -17,4 +17,4 @@ name = "uniffi-bindgen" path = "uniffi-bindgen.rs" [dependencies] -uniffi = { version = "=0.28.1", features = ["cli"] } +uniffi = { workspace = true, features = ["cli"] } From eb0d68308648233d1e0bcdc702d62d8c14d3d70f Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Tue, 1 Oct 2024 04:31:49 -0400 Subject: [PATCH 193/214] Release @bitwarden/sdk-napi workflow - Fix logic (#1104) --- .github/workflows/release-napi.yml | 35 +++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release-napi.yml b/.github/workflows/release-napi.yml index e8be69f99..761515c73 100644 --- a/.github/workflows/release-napi.yml +++ b/.github/workflows/release-napi.yml @@ -14,11 +14,6 @@ on: - Initial Release - Redeploy - Dry Run - npm_publish: - description: "Publish to NPM registry" - required: true - default: true - type: boolean defaults: run: @@ -63,17 +58,23 @@ jobs: uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 - name: Download artifacts - uses: bitwarden/gh-actions/download-artifacts@main + uses: dawidd6/action-download-artifact@bf251b5aa9c2f7eeb574a96ee720e24f801b7c11 # v6 with: workflow: build-napi.yml workflow_conclusion: success branch: main - artifacts: | - sdk-bitwarden-napi-aarch64-apple-darwin - sdk-bitwarden-napi-x86_64-apple-darwin - sdk-bitwarden-napi-x86_64-pc-windows-msvc - sdk-bitwarden-napi-x86_64-unknown-linux-gnu - schemas.ts + name: sdk-bitwarden-napi-(.*)|schemas.ts + name_is_regexp: true + path: dist + + - name: Move artifact files to single directory + run: | + ls -alhR + shopt -s globstar + mv **/*.node . + mv schemas.ts/ schemas/ + mv schemas/schemas.ts . + working-directory: dist - name: Create release if: ${{ inputs.release_type != 'Dry Run' }} @@ -88,8 +89,8 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} draft: true artifacts: | - sdk-napi.darwin-arm64.node - sdk-napi.darwin-x64.node - sdk-napi.win32-x64-msvc.node - sdk-napi.linux-x64-gnu.node - schemas.ts + dist/sdk-napi.darwin-arm64.node + dist/sdk-napi.darwin-x64.node + dist/sdk-napi.win32-x64-msvc.node + dist/sdk-napi.linux-x64-gnu.node + dist/schemas.ts From 66949afb5bb1f02012988b3839c1186a3c4eeca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Tue, 1 Oct 2024 12:47:14 +0200 Subject: [PATCH 194/214] Fix panic handling during memory testing (#1106) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 📔 Objective Previously the memory testing program wouldn't detect when the binary being executed panicked unexpectedly, which caused the program to run indefinitely while waiting for the binary to notify it to continue. This started appearing when adding the validation for KDF minimums, as one of the tests we run is under the minimum, which causes CI to run until timeout: https://github.com/bitwarden/sdk/actions/runs/11109271931 ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/memory-testing/cases.json | 8 ++++---- crates/memory-testing/src/bin/capture-dumps.rs | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/memory-testing/cases.json b/crates/memory-testing/cases.json index 4205e3dce..5223d3671 100644 --- a/crates/memory-testing/cases.json +++ b/crates/memory-testing/cases.json @@ -72,7 +72,7 @@ "kdf": { "argon2id": { "iterations": 3, - "memory": 4, + "memory": 16, "parallelism": 1 } } @@ -80,15 +80,15 @@ "memory_lookups": [ { "name": "Key", - "hex": "3bc0520a0abff0097d521ce0ee5e5b1cee301939a84742623c0c1697d7a4bd46" + "hex": "59079cd7134409c6882c2701de8357a3d8aabb2dad2da19eea5f1b8081dfb51c" }, { "name": "Hash B64", - "string": "lHkprdORlICVJ4Umwi94Uz/nATK6Y7If7e+iFoabzh0=" + "string": "P1ZT6T80zOfEqXj/kPbtON3yszf7xLNGCxWjdO2xfjU=" }, { "name": "Hash bytes", - "hex": "947929add391948095278526c22f78533fe70132ba63b21fedefa216869bce1d" + "hex": "3f5653e93f34cce7c4a978ff90f6ed38ddf2b337fbc4b3460b15a374edb17e35" } ] }, diff --git a/crates/memory-testing/src/bin/capture-dumps.rs b/crates/memory-testing/src/bin/capture-dumps.rs index 1fe4eead1..5dddd7622 100644 --- a/crates/memory-testing/src/bin/capture-dumps.rs +++ b/crates/memory-testing/src/bin/capture-dumps.rs @@ -37,6 +37,11 @@ fn wait_dump_and_continue( loop { let mut buf = [0u8; 1024]; let read = stdout.read(&mut buf).unwrap(); + + if read == 0 { + panic!("Process exited unexpectedly"); + } + let buf_str = std::str::from_utf8(&buf[..read]).unwrap(); if buf_str.contains("Waiting for dump...") { break; From 8dde05e0caca144a1e1b99476d5d6e676ea5d59f Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Tue, 1 Oct 2024 16:36:40 -0400 Subject: [PATCH 195/214] Fix Build Rust Cross Platform Upload (#1107) --- .github/workflows/build-rust-cross-platform.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-rust-cross-platform.yml b/.github/workflows/build-rust-cross-platform.yml index fab7df991..1748661b9 100644 --- a/.github/workflows/build-rust-cross-platform.yml +++ b/.github/workflows/build-rust-cross-platform.yml @@ -86,6 +86,10 @@ jobs: uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 with: name: libbitwarden_c_files-${{ matrix.settings.target }} - path: | - target/${{ matrix.settings.target }}/release/*bitwarden_c* - target/${{ matrix.settings.target }}/release-windows/*bitwarden_c* + path: target/${{ matrix.settings.target }}/release/*bitwarden_c* + + - name: Upload Artifact + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + name: libbitwarden_c_files-${{ matrix.settings.target }} + path: target/${{ matrix.settings.target }}/release-windows/*bitwarden_c* From 99f5c6bbdd5721116fe63c4c6e08a90f13db949d Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 3 Oct 2024 17:47:50 +0200 Subject: [PATCH 196/214] Format workflows (#1109) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/publish-bws.yml | 3 +-- .github/workflows/publish-dotnet.yml | 16 ++++++++-------- .github/workflows/publish-rust-crates.yml | 2 +- .github/workflows/release-dotnet.yml | 1 - 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/publish-bws.yml b/.github/workflows/publish-bws.yml index 506427faa..dc939a5d6 100644 --- a/.github/workflows/publish-bws.yml +++ b/.github/workflows/publish-bws.yml @@ -14,7 +14,7 @@ on: - Release - Dry Run version: - description: 'Version to publish (default: latest bws cli release)' + description: "Version to publish (default: latest bws cli release)" required: true type: string default: latest @@ -71,7 +71,6 @@ jobs: description: "Deployment ${{ steps.version-output.outputs.version }} from branch ${{ github.ref_name }}" task: release - publish: name: Publish bws to crates.io runs-on: ubuntu-22.04 diff --git a/.github/workflows/publish-dotnet.yml b/.github/workflows/publish-dotnet.yml index baafcc522..1e2fc06f4 100644 --- a/.github/workflows/publish-dotnet.yml +++ b/.github/workflows/publish-dotnet.yml @@ -66,10 +66,10 @@ jobs: uses: chrnorm/deployment-action@55729fcebec3d284f60f5bcabbd8376437d696b1 # v2.0.7 id: deployment with: - token: '${{ secrets.GITHUB_TOKEN }}' - initial-status: 'in_progress' - environment: 'dotnet - Production' - description: 'Deployment ${{ needs.validate.outputs.version }} from branch ${{ github.ref_name }}' + token: "${{ secrets.GITHUB_TOKEN }}" + initial-status: "in_progress" + environment: "dotnet - Production" + description: "Deployment ${{ needs.validate.outputs.version }} from branch ${{ github.ref_name }}" task: release - name: Download artifact @@ -100,14 +100,14 @@ jobs: if: ${{ inputs.release_type != 'Dry Run' && success() }} uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 with: - token: '${{ secrets.GITHUB_TOKEN }}' - state: 'success' + token: "${{ secrets.GITHUB_TOKEN }}" + state: "success" deployment-id: ${{ steps.deployment.outputs.deployment_id }} - name: Update deployment status to Failure if: ${{ inputs.release_type != 'Dry Run' && failure() }} uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 with: - token: '${{ secrets.GITHUB_TOKEN }}' - state: 'failure' + token: "${{ secrets.GITHUB_TOKEN }}" + state: "failure" deployment-id: ${{ steps.deployment.outputs.deployment_id }} diff --git a/.github/workflows/publish-rust-crates.yml b/.github/workflows/publish-rust-crates.yml index 43f19323a..bb79aad24 100644 --- a/.github/workflows/publish-rust-crates.yml +++ b/.github/workflows/publish-rust-crates.yml @@ -15,7 +15,7 @@ on: - Redeploy - Dry Run version: - description: 'Version to publish (default: latest rust crates release)' + description: "Version to publish (default: latest rust crates release)" required: true type: string default: latest diff --git a/.github/workflows/release-dotnet.yml b/.github/workflows/release-dotnet.yml index 2e08e8a76..dc8539271 100644 --- a/.github/workflows/release-dotnet.yml +++ b/.github/workflows/release-dotnet.yml @@ -13,7 +13,6 @@ on: - Release - Dry Run - jobs: setup: name: Setup From b74d969dab9502eb1365c79f9bac35ad3469646d Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 4 Oct 2024 10:16:13 +0200 Subject: [PATCH 197/214] [PM-12967] Create bitwarden-wasm-internal (#1089) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking https://bitwarden.atlassian.net/browse/PM-12967 ## 📔 Objective PM SDK. Based on the research spike in #1077 ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/build-wasm-internal.yml | 59 ++++++++ .github/workflows/publish-internal.yml | 136 ++++++++++++++++++ .prettierignore | 4 + Cargo.lock | 51 +++++++ Cargo.toml | 5 +- crates/bitwarden-core/Cargo.toml | 3 + .../src/client/client_settings.rs | 15 +- crates/bitwarden-wasm-internal/Cargo.toml | 28 ++++ crates/bitwarden-wasm-internal/README.md | 25 ++++ crates/bitwarden-wasm-internal/build.sh | 26 ++++ crates/bitwarden-wasm-internal/src/client.rs | 57 ++++++++ crates/bitwarden-wasm-internal/src/lib.rs | 1 + crates/bitwarden/Cargo.toml | 1 + languages/js/sdk-internal/.gitignore | 6 + languages/js/sdk-internal/index.js | 8 ++ languages/js/sdk-internal/package.json | 24 ++++ 16 files changed, 447 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build-wasm-internal.yml create mode 100644 .github/workflows/publish-internal.yml create mode 100644 crates/bitwarden-wasm-internal/Cargo.toml create mode 100644 crates/bitwarden-wasm-internal/README.md create mode 100755 crates/bitwarden-wasm-internal/build.sh create mode 100644 crates/bitwarden-wasm-internal/src/client.rs create mode 100644 crates/bitwarden-wasm-internal/src/lib.rs create mode 100644 languages/js/sdk-internal/.gitignore create mode 100644 languages/js/sdk-internal/index.js create mode 100644 languages/js/sdk-internal/package.json diff --git a/.github/workflows/build-wasm-internal.yml b/.github/workflows/build-wasm-internal.yml new file mode 100644 index 000000000..99fe06c44 --- /dev/null +++ b/.github/workflows/build-wasm-internal.yml @@ -0,0 +1,59 @@ +--- +name: Build @bitwarden/sdk-internal + +on: + pull_request: + push: + branches: + - "main" + - "rc" + - "hotfix-rc" + workflow_dispatch: + +defaults: + run: + shell: bash + working-directory: crates/bitwarden-wasm-internal + +jobs: + build: + name: Building @bitwarden/sdk-wasm-internal + runs-on: ubuntu-22.04 + + steps: + - name: Checkout repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Setup Node + uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4 + with: + node-version: 20 + registry-url: "https://npm.pkg.github.com" + cache: "npm" + + - name: Install dependencies + run: npm i -g binaryen + + - name: Install rust + uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable + with: + toolchain: stable + targets: wasm32-unknown-unknown + + - name: Cache cargo registry + uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3 + with: + key: wasm-cargo-cache + + - name: Install wasm-bindgen-cli + run: cargo install wasm-bindgen-cli + + - name: Build + run: ./build.sh -r + + - name: Upload artifact + uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 + with: + name: sdk-internal + path: ${{ github.workspace }}/languages/js/sdk-internal/* + if-no-files-found: error diff --git a/.github/workflows/publish-internal.yml b/.github/workflows/publish-internal.yml new file mode 100644 index 000000000..304fade43 --- /dev/null +++ b/.github/workflows/publish-internal.yml @@ -0,0 +1,136 @@ +--- +name: Publish @bitwarden/sdk-internal +run-name: Publish @bitwarden/sdk-internal ${{ inputs.release_type }} + +on: + workflow_dispatch: + inputs: + release_type: + description: "Release Options" + required: true + default: "Release" + type: choice + options: + - Release + - Dry Run + version: + description: "Release Version" + required: false + default: "latest" + +defaults: + run: + working-directory: languages/js/sdk-internal + +jobs: + setup: + name: Setup + runs-on: ubuntu-22.04 + outputs: + release-version: ${{ steps.version-output.outputs.version }} + tag_name: ${{ steps.version-output.outputs.tag_name }} + steps: + - name: Checkout repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Branch check + if: ${{ inputs.release_type != 'Dry Run' }} + run: | + if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then + echo "===================================" + echo "[!] Can only release from the 'main' branch" + echo "===================================" + exit 1 + fi + + - name: Version output + id: version-output + run: | + if [[ "${{ inputs.version }}" == "latest" || "${{ inputs.version }}" == "" ]]; then + TAG_NAME=$(curl "https://api.github.com/repos/bitwarden/sdk/releases" | jq -c '.[] | select(.tag_name | contains("sdk-internal")) | .tag_name' | head -1) + VERSION=$(echo $TAG_NAME | grep -ohE '20[0-9]{2}\.([1-9]|1[0-2])\.[0-9]+') + echo "Latest Released Version: $VERSION" + echo "version=$VERSION" >> $GITHUB_OUTPUT + + echo "Latest Released Tag name: $TAG_NAME" + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT + else + echo "Release Version: ${{ inputs.version }}" + echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT + fi + + npm: + name: Publish NPM + runs-on: ubuntu-22.04 + needs: setup + env: + _VERSION: ${{ needs.setup.outputs.release-version }} + steps: + - name: Checkout repo + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + with: + ref: ${{ needs.setup.outputs.tag_name }} + + - name: Setup Node + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 + with: + node-version: 20 + + - name: Login to Azure + uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 + with: + creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve secrets + id: retrieve-secrets + uses: bitwarden/gh-actions/get-keyvault-secrets@main + with: + keyvault: "bitwarden-ci" + secrets: "npm-api-key" + + - name: Download artifact + run: | + wget https://github.com/bitwarden/sdk/releases/download/sdk-internal-v${{ env._VERSION }}/sdk-internal.zip + unzip sdk-internal.zip + rm sdk-internal.zip + + - name: Create GitHub deployment + if: ${{ inputs.release_type != 'Dry Run' }} + uses: chrnorm/deployment-action@55729fcebec3d284f60f5bcabbd8376437d696b1 # v2.0.7 + id: deployment + with: + token: "${{ secrets.GITHUB_TOKEN }}" + initial-status: "in_progress" + environment: "Bitwarden SDK Internal - Production" + description: "Deployment ${{ env._VERSION }} from branch ${{ github.ref_name }}" + task: release + + - name: Setup NPM + run: | + echo 'registry="https://registry.npmjs.org/"' > ./.npmrc + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ./.npmrc + + echo 'registry="https://registry.npmjs.org/"' > ~/.npmrc + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc + env: + NPM_TOKEN: ${{ steps.retrieve-secrets.outputs.npm-api-key }} + + - name: Publish NPM + if: ${{ inputs.release_type != 'Dry Run' }} + run: npm publish --access public --registry=https://registry.npmjs.org/ --userconfig=./.npmrc + + - name: Update deployment status to Success + if: ${{ inputs.release_type != 'Dry Run' && success() }} + uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 + with: + token: "${{ secrets.GITHUB_TOKEN }}" + state: "success" + deployment-id: ${{ steps.deployment.outputs.deployment_id }} + + - name: Update deployment status to Failure + if: ${{ inputs.release_type != 'Dry Run' && failure() }} + uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 + with: + token: "${{ secrets.GITHUB_TOKEN }}" + state: "failure" + deployment-id: ${{ steps.deployment.outputs.deployment_id }} diff --git a/.prettierignore b/.prettierignore index 36c418776..16243942f 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,9 @@ target languages/* +!languages/js +languages/js/* +!languages/js/sdk-internal +languages/js/sdk-internal/bitwarden_wasm_internal_bg.wasm.js schemas /crates/bitwarden-napi/src-ts/bitwarden_client/schemas.ts about.hbs diff --git a/Cargo.lock b/Cargo.lock index 27eddfa65..4e0d14119 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -446,9 +446,11 @@ dependencies = [ "sha2", "thiserror", "tokio", + "tsify-next", "uniffi", "uuid", "validator", + "wasm-bindgen", "wiremock", "zeroize", "zxcvbn", @@ -683,6 +685,20 @@ dependencies = [ "wasm-bindgen-test", ] +[[package]] +name = "bitwarden-wasm-internal" +version = "0.1.0" +dependencies = [ + "bitwarden", + "console_error_panic_hook", + "console_log", + "js-sys", + "log", + "serde_json", + "wasm-bindgen", + "wasm-bindgen-futures", +] + [[package]] name = "blake2" version = "0.10.6" @@ -3509,6 +3525,17 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-wasm-bindgen" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + [[package]] name = "serde_derive" version = "1.0.210" @@ -4155,6 +4182,30 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" +[[package]] +name = "tsify-next" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4a645dca4ee0800f5ab60ce166deba2db6a0315de795a2691e138a3d55d756" +dependencies = [ + "serde", + "serde-wasm-bindgen", + "tsify-next-macros", + "wasm-bindgen", +] + +[[package]] +name = "tsify-next-macros" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d5c06f8a51d759bb58129e30b2631739e7e1e4579fad1f30ac09a6c88e488a6" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 2.0.79", +] + [[package]] name = "typenum" version = "1.17.0" diff --git a/Cargo.toml b/Cargo.toml index 190341a7e..ce01a7b7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,10 +49,13 @@ serde_qs = ">=0.12.0, <0.14" serde_repr = ">=0.1.12, <0.2" thiserror = ">=1.0.40, <2.0" tokio = { version = "1.36.0", features = ["macros"] } +tsify-next = { version = ">=0.5.4, <0.6", features = [ + "js", +], default-features = false } uniffi = "=0.28.1" uuid = { version = ">=1.3.3, <2.0", features = ["serde", "v4"] } validator = { version = "0.18.1", features = ["derive"] } -wasm-bindgen = { version = "0.2.91", features = ["serde-serialize"] } +wasm-bindgen = { version = ">=0.2.91, <0.3", features = ["serde-serialize"] } wasm-bindgen-futures = "0.4.41" [workspace.lints.clippy] diff --git a/crates/bitwarden-core/Cargo.toml b/crates/bitwarden-core/Cargo.toml index f4b6ec423..d212afb7a 100644 --- a/crates/bitwarden-core/Cargo.toml +++ b/crates/bitwarden-core/Cargo.toml @@ -20,6 +20,7 @@ no-memory-hardening = [ ] # Disable memory hardening features uniffi = ["bitwarden-crypto/uniffi", "dep:uniffi"] # Uniffi bindings secrets = [] # Secrets manager API +wasm = ["dep:wasm-bindgen", "dep:tsify-next"] # WASM support [dependencies] base64 = ">=0.22.1, <0.23" @@ -44,8 +45,10 @@ thiserror = { workspace = true } uniffi = { workspace = true, optional = true, features = ["tokio"] } uuid = { workspace = true } validator = { workspace = true } +wasm-bindgen = { workspace = true, optional = true } zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } zxcvbn = { version = ">=3.0.1, <4.0", optional = true } +tsify-next = { workspace = true, optional = true } [target.'cfg(not(target_arch="wasm32"))'.dependencies] # By default, we use rustls as the TLS stack and rust-platform-verifier to support user-installed root certificates diff --git a/crates/bitwarden-core/src/client/client_settings.rs b/crates/bitwarden-core/src/client/client_settings.rs index bd678d131..70e2e6839 100644 --- a/crates/bitwarden-core/src/client/client_settings.rs +++ b/crates/bitwarden-core/src/client/client_settings.rs @@ -19,6 +19,11 @@ use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(default, rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] +#[cfg_attr( + feature = "wasm", + derive(tsify_next::Tsify), + tsify(into_wasm_abi, from_wasm_abi) +)] pub struct ClientSettings { /// The identity url of the targeted Bitwarden instance. Defaults to `https://identity.bitwarden.com` pub identity_url: String, @@ -44,6 +49,11 @@ impl Default for ClientSettings { #[allow(non_camel_case_types)] #[derive(Serialize, Deserialize, Copy, Clone, Debug, JsonSchema)] #[cfg_attr(feature = "uniffi", derive(uniffi::Enum))] +#[cfg_attr( + feature = "wasm", + derive(tsify_next::Tsify), + tsify(into_wasm_abi, from_wasm_abi) +)] pub enum DeviceType { Android = 0, iOS = 1, @@ -66,6 +76,9 @@ pub enum DeviceType { VivaldiBrowser = 18, VivaldiExtension = 19, SafariExtension = 20, - SDK = 21, + Server = 22, + WindowsCLI = 23, + MacOsCLI = 24, + LinuxCLI = 25, } diff --git a/crates/bitwarden-wasm-internal/Cargo.toml b/crates/bitwarden-wasm-internal/Cargo.toml new file mode 100644 index 000000000..df69015cf --- /dev/null +++ b/crates/bitwarden-wasm-internal/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "bitwarden-wasm-internal" +version = "0.1.0" +publish = false + +authors.workspace = true +edition.workspace = true +rust-version.workspace = true +homepage.workspace = true +repository.workspace = true +license-file.workspace = true +keywords.workspace = true + +[lib] +crate-type = ["cdylib"] + +[dependencies] +bitwarden = { workspace = true, features = ["internal", "wasm"] } +console_error_panic_hook = "0.1.7" +console_log = { version = "1.0.0", features = ["color"] } +js-sys = "0.3.68" +log = "0.4.20" +serde_json = ">=1.0.96, <2.0" +wasm-bindgen = { version = "0.2.91", features = ["serde-serialize"] } +wasm-bindgen-futures = "0.4.41" + +[lints] +workspace = true diff --git a/crates/bitwarden-wasm-internal/README.md b/crates/bitwarden-wasm-internal/README.md new file mode 100644 index 000000000..4db9847f5 --- /dev/null +++ b/crates/bitwarden-wasm-internal/README.md @@ -0,0 +1,25 @@ +# bitwarden-wasm-internal + +**Note:** This is only for internal use. Bitwarden will not provide any support for this crate. + +Requirements: + +- `wasm32-unknown-unknown` rust target. +- `wasm-bindgen-cli` installed. +- `binaryen` installed for `wasm-opt` and `wasm2js`. + +```bash +rustup target add wasm32-unknown-unknown +cargo install -f wasm-bindgen-cli +brew install binaryen +``` + +#### Build + +```bash +# dev +./build.sh + +# release +./build.sh -r +``` diff --git a/crates/bitwarden-wasm-internal/build.sh b/crates/bitwarden-wasm-internal/build.sh new file mode 100755 index 000000000..aa8426c59 --- /dev/null +++ b/crates/bitwarden-wasm-internal/build.sh @@ -0,0 +1,26 @@ +# Move to the root of the repository +cd "$(dirname "$0")" +cd ../../ + +if [ "$1" != "-r" ]; then + # Dev + cargo build -p bitwarden-wasm-internal --target wasm32-unknown-unknown + wasm-bindgen --target bundler --out-dir languages/js/sdk-internal ./target/wasm32-unknown-unknown/debug/bitwarden_wasm_internal.wasm + wasm-bindgen --target nodejs --out-dir languages/js/sdk-internal/node ./target/wasm32-unknown-unknown/debug/bitwarden_wasm_internal.wasm +else + # Release + cargo build -p bitwarden-wasm-internal --target wasm32-unknown-unknown --release + wasm-bindgen --target bundler --out-dir languages/js/sdk-internal ./target/wasm32-unknown-unknown/release/bitwarden_wasm_internal.wasm + wasm-bindgen --target nodejs --out-dir languages/js/sdk-internal/node ./target/wasm32-unknown-unknown/release/bitwarden_wasm_internal.wasm +fi + +# Format +npx prettier --write ./languages/js/sdk-internal + +# Optimize size +wasm-opt -Os ./languages/js/sdk-internal/bitwarden_wasm_internal_bg.wasm -o ./languages/js/sdk-internal/bitwarden_wasm_internal_bg.wasm +wasm-opt -Os ./languages/js/sdk-internal/node/bitwarden_wasm_internal_bg.wasm -o ./languages/js/sdk-internal/node/bitwarden_wasm_internal_bg.wasm + +# Transpile to JS +wasm2js ./languages/js/sdk-internal/bitwarden_wasm_internal_bg.wasm -o ./languages/js/sdk-internal/bitwarden_wasm_internal_bg.wasm.js +npx terser ./languages/js/sdk-internal/bitwarden_wasm_internal_bg.wasm.js -o ./languages/js/sdk-internal/bitwarden_wasm_internal_bg.wasm.js diff --git a/crates/bitwarden-wasm-internal/src/client.rs b/crates/bitwarden-wasm-internal/src/client.rs new file mode 100644 index 000000000..994af1fcf --- /dev/null +++ b/crates/bitwarden-wasm-internal/src/client.rs @@ -0,0 +1,57 @@ +extern crate console_error_panic_hook; +use std::rc::Rc; + +use bitwarden::{Client, ClientSettings}; +use log::{set_max_level, Level}; +use wasm_bindgen::prelude::*; + +#[wasm_bindgen] +pub enum LogLevel { + Trace, + Debug, + Info, + Warn, + Error, +} + +fn convert_level(level: LogLevel) -> Level { + match level { + LogLevel::Trace => Level::Trace, + LogLevel::Debug => Level::Debug, + LogLevel::Info => Level::Info, + LogLevel::Warn => Level::Warn, + LogLevel::Error => Level::Error, + } +} + +// Rc<...> is to avoid needing to take ownership of the Client during our async run_command +// function https://github.com/rustwasm/wasm-bindgen/issues/2195#issuecomment-799588401 +#[wasm_bindgen] +pub struct BitwardenClient(Rc); + +#[wasm_bindgen] +impl BitwardenClient { + #[wasm_bindgen(constructor)] + pub fn new(settings: Option, log_level: Option) -> Self { + console_error_panic_hook::set_once(); + let log_level = convert_level(log_level.unwrap_or(LogLevel::Info)); + if let Err(_e) = console_log::init_with_level(log_level) { + set_max_level(log_level.to_level_filter()) + } + + Self(Rc::new(Client::new(settings))) + } + + /// Test method, echoes back the input + pub fn echo(&self, msg: String) -> String { + msg + } + + /// Test method, calls http endpoint + pub async fn http_get(&self, url: String) -> Result { + let client = self.0.internal.get_http_client(); + let res = client.get(&url).send().await.map_err(|e| e.to_string())?; + + res.text().await.map_err(|e| e.to_string()) + } +} diff --git a/crates/bitwarden-wasm-internal/src/lib.rs b/crates/bitwarden-wasm-internal/src/lib.rs new file mode 100644 index 000000000..b79c47fca --- /dev/null +++ b/crates/bitwarden-wasm-internal/src/lib.rs @@ -0,0 +1 @@ +mod client; diff --git a/crates/bitwarden/Cargo.toml b/crates/bitwarden/Cargo.toml index 9fa5c0cb3..1d09377cf 100644 --- a/crates/bitwarden/Cargo.toml +++ b/crates/bitwarden/Cargo.toml @@ -40,6 +40,7 @@ secrets = [ "dep:bitwarden-sm", "dep:bitwarden-generators", ] # Secrets manager API +wasm = ["bitwarden-core/wasm"] # WASM support [dependencies] bitwarden-api-api = { workspace = true } diff --git a/languages/js/sdk-internal/.gitignore b/languages/js/sdk-internal/.gitignore new file mode 100644 index 000000000..ef69b9de9 --- /dev/null +++ b/languages/js/sdk-internal/.gitignore @@ -0,0 +1,6 @@ +bitwarden_wasm_internal_bg.js +bitwarden_wasm_internal_bg.wasm +bitwarden_wasm_internal_bg.wasm.d.ts +bitwarden_wasm_internal_bg.wasm.js +bitwarden_wasm_internal.d.ts +bitwarden_wasm_internal.js diff --git a/languages/js/sdk-internal/index.js b/languages/js/sdk-internal/index.js new file mode 100644 index 000000000..0525f7aa4 --- /dev/null +++ b/languages/js/sdk-internal/index.js @@ -0,0 +1,8 @@ +import { __wbg_set_wasm } from "./bitwarden_wasm_internal_bg.js"; + +// In order to support a fallback strategy for web we need to conditionally load the wasm file +export function init(wasm) { + __wbg_set_wasm(wasm); +} + +export * from "./bitwarden_wasm_internal_bg.js"; diff --git a/languages/js/sdk-internal/package.json b/languages/js/sdk-internal/package.json new file mode 100644 index 000000000..94b678141 --- /dev/null +++ b/languages/js/sdk-internal/package.json @@ -0,0 +1,24 @@ +{ + "name": "@bitwarden/sdk-internal", + "version": "0.1.0", + "files": [ + "bitwarden_wasm_internal_bg.js", + "bitwarden_wasm_internal_bg.wasm", + "bitwarden_wasm_internal_bg.wasm.d.ts", + "bitwarden_wasm_internal_bg.wasm.js", + "bitwarden_wasm_internal.d.ts", + "bitwarden_wasm_internal.js", + "index.js", + "node/bitwarden_wasm_internal.wasm", + "node/bitwarden_wasm_internal.wasm.d.ts", + "node/bitwarden_wasm_internal.d.ts", + "node/bitwarden_wasm_internal.js" + ], + "main": "node/bitwarden_wasm_internal.js", + "module": "index.js", + "types": "bitwarden_wasm_internal.d.ts", + "scripts": {}, + "sideEffects": [ + "./bitwarden_wasm_internal.js" + ] +} From 3f023405e8a31fc68dd1c78af96e652ef1af203e Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 4 Oct 2024 11:19:11 +0200 Subject: [PATCH 198/214] Fix publish internal (#1111) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking [bitwarden.atlassian.net/browse/PM-12967](https://bitwarden.atlassian.net/browse/PM-12967) ## 📔 Objective We expect to automate this so that every merge to main will publish a new sdk-internal release. Therefore we want to: - Not create github releases - Publish to GH packages ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/publish-internal.yml | 89 +++---------------------- crates/bitwarden-wasm-internal/build.sh | 3 - 2 files changed, 11 insertions(+), 81 deletions(-) diff --git a/.github/workflows/publish-internal.yml b/.github/workflows/publish-internal.yml index 304fade43..7d0ceb198 100644 --- a/.github/workflows/publish-internal.yml +++ b/.github/workflows/publish-internal.yml @@ -15,8 +15,7 @@ on: - Dry Run version: description: "Release Version" - required: false - default: "latest" + required: true defaults: run: @@ -26,9 +25,6 @@ jobs: setup: name: Setup runs-on: ubuntu-22.04 - outputs: - release-version: ${{ steps.version-output.outputs.version }} - tag_name: ${{ steps.version-output.outputs.tag_name }} steps: - name: Checkout repo uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 @@ -43,94 +39,31 @@ jobs: exit 1 fi - - name: Version output - id: version-output - run: | - if [[ "${{ inputs.version }}" == "latest" || "${{ inputs.version }}" == "" ]]; then - TAG_NAME=$(curl "https://api.github.com/repos/bitwarden/sdk/releases" | jq -c '.[] | select(.tag_name | contains("sdk-internal")) | .tag_name' | head -1) - VERSION=$(echo $TAG_NAME | grep -ohE '20[0-9]{2}\.([1-9]|1[0-2])\.[0-9]+') - echo "Latest Released Version: $VERSION" - echo "version=$VERSION" >> $GITHUB_OUTPUT - - echo "Latest Released Tag name: $TAG_NAME" - echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT - else - echo "Release Version: ${{ inputs.version }}" - echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT - fi - npm: name: Publish NPM runs-on: ubuntu-22.04 needs: setup - env: - _VERSION: ${{ needs.setup.outputs.release-version }} steps: - name: Checkout repo uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - with: - ref: ${{ needs.setup.outputs.tag_name }} - name: Setup Node uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version: 20 - - - name: Login to Azure - uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 - with: - creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} - - - name: Retrieve secrets - id: retrieve-secrets - uses: bitwarden/gh-actions/get-keyvault-secrets@main - with: - keyvault: "bitwarden-ci" - secrets: "npm-api-key" + registry-url: "https://npm.pkg.github.com" - name: Download artifact - run: | - wget https://github.com/bitwarden/sdk/releases/download/sdk-internal-v${{ env._VERSION }}/sdk-internal.zip - unzip sdk-internal.zip - rm sdk-internal.zip - - - name: Create GitHub deployment - if: ${{ inputs.release_type != 'Dry Run' }} - uses: chrnorm/deployment-action@55729fcebec3d284f60f5bcabbd8376437d696b1 # v2.0.7 - id: deployment + uses: bitwarden/gh-actions/download-artifacts@main with: - token: "${{ secrets.GITHUB_TOKEN }}" - initial-status: "in_progress" - environment: "Bitwarden SDK Internal - Production" - description: "Deployment ${{ env._VERSION }} from branch ${{ github.ref_name }}" - task: release - - - name: Setup NPM - run: | - echo 'registry="https://registry.npmjs.org/"' > ./.npmrc - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ./.npmrc - - echo 'registry="https://registry.npmjs.org/"' > ~/.npmrc - echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc - env: - NPM_TOKEN: ${{ steps.retrieve-secrets.outputs.npm-api-key }} + workflow: build-wasm-internal.yml + workflow_conclusion: success + branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} + artifacts: sdk-internal - name: Publish NPM if: ${{ inputs.release_type != 'Dry Run' }} - run: npm publish --access public --registry=https://registry.npmjs.org/ --userconfig=./.npmrc - - - name: Update deployment status to Success - if: ${{ inputs.release_type != 'Dry Run' && success() }} - uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 - with: - token: "${{ secrets.GITHUB_TOKEN }}" - state: "success" - deployment-id: ${{ steps.deployment.outputs.deployment_id }} - - - name: Update deployment status to Failure - if: ${{ inputs.release_type != 'Dry Run' && failure() }} - uses: chrnorm/deployment-status@9a72af4586197112e0491ea843682b5dc280d806 # v2.0.3 - with: - token: "${{ secrets.GITHUB_TOKEN }}" - state: "failure" - deployment-id: ${{ steps.deployment.outputs.deployment_id }} + run: npm publish --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + working-directory: languages/js/sdk-internal diff --git a/crates/bitwarden-wasm-internal/build.sh b/crates/bitwarden-wasm-internal/build.sh index aa8426c59..b02ee1ea1 100755 --- a/crates/bitwarden-wasm-internal/build.sh +++ b/crates/bitwarden-wasm-internal/build.sh @@ -6,12 +6,10 @@ if [ "$1" != "-r" ]; then # Dev cargo build -p bitwarden-wasm-internal --target wasm32-unknown-unknown wasm-bindgen --target bundler --out-dir languages/js/sdk-internal ./target/wasm32-unknown-unknown/debug/bitwarden_wasm_internal.wasm - wasm-bindgen --target nodejs --out-dir languages/js/sdk-internal/node ./target/wasm32-unknown-unknown/debug/bitwarden_wasm_internal.wasm else # Release cargo build -p bitwarden-wasm-internal --target wasm32-unknown-unknown --release wasm-bindgen --target bundler --out-dir languages/js/sdk-internal ./target/wasm32-unknown-unknown/release/bitwarden_wasm_internal.wasm - wasm-bindgen --target nodejs --out-dir languages/js/sdk-internal/node ./target/wasm32-unknown-unknown/release/bitwarden_wasm_internal.wasm fi # Format @@ -19,7 +17,6 @@ npx prettier --write ./languages/js/sdk-internal # Optimize size wasm-opt -Os ./languages/js/sdk-internal/bitwarden_wasm_internal_bg.wasm -o ./languages/js/sdk-internal/bitwarden_wasm_internal_bg.wasm -wasm-opt -Os ./languages/js/sdk-internal/node/bitwarden_wasm_internal_bg.wasm -o ./languages/js/sdk-internal/node/bitwarden_wasm_internal_bg.wasm # Transpile to JS wasm2js ./languages/js/sdk-internal/bitwarden_wasm_internal_bg.wasm -o ./languages/js/sdk-internal/bitwarden_wasm_internal_bg.wasm.js From e0a4c2e14f4353a89ba81de407eacb628cf24394 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 4 Oct 2024 11:29:31 +0200 Subject: [PATCH 199/214] Set version when publishing (#1112) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/publish-internal.yml | 7 ++++++- languages/js/sdk-internal/package.json | 7 +------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish-internal.yml b/.github/workflows/publish-internal.yml index 7d0ceb198..915b0bfe4 100644 --- a/.github/workflows/publish-internal.yml +++ b/.github/workflows/publish-internal.yml @@ -61,9 +61,14 @@ jobs: branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} artifacts: sdk-internal + - name: Set version + run: | + npm version --no-git-tag-version ${{ inputs.version }} + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish NPM if: ${{ inputs.release_type != 'Dry Run' }} run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - working-directory: languages/js/sdk-internal diff --git a/languages/js/sdk-internal/package.json b/languages/js/sdk-internal/package.json index 94b678141..4ce87a3c1 100644 --- a/languages/js/sdk-internal/package.json +++ b/languages/js/sdk-internal/package.json @@ -8,13 +8,8 @@ "bitwarden_wasm_internal_bg.wasm.js", "bitwarden_wasm_internal.d.ts", "bitwarden_wasm_internal.js", - "index.js", - "node/bitwarden_wasm_internal.wasm", - "node/bitwarden_wasm_internal.wasm.d.ts", - "node/bitwarden_wasm_internal.d.ts", - "node/bitwarden_wasm_internal.js" + "index.js" ], - "main": "node/bitwarden_wasm_internal.js", "module": "index.js", "types": "bitwarden_wasm_internal.d.ts", "scripts": {}, From bb93c233314b889c1b53fb3b9b62a106ef68578f Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 4 Oct 2024 13:40:45 +0200 Subject: [PATCH 200/214] Switch to using npm for sdk-internal (#1113) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective It's a hassle to consume an package published on GitHub Packages in GitHub Actions as you need a PAT. Proposing we switch to publishing on npm instead. ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/publish-internal.yml | 27 ++- languages/js/sdk-internal/LICENSE | 295 +++++++++++++++++++++++++ languages/js/sdk-internal/README.md | 3 + languages/js/sdk-internal/package.json | 1 + 4 files changed, 322 insertions(+), 4 deletions(-) create mode 100644 languages/js/sdk-internal/LICENSE create mode 100644 languages/js/sdk-internal/README.md diff --git a/.github/workflows/publish-internal.yml b/.github/workflows/publish-internal.yml index 915b0bfe4..6df0b844c 100644 --- a/.github/workflows/publish-internal.yml +++ b/.github/workflows/publish-internal.yml @@ -51,7 +51,18 @@ jobs: uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version: 20 - registry-url: "https://npm.pkg.github.com" + + - name: Login to Azure + uses: Azure/login@e15b166166a8746d1a47596803bd8c1b595455cf # v1.6.0 + with: + creds: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} + + - name: Retrieve secrets + id: retrieve-secrets + uses: bitwarden/gh-actions/get-keyvault-secrets@main + with: + keyvault: "bitwarden-ci" + secrets: "npm-api-key" - name: Download artifact uses: bitwarden/gh-actions/download-artifacts@main @@ -67,8 +78,16 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Setup NPM + run: | + echo 'registry="https://registry.npmjs.org/"' > ./.npmrc + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ./.npmrc + + echo 'registry="https://registry.npmjs.org/"' > ~/.npmrc + echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc + env: + NPM_TOKEN: ${{ steps.retrieve-secrets.outputs.npm-api-key }} + - name: Publish NPM if: ${{ inputs.release_type != 'Dry Run' }} - run: npm publish --access public - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: npm publish --access public --registry=https://registry.npmjs.org/ --userconfig=./.npmrc diff --git a/languages/js/sdk-internal/LICENSE b/languages/js/sdk-internal/LICENSE new file mode 100644 index 000000000..e9d496ff7 --- /dev/null +++ b/languages/js/sdk-internal/LICENSE @@ -0,0 +1,295 @@ +BITWARDEN SOFTWARE DEVELOPMENT KIT LICENSE AGREEMENT +Version 1, 17 March 2023 + +1. Introduction + +1.1 The Bitwarden Software Development Kit (referred to in the License Agreement +as the "SDK" and available for download at the following URL +https://github.com/bitwarden/sdk) is licensed to you subject to the terms of +this License Agreement. The License Agreement forms a legally binding contract +between you and the Company in relation to your use of the SDK. + +1.2 "Bitwarden" means the Bitwarden software made available by the Company, +available for download at the following URL, as updated from time to time. + +1.3 A "Compatible Application" means any software program or service that (i) +connects to and interoperates with a current version of the Bitwarden server +products distributed by the Company; and (ii) complies with the Company’s +acceptable use policy available at the following URL: +https://bitwarden.com/terms/#acceptable_use. + +1.4 "Company" means Bitwarden Inc., organized under the laws of the State of +Delaware. + +2. Accepting this License Agreement + +2.1 In order to access or use the SDK, you must first agree to the License +Agreement. You may not access or use the SDK if you do not accept the License +Agreement. + +2.2 By clicking to accept and/or accessing or using the SDK, you hereby agree to +the terms of the License Agreement. + +2.3 You may not access or use the SDK and may not accept the License Agreement +if you are a person barred from receiving the SDK under the laws of the United +States or other countries, including the country in which you are resident or +from which you access or use the SDK. + +2.4 If you are agreeing to be bound by the License Agreement on behalf of your +employer or any other entity, you represent and warrant that you have full legal +authority to bind your employer or such other entity to the License Agreement. +If you do not have the requisite authority, you may not accept the License +Agreement or you may not access or use the SDK on behalf of your employer or +other entity. + +3. SDK License from Bitwarden + +3.1 Subject to the terms of this License Agreement, Bitwarden grants you a +limited, worldwide, royalty-free, non-assignable, non-exclusive, and +non-sublicensable license to use the SDK solely (a) to develop, test, and +demonstrate a Compatible Application; (b) to develop, test, and run a Compatible +Application for personal use by your family; or (c) to to develop, test, and run +a Compatible Application for the internal business operations of your +organization in connection with a paid license for a Bitwarden server product, +provided that in no case above may the Compatible Application be offered, +licensed, or sold to a third party. + +3.2 You agree that Bitwarden or third parties own all legal right, title and +interest in and to the SDK, including any Intellectual Property Rights that +subsist in the SDK. "Intellectual Property Rights" means any and all rights +under patent law, copyright law, trade secret law, trademark law, and any and +all other proprietary rights. Bitwarden reserves all rights not expressly +granted to you. + +3.3 You may not use this SDK to develop applications for use with software other +than Bitwarden (including non-compatible implementations of Bitwarden) or to +develop another SDK. + +3.4 You may not use the SDK for any purpose not expressly permitted by the +License Agreement. Except for contributions to Bitwarden pursuant to the +Contribution License Agreement available at this URL: +https://cla-assistant.io/bitwarden/clients, or to the extent required by +applicable third party licenses, you may not copy modify, adapt, redistribute, +decompile, reverse engineer, disassemble, or create derivative works of the SDK +or any part of the SDK. + +3.5 Use, reproduction, and distribution of a component of the SDK licensed under +an open source software license are governed solely by the terms of that open +source software license and not the License Agreement. + +3.6 You agree that the form and nature of the SDK that the Company provides may +change without prior notice to you and that future versions of the SDK may be +incompatible with applications developed on previous versions of the SDK. You +agree that the Company may stop (permanently or temporarily) providing the SDK +or any features within the SDK to you or to users generally at the Company’s +sole discretion, without prior notice to you. + +3.7 Nothing in the License Agreement gives you a right to use any of the +Company’s trade names, trademarks, service marks, logos, domain names, or other +distinctive brand features. + +3.8 You agree that you will not remove, obscure, or alter any proprietary rights +notices (including copyright and trademark notices) that may be affixed to or +contained within the SDK. + +4. Use of the SDK by You + +4.1 The Company agrees that it obtains no right, title, or interest from you (or +your licensors) under the License Agreement in or to any software applications +that you develop using the SDK, including any Intellectual Property Rights that +subsist in those applications. + +4.2 You agree to use the SDK and write applications only for purposes that are +permitted by (a) the License Agreement and (b) any applicable law, regulation or +generally accepted practices or guidelines in the relevant jurisdictions +(including any laws regarding the export of data or software to and from the +United States or other relevant countries). + +4.3 You agree that if you use the SDK to develop applications for other users, +you will protect the privacy and legal rights of those users. If the users +provide you with user names, passwords, or other login information or personal +information, you must make the users aware that the information will be +available to your application, and you must provide legally adequate privacy +notice and protection for those users. If your application stores personal or +sensitive information provided by users, it must do so securely. If the user +provides your application with Bitwarden Account information, your application +may only use that information to access the user's Bitwarden Account when, and +for the limited purposes for which, the user has given you permission to do so. + +4.4 You agree that you will not engage in any activity with the SDK, including +the development or distribution of an application, that interferes with, +disrupts, damages, or accesses in an unauthorized manner the servers, networks, +or other properties or services of any third party including, but not limited +to, the Company, or any mobile communications carrier or public cloud service. + +4.5 If you use the SDK to retrieve a user's data from Bitwarden, you acknowledge +and agree that you shall retrieve data only with the user's explicit consent and +only when, and for the limited purposes for which, the user has given you +permission to do so. + +4.6 You agree that you are solely responsible for, and that the Company has no +responsibility to you or to any third party for, any data, content, or resources +that you create, transmit or display through Bitwarden and/or applications for +Bitwarden, and for the consequences of your actions (including any loss or +damage which Bitwarden may suffer) by doing so. + +4.7 You agree that you are solely responsible for, and that the Company has no +responsibility to you or to any third party for, any breach of your obligations +under the License Agreement, any applicable third party contract or Terms of +Service, or any applicable law or regulation, and for the consequences +(including any loss or damage which the Company or any third party may suffer) +of any such breach. + +5. Third Party Applications + +5.1 If you use the SDK to integrate or run applications developed by a third +party or that access data, content or resources provided by a third party, you +agree that the Company is not responsible for those applications, data, content, +or resources. You understand that all data, content or resources which you may +access through such third party applications are the sole responsibility of the +person from which they originated and that the Company is not liable for any +loss or damage that you may experience as a result of the use or access of any +of those third party applications, data, content, or resources. + +5.2 You should be aware that the data, content, and resources presented to you +through such a third party application may be protected by intellectual property +rights which are owned by the providers (or by other persons or companies on +their behalf). You acknowledge that your use of such third party applications, +data, content, or resources may be subject to separate terms between you and the +relevant third party. In that case, the License Agreement does not affect your +legal relationship with these third parties. + +6. Use of Bitwarden Server + +You acknowledge and agree that the Bitwarden server products to which any +Compatible Application must connect is protected by intellectual property rights +which are owned by the Company and your use of the Bitwarden server products is +subject to additional terms not set forth in this License Agreement. + +7. Terminating this License Agreement + +7.1 The License Agreement will continue to apply until terminated by either you +or the Company as set out below. + +7.2 If you want to terminate the License Agreement, you may do so by ceasing +your use of the SDK and any relevant developer credentials. + +7.3 The Company may at any time, terminate the License Agreement with you if: + +(a) you have breached any provision of the License Agreement; or + +(b) the Company is required to do so by law; or + +(c) a third party with whom the Company offered certain parts of the SDK to you +has terminated its relationship with the Company or ceased to offer certain +parts of the SDK to either the Company or to you; or + +(d) the Company decides to no longer provide the SDK or certain parts of the SDK +to users in the country in which you are resident or from which you use the +service, or the provision of the SDK or certain SDK services to you by the +Company is, in the Company’'s sole discretion, no longer commercially viable or +technically practicable. + +7.4 When the License Agreement comes to an end, all of the legal rights, +obligations and liabilities that you and the Company have benefited from, been +subject to (or which have accrued over time whilst the License Agreement has +been in force) or which are expressed to continue indefinitely, shall be +unaffected by this cessation, and the provisions of paragraph 12.8 shall +continue to apply to such rights, obligations and liabilities indefinitely. + +8. NO SUPPORT + +The Company is not obligated under this License Agreement to provide you any +support services for the SDK. Any support provided is at the Company’s sole +discretion and provided on an "as is" basis and without warranty of any kind. + +9. DISCLAIMER OF WARRANTIES + +9.1 YOU EXPRESSLY UNDERSTAND AND AGREE THAT YOUR USE OF THE SDK IS AT YOUR SOLE +RISK AND THAT THE SDK IS PROVIDED "AS IS" AND "AS AVAILABLE" WITHOUT WARRANTY OF +ANY KIND FROM Bitwarden. + +9.2 YOUR USE OF THE SDK AND ANY MATERIAL DOWNLOADED OR OTHERWISE OBTAINED +THROUGH THE USE OF THE SDK IS AT YOUR OWN DISCRETION AND RISK AND YOU ARE SOLELY +RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF +DATA THAT RESULTS FROM SUCH USE. + +9.3 THE COMPANY FURTHER EXPRESSLY DISCLAIMS ALL WARRANTIES AND CONDITIONS OF ANY +KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED +WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE +AND NON-INFRINGEMENT. + +10. LIMITATION OF LIABILITY + +YOU EXPRESSLY UNDERSTAND AND AGREE THAT THE COMPANY, ITS SUBSIDIARIES AND +AFFILIATES, AND ITS LICENSORS SHALL NOT BE LIABLE TO YOU UNDER ANY THEORY OF +LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL, +STATUTORY, OR EXEMPLARY DAMAGES THAT MAY BE INCURRED BY YOU, INCLUDING ANY LOSS +OF DATA, WHETHER OR NOT THE COMPANY OR ITS REPRESENTATIVES HAVE BEEN ADVISED OF +OR SHOULD HAVE BEEN AWARE OF THE POSSIBILITY OF ANY SUCH LOSSES ARISING. + +11. Indemnification + +To the maximum extent permitted by law, you agree to defend, indemnify and hold +harmless the Company, its affiliates and their respective directors, officers, +employees and agents from and against any and all claims, actions, suits or +proceedings, as well as any and all losses, liabilities, damages, costs and +expenses (including reasonable attorneys fees) arising out of or accruing from +(a) your use of the SDK, (b) any application you develop on the SDK that +infringes any copyright, trademark, trade secret, trade dress, patent or other +intellectual property right of any person or defames any person or violates +their rights of publicity or privacy, and (c) any non-compliance by you with the +License Agreement. + +12. General Legal Terms + +12.1 The Company may make changes to the License Agreement as it distributes new +versions of the SDK. When these changes are made, the Company will make a new +version of the License Agreement available on the website where the SDK is made +available. + +12.2 The License Agreement constitutes the whole legal agreement between you and +the Company and governs your use of the SDK (excluding any services or software +which the Company may provide to you under a separate written agreement), and +completely replaces any prior agreements between you and the Company in relation +to the SDK. + +12.3 You agree that if the Company does not exercise or enforce any legal right +or remedy which is contained in the License Agreement (or which the Company has +the benefit of under any applicable law), this will not be taken to be a formal +waiver of the Company's rights and that those rights or remedies will still be +available to the Company. + +12.4 If any court of law, having the jurisdiction to decide on this matter, +rules that any provision of the License Agreement is invalid, then that +provision will be removed from the License Agreement without affecting the rest +of the License Agreement. The remaining provisions of the License Agreement will +continue to be valid and enforceable. + +12.5 You acknowledge and agree that each member of the group of companies of +which the Company is the parent shall be third party beneficiaries to the +License Agreement and that such other companies shall be entitled to directly +enforce, and rely upon, any provision of the License Agreement that confers a +benefit on them or rights in favor of them. Other than this, no other person or +company shall be third party beneficiaries to the License Agreement. + +12.6 EXPORT RESTRICTIONS. THE SDK IS SUBJECT TO UNITED STATES EXPORT LAWS AND +REGULATIONS. YOU MUST COMPLY WITH ALL DOMESTIC AND INTERNATIONAL EXPORT LAWS AND +REGULATIONS THAT APPLY TO THE SDK. THESE LAWS INCLUDE RESTRICTIONS ON +DESTINATIONS, END USERS, AND END USE. + +12.7 The rights granted in the License Agreement may not be assigned or +transferred by either you or the Company without the prior written approval of +the other party, provided that the Company may assign this License Agreement +upon notice to you in connection with an acquisition, merger, sale of assets, or +similar corporate change in control for the Company or the Intellectual Property +Rights in the SDK. + +12.8 The License Agreement, and any dispute relating to or arising out of this +License Agreement, shall be governed by the laws of the State of California +without regard to its conflict of laws provisions. You and the Company agree to +submit to the exclusive jurisdiction of the courts located within the county of +Los Angeles, California to resolve any dispute or legal matter arising from the +License Agreement. Notwithstanding this, you agree that the Company shall be +allowed to apply for injunctive remedies, or any equivalent type of urgent legal +relief, in any forum or jurisdiction. diff --git a/languages/js/sdk-internal/README.md b/languages/js/sdk-internal/README.md new file mode 100644 index 000000000..9391aa071 --- /dev/null +++ b/languages/js/sdk-internal/README.md @@ -0,0 +1,3 @@ +# @bitwarden/sdk-internal + +**Note:** This is only for internal use. Bitwarden will not provide any support for this package. diff --git a/languages/js/sdk-internal/package.json b/languages/js/sdk-internal/package.json index 4ce87a3c1..51cfa577c 100644 --- a/languages/js/sdk-internal/package.json +++ b/languages/js/sdk-internal/package.json @@ -1,6 +1,7 @@ { "name": "@bitwarden/sdk-internal", "version": "0.1.0", + "license": "SEE LICENSE IN LICENSE", "files": [ "bitwarden_wasm_internal_bg.js", "bitwarden_wasm_internal_bg.wasm", From 5dd990954004e4e0e2c04553f632a1d1d6c02cd4 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 4 Oct 2024 14:24:14 +0200 Subject: [PATCH 201/214] Ensure the built files are added to published (#1114) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .github/workflows/publish-internal.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish-internal.yml b/.github/workflows/publish-internal.yml index 6df0b844c..13f3a9d97 100644 --- a/.github/workflows/publish-internal.yml +++ b/.github/workflows/publish-internal.yml @@ -71,6 +71,7 @@ jobs: workflow_conclusion: success branch: ${{ inputs.release_type == 'Dry Run' && 'main' || github.ref_name }} artifacts: sdk-internal + path: languages/js/sdk-internal - name: Set version run: | From 16a8496bfb62d78c9692a44515f63e73248e7aab Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 4 Oct 2024 17:04:39 +0200 Subject: [PATCH 202/214] Publish node compatible sdk (#1115) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- crates/bitwarden-wasm-internal/build.sh | 2 ++ languages/js/sdk-internal/package.json | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/bitwarden-wasm-internal/build.sh b/crates/bitwarden-wasm-internal/build.sh index b02ee1ea1..109037e89 100755 --- a/crates/bitwarden-wasm-internal/build.sh +++ b/crates/bitwarden-wasm-internal/build.sh @@ -6,10 +6,12 @@ if [ "$1" != "-r" ]; then # Dev cargo build -p bitwarden-wasm-internal --target wasm32-unknown-unknown wasm-bindgen --target bundler --out-dir languages/js/sdk-internal ./target/wasm32-unknown-unknown/debug/bitwarden_wasm_internal.wasm + wasm-bindgen --target nodejs --out-dir languages/js/sdk-internal/node ./target/wasm32-unknown-unknown/debug/bitwarden_wasm_internal.wasm else # Release cargo build -p bitwarden-wasm-internal --target wasm32-unknown-unknown --release wasm-bindgen --target bundler --out-dir languages/js/sdk-internal ./target/wasm32-unknown-unknown/release/bitwarden_wasm_internal.wasm + wasm-bindgen --target nodejs --out-dir languages/js/sdk-internal/node ./target/wasm32-unknown-unknown/release/bitwarden_wasm_internal.wasm fi # Format diff --git a/languages/js/sdk-internal/package.json b/languages/js/sdk-internal/package.json index 51cfa577c..29e5c5a54 100644 --- a/languages/js/sdk-internal/package.json +++ b/languages/js/sdk-internal/package.json @@ -9,8 +9,13 @@ "bitwarden_wasm_internal_bg.wasm.js", "bitwarden_wasm_internal.d.ts", "bitwarden_wasm_internal.js", - "index.js" + "index.js", + "node/bitwarden_wasm_internal_bg.wasm", + "node/bitwarden_wasm_internal_bg.wasm.d.ts", + "node/bitwarden_wasm_internal.d.ts", + "node/bitwarden_wasm_internal.js" ], + "main": "node/bitwarden_wasm_internal.js", "module": "index.js", "types": "bitwarden_wasm_internal.d.ts", "scripts": {}, From 3db0850ad83b802745251cfd25d42cb43a8b601f Mon Sep 17 00:00:00 2001 From: Bitwarden DevOps <106330231+bitwarden-devops-bot@users.noreply.github.com> Date: Mon, 7 Oct 2024 13:27:11 -0600 Subject: [PATCH 203/214] Bump go-sdk version to 1.0.2 (#1118) ## Type of change - [ ] Bug fix - [ ] New feature development - [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [X] Other ## Objective Automated go-sdk version bump to 1.0.2 --- languages/go/.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/go/.version b/languages/go/.version index 7f207341d..e6d5cb833 100644 --- a/languages/go/.version +++ b/languages/go/.version @@ -1 +1 @@ -1.0.1 \ No newline at end of file +1.0.2 \ No newline at end of file From a76013c44829874ab0f8e20ba733693c3d9256ca Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:46:50 -0400 Subject: [PATCH 204/214] [deps]: Update System.Text.Json to 8.0.5 [SECURITY] (#1121) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [System.Text.Json](https://dot.net/) ([source](https://redirect.github.com/dotnet/runtime)) | `8.0.4` -> `8.0.5` | [![age](https://developer.mend.io/api/mc/badges/age/nuget/System.Text.Json/8.0.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/nuget/System.Text.Json/8.0.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/nuget/System.Text.Json/8.0.4/8.0.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/nuget/System.Text.Json/8.0.4/8.0.5?slim=true)](https://docs.renovatebot.com/merge-confidence/) | ### GitHub Vulnerability Alerts #### [CVE-2024-43485](https://redirect.github.com/dotnet/runtime/security/advisories/GHSA-8g4q-xg66-9fp4) # Microsoft Security Advisory CVE-2024-43485 | .NET Denial of Service Vulnerability ## Executive summary Microsoft is releasing this security advisory to provide information about a vulnerability in System.Text.Json 6.0.x and 8.0.x. This advisory also provides guidance on what developers can do to update their applications to remove this vulnerability. In System.Text.Json 6.0.x and 8.0.x, applications which deserialize input to a model with an `[ExtensionData]` property can be vulnerable to an algorithmic complexity attack resulting in Denial of Service. ## Announcement Announcement for this issue can be found at [https://github.com/dotnet/announcements/issues/329](https://redirect.github.com/dotnet/announcements/issues/329) ## Mitigation factors JSON models which do not utilize the `[ExtensionData]` feature are not impacted by this vulnerability. ## Affected software * Any .NET 8.0 application running on .NET 8.0.8 or earlier. * Any .NET 6.0 aplication running on .NET 6.0.33 or earlier. * Any application consuming one of the [vulnerable packages](affected-packages). ## Affected Packages The vulnerability affects any Microsoft .NET Core project if it uses any of affected packages versions listed below ### .NET 8 Package name | Affected version | Patched version ------------ | ---------------- | ------------------------- [System.Text.Json](https://www.nuget.org/packages/System.Text.Json) | >= 8.0.0, <= 8.0.4 | 8.0.5 ### .NET 6 Package name | Affected version | Patched version ------------ | ---------------- | ------------------------- [System.Text.Json](https://www.nuget.org/packages/System.Text.Json) | >= 6.0.0, <= 6.0.9 | 6.0.10 ## Advisory FAQ ### How do I know if I am affected? If you have a runtime or SDK with a version listed, or an affected package listed in [affected software](#affected-packages) or [affected packages](#affected-software), you're exposed to the vulnerability. ### How do I fix the issue? * To fix the issue please install the latest version of .NET 8.0 or .NET 6.0. If you have installed one or more .NET SDKs through Visual Studio, Visual Studio will prompt you to update Visual Studio, which will also update your .NET SDKs. * .NET Framework-based applications and other application types need to perform a package update. * If you have .NET 6.0 or greater installed, you can list the versions you have installed by running the `dotnet --info` command. You will see output like the following; ``` .NET Core SDK (reflecting any global.json): Version: 8.0.200 Commit: 8473146e7d Runtime Environment: OS Name: Windows OS Version: 10.0.18363 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.300\ Host (useful for support): Version: 8.0.3 Commit: 8473146e7d .NET Core SDKs installed: 8.0.200 [C:\Program Files\dotnet\sdk] .NET Core runtimes installed: Microsoft.AspAspNetCore.App 8.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspAspNetCore.App] Microsoft.AspNetCore.App 8.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.WindowsDesktop.App 8.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download ``` * If you're using .NET 6.0, you should download and install .NET 6.0.35 Runtime or .NET 6.0.135 SDK (for Visual Studio 2022 v17.6) from https://dotnet.microsoft.com/download/dotnet-core/6.0. * If you're using .NET 8.0, you should download and install .NET 8.0.10 Runtime or .NET 8.0.110 SDK (for Visual Studio 2022 v17.8) from https://dotnet.microsoft.com/download/dotnet-core/8.0. .NET 8.0 and .NET 6.0 updates are also available from Microsoft Update. To access this either type "Check for updates" in your Windows search, or open Settings, choose Update & Security and then click Check for Updates. Once you have installed the updated runtime or SDK, restart your apps for the update to take effect. Additionally, if you've deployed [self-contained applications](https://docs.microsoft.com/dotnet/core/deploying/#self-contained-deployments-scd) targeting any of the impacted versions, these applications are also vulnerable and must be recompiled and redeployed. ## Other Information ### Reporting Security Issues If you have found a potential security issue in .NET 8.0 or .NET 6.0, please email details to secure@microsoft.com. Reports may qualify for the Microsoft .NET Core & .NET 5 Bounty. Details of the Microsoft .NET Bounty Program including terms and conditions are at . ### Support You can ask questions about this issue on GitHub in the .NET GitHub organization. The main repos are located at https://github.com/dotnet/runtime and https://github.com/dotnet/aspnet/. The Announcements repo (https://github.com/dotnet/Announcements) will contain this bulletin as an issue and will include a link to a discussion issue. You can ask questions in the linked discussion issue. ### Disclaimer The information provided in this advisory is provided "as is" without warranty of any kind. Microsoft disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. In no event shall Microsoft Corporation or its suppliers be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages, even if Microsoft Corporation or its suppliers have been advised of the possibility of such damages. Some states do not allow the exclusion or limitation of liability for consequential or incidental damages so the foregoing limitation may not apply. ### External Links [CVE-2024-43485]( https://www.cve.org/CVERecord?id=CVE-2024-43485) ### Revisions V1.0 (October 08, 2024): Advisory published. _Version 1.0_ _Last Updated 2024-10-08_ --- ### Release Notes
dotnet/runtime (System.Text.Json) ### [`v8.0.5`](https://redirect.github.com/dotnet/runtime/releases/tag/v8.0.5): .NET 8.0.5 [Release](https://redirect.github.com/dotnet/core/releases/tag/v8.0.5) #### What's Changed - \[release/8.0-staging] Fix AsyncVoidMethodBuilder race condition around SynchronizationContext by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/99640](https://redirect.github.com/dotnet/runtime/pull/99640) - \[release/8.0-staging] Always keep global symbols on ApplePlatforms by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/99650](https://redirect.github.com/dotnet/runtime/pull/99650) - \[release/8.0-staging] Delete Decrypt_Pkcs1\_ErrorsForInvalidPadding by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/99653](https://redirect.github.com/dotnet/runtime/pull/99653) - \[8.0] Rename MSBuild property MicrosoftNativeQuicMsQuicVersion -> MicrosoftNativeQuicMsQuicSchannelVersion by [@​carlossanlop](https://redirect.github.com/carlossanlop) in [https://github.com/dotnet/runtime/pull/99714](https://redirect.github.com/dotnet/runtime/pull/99714) - \[release/8.0] Fixing SignedXml.CheckSignature for enveloped signature with `#xpointer(/)` Reference by [@​bartonjs](https://redirect.github.com/bartonjs) in [https://github.com/dotnet/runtime/pull/99651](https://redirect.github.com/dotnet/runtime/pull/99651) - \[release/8.0-staging] disable optimizations for PopCount by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/99832](https://redirect.github.com/dotnet/runtime/pull/99832) - \[release/8.0-staging] Handle NativeOverlapped\* coming from both the Windows or Portable thread pool in NativeRuntimeEventSource by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/99656](https://redirect.github.com/dotnet/runtime/pull/99656) - \[release/8.0-staging] Fix exporting certificate keys on macOS 14.4. by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/99776](https://redirect.github.com/dotnet/runtime/pull/99776) - \[release/8.0] Upgrade zlib to 1.3.1 by [@​carlossanlop](https://redirect.github.com/carlossanlop) in [https://github.com/dotnet/runtime/pull/99473](https://redirect.github.com/dotnet/runtime/pull/99473) - \[release/8.0] Fix failing CertificateValidationRemoteServer.ConnectWithRevocation_WithCallback test ([#​99915](https://redirect.github.com/dotnet/runtime/issues/99915)) by [@​rzikm](https://redirect.github.com/rzikm) in [https://github.com/dotnet/runtime/pull/99950](https://redirect.github.com/dotnet/runtime/pull/99950) - \[mono] Stop exporting ICU symbols from Mono by [@​matouskozak](https://redirect.github.com/matouskozak) in [https://github.com/dotnet/runtime/pull/99449](https://redirect.github.com/dotnet/runtime/pull/99449) - \[release/8.0-staging] Fix AV in HttpTelemetry.WriteEvent by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/99607](https://redirect.github.com/dotnet/runtime/pull/99607) - \[release/8.0-staging] \[HTTP/2] Fix handling of effectively empty DATA frame ([#​99502](https://redirect.github.com/dotnet/runtime/issues/99502)) by [@​ManickaP](https://redirect.github.com/ManickaP) in [https://github.com/dotnet/runtime/pull/99677](https://redirect.github.com/dotnet/runtime/pull/99677) - \[release/8.0-staging] \[HttpStress] \[SslStress] Workaround image bug in 1es-windows-2022-open by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/100303](https://redirect.github.com/dotnet/runtime/pull/100303) - \[release/8.0-staging] Support building against clang 18 by [@​omajid](https://redirect.github.com/omajid) in [https://github.com/dotnet/runtime/pull/100258](https://redirect.github.com/dotnet/runtime/pull/100258) - \[release/8.0]\[browser] WebSocket works differently depending on if we look up its state or not by [@​ilonatommy](https://redirect.github.com/ilonatommy) in [https://github.com/dotnet/runtime/pull/99673](https://redirect.github.com/dotnet/runtime/pull/99673) - \[release/8.0-staging] Call the Copy Constructor for stack arguments in C++/CLI on x86 by [@​AaronRobinsonMSFT](https://redirect.github.com/AaronRobinsonMSFT) in [https://github.com/dotnet/runtime/pull/100221](https://redirect.github.com/dotnet/runtime/pull/100221) - \[release/8.0] Don't unset ALPN list pointer during ALPN selection callback. by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/99670](https://redirect.github.com/dotnet/runtime/pull/99670) - \[release/8.0-staging]\[mono]\[debugger] Fix inspect Span by [@​thaystg](https://redirect.github.com/thaystg) in [https://github.com/dotnet/runtime/pull/99844](https://redirect.github.com/dotnet/runtime/pull/99844) - Update branding to 8.0.5 by [@​vseanreesermsft](https://redirect.github.com/vseanreesermsft) in [https://github.com/dotnet/runtime/pull/100547](https://redirect.github.com/dotnet/runtime/pull/100547) - \[release/8.0-staging] Ensure that Sse3.MoveAndDuplicate correctly tracks supporting SIMD scalar loads by [@​tannergooding](https://redirect.github.com/tannergooding) in [https://github.com/dotnet/runtime/pull/100417](https://redirect.github.com/dotnet/runtime/pull/100417) - \[release/8.0] Avoid allocating collectible instances in the frozen heap ([#​100444](https://redirect.github.com/dotnet/runtime/issues/100444)) by [@​jkotas](https://redirect.github.com/jkotas) in [https://github.com/dotnet/runtime/pull/100509](https://redirect.github.com/dotnet/runtime/pull/100509) - \[release/8.0-staging] Use clang --version to get Apple toolset version by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/100199](https://redirect.github.com/dotnet/runtime/pull/100199) - \[release/8.0-staging] Azure Linux 3.0 deps package by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/100684](https://redirect.github.com/dotnet/runtime/pull/100684) - \[release/8.0-staging] Fix Http2 deadlock by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/100086](https://redirect.github.com/dotnet/runtime/pull/100086) - Merging internal commits for release/8.0 by [@​vseanreesermsft](https://redirect.github.com/vseanreesermsft) in [https://github.com/dotnet/runtime/pull/100835](https://redirect.github.com/dotnet/runtime/pull/100835) - \[release/8.0-staging] Update CI builds to not use VS Previews by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/100622](https://redirect.github.com/dotnet/runtime/pull/100622) - \[release/8.0-staging] Update dependencies from dotnet/hotreload-utils by [@​dotnet-maestro](https://redirect.github.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/100892](https://redirect.github.com/dotnet/runtime/pull/100892) - \[release/8.0-staging] Update dependencies from dotnet/runtime-assets by [@​dotnet-maestro](https://redirect.github.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/100073](https://redirect.github.com/dotnet/runtime/pull/100073) - \[automated] Merge branch 'release/8.0' => 'release/8.0-staging' by [@​dotnet-maestro-bot](https://redirect.github.com/dotnet-maestro-bot) in [https://github.com/dotnet/runtime/pull/99585](https://redirect.github.com/dotnet/runtime/pull/99585) - \[release/8.0-staging] Update dependencies from dotnet/source-build-externals by [@​dotnet-maestro](https://redirect.github.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/99601](https://redirect.github.com/dotnet/runtime/pull/99601) - \[release/8.0-staging] Update dependencies from dotnet/xharness by [@​dotnet-maestro](https://redirect.github.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/100883](https://redirect.github.com/dotnet/runtime/pull/100883) - \[release/8.0-staging] Update dependencies from dotnet/source-build-reference-packages by [@​dotnet-maestro](https://redirect.github.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/99902](https://redirect.github.com/dotnet/runtime/pull/99902) - \[release/8.0-staging] Update dependencies from dotnet/source-build-externals by [@​dotnet-maestro](https://redirect.github.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/100015](https://redirect.github.com/dotnet/runtime/pull/100015) - \[release/8.0-staging] Update dependencies from dotnet/runtime-assets by [@​dotnet-maestro](https://redirect.github.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/100958](https://redirect.github.com/dotnet/runtime/pull/100958) - \[release/8.0-staging] Update dependencies from dotnet/arcade by [@​dotnet-maestro](https://redirect.github.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/100885](https://redirect.github.com/dotnet/runtime/pull/100885) - \[release/8.0-staging] Fix native leak in CryptoNative_GetX509nameInfo by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/100793](https://redirect.github.com/dotnet/runtime/pull/100793) - \[release/8.0-staging] Update dependencies from dotnet/emsdk by [@​dotnet-maestro](https://redirect.github.com/dotnet-maestro) in [https://github.com/dotnet/runtime/pull/99696](https://redirect.github.com/dotnet/runtime/pull/99696) - \[release/8.0-staging] \[mono]\[debugger] Search for seqpoints directly from jitinfo if it's not find on get_default_jit_mm by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/100978](https://redirect.github.com/dotnet/runtime/pull/100978) - \[release/8.0]\[browser] fix emscripten out/err overrides by [@​pavelsavara](https://redirect.github.com/pavelsavara) in [https://github.com/dotnet/runtime/pull/100818](https://redirect.github.com/dotnet/runtime/pull/100818) - \[release/8.0-staging] \[mono]\[eventpipe] Fix firing dynamic method wrappers crash by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/99712](https://redirect.github.com/dotnet/runtime/pull/99712) - Update Alpine versions for `release/8.0-staging` by [@​richlander](https://redirect.github.com/richlander) in [https://github.com/dotnet/runtime/pull/99849](https://redirect.github.com/dotnet/runtime/pull/99849) - \[release/8.0-staging] Guard against -1 Returned from sysconf for the Cache Sizes Causing Large Gen0 Sizes and Budgets for Certain Linux Distributions. by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/100575](https://redirect.github.com/dotnet/runtime/pull/100575) - \[Release/8.0] Remove preventing EH at shutdown by [@​janvorli](https://redirect.github.com/janvorli) in [https://github.com/dotnet/runtime/pull/100836](https://redirect.github.com/dotnet/runtime/pull/100836) - \[release/8.8] Add metadata for workload automation by [@​joeloff](https://redirect.github.com/joeloff) in [https://github.com/dotnet/runtime/pull/100649](https://redirect.github.com/dotnet/runtime/pull/100649) - \[8.0] Reset OOB packages enabled in the April release by [@​carlossanlop](https://redirect.github.com/carlossanlop) in [https://github.com/dotnet/runtime/pull/99583](https://redirect.github.com/dotnet/runtime/pull/99583) - \[release/8.0-staging] Always zero-init if object contains pointers by [@​VSadov](https://redirect.github.com/VSadov) in [https://github.com/dotnet/runtime/pull/100426](https://redirect.github.com/dotnet/runtime/pull/100426) - \[release/8.0-staging] JIT: Fixed incorrect reversed condition for GT by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/100372](https://redirect.github.com/dotnet/runtime/pull/100372) - \[manual] Merge release/8.0-staging into release/8.0 by [@​directhex](https://redirect.github.com/directhex) in [https://github.com/dotnet/runtime/pull/101091](https://redirect.github.com/dotnet/runtime/pull/101091) - \[release/8.0] \[release/8.0] Update MicrosoftBuildVersion to latest by [@​github-actions](https://redirect.github.com/github-actions) in [https://github.com/dotnet/runtime/pull/101145](https://redirect.github.com/dotnet/runtime/pull/101145) **Full Changelog**: https://github.com/dotnet/runtime/compare/v8.0.4...v8.0.5
--- ### Configuration 📅 **Schedule**: Branch creation - "" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- languages/csharp/Bitwarden.Sdk/Bitwarden.Sdk.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/csharp/Bitwarden.Sdk/Bitwarden.Sdk.csproj b/languages/csharp/Bitwarden.Sdk/Bitwarden.Sdk.csproj index d2363f4a9..a7c82e4b5 100644 --- a/languages/csharp/Bitwarden.Sdk/Bitwarden.Sdk.csproj +++ b/languages/csharp/Bitwarden.Sdk/Bitwarden.Sdk.csproj @@ -25,7 +25,7 @@ - + From 89b23bd85ea09f3af43a41e216cfd7fe9917b188 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2024 11:02:59 +0200 Subject: [PATCH 205/214] [deps]: Lock file maintenance (#1125) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. đŸ‘ģ **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 190 +++++++++++----------- languages/js/sdk-client/package-lock.json | 12 +- package-lock.json | 18 +- 3 files changed, 111 insertions(+), 109 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4e0d14119..5397271ce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -861,9 +861,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.22" +version = "1.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0" +checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" dependencies = [ "shlex", ] @@ -935,9 +935,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.18" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0956a43b323ac1afaffc053ed5c4b7c1f1800bacd1683c353aabbb752515dd3" +checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" dependencies = [ "clap_builder", "clap_derive", @@ -945,9 +945,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.18" +version = "4.5.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d72166dd41634086d5803a47eb71ae740e61d84709c36f3c34110173db3961b" +checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" dependencies = [ "anstream", "anstyle", @@ -957,9 +957,9 @@ dependencies = [ [[package]] name = "clap_complete" -version = "4.5.29" +version = "4.5.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8937760c3f4c60871870b8c3ee5f9b30771f792a7045c48bcbba999d7d6b3b8e" +checksum = "9646e2e245bf62f45d39a0f3f36f1171ad1ea0d6967fd114bca72cb02a8fcdfb" dependencies = [ "clap", ] @@ -984,9 +984,9 @@ checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" [[package]] name = "clap_mangen" -version = "0.2.23" +version = "0.2.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f17415fd4dfbea46e3274fcd8d368284519b358654772afb700dc2e8d2b24eeb" +checksum = "fbae9cbfdc5d4fa8711c09bd7b83f644cb48281ac35bf97af3e47b0675864bdf" dependencies = [ "clap", "roff", @@ -1414,18 +1414,18 @@ dependencies = [ [[package]] name = "derive_builder" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd33f37ee6a119146a1781d3356a7c26028f83d779b2e04ecd45fdc75c76877b" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" dependencies = [ "derive_builder_macro", ] [[package]] name = "derive_builder_core" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7431fa049613920234f22c47fdc33e6cf3ee83067091ea4277a3f8c4587aae38" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" dependencies = [ "darling", "proc-macro2", @@ -1435,9 +1435,9 @@ dependencies = [ [[package]] name = "derive_builder_macro" -version = "0.20.1" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4abae7035bf79b9877b779505d8cf3749285b80c43941eda66604841889451dc" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" dependencies = [ "derive_builder_core", "syn 2.0.79", @@ -1652,9 +1652,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -1667,9 +1667,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -1677,15 +1677,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -1694,15 +1694,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", @@ -1711,21 +1711,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -1840,7 +1840,7 @@ dependencies = [ "futures-core", "futures-sink", "http", - "indexmap 2.5.0", + "indexmap 2.6.0", "slab", "tokio", "tokio-util", @@ -1869,6 +1869,12 @@ version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" + [[package]] name = "heck" version = "0.4.1" @@ -1962,9 +1968,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -2093,12 +2099,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.14.5", + "hashbrown 0.15.0", "serde", ] @@ -2137,9 +2143,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.10.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "is-terminal" @@ -2210,9 +2216,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "0cb94a0ffd3f3ee755c20f7d8752f45cac88605a4dcf808abcff72873296ec7b" dependencies = [ "wasm-bindgen", ] @@ -2551,12 +2557,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.1" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" -dependencies = [ - "portable-atomic", -] +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "onig" @@ -2706,7 +2709,7 @@ dependencies = [ "coset", "data-encoding", "getrandom", - "indexmap 2.5.0", + "indexmap 2.6.0", "rand", "serde", "serde_json", @@ -2816,7 +2819,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" dependencies = [ "base64", - "indexmap 2.5.0", + "indexmap 2.6.0", "quick-xml", "serde", "time", @@ -2906,9 +2909,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" dependencies = [ "unicode-ident", ] @@ -3110,9 +3113,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] @@ -3159,9 +3162,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.7" +version = "0.12.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63" +checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" dependencies = [ "base64", "bytes", @@ -3287,9 +3290,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.13" +version = "0.23.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" +checksum = "415d9944693cb90382053259f89fbb077ea730ad7273047ec63b19bc9b160ba8" dependencies = [ "once_cell", "ring", @@ -3314,11 +3317,10 @@ dependencies = [ [[package]] name = "rustls-pemfile" -version = "2.1.3" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "base64", "rustls-pki-types", ] @@ -3389,9 +3391,9 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" dependencies = [ "windows-sys 0.59.0", ] @@ -3564,7 +3566,7 @@ version = "1.0.128" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.6.0", "itoa", "memchr", "ryu", @@ -3616,15 +3618,15 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.9.0" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" +checksum = "8e28bdad6db2b8340e449f7108f020b3b092e8583a9e3fb82713e1d4e71fe817" dependencies = [ "base64", "chrono", "hex", "indexmap 1.9.3", - "indexmap 2.5.0", + "indexmap 2.6.0", "serde", "serde_derive", "serde_json", @@ -3634,9 +3636,9 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.9.0" +version = "3.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" +checksum = "9d846214a9854ef724f3da161b426242d8de7c1fc7de2f89bb1efcb154dca79d" dependencies = [ "darling", "proc-macro2", @@ -3650,7 +3652,7 @@ version = "0.9.34+deprecated" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.6.0", "itoa", "ryu", "serde", @@ -4122,7 +4124,7 @@ version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ - "indexmap 2.5.0", + "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", @@ -4223,9 +4225,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" @@ -4313,9 +4315,9 @@ dependencies = [ [[package]] name = "uniffi_checksum_derive" -version = "0.28.1" +version = "0.28.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a22dbe67c1c957ac6e7611bdf605a6218aa86b0eebeb8be58b70ae85ad7d73dc" +checksum = "d2c801f0f05b06df456a2da4c41b9c2c4fdccc6b9916643c6c67275c4c9e4d07" dependencies = [ "quote", "syn 2.0.79", @@ -4507,9 +4509,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "ef073ced962d62984fb38a36e5fdc1a2b23c9e0e1fa0689bb97afa4202ef6887" dependencies = [ "cfg-if", "once_cell", @@ -4520,9 +4522,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "c4bfab14ef75323f4eb75fa52ee0a3fb59611977fd3240da19b2cf36ff85030e" dependencies = [ "bumpalo", "log", @@ -4535,9 +4537,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "65471f79c1022ffa5291d33520cbbb53b7687b01c2f8e83b57d102eed7ed479d" dependencies = [ "cfg-if", "js-sys", @@ -4547,9 +4549,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "a7bec9830f60924d9ceb3ef99d55c155be8afa76954edffbb5936ff4509474e7" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4557,9 +4559,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "4c74f6e152a76a2ad448e223b0fc0b6b5747649c3d769cc6bf45737bf97d0ed6" dependencies = [ "proc-macro2", "quote", @@ -4570,15 +4572,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "a42f6c679374623f295a8623adfe63d9284091245c3504bde47c17a3ce2777d9" [[package]] name = "wasm-bindgen-test" -version = "0.3.43" +version = "0.3.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68497a05fb21143a08a7d24fc81763384a3072ee43c44e86aad1744d6adef9d9" +checksum = "a93d2a9ae98f1af8953f6415397299d808cce0a24f6d7c613d27bd83edf98da8" dependencies = [ "console_error_panic_hook", "js-sys", @@ -4591,9 +4593,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.43" +version = "0.3.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8220be1fa9e4c889b30fd207d4906657e7e90b12e0e6b0c8b8d8709f5de021" +checksum = "fb8b294691f640bad8f2bb35a11bb28272701b1d687bd5fd661a27684e894d4d" dependencies = [ "proc-macro2", "quote", @@ -4602,9 +4604,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "44188d185b5bdcae1052d08bcbcf9091a5524038d4572cc4f4f2bb9d5554ddd9" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/languages/js/sdk-client/package-lock.json b/languages/js/sdk-client/package-lock.json index f5b6f590b..5911a3331 100644 --- a/languages/js/sdk-client/package-lock.json +++ b/languages/js/sdk-client/package-lock.json @@ -30,9 +30,9 @@ } }, "node_modules/@types/node": { - "version": "20.16.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.10.tgz", - "integrity": "sha512-vQUKgWTjEIRFCvK6CyriPH3MZYiYlNy0fKiEYHWbcoWLEgs4opurGGKlebrTLqdSMIbXImH6XExNiIyNUv3WpA==", + "version": "20.16.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.11.tgz", + "integrity": "sha512-y+cTCACu92FyA5fgQSAI8A1H429g7aSK2HsO7K4XYUWc4dY5IUz55JSDIYT6/VsOLfGy8vmvQYC2hfb0iF16Uw==", "dev": true, "license": "MIT", "dependencies": { @@ -436,9 +436,9 @@ } }, "node_modules/typescript": { - "version": "5.6.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", - "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", + "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/package-lock.json b/package-lock.json index 9ceb5ffed..3d3e16698 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,9 +19,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.25.6", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.6.tgz", - "integrity": "sha512-VBj9MYyDb9tuLq7yzqjgzt6Q+IBQLrGZfdjOekyEirZPHxXWoTSGUTMrpsfi58Up73d13NfYLv8HT9vmznjzhQ==", + "version": "7.25.7", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.25.7.tgz", + "integrity": "sha512-FjoyLe754PMiYsFaN5C94ttGiOmBNYTf6pLr4xXHAT5uctHb092PBszndLDR5XA/jghQvn4n7JMHl7dmTgbm9w==", "dev": true, "license": "MIT", "dependencies": { @@ -359,9 +359,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.7.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.4.tgz", - "integrity": "sha512-y+NPi1rFzDs1NdQHHToqeiX2TIS79SWEAw9GYhkkx8bD0ChpfqC+n2j5OXOCpzfojBEBt6DnEnnG9MY0zk1XLg==", + "version": "22.7.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.5.tgz", + "integrity": "sha512-jML7s2NAzMWc//QSJ1a3prpk78cOPchGvXJsC3C6R6PSMoooztvRVQEz89gmBTBY1SPMaqo5teB4uNHPdetShQ==", "dev": true, "license": "MIT", "peer": true, @@ -1069,9 +1069,9 @@ } }, "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", "dev": true, "license": "MIT", "dependencies": { From 4e341e55541f9c9f70c765c4a2d9ac8e98d3a750 Mon Sep 17 00:00:00 2001 From: Vince Grassia <593223+vgrassia@users.noreply.github.com> Date: Thu, 10 Oct 2024 05:46:39 -0400 Subject: [PATCH 206/214] BRE-359 - Update Build C++ workflow (#1123) --- .github/workflows/build-cpp.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build-cpp.yml b/.github/workflows/build-cpp.yml index 01222aac9..686369366 100644 --- a/.github/workflows/build-cpp.yml +++ b/.github/workflows/build-cpp.yml @@ -95,7 +95,6 @@ jobs: working-directory: languages/cpp shell: bash run: | - mv include/release/* include/ if [[ '${{ runner.os }}' == 'macOS' || '${{ runner.os }}' == 'Linux' ]]; then ls include/libbitwarden_c.* || { echo "Missing libbitwarden_c.*"; exit 1; } fi @@ -103,7 +102,6 @@ jobs: ls include/bitwarden_c.dll || { echo "Missing bitwarden_c.dll"; exit 1; } ls include/bitwarden_c.dll.lib || { echo "Missing bitwarden_c.dll.lib"; exit 1; } fi - rmdir include/release - name: Build unix working-directory: languages/cpp From 7e663e9cfa88782ccb45376690c5dca41c0b1711 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Thu, 10 Oct 2024 13:36:42 +0200 Subject: [PATCH 207/214] Remove the old doc script (#1126) --- crates/bitwarden-uniffi/README.md | 12 --- crates/bitwarden-uniffi/src/docs.rs | 49 ---------- crates/bitwarden-uniffi/src/lib.rs | 3 - crates/sdk-schemas/Cargo.toml | 6 +- crates/sdk-schemas/src/main.rs | 3 - package-lock.json | 64 ------------- package.json | 1 - support/docs/docs.ts | 139 ---------------------------- support/docs/rustdoc.ts | 12 --- support/docs/template.hbs | 91 ------------------ 10 files changed, 1 insertion(+), 379 deletions(-) delete mode 100644 crates/bitwarden-uniffi/src/docs.rs delete mode 100644 support/docs/docs.ts delete mode 100644 support/docs/rustdoc.ts delete mode 100644 support/docs/template.hbs diff --git a/crates/bitwarden-uniffi/README.md b/crates/bitwarden-uniffi/README.md index 4b2e61714..c2e4d6c45 100644 --- a/crates/bitwarden-uniffi/README.md +++ b/crates/bitwarden-uniffi/README.md @@ -1,13 +1 @@ # Bitwarden-uniffi - -## Generating documentation - -If desired we have some scripts that generates markdown documentation from the rustdoc output. - -```bash -cargo +nightly rustdoc -p bitwarden -- -Zunstable-options --output-format json -cargo +nightly rustdoc -p bitwarden-uniffi -- -Zunstable-options --output-format json -npm run schemas - -npx ts-node ./support/docs/docs.ts > doc.md -``` diff --git a/crates/bitwarden-uniffi/src/docs.rs b/crates/bitwarden-uniffi/src/docs.rs deleted file mode 100644 index 5edbc7144..000000000 --- a/crates/bitwarden-uniffi/src/docs.rs +++ /dev/null @@ -1,49 +0,0 @@ -use bitwarden::{ - auth::password::MasterPasswordPolicyOptions, - exporters::ExportFormat, - generators::{PassphraseGeneratorRequest, PasswordGeneratorRequest}, - mobile::crypto::{InitOrgCryptoRequest, InitUserCryptoRequest}, - platform::FingerprintRequest, - send::{Send, SendListView, SendView}, - vault::{Cipher, CipherView, Collection, Folder, FolderView, TotpResponse}, -}; -use bitwarden_crypto::{HashPurpose, Kdf}; -use schemars::JsonSchema; - -#[derive(JsonSchema)] -#[allow(clippy::large_enum_variant)] -pub enum DocRef { - // Vault - Cipher(Cipher), - CipherView(CipherView), - Collection(Collection), - Folder(Folder), - FolderView(FolderView), - Send(Send), - SendView(SendView), - SendListView(SendListView), - - // Crypto - InitUserCryptoRequest(InitUserCryptoRequest), - InitOrgCryptoRequest(InitOrgCryptoRequest), - HashPurpose(HashPurpose), - - // Generators - PasswordGeneratorRequest(PasswordGeneratorRequest), - PassphraseGeneratorRequest(PassphraseGeneratorRequest), - - // Exporters - ExportFormat(ExportFormat), - - // Platform - FingerprintRequest(FingerprintRequest), - - // Auth - MasterPasswordPolicyOptions(MasterPasswordPolicyOptions), - - // Kdf - Kdf(Kdf), - - /// TOTP - TotpResponse(TotpResponse), -} diff --git a/crates/bitwarden-uniffi/src/lib.rs b/crates/bitwarden-uniffi/src/lib.rs index 0d89ffdb8..a9eb6a3e0 100644 --- a/crates/bitwarden-uniffi/src/lib.rs +++ b/crates/bitwarden-uniffi/src/lib.rs @@ -13,9 +13,6 @@ pub mod tool; mod uniffi_support; pub mod vault; -#[cfg(feature = "docs")] -pub mod docs; - #[cfg(target_os = "android")] mod android_support; diff --git a/crates/sdk-schemas/Cargo.toml b/crates/sdk-schemas/Cargo.toml index 8d48cd691..b4dd496a4 100644 --- a/crates/sdk-schemas/Cargo.toml +++ b/crates/sdk-schemas/Cargo.toml @@ -12,11 +12,7 @@ license-file.workspace = true keywords.workspace = true [features] -internal = [ - "bitwarden/internal", - "bitwarden-json/internal", - "bitwarden-uniffi/docs", -] +internal = ["bitwarden/internal", "bitwarden-json/internal"] [dependencies] anyhow = "1.0.82" diff --git a/crates/sdk-schemas/src/main.rs b/crates/sdk-schemas/src/main.rs index 94959fa69..66683256b 100644 --- a/crates/sdk-schemas/src/main.rs +++ b/crates/sdk-schemas/src/main.rs @@ -121,8 +121,5 @@ struct SchemaTypes { fn main() -> Result<()> { write_schema_for!("schema_types", SchemaTypes); - #[cfg(feature = "internal")] - write_schema_for!(bitwarden_uniffi::docs::DocRef); - Ok(()) } diff --git a/package-lock.json b/package-lock.json index 3d3e16698..894ec74eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "license": "SEE LICENSE IN LICENSE", "devDependencies": { "@openapitools/openapi-generator-cli": "2.13.4", - "handlebars": "^4.7.8", "prettier": "3.3.3", "quicktype-core": "23.0.170", "rimraf": "6.0.1", @@ -1144,28 +1143,6 @@ "dev": true, "license": "ISC" }, - "node_modules/handlebars": { - "version": "4.7.8", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz", - "integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "minimist": "^1.2.5", - "neo-async": "^2.6.2", - "source-map": "^0.6.1", - "wordwrap": "^1.0.0" - }, - "bin": { - "handlebars": "bin/handlebars" - }, - "engines": { - "node": ">=0.4.7" - }, - "optionalDependencies": { - "uglify-js": "^3.1.4" - } - }, "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", @@ -1450,16 +1427,6 @@ "node": "*" } }, - "node_modules/minimist": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", - "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/minipass": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", @@ -1484,13 +1451,6 @@ "dev": true, "license": "ISC" }, - "node_modules/neo-async": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", - "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", - "dev": true, - "license": "MIT" - }, "node_modules/node-fetch": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", @@ -1939,16 +1899,6 @@ "dev": true, "license": "ISC" }, - "node_modules/source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "license": "BSD-3-Clause", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/spawn-command": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2.tgz", @@ -2158,20 +2108,6 @@ "node": ">=14.17" } }, - "node_modules/uglify-js": { - "version": "3.19.3", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz", - "integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==", - "dev": true, - "license": "BSD-2-Clause", - "optional": true, - "bin": { - "uglifyjs": "bin/uglifyjs" - }, - "engines": { - "node": ">=0.8.0" - } - }, "node_modules/uid": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/uid/-/uid-2.0.2.tgz", diff --git a/package.json b/package.json index 8f40e36ab..e7e419467 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ }, "devDependencies": { "@openapitools/openapi-generator-cli": "2.13.4", - "handlebars": "^4.7.8", "prettier": "3.3.3", "quicktype-core": "23.0.170", "rimraf": "6.0.1", diff --git a/support/docs/docs.ts b/support/docs/docs.ts deleted file mode 100644 index 067ff0827..000000000 --- a/support/docs/docs.ts +++ /dev/null @@ -1,139 +0,0 @@ -// Quick script that parses the rustdoc json output and generates a basic markdown documentation. -// -// Do note that this script follows no best practices and will not handle anything many edge cases. - -import fs from "fs"; -import path from "path"; -import Handlebars from "handlebars"; - -import { Input, InputType } from "./rustdoc"; - -const doc = JSON.parse(fs.readFileSync("./target/doc/bitwarden_uniffi.json", "utf8")); -const command = JSON.parse( - fs.readFileSync("./support/schemas/bitwarden_uniffi/DocRef.json", "utf8"), -); - -const template = Handlebars.compile( - fs.readFileSync(path.resolve(__dirname, "template.hbs"), "utf8"), -); - -// Modify this to include more root elements -const rootElements = [ - "Client", - "ClientAuth", - "ClientAttachments", - "ClientCiphers", - "ClientCollections", - "ClientCrypto", - "ClientExporters", - "ClientFolders", - "ClientGenerators", - "ClientPasswordHistory", - "ClientPlatform", - "ClientSends", - "ClientVault", -]; - -const localIndexArray = Object.values(doc.index).filter((entry: any) => entry.crate_id == 0); -const localIndex = localIndexArray.reduce((map: any, obj: any) => { - map[obj.id] = obj; - return map; -}, {}) as Record; - -let usedDefinitions: any[] = []; - -const out = rootElements.map((rootElement) => { - const root: any = localIndexArray.find((entry: any) => entry.name == rootElement); - const impls = root.inner.struct.impls; - - const elements = impls - .flatMap((e: any) => localIndex[e]) - .flatMap((e: any) => e.inner.impl.items) - .map((e: any) => localIndex[e]) - .filter((e: any) => e?.docs != null); - - return { - name: rootElement, - elements: elements.map((e: any) => { - return { - name: e.name, - docs: e.docs, - args: e.inner.function.decl.inputs.map((e: any) => map_input(e)), - output: map_type(e.inner.function.decl.output), - }; - }), - }; -}); - -function stripDef(str: string) { - return str.replace(/#\/definitions\//g, ""); -} - -Handlebars.registerHelper("stripDef", (str: string) => { - return stripDef(str); -}); - -// Add references -for (let i = 0; i < usedDefinitions.length; i++) { - const key = usedDefinitions[i]; - const cmd = command.definitions[key]; - if (cmd == null) { - continue; - } - - Object.entries(cmd.properties ?? {}).forEach((prop: any) => { - prop[1].allOf?.forEach((e: any) => { - usedDefinitions.push(stripDef(e["$ref"] as string)); - }); - }); -} - -const filteredDefinitions = [...new Set(usedDefinitions)] - .sort() - .map((key) => [key, command.definitions[key]]) - .filter((e) => e[1] != null) - .reduce((obj, cur) => ({ ...obj, [cur[0]]: cur[1] }), {}); - -console.log(template({ sections: out, commands: filteredDefinitions })); - -/// -/// Implementation details below. -/// - -// Format -function map_input(input: Input) { - return { - name: input[0], - type: map_type(input[1]), - }; -} - -function map_type(t: InputType) { - const args = t.resolved_path?.args; - const name = t.resolved_path?.name; - - let out = ""; - - if (name) { - usedDefinitions.push(name); - - if (command.definitions[name] != null) { - out += `[${name}](#${name.toLowerCase()})`; - } else { - out += name; - } - } - - if (args != null && args.angle_bracketed.args.length > 0) { - out += "<"; - out += args.angle_bracketed.args.map((t: any) => { - if (t.type.generic) { - return t.type.generic; - } else if (t.type.resolved_path) { - return t.type.resolved_path.name; - } - }); - out += ">"; - } - return out; -} diff --git a/support/docs/rustdoc.ts b/support/docs/rustdoc.ts deleted file mode 100644 index 2622b711e..000000000 --- a/support/docs/rustdoc.ts +++ /dev/null @@ -1,12 +0,0 @@ -export type Input = [string, InputType]; - -export type InputType = { - resolved_path?: { - name: string; - args: { - angle_bracketed: { - args: any[]; - }; - }; - }; -}; diff --git a/support/docs/template.hbs b/support/docs/template.hbs deleted file mode 100644 index bd78d138a..000000000 --- a/support/docs/template.hbs +++ /dev/null @@ -1,91 +0,0 @@ -# Bitwarden Mobile SDK - -Auto generated documentation for the Bitwarden Mobile SDK. For more information please refer to -the rust crates `bitwarden` and `bitwarden-uniffi`. For code samples check the -`languages/kotlin/app` and `languages/swift/app` directories. - -{{#each sections}} - -## {{name}} - -{{#each elements}} -### `{{name}}` -{{docs}} - -**Arguments**: -{{#each args}} -- {{name}}: {{{type}}} -{{/each}} - -**Output**: {{{output}}} - -{{/each}} -{{/each}} - -# References - -References are generated from the JSON schemas and should mostly match the kotlin and swift -implementations. - -{{#each commands}} - -## `{{@key}}` - -{{#if oneOf}} - - - - - - -{{#each oneOf}} -{{#each properties}} - - - - - -{{#if properties}} - - - -{{/if}} -{{/each}} -{{/each}} -
KeyTypeDescription
{{@key}}{{type}}
- - - - - - - {{#each properties}} - - - - - - {{/each}} -
KeyTypeDescription
{{@key}}{{type}}{{{description}}}
-
- -{{/if}} - -{{#unless oneOf}} - - - - - - -{{#each properties}} - - - - - -{{/each}} -
KeyTypeDescription
{{@key}}{{type}}{{description}}
-{{/unless}} - -{{/each}} From 0ae6d73e6b066bac69dd3769e643137a2bec119c Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Thu, 10 Oct 2024 17:00:06 +0200 Subject: [PATCH 208/214] fix: .editorconfig not being applied properly (#1127) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective `[*.{ts}]` -> `[*.ts]` ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- .editorconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.editorconfig b/.editorconfig index 28ef180e8..33fa272b4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,10 +12,10 @@ insert_final_newline = true indent_style = space indent_size = 2 -[*.{ts}] -quote_type = single +[*.ts] +quote_type = double -[*.{rs}] +[*.rs] indent_style = space indent_size = 4 @@ -23,6 +23,6 @@ indent_size = 4 indent_style = space indent_size = 4 -[*.{xml}] +[*.xml] # VS Code XML extension removes the final newline insert_final_newline = false From 7e90f52cfd9fe3741816962cb3555cac40627ad4 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 11 Oct 2024 13:09:52 +0200 Subject: [PATCH 209/214] [PM-13371] Repository split - Avoid depdending on Bitwarden (#1124) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking Epic: https://bitwarden.atlassian.net/browse/PM-13370 Phase: https://bitwarden.atlassian.net/browse/PM-13371 ## 📔 Objective Decouples our internal crates from depending on the public `bitwarden` crate. `uniffi`, `wasm-internal` and `bw` now depends directly on feature crates. --- .github/workflows/build-rust-crates.yml | 6 -- Cargo.lock | 12 +--- crates/bitwarden-json/Cargo.toml | 3 +- crates/bitwarden-json/src/client.rs | 14 ---- crates/bitwarden-json/src/command.rs | 46 ------------- crates/bitwarden-uniffi/Cargo.toml | 4 +- crates/bitwarden-uniffi/src/auth/mod.rs | 2 +- crates/bitwarden-uniffi/src/crypto.rs | 2 +- crates/bitwarden-uniffi/src/error.rs | 52 +++++++++++++-- crates/bitwarden-uniffi/src/lib.rs | 10 +-- crates/bitwarden-uniffi/src/platform/fido2.rs | 41 ++++++------ crates/bitwarden-uniffi/src/platform/mod.rs | 2 +- crates/bitwarden-uniffi/src/tool/mod.rs | 18 ++--- crates/bitwarden-uniffi/src/tool/sends.rs | 2 +- crates/bitwarden-uniffi/src/uniffi_support.rs | 8 ++- .../bitwarden-uniffi/src/vault/attachments.rs | 2 +- crates/bitwarden-uniffi/src/vault/ciphers.rs | 8 +-- .../bitwarden-uniffi/src/vault/collections.rs | 2 +- crates/bitwarden-uniffi/src/vault/folders.rs | 2 +- crates/bitwarden-uniffi/src/vault/mod.rs | 11 ++-- .../src/vault/password_history.rs | 2 +- crates/bitwarden-wasm-internal/Cargo.toml | 2 +- crates/bitwarden-wasm/Cargo.toml | 5 +- crates/bitwarden/Cargo.toml | 23 ------- crates/bitwarden/src/error.rs | 66 +------------------ crates/bitwarden/src/lib.rs | 29 +------- crates/bw/Cargo.toml | 4 +- crates/bw/src/auth/login.rs | 6 +- crates/bw/src/main.rs | 15 ++--- crates/sdk-schemas/Cargo.toml | 1 - crates/sdk-schemas/src/main.rs | 7 -- support/scripts/schemas.ts | 12 ---- 32 files changed, 124 insertions(+), 295 deletions(-) diff --git a/.github/workflows/build-rust-crates.yml b/.github/workflows/build-rust-crates.yml index d4116bcf9..8400fcbf6 100644 --- a/.github/workflows/build-rust-crates.yml +++ b/.github/workflows/build-rust-crates.yml @@ -49,12 +49,6 @@ jobs: env: RUSTFLAGS: "-D warnings" - - name: Build Internal - if: ${{ matrix.package == 'bitwarden' }} - run: cargo build -p ${{ matrix.package }} --features internal --release - env: - RUSTFLAGS: "-D warnings" - release-dry-run: name: Release dry-run runs-on: ubuntu-latest diff --git a/Cargo.lock b/Cargo.lock index 5397271ce..024abbe00 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -362,16 +362,9 @@ checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" name = "bitwarden" version = "1.0.0" dependencies = [ - "bitwarden-api-api", - "bitwarden-api-identity", "bitwarden-core", - "bitwarden-crypto", - "bitwarden-exporters", - "bitwarden-fido", "bitwarden-generators", - "bitwarden-send", "bitwarden-sm", - "bitwarden-vault", "thiserror", "uuid", ] @@ -623,7 +616,6 @@ version = "0.1.0" dependencies = [ "android_logger", "async-trait", - "bitwarden", "bitwarden-core", "bitwarden-crypto", "bitwarden-exporters", @@ -746,9 +738,11 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" name = "bw" version = "0.0.2" dependencies = [ - "bitwarden", "bitwarden-cli", + "bitwarden-core", "bitwarden-crypto", + "bitwarden-generators", + "bitwarden-vault", "clap", "color-eyre", "env_logger", diff --git a/crates/bitwarden-json/Cargo.toml b/crates/bitwarden-json/Cargo.toml index ed1b39580..b5b8052b0 100644 --- a/crates/bitwarden-json/Cargo.toml +++ b/crates/bitwarden-json/Cargo.toml @@ -16,8 +16,7 @@ repository.workspace = true license-file.workspace = true [features] -internal = ["bitwarden/internal"] # Internal testing methods -secrets = ["bitwarden/secrets"] # Secrets manager API +secrets = ["bitwarden/secrets"] # Secrets manager API [dependencies] bitwarden = { workspace = true } diff --git a/crates/bitwarden-json/src/client.rs b/crates/bitwarden-json/src/client.rs index dc84c559d..8da635a29 100644 --- a/crates/bitwarden-json/src/client.rs +++ b/crates/bitwarden-json/src/client.rs @@ -1,5 +1,3 @@ -#[cfg(feature = "internal")] -use bitwarden::vault::ClientVaultExt; use bitwarden::ClientSettings; #[cfg(feature = "secrets")] use bitwarden::{ @@ -54,22 +52,10 @@ impl Client { let client = &self.0; match cmd { - #[cfg(feature = "internal")] - Command::PasswordLogin(req) => client.auth().login_password(&req).await.into_string(), #[cfg(feature = "secrets")] Command::LoginAccessToken(req) => { client.auth().login_access_token(&req).await.into_string() } - #[cfg(feature = "internal")] - Command::GetUserApiKey(req) => { - client.platform().get_user_api_key(req).await.into_string() - } - #[cfg(feature = "internal")] - Command::ApiKeyLogin(req) => client.auth().login_api_key(&req).await.into_string(), - #[cfg(feature = "internal")] - Command::Sync(req) => client.vault().sync(&req).await.into_string(), - #[cfg(feature = "internal")] - Command::Fingerprint(req) => client.platform().fingerprint(&req).into_string(), #[cfg(feature = "secrets")] Command::Secrets(cmd) => match cmd { diff --git a/crates/bitwarden-json/src/command.rs b/crates/bitwarden-json/src/command.rs index 7483b90cf..faaa81776 100644 --- a/crates/bitwarden-json/src/command.rs +++ b/crates/bitwarden-json/src/command.rs @@ -13,38 +13,12 @@ use bitwarden::{ }, }, }; -#[cfg(feature = "internal")] -use bitwarden::{ - auth::login::{ApiKeyLoginRequest, PasswordLoginRequest}, - platform::{FingerprintRequest, SecretVerificationRequest}, - vault::SyncRequest, -}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, JsonSchema, Debug)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub enum Command { - #[cfg(feature = "internal")] - /// Login with username and password - /// - /// This command is for initiating an authentication handshake with Bitwarden. - /// Authorization may fail due to requiring 2fa or captcha challenge completion - /// despite accurate credentials. - /// - /// This command is not capable of handling authentication requiring 2fa or captcha. - /// - /// Returns: [PasswordLoginResponse](bitwarden::auth::login::PasswordLoginResponse) - PasswordLogin(PasswordLoginRequest), - - #[cfg(feature = "internal")] - /// Login with API Key - /// - /// This command is for initiating an authentication handshake with Bitwarden. - /// - /// Returns: [ApiKeyLoginResponse](bitwarden::auth::login::ApiKeyLoginResponse) - ApiKeyLogin(ApiKeyLoginRequest), - #[cfg(feature = "secrets")] /// Login with Secrets Manager Access Token /// @@ -53,26 +27,6 @@ pub enum Command { /// Returns: [ApiKeyLoginResponse](bitwarden::auth::login::ApiKeyLoginResponse) LoginAccessToken(AccessTokenLoginRequest), - #[cfg(feature = "internal")] - /// > Requires Authentication - /// Get the API key of the currently authenticated user - /// - /// Returns: [UserApiKeyResponse](bitwarden::platform::UserApiKeyResponse) - GetUserApiKey(SecretVerificationRequest), - - #[cfg(feature = "internal")] - /// Get the user's passphrase - /// - /// Returns: String - Fingerprint(FingerprintRequest), - - #[cfg(feature = "internal")] - /// > Requires Authentication - /// Retrieve all user data, ciphers and organizations the user is a part of - /// - /// Returns: [SyncResponse](bitwarden::vault::SyncResponse) - Sync(SyncRequest), - #[cfg(feature = "secrets")] Secrets(SecretsCommand), #[cfg(feature = "secrets")] diff --git a/crates/bitwarden-uniffi/Cargo.toml b/crates/bitwarden-uniffi/Cargo.toml index 822ed0d38..2e57e23b5 100644 --- a/crates/bitwarden-uniffi/Cargo.toml +++ b/crates/bitwarden-uniffi/Cargo.toml @@ -11,7 +11,6 @@ repository.workspace = true license-file.workspace = true [features] -docs = ["dep:schemars"] # Docs [lib] crate-type = ["lib", "staticlib", "cdylib"] @@ -19,7 +18,6 @@ bench = false [dependencies] async-trait = "0.1.80" -bitwarden = { workspace = true, features = ["internal", "uniffi"] } bitwarden-core = { workspace = true, features = ["uniffi"] } bitwarden-crypto = { workspace = true, features = ["uniffi"] } bitwarden-exporters = { workspace = true, features = ["uniffi"] } @@ -28,8 +26,8 @@ bitwarden-generators = { workspace = true, features = ["uniffi"] } bitwarden-send = { workspace = true, features = ["uniffi"] } bitwarden-vault = { workspace = true, features = ["uniffi"] } chrono = { workspace = true, features = ["std"] } -log = { workspace = true } env_logger = "0.11.1" +log = { workspace = true } schemars = { workspace = true, optional = true } thiserror = { workspace = true } uniffi = { workspace = true } diff --git a/crates/bitwarden-uniffi/src/auth/mod.rs b/crates/bitwarden-uniffi/src/auth/mod.rs index d036991e3..43496080a 100644 --- a/crates/bitwarden-uniffi/src/auth/mod.rs +++ b/crates/bitwarden-uniffi/src/auth/mod.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use bitwarden::{ +use bitwarden_core::{ auth::{ password::MasterPasswordPolicyOptions, AuthRequestResponse, KeyConnectorResponse, RegisterKeyResponse, RegisterTdeKeyResponse, diff --git a/crates/bitwarden-uniffi/src/crypto.rs b/crates/bitwarden-uniffi/src/crypto.rs index 608698fc6..6404d62f6 100644 --- a/crates/bitwarden-uniffi/src/crypto.rs +++ b/crates/bitwarden-uniffi/src/crypto.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use bitwarden::{ +use bitwarden_core::{ mobile::crypto::{ DeriveKeyConnectorRequest, DerivePinKeyResponse, InitOrgCryptoRequest, InitUserCryptoRequest, UpdatePasswordResponse, diff --git a/crates/bitwarden-uniffi/src/error.rs b/crates/bitwarden-uniffi/src/error.rs index 5a1dfe43a..889e3c7fb 100644 --- a/crates/bitwarden-uniffi/src/error.rs +++ b/crates/bitwarden-uniffi/src/error.rs @@ -1,21 +1,24 @@ use std::fmt::{Display, Formatter}; +use bitwarden_exporters::ExportError; +use bitwarden_generators::{PassphraseError, PasswordError, UsernameError}; + // Name is converted from *Error to *Exception, so we can't just name the enum Error because // Exception already exists #[derive(uniffi::Error, Debug)] #[uniffi(flat_error)] pub enum BitwardenError { - E(bitwarden::error::Error), + E(Error), } -impl From for BitwardenError { - fn from(e: bitwarden::Error) -> Self { +impl From for BitwardenError { + fn from(e: bitwarden_core::Error) -> Self { Self::E(e.into()) } } -impl From for BitwardenError { - fn from(e: bitwarden::error::Error) -> Self { +impl From for BitwardenError { + fn from(e: Error) -> Self { Self::E(e) } } @@ -37,3 +40,42 @@ impl std::error::Error for BitwardenError { } pub type Result = std::result::Result; + +#[derive(thiserror::Error, Debug)] +pub enum Error { + #[error(transparent)] + Core(#[from] bitwarden_core::Error), + + // Generators + #[error(transparent)] + UsernameError(#[from] UsernameError), + #[error(transparent)] + PassphraseError(#[from] PassphraseError), + #[error(transparent)] + PasswordError(#[from] PasswordError), + + // Vault + #[error(transparent)] + Cipher(#[from] bitwarden_vault::CipherError), + #[error(transparent)] + Totp(#[from] bitwarden_vault::TotpError), + + #[error(transparent)] + ExportError(#[from] ExportError), + + // Fido + #[error(transparent)] + MakeCredential(#[from] bitwarden_fido::MakeCredentialError), + #[error(transparent)] + GetAssertion(#[from] bitwarden_fido::GetAssertionError), + #[error(transparent)] + SilentlyDiscoverCredentials(#[from] bitwarden_fido::SilentlyDiscoverCredentialsError), + #[error(transparent)] + CredentialsForAutofillError(#[from] bitwarden_fido::CredentialsForAutofillError), + #[error(transparent)] + DecryptFido2AutofillCredentialsError( + #[from] bitwarden_fido::DecryptFido2AutofillCredentialsError, + ), + #[error(transparent)] + Fido2Client(#[from] bitwarden_fido::Fido2ClientError), +} diff --git a/crates/bitwarden-uniffi/src/lib.rs b/crates/bitwarden-uniffi/src/lib.rs index a9eb6a3e0..aae35c37a 100644 --- a/crates/bitwarden-uniffi/src/lib.rs +++ b/crates/bitwarden-uniffi/src/lib.rs @@ -3,7 +3,7 @@ uniffi::setup_scaffolding!(); use std::sync::Arc; use auth::ClientAuth; -use bitwarden::ClientSettings; +use bitwarden_core::ClientSettings; pub mod auth; pub mod crypto; @@ -23,7 +23,7 @@ use tool::{ClientExporters, ClientGenerators, ClientSends}; use vault::ClientVault; #[derive(uniffi::Object)] -pub struct Client(bitwarden::Client); +pub struct Client(bitwarden_core::Client); #[uniffi::export(async_runtime = "tokio")] impl Client { @@ -35,7 +35,7 @@ impl Client { #[cfg(target_os = "android")] android_support::init(); - Arc::new(Self(bitwarden::Client::new(settings))) + Arc::new(Self(bitwarden_core::Client::new(settings))) } /// Crypto operations @@ -84,9 +84,9 @@ impl Client { .get(&url) .send() .await - .map_err(bitwarden::Error::Reqwest)?; + .map_err(bitwarden_core::Error::Reqwest)?; - Ok(res.text().await.map_err(bitwarden::Error::Reqwest)?) + Ok(res.text().await.map_err(bitwarden_core::Error::Reqwest)?) } } diff --git a/crates/bitwarden-uniffi/src/platform/fido2.rs b/crates/bitwarden-uniffi/src/platform/fido2.rs index f483ff346..99c998648 100644 --- a/crates/bitwarden-uniffi/src/platform/fido2.rs +++ b/crates/bitwarden-uniffi/src/platform/fido2.rs @@ -1,19 +1,18 @@ use std::sync::Arc; -use bitwarden::{ - error::Error, - fido::{ - CheckUserOptions, ClientData, ClientFido2Ext, Fido2CallbackError as BitFido2CallbackError, - GetAssertionRequest, GetAssertionResult, MakeCredentialRequest, MakeCredentialResult, - PublicKeyCredentialAuthenticatorAssertionResponse, - PublicKeyCredentialAuthenticatorAttestationResponse, PublicKeyCredentialRpEntity, - PublicKeyCredentialUserEntity, - }, - vault::{Cipher, CipherView, Fido2CredentialNewView}, +use bitwarden_fido::{ + CheckUserOptions, ClientData, ClientFido2Ext, Fido2CallbackError as BitFido2CallbackError, + Fido2CredentialAutofillView, GetAssertionRequest, GetAssertionResult, MakeCredentialRequest, + MakeCredentialResult, Origin, PublicKeyCredentialAuthenticatorAssertionResponse, + PublicKeyCredentialAuthenticatorAttestationResponse, PublicKeyCredentialRpEntity, + PublicKeyCredentialUserEntity, }; -use bitwarden_fido::{Fido2CredentialAutofillView, Origin}; +use bitwarden_vault::{Cipher, CipherView, Fido2CredentialNewView}; -use crate::{error::Result, Client}; +use crate::{ + error::{Error, Result}, + Client, +}; #[derive(uniffi::Object)] pub struct ClientFido2(pub(crate) Arc); @@ -180,7 +179,7 @@ pub struct CheckUserResult { user_verified: bool, } -impl From for bitwarden::fido::CheckUserResult { +impl From for bitwarden_fido::CheckUserResult { fn from(val: CheckUserResult) -> Self { Self { user_present: val.user_present, @@ -268,7 +267,7 @@ pub trait Fido2CredentialStore: Send + Sync { struct UniffiTraitBridge(T); #[async_trait::async_trait] -impl bitwarden::fido::Fido2CredentialStore for UniffiTraitBridge<&dyn Fido2CredentialStore> { +impl bitwarden_fido::Fido2CredentialStore for UniffiTraitBridge<&dyn Fido2CredentialStore> { async fn find_credentials( &self, ids: Option>>, @@ -306,9 +305,9 @@ pub enum UIHint { RequestExistingCredential(CipherView), } -impl From> for UIHint { - fn from(hint: bitwarden::fido::UIHint<'_, CipherView>) -> Self { - use bitwarden::fido::UIHint as BWUIHint; +impl From> for UIHint { + fn from(hint: bitwarden_fido::UIHint<'_, CipherView>) -> Self { + use bitwarden_fido::UIHint as BWUIHint; match hint { BWUIHint::InformExcludedCredentialFound(cipher) => { UIHint::InformExcludedCredentialFound(cipher.clone()) @@ -333,12 +332,12 @@ impl From> for UIHint { } #[async_trait::async_trait] -impl bitwarden::fido::Fido2UserInterface for UniffiTraitBridge<&dyn Fido2UserInterface> { +impl bitwarden_fido::Fido2UserInterface for UniffiTraitBridge<&dyn Fido2UserInterface> { async fn check_user<'a>( &self, options: CheckUserOptions, - hint: bitwarden::fido::UIHint<'a, CipherView>, - ) -> Result { + hint: bitwarden_fido::UIHint<'a, CipherView>, + ) -> Result { self.0 .check_user(options.clone(), hint.into()) .await @@ -359,7 +358,7 @@ impl bitwarden::fido::Fido2UserInterface for UniffiTraitBridge<&dyn Fido2UserInt &self, options: CheckUserOptions, new_credential: Fido2CredentialNewView, - ) -> Result<(CipherView, bitwarden::fido::CheckUserResult), BitFido2CallbackError> { + ) -> Result<(CipherView, bitwarden_fido::CheckUserResult), BitFido2CallbackError> { self.0 .check_user_and_pick_credential_for_creation(options, new_credential) .await diff --git a/crates/bitwarden-uniffi/src/platform/mod.rs b/crates/bitwarden-uniffi/src/platform/mod.rs index 63ff6e183..b5d944152 100644 --- a/crates/bitwarden-uniffi/src/platform/mod.rs +++ b/crates/bitwarden-uniffi/src/platform/mod.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use bitwarden::platform::FingerprintRequest; +use bitwarden_core::platform::FingerprintRequest; use crate::{error::Result, Client}; diff --git a/crates/bitwarden-uniffi/src/tool/mod.rs b/crates/bitwarden-uniffi/src/tool/mod.rs index 1fd439a4f..498884218 100644 --- a/crates/bitwarden-uniffi/src/tool/mod.rs +++ b/crates/bitwarden-uniffi/src/tool/mod.rs @@ -1,16 +1,16 @@ use std::sync::Arc; -use bitwarden::{ - error::Error, - exporters::{ClientExportersExt, ExportFormat}, - generators::{ - ClientGeneratorExt, PassphraseGeneratorRequest, PasswordGeneratorRequest, - UsernameGeneratorRequest, - }, - vault::{Cipher, Collection, Folder}, +use bitwarden_exporters::{ClientExportersExt, ExportFormat}; +use bitwarden_generators::{ + ClientGeneratorExt, PassphraseGeneratorRequest, PasswordGeneratorRequest, + UsernameGeneratorRequest, }; +use bitwarden_vault::{Cipher, Collection, Folder}; -use crate::{error::Result, Client}; +use crate::{ + error::{Error, Result}, + Client, +}; mod sends; pub use sends::ClientSends; diff --git a/crates/bitwarden-uniffi/src/tool/sends.rs b/crates/bitwarden-uniffi/src/tool/sends.rs index 1d5a056a3..18732f57c 100644 --- a/crates/bitwarden-uniffi/src/tool/sends.rs +++ b/crates/bitwarden-uniffi/src/tool/sends.rs @@ -1,6 +1,6 @@ use std::{path::Path, sync::Arc}; -use bitwarden::send::{ClientSendsExt, Send, SendListView, SendView}; +use bitwarden_send::{ClientSendsExt, Send, SendListView, SendView}; use crate::{Client, Result}; diff --git a/crates/bitwarden-uniffi/src/uniffi_support.rs b/crates/bitwarden-uniffi/src/uniffi_support.rs index 74f484869..282b03460 100644 --- a/crates/bitwarden-uniffi/src/uniffi_support.rs +++ b/crates/bitwarden-uniffi/src/uniffi_support.rs @@ -4,6 +4,10 @@ use uuid::Uuid; // Forward the type definitions to the main bitwarden crate type DateTime = chrono::DateTime; uniffi::ffi_converter_forward!(DateTime, bitwarden_core::UniFfiTag, crate::UniFfiTag); -uniffi::ffi_converter_forward!(EncString, bitwarden::UniFfiTag, crate::UniFfiTag); -uniffi::ffi_converter_forward!(AsymmetricEncString, bitwarden::UniFfiTag, crate::UniFfiTag); +uniffi::ffi_converter_forward!(EncString, bitwarden_core::UniFfiTag, crate::UniFfiTag); +uniffi::ffi_converter_forward!( + AsymmetricEncString, + bitwarden_core::UniFfiTag, + crate::UniFfiTag +); uniffi::ffi_converter_forward!(Uuid, bitwarden_core::UniFfiTag, crate::UniFfiTag); diff --git a/crates/bitwarden-uniffi/src/vault/attachments.rs b/crates/bitwarden-uniffi/src/vault/attachments.rs index e8bddd124..cb2a011a0 100644 --- a/crates/bitwarden-uniffi/src/vault/attachments.rs +++ b/crates/bitwarden-uniffi/src/vault/attachments.rs @@ -1,6 +1,6 @@ use std::{path::Path, sync::Arc}; -use bitwarden::vault::{ +use bitwarden_vault::{ Attachment, AttachmentEncryptResult, AttachmentView, Cipher, ClientVaultExt, }; diff --git a/crates/bitwarden-uniffi/src/vault/ciphers.rs b/crates/bitwarden-uniffi/src/vault/ciphers.rs index 1195cf81a..64751b37c 100644 --- a/crates/bitwarden-uniffi/src/vault/ciphers.rs +++ b/crates/bitwarden-uniffi/src/vault/ciphers.rs @@ -1,13 +1,9 @@ use std::sync::Arc; -use bitwarden::{ - error::Error, - vault::{Cipher, CipherListView, CipherView, ClientVaultExt}, -}; -use bitwarden_vault::Fido2CredentialView; +use bitwarden_vault::{Cipher, CipherListView, CipherView, ClientVaultExt, Fido2CredentialView}; use uuid::Uuid; -use crate::{Client, Result}; +use crate::{error::Error, Client, Result}; #[derive(uniffi::Object)] pub struct ClientCiphers(pub Arc); diff --git a/crates/bitwarden-uniffi/src/vault/collections.rs b/crates/bitwarden-uniffi/src/vault/collections.rs index 84d928e64..250588e8d 100644 --- a/crates/bitwarden-uniffi/src/vault/collections.rs +++ b/crates/bitwarden-uniffi/src/vault/collections.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use bitwarden::vault::{ClientVaultExt, Collection, CollectionView}; +use bitwarden_vault::{ClientVaultExt, Collection, CollectionView}; use crate::{Client, Result}; diff --git a/crates/bitwarden-uniffi/src/vault/folders.rs b/crates/bitwarden-uniffi/src/vault/folders.rs index 2efeb1f11..758d09173 100644 --- a/crates/bitwarden-uniffi/src/vault/folders.rs +++ b/crates/bitwarden-uniffi/src/vault/folders.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use bitwarden::vault::{ClientVaultExt, Folder, FolderView}; +use bitwarden_vault::{ClientVaultExt, Folder, FolderView}; use crate::{Client, Result}; diff --git a/crates/bitwarden-uniffi/src/vault/mod.rs b/crates/bitwarden-uniffi/src/vault/mod.rs index 4cf840868..cec625e33 100644 --- a/crates/bitwarden-uniffi/src/vault/mod.rs +++ b/crates/bitwarden-uniffi/src/vault/mod.rs @@ -1,13 +1,12 @@ use std::sync::Arc; -use bitwarden::{ - error::Error, - vault::{ClientVaultExt, TotpResponse}, -}; -use bitwarden_vault::CipherListView; +use bitwarden_vault::{CipherListView, ClientVaultExt, TotpResponse}; use chrono::{DateTime, Utc}; -use crate::{error::Result, Client}; +use crate::{ + error::{Error, Result}, + Client, +}; pub mod attachments; pub mod ciphers; diff --git a/crates/bitwarden-uniffi/src/vault/password_history.rs b/crates/bitwarden-uniffi/src/vault/password_history.rs index 3fa0fd3bc..330e91214 100644 --- a/crates/bitwarden-uniffi/src/vault/password_history.rs +++ b/crates/bitwarden-uniffi/src/vault/password_history.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use bitwarden::vault::{ClientVaultExt, PasswordHistory, PasswordHistoryView}; +use bitwarden_vault::{ClientVaultExt, PasswordHistory, PasswordHistoryView}; use crate::{Client, Result}; diff --git a/crates/bitwarden-wasm-internal/Cargo.toml b/crates/bitwarden-wasm-internal/Cargo.toml index df69015cf..4f68c08d6 100644 --- a/crates/bitwarden-wasm-internal/Cargo.toml +++ b/crates/bitwarden-wasm-internal/Cargo.toml @@ -15,7 +15,7 @@ keywords.workspace = true crate-type = ["cdylib"] [dependencies] -bitwarden = { workspace = true, features = ["internal", "wasm"] } +bitwarden = { workspace = true, features = ["wasm"] } console_error_panic_hook = "0.1.7" console_log = { version = "1.0.0", features = ["color"] } js-sys = "0.3.68" diff --git a/crates/bitwarden-wasm/Cargo.toml b/crates/bitwarden-wasm/Cargo.toml index c4be614d3..fd3c278f8 100644 --- a/crates/bitwarden-wasm/Cargo.toml +++ b/crates/bitwarden-wasm/Cargo.toml @@ -19,10 +19,7 @@ argon2 = { version = ">=0.5.0, <0.6", features = [ "alloc", "zeroize", ], default-features = false } -bitwarden-json = { path = "../bitwarden-json", features = [ - "secrets", - "internal", -] } +bitwarden-json = { path = "../bitwarden-json", features = ["secrets"] } console_error_panic_hook = "0.1.7" console_log = { version = "1.0.0", features = ["color"] } js-sys = "0.3.68" diff --git a/crates/bitwarden/Cargo.toml b/crates/bitwarden/Cargo.toml index 1d09377cf..3626f9d11 100644 --- a/crates/bitwarden/Cargo.toml +++ b/crates/bitwarden/Cargo.toml @@ -16,25 +16,9 @@ license-file.workspace = true [features] default = ["secrets"] -internal = [ - "bitwarden-core/internal", - "dep:bitwarden-exporters", - "dep:bitwarden-generators", - "dep:bitwarden-send", - "dep:bitwarden-vault", -] # Internal testing methods no-memory-hardening = [ "bitwarden-core/no-memory-hardening", ] # Disable memory hardening features -uniffi = [ - "bitwarden-core/uniffi", - "bitwarden-crypto/uniffi", - "bitwarden-exporters/uniffi", - "bitwarden-fido/uniffi", - "bitwarden-generators/uniffi", - "bitwarden-send/uniffi", - "bitwarden-vault/uniffi", -] # Uniffi bindings secrets = [ "bitwarden-core/secrets", "dep:bitwarden-sm", @@ -43,16 +27,9 @@ secrets = [ wasm = ["bitwarden-core/wasm"] # WASM support [dependencies] -bitwarden-api-api = { workspace = true } -bitwarden-api-identity = { workspace = true } bitwarden-core = { workspace = true } -bitwarden-crypto = { workspace = true } -bitwarden-exporters = { workspace = true, optional = true } -bitwarden-fido = { workspace = true, optional = true } bitwarden-generators = { workspace = true, optional = true } -bitwarden-send = { workspace = true, optional = true } bitwarden-sm = { workspace = true, optional = true } -bitwarden-vault = { workspace = true, optional = true } thiserror = { workspace = true } [dev-dependencies] diff --git a/crates/bitwarden/src/error.rs b/crates/bitwarden/src/error.rs index 06ef09648..163ccc208 100644 --- a/crates/bitwarden/src/error.rs +++ b/crates/bitwarden/src/error.rs @@ -1,77 +1,13 @@ //! Errors that can occur when using this SDK -use std::{borrow::Cow, fmt::Debug}; +use std::fmt::Debug; -#[cfg(feature = "internal")] -use bitwarden_exporters::ExportError; -#[cfg(feature = "internal")] -use bitwarden_generators::{PassphraseError, PasswordError, UsernameError}; use thiserror::Error; #[derive(Debug, Error)] pub enum Error { #[error(transparent)] Core(#[from] bitwarden_core::Error), - - // Generators - #[cfg(feature = "internal")] - #[error(transparent)] - UsernameError(#[from] UsernameError), - #[cfg(feature = "internal")] - #[error(transparent)] - PassphraseError(#[from] PassphraseError), - #[cfg(feature = "internal")] - #[error(transparent)] - PasswordError(#[from] PasswordError), - - // Vault - #[cfg(feature = "internal")] - #[error(transparent)] - Cipher(#[from] bitwarden_vault::CipherError), - #[cfg(feature = "internal")] - #[error(transparent)] - Totp(#[from] bitwarden_vault::TotpError), - - #[cfg(feature = "internal")] - #[error(transparent)] - ExportError(#[from] ExportError), - - // Fido - #[cfg(all(feature = "uniffi", feature = "internal"))] - #[error(transparent)] - MakeCredential(#[from] bitwarden_fido::MakeCredentialError), - #[cfg(all(feature = "uniffi", feature = "internal"))] - #[error(transparent)] - GetAssertion(#[from] bitwarden_fido::GetAssertionError), - #[cfg(all(feature = "uniffi", feature = "internal"))] - #[error(transparent)] - SilentlyDiscoverCredentials(#[from] bitwarden_fido::SilentlyDiscoverCredentialsError), - #[cfg(all(feature = "uniffi", feature = "internal"))] - #[error(transparent)] - CredentialsForAutofillError(#[from] bitwarden_fido::CredentialsForAutofillError), - #[cfg(all(feature = "uniffi", feature = "internal"))] - #[error(transparent)] - DecryptFido2AutofillCredentialsError( - #[from] bitwarden_fido::DecryptFido2AutofillCredentialsError, - ), - #[cfg(all(feature = "uniffi", feature = "internal"))] - #[error(transparent)] - Fido2Client(#[from] bitwarden_fido::Fido2ClientError), - - #[error("Internal error: {0}")] - Internal(Cow<'static, str>), -} - -impl From for Error { - fn from(s: String) -> Self { - Self::Internal(s.into()) - } -} - -impl From<&'static str> for Error { - fn from(s: &'static str) -> Self { - Self::Internal(s.into()) - } } // Ensure that the error messages implement Send and Sync diff --git a/crates/bitwarden/src/lib.rs b/crates/bitwarden/src/lib.rs index c87693ce7..77a063f52 100644 --- a/crates/bitwarden/src/lib.rs +++ b/crates/bitwarden/src/lib.rs @@ -61,34 +61,7 @@ mod readme {} pub use bitwarden_core::*; pub mod error; -#[cfg(feature = "internal")] -pub mod internal { - pub mod generators { - pub use bitwarden_generators::*; - } - - pub mod exporters { - pub use bitwarden_exporters::*; - } - - pub mod send { - pub use bitwarden_send::*; - } - - pub mod vault { - pub use bitwarden_vault::*; - } - - #[cfg(feature = "uniffi")] - pub mod fido { - pub use bitwarden_fido::*; - } -} -#[cfg(feature = "internal")] -pub use internal::*; - -// Re-export generators used for secrets-manager, internal flag already exports all generators -#[cfg(all(feature = "secrets", not(feature = "internal")))] +#[cfg(feature = "secrets")] pub mod generators { pub use bitwarden_generators::{ClientGeneratorExt, PasswordError, PasswordGeneratorRequest}; } diff --git a/crates/bw/Cargo.toml b/crates/bw/Cargo.toml index cb8e02ba1..a2ba807c3 100644 --- a/crates/bw/Cargo.toml +++ b/crates/bw/Cargo.toml @@ -14,9 +14,11 @@ repository.workspace = true license-file.workspace = true [dependencies] -bitwarden = { workspace = true, features = ["internal"] } bitwarden-cli = { workspace = true } +bitwarden-core = { workspace = true } bitwarden-crypto = { workspace = true } +bitwarden-generators = { workspace = true } +bitwarden-vault = { workspace = true } clap = { version = "4.5.4", features = ["derive", "env"] } color-eyre = "0.6.3" env_logger = "0.11.1" diff --git a/crates/bw/src/auth/login.rs b/crates/bw/src/auth/login.rs index 51fe64a39..131d39f02 100644 --- a/crates/bw/src/auth/login.rs +++ b/crates/bw/src/auth/login.rs @@ -1,12 +1,12 @@ -use bitwarden::{ +use bitwarden_cli::text_prompt_when_none; +use bitwarden_core::{ auth::login::{ ApiKeyLoginRequest, PasswordLoginRequest, TwoFactorEmailRequest, TwoFactorProvider, TwoFactorRequest, }, - vault::{ClientVaultExt, SyncRequest}, Client, }; -use bitwarden_cli::text_prompt_when_none; +use bitwarden_vault::{ClientVaultExt, SyncRequest}; use color_eyre::eyre::{bail, Result}; use inquire::{Password, Text}; use log::{debug, error, info}; diff --git a/crates/bw/src/main.rs b/crates/bw/src/main.rs index a9a7eeea2..06d5d0bd5 100644 --- a/crates/bw/src/main.rs +++ b/crates/bw/src/main.rs @@ -1,9 +1,8 @@ -use bitwarden::{ - auth::RegisterRequest, - generators::{ClientGeneratorExt, PassphraseGeneratorRequest, PasswordGeneratorRequest}, - ClientSettings, -}; use bitwarden_cli::{install_color_eyre, text_prompt_when_none, Color}; +use bitwarden_core::{auth::RegisterRequest, ClientSettings}; +use bitwarden_generators::{ + ClientGeneratorExt, PassphraseGeneratorRequest, PasswordGeneratorRequest, +}; use clap::{command, Args, CommandFactory, Parser, Subcommand}; use color_eyre::eyre::Result; use inquire::Password; @@ -157,7 +156,7 @@ async fn process_commands() -> Result<()> { identity_url: format!("{}/identity", server), ..Default::default() }); - let client = bitwarden::Client::new(settings); + let client = bitwarden_core::Client::new(settings); match args.command { // FIXME: Rust CLI will not support password login! @@ -188,7 +187,7 @@ async fn process_commands() -> Result<()> { identity_url: format!("{}/identity", server), ..Default::default() }); - let client = bitwarden::Client::new(settings); + let client = bitwarden_core::Client::new(settings); let email = text_prompt_when_none("Email", email)?; let password = Password::new("Password").prompt()?; @@ -207,7 +206,7 @@ async fn process_commands() -> Result<()> { } // Not login, assuming we have a config - let client = bitwarden::Client::new(None); + let client = bitwarden_core::Client::new(None); // And finally we process all the commands which require authentication match command { diff --git a/crates/sdk-schemas/Cargo.toml b/crates/sdk-schemas/Cargo.toml index b4dd496a4..13a664873 100644 --- a/crates/sdk-schemas/Cargo.toml +++ b/crates/sdk-schemas/Cargo.toml @@ -12,7 +12,6 @@ license-file.workspace = true keywords.workspace = true [features] -internal = ["bitwarden/internal", "bitwarden-json/internal"] [dependencies] anyhow = "1.0.82" diff --git a/crates/sdk-schemas/src/main.rs b/crates/sdk-schemas/src/main.rs index 66683256b..2db3ce5fe 100644 --- a/crates/sdk-schemas/src/main.rs +++ b/crates/sdk-schemas/src/main.rs @@ -109,13 +109,6 @@ struct SchemaTypes { projects: Response, projects_delete: Response, password: Response, - - #[cfg(feature = "internal")] - fingerprint: Response, - #[cfg(feature = "internal")] - sync: Response, - #[cfg(feature = "internal")] - user_api_key: Response, } fn main() -> Result<()> { diff --git a/support/scripts/schemas.ts b/support/scripts/schemas.ts index 3eaad1903..873a9de7d 100644 --- a/support/scripts/schemas.ts +++ b/support/scripts/schemas.ts @@ -7,18 +7,6 @@ import { } from "quicktype-core"; import fs from "fs"; -import path from "path"; - -async function* walk(dir: string): AsyncIterable { - for await (const d of await fs.promises.opendir(dir)) { - const entry = path.join(dir, d.name); - if (d.isDirectory()) { - yield* walk(entry); - } else if (d.isFile()) { - yield entry; - } - } -} async function main() { const schemaInput = new JSONSchemaInput(new FetchingJSONSchemaStore()); From 97116b1151a8942f640a264fa1c1c4a37512a482 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 11 Oct 2024 14:28:28 +0200 Subject: [PATCH 210/214] Pin WASM bindgen (#1129) Every time wasm-bindgen is updated we run into conflicts with the wasm-bindgen-cli version. Pin it to avoid this problem in the future. --- .github/workflows/build-wasm-internal.yml | 2 +- .github/workflows/build-wasm.yml | 2 +- Cargo.lock | 20 ++++++++++---------- crates/bitwarden-wasm-internal/Cargo.toml | 3 ++- crates/bitwarden-wasm/Cargo.toml | 3 ++- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-wasm-internal.yml b/.github/workflows/build-wasm-internal.yml index 99fe06c44..0be6b29c1 100644 --- a/.github/workflows/build-wasm-internal.yml +++ b/.github/workflows/build-wasm-internal.yml @@ -46,7 +46,7 @@ jobs: key: wasm-cargo-cache - name: Install wasm-bindgen-cli - run: cargo install wasm-bindgen-cli + run: cargo install wasm-bindgen-cli --version 0.2.95 - name: Build run: ./build.sh -r diff --git a/.github/workflows/build-wasm.yml b/.github/workflows/build-wasm.yml index 35c0ca6b6..117bbf2c7 100644 --- a/.github/workflows/build-wasm.yml +++ b/.github/workflows/build-wasm.yml @@ -46,7 +46,7 @@ jobs: key: wasm-cargo-cache - name: Install wasm-bindgen-cli - run: cargo install wasm-bindgen-cli + run: cargo install wasm-bindgen-cli --version 0.2.95 - name: Build run: ./build.sh -r diff --git a/Cargo.lock b/Cargo.lock index 024abbe00..e6ca566f9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4503,9 +4503,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.94" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef073ced962d62984fb38a36e5fdc1a2b23c9e0e1fa0689bb97afa4202ef6887" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -4516,9 +4516,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.94" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4bfab14ef75323f4eb75fa52ee0a3fb59611977fd3240da19b2cf36ff85030e" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", @@ -4543,9 +4543,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.94" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7bec9830f60924d9ceb3ef99d55c155be8afa76954edffbb5936ff4509474e7" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4553,9 +4553,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.94" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c74f6e152a76a2ad448e223b0fc0b6b5747649c3d769cc6bf45737bf97d0ed6" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", @@ -4566,9 +4566,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.94" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a42f6c679374623f295a8623adfe63d9284091245c3504bde47c17a3ce2777d9" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "wasm-bindgen-test" diff --git a/crates/bitwarden-wasm-internal/Cargo.toml b/crates/bitwarden-wasm-internal/Cargo.toml index 4f68c08d6..b18e412c9 100644 --- a/crates/bitwarden-wasm-internal/Cargo.toml +++ b/crates/bitwarden-wasm-internal/Cargo.toml @@ -21,7 +21,8 @@ console_log = { version = "1.0.0", features = ["color"] } js-sys = "0.3.68" log = "0.4.20" serde_json = ">=1.0.96, <2.0" -wasm-bindgen = { version = "0.2.91", features = ["serde-serialize"] } +# When upgrading wasm-bindgen, make sure to update the version in the workflows! +wasm-bindgen = { version = "=0.2.95", features = ["serde-serialize"] } wasm-bindgen-futures = "0.4.41" [lints] diff --git a/crates/bitwarden-wasm/Cargo.toml b/crates/bitwarden-wasm/Cargo.toml index fd3c278f8..b57a0192e 100644 --- a/crates/bitwarden-wasm/Cargo.toml +++ b/crates/bitwarden-wasm/Cargo.toml @@ -25,7 +25,8 @@ console_log = { version = "1.0.0", features = ["color"] } js-sys = "0.3.68" log = "0.4.20" serde = { version = "1.0.196", features = ["derive"] } -wasm-bindgen = { version = "0.2.91", features = ["serde-serialize"] } +# When upgrading wasm-bindgen, make sure to update the version in the workflows! +wasm-bindgen = { version = "=0.2.95", features = ["serde-serialize"] } wasm-bindgen-futures = "0.4.41" [dev-dependencies] From 43e5ae9165732ffb0b79a9fa6b9866b679d881f0 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 11 Oct 2024 15:32:44 +0200 Subject: [PATCH 211/214] Remove direct dependency to bitwarden in wasm-internal (#1131) In preparation for the bitwarden crate being removes we can stop depending on it in wasm-internal. --- Cargo.lock | 2 +- crates/bitwarden-wasm-internal/Cargo.toml | 2 +- crates/bitwarden-wasm-internal/src/client.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e6ca566f9..9f8552b65 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -681,7 +681,7 @@ dependencies = [ name = "bitwarden-wasm-internal" version = "0.1.0" dependencies = [ - "bitwarden", + "bitwarden-core", "console_error_panic_hook", "console_log", "js-sys", diff --git a/crates/bitwarden-wasm-internal/Cargo.toml b/crates/bitwarden-wasm-internal/Cargo.toml index b18e412c9..e943daca8 100644 --- a/crates/bitwarden-wasm-internal/Cargo.toml +++ b/crates/bitwarden-wasm-internal/Cargo.toml @@ -15,7 +15,7 @@ keywords.workspace = true crate-type = ["cdylib"] [dependencies] -bitwarden = { workspace = true, features = ["wasm"] } +bitwarden-core = { workspace = true, features = ["wasm", "internal"] } console_error_panic_hook = "0.1.7" console_log = { version = "1.0.0", features = ["color"] } js-sys = "0.3.68" diff --git a/crates/bitwarden-wasm-internal/src/client.rs b/crates/bitwarden-wasm-internal/src/client.rs index 994af1fcf..8f2fa80dd 100644 --- a/crates/bitwarden-wasm-internal/src/client.rs +++ b/crates/bitwarden-wasm-internal/src/client.rs @@ -1,7 +1,7 @@ extern crate console_error_panic_hook; use std::rc::Rc; -use bitwarden::{Client, ClientSettings}; +use bitwarden_core::{Client, ClientSettings}; use log::{set_max_level, Level}; use wasm_bindgen::prelude::*; From 639667c81f4ffef96f6c4bf40aa25bbb4349a990 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 14:38:29 +0200 Subject: [PATCH 212/214] [deps]: Lock file maintenance (#1139) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Update | Change | |---|---| | lockFileMaintenance | All locks refreshed | 🔧 This Pull Request updates lock files to use the latest dependency versions. --- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. đŸ‘ģ **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://redirect.github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 52 +++++++++++++++++++++++------------------------ package-lock.json | 6 +++--- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9f8552b65..678c86e57 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -784,9 +784,9 @@ dependencies = [ [[package]] name = "bytemuck" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" +checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" [[package]] name = "byteorder" @@ -855,9 +855,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.28" +version = "1.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" +checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" dependencies = [ "shlex", ] @@ -2210,9 +2210,9 @@ checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" [[package]] name = "js-sys" -version = "0.3.71" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cb94a0ffd3f3ee755c20f7d8752f45cac88605a4dcf808abcff72873296ec7b" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] @@ -2383,9 +2383,9 @@ dependencies = [ [[package]] name = "napi" -version = "2.16.11" +version = "2.16.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53575dfa17f208dd1ce3a2da2da4659aae393b256a472f2738a8586a6c4107fd" +checksum = "3a84fdaf64da2b2d86b1be5db1b81963353bf00f7bef4b9e2668bbe6f72e8eb3" dependencies = [ "bitflags 2.6.0", "ctor", @@ -2917,9 +2917,9 @@ source = "git+https://github.com/bitwarden/passkey-rs?rev=ff757604cd7b4e8f321ed1 [[package]] name = "pyo3" -version = "0.22.3" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15ee168e30649f7f234c3d49ef5a7a6cbf5134289bc46c29ff3155fa3221c225" +checksum = "00e89ce2565d6044ca31a3eb79a334c3a79a841120a98f64eea9f579564cb691" dependencies = [ "cfg-if", "indoc", @@ -2935,9 +2935,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.22.3" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e61cef80755fe9e46bb8a0b8f20752ca7676dcc07a5277d8b7768c6172e529b3" +checksum = "d8afbaf3abd7325e08f35ffb8deb5892046fcb2608b703db6a583a5ba4cea01e" dependencies = [ "once_cell", "target-lexicon", @@ -2945,9 +2945,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.22.3" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ce096073ec5405f5ee2b8b31f03a68e02aa10d5d4f565eca04acc41931fa1c" +checksum = "ec15a5ba277339d04763f4c23d85987a5b08cbb494860be141e6a10a8eb88022" dependencies = [ "libc", "pyo3-build-config", @@ -2966,9 +2966,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.22.3" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2440c6d12bc8f3ae39f1e775266fa5122fd0c8891ce7520fa6048e683ad3de28" +checksum = "15e0f01b5364bcfbb686a52fc4181d412b708a68ed20c330db9fc8d2c2bf5a43" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -2978,9 +2978,9 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.22.3" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1be962f0e06da8f8465729ea2cb71a416d2257dff56cbe40a70d3e62a93ae5d1" +checksum = "a09b550200e1e5ed9176976d0060cbc2ea82dc8515da07885e7b8153a85caacb" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -4531,9 +4531,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.44" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65471f79c1022ffa5291d33520cbbb53b7687b01c2f8e83b57d102eed7ed479d" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" dependencies = [ "cfg-if", "js-sys", @@ -4572,9 +4572,9 @@ checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "wasm-bindgen-test" -version = "0.3.44" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a93d2a9ae98f1af8953f6415397299d808cce0a24f6d7c613d27bd83edf98da8" +checksum = "d381749acb0943d357dcbd8f0b100640679883fcdeeef04def49daf8d33a5426" dependencies = [ "console_error_panic_hook", "js-sys", @@ -4587,9 +4587,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.44" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb8b294691f640bad8f2bb35a11bb28272701b1d687bd5fd661a27684e894d4d" +checksum = "c97b2ef2c8d627381e51c071c2ab328eac606d3f69dd82bcbca20a9e389d95f0" dependencies = [ "proc-macro2", "quote", @@ -4598,9 +4598,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.71" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44188d185b5bdcae1052d08bcbcf9091a5524038d4572cc4f4f2bb9d5554ddd9" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", diff --git a/package-lock.json b/package-lock.json index 894ec74eb..e41dd2a89 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2292,9 +2292,9 @@ } }, "node_modules/yaml": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.1.tgz", - "integrity": "sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==", + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.0.tgz", + "integrity": "sha512-a6ae//JvKDEra2kdi1qzCyrJW/WZCgFi8ydDV+eXExl95t+5R+ijnqHJbz9tmMh8FUjx3iv2fCQ4dclAQlO2UQ==", "dev": true, "license": "ISC", "bin": { From a0f45304563e6c02471012801f5a9bd7f70c1f2c Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Mon, 14 Oct 2024 14:44:31 +0200 Subject: [PATCH 213/214] [PM-11764] Implement account switching and sdk initialization (#1116) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 🎟ī¸ Tracking ## 📔 Objective - Expose crypto client - Add error handling ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## đŸĻŽ Reviewer guidelines - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹī¸ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠ī¸ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or â™ģī¸ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes --- Cargo.lock | 6 ++++ crates/bitwarden-core/src/mobile/crypto.rs | 6 ++++ crates/bitwarden-crypto/Cargo.toml | 3 ++ .../src/enc_string/asymmetric.rs | 7 +++- .../src/enc_string/symmetric.rs | 6 ++++ .../bitwarden-crypto/src/keys/master_key.rs | 3 ++ crates/bitwarden-vault/Cargo.toml | 3 ++ crates/bitwarden-vault/src/folder.rs | 4 +++ crates/bitwarden-wasm-internal/Cargo.toml | 2 ++ crates/bitwarden-wasm-internal/src/client.rs | 12 ++++++- crates/bitwarden-wasm-internal/src/crypto.rs | 33 +++++++++++++++++++ .../src/custom_types.rs | 22 +++++++++++++ crates/bitwarden-wasm-internal/src/error.js | 13 ++++++++ crates/bitwarden-wasm-internal/src/error.rs | 27 +++++++++++++++ crates/bitwarden-wasm-internal/src/lib.rs | 8 +++++ .../src/vault/folders.rs | 24 ++++++++++++++ .../bitwarden-wasm-internal/src/vault/mod.rs | 24 ++++++++++++++ languages/js/sdk-internal/.gitignore | 1 + 18 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 crates/bitwarden-wasm-internal/src/crypto.rs create mode 100644 crates/bitwarden-wasm-internal/src/custom_types.rs create mode 100644 crates/bitwarden-wasm-internal/src/error.js create mode 100644 crates/bitwarden-wasm-internal/src/error.rs create mode 100644 crates/bitwarden-wasm-internal/src/vault/folders.rs create mode 100644 crates/bitwarden-wasm-internal/src/vault/mod.rs diff --git a/Cargo.lock b/Cargo.lock index 678c86e57..e9b7646b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -475,8 +475,10 @@ dependencies = [ "sha2", "subtle", "thiserror", + "tsify-next", "uniffi", "uuid", + "wasm-bindgen", "zeroize", ] @@ -656,8 +658,10 @@ dependencies = [ "sha2", "thiserror", "tokio", + "tsify-next", "uniffi", "uuid", + "wasm-bindgen", ] [[package]] @@ -682,6 +686,8 @@ name = "bitwarden-wasm-internal" version = "0.1.0" dependencies = [ "bitwarden-core", + "bitwarden-crypto", + "bitwarden-vault", "console_error_panic_hook", "console_log", "js-sys", diff --git a/crates/bitwarden-core/src/mobile/crypto.rs b/crates/bitwarden-core/src/mobile/crypto.rs index 2aae903c5..1b027df43 100644 --- a/crates/bitwarden-core/src/mobile/crypto.rs +++ b/crates/bitwarden-core/src/mobile/crypto.rs @@ -6,6 +6,8 @@ use bitwarden_crypto::{ }; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +#[cfg(feature = "wasm")] +use {tsify_next::Tsify, wasm_bindgen::prelude::*}; use crate::{ client::{encryption_settings::EncryptionSettingsError, LoginMethod, UserLoginMethod}, @@ -16,6 +18,7 @@ use crate::{ #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] +#[cfg_attr(feature = "wasm", derive(Tsify), tsify(into_wasm_abi, from_wasm_abi))] pub struct InitUserCryptoRequest { /// The user's KDF parameters, as received from the prelogin request pub kdf_params: Kdf, @@ -30,6 +33,7 @@ pub struct InitUserCryptoRequest { #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "uniffi", derive(uniffi::Enum))] +#[cfg_attr(feature = "wasm", derive(Tsify), tsify(into_wasm_abi, from_wasm_abi))] pub enum InitUserCryptoMethod { Password { /// The user's master password @@ -73,6 +77,7 @@ pub enum InitUserCryptoMethod { #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "uniffi", derive(uniffi::Enum))] +#[cfg_attr(feature = "wasm", derive(Tsify), tsify(into_wasm_abi, from_wasm_abi))] pub enum AuthRequestMethod { UserKey { /// User Key protected by the private key provided in `AuthRequestResponse`. @@ -185,6 +190,7 @@ pub async fn initialize_user_crypto( #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] +#[cfg_attr(feature = "wasm", derive(Tsify), tsify(into_wasm_abi, from_wasm_abi))] pub struct InitOrgCryptoRequest { /// The encryption keys for all the organizations the user is a part of pub organization_keys: HashMap, diff --git a/crates/bitwarden-crypto/Cargo.toml b/crates/bitwarden-crypto/Cargo.toml index 3254640fe..7671a7762 100644 --- a/crates/bitwarden-crypto/Cargo.toml +++ b/crates/bitwarden-crypto/Cargo.toml @@ -15,6 +15,7 @@ keywords.workspace = true [features] default = [] +wasm = ["dep:tsify-next", "dep:wasm-bindgen"] # WASM support uniffi = ["dep:uniffi"] # Uniffi bindings no-memory-hardening = [] # Disable memory hardening features @@ -42,8 +43,10 @@ sha1 = ">=0.10.5, <0.11" sha2 = ">=0.10.6, <0.11" subtle = ">=2.5.0, <3.0" thiserror = { workspace = true } +tsify-next = { workspace = true, optional = true } uniffi = { workspace = true, optional = true } uuid = { workspace = true } +wasm-bindgen = { workspace = true, optional = true } zeroize = { version = ">=1.7.0, <2.0", features = ["derive", "aarch64"] } [dev-dependencies] diff --git a/crates/bitwarden-crypto/src/enc_string/asymmetric.rs b/crates/bitwarden-crypto/src/enc_string/asymmetric.rs index f9bda838a..9d4f0d635 100644 --- a/crates/bitwarden-crypto/src/enc_string/asymmetric.rs +++ b/crates/bitwarden-crypto/src/enc_string/asymmetric.rs @@ -11,11 +11,16 @@ use crate::{ rsa::encrypt_rsa2048_oaep_sha1, AsymmetricCryptoKey, AsymmetricEncryptable, KeyDecryptable, }; - // This module is a workaround to avoid deprecated warnings that come from the ZeroizeOnDrop // macro expansion #[allow(deprecated)] mod internal { + #[cfg(feature = "wasm")] + #[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] + const TS_CUSTOM_TYPES: &'static str = r#" + export type AsymmetricEncString = string; + "#; + /// # Encrypted string primitive /// /// [AsymmetricEncString] is a Bitwarden specific primitive that represents an asymmetrically diff --git a/crates/bitwarden-crypto/src/enc_string/symmetric.rs b/crates/bitwarden-crypto/src/enc_string/symmetric.rs index 1fc9b3a9d..69711f74a 100644 --- a/crates/bitwarden-crypto/src/enc_string/symmetric.rs +++ b/crates/bitwarden-crypto/src/enc_string/symmetric.rs @@ -11,6 +11,12 @@ use crate::{ KeyDecryptable, KeyEncryptable, LocateKey, SymmetricCryptoKey, }; +#[cfg(feature = "wasm")] +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_CUSTOM_TYPES: &'static str = r#" +export type EncString = string; +"#; + /// # Encrypted string primitive /// /// [EncString] is a Bitwarden specific primitive that represents a symmetrically encrypted string. diff --git a/crates/bitwarden-crypto/src/keys/master_key.rs b/crates/bitwarden-crypto/src/keys/master_key.rs index fc9762c3c..7a1e49596 100644 --- a/crates/bitwarden-crypto/src/keys/master_key.rs +++ b/crates/bitwarden-crypto/src/keys/master_key.rs @@ -5,6 +5,8 @@ use generic_array::{typenum::U32, GenericArray}; use rand::Rng; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +#[cfg(feature = "wasm")] +use {tsify_next::Tsify, wasm_bindgen::prelude::*}; use super::utils::{derive_kdf_key, stretch_kdf_key}; use crate::{util, CryptoError, EncString, KeyDecryptable, Result, SymmetricCryptoKey, UserKey}; @@ -16,6 +18,7 @@ use crate::{util, CryptoError, EncString, KeyDecryptable, Result, SymmetricCrypt #[derive(Serialize, Deserialize, Debug, JsonSchema, Clone)] #[serde(rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "uniffi", derive(uniffi::Enum))] +#[cfg_attr(feature = "wasm", derive(Tsify), tsify(into_wasm_abi, from_wasm_abi))] pub enum Kdf { PBKDF2 { iterations: NonZeroU32, diff --git a/crates/bitwarden-vault/Cargo.toml b/crates/bitwarden-vault/Cargo.toml index 4c41e139c..3c7757e2f 100644 --- a/crates/bitwarden-vault/Cargo.toml +++ b/crates/bitwarden-vault/Cargo.toml @@ -19,6 +19,7 @@ uniffi = [ "bitwarden-crypto/uniffi", "dep:uniffi", ] # Uniffi bindings +wasm = ["dep:tsify-next", "dep:wasm-bindgen"] # WASM support [dependencies] base64 = ">=0.22.1, <0.23" @@ -38,6 +39,8 @@ sha2 = ">=0.10.6, <0.11" thiserror = { workspace = true } uniffi = { version = "=0.28.1", optional = true } uuid = { workspace = true } +tsify-next = { workspace = true, optional = true } +wasm-bindgen = { workspace = true, optional = true } [dev-dependencies] tokio = { workspace = true, features = ["rt"] } diff --git a/crates/bitwarden-vault/src/folder.rs b/crates/bitwarden-vault/src/folder.rs index c5ab1401b..f57b8ee15 100644 --- a/crates/bitwarden-vault/src/folder.rs +++ b/crates/bitwarden-vault/src/folder.rs @@ -7,12 +7,15 @@ use chrono::{DateTime, Utc}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use uuid::Uuid; +#[cfg(feature = "wasm")] +use {tsify_next::Tsify, wasm_bindgen::prelude::*}; use crate::VaultParseError; #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase")] #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] +#[cfg_attr(feature = "wasm", derive(Tsify), tsify(into_wasm_abi, from_wasm_abi))] pub struct Folder { id: Option, name: EncString, @@ -22,6 +25,7 @@ pub struct Folder { #[derive(Serialize, Deserialize, Debug, JsonSchema)] #[serde(rename_all = "camelCase")] #[cfg_attr(feature = "uniffi", derive(uniffi::Record))] +#[cfg_attr(feature = "wasm", derive(Tsify), tsify(into_wasm_abi, from_wasm_abi))] pub struct FolderView { pub id: Option, pub name: String, diff --git a/crates/bitwarden-wasm-internal/Cargo.toml b/crates/bitwarden-wasm-internal/Cargo.toml index e943daca8..33f8128e7 100644 --- a/crates/bitwarden-wasm-internal/Cargo.toml +++ b/crates/bitwarden-wasm-internal/Cargo.toml @@ -16,6 +16,8 @@ crate-type = ["cdylib"] [dependencies] bitwarden-core = { workspace = true, features = ["wasm", "internal"] } +bitwarden-crypto = { workspace = true, features = ["wasm"] } +bitwarden-vault = { workspace = true, features = ["wasm"] } console_error_panic_hook = "0.1.7" console_log = { version = "1.0.0", features = ["color"] } js-sys = "0.3.68" diff --git a/crates/bitwarden-wasm-internal/src/client.rs b/crates/bitwarden-wasm-internal/src/client.rs index 8f2fa80dd..ac7779b2f 100644 --- a/crates/bitwarden-wasm-internal/src/client.rs +++ b/crates/bitwarden-wasm-internal/src/client.rs @@ -5,6 +5,8 @@ use bitwarden_core::{Client, ClientSettings}; use log::{set_max_level, Level}; use wasm_bindgen::prelude::*; +use crate::{vault::ClientVault, ClientCrypto}; + #[wasm_bindgen] pub enum LogLevel { Trace, @@ -27,7 +29,7 @@ fn convert_level(level: LogLevel) -> Level { // Rc<...> is to avoid needing to take ownership of the Client during our async run_command // function https://github.com/rustwasm/wasm-bindgen/issues/2195#issuecomment-799588401 #[wasm_bindgen] -pub struct BitwardenClient(Rc); +pub struct BitwardenClient(pub(crate) Rc); #[wasm_bindgen] impl BitwardenClient { @@ -54,4 +56,12 @@ impl BitwardenClient { res.text().await.map_err(|e| e.to_string()) } + + pub fn crypto(&self) -> ClientCrypto { + ClientCrypto::new(self.0.clone()) + } + + pub fn vault(&self) -> ClientVault { + ClientVault::new(self.0.clone()) + } } diff --git a/crates/bitwarden-wasm-internal/src/crypto.rs b/crates/bitwarden-wasm-internal/src/crypto.rs new file mode 100644 index 000000000..f1b581964 --- /dev/null +++ b/crates/bitwarden-wasm-internal/src/crypto.rs @@ -0,0 +1,33 @@ +use std::rc::Rc; + +use bitwarden_core::{ + mobile::crypto::{InitOrgCryptoRequest, InitUserCryptoRequest}, + Client, +}; +use wasm_bindgen::prelude::*; + +use crate::error::Result; + +#[wasm_bindgen] +pub struct ClientCrypto(Rc); + +impl ClientCrypto { + pub fn new(client: Rc) -> Self { + Self(client) + } +} + +#[wasm_bindgen] +impl ClientCrypto { + /// Initialization method for the user crypto. Needs to be called before any other crypto + /// operations. + pub async fn initialize_user_crypto(&self, req: InitUserCryptoRequest) -> Result<()> { + Ok(self.0.crypto().initialize_user_crypto(req).await?) + } + + /// Initialization method for the organization crypto. Needs to be called after + /// `initialize_user_crypto` but before any other crypto operations. + pub async fn initialize_org_crypto(&self, req: InitOrgCryptoRequest) -> Result<()> { + Ok(self.0.crypto().initialize_org_crypto(req).await?) + } +} diff --git a/crates/bitwarden-wasm-internal/src/custom_types.rs b/crates/bitwarden-wasm-internal/src/custom_types.rs new file mode 100644 index 000000000..8d20bf85d --- /dev/null +++ b/crates/bitwarden-wasm-internal/src/custom_types.rs @@ -0,0 +1,22 @@ +/// This file contains custom TypeScript for types defined by external crates. +/// Everything in the string below is appended to the generated TypeScript definition file. +#[wasm_bindgen::prelude::wasm_bindgen(typescript_custom_section)] +const TS_CUSTOM_TYPES: &'static str = r#" +export type Uuid = string; + +/** + * RFC3339 compliant date-time string. + * @typeParam T - Not used in JavaScript. + */ +export type DateTime = string; + +/** + * UTC date-time string. Not used in JavaScript. + */ +export type Utc = unknown; + +/** + * An integer that is known not to equal zero. + */ +export type NonZeroU32 = number; +"#; diff --git a/crates/bitwarden-wasm-internal/src/error.js b/crates/bitwarden-wasm-internal/src/error.js new file mode 100644 index 000000000..cd3d3a346 --- /dev/null +++ b/crates/bitwarden-wasm-internal/src/error.js @@ -0,0 +1,13 @@ +/** + * Error thrown by the WASM module. + * @param {string} message - Error message. + * @extends Error + */ +class WasmError extends Error { + constructor(message) { + super(message); + this.name = "WasmError"; + } +} + +exports.WasmError = WasmError; diff --git a/crates/bitwarden-wasm-internal/src/error.rs b/crates/bitwarden-wasm-internal/src/error.rs new file mode 100644 index 000000000..2750d2629 --- /dev/null +++ b/crates/bitwarden-wasm-internal/src/error.rs @@ -0,0 +1,27 @@ +use wasm_bindgen::prelude::*; + +// Importing an error class defined in JavaScript instead of defining it in Rust +// allows us to extend the `Error` class. It also provides much better console output. +#[wasm_bindgen(module = "/src/error.js")] +extern "C" { + type WasmError; + + #[wasm_bindgen(constructor)] + fn new(message: String) -> WasmError; +} + +pub type Result = std::result::Result; + +pub struct GenericError(pub String); + +impl From for GenericError { + fn from(error: T) -> Self { + GenericError(error.to_string()) + } +} + +impl From for JsValue { + fn from(error: GenericError) -> Self { + WasmError::new(error.0).into() + } +} diff --git a/crates/bitwarden-wasm-internal/src/lib.rs b/crates/bitwarden-wasm-internal/src/lib.rs index b79c47fca..6367ff317 100644 --- a/crates/bitwarden-wasm-internal/src/lib.rs +++ b/crates/bitwarden-wasm-internal/src/lib.rs @@ -1 +1,9 @@ mod client; +mod crypto; +mod custom_types; +mod error; +mod vault; + +pub use client::BitwardenClient; +pub use crypto::ClientCrypto; +pub use vault::{folders::ClientFolders, ClientVault}; diff --git a/crates/bitwarden-wasm-internal/src/vault/folders.rs b/crates/bitwarden-wasm-internal/src/vault/folders.rs new file mode 100644 index 000000000..652892694 --- /dev/null +++ b/crates/bitwarden-wasm-internal/src/vault/folders.rs @@ -0,0 +1,24 @@ +use std::rc::Rc; + +use bitwarden_core::Client; +use bitwarden_vault::{ClientVaultExt, Folder, FolderView}; +use wasm_bindgen::prelude::*; + +use crate::error::Result; + +#[wasm_bindgen] +pub struct ClientFolders(Rc); + +impl ClientFolders { + pub fn new(client: Rc) -> Self { + Self(client) + } +} + +#[wasm_bindgen] +impl ClientFolders { + /// Decrypt folder + pub fn decrypt(&self, folder: Folder) -> Result { + Ok(self.0.vault().folders().decrypt(folder)?) + } +} diff --git a/crates/bitwarden-wasm-internal/src/vault/mod.rs b/crates/bitwarden-wasm-internal/src/vault/mod.rs new file mode 100644 index 000000000..11db0e130 --- /dev/null +++ b/crates/bitwarden-wasm-internal/src/vault/mod.rs @@ -0,0 +1,24 @@ +pub mod folders; + +use std::rc::Rc; + +use bitwarden_core::Client; +use wasm_bindgen::prelude::*; + +use crate::ClientFolders; + +#[wasm_bindgen] +pub struct ClientVault(Rc); + +impl ClientVault { + pub fn new(client: Rc) -> Self { + Self(client) + } +} + +#[wasm_bindgen] +impl ClientVault { + pub fn folders(&self) -> ClientFolders { + ClientFolders::new(self.0.clone()) + } +} diff --git a/languages/js/sdk-internal/.gitignore b/languages/js/sdk-internal/.gitignore index ef69b9de9..99cddcd21 100644 --- a/languages/js/sdk-internal/.gitignore +++ b/languages/js/sdk-internal/.gitignore @@ -1,3 +1,4 @@ +**/snippets/**/*.js bitwarden_wasm_internal_bg.js bitwarden_wasm_internal_bg.wasm bitwarden_wasm_internal_bg.wasm.d.ts From d094901a8badd3f84e1173440839c58639c3bbe6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:37:12 +0200 Subject: [PATCH 214/214] [deps]: Update @openapitools/openapi-generator-cli to v2.14.0 (#1007) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@openapitools/openapi-generator-cli](https://redirect.github.com/OpenAPITools/openapi-generator-cli) | [`2.13.4` -> `2.14.0`](https://renovatebot.com/diffs/npm/@openapitools%2fopenapi-generator-cli/2.13.4/2.14.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@openapitools%2fopenapi-generator-cli/2.14.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@openapitools%2fopenapi-generator-cli/2.14.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@openapitools%2fopenapi-generator-cli/2.13.4/2.14.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@openapitools%2fopenapi-generator-cli/2.13.4/2.14.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
OpenAPITools/openapi-generator-cli (@​openapitools/openapi-generator-cli) ### [`v2.14.0`](https://redirect.github.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.14.0) [Compare Source](https://redirect.github.com/OpenAPITools/openapi-generator-cli/compare/v2.13.13...v2.14.0) ##### Features - **config schema:** add openapi-normalizer generator property ([#​830](https://redirect.github.com/OpenAPITools/openapi-generator-cli/issues/830)) ([c91d116](https://redirect.github.com/OpenAPITools/openapi-generator-cli/commit/c91d116a1fe4b8ed9270c4546447173b0af1e6ab)) ### [`v2.13.13`](https://redirect.github.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.13.13) [Compare Source](https://redirect.github.com/OpenAPITools/openapi-generator-cli/compare/v2.13.12...v2.13.13) ##### Bug Fixes - update `glob` package ([#​828](https://redirect.github.com/OpenAPITools/openapi-generator-cli/issues/828)) ([4d88fe2](https://redirect.github.com/OpenAPITools/openapi-generator-cli/commit/4d88fe2c1c9c23097b197cbb1161fcf827a81770)) ### [`v2.13.12`](https://redirect.github.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.13.12) [Compare Source](https://redirect.github.com/OpenAPITools/openapi-generator-cli/compare/v2.13.11...v2.13.12) ##### Bug Fixes - **deps:** update dependency axios to v1.7.7 ([#​817](https://redirect.github.com/OpenAPITools/openapi-generator-cli/issues/817)) ([f5b3ede](https://redirect.github.com/OpenAPITools/openapi-generator-cli/commit/f5b3eded0a6b7b4a5761deb6dec6287fb670d014)) ### [`v2.13.11`](https://redirect.github.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.13.11) [Compare Source](https://redirect.github.com/OpenAPITools/openapi-generator-cli/compare/v2.13.10...v2.13.11) ##### Bug Fixes - **deps:** update dependency tslib to v2.7.0 ([#​810](https://redirect.github.com/OpenAPITools/openapi-generator-cli/issues/810)) ([d800f75](https://redirect.github.com/OpenAPITools/openapi-generator-cli/commit/d800f75d9b4c77f78e8f3e7cf082ed3f36add0bd)) ### [`v2.13.10`](https://redirect.github.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.13.10) [Compare Source](https://redirect.github.com/OpenAPITools/openapi-generator-cli/compare/v2.13.9...v2.13.10) ##### Bug Fixes - **deps:** update dependency https-proxy-agent to v7.0.5 ([#​800](https://redirect.github.com/OpenAPITools/openapi-generator-cli/issues/800)) ([e8226d8](https://redirect.github.com/OpenAPITools/openapi-generator-cli/commit/e8226d8e2f92da5649e5e679dcd155f69464205c)) ### [`v2.13.9`](https://redirect.github.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.13.9) [Compare Source](https://redirect.github.com/OpenAPITools/openapi-generator-cli/compare/v2.13.8...v2.13.9) ##### Bug Fixes - **[#​802](https://redirect.github.com/OpenAPITools/openapi-generator-cli/issues/802):** better error handling ([#​812](https://redirect.github.com/OpenAPITools/openapi-generator-cli/issues/812)) ([1879a1e](https://redirect.github.com/OpenAPITools/openapi-generator-cli/commit/1879a1eda21a7757ce0eab748d381d985e52d792)), closes [#​802](https://redirect.github.com/OpenAPITools/openapi-generator-cli/issues/802) [#​802](https://redirect.github.com/OpenAPITools/openapi-generator-cli/issues/802) [#​802](https://redirect.github.com/OpenAPITools/openapi-generator-cli/issues/802) ### [`v2.13.8`](https://redirect.github.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.13.8) [Compare Source](https://redirect.github.com/OpenAPITools/openapi-generator-cli/compare/v2.13.7...v2.13.8) ##### Bug Fixes - **[#​802](https://redirect.github.com/OpenAPITools/openapi-generator-cli/issues/802):** add fallback to default versions if search returns errors ([#​811](https://redirect.github.com/OpenAPITools/openapi-generator-cli/issues/811)) ([129c002](https://redirect.github.com/OpenAPITools/openapi-generator-cli/commit/129c00259d9f842f42b1772cc6baf1eef73ac797)), closes [#​802](https://redirect.github.com/OpenAPITools/openapi-generator-cli/issues/802) ### [`v2.13.7`](https://redirect.github.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.13.7) [Compare Source](https://redirect.github.com/OpenAPITools/openapi-generator-cli/compare/v2.13.6...v2.13.7) ##### Bug Fixes - **deps:** update nest dependencies to v10.4.2 ([#​801](https://redirect.github.com/OpenAPITools/openapi-generator-cli/issues/801)) ([fff1d32](https://redirect.github.com/OpenAPITools/openapi-generator-cli/commit/fff1d32a1f313781fe17eedf3d21d4052d8b09e9)) ### [`v2.13.6`](https://redirect.github.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.13.6) [Compare Source](https://redirect.github.com/OpenAPITools/openapi-generator-cli/compare/v2.13.5...v2.13.6) ##### Bug Fixes - **deps:** update dependency [@​nestjs/axios](https://redirect.github.com/nestjs/axios) to v3.0.3 ([#​799](https://redirect.github.com/OpenAPITools/openapi-generator-cli/issues/799)) ([868d55e](https://redirect.github.com/OpenAPITools/openapi-generator-cli/commit/868d55eb989111296a068d1c521e45f5a13889b0)) ### [`v2.13.5`](https://redirect.github.com/OpenAPITools/openapi-generator-cli/releases/tag/v2.13.5) [Compare Source](https://redirect.github.com/OpenAPITools/openapi-generator-cli/compare/v2.13.4...v2.13.5) ##### Bug Fixes - **deps:** update dependency axios to v1.7.4 \[security] ([#​789](https://redirect.github.com/OpenAPITools/openapi-generator-cli/issues/789)) ([18abce4](https://redirect.github.com/OpenAPITools/openapi-generator-cli/commit/18abce41f5fac12e574977e175adf32a42f8b5a6))
--- ### Configuration 📅 **Schedule**: Branch creation - "every 2nd week starting on the 2 week of the year before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). đŸšĻ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. â™ģ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/bitwarden/sdk). Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 215 ++++++++++++++++++++++------------------------ package.json | 2 +- 2 files changed, 102 insertions(+), 115 deletions(-) diff --git a/package-lock.json b/package-lock.json index e41dd2a89..bdf9b4859 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.0", "license": "SEE LICENSE IN LICENSE", "devDependencies": { - "@openapitools/openapi-generator-cli": "2.13.4", + "@openapitools/openapi-generator-cli": "2.14.0", "prettier": "3.3.3", "quicktype-core": "23.0.170", "rimraf": "6.0.1", @@ -192,9 +192,9 @@ } }, "node_modules/@nestjs/axios": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-3.0.2.tgz", - "integrity": "sha512-Z6GuOUdNQjP7FX+OuV2Ybyamse+/e0BFdTWBX5JxpBDKA+YkdLynDgG6HTF04zy6e9zPa19UX0WA2VDoehwhXQ==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@nestjs/axios/-/axios-3.0.3.tgz", + "integrity": "sha512-h6TCn3yJwD6OKqqqfmtRS5Zo4E46Ip2n+gK1sqwzNBC+qxQ9xpCu+ODVRFur6V3alHSCSBxb3nNtt73VEdluyA==", "dev": true, "license": "MIT", "peerDependencies": { @@ -204,14 +204,14 @@ } }, "node_modules/@nestjs/common": { - "version": "10.3.0", - "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.3.0.tgz", - "integrity": "sha512-DGv34UHsZBxCM3H5QGE2XE/+oLJzz5+714JQjBhjD9VccFlQs3LRxo/epso4l7nJIiNlZkPyIUC8WzfU/5RTsQ==", + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.4.3.tgz", + "integrity": "sha512-4hbLd3XIJubHSylYd/1WSi4VQvG68KM/ECYpMDqA3k3J1/T17SAg40sDoq3ZoO5OZgU0xuNyjuISdOTjs11qVg==", "dev": true, "license": "MIT", "dependencies": { "iterare": "1.2.1", - "tslib": "2.6.2", + "tslib": "2.7.0", "uid": "2.0.2" }, "funding": { @@ -221,7 +221,7 @@ "peerDependencies": { "class-transformer": "*", "class-validator": "*", - "reflect-metadata": "^0.1.12", + "reflect-metadata": "^0.1.12 || ^0.2.0", "rxjs": "^7.1.0" }, "peerDependenciesMeta": { @@ -234,9 +234,9 @@ } }, "node_modules/@nestjs/core": { - "version": "10.3.0", - "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.3.0.tgz", - "integrity": "sha512-N06P5ncknW/Pm8bj964WvLIZn2gNhHliCBoAO1LeBvNImYkecqKcrmLbY49Fa1rmMfEM3MuBHeDys3edeuYAOA==", + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.4.3.tgz", + "integrity": "sha512-6OQz+5C8mT8yRtfvE5pPCq+p6w5jDot+oQku1KzQ24ABn+lay1KGuJwcKZhdVNuselx+8xhdMxknZTA8wrGLIg==", "dev": true, "hasInstallScript": true, "license": "MIT", @@ -244,8 +244,8 @@ "@nuxtjs/opencollective": "0.3.2", "fast-safe-stringify": "2.1.1", "iterare": "1.2.1", - "path-to-regexp": "3.2.0", - "tslib": "2.6.2", + "path-to-regexp": "3.3.0", + "tslib": "2.7.0", "uid": "2.0.2" }, "funding": { @@ -257,7 +257,7 @@ "@nestjs/microservices": "^10.0.0", "@nestjs/platform-express": "^10.0.0", "@nestjs/websockets": "^10.0.0", - "reflect-metadata": "^0.1.12", + "reflect-metadata": "^0.1.12 || ^0.2.0", "rxjs": "^7.1.0" }, "peerDependenciesMeta": { @@ -292,37 +292,37 @@ } }, "node_modules/@openapitools/openapi-generator-cli": { - "version": "2.13.4", - "resolved": "https://registry.npmjs.org/@openapitools/openapi-generator-cli/-/openapi-generator-cli-2.13.4.tgz", - "integrity": "sha512-4JKyrk55ohQK2FcuZbPdNvxdyXD14jjOIvE8hYjJ+E1cHbRbfXQXbYnjTODFE52Gx8eAxz8C9icuhDYDLn7nww==", + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/@openapitools/openapi-generator-cli/-/openapi-generator-cli-2.14.0.tgz", + "integrity": "sha512-k+ioQLtXLXgNbhQbp1UOxtaUnnYTWwAPev88hP5qauFA+eq4NyeQGNojknFssXg2x0VT0TUGmU3PZ2DiQ70IVg==", "dev": true, "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { - "@nestjs/axios": "3.0.2", - "@nestjs/common": "10.3.0", - "@nestjs/core": "10.3.0", + "@nestjs/axios": "3.0.3", + "@nestjs/common": "10.4.3", + "@nestjs/core": "10.4.3", "@nuxtjs/opencollective": "0.3.2", - "axios": "1.6.8", + "axios": "1.7.7", "chalk": "4.1.2", "commander": "8.3.0", "compare-versions": "4.1.4", "concurrently": "6.5.1", "console.table": "0.10.0", "fs-extra": "10.1.0", - "glob": "7.2.3", - "https-proxy-agent": "7.0.4", + "glob": "9.3.5", + "https-proxy-agent": "7.0.5", "inquirer": "8.2.6", "lodash": "4.17.21", "reflect-metadata": "0.1.13", "rxjs": "7.8.1", - "tslib": "2.6.2" + "tslib": "2.7.0" }, "bin": { "openapi-generator-cli": "main.js" }, "engines": { - "node": ">=10.0.0" + "node": ">=16" }, "funding": { "type": "opencollective", @@ -477,9 +477,9 @@ "license": "MIT" }, "node_modules/axios": { - "version": "1.6.8", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", - "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.7.tgz", + "integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", "dev": true, "license": "MIT", "dependencies": { @@ -529,14 +529,13 @@ } }, "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", "dev": true, "license": "MIT", "dependencies": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" + "balanced-match": "^1.0.0" } }, "node_modules/browser-or-node": { @@ -728,13 +727,6 @@ "dev": true, "license": "MIT" }, - "node_modules/concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", - "dev": true, - "license": "MIT" - }, "node_modules/concurrently": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-6.5.1.tgz", @@ -1115,27 +1107,68 @@ } }, "node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "deprecated": "Glob versions prior to v9 are no longer supported", + "version": "9.3.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-9.3.5.tgz", + "integrity": "sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q==", "dev": true, "license": "ISC", "dependencies": { "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "minimatch": "^8.0.2", + "minipass": "^4.2.4", + "path-scurry": "^1.6.1" }, "engines": { - "node": "*" + "node": ">=16 || 14 >=14.17" }, "funding": { "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/glob/node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/glob/node_modules/minipass": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.8.tgz", + "integrity": "sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=8" + } + }, + "node_modules/glob/node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob/node_modules/path-scurry/node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", @@ -1154,9 +1187,9 @@ } }, "node_modules/https-proxy-agent": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.4.tgz", - "integrity": "sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz", + "integrity": "sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw==", "dev": true, "license": "MIT", "dependencies": { @@ -1201,18 +1234,6 @@ ], "license": "BSD-3-Clause" }, - "node_modules/inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", - "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", - "dev": true, - "license": "ISC", - "dependencies": { - "once": "^1.3.0", - "wrappy": "1" - } - }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", @@ -1415,16 +1436,19 @@ } }, "node_modules/minimatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", - "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "version": "8.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-8.0.4.tgz", + "integrity": "sha512-W0Wvr9HyFXZRGIDgCicunpQ299OKXs9RgZfaukz4qAW/pJhcpUfupc9c+OObPOFueNy8VSrZgEmDtk6Kh4WzDA==", "dev": true, "license": "ISC", "dependencies": { - "brace-expansion": "^1.1.7" + "brace-expansion": "^2.0.1" }, "engines": { - "node": "*" + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/minipass": { @@ -1472,16 +1496,6 @@ } } }, - "node_modules/once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", - "dev": true, - "license": "ISC", - "dependencies": { - "wrappy": "1" - } - }, "node_modules/onetime": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", @@ -1546,16 +1560,6 @@ "dev": true, "license": "(MIT AND Zlib)" }, - "node_modules/path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -1584,9 +1588,9 @@ } }, "node_modules/path-to-regexp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.2.0.tgz", - "integrity": "sha512-jczvQbCUS7XmS7o+y1aEO9OBVFeZBQ1MDSEqmO7xSoPgOPoowY/SxLpZ6Vh97/8qHZOteiCKb7gkG9gA2ZUxJA==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.3.0.tgz", + "integrity": "sha512-qyCH421YQPS2WFDxDjftfc1ZR5WKQzVzqsp4n9M2kQhVOo/ByahFoUNJfl58kOcEGfQ//7weFTDhm+ss8Ecxgw==", "dev": true, "license": "MIT" }, @@ -1771,16 +1775,6 @@ "url": "https://github.com/sponsors/isaacs" } }, - "node_modules/rimraf/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, "node_modules/rimraf/node_modules/glob": { "version": "11.0.0", "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.0.tgz", @@ -2075,9 +2069,9 @@ } }, "node_modules/tslib": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", - "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", "dev": true, "license": "0BSD" }, @@ -2274,13 +2268,6 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", - "dev": true, - "license": "ISC" - }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/package.json b/package.json index e7e419467..fada308d2 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "devDependencies": { - "@openapitools/openapi-generator-cli": "2.13.4", + "@openapitools/openapi-generator-cli": "2.14.0", "prettier": "3.3.3", "quicktype-core": "23.0.170", "rimraf": "6.0.1",