benchling-sdk 1.21.0__py3-none-any.whl → 1.21.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.
@@ -1,6 +1,6 @@
1
1
  import base64
2
2
  from datetime import datetime, timedelta, timezone
3
- from typing import Any, cast, List, Mapping, Optional, Protocol, Union
3
+ from typing import cast, List, Optional, Protocol, Union
4
4
 
5
5
  from benchling_api_client.v2.benchling_client import BenchlingApiClient
6
6
  import httpx
@@ -12,6 +12,21 @@ from benchling_sdk.helpers.package_helpers import _required_packages_context, Ex
12
12
  from benchling_sdk.services.v2.stable.api_service import build_json_response
13
13
 
14
14
 
15
+ class HeadersMapping(Protocol):
16
+ """
17
+ A general type for objects that represent request headers.
18
+
19
+ This can be a dict, or any `Mapping[str, str]`, or an instance of a class like
20
+ Flask's Headers class which is dict-like to a limited degree.
21
+ """
22
+
23
+ def __contains__(self, key: str) -> bool:
24
+ pass
25
+
26
+ def __getitem__(self, key: str) -> str:
27
+ pass
28
+
29
+
15
30
  class WebhookVerificationError(Exception):
16
31
  """
17
32
  Webhook Verification Error.
@@ -146,7 +161,7 @@ def jwks_by_app_definition(
146
161
 
147
162
 
148
163
  def verify_app_installation(
149
- app_id: str, data: str, headers: Mapping[str, Any], jwk_function: Optional[LegacyGetJwksFunction] = None
164
+ app_id: str, data: str, headers: HeadersMapping, jwk_function: Optional[LegacyGetJwksFunction] = None
150
165
  ) -> None:
151
166
  """
152
167
  Verify a webhook for an app installation (Deprecated).
