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§
Source§impl UnlockClient
impl UnlockClient
pub(crate) fn new(client: Client) -> Self
Sourcepub 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.
Sourcefn has_user_key(&self) -> bool
fn has_user_key(&self) -> bool
Whether the key store holds the user key.
Sourceasync fn unlock_with_session_key(
&self,
session_key: SessionKey,
) -> Result<(), UnlockError>
async fn unlock_with_session_key( &self, session_key: SessionKey, ) -> Result<(), UnlockError>
Unlock a rehydrated client with a session key.
Reads [SESSION_PROTECTED_USER_KEY] and [ACCOUNT_CRYPTO_STATE] from
the state registry, unwraps the user key, initializes the user’s crypto
state, and restores any persisted organization keys.
Sourcepub async fn invalidate_session_key(&self) -> Result<(), PersistedValueError>
pub async fn invalidate_session_key(&self) -> Result<(), PersistedValueError>
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.
Source§impl UnlockClient
impl UnlockClient
Sourcepub 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.
Source§impl UnlockClient
impl UnlockClient
Sourcepub 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§
Source§impl Clone for UnlockClient
impl Clone for UnlockClient
Source§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 moreSource§impl From<UnlockClient> for JsValue
impl From<UnlockClient> for JsValue
Source§fn from(value: UnlockClient) -> Self
fn from(value: UnlockClient) -> Self
Source§impl FromWasm for UnlockClient
Available on crate feature wasm only.
impl FromWasm for UnlockClient
wasm only.Source§impl FromWasmAbi for UnlockClient
impl FromWasmAbi for UnlockClient
Source§impl IntoWasmAbi for UnlockClient
impl IntoWasmAbi for UnlockClient
Source§type Abi = WasmPtr<WasmRefCell<UnlockClient>>
type Abi = WasmPtr<WasmRefCell<UnlockClient>>
Source§impl<UT> LiftRef<UT> for UnlockClient
impl<UT> LiftRef<UT> for UnlockClient
type LiftType = Arc<UnlockClient>
Source§impl LongRefFromWasmAbi for UnlockClient
impl LongRefFromWasmAbi for UnlockClient
Source§type Abi = WasmPtr<WasmRefCell<UnlockClient>>
type Abi = WasmPtr<WasmRefCell<UnlockClient>>
RefFromWasmAbi::AbiSource§type Anchor = RcRef<UnlockClient>
type Anchor = RcRef<UnlockClient>
RefFromWasmAbi::AnchorSource§unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiSource§impl<UT> LowerError<UT> for UnlockClient
impl<UT> LowerError<UT> for UnlockClient
Source§fn lower_error(obj: Self) -> RustBuffer
fn lower_error(obj: Self) -> RustBuffer
Source§impl<UT> LowerReturn<UT> for UnlockClient
impl<UT> LowerReturn<UT> for UnlockClient
Source§type ReturnType = <Arc<UnlockClient> as LowerReturn<UniFfiTag>>::ReturnType
type ReturnType = <Arc<UnlockClient> as LowerReturn<UniFfiTag>>::ReturnType
Source§fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
§fn handle_failed_lift(
error: LiftArgsError,
) -> Result<Self::ReturnType, RustCallError>
fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>
Source§impl NullableFromWasmAbi for UnlockClient
impl NullableFromWasmAbi for UnlockClient
Source§impl NullableIntoWasmAbi for UnlockClient
impl NullableIntoWasmAbi for UnlockClient
Source§impl OptionFromWasmAbi for UnlockClient
impl OptionFromWasmAbi for UnlockClient
Source§impl OptionIntoWasmAbi for UnlockClient
impl OptionIntoWasmAbi for UnlockClient
Source§impl RefFromWasmAbi for UnlockClient
impl RefFromWasmAbi for UnlockClient
Source§type Abi = WasmPtr<WasmRefCell<UnlockClient>>
type Abi = WasmPtr<WasmRefCell<UnlockClient>>
Self are recovered from.Source§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.Source§impl RefMutFromWasmAbi for UnlockClient
impl RefMutFromWasmAbi for UnlockClient
Source§type Abi = WasmPtr<WasmRefCell<UnlockClient>>
type Abi = WasmPtr<WasmRefCell<UnlockClient>>
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<UnlockClient>
type Anchor = RcRefMut<UnlockClient>
RefFromWasmAbi::AnchorSource§unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
RefFromWasmAbi::ref_from_abiimpl SupportsConstructor for UnlockClient
impl SupportsInstanceProperty for UnlockClient
impl SupportsStaticProperty for UnlockClient
Source§impl ToWasm for UnlockClient
Available on crate feature wasm only.
impl ToWasm for UnlockClient
wasm only.Source§impl TryFromJsValue for UnlockClient
impl TryFromJsValue for UnlockClient
Source§fn try_from_js_value_ref(value: &JsValue) -> Option<Self>
fn try_from_js_value_ref(value: &JsValue) -> Option<Self>
Source§const NULLABLE: bool = false
const NULLABLE: bool = false
Self accepts null as a distinct value space, as
Nullable<T> does. An enclosing Option then passes null through
instead of reading it as None, so Option<T> is itself nullable
exactly when T is not. JsValue does not set this: it accepts
null as one value among all of them, not as a distinct space, and
Option<JsValue> reads it as None like the ABI does. This is the
JS-value side of NullableFromWasmAbi, which claims null at the
ABI.Source§impl<UT> TypeId<UT> for UnlockClient
impl<UT> TypeId<UT> for UnlockClient
const TYPE_ID_META: MetadataBuffer
Source§impl VectorFromWasmAbi for UnlockClient
impl VectorFromWasmAbi for UnlockClient
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[UnlockClient]>
Source§impl VectorIntoWasmAbi for UnlockClient
impl VectorIntoWasmAbi for UnlockClient
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[UnlockClient]>) -> Self::Abi
Source§impl WasmDescribe for UnlockClient
impl WasmDescribe for UnlockClient
Source§impl WasmDescribeVector for UnlockClient
impl WasmDescribeVector for UnlockClient
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 moreSource§impl<T> MaybeFromWasmAbi for Twhere
T: OptionFromWasmAbi,
impl<T> MaybeFromWasmAbi for Twhere
T: OptionFromWasmAbi,
Source§type MaybeAbi = <T as FromWasmAbi>::Abi
type MaybeAbi = <T as FromWasmAbi>::Abi
Option<Self>.Source§unsafe fn from_maybe_abi(js: <T as FromWasmAbi>::Abi) -> T
unsafe fn from_maybe_abi(js: <T as FromWasmAbi>::Abi) -> T
unsafe fn try_from_maybe_abi( js: <T as FromWasmAbi>::Abi, ) -> Result<T, &'static str>
Source§impl<T> MaybeIntoWasmAbi for Twhere
T: OptionIntoWasmAbi,
impl<T> MaybeIntoWasmAbi for Twhere
T: OptionIntoWasmAbi,
Source§type MaybeAbi = <T as IntoWasmAbi>::Abi
type MaybeAbi = <T as IntoWasmAbi>::Abi
Option<Self>.Source§fn into_maybe_abi(self) -> <T as IntoWasmAbi>::Abi
fn into_maybe_abi(self) -> <T as IntoWasmAbi>::Abi
Option<Self> ABI.§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.