async-mega-py 2.3.0__tar.gz → 2.3.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.
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/PKG-INFO +1 -1
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/pyproject.toml +1 -1
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/data_structures.py +4 -6
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/vault.py +9 -4
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/LICENSE +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/README.md +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/__init__.py +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/__main__.py +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/api.py +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/auth.py +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/chunker.py +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/client.py +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/core.py +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/crypto.py +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/download.py +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/env.py +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/errors.py +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/filesystem.py +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/progress/__init__.py +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/progress/rich_progress.py +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/py.typed +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/transfer_it.py +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/upload.py +0 -0
- {async_mega_py-2.3.0 → async_mega_py-2.3.1}/src/mega/utils.py +0 -0
|
@@ -29,7 +29,6 @@ SharedKeys: TypeAlias = dict[NodeID, tuple[int, ...]]
|
|
|
29
29
|
|
|
30
30
|
NodeKey = tuple[int, int, int, int]
|
|
31
31
|
ComposedFileKey = tuple[int, int, int, int, int, int, int, int]
|
|
32
|
-
ComposedFolderKey = tuple[int, int, int, int]
|
|
33
32
|
|
|
34
33
|
|
|
35
34
|
class ByteSize(int):
|
|
@@ -182,7 +181,7 @@ class Crypto(_DictDumper):
|
|
|
182
181
|
iv: tuple[int, int]
|
|
183
182
|
meta_mac: tuple[int, int]
|
|
184
183
|
|
|
185
|
-
full_key: ComposedFileKey |
|
|
184
|
+
full_key: ComposedFileKey | NodeKey
|
|
186
185
|
share_key: NodeKey | None
|
|
187
186
|
|
|
188
187
|
@classmethod
|
|
@@ -206,19 +205,18 @@ class Crypto(_DictDumper):
|
|
|
206
205
|
raise RuntimeError(f"Invalid key, expected key len for files is 8, got {len(composed_key) = }")
|
|
207
206
|
|
|
208
207
|
else:
|
|
209
|
-
if len(key) != 4:
|
|
210
|
-
raise RuntimeError(f"Invalid key, expected key len for folders is 4, got {len(key) = }")
|
|
211
|
-
|
|
212
208
|
iv = ()
|
|
213
209
|
meta_mac = ()
|
|
214
210
|
composed_key = key
|
|
211
|
+
if len(composed_key) != 4:
|
|
212
|
+
raise RuntimeError(f"Invalid key, expected key len for folders is 4, got {len(composed_key) = }")
|
|
215
213
|
|
|
216
214
|
return Crypto(key, iv, meta_mac, composed_key, None) # pyright: ignore[reportArgumentType]
|
|
217
215
|
|
|
218
216
|
@classmethod
|
|
219
217
|
def decompose(
|
|
220
218
|
cls,
|
|
221
|
-
composed_key: ComposedFileKey |
|
|
219
|
+
composed_key: ComposedFileKey | NodeKey,
|
|
222
220
|
node_type: NodeType = NodeType.FILE,
|
|
223
221
|
share_key: NodeKey | None = None,
|
|
224
222
|
) -> Crypto:
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import dataclasses
|
|
4
|
-
from typing import TYPE_CHECKING, Final, cast
|
|
4
|
+
from typing import TYPE_CHECKING, Final, NamedTuple, cast
|
|
5
5
|
|
|
6
6
|
from mega.crypto import b64_to_a32, decrypt_key
|
|
7
7
|
|
|
8
8
|
if TYPE_CHECKING:
|
|
9
9
|
from mega.data_structures import (
|
|
10
10
|
ComposedFileKey,
|
|
11
|
-
ComposedFolderKey,
|
|
12
11
|
GetNodesResponse,
|
|
13
12
|
Node,
|
|
14
13
|
NodeID,
|
|
14
|
+
NodeKey,
|
|
15
15
|
SharedKeys,
|
|
16
16
|
UserID,
|
|
17
17
|
)
|
|
@@ -21,6 +21,11 @@ _EXPORTED: Final = "EXP"
|
|
|
21
21
|
# An special owner used for exported (AKA public) file/folders
|
|
22
22
|
|
|
23
23
|
|
|
24
|
+
class KeyLookup(NamedTuple):
|
|
25
|
+
full_key: ComposedFileKey | NodeKey
|
|
26
|
+
share_key: NodeKey | None
|
|
27
|
+
|
|
28
|
+
|
|
24
29
|
@dataclasses.dataclass(slots=True, frozen=True)
|
|
25
30
|
class MegaVault:
|
|
26
31
|
master_key: tuple[int, ...] = ()
|
|
@@ -43,7 +48,7 @@ class MegaVault:
|
|
|
43
48
|
if key := new_keys.get(node_id):
|
|
44
49
|
self._shared_keys.setdefault(owner, {})[node_id] = key
|
|
45
50
|
|
|
46
|
-
def __getitem__(self, node: Node) ->
|
|
51
|
+
def __getitem__(self, node: Node) -> KeyLookup:
|
|
47
52
|
share_key: tuple[int, ...] | None = None
|
|
48
53
|
|
|
49
54
|
# my files/folders
|
|
@@ -74,7 +79,7 @@ class MegaVault:
|
|
|
74
79
|
if len(full_key) not in (4, 8):
|
|
75
80
|
raise RuntimeError(f"Invalid key len found for node {node.id} ({len(full_key)})")
|
|
76
81
|
|
|
77
|
-
return cast("ComposedFileKey |
|
|
82
|
+
return KeyLookup(cast("ComposedFileKey | NodeKey", full_key), share_key)
|
|
78
83
|
|
|
79
84
|
def save_public_key(self, node_id: NodeID, share_key: tuple[int, ...]) -> None:
|
|
80
85
|
self._shared_keys[_EXPORTED][node_id] = share_key
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|