Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions crates/bitwarden-api-api/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,8 @@ src/models/selection_read_only_request_model.rs
src/models/selection_read_only_response_model.rs
src/models/self_hosted_organization_license_request_model.rs
src/models/send_access_response_model.rs
src/models/send_data_model.rs
src/models/send_encryption_type.rs
src/models/send_file_download_data_response_model.rs
src/models/send_file_model.rs
src/models/send_file_upload_data_response_model.rs
Expand Down
4 changes: 4 additions & 0 deletions crates/bitwarden-api-api/src/models/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,10 @@ pub mod self_hosted_organization_license_request_model;
pub use self::self_hosted_organization_license_request_model::SelfHostedOrganizationLicenseRequestModel;
pub mod send_access_response_model;
pub use self::send_access_response_model::SendAccessResponseModel;
pub mod send_data_model;
pub use self::send_data_model::SendDataModel;
pub mod send_encryption_type;
pub use self::send_encryption_type::SendEncryptionType;
pub mod send_file_download_data_response_model;
pub use self::send_file_download_data_response_model::SendFileDownloadDataResponseModel;
pub mod send_file_model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ pub struct SendAccessResponseModel {
skip_serializing_if = "Option::is_none"
)]
pub text: Option<Box<models::SendTextModel>>,
/// Encrypted string containing secret Send data
#[serde(
rename = "data",
alias = "Data",
skip_serializing_if = "Option::is_none"
)]
pub data: Option<String>,
pub data: Option<Box<models::SendDataModel>>,
/// The date after which a send cannot be accessed. When this value is null, there is no
/// expiration date.
#[serde(
Expand Down
38 changes: 38 additions & 0 deletions crates/bitwarden-api-api/src/models/send_data_model.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Bitwarden Internal API
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: latest
*
* Generated by: https://openapi-generator.tech
*/

use serde::{Deserialize, Serialize};

use crate::models;

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct SendDataModel {
#[serde(
rename = "encryptionVersion",
alias = "EncryptionVersion",
skip_serializing_if = "Option::is_none"
)]
pub encryption_version: Option<models::SendEncryptionType>,
#[serde(
rename = "data",
alias = "Data",
skip_serializing_if = "Option::is_none"
)]
pub data: Option<String>,
}

impl SendDataModel {
pub fn new() -> SendDataModel {
SendDataModel {
encryption_version: None,
data: None,
}
}
}
78 changes: 78 additions & 0 deletions crates/bitwarden-api-api/src/models/send_encryption_type.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Bitwarden Internal API
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: latest
*
* Generated by: https://openapi-generator.tech
*/

use serde::{Deserialize, Deserializer, Serialize, Serializer, de::Visitor};

use crate::models;
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum SendEncryptionType {
V1,

/// Unknown value returned from the server. This is used to handle forward compatibility.
__Unknown(i64),
}

impl SendEncryptionType {
pub fn as_i64(&self) -> i64 {
match self {
Self::V1 => 1,
Self::__Unknown(v) => *v,
}
}

pub fn from_i64(value: i64) -> Self {
match value {
1 => Self::V1,
v => Self::__Unknown(v),
}
}
}

impl serde::Serialize for SendEncryptionType {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_i64(self.as_i64())
}
}

impl<'de> serde::Deserialize<'de> for SendEncryptionType {
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
struct SendEncryptionTypeVisitor;

impl Visitor<'_> for SendEncryptionTypeVisitor {
type Value = SendEncryptionType;

fn expecting(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str("an integer")
}

fn visit_i64<E: serde::de::Error>(self, v: i64) -> Result<Self::Value, E> {
Ok(SendEncryptionType::from_i64(v))
}

fn visit_u64<E: serde::de::Error>(self, v: u64) -> Result<Self::Value, E> {
Ok(SendEncryptionType::from_i64(v as i64))
}
}

deserializer.deserialize_i64(SendEncryptionTypeVisitor)
}
}

