Skip to content

[PM-24051] In identity and sync response & decryption options, add MasterPasswordUnlockDataResponse in response model #376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions crates/bitwarden-api-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ repository.workspace = true
license-file.workspace = true
keywords.workspace = true

[features]
default = []
wasm = ["dep:tsify", "dep:wasm-bindgen"] # WASM support

[dependencies]
reqwest = { workspace = true }
serde = { workspace = true }
Expand All @@ -22,5 +26,7 @@ serde_with = { version = ">=3.8, <4", default-features = false, features = [
"std",
"macros",
] }
tsify = { workspace = true, optional = true, features = ["js"], default-features = false }
url = ">=2.5, <3"
uuid = { workspace = true }
wasm-bindgen = { workspace = true, optional = true, features = ["serde-serialize"] }
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@
*/

use serde::{Deserialize, Serialize};
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::wasm_bindgen;

use crate::models;

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[cfg_attr(
feature = "wasm",
derive(tsify::Tsify),
tsify(into_wasm_abi, from_wasm_abi)
)]
pub struct MasterPasswordUnlockKdfResponseModel {
#[serde(rename = "kdfType")]
pub kdf_type: models::KdfType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,31 @@
*/

use serde::{Deserialize, Serialize};
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::wasm_bindgen;

use crate::models;

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[cfg_attr(
feature = "wasm",
derive(tsify::Tsify),
tsify(into_wasm_abi, from_wasm_abi)
)]
pub struct MasterPasswordUnlockResponseModel {
#[serde(rename = "kdf")]
pub kdf: Box<models::MasterPasswordUnlockKdfResponseModel>,
#[serde(rename = "masterKeyEncryptedUserKey")]
pub master_key_encrypted_user_key: Option<String>,
pub master_key_encrypted_user_key: String,
Copy link
Member

@Hinton Hinton Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Platform hasn't made any strides into making fields required as it has compatibility implications. This will throw an error should these fields not be available in the past, present or future. I.e. can we guarantee forever that this endpoint in the past and future has and always will include master_key_encrypted_user_key and salt? And if these are missing are we fine with it throwing?

This is related to https://bitwarden.atlassian.net/wiki/spaces/DEV/pages/760971277/Improve+API+bindings.

#[serde(rename = "salt")]
pub salt: Option<String>,
pub salt: String,
}

impl MasterPasswordUnlockResponseModel {
pub fn new(
kdf: models::MasterPasswordUnlockKdfResponseModel,
master_key_encrypted_user_key: Option<String>,
salt: Option<String>,
master_key_encrypted_user_key: String,
salt: String,
) -> MasterPasswordUnlockResponseModel {
MasterPasswordUnlockResponseModel {
kdf: Box::new(kdf),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@
*/

use serde::{Deserialize, Serialize};
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::wasm_bindgen;

use crate::models;

#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
#[cfg_attr(
feature = "wasm",
derive(tsify::Tsify),
tsify(into_wasm_abi, from_wasm_abi)
)]
pub struct UserDecryptionResponseModel {
#[serde(
rename = "masterPasswordUnlock",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use std::{collections::HashMap, num::NonZeroU32};

use bitwarden_api_api::models::UserDecryptionResponseModel;
use bitwarden_api_identity::models::KdfType;
use serde::{Deserialize, Serialize};
use serde_json::Value;
Expand Down Expand Up @@ -35,6 +36,9 @@ pub struct IdentityTokenSuccessResponse {
#[serde(rename = "keyConnectorUrl", alias = "KeyConnectorUrl")]
key_connector_url: Option<String>,

#[serde(rename = "userDecryptionOptions", alias = "UserDecryptionOptions")]
pub user_decryption_options: Option<UserDecryptionResponseModel>,

/// Stores unknown api response fields
extra: Option<HashMap<String, Value>>,
}
Expand All @@ -61,6 +65,7 @@ mod test {
force_password_reset: Default::default(),
api_use_key_connector: Default::default(),
key_connector_url: Default::default(),
user_decryption_options: Default::default(),
extra: Default::default(),
}
}
Expand Down
Loading
Loading