Skip to content

Commit

Permalink
Merge branch 'main' of github.com:bitwarden/sdk into ps/rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton committed Jan 22, 2024
2 parents 051e455 + 785e7c4 commit b732486
Show file tree
Hide file tree
Showing 25 changed files with 260 additions and 251 deletions.
20 changes: 7 additions & 13 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/bitwarden-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"
rust-version = "1.57"

[dependencies]
clap = { version = "4.4.16", features = ["derive"] }
clap = { version = "4.4.18", features = ["derive"] }
color-eyre = "0.6"
inquire = "0.6.2"
supports-color = "2.1.0"
8 changes: 8 additions & 0 deletions crates/bitwarden-generators/uniffi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[bindings.kotlin]
package_name = "com.bitwarden.generators"
generate_immutable_records = true

[bindings.swift]
ffi_module_name = "BitwardenGeneratorsFFI"
module_name = "BitwardenGenerators"
generate_immutable_records = true
6 changes: 3 additions & 3 deletions crates/bitwarden-napi/package-lock.json

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

4 changes: 2 additions & 2 deletions crates/bitwarden-napi/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"declaration": true
"declaration": true,
},
"include": ["src-ts", "src-ts/bitwarden_client", "src-ts/index.ts"]
"include": ["src-ts", "src-ts/bitwarden_client", "src-ts/index.ts"],
}
3 changes: 3 additions & 0 deletions crates/bitwarden-uniffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ bitwarden = { path = "../bitwarden", features = ["mobile", "internal"] }
bitwarden-crypto = { path = "../bitwarden-crypto", version = "=0.1.0", features = [
"mobile",
] }
bitwarden-generators = { path = "../bitwarden-generators", version = "=0.1.0", features = [
"mobile",
] }

