From e7df4de423060f5c33c9ad868085540142c6b437 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 4 Sep 2023 14:55:59 +0200 Subject: [PATCH 01/12] Refactor master key operations (#207) --- crates/bitwarden/src/auth/login/mod.rs | 2 +- crates/bitwarden/src/client/auth_settings.rs | 79 +------- .../src/client/encryption_settings.rs | 24 +-- crates/bitwarden/src/client/mod.rs | 1 - crates/bitwarden/src/crypto/master_key.rs | 175 ++++++++++++++---- crates/bitwarden/src/crypto/mod.rs | 4 +- .../src/crypto/symmetric_crypto_key.rs | 1 + crates/bitwarden/src/mobile/kdf.rs | 2 +- .../src/platform/get_user_api_key.rs | 2 +- 9 files changed, 155 insertions(+), 135 deletions(-) diff --git a/crates/bitwarden/src/auth/login/mod.rs b/crates/bitwarden/src/auth/login/mod.rs index b1ab54ecf..e3b3ebffa 100644 --- a/crates/bitwarden/src/auth/login/mod.rs +++ b/crates/bitwarden/src/auth/login/mod.rs @@ -47,7 +47,7 @@ async fn determine_password_hash( ) -> Result { let pre_login = request_prelogin(client, email.to_owned()).await?; let auth_settings = AuthSettings::new(pre_login, email.to_owned()); - let password_hash = auth_settings.make_user_password_hash(password)?; + let password_hash = auth_settings.derive_user_password_hash(password)?; client.set_auth_settings(auth_settings); Ok(password_hash) diff --git a/crates/bitwarden/src/client/auth_settings.rs b/crates/bitwarden/src/client/auth_settings.rs index 5e23947a1..8d9aac3ca 100644 --- a/crates/bitwarden/src/client/auth_settings.rs +++ b/crates/bitwarden/src/client/auth_settings.rs @@ -1,20 +1,21 @@ use std::num::NonZeroU32; -use base64::Engine; #[cfg(feature = "internal")] use bitwarden_api_identity::models::{KdfType, PreloginResponseModel}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +#[cfg(feature = "internal")] use crate::{ - crypto::{PbkdfSha256Hmac, PBKDF_SHA256_HMAC_OUT_SIZE}, + crypto::{HashPurpose, MasterKey}, error::Result, - util::BASE64_ENGINE, }; #[derive(Debug)] pub(crate) struct AuthSettings { + #[cfg(feature = "internal")] pub email: String, + #[cfg(feature = "internal")] pub(crate) kdf: Kdf, } @@ -66,73 +67,9 @@ impl AuthSettings { Self { email, kdf } } - pub fn make_user_password_hash(&self, password: &str) -> Result { - self.make_password_hash(password, &self.email) - } - - pub fn make_password_hash(&self, password: &str, salt: &str) -> Result { - let hash: [u8; 32] = - crate::crypto::hash_kdf(password.as_bytes(), salt.as_bytes(), &self.kdf)?; - - // Server expects hash + 1 iteration - let login_hash = pbkdf2::pbkdf2_array::( - &hash, - password.as_bytes(), - 1, - ) - .expect("hash is a valid fixed size"); - - Ok(BASE64_ENGINE.encode(login_hash)) - } -} - -#[cfg(test)] -mod tests { - use bitwarden_api_identity::models::{KdfType, PreloginResponseModel}; - - use super::AuthSettings; - - #[test] - fn test_password_hash_pbkdf2() { - let res = PreloginResponseModel { - kdf: Some(KdfType::Variant0), - kdf_iterations: Some(100_000), - kdf_memory: None, - kdf_parallelism: None, - }; - let settings = AuthSettings::new(res, "test@bitwarden.com".into()); - - assert_eq!( - settings - .make_password_hash("asdfasdf", "test_salt") - .unwrap(), - "ZF6HjxUTSyBHsC+HXSOhZoXN+UuMnygV5YkWXCY4VmM=" - ); - assert_eq!( - settings.make_user_password_hash("asdfasdf").unwrap(), - "wmyadRMyBZOH7P/a/ucTCbSghKgdzDpPqUnu/DAVtSw=" - ); - } - - #[test] - fn test_password_hash_argon2id() { - let res = PreloginResponseModel { - kdf: Some(KdfType::Variant1), - kdf_iterations: Some(4), - kdf_memory: Some(32), - kdf_parallelism: Some(2), - }; - let settings = AuthSettings::new(res, "test@bitwarden.com".into()); - - assert_eq!( - settings - .make_password_hash("asdfasdf", "test_salt") - .unwrap(), - "PR6UjYmjmppTYcdyTiNbAhPJuQQOmynKbdEl1oyi/iQ=" - ); - assert_eq!( - settings.make_user_password_hash("asdfasdf").unwrap(), - "ImYMPyd/X7FPrWzbt+wRfmlICWTA25yZrOob4TBMEZw=" - ); + #[cfg(feature = "internal")] + pub fn derive_user_password_hash(&self, password: &str) -> Result { + let master_key = MasterKey::derive(password.as_bytes(), self.email.as_bytes(), &self.kdf)?; + master_key.derive_master_key_hash(password.as_bytes(), HashPurpose::ServerAuthorization) } } diff --git a/crates/bitwarden/src/client/encryption_settings.rs b/crates/bitwarden/src/client/encryption_settings.rs index 29fd38b42..495884c3a 100644 --- a/crates/bitwarden/src/client/encryption_settings.rs +++ b/crates/bitwarden/src/client/encryption_settings.rs @@ -33,25 +33,13 @@ impl EncryptionSettings { user_key: EncString, private_key: EncString, ) -> Result { - use crate::crypto::decrypt_aes256; - - // Stretch keys from the provided password - let (key, mac_key) = crate::crypto::stretch_key_password( - password.as_bytes(), - auth.email.as_bytes(), - &auth.kdf, - )?; - - // Decrypt the user key with the stretched key - let user_key = { - let (iv, mac, data) = match user_key { - EncString::AesCbc256_HmacSha256_B64 { iv, mac, data } => (iv, mac, data), - _ => return Err(CryptoError::InvalidKey.into()), - }; + use crate::crypto::MasterKey; - let dec = decrypt_aes256(&iv, &mac, data, Some(mac_key), key)?; - SymmetricCryptoKey::try_from(dec.as_slice())? - }; + // Derive master key from password + let master_key = MasterKey::derive(password.as_bytes(), auth.email.as_bytes(), &auth.kdf)?; + + // Decrypt the user key + let user_key = master_key.decrypt_user_key(user_key)?; // Decrypt the private key with the user key let private_key = { diff --git a/crates/bitwarden/src/client/mod.rs b/crates/bitwarden/src/client/mod.rs index c7bd1918c..017d14ec8 100644 --- a/crates/bitwarden/src/client/mod.rs +++ b/crates/bitwarden/src/client/mod.rs @@ -2,7 +2,6 @@ pub(crate) use client::*; pub(crate) mod access_token; -#[cfg(any(feature = "internal", feature = "mobile"))] pub mod auth_settings; #[allow(clippy::module_inception)] mod client; diff --git a/crates/bitwarden/src/crypto/master_key.rs b/crates/bitwarden/src/crypto/master_key.rs index f2df690f9..dee95d662 100644 --- a/crates/bitwarden/src/crypto/master_key.rs +++ b/crates/bitwarden/src/crypto/master_key.rs @@ -1,17 +1,58 @@ use aes::cipher::typenum::U32; +use base64::Engine; -use super::hkdf_expand; +use crate::util::BASE64_ENGINE; + +use super::{ + hkdf_expand, EncString, PbkdfSha256Hmac, SymmetricCryptoKey, PBKDF_SHA256_HMAC_OUT_SIZE, +}; use { crate::{client::auth_settings::Kdf, error::Result}, aes::cipher::generic_array::GenericArray, sha2::Digest, }; -pub(crate) fn hash_kdf(secret: &[u8], salt: &[u8], kdf: &Kdf) -> Result<[u8; 32]> { - use crate::crypto::PBKDF_SHA256_HMAC_OUT_SIZE; +#[derive(Copy, Clone)] +pub(crate) enum HashPurpose { + ServerAuthorization = 1, + // LocalAuthorization = 2, +} + +/// A Master Key. +pub(crate) struct MasterKey(SymmetricCryptoKey); + +impl MasterKey { + /// Derives a users master key from their password, email and KDF. + pub fn derive(password: &[u8], email: &[u8], kdf: &Kdf) -> Result { + derive_key(password, email, kdf).map(Self) + } + + /// Derive the master key hash, used for server authorization. + pub(crate) fn derive_master_key_hash( + &self, + password: &[u8], + purpose: HashPurpose, + ) -> Result { + let hash = pbkdf2::pbkdf2_array::( + &self.0.key, + password, + purpose as u32, + ) + .expect("hash is a valid fixed size"); + + Ok(BASE64_ENGINE.encode(hash)) + } - use super::PbkdfSha256Hmac; + pub(crate) fn decrypt_user_key(&self, user_key: EncString) -> Result { + let stretched_key = stretch_master_key(self)?; + let dec = user_key.decrypt_with_key(&stretched_key)?; + SymmetricCryptoKey::try_from(dec.as_slice()) + } +} + +/// Derive a generic key from a secret and salt using the provided KDF. +fn derive_key(secret: &[u8], salt: &[u8], kdf: &Kdf) -> Result { let hash = match kdf { Kdf::PBKDF2 { iterations } => pbkdf2::pbkdf2_array::< PbkdfSha256Hmac, @@ -47,32 +88,29 @@ pub(crate) fn hash_kdf(secret: &[u8], salt: &[u8], kdf: &Kdf) -> Result<[u8; 32] hash } }; - Ok(hash) + SymmetricCryptoKey::try_from(hash.as_slice()) } -pub(crate) fn stretch_key_password( - secret: &[u8], - salt: &[u8], - kdf: &Kdf, -) -> Result<(GenericArray, GenericArray)> { - let master_key: [u8; 32] = hash_kdf(secret, salt, kdf)?; - - let key: GenericArray = hkdf_expand(&master_key, Some("enc"))?; - let mac_key: GenericArray = hkdf_expand(&master_key, Some("mac"))?; +fn stretch_master_key(master_key: &MasterKey) -> Result { + let key: GenericArray = hkdf_expand(&master_key.0.key, Some("enc"))?; + let mac_key: GenericArray = hkdf_expand(&master_key.0.key, Some("mac"))?; - Ok((key, mac_key)) + Ok(SymmetricCryptoKey { + key, + mac_key: Some(mac_key), + }) } #[cfg(test)] mod tests { - use { - crate::{client::auth_settings::Kdf, crypto::stretch_key_password}, - std::num::NonZeroU32, - }; + use crate::crypto::SymmetricCryptoKey; + + use super::{stretch_master_key, HashPurpose, MasterKey}; + use {crate::client::auth_settings::Kdf, std::num::NonZeroU32}; #[test] - fn test_key_stretch_password_pbkdf2() { - let (key, mac) = stretch_key_password( + fn test_master_key_derive_pbkdf2() { + let master_key = MasterKey::derive( &b"67t9b5g67$%Dh89n"[..], "test_key".as_bytes(), &Kdf::PBKDF2 { @@ -82,24 +120,18 @@ mod tests { .unwrap(); assert_eq!( - key.as_slice(), [ - 111, 31, 178, 45, 238, 152, 37, 114, 143, 215, 124, 83, 135, 173, 195, 23, 142, - 134, 120, 249, 61, 132, 163, 182, 113, 197, 189, 204, 188, 21, 237, 96 - ] - ); - assert_eq!( - mac.as_slice(), - [ - 221, 127, 206, 234, 101, 27, 202, 38, 86, 52, 34, 28, 78, 28, 185, 16, 48, 61, 127, - 166, 209, 247, 194, 87, 232, 26, 48, 85, 193, 249, 179, 155 - ] + 31, 79, 104, 226, 150, 71, 177, 90, 194, 80, 172, 209, 17, 129, 132, 81, 138, 167, + 69, 167, 254, 149, 2, 27, 39, 197, 64, 42, 22, 195, 86, 75 + ], + master_key.0.key.as_slice() ); + assert_eq!(None, master_key.0.mac_key); } #[test] - fn test_key_stretch_password_argon2() { - let (key, mac) = stretch_key_password( + fn test_master_key_derive_argon2() { + let master_key = MasterKey::derive( &b"67t9b5g67$%Dh89n"[..], "test_key".as_bytes(), &Kdf::Argon2id { @@ -111,18 +143,79 @@ mod tests { .unwrap(); assert_eq!( - key.as_slice(), [ - 236, 253, 166, 121, 207, 124, 98, 149, 42, 141, 97, 226, 207, 71, 173, 60, 10, 0, - 184, 255, 252, 87, 62, 32, 188, 166, 173, 223, 146, 159, 222, 219 + 207, 240, 225, 177, 162, 19, 163, 76, 98, 106, 179, 175, 224, 9, 17, 240, 20, 147, + 237, 47, 246, 150, 141, 184, 62, 225, 131, 242, 51, 53, 225, 242 + ], + master_key.0.key.as_slice() + ); + assert_eq!(None, master_key.0.mac_key); + } + + #[test] + fn test_stretch_master_key() { + let master_key = MasterKey(SymmetricCryptoKey { + key: [ + 31, 79, 104, 226, 150, 71, 177, 90, 194, 80, 172, 209, 17, 129, 132, 81, 138, 167, + 69, 167, 254, 149, 2, 27, 39, 197, 64, 42, 22, 195, 86, 75, ] + .into(), + mac_key: None, + }); + + let stretched = stretch_master_key(&master_key).unwrap(); + + assert_eq!( + [ + 111, 31, 178, 45, 238, 152, 37, 114, 143, 215, 124, 83, 135, 173, 195, 23, 142, + 134, 120, 249, 61, 132, 163, 182, 113, 197, 189, 204, 188, 21, 237, 96 + ], + stretched.key.as_slice() ); assert_eq!( - mac.as_slice(), [ - 214, 144, 76, 173, 225, 106, 132, 131, 173, 56, 134, 241, 223, 227, 165, 161, 146, - 37, 111, 206, 155, 24, 224, 151, 134, 189, 202, 0, 27, 149, 131, 21 - ] + 221, 127, 206, 234, 101, 27, 202, 38, 86, 52, 34, 28, 78, 28, 185, 16, 48, 61, 127, + 166, 209, 247, 194, 87, 232, 26, 48, 85, 193, 249, 179, 155 + ], + stretched.mac_key.unwrap().as_slice() + ); + } + + #[test] + fn test_password_hash_pbkdf2() { + let password = "asdfasdf".as_bytes(); + let salt = "test_salt".as_bytes(); + let kdf = Kdf::PBKDF2 { + iterations: NonZeroU32::new(100_000).unwrap(), + }; + + let master_key = MasterKey::derive(password, salt, &kdf).unwrap(); + + assert_eq!( + "ZF6HjxUTSyBHsC+HXSOhZoXN+UuMnygV5YkWXCY4VmM=", + master_key + .derive_master_key_hash(password, HashPurpose::ServerAuthorization) + .unwrap(), + ); + } + + #[test] + fn test_password_hash_argon2id() { + let password = "asdfasdf".as_bytes(); + let salt = "test_salt".as_bytes(); + let kdf = Kdf::Argon2id { + iterations: NonZeroU32::new(4).unwrap(), + memory: NonZeroU32::new(32).unwrap(), + parallelism: NonZeroU32::new(2).unwrap(), + }; + + let master_key = MasterKey::derive(password, salt, &kdf).unwrap(); + + assert_eq!( + "PR6UjYmjmppTYcdyTiNbAhPJuQQOmynKbdEl1oyi/iQ=", + master_key + .derive_master_key_hash(password, HashPurpose::ServerAuthorization) + .unwrap(), ); } } diff --git a/crates/bitwarden/src/crypto/mod.rs b/crates/bitwarden/src/crypto/mod.rs index 1172c9dfb..61c6742bf 100644 --- a/crates/bitwarden/src/crypto/mod.rs +++ b/crates/bitwarden/src/crypto/mod.rs @@ -16,6 +16,8 @@ //! //! - `CryptoService.makeSendKey` & `AccessService.createAccessToken` are replaced by the generic //! `derive_shareable_key` +//! - MasterKey operations such as `makeMasterKey` and `hashMasterKey` are moved to the MasterKey +//! struct. //! use aes::cipher::{generic_array::GenericArray, ArrayLength, Unsigned}; @@ -37,7 +39,7 @@ pub(crate) use shareable_key::derive_shareable_key; #[cfg(feature = "internal")] mod master_key; #[cfg(feature = "internal")] -pub(crate) use master_key::{hash_kdf, stretch_key_password}; +pub(crate) use master_key::{HashPurpose, MasterKey}; #[cfg(feature = "internal")] mod fingerprint; diff --git a/crates/bitwarden/src/crypto/symmetric_crypto_key.rs b/crates/bitwarden/src/crypto/symmetric_crypto_key.rs index 4d0f573d9..7b2086f75 100644 --- a/crates/bitwarden/src/crypto/symmetric_crypto_key.rs +++ b/crates/bitwarden/src/crypto/symmetric_crypto_key.rs @@ -9,6 +9,7 @@ use crate::{ util::BASE64_ENGINE, }; +/// A symmetric encryption key. Used to encrypt and decrypt [`EncString`](crate::crypto::EncString) pub struct SymmetricCryptoKey { pub key: GenericArray, pub mac_key: Option>, diff --git a/crates/bitwarden/src/mobile/kdf.rs b/crates/bitwarden/src/mobile/kdf.rs index bebf73423..e79e0ab12 100644 --- a/crates/bitwarden/src/mobile/kdf.rs +++ b/crates/bitwarden/src/mobile/kdf.rs @@ -14,6 +14,6 @@ pub async fn hash_password( email, kdf: kdf_params, }; - let hash = auth_settings.make_user_password_hash(&password)?; + let hash = auth_settings.derive_user_password_hash(&password)?; Ok(hash) } diff --git a/crates/bitwarden/src/platform/get_user_api_key.rs b/crates/bitwarden/src/platform/get_user_api_key.rs index 98035ad45..629bfc8c4 100644 --- a/crates/bitwarden/src/platform/get_user_api_key.rs +++ b/crates/bitwarden/src/platform/get_user_api_key.rs @@ -48,7 +48,7 @@ fn get_secret_verification_request( let master_password_hash = input .master_password .as_ref() - .map(|p| auth_settings.make_user_password_hash(p)) + .map(|p| auth_settings.derive_user_password_hash(p)) .transpose()?; Ok(SecretVerificationRequestModel { master_password_hash, From 1d3bae3dd60faac87104e71737e6c29d6078bba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Mon, 4 Sep 2023 15:26:25 +0200 Subject: [PATCH 02/12] Make MAC validation optional when decrypting (#212) * Make MAC validation optional when decrypting * Separate AES into two functions * Remove superfluous comment --- crates/bitwarden/src/crypto/aes_ops.rs | 33 +++++++++++------------ crates/bitwarden/src/crypto/enc_string.rs | 5 ++-- crates/bitwarden/src/crypto/mod.rs | 2 +- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/crates/bitwarden/src/crypto/aes_ops.rs b/crates/bitwarden/src/crypto/aes_ops.rs index 109deac4f..eb5b82a60 100644 --- a/crates/bitwarden/src/crypto/aes_ops.rs +++ b/crates/bitwarden/src/crypto/aes_ops.rs @@ -10,24 +10,7 @@ use crate::{ error::{CryptoError, Result}, }; -pub fn decrypt_aes256( - iv: &[u8; 16], - mac: &[u8; 32], - data: Vec, - mac_key: Option>, - key: GenericArray, -) -> Result> { - let mac_key = match mac_key { - Some(k) => k, - None => return Err(CryptoError::InvalidMac.into()), - }; - - // Validate HMAC - let res = validate_mac(&mac_key, iv, &data)?; - if res != *mac { - return Err(CryptoError::InvalidMac.into()); - } - +pub fn decrypt_aes256(iv: &[u8; 16], data: Vec, key: GenericArray) -> Result> { // Decrypt data let iv = GenericArray::from_slice(iv); let mut data = data; @@ -42,6 +25,20 @@ pub fn decrypt_aes256( Ok(data) } +pub fn decrypt_aes256_hmac( + iv: &[u8; 16], + mac: &[u8; 32], + data: Vec, + mac_key: GenericArray, + key: GenericArray, +) -> Result> { + let res = validate_mac(&mac_key, iv, &data)?; + if res != *mac { + return Err(CryptoError::InvalidMac.into()); + } + decrypt_aes256(iv, data, key) +} + pub fn encrypt_aes256( data_dec: &[u8], mac_key: Option>, diff --git a/crates/bitwarden/src/crypto/enc_string.rs b/crates/bitwarden/src/crypto/enc_string.rs index 57958af8c..7b739ffe9 100644 --- a/crates/bitwarden/src/crypto/enc_string.rs +++ b/crates/bitwarden/src/crypto/enc_string.rs @@ -6,7 +6,7 @@ use uuid::Uuid; use crate::{ client::encryption_settings::EncryptionSettings, - crypto::{decrypt_aes256, Decryptable, Encryptable, SymmetricCryptoKey}, + crypto::{decrypt_aes256_hmac, Decryptable, Encryptable, SymmetricCryptoKey}, error::{CryptoError, EncStringParseError, Error, Result}, util::BASE64_ENGINE, }; @@ -255,7 +255,8 @@ impl EncString { pub fn decrypt_with_key(&self, key: &SymmetricCryptoKey) -> Result> { match self { EncString::AesCbc256_HmacSha256_B64 { iv, mac, data } => { - let dec = decrypt_aes256(iv, mac, data.clone(), key.mac_key, key.key)?; + let mac_key = key.mac_key.ok_or(CryptoError::InvalidMac)?; + let dec = decrypt_aes256_hmac(iv, mac, data.clone(), mac_key, key.key)?; Ok(dec) } _ => Err(CryptoError::InvalidKey.into()), diff --git a/crates/bitwarden/src/crypto/mod.rs b/crates/bitwarden/src/crypto/mod.rs index 61c6742bf..fa39e2d58 100644 --- a/crates/bitwarden/src/crypto/mod.rs +++ b/crates/bitwarden/src/crypto/mod.rs @@ -30,7 +30,7 @@ pub use enc_string::EncString; mod encryptable; pub use encryptable::{Decryptable, Encryptable}; mod aes_ops; -pub use aes_ops::{decrypt_aes256, encrypt_aes256}; +pub use aes_ops::{decrypt_aes256, decrypt_aes256_hmac, encrypt_aes256}; mod symmetric_crypto_key; pub use symmetric_crypto_key::SymmetricCryptoKey; mod shareable_key; From 18afcab483076fbe6fa1dcf8bc6e6b394a75b2fa Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 4 Sep 2023 17:47:08 +0200 Subject: [PATCH 03/12] Scaffold exporters (#216) --- .vscode/settings.json | 1 + crates/bitwarden-uniffi/src/docs.rs | 5 +- crates/bitwarden-uniffi/src/tool/mod.rs | 45 +++++++++++++- crates/bitwarden/src/auth/password.rs | 4 +- crates/bitwarden/src/crypto/mod.rs | 2 +- crates/bitwarden/src/lib.rs | 2 +- crates/bitwarden/src/tool/client_generator.rs | 25 -------- .../src/tool/exporters/client_exporter.rs | 36 +++++++++++ crates/bitwarden/src/tool/exporters/mod.rs | 33 +++++++++++ .../src/tool/generators/client_generator.rs | 27 +++++++++ crates/bitwarden/src/tool/generators/mod.rs | 4 ++ .../src/tool/{ => generators}/password.rs | 9 +++ crates/bitwarden/src/tool/mod.rs | 7 ++- languages/kotlin/doc.md | 59 +++++++++++++++++++ support/docs/docs.ts | 1 + 15 files changed, 226 insertions(+), 34 deletions(-) delete mode 100644 crates/bitwarden/src/tool/client_generator.rs create mode 100644 crates/bitwarden/src/tool/exporters/client_exporter.rs create mode 100644 crates/bitwarden/src/tool/exporters/mod.rs create mode 100644 crates/bitwarden/src/tool/generators/client_generator.rs create mode 100644 crates/bitwarden/src/tool/generators/mod.rs rename crates/bitwarden/src/tool/{ => generators}/password.rs (85%) diff --git a/.vscode/settings.json b/.vscode/settings.json index ab645ffae..8fbaf48b5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,6 +12,7 @@ "Maybeable", "Oaep", "Pbkdf", + "repr", "schemars", "uniffi", "wordlist" diff --git a/crates/bitwarden-uniffi/src/docs.rs b/crates/bitwarden-uniffi/src/docs.rs index f67e6fb98..af9b9a8d5 100644 --- a/crates/bitwarden-uniffi/src/docs.rs +++ b/crates/bitwarden-uniffi/src/docs.rs @@ -2,7 +2,7 @@ use bitwarden::{ auth::password::MasterPasswordPolicyOptions, client::auth_settings::Kdf, mobile::crypto::InitCryptoRequest, - tool::{PassphraseGeneratorRequest, PasswordGeneratorRequest}, + tool::{ExportFormat, PassphraseGeneratorRequest, PasswordGeneratorRequest}, vault::{Cipher, CipherView, Collection, Folder, FolderView}, }; use schemars::JsonSchema; @@ -24,6 +24,9 @@ pub enum DocRef { PasswordGeneratorRequest(PasswordGeneratorRequest), PassphraseGeneratorRequest(PassphraseGeneratorRequest), + // Exporters + ExportFormat(ExportFormat), + // Auth MasterPasswordPolicyOptions(MasterPasswordPolicyOptions), diff --git a/crates/bitwarden-uniffi/src/tool/mod.rs b/crates/bitwarden-uniffi/src/tool/mod.rs index 3f4faed45..3243cceb6 100644 --- a/crates/bitwarden-uniffi/src/tool/mod.rs +++ b/crates/bitwarden-uniffi/src/tool/mod.rs @@ -1,6 +1,9 @@ use std::sync::Arc; -use bitwarden::tool::{PassphraseGeneratorRequest, PasswordGeneratorRequest}; +use bitwarden::{ + tool::{ExportFormat, PassphraseGeneratorRequest, PasswordGeneratorRequest}, + vault::{Cipher, Collection, Folder}, +}; use crate::{error::Result, Client}; @@ -33,3 +36,43 @@ impl ClientGenerators { .await?) } } + +#[derive(uniffi::Object)] +pub struct ClientExporters(pub(crate) Arc); + +#[uniffi::export] +impl ClientExporters { + /// **API Draft:** Export user vault + pub async fn export_vault( + &self, + folders: Vec, + ciphers: Vec, + format: ExportFormat, + ) -> Result { + Ok(self + .0 + .0 + .read() + .await + .exporters() + .export_vault(folders, ciphers, format) + .await?) + } + + /// **API Draft:** Export organization vault + pub async fn export_organization_vault( + &self, + collections: Vec, + ciphers: Vec, + format: ExportFormat, + ) -> Result { + Ok(self + .0 + .0 + .read() + .await + .exporters() + .export_organization_vault(collections, ciphers, format) + .await?) + } +} diff --git a/crates/bitwarden/src/auth/password.rs b/crates/bitwarden/src/auth/password.rs index a49253f6d..7749710d4 100644 --- a/crates/bitwarden/src/auth/password.rs +++ b/crates/bitwarden/src/auth/password.rs @@ -5,7 +5,7 @@ pub(super) fn password_strength( _email: String, _additional_inputs: Vec, ) -> u8 { - unimplemented!() + todo!() } pub(super) fn satisfies_policy( @@ -13,7 +13,7 @@ pub(super) fn satisfies_policy( _strength: u8, _policy: &MasterPasswordPolicyOptions, ) -> bool { - unimplemented!() + todo!() } #[derive(Debug, JsonSchema)] diff --git a/crates/bitwarden/src/crypto/mod.rs b/crates/bitwarden/src/crypto/mod.rs index fa39e2d58..93d4eb1a1 100644 --- a/crates/bitwarden/src/crypto/mod.rs +++ b/crates/bitwarden/src/crypto/mod.rs @@ -2,7 +2,7 @@ //! //! This module contains the cryptographic primitives used throughout the SDK. The module makes a //! best effort to abstract away cryptographic concepts into concepts such as -//! [`EncString`][EncString] and [`SymmetricCryptoKey`][SymmetricCryptoKey]. +//! [`EncString`] and [`SymmetricCryptoKey`]. //! //! ## Conventions: //! diff --git a/crates/bitwarden/src/lib.rs b/crates/bitwarden/src/lib.rs index dd3f40768..31af93419 100644 --- a/crates/bitwarden/src/lib.rs +++ b/crates/bitwarden/src/lib.rs @@ -61,7 +61,7 @@ pub mod mobile; pub mod platform; #[cfg(feature = "secrets")] pub mod secrets_manager; -#[cfg(feature = "internal")] +#[cfg(feature = "mobile")] pub mod tool; #[cfg(feature = "mobile")] pub(crate) mod uniffi_support; diff --git a/crates/bitwarden/src/tool/client_generator.rs b/crates/bitwarden/src/tool/client_generator.rs deleted file mode 100644 index 55d1acbba..000000000 --- a/crates/bitwarden/src/tool/client_generator.rs +++ /dev/null @@ -1,25 +0,0 @@ -use crate::{ - error::Result, - tool::password::{PassphraseGeneratorRequest, PasswordGeneratorRequest}, - Client, -}; - -pub struct ClientGenerator<'a> { - pub(crate) _client: &'a crate::Client, -} - -impl<'a> ClientGenerator<'a> { - pub async fn password(&self, _input: PasswordGeneratorRequest) -> Result { - todo!() - } - - pub async fn passphrase(&self, _input: PassphraseGeneratorRequest) -> Result { - todo!() - } -} - -impl<'a> Client { - pub fn generator(&'a self) -> ClientGenerator<'a> { - ClientGenerator { _client: self } - } -} diff --git a/crates/bitwarden/src/tool/exporters/client_exporter.rs b/crates/bitwarden/src/tool/exporters/client_exporter.rs new file mode 100644 index 000000000..f14cbc846 --- /dev/null +++ b/crates/bitwarden/src/tool/exporters/client_exporter.rs @@ -0,0 +1,36 @@ +use crate::{ + error::Result, + tool::exporters::{export_organization_vault, export_vault, ExportFormat}, + vault::{Cipher, Collection, Folder}, + Client, +}; + +pub struct ClientExporters<'a> { + pub(crate) _client: &'a crate::Client, +} + +impl<'a> ClientExporters<'a> { + pub async fn export_vault( + &self, + folders: Vec, + ciphers: Vec, + format: ExportFormat, + ) -> Result { + export_vault(folders, ciphers, format) + } + + pub async fn export_organization_vault( + &self, + collections: Vec, + ciphers: Vec, + format: ExportFormat, + ) -> Result { + export_organization_vault(collections, ciphers, format) + } +} + +impl<'a> Client { + pub fn exporters(&'a self) -> ClientExporters<'a> { + ClientExporters { _client: self } + } +} diff --git a/crates/bitwarden/src/tool/exporters/mod.rs b/crates/bitwarden/src/tool/exporters/mod.rs new file mode 100644 index 000000000..508aae8fb --- /dev/null +++ b/crates/bitwarden/src/tool/exporters/mod.rs @@ -0,0 +1,33 @@ +use schemars::JsonSchema; + +use crate::{ + error::Result, + vault::{Cipher, Collection, Folder}, +}; + +mod client_exporter; + +#[derive(JsonSchema)] +#[cfg_attr(feature = "mobile", derive(uniffi::Enum))] +pub enum ExportFormat { + Csv, + Json, + AccountEncryptedJson, // TODO: Should we deprecate this option completely? + EncryptedJson { password: String }, +} + +pub(super) fn export_vault( + _folders: Vec, + _ciphers: Vec, + _format: ExportFormat, +) -> Result { + todo!(); +} + +pub(super) fn export_organization_vault( + _collections: Vec, + _ciphers: Vec, + _format: ExportFormat, +) -> Result { + todo!(); +} diff --git a/crates/bitwarden/src/tool/generators/client_generator.rs b/crates/bitwarden/src/tool/generators/client_generator.rs new file mode 100644 index 000000000..0384eec6a --- /dev/null +++ b/crates/bitwarden/src/tool/generators/client_generator.rs @@ -0,0 +1,27 @@ +use crate::{ + error::Result, + tool::generators::password::{ + passphrase, password, PassphraseGeneratorRequest, PasswordGeneratorRequest, + }, + Client, +}; + +pub struct ClientGenerator<'a> { + pub(crate) _client: &'a crate::Client, +} + +impl<'a> ClientGenerator<'a> { + pub async fn password(&self, input: PasswordGeneratorRequest) -> Result { + password(input) + } + + pub async fn passphrase(&self, input: PassphraseGeneratorRequest) -> Result { + passphrase(input) + } +} + +impl<'a> Client { + pub fn generator(&'a self) -> ClientGenerator<'a> { + ClientGenerator { _client: self } + } +} diff --git a/crates/bitwarden/src/tool/generators/mod.rs b/crates/bitwarden/src/tool/generators/mod.rs new file mode 100644 index 000000000..bdc0fb260 --- /dev/null +++ b/crates/bitwarden/src/tool/generators/mod.rs @@ -0,0 +1,4 @@ +mod client_generator; +mod password; + +pub use password::{PassphraseGeneratorRequest, PasswordGeneratorRequest}; diff --git a/crates/bitwarden/src/tool/password.rs b/crates/bitwarden/src/tool/generators/password.rs similarity index 85% rename from crates/bitwarden/src/tool/password.rs rename to crates/bitwarden/src/tool/generators/password.rs index 144ff0d1c..ea74616b2 100644 --- a/crates/bitwarden/src/tool/password.rs +++ b/crates/bitwarden/src/tool/generators/password.rs @@ -1,3 +1,4 @@ +use crate::error::Result; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -38,3 +39,11 @@ pub struct PassphraseGeneratorRequest { pub capitalize: Option, pub include_number: Option, } + +pub(super) fn password(_input: PasswordGeneratorRequest) -> Result { + todo!() +} + +pub(super) fn passphrase(_input: PassphraseGeneratorRequest) -> Result { + todo!() +} diff --git a/crates/bitwarden/src/tool/mod.rs b/crates/bitwarden/src/tool/mod.rs index bdc0fb260..2130a6b0c 100644 --- a/crates/bitwarden/src/tool/mod.rs +++ b/crates/bitwarden/src/tool/mod.rs @@ -1,4 +1,5 @@ -mod client_generator; -mod password; +mod exporters; +mod generators; -pub use password::{PassphraseGeneratorRequest, PasswordGeneratorRequest}; +pub use exporters::ExportFormat; +pub use generators::{PassphraseGeneratorRequest, PasswordGeneratorRequest}; diff --git a/languages/kotlin/doc.md b/languages/kotlin/doc.md index 9cda1386e..6d0ed6b12 100644 --- a/languages/kotlin/doc.md +++ b/languages/kotlin/doc.md @@ -180,6 +180,34 @@ Initialization method for the crypto. Needs to be called before any other crypto **Output**: std::result::Result<,BitwardenError> +## ClientExporters + +### `export_vault` + +**API Draft:** Export user vault + +**Arguments**: + +- self: +- folders: Vec +- ciphers: Vec +- format: [ExportFormat](#exportformat) + +**Output**: std::result::Result + +### `export_organization_vault` + +**API Draft:** Export organization vault + +**Arguments**: + +- self: +- collections: Vec +- ciphers: Vec +- format: [ExportFormat](#exportformat) + +**Output**: std::result::Result + ## ClientFolders ### `encrypt` @@ -600,6 +628,37 @@ implementations. +## `ExportFormat` + + + + + + + + + + + + + + + +
KeyTypeDescription
EncryptedJsonobject
+ + + + + + + + + + + +
KeyTypeDescription
passwordstring
+
+ ## `Folder` diff --git a/support/docs/docs.ts b/support/docs/docs.ts index 331047fb9..ed79c4c2c 100644 --- a/support/docs/docs.ts +++ b/support/docs/docs.ts @@ -24,6 +24,7 @@ const rootElements = [ "ClientCiphers", "ClientCollections", "ClientCrypto", + "ClientExporters", "ClientFolders", "ClientGenerators", "ClientPasswordHistory", From 2dc124d6227fda02f9886f2f99b9fa9fcd1b5623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Mon, 4 Sep 2023 17:54:18 +0200 Subject: [PATCH 04/12] Implement parsing for all EncString ciphers (#213) * Implement parsing for all EncString ciphers * Fix wrong field order * Remove unnecessary combined match * Split combined match in from_buffer as well --- crates/bitwarden/src/crypto/enc_string.rs | 197 ++++++++++++++-------- 1 file changed, 125 insertions(+), 72 deletions(-) diff --git a/crates/bitwarden/src/crypto/enc_string.rs b/crates/bitwarden/src/crypto/enc_string.rs index 7b739ffe9..b701aaf8f 100644 --- a/crates/bitwarden/src/crypto/enc_string.rs +++ b/crates/bitwarden/src/crypto/enc_string.rs @@ -14,41 +14,30 @@ use crate::{ #[derive(Clone)] #[allow(unused, non_camel_case_types)] pub enum EncString { - // 0 - AesCbc256_B64 { - iv: [u8; 16], - data: Vec, - }, - // 1 + /// 0 + AesCbc256_B64 { iv: [u8; 16], data: Vec }, + /// 1 AesCbc128_HmacSha256_B64 { iv: [u8; 16], mac: [u8; 32], data: Vec, }, - // 2 + /// 2 AesCbc256_HmacSha256_B64 { iv: [u8; 16], mac: [u8; 32], data: Vec, }, - // 3 - Rsa2048_OaepSha256_B64 { - data: Vec, - }, - // 4 - Rsa2048_OaepSha1_B64 { - data: Vec, - }, - // 5 - Rsa2048_OaepSha256_HmacSha256_B64 { - mac: [u8; 32], - data: Vec, - }, - // 6 - Rsa2048_OaepSha1_HmacSha256_B64 { - mac: [u8; 32], - data: Vec, - }, + /// 3 + Rsa2048_OaepSha256_B64 { data: Vec }, + /// 4 + Rsa2048_OaepSha1_B64 { data: Vec }, + /// 5 + #[deprecated] + Rsa2048_OaepSha256_HmacSha256_B64 { data: Vec }, + /// 6 + #[deprecated] + Rsa2048_OaepSha1_HmacSha256_B64 { data: Vec }, } // We manually implement these to make sure we don't print any sensitive data @@ -62,32 +51,43 @@ impl FromStr for EncString { type Err = Error; fn from_str(s: &str) -> Result { - let (enc_type, data) = s.split_once('.').ok_or(EncStringParseError::NoType)?; + let (enc_type, parts): (&str, Vec<_>) = { + let header_parts: Vec<_> = s.split('.').collect(); + + if header_parts.len() == 2 { + (header_parts[0], header_parts[1].split('|').collect()) + } else { + // Support legacy format with no header + let parts: Vec<_> = s.split('|').collect(); + if parts.len() == 3 { + ("1", parts) // AesCbc128_HmacSha256_B64 + } else { + ("0", parts) // AesCbc256_B64 + } + } + }; + + fn from_b64_vec(s: &str) -> Result> { + Ok(BASE64_ENGINE + .decode(s) + .map_err(EncStringParseError::InvalidBase64)?) + } + + fn from_b64(s: &str) -> Result<[u8; N]> { + Ok(from_b64_vec(s)?.try_into().map_err(invalid_len_error(N))?) + } - let parts: Vec<_> = data.split('|').collect(); match (enc_type, parts.len()) { - ("0", 2) => unimplemented!(), + ("0", 2) => { + let iv = from_b64(parts[0])?; + let data = from_b64_vec(parts[1])?; + Ok(EncString::AesCbc256_B64 { iv, data }) + } ("1" | "2", 3) => { - let iv_str = parts[0]; - let data_str = parts[1]; - let mac_str = parts[2]; - - let iv = BASE64_ENGINE - .decode(iv_str) - .map_err(EncStringParseError::InvalidBase64)? - .try_into() - .map_err(invalid_len_error(16))?; - - let mac = BASE64_ENGINE - .decode(mac_str) - .map_err(EncStringParseError::InvalidBase64)? - .try_into() - .map_err(invalid_len_error(32))?; - - let data = BASE64_ENGINE - .decode(data_str) - .map_err(EncStringParseError::InvalidBase64)?; + let iv = from_b64(parts[0])?; + let data = from_b64_vec(parts[1])?; + let mac = from_b64(parts[2])?; if enc_type == "1" { Ok(EncString::AesCbc128_HmacSha256_B64 { iv, mac, data }) @@ -95,19 +95,23 @@ impl FromStr for EncString { Ok(EncString::AesCbc256_HmacSha256_B64 { iv, mac, data }) } } - - ("3" | "4", 1) => { - let data = BASE64_ENGINE - .decode(data) - .map_err(EncStringParseError::InvalidBase64)?; - if enc_type == "3" { - Ok(EncString::Rsa2048_OaepSha256_B64 { data }) - } else { - Ok(EncString::Rsa2048_OaepSha1_B64 { data }) - } + ("3", 1) => { + let data = from_b64_vec(parts[0])?; + Ok(EncString::Rsa2048_OaepSha256_B64 { data }) + } + ("4", 1) => { + let data = from_b64_vec(parts[0])?; + Ok(EncString::Rsa2048_OaepSha1_B64 { data }) + } + #[allow(deprecated)] + ("5", 1) => { + let data = from_b64_vec(parts[0])?; + Ok(EncString::Rsa2048_OaepSha256_HmacSha256_B64 { data }) } - ("5" | "6", 2) => { - unimplemented!() + #[allow(deprecated)] + ("6", 1) => { + let data = from_b64_vec(parts[0])?; + Ok(EncString::Rsa2048_OaepSha1_HmacSha256_B64 { data }) } (enc_type, parts) => Err(EncStringParseError::InvalidType { @@ -127,17 +131,27 @@ impl EncString { } let enc_type = buf[0]; - match enc_type { - 0 => unimplemented!(), - 1 | 2 => { - if buf.len() < 49 { - return Err(EncStringParseError::InvalidLength { - expected: 49, - got: buf.len(), - } - .into()); + fn check_length(buf: &[u8], expected: usize) -> Result<()> { + if buf.len() < expected { + return Err(EncStringParseError::InvalidLength { + expected, + got: buf.len(), } + .into()); + } + Ok(()) + } + + match enc_type { + 0 => { + check_length(buf, 18)?; + let iv = buf[1..17].try_into().unwrap(); + let data = buf[17..].to_vec(); + Ok(EncString::AesCbc256_B64 { iv, data }) + } + 1 | 2 => { + check_length(buf, 50)?; let iv = buf[1..17].try_into().unwrap(); let mac = buf[17..49].try_into().unwrap(); let data = buf[49..].to_vec(); @@ -148,6 +162,28 @@ impl EncString { Ok(EncString::AesCbc256_HmacSha256_B64 { iv, mac, data }) } } + 3 => { + check_length(buf, 2)?; + let data = buf[1..].to_vec(); + Ok(EncString::Rsa2048_OaepSha256_B64 { data }) + } + 4 => { + check_length(buf, 2)?; + let data = buf[1..].to_vec(); + Ok(EncString::Rsa2048_OaepSha1_B64 { data }) + } + #[allow(deprecated)] + 5 => { + check_length(buf, 2)?; + let data = buf[1..].to_vec(); + Ok(EncString::Rsa2048_OaepSha256_HmacSha256_B64 { data }) + } + #[allow(deprecated)] + 6 => { + check_length(buf, 2)?; + let data = buf[1..].to_vec(); + Ok(EncString::Rsa2048_OaepSha1_HmacSha256_B64 { data }) + } _ => Err(EncStringParseError::InvalidType { enc_type: enc_type.to_string(), parts: 1, @@ -175,7 +211,20 @@ impl EncString { buf.extend_from_slice(mac); buf.extend_from_slice(data); } - _ => todo!(), + + EncString::Rsa2048_OaepSha256_B64 { data } + | EncString::Rsa2048_OaepSha1_B64 { data } => { + buf = Vec::with_capacity(1 + data.len()); + buf.push(self.enc_type()); + buf.extend_from_slice(data); + } + #[allow(deprecated)] + EncString::Rsa2048_OaepSha256_HmacSha256_B64 { data } + | EncString::Rsa2048_OaepSha1_HmacSha256_B64 { data } => { + buf = Vec::with_capacity(1 + data.len()); + buf.push(self.enc_type()); + buf.extend_from_slice(data); + } } Ok(buf) @@ -190,8 +239,10 @@ impl Display for EncString { EncString::AesCbc256_HmacSha256_B64 { iv, mac, data } => vec![iv, data, mac], EncString::Rsa2048_OaepSha256_B64 { data } => vec![data], EncString::Rsa2048_OaepSha1_B64 { data } => vec![data], - EncString::Rsa2048_OaepSha256_HmacSha256_B64 { mac, data } => vec![data, mac], - EncString::Rsa2048_OaepSha1_HmacSha256_B64 { mac, data } => vec![data, mac], + #[allow(deprecated)] + EncString::Rsa2048_OaepSha256_HmacSha256_B64 { data } => vec![data], + #[allow(deprecated)] + EncString::Rsa2048_OaepSha1_HmacSha256_B64 { data } => vec![data], }; let encoded_parts: Vec = parts @@ -240,14 +291,16 @@ impl serde::Serialize for EncString { } impl EncString { - fn enc_type(&self) -> u8 { + const fn enc_type(&self) -> u8 { match self { EncString::AesCbc256_B64 { .. } => 0, EncString::AesCbc128_HmacSha256_B64 { .. } => 1, EncString::AesCbc256_HmacSha256_B64 { .. } => 2, EncString::Rsa2048_OaepSha256_B64 { .. } => 3, EncString::Rsa2048_OaepSha1_B64 { .. } => 4, + #[allow(deprecated)] EncString::Rsa2048_OaepSha256_HmacSha256_B64 { .. } => 5, + #[allow(deprecated)] EncString::Rsa2048_OaepSha1_HmacSha256_B64 { .. } => 6, } } From 41be23518fbd2bded57a053b942383eb455ca46b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Tue, 5 Sep 2023 11:46:51 +0200 Subject: [PATCH 05/12] Add Sends API in bitwarden-uniffi (#217) * Add Sends api in bitwarden-uniffi * Update doc.md --- .prettierignore | 5 +- crates/bitwarden-uniffi/src/docs.rs | 5 +- crates/bitwarden-uniffi/src/vault/mod.rs | 8 +- crates/bitwarden-uniffi/src/vault/sends.rs | 104 +++++++++++++++++++++ languages/kotlin/doc.md | 97 ++++++++++++++++++- support/docs/docs.ts | 1 + 6 files changed, 216 insertions(+), 4 deletions(-) create mode 100644 crates/bitwarden-uniffi/src/vault/sends.rs diff --git a/.prettierignore b/.prettierignore index ba98edfb6..d5ffe5a0e 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,8 @@ target -languages +languages/* +!/languages/kotlin +languages/kotlin/* +!/languages/kotlin/doc.md schemas /crates/bitwarden-napi/src-ts/bitwarden_client/schemas.ts about.hbs diff --git a/crates/bitwarden-uniffi/src/docs.rs b/crates/bitwarden-uniffi/src/docs.rs index af9b9a8d5..94a40a0e9 100644 --- a/crates/bitwarden-uniffi/src/docs.rs +++ b/crates/bitwarden-uniffi/src/docs.rs @@ -3,7 +3,7 @@ use bitwarden::{ client::auth_settings::Kdf, mobile::crypto::InitCryptoRequest, tool::{ExportFormat, PassphraseGeneratorRequest, PasswordGeneratorRequest}, - vault::{Cipher, CipherView, Collection, Folder, FolderView}, + vault::{Cipher, CipherView, Collection, Folder, FolderView, Send, SendListView, SendView}, }; use schemars::JsonSchema; @@ -16,6 +16,9 @@ pub enum DocRef { Collection(Collection), Folder(Folder), FolderView(FolderView), + Send(Send), + SendView(SendView), + SendListView(SendListView), // Crypto InitCryptoRequest(InitCryptoRequest), diff --git a/crates/bitwarden-uniffi/src/vault/mod.rs b/crates/bitwarden-uniffi/src/vault/mod.rs index 53567c063..2692632ab 100644 --- a/crates/bitwarden-uniffi/src/vault/mod.rs +++ b/crates/bitwarden-uniffi/src/vault/mod.rs @@ -6,6 +6,7 @@ pub mod ciphers; pub mod collections; pub mod folders; pub mod password_history; +pub mod sends; #[derive(uniffi::Object)] pub struct ClientVault(pub(crate) Arc); @@ -27,8 +28,13 @@ impl ClientVault { Arc::new(ciphers::ClientCiphers(self.0.clone())) } - /// Ciphers operations + /// Password history operations pub fn password_history(self: Arc) -> Arc { Arc::new(password_history::ClientPasswordHistory(self.0.clone())) } + + /// Sends operations + pub fn sends(self: Arc) -> Arc { + Arc::new(sends::ClientSends(self.0.clone())) + } } diff --git a/crates/bitwarden-uniffi/src/vault/sends.rs b/crates/bitwarden-uniffi/src/vault/sends.rs new file mode 100644 index 000000000..6e2f1b879 --- /dev/null +++ b/crates/bitwarden-uniffi/src/vault/sends.rs @@ -0,0 +1,104 @@ +use std::{path::Path, sync::Arc}; + +use bitwarden::vault::{Send, SendListView, SendView}; + +use crate::{Client, Result}; + +#[derive(uniffi::Object)] +pub struct ClientSends(pub Arc); + +#[uniffi::export] +impl ClientSends { + /// Encrypt send + pub async fn encrypt(&self, send: SendView) -> Result { + Ok(self.0 .0.read().await.vault().sends().encrypt(send).await?) + } + + /// Encrypt a send file in memory + pub async fn encrypt_buffer(&self, send: Send, buffer: Vec) -> Result> { + Ok(self + .0 + .0 + .read() + .await + .vault() + .sends() + .encrypt_buffer(send, &buffer) + .await?) + } + + /// Encrypt a send file located in the file system + pub async fn encrypt_file( + &self, + send: Send, + decrypted_file_path: String, + encrypted_file_path: String, + ) -> Result<()> { + Ok(self + .0 + .0 + .read() + .await + .vault() + .sends() + .encrypt_file( + send, + Path::new(&decrypted_file_path), + Path::new(&encrypted_file_path), + ) + .await?) + } + + /// Decrypt send + pub async fn decrypt(&self, send: Send) -> Result { + Ok(self.0 .0.read().await.vault().sends().decrypt(send).await?) + } + + /// Decrypt send list + pub async fn decrypt_list(&self, sends: Vec) -> Result> { + Ok(self + .0 + .0 + .read() + .await + .vault() + .sends() + .decrypt_list(sends) + .await?) + } + + /// Decrypt a send file in memory + pub async fn decrypt_buffer(&self, send: Send, buffer: Vec) -> Result> { + Ok(self + .0 + .0 + .read() + .await + .vault() + .sends() + .decrypt_buffer(send, &buffer) + .await?) + } + + /// Decrypt a send file located in the file system + pub async fn decrypt_file( + &self, + send: Send, + encrypted_file_path: String, + decrypted_file_path: String, + ) -> Result<()> { + Ok(self + .0 + .0 + .read() + .await + .vault() + .sends() + .decrypt_file( + send, + Path::new(&encrypted_file_path), + Path::new(&decrypted_file_path), + ) + .await?) + } +} diff --git a/languages/kotlin/doc.md b/languages/kotlin/doc.md index 6d0ed6b12..55e5124e2 100644 --- a/languages/kotlin/doc.md +++ b/languages/kotlin/doc.md @@ -291,6 +291,91 @@ Decrypt password history **Output**: std::result::Result +## ClientSends + +### `encrypt` + +Encrypt send + +**Arguments**: + +- self: +- send: SendView + +**Output**: std::result::Result + +### `encrypt_buffer` + +Encrypt a send file in memory + +**Arguments**: + +- self: +- send: Send +- buffer: Vec<> + +**Output**: std::result::Result + +### `encrypt_file` + +Encrypt a send file located in the file system + +**Arguments**: + +- self: +- send: Send +- decrypted_file_path: String +- encrypted_file_path: String + +**Output**: std::result::Result<,BitwardenError> + +### `decrypt` + +Decrypt send + +**Arguments**: + +- self: +- send: Send + +**Output**: std::result::Result + +### `decrypt_list` + +Decrypt send list + +**Arguments**: + +- self: +- sends: Vec + +**Output**: std::result::Result + +### `decrypt_buffer` + +Decrypt a send file in memory + +**Arguments**: + +- self: +- send: Send +- buffer: Vec<> + +**Output**: std::result::Result + +### `decrypt_file` + +Decrypt a send file located in the file system + +**Arguments**: + +- self: +- send: Send +- encrypted_file_path: String +- decrypted_file_path: String + +**Output**: std::result::Result<,BitwardenError> + ## ClientVault ### `folders` @@ -325,7 +410,7 @@ Ciphers operations ### `password_history` -Ciphers operations +Password history operations **Arguments**: @@ -333,6 +418,16 @@ Ciphers operations **Output**: Arc +### `sends` + +Sends operations + +**Arguments**: + +- self: Arc + +**Output**: Arc + # References References are generated from the JSON schemas and should mostly match the kotlin and swift diff --git a/support/docs/docs.ts b/support/docs/docs.ts index ed79c4c2c..14603dd57 100644 --- a/support/docs/docs.ts +++ b/support/docs/docs.ts @@ -28,6 +28,7 @@ const rootElements = [ "ClientFolders", "ClientGenerators", "ClientPasswordHistory", + "ClientSends", "ClientVault", ]; From 4913b6663cd179fd0b0077ae989b277e4380d7ce Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 12:32:30 +0200 Subject: [PATCH 06/12] Update bitwarden/gh-actions digest to 4a7ddc1 (#191) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/build-android.yml | 2 +- .github/workflows/publish-rust-crates.yml | 2 +- .github/workflows/release-cli.yml | 8 ++++---- .github/workflows/release-napi.yml | 12 ++++++------ .github/workflows/version-bump.yml | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index 00e1fffce..4e33e31fe 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -108,7 +108,7 @@ jobs: - name: Retrieve bot secrets id: retrieve-bot-secrets - uses: bitwarden/gh-actions/get-keyvault-secrets@f096207b7a2f31723165aee6ad03e91716686e78 + uses: bitwarden/gh-actions/get-keyvault-secrets@4a7ddc1b38ca5cb4e3e43578f4df5cabe4f55a67 with: keyvault: bitwarden-ci secrets: "github-pat-bitwarden-devops-bot-packages-scope" diff --git a/.github/workflows/publish-rust-crates.yml b/.github/workflows/publish-rust-crates.yml index 14d846545..bad422424 100644 --- a/.github/workflows/publish-rust-crates.yml +++ b/.github/workflows/publish-rust-crates.yml @@ -109,7 +109,7 @@ jobs: - name: Retrieve secrets id: retrieve-secrets - uses: bitwarden/gh-actions/get-keyvault-secrets@f096207b7a2f31723165aee6ad03e91716686e78 + uses: bitwarden/gh-actions/get-keyvault-secrets@4a7ddc1b38ca5cb4e3e43578f4df5cabe4f55a67 with: keyvault: "bitwarden-ci" secrets: "cratesio-api-token" diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index 4c74d1e64..6bfba11fb 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -58,7 +58,7 @@ jobs: - name: Download all Release artifacts if: ${{ github.event.inputs.release_type != 'Dry Run' }} - uses: bitwarden/gh-actions/download-artifacts@f096207b7a2f31723165aee6ad03e91716686e78 + uses: bitwarden/gh-actions/download-artifacts@4a7ddc1b38ca5cb4e3e43578f4df5cabe4f55a67 with: workflow: build-cli.yml path: packages @@ -67,7 +67,7 @@ jobs: - name: Dry Run - Download all artifacts if: ${{ github.event.inputs.release_type == 'Dry Run' }} - uses: bitwarden/gh-actions/download-artifacts@f096207b7a2f31723165aee6ad03e91716686e78 + uses: bitwarden/gh-actions/download-artifacts@4a7ddc1b38ca5cb4e3e43578f4df5cabe4f55a67 with: workflow: build-cli.yml path: packages @@ -75,7 +75,7 @@ jobs: branch: master - name: Get checksum files - uses: bitwarden/gh-actions/get-checksum@f096207b7a2f31723165aee6ad03e91716686e78 + uses: bitwarden/gh-actions/get-checksum@4a7ddc1b38ca5cb4e3e43578f4df5cabe4f55a67 with: packages_dir: "packages" file_path: "packages/bws-sha256-checksums-${{ steps.version.outputs.version }}.txt" @@ -134,7 +134,7 @@ jobs: - name: Retrieve secrets id: retrieve-secrets - uses: bitwarden/gh-actions/get-keyvault-secrets@f096207b7a2f31723165aee6ad03e91716686e78 + uses: bitwarden/gh-actions/get-keyvault-secrets@4a7ddc1b38ca5cb4e3e43578f4df5cabe4f55a67 with: keyvault: "bitwarden-ci" secrets: "cratesio-api-token" diff --git a/.github/workflows/release-napi.yml b/.github/workflows/release-napi.yml index e5c652fb9..6c8b73341 100644 --- a/.github/workflows/release-napi.yml +++ b/.github/workflows/release-napi.yml @@ -47,7 +47,7 @@ jobs: - name: Check Release Version id: version - uses: bitwarden/gh-actions/release-version-check@f096207b7a2f31723165aee6ad03e91716686e78 + uses: bitwarden/gh-actions/release-version-check@4a7ddc1b38ca5cb4e3e43578f4df5cabe4f55a67 with: release-type: ${{ github.event.inputs.release_type }} project-type: ts @@ -101,7 +101,7 @@ jobs: - name: Download schemas if: ${{ github.event.inputs.release_type != 'Dry Run' }} - uses: bitwarden/gh-actions/download-artifacts@f096207b7a2f31723165aee6ad03e91716686e78 + uses: bitwarden/gh-actions/download-artifacts@4a7ddc1b38ca5cb4e3e43578f4df5cabe4f55a67 with: workflow: build-napi.yml artifacts: schemas.ts @@ -111,7 +111,7 @@ jobs: - name: Dry Run - Download schemas if: ${{ github.event.inputs.release_type == 'Dry Run' }} - uses: bitwarden/gh-actions/download-artifacts@f096207b7a2f31723165aee6ad03e91716686e78 + uses: bitwarden/gh-actions/download-artifacts@4a7ddc1b38ca5cb4e3e43578f4df5cabe4f55a67 with: workflow: build-napi.yml artifacts: schemas.ts @@ -132,14 +132,14 @@ jobs: - name: Retrieve secrets id: retrieve-secrets - uses: bitwarden/gh-actions/get-keyvault-secrets@f096207b7a2f31723165aee6ad03e91716686e78 + uses: bitwarden/gh-actions/get-keyvault-secrets@4a7ddc1b38ca5cb4e3e43578f4df5cabe4f55a67 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@f096207b7a2f31723165aee6ad03e91716686e78 + uses: bitwarden/gh-actions/download-artifacts@4a7ddc1b38ca5cb4e3e43578f4df5cabe4f55a67 with: workflow: build-napi.yml path: ${{ github.workspace }}/crates/bitwarden-napi/artifacts @@ -148,7 +148,7 @@ jobs: - name: Dry Run - Download artifacts if: ${{ github.event.inputs.release_type == 'Dry Run' }} - uses: bitwarden/gh-actions/download-artifacts@f096207b7a2f31723165aee6ad03e91716686e78 + uses: bitwarden/gh-actions/download-artifacts@4a7ddc1b38ca5cb4e3e43578f4df5cabe4f55a67 with: workflow: build-napi.yml path: ${{ github.workspace }}/crates/bitwarden-napi/artifacts diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index d370d5e6a..f667371ec 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -49,7 +49,7 @@ jobs: - name: Retrieve secrets id: retrieve-secrets - uses: bitwarden/gh-actions/get-keyvault-secrets@f096207b7a2f31723165aee6ad03e91716686e78 + uses: bitwarden/gh-actions/get-keyvault-secrets@4a7ddc1b38ca5cb4e3e43578f4df5cabe4f55a67 with: keyvault: "bitwarden-ci" secrets: "github-gpg-private-key, github-gpg-private-key-passphrase" From f5d5760a6ee408e49c0641c63643f5d38297015a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 10:33:47 +0000 Subject: [PATCH 07/12] Update gh minor (#192) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/build-android.yml | 8 ++++---- .github/workflows/build-cli.yml | 8 ++++---- .github/workflows/build-napi.yml | 2 +- .github/workflows/build-rust-crates.yml | 4 ++-- .github/workflows/cloc.yml | 2 +- .github/workflows/direct-minimal-versions.yml | 2 +- .github/workflows/generate_schemas.yml | 2 +- .github/workflows/lint.yml | 2 +- .github/workflows/publish-rust-crates.yml | 4 ++-- .github/workflows/release-cli.yml | 6 +++--- .github/workflows/release-napi.yml | 4 ++-- .github/workflows/rust-test.yml | 4 ++-- .github/workflows/version-bump.yml | 4 ++-- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index 4e33e31fe..a1db20ed2 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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Install rust uses: dtolnay/rust-toolchain@f361669954a8ecfc00a3443f35f9ac8e610ffc06 # stable @@ -57,14 +57,14 @@ jobs: needs: build steps: - name: Checkout repo (PR) - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 if: github.event_name == 'push' with: fetch-depth: 0 @@ -114,7 +114,7 @@ jobs: secrets: "github-pat-bitwarden-devops-bot-packages-scope" - name: Publish - uses: gradle/gradle-build-action@243af859f8ca30903d9d7f7936897ca0358ba691 # v2.7.1 + uses: gradle/gradle-build-action@ef76a971e2fa3f867b617efd72f2fbd72cf6f8bc # v2.8.0 with: arguments: sdk:publish build-root-directory: languages/kotlin diff --git a/.github/workflows/build-cli.yml b/.github/workflows/build-cli.yml index 132c67cd6..27262e53a 100644 --- a/.github/workflows/build-cli.yml +++ b/.github/workflows/build-cli.yml @@ -22,7 +22,7 @@ jobs: package_version: ${{ steps.retrieve-version.outputs.package_version }} steps: - name: Checkout repo - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Get Package Version id: retrieve-version @@ -60,7 +60,7 @@ jobs: target: aarch64-unknown-linux-gnu steps: - name: Checkout repo - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Install rust uses: dtolnay/rust-toolchain@f361669954a8ecfc00a3443f35f9ac8e610ffc06 # stable @@ -115,7 +115,7 @@ jobs: _PACKAGE_VERSION: ${{ needs.setup.outputs.package_version }} steps: - name: Checkout repo - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Download x86_64-apple-darwin artifact uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2 @@ -155,7 +155,7 @@ jobs: - setup steps: - name: Checkout repo - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Install rust uses: dtolnay/rust-toolchain@f361669954a8ecfc00a3443f35f9ac8e610ffc06 # stable diff --git a/.github/workflows/build-napi.yml b/.github/workflows/build-napi.yml index b2433e4b5..87b9db7af 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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Setup Node uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1 diff --git a/.github/workflows/build-rust-crates.yml b/.github/workflows/build-rust-crates.yml index d170e93c2..db01e39b0 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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Install rust uses: dtolnay/rust-toolchain@f361669954a8ecfc00a3443f35f9ac8e610ffc06 # stable @@ -64,7 +64,7 @@ jobs: - build steps: - name: Checkout - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Install rust uses: dtolnay/rust-toolchain@f361669954a8ecfc00a3443f35f9ac8e610ffc06 # stable diff --git a/.github/workflows/cloc.yml b/.github/workflows/cloc.yml index 6b0672dcb..6730cbc08 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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Set up cloc run: | diff --git a/.github/workflows/direct-minimal-versions.yml b/.github/workflows/direct-minimal-versions.yml index ab5462f22..37f21205a 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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Install rust uses: dtolnay/rust-toolchain@f361669954a8ecfc00a3443f35f9ac8e610ffc06 # stable diff --git a/.github/workflows/generate_schemas.yml b/.github/workflows/generate_schemas.yml index a391cfb83..98eb2ce9c 100644 --- a/.github/workflows/generate_schemas.yml +++ b/.github/workflows/generate_schemas.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Install rust uses: dtolnay/rust-toolchain@f361669954a8ecfc00a3443f35f9ac8e610ffc06 # stable diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index aeebb60cd..c72a2e653 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Install rust uses: dtolnay/rust-toolchain@f361669954a8ecfc00a3443f35f9ac8e610ffc06 # stable diff --git a/.github/workflows/publish-rust-crates.yml b/.github/workflows/publish-rust-crates.yml index bad422424..7723cac66 100644 --- a/.github/workflows/publish-rust-crates.yml +++ b/.github/workflows/publish-rust-crates.yml @@ -43,7 +43,7 @@ jobs: packages_command: ${{ steps.packages-list.outputs.packages_command }} steps: - name: Checkout repo - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Branch check if: ${{ github.event.inputs.release_type != 'Dry Run' }} @@ -100,7 +100,7 @@ jobs: - setup steps: - name: Checkout - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Login to Azure uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index 6bfba11fb..bd0c1cdeb 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -27,7 +27,7 @@ jobs: release-version: ${{ steps.version.outputs.version }} steps: - name: Checkout repo - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Branch check if: ${{ github.event.inputs.release_type != 'Dry Run' }} @@ -82,7 +82,7 @@ jobs: - name: Create release if: ${{ github.event.inputs.release_type != 'Dry Run' }} - uses: ncipollo/release-action@a2e71bdd4e7dab70ca26a852f29600c98b33153e # v1.12.0 + uses: ncipollo/release-action@6c75be85e571768fa31b40abf38de58ba0397db5 # v1.13.0 env: PKG_VERSION: ${{ steps.version.outputs.version }} with: @@ -125,7 +125,7 @@ jobs: - setup steps: - name: Checkout - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Login to Azure uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 diff --git a/.github/workflows/release-napi.yml b/.github/workflows/release-napi.yml index 6c8b73341..497b582eb 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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Setup Node uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3.8.1 diff --git a/.github/workflows/rust-test.yml b/.github/workflows/rust-test.yml index 9cc44a962..09168e9db 100644 --- a/.github/workflows/rust-test.yml +++ b/.github/workflows/rust-test.yml @@ -36,7 +36,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Install rust uses: dtolnay/rust-toolchain@f361669954a8ecfc00a3443f35f9ac8e610ffc06 # stable @@ -56,7 +56,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Install rust uses: dtolnay/rust-toolchain@f361669954a8ecfc00a3443f35f9ac8e610ffc06 # stable diff --git a/.github/workflows/version-bump.yml b/.github/workflows/version-bump.yml index f667371ec..352904fba 100644 --- a/.github/workflows/version-bump.yml +++ b/.github/workflows/version-bump.yml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout Branch - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - name: Install rust uses: dtolnay/rust-toolchain@f361669954a8ecfc00a3443f35f9ac8e610ffc06 # stable @@ -55,7 +55,7 @@ jobs: secrets: "github-gpg-private-key, github-gpg-private-key-passphrase" - name: Import GPG key - uses: crazy-max/ghaction-import-gpg@72b6676b71ab476b77e676928516f6982eef7a41 # v5.3.0 + uses: crazy-max/ghaction-import-gpg@d6f3f49f3345e29369fe57596a3ca8f94c4d2ca7 # v5.4.0 with: gpg_private_key: ${{ steps.retrieve-secrets.outputs.github-gpg-private-key }} passphrase: ${{ steps.retrieve-secrets.outputs.github-gpg-private-key-passphrase }} From 9b46d284d93527f046c391f858d5b759984db954 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 5 Sep 2023 13:23:39 +0200 Subject: [PATCH 08/12] Change gh action android combine rust toolchain to stable (#219) --- .github/workflows/build-android.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml index a1db20ed2..e61535d08 100644 --- a/.github/workflows/build-android.yml +++ b/.github/workflows/build-android.yml @@ -72,7 +72,7 @@ jobs: - name: Install rust uses: dtolnay/rust-toolchain@f361669954a8ecfc00a3443f35f9ac8e610ffc06 # stable with: - toolchain: 1.67.0 # https://github.com/cross-rs/cross/issues/1222 + toolchain: stable - name: Cache cargo registry uses: Swatinem/rust-cache@e207df5d269b42b69c8bc5101da26f7d31feddb4 # v2.6.2 From de2199a9cce976a407fedf79cbf43fa93f8cfb3e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Tue, 5 Sep 2023 14:33:33 +0200 Subject: [PATCH 09/12] Lock file maintenance (#194) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 236 ++++++++++----------- crates/bitwarden-napi/package-lock.json | 12 +- languages/js_webassembly/package-lock.json | 72 +++---- package-lock.json | 42 ++-- 4 files changed, 180 insertions(+), 182 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 56d5a6205..5b1c29183 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.20.0" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4fa78e18c64fce05e902adecd7a5eed15a5e0a3439f7b0e169f0252214865e3" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" dependencies = [ "gimli", ] @@ -30,9 +30,9 @@ dependencies = [ [[package]] name = "aho-corasick" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6748e8def348ed4d14996fa801f4122cd763fff530258cdc03f64b25f89d3a5a" +checksum = "0c378d78423fdad8089616f827526ee33c19f2fddbd5de1629152c9593ba4783" dependencies = [ "memchr", ] @@ -63,24 +63,23 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.2" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "b1f58811cfac344940f1a400b6e6231ce35171f614f26439e80f8c1465c5cc0c" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "15c4c2c83f81532e5845a733998b6971faca23490340a418e9b72a3ec9de12ea" [[package]] name = "anstyle-parse" @@ -102,9 +101,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.2" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c677ab05e09154296dd37acecd46420c17b9713e8366facafa8fc0885167cf4c" +checksum = "58f54d10c6dfa51283a066ceab3ec1ab78d13fae00aa49243a45e4571fb79dfd" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -124,9 +123,9 @@ checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6" [[package]] name = "argon2" -version = "0.5.1" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2e554a8638bdc1e4eae9984845306cc95f8a9208ba8d49c3859fd958b46774d" +checksum = "17ba4cac0a46bc1d2912652a751c47f2a9f3a7fe89bcae2275d418f5270402f9" dependencies = [ "base64ct", "blake2", @@ -157,7 +156,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -210,7 +209,7 @@ checksum = "bc00ceb34980c03614e35a3a4e218276a0a824e911d07651cd0d858a51e8c0f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -221,9 +220,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.68" +version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4319208da049c43661739c5fade2ba182f09d1dc2299b32298d3a31692b17e12" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" dependencies = [ "addr2line", "cc", @@ -242,9 +241,9 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" [[package]] name = "base64" -version = "0.21.2" +version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" +checksum = "414dcefbc63d77c526a76b3afcf6fbb9b5e2791c19c3aa2297733208750c6e53" [[package]] name = "base64ct" @@ -317,7 +316,7 @@ dependencies = [ "aes", "argon2", "assert_matches", - "base64 0.21.2", + "base64 0.21.3", "bitwarden-api-api", "bitwarden-api-identity", "cbc", @@ -482,9 +481,9 @@ dependencies = [ [[package]] name = "bstr" -version = "1.6.0" +version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6798148dccfbff0fae41c7574d2fa8f1ef3492fba0face179de5d8d447d67b05" +checksum = "4c2f7349907b712260e64b0afe2f84692af14a454be26187d9df565c7f69266a" dependencies = [ "memchr", "serde", @@ -557,9 +556,9 @@ checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" [[package]] name = "bytesize" -version = "1.2.0" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38fcc2979eff34a4b84e1cf9a1e3da42a7d44b3b690a40cdcb23e3d556cfb2e5" +checksum = "a3e368af43e418a04d52505cf3dbc23dda4e3407ae2fa99fd0e4f308ce546acc" [[package]] name = "camino" @@ -619,15 +618,15 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.26" +version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" +checksum = "95ed24df0632f708f5f6d8082675bef2596f7084dee3dd55f632290bf35bfe0f" dependencies = [ "android-tzdata", "iana-time-zone", "num-traits", "serde", - "winapi", + "windows-targets 0.48.5", ] [[package]] @@ -642,54 +641,52 @@ dependencies = [ [[package]] name = "clap" -version = "4.3.23" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03aef18ddf7d879c15ce20f04826ef8418101c7e528014c3eeea13321047dca3" +checksum = "6a13b88d2c62ff462f88e4a121f17a82c1af05693a2f192b5c38d14de73c19f6" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] name = "clap_builder" -version = "4.3.23" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ce6fffb678c9b80a70b6b6de0aad31df727623a70fd9a842c30cd573e2fa98" +checksum = "2bb9faaa7c2ef94b2743a21f5a29e6f0010dff4caa69ac8e9d6cf8b6fa74da08" dependencies = [ "anstream", "anstyle", "clap_lex", - "once_cell", "strsim", ] [[package]] name = "clap_complete" -version = "4.3.2" +version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fc443334c81a804575546c5a8a79b4913b50e28d69232903604cada1de817ce" +checksum = "586a385f7ef2f8b4d86bddaa0c094794e7ccbfe5ffef1f434fe928143fc783a5" dependencies = [ "clap", ] [[package]] name = "clap_derive" -version = "4.3.12" +version = "4.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +checksum = "0862016ff20d69b84ef8247369fabf5c008a7417002411897d40ee1f4532b873" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "cd7cc57abe963c6d3b9d8be5b06ba7c8957a930305ca90304f24ef040aa6f961" [[package]] name = "clircle" @@ -916,7 +913,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f34ba9a9bcb8645379e9de8cb3ecfcf4d1c85ba66d90deb3259206fa5aa193b" dependencies = [ "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -1081,9 +1078,9 @@ checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" [[package]] name = "encoding_rs" -version = "0.8.32" +version = "0.8.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +checksum = "7268b386296a025e474d5140678f75d6de9493ae55a5d709eeb9dd08149945e1" dependencies = [ "cfg-if", ] @@ -1109,9 +1106,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" +checksum = "136526188508e25c6fef639d7927dfb3e0e3084488bf202267829cf7fc23dbdd" dependencies = [ "errno-dragonfly", "libc", @@ -1276,7 +1273,7 @@ checksum = "89ca545a94061b6365f2c7355b4b32bd20df3ff95f02da9329b34ccc3bd6ee72" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -1351,9 +1348,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.27.3" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6c80984affa11d98d1b88b66ac8853f143217b399d3c74116778ff8fdb4ed2e" +checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" [[package]] name = "glob" @@ -1387,9 +1384,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.20" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97ec8491ebaf99c8eaa73058b045fe58073cd6be7f596ac993ced0b0a0c01049" +checksum = "91fc23aa11be92976ef4729127f1a74adf36d8436f7816b185d18df956790833" dependencies = [ "bytes", "fnv", @@ -1768,9 +1765,9 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" [[package]] name = "memoffset" @@ -1930,9 +1927,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg", "num-integer", @@ -1999,9 +1996,9 @@ dependencies = [ [[package]] name = "object" -version = "0.31.1" +version = "0.32.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8bda667d9f2b5051b8833f59f3bf748b28ef54f850f4fcb389a252aa383866d1" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" dependencies = [ "memchr", ] @@ -2036,11 +2033,11 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.56" +version = "0.10.57" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "729b745ad4a5575dd06a3e1af1414bd330ee561c01b3899eb584baeaa8def17e" +checksum = "bac25ee399abb46215765b1cb35bc0212377e58a061560d8b29b024fd0430e7c" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.0", "cfg-if", "foreign-types", "libc", @@ -2057,7 +2054,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -2068,18 +2065,18 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "111.27.0+1.1.1v" +version = "300.1.3+3.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06e8f197c82d7511c5b014030c9b1efeda40d7d5f99d23b4ceed3524a5e63f02" +checksum = "cd2c101a165fff9935e34def4669595ab1c7847943c42be86e21503e482be107" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.91" +version = "0.9.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "866b5f16f90776b9bb8dc1e1802ac6f0513de3a7a7465867bfbc563dc737faac" +checksum = "db4d56a4c0478783083cfafcc42493dd4a981d41669da64b4572a2a089b51b1d" dependencies = [ "cc", "libc", @@ -2181,9 +2178,9 @@ checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" -version = "0.2.12" +version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12cc1b0bf1727a77a54b6654e7b5f1af8604923edc8b81885f8ec92f9e3f0a05" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" [[package]] name = "pin-utils" @@ -2230,7 +2227,7 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bdc0001cfea3db57a2e24bc0d818e9e20e554b5f97fabb9bc231dc240269ae06" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", "indexmap 1.9.3", "line-wrap", "quick-xml", @@ -2469,9 +2466,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.3" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bc1d4caf89fac26a70747fe603c130093b53c773888797a6329091246d651a" +checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" dependencies = [ "aho-corasick", "memchr", @@ -2481,9 +2478,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.6" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed1ceff11a1dddaee50c9dc8e4938bd106e9d89ae372f192311e7da498e3b69" +checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" dependencies = [ "aho-corasick", "memchr", @@ -2492,17 +2489,17 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "reqwest" -version = "0.11.18" +version = "0.11.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cde824a14b7c14f85caff81225f411faacc04a2013f41670f41443742b1c1c55" +checksum = "3e9ad3fe7488d7e34558a2033d45a0c90b72d97b4f80705666fea71472e2e6a1" dependencies = [ - "base64 0.21.2", + "base64 0.21.3", "bytes", "encoding_rs", "futures-core", @@ -2579,9 +2576,9 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.38.8" +version = "0.38.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19ed4fa021d81c8392ce04db050a3da9a60299050b7ae1cf482d862b54a7218f" +checksum = "c0c3dde1fc030af041adc40e79c0e7fbcf431dd24870053d187d7c66e4b87453" dependencies = [ "bitflags 2.4.0", "errno", @@ -2628,9 +2625,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02c613288622e5f0c3fdc5dbd4db1c5fbe752746b1d1a56a0630b78fd00de44f" +checksum = "763f8cd0d4c71ed8389c90cb8100cba87e763bd01a8e614d4f0af97bcd50a161" dependencies = [ "chrono", "dyn-clone", @@ -2643,9 +2640,9 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.12" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109da1e6b197438deb6db99952990c7f959572794b80ff93707d55a232545e7c" +checksum = "ec0f696e21e10fa546b7ffb1c9672c6de8fbc7a81acf59524386d8639bf12737" dependencies = [ "proc-macro2", "quote", @@ -2682,7 +2679,7 @@ checksum = "1db149f81d46d2deba7cd3c50772474707729550221e69588478ebf9ada425ae" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -2732,22 +2729,22 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.185" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be9b6f69f1dfd54c3b568ffa45c310d6973a5e5148fd40cf515acaf38cf5bc31" +checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.185" +version = "1.0.188" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc59dfdcbad1437773485e0367fea4b090a2e0a16d9ffc46af47764536a298ec" +checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -2802,7 +2799,7 @@ checksum = "8725e1dfadb3a50f7e5ce0b1a540466f6ed3fe7a0fca2ac2b8b831d31316bd00" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -2924,15 +2921,15 @@ dependencies = [ [[package]] name = "siphasher" -version = "0.3.10" +version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" +checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "slab" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] @@ -3045,9 +3042,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.29" +version = "2.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c324c494eba9d92503e6f1ef2e6df781e78f6a7705a0202d9801b198807d518a" +checksum = "718fa2415bcb8d8bd775917a1bf12a7931b6dfa890753378538118181e0cb398" dependencies = [ "proc-macro2", "quote", @@ -3103,22 +3100,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.47" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97a802ec30afc17eee47b2855fc72e0c4cd62be9b4efe6591edde0ec5bd68d8f" +checksum = "9d6d7a740b8a666a7e828dd00da9c0dc290dff53154ea77ac109281de90589b7" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.47" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb623b56e39ab7dcd4b1b98bb6c8f8d907ed255b18de254088016b27a8ee19b" +checksum = "49922ecae66cc8a249b77e68d1d0623c1b2c514f0060c27cdc68bd62a1219d35" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -3133,9 +3130,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.25" +version = "0.3.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea" +checksum = "17f6bb557fd245c28e6411aa56b6403c689ad95061f50e4be16c274e70a17e48" dependencies = [ "deranged", "itoa", @@ -3152,9 +3149,9 @@ checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" [[package]] name = "time-macros" -version = "0.2.11" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb71511c991639bb078fd5bf97757e03914361c48100d52878b8e52b46fb92cd" +checksum = "1a942f44339478ef67935ab2bbaec2fb0322496cf3cbe84b261e06ac3814c572" dependencies = [ "time-core", ] @@ -3199,7 +3196,7 @@ checksum = "630bdcf245f78637c13ec01ffae6187cca34625e8c63150d424b59e55af2675e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -3331,9 +3328,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "unicase" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" dependencies = [ "version_check", ] @@ -3432,7 +3429,7 @@ version = "0.24.1" source = "git+https://github.com/mozilla/uniffi-rs?rev=53d5ac7274d8b4d66ad35b68cb6e2d89898f96af#53d5ac7274d8b4d66ad35b68cb6e2d89898f96af" dependencies = [ "quote", - "syn 2.0.29", + "syn 2.0.31", ] [[package]] @@ -3462,7 +3459,7 @@ dependencies = [ "proc-macro2", "quote", "serde", - "syn 2.0.29", + "syn 2.0.31", "toml 0.5.11", "uniffi_build", "uniffi_meta", @@ -3519,9 +3516,9 @@ checksum = "f28467d3e1d3c6586d8f25fa243f544f5800fec42d97032474e17222c2b75cfa" [[package]] name = "url" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" +checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" dependencies = [ "form_urlencoded", "idna", @@ -3622,7 +3619,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", "wasm-bindgen-shared", ] @@ -3656,7 +3653,7 @@ checksum = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.29", + "syn 2.0.31", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3883,20 +3880,21 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "winnow" -version = "0.5.14" +version = "0.5.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d09770118a7eb1ccaf4a594a221334119a44a814fcb0d31c5b85e83e97227a97" +checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc" dependencies = [ "memchr", ] [[package]] name = "winreg" -version = "0.10.1" +version = "0.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ - "winapi", + "cfg-if", + "windows-sys 0.48.0", ] [[package]] @@ -3907,7 +3905,7 @@ checksum = "c6f71803d3a1c80377a06221e0530be02035d5b3e854af56c6ece7ac20ac441d" dependencies = [ "assert-json-diff", "async-trait", - "base64 0.21.2", + "base64 0.21.3", "deadpool", "futures", "futures-timer", diff --git a/crates/bitwarden-napi/package-lock.json b/crates/bitwarden-napi/package-lock.json index 1a1b31054..72fcf5e58 100644 --- a/crates/bitwarden-napi/package-lock.json +++ b/crates/bitwarden-napi/package-lock.json @@ -95,9 +95,9 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.5.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.1.tgz", - "integrity": "sha512-4tT2UrL5LBqDwoed9wZ6N3umC4Yhz3W3FloMmiiG4JwmUJWpie0c7lcnUNd4gtMKuDEO4wRVS8B6Xa0uMRsMKg==", + "version": "20.5.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.9.tgz", + "integrity": "sha512-PcGNd//40kHAS3sTlzKB9C9XL4K0sTup8nbG5lC14kzEteTNuAFh9u5nA0o5TWnSG2r/JNPRXFVcHJIIeRlmqQ==", "dev": true, "peer": true }, @@ -193,9 +193,9 @@ } }, "node_modules/typescript": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", - "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "dev": true, "bin": { "tsc": "bin/tsc", diff --git a/languages/js_webassembly/package-lock.json b/languages/js_webassembly/package-lock.json index ad09cd303..f0530cd87 100644 --- a/languages/js_webassembly/package-lock.json +++ b/languages/js_webassembly/package-lock.json @@ -107,18 +107,18 @@ } }, "node_modules/@types/connect": { - "version": "3.4.35", - "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz", - "integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==", + "version": "3.4.36", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.36.tgz", + "integrity": "sha512-P63Zd/JUGq+PdrM1lv0Wv5SBYeA2+CORvbrXbngriYY0jzLUWfQMQQxOhjONEz/wlHOAxOdY7CY65rgQdTjq2w==", "dev": true, "dependencies": { "@types/node": "*" } }, "node_modules/@types/connect-history-api-fallback": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.5.0.tgz", - "integrity": "sha512-4x5FkPpLipqwthjPsF7ZRbOv3uoLUFkTA9G9v583qi4pACvq0uTELrB8OLUzPWUI4IJIyvM85vzkV1nyiI2Lig==", + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.5.1.tgz", + "integrity": "sha512-iaQslNbARe8fctL5Lk+DsmgWOM83lM+7FzP0eQUJs1jd3kBE8NWqBTIT2S8SqQOJjxvt2eyIjpOuYeRXq2AdMw==", "dev": true, "dependencies": { "@types/express-serve-static-core": "*", @@ -164,9 +164,9 @@ } }, "node_modules/@types/express-serve-static-core": { - "version": "4.17.35", - "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.35.tgz", - "integrity": "sha512-wALWQwrgiB2AWTT91CB62b6Yt0sNHpznUXeZEcnPU3DRdlDIz74x8Qg1UUYKSVFi+va5vKOLYRBI1bRKiLLKIg==", + "version": "4.17.36", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.17.36.tgz", + "integrity": "sha512-zbivROJ0ZqLAtMzgzIUC4oNqDG9iF0lSsAqpOD9kbs5xcIM3dTiyuHvBc7R8MtWBp3AAWGaovJa+wzWPjLYW7Q==", "dev": true, "dependencies": { "@types/node": "*", @@ -209,15 +209,15 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.5.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.1.tgz", - "integrity": "sha512-4tT2UrL5LBqDwoed9wZ6N3umC4Yhz3W3FloMmiiG4JwmUJWpie0c7lcnUNd4gtMKuDEO4wRVS8B6Xa0uMRsMKg==", + "version": "20.5.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.9.tgz", + "integrity": "sha512-PcGNd//40kHAS3sTlzKB9C9XL4K0sTup8nbG5lC14kzEteTNuAFh9u5nA0o5TWnSG2r/JNPRXFVcHJIIeRlmqQ==", "dev": true }, "node_modules/@types/qs": { - "version": "6.9.7", - "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", - "integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==", + "version": "6.9.8", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.8.tgz", + "integrity": "sha512-u95svzDlTysU5xecFNTgfFG5RUWu1A9P0VzgpcIiGZA9iraHOdSzcxMxQ55DyeRaGCSxQi7LxXDI4rzq/MYfdg==", "dev": true }, "node_modules/@types/range-parser": { @@ -823,9 +823,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001522", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001522.tgz", - "integrity": "sha512-TKiyTVZxJGhsTszLuzb+6vUZSjVOAhClszBr2Ta2k9IwtNBT/4dzmL6aywt0HCgEZlmwJzXJd8yNiob6HgwTRg==", + "version": "1.0.30001527", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001527.tgz", + "integrity": "sha512-YkJi7RwPgWtXVSgK4lG9AHH57nSzvvOp9MesgXmw4Q7n0C3H04L0foHqfxcmSAm5AcWb8dW9AYj2tR7/5GnddQ==", "dev": true, "funding": [ { @@ -1159,9 +1159,9 @@ "dev": true }, "node_modules/dns-packet": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-5.6.0.tgz", - "integrity": "sha512-rza3UH1LwdHh9qyPXp8lkwpjSNk/AMD3dPytUoRoqnypDUhY0xvbdmVhWOfxO68frEfV9BU8V12Ez7ZsHGZpCQ==", + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/dns-packet/-/dns-packet-5.6.1.tgz", + "integrity": "sha512-l4gcSouhcgIKRvyy99RNVOgxXiicE+2jZoNmaNmZ6JXiGajBOJAesk1OBlJuM5k2c+eudGdLxDqXuPCKIj6kpw==", "dev": true, "dependencies": { "@leichtgewicht/ip-codec": "^2.0.1" @@ -1251,9 +1251,9 @@ "dev": true }, "node_modules/electron-to-chromium": { - "version": "1.4.496", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.496.tgz", - "integrity": "sha512-qeXC3Zbykq44RCrBa4kr8v/dWzYJA8rAwpyh9Qd+NKWoJfjG5vvJqy9XOJ9H4P/lqulZBCgUWAYi+FeK5AuJ8g==", + "version": "1.4.508", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.508.tgz", + "integrity": "sha512-FFa8QKjQK/A5QuFr2167myhMesGrhlOBD+3cYNxO9/S4XzHEXesyTD/1/xF644gC8buFPz3ca6G1LOQD0tZrrg==", "dev": true }, "node_modules/encodeurl": { @@ -1609,9 +1609,9 @@ "dev": true }, "node_modules/fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", "dev": true, "hasInstallScript": true, "optional": true, @@ -3425,9 +3425,9 @@ } }, "node_modules/tar": { - "version": "6.1.15", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.15.tgz", - "integrity": "sha512-/zKt9UyngnxIT/EAGYuxaMYgOIJiP81ab9ZfkILq4oNLPFX50qyYmu7jRj9qeXoxmJHjGlbH0+cm2uy1WCs10A==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz", + "integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==", "dev": true, "dependencies": { "chownr": "^2.0.0", @@ -3442,9 +3442,9 @@ } }, "node_modules/terser": { - "version": "5.19.2", - "resolved": "https://registry.npmjs.org/terser/-/terser-5.19.2.tgz", - "integrity": "sha512-qC5+dmecKJA4cpYxRa5aVkKehYsQKc+AHeKl0Oe62aYjBL8ZA33tTljktDHJSaxxMnbI5ZYw+o/S2DxxLu8OfA==", + "version": "5.19.4", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.19.4.tgz", + "integrity": "sha512-6p1DjHeuluwxDXcuT9VR8p64klWJKo1ILiy19s6C9+0Bh2+NWTX6nD9EPppiER4ICkHDVB1RkVpin/YW2nQn/g==", "dev": true, "dependencies": { "@jridgewell/source-map": "^0.3.3", @@ -3572,9 +3572,9 @@ } }, "node_modules/typescript": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.1.6.tgz", - "integrity": "sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==", + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz", + "integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==", "dev": true, "peer": true, "bin": { diff --git a/package-lock.json b/package-lock.json index d3e3682db..ba1c715bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,9 +19,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.22.10", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.10.tgz", - "integrity": "sha512-21t/fkKLMZI4pqP2wlmsQAWnYW1PDyKyyUV4vCi+B25ydmdaYTKXPwCj0BzSUnZf4seIiYvSA3jcZ3gdsMFkLQ==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.15.tgz", + "integrity": "sha512-T0O+aa+4w0u06iNmapipJXMV4HoUir03hpx3/YqXXhu9xim3w+dVphjFWl1OH8NbZHw5Lbm9k45drDkgq2VNNA==", "dev": true, "dependencies": { "regenerator-runtime": "^0.14.0" @@ -405,16 +405,16 @@ "dev": true }, "node_modules/@types/node": { - "version": "20.5.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.1.tgz", - "integrity": "sha512-4tT2UrL5LBqDwoed9wZ6N3umC4Yhz3W3FloMmiiG4JwmUJWpie0c7lcnUNd4gtMKuDEO4wRVS8B6Xa0uMRsMKg==", + "version": "20.5.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.9.tgz", + "integrity": "sha512-PcGNd//40kHAS3sTlzKB9C9XL4K0sTup8nbG5lC14kzEteTNuAFh9u5nA0o5TWnSG2r/JNPRXFVcHJIIeRlmqQ==", "dev": true, "peer": true }, "node_modules/@types/urijs": { - "version": "1.19.19", - "resolved": "https://registry.npmjs.org/@types/urijs/-/urijs-1.19.19.tgz", - "integrity": "sha512-FDJNkyhmKLw7uEvTxx5tSXfPeQpO0iy73Ry+PmYZJvQy0QIWX8a7kJ4kLWRf+EbTPJEPDSgPXHaM7pzr5lmvCg==", + "version": "1.19.20", + "resolved": "https://registry.npmjs.org/@types/urijs/-/urijs-1.19.20.tgz", + "integrity": "sha512-77Mq/2BeHU894J364dUv9tSwxxyCLtcX228Pc8TwZpP5bvOoMns+gZoftp3LYl3FBH8vChpWbuagKGiMki2c1A==", "dev": true }, "node_modules/abort-controller": { @@ -1233,9 +1233,9 @@ } }, "node_modules/jackspeak": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.0.tgz", - "integrity": "sha512-uKmsITSsF4rUWQHzqaRUuyAir3fZfW3f202Ee34lz/gZCi970CPZwyQXLGNgWJvvZbvFyzeyGq0+4fcG/mBKZg==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.3.tgz", + "integrity": "sha512-R2bUw+kVZFS/h1AZqBKrSgDmdmjApzgY0AlCPumopFiAlbUxE2gf+SCuBzQ0cP5hHmUmFYF5yw55T97Th5Kstg==", "dev": true, "dependencies": { "@isaacs/cliui": "^8.0.2" @@ -1378,9 +1378,9 @@ "dev": true }, "node_modules/node-fetch": { - "version": "2.6.13", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.13.tgz", - "integrity": "sha512-StxNAxh15zr77QvvkmveSQ8uCQ4+v5FkvNTj0OESmiHu+VRi/gXArXtkWMElOsOUNLtUEvI4yS+rdtOHZTwlQA==", + "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, "dependencies": { "whatwg-url": "^5.0.0" @@ -1670,9 +1670,9 @@ } }, "node_modules/rimraf/node_modules/glob": { - "version": "10.3.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.3.tgz", - "integrity": "sha512-92vPiMb/iqpmEgsOoIDvTjc50wf9CCCvMzsi6W0JLPeUKE8TWP1a73PgqSrqy7iAZxaSD1YdzU7QZR5LF51MJw==", + "version": "10.3.4", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.3.4.tgz", + "integrity": "sha512-6LFElP3A+i/Q8XQKEvZjkEWEOTgAIALR9AO2rwT8bgPhDd1anmqDJDZ6lLddI4ehxxxR1S5RIqKe1uapMQfYaQ==", "dev": true, "dependencies": { "foreground-child": "^3.1.0", @@ -2171,9 +2171,9 @@ } }, "node_modules/yaml": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.1.tgz", - "integrity": "sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.3.2.tgz", + "integrity": "sha512-N/lyzTPaJasoDmfV7YTrYCI0G/3ivm/9wdG0aHuheKowWQwGTsK0Eoiw6utmzAnI6pkJa0DUVygvp3spqqEKXg==", "dev": true, "engines": { "node": ">= 14" From 766c85b251e819b10e1570cc34d478dc854935aa Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Tue, 5 Sep 2023 16:53:59 +0200 Subject: [PATCH 10/12] [PM-3431] Generate registration keys (#198) --- .vscode/settings.json | 1 + Cargo.lock | 1 + crates/bitwarden-cli/Cargo.toml | 1 + crates/bitwarden-cli/src/lib.rs | 12 + crates/bitwarden-uniffi/src/auth/mod.rs | 25 ++- crates/bitwarden/src/auth/client_auth.rs | 28 ++- crates/bitwarden/src/auth/mod.rs | 5 + crates/bitwarden/src/auth/register.rs | 85 ++++++++ .../src/client/encryption_settings.rs | 4 +- crates/bitwarden/src/crypto/aes_ops.rs | 24 +- crates/bitwarden/src/crypto/master_key.rs | 14 +- crates/bitwarden/src/crypto/mod.rs | 11 +- crates/bitwarden/src/crypto/rsa.rs | 42 ++++ crates/bitwarden/src/crypto/user_key.rs | 19 ++ .../src/mobile/vault/client_sends.rs | 3 +- crates/bw/src/auth/login.rs | 12 +- crates/bw/src/main.rs | 84 +++++-- languages/kotlin/doc.md | 205 +++++++++++++++++- 18 files changed, 517 insertions(+), 59 deletions(-) create mode 100644 crates/bitwarden/src/auth/register.rs create mode 100644 crates/bitwarden/src/crypto/rsa.rs create mode 100644 crates/bitwarden/src/crypto/user_key.rs diff --git a/.vscode/settings.json b/.vscode/settings.json index 8fbaf48b5..fcf022457 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,6 +12,7 @@ "Maybeable", "Oaep", "Pbkdf", + "PKCS8", "repr", "schemars", "uniffi", diff --git a/Cargo.lock b/Cargo.lock index 5b1c29183..1a749080d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -387,6 +387,7 @@ version = "0.1.0" dependencies = [ "clap", "color-eyre", + "inquire", "supports-color", ] diff --git a/crates/bitwarden-cli/Cargo.toml b/crates/bitwarden-cli/Cargo.toml index ca2e4ba7c..606e24856 100644 --- a/crates/bitwarden-cli/Cargo.toml +++ b/crates/bitwarden-cli/Cargo.toml @@ -7,4 +7,5 @@ rust-version = "1.57" [dependencies] clap = { version = "4.3.0", features = ["derive"] } color-eyre = "0.6" +inquire = "0.6.2" supports-color = "2.0.0" diff --git a/crates/bitwarden-cli/src/lib.rs b/crates/bitwarden-cli/src/lib.rs index 2652553f0..d0c6a836e 100644 --- a/crates/bitwarden-cli/src/lib.rs +++ b/crates/bitwarden-cli/src/lib.rs @@ -1,3 +1,15 @@ mod color; pub use color::{install_color_eyre, Color}; +use inquire::{error::InquireResult, Text}; + +/// Prompt the user for input if the value is None +/// +/// Typically used when the user can provide a value via CLI or prompt +pub fn text_prompt_when_none(prompt: &str, val: Option) -> InquireResult { + Ok(if let Some(val) = val { + val + } else { + Text::new(prompt).prompt()? + }) +} diff --git a/crates/bitwarden-uniffi/src/auth/mod.rs b/crates/bitwarden-uniffi/src/auth/mod.rs index fed3dc058..a1a0a2884 100644 --- a/crates/bitwarden-uniffi/src/auth/mod.rs +++ b/crates/bitwarden-uniffi/src/auth/mod.rs @@ -1,6 +1,9 @@ use std::sync::Arc; -use bitwarden::{auth::password::MasterPasswordPolicyOptions, client::auth_settings::Kdf}; +use bitwarden::{ + auth::{password::MasterPasswordPolicyOptions, RegisterKeyResponse}, + client::auth_settings::Kdf, +}; use crate::{error::Result, Client}; @@ -18,7 +21,7 @@ impl ClientAuth { ) -> u8 { self.0 .0 - .read() + .write() .await .auth() .password_strength(password, email, additional_inputs) @@ -34,7 +37,7 @@ impl ClientAuth { ) -> bool { self.0 .0 - .read() + .write() .await .auth() .satisfies_policy(password, strength, &policy) @@ -57,4 +60,20 @@ impl ClientAuth { .hash_password(email, password, kdf_params) .await?) } + + /// Generate keys needed for registration process + pub async 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)?) + } } diff --git a/crates/bitwarden/src/auth/client_auth.rs b/crates/bitwarden/src/auth/client_auth.rs index 086ce2752..7c5d1d98e 100644 --- a/crates/bitwarden/src/auth/client_auth.rs +++ b/crates/bitwarden/src/auth/client_auth.rs @@ -1,8 +1,12 @@ -use super::password::{password_strength, satisfies_policy, MasterPasswordPolicyOptions}; -use crate::Client; +use super::{ + password::{password_strength, satisfies_policy, MasterPasswordPolicyOptions}, + register::{make_register_keys, register}, + RegisterKeyResponse, RegisterRequest, +}; +use crate::{client::auth_settings::Kdf, error::Result, Client}; pub struct ClientAuth<'a> { - pub(crate) _client: &'a crate::Client, + pub(crate) client: &'a mut crate::Client, } impl<'a> ClientAuth<'a> { @@ -23,10 +27,24 @@ impl<'a> ClientAuth<'a> { ) -> bool { satisfies_policy(password, strength, policy) } + + pub fn make_register_keys( + &self, + email: String, + password: String, + kdf: Kdf, + ) -> Result { + make_register_keys(email, password, kdf) + } + + #[cfg(feature = "internal")] + pub async fn register(&mut self, input: &RegisterRequest) -> Result<()> { + register(self.client, input).await + } } impl<'a> Client { - pub fn auth(&'a self) -> ClientAuth<'a> { - ClientAuth { _client: self } + pub fn auth(&'a mut self) -> ClientAuth<'a> { + ClientAuth { client: self } } } diff --git a/crates/bitwarden/src/auth/mod.rs b/crates/bitwarden/src/auth/mod.rs index 28606d132..f2f6a3144 100644 --- a/crates/bitwarden/src/auth/mod.rs +++ b/crates/bitwarden/src/auth/mod.rs @@ -5,3 +5,8 @@ pub mod login; #[cfg(feature = "internal")] pub mod password; pub mod renew; + +#[cfg(feature = "internal")] +mod register; +#[cfg(feature = "internal")] +pub use register::{RegisterKeyResponse, RegisterRequest}; diff --git a/crates/bitwarden/src/auth/register.rs b/crates/bitwarden/src/auth/register.rs new file mode 100644 index 000000000..1815b5457 --- /dev/null +++ b/crates/bitwarden/src/auth/register.rs @@ -0,0 +1,85 @@ +use bitwarden_api_identity::{ + apis::accounts_api::accounts_register_post, + models::{KeysRequestModel, RegisterRequestModel}, +}; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; + +use crate::{ + client::auth_settings::Kdf, + crypto::{HashPurpose, MasterKey, RsaKeyPair}, + error::Result, + util::default_pbkdf2_iterations, + Client, +}; + +#[derive(Serialize, Deserialize, Debug, JsonSchema)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct RegisterRequest { + pub email: String, + pub name: Option, + pub password: String, + pub password_hint: Option, +} + +/// Half baked implementation of user registration +pub(super) async fn register(client: &mut Client, req: &RegisterRequest) -> Result<()> { + let config = client.get_api_configurations().await; + + let kdf = Kdf::PBKDF2 { + iterations: default_pbkdf2_iterations(), + }; + + let keys = make_register_keys(req.email.to_owned(), req.password.to_owned(), kdf)?; + + accounts_register_post( + &config.identity, + Some(RegisterRequestModel { + name: req.name.to_owned(), + email: req.email.to_owned(), + master_password_hash: keys.master_password_hash, + master_password_hint: req.password_hint.to_owned(), + captcha_response: None, // TODO: Add + key: Some(keys.encrypted_user_key.to_string()), + keys: Some(Box::new(KeysRequestModel { + public_key: Some(keys.keys.public), + encrypted_private_key: keys.keys.private.to_string(), + })), + token: None, + organization_user_id: None, + kdf: Some(bitwarden_api_identity::models::KdfType::Variant0), + kdf_iterations: Some(default_pbkdf2_iterations().get() as i32), + kdf_memory: None, + kdf_parallelism: None, + reference_data: None, // TODO: Add + }), + ) + .await?; + + Ok(()) +} + +pub(super) fn make_register_keys( + email: String, + password: String, + kdf: Kdf, +) -> Result { + let master_key = MasterKey::derive(password.as_bytes(), email.as_bytes(), &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()?; + let keys = user_key.make_key_pair()?; + + Ok(RegisterKeyResponse { + master_password_hash, + encrypted_user_key: encrypted_user_key.to_string(), + keys, + }) +} + +#[cfg_attr(feature = "mobile", derive(uniffi::Record))] +pub struct RegisterKeyResponse { + master_password_hash: String, + encrypted_user_key: String, + keys: RsaKeyPair, +} diff --git a/crates/bitwarden/src/client/encryption_settings.rs b/crates/bitwarden/src/client/encryption_settings.rs index 495884c3a..56f4b2628 100644 --- a/crates/bitwarden/src/client/encryption_settings.rs +++ b/crates/bitwarden/src/client/encryption_settings.rs @@ -9,7 +9,7 @@ use { }; use crate::{ - crypto::{encrypt_aes256, EncString, SymmetricCryptoKey}, + crypto::{encrypt_aes256_hmac, EncString, SymmetricCryptoKey}, error::{CryptoError, Result}, }; @@ -119,7 +119,7 @@ impl EncryptionSettings { pub(crate) fn encrypt(&self, data: &[u8], org_id: &Option) -> Result { let key = self.get_key(org_id).ok_or(CryptoError::NoKeyForOrg)?; - let dec = encrypt_aes256(data, key.mac_key, key.key)?; + let dec = encrypt_aes256_hmac(data, key.mac_key.ok_or(CryptoError::InvalidMac)?, key.key)?; Ok(dec) } } diff --git a/crates/bitwarden/src/crypto/aes_ops.rs b/crates/bitwarden/src/crypto/aes_ops.rs index eb5b82a60..34d4021e8 100644 --- a/crates/bitwarden/src/crypto/aes_ops.rs +++ b/crates/bitwarden/src/crypto/aes_ops.rs @@ -39,24 +39,30 @@ pub fn decrypt_aes256_hmac( decrypt_aes256(iv, data, key) } -pub fn encrypt_aes256( +pub fn encrypt_aes256(data_dec: &[u8], key: GenericArray) -> Result { + let (iv, data) = encrypt_aes256_internal(data_dec, key); + + Ok(EncString::AesCbc256_B64 { iv, data }) +} + +pub fn encrypt_aes256_hmac( data_dec: &[u8], - mac_key: Option>, + mac_key: GenericArray, key: GenericArray, ) -> Result { - let mac_key = match mac_key { - Some(k) => k, - None => return Err(CryptoError::InvalidMac.into()), - }; + let (iv, data) = encrypt_aes256_internal(data_dec, key); + let mac = validate_mac(&mac_key, &iv, &data)?; + Ok(EncString::AesCbc256_HmacSha256_B64 { iv, mac, data }) +} + +fn encrypt_aes256_internal(data_dec: &[u8], key: GenericArray) -> ([u8; 16], Vec) { let mut iv = [0u8; 16]; rand::thread_rng().fill_bytes(&mut iv); let data = cbc::Encryptor::::new(&key, &iv.into()) .encrypt_padded_vec_mut::(data_dec); - let mac = validate_mac(&mac_key, &iv, &data)?; - - Ok(EncString::AesCbc256_HmacSha256_B64 { iv, mac, data }) + (iv, data) } fn validate_mac(mac_key: &[u8], iv: &[u8], data: &[u8]) -> Result<[u8; 32]> { diff --git a/crates/bitwarden/src/crypto/master_key.rs b/crates/bitwarden/src/crypto/master_key.rs index dee95d662..dd4dd5019 100644 --- a/crates/bitwarden/src/crypto/master_key.rs +++ b/crates/bitwarden/src/crypto/master_key.rs @@ -1,10 +1,12 @@ use aes::cipher::typenum::U32; use base64::Engine; +use rand::Rng; use crate::util::BASE64_ENGINE; use super::{ - hkdf_expand, EncString, PbkdfSha256Hmac, SymmetricCryptoKey, PBKDF_SHA256_HMAC_OUT_SIZE, + encrypt_aes256, hkdf_expand, EncString, PbkdfSha256Hmac, SymmetricCryptoKey, UserKey, + PBKDF_SHA256_HMAC_OUT_SIZE, }; use { crate::{client::auth_settings::Kdf, error::Result}, @@ -43,6 +45,16 @@ impl MasterKey { Ok(BASE64_ENGINE.encode(hash)) } + pub(crate) fn make_user_key(&self) -> Result<(UserKey, EncString)> { + let mut user_key = [0u8; 64]; + rand::thread_rng().fill(&mut user_key); + + let protected = encrypt_aes256(&user_key, self.0.key)?; + + let u: &[u8] = &user_key; + Ok((UserKey::new(SymmetricCryptoKey::try_from(u)?), protected)) + } + pub(crate) fn decrypt_user_key(&self, user_key: EncString) -> Result { let stretched_key = stretch_master_key(self)?; diff --git a/crates/bitwarden/src/crypto/mod.rs b/crates/bitwarden/src/crypto/mod.rs index 93d4eb1a1..b35157981 100644 --- a/crates/bitwarden/src/crypto/mod.rs +++ b/crates/bitwarden/src/crypto/mod.rs @@ -7,6 +7,7 @@ //! ## Conventions: //! //! - Pure Functions that deterministically "derive" keys from input are prefixed with `derive_`. +//! - Functions that generate new keys are prefixed with `make_`. //! //! ## Differences from [`clients`](https://github.com/bitwarden/clients) //! @@ -30,7 +31,7 @@ pub use enc_string::EncString; mod encryptable; pub use encryptable::{Decryptable, Encryptable}; mod aes_ops; -pub use aes_ops::{decrypt_aes256, decrypt_aes256_hmac, encrypt_aes256}; +pub use aes_ops::{decrypt_aes256, decrypt_aes256_hmac, encrypt_aes256, encrypt_aes256_hmac}; mod symmetric_crypto_key; pub use symmetric_crypto_key::SymmetricCryptoKey; mod shareable_key; @@ -40,6 +41,14 @@ pub(crate) use shareable_key::derive_shareable_key; mod master_key; #[cfg(feature = "internal")] pub(crate) use master_key::{HashPurpose, MasterKey}; +#[cfg(feature = "internal")] +mod user_key; +#[cfg(feature = "internal")] +pub(crate) use user_key::UserKey; +#[cfg(feature = "internal")] +mod rsa; +#[cfg(feature = "internal")] +pub use self::rsa::RsaKeyPair; #[cfg(feature = "internal")] mod fingerprint; diff --git a/crates/bitwarden/src/crypto/rsa.rs b/crates/bitwarden/src/crypto/rsa.rs new file mode 100644 index 000000000..0d2d135b9 --- /dev/null +++ b/crates/bitwarden/src/crypto/rsa.rs @@ -0,0 +1,42 @@ +use base64::Engine; +use rsa::{ + pkcs8::{EncodePrivateKey, EncodePublicKey}, + RsaPrivateKey, RsaPublicKey, +}; + +use crate::{ + crypto::{encrypt_aes256_hmac, EncString, SymmetricCryptoKey}, + error::{Error, Result}, + util::BASE64_ENGINE, +}; + +#[cfg_attr(feature = "mobile", derive(uniffi::Record))] +pub struct RsaKeyPair { + /// Base64 encoded DER representation of the public key + pub public: String, + /// Encrypted PKCS8 private key + pub private: EncString, +} + +pub(super) fn make_key_pair(key: &SymmetricCryptoKey) -> Result { + let mut rng = rand::thread_rng(); + let bits = 2048; + let priv_key = RsaPrivateKey::new(&mut rng, bits).expect("failed to generate a key"); + let pub_key = RsaPublicKey::from(&priv_key); + + let spki = pub_key + .to_public_key_der() + .map_err(|_| Error::Internal("unable to create public key"))?; + + let b64 = BASE64_ENGINE.encode(spki.as_bytes()); + let pkcs = priv_key + .to_pkcs8_der() + .map_err(|_| Error::Internal("unable to create private key"))?; + + let protected = encrypt_aes256_hmac(pkcs.as_bytes(), key.mac_key.unwrap(), key.key)?; + + Ok(RsaKeyPair { + public: b64, + private: protected, + }) +} diff --git a/crates/bitwarden/src/crypto/user_key.rs b/crates/bitwarden/src/crypto/user_key.rs new file mode 100644 index 000000000..0fe560665 --- /dev/null +++ b/crates/bitwarden/src/crypto/user_key.rs @@ -0,0 +1,19 @@ +use crate::{ + crypto::{ + rsa::{make_key_pair, RsaKeyPair}, + SymmetricCryptoKey, + }, + error::Result, +}; + +pub(crate) struct UserKey(SymmetricCryptoKey); + +impl UserKey { + pub(crate) fn new(key: SymmetricCryptoKey) -> Self { + Self(key) + } + + pub(crate) fn make_key_pair(&self) -> Result { + make_key_pair(&self.0) + } +} diff --git a/crates/bitwarden/src/mobile/vault/client_sends.rs b/crates/bitwarden/src/mobile/vault/client_sends.rs index 91efc3603..0adef3410 100644 --- a/crates/bitwarden/src/mobile/vault/client_sends.rs +++ b/crates/bitwarden/src/mobile/vault/client_sends.rs @@ -1,5 +1,6 @@ use std::path::Path; +use super::client_vault::ClientVault; use crate::{ crypto::{Decryptable, EncString, Encryptable}, error::Result, @@ -7,8 +8,6 @@ use crate::{ Client, }; -use super::client_vault::ClientVault; - pub struct ClientSends<'a> { pub(crate) client: &'a Client, } diff --git a/crates/bw/src/auth/login.rs b/crates/bw/src/auth/login.rs index d056f33a5..6ba3c7929 100644 --- a/crates/bw/src/auth/login.rs +++ b/crates/bw/src/auth/login.rs @@ -5,6 +5,7 @@ use bitwarden::{ }, Client, }; +use bitwarden_cli::text_prompt_when_none; use color_eyre::eyre::{bail, Result}; use inquire::{Password, Text}; use log::{debug, error, info}; @@ -97,14 +98,3 @@ pub(crate) async fn api_key_login( Ok(()) } - -/// Prompt the user for input if the value is None -/// -/// Typically used when the user can provide a value via CLI or prompt -fn text_prompt_when_none(prompt: &str, val: Option) -> Result { - Ok(if let Some(val) = val { - val - } else { - Text::new(prompt).prompt()? - }) -} diff --git a/crates/bw/src/main.rs b/crates/bw/src/main.rs index e5e7ccdb6..73e64a4aa 100644 --- a/crates/bw/src/main.rs +++ b/crates/bw/src/main.rs @@ -1,7 +1,10 @@ -use bitwarden::{client::client_settings::ClientSettings, tool::PasswordGeneratorRequest}; -use bitwarden_cli::{install_color_eyre, Color}; +use bitwarden::{ + auth::RegisterRequest, client::client_settings::ClientSettings, tool::PasswordGeneratorRequest, +}; +use bitwarden_cli::{install_color_eyre, text_prompt_when_none, Color}; use clap::{command, Args, CommandFactory, Parser, Subcommand}; use color_eyre::eyre::Result; +use inquire::Password; use render::Output; mod auth; @@ -25,6 +28,19 @@ struct Cli { enum Commands { Login(LoginArgs), + #[command(long_about = "Register")] + Register { + #[arg(short = 'e', long, help = "Email address")] + email: Option, + + name: Option, + + password_hint: Option, + + #[arg(short = 's', long, global = true, help = "Server URL")] + server: Option, + }, + #[command(long_about = "Manage vault items")] Item { #[command(subcommand)] @@ -115,25 +131,54 @@ async fn process_commands() -> Result<()> { return Ok(()); }; - if let Commands::Login(args) = command.clone() { - let settings = args.server.map(|server| ClientSettings { - api_url: format!("{}/api", server), - identity_url: format!("{}/identity", server), - ..Default::default() - }); - let client = bitwarden::Client::new(settings); - - match args.command { - // FIXME: Rust CLI will not support password login! - LoginCommands::Password { email } => { - auth::password_login(client, email).await?; + match command.clone() { + Commands::Login(args) => { + let settings = args.server.map(|server| ClientSettings { + api_url: format!("{}/api", server), + identity_url: format!("{}/identity", server), + ..Default::default() + }); + let client = bitwarden::Client::new(settings); + + match args.command { + // FIXME: Rust CLI will not support password login! + LoginCommands::Password { email } => { + auth::password_login(client, email).await?; + } + LoginCommands::ApiKey { + client_id, + client_secret, + } => auth::api_key_login(client, client_id, client_secret).await?, } - LoginCommands::ApiKey { - client_id, - client_secret, - } => auth::api_key_login(client, client_id, client_secret).await?, + return Ok(()); } - return Ok(()); + Commands::Register { + email, + name, + password_hint, + server, + } => { + let settings = server.map(|server| ClientSettings { + api_url: format!("{}/api", server), + identity_url: format!("{}/identity", server), + ..Default::default() + }); + let mut client = bitwarden::Client::new(settings); + + let email = text_prompt_when_none("Email", email)?; + let password = Password::new("Password").prompt()?; + + client + .auth() + .register(&RegisterRequest { + email, + name, + password, + password_hint, + }) + .await?; + } + _ => {} } // Not login, assuming we have a config @@ -142,6 +187,7 @@ async fn process_commands() -> Result<()> { // And finally we process all the commands which require authentication match command { Commands::Login(_) => unreachable!(), + Commands::Register { .. } => unreachable!(), Commands::Item { command: _ } => todo!(), Commands::Sync {} => todo!(), Commands::Generate { command } => match command { diff --git a/languages/kotlin/doc.md b/languages/kotlin/doc.md index 55e5124e2..824f0da27 100644 --- a/languages/kotlin/doc.md +++ b/languages/kotlin/doc.md @@ -108,6 +108,19 @@ Hash the user password **Output**: std::result::Result +### `make_register_keys` + +Generate keys needed for registration process + +**Arguments**: + +- self: +- email: String +- password: String +- kdf: [Kdf](#kdf) + +**Output**: std::result::Result + ## ClientCiphers ### `encrypt` @@ -300,7 +313,7 @@ Encrypt send **Arguments**: - self: -- send: SendView +- send: [SendView](#sendview) **Output**: std::result::Result @@ -311,7 +324,7 @@ Encrypt a send file in memory **Arguments**: - self: -- send: Send +- send: [Send](#send) - buffer: Vec<> **Output**: std::result::Result @@ -323,7 +336,7 @@ Encrypt a send file located in the file system **Arguments**: - self: -- send: Send +- send: [Send](#send) - decrypted_file_path: String - encrypted_file_path: String @@ -336,7 +349,7 @@ Decrypt send **Arguments**: - self: -- send: Send +- send: [Send](#send) **Output**: std::result::Result @@ -358,7 +371,7 @@ Decrypt a send file in memory **Arguments**: - self: -- send: Send +- send: [Send](#send) - buffer: Vec<> **Output**: std::result::Result @@ -370,7 +383,7 @@ Decrypt a send file located in the file system **Arguments**: - self: -- send: Send +- send: [Send](#send) - encrypted_file_path: String - decrypted_file_path: String @@ -1060,3 +1073,183 @@ implementations.
+ +## `Send` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyTypeDescription
idstring
accessIdstring
name
notes
key
passwordstring,null
type
file
text
maxAccessCountinteger,null
accessCountinteger
disabledboolean
hideEmailboolean
revisionDatestring
deletionDatestring
expirationDatestring,null
+ +## `SendView` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyTypeDescription
idstring
accessIdstring
namestring
notesstring,null
key
passwordstring,null
type
file
text
maxAccessCountinteger,null
accessCountinteger
disabledboolean
hideEmailboolean
revisionDatestring
deletionDatestring
expirationDatestring,null
From 19d7f2f46175263c1ad69a63a2bde4766ee411b8 Mon Sep 17 00:00:00 2001 From: Colton Hurst Date: Wed, 6 Sep 2023 12:40:41 -0400 Subject: [PATCH 11/12] SM-774: Write Help Text to 'stderr' When No Args Are Provided (#190) * SM-774: Write help text to stderr on no args * SM-774: Add styling to output change * SM-774: Update the changelog --- crates/bws/CHANGELOG.md | 1 + crates/bws/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/bws/CHANGELOG.md b/crates/bws/CHANGELOG.md index 65568c6c2..a0a16f745 100644 --- a/crates/bws/CHANGELOG.md +++ b/crates/bws/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Support for shell autocompletion with the `bws completions` command (#103) +- When running `bws` with no args, the help text is now printed to `stderr` instead of `stdout` to be consistent with `bws subcommand` behavior (#190) ## [0.3.0] - 2023-07-26 diff --git a/crates/bws/src/main.rs b/crates/bws/src/main.rs index ab0c9afb2..5e6da19d8 100644 --- a/crates/bws/src/main.rs +++ b/crates/bws/src/main.rs @@ -246,7 +246,7 @@ async fn process_commands() -> Result<()> { let Some(command) = cli.command else { let mut cmd = Cli::command(); - cmd.print_help()?; + eprintln!("{}", cmd.render_help().ansi()); return Ok(()); }; From 7196a66f2b10258e0f3d13c7b80941b8931775ef Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Fri, 8 Sep 2023 12:24:47 +0200 Subject: [PATCH 12/12] Change to system.text for c# (#221) --- crates/bitwarden/src/client/client_settings.rs | 2 +- languages/csharp/BitwardenSdk.cs | 2 +- languages/csharp/Program.cs | 2 +- languages/csharp/bitwardenSdk.csproj | 5 +++-- support/scripts/schemas.ts | 3 ++- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/bitwarden/src/client/client_settings.rs b/crates/bitwarden/src/client/client_settings.rs index a2aed76f1..74a8080a1 100644 --- a/crates/bitwarden/src/client/client_settings.rs +++ b/crates/bitwarden/src/client/client_settings.rs @@ -21,7 +21,7 @@ use serde::{Deserialize, Serialize}; /// /// Targets `localhost:8080` for debug builds. #[derive(Serialize, Deserialize, Debug, JsonSchema)] -#[serde(rename_all = "camelCase", deny_unknown_fields)] +#[serde(default, rename_all = "camelCase", deny_unknown_fields)] #[cfg_attr(feature = "mobile", derive(uniffi::Record))] pub struct ClientSettings { /// The identity url of the targeted Bitwarden instance. Defaults to `https://identity.bitwarden.com` diff --git a/languages/csharp/BitwardenSdk.cs b/languages/csharp/BitwardenSdk.cs index 286be75d5..388b7977f 100644 --- a/languages/csharp/BitwardenSdk.cs +++ b/languages/csharp/BitwardenSdk.cs @@ -1,6 +1,6 @@ using System.Runtime.InteropServices; -namespace Bit.Sdk +namespace Bitwarden.Sdk { internal class BitwardenSdk : IDisposable { diff --git a/languages/csharp/Program.cs b/languages/csharp/Program.cs index 359454e32..d2e047bfb 100644 --- a/languages/csharp/Program.cs +++ b/languages/csharp/Program.cs @@ -1,4 +1,4 @@ -using Bit.Sdk; +using Bitwarden.Sdk; var sdk = new BitwardenSdk(); sdk.PasswordLogin("test@bitwarden.com", "asdfasdf"); diff --git a/languages/csharp/bitwardenSdk.csproj b/languages/csharp/bitwardenSdk.csproj index 10e89212e..315bdca9f 100644 --- a/languages/csharp/bitwardenSdk.csproj +++ b/languages/csharp/bitwardenSdk.csproj @@ -5,13 +5,14 @@ net6.0 enable enable + Bitwarden.Sdk - + - + diff --git a/support/scripts/schemas.ts b/support/scripts/schemas.ts index f5d5bce4e..e08661017 100644 --- a/support/scripts/schemas.ts +++ b/support/scripts/schemas.ts @@ -56,7 +56,8 @@ async function main() { inputData, lang: "csharp", rendererOptions: { - namespace: "Bit.Sdk", + namespace: "Bitwarden.Sdk", + framework: "SystemTextJson", "csharp-version": "6", }, });