langgraph-api 0.0.10__py3-none-any.whl → 0.0.11__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.

Potentially problematic release.


This version of langgraph-api might be problematic. Click here for more details.

@@ -158,8 +158,8 @@ class CustomAuthBackend(AuthenticationBackend):
158
158
  args = _extract_arguments_from_scope(
159
159
  conn.scope, self._param_names, request=Request(conn.scope)
160
160
  )
161
- scopes, user = await self.fn(**args)
162
- return AuthCredentials(scopes), _normalize_user(user)
161
+ response = await self.fn(**args)
162
+ return _normalize_auth_response(response)
163
163
  except AssertionError as e:
164
164
  raise AuthenticationError(str(e)) from None
165
165
 
@@ -415,6 +415,28 @@ class ProxyUser(BaseUser):
415
415
  return getattr(self._user, name)
416
416
 
417
417
 
418
+ def _normalize_auth_response(
419
+ response: Any,
420
+ ) -> tuple[AuthCredentials, BaseUser]:
421
+ if isinstance(response, tuple):
422
+ if len(response) != 2:
423
+ raise ValueError(
424
+ f"Expected a tuple with two elements (permissions, user), got {len(response)}"
425
+ )
426
+ permissions, user = response
427
+ elif hasattr(response, "permissions"):
428
+ permissions = response.permissions
429
+ user = response
430
+ elif isinstance(response, dict | Mapping) and "permissions" in response:
431
+ permissions = response["permissions"]
432
+ user = response
433
+ else:
434
+ user = response
435
+ permissions = []
436
+
437
+ return AuthCredentials(permissions), _normalize_user(user)
438
+
439
+
418
440
  def _normalize_user(user: Any) -> BaseUser:
419
441
  """Normalize user into a BaseUser instance."""
420
442
  if isinstance(user, BaseUser):
langgraph_api/utils.py CHANGED
@@ -6,7 +6,7 @@ from datetime import datetime
6
6
  from typing import Any, Protocol, TypeAlias, TypeVar
7
7
 
8
8
  from langgraph_sdk import Auth
9
- from starlette.authentication import AuthCredentials, BaseUser
9
+ from starlette.authentication import AuthCredentials, BaseUser, SimpleUser
10
10
  from starlette.exceptions import HTTPException
11
11
 
12
12
  T = TypeVar("T")
@@ -32,8 +32,8 @@ def set_auth_ctx(user: BaseUser | None, auth: AuthCredentials | None) -> None:
32
32
  else:
33
33
  AuthContext.set(
34
34
  Auth.types.BaseAuthContext(
35
- scopes=auth.scopes,
36
- user=user,
35
+ permissions=auth.scopes,
36
+ user=user or SimpleUser(""),
37
37
  )
38
38
  )
39
39
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langgraph-api
3
- Version: 0.0.10
3
+ Version: 0.0.11
4
4
  Summary:
5
5
  License: Elastic-2.0
6
6
  Author: Nuno Campos
@@ -16,6 +16,7 @@ Requires-Dist: jsonschema-rs (>=0.25.0,<0.26.0)
16
16
  Requires-Dist: langchain-core (>=0.2.38,<0.4.0)
17
17
  Requires-Dist: langgraph (>=0.2.56,<0.3.0)
18
18
  Requires-Dist: langgraph-checkpoint (>=2.0.7,<3.0)
19
+ Requires-Dist: langgraph-sdk (>=0.1.47,<0.2.0)
19
20
  Requires-Dist: langsmith (>=0.1.63,<0.3.0)
20
21
  Requires-Dist: orjson (>=3.10.1)
21
22
  Requires-Dist: pyjwt (>=2.9.0,<3.0.0)
@@ -9,7 +9,7 @@ langgraph_api/api/store.py,sha256=y7VIejpsE7rpPF-tiMGBqqBwWPZ1wb3o48th6NUvb5I,38
9
9
  langgraph_api/api/threads.py,sha256=taU61XPcCEhBPCYPZcMDsgVDwwWUWJs8p-PrXFXWY48,8661
10
10
  langgraph_api/asyncio.py,sha256=XiFEllu-Kg4zAO084npHPYOPnLQRire3V75XrVQYMxE,6023
11
11
  langgraph_api/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
- langgraph_api/auth/custom.py,sha256=nE8dgtSuX4W8UoByEmr5aH0yK6H_rk0VOoETET9BqJQ,17528
12
+ langgraph_api/auth/custom.py,sha256=8jyZz-HOC4NwpDASVAD2fP8priQSw8uEjZ8VPJNC5EE,18225
13
13
  langgraph_api/auth/langsmith/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
14
  langgraph_api/auth/langsmith/backend.py,sha256=uHeb5-h13NIjrX_LDAvfWYr3zpbJvlvbdUffch48hbM,2571
15
15
  langgraph_api/auth/langsmith/client.py,sha256=eKchvAom7hdkUXauD8vHNceBDDUijrFgdTV8bKd7x4Q,3998
