pub struct VaultClient {
http: Client,
download_http: Client,
base: String,
base_url: Url,
device_id: String,
}Fields§
§http: Client§download_http: Client§base: String§base_url: Url§device_id: StringImplementations§
Source§impl VaultClient
impl VaultClient
Sourcepub fn new(base: &str) -> Result<Self, VaultError>
pub fn new(base: &str) -> Result<Self, VaultError>
Build a client for base, which may carry a trailing slash. The
workspace’s production session builds its clients through
VaultClient::with_clients so the machine’s TLS roots and
https_only apply; this constructor is for local servers and tests.
Sourcepub fn with_clients(
base: &str,
http: Client,
download_http: Client,
) -> Result<Self, VaultError>
pub fn with_clients( base: &str, http: Client, download_http: Client, ) -> Result<Self, VaultError>
Build a client over callers’ own HTTP clients. The download client is separate because its read and total bounds are longer than an API call’s.
fn unauth(&self, method: Method, path: &str) -> RequestBuilder
fn authed(&self, method: Method, path: &str, token: &str) -> RequestBuilder
Sourceasync fn send_body(
&self,
resp: Response,
fields: ErrorFields,
) -> Result<Zeroizing<String>, VaultError>
async fn send_body( &self, resp: Response, fields: ErrorFields, ) -> Result<Zeroizing<String>, VaultError>
Read one response body, mapping a non-2xx status to its named error.
The body is zeroized on every path: a token response’s body carries
the access and refresh tokens. fields scopes which error fields may
be surfaced, so the identity route never reads the API’s pointers.
Sourceasync fn send_json(&self, resp: Response) -> Result<Value, VaultError>
async fn send_json(&self, resp: Response) -> Result<Value, VaultError>
Read one response as JSON. An empty success body is Value::Null.
Sourceasync fn send_typed<T: DeserializeOwned>(
&self,
resp: Response,
) -> Result<T, VaultError>
async fn send_typed<T: DeserializeOwned>( &self, resp: Response, ) -> Result<T, VaultError>
Parse one response straight into T, zeroizing the raw text after the
parse rather than leaving a token-bearing Value to drop unzeroized.
Sourceasync fn send_typed_oauth<T: DeserializeOwned>(
&self,
resp: Response,
) -> Result<T, VaultError>
async fn send_typed_oauth<T: DeserializeOwned>( &self, resp: Response, ) -> Result<T, VaultError>
The identity endpoints’ own parse: an error there is read through the OAuth pair only, never the API’s wider pointer set.
async fn send_typed_with<T: DeserializeOwned>( &self, resp: Response, fields: ErrorFields, ) -> Result<T, VaultError>
Sourcepub async fn prelogin(&self, email: &str) -> Result<Prelogin, VaultError>
pub async fn prelogin(&self, email: &str) -> Result<Prelogin, VaultError>
POST /identity/accounts/prelogin, which is where Vaultwarden mounts it
(the /api/accounts/prelogin forms answer 404).
Sourcepub async fn login_password(
&self,
email: &str,
master_password_hash: &str,
two_factor: Option<&TwoFactorCode>,
) -> Result<TokenResponse, VaultError>
pub async fn login_password( &self, email: &str, master_password_hash: &str, two_factor: Option<&TwoFactorCode>, ) -> Result<TokenResponse, VaultError>
POST /identity/connect/token with the password grant.
Sourcepub async fn refresh(
&self,
refresh_token: &str,
) -> Result<TokenResponse, VaultError>
pub async fn refresh( &self, refresh_token: &str, ) -> Result<TokenResponse, VaultError>
POST /identity/connect/token with the refresh grant.
Sourcepub async fn sync(&self, token: &str) -> Result<SyncData, VaultError>
pub async fn sync(&self, token: &str) -> Result<SyncData, VaultError>
GET /api/sync: the profile and every cipher and folder.
pub async fn get_cipher( &self, token: &str, id: &str, ) -> Result<Value, VaultError>
pub async fn create_cipher( &self, token: &str, body: &Value, ) -> Result<Value, VaultError>
pub async fn update_cipher( &self, token: &str, id: &str, body: &Value, ) -> Result<Value, VaultError>
Sourcepub async fn trash_cipher(
&self,
token: &str,
id: &str,
) -> Result<Value, VaultError>
pub async fn trash_cipher( &self, token: &str, id: &str, ) -> Result<Value, VaultError>
The soft delete. POST /api/ciphers/{id}/delete and
DELETE /api/ciphers/{id} are permanent and are never called here.
pub async fn restore_cipher( &self, token: &str, id: &str, ) -> Result<Value, VaultError>
pub async fn list_folders(&self, token: &str) -> Result<Vec<Folder>, VaultError>
pub async fn create_folder( &self, token: &str, name: &str, ) -> Result<Value, VaultError>
pub async fn update_folder( &self, token: &str, id: &str, name: &str, ) -> Result<Value, VaultError>
pub async fn delete_folder( &self, token: &str, id: &str, ) -> Result<Value, VaultError>
Sourcepub async fn create_attachment_slot(
&self,
token: &str,
cipher_id: &str,
body: &Value,
) -> Result<Value, VaultError>
pub async fn create_attachment_slot( &self, token: &str, cipher_id: &str, body: &Value, ) -> Result<Value, VaultError>
Create the v2 attachment slot, which records the wrapped key and the declared size the server later checks against the upload.
Sourcepub async fn upload_attachment(
&self,
token: &str,
cipher_id: &str,
attachment_id: &str,
data: &[u8],
) -> Result<Value, VaultError>
pub async fn upload_attachment( &self, token: &str, cipher_id: &str, attachment_id: &str, data: &[u8], ) -> Result<Value, VaultError>
Upload the encrypted blob. Exactly one data part: v2 stored the key at
slot time, and a second part leaks multipart boundary bytes into the
stored blob through the server’s parser.
Sourcepub async fn get_attachment_meta(
&self,
token: &str,
cipher_id: &str,
attachment_id: &str,
) -> Result<AttachmentMeta, VaultError>
pub async fn get_attachment_meta( &self, token: &str, cipher_id: &str, attachment_id: &str, ) -> Result<AttachmentMeta, VaultError>
The download metadata: the wrapped key and the signed URL.
Sourcepub async fn delete_attachment(
&self,
token: &str,
cipher_id: &str,
attachment_id: &str,
) -> Result<Value, VaultError>
pub async fn delete_attachment( &self, token: &str, cipher_id: &str, attachment_id: &str, ) -> Result<Value, VaultError>
Delete one attachment. Used only by a replace, which names the old and the new file in one approval; it is never its own agent-callable tool.
Sourcepub async fn download_attachment(
&self,
token: &str,
url: &str,
max_bytes: u64,
) -> Result<Vec<u8>, VaultError>
pub async fn download_attachment( &self, token: &str, url: &str, max_bytes: u64, ) -> Result<Vec<u8>, VaultError>
Download a signed attachment URL. The bytes are opaque ciphertext, so the
request asks the proxy not to re-encode them. A relative URL is the API
route and takes the bearer; an absolute one is signed and does not, and
may only name this vault’s own host. max_bytes bounds the body while it
streams, so an endless response cannot buffer past the cap.
Auto Trait Implementations§
impl !RefUnwindSafe for VaultClient
impl !UnwindSafe for VaultClient
impl Freeze for VaultClient
impl Send for VaultClient
impl Sync for VaultClient
impl Unpin for VaultClient
impl UnsafeUnpin for VaultClient
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> 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