workos 1.5.1__py3-none-any.whl → 5.38.0__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 (150) hide show
  1. workos/__about__.py +1 -1
  2. workos/__init__.py +3 -7
  3. workos/_base_client.py +138 -0
  4. workos/_client_configuration.py +10 -0
  5. workos/api_keys.py +53 -0
  6. workos/async_client.py +144 -0
  7. workos/audit_logs.py +125 -0
  8. workos/client.py +110 -18
  9. workos/directory_sync.py +379 -99
  10. workos/events.py +111 -0
  11. workos/exceptions.py +53 -26
  12. workos/fga.py +649 -0
  13. workos/mfa.py +205 -0
  14. workos/organization_domains.py +179 -0
  15. workos/organizations.py +403 -73
  16. workos/passwordless.py +67 -43
  17. workos/pipes.py +93 -0
  18. workos/portal.py +51 -28
  19. workos/session.py +337 -0
  20. workos/sso.py +311 -101
  21. workos/types/__init__.py +4 -0
  22. workos/types/api_keys/__init__.py +1 -0
  23. workos/types/api_keys/api_keys.py +20 -0
  24. workos/types/audit_logs/__init__.py +6 -0
  25. workos/types/audit_logs/audit_log_event.py +16 -0
  26. workos/types/audit_logs/audit_log_event_actor.py +12 -0
  27. workos/types/audit_logs/audit_log_event_context.py +8 -0
  28. workos/types/audit_logs/audit_log_event_target.py +12 -0
  29. workos/types/audit_logs/audit_log_export.py +18 -0
  30. workos/types/audit_logs/audit_log_metadata.py +4 -0
  31. workos/types/directory_sync/__init__.py +5 -0
  32. workos/types/directory_sync/directory.py +31 -0
  33. workos/types/directory_sync/directory_group.py +16 -0
  34. workos/types/directory_sync/directory_state.py +28 -0
  35. workos/types/directory_sync/directory_type.py +24 -0
  36. workos/types/directory_sync/directory_user.py +50 -0
  37. workos/types/directory_sync/list_filters.py +21 -0
  38. workos/types/events/__init__.py +13 -0
  39. workos/types/events/authentication_payload.py +70 -0
  40. workos/types/events/connection_payload_with_legacy_fields.py +5 -0
  41. workos/types/events/directory_group_membership_payload.py +9 -0
  42. workos/types/events/directory_group_with_previous_attributes.py +6 -0
  43. workos/types/events/directory_payload.py +16 -0
  44. workos/types/events/directory_payload_with_legacy_fields.py +29 -0
  45. workos/types/events/directory_user_with_previous_attributes.py +6 -0
  46. workos/types/events/event.py +324 -0
  47. workos/types/events/event_model.py +103 -0
  48. workos/types/events/event_type.py +59 -0
  49. workos/types/events/list_filters.py +10 -0
  50. workos/types/events/organization_domain_verification_failed_payload.py +14 -0
  51. workos/types/events/previous_attributes.py +3 -0
  52. workos/types/events/session_payload.py +27 -0
  53. workos/types/feature_flags/__init__.py +3 -0
  54. workos/types/feature_flags/feature_flag.py +12 -0
  55. workos/types/feature_flags/list_filters.py +5 -0
  56. workos/types/fga/__init__.py +5 -0
  57. workos/types/fga/authorization_resource_types.py +9 -0
  58. workos/types/fga/authorization_resources.py +10 -0
  59. workos/types/fga/check.py +51 -0
  60. workos/types/fga/list_filters.py +24 -0
  61. workos/types/fga/warnings.py +33 -0
  62. workos/types/fga/warrant.py +49 -0
  63. workos/types/list_resource.py +198 -0
  64. workos/types/metadata.py +4 -0
  65. workos/types/mfa/__init__.py +5 -0
  66. workos/types/mfa/authentication_challenge.py +14 -0
  67. workos/types/mfa/authentication_challenge_verification_response.py +9 -0
  68. workos/types/mfa/authentication_factor.py +70 -0
  69. workos/types/mfa/authentication_factor_totp_and_challenge_response.py +10 -0
  70. workos/types/mfa/enroll_authentication_factor_type.py +8 -0
  71. workos/types/organization_domains/__init__.py +1 -0
  72. workos/types/organization_domains/organization_domain.py +18 -0
  73. workos/types/organizations/__init__.py +6 -0
  74. workos/types/organizations/domain_data_input.py +7 -0
  75. workos/types/organizations/list_filters.py +6 -0
  76. workos/types/organizations/organization.py +13 -0
  77. workos/types/organizations/organization_common.py +12 -0
  78. workos/types/passwordless/__init__.py +2 -0
  79. workos/types/passwordless/passwordless_session.py +12 -0
  80. workos/types/passwordless/passwordless_session_type.py +3 -0
  81. workos/types/pipes/__init__.py +6 -0
  82. workos/types/pipes/pipes.py +34 -0
  83. workos/types/portal/__init__.py +2 -0
  84. workos/types/portal/portal_link.py +7 -0
  85. workos/types/portal/portal_link_intent.py +11 -0
  86. workos/types/portal/portal_link_intent_options.py +9 -0
  87. workos/types/roles/__init__.py +0 -0
  88. workos/types/roles/role.py +27 -0
  89. workos/types/sso/__init__.py +4 -0
  90. workos/types/sso/connection.py +70 -0
  91. workos/types/sso/connection_domain.py +8 -0
  92. workos/types/sso/profile.py +35 -0
  93. workos/types/sso/sso_provider_type.py +10 -0
  94. workos/types/user_management/__init__.py +12 -0
  95. workos/types/user_management/authenticate_with_common.py +66 -0
  96. workos/types/user_management/authentication_response.py +53 -0
  97. workos/types/user_management/email_verification.py +18 -0
  98. workos/types/user_management/impersonator.py +8 -0
  99. workos/types/user_management/invitation.py +26 -0
  100. workos/types/user_management/list_filters.py +29 -0
  101. workos/types/user_management/magic_auth.py +18 -0
  102. workos/types/user_management/oauth_tokens.py +21 -0
  103. workos/types/user_management/organization_membership.py +25 -0
  104. workos/types/user_management/password_hash_type.py +4 -0
  105. workos/types/user_management/password_reset.py +18 -0
  106. workos/types/user_management/screen_hint.py +3 -0
  107. workos/types/user_management/session.py +79 -0
  108. workos/types/user_management/user.py +22 -0
  109. workos/types/user_management/user_management_provider_type.py +11 -0
  110. workos/types/vault/__init__.py +2 -0
  111. workos/types/vault/key.py +25 -0
  112. workos/types/vault/object.py +38 -0
  113. workos/types/webhooks/__init__.py +0 -0
  114. workos/types/webhooks/webhook.py +330 -0
  115. workos/types/webhooks/webhook_model.py +14 -0
  116. workos/types/webhooks/webhook_payload.py +4 -0
  117. workos/types/widgets/__init__.py +2 -0
  118. workos/types/widgets/widget_scope.py +4 -0
  119. workos/types/widgets/widget_token_response.py +7 -0
  120. workos/types/workos_model.py +26 -0
  121. workos/typing/__init__.py +1 -0
  122. workos/typing/literals.py +32 -0
  123. workos/typing/sync_or_async.py +5 -0
  124. workos/typing/untyped_literal.py +37 -0
  125. workos/typing/webhooks.py +18 -0
  126. workos/user_management.py +2400 -0
  127. workos/utils/_base_http_client.py +252 -0
  128. workos/utils/crypto_provider.py +39 -0
  129. workos/utils/http_client.py +214 -0
  130. workos/utils/pagination_order.py +4 -0
  131. workos/utils/request_helper.py +27 -0
  132. workos/vault.py +544 -0
  133. workos/webhooks.py +96 -39
  134. workos/widgets.py +55 -0
  135. {workos-1.5.1.dist-info → workos-5.38.0.dist-info}/LICENSE +1 -1
  136. workos-5.38.0.dist-info/METADATA +107 -0
  137. workos-5.38.0.dist-info/RECORD +141 -0
  138. {workos-1.5.1.dist-info → workos-5.38.0.dist-info}/WHEEL +1 -1
  139. workos/audit_trail.py +0 -172
  140. workos/resources/base.py +0 -36
  141. workos/resources/event.py +0 -42
  142. workos/resources/event_action.py +0 -11
  143. workos/resources/sso.py +0 -53
  144. workos/utils/connection_types.py +0 -17
  145. workos/utils/request.py +0 -95
  146. workos/utils/validation.py +0 -45
  147. workos-1.5.1.dist-info/METADATA +0 -77
  148. workos-1.5.1.dist-info/RECORD +0 -25
  149. /workos/{resources/__init__.py → py.typed} +0 -0
  150. {workos-1.5.1.dist-info → workos-5.38.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,32 @@
1
+ from typing import Any, TypeVar, Union
2
+ from typing_extensions import Annotated, LiteralString
3
+ from pydantic import (
4
+ Field,
5
+ ValidationError,
6
+ ValidationInfo,
7
+ ValidatorFunctionWrapHandler,
8
+ WrapValidator,
9
+ )
10
+ from workos.typing.untyped_literal import UntypedLiteral
11
+
12
+
13
+ def convert_unknown_literal_to_untyped_literal(
14
+ value: Any,
15
+ handler: ValidatorFunctionWrapHandler,
16
+ info: ValidationInfo,
17
+ # TODO: Find a way to better type, give that the last case in the except block truly can return Any
18
+ ) -> Union[LiteralString, UntypedLiteral, Any]:
19
+ try:
20
+ return handler(value)
21
+ except ValidationError as validation_error:
22
+ if validation_error.errors()[0]["type"] == "literal_error":
23
+ return handler(UntypedLiteral(value))
24
+ else:
25
+ return handler(value)
26
+
27
+
28
+ LiteralType = TypeVar("LiteralType", bound=LiteralString)
29
+ LiteralOrUntyped = Annotated[
30
+ Annotated[Union[LiteralType, UntypedLiteral], Field(union_mode="left_to_right")],
31
+ WrapValidator(convert_unknown_literal_to_untyped_literal),
32
+ ]
@@ -0,0 +1,5 @@
1
+ from typing import Awaitable, TypeVar, Union
2
+
3
+
4
+ T = TypeVar("T")
5
+ SyncOrAsync = Union[T, Awaitable[T]]
@@ -0,0 +1,37 @@
1
+ from typing import Any
2
+ from pydantic_core import CoreSchema, core_schema
3
+ from pydantic import GetCoreSchemaHandler
4
+
5
+
6
+ class UntypedLiteral(str):
7
+ def __new__(cls, value: str) -> "UntypedLiteral":
8
+ return super().__new__(cls, f"Untyped[{value}]")
9
+
10
+ @classmethod
11
+ def validate_untyped_literal(cls, value: Any) -> Any:
12
+ if isinstance(value, UntypedLiteral):
13
+ return value
14
+ else:
15
+ # TODO: Should this raise an error that translates to pydantic's is_instance_of error?
16
+ raise ValueError("Value is not an instance of UntypedLiteral")
17
+
18
+ @classmethod
19
+ def __get_pydantic_core_schema__(
20
+ cls, source_type: Any, handler: GetCoreSchemaHandler
21
+ ) -> CoreSchema:
22
+ return core_schema.no_info_plain_validator_function(
23
+ function=cls.validate_untyped_literal,
24
+ )
25
+
26
+
27
+ # TypeGuard doesn't actually work for exhaustiveness checking, but we can return a boolean expression instead
28
+ # https://github.com/python/mypy/issues/15305
29
+ # TODO: see if there is a way to define this as TypeGuard, TypeIs, or bool depending on python version
30
+ # def is_untyped_literal(value: Union[str, UntypedLiteral]) -> TypeGuard[UntypedLiteral]:
31
+ # return isinstance(value, UntypedLiteral)
32
+
33
+
34
+ def is_untyped_literal(value: Any) -> bool:
35
+ # A helper to detect untyped values from the API (more explainer here)
36
+ # Does not help with exhaustiveness checking
37
+ return isinstance(value, UntypedLiteral)
@@ -0,0 +1,18 @@
1
+ from typing import Any, Dict, Union
2
+ from typing_extensions import Annotated
3
+ from pydantic import Field, TypeAdapter
4
+ from workos.types.webhooks.webhook import Webhook
5
+ from workos.types.workos_model import WorkOSModel
6
+
7
+
8
+ # Fall back to untyped Webhook if the event type is not recognized
9
+ class UntypedWebhook(WorkOSModel):
10
+ id: str
11
+ event: str
12
+ data: Dict[str, Any]
13
+ created_at: str
14
+
15
+
16
+ WebhookTypeAdapter: TypeAdapter[Webhook] = TypeAdapter(
17
+ Annotated[Union[Webhook, UntypedWebhook], Field(union_mode="left_to_right")],
18
+ )