cryptascreen 0.2.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.
Files changed (41) hide show
  1. cryptascreen/__init__.py +61 -0
  2. cryptascreen/_util.py +111 -0
  3. cryptascreen/_version.py +3 -0
  4. cryptascreen/client.py +231 -0
  5. cryptascreen/config.py +48 -0
  6. cryptascreen/errors.py +217 -0
  7. cryptascreen/helpers.py +47 -0
  8. cryptascreen/operations.py +131 -0
  9. cryptascreen/resources/__init__.py +1 -0
  10. cryptascreen/resources/alerts.py +51 -0
  11. cryptascreen/resources/auth.py +36 -0
  12. cryptascreen/resources/capabilities.py +36 -0
  13. cryptascreen/resources/cases.py +198 -0
  14. cryptascreen/resources/compliance.py +116 -0
  15. cryptascreen/resources/graph.py +70 -0
  16. cryptascreen/resources/intelligence.py +69 -0
  17. cryptascreen/resources/monitoring.py +142 -0
  18. cryptascreen/resources/names.py +97 -0
  19. cryptascreen/resources/sanctions.py +50 -0
  20. cryptascreen/resources/screening.py +379 -0
  21. cryptascreen/resources/settings.py +115 -0
  22. cryptascreen/resources/webhooks.py +55 -0
  23. cryptascreen/retry.py +176 -0
  24. cryptascreen/signature.py +118 -0
  25. cryptascreen/types/__init__.py +313 -0
  26. cryptascreen/types/_account.py +199 -0
  27. cryptascreen/types/_models.py +1620 -0
  28. cryptascreen/types/cases.py +31 -0
  29. cryptascreen/types/common.py +17 -0
  30. cryptascreen/types/compliance.py +27 -0
  31. cryptascreen/types/graph.py +25 -0
  32. cryptascreen/types/intelligence.py +11 -0
  33. cryptascreen/types/names.py +39 -0
  34. cryptascreen/types/sanctions.py +13 -0
  35. cryptascreen/types/screening.py +73 -0
  36. cryptascreen/types/wallet.py +85 -0
  37. cryptascreen/types/webhooks.py +13 -0
  38. cryptascreen-0.2.0.dist-info/METADATA +305 -0
  39. cryptascreen-0.2.0.dist-info/RECORD +41 -0
  40. cryptascreen-0.2.0.dist-info/WHEEL +4 -0
  41. cryptascreen-0.2.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,70 @@
