Struct UnlockClient
pub struct UnlockClient {
pub(crate) client: Client,
}Expand description
Client for unlocking and locking the vault in memory, and for minting session keys and unlocking the vault with one.
Fields§
§client: ClientImplementations§
§impl UnlockClient
impl UnlockClient
pub async fn generate_session_key(&self) -> Result<SessionKey, UnlockError>
pub async fn generate_session_key(&self) -> Result<SessionKey, UnlockError>
Mint a new session key and persist the user key wrapped by it.
Requires the client to be unlocked (the user key must be present in the
key store). The returned SessionKey should be stored outside the SDK
by the caller and provided back to UnlockClient::unlock on the next
rehydrated client.
pub async fn invalidate_session_key(&self) -> Result<(), SettingsError>
pub async fn invalidate_session_key(&self) -> Result<(), SettingsError>
Delete the persisted session key, so later CLI invocations can no longer unlock with it.
Removes [SESSION_PROTECTED_USER_KEY] from the database. This is how the CLI locks: each
command runs in a new process, so there are no in-memory keys to clear. Long-lived clients
lock with UnlockClient::lock instead.
§impl UnlockClient
impl UnlockClient
pub async fn unlock(&self, method: UnlockMethod) -> Result<(), UnlockError>
pub async fn unlock(&self, method: UnlockMethod) -> Result<(), UnlockError>
Unlock the client with the supplied unlock factor.
UnlockMethod::Legacy initializes the user’s crypto state from the request, as
CryptoClient::initialize_user_crypto does, and returns its errors as
UnlockError::EncryptionSettings.
If the client is already unlocked, this returns UnlockError::AlreadyUnlocked before
doing any work and leaves the client’s keys untouched. The check only looks at whether a
user key is present: it does not check which key the client holds, or whether it belongs
to the user or account in the request.
§impl UnlockClient
impl UnlockClient
pub async fn lock(&self)
pub async fn lock(&self)
Clear the in-memory user and organization keys, retaining the client instance so that a
later UnlockClient::unlock re-unlocks it.
On WASM, unlocking also copies the user key into client-held state through the key-management state bridge, so locking clears it there as well. The in-memory keys are cleared first, so the SDK is locked even if the state bridge call fails.
Trait Implementations§
§impl Clone for UnlockClient
impl Clone for UnlockClient
§fn clone(&self) -> UnlockClient
fn clone(&self) -> UnlockClient
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl FromWasm for UnlockClient
Available on crate feature wasm only.
impl FromWasm for UnlockClient
wasm only.§type Wire = UnlockClient
type Wire = UnlockClient
§fn from_wire(
wire: <UnlockClient as FromWasm>::Wire,
) -> Result<UnlockClient, WireError>
fn from_wire( wire: <UnlockClient as FromWasm>::Wire, ) -> Result<UnlockClient, WireError>
§impl FromWasmAbi for UnlockClient
impl FromWasmAbi for UnlockClient
§impl IntoWasmAbi for UnlockClient
impl IntoWasmAbi for UnlockClient
§impl<UT> LiftRef<UT> for UnlockClient
impl<UT> LiftRef<UT> for UnlockClient
type LiftType = Arc<UnlockClient>
§impl LongRefFromWasmAbi for UnlockClient
impl LongRefFromWasmAbi for UnlockClient
§type Anchor = RcRef<UnlockClient>
type Anchor = RcRef<UnlockClient>
RefFromWasmAbi::Anchor§unsafe fn long_ref_from_abi(
js: <UnlockClient as LongRefFromWasmAbi>::Abi,
) -> <UnlockClient as LongRefFromWasmAbi>::Anchor
unsafe fn long_ref_from_abi( js: <UnlockClient as LongRefFromWasmAbi>::Abi, ) -> <UnlockClient as LongRefFromWasmAbi>::Anchor
RefFromWasmAbi::ref_from_abi§impl<UT> LowerError<UT> for UnlockClient
impl<UT> LowerError<UT> for UnlockClient
§fn lower_error(obj: UnlockClient) -> RustBuffer
fn lower_error(obj: UnlockClient) -> RustBuffer
§impl<UT> LowerReturn<UT> for UnlockClient
impl<UT> LowerReturn<UT> for UnlockClient
§type ReturnType = <Arc<UnlockClient> as LowerReturn<UniFfiTag>>::ReturnType
type ReturnType = <Arc<UnlockClient> as LowerReturn<UniFfiTag>>::ReturnType
§fn lower_return(
obj: UnlockClient,
) -> Result<<UnlockClient as LowerReturn<UT>>::ReturnType, RustCallError>
fn lower_return( obj: UnlockClient, ) -> Result<<UnlockClient as LowerReturn<UT>>::ReturnType, RustCallError>
§fn handle_failed_lift(
error: LiftArgsError,
) -> Result<Self::ReturnType, RustCallError>
fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>
§impl OptionFromWasmAbi for UnlockClient
impl OptionFromWasmAbi for UnlockClient
§fn is_none(abi: &<UnlockClient as FromWasmAbi>::Abi) -> bool
fn is_none(abi: &<UnlockClient as FromWasmAbi>::Abi) -> bool
None, and otherwise it will be passed to
FromWasmAbi.§impl OptionIntoWasmAbi for UnlockClient
impl OptionIntoWasmAbi for UnlockClient
§fn none() -> <UnlockClient as IntoWasmAbi>::Abi
fn none() -> <UnlockClient as IntoWasmAbi>::Abi
None branch of this option. Read more§impl RefFromWasmAbi for UnlockClient
impl RefFromWasmAbi for UnlockClient
§type Anchor = RcRef<UnlockClient>
type Anchor = RcRef<UnlockClient>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.§unsafe fn ref_from_abi(
js: <UnlockClient as RefFromWasmAbi>::Abi,
) -> <UnlockClient as RefFromWasmAbi>::Anchor
unsafe fn ref_from_abi( js: <UnlockClient as RefFromWasmAbi>::Abi, ) -> <UnlockClient as RefFromWasmAbi>::Anchor
§impl RefMutFromWasmAbi for UnlockClient
impl RefMutFromWasmAbi for UnlockClient
§type Anchor = RcRefMut<UnlockClient>
type Anchor = RcRefMut<UnlockClient>
RefFromWasmAbi::Anchor§unsafe fn ref_mut_from_abi(
js: <UnlockClient as RefMutFromWasmAbi>::Abi,
) -> <UnlockClient as RefMutFromWasmAbi>::Anchor
unsafe fn ref_mut_from_abi( js: <UnlockClient as RefMutFromWasmAbi>::Abi, ) -> <UnlockClient as RefMutFromWasmAbi>::Anchor
RefFromWasmAbi::ref_from_abi§impl ToWasm for UnlockClient
Available on crate feature wasm only.
impl ToWasm for UnlockClient
wasm only.§type Wire = UnlockClient
type Wire = UnlockClient
§fn to_wire(self) -> Result<<UnlockClient as ToWasm>::Wire, WireError>
fn to_wire(self) -> Result<<UnlockClient as ToWasm>::Wire, WireError>
§impl TryFromJsValue for UnlockClient
impl TryFromJsValue for UnlockClient
§fn try_from_js_value(value: JsValue) -> Result<UnlockClient, JsValue>
fn try_from_js_value(value: JsValue) -> Result<UnlockClient, JsValue>
§fn try_from_js_value_ref(value: &JsValue) -> Option<UnlockClient>
fn try_from_js_value_ref(value: &JsValue) -> Option<UnlockClient>
§impl<UT> TypeId<UT> for UnlockClient
impl<UT> TypeId<UT> for UnlockClient
const TYPE_ID_META: MetadataBuffer
§impl VectorFromWasmAbi for UnlockClient
impl VectorFromWasmAbi for UnlockClient
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi( js: <UnlockClient as VectorFromWasmAbi>::Abi, ) -> Box<[UnlockClient]>
§impl VectorIntoWasmAbi for UnlockClient
impl VectorIntoWasmAbi for UnlockClient
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi( vector: Box<[UnlockClient]>, ) -> <UnlockClient as VectorIntoWasmAbi>::Abi
Auto Trait Implementations§
impl !RefUnwindSafe for UnlockClient
impl !UnwindSafe for UnlockClient
impl Freeze for UnlockClient
impl Send for UnlockClient
impl Sync for UnlockClient
impl Unpin for UnlockClient
impl UnsafeUnpin for UnlockClient
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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> ⓘ
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.