pangea-sdk 6.1.1__py3-none-any.whl → 6.2.0b2__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.
- pangea/__init__.py +9 -1
- pangea/asyncio/__init__.py +1 -0
- pangea/asyncio/file_uploader.py +4 -2
- pangea/asyncio/request.py +199 -35
- pangea/asyncio/services/__init__.py +3 -0
- pangea/asyncio/services/ai_guard.py +91 -2
- pangea/asyncio/services/audit.py +307 -2
- pangea/asyncio/services/authn.py +12 -2
- pangea/asyncio/services/base.py +4 -0
- pangea/asyncio/services/file_scan.py +7 -1
- pangea/asyncio/services/intel.py +6 -2
- pangea/asyncio/services/management.py +576 -0
- pangea/asyncio/services/prompt_guard.py +112 -2
- pangea/asyncio/services/redact.py +269 -4
- pangea/asyncio/services/sanitize.py +5 -1
- pangea/asyncio/services/share.py +5 -1
- pangea/asyncio/services/vault.py +4 -0
- pangea/audit_logger.py +3 -1
- pangea/deep_verify.py +13 -13
- pangea/deprecated.py +1 -1
- pangea/dump_audit.py +2 -3
- pangea/exceptions.py +8 -5
- pangea/file_uploader.py +4 -0
- pangea/request.py +205 -52
- pangea/response.py +15 -12
- pangea/services/__init__.py +3 -0
- pangea/services/ai_guard.py +497 -16
- pangea/services/audit/audit.py +310 -8
- pangea/services/audit/models.py +279 -0
- pangea/services/audit/signing.py +1 -1
- pangea/services/audit/util.py +10 -10
- pangea/services/authn/authn.py +12 -2
- pangea/services/authn/models.py +3 -0
- pangea/services/authz.py +4 -0
- pangea/services/base.py +5 -1
- pangea/services/embargo.py +6 -0
- pangea/services/file_scan.py +7 -1
- pangea/services/intel.py +4 -0
- pangea/services/management.py +720 -0
- pangea/services/prompt_guard.py +193 -2
- pangea/services/redact.py +477 -7
- pangea/services/sanitize.py +5 -1
- pangea/services/share/share.py +13 -7
- pangea/services/vault/models/asymmetric.py +4 -0
- pangea/services/vault/models/common.py +4 -0
- pangea/services/vault/models/symmetric.py +4 -0
- pangea/services/vault/vault.py +2 -4
- pangea/tools.py +13 -9
- pangea/utils.py +3 -5
- pangea/verify_audit.py +23 -27
- {pangea_sdk-6.1.1.dist-info → pangea_sdk-6.2.0b2.dist-info}/METADATA +4 -4
- pangea_sdk-6.2.0b2.dist-info/RECORD +62 -0
- pangea_sdk-6.1.1.dist-info/RECORD +0 -60
- {pangea_sdk-6.1.1.dist-info → pangea_sdk-6.2.0b2.dist-info}/WHEEL +0 -0
pangea/services/audit/util.py
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
|
4
|
+
# TODO: Modernize.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
|
7
|
+
from __future__ import annotations
|
8
|
+
|
3
9
|
import base64
|
4
10
|
import json
|
5
11
|
import logging
|
@@ -155,9 +161,9 @@ def verify_membership_proof(node_hash: Hash, root_hash: Hash, proof: MembershipP
|
|
155
161
|
def normalize_log(data: dict) -> dict:
|
156
162
|
ans = {}
|
157
163
|
for key in data:
|
158
|
-
if
|
164
|
+
if isinstance(data[key], datetime):
|
159
165
|
ans[key] = format_datetime(data[key])
|
160
|
-
elif
|
166
|
+
elif isinstance(data[key], dict):
|
161
167
|
ans[key] = normalize_log(data[key]) # type: ignore[assignment]
|
162
168
|
else:
|
163
169
|
ans[key] = data[key]
|
@@ -223,9 +229,7 @@ def get_arweave_published_roots(tree_name: str, tree_sizes: Collection[int]) ->
|
|
223
229
|
}
|
224
230
|
}
|
225
231
|
}
|
226
|
-
""".replace(
|
227
|
-
"{tree_sizes}", ", ".join(f'"{tree_size}"' for tree_size in tree_sizes)
|
228
|
-
).replace(
|
232
|
+
""".replace("{tree_sizes}", ", ".join(f'"{tree_size}"' for tree_size in tree_sizes)).replace(
|
229
233
|
"{tree_name}", tree_name
|
230
234
|
)
|
231
235
|
|
@@ -273,8 +277,4 @@ def verify_consistency_proof(new_root: Hash, prev_root: Hash, proof: Consistency
|
|
273
277
|
return False
|
274
278
|
|
275
279
|
logger.debug("Verifying the proofs for the new root")
|
276
|
-
for item in proof
|
277
|
-
if not verify_membership_proof(item.node_hash, new_root, item.proof):
|
278
|
-
return False
|
279
|
-
|
280
|
-
return True
|
280
|
+
return all(verify_membership_proof(item.node_hash, new_root, item.proof) for item in proof)
|
pangea/services/authn/authn.py
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
|
4
|
+
# TODO: Modernize.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
|
3
7
|
from __future__ import annotations
|
4
8
|
|
5
9
|
from typing import Dict, List, Literal, Optional, Union
|
@@ -991,7 +995,10 @@ class AuthN(ServiceBase):
|
|
991
995
|
return self.request.post("v2/flow/complete", m.FlowCompleteResult, data=input.model_dump(exclude_none=True))
|
992
996
|
|
993
997
|
def restart(
|
994
|
-
self,
|
998
|
+
self,
|
999
|
+
flow_id: str,
|
1000
|
+
choice: m.FlowChoice,
|
1001
|
+
data: m.FlowRestartData = {}, # noqa: B006
|
995
1002
|
) -> PangeaResponse[m.FlowRestartResult]:
|
996
1003
|
"""
|
997
1004
|
Restart a sign-up/sign-in flow
|
@@ -1062,7 +1069,10 @@ class AuthN(ServiceBase):
|
|
1062
1069
|
return self.request.post("v2/flow/start", m.FlowStartResult, data=input.model_dump(exclude_none=True))
|
1063
1070
|
|
1064
1071
|
def update(
|
1065
|
-
self,
|
1072
|
+
self,
|
1073
|
+
flow_id: str,
|
1074
|
+
choice: m.FlowChoice,
|
1075
|
+
data: m.FlowUpdateData = {}, # noqa: B006
|
1066
1076
|
) -> PangeaResponse[m.FlowUpdateResult]:
|
1067
1077
|
"""
|
1068
1078
|
Update a sign-up/sign-in flow
|
pangea/services/authn/models.py
CHANGED
pangea/services/authz.py
CHANGED
pangea/services/base.py
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
|
4
|
+
# TODO: Modernize.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
|
3
7
|
from __future__ import annotations
|
4
8
|
|
5
9
|
import copy
|
@@ -17,7 +21,7 @@ from pangea.response import AttachedFile, PangeaResponse, PangeaResponseResult
|
|
17
21
|
TResult = TypeVar("TResult", bound=PangeaResponseResult, default=PangeaResponseResult)
|
18
22
|
|
19
23
|
|
20
|
-
class ServiceBase
|
24
|
+
class ServiceBase:
|
21
25
|
service_name: str = "base"
|
22
26
|
|
23
27
|
def __init__(
|
pangea/services/embargo.py
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
|
4
|
+
# TODO: Use `list` instead of `List`.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
|
7
|
+
from __future__ import annotations
|
8
|
+
|
3
9
|
from typing import Any, Dict, List
|
4
10
|
|
5
11
|
from pangea.response import APIRequestModel, APIResponseModel, PangeaResponse, PangeaResponseResult
|
pangea/services/file_scan.py
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Copyright 2022 Pangea Cyber Corporation
|
2
2
|
# Author: Pangea Cyber Corporation
|
3
|
+
|
4
|
+
# TODO: Use `list` instead of `List`.
|
5
|
+
# ruff: noqa: UP006, UP035
|
6
|
+
|
7
|
+
from __future__ import annotations
|
8
|
+
|
3
9
|
import io
|
4
10
|
import logging
|
5
11
|
from typing import Dict, List, Optional, Tuple
|
@@ -133,7 +139,7 @@ class FileScan(ServiceBase):
|
|
133
139
|
files: Optional[List[Tuple]] = None
|
134
140
|
if file or file_path:
|
135
141
|
if file_path:
|
136
|
-
file = open(file_path, "rb")
|
142
|
+
file = open(file_path, "rb") # noqa: SIM115
|
137
143
|
if transfer_method == TransferMethod.POST_URL:
|
138
144
|
params = get_file_upload_params(file) # type: ignore[arg-type]
|
139
145
|
crc = params.crc_hex
|