pub struct AttachmentsClient {
pub(crate) key_store: KeyStore<KeySlotIds>,
pub(crate) api_configurations: Arc<ApiConfigurations>,
pub(crate) repository: Option<Arc<dyn Repository<Cipher>>>,
pub(crate) http_client: Client,
}Expand description
Wrapper for attachment-specific cipher operations.
Fields§
§key_store: KeyStore<KeySlotIds>§api_configurations: Arc<ApiConfigurations>§repository: Option<Arc<dyn Repository<Cipher>>>§http_client: ClientImplementations§
Source§impl AttachmentsClient
impl AttachmentsClient
Sourcepub async fn create_attachment(
&self,
cipher_id: CipherId,
request: CreateAttachmentRequest,
) -> Result<CreatedAttachment, CipherCreateAttachmentError>
pub async fn create_attachment( &self, cipher_id: CipherId, request: CreateAttachmentRequest, ) -> Result<CreatedAttachment, CipherCreateAttachmentError>
Creates a new attachment slot on the server and updates local repository state with the merged cipher returned by the server.
The caller must upload the encrypted bytes to CreatedAttachment::upload_url
using the transport in CreatedAttachment::file_upload_type.
If a later step fails after slot creation, the SDK best-effort deletes the orphaned slot and returns the original error.
Source§impl AttachmentsClient
impl AttachmentsClient
Sourcepub async fn delete_attachment(
&self,
cipher_id: CipherId,
attachment_id: String,
) -> Result<Cipher, CipherDeleteAttachmentError>
pub async fn delete_attachment( &self, cipher_id: CipherId, attachment_id: String, ) -> Result<Cipher, CipherDeleteAttachmentError>
Deletes an attachment from a cipher, and updates the local repository with the new cipher data returned from the API.
Source§impl AttachmentsClient
impl AttachmentsClient
Sourcepub async fn get_attachment_download_url(
&self,
cipher_id: CipherId,
attachment_id: String,
emergency_access_id: Option<String>,
) -> Result<String, CipherGetAttachmentDownloadUrlError>
pub async fn get_attachment_download_url( &self, cipher_id: CipherId, attachment_id: String, emergency_access_id: Option<String>, ) -> Result<String, CipherGetAttachmentDownloadUrlError>
Returns the attachment download URL.
With emergency_access_id, uses the emergency-access endpoint and never falls back.
Otherwise uses the cipher endpoint and falls back to the local repository on 404.
Source§impl AttachmentsClient
impl AttachmentsClient
Sourceasync fn get_emergency_access_attachment_download_url(
&self,
emergency_access_id: &str,
cipher_id: CipherId,
attachment_id: &str,
) -> Result<String, CipherGetAttachmentDownloadUrlError>
async fn get_emergency_access_attachment_download_url( &self, emergency_access_id: &str, cipher_id: CipherId, attachment_id: &str, ) -> Result<String, CipherGetAttachmentDownloadUrlError>
Fetches an attachment download URL via the emergency-access endpoint.
Source§impl AttachmentsClient
impl AttachmentsClient
Sourcepub async fn renew_file_upload_url(
&self,
cipher_id: CipherId,
attachment_id: String,
) -> Result<String, CipherRenewFileUploadUrlError>
pub async fn renew_file_upload_url( &self, cipher_id: CipherId, attachment_id: String, ) -> Result<String, CipherRenewFileUploadUrlError>
Returns a renewed upload URL for an attachment. Does not modify the attachment slot.
Source§impl AttachmentsClient
impl AttachmentsClient
Sourcepub async fn upgrade_attachment(
&self,
cipher_id: CipherId,
attachment_id: String,
) -> Result<CipherView, CipherUpgradeAttachmentError>
pub async fn upgrade_attachment( &self, cipher_id: CipherId, attachment_id: String, ) -> Result<CipherView, CipherUpgradeAttachmentError>
Upgrades a legacy v1 attachment to CipherKey(AttachmentKey(Contents)).
Downloads and re-encrypts the attachment, creates a new slot, uploads the new bytes, then deletes the old attachment. If the upload fails, it tries to delete the new slot before returning the error. Returns the decrypted cipher view.
Source§impl AttachmentsClient
impl AttachmentsClient
Sourceasync fn download_and_reencrypt(
&self,
legacy_key_slot: SymmetricKeySlotId,
new_attachment_key: SymmetricCryptoKey,
plaintext_size_hint: u64,
download_url: &str,
) -> Result<Vec<u8>, CipherUpgradeAttachmentError>
async fn download_and_reencrypt( &self, legacy_key_slot: SymmetricKeySlotId, new_attachment_key: SymmetricCryptoKey, plaintext_size_hint: u64, download_url: &str, ) -> Result<Vec<u8>, CipherUpgradeAttachmentError>
Downloads the legacy ciphertext and re-encrypts it into memory.
Wasm reqwest only supports buffered request bodies so the output is buffered.
Sourceasync fn upload_reencrypted(
&self,
cipher_id: CipherId,
created: &CreatedAttachment,
reencrypted: Vec<u8>,
) -> Result<(), CipherUpgradeAttachmentError>
async fn upload_reencrypted( &self, cipher_id: CipherId, created: &CreatedAttachment, reencrypted: Vec<u8>, ) -> Result<(), CipherUpgradeAttachmentError>
Uploads the re-encrypted bytes to the newly created attachment slot.
Transport depends on AttachmentFileUploadType: Azure PUTs to the presigned blob URL
on the unauthenticated client (the SAS token in the URL authorizes it; a Bearer token must
not be attached), while Direct POSTs to the authenticated Bitwarden API endpoint
(POST /ciphers/{id}/attachment/{attachmentId}) using the configured API client.
Source§impl AttachmentsClient
impl AttachmentsClient
Sourcepub fn admin(&self) -> AttachmentAdminClient
pub fn admin(&self) -> AttachmentAdminClient
Returns a new client for performing attachment admin operations. Uses the admin server API endpoints and does not modify local state.
pub fn decrypt_buffer( &self, cipher: Cipher, attachment: AttachmentView, encrypted_buffer: &[u8], ) -> Result<Vec<u8>, DecryptError>
Source§impl AttachmentsClient
impl AttachmentsClient
pub fn encrypt_buffer( &self, cipher: Cipher, attachment: AttachmentView, buffer: &[u8], ) -> Result<AttachmentEncryptResult, EncryptError>
pub fn encrypt_file( &self, cipher: Cipher, attachment: AttachmentView, decrypted_file_path: &Path, encrypted_file_path: &Path, ) -> Result<Attachment, EncryptFileError>
pub fn decrypt_file( &self, cipher: Cipher, attachment: AttachmentView, encrypted_file_path: &Path, decrypted_file_path: &Path, ) -> Result<(), DecryptFileError>
Trait Implementations§
Source§impl From<AttachmentsClient> for JsValue
impl From<AttachmentsClient> for JsValue
Source§fn from(value: AttachmentsClient) -> Self
fn from(value: AttachmentsClient) -> Self
Source§impl FromClient for AttachmentsClient
impl FromClient for AttachmentsClient
Source§fn from_client(client: &Client) -> Self
fn from_client(client: &Client) -> Self
Client] reference.Source§impl FromWasm for AttachmentsClient
Available on crate feature wasm only.
impl FromWasm for AttachmentsClient
wasm only.Source§impl FromWasmAbi for AttachmentsClient
impl FromWasmAbi for AttachmentsClient
Source§impl IntoWasmAbi for AttachmentsClient
impl IntoWasmAbi for AttachmentsClient
Source§type Abi = WasmPtr<WasmRefCell<AttachmentsClient>>
type Abi = WasmPtr<WasmRefCell<AttachmentsClient>>
Source§impl LongRefFromWasmAbi for AttachmentsClient
impl LongRefFromWasmAbi for AttachmentsClient
Source§type Abi = WasmPtr<WasmRefCell<AttachmentsClient>>
type Abi = WasmPtr<WasmRefCell<AttachmentsClient>>
RefFromWasmAbi::AbiSource§type Anchor = RcRef<AttachmentsClient>
type Anchor = RcRef<AttachmentsClient>
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 RefFromWasmAbi for AttachmentsClient
impl RefFromWasmAbi for AttachmentsClient
Source§type Abi = WasmPtr<WasmRefCell<AttachmentsClient>>
type Abi = WasmPtr<WasmRefCell<AttachmentsClient>>
Self are recovered from.Source§type Anchor = RcRef<AttachmentsClient>
type Anchor = RcRef<AttachmentsClient>
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 AttachmentsClient
impl RefMutFromWasmAbi for AttachmentsClient
Source§type Abi = WasmPtr<WasmRefCell<AttachmentsClient>>
type Abi = WasmPtr<WasmRefCell<AttachmentsClient>>
RefFromWasmAbi::AbiSource§type Anchor = RcRefMut<AttachmentsClient>
type Anchor = RcRefMut<AttachmentsClient>
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 AttachmentsClient
impl SupportsInstanceProperty for AttachmentsClient
impl SupportsStaticProperty for AttachmentsClient
Source§impl ToWasm for AttachmentsClient
Available on crate feature wasm only.
impl ToWasm for AttachmentsClient
wasm only.Source§impl TryFromJsValue for AttachmentsClient
impl TryFromJsValue for AttachmentsClient
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 VectorFromWasmAbi for AttachmentsClient
impl VectorFromWasmAbi for AttachmentsClient
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[AttachmentsClient]>
Source§impl VectorIntoWasmAbi for AttachmentsClient
impl VectorIntoWasmAbi for AttachmentsClient
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[AttachmentsClient]>) -> Self::Abi
Source§impl WasmDescribe for AttachmentsClient
impl WasmDescribe for AttachmentsClient
Auto Trait Implementations§
impl !RefUnwindSafe for AttachmentsClient
impl !UnwindSafe for AttachmentsClient
impl Freeze for AttachmentsClient
impl Send for AttachmentsClient
impl Sync for AttachmentsClient
impl Unpin for AttachmentsClient
impl UnsafeUnpin for AttachmentsClient
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
§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.