workos 5.23.0__py3-none-any.whl → 5.24.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 CHANGED
@@ -12,7 +12,7 @@ __package_name__ = "workos"
12
12
 
13
13
  __package_url__ = "https://github.com/workos-inc/workos-python"
14
14
 
15
- __version__ = "5.23.0"
15
+ __version__ = "5.24.0"
16
16
 
17
17
  __author__ = "WorkOS"
18
18
 
workos/async_client.py CHANGED
@@ -14,6 +14,7 @@ from workos.user_management import AsyncUserManagement
14
14
  from workos.utils.http_client import AsyncHTTPClient
15
15
  from workos.webhooks import WebhooksModule
16
16
  from workos.widgets import WidgetsModule
17
+ from workos.vault import VaultModule
17
18
 
18
19
 
19
20
  class AsyncClient(BaseClient):
@@ -112,3 +113,9 @@ class AsyncClient(BaseClient):
112
113
  raise NotImplementedError(
113
114
  "Widgets APIs are not yet supported in the async client."
114
115
  )
116
+
117
+ @property
118
+ def vault(self) -> VaultModule:
119
+ raise NotImplementedError(
120
+ "Vault APIs are not yet supported in the async client."
121
+ )
workos/client.py CHANGED
@@ -14,6 +14,7 @@ from workos.events import Events
14
14
  from workos.user_management import UserManagement
15
15
  from workos.utils.http_client import SyncHTTPClient
16
16
  from workos.widgets import Widgets
17
+ from workos.vault import Vault
17
18
 
18
19
 
19
20
  class SyncClient(BaseClient):
@@ -116,3 +117,9 @@ class SyncClient(BaseClient):
116
117
  if not getattr(self, "_widgets", None):
117
118
  self._widgets = Widgets(http_client=self._http_client)
118
119
  return self._widgets
120
+
121
+ @property
122
+ def vault(self) -> Vault:
123
+ if not getattr(self, "_vault", None):
124
+ self._vault = Vault(http_client=self._http_client)
125
+ return self._vault
@@ -193,6 +193,18 @@ class OrganizationDomainVerifiedEvent(EventModel[OrganizationDomain]):
193
193
  event: Literal["organization_domain.verified"]
194
194
 
195
195
 
196
+ class OrganizationDomainCreatedEvent(EventModel[OrganizationDomain]):
197
+ event: Literal["organization_domain.created"]
198
+
199
+
200
+ class OrganizationDomainUpdatedEvent(EventModel[OrganizationDomain]):
201
+ event: Literal["organization_domain.updated"]
202
+
203
+
204
+ class OrganizationDomainDeletedEvent(EventModel[OrganizationDomain]):
205
+ event: Literal["organization_domain.deleted"]
206
+
207
+
196
208
  class OrganizationMembershipCreatedEvent(EventModel[OrganizationMembership]):
197
209
  event: Literal["organization_membership.created"]
198
210
 
