pub struct TokenStore { /* private fields */ }Implementations§
Source§impl TokenStore
impl TokenStore
Sourcepub fn load(
path: PathBuf,
client_id: &str,
access_ttl: Duration,
refresh_ttl: Duration,
) -> Result<Self>
pub fn load( path: PathBuf, client_id: &str, access_ttl: Duration, refresh_ttl: Duration, ) -> Result<Self>
Load (or initialize) the store at path.
- Missing file → empty store (info log).
- Unreadable/corrupt file → rename aside to
tokens.json.broken-{ts}, start empty (warn log). client_id_hashmismatch → wipe (warn log). Handlesoauth.tomlregeneration.- Otherwise → drop expired entries and load.
Sourcepub async fn mint_pair(&self, chain_id: Option<ChainId>) -> Result<MintedPair>
pub async fn mint_pair(&self, chain_id: Option<ChainId>) -> Result<MintedPair>
Mint a new (access, refresh) pair. Pass None for chain_id to start
a new chain (use case: authorization_code grant). Pass Some(id) to
continue an existing chain (use case: refresh_token grant rotation).
Persists to disk before returning. On persist failure logs an error and
keeps the in-memory state — the caller still gets a valid pair.
Sourcepub async fn validate_access(&self, raw: &str) -> bool
pub async fn validate_access(&self, raw: &str) -> bool
Validate an access token. Returns true iff the token was issued, has
not expired, and its chain has not been revoked.
Sourcepub async fn consume_refresh(&self, raw: &str) -> Result<ChainId, RefreshError>
pub async fn consume_refresh(&self, raw: &str) -> Result<ChainId, RefreshError>
Consume a refresh token. Returns the chain_id on success.
Returns Replayed { chain_id } if the token was already consumed —
this is a leak signal and the caller MUST follow up with
revoke_chain(chain_id). Returns Unknown for a refresh token in an
already-revoked chain (we don’t disclose chain identity to a caller
who doesn’t already know it).
Sourcepub async fn revoke_chain(&self, chain_id: ChainId)
pub async fn revoke_chain(&self, chain_id: ChainId)
Mark a chain as revoked. All access tokens in this chain stop validating immediately; any refresh tokens in this chain stop being consumable.