impl std::fmt::Display for SendEncryptionType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.as_i64())
}
}
impl Default for SendEncryptionType {
fn default() -> SendEncryptionType {
Self::V1
}
}
3 changes: 1 addition & 2 deletions crates/bitwarden-api-api/src/models/send_request_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,12 @@ pub struct SendRequestModel {
skip_serializing_if = "Option::is_none"
)]
pub text: Option<Box<models::SendTextModel>>,
/// String containing secret Send data
#[serde(
rename = "data",
alias = "Data",
skip_serializing_if = "Option::is_none"
)]
pub data: Option<String>,
pub data: Option<Box<models::SendDataModel>>,
/// Base64-encoded byte array of a password hash that grants access to the send. Mutually
/// exclusive with Bit.Api.Tools.Models.Request.SendRequestModel.Emails.
#[serde(
Expand Down
3 changes: 1 addition & 2 deletions crates/bitwarden-api-api/src/models/send_response_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,12 @@ pub struct SendResponseModel {
skip_serializing_if = "Option::is_none"
)]
pub text: Option<Box<models::SendTextModel>>,
/// Encrypted string containing secret Send data
#[serde(
rename = "data",
alias = "Data",
skip_serializing_if = "Option::is_none"
)]
pub data: Option<String>,
pub data: Option<Box<models::SendDataModel>>,
/// A base64-encoded byte array containing the Send's encryption key. It's also provided to
/// send recipients in the Send's URL.
#[serde(rename = "key", alias = "Key", skip_serializing_if = "Option::is_none")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,12 @@ pub struct SendWithIdRequestModel {
skip_serializing_if = "Option::is_none"
)]
pub text: Option<Box<models::SendTextModel>>,
/// String containing secret Send data
#[serde(
rename = "data",
alias = "Data",
skip_serializing_if = "Option::is_none"
)]
pub data: Option<String>,
pub data: Option<Box<models::SendDataModel>>,
/// Base64-encoded byte array of a password hash that grants access to the send. Mutually
/// exclusive with Bit.Api.Tools.Models.Request.SendRequestModel.Emails.
#[serde(
Expand Down
3 changes: 1 addition & 2 deletions crates/bitwarden-api-identity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ client.
- API version: v1
- Package version: 3.0.0
- Server Git commit:
[`c2d97d5ff2019c524405c36f7f3afc992ec0ef03`](https://github.com/bitwarden/server/commit/c2d97d5ff2019c524405c36f7f3afc992ec0ef03)
[`4f8c0f010712cbd860c29b225bec84b2592a331c`](https://github.com/bitwarden/server/commit/4f8c0f010712cbd860c29b225bec84b2592a331c)
- Generator version: 7.15.0
- Build package: `org.openapitools.codegen.languages.RustClientCodegen`

Expand All @@ -39,7 +39,6 @@ All URIs are relative to *https://identity.bitwarden.com*
| _AccountsApi_ | [**post_register_verification_email_clicked**](docs/AccountsApi.md#accounts_post_register_verification_email_clicked) | **POST** /accounts/register/verification-email-clicked |
| _AccountsApi_ | [**post_trial_initiation_send_verification_email**](docs/AccountsApi.md#accounts_post_trial_initiation_send_verification_email) | **POST** /accounts/trial/send-verification-email |
| _InfoApi_ | [**get_alive**](docs/InfoApi.md#info_get_alive) | **GET** /alive |
| _InfoApi_ | [**get_version**](docs/InfoApi.md#info_get_version) | **GET** /version |
| _SsoApi_ | [**external_callback**](docs/SsoApi.md#sso_external_callback) | **GET** /sso/ExternalCallback |
| _SsoApi_ | [**external_challenge**](docs/SsoApi.md#sso_external_challenge) | **GET** /sso/ExternalChallenge |
| _SsoApi_ | [**login**](docs/SsoApi.md#sso_login) | **GET** /sso/Login |
Expand Down
3 changes: 2 additions & 1 deletion crates/bitwarden-send/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ bitwarden-encoding = { workspace = true }
bitwarden-error = { workspace = true }
bitwarden-state = { workspace = true }
bitwarden-uuid = { workspace = true }
bitwarden-vault = { workspace = true }
chrono = { workspace = true }
reqwest = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
serde_repr = { workspace = true }
sha2 = { workspace = true }
thiserror = { workspace = true }
Expand All @@ -50,7 +52,6 @@ zeroize = { workspace = true }
[dev-dependencies]
bitwarden-api-api = { workspace = true, features = ["mockall"] }
bitwarden-test = { workspace = true }
serde_json = { workspace = true }
tokio = { workspace = true, features = ["rt"] }
wiremock = { workspace = true }

Expand Down
1 change: 1 addition & 0 deletions crates/bitwarden-send/src/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ mod tests {
text: Some(text.to_owned()),
hidden: false,
}),
data: None,
max_access_count: None,
access_count: 0,
disabled: false,
Expand Down
6 changes: 3 additions & 3 deletions crates/bitwarden-send/src/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ impl
// Derive the shareable send key for encrypting content
let send_key = Send::derive_shareable_key(ctx, &k)?;

let (send_type, file, text) = self.view_type.clone().encrypt_composite(ctx, send_key)?;
let (send_type, file, text, data) =
self.view_type.clone().encrypt_composite(ctx, send_key)?;

let (password, emails) = self.auth.auth_data(&k);

Expand All @@ -109,8 +110,7 @@ impl
deletion_date: self.deletion_date.to_rfc3339(),
file,
text,
// TODO: Implement logic for item-based Sends
data: None,
data,
password,
emails,
disabled: self.disabled,
Expand Down
1 change: 1 addition & 0 deletions crates/bitwarden-send/src/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ mod tests {
text: Some("Secret text".to_string()),
hidden: false,
}),
data: None,
max_access_count: None,
access_count: 0,
disabled: false,
Expand Down
8 changes: 5 additions & 3 deletions crates/bitwarden-send/src/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl

let send_key = Send::derive_shareable_key(ctx, &k)?;

let (send_type, file, text) = self
let (send_type, file, text, data) = self
.request
.view_type
.clone()
Expand Down Expand Up @@ -167,8 +167,7 @@ impl
deletion_date: self.request.deletion_date.to_rfc3339(),
file,
text,
// TODO: Implement logic for item-based Sends
data: None,
data,
password,
emails,
disabled: self.request.disabled,
Expand Down Expand Up @@ -344,6 +343,7 @@ mod tests {
text: Some("original text".to_string()),
hidden: false,
}),
data: None,
max_access_count: None,
access_count: 0,
disabled: false,
Expand Down Expand Up @@ -511,6 +511,7 @@ mod tests {
text: Some("original text".to_string()),
hidden: false,
}),
data: None,
max_access_count: None,
access_count: 0,
disabled: false,
Expand Down Expand Up @@ -596,6 +597,7 @@ mod tests {
text: Some("secret".to_string()),
hidden: false,
}),
data: None,
max_access_count: None,
access_count: 0,
disabled: false,
Expand Down
7 changes: 7 additions & 0 deletions crates/bitwarden-send/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ pub enum SendParseError {
Crypto(#[from] bitwarden_crypto::CryptoError),
#[error(transparent)]
MissingField(#[from] bitwarden_core::MissingFieldError),
#[error(transparent)]
DeserializationFailure(#[from] SendItemDeserializationFailure),
}

/// Item does not exist error.
#[derive(Debug, thiserror::Error)]
#[error("Item does not exist")]
pub struct ItemNotFoundError;

/// Unable to deserialize Item-type Send data
#[derive(Debug, thiserror::Error)]
#[error("Send item deserialization failure")]
pub struct SendItemDeserializationFailure;
3 changes: 3 additions & 0 deletions crates/bitwarden-send/src/get_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ mod tests {
text: Some("Secret text".to_string()),
hidden: false,
}),
data: None,
max_access_count: None,
access_count: 0,
disabled: false,
Expand Down Expand Up @@ -177,6 +178,7 @@ mod tests {
text: Some("Text 1".to_string()),
hidden: false,
}),
data: None,
max_access_count: None,
access_count: 0,
disabled: false,
Expand Down Expand Up @@ -209,6 +211,7 @@ mod tests {
text: Some("Text 2".to_string()),
hidden: false,
}),
data: None,
max_access_count: None,
access_count: 0,
disabled: false,
Expand Down
1 change: 1 addition & 0 deletions crates/bitwarden-send/src/remove_password.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ mod tests {
text: Some("Secret text".to_string()),
hidden: false,
}),
data: None,
max_access_count: None,
access_count: 0,
disabled: false,
Expand Down
Loading