Skip to content

Commit 984df7f

Browse files
authored
Merge branch 'main' into logan/url-encoding
2 parents 34222de + dc0f784 commit 984df7f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1448
-124
lines changed

stytch/b2b/api/discovery_intermediate_sessions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def exchange(
3131
session_duration_minutes: Optional[int] = None,
3232
session_custom_claims: Optional[Dict[str, Any]] = None,
3333
locale: Optional[Union[ExchangeRequestLocale, str]] = None,
34+
telemetry_id: Optional[str] = None,
3435
) -> ExchangeResponse:
3536
"""Exchange an Intermediate Session for a fully realized [Member Session](https://stytch.com/docs/b2b/api/session-object) for the [Organization](https://stytch.com/docs/b2b/api/organization-object) that the user wishes to log into.
3637
@@ -73,6 +74,7 @@ def exchange(
7374
7475
Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
7576
77+
- telemetry_id: If the `telemetry_id` is passed, as part of this request, Stytch will call the [Fingerprint Lookup API](https://stytch.com/docs/fraud/api/fingerprint-lookup) and store the associated fingerprints and IPGEO information for the Member. Your workspace must be enabled for Device Fingerprinting to use this feature.
7678
""" # noqa
7779
headers: Dict[str, str] = {}
7880
data: Dict[str, Any] = {
@@ -85,6 +87,8 @@ def exchange(
8587
data["session_custom_claims"] = session_custom_claims
8688
if locale is not None:
8789
data["locale"] = locale
90+
if telemetry_id is not None:
91+
data["telemetry_id"] = telemetry_id
8892

8993
url = self.api_base.url_for(
9094
"/v1/b2b/discovery/intermediate_sessions/exchange", data
@@ -99,6 +103,7 @@ async def exchange_async(
99103
session_duration_minutes: Optional[int] = None,
100104
session_custom_claims: Optional[Dict[str, Any]] = None,
101105
locale: Optional[ExchangeRequestLocale] = None,
106+
telemetry_id: Optional[str] = None,
102107
) -> ExchangeResponse:
103108
"""Exchange an Intermediate Session for a fully realized [Member Session](https://stytch.com/docs/b2b/api/session-object) for the [Organization](https://stytch.com/docs/b2b/api/organization-object) that the user wishes to log into.
104109
@@ -141,6 +146,7 @@ async def exchange_async(
141146
142147
Request support for additional languages [here](https://docs.google.com/forms/d/e/1FAIpQLScZSpAu_m2AmLXRT3F3kap-s_mcV6UTBitYn6CdyWP0-o7YjQ/viewform?usp=sf_link")!
143148
149+
- telemetry_id: If the `telemetry_id` is passed, as part of this request, Stytch will call the [Fingerprint Lookup API](https://stytch.com/docs/fraud/api/fingerprint-lookup) and store the associated fingerprints and IPGEO information for the Member. Your workspace must be enabled for Device Fingerprinting to use this feature.
144150
""" # noqa
145151
headers: Dict[str, str] = {}
146152
data: Dict[str, Any] = {
@@ -153,6 +159,8 @@ async def exchange_async(
153159
data["session_custom_claims"] = session_custom_claims
154160
if locale is not None:
155161
data["locale"] = locale
162+
if telemetry_id is not None:
163+
data["telemetry_id"] = telemetry_id
156164

157165
url = self.api_base.url_for(
158166
"/v1/b2b/discovery/intermediate_sessions/exchange", data

stytch/b2b/api/discovery_organizations.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ def create(
5858
Union[CreateRequestThirdPartyConnectedAppsAllowedType, str]
5959
] = None,
6060
allowed_third_party_connected_apps: Optional[List[str]] = None,
61+
telemetry_id: Optional[str] = None,
6162
) -> CreateResponse:
6263
"""This endpoint allows you to exchange the `intermediate_session_token` returned when the user successfully completes a Discovery authentication flow to create a new
6364
[Organization](https://stytch.com/docs/b2b/api/organization-object) and [Member](https://stytch.com/docs/b2b/api/member-object) and log the user in. If the user wants to log into an existing Organization, use the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) instead.
@@ -174,6 +175,7 @@ def create(
174175
`NOT_ALLOWED` – no third party Connected Apps are permitted.
175176
176177
- allowed_third_party_connected_apps: An array of third party Connected App IDs that are allowed for the Organization. Only used when the Organization's `third_party_connected_apps_allowed_type` is `RESTRICTED`.
178+
- telemetry_id: If the `telemetry_id` is passed, as part of this request, Stytch will call the [Fingerprint Lookup API](https://stytch.com/docs/fraud/api/fingerprint-lookup) and store the associated fingerprints and IPGEO information for the Member. Your workspace must be enabled for Device Fingerprinting to use this feature.
177179
""" # noqa
178180
headers: Dict[str, str] = {}
179181
data: Dict[str, Any] = {
@@ -234,6 +236,8 @@ def create(
234236
data["allowed_third_party_connected_apps"] = (
235237
allowed_third_party_connected_apps
236238
)
239+
if telemetry_id is not None:
240+
data["telemetry_id"] = telemetry_id
237241

238242
url = self.api_base.url_for("/v1/b2b/discovery/organizations/create", data)
239243
res = self.sync_client.post(url, data, headers)
@@ -270,6 +274,7 @@ async def create_async(
270274
CreateRequestThirdPartyConnectedAppsAllowedType
271275
] = None,
272276
allowed_third_party_connected_apps: Optional[List[str]] = None,
277+
telemetry_id: Optional[str] = None,
273278
) -> CreateResponse:
274279
"""This endpoint allows you to exchange the `intermediate_session_token` returned when the user successfully completes a Discovery authentication flow to create a new
275280
[Organization](https://stytch.com/docs/b2b/api/organization-object) and [Member](https://stytch.com/docs/b2b/api/member-object) and log the user in. If the user wants to log into an existing Organization, use the [Exchange Intermediate Session endpoint](https://stytch.com/docs/b2b/api/exchange-intermediate-session) instead.
@@ -386,6 +391,7 @@ async def create_async(
386391
`NOT_ALLOWED` – no third party Connected Apps are permitted.
387392
388393
- allowed_third_party_connected_apps: An array of third party Connected App IDs that are allowed for the Organization. Only used when the Organization's `third_party_connected_apps_allowed_type` is `RESTRICTED`.
394+
- telemetry_id: If the `telemetry_id` is passed, as part of this request, Stytch will call the [Fingerprint Lookup API](https://stytch.com/docs/fraud/api/fingerprint-lookup) and store the associated fingerprints and IPGEO information for the Member. Your workspace must be enabled for Device Fingerprinting to use this feature.
389395
""" # noqa
390396
headers: Dict[str, str] = {}
391397
data: Dict[str, Any] = {
@@ -446,6 +452,8 @@ async def create_async(
446452
data["allowed_third_party_connected_apps"] = (
447453
allowed_third_party_connected_apps
448454
)
455+
if telemetry_id is not None:
456+
data["telemetry_id"] = telemetry_id
449457

450458
url = self.api_base.url_for("/v1/b2b/discovery/organizations/create", data)
451459
res = await self.async_client.post(url, data, headers)

stytch/b2b/api/idp.py

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1+
# !!!
2+
# WARNING: This file is autogenerated
3+
# Only modify code within MANUAL() sections
4+
# or your changes may be overwritten later!
5+
# !!!
6+
17
from __future__ import annotations
28

39
from typing import Any, Dict, Optional
410

511
import jwt
612

13+
from stytch.b2b.api.idp_oauth import OAuth
714
from stytch.b2b.models.sessions import AuthorizationCheck
815
from stytch.consumer.models.idp import IDPTokenClaims, IDPTokenResponse
916
from stytch.core.api_base import ApiBase
@@ -25,26 +32,19 @@ def __init__(
2532
self.api_base = api_base
2633
self.sync_client = sync_client
2734
self.async_client = async_client
35+
self.policy_cache = policy_cache
2836
self.jwks_client = jwks_client
2937
self.project_id = project_id
30-
self.non_custom_claim_keys = [
31-
"aud",
32-
"exp",
33-
"iat",
34-
"iss",
35-
"jti",
36-
"nbf",
37-
"sub",
38-
"active",
39-
"client_id",
40-
"request_id",
41-
"scope",
42-
"status_code",
43-
"token_type",
44-
"https://stytch.com/organization",
45-
]
46-
self.policy_cache = policy_cache
38+
self.oauth = OAuth(
39+
api_base=self.api_base,
40+
sync_client=self.sync_client,
41+
async_client=self.async_client,
42+
)
4743

44+
# MANUAL(IDP)(SERVICE_METHOD)
45+
# ADDIMPORT: from stytch.b2b.models.sessions import AuthorizationCheck
46+
# ADDIMPORT: from stytch.shared import jwt_helpers, rbac_local
47+
# ADDIMPORT: from stytch.consumer.models.idp import IDPTokenClaims, IDPTokenResponse
4848
def introspect_token_network(
4949
self,
5050
token: str,
@@ -80,7 +80,7 @@ def introspect_token_network(
8080
if not jwtResponse.active:
8181
return None
8282
custom_claims = {
83-
k: v for k, v in res.json.items() if k not in self.non_custom_claim_keys
83+
k: v for k, v in res.json.items() if k not in self._non_custom_claim_keys()
8484
}
8585
organization_claim = res.json["https://stytch.com/organization"]
8686
organization_id = organization_claim["organization_id"]
@@ -142,7 +142,7 @@ async def introspect_token_network_async(
142142
if not jwtResponse.active:
143143
return None
144144
custom_claims = {
145-
k: v for k, v in res.json.items() if k not in self.non_custom_claim_keys
145+
k: v for k, v in res.json.items() if k not in self._non_custom_claim_keys()
146146
}
147147
organization_claim = res.json["https://stytch.com/organization"]
148148
organization_id = organization_claim["organization_id"]
@@ -222,3 +222,22 @@ def introspect_access_token_local(
222222
token_type="access_token",
223223
organization_claim=org_claim,
224224
)
225+
226+
def _non_custom_claim_keys(self):
227+
return [
228+
"aud",
229+
"exp",
230+
"iat",
231+
"iss",
232+
"jti",
233+
"nbf",
234+
"sub",
235+
"active",
236+
"client_id",
237+
"request_id",
238+
"scope",
239+
"status_code",
240+
"token_type",
241+
]
242+
243+
# ENDMANUAL(IDP)

0 commit comments

Comments
 (0)