pub struct RecoveryClient { /* private fields */ }Expand description
The networked recovery client: escrow cache/refresh, stale-cache-aware local verification, and the guided re-wrap.
It holds one AuthenticatedClient, so every call rides the generated operation paths
and the SDK’s bearer/refresh machinery, and this module states no route of its own. The
client is behind an Arc only so RecoveryClient stays Clone — the cadence hands
one client to several prompts. There is deliberately no repoint/session-swap accessor:
AuthenticatedClient’s own take &mut self and are unreachable through the Arc, and an
escrow client that changed origin mid-cadence would be a way to pull one account’s escrow
into another’s cache. Build a new one instead.
Implementations§
Source§impl RecoveryClient
impl RecoveryClient
Sourcepub fn new(session: Session, api_base_url: &str) -> Result<Self, RecoveryError>
pub fn new(session: Session, api_base_url: &str) -> Result<Self, RecoveryError>
Build a recovery client against the API root — the origin the generated operation
paths hang off (e.g. https://api.example.com), which is the same base
AuthenticatedClient and crate::sync::SyncConsumer take.
§Errors
RecoveryError::InvalidBaseUrl when api_base_url is not a URL operation paths can
hang off. Fallible where the old hand-written format! was not, because the generated
client parses the base once at construction rather than per call.
Sourcepub async fn fetch_escrow(&self) -> Result<EscrowCache, RecoveryError>
pub async fn fetch_escrow(&self) -> Result<EscrowCache, RecoveryError>
Fetch the current escrow blob from the server (GET /v1/auth/escrow) into a fresh
EscrowCache. 404 maps to RecoveryError::NotEnrolled.
Sourcepub async fn store_escrow(
&self,
blob: &WrappedSecret,
) -> Result<EscrowStored, RecoveryError>
pub async fn store_escrow( &self, blob: &WrappedSecret, ) -> Result<EscrowStored, RecoveryError>
Store or replace the caller’s escrow blob (PUT /v1/auth/escrow). Single active
escrow: the server overwrites any prior blob in the same transaction.
The canonical CBOR goes on the wire verbatim. The answer comes back as
EscrowStored: stored_at for the stale-cache rule, replaced to tell a first
enrollment from a rotation.
§Errors
The refusals store_escrow_error maps, and RecoveryError::InvalidResponse when
the server’s stored_at is not an RFC 3339 instant.
Sourcepub async fn store_sealed_identity(
&self,
sealed: &[u8],
) -> Result<SealedIdentityStored, RecoveryError>
pub async fn store_sealed_identity( &self, sealed: &[u8], ) -> Result<SealedIdentityStored, RecoveryError>
Store or replace the caller’s sealed identity (PUT /v1/auth/escrow/identity): the
user identity key sealed under the master key, as Workspace::sealed_identity returns
it. The other half of what a recovered device needs beside the escrow — the identity is
random rather than master-derived, and the server pins it on first directory publish, so
a recovered device must carry this one rather than mint its own.
Opaque on the wire and stored independently of the escrow: a
guided_rewrap replaces the escrow and leaves this alone, because
re-wrapping the master key under a new recovery secret does not change the master key
the identity is sealed under.
§Errors
The same refusals store_escrow maps, under this operation’s
statuses, and RecoveryError::InvalidResponse for an unreadable stored_at.
Sourcepub async fn fetch_sealed_identity(&self) -> Result<Vec<u8>, RecoveryError>
pub async fn fetch_sealed_identity(&self) -> Result<Vec<u8>, RecoveryError>
Fetch the caller’s sealed identity (GET /v1/auth/escrow/identity), verbatim — the
bytes Workspace::create_from_master opens under the recovered master key.
§Errors
RecoveryError::IdentityNotStored on the coded 404; otherwise the refusals
fetch_escrow maps.
Sourcepub async fn store_album_keys(
&self,
album_id: Uuid,
sealed: &[u8],
) -> Result<AlbumKeysStored, RecoveryError>
pub async fn store_album_keys( &self, album_id: Uuid, sealed: &[u8], ) -> Result<AlbumKeysStored, RecoveryError>
Store or replace one album’s key escrow (PUT /v1/auth/escrow/albums/{album_id},
#741): the album’s whole key state sealed under the master key, as
Workspace::album_key_escrow returns it. One slot per album; storing it never touches
another album’s, the escrow or the sealed identity.
§Errors
RecoveryError::Malformed for a blob the server refuses (empty, past the album keys’
ceiling, or an album id that is not canonical), the credential and store refusals
store_escrow maps, and RecoveryError::InvalidResponse for an
unreadable stored_at.
Sourcepub async fn list_album_keys(
&self,
) -> Result<Vec<EscrowedAlbumKeys>, RecoveryError>
pub async fn list_album_keys( &self, ) -> Result<Vec<EscrowedAlbumKeys>, RecoveryError>
Every album key escrow the account holds (GET /v1/auth/escrow/albums), each blob
verbatim, in album order. Empty for an account that has escrowed no album.
§Errors
The credential and store refusals fetch_escrow maps, and
RecoveryError::InvalidResponse when an entry’s album id, blob or stored_at cannot
be read.
Sourcepub async fn verify(
&self,
cache: &mut EscrowCache,
passphrase: &[u8],
device_master: &[u8; 32],
latest_stored_at: Option<Timestamp>,
) -> Result<VerifyOutcome, RecoveryError>
pub async fn verify( &self, cache: &mut EscrowCache, passphrase: &[u8], device_master: &[u8; 32], latest_stored_at: Option<Timestamp>, ) -> Result<VerifyOutcome, RecoveryError>
Local recovery-secret verification with the stale-cache rule (SSoT § Local Verification): run the offline derived-tag compare against the cached blob; if it does not verify, refresh the blob from the server once and retry before returning a failure — so a rotation on another device cannot manufacture a false failure here.
latest_stored_at is the newest escrow stored_at the caller has seen — an
EscrowStored from any device, however it reached this one. When the cache is
older than it, the cache is known stale: it is refreshed
before the compare and stamped with latest_stored_at, and the compare against
the fresh blob is the answer, with no second fetch on a failure. None, or a cache at
least that new, keeps the refresh-on-failure rule above.
Purely local crypto (capsule_core::backup::verify_recovery_secret); the only
network I/O is the single conditional refresh. Never blocks anything.
Sourcepub async fn guided_rewrap(
&self,
device_master: &[u8; 32],
tier: DeviceTier,
shamir_enrolled: bool,
) -> Result<GuidedRewrap, RecoveryError>
pub async fn guided_rewrap( &self, device_master: &[u8; 32], tier: DeviceTier, shamir_enrolled: bool, ) -> Result<GuidedRewrap, RecoveryError>
Run the guided re-wrap (SSoT § On Repeated Failure): mint a fresh ≥128-bit recovery secret, re-wrap the same master key under it, replace the server escrow (single active — the old blob is deleted, so the lost secret unwraps nothing), re-issue Shamir shares when enrolled, and surface the old-artifact guidance when the store displaced an earlier escrow. Wrap rotation, not key rotation: no data re-encryption, no blob-hash changes.
After this succeeds, the caller should
rearm(now, RearmTrigger::SecretRotated) its cadence
when GuidedRewrap::stored says it replaced an escrow; a
store that replaced nothing is a first enrollment, which arms a fresh ladder with
RecoveryCadence::armed_at_setup.
Trait Implementations§
Source§impl Clone for RecoveryClient
impl Clone for RecoveryClient
Source§fn clone(&self) -> RecoveryClient
fn clone(&self) -> RecoveryClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for RecoveryClient
impl !UnwindSafe for RecoveryClient
impl Freeze for RecoveryClient
impl Send for RecoveryClient
impl Sync for RecoveryClient
impl Unpin for RecoveryClient
impl UnsafeUnpin for RecoveryClient
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
unsafe fn consume_handle(handle: Handle) -> Arc<T> ⓘ
Arc<> Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 more