Skip to main content

ory_kratos_client_wasm/wasm_apis/
frontend_api.rs

1/*
2 * Ory Identities API
3 *
4 * This is the API specification for Ory Identities with features such as registration, login, recovery, account verification, profile settings, password reset, identity management, session management, email and sms delivery, and more.
5 *
6 * The version of the OpenAPI document: v26.2.0
7 * Contact: office@ory.sh
8 * Generated by: https://openapi-generator.tech (via tools/regen-fetch-apis, see task #23)
9 */
10
11use super::{AddQuery, Error, configuration};
12use crate::models;
13use gloo_utils::format::JsValueSerdeExt;
14use serde::{Deserialize, Serialize};
15use wasm_bindgen::prelude::*;
16
17/// struct for typed errors of method [`create_browser_login_flow`]
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(untagged)]
20pub enum CreateBrowserLoginFlowError {
21    Status400(models::ErrorGeneric),
22    DefaultResponse(models::ErrorGeneric),
23    UnknownValue(serde_json::Value),
24}
25
26/// struct for typed errors of method [`create_browser_logout_flow`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum CreateBrowserLogoutFlowError {
30    Status400(models::ErrorGeneric),
31    Status401(models::ErrorGeneric),
32    Status500(models::ErrorGeneric),
33    UnknownValue(serde_json::Value),
34}
35
36/// struct for typed errors of method [`create_browser_recovery_flow`]
37#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum CreateBrowserRecoveryFlowError {
40    Status400(models::ErrorGeneric),
41    DefaultResponse(models::ErrorGeneric),
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`create_browser_registration_flow`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum CreateBrowserRegistrationFlowError {
49    DefaultResponse(models::ErrorGeneric),
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`create_browser_settings_flow`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum CreateBrowserSettingsFlowError {
57    Status400(models::ErrorGeneric),
58    Status401(models::ErrorGeneric),
59    Status403(models::ErrorGeneric),
60    DefaultResponse(models::ErrorGeneric),
61    UnknownValue(serde_json::Value),
62}
63
64/// struct for typed errors of method [`create_browser_verification_flow`]
65#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(untagged)]
67pub enum CreateBrowserVerificationFlowError {
68    DefaultResponse(models::ErrorGeneric),
69    UnknownValue(serde_json::Value),
70}
71
72/// struct for typed errors of method [`create_fedcm_flow`]
73#[derive(Debug, Clone, Serialize, Deserialize)]
74#[serde(untagged)]
75pub enum CreateFedcmFlowError {
76    Status400(models::ErrorGeneric),
77    DefaultResponse(models::ErrorGeneric),
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`create_native_login_flow`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum CreateNativeLoginFlowError {
85    Status400(models::ErrorGeneric),
86    DefaultResponse(models::ErrorGeneric),
87    UnknownValue(serde_json::Value),
88}
89
90/// struct for typed errors of method [`create_native_recovery_flow`]
91#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum CreateNativeRecoveryFlowError {
94    Status400(models::ErrorGeneric),
95    DefaultResponse(models::ErrorGeneric),
96    UnknownValue(serde_json::Value),
97}
98
99/// struct for typed errors of method [`create_native_registration_flow`]
100#[derive(Debug, Clone, Serialize, Deserialize)]
101#[serde(untagged)]
102pub enum CreateNativeRegistrationFlowError {
103    Status400(models::ErrorGeneric),
104    DefaultResponse(models::ErrorGeneric),
105    UnknownValue(serde_json::Value),
106}
107
108/// struct for typed errors of method [`create_native_settings_flow`]
109#[derive(Debug, Clone, Serialize, Deserialize)]
110#[serde(untagged)]
111pub enum CreateNativeSettingsFlowError {
112    Status400(models::ErrorGeneric),
113    DefaultResponse(models::ErrorGeneric),
114    UnknownValue(serde_json::Value),
115}
116
117/// struct for typed errors of method [`create_native_verification_flow`]
118#[derive(Debug, Clone, Serialize, Deserialize)]
119#[serde(untagged)]
120pub enum CreateNativeVerificationFlowError {
121    Status400(models::ErrorGeneric),
122    DefaultResponse(models::ErrorGeneric),
123    UnknownValue(serde_json::Value),
124}
125
126/// struct for typed errors of method [`disable_my_other_sessions`]
127#[derive(Debug, Clone, Serialize, Deserialize)]
128#[serde(untagged)]
129pub enum DisableMyOtherSessionsError {
130    Status400(models::ErrorGeneric),
131    Status401(models::ErrorGeneric),
132    DefaultResponse(models::ErrorGeneric),
133    UnknownValue(serde_json::Value),
134}
135
136/// struct for typed errors of method [`disable_my_session`]
137#[derive(Debug, Clone, Serialize, Deserialize)]
138#[serde(untagged)]
139pub enum DisableMySessionError {
140    Status400(models::ErrorGeneric),
141    Status401(models::ErrorGeneric),
142    DefaultResponse(models::ErrorGeneric),
143    UnknownValue(serde_json::Value),
144}
145
146/// struct for typed errors of method [`exchange_session_token`]
147#[derive(Debug, Clone, Serialize, Deserialize)]
148#[serde(untagged)]
149pub enum ExchangeSessionTokenError {
150    Status403(models::ErrorGeneric),
151    Status404(models::ErrorGeneric),
152    Status410(models::ErrorGeneric),
153    DefaultResponse(models::ErrorGeneric),
154    UnknownValue(serde_json::Value),
155}
156
157/// struct for typed errors of method [`get_flow_error`]
158#[derive(Debug, Clone, Serialize, Deserialize)]
159#[serde(untagged)]
160pub enum GetFlowErrorError {
161    Status403(models::ErrorGeneric),
162    Status404(models::ErrorGeneric),
163    Status500(models::ErrorGeneric),
164    UnknownValue(serde_json::Value),
165}
166
167/// struct for typed errors of method [`get_login_flow`]
168#[derive(Debug, Clone, Serialize, Deserialize)]
169#[serde(untagged)]
170pub enum GetLoginFlowError {
171    Status403(models::ErrorGeneric),
172    Status404(models::ErrorGeneric),
173    Status410(models::ErrorGeneric),
174    DefaultResponse(models::ErrorGeneric),
175    UnknownValue(serde_json::Value),
176}
177
178/// struct for typed errors of method [`get_recovery_flow`]
179#[derive(Debug, Clone, Serialize, Deserialize)]
180#[serde(untagged)]
181pub enum GetRecoveryFlowError {
182    Status404(models::ErrorGeneric),
183    Status410(models::ErrorGeneric),
184    DefaultResponse(models::ErrorGeneric),
185    UnknownValue(serde_json::Value),
186}
187
188/// struct for typed errors of method [`get_registration_flow`]
189#[derive(Debug, Clone, Serialize, Deserialize)]
190#[serde(untagged)]
191pub enum GetRegistrationFlowError {
192    Status403(models::ErrorGeneric),
193    Status404(models::ErrorGeneric),
194    Status410(models::ErrorGeneric),
195    DefaultResponse(models::ErrorGeneric),
196    UnknownValue(serde_json::Value),
197}
198
199/// struct for typed errors of method [`get_settings_flow`]
200#[derive(Debug, Clone, Serialize, Deserialize)]
201#[serde(untagged)]
202pub enum GetSettingsFlowError {
203    Status401(models::ErrorGeneric),
204    Status403(models::ErrorGeneric),
205    Status404(models::ErrorGeneric),
206    Status410(models::ErrorGeneric),
207    DefaultResponse(models::ErrorGeneric),
208    UnknownValue(serde_json::Value),
209}
210
211/// struct for typed errors of method [`get_verification_flow`]
212#[derive(Debug, Clone, Serialize, Deserialize)]
213#[serde(untagged)]
214pub enum GetVerificationFlowError {
215    Status403(models::ErrorGeneric),
216    Status404(models::ErrorGeneric),
217    DefaultResponse(models::ErrorGeneric),
218    UnknownValue(serde_json::Value),
219}
220
221/// struct for typed errors of method [`get_web_authn_java_script`]
222#[derive(Debug, Clone, Serialize, Deserialize)]
223#[serde(untagged)]
224pub enum GetWebAuthnJavaScriptError {
225    UnknownValue(serde_json::Value),
226}
227
228/// struct for typed errors of method [`list_my_sessions`]
229#[derive(Debug, Clone, Serialize, Deserialize)]
230#[serde(untagged)]
231pub enum ListMySessionsError {
232    Status400(models::ErrorGeneric),
233    Status401(models::ErrorGeneric),
234    DefaultResponse(models::ErrorGeneric),
235    UnknownValue(serde_json::Value),
236}
237
238/// struct for typed errors of method [`perform_native_logout`]
239#[derive(Debug, Clone, Serialize, Deserialize)]
240#[serde(untagged)]
241pub enum PerformNativeLogoutError {
242    Status400(models::ErrorGeneric),
243    DefaultResponse(models::ErrorGeneric),
244    UnknownValue(serde_json::Value),
245}
246
247/// struct for typed errors of method [`to_session`]
248#[derive(Debug, Clone, Serialize, Deserialize)]
249#[serde(untagged)]
250pub enum ToSessionError {
251    Status401(models::ErrorGeneric),
252    Status403(models::ErrorGeneric),
253    DefaultResponse(models::ErrorGeneric),
254    UnknownValue(serde_json::Value),
255}
256
257/// struct for typed errors of method [`update_fedcm_flow`]
258#[derive(Debug, Clone, Serialize, Deserialize)]
259#[serde(untagged)]
260pub enum UpdateFedcmFlowError {
261    Status400(models::LoginFlow),
262    Status410(models::ErrorGeneric),
263    Status422(models::ErrorBrowserLocationChangeRequired),
264    DefaultResponse(models::ErrorGeneric),
265    UnknownValue(serde_json::Value),
266}
267
268/// struct for typed errors of method [`update_login_flow`]
269#[derive(Debug, Clone, Serialize, Deserialize)]
270#[serde(untagged)]
271pub enum UpdateLoginFlowError {
272    Status400(models::LoginFlow),
273    Status410(models::ErrorGeneric),
274    Status422(models::ErrorBrowserLocationChangeRequired),
275    DefaultResponse(models::ErrorGeneric),
276    UnknownValue(serde_json::Value),
277}
278
279/// struct for typed errors of method [`update_logout_flow`]
280#[derive(Debug, Clone, Serialize, Deserialize)]
281#[serde(untagged)]
282pub enum UpdateLogoutFlowError {
283    DefaultResponse(models::ErrorGeneric),
284    UnknownValue(serde_json::Value),
285}
286
287/// struct for typed errors of method [`update_recovery_flow`]
288#[derive(Debug, Clone, Serialize, Deserialize)]
289#[serde(untagged)]
290pub enum UpdateRecoveryFlowError {
291    Status400(models::RecoveryFlow),
292    Status410(models::ErrorGeneric),
293    Status422(models::ErrorBrowserLocationChangeRequired),
294    DefaultResponse(models::ErrorGeneric),
295    UnknownValue(serde_json::Value),
296}
297
298/// struct for typed errors of method [`update_registration_flow`]
299#[derive(Debug, Clone, Serialize, Deserialize)]
300#[serde(untagged)]
301pub enum UpdateRegistrationFlowError {
302    Status400(models::RegistrationFlow),
303    Status410(models::ErrorGeneric),
304    Status422(models::ErrorBrowserLocationChangeRequired),
305    DefaultResponse(models::ErrorGeneric),
306    UnknownValue(serde_json::Value),
307}
308
309/// struct for typed errors of method [`update_settings_flow`]
310#[derive(Debug, Clone, Serialize, Deserialize)]
311#[serde(untagged)]
312pub enum UpdateSettingsFlowError {
313    Status400(models::SettingsFlow),
314    Status401(models::ErrorGeneric),
315    Status403(models::ErrorGeneric),
316    Status410(models::ErrorGeneric),
317    Status422(models::ErrorBrowserLocationChangeRequired),
318    DefaultResponse(models::ErrorGeneric),
319    UnknownValue(serde_json::Value),
320}
321
322/// struct for typed errors of method [`update_verification_flow`]
323#[derive(Debug, Clone, Serialize, Deserialize)]
324#[serde(untagged)]
325pub enum UpdateVerificationFlowError {
326    Status400(models::VerificationFlow),
327    Status410(models::ErrorGeneric),
328    DefaultResponse(models::ErrorGeneric),
329    UnknownValue(serde_json::Value),
330}
331
332/// This endpoint initializes a browser-based user login flow. This endpoint will set the appropriate cookies and anti-CSRF measures required for browser-based flows.  If this endpoint is opened as a link in the browser, it will be redirected to `selfservice.flows.login.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session exists already, the browser will be redirected to `urls.default_redirect_url` unless the query parameter `?refresh=true` was set.  If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `session_aal1_required`: Multi-factor auth (e.g. 2fa) was requested but the user has no session yet. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration!  The optional query parameter login_challenge is set when using Kratos with Hydra in an OAuth2 flow. See the oauth2_provider.url configuration option.  This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
333pub async fn create_browser_login_flow(
334    configuration: &configuration::Configuration,
335    refresh: Option<bool>,
336    aal: Option<&str>,
337    return_to: Option<&str>,
338    cookie: Option<&str>,
339    login_challenge: Option<&str>,
340    organization: Option<&str>,
341    via: Option<&str>,
342    identity_schema: Option<&str>,
343) -> Result<models::LoginFlow, Error<CreateBrowserLoginFlowError>> {
344    let mut uri_str = String::new();
345    uri_str.push_str(&configuration.base_path);
346    uri_str.push_str("/self-service/login/browser");
347    let client = web_sys::RequestInit::new();
348    client.set_method("GET");
349    client.set_mode(web_sys::RequestMode::Cors);
350    client.set_credentials(web_sys::RequestCredentials::Include);
351    let mut is_first_query: bool = true;
352    if let Some(ref str) = refresh {
353        uri_str.add_query(&mut is_first_query, "refresh=", &str.to_string());
354    }
355    if let Some(ref str) = aal {
356        uri_str.add_query(&mut is_first_query, "aal=", &str.to_string());
357    }
358    if let Some(ref str) = return_to {
359        uri_str.add_query(&mut is_first_query, "return_to=", &str.to_string());
360    }
361    if let Some(ref str) = login_challenge {
362        uri_str.add_query(&mut is_first_query, "login_challenge=", &str.to_string());
363    }
364    if let Some(ref str) = organization {
365        uri_str.add_query(&mut is_first_query, "organization=", &str.to_string());
366    }
367    if let Some(ref str) = via {
368        uri_str.add_query(&mut is_first_query, "via=", &str.to_string());
369    }
370    if let Some(ref str) = identity_schema {
371        uri_str.add_query(&mut is_first_query, "identity_schema=", &str.to_string());
372    }
373    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
374    if let Some(ref user_agent) = configuration.user_agent {
375        req_builder.headers().set("USER_AGENT", user_agent)?;
376    }
377    if let Some(cookie) = cookie {
378        req_builder.headers().set("Cookie", cookie)?;
379    }
380    req_builder.headers().set("Accept", "application/json")?;
381    let req = wasm_bindgen_futures::JsFuture::from(
382        web_sys::window()
383            .expect("Failed to get Window object")
384            .fetch_with_request(&req_builder),
385    )
386    .await?;
387    assert!(req.is_instance_of::<web_sys::Response>());
388    let resp: web_sys::Response = req
389        .dyn_into()
390        .expect("Failed to dynamically cast JsFuture into Response");
391    super::handle_response(resp).await
392}
393
394/// This endpoint initializes a browser-based user logout flow and a URL which can be used to log out the user.  This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...). For API clients you can call the `/self-service/logout/api` URL directly with the Ory Session Token.  The URL is only valid for the currently signed in user. If no user is signed in, this endpoint returns a 401 error.  When calling this endpoint from a backend, please ensure to properly forward the HTTP cookies.
395pub async fn create_browser_logout_flow(
396    configuration: &configuration::Configuration,
397    cookie: Option<&str>,
398    return_to: Option<&str>,
399) -> Result<models::LogoutFlow, Error<CreateBrowserLogoutFlowError>> {
400    let mut uri_str = String::new();
401    uri_str.push_str(&configuration.base_path);
402    uri_str.push_str("/self-service/logout/browser");
403    let client = web_sys::RequestInit::new();
404    client.set_method("GET");
405    client.set_mode(web_sys::RequestMode::Cors);
406    client.set_credentials(web_sys::RequestCredentials::Include);
407    let mut is_first_query: bool = true;
408    if let Some(ref str) = return_to {
409        uri_str.add_query(&mut is_first_query, "return_to=", &str.to_string());
410    }
411    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
412    if let Some(ref user_agent) = configuration.user_agent {
413        req_builder.headers().set("USER_AGENT", user_agent)?;
414    }
415    if let Some(cookie) = cookie {
416        req_builder.headers().set("cookie", cookie)?;
417    }
418    req_builder.headers().set("Accept", "application/json")?;
419    let req = wasm_bindgen_futures::JsFuture::from(
420        web_sys::window()
421            .expect("Failed to get Window object")
422            .fetch_with_request(&req_builder),
423    )
424    .await?;
425    assert!(req.is_instance_of::<web_sys::Response>());
426    let resp: web_sys::Response = req
427        .dyn_into()
428        .expect("Failed to dynamically cast JsFuture into Response");
429    super::handle_response(resp).await
430}
431
432/// This endpoint initializes a browser-based account recovery flow. Once initialized, the browser will be redirected to `selfservice.flows.recovery.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session exists, the browser is returned to the configured return URL.  If this endpoint is called via an AJAX request, the response contains the recovery flow without any redirects or a 400 bad request error if the user is already authenticated.  This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed.  More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery).
433pub async fn create_browser_recovery_flow(
434    configuration: &configuration::Configuration,
435    return_to: Option<&str>,
436) -> Result<models::RecoveryFlow, Error<CreateBrowserRecoveryFlowError>> {
437    let mut uri_str = String::new();
438    uri_str.push_str(&configuration.base_path);
439    uri_str.push_str("/self-service/recovery/browser");
440    let client = web_sys::RequestInit::new();
441    client.set_method("GET");
442    client.set_mode(web_sys::RequestMode::Cors);
443    client.set_credentials(web_sys::RequestCredentials::Include);
444    let mut is_first_query: bool = true;
445    if let Some(ref str) = return_to {
446        uri_str.add_query(&mut is_first_query, "return_to=", &str.to_string());
447    }
448    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
449    if let Some(ref user_agent) = configuration.user_agent {
450        req_builder.headers().set("USER_AGENT", user_agent)?;
451    }
452    req_builder.headers().set("Accept", "application/json")?;
453    let req = wasm_bindgen_futures::JsFuture::from(
454        web_sys::window()
455            .expect("Failed to get Window object")
456            .fetch_with_request(&req_builder),
457    )
458    .await?;
459    assert!(req.is_instance_of::<web_sys::Response>());
460    let resp: web_sys::Response = req
461        .dyn_into()
462        .expect("Failed to dynamically cast JsFuture into Response");
463    super::handle_response(resp).await
464}
465
466/// This endpoint initializes a browser-based user registration flow. This endpoint will set the appropriate cookies and anti-CSRF measures required for browser-based flows.  If this endpoint is opened as a link in the browser, it will be redirected to `selfservice.flows.registration.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session exists already, the browser will be redirected to `urls.default_redirect_url`.  If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration!  If this endpoint is called via an AJAX request, the response contains the registration flow without a redirect.  This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
467pub async fn create_browser_registration_flow(
468    configuration: &configuration::Configuration,
469    return_to: Option<&str>,
470    login_challenge: Option<&str>,
471    after_verification_return_to: Option<&str>,
472    organization: Option<&str>,
473    identity_schema: Option<&str>,
474) -> Result<models::RegistrationFlow, Error<CreateBrowserRegistrationFlowError>> {
475    let mut uri_str = String::new();
476    uri_str.push_str(&configuration.base_path);
477    uri_str.push_str("/self-service/registration/browser");
478    let client = web_sys::RequestInit::new();
479    client.set_method("GET");
480    client.set_mode(web_sys::RequestMode::Cors);
481    client.set_credentials(web_sys::RequestCredentials::Include);
482    let mut is_first_query: bool = true;
483    if let Some(ref str) = return_to {
484        uri_str.add_query(&mut is_first_query, "return_to=", &str.to_string());
485    }
486    if let Some(ref str) = login_challenge {
487        uri_str.add_query(&mut is_first_query, "login_challenge=", &str.to_string());
488    }
489    if let Some(ref str) = after_verification_return_to {
490        uri_str.add_query(
491            &mut is_first_query,
492            "after_verification_return_to=",
493            &str.to_string(),
494        );
495    }
496    if let Some(ref str) = organization {
497        uri_str.add_query(&mut is_first_query, "organization=", &str.to_string());
498    }
499    if let Some(ref str) = identity_schema {
500        uri_str.add_query(&mut is_first_query, "identity_schema=", &str.to_string());
501    }
502    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
503    if let Some(ref user_agent) = configuration.user_agent {
504        req_builder.headers().set("USER_AGENT", user_agent)?;
505    }
506    req_builder.headers().set("Accept", "application/json")?;
507    let req = wasm_bindgen_futures::JsFuture::from(
508        web_sys::window()
509            .expect("Failed to get Window object")
510            .fetch_with_request(&req_builder),
511    )
512    .await?;
513    assert!(req.is_instance_of::<web_sys::Response>());
514    let resp: web_sys::Response = req
515        .dyn_into()
516        .expect("Failed to dynamically cast JsFuture into Response");
517    super::handle_response(resp).await
518}
519
520/// This endpoint initializes a browser-based user settings flow. Once initialized, the browser will be redirected to `selfservice.flows.settings.ui_url` with the flow ID set as the query parameter `?flow=`. If no valid Ory Kratos Session Cookie is included in the request, a login flow will be initialized.  If this endpoint is opened as a link in the browser, it will be redirected to `selfservice.flows.settings.ui_url` with the flow ID set as the query parameter `?flow=`. If no valid user session was set, the browser will be redirected to the login endpoint.  If this endpoint is called via an AJAX request, the response contains the settings flow without any redirects or a 401 forbidden error if no valid session was set.  Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor (happens automatically for server-side browser flows) or change the configuration.  If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `session_inactive`: No Ory Session was found - sign in a user first. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration!  This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed.  More information can be found at [Ory Kratos User Settings & Profile Management Documentation](../self-service/flows/user-settings).
521pub async fn create_browser_settings_flow(
522    configuration: &configuration::Configuration,
523    return_to: Option<&str>,
524    cookie: Option<&str>,
525) -> Result<models::SettingsFlow, Error<CreateBrowserSettingsFlowError>> {
526    let mut uri_str = String::new();
527    uri_str.push_str(&configuration.base_path);
528    uri_str.push_str("/self-service/settings/browser");
529    let client = web_sys::RequestInit::new();
530    client.set_method("GET");
531    client.set_mode(web_sys::RequestMode::Cors);
532    client.set_credentials(web_sys::RequestCredentials::Include);
533    let mut is_first_query: bool = true;
534    if let Some(ref str) = return_to {
535        uri_str.add_query(&mut is_first_query, "return_to=", &str.to_string());
536    }
537    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
538    if let Some(ref user_agent) = configuration.user_agent {
539        req_builder.headers().set("USER_AGENT", user_agent)?;
540    }
541    if let Some(cookie) = cookie {
542        req_builder.headers().set("Cookie", cookie)?;
543    }
544    req_builder.headers().set("Accept", "application/json")?;
545    let req = wasm_bindgen_futures::JsFuture::from(
546        web_sys::window()
547            .expect("Failed to get Window object")
548            .fetch_with_request(&req_builder),
549    )
550    .await?;
551    assert!(req.is_instance_of::<web_sys::Response>());
552    let resp: web_sys::Response = req
553        .dyn_into()
554        .expect("Failed to dynamically cast JsFuture into Response");
555    super::handle_response(resp).await
556}
557
558/// This endpoint initializes a browser-based account verification flow. Once initialized, the browser will be redirected to `selfservice.flows.verification.ui_url` with the flow ID set as the query parameter `?flow=`.  If this endpoint is called via an AJAX request, the response contains the recovery flow without any redirects.  This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...).  More information can be found at [Ory Kratos Email and Phone Verification Documentation](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation).
559pub async fn create_browser_verification_flow(
560    configuration: &configuration::Configuration,
561    return_to: Option<&str>,
562) -> Result<models::VerificationFlow, Error<CreateBrowserVerificationFlowError>> {
563    let mut uri_str = String::new();
564    uri_str.push_str(&configuration.base_path);
565    uri_str.push_str("/self-service/verification/browser");
566    let client = web_sys::RequestInit::new();
567    client.set_method("GET");
568    client.set_mode(web_sys::RequestMode::Cors);
569    client.set_credentials(web_sys::RequestCredentials::Include);
570    let mut is_first_query: bool = true;
571    if let Some(ref str) = return_to {
572        uri_str.add_query(&mut is_first_query, "return_to=", &str.to_string());
573    }
574    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
575    if let Some(ref user_agent) = configuration.user_agent {
576        req_builder.headers().set("USER_AGENT", user_agent)?;
577    }
578    req_builder.headers().set("Accept", "application/json")?;
579    let req = wasm_bindgen_futures::JsFuture::from(
580        web_sys::window()
581            .expect("Failed to get Window object")
582            .fetch_with_request(&req_builder),
583    )
584    .await?;
585    assert!(req.is_instance_of::<web_sys::Response>());
586    let resp: web_sys::Response = req
587        .dyn_into()
588        .expect("Failed to dynamically cast JsFuture into Response");
589    super::handle_response(resp).await
590}
591
592/// This endpoint returns a list of all available FedCM providers. It is only supported on the Ory Network.
593pub async fn create_fedcm_flow(
594    configuration: &configuration::Configuration,
595) -> Result<models::CreateFedcmFlowResponse, Error<CreateFedcmFlowError>> {
596    let mut uri_str = String::new();
597    uri_str.push_str(&configuration.base_path);
598    uri_str.push_str("/self-service/fed-cm/parameters");
599    let client = web_sys::RequestInit::new();
600    client.set_method("GET");
601    client.set_mode(web_sys::RequestMode::Cors);
602    client.set_credentials(web_sys::RequestCredentials::Include);
603    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
604    if let Some(ref user_agent) = configuration.user_agent {
605        req_builder.headers().set("USER_AGENT", user_agent)?;
606    }
607    req_builder.headers().set("Accept", "application/json")?;
608    let req = wasm_bindgen_futures::JsFuture::from(
609        web_sys::window()
610            .expect("Failed to get Window object")
611            .fetch_with_request(&req_builder),
612    )
613    .await?;
614    assert!(req.is_instance_of::<web_sys::Response>());
615    let resp: web_sys::Response = req
616        .dyn_into()
617        .expect("Failed to dynamically cast JsFuture into Response");
618    super::handle_response(resp).await
619}
620
621/// This endpoint initiates a login flow for native apps that do not use a browser, such as mobile devices, smart TVs, and so on.  If a valid provided session cookie or session token is provided, a 400 Bad Request error will be returned unless the URL query parameter `?refresh=true` is set.  To fetch an existing login flow call `/self-service/login/flows?flow=<flow_id>`.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks, including CSRF login attacks.  In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `session_aal1_required`: Multi-factor auth (e.g. 2fa) was requested but the user has no session yet. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
622pub async fn create_native_login_flow(
623    configuration: &configuration::Configuration,
624    refresh: Option<bool>,
625    aal: Option<&str>,
626    x_session_token: Option<&str>,
627    return_session_token_exchange_code: Option<bool>,
628    return_to: Option<&str>,
629    organization: Option<&str>,
630    via: Option<&str>,
631    identity_schema: Option<&str>,
632) -> Result<models::LoginFlow, Error<CreateNativeLoginFlowError>> {
633    let mut uri_str = String::new();
634    uri_str.push_str(&configuration.base_path);
635    uri_str.push_str("/self-service/login/api");
636    let client = web_sys::RequestInit::new();
637    client.set_method("GET");
638    client.set_mode(web_sys::RequestMode::Cors);
639    client.set_credentials(web_sys::RequestCredentials::Include);
640    let mut is_first_query: bool = true;
641    if let Some(ref str) = refresh {
642        uri_str.add_query(&mut is_first_query, "refresh=", &str.to_string());
643    }
644    if let Some(ref str) = aal {
645        uri_str.add_query(&mut is_first_query, "aal=", &str.to_string());
646    }
647    if let Some(ref str) = return_session_token_exchange_code {
648        uri_str.add_query(
649            &mut is_first_query,
650            "return_session_token_exchange_code=",
651            &str.to_string(),
652        );
653    }
654    if let Some(ref str) = return_to {
655        uri_str.add_query(&mut is_first_query, "return_to=", &str.to_string());
656    }
657    if let Some(ref str) = organization {
658        uri_str.add_query(&mut is_first_query, "organization=", &str.to_string());
659    }
660    if let Some(ref str) = via {
661        uri_str.add_query(&mut is_first_query, "via=", &str.to_string());
662    }
663    if let Some(ref str) = identity_schema {
664        uri_str.add_query(&mut is_first_query, "identity_schema=", &str.to_string());
665    }
666    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
667    if let Some(ref user_agent) = configuration.user_agent {
668        req_builder.headers().set("USER_AGENT", user_agent)?;
669    }
670    if let Some(x_session_token) = x_session_token {
671        req_builder
672            .headers()
673            .set("X-Session-Token", x_session_token)?;
674    }
675    req_builder.headers().set("Accept", "application/json")?;
676    let req = wasm_bindgen_futures::JsFuture::from(
677        web_sys::window()
678            .expect("Failed to get Window object")
679            .fetch_with_request(&req_builder),
680    )
681    .await?;
682    assert!(req.is_instance_of::<web_sys::Response>());
683    let resp: web_sys::Response = req
684        .dyn_into()
685        .expect("Failed to dynamically cast JsFuture into Response");
686    super::handle_response(resp).await
687}
688
689/// This endpoint initiates a recovery flow for API clients such as mobile devices, smart TVs, and so on.  If a valid provided session cookie or session token is provided, a 400 Bad Request error.  On an existing recovery flow, use the `getRecoveryFlow` API endpoint.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery).
690pub async fn create_native_recovery_flow(
691    configuration: &configuration::Configuration,
692) -> Result<models::RecoveryFlow, Error<CreateNativeRecoveryFlowError>> {
693    let mut uri_str = String::new();
694    uri_str.push_str(&configuration.base_path);
695    uri_str.push_str("/self-service/recovery/api");
696    let client = web_sys::RequestInit::new();
697    client.set_method("GET");
698    client.set_mode(web_sys::RequestMode::Cors);
699    client.set_credentials(web_sys::RequestCredentials::Include);
700    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
701    if let Some(ref user_agent) = configuration.user_agent {
702        req_builder.headers().set("USER_AGENT", user_agent)?;
703    }
704    req_builder.headers().set("Accept", "application/json")?;
705    let req = wasm_bindgen_futures::JsFuture::from(
706        web_sys::window()
707            .expect("Failed to get Window object")
708            .fetch_with_request(&req_builder),
709    )
710    .await?;
711    assert!(req.is_instance_of::<web_sys::Response>());
712    let resp: web_sys::Response = req
713        .dyn_into()
714        .expect("Failed to dynamically cast JsFuture into Response");
715    super::handle_response(resp).await
716}
717
718/// This endpoint initiates a registration flow for API clients such as mobile devices, smart TVs, and so on.  If a valid provided session cookie or session token is provided, a 400 Bad Request error will be returned unless the URL query parameter `?refresh=true` is set.  To fetch an existing registration flow call `/self-service/registration/flows?flow=<flow_id>`.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks.  In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
719pub async fn create_native_registration_flow(
720    configuration: &configuration::Configuration,
721    return_session_token_exchange_code: Option<bool>,
722    return_to: Option<&str>,
723    organization: Option<&str>,
724    identity_schema: Option<&str>,
725) -> Result<models::RegistrationFlow, Error<CreateNativeRegistrationFlowError>> {
726    let mut uri_str = String::new();
727    uri_str.push_str(&configuration.base_path);
728    uri_str.push_str("/self-service/registration/api");
729    let client = web_sys::RequestInit::new();
730    client.set_method("GET");
731    client.set_mode(web_sys::RequestMode::Cors);
732    client.set_credentials(web_sys::RequestCredentials::Include);
733    let mut is_first_query: bool = true;
734    if let Some(ref str) = return_session_token_exchange_code {
735        uri_str.add_query(
736            &mut is_first_query,
737            "return_session_token_exchange_code=",
738            &str.to_string(),
739        );
740    }
741    if let Some(ref str) = return_to {
742        uri_str.add_query(&mut is_first_query, "return_to=", &str.to_string());
743    }
744    if let Some(ref str) = organization {
745        uri_str.add_query(&mut is_first_query, "organization=", &str.to_string());
746    }
747    if let Some(ref str) = identity_schema {
748        uri_str.add_query(&mut is_first_query, "identity_schema=", &str.to_string());
749    }
750    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
751    if let Some(ref user_agent) = configuration.user_agent {
752        req_builder.headers().set("USER_AGENT", user_agent)?;
753    }
754    req_builder.headers().set("Accept", "application/json")?;
755    let req = wasm_bindgen_futures::JsFuture::from(
756        web_sys::window()
757            .expect("Failed to get Window object")
758            .fetch_with_request(&req_builder),
759    )
760    .await?;
761    assert!(req.is_instance_of::<web_sys::Response>());
762    let resp: web_sys::Response = req
763        .dyn_into()
764        .expect("Failed to dynamically cast JsFuture into Response");
765    super::handle_response(resp).await
766}
767
768/// This endpoint initiates a settings flow for API clients such as mobile devices, smart TVs, and so on. You must provide a valid Ory Kratos Session Token for this endpoint to respond with HTTP 200 OK.  To fetch an existing settings flow call `/self-service/settings/flows?flow=<flow_id>`.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks.  Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor or change the configuration.  In the case of an error, the `error.id` of the JSON response body can be one of:  `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `session_inactive`: No Ory Session was found - sign in a user first.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Kratos User Settings & Profile Management Documentation](../self-service/flows/user-settings).
769pub async fn create_native_settings_flow(
770    configuration: &configuration::Configuration,
771    x_session_token: Option<&str>,
772) -> Result<models::SettingsFlow, Error<CreateNativeSettingsFlowError>> {
773    let mut uri_str = String::new();
774    uri_str.push_str(&configuration.base_path);
775    uri_str.push_str("/self-service/settings/api");
776    let client = web_sys::RequestInit::new();
777    client.set_method("GET");
778    client.set_mode(web_sys::RequestMode::Cors);
779    client.set_credentials(web_sys::RequestCredentials::Include);
780    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
781    if let Some(ref user_agent) = configuration.user_agent {
782        req_builder.headers().set("USER_AGENT", user_agent)?;
783    }
784    if let Some(x_session_token) = x_session_token {
785        req_builder
786            .headers()
787            .set("X-Session-Token", x_session_token)?;
788    }
789    req_builder.headers().set("Accept", "application/json")?;
790    let req = wasm_bindgen_futures::JsFuture::from(
791        web_sys::window()
792            .expect("Failed to get Window object")
793            .fetch_with_request(&req_builder),
794    )
795    .await?;
796    assert!(req.is_instance_of::<web_sys::Response>());
797    let resp: web_sys::Response = req
798        .dyn_into()
799        .expect("Failed to dynamically cast JsFuture into Response");
800    super::handle_response(resp).await
801}
802
803/// This endpoint initiates a verification flow for API clients such as mobile devices, smart TVs, and so on.  To fetch an existing verification flow call `/self-service/verification/flows?flow=<flow_id>`.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Email and Phone Verification Documentation](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation).
804pub async fn create_native_verification_flow(
805    configuration: &configuration::Configuration,
806    return_to: Option<&str>,
807) -> Result<models::VerificationFlow, Error<CreateNativeVerificationFlowError>> {
808    let mut uri_str = String::new();
809    uri_str.push_str(&configuration.base_path);
810    uri_str.push_str("/self-service/verification/api");
811    let client = web_sys::RequestInit::new();
812    client.set_method("GET");
813    client.set_mode(web_sys::RequestMode::Cors);
814    client.set_credentials(web_sys::RequestCredentials::Include);
815    let mut is_first_query: bool = true;
816    if let Some(ref str) = return_to {
817        uri_str.add_query(&mut is_first_query, "return_to=", &str.to_string());
818    }
819    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
820    if let Some(ref user_agent) = configuration.user_agent {
821        req_builder.headers().set("USER_AGENT", user_agent)?;
822    }
823    req_builder.headers().set("Accept", "application/json")?;
824    let req = wasm_bindgen_futures::JsFuture::from(
825        web_sys::window()
826            .expect("Failed to get Window object")
827            .fetch_with_request(&req_builder),
828    )
829    .await?;
830    assert!(req.is_instance_of::<web_sys::Response>());
831    let resp: web_sys::Response = req
832        .dyn_into()
833        .expect("Failed to dynamically cast JsFuture into Response");
834    super::handle_response(resp).await
835}
836
837/// Calling this endpoint invalidates all except the current session that belong to the logged-in user. Session data are not deleted.
838pub async fn disable_my_other_sessions(
839    configuration: &configuration::Configuration,
840    x_session_token: Option<&str>,
841    cookie: Option<&str>,
842) -> Result<models::DeleteMySessionsCount, Error<DisableMyOtherSessionsError>> {
843    let mut uri_str = String::new();
844    uri_str.push_str(&configuration.base_path);
845    uri_str.push_str("/sessions");
846    let client = web_sys::RequestInit::new();
847    client.set_method("DELETE");
848    client.set_mode(web_sys::RequestMode::Cors);
849    client.set_credentials(web_sys::RequestCredentials::Include);
850    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
851    if let Some(ref user_agent) = configuration.user_agent {
852        req_builder.headers().set("USER_AGENT", user_agent)?;
853    }
854    if let Some(x_session_token) = x_session_token {
855        req_builder
856            .headers()
857            .set("X-Session-Token", x_session_token)?;
858    }
859    if let Some(cookie) = cookie {
860        req_builder.headers().set("Cookie", cookie)?;
861    }
862    req_builder.headers().set("Accept", "application/json")?;
863    let req = wasm_bindgen_futures::JsFuture::from(
864        web_sys::window()
865            .expect("Failed to get Window object")
866            .fetch_with_request(&req_builder),
867    )
868    .await?;
869    assert!(req.is_instance_of::<web_sys::Response>());
870    let resp: web_sys::Response = req
871        .dyn_into()
872        .expect("Failed to dynamically cast JsFuture into Response");
873    super::handle_response(resp).await
874}
875
876/// Calling this endpoint invalidates the specified session. The current session cannot be revoked. Session data are not deleted.
877pub async fn disable_my_session(
878    configuration: &configuration::Configuration,
879    id: &str,
880    x_session_token: Option<&str>,
881    cookie: Option<&str>,
882) -> Result<(), Error<DisableMySessionError>> {
883    let id = crate::wasm_apis::urlencode(id);
884    let mut uri_str = String::new();
885    uri_str.push_str(&configuration.base_path);
886    uri_str.push_str("/sessions/");
887    uri_str.push_str(&id);
888    let client = web_sys::RequestInit::new();
889    client.set_method("DELETE");
890    client.set_mode(web_sys::RequestMode::Cors);
891    client.set_credentials(web_sys::RequestCredentials::Include);
892    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
893    if let Some(ref user_agent) = configuration.user_agent {
894        req_builder.headers().set("USER_AGENT", user_agent)?;
895    }
896    if let Some(x_session_token) = x_session_token {
897        req_builder
898            .headers()
899            .set("X-Session-Token", x_session_token)?;
900    }
901    if let Some(cookie) = cookie {
902        req_builder.headers().set("Cookie", cookie)?;
903    }
904    req_builder.headers().set("Accept", "application/json")?;
905    let req = wasm_bindgen_futures::JsFuture::from(
906        web_sys::window()
907            .expect("Failed to get Window object")
908            .fetch_with_request(&req_builder),
909    )
910    .await?;
911    assert!(req.is_instance_of::<web_sys::Response>());
912    let resp: web_sys::Response = req
913        .dyn_into()
914        .expect("Failed to dynamically cast JsFuture into Response");
915    super::handle_empty_response(resp).await
916}
917
918pub async fn exchange_session_token(
919    configuration: &configuration::Configuration,
920    init_code: &str,
921    return_to_code: &str,
922) -> Result<models::SuccessfulNativeLogin, Error<ExchangeSessionTokenError>> {
923    let mut uri_str = String::new();
924    uri_str.push_str(&configuration.base_path);
925    uri_str.push_str("/sessions/token-exchange");
926    let client = web_sys::RequestInit::new();
927    client.set_method("GET");
928    client.set_mode(web_sys::RequestMode::Cors);
929    client.set_credentials(web_sys::RequestCredentials::Include);
930    let mut is_first_query: bool = true;
931    uri_str.add_query(&mut is_first_query, "init_code=", &init_code.to_string());
932    uri_str.add_query(
933        &mut is_first_query,
934        "return_to_code=",
935        &return_to_code.to_string(),
936    );
937    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
938    if let Some(ref user_agent) = configuration.user_agent {
939        req_builder.headers().set("USER_AGENT", user_agent)?;
940    }
941    req_builder.headers().set("Accept", "application/json")?;
942    let req = wasm_bindgen_futures::JsFuture::from(
943        web_sys::window()
944            .expect("Failed to get Window object")
945            .fetch_with_request(&req_builder),
946    )
947    .await?;
948    assert!(req.is_instance_of::<web_sys::Response>());
949    let resp: web_sys::Response = req
950        .dyn_into()
951        .expect("Failed to dynamically cast JsFuture into Response");
952    super::handle_response(resp).await
953}
954
955/// This endpoint returns the error associated with a user-facing self service errors.  This endpoint supports stub values to help you implement the error UI:  `?id=stub:500` - returns a stub 500 (Internal Server Error) error.  More information can be found at [Ory Kratos User User Facing Error Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-facing-errors).
956pub async fn get_flow_error(
957    configuration: &configuration::Configuration,
958    id: &str,
959) -> Result<models::FlowError, Error<GetFlowErrorError>> {
960    let mut uri_str = String::new();
961    uri_str.push_str(&configuration.base_path);
962    uri_str.push_str("/self-service/errors");
963    let client = web_sys::RequestInit::new();
964    client.set_method("GET");
965    client.set_mode(web_sys::RequestMode::Cors);
966    client.set_credentials(web_sys::RequestCredentials::Include);
967    let mut is_first_query: bool = true;
968    uri_str.add_query(&mut is_first_query, "id=", &id.to_string());
969    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
970    if let Some(ref user_agent) = configuration.user_agent {
971        req_builder.headers().set("USER_AGENT", user_agent)?;
972    }
973    req_builder.headers().set("Accept", "application/json")?;
974    let req = wasm_bindgen_futures::JsFuture::from(
975        web_sys::window()
976            .expect("Failed to get Window object")
977            .fetch_with_request(&req_builder),
978    )
979    .await?;
980    assert!(req.is_instance_of::<web_sys::Response>());
981    let resp: web_sys::Response = req
982        .dyn_into()
983        .expect("Failed to dynamically cast JsFuture into Response");
984    super::handle_response(resp).await
985}
986
987/// This endpoint returns a login flow's context with, for example, error details and other information.  Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail.  If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint:  ```js pseudo-code example router.get('/login', async function (req, res) { const flow = await client.getLoginFlow(req.header('cookie'), req.query['flow'])  res.render('login', flow) }) ```  This request may fail due to several reasons. The `error.id` can be one of:  `session_already_available`: The user is already signed in. `self_service_flow_expired`: The flow is expired and you should request a new one.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
988pub async fn get_login_flow(
989    configuration: &configuration::Configuration,
990    id: &str,
991    cookie: Option<&str>,
992) -> Result<models::LoginFlow, Error<GetLoginFlowError>> {
993    let mut uri_str = String::new();
994    uri_str.push_str(&configuration.base_path);
995    uri_str.push_str("/self-service/login/flows");
996    let client = web_sys::RequestInit::new();
997    client.set_method("GET");
998    client.set_mode(web_sys::RequestMode::Cors);
999    client.set_credentials(web_sys::RequestCredentials::Include);
1000    let mut is_first_query: bool = true;
1001    uri_str.add_query(&mut is_first_query, "id=", &id.to_string());
1002    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
1003    if let Some(ref user_agent) = configuration.user_agent {
1004        req_builder.headers().set("USER_AGENT", user_agent)?;
1005    }
1006    if let Some(cookie) = cookie {
1007        req_builder.headers().set("Cookie", cookie)?;
1008    }
1009    req_builder.headers().set("Accept", "application/json")?;
1010    let req = wasm_bindgen_futures::JsFuture::from(
1011        web_sys::window()
1012            .expect("Failed to get Window object")
1013            .fetch_with_request(&req_builder),
1014    )
1015    .await?;
1016    assert!(req.is_instance_of::<web_sys::Response>());
1017    let resp: web_sys::Response = req
1018        .dyn_into()
1019        .expect("Failed to dynamically cast JsFuture into Response");
1020    super::handle_response(resp).await
1021}
1022
1023/// This endpoint returns a recovery flow's context with, for example, error details and other information.  Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail.  If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint:  ```js pseudo-code example router.get('/recovery', async function (req, res) { const flow = await client.getRecoveryFlow(req.header('Cookie'), req.query['flow'])  res.render('recovery', flow) }) ```  More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery).
1024pub async fn get_recovery_flow(
1025    configuration: &configuration::Configuration,
1026    id: &str,
1027    cookie: Option<&str>,
1028) -> Result<models::RecoveryFlow, Error<GetRecoveryFlowError>> {
1029    let mut uri_str = String::new();
1030    uri_str.push_str(&configuration.base_path);
1031    uri_str.push_str("/self-service/recovery/flows");
1032    let client = web_sys::RequestInit::new();
1033    client.set_method("GET");
1034    client.set_mode(web_sys::RequestMode::Cors);
1035    client.set_credentials(web_sys::RequestCredentials::Include);
1036    let mut is_first_query: bool = true;
1037    uri_str.add_query(&mut is_first_query, "id=", &id.to_string());
1038    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
1039    if let Some(ref user_agent) = configuration.user_agent {
1040        req_builder.headers().set("USER_AGENT", user_agent)?;
1041    }
1042    if let Some(cookie) = cookie {
1043        req_builder.headers().set("Cookie", cookie)?;
1044    }
1045    req_builder.headers().set("Accept", "application/json")?;
1046    let req = wasm_bindgen_futures::JsFuture::from(
1047        web_sys::window()
1048            .expect("Failed to get Window object")
1049            .fetch_with_request(&req_builder),
1050    )
1051    .await?;
1052    assert!(req.is_instance_of::<web_sys::Response>());
1053    let resp: web_sys::Response = req
1054        .dyn_into()
1055        .expect("Failed to dynamically cast JsFuture into Response");
1056    super::handle_response(resp).await
1057}
1058
1059/// This endpoint returns a registration flow's context with, for example, error details and other information.  Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail.  If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint:  ```js pseudo-code example router.get('/registration', async function (req, res) { const flow = await client.getRegistrationFlow(req.header('cookie'), req.query['flow'])  res.render('registration', flow) }) ```  This request may fail due to several reasons. The `error.id` can be one of:  `session_already_available`: The user is already signed in. `self_service_flow_expired`: The flow is expired and you should request a new one.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
1060pub async fn get_registration_flow(
1061    configuration: &configuration::Configuration,
1062    id: &str,
1063    cookie: Option<&str>,
1064) -> Result<models::RegistrationFlow, Error<GetRegistrationFlowError>> {
1065    let mut uri_str = String::new();
1066    uri_str.push_str(&configuration.base_path);
1067    uri_str.push_str("/self-service/registration/flows");
1068    let client = web_sys::RequestInit::new();
1069    client.set_method("GET");
1070    client.set_mode(web_sys::RequestMode::Cors);
1071    client.set_credentials(web_sys::RequestCredentials::Include);
1072    let mut is_first_query: bool = true;
1073    uri_str.add_query(&mut is_first_query, "id=", &id.to_string());
1074    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
1075    if let Some(ref user_agent) = configuration.user_agent {
1076        req_builder.headers().set("USER_AGENT", user_agent)?;
1077    }
1078    if let Some(cookie) = cookie {
1079        req_builder.headers().set("Cookie", cookie)?;
1080    }
1081    req_builder.headers().set("Accept", "application/json")?;
1082    let req = wasm_bindgen_futures::JsFuture::from(
1083        web_sys::window()
1084            .expect("Failed to get Window object")
1085            .fetch_with_request(&req_builder),
1086    )
1087    .await?;
1088    assert!(req.is_instance_of::<web_sys::Response>());
1089    let resp: web_sys::Response = req
1090        .dyn_into()
1091        .expect("Failed to dynamically cast JsFuture into Response");
1092    super::handle_response(resp).await
1093}
1094
1095/// When accessing this endpoint through Ory Kratos' Public API you must ensure that either the Ory Kratos Session Cookie or the Ory Kratos Session Token are set.  Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor or change the configuration.  You can access this endpoint without credentials when using Ory Kratos' Admin API.  If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `session_inactive`: No Ory Session was found - sign in a user first. `security_identity_mismatch`: The flow was interrupted with `session_refresh_required` but apparently some other identity logged in instead.  More information can be found at [Ory Kratos User Settings & Profile Management Documentation](../self-service/flows/user-settings).
1096pub async fn get_settings_flow(
1097    configuration: &configuration::Configuration,
1098    id: &str,
1099    x_session_token: Option<&str>,
1100    cookie: Option<&str>,
1101) -> Result<models::SettingsFlow, Error<GetSettingsFlowError>> {
1102    let mut uri_str = String::new();
1103    uri_str.push_str(&configuration.base_path);
1104    uri_str.push_str("/self-service/settings/flows");
1105    let client = web_sys::RequestInit::new();
1106    client.set_method("GET");
1107    client.set_mode(web_sys::RequestMode::Cors);
1108    client.set_credentials(web_sys::RequestCredentials::Include);
1109    let mut is_first_query: bool = true;
1110    uri_str.add_query(&mut is_first_query, "id=", &id.to_string());
1111    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
1112    if let Some(ref user_agent) = configuration.user_agent {
1113        req_builder.headers().set("USER_AGENT", user_agent)?;
1114    }
1115    if let Some(x_session_token) = x_session_token {
1116        req_builder
1117            .headers()
1118            .set("X-Session-Token", x_session_token)?;
1119    }
1120    if let Some(cookie) = cookie {
1121        req_builder.headers().set("Cookie", cookie)?;
1122    }
1123    req_builder.headers().set("Accept", "application/json")?;
1124    let req = wasm_bindgen_futures::JsFuture::from(
1125        web_sys::window()
1126            .expect("Failed to get Window object")
1127            .fetch_with_request(&req_builder),
1128    )
1129    .await?;
1130    assert!(req.is_instance_of::<web_sys::Response>());
1131    let resp: web_sys::Response = req
1132        .dyn_into()
1133        .expect("Failed to dynamically cast JsFuture into Response");
1134    super::handle_response(resp).await
1135}
1136
1137/// This endpoint returns a verification flow's context with, for example, error details and other information.  Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail.  If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint:  ```js pseudo-code example router.get('/recovery', async function (req, res) { const flow = await client.getVerificationFlow(req.header('cookie'), req.query['flow'])  res.render('verification', flow) }) ```  More information can be found at [Ory Kratos Email and Phone Verification Documentation](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation).
1138pub async fn get_verification_flow(
1139    configuration: &configuration::Configuration,
1140    id: &str,
1141    cookie: Option<&str>,
1142) -> Result<models::VerificationFlow, Error<GetVerificationFlowError>> {
1143    let mut uri_str = String::new();
1144    uri_str.push_str(&configuration.base_path);
1145    uri_str.push_str("/self-service/verification/flows");
1146    let client = web_sys::RequestInit::new();
1147    client.set_method("GET");
1148    client.set_mode(web_sys::RequestMode::Cors);
1149    client.set_credentials(web_sys::RequestCredentials::Include);
1150    let mut is_first_query: bool = true;
1151    uri_str.add_query(&mut is_first_query, "id=", &id.to_string());
1152    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
1153    if let Some(ref user_agent) = configuration.user_agent {
1154        req_builder.headers().set("USER_AGENT", user_agent)?;
1155    }
1156    if let Some(cookie) = cookie {
1157        req_builder.headers().set("cookie", cookie)?;
1158    }
1159    req_builder.headers().set("Accept", "application/json")?;
1160    let req = wasm_bindgen_futures::JsFuture::from(
1161        web_sys::window()
1162            .expect("Failed to get Window object")
1163            .fetch_with_request(&req_builder),
1164    )
1165    .await?;
1166    assert!(req.is_instance_of::<web_sys::Response>());
1167    let resp: web_sys::Response = req
1168        .dyn_into()
1169        .expect("Failed to dynamically cast JsFuture into Response");
1170    super::handle_response(resp).await
1171}
1172
1173/// This endpoint provides JavaScript which is needed in order to perform WebAuthn login and registration.  If you are building a JavaScript Browser App (e.g. in ReactJS or AngularJS) you will need to load this file:  ```html <script src=\"https://public-kratos.example.org/.well-known/ory/webauthn.js\" type=\"script\" async /> ```  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
1174pub async fn get_web_authn_java_script(
1175    configuration: &configuration::Configuration,
1176) -> Result<String, Error<GetWebAuthnJavaScriptError>> {
1177    let mut uri_str = String::new();
1178    uri_str.push_str(&configuration.base_path);
1179    uri_str.push_str("/.well-known/ory/webauthn.js");
1180    let client = web_sys::RequestInit::new();
1181    client.set_method("GET");
1182    client.set_mode(web_sys::RequestMode::Cors);
1183    client.set_credentials(web_sys::RequestCredentials::Include);
1184    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
1185    if let Some(ref user_agent) = configuration.user_agent {
1186        req_builder.headers().set("USER_AGENT", user_agent)?;
1187    }
1188    req_builder.headers().set("Accept", "application/json")?;
1189    let req = wasm_bindgen_futures::JsFuture::from(
1190        web_sys::window()
1191            .expect("Failed to get Window object")
1192            .fetch_with_request(&req_builder),
1193    )
1194    .await?;
1195    assert!(req.is_instance_of::<web_sys::Response>());
1196    let resp: web_sys::Response = req
1197        .dyn_into()
1198        .expect("Failed to dynamically cast JsFuture into Response");
1199    super::handle_response(resp).await
1200}
1201
1202/// This endpoints returns all other active sessions that belong to the logged-in user. The current session can be retrieved by calling the `/sessions/whoami` endpoint.
1203pub async fn list_my_sessions(
1204    configuration: &configuration::Configuration,
1205    per_page: Option<i64>,
1206    page: Option<i64>,
1207    page_size: Option<i64>,
1208    page_token: Option<&str>,
1209    x_session_token: Option<&str>,
1210    cookie: Option<&str>,
1211) -> Result<Vec<models::Session>, Error<ListMySessionsError>> {
1212    let mut uri_str = String::new();
1213    uri_str.push_str(&configuration.base_path);
1214    uri_str.push_str("/sessions");
1215    let client = web_sys::RequestInit::new();
1216    client.set_method("GET");
1217    client.set_mode(web_sys::RequestMode::Cors);
1218    client.set_credentials(web_sys::RequestCredentials::Include);
1219    let mut is_first_query: bool = true;
1220    if let Some(ref str) = per_page {
1221        uri_str.add_query(&mut is_first_query, "per_page=", &str.to_string());
1222    }
1223    if let Some(ref str) = page {
1224        uri_str.add_query(&mut is_first_query, "page=", &str.to_string());
1225    }
1226    if let Some(ref str) = page_size {
1227        uri_str.add_query(&mut is_first_query, "page_size=", &str.to_string());
1228    }
1229    if let Some(ref str) = page_token {
1230        uri_str.add_query(&mut is_first_query, "page_token=", &str.to_string());
1231    }
1232    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
1233    if let Some(ref user_agent) = configuration.user_agent {
1234        req_builder.headers().set("USER_AGENT", user_agent)?;
1235    }
1236    if let Some(x_session_token) = x_session_token {
1237        req_builder
1238            .headers()
1239            .set("X-Session-Token", x_session_token)?;
1240    }
1241    if let Some(cookie) = cookie {
1242        req_builder.headers().set("Cookie", cookie)?;
1243    }
1244    req_builder.headers().set("Accept", "application/json")?;
1245    let req = wasm_bindgen_futures::JsFuture::from(
1246        web_sys::window()
1247            .expect("Failed to get Window object")
1248            .fetch_with_request(&req_builder),
1249    )
1250    .await?;
1251    assert!(req.is_instance_of::<web_sys::Response>());
1252    let resp: web_sys::Response = req
1253        .dyn_into()
1254        .expect("Failed to dynamically cast JsFuture into Response");
1255    super::handle_response(resp).await
1256}
1257
1258/// Use this endpoint to log out an identity using an Ory Session Token. If the Ory Session Token was successfully revoked, the server returns a 204 No Content response. A 204 No Content response is also sent when the Ory Session Token has been revoked already before.  If the Ory Session Token is malformed or does not exist a 403 Forbidden response will be returned.  This endpoint does not remove any HTTP Cookies - use the Browser-Based Self-Service Logout Flow instead.
1259pub async fn perform_native_logout(
1260    configuration: &configuration::Configuration,
1261    perform_native_logout_body: models::PerformNativeLogoutBody,
1262) -> Result<(), Error<PerformNativeLogoutError>> {
1263    let mut uri_str = String::new();
1264    uri_str.push_str(&configuration.base_path);
1265    uri_str.push_str("/self-service/logout/api");
1266    let client = web_sys::RequestInit::new();
1267    client.set_method("DELETE");
1268    client.set_mode(web_sys::RequestMode::Cors);
1269    client.set_credentials(web_sys::RequestCredentials::Include);
1270    client.set_body(&JsValue::from_serde(&perform_native_logout_body)?);
1271    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
1272    if let Some(ref user_agent) = configuration.user_agent {
1273        req_builder.headers().set("USER_AGENT", user_agent)?;
1274    }
1275    req_builder.headers().set("Accept", "application/json")?;
1276    req_builder
1277        .headers()
1278        .set("Content-Type", "application/json")?;
1279    let req = wasm_bindgen_futures::JsFuture::from(
1280        web_sys::window()
1281            .expect("Failed to get Window object")
1282            .fetch_with_request(&req_builder),
1283    )
1284    .await?;
1285    assert!(req.is_instance_of::<web_sys::Response>());
1286    let resp: web_sys::Response = req
1287        .dyn_into()
1288        .expect("Failed to dynamically cast JsFuture into Response");
1289    super::handle_empty_response(resp).await
1290}
1291
1292/// Uses the HTTP Headers in the GET request to determine (e.g. by using checking the cookies) who is authenticated. Returns a session object in the body or 401 if the credentials are invalid or no credentials were sent. When the request it successful it adds the user ID to the 'X-Kratos-Authenticated-Identity-Id' header in the response.  If you call this endpoint from a server-side application, you must forward the HTTP Cookie Header to this endpoint:  ```js pseudo-code example router.get('/protected-endpoint', async function (req, res) { const session = await client.toSession(undefined, req.header('cookie'))  console.log(session) }) ```  When calling this endpoint from a non-browser application (e.g. mobile app) you must include the session token:  ```js pseudo-code example ... const session = await client.toSession(\"the-session-token\")  console.log(session) ```  When using a token template, the token is included in the `tokenized` field of the session.  ```js pseudo-code example ... const session = await client.toSession(\"the-session-token\", { tokenize_as: \"example-jwt-template\" })  console.log(session.tokenized) // The JWT ```  Depending on your configuration this endpoint might return a 403 status code if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor or change the configuration.  This endpoint is useful for:  AJAX calls. Remember to send credentials and set up CORS correctly! Reverse proxies and API Gateways Server-side calls - use the `X-Session-Token` header!  This endpoint authenticates users by checking:  if the `Cookie` HTTP header was set containing an Ory Kratos Session Cookie; if the `Authorization: bearer <ory-session-token>` HTTP header was set with a valid Ory Kratos Session Token; if the `X-Session-Token` HTTP header was set with a valid Ory Kratos Session Token.  If none of these headers are set or the cookie or token are invalid, the endpoint returns a HTTP 401 status code.  As explained above, this request may fail due to several reasons. The `error.id` can be one of:  `session_inactive`: No active session was found in the request (e.g. no Ory Session Cookie / Ory Session Token). `session_aal2_required`: An active session was found but it does not fulfil the Authenticator Assurance Level, implying that the session must (e.g.) authenticate the second factor.
1293pub async fn to_session(
1294    configuration: &configuration::Configuration,
1295    x_session_token: Option<&str>,
1296    cookie: Option<&str>,
1297    tokenize_as: Option<&str>,
1298) -> Result<models::Session, Error<ToSessionError>> {
1299    let mut uri_str = String::new();
1300    uri_str.push_str(&configuration.base_path);
1301    uri_str.push_str("/sessions/whoami");
1302    let client = web_sys::RequestInit::new();
1303    client.set_method("GET");
1304    client.set_mode(web_sys::RequestMode::Cors);
1305    client.set_credentials(web_sys::RequestCredentials::Include);
1306    let mut is_first_query: bool = true;
1307    if let Some(ref str) = tokenize_as {
1308        uri_str.add_query(&mut is_first_query, "tokenize_as=", &str.to_string());
1309    }
1310    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
1311    if let Some(ref user_agent) = configuration.user_agent {
1312        req_builder.headers().set("USER_AGENT", user_agent)?;
1313    }
1314    if let Some(x_session_token) = x_session_token {
1315        req_builder
1316            .headers()
1317            .set("X-Session-Token", x_session_token)?;
1318    }
1319    if let Some(cookie) = cookie {
1320        req_builder.headers().set("Cookie", cookie)?;
1321    }
1322    req_builder.headers().set("Accept", "application/json")?;
1323    let req = wasm_bindgen_futures::JsFuture::from(
1324        web_sys::window()
1325            .expect("Failed to get Window object")
1326            .fetch_with_request(&req_builder),
1327    )
1328    .await?;
1329    assert!(req.is_instance_of::<web_sys::Response>());
1330    let resp: web_sys::Response = req
1331        .dyn_into()
1332        .expect("Failed to dynamically cast JsFuture into Response");
1333    super::handle_response(resp).await
1334}
1335
1336/// Use this endpoint to submit a token from a FedCM provider through `navigator.credentials.get` and log the user in. The parameters from `navigator.credentials.get` must have come from `GET self-service/fed-cm/parameters`.
1337pub async fn update_fedcm_flow(
1338    configuration: &configuration::Configuration,
1339    update_fedcm_flow_body: models::UpdateFedcmFlowBody,
1340) -> Result<models::SuccessfulNativeLogin, Error<UpdateFedcmFlowError>> {
1341    let mut uri_str = String::new();
1342    uri_str.push_str(&configuration.base_path);
1343    uri_str.push_str("/self-service/fed-cm/token");
1344    let client = web_sys::RequestInit::new();
1345    client.set_method("POST");
1346    client.set_mode(web_sys::RequestMode::Cors);
1347    client.set_credentials(web_sys::RequestCredentials::Include);
1348    client.set_body(&JsValue::from_serde(&update_fedcm_flow_body)?);
1349    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
1350    if let Some(ref user_agent) = configuration.user_agent {
1351        req_builder.headers().set("USER_AGENT", user_agent)?;
1352    }
1353    req_builder.headers().set("Accept", "application/json")?;
1354    req_builder
1355        .headers()
1356        .set("Content-Type", "application/json")?;
1357    let req = wasm_bindgen_futures::JsFuture::from(
1358        web_sys::window()
1359            .expect("Failed to get Window object")
1360            .fetch_with_request(&req_builder),
1361    )
1362    .await?;
1363    assert!(req.is_instance_of::<web_sys::Response>());
1364    let resp: web_sys::Response = req
1365        .dyn_into()
1366        .expect("Failed to dynamically cast JsFuture into Response");
1367    super::handle_response(resp).await
1368}
1369
1370/// Use this endpoint to complete a login flow. This endpoint behaves differently for API and browser flows.  API flows expect `application/json` to be sent in the body and responds with HTTP 200 and a application/json body with the session token on success; HTTP 410 if the original flow expired with the appropriate error messages set and optionally a `use_flow_id` parameter in the body; HTTP 400 on form validation errors.  Browser flows expect a Content-Type of `application/x-www-form-urlencoded` or `application/json` to be sent in the body and respond with a HTTP 303 redirect to the post/after login URL or the `return_to` value if it was set and if the login succeeded; a HTTP 303 redirect to the login UI URL with the flow ID containing the validation errors otherwise.  Browser flows with an accept header of `application/json` will not redirect but instead respond with HTTP 200 and a application/json body with the signed in identity and a `Set-Cookie` header on success; HTTP 303 redirect to a fresh login flow if the original flow expired with the appropriate error messages set; HTTP 400 on form validation errors.  If this endpoint is called with `Accept: application/json` in the header, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! `browser_location_change_required`: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
1371pub async fn update_login_flow(
1372    configuration: &configuration::Configuration,
1373    flow: &str,
1374    update_login_flow_body: models::UpdateLoginFlowBody,
1375    x_session_token: Option<&str>,
1376    cookie: Option<&str>,
1377) -> Result<models::SuccessfulNativeLogin, Error<UpdateLoginFlowError>> {
1378    let mut uri_str = String::new();
1379    uri_str.push_str(&configuration.base_path);
1380    uri_str.push_str("/self-service/login");
1381    let client = web_sys::RequestInit::new();
1382    client.set_method("POST");
1383    client.set_mode(web_sys::RequestMode::Cors);
1384    client.set_credentials(web_sys::RequestCredentials::Include);
1385    client.set_body(&JsValue::from_serde(&update_login_flow_body)?);
1386    let mut is_first_query: bool = true;
1387    uri_str.add_query(&mut is_first_query, "flow=", &flow.to_string());
1388    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
1389    if let Some(ref user_agent) = configuration.user_agent {
1390        req_builder.headers().set("USER_AGENT", user_agent)?;
1391    }
1392    if let Some(x_session_token) = x_session_token {
1393        req_builder
1394            .headers()
1395            .set("X-Session-Token", x_session_token)?;
1396    }
1397    if let Some(cookie) = cookie {
1398        req_builder.headers().set("Cookie", cookie)?;
1399    }
1400    req_builder.headers().set("Accept", "application/json")?;
1401    req_builder
1402        .headers()
1403        .set("Content-Type", "application/json")?;
1404    let req = wasm_bindgen_futures::JsFuture::from(
1405        web_sys::window()
1406            .expect("Failed to get Window object")
1407            .fetch_with_request(&req_builder),
1408    )
1409    .await?;
1410    assert!(req.is_instance_of::<web_sys::Response>());
1411    let resp: web_sys::Response = req
1412        .dyn_into()
1413        .expect("Failed to dynamically cast JsFuture into Response");
1414    super::handle_response(resp).await
1415}
1416
1417/// This endpoint logs out an identity in a self-service manner.  If the `Accept` HTTP header is not set to `application/json`, the browser will be redirected (HTTP 303 See Other) to the `return_to` parameter of the initial request or fall back to `urls.default_return_to`.  If the `Accept` HTTP header is set to `application/json`, a 204 No Content response will be sent on successful logout instead.  This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...). For API clients you can call the `/self-service/logout/api` URL directly with the Ory Session Token.  More information can be found at [Ory Kratos User Logout Documentation](https://www.ory.sh/docs/next/kratos/self-service/flows/user-logout).
1418pub async fn update_logout_flow(
1419    configuration: &configuration::Configuration,
1420    token: Option<&str>,
1421    return_to: Option<&str>,
1422    cookie: Option<&str>,
1423) -> Result<(), Error<UpdateLogoutFlowError>> {
1424    let mut uri_str = String::new();
1425    uri_str.push_str(&configuration.base_path);
1426    uri_str.push_str("/self-service/logout");
1427    let client = web_sys::RequestInit::new();
1428    client.set_method("GET");
1429    client.set_mode(web_sys::RequestMode::Cors);
1430    client.set_credentials(web_sys::RequestCredentials::Include);
1431    let mut is_first_query: bool = true;
1432    if let Some(ref str) = token {
1433        uri_str.add_query(&mut is_first_query, "token=", &str.to_string());
1434    }
1435    if let Some(ref str) = return_to {
1436        uri_str.add_query(&mut is_first_query, "return_to=", &str.to_string());
1437    }
1438    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
1439    if let Some(ref user_agent) = configuration.user_agent {
1440        req_builder.headers().set("USER_AGENT", user_agent)?;
1441    }
1442    if let Some(cookie) = cookie {
1443        req_builder.headers().set("Cookie", cookie)?;
1444    }
1445    req_builder.headers().set("Accept", "application/json")?;
1446    let req = wasm_bindgen_futures::JsFuture::from(
1447        web_sys::window()
1448            .expect("Failed to get Window object")
1449            .fetch_with_request(&req_builder),
1450    )
1451    .await?;
1452    assert!(req.is_instance_of::<web_sys::Response>());
1453    let resp: web_sys::Response = req
1454        .dyn_into()
1455        .expect("Failed to dynamically cast JsFuture into Response");
1456    super::handle_empty_response(resp).await
1457}
1458
1459/// Use this endpoint to update a recovery flow. This endpoint behaves differently for API and browser flows and has several states:  `choose_method` expects `flow` (in the URL query) and `email` (in the body) to be sent and works with API- and Browser-initiated flows. For API clients and Browser clients with HTTP Header `Accept: application/json` it either returns a HTTP 200 OK when the form is valid and HTTP 400 OK when the form is invalid. and a HTTP 303 See Other redirect with a fresh recovery flow if the flow was otherwise invalid (e.g. expired). For Browser clients without HTTP Header `Accept` or with `Accept: text/_*` it returns a HTTP 303 See Other redirect to the Recovery UI URL with the Recovery Flow ID appended. `sent_email` is the success state after `choose_method` for the `link` method and allows the user to request another recovery email. It works for both API and Browser-initiated flows and returns the same responses as the flow in `choose_method` state. `passed_challenge` expects a `token` to be sent in the URL query and given the nature of the flow (\"sending a recovery link\") does not have any API capabilities. The server responds with a HTTP 303 See Other redirect either to the Settings UI URL (if the link was valid) and instructs the user to update their password, or a redirect to the Recover UI URL with a new Recovery Flow ID which contains an error message that the recovery link was invalid.  More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery).
1460pub async fn update_recovery_flow(
1461    configuration: &configuration::Configuration,
1462    flow: &str,
1463    update_recovery_flow_body: models::UpdateRecoveryFlowBody,
1464    token: Option<&str>,
1465    cookie: Option<&str>,
1466) -> Result<models::RecoveryFlow, Error<UpdateRecoveryFlowError>> {
1467    let mut uri_str = String::new();
1468    uri_str.push_str(&configuration.base_path);
1469    uri_str.push_str("/self-service/recovery");
1470    let client = web_sys::RequestInit::new();
1471    client.set_method("POST");
1472    client.set_mode(web_sys::RequestMode::Cors);
1473    client.set_credentials(web_sys::RequestCredentials::Include);
1474    client.set_body(&JsValue::from_serde(&update_recovery_flow_body)?);
1475    let mut is_first_query: bool = true;
1476    uri_str.add_query(&mut is_first_query, "flow=", &flow.to_string());
1477    if let Some(ref str) = token {
1478        uri_str.add_query(&mut is_first_query, "token=", &str.to_string());
1479    }
1480    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
1481    if let Some(ref user_agent) = configuration.user_agent {
1482        req_builder.headers().set("USER_AGENT", user_agent)?;
1483    }
1484    if let Some(cookie) = cookie {
1485        req_builder.headers().set("Cookie", cookie)?;
1486    }
1487    req_builder.headers().set("Accept", "application/json")?;
1488    req_builder
1489        .headers()
1490        .set("Content-Type", "application/json")?;
1491    let req = wasm_bindgen_futures::JsFuture::from(
1492        web_sys::window()
1493            .expect("Failed to get Window object")
1494            .fetch_with_request(&req_builder),
1495    )
1496    .await?;
1497    assert!(req.is_instance_of::<web_sys::Response>());
1498    let resp: web_sys::Response = req
1499        .dyn_into()
1500        .expect("Failed to dynamically cast JsFuture into Response");
1501    super::handle_response(resp).await
1502}
1503
1504/// Use this endpoint to complete a registration flow by sending an identity's traits and password. This endpoint behaves differently for API and browser flows.  API flows expect `application/json` to be sent in the body and respond with HTTP 200 and a application/json body with the created identity success - if the session hook is configured the `session` and `session_token` will also be included; HTTP 410 if the original flow expired with the appropriate error messages set and optionally a `use_flow_id` parameter in the body; HTTP 400 on form validation errors.  Browser flows expect a Content-Type of `application/x-www-form-urlencoded` or `application/json` to be sent in the body and respond with a HTTP 303 redirect to the post/after registration URL or the `return_to` value if it was set and if the registration succeeded; a HTTP 303 redirect to the registration UI URL with the flow ID containing the validation errors otherwise.  Browser flows with an accept header of `application/json` will not redirect but instead respond with HTTP 200 and a application/json body with the signed in identity and a `Set-Cookie` header on success; HTTP 303 redirect to a fresh login flow if the original flow expired with the appropriate error messages set; HTTP 400 on form validation errors.  If this endpoint is called with `Accept: application/json` in the header, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `session_already_available`: The user is already signed in. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! `browser_location_change_required`: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows.  More information can be found at [Ory Kratos User Login](https://www.ory.sh/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-registration).
1505pub async fn update_registration_flow(
1506    configuration: &configuration::Configuration,
1507    flow: &str,
1508    update_registration_flow_body: models::UpdateRegistrationFlowBody,
1509    cookie: Option<&str>,
1510) -> Result<models::SuccessfulNativeRegistration, Error<UpdateRegistrationFlowError>> {
1511    let mut uri_str = String::new();
1512    uri_str.push_str(&configuration.base_path);
1513    uri_str.push_str("/self-service/registration");
1514    let client = web_sys::RequestInit::new();
1515    client.set_method("POST");
1516    client.set_mode(web_sys::RequestMode::Cors);
1517    client.set_credentials(web_sys::RequestCredentials::Include);
1518    client.set_body(&JsValue::from_serde(&update_registration_flow_body)?);
1519    let mut is_first_query: bool = true;
1520    uri_str.add_query(&mut is_first_query, "flow=", &flow.to_string());
1521    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
1522    if let Some(ref user_agent) = configuration.user_agent {
1523        req_builder.headers().set("USER_AGENT", user_agent)?;
1524    }
1525    if let Some(cookie) = cookie {
1526        req_builder.headers().set("Cookie", cookie)?;
1527    }
1528    req_builder.headers().set("Accept", "application/json")?;
1529    req_builder
1530        .headers()
1531        .set("Content-Type", "application/json")?;
1532    let req = wasm_bindgen_futures::JsFuture::from(
1533        web_sys::window()
1534            .expect("Failed to get Window object")
1535            .fetch_with_request(&req_builder),
1536    )
1537    .await?;
1538    assert!(req.is_instance_of::<web_sys::Response>());
1539    let resp: web_sys::Response = req
1540        .dyn_into()
1541        .expect("Failed to dynamically cast JsFuture into Response");
1542    super::handle_response(resp).await
1543}
1544
1545/// Use this endpoint to complete a settings flow by sending an identity's updated password. This endpoint behaves differently for API and browser flows.  API-initiated flows expect `application/json` to be sent in the body and respond with HTTP 200 and an application/json body with the session token on success; HTTP 303 redirect to a fresh settings flow if the original flow expired with the appropriate error messages set; HTTP 400 on form validation errors. HTTP 401 when the endpoint is called without a valid session token. HTTP 403 when `selfservice.flows.settings.privileged_session_max_age` was reached or the session's AAL is too low. Implies that the user needs to re-authenticate.  Browser flows without HTTP Header `Accept` or with `Accept: text/_*` respond with a HTTP 303 redirect to the post/after settings URL or the `return_to` value if it was set and if the flow succeeded; a HTTP 303 redirect to the Settings UI URL with the flow ID containing the validation errors otherwise. a HTTP 303 redirect to the login endpoint when `selfservice.flows.settings.privileged_session_max_age` was reached or the session's AAL is too low.  Browser flows with HTTP Header `Accept: application/json` respond with HTTP 200 and a application/json body with the signed in identity and a `Set-Cookie` header on success; HTTP 303 redirect to a fresh login flow if the original flow expired with the appropriate error messages set; HTTP 401 when the endpoint is called without a valid session cookie. HTTP 403 when the page is accessed without a session cookie or the session's AAL is too low. HTTP 400 on form validation errors.  Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor (happens automatically for server-side browser flows) or change the configuration.  If this endpoint is called with a `Accept: application/json` HTTP header, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  `session_refresh_required`: The identity requested to change something that needs a privileged session. Redirect the identity to the login init endpoint with query parameters `?refresh=true&return_to=<the-current-browser-url>`, or initiate a refresh login flow otherwise. `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. `session_inactive`: No Ory Session was found - sign in a user first. `security_identity_mismatch`: The flow was interrupted with `session_refresh_required` but apparently some other identity logged in instead. `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! `browser_location_change_required`: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows.  More information can be found at [Ory Kratos User Settings & Profile Management Documentation](../self-service/flows/user-settings).
1546pub async fn update_settings_flow(
1547    configuration: &configuration::Configuration,
1548    flow: &str,
1549    update_settings_flow_body: models::UpdateSettingsFlowBody,
1550    x_session_token: Option<&str>,
1551    cookie: Option<&str>,
1552) -> Result<models::SettingsFlow, Error<UpdateSettingsFlowError>> {
1553    let mut uri_str = String::new();
1554    uri_str.push_str(&configuration.base_path);
1555    uri_str.push_str("/self-service/settings");
1556    let client = web_sys::RequestInit::new();
1557    client.set_method("POST");
1558    client.set_mode(web_sys::RequestMode::Cors);
1559    client.set_credentials(web_sys::RequestCredentials::Include);
1560    client.set_body(&JsValue::from_serde(&update_settings_flow_body)?);
1561    let mut is_first_query: bool = true;
1562    uri_str.add_query(&mut is_first_query, "flow=", &flow.to_string());
1563    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
1564    if let Some(ref user_agent) = configuration.user_agent {
1565        req_builder.headers().set("USER_AGENT", user_agent)?;
1566    }
1567    if let Some(x_session_token) = x_session_token {
1568        req_builder
1569            .headers()
1570            .set("X-Session-Token", x_session_token)?;
1571    }
1572    if let Some(cookie) = cookie {
1573        req_builder.headers().set("Cookie", cookie)?;
1574    }
1575    req_builder.headers().set("Accept", "application/json")?;
1576    req_builder
1577        .headers()
1578        .set("Content-Type", "application/json")?;
1579    let req = wasm_bindgen_futures::JsFuture::from(
1580        web_sys::window()
1581            .expect("Failed to get Window object")
1582            .fetch_with_request(&req_builder),
1583    )
1584    .await?;
1585    assert!(req.is_instance_of::<web_sys::Response>());
1586    let resp: web_sys::Response = req
1587        .dyn_into()
1588        .expect("Failed to dynamically cast JsFuture into Response");
1589    super::handle_response(resp).await
1590}
1591
1592/// Use this endpoint to complete a verification flow. This endpoint behaves differently for API and browser flows and has several states:  `choose_method` expects `flow` (in the URL query) and `email` (in the body) to be sent and works with API- and Browser-initiated flows. For API clients and Browser clients with HTTP Header `Accept: application/json` it either returns a HTTP 200 OK when the form is valid and HTTP 400 OK when the form is invalid and a HTTP 303 See Other redirect with a fresh verification flow if the flow was otherwise invalid (e.g. expired). For Browser clients without HTTP Header `Accept` or with `Accept: text/_*` it returns a HTTP 303 See Other redirect to the Verification UI URL with the Verification Flow ID appended. `sent_email` is the success state after `choose_method` when using the `link` method and allows the user to request another verification email. It works for both API and Browser-initiated flows and returns the same responses as the flow in `choose_method` state. `passed_challenge` expects a `token` to be sent in the URL query and given the nature of the flow (\"sending a verification link\") does not have any API capabilities. The server responds with a HTTP 303 See Other redirect either to the Settings UI URL (if the link was valid) and instructs the user to update their password, or a redirect to the Verification UI URL with a new Verification Flow ID which contains an error message that the verification link was invalid.  More information can be found at [Ory Kratos Email and Phone Verification Documentation](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation).
1593pub async fn update_verification_flow(
1594    configuration: &configuration::Configuration,
1595    flow: &str,
1596    update_verification_flow_body: models::UpdateVerificationFlowBody,
1597    token: Option<&str>,
1598    cookie: Option<&str>,
1599) -> Result<models::VerificationFlow, Error<UpdateVerificationFlowError>> {
1600    let mut uri_str = String::new();
1601    uri_str.push_str(&configuration.base_path);
1602    uri_str.push_str("/self-service/verification");
1603    let client = web_sys::RequestInit::new();
1604    client.set_method("POST");
1605    client.set_mode(web_sys::RequestMode::Cors);
1606    client.set_credentials(web_sys::RequestCredentials::Include);
1607    client.set_body(&JsValue::from_serde(&update_verification_flow_body)?);
1608    let mut is_first_query: bool = true;
1609    uri_str.add_query(&mut is_first_query, "flow=", &flow.to_string());
1610    if let Some(ref str) = token {
1611        uri_str.add_query(&mut is_first_query, "token=", &str.to_string());
1612    }
1613    let req_builder = web_sys::Request::new_with_str_and_init(&uri_str, &client)?;
1614    if let Some(ref user_agent) = configuration.user_agent {
1615        req_builder.headers().set("USER_AGENT", user_agent)?;
1616    }
1617    if let Some(cookie) = cookie {
1618        req_builder.headers().set("Cookie", cookie)?;
1619    }
1620    req_builder.headers().set("Accept", "application/json")?;
1621    req_builder
1622        .headers()
1623        .set("Content-Type", "application/json")?;
1624    let req = wasm_bindgen_futures::JsFuture::from(
1625        web_sys::window()
1626            .expect("Failed to get Window object")
1627            .fetch_with_request(&req_builder),
1628    )
1629    .await?;
1630    assert!(req.is_instance_of::<web_sys::Response>());
1631    let resp: web_sys::Response = req
1632        .dyn_into()
1633        .expect("Failed to dynamically cast JsFuture into Response");
1634    super::handle_response(resp).await
1635}