Skip to content

Commit a36a8ef

Browse files
feat(IdentityClientStub): [PM-23835] Stub out auth identity client (#546)
## 🎟️ Tracking <!-- Paste the link to the Jira or GitHub issue or otherwise describe / point to where this change is coming from. --> https://bitwarden.atlassian.net/browse/PM-23835 ## 📔 Objective <!-- Describe what the purpose of this PR is, for example what bug you're fixing or new feature you're adding. --> To stub out the auth client > identity client ## ⏰ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## 🦮 Reviewer guidelines <!-- Suggested interactions but feel free to use (or not) as you desire! --> - 👍 (`:+1:`) or similar for great changes - 📝 (`:memo:`) or ℹ️ (`:information_source:`) for notes or general info - ❓ (`:question:`) for questions - 🤔 (`:thinking:`) or 💭 (`:thought_balloon:`) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion - 🎨 (`:art:`) for suggestions / improvements - ❌ (`:x:`) or ⚠️ (`:warning:`) for more significant problems or concerns needing attention - 🌱 (`:seedling:`) or ♻️ (`:recycle:`) for future improvements or indications of technical debt - ⛏ (`:pick:`) for minor or nitpick changes
1 parent 95e329a commit a36a8ef

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

crates/bitwarden-auth/src/auth_client.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use bitwarden_core::Client;
22
#[cfg(feature = "wasm")]
33
use wasm_bindgen::prelude::*;
44

5-
use crate::send_access::SendAccessClient;
5+
use crate::{identity::IdentityClient, send_access::SendAccessClient};
66

77
/// Subclient containing auth functionality.
88
#[derive(Clone)]
@@ -23,6 +23,11 @@ impl AuthClient {
2323

2424
#[cfg_attr(feature = "wasm", wasm_bindgen)]
2525
impl AuthClient {
26+
/// Client for identity functionality
27+
pub fn identity(&self) -> IdentityClient {
28+
IdentityClient::new(self.client.clone())
29+
}
30+
2631
/// Client for send access functionality
2732
pub fn send_access(&self) -> SendAccessClient {
2833
SendAccessClient::new(self.client.clone())
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
use bitwarden_core::Client;
2+
#[cfg(feature = "wasm")]
3+
use wasm_bindgen::prelude::*;
4+
5+
/// The IdentityClient is used to obtain identity / access tokens from the Bitwarden Identity API.
6+
#[derive(Clone)]
7+
#[cfg_attr(feature = "wasm", wasm_bindgen)]
8+
pub struct IdentityClient {
9+
#[allow(dead_code)] // TODO: Remove when methods using client are implemented
10+
pub(crate) client: Client,
11+
}
12+
13+
impl IdentityClient {
14+
/// Create a new IdentityClient with the given Client.
15+
pub(crate) fn new(client: Client) -> Self {
16+
Self { client }
17+
}
18+
}
19+
20+
#[cfg_attr(feature = "wasm", wasm_bindgen)]
21+
impl IdentityClient {
22+
// TODO: Add methods to interact with the Identity API.
23+
}
24+
25+
#[cfg(test)]
26+
mod tests {
27+
use super::*;
28+
29+
#[test]
30+
fn test_identity_client_creation() {
31+
let client: Client = Client::new(None);
32+
let identity_client = IdentityClient::new(client);
33+
34+
// Verify the identity client was created successfully
35+
// The client field is present and accessible
36+
let _ = identity_client.client;
37+
}
38+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//! Identity client module
2+
//! The IdentityClient is used to obtain identity / access tokens from the Bitwarden Identity API.
3+
mod client;
4+
5+
pub use client::IdentityClient;

crates/bitwarden-auth/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
mod auth_client;
44

5+
pub mod identity;
56
pub mod send_access;
67

78
pub(crate) mod api; // keep internal to crate

0 commit comments

Comments
 (0)