Skip to main content

bitwarden_api_api/apis/
web_authn_api.rs

1/*
2 * Bitwarden Internal API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: latest
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use std::sync::Arc;
12
13use async_trait::async_trait;
14#[cfg(feature = "mockall")]
15use mockall::automock;
16use reqwest;
17use serde::{Deserialize, Serialize, de::Error as _};
18
19use super::{Error, configuration};
20use crate::{
21    apis::{AuthRequired, ContentType, ResponseContent},
22    models,
23};
24
25#[cfg_attr(feature = "mockall", automock)]
26#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
27#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
28pub trait WebAuthnApi: Send + Sync {
29    /// POST /webauthn/assertion-options
30    async fn assertion_options<'a>(
31        &self,
32        secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
33    ) -> Result<models::WebAuthnLoginAssertionOptionsResponseModel, Error<AssertionOptionsError>>;
34
35    /// POST /webauthn/attestation-options
36    async fn attestation_options<'a>(
37        &self,
38        secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
39    ) -> Result<models::WebAuthnCredentialCreateOptionsResponseModel, Error<AttestationOptionsError>>;
40
41    /// POST /webauthn/{id}/delete
42    async fn delete<'a>(
43        &self,
44        id: uuid::Uuid,
45        secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
46    ) -> Result<(), Error<DeleteError>>;
47
48    /// GET /webauthn
49    async fn get(
50        &self,
51    ) -> Result<models::WebAuthnCredentialResponseModelListResponseModel, Error<GetError>>;
52
53    /// POST /webauthn
54    async fn post<'a>(
55        &self,
56        web_authn_login_credential_create_request_model: Option<
57            models::WebAuthnLoginCredentialCreateRequestModel,
58        >,
59    ) -> Result<models::WebAuthnCredentialResponseModel, Error<PostError>>;
60
61    /// PUT /webauthn
62    async fn update_credential<'a>(
63        &self,
64        web_authn_login_credential_update_request_model: Option<
65            models::WebAuthnLoginCredentialUpdateRequestModel,
66        >,
67    ) -> Result<(), Error<UpdateCredentialError>>;
68}
69
70pub struct WebAuthnApiClient {
71    configuration: Arc<configuration::Configuration>,
72}
73
74impl WebAuthnApiClient {
75    pub fn new(configuration: Arc<configuration::Configuration>) -> Self {
76        Self { configuration }
77    }
78}
79
80#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
81#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
82impl WebAuthnApi for WebAuthnApiClient {
83    async fn assertion_options<'a>(
84        &self,
85        secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
86    ) -> Result<models::WebAuthnLoginAssertionOptionsResponseModel, Error<AssertionOptionsError>>
87    {
88        let local_var_configuration = &self.configuration;
89
90        let local_var_client = &local_var_configuration.client;
91
92        let local_var_uri_str = format!(
93            "{}/webauthn/assertion-options",
94            local_var_configuration.base_path
95        );
96        let mut local_var_req_builder =
97            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
98
99        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
100        local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model);
101
102        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
103    }
104
105    async fn attestation_options<'a>(
106        &self,
107        secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
108    ) -> Result<models::WebAuthnCredentialCreateOptionsResponseModel, Error<AttestationOptionsError>>
109    {
110        let local_var_configuration = &self.configuration;
111
112        let local_var_client = &local_var_configuration.client;
113
114        let local_var_uri_str = format!(
115            "{}/webauthn/attestation-options",
116            local_var_configuration.base_path
117        );
118        let mut local_var_req_builder =
119            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
120
121        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
122        local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model);
123
124        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
125    }
126
127    async fn delete<'a>(
128        &self,
129        id: uuid::Uuid,
130        secret_verification_request_model: Option<models::SecretVerificationRequestModel>,
131    ) -> Result<(), Error<DeleteError>> {
132        let local_var_configuration = &self.configuration;
133
134        let local_var_client = &local_var_configuration.client;
135
136        let local_var_uri_str = format!(
137            "{}/webauthn/{id}/delete",
138            local_var_configuration.base_path,
139            id = id
140        );
141        let mut local_var_req_builder =
142            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
143
144        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
145        local_var_req_builder = local_var_req_builder.json(&secret_verification_request_model);
146
147        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
148    }
149
150    async fn get(
151        &self,
152    ) -> Result<models::WebAuthnCredentialResponseModelListResponseModel, Error<GetError>> {
153        let local_var_configuration = &self.configuration;
154
155        let local_var_client = &local_var_configuration.client;
156
157        let local_var_uri_str = format!("{}/webauthn", local_var_configuration.base_path);
158        let mut local_var_req_builder =
159            local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
160
161        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
162
163        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
164    }
165
166    async fn post<'a>(
167        &self,
168        web_authn_login_credential_create_request_model: Option<
169            models::WebAuthnLoginCredentialCreateRequestModel,
170        >,
171    ) -> Result<models::WebAuthnCredentialResponseModel, Error<PostError>> {
172        let local_var_configuration = &self.configuration;
173
174        let local_var_client = &local_var_configuration.client;
175
176        let local_var_uri_str = format!("{}/webauthn", local_var_configuration.base_path);
177        let mut local_var_req_builder =
178            local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
179
180        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
181        local_var_req_builder =
182            local_var_req_builder.json(&web_authn_login_credential_create_request_model);
183
184        bitwarden_api_base::process_with_json_response(local_var_req_builder).await
185    }
186
187    async fn update_credential<'a>(
188        &self,
189        web_authn_login_credential_update_request_model: Option<
190            models::WebAuthnLoginCredentialUpdateRequestModel,
191        >,
192    ) -> Result<(), Error<UpdateCredentialError>> {
193        let local_var_configuration = &self.configuration;
194
195        let local_var_client = &local_var_configuration.client;
196
197        let local_var_uri_str = format!("{}/webauthn", local_var_configuration.base_path);
198        let mut local_var_req_builder =
199            local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());
200
201        local_var_req_builder = local_var_req_builder.with_extension(AuthRequired::Bearer);
202        local_var_req_builder =
203            local_var_req_builder.json(&web_authn_login_credential_update_request_model);
204
205        bitwarden_api_base::process_with_empty_response(local_var_req_builder).await
206    }
207}
208
209/// struct for typed errors of method [`WebAuthnApi::assertion_options`]
210#[derive(Debug, Clone, Serialize, Deserialize)]
211#[serde(untagged)]
212pub enum AssertionOptionsError {
213    UnknownValue(serde_json::Value),
214}
215/// struct for typed errors of method [`WebAuthnApi::attestation_options`]
216#[derive(Debug, Clone, Serialize, Deserialize)]
217#[serde(untagged)]
218pub enum AttestationOptionsError {
219    UnknownValue(serde_json::Value),
220}
221/// struct for typed errors of method [`WebAuthnApi::delete`]
222#[derive(Debug, Clone, Serialize, Deserialize)]
223#[serde(untagged)]
224pub enum DeleteError {
225    UnknownValue(serde_json::Value),
226}
227/// struct for typed errors of method [`WebAuthnApi::get`]
228#[derive(Debug, Clone, Serialize, Deserialize)]
229#[serde(untagged)]
230pub enum GetError {
231    UnknownValue(serde_json::Value),
232}
233/// struct for typed errors of method [`WebAuthnApi::post`]
234#[derive(Debug, Clone, Serialize, Deserialize)]
235#[serde(untagged)]
236pub enum PostError {
237    UnknownValue(serde_json::Value),
238}
239/// struct for typed errors of method [`WebAuthnApi::update_credential`]
240#[derive(Debug, Clone, Serialize, Deserialize)]
241#[serde(untagged)]
242pub enum UpdateCredentialError {
243    UnknownValue(serde_json::Value),
244}