Skip to content

Commit 1fbe63d

Browse files
authored
Merge branch 'main' into ps/use-proper-error-uniffi
2 parents efa8e04 + d0262d3 commit 1fbe63d

File tree

27 files changed

+280
-95
lines changed

27 files changed

+280
-95
lines changed

Cargo.lock

Lines changed: 20 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ bitwarden-exporters = { path = "crates/bitwarden-exporters", version = "=1.0.0"
3434
bitwarden-fido = { path = "crates/bitwarden-fido", version = "=1.0.0" }
3535
bitwarden-generators = { path = "crates/bitwarden-generators", version = "=1.0.0" }
3636
bitwarden-ipc = { path = "crates/bitwarden-ipc", version = "=1.0.0" }
37+
bitwarden-pm = { path = "crates/bitwarden-pm", version = "=1.0.0" }
3738
bitwarden-send = { path = "crates/bitwarden-send", version = "=1.0.0" }
3839
bitwarden-sm = { path = "bitwarden_license/bitwarden-sm", version = "=1.0.0" }
3940
bitwarden-ssh = { path = "crates/bitwarden-ssh", version = "=1.0.0" }

crates/bitwarden-api-api/src/models/cipher_details_response_model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct CipherDetailsResponseModel {
2323
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
2424
pub r#type: Option<models::CipherType>,
2525
#[serde(rename = "data", skip_serializing_if = "Option::is_none")]
26-
pub data: Option<serde_json::Value>,
26+
pub data: Option<String>,
2727
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
2828
pub name: Option<String>,
2929
#[serde(rename = "notes", skip_serializing_if = "Option::is_none")]

crates/bitwarden-api-api/src/models/cipher_mini_details_response_model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct CipherMiniDetailsResponseModel {
2323
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
2424
pub r#type: Option<models::CipherType>,
2525
#[serde(rename = "data", skip_serializing_if = "Option::is_none")]
26-
pub data: Option<serde_json::Value>,
26+
pub data: Option<String>,
2727
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
2828
pub name: Option<String>,
2929
#[serde(rename = "notes", skip_serializing_if = "Option::is_none")]

crates/bitwarden-api-api/src/models/cipher_mini_response_model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct CipherMiniResponseModel {
2323
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
2424
pub r#type: Option<models::CipherType>,
2525
#[serde(rename = "data", skip_serializing_if = "Option::is_none")]
26-
pub data: Option<serde_json::Value>,
26+
pub data: Option<String>,
2727
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
2828
pub name: Option<String>,
2929
#[serde(rename = "notes", skip_serializing_if = "Option::is_none")]

crates/bitwarden-api-api/src/models/cipher_request_model.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ pub struct CipherRequestModel {
5151
pub secure_note: Option<Box<models::CipherSecureNoteModel>>,
5252
#[serde(rename = "sshKey", skip_serializing_if = "Option::is_none")]
5353
pub ssh_key: Option<Box<models::CipherSshKeyModel>>,
54+
/// JSON string containing cipher-specific data
55+
#[serde(rename = "data", skip_serializing_if = "Option::is_none")]
56+
pub data: Option<String>,
5457
#[serde(
5558
rename = "lastKnownRevisionDate",
5659
skip_serializing_if = "Option::is_none"
@@ -81,6 +84,7 @@ impl CipherRequestModel {
8184
identity: None,
8285
secure_note: None,
8386
ssh_key: None,
87+
data: None,
8488
last_known_revision_date: None,
8589
archived_date: None,
8690
}

crates/bitwarden-api-api/src/models/cipher_response_model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub struct CipherResponseModel {
2323
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
2424
pub r#type: Option<models::CipherType>,
2525
#[serde(rename = "data", skip_serializing_if = "Option::is_none")]
26-
pub data: Option<serde_json::Value>,
26+
pub data: Option<String>,
2727
#[serde(rename = "name", skip_serializing_if = "Option::is_none")]
2828
pub name: Option<String>,
2929
#[serde(rename = "notes", skip_serializing_if = "Option::is_none")]

crates/bitwarden-api-api/src/models/cipher_with_id_request_model.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ pub struct CipherWithIdRequestModel {
5151
pub secure_note: Option<Box<models::CipherSecureNoteModel>>,
5252
#[serde(rename = "sshKey", skip_serializing_if = "Option::is_none")]
5353
pub ssh_key: Option<Box<models::CipherSshKeyModel>>,
54+
/// JSON string containing cipher-specific data
55+
#[serde(rename = "data", skip_serializing_if = "Option::is_none")]
56+
pub data: Option<String>,
5457
#[serde(
5558
rename = "lastKnownRevisionDate",
5659
skip_serializing_if = "Option::is_none"
@@ -83,6 +86,7 @@ impl CipherWithIdRequestModel {
8386
identity: None,
8487
secure_note: None,
8588
ssh_key: None,
89+
data: None,
8690
last_known_revision_date: None,
8791
archived_date: None,
8892
id,

crates/bitwarden-auth/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,21 @@ wasm = [
2222
"dep:wasm-bindgen-futures"
2323
] # WASM support
2424

25-
# Note: dependencies must be alphabetized to pass the cargo sort check in the CI pipeline..
25+
# Note: dependencies must be alphabetized to pass the cargo sort check in the CI pipeline.
2626
[dependencies]
2727
bitwarden-core = { workspace = true, features = ["internal"] }
2828
bitwarden-error = { workspace = true }
2929
chrono = { workspace = true }
3030
reqwest = { workspace = true }
3131
serde = { workspace = true }
32-
serde_json = { workspace = true }
33-
serde_qs = { workspace = true }
34-
serde_urlencoded = ">=0.7.1, <0.8"
3532
thiserror = { workspace = true }
3633
tsify = { workspace = true, optional = true }
3734
wasm-bindgen = { workspace = true, optional = true }
3835
wasm-bindgen-futures = { workspace = true, optional = true }
3936

4037
[dev-dependencies]
4138
bitwarden-test = { workspace = true }
39+
serde_json = { workspace = true }
4240
tokio = { workspace = true, features = ["rt"] }
4341
wiremock = "0.6.0"
4442

crates/bitwarden-auth/src/send_access/client.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,9 @@ impl SendAccessClient {
4949
.identity
5050
.client
5151
.post(&url)
52-
.header(
53-
reqwest::header::CONTENT_TYPE,
54-
"application/x-www-form-urlencoded; charset=utf-8",
55-
)
5652
.header(reqwest::header::ACCEPT, "application/json")
5753
.header(reqwest::header::CACHE_CONTROL, "no-store")
58-
// We can use `serde_urlencoded` to serialize the payload into a URL-encoded string
59-
// because we don't have complex nested structures in the payload.
60-
// If we had nested structures, we have to use serde_qs::to_string instead.
61-
.body(serde_urlencoded::to_string(&payload).expect("Serialize should be infallible"));
54+
.form(&payload);
6255

6356
// Because of the ? operator, any errors from sending the request are automatically
6457
// wrapped in SendAccessTokenError::Unexpected as an UnexpectedIdentityError::Reqwest
@@ -164,7 +157,7 @@ mod tests {
164157
// expect the headers we set in the client
165158
.and(matchers::header(
166159
reqwest::header::CONTENT_TYPE.as_str(),
167-
"application/x-www-form-urlencoded; charset=utf-8",
160+
"application/x-www-form-urlencoded",
168161
))
169162
.and(matchers::header(
170163
reqwest::header::ACCEPT.as_str(),
@@ -234,7 +227,7 @@ mod tests {
234227
// expect the headers we set in the client
235228
.and(matchers::header(
236229
reqwest::header::CONTENT_TYPE.as_str(),
237-
"application/x-www-form-urlencoded; charset=utf-8",
230+
"application/x-www-form-urlencoded",
238231
))
239232
.and(matchers::header(
240233
reqwest::header::ACCEPT.as_str(),
@@ -298,8 +291,6 @@ mod tests {
298291
otp: otp.into(),
299292
};
300293

301-
let email_param = serde_urlencoded::to_string([("email", email)]).unwrap(); // "email=valid%40email.com"
302-
303294
let req = SendAccessTokenRequest {
304295
send_id: "valid-send-id".into(),
305296
send_access_credentials: Some(SendAccessCredentials::EmailOtp(
@@ -312,7 +303,7 @@ mod tests {
312303
// expect the headers we set in the client
313304
.and(matchers::header(
314305
reqwest::header::CONTENT_TYPE.as_str(),
315-
"application/x-www-form-urlencoded; charset=utf-8",
306+
"application/x-www-form-urlencoded",
316307
))
317308
.and(matchers::header(
318309
reqwest::header::ACCEPT.as_str(),
@@ -330,7 +321,7 @@ mod tests {
330321
)))
331322
.and(body_string_contains(format!("scope={}", scope_str)))
332323
.and(body_string_contains(format!("send_id={}", req.send_id)))
333-
.and(body_string_contains(email_param))
324+
.and(body_string_contains("email=valid%40email.com"))
334325
.and(body_string_contains(format!("otp={}", otp)))
335326
// respond with the mock success response
336327
.respond_with(ResponseTemplate::new(200).set_body_json(raw_success));

0 commit comments

Comments
 (0)