Expand description
App-owned credential storage: modify is the only write path.
Ported from pi-mono packages/ai/src/auth/types.ts (CredentialStore) and
packages/ai/src/auth/credential-store.ts (InMemoryCredentialStore),
MIT, Copyright (c) 2025 Mario Zechner — full notice in the parent module.
Several doc comments below are adapted closely from pi’s.
pi’s rule, kept verbatim in spirit: every mutation is a serialized read-modify-write whose closure sees the current credential, so a refresh and a concurrent login cannot clobber each other.
CodeWhale already serializes the xAI OAuth refresh that way, but not
through this store: xai_oauth holds with_xai_oauth_lifecycle_lock
across the token-file read, the refresh request, and the write-back, so
two concurrent near-expiry observers share one rotated epoch rather than
overwriting each other’s refresh token. That lock is process- and
file-level, not this registry’s per-provider mutex, and the xAI flow is
not rewritten onto CredentialStore::modify here. This trait is
the shape that would put API-key slots and that OAuth flow on one write
path.
Structs§
- Credential
Info - Non-secret credential metadata for account/status enumeration.
- Secret
Store Credentials - Adapter over CodeWhale’s existing durable secret store.
Traits§
- Credential
Store - App-owned credential storage, keyed by provider id, one credential per provider.
Functions§
- with_
provider_ write_ lock - Run
bodyholding this provider’s write lock. - with_
provider_ write_ locks - Run
bodyholding every listed provider’s write lock.