pub struct AuthWallet {
pub mint_url: MintUrl,
pub localstore: Arc<dyn WalletDatabase<Error> + Send + Sync>,
pub metadata_cache: Arc<MintMetadataCache>,
pub protected_endpoints: Arc<RwLock<HashMap<ProtectedEndpoint, AuthRequired>>>,
/* private fields */
}Expand description
CDK Auth Wallet
A AuthWallet is for auth operations with a single mint.
Fields§
§mint_url: MintUrlMint Url
localstore: Arc<dyn WalletDatabase<Error> + Send + Sync>Storage backend
metadata_cache: Arc<MintMetadataCache>Mint metadata cache (lock-free cached access to keys, keysets, and mint info)
protected_endpoints: Arc<RwLock<HashMap<ProtectedEndpoint, AuthRequired>>>Protected methods
Implementations§
Source§impl AuthWallet
impl AuthWallet
Sourcepub fn new(
mint_url: MintUrl,
cat: Option<AuthToken>,
localstore: Arc<dyn WalletDatabase<Error> + Send + Sync>,
metadata_cache: Arc<MintMetadataCache>,
protected_endpoints: HashMap<ProtectedEndpoint, AuthRequired>,
oidc_client: Option<OidcClient>,
) -> Self
pub fn new( mint_url: MintUrl, cat: Option<AuthToken>, localstore: Arc<dyn WalletDatabase<Error> + Send + Sync>, metadata_cache: Arc<MintMetadataCache>, protected_endpoints: HashMap<ProtectedEndpoint, AuthRequired>, oidc_client: Option<OidcClient>, ) -> Self
Create a new AuthWallet instance
Sourcepub async fn get_auth_token(&self) -> Result<AuthToken, Error>
pub async fn get_auth_token(&self) -> Result<AuthToken, Error>
Get the current auth token
Sourcepub async fn get_refresh_token(&self) -> Option<String>
pub async fn get_refresh_token(&self) -> Option<String>
Get the current refresh token if one exists
Sourcepub async fn set_refresh_token(&self, token: Option<String>)
pub async fn set_refresh_token(&self, token: Option<String>)
Set a new refresh token
Sourcepub async fn get_oidc_client(&self) -> Option<OidcClient>
pub async fn get_oidc_client(&self) -> Option<OidcClient>
Get the OIDC client if one exists
Sourcepub async fn set_oidc_client(&self, client: Option<OidcClient>)
pub async fn set_oidc_client(&self, client: Option<OidcClient>)
Set a new OIDC client
Sourcepub async fn refresh_access_token(&self) -> Result<(), Error>
pub async fn refresh_access_token(&self) -> Result<(), Error>
Refresh the access token using the stored refresh token
Sourcepub async fn get_mint_info(&self) -> Result<Option<MintInfo>, Error>
pub async fn get_mint_info(&self) -> Result<Option<MintInfo>, Error>
Query mint for current mint information
Sourcepub async fn load_keyset_keys(&self, keyset_id: Id) -> Result<Keys, Error>
pub async fn load_keyset_keys(&self, keyset_id: Id) -> Result<Keys, Error>
Fetch keys for mint keyset
Returns keys from metadata cache if available, fetches from mint if not.
Sourcepub async fn load_mint_keysets(&self) -> Result<Vec<KeySetInfo>, Error>
pub async fn load_mint_keysets(&self) -> Result<Vec<KeySetInfo>, Error>
Get blind auth keysets from metadata cache
Checks the metadata cache for auth keysets. If cache is not populated, fetches from the mint server and updates the cache. This is the main method for getting auth keysets in operations that can work offline but will fall back to online if needed.
Sourcepub async fn refresh_keysets(&self) -> Result<Vec<KeySetInfo>, Error>
pub async fn refresh_keysets(&self) -> Result<Vec<KeySetInfo>, Error>
Refresh blind auth keysets by fetching the latest from mint
Fetches the latest blind auth keyset information from the mint server, updating the metadata cache and database. Returns only the keysets with Auth currency unit. Use this when you need the most up-to-date keyset information.
Sourcepub async fn fetch_active_keyset(&self) -> Result<KeySetInfo, Error>
pub async fn fetch_active_keyset(&self) -> Result<KeySetInfo, Error>
Get the first active blind auth keyset - always goes online
This method always goes online to refresh keysets from the mint and then returns the first active keyset found. Use this when you need the most up-to-date keyset information for blind auth operations.
Sourcepub async fn get_unspent_auth_proofs(&self) -> Result<Vec<AuthProof>, Error>
pub async fn get_unspent_auth_proofs(&self) -> Result<Vec<AuthProof>, Error>
Get unspent auth proofs from local database only - offline operation
Returns auth proofs from the local database that are in the Unspent state. This is an offline operation that does not contact the mint.
Sourcepub async fn is_protected(
&self,
method: &ProtectedEndpoint,
) -> Option<AuthRequired>
pub async fn is_protected( &self, method: &ProtectedEndpoint, ) -> Option<AuthRequired>
Check if and what kind of auth is required for a method
Sourcepub async fn get_blind_auth_token(
&self,
) -> Result<Option<BlindAuthToken>, Error>
pub async fn get_blind_auth_token( &self, ) -> Result<Option<BlindAuthToken>, Error>
Get Auth Token
Sourcepub async fn get_auth_for_request(
&self,
method: &ProtectedEndpoint,
) -> Result<Option<AuthToken>, Error>
pub async fn get_auth_for_request( &self, method: &ProtectedEndpoint, ) -> Result<Option<AuthToken>, Error>
Auth for request
Sourcepub async fn total_blind_auth_balance(&self) -> Result<Amount, Error>
pub async fn total_blind_auth_balance(&self) -> Result<Amount, Error>
Total unspent balance of wallet
Source§impl AuthWallet
impl AuthWallet
Sourcepub fn get_metadata_cache_info(&self) -> FreshnessStatus
pub fn get_metadata_cache_info(&self) -> FreshnessStatus
Get information about metadata cache info
Trait Implementations§
Source§impl Clone for AuthWallet
impl Clone for AuthWallet
Source§fn clone(&self) -> AuthWallet
fn clone(&self) -> AuthWallet
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AuthWallet
impl !RefUnwindSafe for AuthWallet
impl Send for AuthWallet
impl Sync for AuthWallet
impl Unpin for AuthWallet
impl UnsafeUnpin for AuthWallet
impl !UnwindSafe for AuthWallet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request