pub struct CryptoClient {
pub(crate) client: Client,
}
Expand description
A client for the crypto operations.
Fields§
§client: Client
Implementations§
Source§impl CryptoClient
impl CryptoClient
Sourcepub async fn initialize_user_crypto(
&self,
req: InitUserCryptoRequest,
) -> Result<(), EncryptionSettingsError>
pub async fn initialize_user_crypto( &self, req: InitUserCryptoRequest, ) -> Result<(), EncryptionSettingsError>
Initialization method for the user crypto. Needs to be called before any other crypto operations.
Sourcepub async fn initialize_org_crypto(
&self,
req: InitOrgCryptoRequest,
) -> Result<(), EncryptionSettingsError>
pub async fn initialize_org_crypto( &self, req: InitOrgCryptoRequest, ) -> Result<(), EncryptionSettingsError>
Initialization method for the organization crypto. Needs to be called after
initialize_user_crypto
but before any other crypto operations.
Sourcepub fn make_key_pair(
&self,
user_key: B64,
) -> Result<MakeKeyPairResponse, CryptoError>
pub fn make_key_pair( &self, user_key: B64, ) -> Result<MakeKeyPairResponse, CryptoError>
Generates a new key pair and encrypts the private key with the provided user key. Crypto initialization not required.
Sourcepub fn verify_asymmetric_keys(
&self,
request: VerifyAsymmetricKeysRequest,
) -> Result<VerifyAsymmetricKeysResponse, CryptoError>
pub fn verify_asymmetric_keys( &self, request: VerifyAsymmetricKeysRequest, ) -> Result<VerifyAsymmetricKeysResponse, CryptoError>
Verifies a user’s asymmetric keys by decrypting the private key with the provided user key. Returns if the private key is decryptable and if it is a valid matching key. Crypto initialization not required.
Sourcepub fn make_keys_for_user_crypto_v2(
&self,
) -> Result<UserCryptoV2KeysResponse, StatefulCryptoError>
pub fn make_keys_for_user_crypto_v2( &self, ) -> Result<UserCryptoV2KeysResponse, StatefulCryptoError>
Makes a new signing key pair and signs the public key for the user
Sourcepub fn get_v2_rotated_account_keys(
&self,
) -> Result<UserCryptoV2KeysResponse, StatefulCryptoError>
pub fn get_v2_rotated_account_keys( &self, ) -> Result<UserCryptoV2KeysResponse, StatefulCryptoError>
Creates a rotated set of account keys for the current state
Sourcepub fn make_update_kdf(
&self,
password: String,
kdf: Kdf,
) -> Result<UpdateKdfResponse, CryptoClientError>
pub fn make_update_kdf( &self, password: String, kdf: Kdf, ) -> Result<UpdateKdfResponse, CryptoClientError>
Create the data necessary to update the user’s kdf settings. The user’s encryption key is re-encrypted for the password under the new kdf settings. This returns the re-encrypted user key and the new password hash but does not update sdk state.
Sourcepub fn enroll_pin(
&self,
pin: String,
) -> Result<EnrollPinResponse, CryptoClientError>
pub fn enroll_pin( &self, pin: String, ) -> Result<EnrollPinResponse, CryptoClientError>
Protects the current user key with the provided PIN. The result can be stored and later
used to initialize another client instance by using the PIN and the PIN key with
initialize_user_crypto
.
Sourcepub fn enroll_pin_with_encrypted_pin(
&self,
encrypted_pin: String,
) -> Result<EnrollPinResponse, CryptoClientError>
pub fn enroll_pin_with_encrypted_pin( &self, encrypted_pin: String, ) -> Result<EnrollPinResponse, CryptoClientError>
Protects the current user key with the provided PIN. The result can be stored and later
used to initialize another client instance by using the PIN and the PIN key with
initialize_user_crypto
. The provided pin is encrypted with the user key.
Sourcepub fn unseal_password_protected_key_envelope(
&self,
pin: String,
envelope: PasswordProtectedKeyEnvelope,
) -> Result<Vec<u8>, CryptoClientError>
pub fn unseal_password_protected_key_envelope( &self, pin: String, envelope: PasswordProtectedKeyEnvelope, ) -> Result<Vec<u8>, CryptoClientError>
Decrypts a PasswordProtectedKeyEnvelope
, returning the user key, if successful.
This is a stop-gap solution, until initialization of the SDK is used.
Source§impl CryptoClient
impl CryptoClient
Sourcepub async fn get_user_encryption_key(&self) -> Result<B64, CryptoClientError>
pub async fn get_user_encryption_key(&self) -> Result<B64, CryptoClientError>
Get the uses’s decrypted encryption key. Note: It’s very important to keep this key safe, as it can be used to decrypt all of the user’s data
Sourcepub fn make_update_password(
&self,
new_password: String,
) -> Result<UpdatePasswordResponse, CryptoClientError>
pub fn make_update_password( &self, new_password: String, ) -> Result<UpdatePasswordResponse, CryptoClientError>
Create the data necessary to update the user’s password. The user’s encryption key is re-encrypted with the new password. This returns the new encrypted user key and the new password hash but does not update sdk state.
Sourcepub fn derive_pin_key(
&self,
pin: String,
) -> Result<DerivePinKeyResponse, CryptoClientError>
pub fn derive_pin_key( &self, pin: String, ) -> Result<DerivePinKeyResponse, CryptoClientError>
Generates a PIN protected user key from the provided PIN. The result can be stored and later
used to initialize another client instance by using the PIN and the PIN key with
initialize_user_crypto
.
Sourcepub fn derive_pin_user_key(
&self,
encrypted_pin: EncString,
) -> Result<EncString, CryptoClientError>
pub fn derive_pin_user_key( &self, encrypted_pin: EncString, ) -> Result<EncString, CryptoClientError>
Derives the pin protected user key from encrypted pin. Used when pin requires master password on first unlock.
Sourcepub fn enroll_admin_password_reset(
&self,
public_key: B64,
) -> Result<UnsignedSharedKey, EnrollAdminPasswordResetError>
pub fn enroll_admin_password_reset( &self, public_key: B64, ) -> Result<UnsignedSharedKey, EnrollAdminPasswordResetError>
Prepares the account for being enrolled in the admin password reset feature. This encrypts the users UserKey with the organization’s public key.
Sourcepub fn derive_key_connector(
&self,
request: DeriveKeyConnectorRequest,
) -> Result<B64, DeriveKeyConnectorError>
pub fn derive_key_connector( &self, request: DeriveKeyConnectorRequest, ) -> Result<B64, DeriveKeyConnectorError>
Derive the master key for migrating to the key connector
Trait Implementations§
Source§impl From<CryptoClient> for JsValue
impl From<CryptoClient> for JsValue
Source§fn from(value: CryptoClient) -> JsValue
fn from(value: CryptoClient) -> JsValue
Source§impl FromWasmAbi for CryptoClient
impl FromWasmAbi for CryptoClient
Source§impl IntoWasmAbi for CryptoClient
impl IntoWasmAbi for CryptoClient
Source§impl LongRefFromWasmAbi for CryptoClient
impl LongRefFromWasmAbi for CryptoClient
Source§type Anchor = RcRef<CryptoClient>
type Anchor = RcRef<CryptoClient>
RefFromWasmAbi::Anchor
Source§unsafe fn long_ref_from_abi(
js: <CryptoClient as LongRefFromWasmAbi>::Abi,
) -> <CryptoClient as LongRefFromWasmAbi>::Anchor
unsafe fn long_ref_from_abi( js: <CryptoClient as LongRefFromWasmAbi>::Abi, ) -> <CryptoClient as LongRefFromWasmAbi>::Anchor
RefFromWasmAbi::ref_from_abi
Source§impl OptionFromWasmAbi for CryptoClient
impl OptionFromWasmAbi for CryptoClient
Source§fn is_none(abi: &<CryptoClient as FromWasmAbi>::Abi) -> bool
fn is_none(abi: &<CryptoClient as FromWasmAbi>::Abi) -> bool
None
, and otherwise it will be passed to
FromWasmAbi
.Source§impl OptionIntoWasmAbi for CryptoClient
impl OptionIntoWasmAbi for CryptoClient
Source§fn none() -> <CryptoClient as IntoWasmAbi>::Abi
fn none() -> <CryptoClient as IntoWasmAbi>::Abi
None
branch of this option. Read moreSource§impl RefFromWasmAbi for CryptoClient
impl RefFromWasmAbi for CryptoClient
Source§type Anchor = RcRef<CryptoClient>
type Anchor = RcRef<CryptoClient>
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§unsafe fn ref_from_abi(
js: <CryptoClient as RefFromWasmAbi>::Abi,
) -> <CryptoClient as RefFromWasmAbi>::Anchor
unsafe fn ref_from_abi( js: <CryptoClient as RefFromWasmAbi>::Abi, ) -> <CryptoClient as RefFromWasmAbi>::Anchor
Source§impl RefMutFromWasmAbi for CryptoClient
impl RefMutFromWasmAbi for CryptoClient
Source§type Anchor = RcRefMut<CryptoClient>
type Anchor = RcRefMut<CryptoClient>
RefFromWasmAbi::Anchor
Source§unsafe fn ref_mut_from_abi(
js: <CryptoClient as RefMutFromWasmAbi>::Abi,
) -> <CryptoClient as RefMutFromWasmAbi>::Anchor
unsafe fn ref_mut_from_abi( js: <CryptoClient as RefMutFromWasmAbi>::Abi, ) -> <CryptoClient as RefMutFromWasmAbi>::Anchor
RefFromWasmAbi::ref_from_abi
Source§impl TryFromJsValue for CryptoClient
impl TryFromJsValue for CryptoClient
Source§fn try_from_js_value(
value: JsValue,
) -> Result<CryptoClient, <CryptoClient as TryFromJsValue>::Error>
fn try_from_js_value( value: JsValue, ) -> Result<CryptoClient, <CryptoClient as TryFromJsValue>::Error>
Source§impl VectorFromWasmAbi for CryptoClient
impl VectorFromWasmAbi for CryptoClient
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi( js: <CryptoClient as VectorFromWasmAbi>::Abi, ) -> Box<[CryptoClient]>
Source§impl VectorIntoWasmAbi for CryptoClient
impl VectorIntoWasmAbi for CryptoClient
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi( vector: Box<[CryptoClient]>, ) -> <CryptoClient as VectorIntoWasmAbi>::Abi
Auto Trait Implementations§
impl Freeze for CryptoClient
impl !RefUnwindSafe for CryptoClient
impl Send for CryptoClient
impl Sync for CryptoClient
impl Unpin for CryptoClient
impl !UnwindSafe for CryptoClient
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<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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt 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::Abi
Source§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
.