workos 5.30.0__py3-none-any.whl → 5.31.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.
- workos/__about__.py +1 -1
- workos/session.py +4 -0
- workos/types/list_resource.py +2 -0
- workos/types/user_management/__init__.py +1 -0
- workos/types/user_management/list_filters.py +4 -0
- workos/types/user_management/session.py +32 -0
- workos/user_management.py +119 -0
- {workos-5.30.0.dist-info → workos-5.31.0.dist-info}/METADATA +1 -1
- {workos-5.30.0.dist-info → workos-5.31.0.dist-info}/RECORD +12 -12
- {workos-5.30.0.dist-info → workos-5.31.0.dist-info}/LICENSE +0 -0
- {workos-5.30.0.dist-info → workos-5.31.0.dist-info}/WHEEL +0 -0
- {workos-5.30.0.dist-info → workos-5.31.0.dist-info}/top_level.txt +0 -0
workos/__about__.py
CHANGED
workos/session.py
CHANGED
|
@@ -4,6 +4,7 @@ from typing import TYPE_CHECKING, List, Protocol
|
|
|
4
4
|
from functools import lru_cache
|
|
5
5
|
import json
|
|
6
6
|
from typing import Any, Dict, Optional, Union, cast
|
|
7
|
+
|
|
7
8
|
import jwt
|
|
8
9
|
from jwt import PyJWKClient
|
|
9
10
|
from cryptography.fernet import Fernet
|
|
@@ -107,6 +108,7 @@ class SessionModule(Protocol):
|
|
|
107
108
|
entitlements=decoded.get("entitlements", None),
|
|
108
109
|
user=session["user"],
|
|
109
110
|
impersonator=session.get("impersonator", None),
|
|
111
|
+
feature_flags=decoded.get("feature_flags", None),
|
|
110
112
|
)
|
|
111
113
|
|
|
112
114
|
def refresh(
|
|
@@ -235,6 +237,7 @@ class Session(SessionModule):
|
|
|
235
237
|
entitlements=decoded.get("entitlements", None),
|
|
236
238
|
user=auth_response.user,
|
|
237
239
|
impersonator=auth_response.impersonator,
|
|
240
|
+
feature_flags=decoded.get("feature_flags", None),
|
|
238
241
|
)
|
|
239
242
|
except Exception as e:
|
|
240
243
|
return RefreshWithSessionCookieErrorResponse(
|
|
@@ -326,6 +329,7 @@ class AsyncSession(SessionModule):
|
|
|
326
329
|
entitlements=decoded.get("entitlements", None),
|
|
327
330
|
user=auth_response.user,
|
|
328
331
|
impersonator=auth_response.impersonator,
|
|
332
|
+
feature_flags=decoded.get("feature_flags", None),
|
|
329
333
|
)
|
|
330
334
|
except Exception as e:
|
|
331
335
|
return RefreshWithSessionCookieErrorResponse(
|
workos/types/list_resource.py
CHANGED
|
@@ -34,6 +34,7 @@ from workos.types.mfa import AuthenticationFactor
|
|
|
34
34
|
from workos.types.organizations import Organization
|
|
35
35
|
from workos.types.sso import ConnectionWithDomains
|
|
36
36
|
from workos.types.user_management import Invitation, OrganizationMembership, User
|
|
37
|
+
from workos.types.user_management.session import Session as UserManagementSession
|
|
37
38
|
from workos.types.vault import ObjectDigest
|
|
38
39
|
from workos.types.workos_model import WorkOSModel
|
|
39
40
|
from workos.utils.request_helper import DEFAULT_LIST_RESPONSE_LIMIT
|
|
@@ -54,6 +55,7 @@ ListableResource = TypeVar(
|
|
|
54
55
|
AuthorizationResource,
|
|
55
56
|
AuthorizationResourceType,
|
|
56
57
|
User,
|
|
58
|
+
UserManagementSession,
|
|
57
59
|
ObjectDigest,
|
|
58
60
|
Warrant,
|
|
59
61
|
WarrantQueryResult,
|
|
@@ -24,6 +24,7 @@ class AuthenticateWithSessionCookieSuccessResponse(WorkOSModel):
|
|
|
24
24
|
user: User
|
|
25
25
|
impersonator: Optional[Impersonator] = None
|
|
26
26
|
entitlements: Optional[Sequence[str]] = None
|
|
27
|
+
feature_flags: Optional[Sequence[str]] = None
|
|
27
28
|
|
|
28
29
|
|
|
29
30
|
class AuthenticateWithSessionCookieErrorResponse(WorkOSModel):
|
|
@@ -45,3 +46,34 @@ class RefreshWithSessionCookieErrorResponse(WorkOSModel):
|
|
|
45
46
|
class SessionConfig(TypedDict, total=False):
|
|
46
47
|
seal_session: bool
|
|
47
48
|
cookie_password: str
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
AuthMethodType = Literal[
|
|
52
|
+
"external_auth",
|
|
53
|
+
"impersonation",
|
|
54
|
+
"magic_code",
|
|
55
|
+
"migrated_session",
|
|
56
|
+
"oauth",
|
|
57
|
+
"passkey",
|
|
58
|
+
"password",
|
|
59
|
+
"sso",
|
|
60
|
+
"unknown",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
class Session(WorkOSModel):
|
|
65
|
+
"""Representation of a WorkOS User Management Session."""
|
|
66
|
+
|
|
67
|
+
object: Literal["session"]
|
|
68
|
+
id: str
|
|
69
|
+
user_id: str
|
|
70
|
+
organization_id: Optional[str] = None
|
|
71
|
+
status: str
|
|
72
|
+
auth_method: AuthMethodType
|
|
73
|
+
impersonator: Optional[Impersonator] = None
|
|
74
|
+
ip_address: Optional[str] = None
|
|
75
|
+
user_agent: Optional[str] = None
|
|
76
|
+
expires_at: str
|
|
77
|
+
ended_at: Optional[str] = None
|
|
78
|
+
created_at: str
|
|
79
|
+
updated_at: str
|
workos/user_management.py
CHANGED
|
@@ -48,6 +48,7 @@ from workos.types.user_management.list_filters import (
|
|
|
48
48
|
from workos.types.user_management.password_hash_type import PasswordHashType
|
|
49
49
|
from workos.types.user_management.screen_hint import ScreenHintType
|
|
50
50
|
from workos.types.user_management.session import SessionConfig
|
|
51
|
+
from workos.types.user_management.session import Session as UserManagementSession
|
|
51
52
|
from workos.types.user_management.user_management_provider_type import (
|
|
52
53
|
UserManagementProviderType,
|
|
53
54
|
)
|
|
@@ -86,6 +87,8 @@ MAGIC_AUTH_DETAIL_PATH = "user_management/magic_auth/{0}"
|
|
|
86
87
|
MAGIC_AUTH_PATH = "user_management/magic_auth"
|
|
87
88
|
USER_SEND_MAGIC_AUTH_PATH = "user_management/magic_auth/send"
|
|
88
89
|
USER_AUTH_FACTORS_PATH = "user_management/users/{0}/auth_factors"
|
|
90
|
+
USER_SESSIONS_PATH = "user_management/users/{0}/sessions"
|
|
91
|
+
SESSIONS_REVOKE_PATH = "user_management/sessions/revoke"
|
|
89
92
|
EMAIL_VERIFICATION_DETAIL_PATH = "user_management/email_verification/{0}"
|
|
90
93
|
INVITATION_PATH = "user_management/invitations"
|
|
91
94
|
INVITATION_DETAIL_PATH = "user_management/invitations/{0}"
|
|
@@ -109,6 +112,12 @@ InvitationsListResource = WorkOSListResource[
|
|
|
109
112
|
Invitation, InvitationsListFilters, ListMetadata
|
|
110
113
|
]
|
|
111
114
|
|
|
115
|
+
from workos.types.user_management.list_filters import SessionsListFilters
|
|
116
|
+
|
|
117
|
+
SessionsListResource = WorkOSListResource[
|
|
118
|
+
UserManagementSession, SessionsListFilters, ListMetadata
|
|
119
|
+
]
|
|
120
|
+
|
|
112
121
|
|
|
113
122
|
class UserManagementModule(Protocol):
|
|
114
123
|
"""Offers methods for using the WorkOS User Management API."""
|
|
@@ -720,6 +729,20 @@ class UserManagementModule(Protocol):
|
|
|
720
729
|
"""
|
|
721
730
|
...
|
|
722
731
|
|
|
732
|
+
def list_sessions(
|
|
733
|
+
self,
|
|
734
|
+
*,
|
|
735
|
+
user_id: str,
|
|
736
|
+
limit: Optional[int] = None,
|
|
737
|
+
before: Optional[str] = None,
|
|
738
|
+
after: Optional[str] = None,
|
|
739
|
+
order: Optional[PaginationOrder] = "desc",
|
|
740
|
+
) -> SyncOrAsync["SessionsListResource"]: ...
|
|
741
|
+
|
|
742
|
+
def revoke_session(
|
|
743
|
+
self, *, session_id: str
|
|
744
|
+
) -> SyncOrAsync[UserManagementSession]: ...
|
|
745
|
+
|
|
723
746
|
def get_magic_auth(self, magic_auth_id: str) -> SyncOrAsync[MagicAuth]:
|
|
724
747
|
"""Get the details of a Magic Auth object.
|
|
725
748
|
|
|
@@ -1377,6 +1400,54 @@ class UserManagement(UserManagementModule):
|
|
|
1377
1400
|
|
|
1378
1401
|
return MagicAuth.model_validate(response)
|
|
1379
1402
|
|
|
1403
|
+
def list_sessions(
|
|
1404
|
+
self,
|
|
1405
|
+
*,
|
|
1406
|
+
user_id: str,
|
|
1407
|
+
limit: Optional[int] = DEFAULT_LIST_RESPONSE_LIMIT,
|
|
1408
|
+
before: Optional[str] = None,
|
|
1409
|
+
after: Optional[str] = None,
|
|
1410
|
+
order: Optional[PaginationOrder] = "desc",
|
|
1411
|
+
) -> "SessionsListResource":
|
|
1412
|
+
limit_value: int = limit if limit is not None else DEFAULT_LIST_RESPONSE_LIMIT
|
|
1413
|
+
|
|
1414
|
+
params: ListArgs = {
|
|
1415
|
+
"limit": limit_value,
|
|
1416
|
+
"before": before,
|
|
1417
|
+
"after": after,
|
|
1418
|
+
"order": order,
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
response = self._http_client.request(
|
|
1422
|
+
USER_SESSIONS_PATH.format(user_id),
|
|
1423
|
+
method=REQUEST_METHOD_GET,
|
|
1424
|
+
params=params,
|
|
1425
|
+
)
|
|
1426
|
+
|
|
1427
|
+
list_args: SessionsListFilters = {
|
|
1428
|
+
"limit": limit_value,
|
|
1429
|
+
"before": before,
|
|
1430
|
+
"after": after,
|
|
1431
|
+
"user_id": user_id,
|
|
1432
|
+
}
|
|
1433
|
+
if order is not None:
|
|
1434
|
+
list_args["order"] = order
|
|
1435
|
+
|
|
1436
|
+
return SessionsListResource(
|
|
1437
|
+
list_method=self.list_sessions,
|
|
1438
|
+
list_args=list_args,
|
|
1439
|
+
**ListPage[UserManagementSession](**response).model_dump(),
|
|
1440
|
+
)
|
|
1441
|
+
|
|
1442
|
+
def revoke_session(self, *, session_id: str) -> UserManagementSession:
|
|
1443
|
+
json = {"session_id": session_id}
|
|
1444
|
+
|
|
1445
|
+
response = self._http_client.request(
|
|
1446
|
+
SESSIONS_REVOKE_PATH, method=REQUEST_METHOD_POST, json=json
|
|
1447
|
+
)
|
|
1448
|
+
|
|
1449
|
+
return UserManagementSession.model_validate(response)
|
|
1450
|
+
|
|
1380
1451
|
def enroll_auth_factor(
|
|
1381
1452
|
self,
|
|
1382
1453
|
*,
|
|
@@ -2033,6 +2104,54 @@ class AsyncUserManagement(UserManagementModule):
|
|
|
2033
2104
|
|
|
2034
2105
|
return MagicAuth.model_validate(response)
|
|
2035
2106
|
|
|
2107
|
+
async def list_sessions(
|
|
2108
|
+
self,
|
|
2109
|
+
*,
|
|
2110
|
+
user_id: str,
|
|
2111
|
+
limit: Optional[int] = DEFAULT_LIST_RESPONSE_LIMIT,
|
|
2112
|
+
before: Optional[str] = None,
|
|
2113
|
+
after: Optional[str] = None,
|
|
2114
|
+
order: Optional[PaginationOrder] = "desc",
|
|
2115
|
+
) -> "SessionsListResource":
|
|
2116
|
+
limit_value: int = limit if limit is not None else DEFAULT_LIST_RESPONSE_LIMIT
|
|
2117
|
+
|
|
2118
|
+
params: ListArgs = {
|
|
2119
|
+
"limit": limit_value,
|
|
2120
|
+
"before": before,
|
|
2121
|
+
"after": after,
|
|
2122
|
+
"order": order,
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
response = await self._http_client.request(
|
|
2126
|
+
USER_SESSIONS_PATH.format(user_id),
|
|
2127
|
+
method=REQUEST_METHOD_GET,
|
|
2128
|
+
params=params,
|
|
2129
|
+
)
|
|
2130
|
+
|
|
2131
|
+
list_args: SessionsListFilters = {
|
|
2132
|
+
"limit": limit_value,
|
|
2133
|
+
"before": before,
|
|
2134
|
+
"after": after,
|
|
2135
|
+
"user_id": user_id,
|
|
2136
|
+
}
|
|
2137
|
+
if order is not None:
|
|
2138
|
+
list_args["order"] = order
|
|
2139
|
+
|
|
2140
|
+
return SessionsListResource(
|
|
2141
|
+
list_method=self.list_sessions,
|
|
2142
|
+
list_args=list_args,
|
|
2143
|
+
**ListPage[UserManagementSession](**response).model_dump(),
|
|
2144
|
+
)
|
|
2145
|
+
|
|
2146
|
+
async def revoke_session(self, *, session_id: str) -> UserManagementSession:
|
|
2147
|
+
json = {"session_id": session_id}
|
|
2148
|
+
|
|
2149
|
+
response = await self._http_client.request(
|
|
2150
|
+
SESSIONS_REVOKE_PATH, method=REQUEST_METHOD_POST, json=json
|
|
2151
|
+
)
|
|
2152
|
+
|
|
2153
|
+
return UserManagementSession.model_validate(response)
|
|
2154
|
+
|
|
2036
2155
|
async def enroll_auth_factor(
|
|
2037
2156
|
self,
|
|
2038
2157
|
*,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
workos/__about__.py,sha256=
|
|
1
|
+
workos/__about__.py,sha256=sUrMcjQcQtdtxSlUlUuALqeDB8XbntQylllk9swC78M,406
|
|
2
2
|
workos/__init__.py,sha256=hOdbO_MJCvpLx8EbRjQg-fvFAB-glJmrmxUZK8kWG0k,167
|
|
3
3
|
workos/_base_client.py,sha256=YWLXBpd0YeID3WKYZkKa4l9ZuB9e6HgdLmPKZIzXsME,3599
|
|
4
4
|
workos/_client_configuration.py,sha256=g3eXhtrEMN6CW0hZ5uHb2PmLurXjyBkWZeQYMPeJD6s,222
|
|
@@ -15,14 +15,14 @@ workos/organizations.py,sha256=_kiS0KbFd6TjOqFxwA2gL2EaDO7cDPKwb3RWlw8sQi4,15285
|
|
|
15
15
|
workos/passwordless.py,sha256=NGXDoxomBkrIml8-VHXH1HvCFMqotQ-YhRobUQXpVZs,3203
|
|
16
16
|
workos/portal.py,sha256=lzf3fnOor4AyVdHCHMuJzVSpAC9LWWdC5sZIRtCsb0c,2443
|
|
17
17
|
workos/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
-
workos/session.py,sha256=
|
|
18
|
+
workos/session.py,sha256=Fh9Y7fyjoX_cK2TayhNzpL725pwrNg-QClsgEfuMZsU,12412
|
|
19
19
|
workos/sso.py,sha256=ZBC3y-IRmxG0jPd0BOj7s7XQkXJoTLUg1fx-h3Gfy4g,13541
|
|
20
|
-
workos/user_management.py,sha256=
|
|
20
|
+
workos/user_management.py,sha256=vrqOJO7U8abvnDq36BE7bvqLk9e6diGHeKBH2RYY534,82176
|
|
21
21
|
workos/vault.py,sha256=SJXr3nJ03qJFuf30FjevMD6LLlDNX3MGaKlYGgICRRE,15657
|
|
22
22
|
workos/webhooks.py,sha256=CuwBxh6va9VZFVSXOknveGt6CCGDF3em07a-J12DbXI,4790
|
|
23
23
|
workos/widgets.py,sha256=bfbR0hQOHZabbgGL2ekD5sY1sjiUoWBTdrBd_a6WmBc,1721
|
|
24
24
|
workos/types/__init__.py,sha256=aYScTXq5jOyp0AYvdWffaj5-zdDuNtCCJtbzt5GM19k,267
|
|
25
|
-
workos/types/list_resource.py,sha256=
|
|
25
|
+
workos/types/list_resource.py,sha256=VcJaz8qE91y9t-PRI0mTjzPdtyoU8EGAo6-TJGjbqzg,6747
|
|
26
26
|
workos/types/metadata.py,sha256=uUqDkGJGyFY3H4JZObSiCfn4jKBue5CBhOqv79TI1n0,52
|
|
27
27
|
workos/types/workos_model.py,sha256=bV_p3baadcUJOU_7f6ysZ6KXhpt3E_93spuZnfJs9vc,735
|
|
28
28
|
workos/types/audit_logs/__init__.py,sha256=daPn8wAVEnlM1fCpOsy3dVZV_0YEp8bA1T_nhk5-pU8,211
|
|
@@ -91,20 +91,20 @@ workos/types/sso/connection.py,sha256=GTpaS02EMv2cJAkt20tSxldVCcKQlpl37vQSIAIHSd
|
|
|
91
91
|
workos/types/sso/connection_domain.py,sha256=kMa9GatwUl6YilMU9iiyUKXFfEUKWYub7PyjjYmqhLc,185
|
|
92
92
|
workos/types/sso/profile.py,sha256=IWHpg2GdIvE7eAGi1RJheAqp9AozsKuGfiFc9_IteHI,1075
|
|
93
93
|
workos/types/sso/sso_provider_type.py,sha256=JfO-Ta1wJP7jhtbnWKcS9tElMK_7P6AM10nY-7mM4XE,159
|
|
94
|
-
workos/types/user_management/__init__.py,sha256=
|
|
94
|
+
workos/types/user_management/__init__.py,sha256=paHEZ8-QWPjX6PftupYRRVqfy6tVNevfl2kAD3ZgEZw,384
|
|
95
95
|
workos/types/user_management/authenticate_with_common.py,sha256=2mGRfIgoeX5Ee7c_rxQm6rb6PHyaIBHbGFQsWAhGhY8,2101
|
|
96
96
|
workos/types/user_management/authentication_response.py,sha256=2A6vU8FBEE7bXl5aULB-s80_xsR9caqC9tSr9Yq1NtE,1437
|
|
97
97
|
workos/types/user_management/email_verification.py,sha256=4EqlN7qZBVTZGKaU9WdCSdgFjOMZtkYWTolE-h_hTXA,399
|
|
98
98
|
workos/types/user_management/impersonator.py,sha256=_PAPYg_Q1M8wpwtnkQxuA2vtUIwvs_G30vYY91aqw8E,192
|
|
99
99
|
workos/types/user_management/invitation.py,sha256=4fK-Fk786MlhzZvvOrZtU_6SCJXmem3xw62SkBE1c-0,721
|
|
100
|
-
workos/types/user_management/list_filters.py,sha256=
|
|
100
|
+
workos/types/user_management/list_filters.py,sha256=9QH4UbU28LaZ1iyiMs8H6heqbWpbCunD2MYmO_qA9pY,756
|
|
101
101
|
workos/types/user_management/magic_auth.py,sha256=Sda13_uMOC-hHlyGeOXNnCn-HrpwUmtrf2hO5ek9U98,359
|
|
102
102
|
workos/types/user_management/oauth_tokens.py,sha256=pANk6AyqyRq6hrOrJYQ9AHALVxUbqhGnggzD8PVV-Ew,468
|
|
103
103
|
workos/types/user_management/organization_membership.py,sha256=dllONFtD1IZZiyqxnV8lJpJyH55OeOeaHRBDZlcWLwk,735
|
|
104
104
|
workos/types/user_management/password_hash_type.py,sha256=1752LWdXbaH6TZ6IxbJWeRwlYXX9zN5iJATTaDrCQVA,93
|
|
105
105
|
workos/types/user_management/password_reset.py,sha256=-NJCfEh4Q1xS9fFXJaF_acYeuUc9POqERLh8urMhqt8,403
|
|
106
106
|
workos/types/user_management/screen_hint.py,sha256=DnPgvjRK-20i82v3YPzggna1rc6yOMyhiqwUdk01L3s,75
|
|
107
|
-
workos/types/user_management/session.py,sha256=
|
|
107
|
+
workos/types/user_management/session.py,sha256=crNGjN5pwGM3rXET7iCp0PZpSBK826P_bRlpFOhM5-4,2128
|
|
108
108
|
workos/types/user_management/user.py,sha256=aXRHsLXnQbXWBPRTdAP9Ym_-D9hjmrp_E4PTPi1gF1s,603
|
|
109
109
|
workos/types/user_management/user_management_provider_type.py,sha256=t7S3zLf9n9GSYQJjshGRdiAfebYQKziGmUgbBlOmYuE,185
|
|
110
110
|
workos/types/vault/__init__.py,sha256=krBuIl8luysrtDf9-b8KTkXOHDOaSsOR-Aao6Wlil0Q,41
|
|
@@ -128,8 +128,8 @@ workos/utils/crypto_provider.py,sha256=QeQSR4t9xLlb90kEfl8onVUsf1yCkYq0EjFTxK0mU
|
|
|
128
128
|
workos/utils/http_client.py,sha256=TM5yMFFExmAE8D2Z43-5O301tRbnylLG0aXO0isGorE,6197
|
|
129
129
|
workos/utils/pagination_order.py,sha256=_-et1DDJLG0czarTU7op4W6RA0V1f85GNsUgtyRU55Q,70
|
|
130
130
|
workos/utils/request_helper.py,sha256=NaO16qPPbSNnCeE0fiNKYb8gM-dK_okYVJbLGrEGXz8,793
|
|
131
|
-
workos-5.
|
|
132
|
-
workos-5.
|
|
133
|
-
workos-5.
|
|
134
|
-
workos-5.
|
|
135
|
-
workos-5.
|
|
131
|
+
workos-5.31.0.dist-info/LICENSE,sha256=mU--WL1JzelH2tXpKVoOlpud4cpqKSRTtdArCvYZmb4,1063
|
|
132
|
+
workos-5.31.0.dist-info/METADATA,sha256=YUFDYHxuihkBeFTZ3EbNagDQuyDcI431mVt8mNGFtc0,4187
|
|
133
|
+
workos-5.31.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
134
|
+
workos-5.31.0.dist-info/top_level.txt,sha256=ZFskIfue1Tw-JwjyIXRvdsAl9i0DX9VbqmgICXV84Sk,7
|
|
135
|
+
workos-5.31.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|