Skip to main content

dfns_sdk_rust/auth/
mod.rs

1// Code generated by rust-sdk-generator. DO NOT EDIT.
2
3pub mod types;
4
5#[allow(unused_imports)]
6use types::*;
7
8/// Client for auth operations.
9#[derive(Clone)]
10pub struct AuthClient {
11    client: crate::client::Client,
12}
13
14impl AuthClient {
15    pub fn new(client: crate::client::Client) -> Self {
16        AuthClient { client }
17    }
18
19    /// Completes the user action signing process and provides a signing token that can be used to verify the user intended to perform the action.
20    ///
21    /// This is the first step of the [User Action Signing flow](https://docs.dfns.co/api-reference/auth/signing-flows).
22    ///
23    pub async fn create_user_action_signature(
24        &self,
25        body: CreateUserActionSignatureRequest,
26    ) -> Result<CreateUserActionSignatureResponse, crate::error::Error> {
27        let path = String::from("/auth/action");
28        let body = serde_json::to_value(&body)?;
29        self.client
30            .request::<CreateUserActionSignatureResponse>(
31                reqwest::Method::POST,
32                &path,
33                Some(&body),
34                false,
35            )
36            .await
37    }
38
39    /// Starts a user action signing session, returning a challenge that will be used to verify the user's intent to perform an action.
40    ///   
41    ///   This is the first step of the [User Action Signing flow](https://docs.dfns.co/api-reference/auth/signing-flows).
42    pub async fn create_user_action_challenge(
43        &self,
44        body: CreateUserActionChallengeRequest,
45    ) -> Result<CreateUserActionChallengeResponse, crate::error::Error> {
46        let path = String::from("/auth/action/init");
47        let body = serde_json::to_value(&body)?;
48        self.client
49            .request::<CreateUserActionChallengeResponse>(
50                reqwest::Method::POST,
51                &path,
52                Some(&body),
53                false,
54            )
55            .await
56    }
57
58    /// Gets all signature events which have occurred in the over the timeframe. The time range is unbounded, but the export is capped at 100,000 rows. When the result is truncated, the `X-Dfns-Result-Truncated: true` response header is set and a trailing `# TRUNCATED ...` line is appended to the CSV; narrow the time range to retrieve all data.
59    ///
60    /// StartTime and EndTime are URL-encoded UTC ISO timestamps:
61    /// `startTime=2025-08-29T02%3A46%3A40Z`   
62    pub async fn list_audit_logs(
63        &self,
64        query: Option<ListAuditLogsQuery>,
65    ) -> Result<(), crate::error::Error> {
66        let mut path = String::from("/auth/action/logs");
67        if let Some(query) = &query {
68            let mut q: Vec<String> = Vec::new();
69            q.push(format!(
70                "startTime={}",
71                urlencoding::encode(&query.start_time.to_string())
72            ));
73            q.push(format!(
74                "endTime={}",
75                urlencoding::encode(&query.end_time.to_string())
76            ));
77            if let Some(v) = &query.user_id {
78                q.push(format!("userId={}", urlencoding::encode(&v.to_string())));
79            }
80            if !q.is_empty() {
81                path.push('?');
82                path.push_str(&q.join("&"));
83            }
84        }
85        self.client
86            .request_no_content(reqwest::Method::GET, &path, None, false)
87            .await
88    }
89
90    /// Gets detailed information for a particular audit log. Specifically, the API returns the action performed, as well as the `firstFactorCredential` in which you will find the signature information required to validate it.
91    ///
92    /// Dfns maintains a script which can be used for audit log signature validation: [WebAuthn Signature Verifier](https://github.com/dfns/example-scripts/tree/m/python/utils)
93    pub async fn get_audit_log(
94        &self,
95        id: String,
96    ) -> Result<GetAuditLogResponse, crate::error::Error> {
97        let path = format!("/auth/action/logs/{}", urlencoding::encode(&id));
98        self.client
99            .request::<GetAuditLogResponse>(reqwest::Method::GET, &path, None, false)
100            .await
101    }
102
103    /// <Warning>
104    ///   Applications are deprecated and will be removed in a future release. See details [here](https://docs.dfns.co/deprecation/applications-deprecation).
105    ///   </Warning>
106    #[deprecated(note = "This endpoint is deprecated.")]
107    pub async fn list_applications(&self) -> Result<ListApplicationsResponse, crate::error::Error> {
108        let path = String::from("/auth/apps");
109        self.client
110            .request::<ListApplicationsResponse>(reqwest::Method::GET, &path, None, false)
111            .await
112    }
113
114    /// <Warning>
115    ///   Applications are deprecated and will be removed in a future release. See details [here](https://docs.dfns.co/deprecation/applications-deprecation).
116    ///   </Warning>
117    #[deprecated(note = "This endpoint is deprecated.")]
118    pub async fn get_application(
119        &self,
120        app_id: String,
121    ) -> Result<GetApplicationResponse, crate::error::Error> {
122        let path = format!("/auth/apps/{}", urlencoding::encode(&app_id));
123        self.client
124            .request::<GetApplicationResponse>(reqwest::Method::GET, &path, None, false)
125            .await
126    }
127
128    /// List all credentials for a user.
129    pub async fn list_credentials(&self) -> Result<ListCredentialsResponse, crate::error::Error> {
130        let path = String::from("/auth/credentials");
131        self.client
132            .request::<ListCredentialsResponse>(reqwest::Method::GET, &path, None, false)
133            .await
134    }
135
136    /// Part of the flow [Create Credential Regular flow](https://docs.dfns.co/api-reference/auth/credentials#regular-flow).
137    ///
138    /// Adds a new credential to a user's account. See [Credential Kinds](https://docs.dfns.co/api-reference/auth/credentials#credential-kinds) for all supported credential types.
139    pub async fn create_credential(
140        &self,
141        body: CreateCredentialRequest,
142    ) -> Result<CreateCredentialResponse, crate::error::Error> {
143        let path = String::from("/auth/credentials");
144        let body = serde_json::to_value(&body)?;
145        self.client
146            .request::<CreateCredentialResponse>(reqwest::Method::POST, &path, Some(&body), true)
147            .await
148    }
149
150    /// Part of the flow [Create Credential Regular flow](https://docs.dfns.co/api-reference/auth/credentials#regular-flow).
151    ///   
152    ///   Starts a create user credential session, returning a challenge that will be used to verify the user's identity.
153    pub async fn create_credential_challenge(
154        &self,
155        body: CreateCredentialChallengeRequest,
156    ) -> Result<serde_json::Value, crate::error::Error> {
157        let path = String::from("/auth/credentials/init");
158        let body = serde_json::to_value(&body)?;
159        self.client
160            .request::<serde_json::Value>(reqwest::Method::POST, &path, Some(&body), false)
161            .await
162    }
163
164    /// Activates a credential that was previously deactivated. If the credential is already activated no action is taken.
165    pub async fn activate_credential(
166        &self,
167        body: ActivateCredentialRequest,
168    ) -> Result<ActivateCredentialResponse, crate::error::Error> {
169        let path = String::from("/auth/credentials/activate");
170        let body = serde_json::to_value(&body)?;
171        self.client
172            .request::<ActivateCredentialResponse>(reqwest::Method::PUT, &path, Some(&body), true)
173            .await
174    }
175
176    /// Delete a specific credential.
177    pub async fn delete_credential(
178        &self,
179        credential_uuid: String,
180    ) -> Result<DeleteCredentialResponse, crate::error::Error> {
181        let path = format!(
182            "/auth/credentials/{}",
183            urlencoding::encode(&credential_uuid)
184        );
185        self.client
186            .request::<DeleteCredentialResponse>(reqwest::Method::DELETE, &path, None, true)
187            .await
188    }
189
190    /// Deactivates a credential that was previously active. If the credential is already deactivated no action is taken.
191    pub async fn deactivate_credential(
192        &self,
193        body: DeactivateCredentialRequest,
194    ) -> Result<DeactivateCredentialResponse, crate::error::Error> {
195        let path = String::from("/auth/credentials/deactivate");
196        let body = serde_json::to_value(&body)?;
197        self.client
198            .request::<DeactivateCredentialResponse>(reqwest::Method::PUT, &path, Some(&body), true)
199            .await
200    }
201
202    /// Part of the [Create Credential With Code flow](https://docs.dfns.co/api-reference/auth/credentials#create-credential-with-code-flow).
203    ///
204    /// Creates a one-time-code that can then be used to create a new credential from a place you don't have access to one of your existing credential.
205    pub async fn create_credential_code(
206        &self,
207        body: CreateCredentialCodeRequest,
208    ) -> Result<CreateCredentialCodeResponse, crate::error::Error> {
209        let path = String::from("/auth/credentials/code");
210        let body = serde_json::to_value(&body)?;
211        self.client
212            .request::<CreateCredentialCodeResponse>(
213                reqwest::Method::POST,
214                &path,
215                Some(&body),
216                true,
217            )
218            .await
219    }
220
221    /// Part of the flow [Create Credential With Code](https://docs.dfns.co/api-reference/auth/credentials#create-credential-with-code-flow).
222    ///
223    /// Creates a credential challenge using a one time code-time-code. This challenge must then be signed by the new credential, before finalizing the flow.
224    pub async fn create_credential_challenge_with_code(
225        &self,
226        body: CreateCredentialChallengeWithCodeRequest,
227    ) -> Result<serde_json::Value, crate::error::Error> {
228        let path = String::from("/auth/credentials/code/init");
229        let body = serde_json::to_value(&body)?;
230        self.client
231            .request::<serde_json::Value>(reqwest::Method::POST, &path, Some(&body), false)
232            .await
233    }
234
235    /// Finalizes the flow [Create Credential With Code](https://docs.dfns.co/api-reference/auth/credentials#create-credential-with-code-flow).
236    ///   
237    /// Adds a new credential to a user's account. This endpoint is similar to the [Create Credential](https://docs.dfns.co/api-reference/auth/create-credential) endpoint, except:
238    /// * it does not need the user to be authenticated
239    pub async fn create_credential_with_code(
240        &self,
241        body: CreateCredentialWithCodeRequest,
242    ) -> Result<CreateCredentialWithCodeResponse, crate::error::Error> {
243        let path = String::from("/auth/credentials/code/verify");
244        let body = serde_json::to_value(&body)?;
245        self.client
246            .request::<CreateCredentialWithCodeResponse>(
247                reqwest::Method::POST,
248                &path,
249                Some(&body),
250                false,
251            )
252            .await
253    }
254
255    /// Start a user login session, returning a challenge that will be used to verify the user's identity.
256    ///
257    /// If the user has a credential of kind `PasswordProtectedKey` a temporary one time code needs to be passed in the `loginCode` field.
258    ///
259    pub async fn create_login_challenge(
260        &self,
261        body: CreateLoginChallengeRequest,
262    ) -> Result<CreateLoginChallengeResponse, crate::error::Error> {
263        let path = String::from("/auth/login/init");
264        let body = serde_json::to_value(&body)?;
265        self.client
266            .request::<CreateLoginChallengeResponse>(
267                reqwest::Method::POST,
268                &path,
269                Some(&body),
270                false,
271            )
272            .await
273    }
274
275    /// <Warning>
276    /// Only a [Service Account](https://docs.dfns.co/api-reference/auth/service-accounts) can use this endpoint.
277    /// </Warning>
278    ///
279    pub async fn delegated_login(
280        &self,
281        body: DelegatedLoginRequest,
282    ) -> Result<DelegatedLoginResponse, crate::error::Error> {
283        let path = String::from("/auth/login/delegated");
284        let body = serde_json::to_value(&body)?;
285        self.client
286            .request::<DelegatedLoginResponse>(reqwest::Method::POST, &path, Some(&body), true)
287            .await
288    }
289
290    /// Completes the login process and provides the authenticated user with their authentication token.
291    ///
292    /// The type of credentials used to login is determined by the `kind` field in the nested objects (`firstFactor` and `secondFactor`). Supported credential kinds are:
293    /// * `Fido2`: Login challenge is signed by a user's signing device using `WebAuthn`.
294    pub async fn complete_user_login(
295        &self,
296        body: CompleteUserLoginRequest,
297    ) -> Result<serde_json::Value, crate::error::Error> {
298        let path = String::from("/auth/login");
299        let body = serde_json::to_value(&body)?;
300        self.client
301            .request::<serde_json::Value>(reqwest::Method::POST, &path, Some(&body), false)
302            .await
303    }
304
305    /// Completes the user logout process.
306    pub async fn logout(&self, body: LogoutRequest) -> Result<LogoutResponse, crate::error::Error> {
307        let path = String::from("/auth/logout");
308        let body = serde_json::to_value(&body)?;
309        self.client
310            .request::<LogoutResponse>(reqwest::Method::PUT, &path, Some(&body), false)
311            .await
312    }
313
314    /// Sends a temporary one time code to the user that can be used during login flow.
315    ///
316    /// If the user has a credential of kind `PasswordProtectedKey` a temporary one time code needs to be passed in the `loginCode` field. That's because the [Create Login Challenge](https://docs.dfns.co/api-reference/auth/create-login-challenge) is unauthenticated and returns the encrypted private key of the user. So we need a first step to verify the identity of the user to prevent anybody from fetching the encrypted private key and trying to brute force it offline.
317    pub async fn send_login_code(
318        &self,
319        body: SendLoginCodeRequest,
320    ) -> Result<SendLoginCodeResponse, crate::error::Error> {
321        let path = String::from("/auth/login/code");
322        let body = serde_json::to_value(&body)?;
323        self.client
324            .request::<SendLoginCodeResponse>(reqwest::Method::POST, &path, Some(&body), false)
325            .await
326    }
327
328    /// Logs a user in with a JWT id token issued by a social login provider and provides the authenticated user with their authentication token.
329    pub async fn social_login(
330        &self,
331        body: SocialLoginRequest,
332    ) -> Result<SocialLoginResponse, crate::error::Error> {
333        let path = String::from("/auth/login/social");
334        let body = serde_json::to_value(&body)?;
335        self.client
336            .request::<SocialLoginResponse>(reqwest::Method::POST, &path, Some(&body), false)
337            .await
338    }
339
340    /// Completes the SSO login process by exchanging the authorization code obtained from the identity provider for the user's authentication token.
341    pub async fn complete_sso_login(
342        &self,
343        body: CompleteSsoLoginRequest,
344    ) -> Result<CompleteSsoLoginResponse, crate::error::Error> {
345        let path = String::from("/auth/login/sso");
346        let body = serde_json::to_value(&body)?;
347        self.client
348            .request::<CompleteSsoLoginResponse>(reqwest::Method::POST, &path, Some(&body), false)
349            .await
350    }
351
352    /// Initialize the login process with SSO by returning the IdP URL to call.
353    pub async fn initiate_sso_login(
354        &self,
355        body: InitiateSsoLoginRequest,
356    ) -> Result<InitiateSsoLoginResponse, crate::error::Error> {
357        let path = String::from("/auth/login/sso/init");
358        let body = serde_json::to_value(&body)?;
359        self.client
360            .request::<InitiateSsoLoginResponse>(reqwest::Method::POST, &path, Some(&body), false)
361            .await
362    }
363
364    /// Only for TenantUsers - Exchanges the current user access token, for an org-bound or tenant-bound token. The user must have access to the target org / tenant. The new access token expiration won't exceed the current token's one.
365    pub async fn exchange_access_token(
366        &self,
367        body: ExchangeAccessTokenRequest,
368    ) -> Result<ExchangeAccessTokenResponse, crate::error::Error> {
369        let path = String::from("/auth/tokens");
370        let body = serde_json::to_value(&body)?;
371        self.client
372            .request::<ExchangeAccessTokenResponse>(
373                reqwest::Method::POST,
374                &path,
375                Some(&body),
376                false,
377            )
378            .await
379    }
380
381    /// Retrieve the list of your Personal Access Tokens.
382    pub async fn list_personal_access_tokens(
383        &self,
384    ) -> Result<ListPersonalAccessTokensResponse, crate::error::Error> {
385        let path = String::from("/auth/pats");
386        self.client
387            .request::<ListPersonalAccessTokensResponse>(reqwest::Method::GET, &path, None, false)
388            .await
389    }
390
391    /// Create a new Personal Access Token for the caller.
392    pub async fn create_personal_access_token(
393        &self,
394        body: CreatePersonalAccessTokenRequest,
395    ) -> Result<CreatePersonalAccessTokenResponse, crate::error::Error> {
396        let path = String::from("/auth/pats");
397        let body = serde_json::to_value(&body)?;
398        self.client
399            .request::<CreatePersonalAccessTokenResponse>(
400                reqwest::Method::POST,
401                &path,
402                Some(&body),
403                true,
404            )
405            .await
406    }
407
408    /// Retrieve a specific Personal Access Token.
409    pub async fn get_personal_access_token(
410        &self,
411        token_id: String,
412    ) -> Result<GetPersonalAccessTokenResponse, crate::error::Error> {
413        let path = format!("/auth/pats/{}", urlencoding::encode(&token_id));
414        self.client
415            .request::<GetPersonalAccessTokenResponse>(reqwest::Method::GET, &path, None, false)
416            .await
417    }
418
419    /// Update a specific Personal Access Token.
420    pub async fn update_personal_access_token(
421        &self,
422        token_id: String,
423        body: UpdatePersonalAccessTokenRequest,
424    ) -> Result<UpdatePersonalAccessTokenResponse, crate::error::Error> {
425        let path = format!("/auth/pats/{}", urlencoding::encode(&token_id));
426        let body = serde_json::to_value(&body)?;
427        self.client
428            .request::<UpdatePersonalAccessTokenResponse>(
429                reqwest::Method::PUT,
430                &path,
431                Some(&body),
432                true,
433            )
434            .await
435    }
436
437    /// Delete a specific Personal Access Token.
438    pub async fn delete_personal_access_token(
439        &self,
440        token_id: String,
441    ) -> Result<DeletePersonalAccessTokenResponse, crate::error::Error> {
442        let path = format!("/auth/pats/{}", urlencoding::encode(&token_id));
443        self.client
444            .request::<DeletePersonalAccessTokenResponse>(
445                reqwest::Method::DELETE,
446                &path,
447                None,
448                true,
449            )
450            .await
451    }
452
453    /// Activate a specific Personal Access Token.
454    pub async fn activate_personal_access_token(
455        &self,
456        token_id: String,
457    ) -> Result<ActivatePersonalAccessTokenResponse, crate::error::Error> {
458        let path = format!("/auth/pats/{}/activate", urlencoding::encode(&token_id));
459        self.client
460            .request::<ActivatePersonalAccessTokenResponse>(reqwest::Method::PUT, &path, None, true)
461            .await
462    }
463
464    /// Deactivates a personal access token that was previously active. If the token is already deactivated no action is taken.
465    pub async fn deactivate_personal_access_token(
466        &self,
467        token_id: String,
468    ) -> Result<DeactivatePersonalAccessTokenResponse, crate::error::Error> {
469        let path = format!("/auth/pats/{}/deactivate", urlencoding::encode(&token_id));
470        self.client
471            .request::<DeactivatePersonalAccessTokenResponse>(
472                reqwest::Method::PUT,
473                &path,
474                None,
475                true,
476            )
477            .await
478    }
479
480    /// <Warning>
481    /// Only a [Service Account](https://docs.dfns.co/api-reference/auth/service-accounts) can use this endpoint.
482    /// </Warning>
483    ///
484    pub async fn create_delegated_recovery_challenge(
485        &self,
486        body: CreateDelegatedRecoveryChallengeRequest,
487    ) -> Result<CreateDelegatedRecoveryChallengeResponse, crate::error::Error> {
488        let path = String::from("/auth/recover/user/delegated");
489        let body = serde_json::to_value(&body)?;
490        self.client
491            .request::<CreateDelegatedRecoveryChallengeResponse>(
492                reqwest::Method::POST,
493                &path,
494                Some(&body),
495                true,
496            )
497            .await
498    }
499
500    /// Recovers a user, using a recovery credential. After successfully recovering the user, all of the user's previous credentials and personal access tokens will be invalidated.
501    ///
502    /// This flow requires cryptographic validation of newly created credential(s) using a recovery credential. The `recovery.credentialAssertion.clientData` field's challenge must be the _base64url-encoded_ representation of the `newCredential` object.
503    ///
504    pub async fn recover_user(
505        &self,
506        body: RecoverUserRequest,
507    ) -> Result<RecoverUserResponse, crate::error::Error> {
508        let path = String::from("/auth/recover/user");
509        let body = serde_json::to_value(&body)?;
510        self.client
511            .request::<RecoverUserResponse>(reqwest::Method::POST, &path, Some(&body), false)
512            .await
513    }
514
515    /// Starts a user recovery session, returning a challenge that will be used to verify the user's identity.
516    pub async fn create_recovery_challenge(
517        &self,
518        body: CreateRecoveryChallengeRequest,
519    ) -> Result<CreateRecoveryChallengeResponse, crate::error::Error> {
520        let path = String::from("/auth/recover/user/init");
521        let body = serde_json::to_value(&body)?;
522        self.client
523            .request::<CreateRecoveryChallengeResponse>(
524                reqwest::Method::POST,
525                &path,
526                Some(&body),
527                false,
528            )
529            .await
530    }
531
532    /// Send the user a recovery verification code. This code is used as a second factor to verify the user initiated the recovery request.
533    pub async fn send_recovery_code_email(
534        &self,
535        body: SendRecoveryCodeEmailRequest,
536    ) -> Result<SendRecoveryCodeEmailResponse, crate::error::Error> {
537        let path = String::from("/auth/recover/user/code");
538        let body = serde_json::to_value(&body)?;
539        self.client
540            .request::<SendRecoveryCodeEmailResponse>(
541                reqwest::Method::POST,
542                &path,
543                Some(&body),
544                false,
545            )
546            .await
547    }
548
549    /// <Warning>
550    /// Only a [Service Account](https://docs.dfns.co/api-reference/auth/service-accounts) can use this endpoint.
551    /// </Warning>
552    ///
553    pub async fn create_delegated_registration_challenge(
554        &self,
555        body: CreateDelegatedRegistrationChallengeRequest,
556    ) -> Result<CreateDelegatedRegistrationChallengeResponse, crate::error::Error> {
557        let path = String::from("/auth/registration/delegated");
558        let body = serde_json::to_value(&body)?;
559        self.client
560            .request::<CreateDelegatedRegistrationChallengeResponse>(
561                reqwest::Method::POST,
562                &path,
563                Some(&body),
564                true,
565            )
566            .await
567    }
568
569    /// Starts a user registration session. It returns a challenge that will need to be signed by a passkey and used to perform the step [Complete User Registration](/api-reference/auth/complete-user-registration)
570    pub async fn create_registration_challenge(
571        &self,
572        body: CreateRegistrationChallengeRequest,
573    ) -> Result<CreateRegistrationChallengeResponse, crate::error::Error> {
574        let path = String::from("/auth/registration/init");
575        let body = serde_json::to_value(&body)?;
576        self.client
577            .request::<CreateRegistrationChallengeResponse>(
578                reqwest::Method::POST,
579                &path,
580                Some(&body),
581                false,
582            )
583            .await
584    }
585
586    /// Starts an end-user registration session by passing a JWT obtained by an IdP. It returns a challenge that will need to be signed by a passkey and used to perform [Complete End User Registration with Wallets](/api-reference/auth/complete-end-user-registration-with-wallets).
587    pub async fn create_social_registration_challenge(
588        &self,
589        body: CreateSocialRegistrationChallengeRequest,
590    ) -> Result<CreateSocialRegistrationChallengeResponse, crate::error::Error> {
591        let path = String::from("/auth/registration/social");
592        let body = serde_json::to_value(&body)?;
593        self.client
594            .request::<CreateSocialRegistrationChallengeResponse>(
595                reqwest::Method::POST,
596                &path,
597                Some(&body),
598                false,
599            )
600            .await
601    }
602
603    /// Completes the user registration process and creates the user's initial credentials.
604    ///
605    /// All credentials submitted in this call (`firstFactorCredential`, `secondFactorCredential`, `recoveryCredential`) sign the same challenge returned by the registration init endpoint ([Create Registration Challenge](https://docs.dfns.co/api-reference/auth/create-registration-challenge), [Create Delegated Registration Challenge](https://docs.dfns.co/api-reference/auth/create-delegated-registration-challenge), or [Create Social Registration Challenge](https://docs.dfns.co/api-reference/auth/create-social-registration-challenge)).
606    ///
607    pub async fn complete_user_registration(
608        &self,
609        body: CompleteUserRegistrationRequest,
610    ) -> Result<CompleteUserRegistrationResponse, crate::error::Error> {
611        let path = String::from("/auth/registration");
612        let body = serde_json::to_value(&body)?;
613        self.client
614            .request::<CompleteUserRegistrationResponse>(
615                reqwest::Method::POST,
616                &path,
617                Some(&body),
618                false,
619            )
620            .await
621    }
622
623    /// Completes the end user registration process and creates the user's initial credentials along with delegated wallets for the new end user.
624    ///
625    /// All credentials submitted in this call (`firstFactorCredential`, `secondFactorCredential`, `recoveryCredential`) sign the same challenge returned by the registration init endpoint ([Create Delegated Registration Challenge](https://docs.dfns.co/api-reference/auth/create-delegated-registration-challenge) or [Create Social Registration Challenge](https://docs.dfns.co/api-reference/auth/create-social-registration-challenge)).
626    ///
627    pub async fn complete_end_user_registration_with_wallets(
628        &self,
629        body: CompleteEndUserRegistrationWithWalletsRequest,
630    ) -> Result<CompleteEndUserRegistrationWithWalletsResponse, crate::error::Error> {
631        let path = String::from("/auth/registration/enduser");
632        let body = serde_json::to_value(&body)?;
633        self.client
634            .request::<CompleteEndUserRegistrationWithWalletsResponse>(
635                reqwest::Method::POST,
636                &path,
637                Some(&body),
638                false,
639            )
640            .await
641    }
642
643    /// Sends the user a new registration code. The previous registration code will be marked invalid. If the user has already completed their registration no action will be taken.
644    pub async fn resend_registration_code(
645        &self,
646        body: ResendRegistrationCodeRequest,
647    ) -> Result<ResendRegistrationCodeResponse, crate::error::Error> {
648        let path = String::from("/auth/registration/code");
649        let body = serde_json::to_value(&body)?;
650        self.client
651            .request::<ResendRegistrationCodeResponse>(
652                reqwest::Method::PUT,
653                &path,
654                Some(&body),
655                false,
656            )
657            .await
658    }
659
660    /// List all Service Accounts in your organization.
661    pub async fn list_service_accounts(
662        &self,
663    ) -> Result<ListServiceAccountsResponse, crate::error::Error> {
664        let path = String::from("/auth/service-accounts");
665        self.client
666            .request::<ListServiceAccountsResponse>(reqwest::Method::GET, &path, None, false)
667            .await
668    }
669
670    /// Create a new Service Account for your organization.
671    pub async fn create_service_account(
672        &self,
673        body: CreateServiceAccountRequest,
674    ) -> Result<CreateServiceAccountResponse, crate::error::Error> {
675        let path = String::from("/auth/service-accounts");
676        let body = serde_json::to_value(&body)?;
677        self.client
678            .request::<CreateServiceAccountResponse>(
679                reqwest::Method::POST,
680                &path,
681                Some(&body),
682                true,
683            )
684            .await
685    }
686
687    /// Get information about a specific Service Account.
688    pub async fn get_service_account(
689        &self,
690        service_account_id: String,
691    ) -> Result<GetServiceAccountResponse, crate::error::Error> {
692        let path = format!(
693            "/auth/service-accounts/{}",
694            urlencoding::encode(&service_account_id)
695        );
696        self.client
697            .request::<GetServiceAccountResponse>(reqwest::Method::GET, &path, None, false)
698            .await
699    }
700
701    /// Update a specific Service Account.
702    pub async fn update_service_account(
703        &self,
704        service_account_id: String,
705        body: UpdateServiceAccountRequest,
706    ) -> Result<UpdateServiceAccountResponse, crate::error::Error> {
707        let path = format!(
708            "/auth/service-accounts/{}",
709            urlencoding::encode(&service_account_id)
710        );
711        let body = serde_json::to_value(&body)?;
712        self.client
713            .request::<UpdateServiceAccountResponse>(reqwest::Method::PUT, &path, Some(&body), true)
714            .await
715    }
716
717    /// Delete a specific Service Account.
718    pub async fn delete_service_account(
719        &self,
720        service_account_id: String,
721        query: Option<DeleteServiceAccountQuery>,
722    ) -> Result<DeleteServiceAccountResponse, crate::error::Error> {
723        let mut path = format!(
724            "/auth/service-accounts/{}",
725            urlencoding::encode(&service_account_id)
726        );
727        if let Some(query) = &query {
728            let mut q: Vec<String> = Vec::new();
729            if let Some(v) = &query.force {
730                q.push(format!("force={}", urlencoding::encode(&v.to_string())));
731            }
732            if !q.is_empty() {
733                path.push('?');
734                path.push_str(&q.join("&"));
735            }
736        }
737        self.client
738            .request::<DeleteServiceAccountResponse>(reqwest::Method::DELETE, &path, None, true)
739            .await
740    }
741
742    /// Activate a specific Service Account.
743    pub async fn activate_service_account(
744        &self,
745        service_account_id: String,
746    ) -> Result<ActivateServiceAccountResponse, crate::error::Error> {
747        let path = format!(
748            "/auth/service-accounts/{}/activate",
749            urlencoding::encode(&service_account_id)
750        );
751        self.client
752            .request::<ActivateServiceAccountResponse>(reqwest::Method::PUT, &path, None, true)
753            .await
754    }
755
756    /// Deactivate a specific Service Account.
757    pub async fn deactivate_service_account(
758        &self,
759        service_account_id: String,
760        body: DeactivateServiceAccountRequest,
761    ) -> Result<DeactivateServiceAccountResponse, crate::error::Error> {
762        let path = format!(
763            "/auth/service-accounts/{}/deactivate",
764            urlencoding::encode(&service_account_id)
765        );
766        let body = serde_json::to_value(&body)?;
767        self.client
768            .request::<DeactivateServiceAccountResponse>(
769                reqwest::Method::PUT,
770                &path,
771                Some(&body),
772                true,
773            )
774            .await
775    }
776
777    /// Activate a specific User.
778    pub async fn activate_user(
779        &self,
780        user_id: String,
781    ) -> Result<ActivateUserResponse, crate::error::Error> {
782        let path = format!("/auth/users/{}/activate", urlencoding::encode(&user_id));
783        self.client
784            .request::<ActivateUserResponse>(reqwest::Method::PUT, &path, None, true)
785            .await
786    }
787
788    /// Deactivate a specific User.
789    pub async fn deactivate_user(
790        &self,
791        user_id: String,
792    ) -> Result<DeactivateUserResponse, crate::error::Error> {
793        let path = format!("/auth/users/{}/deactivate", urlencoding::encode(&user_id));
794        self.client
795            .request::<DeactivateUserResponse>(reqwest::Method::PUT, &path, None, true)
796            .await
797    }
798
799    /// Retrieve information about a specific User.
800    pub async fn get_user(&self, user_id: String) -> Result<GetUserResponse, crate::error::Error> {
801        let path = format!("/auth/users/{}", urlencoding::encode(&user_id));
802        self.client
803            .request::<GetUserResponse>(reqwest::Method::GET, &path, None, false)
804            .await
805    }
806
807    /// Update a specific User.
808    pub async fn update_user(
809        &self,
810        user_id: String,
811        body: UpdateUserRequest,
812    ) -> Result<UpdateUserResponse, crate::error::Error> {
813        let path = format!("/auth/users/{}", urlencoding::encode(&user_id));
814        let body = serde_json::to_value(&body)?;
815        self.client
816            .request::<UpdateUserResponse>(reqwest::Method::PUT, &path, Some(&body), true)
817            .await
818    }
819
820    /// Delete a specific User.
821    pub async fn delete_user(
822        &self,
823        user_id: String,
824    ) -> Result<DeleteUserResponse, crate::error::Error> {
825        let path = format!("/auth/users/{}", urlencoding::encode(&user_id));
826        self.client
827            .request::<DeleteUserResponse>(reqwest::Method::DELETE, &path, None, true)
828            .await
829    }
830
831    /// List all Users in your organization.
832    pub async fn list_users(
833        &self,
834        query: Option<ListUsersQuery>,
835    ) -> Result<ListUsersResponse, crate::error::Error> {
836        let mut path = String::from("/auth/users");
837        if let Some(query) = &query {
838            let mut q: Vec<String> = Vec::new();
839            if let Some(v) = &query.limit {
840                q.push(format!("limit={}", urlencoding::encode(&v.to_string())));
841            }
842            if let Some(v) = &query.pagination_token {
843                q.push(format!(
844                    "paginationToken={}",
845                    urlencoding::encode(&v.to_string())
846                ));
847            }
848            if let Some(v) = &query.kind {
849                q.push(format!("kind={}", urlencoding::encode(&v.to_string())));
850            }
851            if !q.is_empty() {
852                path.push('?');
853                path.push_str(&q.join("&"));
854            }
855        }
856        self.client
857            .request::<ListUsersResponse>(reqwest::Method::GET, &path, None, false)
858            .await
859    }
860
861    /// Invite a new user in the caller's org. This will create the user and send a registration email to the created User's email, with a registration code, and pointing him to complete his registration on Dfns Dashboard. The user is created without any permissions.
862    ///   
863    ///   <Note>If you want the created User to not know about about Dfns, and don't want him to
864    ///   receive the registration email from Dfns, you should rather use the Delegated Registration
865    pub async fn create_user(
866        &self,
867        body: CreateUserRequest,
868    ) -> Result<CreateUserResponse, crate::error::Error> {
869        let path = String::from("/auth/users");
870        let body = serde_json::to_value(&body)?;
871        self.client
872            .request::<CreateUserResponse>(reqwest::Method::POST, &path, Some(&body), true)
873            .await
874    }
875
876    /// Invite an existing Tenant User in the caller's org. The invited Tenant User starts without any permissions within the org.
877    pub async fn invite_tenant_user(
878        &self,
879        body: InviteTenantUserRequest,
880    ) -> Result<InviteTenantUserResponse, crate::error::Error> {
881        let path = String::from("/auth/users/invite");
882        let body = serde_json::to_value(&body)?;
883        self.client
884            .request::<InviteTenantUserResponse>(reqwest::Method::POST, &path, Some(&body), true)
885            .await
886    }
887}