@@ -65,7 +65,7 @@ langgraph_api/server.py,sha256=afHDnL6b_fAIu_q4icnK60a74lHTTZOMIe1egdhRXIk,1522
65
65
  langgraph_api/sse.py,sha256=2wNodCOP2eg7a9mpSu0S3FQ0CHk2BBV_vv0UtIgJIcc,4034
66
66
  langgraph_api/state.py,sha256=8jx4IoTCOjTJuwzuXJKKFwo1VseHjNnw_CCq4x1SW14,2284
67
67
  langgraph_api/stream.py,sha256=u0gjbCrmYvVw8Ux6DgsYTojLCHSwM4Pi-0LhSLGY4HM,11546
68
- langgraph_api/utils.py,sha256=17AZrdVzGHUQ7Y8b82Mknxe1LD5JMo4tZsb6TCcXEW0,2474
68
+ langgraph_api/utils.py,sha256=o7TFlY25IjujeKdXgtyE2mMLPETIlrbOc3w6giYBq2Y,2509
69
69
  langgraph_api/validation.py,sha256=McizHlz-Ez8Jhdbc79mbPSde7GIuf2Jlbjx2yv_l6dA,4475
70
70
  langgraph_license/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
71
71
  langgraph_license/middleware.py,sha256=_ODIYzQkymr6W9_Fp9wtf1kAQspnpsmr53xuzyF2GA0,612
@@ -73,15 +73,15 @@ langgraph_license/validation.py,sha256=Uu_G8UGO_WTlLsBEY0gTVWjRR4czYGfw5YAD3HLZo
73
73
  langgraph_storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
74
74
  langgraph_storage/checkpoint.py,sha256=V4t2GwYEJdPCHbhq_4Udhlv0TWKDzlMu_rlNPdTDc50,3589
75
75
  langgraph_storage/database.py,sha256=Nr5zE9Fur3-tESkqe7xNXMf2QlBuw3H0CUie7jVa6Q4,6003
76
- langgraph_storage/ops.py,sha256=V0gnBlpzW3AE9kBNcT_uONYYEHEdgTR6a4mA9Owz6S4,67669
76
+ langgraph_storage/ops.py,sha256=W3NcQbY1Q8EpsIs4HjGY5Yx2In0TYc9_D4SKdZYPaDQ,67679
77
77
  langgraph_storage/queue.py,sha256=6cTZ0ubHu3S1T43yxHMVOwsQsDaJupByiU0sTUFFls8,3261
78
78
  langgraph_storage/retry.py,sha256=uvYFuXJ-T6S1QY1ZwkZHyZQbsvS-Ab68LSbzbUUSI2E,696
79
79
  langgraph_storage/store.py,sha256=D-p3cWc_umamkKp-6Cz3cAriSACpvM5nxUIvND6PuxE,2710
80
80
  langgraph_storage/ttl_dict.py,sha256=FlpEY8EANeXWKo_G5nmIotPquABZGyIJyk6HD9u6vqY,1533
81
81
  logging.json,sha256=3RNjSADZmDq38eHePMm1CbP6qZ71AmpBtLwCmKU9Zgo,379
82
82
  openapi.json,sha256=UxAGHZYM4PgNd48TSZt7f2lVuyPUkDadxBBhRy5jcmk,124512
83
- langgraph_api-0.0.10.dist-info/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
84
- langgraph_api-0.0.10.dist-info/METADATA,sha256=VgLW5dnP15w_SuuNkgpgYVjDrBGxxuKGvvEaDOkxMhk,3994
85
- langgraph_api-0.0.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
86
- langgraph_api-0.0.10.dist-info/entry_points.txt,sha256=3EYLgj89DfzqJHHYGxPH4A_fEtClvlRbWRUHaXO7hj4,77
87
- langgraph_api-0.0.10.dist-info/RECORD,,
83
+ langgraph_api-0.0.11.dist-info/LICENSE,sha256=ZPwVR73Biwm3sK6vR54djCrhaRiM4cAD2zvOQZV8Xis,3859
84
+ langgraph_api-0.0.11.dist-info/METADATA,sha256=dIfDLkeyakteByG5V-curloWZyMGWy77SUf1J3gtBok,4041
85
+ langgraph_api-0.0.11.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
86
+ langgraph_api-0.0.11.dist-info/entry_points.txt,sha256=3EYLgj89DfzqJHHYGxPH4A_fEtClvlRbWRUHaXO7hj4,77
87
+ langgraph_api-0.0.11.dist-info/RECORD,,
langgraph_storage/ops.py CHANGED
@@ -83,7 +83,7 @@ class Authenticated:
83
83
  return
84
84
  return Auth.types.AuthContext(
85
85
  user=ctx.user,
86
- scopes=ctx.scopes,
86
+ permissions=ctx.permissions,
87
87
  resource=cls.resource,
88
88
  action=action,
89
89
  )