Skip to content

Commit

Permalink
Resolve more merge issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton committed Jun 17, 2024
1 parent 7a42a36 commit a2928e4
Show file tree
Hide file tree
Showing 30 changed files with 102 additions and 103 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

3 changes: 1 addition & 2 deletions crates/bitwarden-core/src/auth/auth_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ use bitwarden_crypto::{
#[cfg(feature = "internal")]
use bitwarden_crypto::{EncString, KeyDecryptable, SymmetricCryptoKey};

use crate::VaultLocked;
use crate::{error::Error, Client};
use crate::{error::Error, Client, VaultLocked};

#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
pub struct AuthRequestResponse {
Expand Down
3 changes: 2 additions & 1 deletion crates/bitwarden-core/src/client/encryption_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ impl EncryptionSettings {
&mut self,
org_enc_keys: Vec<(Uuid, AsymmetricEncString)>,
) -> Result<&Self> {
use crate::VaultLocked;
use bitwarden_crypto::KeyDecryptable;

use crate::VaultLocked;

let private_key = self.private_key.as_ref().ok_or(VaultLocked)?;

// Make sure we only keep the keys given in the arguments and not any of the previous
Expand Down
7 changes: 3 additions & 4 deletions crates/bitwarden-core/src/client/internal.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use bitwarden_crypto::Kdf;
use bitwarden_crypto::{AsymmetricEncString, EncString, MasterKey, SymmetricCryptoKey};
use std::sync::{Arc, RwLock};

use bitwarden_crypto::{AsymmetricEncString, EncString, Kdf, MasterKey, SymmetricCryptoKey};
use chrono::Utc;
use std::sync::Arc;
use std::sync::RwLock;
use uuid::Uuid;

use super::{
Expand Down
3 changes: 1 addition & 2 deletions crates/bitwarden-core/src/mobile/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ use serde::{Deserialize, Serialize};

#[cfg(feature = "internal")]
use crate::client::{LoginMethod, UserLoginMethod};
use crate::VaultLocked;
use crate::{
client::Kdf,
error::{Error, Result},
Client,
Client, VaultLocked,
};

#[cfg(feature = "internal")]
Expand Down
1 change: 0 additions & 1 deletion crates/bitwarden-core/src/mobile/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pub mod crypto;
pub mod kdf;
//pub mod vault;

mod client_crypto;
mod client_kdf;
Expand Down
4 changes: 2 additions & 2 deletions crates/bitwarden-exporters/src/client_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl<'a> ClientExporters<'a> {
Self { client }
}

pub async fn export_vault(
pub fn export_vault(
&self,
folders: Vec<Folder>,
ciphers: Vec<Cipher>,
Expand All @@ -24,7 +24,7 @@ impl<'a> ClientExporters<'a> {
export_vault(&self.client, folders, ciphers, format)
}

pub async fn export_organization_vault(
pub fn export_organization_vault(
&self,
collections: Vec<Collection>,
ciphers: Vec<Cipher>,
Expand Down
1 change: 0 additions & 1 deletion crates/bitwarden-exporters/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::fmt;

use bitwarden_core::require;
use bitwarden_vault::{CipherView, FieldView, FolderView, LoginUriView};

use chrono::{DateTime, Utc};
use uuid::Uuid;

Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-fido/src/authenticator.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::{Arc, Mutex};
use std::sync::Mutex;

use bitwarden_core::{Client, VaultLocked};
use bitwarden_crypto::{CryptoError, KeyContainer, KeyEncryptable};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
use std::sync::Arc;
use bitwarden_core::Client;

use bitwarden_fido::{
Fido2Authenticator, Fido2Client, Fido2CredentialStore, Fido2UserInterface,
FidoEncryptionSettingStore,
};

use crate::Client;
use crate::{Fido2Authenticator, Fido2Client, Fido2CredentialStore, Fido2UserInterface};

pub struct ClientFido2<'a> {
#[allow(dead_code)]
pub(crate) client: &'a Client,
}

impl FidoEncryptionSettingStore for Client {
fn get_encryption_settings(
&self,
) -> Result<Arc<dyn bitwarden_crypto::KeyContainer>, bitwarden_core::VaultLocked> {
Ok(self.get_encryption_settings()?)
impl<'a> ClientFido2<'a> {
pub fn new(client: &'a Client) -> Self {
Self { client }
}
}

impl<'a> ClientFido2<'a> {
pub fn create_authenticator(
&'a self,
user_interface: &'a dyn Fido2UserInterface,
Expand All @@ -39,3 +30,13 @@ impl<'a> ClientFido2<'a> {
}
}
}

pub trait ClientFido2Ext<'a> {
fn fido2(&'a self) -> ClientFido2<'a>;
}

impl<'a> ClientFido2Ext<'a> for Client {
fn fido2(&'a self) -> ClientFido2<'a> {
ClientFido2::new(self)
}
}
2 changes: 2 additions & 0 deletions crates/bitwarden-fido/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ uniffi::setup_scaffolding!();

mod authenticator;
mod client;
mod client_fido;
mod crypto;
mod traits;
mod types;
pub use authenticator::{
Fido2Authenticator, GetAssertionError, MakeCredentialError, SilentlyDiscoverCredentialsError,
};
pub use client::{Fido2Client, Fido2ClientError};
pub use client_fido::{ClientFido2, ClientFido2Ext};
pub use passkey::authenticator::UIHint;
use thiserror::Error;
pub use traits::{
Expand Down
4 changes: 1 addition & 3 deletions crates/bitwarden-json/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
use async_lock::Mutex;
#[cfg(feature = "secrets")]
use bitwarden::secrets_manager::{ClientProjectsExt, ClientSecretsExt};
use bitwarden::ClientSettings;

#[cfg(feature = "internal")]
use bitwarden::vault::ClientVaultExt;
use bitwarden::ClientSettings;

#[cfg(feature = "secrets")]
use crate::command::{ProjectsCommand, SecretsCommand};
Expand Down
2 changes: 0 additions & 2 deletions crates/bitwarden-send/src/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ impl TryFrom<SendTextModel> for SendText {
}
}

/*
#[cfg(test)]
mod tests {
use std::collections::HashMap;
Expand Down Expand Up @@ -600,4 +599,3 @@ mod tests {
assert!(v.has_password);
}
}
*/
18 changes: 9 additions & 9 deletions crates/bitwarden-sm/src/client_projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,44 @@ use crate::projects::{
};

pub struct ClientProjects<'a> {
pub client: &'a mut Client,
pub client: &'a Client,
}

impl<'a> ClientProjects<'a> {
pub fn new(client: &'a mut Client) -> Self {
pub fn new(client: &'a Client) -> Self {
Self { client }
}

pub async fn get(&mut self, input: &ProjectGetRequest) -> Result<ProjectResponse, Error> {
pub async fn get(&self, input: &ProjectGetRequest) -> Result<ProjectResponse, Error> {
get_project(self.client, input).await
}

pub async fn create(&mut self, input: &ProjectCreateRequest) -> Result<ProjectResponse, Error> {
pub async fn create(&self, input: &ProjectCreateRequest) -> Result<ProjectResponse, Error> {
create_project(self.client, input).await
}

pub async fn list(&mut self, input: &ProjectsListRequest) -> Result<ProjectsResponse, Error> {
pub async fn list(&self, input: &ProjectsListRequest) -> Result<ProjectsResponse, Error> {
list_projects(self.client, input).await
}

pub async fn update(&mut self, input: &ProjectPutRequest) -> Result<ProjectResponse, Error> {
pub async fn update(&self, input: &ProjectPutRequest) -> Result<ProjectResponse, Error> {
update_project(self.client, input).await
}

pub async fn delete(
&mut self,
&self,
input: ProjectsDeleteRequest,
) -> Result<ProjectsDeleteResponse, Error> {
delete_projects(self.client, input).await
}
}

pub trait ClientProjectsExt<'a> {
fn projects(&'a mut self) -> ClientProjects<'a>;
fn projects(&'a self) -> ClientProjects<'a>;
}

impl<'a> ClientProjectsExt<'a> for Client {
fn projects(&'a mut self) -> ClientProjects<'a> {
fn projects(&'a self) -> ClientProjects<'a> {
ClientProjects::new(self)
}
}
24 changes: 12 additions & 12 deletions crates/bitwarden-sm/src/client_secrets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,62 +9,62 @@ use crate::secrets::{
};

pub struct ClientSecrets<'a> {
client: &'a mut Client,
client: &'a Client,
}

impl<'a> ClientSecrets<'a> {
pub fn new(client: &'a mut Client) -> Self {
pub fn new(client: &'a Client) -> Self {
Self { client }
}

pub async fn get(&mut self, input: &SecretGetRequest) -> Result<SecretResponse, Error> {
pub async fn get(&self, input: &SecretGetRequest) -> Result<SecretResponse, Error> {
get_secret(self.client, input).await
}

pub async fn get_by_ids(&mut self, input: SecretsGetRequest) -> Result<SecretsResponse, Error> {
pub async fn get_by_ids(&self, input: SecretsGetRequest) -> Result<SecretsResponse, Error> {
get_secrets_by_ids(self.client, input).await
}

pub async fn create(&mut self, input: &SecretCreateRequest) -> Result<SecretResponse, Error> {
pub async fn create(&self, input: &SecretCreateRequest) -> Result<SecretResponse, Error> {
create_secret(self.client, input).await
}

pub async fn list(
&mut self,
&self,
input: &SecretIdentifiersRequest,
) -> Result<SecretIdentifiersResponse, Error> {
list_secrets(self.client, input).await
}

pub async fn list_by_project(
&mut self,
&self,
input: &SecretIdentifiersByProjectRequest,
) -> Result<SecretIdentifiersResponse, Error> {
list_secrets_by_project(self.client, input).await
}

pub async fn update(&mut self, input: &SecretPutRequest) -> Result<SecretResponse, Error> {
pub async fn update(&self, input: &SecretPutRequest) -> Result<SecretResponse, Error> {
update_secret(self.client, input).await
}

pub async fn delete(
&mut self,
&self,
input: SecretsDeleteRequest,
) -> Result<SecretsDeleteResponse, Error> {
delete_secrets(self.client, input).await
}

pub async fn sync(&mut self, input: &SecretsSyncRequest) -> Result<SecretsSyncResponse, Error> {
pub async fn sync(&self, input: &SecretsSyncRequest) -> Result<SecretsSyncResponse, Error> {
sync_secrets(self.client, input).await
}
}

pub trait ClientSecretsExt<'a> {
fn secrets(&'a mut self) -> ClientSecrets<'a>;
fn secrets(&'a self) -> ClientSecrets<'a>;
}

impl<'a> ClientSecretsExt<'a> for Client {
fn secrets(&'a mut self) -> ClientSecrets<'a> {
fn secrets(&'a self) -> ClientSecrets<'a> {
ClientSecrets::new(self)
}
}
6 changes: 6 additions & 0 deletions crates/bitwarden-uniffi/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ impl From<bitwarden::Error> for BitwardenError {
}
}

impl From<bitwarden::error::Error> for BitwardenError {
fn from(e: bitwarden::error::Error) -> Self {
Self::E2(e)
}
}

impl From<bitwarden::exporters::ExportError> for BitwardenError {
fn from(e: bitwarden::exporters::ExportError) -> Self {
Self::Ee(e)
Expand Down
2 changes: 1 addition & 1 deletion crates/bitwarden-uniffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use bitwarden::ClientSettings;
pub mod auth;
pub mod crypto;
mod error;
//pub mod platform;
pub mod platform;
pub mod tool;
mod uniffi_support;
pub mod vault;
Expand Down
Loading

0 comments on commit a2928e4

Please sign in to comment.