python-vaultwarden2 0.1.0__tar.gz → 0.1.1__tar.gz
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.
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/PKG-INFO +2 -1
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/pyproject.toml +3 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_async/admin.py +12 -10
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_async/base.py +62 -6
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_async/client.py +11 -2
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_async/organizations.py +102 -45
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_async/vault.py +53 -30
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_core.py +15 -6
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_json.py +6 -2
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_merge.py +6 -1
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_sync/admin.py +12 -10
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_sync/base.py +62 -6
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_sync/client.py +11 -2
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_sync/organizations.py +98 -45
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_sync/vault.py +55 -30
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/crypto.py +11 -3
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/dump.py +25 -5
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/models.py +4 -3
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/search.py +45 -7
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/totp.py +10 -3
- python_vaultwarden2-0.1.1/tests/test_hardening.py +406 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_integration_org2.py +24 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/.gitignore +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/LICENSE +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/README.md +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/__init__.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_async/__init__.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_async/account.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_async/auth.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_encode.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_offload.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_sync/__init__.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_sync/account.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/_sync/auth.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/errors.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/export.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/src/vaultwarden2/py.typed +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/conftest.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_client.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_concurrency.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_core.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_crypto.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_doc_examples.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_dump.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_encode.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_export.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_integration.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_integration_account.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_integration_admin.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_integration_org.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_integration_qol.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_integration_write.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_merge.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_search.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_security.py +0 -0
- {python_vaultwarden2-0.1.0 → python_vaultwarden2-0.1.1}/tests/test_totp.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: python-vaultwarden2
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Python client library for Vaultwarden
|
|
5
5
|
Project-URL: Homepage, https://github.com/sim0nx/python-vaultwarden2
|
|
6
6
|
Project-URL: Documentation, https://python-vaultwarden2.readthedocs.io/en/latest/
|
|
@@ -26,6 +26,7 @@ Requires-Python: <3.16,>=3.11
|
|
|
26
26
|
Requires-Dist: anyio>=4.16
|
|
27
27
|
Requires-Dist: cryptography>=50
|
|
28
28
|
Requires-Dist: httpx2>=2.16
|
|
29
|
+
Requires-Dist: regex>=2024.11.6
|
|
29
30
|
Provides-Extra: psl
|
|
30
31
|
Requires-Dist: publicsuffixlist>=1.0; extra == 'psl'
|
|
31
32
|
Provides-Extra: zstd
|
|
@@ -28,6 +28,8 @@ dependencies = [
|
|
|
28
28
|
"httpx2>=2.16",
|
|
29
29
|
"anyio>=4.16",
|
|
30
30
|
"cryptography>=50",
|
|
31
|
+
# Regular-expression URI match rules from vault data run with a timeout (the stdlib re module has none).
|
|
32
|
+
"regex>=2024.11.6",
|
|
31
33
|
]
|
|
32
34
|
dynamic = ["version"]
|
|
33
35
|
|
|
@@ -54,6 +56,7 @@ docs = [
|
|
|
54
56
|
]
|
|
55
57
|
dev = [
|
|
56
58
|
"mypy>=2.4",
|
|
59
|
+
"types-regex>=2024.11.6",
|
|
57
60
|
"ruff>=0.17",
|
|
58
61
|
"prek>=0.5.12",
|
|
59
62
|
"unasyncd>=0.10",
|
|
@@ -17,7 +17,7 @@ from vaultwarden2._json import JsonObject
|
|
|
17
17
|
from vaultwarden2.errors import AuthenticationError, UnsafeWriteError, VaultwardenError
|
|
18
18
|
from vaultwarden2.models import AdminMembership, AdminOrganization, AdminUser, MemberStatus, OrganizationUserType
|
|
19
19
|
|
|
20
|
-
from .base import DEFAULT_TIMEOUT, _body, _warn_if_plaintext
|
|
20
|
+
from .base import DEFAULT_TIMEOUT, _body, _check_path, _seg, _warn_if_plaintext
|
|
21
21
|
|
|
22
22
|
if TYPE_CHECKING:
|
|
23
23
|
from collections.abc import Mapping
|
|
@@ -221,9 +221,11 @@ class AsyncVaultwardenAdmin:
|
|
|
221
221
|
The decoded response.
|
|
222
222
|
|
|
223
223
|
Raises:
|
|
224
|
+
VaultwardenError: ``path`` contains a ``.`` or ``..`` segment; nothing was sent.
|
|
224
225
|
AuthenticationError: The session was rejected even after logging in again.
|
|
225
226
|
ApiError: Any other non-2xx answer.
|
|
226
227
|
"""
|
|
228
|
+
_check_path(path)
|
|
227
229
|
for attempt in range(2):
|
|
228
230
|
if not self._logged_in:
|
|
229
231
|
async with self._login_lock:
|
|
@@ -280,8 +282,8 @@ class AsyncVaultwardenAdmin:
|
|
|
280
282
|
if isinstance(user, AdminUser):
|
|
281
283
|
user = user.id
|
|
282
284
|
if '@' in user:
|
|
283
|
-
return parse_admin_user(await self._request('GET', f'/users/by-mail/{user}'))
|
|
284
|
-
return parse_admin_user(await self._request('GET', f'/users/{user}'))
|
|
285
|
+
return parse_admin_user(await self._request('GET', f'/users/by-mail/{_seg(user)}'))
|
|
286
|
+
return parse_admin_user(await self._request('GET', f'/users/{_seg(user)}'))
|
|
285
287
|
|
|
286
288
|
async def _user_id(self, user: AdminUserRef) -> str:
|
|
287
289
|
"""Turn a user reference into an id.
|
|
@@ -321,7 +323,7 @@ class AsyncVaultwardenAdmin:
|
|
|
321
323
|
Raises:
|
|
322
324
|
ApiError: No such user, or the user already finished the registration.
|
|
323
325
|
"""
|
|
324
|
-
await self._post(f'/users/{await self._user_id(user)}/invite/resend')
|
|
326
|
+
await self._post(f'/users/{_seg(await self._user_id(user))}/invite/resend')
|
|
325
327
|
|
|
326
328
|
async def disable_user(self, user: AdminUserRef) -> None:
|
|
327
329
|
"""Block a user from logging in. All data is kept; undo with ``enable_user``.
|
|
@@ -331,7 +333,7 @@ class AsyncVaultwardenAdmin:
|
|
|
331
333
|
Args:
|
|
332
334
|
user: The user, as [AdminUser][vaultwarden2.models.AdminUser], user id or email address.
|
|
333
335
|
"""
|
|
334
|
-
await self._post(f'/users/{await self._user_id(user)}/disable')
|
|
336
|
+
await self._post(f'/users/{_seg(await self._user_id(user))}/disable')
|
|
335
337
|
|
|
336
338
|
async def enable_user(self, user: AdminUserRef) -> None:
|
|
337
339
|
"""Allow a disabled user to log in again.
|
|
@@ -339,7 +341,7 @@ class AsyncVaultwardenAdmin:
|
|
|
339
341
|
Args:
|
|
340
342
|
user: The user, as [AdminUser][vaultwarden2.models.AdminUser], user id or email address.
|
|
341
343
|
"""
|
|
342
|
-
await self._post(f'/users/{await self._user_id(user)}/enable')
|
|
344
|
+
await self._post(f'/users/{_seg(await self._user_id(user))}/enable')
|
|
343
345
|
|
|
344
346
|
async def deauthorize_user(self, user: AdminUserRef) -> None:
|
|
345
347
|
"""Log a user out of every device and remove all their devices from the device list.
|
|
@@ -347,7 +349,7 @@ class AsyncVaultwardenAdmin:
|
|
|
347
349
|
Args:
|
|
348
350
|
user: The user, as [AdminUser][vaultwarden2.models.AdminUser], user id or email address.
|
|
349
351
|
"""
|
|
350
|
-
await self._post(f'/users/{await self._user_id(user)}/deauth')
|
|
352
|
+
await self._post(f'/users/{_seg(await self._user_id(user))}/deauth')
|
|
351
353
|
|
|
352
354
|
async def remove_two_factor(self, user: AdminUserRef) -> None:
|
|
353
355
|
"""Remove all two-step login methods of a user, for example after a lost authenticator.
|
|
@@ -357,7 +359,7 @@ class AsyncVaultwardenAdmin:
|
|
|
357
359
|
Args:
|
|
358
360
|
user: The user, as [AdminUser][vaultwarden2.models.AdminUser], user id or email address.
|
|
359
361
|
"""
|
|
360
|
-
await self._post(f'/users/{await self._user_id(user)}/remove-2fa')
|
|
362
|
+
await self._post(f'/users/{_seg(await self._user_id(user))}/remove-2fa')
|
|
361
363
|
|
|
362
364
|
async def delete_user(self, user: AdminUserRef) -> None:
|
|
363
365
|
"""Delete a user and all their personal data. This cannot be undone.
|
|
@@ -365,7 +367,7 @@ class AsyncVaultwardenAdmin:
|
|
|
365
367
|
Args:
|
|
366
368
|
user: The user, as [AdminUser][vaultwarden2.models.AdminUser], user id or email address.
|
|
367
369
|
"""
|
|
368
|
-
await self._post(f'/users/{await self._user_id(user)}/delete')
|
|
370
|
+
await self._post(f'/users/{_seg(await self._user_id(user))}/delete')
|
|
369
371
|
|
|
370
372
|
async def set_organization_role(self, user: AdminUserRef, organization: AdminOrganizationRef, role: OrganizationUserType) -> None:
|
|
371
373
|
"""Change a user's role in an organization.
|
|
@@ -432,7 +434,7 @@ class AsyncVaultwardenAdmin:
|
|
|
432
434
|
Raises:
|
|
433
435
|
VaultwardenError: The organization was not found or the name is ambiguous.
|
|
434
436
|
"""
|
|
435
|
-
await self._post(f'/organizations/{await self._organization_id(organization)}/delete')
|
|
437
|
+
await self._post(f'/organizations/{_seg(await self._organization_id(organization))}/delete')
|
|
436
438
|
|
|
437
439
|
# ------------------------------------------------------------ server
|
|
438
440
|
|
|
@@ -8,13 +8,14 @@ from __future__ import annotations
|
|
|
8
8
|
import time
|
|
9
9
|
import warnings
|
|
10
10
|
from typing import TYPE_CHECKING, Any, Self
|
|
11
|
+
from urllib.parse import quote
|
|
11
12
|
|
|
12
13
|
import httpx2
|
|
13
14
|
|
|
14
15
|
from vaultwarden2 import _core, _offload, crypto
|
|
15
16
|
from vaultwarden2._core import Device, UserKeys
|
|
16
17
|
from vaultwarden2._json import JsonObject
|
|
17
|
-
from vaultwarden2.errors import AuthenticationError, InsecureTransportWarning, NotUnlockedError
|
|
18
|
+
from vaultwarden2.errors import ApiError, AuthenticationError, InsecureTransportWarning, NotUnlockedError, VaultwardenError
|
|
18
19
|
from vaultwarden2.models import (
|
|
19
20
|
Cipher,
|
|
20
21
|
CollectionAccess,
|
|
@@ -47,6 +48,29 @@ def _body(response: httpx2.Response) -> Any:
|
|
|
47
48
|
return response.text
|
|
48
49
|
|
|
49
50
|
|
|
51
|
+
def _api_body(response: httpx2.Response) -> Any:
|
|
52
|
+
"""Decode the body of a successful API response, which must be JSON (or empty).
|
|
53
|
+
|
|
54
|
+
A non-JSON answer (for example the HTML login page of a proxy in front of the server) is an error: read as
|
|
55
|
+
JSON it would look like an empty result.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
response: The HTTP response.
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
The decoded JSON value, or None for an empty body.
|
|
62
|
+
|
|
63
|
+
Raises:
|
|
64
|
+
ApiError: The body is not JSON.
|
|
65
|
+
"""
|
|
66
|
+
if not response.content:
|
|
67
|
+
return None
|
|
68
|
+
try:
|
|
69
|
+
return response.json()
|
|
70
|
+
except ValueError:
|
|
71
|
+
raise ApiError(response.status_code, 'the server answered with non-JSON content (a proxy or login page in front of vaultwarden?)') from None
|
|
72
|
+
|
|
73
|
+
|
|
50
74
|
class AsyncClientBase:
|
|
51
75
|
"""HTTP plumbing, session handling and unlocked key state shared by all parts of the client.
|
|
52
76
|
|
|
@@ -246,14 +270,16 @@ class AsyncClientBase:
|
|
|
246
270
|
files: Multipart files, in the format httpx2 accepts.
|
|
247
271
|
|
|
248
272
|
Returns:
|
|
249
|
-
The decoded JSON body,
|
|
273
|
+
The decoded JSON body, or None for an empty response.
|
|
250
274
|
|
|
251
275
|
Raises:
|
|
276
|
+
VaultwardenError: ``path`` contains a ``.`` or ``..`` segment; nothing was sent.
|
|
252
277
|
NotUnlockedError: Nobody is logged in.
|
|
253
278
|
AuthenticationError: The session was rejected and could not be renewed.
|
|
254
279
|
RateLimitError: The server answered HTTP 429.
|
|
255
|
-
ApiError: Any other non-2xx answer.
|
|
280
|
+
ApiError: Any other non-2xx answer, or a successful answer that is not JSON.
|
|
256
281
|
"""
|
|
282
|
+
_check_path(path)
|
|
257
283
|
token = await self._ensure_token()
|
|
258
284
|
response = await self._http.request(method, path, json=json, params=params, files=files, headers=self._headers(Authorization=f'Bearer {token}'))
|
|
259
285
|
if response.status_code == httpx2.codes.UNAUTHORIZED and (self._refresh_token or self._api_key) and _replayable(files):
|
|
@@ -262,9 +288,8 @@ class AsyncClientBase:
|
|
|
262
288
|
await self._refresh_unlocked()
|
|
263
289
|
token = self._access_token or token
|
|
264
290
|
response = await self._http.request(method, path, json=json, params=params, files=files, headers=self._headers(Authorization=f'Bearer {token}'))
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
return body
|
|
291
|
+
_core.raise_for_status(response.status_code, _body(response))
|
|
292
|
+
return _api_body(response)
|
|
268
293
|
|
|
269
294
|
async def alive(self) -> bool:
|
|
270
295
|
"""Check whether the server is up (``/alive``). Needs no login.
|
|
@@ -402,6 +427,37 @@ def _warn_if_plaintext(base_url: str) -> None:
|
|
|
402
427
|
warnings.warn(f'{base_url} uses plain HTTP; use HTTPS for anything but local testing', InsecureTransportWarning, stacklevel=3)
|
|
403
428
|
|
|
404
429
|
|
|
430
|
+
def _seg(value: object) -> str:
|
|
431
|
+
"""Escape one URL path segment (an id or email), so it cannot change which endpoint a request goes to.
|
|
432
|
+
|
|
433
|
+
Args:
|
|
434
|
+
value: The id or other value.
|
|
435
|
+
|
|
436
|
+
Returns:
|
|
437
|
+
The percent-encoded segment (``/``, ``?``, ``#`` and ``%`` included).
|
|
438
|
+
|
|
439
|
+
Raises:
|
|
440
|
+
VaultwardenError: The value is empty, ``.`` or ``..``.
|
|
441
|
+
"""
|
|
442
|
+
text = str(value)
|
|
443
|
+
if text in {'', '.', '..'}:
|
|
444
|
+
raise VaultwardenError(f'invalid id {text!r} for a request path')
|
|
445
|
+
return quote(text, safe='@')
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
def _check_path(path: str) -> None:
|
|
449
|
+
"""Refuse request paths with ``.`` or ``..`` segments: the HTTP client resolves them to another endpoint.
|
|
450
|
+
|
|
451
|
+
Args:
|
|
452
|
+
path: The request path.
|
|
453
|
+
|
|
454
|
+
Raises:
|
|
455
|
+
VaultwardenError: The path has a dot segment.
|
|
456
|
+
"""
|
|
457
|
+
if any(part in {'.', '..'} for part in path.split('?', 1)[0].split('/')):
|
|
458
|
+
raise VaultwardenError(f'request path {path!r} contains a "." or ".." segment')
|
|
459
|
+
|
|
460
|
+
|
|
405
461
|
def _replayable(files: Any) -> bool:
|
|
406
462
|
"""Whether a multipart ``files`` argument can be sent twice.
|
|
407
463
|
|
|
@@ -6,6 +6,7 @@ import functools
|
|
|
6
6
|
from typing import TYPE_CHECKING
|
|
7
7
|
|
|
8
8
|
from vaultwarden2 import _offload, dump
|
|
9
|
+
from vaultwarden2.errors import CryptoError
|
|
9
10
|
|
|
10
11
|
if TYPE_CHECKING:
|
|
11
12
|
import os
|
|
@@ -82,6 +83,7 @@ class AsyncVaultwardenClient(_organizations_mod.AsyncOrganizationsMixin):
|
|
|
82
83
|
*,
|
|
83
84
|
compressor: Compressor | None = None,
|
|
84
85
|
argon2: Argon2Params | None = None,
|
|
86
|
+
allow_incomplete: bool = False,
|
|
85
87
|
) -> None:
|
|
86
88
|
"""Write the personal vault to an encrypted, compressed backup file.
|
|
87
89
|
|
|
@@ -95,12 +97,19 @@ class AsyncVaultwardenClient(_organizations_mod.AsyncOrganizationsMixin):
|
|
|
95
97
|
compressor: Compression module or object with ``compress``/``decompress`` (``gzip``, ``bz2``, ``lzma``,
|
|
96
98
|
...). Defaults to zstd when available, else lzma.
|
|
97
99
|
argon2: Cost of the passphrase key derivation. Defaults to RFC 9106 parameters (64 MiB, 3 passes).
|
|
100
|
+
allow_incomplete: Write the file even if some objects cannot be decrypted (they are missing from it).
|
|
101
|
+
By default nothing is written then.
|
|
98
102
|
|
|
99
103
|
Raises:
|
|
100
104
|
FileExistsError: ``path`` exists already.
|
|
101
|
-
CryptoError: The passphrase is empty
|
|
105
|
+
CryptoError: The passphrase is empty, ``argon2`` is out of range, or something in the vault cannot be
|
|
106
|
+
decrypted (and ``allow_incomplete`` is False); nothing was written.
|
|
102
107
|
"""
|
|
103
108
|
vault = await self.sync(include_archived=True) # a backup must not drop archived items
|
|
109
|
+
if vault.undecryptable and not allow_incomplete:
|
|
110
|
+
raise CryptoError(
|
|
111
|
+
f'cannot decrypt {", ".join(vault.undecryptable)}; the backup would be incomplete, nothing was written (pass allow_incomplete=True to write it anyway)'
|
|
112
|
+
)
|
|
104
113
|
await _offload.arun_cpu(functools.partial(dump.write_dump, compressor=compressor, argon2=argon2), vault, path, passphrase)
|
|
105
114
|
|
|
106
115
|
async def dump_organization(
|
|
@@ -124,7 +133,7 @@ class AsyncVaultwardenClient(_organizations_mod.AsyncOrganizationsMixin):
|
|
|
124
133
|
|
|
125
134
|
Raises:
|
|
126
135
|
FileExistsError: ``path`` exists already.
|
|
127
|
-
CryptoError: The passphrase is empty, or an item cannot be decrypted.
|
|
136
|
+
CryptoError: The passphrase is empty, ``argon2`` is out of range, or an item cannot be decrypted.
|
|
128
137
|
"""
|
|
129
138
|
export = await self.export_organization(organization)
|
|
130
139
|
await _offload.arun_cpu(functools.partial(dump.write_dump, compressor=compressor, argon2=argon2), export, path, passphrase)
|