Skip to content

Commit

Permalink
Run cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Hinton committed Jan 16, 2024
1 parent 6476c92 commit d6e204a
Show file tree
Hide file tree
Showing 35 changed files with 148 additions and 109 deletions.
9 changes: 6 additions & 3 deletions crates/bitwarden-api-api/src/apis/access_policies_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,24 @@ pub enum AccessPoliciesIdPutError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organizations_id_access_policies_people_potential_grantees_get`]
/// struct for typed errors of method
/// [`organizations_id_access_policies_people_potential_grantees_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationsIdAccessPoliciesPeoplePotentialGranteesGetError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organizations_id_access_policies_projects_potential_grantees_get`]
/// struct for typed errors of method
/// [`organizations_id_access_policies_projects_potential_grantees_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationsIdAccessPoliciesProjectsPotentialGranteesGetError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organizations_id_access_policies_service_accounts_potential_grantees_get`]
/// struct for typed errors of method
/// [`organizations_id_access_policies_service_accounts_potential_grantees_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationsIdAccessPoliciesServiceAccountsPotentialGranteesGetError {
Expand Down
6 changes: 4 additions & 2 deletions crates/bitwarden-api-api/src/apis/collections_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ pub enum OrganizationsOrgIdCollectionsIdDeletePostError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organizations_org_id_collections_id_delete_user_org_user_id_post`]
/// struct for typed errors of method
/// [`organizations_org_id_collections_id_delete_user_org_user_id_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationsOrgIdCollectionsIdDeleteUserOrgUserIdPostError {
Expand Down Expand Up @@ -97,7 +98,8 @@ pub enum OrganizationsOrgIdCollectionsIdPutError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organizations_org_id_collections_id_user_org_user_id_delete`]
/// struct for typed errors of method
/// [`organizations_org_id_collections_id_user_org_user_id_delete`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationsOrgIdCollectionsIdUserOrgUserIdDeleteError {
Expand Down
3 changes: 2 additions & 1 deletion crates/bitwarden-api-api/src/apis/groups_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ pub enum OrganizationsOrgIdGroupsIdDeletePostError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organizations_org_id_groups_id_delete_user_org_user_id_post`]
/// struct for typed errors of method
/// [`organizations_org_id_groups_id_delete_user_org_user_id_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationsOrgIdGroupsIdDeleteUserOrgUserIdPostError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ pub enum OrganizationsConnectionsEnabledGetError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organizations_connections_organization_connection_id_delete`]
/// struct for typed errors of method
/// [`organizations_connections_organization_connection_id_delete`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationsConnectionsOrganizationConnectionIdDeleteError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organizations_connections_organization_connection_id_delete_post`]
/// struct for typed errors of method
/// [`organizations_connections_organization_connection_id_delete_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationsConnectionsOrganizationConnectionIdDeletePostError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,24 @@ pub enum OrganizationSponsorshipSponsoredSponsoredOrgIdDeleteError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organization_sponsorship_sponsored_sponsored_org_id_remove_post`]
/// struct for typed errors of method
/// [`organization_sponsorship_sponsored_sponsored_org_id_remove_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationSponsorshipSponsoredSponsoredOrgIdRemovePostError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organization_sponsorship_sponsoring_org_id_families_for_enterprise_post`]
/// struct for typed errors of method
/// [`organization_sponsorship_sponsoring_org_id_families_for_enterprise_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterprisePostError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organization_sponsorship_sponsoring_org_id_families_for_enterprise_resend_post`]
/// struct for typed errors of method
/// [`organization_sponsorship_sponsoring_org_id_families_for_enterprise_resend_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationSponsorshipSponsoringOrgIdFamiliesForEnterpriseResendPostError {
Expand All @@ -62,7 +65,8 @@ pub enum OrganizationSponsorshipSponsoringOrganizationIdDeleteError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organization_sponsorship_sponsoring_organization_id_delete_post`]
/// struct for typed errors of method
/// [`organization_sponsorship_sponsoring_organization_id_delete_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationSponsorshipSponsoringOrganizationIdDeletePostError {
Expand Down
9 changes: 6 additions & 3 deletions crates/bitwarden-api-api/src/apis/organization_users_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,16 @@ pub enum OrganizationsOrgIdUsersInvitePostError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organizations_org_id_users_organization_user_id_accept_init_post`]
/// struct for typed errors of method
/// [`organizations_org_id_users_organization_user_id_accept_init_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationsOrgIdUsersOrganizationUserIdAcceptInitPostError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organizations_org_id_users_organization_user_id_accept_post`]
/// struct for typed errors of method
/// [`organizations_org_id_users_organization_user_id_accept_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationsOrgIdUsersOrganizationUserIdAcceptPostError {
Expand Down Expand Up @@ -230,7 +232,8 @@ pub enum OrganizationsOrgIdUsersRevokePutError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organizations_org_id_users_user_id_reset_password_enrollment_put`]
/// struct for typed errors of method
/// [`organizations_org_id_users_user_id_reset_password_enrollment_put`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationsOrgIdUsersUserIdResetPasswordEnrollmentPutError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,24 @@ use reqwest;
use super::{configuration, Error};
use crate::apis::ResponseContent;

/// struct for typed errors of method [`organization_sponsorship_self_hosted_sponsoring_org_id_delete`]
/// struct for typed errors of method
/// [`organization_sponsorship_self_hosted_sponsoring_org_id_delete`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdDeleteError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organization_sponsorship_self_hosted_sponsoring_org_id_delete_post`]
/// struct for typed errors of method
/// [`organization_sponsorship_self_hosted_sponsoring_org_id_delete_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdDeletePostError {
UnknownValue(serde_json::Value),
}

/// struct for typed errors of method [`organization_sponsorship_self_hosted_sponsoring_org_id_families_for_enterprise_post`]
/// struct for typed errors of method
/// [`organization_sponsorship_self_hosted_sponsoring_org_id_families_for_enterprise_post`]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum OrganizationSponsorshipSelfHostedSponsoringOrgIdFamiliesForEnterprisePostError {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ pub struct SsoConfigurationData {
skip_serializing_if = "Option::is_none"
)]
pub member_decryption_type: Option<crate::models::MemberDecryptionType>,
/// Legacy property to determine if KeyConnector was enabled. Kept for backwards compatibility with old configs that will not have the new Bit.Core.Auth.Models.Data.SsoConfigurationData.MemberDecryptionType when deserialized from the database.
/// Legacy property to determine if KeyConnector was enabled. Kept for backwards compatibility
/// with old configs that will not have the new
/// Bit.Core.Auth.Models.Data.SsoConfigurationData.MemberDecryptionType when deserialized from
/// the database.
#[serde(
rename = "keyConnectorEnabled",
skip_serializing_if = "Option::is_none"
Expand Down
3 changes: 2 additions & 1 deletion crates/bitwarden-crypto/src/aes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ pub(crate) fn decrypt_aes256(
.decrypt_padded_mut::<Pkcs7>(&mut data)
.map_err(|_| CryptoError::KeyDecrypt)?;

// Data is decrypted in place and returns a subslice of the original Vec, to avoid cloning it, we truncate to the subslice length
// Data is decrypted in place and returns a subslice of the original Vec, to avoid cloning it,
// we truncate to the subslice length
let decrypted_len = decrypted_key_slice.len();
data.truncate(decrypted_len);

Expand Down
17 changes: 9 additions & 8 deletions crates/bitwarden-crypto/src/enc_string/asymmetric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ use crate::{

/// # Encrypted string primitive
///
/// [AsymmetricEncString] is a Bitwarden specific primitive that represents an asymmetrically encrypted string.
/// They are used together with the KeyDecryptable and KeyEncryptable traits to encrypt and decrypt data using
/// [AsymmetricCryptoKey]s.
/// [AsymmetricEncString] is a Bitwarden specific primitive that represents an asymmetrically
/// encrypted string. They are used together with the KeyDecryptable and KeyEncryptable traits to
/// encrypt and decrypt data using [AsymmetricCryptoKey]s.
///
/// The flexibility of the [AsymmetricEncString] type allows for different encryption algorithms to be used
/// which is represented by the different variants of the enum.
/// The flexibility of the [AsymmetricEncString] type allows for different encryption algorithms to
/// be used which is represented by the different variants of the enum.
///
/// ## Note
///
Expand All @@ -30,8 +30,8 @@ use crate::{
///
/// ## Serialization
///
/// [AsymmetricEncString] implements [Display] and [FromStr] to allow for easy serialization and uses a
/// custom scheme to represent the different variants.
/// [AsymmetricEncString] implements [Display] and [FromStr] to allow for easy serialization and
/// uses a custom scheme to represent the different variants.
///
/// The scheme is one of the following schemes:
/// - `[type].[data]`
Expand All @@ -54,7 +54,8 @@ pub enum AsymmetricEncString {
Rsa2048_OaepSha1_HmacSha256_B64 { data: Vec<u8>, mac: Vec<u8> },
}

/// To avoid printing sensitive information, [AsymmetricEncString] debug prints to `AsymmetricEncString`.
/// To avoid printing sensitive information, [AsymmetricEncString] debug prints to
/// `AsymmetricEncString`.
impl std::fmt::Debug for AsymmetricEncString {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("AsymmetricEncString").finish()
Expand Down
6 changes: 3 additions & 3 deletions crates/bitwarden-crypto/src/enc_string/symmetric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use crate::{

/// # Encrypted string primitive
///
/// [EncString] is a Bitwarden specific primitive that represents a symmetrically encrypted string. They are
/// are used together with the [KeyDecryptable] and [KeyEncryptable] traits to encrypt and decrypt
/// data using [SymmetricCryptoKey]s.
/// [EncString] is a Bitwarden specific primitive that represents a symmetrically encrypted string.
/// They are are used together with the [KeyDecryptable] and [KeyEncryptable] traits to encrypt and
/// decrypt data using [SymmetricCryptoKey]s.
///
/// The flexibility of the [EncString] type allows for different encryption algorithms to be used
/// which is represented by the different variants of the enum.
Expand Down
3 changes: 2 additions & 1 deletion crates/bitwarden-crypto/src/keys/shareable_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ pub fn derive_shareable_key(
) -> SymmetricCryptoKey {
// Because all inputs are fixed size, we can unwrap all errors here without issue

// TODO: Are these the final `key` and `info` parameters or should we change them? I followed the pattern used for sends
// TODO: Are these the final `key` and `info` parameters or should we change them? I followed
// the pattern used for sends
let res = Hmac::<sha2::Sha256>::new_from_slice(format!("bitwarden-{}", name).as_bytes())
.unwrap()
.chain_update(secret)
Expand Down
20 changes: 2 additions & 18 deletions crates/bitwarden-json/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub enum Command {
/// This command is not capable of handling authentication requiring 2fa or captcha.
///
/// Returns: [PasswordLoginResponse](bitwarden::auth::login::PasswordLoginResponse)
///
PasswordLogin(PasswordLoginRequest),

#[cfg(feature = "internal")]
Expand All @@ -42,7 +41,6 @@ pub enum Command {
/// This command is for initiating an authentication handshake with Bitwarden.
///
/// Returns: [ApiKeyLoginResponse](bitwarden::auth::login::ApiKeyLoginResponse)
///
ApiKeyLogin(ApiKeyLoginRequest),

#[cfg(feature = "secrets")]
Expand All @@ -51,30 +49,26 @@ pub enum Command {
/// This command is for initiating an authentication handshake with Bitwarden.
///
/// Returns: [ApiKeyLoginResponse](bitwarden::auth::login::ApiKeyLoginResponse)
///
AccessTokenLogin(AccessTokenLoginRequest),

#[cfg(feature = "internal")]
/// > Requires Authentication
/// Get the API key of the currently authenticated user
///
/// Returns: [UserApiKeyResponse](bitwarden::platform::UserApiKeyResponse)
///
GetUserApiKey(SecretVerificationRequest),

#[cfg(feature = "internal")]
/// Get the user's passphrase
///
/// Returns: String
///
Fingerprint(FingerprintRequest),

#[cfg(feature = "internal")]
/// > Requires Authentication
/// Retrieve all user data, ciphers and organizations the user is a part of
///
/// Returns: [SyncResponse](bitwarden::platform::SyncResponse)
///
Sync(SyncRequest),

#[cfg(feature = "secrets")]
Expand All @@ -92,47 +86,42 @@ pub enum SecretsCommand {
/// Retrieve a secret by the provided identifier
///
/// Returns: [SecretResponse](bitwarden::secrets_manager::secrets::SecretResponse)
///
Get(SecretGetRequest),

/// > Requires Authentication
/// > Requires using an Access Token for login or calling Sync at least once
/// Retrieve secrets by the provided identifiers
///
/// Returns: [SecretsResponse](bitwarden::secrets_manager::secrets::SecretsResponse)
///
GetByIds(SecretsGetRequest),

/// > Requires Authentication
/// > Requires using an Access Token for login or calling Sync at least once
/// Creates a new secret in the provided organization using the given data
///
/// Returns: [SecretResponse](bitwarden::secrets_manager::secrets::SecretResponse)
///
Create(SecretCreateRequest),

/// > Requires Authentication
/// > Requires using an Access Token for login or calling Sync at least once
/// Lists all secret identifiers of the given organization, to then retrieve each secret, use `CreateSecret`
/// Lists all secret identifiers of the given organization, to then retrieve each secret, use
/// `CreateSecret`
///
/// Returns: [SecretIdentifiersResponse](bitwarden::secrets_manager::secrets::SecretIdentifiersResponse)
///
List(SecretIdentifiersRequest),

/// > Requires Authentication
/// > Requires using an Access Token for login or calling Sync at least once
/// Updates an existing secret with the provided ID using the given data
///
/// Returns: [SecretResponse](bitwarden::secrets_manager::secrets::SecretResponse)
///
Update(SecretPutRequest),

/// > Requires Authentication
/// > Requires using an Access Token for login or calling Sync at least once
/// Deletes all the secrets whose IDs match the provided ones
///
/// Returns: [SecretsDeleteResponse](bitwarden::secrets_manager::secrets::SecretsDeleteResponse)
///
Delete(SecretsDeleteRequest),
}

Expand All @@ -145,38 +134,33 @@ pub enum ProjectsCommand {
/// Retrieve a project by the provided identifier
///
/// Returns: [ProjectResponse](bitwarden::secrets_manager::projects::ProjectResponse)
///
Get(ProjectGetRequest),

/// > Requires Authentication
/// > Requires using an Access Token for login or calling Sync at least once
/// Creates a new project in the provided organization using the given data
///
/// Returns: [ProjectResponse](bitwarden::secrets_manager::projects::ProjectResponse)
///
Create(ProjectCreateRequest),

/// > Requires Authentication
/// > Requires using an Access Token for login or calling Sync at least once
/// Lists all projects of the given organization
///
/// Returns: [ProjectsResponse](bitwarden::secrets_manager::projects::ProjectsResponse)
///
List(ProjectsListRequest),

/// > Requires Authentication
/// > Requires using an Access Token for login or calling Sync at least once
/// Updates an existing project with the provided ID using the given data
///
/// Returns: [ProjectResponse](bitwarden::secrets_manager::projects::ProjectResponse)
///
Update(ProjectPutRequest),

/// > Requires Authentication
/// > Requires using an Access Token for login or calling Sync at least once
/// Deletes all the projects whose IDs match the provided ones
///
/// Returns: [ProjectsDeleteResponse](bitwarden::secrets_manager::projects::ProjectsDeleteResponse)
///
Delete(ProjectsDeleteRequest),
}
Loading

0 comments on commit d6e204a

Please sign in to comment.