Skip to content
Merged
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
7 changes: 6 additions & 1 deletion crates/bitwarden-auth/src/auth_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use bitwarden_core::Client;
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::*;

use crate::send_access::SendAccessClient;
use crate::{identity::IdentityClient, send_access::SendAccessClient};

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

#[cfg_attr(feature = "wasm", wasm_bindgen)]
impl AuthClient {
/// Client for identity functionality
pub fn identity(&self) -> IdentityClient {
IdentityClient::new(self.client.clone())
}

/// Client for send access functionality
pub fn send_access(&self) -> SendAccessClient {
SendAccessClient::new(self.client.clone())
Expand Down
38 changes: 38 additions & 0 deletions crates/bitwarden-auth/src/identity/client.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use bitwarden_core::Client;
#[cfg(feature = "wasm")]
use wasm_bindgen::prelude::*;

/// The IdentityClient is used to obtain identity / access tokens from the Bitwarden Identity API.
#[derive(Clone)]
#[cfg_attr(feature = "wasm", wasm_bindgen)]
pub struct IdentityClient {
#[allow(dead_code)] // TODO: Remove when methods using client are implemented
pub(crate) client: Client,
}

impl IdentityClient {
/// Create a new IdentityClient with the given Client.
pub(crate) fn new(client: Client) -> Self {
Self { client }
}
}

#[cfg_attr(feature = "wasm", wasm_bindgen)]
impl IdentityClient {
// TODO: Add methods to interact with the Identity API.
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn test_identity_client_creation() {
let client: Client = Client::new(None);
let identity_client = IdentityClient::new(client);

// Verify the identity client was created successfully
// The client field is present and accessible
let _ = identity_client.client;
}
}
5 changes: 5 additions & 0 deletions crates/bitwarden-auth/src/identity/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! Identity client module
//! The IdentityClient is used to obtain identity / access tokens from the Bitwarden Identity API.
mod client;

pub use client::IdentityClient;
1 change: 1 addition & 0 deletions crates/bitwarden-auth/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

mod auth_client;

pub mod identity;
pub mod send_access;

pub(crate) mod api; // keep internal to crate
Expand Down
Loading