@@ -272,6 +284,9 @@ Event = Annotated[
272
284
  OrganizationCreatedEvent,
273
285
  OrganizationDeletedEvent,
274
286
  OrganizationUpdatedEvent,
287
+ OrganizationDomainCreatedEvent,
288
+ OrganizationDomainDeletedEvent,
289
+ OrganizationDomainUpdatedEvent,
275
290
  OrganizationDomainVerificationFailedEvent,
276
291
  OrganizationDomainVerifiedEvent,
277
292
  OrganizationMembershipCreatedEvent,
@@ -36,6 +36,9 @@ EventType = Literal[
36
36
  "organization.updated",
37
37
  "organization_domain.verification_failed",
38
38
  "organization_domain.verified",
39
+ "organization_domain.created",
40
+ "organization_domain.deleted",
41
+ "organization_domain.updated",
39
42
  "organization_membership.created",
40
43
  "organization_membership.deleted",
41
44
  "organization_membership.updated",
@@ -33,6 +33,7 @@ from workos.types.mfa import AuthenticationFactor
33
33
  from workos.types.organizations import Organization
34
34
  from workos.types.sso import ConnectionWithDomains
35
35
  from workos.types.user_management import Invitation, OrganizationMembership, User
36
+ from workos.types.vault import ObjectDigest
36
37
  from workos.types.workos_model import WorkOSModel
37
38
  from workos.utils.request_helper import DEFAULT_LIST_RESPONSE_LIMIT
38
39
 
@@ -51,6 +52,7 @@ ListableResource = TypeVar(
51
52
  AuthorizationResource,
52
53
  AuthorizationResourceType,
53
54
  User,
55
+ ObjectDigest,
54
56
  Warrant,
55
57
  WarrantQueryResult,
56
58
  )
@@ -13,3 +13,6 @@ class OrganizationDomain(WorkOSModel):
13
13
  ] = None
14
14
  verification_strategy: Optional[LiteralOrUntyped[Literal["manual", "dns"]]] = None
15
15
  verification_token: Optional[str] = None
16
+ verification_prefix: Optional[str] = None
17
+ created_at: str
18
+ updated_at: str
@@ -0,0 +1,2 @@
1
+ from .key import *
2
+ from .object import *
@@ -0,0 +1,25 @@
1
+ from typing import Dict
2
+ from pydantic import BaseModel, RootModel
3
+ from workos.types.workos_model import WorkOSModel
4
+
5
+
6
+ class KeyContext(RootModel[Dict[str, str]]):
7
+ pass
8
+
9
+
10
+ class DataKey(WorkOSModel):
11
+ id: str
12
+ key: str
13
+
14
+
15
+ class DataKeyPair(WorkOSModel):
16
+ context: KeyContext
17
+ data_key: DataKey
18
+ encrypted_keys: str
19
+
20
+
21
+ class DecodedKeys(BaseModel):
22
+ iv: bytes
23
+ tag: bytes
24
+ keys: str # Base64-encoded string
25
+ ciphertext: bytes
@@ -0,0 +1,38 @@
1
+ from typing import Optional
2
+
3
+ from workos.types.workos_model import WorkOSModel
4
+ from workos.types.vault import KeyContext
5
+
6
+
7
+ class ObjectDigest(WorkOSModel):
8
+ id: str
9
+ name: str
10
+ updated_at: str
11
+
12
+
13
+ class ObjectUpdateBy(WorkOSModel):
14
+ id: str
15
+ name: str
16
+
17
+
18
+ class ObjectMetadata(WorkOSModel):
19
+ context: KeyContext
20
+ environment_id: str
21
+ id: str
22
+ key_id: str
23
+ updated_at: str
24
+ updated_by: ObjectUpdateBy
25
+ version_id: str
26
+
27
+
28
+ class VaultObject(WorkOSModel):
29
+ id: str
30
+ metadata: ObjectMetadata
31
+ name: str
32
+ value: Optional[str] = None
33
+
34
+
35
+ class ObjectVersion(WorkOSModel):
36
+ created_at: str
37
+ current_version: bool
38
+ id: str
@@ -0,0 +1,39 @@
1
+ import os
2
+ from typing import Optional, Dict
3
+ from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
4
+ from cryptography.hazmat.backends import default_backend
5
+
6
+
7
+ class CryptoProvider:
8
+ def encrypt(
9
+ self, plaintext: bytes, key: bytes, iv: bytes, aad: Optional[bytes]
10
+ ) -> Dict[str, bytes]:
11
+ encryptor = Cipher(
12
+ algorithms.AES(key), modes.GCM(iv), backend=default_backend()
13
+ ).encryptor()
14
+
15
+ if aad:
16
+ encryptor.authenticate_additional_data(aad)
17
+
18
+ ciphertext = encryptor.update(plaintext) + encryptor.finalize()
19
+ return {"ciphertext": ciphertext, "iv": iv, "tag": encryptor.tag}
20
+
21
+ def decrypt(
22
+ self,
23
+ ciphertext: bytes,
24
+ key: bytes,
25
+ iv: bytes,
26
+ tag: bytes,
27
+ aad: Optional[bytes] = None,
28
+ ) -> bytes:
29
+ decryptor = Cipher(
30
+ algorithms.AES(key), modes.GCM(iv, tag), backend=default_backend()
31
+ ).decryptor()
32
+
33
+ if aad:
34
+ decryptor.authenticate_additional_data(aad)
35
+
36
+ return decryptor.update(ciphertext) + decryptor.finalize()
37
+
38
+ def random_bytes(self, n: int) -> bytes:
39
+ return os.urandom(n)
workos/vault.py ADDED
@@ -0,0 +1,515 @@
1
+ import base64
2
+ from typing import Optional, Protocol, Sequence, Tuple
3
+ from workos.types.vault import VaultObject, ObjectVersion, ObjectDigest, ObjectMetadata
4
+ from workos.types.vault.key import DataKey, DataKeyPair, KeyContext, DecodedKeys
5
+ from workos.types.list_resource import (
6
+ ListArgs,
7
+ ListMetadata,
8
+ ListPage,
9
+ WorkOSListResource,
10
+ )
11
+ from workos.utils.http_client import SyncHTTPClient
12
+ from workos.utils.pagination_order import PaginationOrder
13
+ from workos.utils.request_helper import (
14
+ DEFAULT_LIST_RESPONSE_LIMIT,
15
+ REQUEST_METHOD_DELETE,
16
+ REQUEST_METHOD_GET,
17
+ REQUEST_METHOD_POST,
18
+ REQUEST_METHOD_PUT,
19
+ RequestHelper,
20
+ )
21
+ from workos.utils.crypto_provider import CryptoProvider
22
+
23
+ DEFAULT_RESPONSE_LIMIT = DEFAULT_LIST_RESPONSE_LIMIT
24
+
25
+ VaultObjectList = WorkOSListResource[ObjectDigest, ListArgs, ListMetadata]
26
+
27
+
28
+ class VaultModule(Protocol):
29
+ def read_object(self, *, object_id: str) -> VaultObject:
30
+ """
31
+ Get a Vault object with the value decrypted.
32
+
33
+ Kwargs:
34
+ object_id (str): The unique identifier for the object.
35
+ Returns:
36
+ VaultObject: A vault object with metadata, name and decrypted value.
37
+ """
38
+ ...
39
+
40
+ def list_objects(
41
+ self,
42
+ *,
43
+ limit: int = DEFAULT_RESPONSE_LIMIT,
44
+ before: Optional[str] = None,
45
+ after: Optional[str] = None,
46
+ ) -> VaultObjectList:
47
+ """
48
+ Gets a list of encrypted Vault objects.
49
+
50
+ Kwargs:
51
+ limit (int): The maximum number of objects to return. (Optional)
52
+ before (str): A cursor to return resources before. (Optional)
53
+ after (str): A cursor to return resources after. (Optional)
54
+
55
+ Returns:
56
+ VaultObjectList: A list of vault objects with built-in pagination iterator.
57
+ """
58
+ ...
59
+
60
+ def list_object_versions(
61
+ self,
62
+ *,
63
+ object_id: str,
64
+ ) -> Sequence[ObjectVersion]:
65
+ """
66
+ Gets a list of versions for a specific Vault object.
67
+
68
+ Kwargs:
69
+ object_id (str): The unique identifier for the object.
70
+
71
+ Returns:
72
+ Sequence[ObjectVersion]: A list of object versions.
73
+ """
74
+ ...
75
+
76
+ def create_object(
77
+ self,
78
+ *,
79
+ name: str,
80
+ value: str,
81
+ key_context: KeyContext,
82
+ ) -> ObjectMetadata:
83
+ """
84
+ Create a new Vault encrypted object.
85
+
86
+ Kwargs:
87
+ name (str): The name of the object.
88
+ value (str): The value to encrypt and store.
89
+ key_context (KeyContext): A set of key-value dictionary pairs that determines which root keys to use when encrypting data.
90
+
91
+ Returns:
92
+ VaultObject: The created vault object.
93
+ """
94
+ ...
95
+
96
+ def update_object(
97
+ self,
98
+ *,
99
+ object_id: str,
100
+ value: str,
101
+ version_check: Optional[str] = None,
102
+ ) -> VaultObject:
103
+ """
104
+ Update an existing Vault object.
105
+
106
+ Kwargs:
107
+ object_id (str): The unique identifier for the object.
108
+ value (str): The new value to encrypt and store.
109
+ version_check (str): A version of the object to prevent clobbering of data during concurrent updates. (Optional)
110
+
111
+ Returns:
112
+ VaultObject: The updated vault object.
113
+ """
114
+ ...
115
+
116
+ def delete_object(
117
+ self,
118
+ *,
119
+ object_id: str,
120
+ ) -> None:
121
+ """
122
+ Permanently delete a Vault encrypted object. Warning: this cannont be undone.
123
+
124
+ Kwargs:
125
+ object_id (str): The unique identifier for the object.
126
+ """
127
+ ...
128
+
129
+ def create_data_key(self, *, key_context: KeyContext) -> DataKeyPair:
130
+ """
131
+ Generate a data key for local encryption based on the provided key context.
132
+ The encrypted data key MUST be stored by the application, as it cannot be retrieved after generation.
133
+
134
+ Kwargs:
135
+ key_context (KeyContext): A set of key-value dictionary pairs that determines which root keys to use when encrypting data.
136
+ """
137
+ ...
138
+
139
+ def decrypt_data_key(
140
+ self,
141
+ *,
142
+ keys: str,
143
+ ) -> DataKey:
144
+ """
145
+ Decrypt encrypted data keys that were previously generated by create_data_key.
146
+
147
+ This method takes the encrypted data key blob and uses the WorkOS Vault service
148
+ to decrypt it, returning the plaintext data key that can be used for local
149
+ encryption/decryption operations.
150
+
151
+ Kwargs:
152
+ keys (str): The base64-encoded encrypted data key blob returned by create_data_key.
153
+
154
+ Returns:
155
+ DataKey: The decrypted data key containing the key ID and the plaintext key material.
156
+ """
157
+ ...
158
+
159
+ def encrypt(
160
+ self,
161
+ *,
162
+ data: str,
163
+ key_context: KeyContext,
164
+ associated_data: Optional[str] = None,
165
+ ) -> str:
166
+ """
167
+ Encrypt data locally using AES-GCM with a data key derived from the provided context.
168
+
169
+ This method generates a new data key for each encryption operation, ensuring that
170
+ the same plaintext will produce different ciphertext each time it's encrypted.
171
+ The encrypted data key is embedded in the result so it can be decrypted later.
172
+
173
+ Kwargs:
174
+ data (str): The plaintext data to encrypt.
175
+ key_context (KeyContext): A set of key-value dictionary pairs that determines which root keys to use when encrypting data.
176
+ associated_data (str): Additional authenticated data (AAD) that will be authenticated but not encrypted. (Optional)
177
+
178
+ Returns:
179
+ str: Base64-encoded encrypted data containing the IV, authentication tag, encrypted data key, and ciphertext.
180
+ """
181
+ ...
182
+
183
+ def decrypt(
184
+ self, *, encrypted_data: str, associated_data: Optional[str] = None
185
+ ) -> str:
186
+ """
187
+ Decrypt data that was previously encrypted using the encrypt method.
188
+
189
+ This method extracts the encrypted data key from the encrypted payload,
190
+ decrypts it using the WorkOS Vault service, and then uses the resulting
191
+ data key to decrypt the actual data using AES-GCM.
192
+
193
+ Kwargs:
194
+ encrypted_data (str): The base64-encoded encrypted data returned by the encrypt method.
195
+ associated_data (str): The same additional authenticated data (AAD) that was used during encryption, if any. (Optional)
196
+
197
+ Returns:
198
+ str: The original plaintext data.
199
+
200
+ Raises:
201
+ ValueError: If the encrypted_data format is invalid or if associated_data doesn't match what was used during encryption.
202
+ cryptography.exceptions.InvalidTag: If the authentication tag verification fails (data has been tampered with).
203
+ """
204
+ ...
205
+
206
+
207
+ class Vault(VaultModule):
208
+ _http_client: SyncHTTPClient
209
+ _crypto_provider: CryptoProvider
210
+
211
+ def __init__(self, http_client: SyncHTTPClient):
212
+ self._http_client = http_client
213
+ self._crypto_provider = CryptoProvider()
214
+
215
+ def read_object(
216
+ self,
217
+ *,
218
+ object_id: str,
219
+ ) -> VaultObject:
220
+ if not object_id:
221
+ raise ValueError("Incomplete arguments: 'object_id' is a required argument")
222
+
223
+ response = self._http_client.request(
224
+ RequestHelper.build_parameterized_url(
225
+ "vault/v1/kv/{object_id}",
226
+ object_id=object_id,
227
+ ),
228
+ method=REQUEST_METHOD_GET,
229
+ )
230
+
231
+ return VaultObject.model_validate(response)
232
+
233
+ def list_objects(
234
+ self,
235
+ *,
236
+ limit: int = DEFAULT_RESPONSE_LIMIT,
237
+ before: Optional[str] = None,
238
+ after: Optional[str] = None,
239
+ ) -> VaultObjectList:
240
+ list_params: ListArgs = {
241
+ "limit": limit,
242
+ "before": before,
243
+ "after": after,
244
+ }
245
+
246
+ response = self._http_client.request(
247
+ "vault/v1/kv",
248
+ method=REQUEST_METHOD_GET,
249
+ params=list_params,
250
+ )
251
+
252
+ # Ensure object field is present
253
+ response_dict = dict(response)
254
+ if "object" not in response_dict:
255
+ response_dict["object"] = "list"
256
+
257
+ return VaultObjectList(
258
+ list_method=self.list_objects,
259
+ list_args=list_params,
260
+ **ListPage[ObjectDigest](**response_dict).model_dump(),
261
+ )
262
+
263
+ def list_object_versions(
264
+ self,
265
+ *,
266
+ object_id: str,
267
+ ) -> Sequence[ObjectVersion]:
268
+ response = self._http_client.request(
269
+ RequestHelper.build_parameterized_url(
270
+ "vault/v1/kv/{object_id}/versions",
271
+ object_id=object_id,
272
+ ),
273
+ method=REQUEST_METHOD_GET,
274
+ )
275
+
276
+ return [
277
+ ObjectVersion.model_validate(version)
278
+ for version in response.get("data", [])
279
+ ]
280
+
281
+ def create_object(
282
+ self,
283
+ *,
284
+ name: str,
285
+ value: str,
286
+ key_context: KeyContext,
287
+ ) -> ObjectMetadata:
288
+ if not name or not value:
289
+ raise ValueError(
290
+ "Incomplete arguments: 'name' and 'value' are required arguments"
291
+ )
292
+
293
+ request_data = {
294
+ "name": name,
295
+ "value": value,
296
+ "key_context": key_context,
297
+ }
298
+
299
+ response = self._http_client.request(
300
+ "vault/v1/kv",
301
+ method=REQUEST_METHOD_POST,
302
+ json=request_data,
303
+ )
304
+
305
+ return ObjectMetadata.model_validate(response)
306
+
307
+ def update_object(
308
+ self,
309
+ *,
310
+ object_id: str,
311
+ value: str,
312
+ version_check: Optional[str] = None,
313
+ ) -> VaultObject:
314
+ if not object_id:
315
+ raise ValueError("Incomplete arguments: 'object_id' is a required argument")
316
+
317
+ request_data = {
318
+ "value": value,
319
+ }
320
+ if version_check is not None:
321
+ request_data["version_check"] = version_check
322
+
323
+ response = self._http_client.request(
324
+ RequestHelper.build_parameterized_url(
325
+ "vault/v1/kv/{object_id}",
326
+ object_id=object_id,
327
+ ),
328
+ method=REQUEST_METHOD_PUT,
329
+ json=request_data,
330
+ )
331
+
332
+ return VaultObject.model_validate(response)
333
+
334
+ def delete_object(
335
+ self,
336
+ *,
337
+ object_id: str,
338
+ ) -> None:
339
+ if not object_id:
340
+ raise ValueError("Incomplete arguments: 'object_id' is a required argument")
341
+
342
+ self._http_client.request(
343
+ RequestHelper.build_parameterized_url(
344
+ "vault/v1/kv/{object_id}",
345
+ object_id=object_id,
346
+ ),
347
+ method=REQUEST_METHOD_DELETE,
348
+ )
349
+
350
+ def create_data_key(self, *, key_context: KeyContext) -> DataKeyPair:
351
+ request_data = {
352
+ "context": key_context,
353
+ }
354
+
355
+ response = self._http_client.request(
356
+ "vault/v1/keys/data-key",
357
+ method=REQUEST_METHOD_POST,
358
+ json=request_data,
359
+ )
360
+
361
+ return DataKeyPair.model_validate(
362
+ {
363
+ "context": response["context"],
364
+ "data_key": {"id": response["id"], "key": response["data_key"]},
365
+ "encrypted_keys": response["encrypted_keys"],
366
+ }
367
+ )
368
+
369
+ def decrypt_data_key(
370
+ self,
371
+ *,
372
+ keys: str,
373
+ ) -> DataKey:
374
+ request_data = {
375
+ "keys": keys,
376
+ }
377
+
378
+ response = self._http_client.request(
379
+ "vault/v1/keys/decrypt",
380
+ method=REQUEST_METHOD_POST,
381
+ json=request_data,
382
+ )
383
+
384
+ return DataKey.model_validate(
385
+ {"id": response["id"], "key": response["data_key"]}
386
+ )
387
+
388
+ def encrypt(
389
+ self,
390
+ *,
391
+ data: str,
392
+ key_context: KeyContext,
393
+ associated_data: Optional[str] = None,
394
+ ) -> str:
395
+ key_pair = self.create_data_key(key_context=key_context)
396
+
397
+ key = self._base64_to_bytes(key_pair.data_key.key)
398
+ key_blob = self._base64_to_bytes(key_pair.encrypted_keys)
399
+ prefix_len_buffer = self._encode_u32(len(key_blob))
400
+ aad_buffer = associated_data.encode("utf-8") if associated_data else None
401
+ iv = self._crypto_provider.random_bytes(12)
402
+
403
+ result = self._crypto_provider.encrypt(
404
+ data.encode("utf-8"), key, iv, aad_buffer
405
+ )
406
+
407
+ combined = (
408
+ result["iv"]
409
+ + result["tag"]
410
+ + prefix_len_buffer
411
+ + key_blob
412
+ + result["ciphertext"]
413
+ )
414
+
415
+ return self._bytes_to_base64(combined)
416
+
417
+ def decrypt(
418
+ self, *, encrypted_data: str, associated_data: Optional[str] = None
419
+ ) -> str:
420
+ decoded = self._decode(encrypted_data)
421
+ data_key = self.decrypt_data_key(keys=decoded.keys)
422
+
423
+ key = self._base64_to_bytes(data_key.key)
424
+ aad_buffer = associated_data.encode("utf-8") if associated_data else None
425
+
426
+ decrypted_bytes = self._crypto_provider.decrypt(
427
+ ciphertext=decoded.ciphertext,
428
+ key=key,
429
+ iv=decoded.iv,
430
+ tag=decoded.tag,
431
+ aad=aad_buffer,
432
+ )
433
+
434
+ return decrypted_bytes.decode("utf-8")
435
+
436
+ def _base64_to_bytes(self, data: str) -> bytes:
437
+ return base64.b64decode(data)
438
+
439
+ def _bytes_to_base64(self, data: bytes) -> str:
440
+ return base64.b64encode(data).decode("utf-8")
441
+
442
+ def _encode_u32(self, value: int) -> bytes:
443
+ """
444
+ Encode a 32-bit unsigned integer as LEB128.
445
+
446
+ Returns:
447
+ bytes: LEB128-encoded representation of the input value.
448
+ """
449
+ if value < 0 or value > 0xFFFFFFFF:
450
+ raise ValueError("Value must be a 32-bit unsigned integer")
451
+
452
+ encoded = bytearray()
453
+ while True:
454
+ byte = value & 0x7F
455
+ value >>= 7
456
+ if value != 0:
457
+ byte |= 0x80 # Set continuation bit
458
+ encoded.append(byte)
459
+ if value == 0:
460
+ break
461
+
462
+ return bytes(encoded)
463
+
464
+ def _decode(self, encrypted_data_b64: str) -> DecodedKeys:
465
+ """
466
+ This function extracts IV, tag, keyBlobLength, keyBlob, and ciphertext
467
+ from a base64-encoded payload.
468
+ Encoding format: [IV][TAG][4B Length][keyBlob][ciphertext]
469
+ """
470
+ try:
471
+ payload = base64.b64decode(encrypted_data_b64)
472
+ except Exception as e:
473
+ raise ValueError("Base64 decoding failed") from e
474
+
475
+ iv = payload[0:12]
476
+ tag = payload[12:28]
477
+
478
+ try:
479
+ key_len, leb_len = self._decode_u32(payload[28:])
480
+ except Exception as e:
481
+ raise ValueError("Failed to decode key length") from e
482
+
483
+ keys_index = 28 + leb_len
484
+ keys_end = keys_index + key_len
485
+ keys_slice = payload[keys_index:keys_end]
486
+ keys = base64.b64encode(keys_slice).decode("utf-8")
487
+ ciphertext = payload[keys_end:]
488
+
489
+ return DecodedKeys(iv=iv, tag=tag, keys=keys, ciphertext=ciphertext)
490
+
491
+ def _decode_u32(self, buf: bytes) -> Tuple[int, int]:
492
+ """
493
+ Decode an unsigned LEB128-encoded 32-bit integer from bytes.
494
+
495
+ Returns:
496
+ (value, length_consumed)
497
+
498
+ Raises:
499
+ ValueError if decoding fails or overflows.
500
+ """
501
+ res = 0
502
+ bit = 0
503
+
504
+ for i, b in enumerate(buf):
505
+ if i > 4:
506
+ raise ValueError("LEB128 integer overflow (was more than 4 bytes)")
507
+
508
+ res |= (b & 0x7F) << (7 * bit)
509
+
510
+ if (b & 0x80) == 0:
511
+ return res, i + 1
512
+
513
+ bit += 1
514
+
515
+ raise ValueError("LEB128 integer not found")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: workos
3
- Version: 5.23.0
3
+ Version: 5.24.0
4
4
  Summary: WorkOS Python Client
5
5
  Home-page: https://github.com/workos-inc/workos-python
6
6
  Author: WorkOS
@@ -1,10 +1,10 @@
1
- workos/__about__.py,sha256=gPnfGwbokmJccKOueu0QsNoiFGUYhHwOVX1_mLa4xzw,406
1
+ workos/__about__.py,sha256=1NsUDPAjsrwknBlghnN-xITmyO39Ieog8l72kRbopYw,406
2
2
  workos/__init__.py,sha256=hOdbO_MJCvpLx8EbRjQg-fvFAB-glJmrmxUZK8kWG0k,167
3
3
  workos/_base_client.py,sha256=t69Nb3zxo3wygI3JtbPdZMGvIuRPsZx_xZANC5K8dn8,3429
4
4
  workos/_client_configuration.py,sha256=g3eXhtrEMN6CW0hZ5uHb2PmLurXjyBkWZeQYMPeJD6s,222
5
- workos/async_client.py,sha256=ezl6pO2I2eGZnq0jrqD7-C7JKfvBqrsqq4T0cbYndPE,3756
5
+ workos/async_client.py,sha256=JTZwKTN7YqPEScXPh-RmBHCs_glPo2LLfMHXhyBJuak,3957
6
6
  workos/audit_logs.py,sha256=bYoAoNO4FRSaT34UxiVkgTXCVH8givcS2YGhH_9O3NA,3983
7
- workos/client.py,sha256=ESweUKW2ju5dPGFCTUMxjVYgh2txoZ3ZVbxy81i0JcI,3747
7
+ workos/client.py,sha256=jvqccyHJWf302ugopj9mt-IidkWBt_r8jihP0IZ4RUI,3959
8
8
  workos/directory_sync.py,sha256=6Z1gHz1LWNy56EtkXwNm6jhRRcvsJ7ASeDLy_Q1oKM0,14601
9
9
  workos/events.py,sha256=b4JIzMbd5LlVtpOMKVojC70RCHAgmLN3nJ62_2U0GwI,3892
10
10
  workos/exceptions.py,sha256=eoy-T4We98HKZn0UZu33fPzhm4DwafzwLeg3juhC6FE,1732
@@ -17,10 +17,11 @@ workos/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  workos/session.py,sha256=CVada-nKRFv9m2-mcghR5VBOguGU76iDCDgQlksOOrQ,11912
18
18
  workos/sso.py,sha256=ZBC3y-IRmxG0jPd0BOj7s7XQkXJoTLUg1fx-h3Gfy4g,13541
19
19
  workos/user_management.py,sha256=qy21HxYVO40xo7TvCGVxvGWdYIFHZTVnUJTpCQIN2ko,77113
20
+ workos/vault.py,sha256=SJXr3nJ03qJFuf30FjevMD6LLlDNX3MGaKlYGgICRRE,15657
20
21
  workos/webhooks.py,sha256=CuwBxh6va9VZFVSXOknveGt6CCGDF3em07a-J12DbXI,4790
21
22
  workos/widgets.py,sha256=bfbR0hQOHZabbgGL2ekD5sY1sjiUoWBTdrBd_a6WmBc,1721
22
23
  workos/types/__init__.py,sha256=aYScTXq5jOyp0AYvdWffaj5-zdDuNtCCJtbzt5GM19k,267
23
- workos/types/list_resource.py,sha256=MLfmtevGVpwb38EurJiD5NO-H5mADEp4DitZMiacSO0,6508
24
+ workos/types/list_resource.py,sha256=6N9OoaFsWPCXEX9plVONODxed-Yx6RaX1ga1b15ENIA,6570
24
25
  workos/types/metadata.py,sha256=uUqDkGJGyFY3H4JZObSiCfn4jKBue5CBhOqv79TI1n0,52
25
26
  workos/types/workos_model.py,sha256=bV_p3baadcUJOU_7f6ysZ6KXhpt3E_93spuZnfJs9vc,735
26
27
  workos/types/audit_logs/__init__.py,sha256=daPn8wAVEnlM1fCpOsy3dVZV_0YEp8bA1T_nhk5-pU8,211
@@ -45,9 +46,9 @@ workos/types/events/directory_group_with_previous_attributes.py,sha256=13VLNhdJZ
45
46
  workos/types/events/directory_payload.py,sha256=tRo3f9g8VoYertSUPAR25iGDyGLr2Dtb2mTkl73PAeA,503
46
47
  workos/types/events/directory_payload_with_legacy_fields.py,sha256=jk9nLmRqgllVkBG4EU3uTgcDOhCNptHgCh93U7aBAYE,1005
47
48
  workos/types/events/directory_user_with_previous_attributes.py,sha256=PhnO3WakBxAvnlOGf0UB0bvoppUYlwLyU-g9X_pPdko,244
48
- workos/types/events/event.py,sha256=OZfsPNDD46-6wWcnAE2HkT5Lt23vGj3o8wz7XfQE2vY,9344
49
+ workos/types/events/event.py,sha256=PDUTGaYlxwMkVKRhj82XMVxfrYzpWVlkQRCRNq-mxlM,9830
49
50
  workos/types/events/event_model.py,sha256=r5B_lZ7QXgoI7SGyQF7xNaEEE-ATMRet83pMYYJANuo,3735
50
- workos/types/events/event_type.py,sha256=jzZ5rlYXKmrHzbnymeMiIqmVF7i1Yvp76zqkCYl6Puo,1585
51
+ workos/types/events/event_type.py,sha256=NIVHMahETiKeFJfZGi-ptHQH7czmRY4tChnuMU0OxWw,1690
51
52
  workos/types/events/list_filters.py,sha256=P04zmRynx9VPqNX_MBXA-3KA6flPZJogtIUqTI7w9Eg,305
52
53
  workos/types/events/organization_domain_verification_failed_payload.py,sha256=26reKTFxdriOo6fF6MVkYx0s867E-bproKTbwLZcUpE,483
53
54
  workos/types/events/previous_attributes.py,sha256=DxolwLwzcnG8r_W6rh5BT29iDfSVsIELvRYJ0NCrNn0,72
@@ -70,7 +71,7 @@ workos/types/organizations/domain_data_input.py,sha256=BW3iYswF-b2SXip7jwPkmlZhg
70
71
  workos/types/organizations/list_filters.py,sha256=u-TsEEMVI8IvPvxn_9--k6iYDs4T64RHTY_HY0Fvwlw,179
71
72
  workos/types/organizations/organization.py,sha256=GNs7Mf4-B4NpKSsE4uD9106kG6e6yz2EImdgSw9X310,533
72
73
  workos/types/organizations/organization_common.py,sha256=HFrXwia3xV6KkAAfW6zyMcjxXrznv82hFajHVHZdhpM,350
73
- workos/types/organizations/organization_domain.py,sha256=gFumod8dBtTLxmAlD83UuF_96B8lSjwsgwr_OOpvxOY,528
74
+ workos/types/organizations/organization_domain.py,sha256=PkmdVVQi6h94xHWLJt0SFGgiGEVoyxwiPD-WwQ1naWs,614
74
75
  workos/types/passwordless/__init__.py,sha256=ZP_XIcGUKXsATb--bfesnsFFbbvg3WYzgqRC_qvW0rw,77
75
76
  workos/types/passwordless/passwordless_session.py,sha256=izmTI5F7qvBdoVodaXP7fnYo_XodG-ygyYTPrCEObTM,293
76
77
  workos/types/passwordless/passwordless_session_type.py,sha256=ltZAV8KFiYDVcxpVt5Hcdc089tB5VETYaa9X6E7Mvoo,75
@@ -101,6 +102,9 @@ workos/types/user_management/screen_hint.py,sha256=DnPgvjRK-20i82v3YPzggna1rc6yO
101
102
  workos/types/user_management/session.py,sha256=pyINOo_a53rxtZ-gGYOZziNHoZzc7s56evKgVAPIgMo,1390
102
103
  workos/types/user_management/user.py,sha256=aXRHsLXnQbXWBPRTdAP9Ym_-D9hjmrp_E4PTPi1gF1s,603
103
104
  workos/types/user_management/user_management_provider_type.py,sha256=UEjtcs9oeDvL9248bFy8nRfzutA6aBfhVMuMByG0qsM,145
105
+ workos/types/vault/__init__.py,sha256=krBuIl8luysrtDf9-b8KTkXOHDOaSsOR-Aao6Wlil0Q,41
106
+ workos/types/vault/key.py,sha256=x30XBplSj9AviDDAB8MdpcULbZvvo2sUzi8RCmZQKxU,453
107
+ workos/types/vault/object.py,sha256=-rk4KovS3eT8T8L3JltYUS0cd2Rg1JKcAX9SOaZO3D8,664
104
108
  workos/types/webhooks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
105
109
  workos/types/webhooks/webhook.py,sha256=IIDhlGTwiNm3xEncSk-OYm0EZsxwXmxDT5_jKx_Bt60,9523
106
110
  workos/types/webhooks/webhook_model.py,sha256=v7Hgtzt0nW_5RaYoB_QGVfElhdjySuG3F1BFjoid36w,404
@@ -115,11 +119,12 @@ workos/typing/untyped_literal.py,sha256=wf48_6kZJ-AN3-V2gLC_y5k2tnUvgGnhn89HsfOK
115
119
  workos/typing/webhooks.py,sha256=8GhUnrlGrgQbknh32tVtHxeR8FsXsJesW94CtZiB-_4,534
116
120
  workos/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
117
121
  workos/utils/_base_http_client.py,sha256=KqRHUaDJUfXGxhu6UHLfZVkIBikcvrUZYhm9GBSByB4,7410
122
+ workos/utils/crypto_provider.py,sha256=QeQSR4t9xLlb90kEfl8onVUsf1yCkYq0EjFTxK0mUlk,1182
118
123
  workos/utils/http_client.py,sha256=TM5yMFFExmAE8D2Z43-5O301tRbnylLG0aXO0isGorE,6197
119
124
  workos/utils/pagination_order.py,sha256=_-et1DDJLG0czarTU7op4W6RA0V1f85GNsUgtyRU55Q,70
120
125
  workos/utils/request_helper.py,sha256=NaO16qPPbSNnCeE0fiNKYb8gM-dK_okYVJbLGrEGXz8,793
121
- workos-5.23.0.dist-info/LICENSE,sha256=mU--WL1JzelH2tXpKVoOlpud4cpqKSRTtdArCvYZmb4,1063
122
- workos-5.23.0.dist-info/METADATA,sha256=6axcTXs8vYKZ4CLs32aIC1znvQQGb0If40EnWk30_fk,4187
123
- workos-5.23.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
124
- workos-5.23.0.dist-info/top_level.txt,sha256=ZFskIfue1Tw-JwjyIXRvdsAl9i0DX9VbqmgICXV84Sk,7
125
- workos-5.23.0.dist-info/RECORD,,
126
+ workos-5.24.0.dist-info/LICENSE,sha256=mU--WL1JzelH2tXpKVoOlpud4cpqKSRTtdArCvYZmb4,1063
127
+ workos-5.24.0.dist-info/METADATA,sha256=7uWspjP8xJKGOnVXxi5BPXCpCwQAGy1pUQlrWMGVMPg,4187
128
+ workos-5.24.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
129
+ workos-5.24.0.dist-info/top_level.txt,sha256=ZFskIfue1Tw-JwjyIXRvdsAl9i0DX9VbqmgICXV84Sk,7
130
+ workos-5.24.0.dist-info/RECORD,,