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.
Files changed (54) hide show
  1. pangea/__init__.py +9 -1
  2. pangea/asyncio/__init__.py +1 -0
  3. pangea/asyncio/file_uploader.py +4 -2
  4. pangea/asyncio/request.py +199 -35
  5. pangea/asyncio/services/__init__.py +3 -0
  6. pangea/asyncio/services/ai_guard.py +91 -2
  7. pangea/asyncio/services/audit.py +307 -2
  8. pangea/asyncio/services/authn.py +12 -2
  9. pangea/asyncio/services/base.py +4 -0
  10. pangea/asyncio/services/file_scan.py +7 -1
  11. pangea/asyncio/services/intel.py +6 -2
  12. pangea/asyncio/services/management.py +576 -0
  13. pangea/asyncio/services/prompt_guard.py +112 -2
  14. pangea/asyncio/services/redact.py +269 -4
  15. pangea/asyncio/services/sanitize.py +5 -1
  16. pangea/asyncio/services/share.py +5 -1
  17. pangea/asyncio/services/vault.py +4 -0
  18. pangea/audit_logger.py +3 -1
  19. pangea/deep_verify.py +13 -13
  20. pangea/deprecated.py +1 -1
  21. pangea/dump_audit.py +2 -3
  22. pangea/exceptions.py +8 -5
  23. pangea/file_uploader.py +4 -0
  24. pangea/request.py +205 -52
  25. pangea/response.py +15 -12
  26. pangea/services/__init__.py +3 -0
  27. pangea/services/ai_guard.py +497 -16
  28. pangea/services/audit/audit.py +310 -8
  29. pangea/services/audit/models.py +279 -0
  30. pangea/services/audit/signing.py +1 -1
  31. pangea/services/audit/util.py +10 -10
  32. pangea/services/authn/authn.py +12 -2
  33. pangea/services/authn/models.py +3 -0
  34. pangea/services/authz.py +4 -0
  35. pangea/services/base.py +5 -1
  36. pangea/services/embargo.py +6 -0
  37. pangea/services/file_scan.py +7 -1
  38. pangea/services/intel.py +4 -0
  39. pangea/services/management.py +720 -0
  40. pangea/services/prompt_guard.py +193 -2
  41. pangea/services/redact.py +477 -7
  42. pangea/services/sanitize.py +5 -1
  43. pangea/services/share/share.py +13 -7
  44. pangea/services/vault/models/asymmetric.py +4 -0
  45. pangea/services/vault/models/common.py +4 -0
  46. pangea/services/vault/models/symmetric.py +4 -0
  47. pangea/services/vault/vault.py +2 -4
  48. pangea/tools.py +13 -9
  49. pangea/utils.py +3 -5
  50. pangea/verify_audit.py +23 -27
  51. {pangea_sdk-6.1.1.dist-info → pangea_sdk-6.2.0b2.dist-info}/METADATA +4 -4
  52. pangea_sdk-6.2.0b2.dist-info/RECORD +62 -0
  53. pangea_sdk-6.1.1.dist-info/RECORD +0 -60
  54. {pangea_sdk-6.1.1.dist-info → pangea_sdk-6.2.0b2.dist-info}/WHEEL +0 -0
@@ -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 type(data[key]) == datetime:
164
+ if isinstance(data[key], datetime):
159
165
  ans[key] = format_datetime(data[key])
160
- elif type(data[key]) == dict:
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)
@@ -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, flow_id: str, choice: m.FlowChoice, data: m.FlowRestartData = {}
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, flow_id: str, choice: m.FlowChoice, data: m.FlowUpdateData = {}
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
@@ -1,6 +1,9 @@
1
1
  # Copyright 2022 Pangea Cyber Corporation
2
2
  # Author: Pangea Cyber Corporation
3
3
 
4
+ # TODO: Modernize.
5
+ # ruff: noqa: UP006, UP035
6
+
4
7
  from __future__ import annotations
5
8
 
6
9
  import enum
pangea/services/authz.py CHANGED
@@ -1,5 +1,9 @@
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
+
3
7
  from __future__ import annotations
4
8
 
5
9
  import enum
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(object):
24
+ class ServiceBase:
21
25
  service_name: str = "base"
22
26
 
23
27
  def __init__(
@@ -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
@@ -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
pangea/services/intel.py CHANGED
@@ -1,5 +1,9 @@
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
+
3
7
  from __future__ import annotations
4
8
 
5
9
  import enum