dfns-sdk 0.0.0.dev0__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.
- dfns_sdk-0.0.0.dev0/.github/workflows/publish.yml +52 -0
- dfns_sdk-0.0.0.dev0/.gitignore +6 -0
- dfns_sdk-0.0.0.dev0/LICENSE +21 -0
- dfns_sdk-0.0.0.dev0/PKG-INFO +191 -0
- dfns_sdk-0.0.0.dev0/README.md +164 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/__init__.py +24 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/_internal/__init__.py +5 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/_internal/http_client.py +395 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/auth.py +137 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/base_auth_api.py +129 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/client.py +81 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/delegated_client.py +97 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/__init__.py +47 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/agreements/__init__.py +7 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/agreements/client.py +55 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/agreements/delegated_client.py +95 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/agreements/types.py +20 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/allocations/__init__.py +7 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/allocations/client.py +118 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/allocations/delegated_client.py +187 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/allocations/types.py +69 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/auth/__init__.py +7 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/auth/client.py +1215 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/auth/delegated_client.py +1825 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/auth/types.py +702 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/exchanges/__init__.py +7 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/exchanges/client.py +209 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/exchanges/delegated_client.py +341 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/exchanges/types.py +96 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/fee_sponsors/__init__.py +7 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/fee_sponsors/client.py +161 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/fee_sponsors/delegated_client.py +287 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/fee_sponsors/types.py +89 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/keys/__init__.py +7 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/keys/client.py +310 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/keys/delegated_client.py +518 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/keys/types.py +229 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/networks/__init__.py +7 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/networks/client.py +176 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/networks/delegated_client.py +274 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/networks/types.py +77 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/permissions/__init__.py +7 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/permissions/client.py +185 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/permissions/delegated_client.py +344 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/permissions/types.py +107 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/policies/__init__.py +7 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/policies/client.py +187 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/policies/delegated_client.py +311 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/policies/types.py +70 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/signers/__init__.py +7 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/signers/client.py +45 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/signers/delegated_client.py +56 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/signers/types.py +13 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/staking/__init__.py +7 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/staking/client.py +142 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/staking/delegated_client.py +211 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/staking/types.py +64 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/swaps/__init__.py +7 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/swaps/client.py +118 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/swaps/delegated_client.py +157 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/swaps/types.py +99 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/wallets/__init__.py +7 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/wallets/client.py +805 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/wallets/delegated_client.py +1231 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/wallets/types.py +534 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/webhooks/__init__.py +7 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/webhooks/client.py +193 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/webhooks/delegated_client.py +320 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/generated/webhooks/types.py +101 -0
- dfns_sdk-0.0.0.dev0/dfns_sdk/types.py +72 -0
- dfns_sdk-0.0.0.dev0/pyproject.toml +52 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
name: Build distribution
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v6
|
|
14
|
+
with:
|
|
15
|
+
persist-credentials: false
|
|
16
|
+
|
|
17
|
+
- name: Set up Python
|
|
18
|
+
uses: actions/setup-python@v6
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.x"
|
|
21
|
+
|
|
22
|
+
- name: Install pypa/build
|
|
23
|
+
run: >-
|
|
24
|
+
python3 -m
|
|
25
|
+
pip install
|
|
26
|
+
build
|
|
27
|
+
--user
|
|
28
|
+
- name: Build a binary wheel and a source tarball
|
|
29
|
+
run: python3 -m build
|
|
30
|
+
- name: Store the distribution packages
|
|
31
|
+
uses: actions/upload-artifact@v5
|
|
32
|
+
with:
|
|
33
|
+
name: python-package-distributions
|
|
34
|
+
path: dist/
|
|
35
|
+
|
|
36
|
+
publish:
|
|
37
|
+
name: Publish to PyPI
|
|
38
|
+
needs: build
|
|
39
|
+
runs-on: ubuntu-latest
|
|
40
|
+
environment:
|
|
41
|
+
name: pypi
|
|
42
|
+
url: https://pypi.org/p/dfns_sdk
|
|
43
|
+
permissions:
|
|
44
|
+
id-token: write
|
|
45
|
+
steps:
|
|
46
|
+
- name: Download all the dists
|
|
47
|
+
uses: actions/download-artifact@v6
|
|
48
|
+
with:
|
|
49
|
+
name: python-package-distributions
|
|
50
|
+
path: dist/
|
|
51
|
+
- name: Publish distribution 📦 to PyPI
|
|
52
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dfns
|
|
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,191 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dfns_sdk
|
|
3
|
+
Version: 0.0.0.dev0
|
|
4
|
+
Summary: Dfns Python SDK - Auto-generated from OpenAPI specification
|
|
5
|
+
Project-URL: Documentation, https://docs.dfns.co
|
|
6
|
+
Project-URL: Repository, https://github.com/dfns/dfns-sdk-python
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Typing :: Typed
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Requires-Dist: cryptography>=41.0.0
|
|
20
|
+
Requires-Dist: httpx>=0.25.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: mypy>=1.5.0; extra == 'dev'
|
|
23
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# Dfns Python SDK
|
|
29
|
+
|
|
30
|
+
Auto-generated Python SDK for the Dfns API.
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install dfns_sdk
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Or install from source:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install -e .
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from dfns_sdk import DfnsClient, DfnsClientConfig
|
|
48
|
+
|
|
49
|
+
# Configure the client
|
|
50
|
+
config = DfnsClientConfig(
|
|
51
|
+
auth_token="your-auth-token",
|
|
52
|
+
base_url="https://api.dfns.io", # Optional, this is the default
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
# Create the client
|
|
56
|
+
client = DfnsClient(config)
|
|
57
|
+
|
|
58
|
+
# Use the client
|
|
59
|
+
wallets = client.wallets.list_wallets()
|
|
60
|
+
print(wallets)
|
|
61
|
+
|
|
62
|
+
# Clean up
|
|
63
|
+
client.close()
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Using as a Context Manager
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from dfns_sdk import DfnsClient, DfnsClientConfig
|
|
70
|
+
|
|
71
|
+
config = DfnsClientConfig(
|
|
72
|
+
auth_token="your-auth-token",
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
with DfnsClient(config) as client:
|
|
76
|
+
wallets = client.wallets.list_wallets()
|
|
77
|
+
print(wallets)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## User Action Signing
|
|
81
|
+
|
|
82
|
+
Some operations (like creating wallets or signing transactions) require user action signing.
|
|
83
|
+
Configure a signer to enable these operations:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from dfns_sdk import DfnsClient, DfnsClientConfig, KeySigner
|
|
87
|
+
|
|
88
|
+
# Load your private key
|
|
89
|
+
with open("private_key.pem") as f:
|
|
90
|
+
private_key = f.read()
|
|
91
|
+
|
|
92
|
+
# Create a signer
|
|
93
|
+
signer = KeySigner(
|
|
94
|
+
credential_id="cr-xxx-xxx", # Your credential ID
|
|
95
|
+
private_key=private_key,
|
|
96
|
+
app_origin="https://app.dfns.io",
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
# Configure the client with the signer
|
|
100
|
+
config = DfnsClientConfig(
|
|
101
|
+
auth_token="your-auth-token",
|
|
102
|
+
signer=signer,
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
with DfnsClient(config) as client:
|
|
106
|
+
# Operations requiring signatures will automatically sign
|
|
107
|
+
wallet = client.wallets.create_wallet({
|
|
108
|
+
"network": "EthereumSepolia",
|
|
109
|
+
})
|
|
110
|
+
print(wallet)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Delegated Client (External Signing)
|
|
114
|
+
|
|
115
|
+
For service accounts that orchestrate signing externally (e.g., using a separate signing service),
|
|
116
|
+
use the `DfnsDelegatedClient`. This client separates user action signing into `*_init()` and
|
|
117
|
+
`*_complete()` method pairs:
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from dfns_sdk import DfnsDelegatedClient, DfnsDelegatedClientConfig
|
|
121
|
+
|
|
122
|
+
# Configure the delegated client (no signer needed)
|
|
123
|
+
config = DfnsDelegatedClientConfig(
|
|
124
|
+
auth_token="service-account-token",
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
with DfnsDelegatedClient(config) as client:
|
|
128
|
+
# Step 1: Initialize the action (returns challenge)
|
|
129
|
+
challenge = client.wallets.create_wallet_init(
|
|
130
|
+
body={"network": "EthereumSepolia"}
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
# Step 2: Sign challenge externally (your signing system)
|
|
134
|
+
# The challenge contains everything needed to sign:
|
|
135
|
+
# - challenge["challenge"]: The challenge string to sign
|
|
136
|
+
# - challenge["challengeIdentifier"]: Unique ID for this challenge
|
|
137
|
+
signed_assertion = your_external_signer.sign(challenge)
|
|
138
|
+
|
|
139
|
+
# Step 3: Complete the action with signed challenge
|
|
140
|
+
wallet = client.wallets.create_wallet_complete(
|
|
141
|
+
body={"network": "EthereumSepolia"},
|
|
142
|
+
signed_challenge={
|
|
143
|
+
"challengeIdentifier": challenge["challengeIdentifier"],
|
|
144
|
+
"firstFactor": signed_assertion,
|
|
145
|
+
},
|
|
146
|
+
)
|
|
147
|
+
print(wallet)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### When to Use Delegated vs Regular Client
|
|
151
|
+
|
|
152
|
+
| Use Case | Client Type |
|
|
153
|
+
|----------|-------------|
|
|
154
|
+
| Single application with embedded signing | `DfnsClient` |
|
|
155
|
+
| Mobile app with local key storage | `DfnsClient` |
|
|
156
|
+
| Backend service with external HSM | `DfnsDelegatedClient` |
|
|
157
|
+
| Multi-step approval workflows | `DfnsDelegatedClient` |
|
|
158
|
+
| Service account orchestrating user actions | `DfnsDelegatedClient` |
|
|
159
|
+
|
|
160
|
+
## Available Domains
|
|
161
|
+
|
|
162
|
+
The client provides access to the following API domains:
|
|
163
|
+
|
|
164
|
+
- `client.auth` - Authentication and user management
|
|
165
|
+
- `client.wallets` - Wallet operations
|
|
166
|
+
- `client.policies` - Policy management
|
|
167
|
+
- `client.permissions` - Permission management
|
|
168
|
+
- `client.webhooks` - Webhook subscriptions
|
|
169
|
+
- And more...
|
|
170
|
+
|
|
171
|
+
Each domain provides typed methods for all available API endpoints.
|
|
172
|
+
|
|
173
|
+
## Error Handling
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
from dfns_sdk import DfnsClient, DfnsClientConfig, DfnsError
|
|
177
|
+
|
|
178
|
+
config = DfnsClientConfig(auth_token="your-auth-token")
|
|
179
|
+
client = DfnsClient(config)
|
|
180
|
+
|
|
181
|
+
try:
|
|
182
|
+
wallet = client.wallets.get_wallet(wallet_id="invalid-id")
|
|
183
|
+
except DfnsError as e:
|
|
184
|
+
print(f"Error: {e.message}")
|
|
185
|
+
print(f"Status: {e.status_code}")
|
|
186
|
+
print(f"Code: {e.error_code}")
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## License
|
|
190
|
+
|
|
191
|
+
MIT License - See LICENSE file for details.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Dfns Python SDK
|
|
2
|
+
|
|
3
|
+
Auto-generated Python SDK for the Dfns API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install dfns_sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or install from source:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install -e .
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from dfns_sdk import DfnsClient, DfnsClientConfig
|
|
21
|
+
|
|
22
|
+
# Configure the client
|
|
23
|
+
config = DfnsClientConfig(
|
|
24
|
+
auth_token="your-auth-token",
|
|
25
|
+
base_url="https://api.dfns.io", # Optional, this is the default
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
# Create the client
|
|
29
|
+
client = DfnsClient(config)
|
|
30
|
+
|
|
31
|
+
# Use the client
|
|
32
|
+
wallets = client.wallets.list_wallets()
|
|
33
|
+
print(wallets)
|
|
34
|
+
|
|
35
|
+
# Clean up
|
|
36
|
+
client.close()
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Using as a Context Manager
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
from dfns_sdk import DfnsClient, DfnsClientConfig
|
|
43
|
+
|
|
44
|
+
config = DfnsClientConfig(
|
|
45
|
+
auth_token="your-auth-token",
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
with DfnsClient(config) as client:
|
|
49
|
+
wallets = client.wallets.list_wallets()
|
|
50
|
+
print(wallets)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## User Action Signing
|
|
54
|
+
|
|
55
|
+
Some operations (like creating wallets or signing transactions) require user action signing.
|
|
56
|
+
Configure a signer to enable these operations:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from dfns_sdk import DfnsClient, DfnsClientConfig, KeySigner
|
|
60
|
+
|
|
61
|
+
# Load your private key
|
|
62
|
+
with open("private_key.pem") as f:
|
|
63
|
+
private_key = f.read()
|
|
64
|
+
|
|
65
|
+
# Create a signer
|
|
66
|
+
signer = KeySigner(
|
|
67
|
+
credential_id="cr-xxx-xxx", # Your credential ID
|
|
68
|
+
private_key=private_key,
|
|
69
|
+
app_origin="https://app.dfns.io",
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
# Configure the client with the signer
|
|
73
|
+
config = DfnsClientConfig(
|
|
74
|
+
auth_token="your-auth-token",
|
|
75
|
+
signer=signer,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
with DfnsClient(config) as client:
|
|
79
|
+
# Operations requiring signatures will automatically sign
|
|
80
|
+
wallet = client.wallets.create_wallet({
|
|
81
|
+
"network": "EthereumSepolia",
|
|
82
|
+
})
|
|
83
|
+
print(wallet)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Delegated Client (External Signing)
|
|
87
|
+
|
|
88
|
+
For service accounts that orchestrate signing externally (e.g., using a separate signing service),
|
|
89
|
+
use the `DfnsDelegatedClient`. This client separates user action signing into `*_init()` and
|
|
90
|
+
`*_complete()` method pairs:
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from dfns_sdk import DfnsDelegatedClient, DfnsDelegatedClientConfig
|
|
94
|
+
|
|
95
|
+
# Configure the delegated client (no signer needed)
|
|
96
|
+
config = DfnsDelegatedClientConfig(
|
|
97
|
+
auth_token="service-account-token",
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
with DfnsDelegatedClient(config) as client:
|
|
101
|
+
# Step 1: Initialize the action (returns challenge)
|
|
102
|
+
challenge = client.wallets.create_wallet_init(
|
|
103
|
+
body={"network": "EthereumSepolia"}
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# Step 2: Sign challenge externally (your signing system)
|
|
107
|
+
# The challenge contains everything needed to sign:
|
|
108
|
+
# - challenge["challenge"]: The challenge string to sign
|
|
109
|
+
# - challenge["challengeIdentifier"]: Unique ID for this challenge
|
|
110
|
+
signed_assertion = your_external_signer.sign(challenge)
|
|
111
|
+
|
|
112
|
+
# Step 3: Complete the action with signed challenge
|
|
113
|
+
wallet = client.wallets.create_wallet_complete(
|
|
114
|
+
body={"network": "EthereumSepolia"},
|
|
115
|
+
signed_challenge={
|
|
116
|
+
"challengeIdentifier": challenge["challengeIdentifier"],
|
|
117
|
+
"firstFactor": signed_assertion,
|
|
118
|
+
},
|
|
119
|
+
)
|
|
120
|
+
print(wallet)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### When to Use Delegated vs Regular Client
|
|
124
|
+
|
|
125
|
+
| Use Case | Client Type |
|
|
126
|
+
|----------|-------------|
|
|
127
|
+
| Single application with embedded signing | `DfnsClient` |
|
|
128
|
+
| Mobile app with local key storage | `DfnsClient` |
|
|
129
|
+
| Backend service with external HSM | `DfnsDelegatedClient` |
|
|
130
|
+
| Multi-step approval workflows | `DfnsDelegatedClient` |
|
|
131
|
+
| Service account orchestrating user actions | `DfnsDelegatedClient` |
|
|
132
|
+
|
|
133
|
+
## Available Domains
|
|
134
|
+
|
|
135
|
+
The client provides access to the following API domains:
|
|
136
|
+
|
|
137
|
+
- `client.auth` - Authentication and user management
|
|
138
|
+
- `client.wallets` - Wallet operations
|
|
139
|
+
- `client.policies` - Policy management
|
|
140
|
+
- `client.permissions` - Permission management
|
|
141
|
+
- `client.webhooks` - Webhook subscriptions
|
|
142
|
+
- And more...
|
|
143
|
+
|
|
144
|
+
Each domain provides typed methods for all available API endpoints.
|
|
145
|
+
|
|
146
|
+
## Error Handling
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
from dfns_sdk import DfnsClient, DfnsClientConfig, DfnsError
|
|
150
|
+
|
|
151
|
+
config = DfnsClientConfig(auth_token="your-auth-token")
|
|
152
|
+
client = DfnsClient(config)
|
|
153
|
+
|
|
154
|
+
try:
|
|
155
|
+
wallet = client.wallets.get_wallet(wallet_id="invalid-id")
|
|
156
|
+
except DfnsError as e:
|
|
157
|
+
print(f"Error: {e.message}")
|
|
158
|
+
print(f"Status: {e.status_code}")
|
|
159
|
+
print(f"Code: {e.error_code}")
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## License
|
|
163
|
+
|
|
164
|
+
MIT License - See LICENSE file for details.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Dfns Python SDK - Auto-generated from OpenAPI specification."""
|
|
2
|
+
|
|
3
|
+
from .client import DfnsClient
|
|
4
|
+
from .delegated_client import DfnsDelegatedClient
|
|
5
|
+
from .types import DfnsClientConfig, DfnsDelegatedClientConfig, DfnsError
|
|
6
|
+
from .auth import Signer, KeySigner
|
|
7
|
+
from .base_auth_api import (
|
|
8
|
+
BaseAuthApi,
|
|
9
|
+
UserActionChallengeResponse,
|
|
10
|
+
SignUserActionChallengeRequest,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
__all__ = [
|
|
14
|
+
"DfnsClient",
|
|
15
|
+
"DfnsDelegatedClient",
|
|
16
|
+
"DfnsClientConfig",
|
|
17
|
+
"DfnsDelegatedClientConfig",
|
|
18
|
+
"DfnsError",
|
|
19
|
+
"Signer",
|
|
20
|
+
"KeySigner",
|
|
21
|
+
"BaseAuthApi",
|
|
22
|
+
"UserActionChallengeResponse",
|
|
23
|
+
"SignUserActionChallengeRequest",
|
|
24
|
+
]
|