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.
async fn finalize_create( &self, response: AttachmentUploadDataResponseModel, existing_cipher: Option<Cipher>, cipher_id: CipherId, as_admin: bool, ) -> Result<CreatedAttachment, CipherCreateAttachmentError>
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 FromWasmAbi for AttachmentsClient
impl FromWasmAbi for AttachmentsClient
Source§impl IntoWasmAbi for AttachmentsClient
impl IntoWasmAbi for AttachmentsClient
Source§impl RefFromWasmAbi for AttachmentsClient
impl RefFromWasmAbi for AttachmentsClient
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 TryFromJsValue for AttachmentsClient
impl TryFromJsValue for AttachmentsClient
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
impl SupportsConstructor for AttachmentsClient
impl SupportsInstanceProperty for AttachmentsClient
impl SupportsStaticProperty for AttachmentsClient
Auto Trait Implementations§
impl Freeze for AttachmentsClient
impl !RefUnwindSafe for AttachmentsClient
impl Send for AttachmentsClient
impl Sync for AttachmentsClient
impl Unpin for AttachmentsClient
impl UnsafeUnpin for AttachmentsClient
impl !UnwindSafe 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<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::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.