workos 5.30.0__py3-none-any.whl → 5.31.1__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 +113 -0
- {workos-5.30.0.dist-info → workos-5.31.1.dist-info}/METADATA +1 -1
- {workos-5.30.0.dist-info → workos-5.31.1.dist-info}/RECORD +12 -12
- {workos-5.30.0.dist-info → workos-5.31.1.dist-info}/LICENSE +0 -0
- {workos-5.30.0.dist-info → workos-5.31.1.dist-info}/WHEEL +0 -0
- {workos-5.30.0.dist-info → workos-5.31.1.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,18 @@ 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(self, *, session_id: str) -> SyncOrAsync[None]: ...
|
|
743
|
+
|
|
723
744
|
def get_magic_auth(self, magic_auth_id: str) -> SyncOrAsync[MagicAuth]:
|
|
724
745
|
"""Get the details of a Magic Auth object.
|
|
725
746
|
|
|
@@ -1377,6 +1398,52 @@ class UserManagement(UserManagementModule):
|
|
|
1377
1398
|
|
|
1378
1399
|
return MagicAuth.model_validate(response)
|
|
1379
1400
|
|
|
1401
|
+
def list_sessions(
|
|
1402
|
+
self,
|
|
1403
|
+
*,
|
|
1404
|
+
user_id: str,
|
|
1405
|
+
limit: Optional[int] = DEFAULT_LIST_RESPONSE_LIMIT,
|
|
1406
|
+
before: Optional[str] = None,
|
|
1407
|
+
after: Optional[str] = None,
|
|
1408
|
+
order: Optional[PaginationOrder] = "desc",
|
|
1409
|
+
) -> "SessionsListResource":
|
|
1410
|
+
limit_value: int = limit if limit is not None else DEFAULT_LIST_RESPONSE_LIMIT
|
|
1411
|
+
|
|
1412
|
+
params: ListArgs = {
|
|
1413
|
+
"limit": limit_value,
|
|
1414
|
+
"before": before,
|
|
1415
|
+
"after": after,
|
|
1416
|
+
"order": order,
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
response = self._http_client.request(
|
|
1420
|
+
USER_SESSIONS_PATH.format(user_id),
|
|
1421
|
+
method=REQUEST_METHOD_GET,
|
|
1422
|
+
params=params,
|
|
1423
|
+
)
|
|
1424
|
+
|
|
1425
|
+
list_args: SessionsListFilters = {
|
|
1426
|
+
"limit": limit_value,
|
|
1427
|
+
"before": before,
|
|
1428
|
+
"after": after,
|
|
1429
|
+
"user_id": user_id,
|
|
1430
|
+
}
|
|
1431
|
+
if order is not None:
|
|
1432
|
+
list_args["order"] = order
|
|
1433
|
+
|
|
1434
|
+
return SessionsListResource(
|
|
1435
|
+
list_method=self.list_sessions,
|
|
1436
|
+
list_args=list_args,
|
|
1437
|
+
**ListPage[UserManagementSession](**response).model_dump(),
|
|
1438
|
+
)
|
|
1439
|
+
|
|
1440
|
+
def revoke_session(self, *, session_id: str) -> None:
|
|
1441
|
+
json = {"session_id": session_id}
|
|
1442
|
+
|
|
1443
|
+
self._http_client.request(
|
|
1444
|
+
SESSIONS_REVOKE_PATH, method=REQUEST_METHOD_POST, json=json
|
|
1445
|
+
)
|
|
1446
|
+
|
|
1380
1447
|
def enroll_auth_factor(
|
|
1381
1448
|
self,
|
|
1382
1449
|
*,
|
|
@@ -2033,6 +2100,52 @@ class AsyncUserManagement(UserManagementModule):
|
|
|
2033
2100
|
|
|
2034
2101
|
return MagicAuth.model_validate(response)
|
|
2035
2102
|
|
|
2103
|
+
async def list_sessions(
|
|
2104
|
+
self,
|
|
2105
|
+
*,
|
|
2106
|
+
user_id: str,
|
|
2107
|
+
limit: Optional[int] = DEFAULT_LIST_RESPONSE_LIMIT,
|
|
2108
|
+
before: Optional[str] = None,
|
|
2109
|
+
after: Optional[str] = None,
|
|
2110
|
+
order: Optional[PaginationOrder] = "desc",
|
|
2111
|
+
) -> "SessionsListResource":
|
|
2112
|
+
limit_value: int = limit if limit is not None else DEFAULT_LIST_RESPONSE_LIMIT
|
|
2113
|
+
|
|
2114
|
+
params: ListArgs = {
|
|
2115
|
+
"limit": limit_value,
|
|
2116
|
+
"before": before,
|
|
2117
|
+
"after": after,
|
|
2118
|
+
"order": order,
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
response = await self._http_client.request(
|
|
2122
|
+
USER_SESSIONS_PATH.format(user_id),
|
|
2123
|
+
method=REQUEST_METHOD_GET,
|
|
2124
|
+
params=params,
|
|
2125
|
+
)
|
|
2126
|
+
|
|
2127
|
+
list_args: SessionsListFilters = {
|
|
2128
|
+
"limit": limit_value,
|
|
2129
|
+
"before": before,
|
|
2130
|
+
"after": after,
|
|
2131
|
+
"user_id": user_id,
|
|
2132
|
+
}
|
|
2133
|
+
if order is not None:
|
|
2134
|
+
list_args["order"] = order
|
|
2135
|
+
|
|
2136
|
+
return SessionsListResource(
|
|
2137
|
+
list_method=self.list_sessions,
|
|
2138
|
+
list_args=list_args,
|
|
2139
|
+
**ListPage[UserManagementSession](**response).model_dump(),
|
|
2140
|
+
)
|
|
2141
|
+
|
|
2142
|
+
async def revoke_session(self, *, session_id: str) -> None:
|
|
2143
|
+
json = {"session_id": session_id}
|
|
2144
|
+
|
|
2145
|
+
await self._http_client.request(
|
|
2146
|
+
SESSIONS_REVOKE_PATH, method=REQUEST_METHOD_POST, json=json
|
|
2147
|
+
)
|
|
2148
|
+
|
|
2036
2149
|
async def enroll_auth_factor(
|
|
2037
2150
|
self,
|
|
2038
2151
|
*,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
workos/__about__.py,sha256=
|
|
1
|
+
workos/__about__.py,sha256=IyGLpvXeW7_jWVZ5WlatVanV7cpOVcOfigzuFGiUSCE,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=n2xaPiv3t38ckWApNZyNKXbv2EQorxgoPhljd-5ekys,81963
|
|
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.1.dist-info/LICENSE,sha256=mU--WL1JzelH2tXpKVoOlpud4cpqKSRTtdArCvYZmb4,1063
|
|
132
|
+
workos-5.31.1.dist-info/METADATA,sha256=sfYe_N4irtXmMSJ-HY8mQFNwx49Pgld-Syx5qAzjedA,4187
|
|
133
|
+
workos-5.31.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
134
|
+
workos-5.31.1.dist-info/top_level.txt,sha256=ZFskIfue1Tw-JwjyIXRvdsAl9i0DX9VbqmgICXV84Sk,7
|
|
135
|
+
workos-5.31.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|