1
+ """Graph resource (mirrors @cryptascreen/sdk graph endpoints)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Any
6
+
7
+ from cryptascreen._util import _body
8
+ from cryptascreen.types._models import (
9
+ GraphRequest,
10
+ GraphResponse,
11
+ )
12
+
13
+ if TYPE_CHECKING:
14
+ from cryptascreen.client import AsyncHttpClient, HttpClient
15
+
16
+
17
+ class GraphResource:
18
+ """Synchronous graph operations. Access via ``client.graph``."""
19
+
20
+ def __init__(self, http: HttpClient) -> None:
21
+ self._http = http
22
+
23
+ def build_graph(self, request: GraphRequest | dict[str, Any]) -> GraphResponse:
24
+ """POST /investigate/graph"""
25
+ data = self._http.request("POST", "/api/v1/investigate/graph", json=_body(request))
26
+ return GraphResponse.model_validate(data)
27
+
28
+ def export_graph(self, request: GraphRequest | dict[str, Any], *, format: str = "json") -> Any:
29
+ """Export a flow-of-funds graph: parsed JSON for ``json``, raw bytes for ``csv``."""
30
+ return self._http.request(
31
+ "POST",
32
+ "/api/v1/investigate/graph/export",
33
+ json=_body(request),
34
+ params={"format": format},
35
+ binary=format != "json",
36
+ )
37
+
38
+ def trace(self, request: GraphRequest | dict[str, Any]) -> GraphResponse:
39
+ """POST /investigate/trace"""
40
+ data = self._http.request("POST", "/api/v1/investigate/trace", json=_body(request))
41
+ return GraphResponse.model_validate(data)
42
+
43
+
44
+ class AsyncGraphResource:
45
+ """Asynchronous graph operations. Access via ``client.graph``."""
46
+
47
+ def __init__(self, http: AsyncHttpClient) -> None:
48
+ self._http = http
49
+
50
+ async def build_graph(self, request: GraphRequest | dict[str, Any]) -> GraphResponse:
51
+ """POST /investigate/graph"""
52
+ data = await self._http.request("POST", "/api/v1/investigate/graph", json=_body(request))
53
+ return GraphResponse.model_validate(data)
54
+
55
+ async def export_graph(
56
+ self, request: GraphRequest | dict[str, Any], *, format: str = "json"
57
+ ) -> Any:
58
+ """Export a flow-of-funds graph: parsed JSON for ``json``, raw bytes for ``csv``."""
59
+ return await self._http.request(
60
+ "POST",
61
+ "/api/v1/investigate/graph/export",
62
+ json=_body(request),
63
+ params={"format": format},
64
+ binary=format != "json",
65
+ )
66
+
67
+ async def trace(self, request: GraphRequest | dict[str, Any]) -> GraphResponse:
68
+ """POST /investigate/trace"""
69
+ data = await self._http.request("POST", "/api/v1/investigate/trace", json=_body(request))
70
+ return GraphResponse.model_validate(data)
@@ -0,0 +1,69 @@
1
+ """Intelligence resource (mirrors @cryptascreen/sdk intelligence endpoints)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ from cryptascreen._util import _enc
8
+ from cryptascreen.errors import CryptaScreenError
9
+ from cryptascreen.types._models import (
10
+ EntityLabel,
11
+ VaspInfo,
12
+ )
13
+
14
+ if TYPE_CHECKING:
15
+ from cryptascreen.client import AsyncHttpClient, HttpClient
16
+
17
+
18
+ class IntelligenceResource:
19
+ """Synchronous intelligence operations. Access via ``client.intelligence``."""
20
+
21
+ def __init__(self, http: HttpClient) -> None:
22
+ self._http = http
23
+
24
+ def get_entity_labels(self, chain: str, address: str) -> list[EntityLabel]:
25
+ """All entity attributions for an address (empty list = no label known; NOT a clean verdict)."""
26
+ data = self._http.request(
27
+ "GET", f"/api/v1/intelligence/entity/{_enc(chain)}/{_enc(address)}"
28
+ )
29
+ return [EntityLabel.model_validate(x) for x in data] if isinstance(data, list) else []
30
+
31
+ def get_entity_label(self, address: str, chain: str) -> EntityLabel | None:
32
+ """Deprecated: first entity attribution or None; use get_entity_labels."""
33
+ labels = self.get_entity_labels(chain, address)
34
+ return labels[0] if labels else None
35
+
36
+ def get_vasp_info(self, vasp_id: str) -> VaspInfo:
37
+ """Deprecated: there is no VASP profile endpoint; raises without making a request."""
38
+ raise CryptaScreenError(
39
+ f"get_vasp_info({vasp_id}) is not available: the API has no VASP profile endpoint. Use compliance.identify_vasp(chain, address).",
40
+ 0,
41
+ "ENDPOINT_NOT_AVAILABLE",
42
+ )
43
+
44
+
45
+ class AsyncIntelligenceResource:
46
+ """Asynchronous intelligence operations. Access via ``client.intelligence``."""
47
+
48
+ def __init__(self, http: AsyncHttpClient) -> None:
49
+ self._http = http
50
+
51
+ async def get_entity_labels(self, chain: str, address: str) -> list[EntityLabel]:
52
+ """All entity attributions for an address (empty list = no label known; NOT a clean verdict)."""
53
+ data = await self._http.request(
54
+ "GET", f"/api/v1/intelligence/entity/{_enc(chain)}/{_enc(address)}"
55
+ )
56
+ return [EntityLabel.model_validate(x) for x in data] if isinstance(data, list) else []
57
+
58
+ async def get_entity_label(self, address: str, chain: str) -> EntityLabel | None:
59
+ """Deprecated: first entity attribution or None; use get_entity_labels."""
60
+ labels = await self.get_entity_labels(chain, address)
61
+ return labels[0] if labels else None
62
+
63
+ async def get_vasp_info(self, vasp_id: str) -> VaspInfo:
64
+ """Deprecated: there is no VASP profile endpoint; raises without making a request."""
65
+ raise CryptaScreenError(
66
+ f"get_vasp_info({vasp_id}) is not available: the API has no VASP profile endpoint. Use compliance.identify_vasp(chain, address).",
67
+ 0,
68
+ "ENDPOINT_NOT_AVAILABLE",
69
+ )
@@ -0,0 +1,142 @@
1
+ """Wallet / name monitoring and breach detections (resource ``client.monitoring``)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Any
6
+
7
+ from cryptascreen._util import _body, _enc
8
+ from cryptascreen.types._account import (
9
+ AddMonitoredWalletRequest,
10
+ BreachDetection,
11
+ BreachSummary,
12
+ DeletedResponse,
13
+ MonitoredName,
14
+ MonitoredNamesResponse,
15
+ MonitoredWallet,
16
+ MonitoringOverview,
17
+ RemovedResponse,
18
+ )
19
+ from cryptascreen.types._models import NameScreenRequest
20
+
21
+ if TYPE_CHECKING:
22
+ from cryptascreen.client import AsyncHttpClient, HttpClient
23
+
24
+
25
+ class MonitoringResource:
26
+ """Synchronous wallet / name monitoring and breach detections. Access via ``client.monitoring``."""
27
+
28
+ def __init__(self, http: HttpClient) -> None:
29
+ self._http = http
30
+
31
+ def list_wallets(self) -> list[MonitoredWallet]:
32
+ """Monitored wallets of the calling tenant."""
33
+ data = self._http.request("GET", "/api/v1/monitoring/wallets")
34
+ return [MonitoredWallet.model_validate(x) for x in data]
35
+
36
+ def add_wallet(self, request: AddMonitoredWalletRequest | dict[str, Any]) -> MonitoredWallet:
37
+ """Add a wallet to monitoring (plan-limited; a duplicate is a 400 DUPLICATE)."""
38
+ data = self._http.request("POST", "/api/v1/monitoring/wallets", json=_body(request))
39
+ return MonitoredWallet.model_validate(data)
40
+
41
+ def remove_wallet(self, id: int | str) -> DeletedResponse:
42
+ """Remove a wallet from monitoring."""
43
+ data = self._http.request("DELETE", f"/api/v1/monitoring/wallets/{_enc(str(id))}")
44
+ return DeletedResponse.model_validate(data)
45
+
46
+ def list_names(self) -> MonitoredNamesResponse:
47
+ """Monitored names of the calling tenant and how many the plan has used."""
48
+ data = self._http.request("GET", "/api/v1/monitoring/names")
49
+ return MonitoredNamesResponse.model_validate(data)
50
+
51
+ def add_name(self, request: NameScreenRequest | dict[str, Any]) -> MonitoredName:
52
+ """Save a name to the monitored list (plan-limited like monitored wallets)."""
53
+ data = self._http.request("POST", "/api/v1/monitoring/names", json=_body(request))
54
+ return MonitoredName.model_validate(data)
55
+
56
+ def remove_name(self, id: int | str) -> RemovedResponse:
57
+ """Remove a name from the monitored list."""
58
+ data = self._http.request("DELETE", f"/api/v1/monitoring/names/{_enc(str(id))}")
59
+ return RemovedResponse.model_validate(data)
60
+
61
+ def get_overview(self) -> MonitoringOverview:
62
+ """Names and wallets on the monitored list, with the last known hits of each name."""
63
+ data = self._http.request("GET", "/api/v1/monitoring/overview")
64
+ return MonitoringOverview.model_validate(data)
65
+
66
+ def list_breaches(self) -> list[BreachDetection]:
67
+ """All breach detections of the calling tenant, newest first."""
68
+ data = self._http.request("GET", "/api/v1/monitoring/breaches")
69
+ return [BreachDetection.model_validate(x) for x in data]
70
+
71
+ def get_breach_summary(self) -> BreachSummary:
72
+ """Counts of breach detections (unacknowledged, by severity, total)."""
73
+ data = self._http.request("GET", "/api/v1/monitoring/breaches/summary")
74
+ return BreachSummary.model_validate(data)
75
+
76
+ def acknowledge_breach(self, id: int | str) -> BreachDetection:
77
+ """Acknowledge a breach detection (a second acknowledge is a 400 ALREADY_ACKNOWLEDGED)."""
78
+ data = self._http.request(
79
+ "POST", f"/api/v1/monitoring/breaches/{_enc(str(id))}/acknowledge"
80
+ )
81
+ return BreachDetection.model_validate(data)
82
+
83
+
84
+ class AsyncMonitoringResource:
85
+ """Asynchronous wallet / name monitoring and breach detections. Access via ``client.monitoring``."""
86
+
87
+ def __init__(self, http: AsyncHttpClient) -> None:
88
+ self._http = http
89
+
90
+ async def list_wallets(self) -> list[MonitoredWallet]:
91
+ """Monitored wallets of the calling tenant."""
92
+ data = await self._http.request("GET", "/api/v1/monitoring/wallets")
93
+ return [MonitoredWallet.model_validate(x) for x in data]
94
+
95
+ async def add_wallet(
96
+ self, request: AddMonitoredWalletRequest | dict[str, Any]
97
+ ) -> MonitoredWallet:
98
+ """Add a wallet to monitoring (plan-limited; a duplicate is a 400 DUPLICATE)."""
99
+ data = await self._http.request("POST", "/api/v1/monitoring/wallets", json=_body(request))
100
+ return MonitoredWallet.model_validate(data)
101
+
102
+ async def remove_wallet(self, id: int | str) -> DeletedResponse:
103
+ """Remove a wallet from monitoring."""
104
+ data = await self._http.request("DELETE", f"/api/v1/monitoring/wallets/{_enc(str(id))}")
105
+ return DeletedResponse.model_validate(data)
106
+
107
+ async def list_names(self) -> MonitoredNamesResponse:
108
+ """Monitored names of the calling tenant and how many the plan has used."""
109
+ data = await self._http.request("GET", "/api/v1/monitoring/names")
110
+ return MonitoredNamesResponse.model_validate(data)
111
+
112
+ async def add_name(self, request: NameScreenRequest | dict[str, Any]) -> MonitoredName:
113
+ """Save a name to the monitored list (plan-limited like monitored wallets)."""
114
+ data = await self._http.request("POST", "/api/v1/monitoring/names", json=_body(request))
115
+ return MonitoredName.model_validate(data)
116
+
117
+ async def remove_name(self, id: int | str) -> RemovedResponse:
118
+ """Remove a name from the monitored list."""
119
+ data = await self._http.request("DELETE", f"/api/v1/monitoring/names/{_enc(str(id))}")
120
+ return RemovedResponse.model_validate(data)
121
+
122
+ async def get_overview(self) -> MonitoringOverview:
123
+ """Names and wallets on the monitored list, with the last known hits of each name."""
124
+ data = await self._http.request("GET", "/api/v1/monitoring/overview")
125
+ return MonitoringOverview.model_validate(data)
126
+
127
+ async def list_breaches(self) -> list[BreachDetection]:
128
+ """All breach detections of the calling tenant, newest first."""
129
+ data = await self._http.request("GET", "/api/v1/monitoring/breaches")
130
+ return [BreachDetection.model_validate(x) for x in data]
131
+
132
+ async def get_breach_summary(self) -> BreachSummary:
133
+ """Counts of breach detections (unacknowledged, by severity, total)."""
134
+ data = await self._http.request("GET", "/api/v1/monitoring/breaches/summary")
135
+ return BreachSummary.model_validate(data)
136
+
137
+ async def acknowledge_breach(self, id: int | str) -> BreachDetection:
138
+ """Acknowledge a breach detection (a second acknowledge is a 400 ALREADY_ACKNOWLEDGED)."""
139
+ data = await self._http.request(
140
+ "POST", f"/api/v1/monitoring/breaches/{_enc(str(id))}/acknowledge"
141
+ )
142
+ return BreachDetection.model_validate(data)
@@ -0,0 +1,97 @@
1
+ """Names resource (mirrors @cryptascreen/sdk names endpoints)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING, Any
6
+
7
+ from cryptascreen._util import _body, _enc, _query
8
+ from cryptascreen.types._models import (
9
+ NameDecisionRequest,
10
+ NameMatchDecision,
11
+ NameScreeningHistoryItem,
12
+ NameScreenRequest,
13
+ NameScreenResponse,
14
+ )
15
+
16
+ if TYPE_CHECKING:
17
+ from cryptascreen.client import AsyncHttpClient, HttpClient
18
+
19
+
20
+ class NamesResource:
21
+ """Synchronous names operations. Access via ``client.names``."""
22
+
23
+ def __init__(self, http: HttpClient) -> None:
24
+ self._http = http
25
+
26
+ def screen(
27
+ self, request: NameScreenRequest | dict[str, Any], *, idempotency_key: str | None = None
28
+ ) -> NameScreenResponse:
29
+ """Screen one name. An invalid request is a 400 (ValidationError) and is not counted."""
30
+ headers = {"Idempotency-Key": idempotency_key} if idempotency_key else None
31
+ data = self._http.request(
32
+ "POST", "/api/v1/screen/name", json=_body(request), headers=headers
33
+ )
34
+ return NameScreenResponse.model_validate(data)
35
+
36
+ def get(self, screening_id: str) -> NameScreenResponse:
37
+ """GET /screen/name/{screeningId}"""
38
+ data = self._http.request("GET", f"/api/v1/screen/name/{_enc(screening_id)}")
39
+ return NameScreenResponse.model_validate(data)
40
+
41
+ def history(self, *, limit: int = 50) -> list[NameScreeningHistoryItem]:
42
+ """GET /screen/name/history"""
43
+ data = self._http.request("GET", "/api/v1/screen/name/history", params=_query(limit=limit))
44
+ return [NameScreeningHistoryItem.model_validate(x) for x in data]
45
+
46
+ def decide(self, request: NameDecisionRequest | dict[str, Any]) -> NameMatchDecision:
47
+ """POST /screen/name/decisions"""
48
+ data = self._http.request("POST", "/api/v1/screen/name/decisions", json=_body(request))
49
+ return NameMatchDecision.model_validate(data)
50
+
51
+ def decision_audit(self, *, format: str = "json") -> Any:
52
+ """GET /screen/name/decisions/audit"""
53
+ return self._http.request(
54
+ "GET", "/api/v1/screen/name/decisions/audit", params=_query(format=format)
55
+ )
56
+
57
+
58
+ class AsyncNamesResource:
59
+ """Asynchronous names operations. Access via ``client.names``."""
60
+
61
+ def __init__(self, http: AsyncHttpClient) -> None:
62
+ self._http = http
63
+
64
+ async def screen(
65
+ self, request: NameScreenRequest | dict[str, Any], *, idempotency_key: str | None = None
66
+ ) -> NameScreenResponse:
67
+ """Screen one name. An invalid request is a 400 (ValidationError) and is not counted."""
68
+ headers = {"Idempotency-Key": idempotency_key} if idempotency_key else None
69
+ data = await self._http.request(
70
+ "POST", "/api/v1/screen/name", json=_body(request), headers=headers
71
+ )
72
+ return NameScreenResponse.model_validate(data)
73
+
74
+ async def get(self, screening_id: str) -> NameScreenResponse:
75
+ """GET /screen/name/{screeningId}"""
76
+ data = await self._http.request("GET", f"/api/v1/screen/name/{_enc(screening_id)}")
77
+ return NameScreenResponse.model_validate(data)
78
+
79
+ async def history(self, *, limit: int = 50) -> list[NameScreeningHistoryItem]:
80
+ """GET /screen/name/history"""
81
+ data = await self._http.request(
82
+ "GET", "/api/v1/screen/name/history", params=_query(limit=limit)
83
+ )
84
+ return [NameScreeningHistoryItem.model_validate(x) for x in data]
85
+
86
+ async def decide(self, request: NameDecisionRequest | dict[str, Any]) -> NameMatchDecision:
87
+ """POST /screen/name/decisions"""
88
+ data = await self._http.request(
89
+ "POST", "/api/v1/screen/name/decisions", json=_body(request)
90
+ )
91
+ return NameMatchDecision.model_validate(data)
92
+
93
+ async def decision_audit(self, *, format: str = "json") -> Any:
94
+ """GET /screen/name/decisions/audit"""
95
+ return await self._http.request(
96
+ "GET", "/api/v1/screen/name/decisions/audit", params=_query(format=format)
97
+ )
@@ -0,0 +1,50 @@
1
+ """Sanctions resource (mirrors @cryptascreen/sdk sanctions endpoints)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ from cryptascreen._util import _enc
8
+ from cryptascreen.types._models import (
9
+ SanctionsCheckResponse,
10
+ SanctionsStatusResponse,
11
+ )
12
+
13
+ if TYPE_CHECKING:
14
+ from cryptascreen.client import AsyncHttpClient, HttpClient
15
+
16
+
17
+ class SanctionsResource:
18
+ """Synchronous sanctions operations. Access via ``client.sanctions``."""
19
+
20
+ def __init__(self, http: HttpClient) -> None:
21
+ self._http = http
22
+
23
+ def check(self, chain: str, address: str) -> SanctionsCheckResponse:
24
+ """GET /sanctions/check/{chain}/{address}"""
25
+ data = self._http.request("GET", f"/api/v1/sanctions/check/{_enc(chain)}/{_enc(address)}")
26
+ return SanctionsCheckResponse.model_validate(data)
27
+
28
+ def get_status(self) -> SanctionsStatusResponse:
29
+ """GET /sanctions/status"""
30
+ data = self._http.request("GET", "/api/v1/sanctions/status")
31
+ return SanctionsStatusResponse.model_validate(data)
32
+
33
+
34
+ class AsyncSanctionsResource:
35
+ """Asynchronous sanctions operations. Access via ``client.sanctions``."""
36
+
37
+ def __init__(self, http: AsyncHttpClient) -> None:
38
+ self._http = http
39
+
40
+ async def check(self, chain: str, address: str) -> SanctionsCheckResponse:
41
+ """GET /sanctions/check/{chain}/{address}"""
42
+ data = await self._http.request(
43
+ "GET", f"/api/v1/sanctions/check/{_enc(chain)}/{_enc(address)}"
44
+ )
45
+ return SanctionsCheckResponse.model_validate(data)
46
+
47
+ async def get_status(self) -> SanctionsStatusResponse:
48
+ """GET /sanctions/status"""
49
+ data = await self._http.request("GET", "/api/v1/sanctions/status")
50
+ return SanctionsStatusResponse.model_validate(data)