dominusnode 2.0.0__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.
- dominusnode-2.0.0/CHANGELOG.md +58 -0
- dominusnode-2.0.0/LICENSE +21 -0
- dominusnode-2.0.0/MANIFEST.in +8 -0
- dominusnode-2.0.0/PKG-INFO +177 -0
- dominusnode-2.0.0/README.md +159 -0
- dominusnode-2.0.0/dominusnode/__init__.py +45 -0
- dominusnode-2.0.0/dominusnode/_ops.py +122 -0
- dominusnode-2.0.0/dominusnode/client.py +192 -0
- dominusnode-2.0.0/dominusnode/constants.py +24 -0
- dominusnode-2.0.0/dominusnode/errors.py +153 -0
- dominusnode-2.0.0/dominusnode/http_client.py +354 -0
- dominusnode-2.0.0/dominusnode/messages.py +79 -0
- dominusnode-2.0.0/dominusnode/pow.py +33 -0
- dominusnode-2.0.0/dominusnode/proxy_fetch.py +341 -0
- dominusnode-2.0.0/dominusnode/py.typed +0 -0
- dominusnode-2.0.0/dominusnode/resources.py +791 -0
- dominusnode-2.0.0/dominusnode/secret.py +60 -0
- dominusnode-2.0.0/dominusnode/signer.py +56 -0
- dominusnode-2.0.0/dominusnode/ssrf.py +176 -0
- dominusnode-2.0.0/dominusnode/token_manager.py +150 -0
- dominusnode-2.0.0/dominusnode/types.py +99 -0
- dominusnode-2.0.0/dominusnode/validation.py +117 -0
- dominusnode-2.0.0/dominusnode.egg-info/PKG-INFO +177 -0
- dominusnode-2.0.0/dominusnode.egg-info/SOURCES.txt +27 -0
- dominusnode-2.0.0/dominusnode.egg-info/dependency_links.txt +1 -0
- dominusnode-2.0.0/dominusnode.egg-info/requires.txt +5 -0
- dominusnode-2.0.0/dominusnode.egg-info/top_level.txt +1 -0
- dominusnode-2.0.0/pyproject.toml +28 -0
- dominusnode-2.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
|
+
|
|
8
|
+
## [2.0.0] - 2026-11-06
|
|
9
|
+
|
|
10
|
+
Breaking: rewritten for the v2 relay-network contract (`sdks/SDK_SURFACE.md`, reference `sdks/node` 2.0.0).
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- 15 resources and 71 methods, the same in `DominusNodeClient` and `AsyncDominusNodeClient`: `network`, `nodes` (with PoW and attestation registration), `credits` (µUSD convert and withdraw), `payout_wallet`, `payouts`, `sessions.report` and `wallet_auth.sign_in`.
|
|
14
|
+
- EIP-191 signer callbacks. The SDK rebuilds the node-attestation, payout-wallet and withdrawal messages itself and refuses to sign a server message that differs (`ProtocolError`).
|
|
15
|
+
- `proxy.build_username`/`build_url` with `country-XX` (OFAC refused), `class-…`, `session-…`, `wallet-<uuid>` and `allowhttp-1`.
|
|
16
|
+
- `proxy.fetch` for GET/HEAD through the gateway, with an SSRF guard (private IPs in every spelling, local names) and a DNS-rebinding check.
|
|
17
|
+
- `Secret` wrapper for one-time credentials, `ProtocolError` and `ProxyError`, error `code` and `details`.
|
|
18
|
+
- Credential scrubbing now also covers `dn_node_`/`dn_proxy_` keys and JWTs.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
- Redirects are refused and API responses are capped at 10 MB, by Content-Length and by the bytes actually read.
|
|
22
|
+
- 429 is retried once, waiting min(Retry-After, 10 s) ±10 % with a 100 ms floor. 401 triggers one JWT refresh, shared by concurrent callers.
|
|
23
|
+
- `/v1` agent routes send the raw API key.
|
|
24
|
+
- `disconnect()` clears the API key and both tokens. The token manager keeps its refresh callback.
|
|
25
|
+
- Amounts must be integers. Floats, NaN, Infinity and bools are rejected.
|
|
26
|
+
|
|
27
|
+
### Removed
|
|
28
|
+
- Plans, slots and waitlist, admin, Stripe and PayPal top-ups, email/password login and registration, human MFA, `connect_with_credentials`, `complete_mfa`, `proxy.get_status`, the legacy `dc-`/`residential-`/`auto-` username prefixes, `state-`/`city-`/`asn-` targeting, and all hardcoded prices.
|
|
29
|
+
- The `respx` dev dependency. Tests use `httpx.MockTransport`.
|
|
30
|
+
|
|
31
|
+
## [1.0.0] - 2026-02-19
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
- Initial release of the Dominus Node SDK for Python.
|
|
35
|
+
- Async client (`AsyncDominusNodeClient`) built on `httpx` for asyncio-based usage.
|
|
36
|
+
- Sync client (`DominusNodeClient`) for synchronous usage with identical API surface.
|
|
37
|
+
- Both clients support context manager protocol (`with` / `async with`) for automatic cleanup.
|
|
38
|
+
- Requires Python 3.9+.
|
|
39
|
+
- Authentication via API key (`connect_with_key`), email/password with MFA support (`connect_with_credentials`, `complete_mfa`), and pre-authenticated JWT tokens (`connect_with_tokens`).
|
|
40
|
+
- `AuthResource` / `AsyncAuthResource` for registration, login, MFA setup/verification, password reset, email verification, and account profile management.
|
|
41
|
+
- `WalletResource` / `AsyncWalletResource` for balance retrieval, transaction history, Stripe checkout session creation, and crypto invoice creation supporting 11 currencies (BTC, ETH, LTC, XMR, ZEC, USDC, SOL, USDT, DAI, BNB, LINK).
|
|
42
|
+
- `UsageResource` / `AsyncUsageResource` for usage summaries, daily breakdown, top hosts, and CSV export.
|
|
43
|
+
- `KeysResource` / `AsyncKeysResource` for creating, listing, and revoking API keys.
|
|
44
|
+
- `PlansResource` / `AsyncPlansResource` for listing available plans, retrieving the current plan, and changing plans.
|
|
45
|
+
- `ProxyResource` / `AsyncProxyResource` for building proxy URLs with geo-targeting (country, state, city, ASN, session ID) and proxy health/status monitoring.
|
|
46
|
+
- `SessionsResource` / `AsyncSessionsResource` for listing active proxy sessions.
|
|
47
|
+
- `AgenticWalletResource` / `AsyncAgenticWalletResource` for creating, funding, listing, querying transactions, freezing, unfreezing, and deleting agentic sub-wallets.
|
|
48
|
+
- `TeamsResource` / `AsyncTeamsResource` with 18 methods for team CRUD, shared wallet management, member management (add, remove, update role), invite management (create, list, cancel, accept), team API key creation and revocation, and team usage and transaction queries.
|
|
49
|
+
- `SlotsResource` / `AsyncSlotsResource` for checking alpha slot availability, joining the waitlist, and checking waitlist position.
|
|
50
|
+
- `AdminResource` / `AsyncAdminResource` for admin-only operations including user management, system stats, revenue reporting, and provider statistics.
|
|
51
|
+
- `TokenManager` / `AsyncTokenManager` with automatic JWT access token refresh using rotating refresh tokens (15-minute access / 7-day refresh).
|
|
52
|
+
- Rate limit handling with exponential backoff, jitter (plus/minus 10%), 10-second max wait cap, and 100ms minimum wait.
|
|
53
|
+
- Typed error hierarchy: `DominusNodeError`, `AuthenticationError`, `AuthorizationError`, `ValidationError`, `NotFoundError`, `ConflictError`, `RateLimitError`, `InsufficientBalanceError`, `ProxyError`, `NetworkError`, `ServerError`.
|
|
54
|
+
- Credential safety: automatic zeroization on `disconnect()`, disabled auto-redirects, 10MB response size limit.
|
|
55
|
+
- `SyncHttpClient` / `AsyncHttpClient` with configurable base URL and automatic `Authorization` header injection.
|
|
56
|
+
- Full type annotations throughout using Python typing module.
|
|
57
|
+
|
|
58
|
+
[1.0.0]: https://github.com/Dominus-Node/dominusnode-python/releases/tag/v1.0.0
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dominus Node
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# sdist contents: package source, metadata and docs only (see scripts/release/check-artifacts.mjs)
|
|
2
|
+
include README.md
|
|
3
|
+
include CHANGELOG.md
|
|
4
|
+
include LICENSE
|
|
5
|
+
prune tests
|
|
6
|
+
exclude conftest.py
|
|
7
|
+
prune examples
|
|
8
|
+
global-exclude *.py[cod] __pycache__ *.map .env .env.* *.log
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dominusnode
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: Official DominusNode SDK for Python: AI-agent relay network (proxy, nodes, credits, payouts)
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/0xcircuitbreaker/DomiNode/tree/master/sdks/python
|
|
7
|
+
Project-URL: Repository, https://github.com/0xcircuitbreaker/DomiNode
|
|
8
|
+
Project-URL: Issues, https://github.com/0xcircuitbreaker/DomiNode/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/0xcircuitbreaker/DomiNode/blob/master/sdks/python/CHANGELOG.md
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: httpx>=0.24.0
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
16
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# dominusnode — DominusNode Python SDK (v2)
|
|
20
|
+
|
|
21
|
+
Python client for the DominusNode AI-agent relay network: proxy through relay nodes,
|
|
22
|
+
register your own nodes, earn credits and withdraw payouts. It implements
|
|
23
|
+
[`sdks/SDK_SURFACE.md`](../SDK_SURFACE.md) (15 resources, 71 methods), with the Node SDK as
|
|
24
|
+
the reference implementation.
|
|
25
|
+
|
|
26
|
+
- Sync `DominusNodeClient` and asyncio `AsyncDominusNodeClient` with the same methods
|
|
27
|
+
- One dependency (`httpx`), no crypto dependency: you sign through a callback
|
|
28
|
+
- Python 3.9+, type hints, PEP 561
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install dominusnode
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Defaults: API `https://api.dominusnode.daedalusdevelopmentgroup.com`, relay gateway `proxy.dominusnode.daedalusdevelopmentgroup.com` (HTTP proxy :8080, SOCKS5 :1080). Both can be overridden in the client configuration.
|
|
35
|
+
|
|
36
|
+
## Quick start
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
import os
|
|
40
|
+
from dominusnode import DominusNodeClient
|
|
41
|
+
|
|
42
|
+
with DominusNodeClient() as dn:
|
|
43
|
+
dn.connect_with_key(os.environ["DOMINUSNODE_API_KEY"]) # dn_live_... / dn_test_...
|
|
44
|
+
|
|
45
|
+
print(dn.network.pricing()) # live per-GB prices (µUSD); the SDK hardcodes no prices
|
|
46
|
+
res = dn.proxy.fetch("https://example.com", country="US", ip_class="residential")
|
|
47
|
+
print(res.status, res.text()[:200])
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Async:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from dominusnode import AsyncDominusNodeClient
|
|
54
|
+
|
|
55
|
+
async with AsyncDominusNodeClient() as dn:
|
|
56
|
+
await dn.connect_with_key(key)
|
|
57
|
+
stats = await dn.network.stats()
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Proxy
|
|
61
|
+
|
|
62
|
+
Routing flags go in the proxy **username**, the API key in the **password**:
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
dn.proxy.build_username(country="DE", session_id="abc123") # "country-DE-session-abc123"
|
|
66
|
+
url = dn.proxy.build_url(country="US", ip_class="dc") # http://country-US-class-dc:<key>@proxy.dominusnode.daedalusdevelopmentgroup.com:8080
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
`build_url` returns a URL that **contains your API key: do not log it.**
|
|
70
|
+
|
|
71
|
+
Flags: `country` (ISO-2; OFAC countries CU IR KP RU SY are refused), `ip_class`
|
|
72
|
+
(`residential`/`dc`/`mobile`), `session_id` (sticky, 1-64 alphanumerics),
|
|
73
|
+
`agentic_wallet_id` (UUID, spend from an agentic wallet), `allow_http` (`allowhttp-1`).
|
|
74
|
+
With no flags the username is `relay`.
|
|
75
|
+
|
|
76
|
+
`proxy.fetch(url, ...)` sends GET or HEAD only. Before it opens a connection it checks the
|
|
77
|
+
URL: http(s) only, ports 80/443, no userinfo, no local or private hosts, including
|
|
78
|
+
decimal/hex/octal IPv4 forms and IPv6 forms that embed IPv4. It then resolves the hostname
|
|
79
|
+
and refuses it if *any* address is private (DNS-rebinding check). https goes through a
|
|
80
|
+
CONNECT tunnel with full TLS verification; `http://` needs `allow_http=True`. Redirects are
|
|
81
|
+
returned as they are, not followed, and the body is capped at 10 MB (`truncated=True` when
|
|
82
|
+
cut).
|
|
83
|
+
|
|
84
|
+
## Signers (EIP-191)
|
|
85
|
+
|
|
86
|
+
Node registration, withdrawals, payout-wallet changes and wallet sign-in need a signature from
|
|
87
|
+
your wallet. Pass any object with an `address` and a `sign_message(message) -> "0x…"` method that
|
|
88
|
+
performs `personal_sign`:
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from eth_account import Account
|
|
92
|
+
from eth_account.messages import encode_defunct
|
|
93
|
+
|
|
94
|
+
acct = Account.from_key(private_key)
|
|
95
|
+
|
|
96
|
+
class Signer:
|
|
97
|
+
address = acct.address
|
|
98
|
+
def sign_message(self, message: str) -> str:
|
|
99
|
+
sig = acct.sign_message(encode_defunct(text=message)).signature.hex()
|
|
100
|
+
return sig if sig.startswith("0x") else "0x" + sig
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
With `AsyncDominusNodeClient`, `sign_message` may be `async def`.
|
|
104
|
+
|
|
105
|
+
The SDK never signs a server string without checking it. For every signed flow it builds the
|
|
106
|
+
expected message itself and compares it byte for byte with the server's. If they differ, it
|
|
107
|
+
raises `ProtocolError` and the signer is never called.
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
node = dn.nodes.register(signer, node_pubkey=ed25519_pub_hex, max_streams=8)
|
|
111
|
+
node_key = node["nodeKey"].reveal() # Secret, shown once
|
|
112
|
+
|
|
113
|
+
dn.payout_wallet.set("0xYourPayoutAddress", signer) # first set
|
|
114
|
+
dn.payout_wallet.set("0xNew...", signer, old_wallet_signer=old) # change: old wallet co-signs
|
|
115
|
+
|
|
116
|
+
r = dn.credits.withdraw(5_000_000, signer) # µUSD (int or digit string, never float); $5
|
|
117
|
+
r["idempotencyKey"] # reuse it to retry safely
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Money
|
|
121
|
+
|
|
122
|
+
- Server money values are `{"musd": "<integer µUSD>", "usd": "<6 decimals>"}`; 1 USD = 1,000,000 µUSD.
|
|
123
|
+
- µUSD inputs accept an `int` or a digit string and are sent as decimal strings. Floats, NaN and Infinity are rejected.
|
|
124
|
+
- `*_cents` inputs are integers with `0 < x <= 2,147,483,647`, checked before any request is sent.
|
|
125
|
+
|
|
126
|
+
## Resources
|
|
127
|
+
|
|
128
|
+
| Resource | Methods |
|
|
129
|
+
|---|---|
|
|
130
|
+
| `auth` | `verify_key`, `refresh`, `logout`, `me` |
|
|
131
|
+
| `wallet_auth` | `challenge`, `verify`, `sign_in`, `link` |
|
|
132
|
+
| `keys` | `create`, `list`, `revoke` |
|
|
133
|
+
| `wallet` | `get_balance`, `get_transactions`, `get_forecast`, `top_up_crypto`, `get_crypto_status` |
|
|
134
|
+
| `agentic_wallets` | `create`, `list`, `get`, `fund`, `update_wallet_policy`, `transactions`, `freeze`, `unfreeze`, `delete` |
|
|
135
|
+
| `teams` | 18 methods: team CRUD, wallet, members, invites, keys (`create_key` … `revoke_key`) |
|
|
136
|
+
| `usage` | `get`, `get_daily`, `get_top_hosts`, `export_csv` (`from_`/`to` -> `since`/`until`) |
|
|
137
|
+
| `sessions` | `get_active` (id, startedAt and status only; never IPs), `report` |
|
|
138
|
+
| `x402` | `get_info` |
|
|
139
|
+
| `network` | `policy`, `pricing`, `stats` |
|
|
140
|
+
| `nodes` | `register_challenge`, `register`, `list`, `revoke`, `update_caps`, `tier` |
|
|
141
|
+
| `credits` | `balance`, `transactions`, `convert`, `withdraw` |
|
|
142
|
+
| `payout_wallet` | `get`, `set` |
|
|
143
|
+
| `payouts` | `list` |
|
|
144
|
+
| `proxy` | `build_username`, `build_url`, `fetch`, `get_health`, `get_config` |
|
|
145
|
+
|
|
146
|
+
Client members: `connect_with_key(api_key)` (returns `{"mfaRequired": bool, "userId"?}`),
|
|
147
|
+
`disconnect()` and `is_connected`. Results are the server's JSON as dicts with camelCase keys.
|
|
148
|
+
|
|
149
|
+
Not in the SDK: plans, slots, admin, Stripe and PayPal top-ups, email/password and human MFA.
|
|
150
|
+
Use the dashboard for those.
|
|
151
|
+
|
|
152
|
+
## Errors
|
|
153
|
+
|
|
154
|
+
`DominusNodeError` (`message`, `status_code`, `code`, `details`) and its subclasses:
|
|
155
|
+
`ValidationError` (HTTP 400, and client-side checks with `code="INVALID_ARGUMENT"`),
|
|
156
|
+
`AuthenticationError`, `InsufficientBalanceError`, `AuthorizationError`, `NotFoundError`,
|
|
157
|
+
`ConflictError`, `RateLimitError` (`retry_after_seconds`), `ServerError`, `NetworkError`,
|
|
158
|
+
`ProtocolError`, `ProxyError`. Error messages are scrubbed of `dn_live_`/`dn_test_`/`dn_node_`/
|
|
159
|
+
`dn_proxy_` keys and JWTs.
|
|
160
|
+
|
|
161
|
+
## Security behaviour
|
|
162
|
+
|
|
163
|
+
- Redirects are never followed. API responses are capped at 10 MB.
|
|
164
|
+
- On 429 the SDK retries once, waiting `min(Retry-After, 10 s)` ±10 % (at least 100 ms).
|
|
165
|
+
- On 401 it refreshes the JWT once. `/v1` routes send the raw API key and are not refreshed.
|
|
166
|
+
- `Secret` (new API keys, team keys, node keys) prints and serialises as `[REDACTED]`. Use `json.dumps(obj, default=dominusnode.json_default)`.
|
|
167
|
+
- `disconnect()` logs out (best effort), then clears the API key and both tokens.
|
|
168
|
+
|
|
169
|
+
## Development
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
pip install -e '.[dev]'
|
|
173
|
+
pytest
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
`tests/fixtures/signed_messages.json` holds the three signed messages as produced by the Node
|
|
177
|
+
SDK builders. `tests/test_signers.py` checks the Python builders against it byte for byte.
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# dominusnode — DominusNode Python SDK (v2)
|
|
2
|
+
|
|
3
|
+
Python client for the DominusNode AI-agent relay network: proxy through relay nodes,
|
|
4
|
+
register your own nodes, earn credits and withdraw payouts. It implements
|
|
5
|
+
[`sdks/SDK_SURFACE.md`](../SDK_SURFACE.md) (15 resources, 71 methods), with the Node SDK as
|
|
6
|
+
the reference implementation.
|
|
7
|
+
|
|
8
|
+
- Sync `DominusNodeClient` and asyncio `AsyncDominusNodeClient` with the same methods
|
|
9
|
+
- One dependency (`httpx`), no crypto dependency: you sign through a callback
|
|
10
|
+
- Python 3.9+, type hints, PEP 561
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install dominusnode
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Defaults: API `https://api.dominusnode.daedalusdevelopmentgroup.com`, relay gateway `proxy.dominusnode.daedalusdevelopmentgroup.com` (HTTP proxy :8080, SOCKS5 :1080). Both can be overridden in the client configuration.
|
|
17
|
+
|
|
18
|
+
## Quick start
|
|
19
|
+
|
|
20
|
+
```python
|
|
21
|
+
import os
|
|
22
|
+
from dominusnode import DominusNodeClient
|
|
23
|
+
|
|
24
|
+
with DominusNodeClient() as dn:
|
|
25
|
+
dn.connect_with_key(os.environ["DOMINUSNODE_API_KEY"]) # dn_live_... / dn_test_...
|
|
26
|
+
|
|
27
|
+
print(dn.network.pricing()) # live per-GB prices (µUSD); the SDK hardcodes no prices
|
|
28
|
+
res = dn.proxy.fetch("https://example.com", country="US", ip_class="residential")
|
|
29
|
+
print(res.status, res.text()[:200])
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Async:
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from dominusnode import AsyncDominusNodeClient
|
|
36
|
+
|
|
37
|
+
async with AsyncDominusNodeClient() as dn:
|
|
38
|
+
await dn.connect_with_key(key)
|
|
39
|
+
stats = await dn.network.stats()
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Proxy
|
|
43
|
+
|
|
44
|
+
Routing flags go in the proxy **username**, the API key in the **password**:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
dn.proxy.build_username(country="DE", session_id="abc123") # "country-DE-session-abc123"
|
|
48
|
+
url = dn.proxy.build_url(country="US", ip_class="dc") # http://country-US-class-dc:<key>@proxy.dominusnode.daedalusdevelopmentgroup.com:8080
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
`build_url` returns a URL that **contains your API key: do not log it.**
|
|
52
|
+
|
|
53
|
+
Flags: `country` (ISO-2; OFAC countries CU IR KP RU SY are refused), `ip_class`
|
|
54
|
+
(`residential`/`dc`/`mobile`), `session_id` (sticky, 1-64 alphanumerics),
|
|
55
|
+
`agentic_wallet_id` (UUID, spend from an agentic wallet), `allow_http` (`allowhttp-1`).
|
|
56
|
+
With no flags the username is `relay`.
|
|
57
|
+
|
|
58
|
+
`proxy.fetch(url, ...)` sends GET or HEAD only. Before it opens a connection it checks the
|
|
59
|
+
URL: http(s) only, ports 80/443, no userinfo, no local or private hosts, including
|
|
60
|
+
decimal/hex/octal IPv4 forms and IPv6 forms that embed IPv4. It then resolves the hostname
|
|
61
|
+
and refuses it if *any* address is private (DNS-rebinding check). https goes through a
|
|
62
|
+
CONNECT tunnel with full TLS verification; `http://` needs `allow_http=True`. Redirects are
|
|
63
|
+
returned as they are, not followed, and the body is capped at 10 MB (`truncated=True` when
|
|
64
|
+
cut).
|
|
65
|
+
|
|
66
|
+
## Signers (EIP-191)
|
|
67
|
+
|
|
68
|
+
Node registration, withdrawals, payout-wallet changes and wallet sign-in need a signature from
|
|
69
|
+
your wallet. Pass any object with an `address` and a `sign_message(message) -> "0x…"` method that
|
|
70
|
+
performs `personal_sign`:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
from eth_account import Account
|
|
74
|
+
from eth_account.messages import encode_defunct
|
|
75
|
+
|
|
76
|
+
acct = Account.from_key(private_key)
|
|
77
|
+
|
|
78
|
+
class Signer:
|
|
79
|
+
address = acct.address
|
|
80
|
+
def sign_message(self, message: str) -> str:
|
|
81
|
+
sig = acct.sign_message(encode_defunct(text=message)).signature.hex()
|
|
82
|
+
return sig if sig.startswith("0x") else "0x" + sig
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
With `AsyncDominusNodeClient`, `sign_message` may be `async def`.
|
|
86
|
+
|
|
87
|
+
The SDK never signs a server string without checking it. For every signed flow it builds the
|
|
88
|
+
expected message itself and compares it byte for byte with the server's. If they differ, it
|
|
89
|
+
raises `ProtocolError` and the signer is never called.
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
node = dn.nodes.register(signer, node_pubkey=ed25519_pub_hex, max_streams=8)
|
|
93
|
+
node_key = node["nodeKey"].reveal() # Secret, shown once
|
|
94
|
+
|
|
95
|
+
dn.payout_wallet.set("0xYourPayoutAddress", signer) # first set
|
|
96
|
+
dn.payout_wallet.set("0xNew...", signer, old_wallet_signer=old) # change: old wallet co-signs
|
|
97
|
+
|
|
98
|
+
r = dn.credits.withdraw(5_000_000, signer) # µUSD (int or digit string, never float); $5
|
|
99
|
+
r["idempotencyKey"] # reuse it to retry safely
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Money
|
|
103
|
+
|
|
104
|
+
- Server money values are `{"musd": "<integer µUSD>", "usd": "<6 decimals>"}`; 1 USD = 1,000,000 µUSD.
|
|
105
|
+
- µUSD inputs accept an `int` or a digit string and are sent as decimal strings. Floats, NaN and Infinity are rejected.
|
|
106
|
+
- `*_cents` inputs are integers with `0 < x <= 2,147,483,647`, checked before any request is sent.
|
|
107
|
+
|
|
108
|
+
## Resources
|
|
109
|
+
|
|
110
|
+
| Resource | Methods |
|
|
111
|
+
|---|---|
|
|
112
|
+
| `auth` | `verify_key`, `refresh`, `logout`, `me` |
|
|
113
|
+
| `wallet_auth` | `challenge`, `verify`, `sign_in`, `link` |
|
|
114
|
+
| `keys` | `create`, `list`, `revoke` |
|
|
115
|
+
| `wallet` | `get_balance`, `get_transactions`, `get_forecast`, `top_up_crypto`, `get_crypto_status` |
|
|
116
|
+
| `agentic_wallets` | `create`, `list`, `get`, `fund`, `update_wallet_policy`, `transactions`, `freeze`, `unfreeze`, `delete` |
|
|
117
|
+
| `teams` | 18 methods: team CRUD, wallet, members, invites, keys (`create_key` … `revoke_key`) |
|
|
118
|
+
| `usage` | `get`, `get_daily`, `get_top_hosts`, `export_csv` (`from_`/`to` -> `since`/`until`) |
|
|
119
|
+
| `sessions` | `get_active` (id, startedAt and status only; never IPs), `report` |
|
|
120
|
+
| `x402` | `get_info` |
|
|
121
|
+
| `network` | `policy`, `pricing`, `stats` |
|
|
122
|
+
| `nodes` | `register_challenge`, `register`, `list`, `revoke`, `update_caps`, `tier` |
|
|
123
|
+
| `credits` | `balance`, `transactions`, `convert`, `withdraw` |
|
|
124
|
+
| `payout_wallet` | `get`, `set` |
|
|
125
|
+
| `payouts` | `list` |
|
|
126
|
+
| `proxy` | `build_username`, `build_url`, `fetch`, `get_health`, `get_config` |
|
|
127
|
+
|
|
128
|
+
Client members: `connect_with_key(api_key)` (returns `{"mfaRequired": bool, "userId"?}`),
|
|
129
|
+
`disconnect()` and `is_connected`. Results are the server's JSON as dicts with camelCase keys.
|
|
130
|
+
|
|
131
|
+
Not in the SDK: plans, slots, admin, Stripe and PayPal top-ups, email/password and human MFA.
|
|
132
|
+
Use the dashboard for those.
|
|
133
|
+
|
|
134
|
+
## Errors
|
|
135
|
+
|
|
136
|
+
`DominusNodeError` (`message`, `status_code`, `code`, `details`) and its subclasses:
|
|
137
|
+
`ValidationError` (HTTP 400, and client-side checks with `code="INVALID_ARGUMENT"`),
|
|
138
|
+
`AuthenticationError`, `InsufficientBalanceError`, `AuthorizationError`, `NotFoundError`,
|
|
139
|
+
`ConflictError`, `RateLimitError` (`retry_after_seconds`), `ServerError`, `NetworkError`,
|
|
140
|
+
`ProtocolError`, `ProxyError`. Error messages are scrubbed of `dn_live_`/`dn_test_`/`dn_node_`/
|
|
141
|
+
`dn_proxy_` keys and JWTs.
|
|
142
|
+
|
|
143
|
+
## Security behaviour
|
|
144
|
+
|
|
145
|
+
- Redirects are never followed. API responses are capped at 10 MB.
|
|
146
|
+
- On 429 the SDK retries once, waiting `min(Retry-After, 10 s)` ±10 % (at least 100 ms).
|
|
147
|
+
- On 401 it refreshes the JWT once. `/v1` routes send the raw API key and are not refreshed.
|
|
148
|
+
- `Secret` (new API keys, team keys, node keys) prints and serialises as `[REDACTED]`. Use `json.dumps(obj, default=dominusnode.json_default)`.
|
|
149
|
+
- `disconnect()` logs out (best effort), then clears the API key and both tokens.
|
|
150
|
+
|
|
151
|
+
## Development
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
pip install -e '.[dev]'
|
|
155
|
+
pytest
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
`tests/fixtures/signed_messages.json` holds the three signed messages as produced by the Node
|
|
159
|
+
SDK builders. `tests/test_signers.py` checks the Python builders against it byte for byte.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Official DominusNode SDK for Python: AI-agent relay network (proxy, nodes, credits, payouts)."""
|
|
2
|
+
|
|
3
|
+
from .client import AsyncDominusNodeClient, DominusNodeClient
|
|
4
|
+
from .constants import (
|
|
5
|
+
DEFAULT_BASE_URL,
|
|
6
|
+
DEFAULT_HTTP_PROXY_PORT,
|
|
7
|
+
DEFAULT_PROXY_HOST,
|
|
8
|
+
DEFAULT_SOCKS5_PROXY_PORT,
|
|
9
|
+
MAX_AMOUNT_CENTS,
|
|
10
|
+
MAX_RESPONSE_BYTES,
|
|
11
|
+
SDK_VERSION,
|
|
12
|
+
USER_AGENT,
|
|
13
|
+
)
|
|
14
|
+
from .errors import (
|
|
15
|
+
AuthenticationError,
|
|
16
|
+
AuthorizationError,
|
|
17
|
+
ConflictError,
|
|
18
|
+
DominusNodeError,
|
|
19
|
+
InsufficientBalanceError,
|
|
20
|
+
NetworkError,
|
|
21
|
+
NotFoundError,
|
|
22
|
+
ProtocolError,
|
|
23
|
+
ProxyError,
|
|
24
|
+
RateLimitError,
|
|
25
|
+
ServerError,
|
|
26
|
+
ValidationError,
|
|
27
|
+
scrub_credentials,
|
|
28
|
+
)
|
|
29
|
+
from .messages import build_attestation_message, build_payout_wallet_message, build_withdraw_message
|
|
30
|
+
from .proxy_fetch import GatewayTls, ProxyFetchResponse, build_proxy_username
|
|
31
|
+
from .secret import Secret, json_default
|
|
32
|
+
from .signer import Signer
|
|
33
|
+
from .ssrf import is_private_ip, validate_target_url
|
|
34
|
+
|
|
35
|
+
__version__ = SDK_VERSION
|
|
36
|
+
|
|
37
|
+
__all__ = [
|
|
38
|
+
"DominusNodeClient", "AsyncDominusNodeClient", "Signer", "Secret", "json_default",
|
|
39
|
+
"build_proxy_username", "ProxyFetchResponse", "GatewayTls", "is_private_ip", "validate_target_url",
|
|
40
|
+
"build_attestation_message", "build_payout_wallet_message", "build_withdraw_message",
|
|
41
|
+
"DominusNodeError", "AuthenticationError", "AuthorizationError", "RateLimitError", "InsufficientBalanceError",
|
|
42
|
+
"ValidationError", "NotFoundError", "ConflictError", "ServerError", "NetworkError", "ProtocolError", "ProxyError",
|
|
43
|
+
"scrub_credentials", "SDK_VERSION", "USER_AGENT", "DEFAULT_BASE_URL", "DEFAULT_PROXY_HOST",
|
|
44
|
+
"DEFAULT_HTTP_PROXY_PORT", "DEFAULT_SOCKS5_PROXY_PORT", "MAX_RESPONSE_BYTES", "MAX_AMOUNT_CENTS", "__version__",
|
|
45
|
+
]
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"""Sans-I/O core shared by the sync and async clients (internal).
|
|
2
|
+
|
|
3
|
+
Each resource method is written once as a generator that yields operations
|
|
4
|
+
(an API ``Request``, a ``Sign`` call or a blocking ``Call``) and receives their
|
|
5
|
+
results. ``drive_sync`` / ``drive_async`` execute those operations, so the sync
|
|
6
|
+
and async clients expose identical behaviour from a single implementation.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import asyncio
|
|
12
|
+
import functools
|
|
13
|
+
import inspect
|
|
14
|
+
from dataclasses import dataclass
|
|
15
|
+
from typing import Any, Callable, Dict, Generator, Tuple, Type, TypeVar
|
|
16
|
+
|
|
17
|
+
from .errors import ProtocolError
|
|
18
|
+
from .http_client import AsyncHttpClient, Request, SyncHttpClient
|
|
19
|
+
|
|
20
|
+
Op = Any
|
|
21
|
+
Gen = Generator[Op, Any, Any]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass
|
|
25
|
+
class Sign:
|
|
26
|
+
signer: Any
|
|
27
|
+
message: str
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass
|
|
31
|
+
class Call:
|
|
32
|
+
"""Blocking work (PoW, socket I/O). Sync: called inline. Async: run in a worker thread."""
|
|
33
|
+
|
|
34
|
+
fn: Callable[..., Any]
|
|
35
|
+
args: Tuple[Any, ...] = ()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _exec_sync(http: SyncHttpClient, op: Op) -> Any:
|
|
39
|
+
if isinstance(op, Request):
|
|
40
|
+
return http.request(op)
|
|
41
|
+
if isinstance(op, Sign):
|
|
42
|
+
result = op.signer.sign_message(op.message)
|
|
43
|
+
if inspect.isawaitable(result):
|
|
44
|
+
if hasattr(result, "close"):
|
|
45
|
+
result.close()
|
|
46
|
+
raise ProtocolError("sign_message returned an awaitable; use AsyncDominusNodeClient for async signers")
|
|
47
|
+
return result
|
|
48
|
+
if isinstance(op, Call):
|
|
49
|
+
return op.fn(*op.args)
|
|
50
|
+
raise TypeError(f"unknown op {op!r}")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
async def _exec_async(http: AsyncHttpClient, op: Op) -> Any:
|
|
54
|
+
if isinstance(op, Request):
|
|
55
|
+
return await http.request(op)
|
|
56
|
+
if isinstance(op, Sign):
|
|
57
|
+
result = op.signer.sign_message(op.message)
|
|
58
|
+
if inspect.isawaitable(result):
|
|
59
|
+
result = await result
|
|
60
|
+
return result
|
|
61
|
+
if isinstance(op, Call):
|
|
62
|
+
return await asyncio.to_thread(op.fn, *op.args)
|
|
63
|
+
raise TypeError(f"unknown op {op!r}")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def drive_sync(http: SyncHttpClient, gen: Gen) -> Any:
|
|
67
|
+
value: Any = None
|
|
68
|
+
exc: Any = None
|
|
69
|
+
while True:
|
|
70
|
+
try:
|
|
71
|
+
op = gen.throw(exc) if exc is not None else gen.send(value)
|
|
72
|
+
except StopIteration as stop:
|
|
73
|
+
return stop.value
|
|
74
|
+
try:
|
|
75
|
+
value, exc = _exec_sync(http, op), None
|
|
76
|
+
except Exception as e: # noqa: BLE001 - delivered into the generator
|
|
77
|
+
value, exc = None, e
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
async def drive_async(http: AsyncHttpClient, gen: Gen) -> Any:
|
|
81
|
+
value: Any = None
|
|
82
|
+
exc: Any = None
|
|
83
|
+
while True:
|
|
84
|
+
try:
|
|
85
|
+
op = gen.throw(exc) if exc is not None else gen.send(value)
|
|
86
|
+
except StopIteration as stop:
|
|
87
|
+
return stop.value
|
|
88
|
+
try:
|
|
89
|
+
value, exc = await _exec_async(http, op), None
|
|
90
|
+
except Exception as e: # noqa: BLE001
|
|
91
|
+
value, exc = None, e
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
T = TypeVar("T")
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _sync_method(fn: Callable[..., Gen]) -> Callable[..., Any]:
|
|
98
|
+
@functools.wraps(fn)
|
|
99
|
+
def wrapper(self: Any, *args: Any, **kwargs: Any) -> Any:
|
|
100
|
+
return drive_sync(self._http, fn(self, *args, **kwargs))
|
|
101
|
+
|
|
102
|
+
return wrapper
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _async_method(fn: Callable[..., Gen]) -> Callable[..., Any]:
|
|
106
|
+
@functools.wraps(fn)
|
|
107
|
+
async def wrapper(self: Any, *args: Any, **kwargs: Any) -> Any:
|
|
108
|
+
return await drive_async(self._http, fn(self, *args, **kwargs))
|
|
109
|
+
|
|
110
|
+
return wrapper
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def make_variants(core: Type[T]) -> Tuple[Type[T], Type[T]]:
|
|
114
|
+
"""Build (SyncResource, AsyncResource) subclasses: every public generator method becomes a plain/async method."""
|
|
115
|
+
name = core.__name__.lstrip("_")
|
|
116
|
+
sync_ns: Dict[str, Any] = {"__doc__": core.__doc__, "__module__": core.__module__}
|
|
117
|
+
async_ns: Dict[str, Any] = {"__doc__": core.__doc__, "__module__": core.__module__}
|
|
118
|
+
for attr, value in vars(core).items():
|
|
119
|
+
if not attr.startswith("_") and inspect.isgeneratorfunction(value):
|
|
120
|
+
sync_ns[attr] = _sync_method(value)
|
|
121
|
+
async_ns[attr] = _async_method(value)
|
|
122
|
+
return type(name, (core,), sync_ns), type("Async" + name, (core,), async_ns) # type: ignore[return-value]
|