[build-dependencies]
uniffi = { version = "=0.25.2", features = ["build"] }
1 change: 0 additions & 1 deletion crates/bitwarden/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ chrono = { version = ">=0.4.26, <0.5", features = [
"serde",
"std",
], default-features = false }
data-encoding = ">=2.5.0, <3.0"
# We don't use this directly (it's used by rand), but we need it here to enable WASM support
getrandom = { version = ">=0.2.9, <0.3", features = ["js"] }
hmac = ">=0.12.1, <0.13"
Expand Down
7 changes: 4 additions & 3 deletions crates/bitwarden/src/tool/client_generator.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use bitwarden_generators::{
passphrase, password, username, PassphraseGeneratorRequest, PasswordGeneratorRequest,
UsernameGeneratorRequest,
use bitwarden_generators::{passphrase, password, username};

use crate::generators::{
PassphraseGeneratorRequest, PasswordGeneratorRequest, UsernameGeneratorRequest,
};

use crate::{error::Result, Client};
Expand Down
12 changes: 6 additions & 6 deletions crates/bitwarden/src/vault/cipher/card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ impl KeyEncryptable<SymmetricCryptoKey, Card> for CardView {
impl KeyDecryptable<SymmetricCryptoKey, CardView> for Card {
fn decrypt_with_key(&self, key: &SymmetricCryptoKey) -> Result<CardView, CryptoError> {
Ok(CardView {
cardholder_name: self.cardholder_name.decrypt_with_key(key)?,
exp_month: self.exp_month.decrypt_with_key(key)?,
exp_year: self.exp_year.decrypt_with_key(key)?,
code: self.code.decrypt_with_key(key)?,
brand: self.brand.decrypt_with_key(key)?,
number: self.number.decrypt_with_key(key)?,
cardholder_name: self.cardholder_name.decrypt_with_key(key).ok().flatten(),
exp_month: self.exp_month.decrypt_with_key(key).ok().flatten(),
exp_year: self.exp_year.decrypt_with_key(key).ok().flatten(),
code: self.code.decrypt_with_key(key).ok().flatten(),
brand: self.brand.decrypt_with_key(key).ok().flatten(),
number: self.number.decrypt_with_key(key).ok().flatten(),
})
}
}
Expand Down
24 changes: 12 additions & 12 deletions crates/bitwarden/src/vault/cipher/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,22 +183,22 @@ impl KeyDecryptable<SymmetricCryptoKey, CipherView> for Cipher {
folder_id: self.folder_id,
collection_ids: self.collection_ids.clone(),
key: self.key.clone(),
name: self.name.decrypt_with_key(key)?,
notes: self.notes.decrypt_with_key(key)?,
name: self.name.decrypt_with_key(key).ok().unwrap_or_default(),
notes: self.notes.decrypt_with_key(key).ok().flatten(),
r#type: self.r#type,
login: self.login.decrypt_with_key(key)?,
identity: self.identity.decrypt_with_key(key)?,
card: self.card.decrypt_with_key(key)?,
secure_note: self.secure_note.decrypt_with_key(key)?,
login: self.login.decrypt_with_key(key).ok().flatten(),
identity: self.identity.decrypt_with_key(key).ok().flatten(),
card: self.card.decrypt_with_key(key).ok().flatten(),
secure_note: self.secure_note.decrypt_with_key(key).ok().flatten(),
favorite: self.favorite,
reprompt: self.reprompt,
organization_use_totp: self.organization_use_totp,
edit: self.edit,
view_password: self.view_password,
local_data: self.local_data.decrypt_with_key(key)?,
attachments: self.attachments.decrypt_with_key(key)?,
fields: self.fields.decrypt_with_key(key)?,
password_history: self.password_history.decrypt_with_key(key)?,
local_data: self.local_data.decrypt_with_key(key).ok().flatten(),
attachments: self.attachments.decrypt_with_key(key).ok().flatten(),
fields: self.fields.decrypt_with_key(key).ok().flatten(),
password_history: self.password_history.decrypt_with_key(key).ok().flatten(),
creation_date: self.creation_date,
deleted_date: self.deleted_date,
revision_date: self.revision_date,
Expand Down Expand Up @@ -299,8 +299,8 @@ impl KeyDecryptable<SymmetricCryptoKey, CipherListView> for Cipher {
organization_id: self.organization_id,
folder_id: self.folder_id,
collection_ids: self.collection_ids.clone(),
name: self.name.decrypt_with_key(key)?,
sub_title: self.get_decrypted_subtitle(key)?,
name: self.name.decrypt_with_key(key).ok().unwrap_or_default(),
sub_title: self.get_decrypted_subtitle(key).ok().unwrap_or_default(),
r#type: self.r#type,
favorite: self.favorite,
reprompt: self.reprompt,
Expand Down
4 changes: 2 additions & 2 deletions crates/bitwarden/src/vault/cipher/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ impl KeyEncryptable<SymmetricCryptoKey, Field> for FieldView {
impl KeyDecryptable<SymmetricCryptoKey, FieldView> for Field {
fn decrypt_with_key(&self, key: &SymmetricCryptoKey) -> Result<FieldView, CryptoError> {
Ok(FieldView {
name: self.name.decrypt_with_key(key)?,
value: self.value.decrypt_with_key(key)?,
name: self.name.decrypt_with_key(key).ok().flatten(),
value: self.value.decrypt_with_key(key).ok().flatten(),
r#type: self.r#type,
linked_id: self.linked_id,
})
Expand Down
36 changes: 18 additions & 18 deletions crates/bitwarden/src/vault/cipher/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,24 @@ impl KeyEncryptable<SymmetricCryptoKey, Identity> for IdentityView {
impl KeyDecryptable<SymmetricCryptoKey, IdentityView> for Identity {
fn decrypt_with_key(&self, key: &SymmetricCryptoKey) -> Result<IdentityView, CryptoError> {
Ok(IdentityView {
title: self.title.decrypt_with_key(key)?,
first_name: self.first_name.decrypt_with_key(key)?,
middle_name: self.middle_name.decrypt_with_key(key)?,
last_name: self.last_name.decrypt_with_key(key)?,
address1: self.address1.decrypt_with_key(key)?,
address2: self.address2.decrypt_with_key(key)?,
address3: self.address3.decrypt_with_key(key)?,
city: self.city.decrypt_with_key(key)?,
state: self.state.decrypt_with_key(key)?,
postal_code: self.postal_code.decrypt_with_key(key)?,
country: self.country.decrypt_with_key(key)?,
company: self.company.decrypt_with_key(key)?,
email: self.email.decrypt_with_key(key)?,
phone: self.phone.decrypt_with_key(key)?,
ssn: self.ssn.decrypt_with_key(key)?,
username: self.username.decrypt_with_key(key)?,
passport_number: self.passport_number.decrypt_with_key(key)?,
license_number: self.license_number.decrypt_with_key(key)?,
title: self.title.decrypt_with_key(key).ok().flatten(),
first_name: self.first_name.decrypt_with_key(key).ok().flatten(),
middle_name: self.middle_name.decrypt_with_key(key).ok().flatten(),
last_name: self.last_name.decrypt_with_key(key).ok().flatten(),
address1: self.address1.decrypt_with_key(key).ok().flatten(),
address2: self.address2.decrypt_with_key(key).ok().flatten(),
address3: self.address3.decrypt_with_key(key).ok().flatten(),
city: self.city.decrypt_with_key(key).ok().flatten(),
state: self.state.decrypt_with_key(key).ok().flatten(),
postal_code: self.postal_code.decrypt_with_key(key).ok().flatten(),
country: self.country.decrypt_with_key(key).ok().flatten(),
company: self.company.decrypt_with_key(key).ok().flatten(),
email: self.email.decrypt_with_key(key).ok().flatten(),
phone: self.phone.decrypt_with_key(key).ok().flatten(),
ssn: self.ssn.decrypt_with_key(key).ok().flatten(),
username: self.username.decrypt_with_key(key).ok().flatten(),
passport_number: self.passport_number.decrypt_with_key(key).ok().flatten(),
license_number: self.license_number.decrypt_with_key(key).ok().flatten(),
})
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/bitwarden/src/vault/cipher/login.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ impl KeyDecryptable<SymmetricCryptoKey, LoginUriView> for LoginUri {
impl KeyDecryptable<SymmetricCryptoKey, LoginView> for Login {
fn decrypt_with_key(&self, key: &SymmetricCryptoKey) -> Result<LoginView, CryptoError> {
Ok(LoginView {
username: self.username.decrypt_with_key(key)?,
password: self.password.decrypt_with_key(key)?,
username: self.username.decrypt_with_key(key).ok().flatten(),
password: self.password.decrypt_with_key(key).ok().flatten(),
password_revision_date: self.password_revision_date,
uris: self.uris.decrypt_with_key(key)?,
totp: self.totp.decrypt_with_key(key)?,
uris: self.uris.decrypt_with_key(key).ok().flatten(),
totp: self.totp.decrypt_with_key(key).ok().flatten(),
autofill_on_page_load: self.autofill_on_page_load,
})
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden/src/vault/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl KeyDecryptable<SymmetricCryptoKey, CollectionView> for Collection {
id: self.id,
organization_id: self.organization_id,

name: self.name.decrypt_with_key(key)?,
name: self.name.decrypt_with_key(key).ok().unwrap_or_default(),

external_id: self.external_id.clone(),
hide_passwords: self.hide_passwords,
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden/src/vault/folder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl KeyDecryptable<SymmetricCryptoKey, FolderView> for Folder {
fn decrypt_with_key(&self, key: &SymmetricCryptoKey) -> Result<FolderView, CryptoError> {
Ok(FolderView {
id: self.id,
name: self.name.decrypt_with_key(key)?,
name: self.name.decrypt_with_key(key).ok().unwrap_or_default(),
revision_date: self.revision_date,
})
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden/src/vault/password_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl KeyDecryptable<SymmetricCryptoKey, PasswordHistoryView> for PasswordHistory
key: &SymmetricCryptoKey,
) -> Result<PasswordHistoryView, CryptoError> {
Ok(PasswordHistoryView {
password: self.password.decrypt_with_key(key)?,
password: self.password.decrypt_with_key(key).ok().unwrap_or_default(),
last_used_date: self.last_used_date,
})
}
Expand Down
8 changes: 4 additions & 4 deletions crates/bitwarden/src/vault/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,15 @@ impl KeyDecryptable<SymmetricCryptoKey, SendView> for Send {
id: self.id,
access_id: self.access_id.clone(),

name: self.name.decrypt_with_key(&key)?,
notes: self.notes.decrypt_with_key(&key)?,
name: self.name.decrypt_with_key(&key).ok().unwrap_or_default(),
notes: self.notes.decrypt_with_key(&key).ok().flatten(),
key: Some(URL_SAFE_NO_PAD.encode(k)),
new_password: None,
has_password: self.password.is_some(),

r#type: self.r#type,
file: self.file.decrypt_with_key(&key)?,
text: self.text.decrypt_with_key(&key)?,
file: self.file.decrypt_with_key(&key).ok().flatten(),
text: self.text.decrypt_with_key(&key).ok().flatten(),

max_access_count: self.max_access_count,
access_count: self.access_count,
Expand Down
Loading

0 comments on commit b732486

Please sign in to comment.