@@ -165,7 +180,7 @@ def verify_app_installation(
165
180
  def verify(
166
181
  app_definition_id: str,
167
182
  data: str,
168
- headers: Mapping[str, Any],
183
+ headers: HeadersMapping,
169
184
  jwk_function: Optional[GetJwksFunction] = None,
170
185
  ) -> None:
171
186
  """
@@ -174,6 +189,9 @@ def verify(
174
189
  Verifies that a webhook was a valid webhook from Benchling.
175
190
  Raises WebhookVerificationError if the webhook could not be verified.
176
191
  Resolves JWKs from Benchling with default settings. Pass jwk_function for customization.
192
+
193
+ The headers parameter can be a dict, or a dict-like object such as the Headers type
194
+ from Flask.
177
195
  """
178
196
  default_jwk_function: GetJwksFunction = jwks_by_app_definition
179
197
  _jwk_function: GetJwksFunction = default_jwk_function if jwk_function is None else jwk_function
@@ -201,7 +219,7 @@ def _has_valid_signature(to_verify: str, jwks: jwk.JWKSet, encoded_signatures: L
201
219
  def _verify(
202
220
  app_installation_or_definition_id: str,
203
221
  data: str,
204
- headers: Mapping[str, Any],
222
+ headers: HeadersMapping,
205
223
  jwk_function: Union[GetJwksFunction, LegacyGetJwksFunction],
206
224
  ) -> None:
207
225
  _verify_headers_present(headers)
@@ -215,7 +233,7 @@ def _verify(
215
233
  raise WebhookVerificationError("No matching signature found")
216
234
 
217
235
 
218
- def _der_signatures_from_versioned_signatures(versioned_signatures: str) -> List[str]:
236
+ def _der_signatures_from_versioned_signatures(versioned_signatures: List[str]) -> List[str]:
219
237
  """
220
238
  Parse and return a list of ders signatures from a single string.
221
239
 
@@ -231,7 +249,7 @@ def _der_signatures_from_versioned_signatures(versioned_signatures: str) -> List
231
249
  return der_signatures
232
250
 
233
251
 
234
- def _verify_headers_present(headers: Mapping[str, Any]) -> None:
252
+ def _verify_headers_present(headers: HeadersMapping) -> None:
235
253
  """
236
254
  Verify Headers Present.
237
255
 
@@ -5,7 +5,7 @@ from contextlib import AbstractContextManager
5
5
  from types import TracebackType
6
6
  from typing import cast, Iterable, List, Optional, Protocol, Type, TYPE_CHECKING, Union
7
7
 
8
- from benchling_api_client.v2.stable.types import Unset, UNSET
8
+ from benchling_api_client.v2.stable.types import UNSET, Unset
9
9
 
10
10
  from benchling_sdk.apps.status.errors import (
11
11
  AppUserFacingError,
@@ -1,7 +1,7 @@
1
1
  from dataclasses import dataclass
2
2
  from typing import Any, Dict, Iterable, Optional, Type, TypeVar, Union
3
3
 
4
- from benchling_api_client.v2.types import Unset, UNSET
4
+ from benchling_api_client.v2.types import UNSET, Unset
5
5
  from dataclasses_json import DataClassJsonMixin
6
6
 
7
7
  from benchling_sdk.models import CustomFields, Field, Fields, SchemaFieldsQueryParam
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: benchling-sdk
3
- Version: 1.21.0
3
+ Version: 1.21.1
4
4
  Summary: SDK for interacting with the Benchling Platform.
5
5
  License: Apache-2.0
6
6
  Author: Benchling Support
@@ -16,10 +16,10 @@ benchling_sdk/apps/config/types.py,sha256=XKfSGv-75CU-j1XwfXBGq8zbtnkF-PQnuY6Z2U
16
16
  benchling_sdk/apps/framework.py,sha256=G15mv20FH7FLHJrnXMPcuFdUsP3Va-grvb5A4eq0Qlk,3175
17
17
  benchling_sdk/apps/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  benchling_sdk/apps/helpers/manifest_helpers.py,sha256=yidiKA5mwWdAFR1ZSUu40QoG0Us-bc6V8tYHYqheEtM,945
19
- benchling_sdk/apps/helpers/webhook_helpers.py,sha256=TG1T76A6zI8EceoVE6E5hYG_hdZCmjRtsF6r0rG6fwo,10065
19
+ benchling_sdk/apps/helpers/webhook_helpers.py,sha256=CLotJQYm6QfXjnzzkO193m_qHbS-TBEniCkICnLH2_w,10535
20
20
  benchling_sdk/apps/status/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  benchling_sdk/apps/status/errors.py,sha256=BezqnaHkCG1QBscD4301NjSYBHu7BzdYEUKF90psuz0,2377
22
- benchling_sdk/apps/status/framework.py,sha256=go0pyU5qgMCvsrTDXWk3V9FZwbaRHgfhEWtjIZ-JLEE,27418
22
+ benchling_sdk/apps/status/framework.py,sha256=xbZ5jJxI62Wf0EehUhPDysv-Utag4sZoisGzqiMm-CM,27418
23
23
  benchling_sdk/apps/status/helpers.py,sha256=MSa2soRIK7TiA9TWAEg-EoqZ7ZYyjTmtJ28JIe6LUds,1316
24
24
  benchling_sdk/apps/status/types.py,sha256=vE7-_7ns3mvPRJoVv-GQxc3389dIIH4mcG0VDNWpVhQ,746
25
25
  benchling_sdk/apps/types.py,sha256=TBTfAB3IOoZjZqzTOK25kN3b6RTU9Z7tOMdBbq6u8lA,110
@@ -41,7 +41,7 @@ benchling_sdk/helpers/package_helpers.py,sha256=JLDDdlOwz6_BgP5j157u0qX-Mtb7ZkzX
41
41
  benchling_sdk/helpers/pagination_helpers.py,sha256=Dewy1OxAO0ZdJOGuEPyJGkjU8Hu8iFNWob-z0riMNOs,7745
42
42
  benchling_sdk/helpers/response_helpers.py,sha256=vtmb9lEEKy3dRFre3Q0R4XaLBEaS_rruxtwPvpepPUw,613
43
43
  benchling_sdk/helpers/retry_helpers.py,sha256=Sd7F8HMGPs31svYW-1z-SujbWUBn3qlZUk52hZ5G7xw,2814
44
- benchling_sdk/helpers/serialization_helpers.py,sha256=IUS0uGU_EiZvb8O-bTViUaROmxKcvdX3JeR9iKsWAG8,3662
44
+ benchling_sdk/helpers/serialization_helpers.py,sha256=jpW7ydipBB1q4Ek1t9tWkTOul_E1QwtlzwTnBZp7LB4,3662
45
45
  benchling_sdk/helpers/task_helpers.py,sha256=4AgAR7JSlP3jb4egGTesxixzgsTbod6uJvdS0VIOppI,7349
46
46
  benchling_sdk/helpers/transaction_manager.py,sha256=HcSDsgGK7Rb93bgv6fpb4HvQUT-tqP0lXgVa_bWCDh4,3663
47
47
  benchling_sdk/models/__init__.py,sha256=4m3QBFbghDfeU3hAf3h-DELjhcH1MUtvc0kJyGRG-q0,372428
@@ -120,7 +120,7 @@ benchling_sdk/services/v2/v2_alpha_service.py,sha256=rl4niKxjU-Rvdx5W6cjyXd4rUMo
120
120
  benchling_sdk/services/v2/v2_beta_service.py,sha256=SEv2AsZG0phf_B4ORqjRO-3VBkYehu1hlUhRFHrpX3c,6093
121
121
  benchling_sdk/services/v2/v2_stable_service.py,sha256=21TzqEFHygMUFv0z0z8_MtXpSHLgwYC7YbIIsHrljaw,28232
122
122
  benchling_sdk/services/v2_service.py,sha256=cGX-Ps0hu7Oh1M7a0tu2zDN8-QG63dNDoK7w4eYo_OQ,3093
123
- benchling_sdk-1.21.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
124
- benchling_sdk-1.21.0.dist-info/METADATA,sha256=kZHp9f3LPEHGoTEM2OddcOE_eQPyZfIQ5mvSnltbkCM,2058
125
- benchling_sdk-1.21.0.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
126
- benchling_sdk-1.21.0.dist-info/RECORD,,
123
+ benchling_sdk-1.21.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
124
+ benchling_sdk-1.21.1.dist-info/METADATA,sha256=JGAaM4hofzaehnL0qmWd3_dZA3dHjKjS79reu0pZKRI,2058
125
+ benchling_sdk-1.21.1.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
126
+ benchling_sdk-1.21.1.dist-info/RECORD,,