dfns-sdk 0.0.0.dev0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. dfns_sdk/__init__.py +24 -0
  2. dfns_sdk/_internal/__init__.py +5 -0
  3. dfns_sdk/_internal/http_client.py +395 -0
  4. dfns_sdk/auth.py +137 -0
  5. dfns_sdk/base_auth_api.py +129 -0
  6. dfns_sdk/client.py +81 -0
  7. dfns_sdk/delegated_client.py +97 -0
  8. dfns_sdk/generated/__init__.py +47 -0
  9. dfns_sdk/generated/agreements/__init__.py +7 -0
  10. dfns_sdk/generated/agreements/client.py +55 -0
  11. dfns_sdk/generated/agreements/delegated_client.py +95 -0
  12. dfns_sdk/generated/agreements/types.py +20 -0
  13. dfns_sdk/generated/allocations/__init__.py +7 -0
  14. dfns_sdk/generated/allocations/client.py +118 -0
  15. dfns_sdk/generated/allocations/delegated_client.py +187 -0
  16. dfns_sdk/generated/allocations/types.py +69 -0
  17. dfns_sdk/generated/auth/__init__.py +7 -0
  18. dfns_sdk/generated/auth/client.py +1215 -0
  19. dfns_sdk/generated/auth/delegated_client.py +1825 -0
  20. dfns_sdk/generated/auth/types.py +702 -0
  21. dfns_sdk/generated/exchanges/__init__.py +7 -0
  22. dfns_sdk/generated/exchanges/client.py +209 -0
  23. dfns_sdk/generated/exchanges/delegated_client.py +341 -0
  24. dfns_sdk/generated/exchanges/types.py +96 -0
  25. dfns_sdk/generated/fee_sponsors/__init__.py +7 -0
  26. dfns_sdk/generated/fee_sponsors/client.py +161 -0
  27. dfns_sdk/generated/fee_sponsors/delegated_client.py +287 -0
  28. dfns_sdk/generated/fee_sponsors/types.py +89 -0
  29. dfns_sdk/generated/keys/__init__.py +7 -0
  30. dfns_sdk/generated/keys/client.py +310 -0
  31. dfns_sdk/generated/keys/delegated_client.py +518 -0
  32. dfns_sdk/generated/keys/types.py +229 -0
  33. dfns_sdk/generated/networks/__init__.py +7 -0
  34. dfns_sdk/generated/networks/client.py +176 -0
  35. dfns_sdk/generated/networks/delegated_client.py +274 -0
  36. dfns_sdk/generated/networks/types.py +77 -0
  37. dfns_sdk/generated/permissions/__init__.py +7 -0
  38. dfns_sdk/generated/permissions/client.py +185 -0
  39. dfns_sdk/generated/permissions/delegated_client.py +344 -0
  40. dfns_sdk/generated/permissions/types.py +107 -0
  41. dfns_sdk/generated/policies/__init__.py +7 -0
  42. dfns_sdk/generated/policies/client.py +187 -0
  43. dfns_sdk/generated/policies/delegated_client.py +311 -0
  44. dfns_sdk/generated/policies/types.py +70 -0
  45. dfns_sdk/generated/signers/__init__.py +7 -0
  46. dfns_sdk/generated/signers/client.py +45 -0
  47. dfns_sdk/generated/signers/delegated_client.py +56 -0
  48. dfns_sdk/generated/signers/types.py +13 -0
  49. dfns_sdk/generated/staking/__init__.py +7 -0
  50. dfns_sdk/generated/staking/client.py +142 -0
  51. dfns_sdk/generated/staking/delegated_client.py +211 -0
  52. dfns_sdk/generated/staking/types.py +64 -0
  53. dfns_sdk/generated/swaps/__init__.py +7 -0
  54. dfns_sdk/generated/swaps/client.py +118 -0
  55. dfns_sdk/generated/swaps/delegated_client.py +157 -0
  56. dfns_sdk/generated/swaps/types.py +99 -0
  57. dfns_sdk/generated/wallets/__init__.py +7 -0
  58. dfns_sdk/generated/wallets/client.py +805 -0
  59. dfns_sdk/generated/wallets/delegated_client.py +1231 -0
  60. dfns_sdk/generated/wallets/types.py +534 -0
  61. dfns_sdk/generated/webhooks/__init__.py +7 -0
  62. dfns_sdk/generated/webhooks/client.py +193 -0
  63. dfns_sdk/generated/webhooks/delegated_client.py +320 -0
  64. dfns_sdk/generated/webhooks/types.py +101 -0
  65. dfns_sdk/types.py +72 -0
  66. dfns_sdk-0.0.0.dev0.dist-info/METADATA +191 -0
  67. dfns_sdk-0.0.0.dev0.dist-info/RECORD +69 -0
  68. dfns_sdk-0.0.0.dev0.dist-info/WHEEL +4 -0
  69. dfns_sdk-0.0.0.dev0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,1825 @@
1
+ """Delegated client for the auth domain."""
2
+
3
+ import json
4
+ from typing import Any, Literal, Optional, TypedDict, Union
5
+ from warnings import deprecated
6
+
7
+
8
+ from ..._internal import HttpClient
9
+ from ...base_auth_api import (
10
+ BaseAuthApi,
11
+ SignUserActionChallengeRequest,
12
+ UserActionChallengeResponse,
13
+ )
14
+ from . import types as T
15
+
16
+
17
+ class DelegatedAuthClient:
18
+ """
19
+ Delegated client for auth operations.
20
+
21
+ This client separates user action signing into _init() and _complete() method pairs,
22
+ allowing external systems to handle the signing process.
23
+ """
24
+
25
+ def __init__(self, http_client: HttpClient):
26
+ self._http = http_client
27
+
28
+ def create_user_action_signature(self, body: T.CreateUserActionSignatureRequest) -> T.CreateUserActionSignatureResponse:
29
+ """
30
+ Create User Action Signature.
31
+
32
+ Completes the user action signing process and provides a signing token that can be used to verify the user intended to perform the action.
33
+
34
+ This is the first step of the [User Action Signing flow](http://docs.dfns.co/api-reference/auth/signing-flows).
35
+
36
+ The type of credentials used to sign the action is determined by the `kind` field in the nested objects (`firstFactor` and `secondFactor`). Supported credential kinds are:
37
+ * `Fido2`: User action is signed by a user's signing device using `WebAuthn`.
38
+ * `Key`: User action is signed by a user's, or token's, private key.
39
+ * `PasswordProtectedKey`: Login challenge is signed by the decrypted user's private key that was sent during [Create User Action Signature Challenge](https://docs.dfns.co/api-reference/auth/create-user-action-challenge) step.
40
+
41
+ Args:
42
+ body: Request body.
43
+
44
+ Returns:
45
+ T.CreateUserActionSignatureResponse: The API response.
46
+ """
47
+ return self._http.request(
48
+ method="POST",
49
+ path="/auth/action",
50
+ path_params={},
51
+ query_params=None,
52
+ body=body,
53
+ requires_signature=False,
54
+ )
55
+
56
+ def create_user_action_challenge(self, body: T.CreateUserActionChallengeRequest) -> T.CreateUserActionChallengeResponse:
57
+ """
58
+ Create User Action Challenge.
59
+
60
+ Starts a user action signing session, returning a challenge that will be used to verify the user's intent to perform an action.
61
+
62
+ This is the first step of the [User Action Signing flow](http://docs.dfns.co/api-reference/auth/signing-flows).
63
+
64
+ Args:
65
+ body: Request body.
66
+
67
+ Returns:
68
+ T.CreateUserActionChallengeResponse: The API response.
69
+ """
70
+ return self._http.request(
71
+ method="POST",
72
+ path="/auth/action/init",
73
+ path_params={},
74
+ query_params=None,
75
+ body=body,
76
+ requires_signature=False,
77
+ )
78
+
79
+ def list_audit_logs(self, query: T.ListAuditLogsQuery) -> None:
80
+ """
81
+ List Audit Logs.
82
+
83
+ Gets all signature events which have occurred in the over the timeframe. The max range the API supports is 7 days.
84
+
85
+ StartTime and EndTime are URL-encoded UTC ISO timestamps:
86
+ `startTime=2025-08-29T02%3A46%3A40Z`
87
+ `endTime=2025-09-01T02%3A46%3A40Z`
88
+
89
+ An additional optional query parameter, `userId` can be specified to filter down events to a particular user. The API will return results found in CSV format.
90
+
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
+
94
+ Args:
95
+ query: Query parameters.
96
+ """
97
+ return self._http.request(
98
+ method="GET",
99
+ path="/auth/action/logs",
100
+ path_params={},
101
+ query_params=query,
102
+ body=None,
103
+ requires_signature=False,
104
+ )
105
+
106
+ def get_audit_log(self, id: str) -> T.GetAuditLogResponse:
107
+ """
108
+ Get Audit Log.
109
+
110
+ 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.
111
+
112
+ 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)
113
+
114
+ Args:
115
+ id: Log id you need information about.
116
+
117
+ Returns:
118
+ T.GetAuditLogResponse: The API response.
119
+ """
120
+ return self._http.request(
121
+ method="GET",
122
+ path="/auth/action/logs/{id}",
123
+ path_params={"id": id},
124
+ query_params=None,
125
+ body=None,
126
+ requires_signature=False,
127
+ )
128
+
129
+ @deprecated("This endpoint is deprecated.")
130
+ def list_applications(self) -> T.ListApplicationsResponse:
131
+ """
132
+ List Applications.
133
+
134
+ <Warning>
135
+ Applications are deprecated and will be removed in a future release. See details [here](https://docs.dfns.co/developers/guides/applications-deprecation).
136
+ </Warning>
137
+
138
+ Returns:
139
+ T.ListApplicationsResponse: The API response.
140
+ """
141
+ return self._http.request(
142
+ method="GET",
143
+ path="/auth/apps",
144
+ path_params={},
145
+ query_params=None,
146
+ body=None,
147
+ requires_signature=False,
148
+ )
149
+
150
+ @deprecated("This endpoint is deprecated.")
151
+ def get_application(self, app_id: str) -> T.GetApplicationResponse:
152
+ """
153
+ Get Application.
154
+
155
+ <Warning>
156
+ Applications are deprecated and will be removed in a future release. See details [here](https://docs.dfns.co/developers/guides/applications-deprecation).
157
+ </Warning>
158
+
159
+ Args:
160
+ app_id: Path parameter.
161
+
162
+ Returns:
163
+ T.GetApplicationResponse: The API response.
164
+ """
165
+ return self._http.request(
166
+ method="GET",
167
+ path="/auth/apps/{appId}",
168
+ path_params={"appId": app_id},
169
+ query_params=None,
170
+ body=None,
171
+ requires_signature=False,
172
+ )
173
+
174
+ def list_credentials(self) -> T.ListCredentialsResponse:
175
+ """
176
+ List Credentials.
177
+
178
+ List all credentials for a user.
179
+
180
+ Returns:
181
+ T.ListCredentialsResponse: The API response.
182
+ """
183
+ return self._http.request(
184
+ method="GET",
185
+ path="/auth/credentials",
186
+ path_params={},
187
+ query_params=None,
188
+ body=None,
189
+ requires_signature=False,
190
+ )
191
+
192
+ def create_credential_init(self, body: dict[str, Any]) -> UserActionChallengeResponse:
193
+ """
194
+ Initialize Create Credential.
195
+
196
+ Creates a user action challenge for external signing.
197
+
198
+ Args:
199
+ body: Request body.
200
+
201
+ Returns:
202
+ UserActionChallengeResponse: The challenge to sign externally.
203
+ """
204
+ path = "/auth/credentials"
205
+ payload = json.dumps(body, separators=(",", ":")) if body else ""
206
+
207
+ return BaseAuthApi.create_user_action_challenge(
208
+ self._http,
209
+ user_action_http_method="POST",
210
+ user_action_http_path=path,
211
+ user_action_payload=payload,
212
+ )
213
+
214
+ def create_credential_complete(self, body: dict[str, Any], signed_challenge: SignUserActionChallengeRequest) -> T.CreateCredentialResponse:
215
+ """
216
+ Complete Create Credential.
217
+
218
+ Submits the signed challenge and makes the API request.
219
+
220
+ Args:
221
+ body: Request body.
222
+ signed_challenge: The signed challenge from external signing.
223
+
224
+ Returns:
225
+ T.CreateCredentialResponse: The API response.
226
+ """
227
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
228
+ self._http, signed_challenge
229
+ )
230
+ user_action_token = user_action_result["userAction"]
231
+
232
+ return self._http.request_with_user_action(
233
+ method="POST",
234
+ path="/auth/credentials",
235
+ path_params={},
236
+ query_params=None,
237
+ body=body,
238
+ user_action=user_action_token,
239
+ )
240
+
241
+ def create_credential_challenge(self, body: T.CreateCredentialChallengeRequest) -> TypedDict:
242
+ """
243
+ Create Credential Challenge.
244
+
245
+ Part of the flow [Create Credential Regular flow](https://docs.dfns.co/api-reference/auth/credentials#regular-flow).
246
+
247
+ Starts a create user credential session, returning a challenge that will be used to verify the user's identity.
248
+
249
+ Args:
250
+ body: Request body.
251
+
252
+ Returns:
253
+ TypedDict: The API response.
254
+ """
255
+ return self._http.request(
256
+ method="POST",
257
+ path="/auth/credentials/init",
258
+ path_params={},
259
+ query_params=None,
260
+ body=body,
261
+ requires_signature=False,
262
+ )
263
+
264
+ def activate_credential_init(self, body: T.ActivateCredentialRequest) -> UserActionChallengeResponse:
265
+ """
266
+ Initialize Activate Credential.
267
+
268
+ Creates a user action challenge for external signing.
269
+
270
+ Args:
271
+ body: Request body.
272
+
273
+ Returns:
274
+ UserActionChallengeResponse: The challenge to sign externally.
275
+ """
276
+ path = "/auth/credentials/activate"
277
+ payload = json.dumps(body, separators=(",", ":")) if body else ""
278
+
279
+ return BaseAuthApi.create_user_action_challenge(
280
+ self._http,
281
+ user_action_http_method="PUT",
282
+ user_action_http_path=path,
283
+ user_action_payload=payload,
284
+ )
285
+
286
+ def activate_credential_complete(self, body: T.ActivateCredentialRequest, signed_challenge: SignUserActionChallengeRequest) -> T.ActivateCredentialResponse:
287
+ """
288
+ Complete Activate Credential.
289
+
290
+ Submits the signed challenge and makes the API request.
291
+
292
+ Args:
293
+ body: Request body.
294
+ signed_challenge: The signed challenge from external signing.
295
+
296
+ Returns:
297
+ T.ActivateCredentialResponse: The API response.
298
+ """
299
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
300
+ self._http, signed_challenge
301
+ )
302
+ user_action_token = user_action_result["userAction"]
303
+
304
+ return self._http.request_with_user_action(
305
+ method="PUT",
306
+ path="/auth/credentials/activate",
307
+ path_params={},
308
+ query_params=None,
309
+ body=body,
310
+ user_action=user_action_token,
311
+ )
312
+
313
+ def deactivate_credential_init(self, body: T.DeactivateCredentialRequest) -> UserActionChallengeResponse:
314
+ """
315
+ Initialize Deactivate Credential.
316
+
317
+ Creates a user action challenge for external signing.
318
+
319
+ Args:
320
+ body: Request body.
321
+
322
+ Returns:
323
+ UserActionChallengeResponse: The challenge to sign externally.
324
+ """
325
+ path = "/auth/credentials/deactivate"
326
+ payload = json.dumps(body, separators=(",", ":")) if body else ""
327
+
328
+ return BaseAuthApi.create_user_action_challenge(
329
+ self._http,
330
+ user_action_http_method="PUT",
331
+ user_action_http_path=path,
332
+ user_action_payload=payload,
333
+ )
334
+
335
+ def deactivate_credential_complete(self, body: T.DeactivateCredentialRequest, signed_challenge: SignUserActionChallengeRequest) -> T.DeactivateCredentialResponse:
336
+ """
337
+ Complete Deactivate Credential.
338
+
339
+ Submits the signed challenge and makes the API request.
340
+
341
+ Args:
342
+ body: Request body.
343
+ signed_challenge: The signed challenge from external signing.
344
+
345
+ Returns:
346
+ T.DeactivateCredentialResponse: The API response.
347
+ """
348
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
349
+ self._http, signed_challenge
350
+ )
351
+ user_action_token = user_action_result["userAction"]
352
+
353
+ return self._http.request_with_user_action(
354
+ method="PUT",
355
+ path="/auth/credentials/deactivate",
356
+ path_params={},
357
+ query_params=None,
358
+ body=body,
359
+ user_action=user_action_token,
360
+ )
361
+
362
+ def create_credential_code_init(self, body: T.CreateCredentialCodeRequest) -> UserActionChallengeResponse:
363
+ """
364
+ Initialize Create Credential Code.
365
+
366
+ Creates a user action challenge for external signing.
367
+
368
+ Args:
369
+ body: Request body.
370
+
371
+ Returns:
372
+ UserActionChallengeResponse: The challenge to sign externally.
373
+ """
374
+ path = "/auth/credentials/code"
375
+ payload = json.dumps(body, separators=(",", ":")) if body else ""
376
+
377
+ return BaseAuthApi.create_user_action_challenge(
378
+ self._http,
379
+ user_action_http_method="POST",
380
+ user_action_http_path=path,
381
+ user_action_payload=payload,
382
+ )
383
+
384
+ def create_credential_code_complete(self, body: T.CreateCredentialCodeRequest, signed_challenge: SignUserActionChallengeRequest) -> T.CreateCredentialCodeResponse:
385
+ """
386
+ Complete Create Credential Code.
387
+
388
+ Submits the signed challenge and makes the API request.
389
+
390
+ Args:
391
+ body: Request body.
392
+ signed_challenge: The signed challenge from external signing.
393
+
394
+ Returns:
395
+ T.CreateCredentialCodeResponse: The API response.
396
+ """
397
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
398
+ self._http, signed_challenge
399
+ )
400
+ user_action_token = user_action_result["userAction"]
401
+
402
+ return self._http.request_with_user_action(
403
+ method="POST",
404
+ path="/auth/credentials/code",
405
+ path_params={},
406
+ query_params=None,
407
+ body=body,
408
+ user_action=user_action_token,
409
+ )
410
+
411
+ def create_credential_challenge_with_code(self, body: T.CreateCredentialChallengeWithCodeRequest) -> TypedDict:
412
+ """
413
+ Create Credential Challenge With Code.
414
+
415
+ Part of the flow [Create Credential With Code](https://docs.dfns.co/api-reference/auth/credentials#create-credential-with-code-flow).
416
+
417
+ 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.
418
+
419
+ Args:
420
+ body: Request body.
421
+
422
+ Returns:
423
+ TypedDict: The API response.
424
+ """
425
+ return self._http.request(
426
+ method="POST",
427
+ path="/auth/credentials/code/init",
428
+ path_params={},
429
+ query_params=None,
430
+ body=body,
431
+ requires_signature=False,
432
+ )
433
+
434
+ def create_credential_with_code(self, body: dict[str, Any]) -> T.CreateCredentialWithCodeResponse:
435
+ """
436
+ Create Credential With Code.
437
+
438
+ Finalizes the flow [Create Credential With Code](https://docs.dfns.co/api-reference/auth/credentials#create-credential-with-code-flow).
439
+
440
+ 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:
441
+ * it does not need the user to be authenticated
442
+ * it does not need user action signing
443
+ * it will only work with the challenge gotten from the [Create Credential Challenge With Code](https://docs.dfns.co/api-reference/auth/create-credential-challenge-with-code) endpoint
444
+
445
+ Args:
446
+ body: Request body.
447
+
448
+ Returns:
449
+ T.CreateCredentialWithCodeResponse: The API response.
450
+ """
451
+ return self._http.request(
452
+ method="POST",
453
+ path="/auth/credentials/code/verify",
454
+ path_params={},
455
+ query_params=None,
456
+ body=body,
457
+ requires_signature=False,
458
+ )
459
+
460
+ def create_login_challenge(self, body: T.CreateLoginChallengeRequest) -> T.CreateLoginChallengeResponse:
461
+ """
462
+ Create Login Challenge.
463
+
464
+ Start a user login session, returning a challenge that will be used to verify the user's identity.
465
+
466
+ If the user has a credential of kind `PasswordProtectedKey` a temporary one time code needs to be passed in the `loginCode` field.
467
+
468
+ If the user has at least one discoverable webauthn credential, `username` is optional (usernamless flow).
469
+
470
+ Args:
471
+ body: Request body.
472
+
473
+ Returns:
474
+ T.CreateLoginChallengeResponse: The API response.
475
+ """
476
+ return self._http.request(
477
+ method="POST",
478
+ path="/auth/login/init",
479
+ path_params={},
480
+ query_params=None,
481
+ body=body,
482
+ requires_signature=False,
483
+ )
484
+
485
+ def delegated_login_init(self, body: T.DelegatedLoginRequest) -> UserActionChallengeResponse:
486
+ """
487
+ Initialize Delegated Login.
488
+
489
+ Creates a user action challenge for external signing.
490
+
491
+ Args:
492
+ body: Request body.
493
+
494
+ Returns:
495
+ UserActionChallengeResponse: The challenge to sign externally.
496
+ """
497
+ path = "/auth/login/delegated"
498
+ payload = json.dumps(body, separators=(",", ":")) if body else ""
499
+
500
+ return BaseAuthApi.create_user_action_challenge(
501
+ self._http,
502
+ user_action_http_method="POST",
503
+ user_action_http_path=path,
504
+ user_action_payload=payload,
505
+ )
506
+
507
+ def delegated_login_complete(self, body: T.DelegatedLoginRequest, signed_challenge: SignUserActionChallengeRequest) -> T.DelegatedLoginResponse:
508
+ """
509
+ Complete Delegated Login.
510
+
511
+ Submits the signed challenge and makes the API request.
512
+
513
+ Args:
514
+ body: Request body.
515
+ signed_challenge: The signed challenge from external signing.
516
+
517
+ Returns:
518
+ T.DelegatedLoginResponse: The API response.
519
+ """
520
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
521
+ self._http, signed_challenge
522
+ )
523
+ user_action_token = user_action_result["userAction"]
524
+
525
+ return self._http.request_with_user_action(
526
+ method="POST",
527
+ path="/auth/login/delegated",
528
+ path_params={},
529
+ query_params=None,
530
+ body=body,
531
+ user_action=user_action_token,
532
+ )
533
+
534
+ def complete_user_login(self, body: T.CompleteUserLoginRequest) -> TypedDict:
535
+ """
536
+ Complete User Login.
537
+
538
+ Completes the login process and provides the authenticated user with their authentication token.
539
+
540
+ The type of credentials used to login is determined by the `kind` field in the nested objects (`firstFactor` and `secondFactor`). Supported credential kinds are:
541
+ * `Fido2`: Login challenge is signed by a user's signing device using `WebAuthn`.
542
+ * `Key`: Login challenge is signed by a user's private key.
543
+ * `PasswordProtectedKey`: Login challenge is signed by the decrypted user's private key that was sent during [Create User Login Challenge](../registration/inituserregistration) step.
544
+
545
+ Args:
546
+ body: Request body.
547
+
548
+ Returns:
549
+ TypedDict: The API response.
550
+ """
551
+ return self._http.request(
552
+ method="POST",
553
+ path="/auth/login",
554
+ path_params={},
555
+ query_params=None,
556
+ body=body,
557
+ requires_signature=False,
558
+ )
559
+
560
+ def logout(self, body: T.LogoutRequest) -> T.LogoutResponse:
561
+ """
562
+ Logout.
563
+
564
+ Completes the user logout process.
565
+
566
+ Args:
567
+ body: Request body.
568
+
569
+ Returns:
570
+ T.LogoutResponse: The API response.
571
+ """
572
+ return self._http.request(
573
+ method="PUT",
574
+ path="/auth/logout",
575
+ path_params={},
576
+ query_params=None,
577
+ body=body,
578
+ requires_signature=False,
579
+ )
580
+
581
+ def send_login_code(self, body: T.SendLoginCodeRequest) -> T.SendLoginCodeResponse:
582
+ """
583
+ Send Login Code.
584
+
585
+ Sends a temporary one time code to the user that can be used during login flow.
586
+
587
+ 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.
588
+
589
+ Args:
590
+ body: Request body.
591
+
592
+ Returns:
593
+ T.SendLoginCodeResponse: The API response.
594
+ """
595
+ return self._http.request(
596
+ method="POST",
597
+ path="/auth/login/code",
598
+ path_params={},
599
+ query_params=None,
600
+ body=body,
601
+ requires_signature=False,
602
+ )
603
+
604
+ def social_login(self, body: T.SocialLoginRequest) -> T.SocialLoginResponse:
605
+ """
606
+ Social Login.
607
+
608
+ Completes the login process and provides the authenticated user with their authentication token.
609
+
610
+ Args:
611
+ body: Request body.
612
+
613
+ Returns:
614
+ T.SocialLoginResponse: The API response.
615
+ """
616
+ return self._http.request(
617
+ method="POST",
618
+ path="/auth/login/social",
619
+ path_params={},
620
+ query_params=None,
621
+ body=body,
622
+ requires_signature=False,
623
+ )
624
+
625
+ def complete_sso_login(self, body: T.CompleteSsoLoginRequest) -> T.CompleteSsoLoginResponse:
626
+ """
627
+ Complete SSO Login.
628
+
629
+ Completes the login process and provides the authenticated user with their authentication token.
630
+
631
+ Args:
632
+ body: Request body.
633
+
634
+ Returns:
635
+ T.CompleteSsoLoginResponse: The API response.
636
+ """
637
+ return self._http.request(
638
+ method="POST",
639
+ path="/auth/login/sso",
640
+ path_params={},
641
+ query_params=None,
642
+ body=body,
643
+ requires_signature=False,
644
+ )
645
+
646
+ def initiate_sso_login(self, body: T.InitiateSsoLoginRequest) -> T.InitiateSsoLoginResponse:
647
+ """
648
+ Initiate SSO Login.
649
+
650
+ Initialize the login process with SSO by returning the IdP Url to call.
651
+
652
+ Args:
653
+ body: Request body.
654
+
655
+ Returns:
656
+ T.InitiateSsoLoginResponse: The API response.
657
+ """
658
+ return self._http.request(
659
+ method="POST",
660
+ path="/auth/login/sso/init",
661
+ path_params={},
662
+ query_params=None,
663
+ body=body,
664
+ requires_signature=False,
665
+ )
666
+
667
+ def list_personal_access_tokens(self) -> T.ListPersonalAccessTokensResponse:
668
+ """
669
+ List Personal Access Tokens.
670
+
671
+ Retrieve the list of your Personal Access Tokens.
672
+
673
+ Returns:
674
+ T.ListPersonalAccessTokensResponse: The API response.
675
+ """
676
+ return self._http.request(
677
+ method="GET",
678
+ path="/auth/pats",
679
+ path_params={},
680
+ query_params=None,
681
+ body=None,
682
+ requires_signature=False,
683
+ )
684
+
685
+ def create_personal_access_token_init(self, body: T.CreatePersonalAccessTokenRequest) -> UserActionChallengeResponse:
686
+ """
687
+ Initialize Create Personal Access Token.
688
+
689
+ Creates a user action challenge for external signing.
690
+
691
+ Args:
692
+ body: Request body.
693
+
694
+ Returns:
695
+ UserActionChallengeResponse: The challenge to sign externally.
696
+ """
697
+ path = "/auth/pats"
698
+ payload = json.dumps(body, separators=(",", ":")) if body else ""
699
+
700
+ return BaseAuthApi.create_user_action_challenge(
701
+ self._http,
702
+ user_action_http_method="POST",
703
+ user_action_http_path=path,
704
+ user_action_payload=payload,
705
+ )
706
+
707
+ def create_personal_access_token_complete(self, body: T.CreatePersonalAccessTokenRequest, signed_challenge: SignUserActionChallengeRequest) -> T.CreatePersonalAccessTokenResponse:
708
+ """
709
+ Complete Create Personal Access Token.
710
+
711
+ Submits the signed challenge and makes the API request.
712
+
713
+ Args:
714
+ body: Request body.
715
+ signed_challenge: The signed challenge from external signing.
716
+
717
+ Returns:
718
+ T.CreatePersonalAccessTokenResponse: The API response.
719
+ """
720
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
721
+ self._http, signed_challenge
722
+ )
723
+ user_action_token = user_action_result["userAction"]
724
+
725
+ return self._http.request_with_user_action(
726
+ method="POST",
727
+ path="/auth/pats",
728
+ path_params={},
729
+ query_params=None,
730
+ body=body,
731
+ user_action=user_action_token,
732
+ )
733
+
734
+ def get_personal_access_token(self, token_id: str) -> T.GetPersonalAccessTokenResponse:
735
+ """
736
+ Get Personal Access Token.
737
+
738
+ Retrieve a specific Personal Access Token.
739
+
740
+ Args:
741
+ token_id: Path parameter.
742
+
743
+ Returns:
744
+ T.GetPersonalAccessTokenResponse: The API response.
745
+ """
746
+ return self._http.request(
747
+ method="GET",
748
+ path="/auth/pats/{tokenId}",
749
+ path_params={"tokenId": token_id},
750
+ query_params=None,
751
+ body=None,
752
+ requires_signature=False,
753
+ )
754
+
755
+ def update_personal_access_token_init(self, token_id: str, body: T.UpdatePersonalAccessTokenRequest) -> UserActionChallengeResponse:
756
+ """
757
+ Initialize Update Personal Access Token.
758
+
759
+ Creates a user action challenge for external signing.
760
+
761
+ Args:
762
+ token_id: Path parameter.
763
+ body: Request body.
764
+
765
+ Returns:
766
+ UserActionChallengeResponse: The challenge to sign externally.
767
+ """
768
+ path = "/auth/pats/{tokenId}"
769
+ path = path.replace("{tokenId}", str(token_id))
770
+ payload = json.dumps(body, separators=(",", ":")) if body else ""
771
+
772
+ return BaseAuthApi.create_user_action_challenge(
773
+ self._http,
774
+ user_action_http_method="PUT",
775
+ user_action_http_path=path,
776
+ user_action_payload=payload,
777
+ )
778
+
779
+ def update_personal_access_token_complete(self, token_id: str, body: T.UpdatePersonalAccessTokenRequest, signed_challenge: SignUserActionChallengeRequest) -> T.UpdatePersonalAccessTokenResponse:
780
+ """
781
+ Complete Update Personal Access Token.
782
+
783
+ Submits the signed challenge and makes the API request.
784
+
785
+ Args:
786
+ token_id: Path parameter.
787
+ body: Request body.
788
+ signed_challenge: The signed challenge from external signing.
789
+
790
+ Returns:
791
+ T.UpdatePersonalAccessTokenResponse: The API response.
792
+ """
793
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
794
+ self._http, signed_challenge
795
+ )
796
+ user_action_token = user_action_result["userAction"]
797
+
798
+ return self._http.request_with_user_action(
799
+ method="PUT",
800
+ path="/auth/pats/{tokenId}",
801
+ path_params={"tokenId": token_id},
802
+ query_params=None,
803
+ body=body,
804
+ user_action=user_action_token,
805
+ )
806
+
807
+ def delete_personal_access_token_init(self, token_id: str) -> UserActionChallengeResponse:
808
+ """
809
+ Initialize Delete Personal Access Token.
810
+
811
+ Creates a user action challenge for external signing.
812
+
813
+ Args:
814
+ token_id: Path parameter.
815
+
816
+ Returns:
817
+ UserActionChallengeResponse: The challenge to sign externally.
818
+ """
819
+ path = "/auth/pats/{tokenId}"
820
+ path = path.replace("{tokenId}", str(token_id))
821
+ payload = ""
822
+
823
+ return BaseAuthApi.create_user_action_challenge(
824
+ self._http,
825
+ user_action_http_method="DELETE",
826
+ user_action_http_path=path,
827
+ user_action_payload=payload,
828
+ )
829
+
830
+ def delete_personal_access_token_complete(self, token_id: str, signed_challenge: SignUserActionChallengeRequest) -> T.DeletePersonalAccessTokenResponse:
831
+ """
832
+ Complete Delete Personal Access Token.
833
+
834
+ Submits the signed challenge and makes the API request.
835
+
836
+ Args:
837
+ token_id: Path parameter.
838
+ signed_challenge: The signed challenge from external signing.
839
+
840
+ Returns:
841
+ T.DeletePersonalAccessTokenResponse: The API response.
842
+ """
843
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
844
+ self._http, signed_challenge
845
+ )
846
+ user_action_token = user_action_result["userAction"]
847
+
848
+ return self._http.request_with_user_action(
849
+ method="DELETE",
850
+ path="/auth/pats/{tokenId}",
851
+ path_params={"tokenId": token_id},
852
+ query_params=None,
853
+ body=None,
854
+ user_action=user_action_token,
855
+ )
856
+
857
+ def activate_personal_access_token_init(self, token_id: str) -> UserActionChallengeResponse:
858
+ """
859
+ Initialize Activate Personal Access Token.
860
+
861
+ Creates a user action challenge for external signing.
862
+
863
+ Args:
864
+ token_id: Path parameter.
865
+
866
+ Returns:
867
+ UserActionChallengeResponse: The challenge to sign externally.
868
+ """
869
+ path = "/auth/pats/{tokenId}/activate"
870
+ path = path.replace("{tokenId}", str(token_id))
871
+ payload = ""
872
+
873
+ return BaseAuthApi.create_user_action_challenge(
874
+ self._http,
875
+ user_action_http_method="PUT",
876
+ user_action_http_path=path,
877
+ user_action_payload=payload,
878
+ )
879
+
880
+ def activate_personal_access_token_complete(self, token_id: str, signed_challenge: SignUserActionChallengeRequest) -> T.ActivatePersonalAccessTokenResponse:
881
+ """
882
+ Complete Activate Personal Access Token.
883
+
884
+ Submits the signed challenge and makes the API request.
885
+
886
+ Args:
887
+ token_id: Path parameter.
888
+ signed_challenge: The signed challenge from external signing.
889
+
890
+ Returns:
891
+ T.ActivatePersonalAccessTokenResponse: The API response.
892
+ """
893
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
894
+ self._http, signed_challenge
895
+ )
896
+ user_action_token = user_action_result["userAction"]
897
+
898
+ return self._http.request_with_user_action(
899
+ method="PUT",
900
+ path="/auth/pats/{tokenId}/activate",
901
+ path_params={"tokenId": token_id},
902
+ query_params=None,
903
+ body=None,
904
+ user_action=user_action_token,
905
+ )
906
+
907
+ def deactivate_personal_access_token_init(self, token_id: str) -> UserActionChallengeResponse:
908
+ """
909
+ Initialize Deactivate Personal Access Token.
910
+
911
+ Creates a user action challenge for external signing.
912
+
913
+ Args:
914
+ token_id: Path parameter.
915
+
916
+ Returns:
917
+ UserActionChallengeResponse: The challenge to sign externally.
918
+ """
919
+ path = "/auth/pats/{tokenId}/deactivate"
920
+ path = path.replace("{tokenId}", str(token_id))
921
+ payload = ""
922
+
923
+ return BaseAuthApi.create_user_action_challenge(
924
+ self._http,
925
+ user_action_http_method="PUT",
926
+ user_action_http_path=path,
927
+ user_action_payload=payload,
928
+ )
929
+
930
+ def deactivate_personal_access_token_complete(self, token_id: str, signed_challenge: SignUserActionChallengeRequest) -> T.DeactivatePersonalAccessTokenResponse:
931
+ """
932
+ Complete Deactivate Personal Access Token.
933
+
934
+ Submits the signed challenge and makes the API request.
935
+
936
+ Args:
937
+ token_id: Path parameter.
938
+ signed_challenge: The signed challenge from external signing.
939
+
940
+ Returns:
941
+ T.DeactivatePersonalAccessTokenResponse: The API response.
942
+ """
943
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
944
+ self._http, signed_challenge
945
+ )
946
+ user_action_token = user_action_result["userAction"]
947
+
948
+ return self._http.request_with_user_action(
949
+ method="PUT",
950
+ path="/auth/pats/{tokenId}/deactivate",
951
+ path_params={"tokenId": token_id},
952
+ query_params=None,
953
+ body=None,
954
+ user_action=user_action_token,
955
+ )
956
+
957
+ def create_delegated_recovery_challenge_init(self, body: T.CreateDelegatedRecoveryChallengeRequest) -> UserActionChallengeResponse:
958
+ """
959
+ Initialize Create Delegated Recovery Challenge.
960
+
961
+ Creates a user action challenge for external signing.
962
+
963
+ Args:
964
+ body: Request body.
965
+
966
+ Returns:
967
+ UserActionChallengeResponse: The challenge to sign externally.
968
+ """
969
+ path = "/auth/recover/user/delegated"
970
+ payload = json.dumps(body, separators=(",", ":")) if body else ""
971
+
972
+ return BaseAuthApi.create_user_action_challenge(
973
+ self._http,
974
+ user_action_http_method="POST",
975
+ user_action_http_path=path,
976
+ user_action_payload=payload,
977
+ )
978
+
979
+ def create_delegated_recovery_challenge_complete(self, body: T.CreateDelegatedRecoveryChallengeRequest, signed_challenge: SignUserActionChallengeRequest) -> T.CreateDelegatedRecoveryChallengeResponse:
980
+ """
981
+ Complete Create Delegated Recovery Challenge.
982
+
983
+ Submits the signed challenge and makes the API request.
984
+
985
+ Args:
986
+ body: Request body.
987
+ signed_challenge: The signed challenge from external signing.
988
+
989
+ Returns:
990
+ T.CreateDelegatedRecoveryChallengeResponse: The API response.
991
+ """
992
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
993
+ self._http, signed_challenge
994
+ )
995
+ user_action_token = user_action_result["userAction"]
996
+
997
+ return self._http.request_with_user_action(
998
+ method="POST",
999
+ path="/auth/recover/user/delegated",
1000
+ path_params={},
1001
+ query_params=None,
1002
+ body=body,
1003
+ user_action=user_action_token,
1004
+ )
1005
+
1006
+ def recover_user(self, body: T.RecoverUserRequest) -> T.RecoverUserResponse:
1007
+ """
1008
+ Recover User.
1009
+
1010
+ 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.
1011
+
1012
+ 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.
1013
+
1014
+ The process is as follows:
1015
+
1016
+ 1. Construct the `newCredential` object, using the challenge obtained from either the [Create Recovery Challenge](https://docs.dfns.co/api-reference/auth/create-recovery-challenge) or [Create Delegated Recovery Challenge](https://docs.dfns.co/api-reference/auth/create-delegated-recovery-challenge) endpoints.
1017
+ 2. Serialize the `newCredential` object to JSON and then base64url-encode the resulting JSON string. This _base64url-encoded_ string will serve as the challenge for the `recovery.credentialAssertion` object.
1018
+ 3. Construct the `recovery.credentialAssertion` object, using the _base64url-encoded_ string generated in step 2 as its challenge.
1019
+
1020
+ Args:
1021
+ body: Request body.
1022
+
1023
+ Returns:
1024
+ T.RecoverUserResponse: The API response.
1025
+ """
1026
+ return self._http.request(
1027
+ method="POST",
1028
+ path="/auth/recover/user",
1029
+ path_params={},
1030
+ query_params=None,
1031
+ body=body,
1032
+ requires_signature=False,
1033
+ )
1034
+
1035
+ def create_recovery_challenge(self, body: T.CreateRecoveryChallengeRequest) -> T.CreateRecoveryChallengeResponse:
1036
+ """
1037
+ Create Recovery Challenge.
1038
+
1039
+ Starts a user recovery session, returning a challenge that will be used to verify the user's identity.
1040
+
1041
+ Args:
1042
+ body: Request body.
1043
+
1044
+ Returns:
1045
+ T.CreateRecoveryChallengeResponse: The API response.
1046
+ """
1047
+ return self._http.request(
1048
+ method="POST",
1049
+ path="/auth/recover/user/init",
1050
+ path_params={},
1051
+ query_params=None,
1052
+ body=body,
1053
+ requires_signature=False,
1054
+ )
1055
+
1056
+ def send_recovery_code_email(self, body: T.SendRecoveryCodeEmailRequest) -> T.SendRecoveryCodeEmailResponse:
1057
+ """
1058
+ Send Recovery Code Email.
1059
+
1060
+ Send the user a recovery verification code. This code is used as a second factor to verify the user initiated the recovery request.
1061
+
1062
+ Args:
1063
+ body: Request body.
1064
+
1065
+ Returns:
1066
+ T.SendRecoveryCodeEmailResponse: The API response.
1067
+ """
1068
+ return self._http.request(
1069
+ method="POST",
1070
+ path="/auth/recover/user/code",
1071
+ path_params={},
1072
+ query_params=None,
1073
+ body=body,
1074
+ requires_signature=False,
1075
+ )
1076
+
1077
+ def create_delegated_registration_challenge_init(self, body: T.CreateDelegatedRegistrationChallengeRequest) -> UserActionChallengeResponse:
1078
+ """
1079
+ Initialize Create Delegated Registration Challenge.
1080
+
1081
+ Creates a user action challenge for external signing.
1082
+
1083
+ Args:
1084
+ body: Request body.
1085
+
1086
+ Returns:
1087
+ UserActionChallengeResponse: The challenge to sign externally.
1088
+ """
1089
+ path = "/auth/registration/delegated"
1090
+ payload = json.dumps(body, separators=(",", ":")) if body else ""
1091
+
1092
+ return BaseAuthApi.create_user_action_challenge(
1093
+ self._http,
1094
+ user_action_http_method="POST",
1095
+ user_action_http_path=path,
1096
+ user_action_payload=payload,
1097
+ )
1098
+
1099
+ def create_delegated_registration_challenge_complete(self, body: T.CreateDelegatedRegistrationChallengeRequest, signed_challenge: SignUserActionChallengeRequest) -> T.CreateDelegatedRegistrationChallengeResponse:
1100
+ """
1101
+ Complete Create Delegated Registration Challenge.
1102
+
1103
+ Submits the signed challenge and makes the API request.
1104
+
1105
+ Args:
1106
+ body: Request body.
1107
+ signed_challenge: The signed challenge from external signing.
1108
+
1109
+ Returns:
1110
+ T.CreateDelegatedRegistrationChallengeResponse: The API response.
1111
+ """
1112
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
1113
+ self._http, signed_challenge
1114
+ )
1115
+ user_action_token = user_action_result["userAction"]
1116
+
1117
+ return self._http.request_with_user_action(
1118
+ method="POST",
1119
+ path="/auth/registration/delegated",
1120
+ path_params={},
1121
+ query_params=None,
1122
+ body=body,
1123
+ user_action=user_action_token,
1124
+ )
1125
+
1126
+ def create_registration_challenge(self, body: T.CreateRegistrationChallengeRequest) -> T.CreateRegistrationChallengeResponse:
1127
+ """
1128
+ Create Registration Challenge.
1129
+
1130
+ 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/register)
1131
+
1132
+ Args:
1133
+ body: Request body.
1134
+
1135
+ Returns:
1136
+ T.CreateRegistrationChallengeResponse: The API response.
1137
+ """
1138
+ return self._http.request(
1139
+ method="POST",
1140
+ path="/auth/registration/init",
1141
+ path_params={},
1142
+ query_params=None,
1143
+ body=body,
1144
+ requires_signature=False,
1145
+ )
1146
+
1147
+ def create_social_registration_challenge(self, body: T.CreateSocialRegistrationChallengeRequest) -> T.CreateSocialRegistrationChallengeResponse:
1148
+ """
1149
+ Create Social Registration Challenge.
1150
+
1151
+ 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/register-end-user).
1152
+
1153
+ Args:
1154
+ body: Request body.
1155
+
1156
+ Returns:
1157
+ T.CreateSocialRegistrationChallengeResponse: The API response.
1158
+ """
1159
+ return self._http.request(
1160
+ method="POST",
1161
+ path="/auth/registration/social",
1162
+ path_params={},
1163
+ query_params=None,
1164
+ body=body,
1165
+ requires_signature=False,
1166
+ )
1167
+
1168
+ def complete_user_registration(self, body: T.CompleteUserRegistrationRequest) -> T.CompleteUserRegistrationResponse:
1169
+ """
1170
+ Complete User Registration.
1171
+
1172
+ Completes the user registration process and creates the user's initial credentials.
1173
+
1174
+ The type of credentials being registered is determined by the `credentialKind` field in the nested objects (`firstFactorCredential` , `secondFactorCredential` and `RecoveryCredential`). Supported credential kinds are:
1175
+ * `Fido2`: User action is signed by a user's signing device using `WebAuthn`.
1176
+ * `Key`: User action is signed by a user's, or token's, private key.
1177
+ * `PasswordProtectedKey`: User action is signed by a user's, or token's, private key. The encrypted version of the private key is stored by Dfns and returns during the signing flow for the user to decrypt it.
1178
+ * `RecoveryKey` : Similar to `PasswordProtectedKey`, but this credential can only be used to recover an account not to sign an action or login. Once this credential is used all the other user's credentials are invalidated.
1179
+
1180
+ Args:
1181
+ body: Request body.
1182
+
1183
+ Returns:
1184
+ T.CompleteUserRegistrationResponse: The API response.
1185
+ """
1186
+ return self._http.request(
1187
+ method="POST",
1188
+ path="/auth/registration",
1189
+ path_params={},
1190
+ query_params=None,
1191
+ body=body,
1192
+ requires_signature=False,
1193
+ )
1194
+
1195
+ def complete_end_user_registration_with_wallets(self, body: T.CompleteEndUserRegistrationWithWalletsRequest) -> T.CompleteEndUserRegistrationWithWalletsResponse:
1196
+ """
1197
+ Complete End User Registration with Wallets.
1198
+
1199
+ Completes the end user registration process and creates the user's initial credentials along with delegated wallets for the new end user.
1200
+
1201
+ The type of credentials being registered is determined by the `credentialKind` field in the nested objects (`firstFactorCredential` , `secondFactorCredential` and `RecoveryCredential`). Supported credential kinds are:
1202
+ * `Fido2`: User action is signed by a user's signing device using `WebAuthn`.
1203
+ * `Key`: User action is signed by a user's, or token's, private key.
1204
+ * `PasswordProtectedKey`: User action is signed by a user's, or token's, private key. The encrypted version of the private key is stored by Dfns and returns during the signing flow for the user to decrypt it.
1205
+
1206
+ The number of delegated wallets created and the wallet types are determined by the `wallets` specifications. The end user is automatically assigned `ManagedDefaultEndUserAccess` managed permission that grants the end user full access to the wallets.
1207
+
1208
+ Args:
1209
+ body: Request body.
1210
+
1211
+ Returns:
1212
+ T.CompleteEndUserRegistrationWithWalletsResponse: The API response.
1213
+ """
1214
+ return self._http.request(
1215
+ method="POST",
1216
+ path="/auth/registration/enduser",
1217
+ path_params={},
1218
+ query_params=None,
1219
+ body=body,
1220
+ requires_signature=False,
1221
+ )
1222
+
1223
+ def resend_registration_code(self, body: T.ResendRegistrationCodeRequest) -> T.ResendRegistrationCodeResponse:
1224
+ """
1225
+ Resend Registration Code.
1226
+
1227
+ 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.
1228
+
1229
+ Args:
1230
+ body: Request body.
1231
+
1232
+ Returns:
1233
+ T.ResendRegistrationCodeResponse: The API response.
1234
+ """
1235
+ return self._http.request(
1236
+ method="PUT",
1237
+ path="/auth/registration/code",
1238
+ path_params={},
1239
+ query_params=None,
1240
+ body=body,
1241
+ requires_signature=False,
1242
+ )
1243
+
1244
+ def list_service_accounts(self) -> T.ListServiceAccountsResponse:
1245
+ """
1246
+ List Service Accounts.
1247
+
1248
+ List all Service Accounts in your organization.
1249
+
1250
+ Returns:
1251
+ T.ListServiceAccountsResponse: The API response.
1252
+ """
1253
+ return self._http.request(
1254
+ method="GET",
1255
+ path="/auth/service-accounts",
1256
+ path_params={},
1257
+ query_params=None,
1258
+ body=None,
1259
+ requires_signature=False,
1260
+ )
1261
+
1262
+ def create_service_account_init(self, body: T.CreateServiceAccountRequest) -> UserActionChallengeResponse:
1263
+ """
1264
+ Initialize Create Service Account.
1265
+
1266
+ Creates a user action challenge for external signing.
1267
+
1268
+ Args:
1269
+ body: Request body.
1270
+
1271
+ Returns:
1272
+ UserActionChallengeResponse: The challenge to sign externally.
1273
+ """
1274
+ path = "/auth/service-accounts"
1275
+ payload = json.dumps(body, separators=(",", ":")) if body else ""
1276
+
1277
+ return BaseAuthApi.create_user_action_challenge(
1278
+ self._http,
1279
+ user_action_http_method="POST",
1280
+ user_action_http_path=path,
1281
+ user_action_payload=payload,
1282
+ )
1283
+
1284
+ def create_service_account_complete(self, body: T.CreateServiceAccountRequest, signed_challenge: SignUserActionChallengeRequest) -> T.CreateServiceAccountResponse:
1285
+ """
1286
+ Complete Create Service Account.
1287
+
1288
+ Submits the signed challenge and makes the API request.
1289
+
1290
+ Args:
1291
+ body: Request body.
1292
+ signed_challenge: The signed challenge from external signing.
1293
+
1294
+ Returns:
1295
+ T.CreateServiceAccountResponse: The API response.
1296
+ """
1297
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
1298
+ self._http, signed_challenge
1299
+ )
1300
+ user_action_token = user_action_result["userAction"]
1301
+
1302
+ return self._http.request_with_user_action(
1303
+ method="POST",
1304
+ path="/auth/service-accounts",
1305
+ path_params={},
1306
+ query_params=None,
1307
+ body=body,
1308
+ user_action=user_action_token,
1309
+ )
1310
+
1311
+ def get_service_account(self, service_account_id: str) -> T.GetServiceAccountResponse:
1312
+ """
1313
+ Get Service Account.
1314
+
1315
+ Get information about a specific Service Account.
1316
+
1317
+ Args:
1318
+ service_account_id: Path parameter.
1319
+
1320
+ Returns:
1321
+ T.GetServiceAccountResponse: The API response.
1322
+ """
1323
+ return self._http.request(
1324
+ method="GET",
1325
+ path="/auth/service-accounts/{serviceAccountId}",
1326
+ path_params={"serviceAccountId": service_account_id},
1327
+ query_params=None,
1328
+ body=None,
1329
+ requires_signature=False,
1330
+ )
1331
+
1332
+ def update_service_account_init(self, service_account_id: str, body: T.UpdateServiceAccountRequest) -> UserActionChallengeResponse:
1333
+ """
1334
+ Initialize Update Service Account.
1335
+
1336
+ Creates a user action challenge for external signing.
1337
+
1338
+ Args:
1339
+ service_account_id: Path parameter.
1340
+ body: Request body.
1341
+
1342
+ Returns:
1343
+ UserActionChallengeResponse: The challenge to sign externally.
1344
+ """
1345
+ path = "/auth/service-accounts/{serviceAccountId}"
1346
+ path = path.replace("{serviceAccountId}", str(service_account_id))
1347
+ payload = json.dumps(body, separators=(",", ":")) if body else ""
1348
+
1349
+ return BaseAuthApi.create_user_action_challenge(
1350
+ self._http,
1351
+ user_action_http_method="PUT",
1352
+ user_action_http_path=path,
1353
+ user_action_payload=payload,
1354
+ )
1355
+
1356
+ def update_service_account_complete(self, service_account_id: str, body: T.UpdateServiceAccountRequest, signed_challenge: SignUserActionChallengeRequest) -> T.UpdateServiceAccountResponse:
1357
+ """
1358
+ Complete Update Service Account.
1359
+
1360
+ Submits the signed challenge and makes the API request.
1361
+
1362
+ Args:
1363
+ service_account_id: Path parameter.
1364
+ body: Request body.
1365
+ signed_challenge: The signed challenge from external signing.
1366
+
1367
+ Returns:
1368
+ T.UpdateServiceAccountResponse: The API response.
1369
+ """
1370
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
1371
+ self._http, signed_challenge
1372
+ )
1373
+ user_action_token = user_action_result["userAction"]
1374
+
1375
+ return self._http.request_with_user_action(
1376
+ method="PUT",
1377
+ path="/auth/service-accounts/{serviceAccountId}",
1378
+ path_params={"serviceAccountId": service_account_id},
1379
+ query_params=None,
1380
+ body=body,
1381
+ user_action=user_action_token,
1382
+ )
1383
+
1384
+ def delete_service_account_init(self, service_account_id: str) -> UserActionChallengeResponse:
1385
+ """
1386
+ Initialize Delete Service Account.
1387
+
1388
+ Creates a user action challenge for external signing.
1389
+
1390
+ Args:
1391
+ service_account_id: Path parameter.
1392
+
1393
+ Returns:
1394
+ UserActionChallengeResponse: The challenge to sign externally.
1395
+ """
1396
+ path = "/auth/service-accounts/{serviceAccountId}"
1397
+ path = path.replace("{serviceAccountId}", str(service_account_id))
1398
+ payload = ""
1399
+
1400
+ return BaseAuthApi.create_user_action_challenge(
1401
+ self._http,
1402
+ user_action_http_method="DELETE",
1403
+ user_action_http_path=path,
1404
+ user_action_payload=payload,
1405
+ )
1406
+
1407
+ def delete_service_account_complete(self, service_account_id: str, signed_challenge: SignUserActionChallengeRequest) -> T.DeleteServiceAccountResponse:
1408
+ """
1409
+ Complete Delete Service Account.
1410
+
1411
+ Submits the signed challenge and makes the API request.
1412
+
1413
+ Args:
1414
+ service_account_id: Path parameter.
1415
+ signed_challenge: The signed challenge from external signing.
1416
+
1417
+ Returns:
1418
+ T.DeleteServiceAccountResponse: The API response.
1419
+ """
1420
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
1421
+ self._http, signed_challenge
1422
+ )
1423
+ user_action_token = user_action_result["userAction"]
1424
+
1425
+ return self._http.request_with_user_action(
1426
+ method="DELETE",
1427
+ path="/auth/service-accounts/{serviceAccountId}",
1428
+ path_params={"serviceAccountId": service_account_id},
1429
+ query_params=None,
1430
+ body=None,
1431
+ user_action=user_action_token,
1432
+ )
1433
+
1434
+ def activate_service_account_init(self, service_account_id: str) -> UserActionChallengeResponse:
1435
+ """
1436
+ Initialize Activate Service Account.
1437
+
1438
+ Creates a user action challenge for external signing.
1439
+
1440
+ Args:
1441
+ service_account_id: Path parameter.
1442
+
1443
+ Returns:
1444
+ UserActionChallengeResponse: The challenge to sign externally.
1445
+ """
1446
+ path = "/auth/service-accounts/{serviceAccountId}/activate"
1447
+ path = path.replace("{serviceAccountId}", str(service_account_id))
1448
+ payload = ""
1449
+
1450
+ return BaseAuthApi.create_user_action_challenge(
1451
+ self._http,
1452
+ user_action_http_method="PUT",
1453
+ user_action_http_path=path,
1454
+ user_action_payload=payload,
1455
+ )
1456
+
1457
+ def activate_service_account_complete(self, service_account_id: str, signed_challenge: SignUserActionChallengeRequest) -> T.ActivateServiceAccountResponse:
1458
+ """
1459
+ Complete Activate Service Account.
1460
+
1461
+ Submits the signed challenge and makes the API request.
1462
+
1463
+ Args:
1464
+ service_account_id: Path parameter.
1465
+ signed_challenge: The signed challenge from external signing.
1466
+
1467
+ Returns:
1468
+ T.ActivateServiceAccountResponse: The API response.
1469
+ """
1470
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
1471
+ self._http, signed_challenge
1472
+ )
1473
+ user_action_token = user_action_result["userAction"]
1474
+
1475
+ return self._http.request_with_user_action(
1476
+ method="PUT",
1477
+ path="/auth/service-accounts/{serviceAccountId}/activate",
1478
+ path_params={"serviceAccountId": service_account_id},
1479
+ query_params=None,
1480
+ body=None,
1481
+ user_action=user_action_token,
1482
+ )
1483
+
1484
+ def deactivate_service_account_init(self, service_account_id: str) -> UserActionChallengeResponse:
1485
+ """
1486
+ Initialize Deactivate Service Account.
1487
+
1488
+ Creates a user action challenge for external signing.
1489
+
1490
+ Args:
1491
+ service_account_id: Path parameter.
1492
+
1493
+ Returns:
1494
+ UserActionChallengeResponse: The challenge to sign externally.
1495
+ """
1496
+ path = "/auth/service-accounts/{serviceAccountId}/deactivate"
1497
+ path = path.replace("{serviceAccountId}", str(service_account_id))
1498
+ payload = ""
1499
+
1500
+ return BaseAuthApi.create_user_action_challenge(
1501
+ self._http,
1502
+ user_action_http_method="PUT",
1503
+ user_action_http_path=path,
1504
+ user_action_payload=payload,
1505
+ )
1506
+
1507
+ def deactivate_service_account_complete(self, service_account_id: str, signed_challenge: SignUserActionChallengeRequest) -> T.DeactivateServiceAccountResponse:
1508
+ """
1509
+ Complete Deactivate Service Account.
1510
+
1511
+ Submits the signed challenge and makes the API request.
1512
+
1513
+ Args:
1514
+ service_account_id: Path parameter.
1515
+ signed_challenge: The signed challenge from external signing.
1516
+
1517
+ Returns:
1518
+ T.DeactivateServiceAccountResponse: The API response.
1519
+ """
1520
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
1521
+ self._http, signed_challenge
1522
+ )
1523
+ user_action_token = user_action_result["userAction"]
1524
+
1525
+ return self._http.request_with_user_action(
1526
+ method="PUT",
1527
+ path="/auth/service-accounts/{serviceAccountId}/deactivate",
1528
+ path_params={"serviceAccountId": service_account_id},
1529
+ query_params=None,
1530
+ body=None,
1531
+ user_action=user_action_token,
1532
+ )
1533
+
1534
+ def activate_user_init(self, user_id: str) -> UserActionChallengeResponse:
1535
+ """
1536
+ Initialize Activate User.
1537
+
1538
+ Creates a user action challenge for external signing.
1539
+
1540
+ Args:
1541
+ user_id: Path parameter.
1542
+
1543
+ Returns:
1544
+ UserActionChallengeResponse: The challenge to sign externally.
1545
+ """
1546
+ path = "/auth/users/{userId}/activate"
1547
+ path = path.replace("{userId}", str(user_id))
1548
+ payload = ""
1549
+
1550
+ return BaseAuthApi.create_user_action_challenge(
1551
+ self._http,
1552
+ user_action_http_method="PUT",
1553
+ user_action_http_path=path,
1554
+ user_action_payload=payload,
1555
+ )
1556
+
1557
+ def activate_user_complete(self, user_id: str, signed_challenge: SignUserActionChallengeRequest) -> T.ActivateUserResponse:
1558
+ """
1559
+ Complete Activate User.
1560
+
1561
+ Submits the signed challenge and makes the API request.
1562
+
1563
+ Args:
1564
+ user_id: Path parameter.
1565
+ signed_challenge: The signed challenge from external signing.
1566
+
1567
+ Returns:
1568
+ T.ActivateUserResponse: The API response.
1569
+ """
1570
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
1571
+ self._http, signed_challenge
1572
+ )
1573
+ user_action_token = user_action_result["userAction"]
1574
+
1575
+ return self._http.request_with_user_action(
1576
+ method="PUT",
1577
+ path="/auth/users/{userId}/activate",
1578
+ path_params={"userId": user_id},
1579
+ query_params=None,
1580
+ body=None,
1581
+ user_action=user_action_token,
1582
+ )
1583
+
1584
+ def deactivate_user_init(self, user_id: str) -> UserActionChallengeResponse:
1585
+ """
1586
+ Initialize Deactivate User.
1587
+
1588
+ Creates a user action challenge for external signing.
1589
+
1590
+ Args:
1591
+ user_id: Path parameter.
1592
+
1593
+ Returns:
1594
+ UserActionChallengeResponse: The challenge to sign externally.
1595
+ """
1596
+ path = "/auth/users/{userId}/deactivate"
1597
+ path = path.replace("{userId}", str(user_id))
1598
+ payload = ""
1599
+
1600
+ return BaseAuthApi.create_user_action_challenge(
1601
+ self._http,
1602
+ user_action_http_method="PUT",
1603
+ user_action_http_path=path,
1604
+ user_action_payload=payload,
1605
+ )
1606
+
1607
+ def deactivate_user_complete(self, user_id: str, signed_challenge: SignUserActionChallengeRequest) -> T.DeactivateUserResponse:
1608
+ """
1609
+ Complete Deactivate User.
1610
+
1611
+ Submits the signed challenge and makes the API request.
1612
+
1613
+ Args:
1614
+ user_id: Path parameter.
1615
+ signed_challenge: The signed challenge from external signing.
1616
+
1617
+ Returns:
1618
+ T.DeactivateUserResponse: The API response.
1619
+ """
1620
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
1621
+ self._http, signed_challenge
1622
+ )
1623
+ user_action_token = user_action_result["userAction"]
1624
+
1625
+ return self._http.request_with_user_action(
1626
+ method="PUT",
1627
+ path="/auth/users/{userId}/deactivate",
1628
+ path_params={"userId": user_id},
1629
+ query_params=None,
1630
+ body=None,
1631
+ user_action=user_action_token,
1632
+ )
1633
+
1634
+ def get_user(self, user_id: str) -> T.GetUserResponse:
1635
+ """
1636
+ Get User.
1637
+
1638
+ Retrieve information about a specific User.
1639
+
1640
+ Args:
1641
+ user_id: Path parameter.
1642
+
1643
+ Returns:
1644
+ T.GetUserResponse: The API response.
1645
+ """
1646
+ return self._http.request(
1647
+ method="GET",
1648
+ path="/auth/users/{userId}",
1649
+ path_params={"userId": user_id},
1650
+ query_params=None,
1651
+ body=None,
1652
+ requires_signature=False,
1653
+ )
1654
+
1655
+ def update_user_init(self, user_id: str, body: T.UpdateUserRequest) -> UserActionChallengeResponse:
1656
+ """
1657
+ Initialize Update User.
1658
+
1659
+ Creates a user action challenge for external signing.
1660
+
1661
+ Args:
1662
+ user_id: Path parameter.
1663
+ body: Request body.
1664
+
1665
+ Returns:
1666
+ UserActionChallengeResponse: The challenge to sign externally.
1667
+ """
1668
+ path = "/auth/users/{userId}"
1669
+ path = path.replace("{userId}", str(user_id))
1670
+ payload = json.dumps(body, separators=(",", ":")) if body else ""
1671
+
1672
+ return BaseAuthApi.create_user_action_challenge(
1673
+ self._http,
1674
+ user_action_http_method="PUT",
1675
+ user_action_http_path=path,
1676
+ user_action_payload=payload,
1677
+ )
1678
+
1679
+ def update_user_complete(self, user_id: str, body: T.UpdateUserRequest, signed_challenge: SignUserActionChallengeRequest) -> T.UpdateUserResponse:
1680
+ """
1681
+ Complete Update User.
1682
+
1683
+ Submits the signed challenge and makes the API request.
1684
+
1685
+ Args:
1686
+ user_id: Path parameter.
1687
+ body: Request body.
1688
+ signed_challenge: The signed challenge from external signing.
1689
+
1690
+ Returns:
1691
+ T.UpdateUserResponse: The API response.
1692
+ """
1693
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
1694
+ self._http, signed_challenge
1695
+ )
1696
+ user_action_token = user_action_result["userAction"]
1697
+
1698
+ return self._http.request_with_user_action(
1699
+ method="PUT",
1700
+ path="/auth/users/{userId}",
1701
+ path_params={"userId": user_id},
1702
+ query_params=None,
1703
+ body=body,
1704
+ user_action=user_action_token,
1705
+ )
1706
+
1707
+ def delete_user_init(self, user_id: str) -> UserActionChallengeResponse:
1708
+ """
1709
+ Initialize Delete User.
1710
+
1711
+ Creates a user action challenge for external signing.
1712
+
1713
+ Args:
1714
+ user_id: Path parameter.
1715
+
1716
+ Returns:
1717
+ UserActionChallengeResponse: The challenge to sign externally.
1718
+ """
1719
+ path = "/auth/users/{userId}"
1720
+ path = path.replace("{userId}", str(user_id))
1721
+ payload = ""
1722
+
1723
+ return BaseAuthApi.create_user_action_challenge(
1724
+ self._http,
1725
+ user_action_http_method="DELETE",
1726
+ user_action_http_path=path,
1727
+ user_action_payload=payload,
1728
+ )
1729
+
1730
+ def delete_user_complete(self, user_id: str, signed_challenge: SignUserActionChallengeRequest) -> T.DeleteUserResponse:
1731
+ """
1732
+ Complete Delete User.
1733
+
1734
+ Submits the signed challenge and makes the API request.
1735
+
1736
+ Args:
1737
+ user_id: Path parameter.
1738
+ signed_challenge: The signed challenge from external signing.
1739
+
1740
+ Returns:
1741
+ T.DeleteUserResponse: The API response.
1742
+ """
1743
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
1744
+ self._http, signed_challenge
1745
+ )
1746
+ user_action_token = user_action_result["userAction"]
1747
+
1748
+ return self._http.request_with_user_action(
1749
+ method="DELETE",
1750
+ path="/auth/users/{userId}",
1751
+ path_params={"userId": user_id},
1752
+ query_params=None,
1753
+ body=None,
1754
+ user_action=user_action_token,
1755
+ )
1756
+
1757
+ def list_users(self, query: Optional[T.ListUsersQuery] = None) -> T.ListUsersResponse:
1758
+ """
1759
+ List Users.
1760
+
1761
+ List all Users in your organization.
1762
+
1763
+ Args:
1764
+ query: Query parameters.
1765
+
1766
+ Returns:
1767
+ T.ListUsersResponse: The API response.
1768
+ """
1769
+ return self._http.request(
1770
+ method="GET",
1771
+ path="/auth/users",
1772
+ path_params={},
1773
+ query_params=query,
1774
+ body=None,
1775
+ requires_signature=False,
1776
+ )
1777
+
1778
+ def create_user_init(self, body: T.CreateUserRequest) -> UserActionChallengeResponse:
1779
+ """
1780
+ Initialize Create User.
1781
+
1782
+ Creates a user action challenge for external signing.
1783
+
1784
+ Args:
1785
+ body: Request body.
1786
+
1787
+ Returns:
1788
+ UserActionChallengeResponse: The challenge to sign externally.
1789
+ """
1790
+ path = "/auth/users"
1791
+ payload = json.dumps(body, separators=(",", ":")) if body else ""
1792
+
1793
+ return BaseAuthApi.create_user_action_challenge(
1794
+ self._http,
1795
+ user_action_http_method="POST",
1796
+ user_action_http_path=path,
1797
+ user_action_payload=payload,
1798
+ )
1799
+
1800
+ def create_user_complete(self, body: T.CreateUserRequest, signed_challenge: SignUserActionChallengeRequest) -> T.CreateUserResponse:
1801
+ """
1802
+ Complete Create User.
1803
+
1804
+ Submits the signed challenge and makes the API request.
1805
+
1806
+ Args:
1807
+ body: Request body.
1808
+ signed_challenge: The signed challenge from external signing.
1809
+
1810
+ Returns:
1811
+ T.CreateUserResponse: The API response.
1812
+ """
1813
+ user_action_result = BaseAuthApi.sign_user_action_challenge(
1814
+ self._http, signed_challenge
1815
+ )
1816
+ user_action_token = user_action_result["userAction"]
1817
+
1818
+ return self._http.request_with_user_action(
1819
+ method="POST",
1820
+ path="/auth/users",
1821
+ path_params={},
1822
+ query_params=None,
1823
+ body=body,
1824
+ user_action=user_action_token,
1825
+ )