Dfns Python SDK - Auto-generated from OpenAPI specification
Project description
Dfns Python SDK
Auto-generated Python SDK for the Dfns API.
Installation
pip install dfns_sdk
Or install from source:
pip install -e .
Quick Start
from dfns_sdk import DfnsClient, DfnsClientConfig
# Configure the client
config = DfnsClientConfig(
auth_token="your-auth-token",
base_url="https://api.dfns.io", # Optional, this is the default
)
# Create the client
client = DfnsClient(config)
# Use the client
wallets = client.wallets.list_wallets()
print(wallets)
# Clean up
client.close()
Using as a Context Manager
from dfns_sdk import DfnsClient, DfnsClientConfig
config = DfnsClientConfig(
auth_token="your-auth-token",
)
with DfnsClient(config) as client:
wallets = client.wallets.list_wallets()
print(wallets)
User Action Signing
Some operations (like creating wallets or signing transactions) require user action signing. Configure a signer to enable these operations:
from dfns_sdk import DfnsClient, DfnsClientConfig, KeySigner
# Load your private key
with open("private_key.pem") as f:
private_key = f.read()
# Create a signer
signer = KeySigner(
credential_id="cr-xxx-xxx", # Your credential ID
private_key=private_key,
app_origin="https://app.dfns.io",
)
# Configure the client with the signer
config = DfnsClientConfig(
auth_token="your-auth-token",
signer=signer,
)
with DfnsClient(config) as client:
# Operations requiring signatures will automatically sign
wallet = client.wallets.create_wallet({
"network": "EthereumSepolia",
})
print(wallet)
Delegated Client (External Signing)
For service accounts that orchestrate signing externally (e.g., using a separate signing service),
use the DfnsDelegatedClient. This client separates user action signing into *_init() and
*_complete() method pairs:
from dfns_sdk import DfnsDelegatedClient, DfnsDelegatedClientConfig
# Configure the delegated client (no signer needed)
config = DfnsDelegatedClientConfig(
auth_token="service-account-token",
)
with DfnsDelegatedClient(config) as client:
# Step 1: Initialize the action (returns challenge)
challenge = client.wallets.create_wallet_init(
body={"network": "EthereumSepolia"}
)
# Step 2: Sign challenge externally (your signing system)
# The challenge contains everything needed to sign:
# - challenge["challenge"]: The challenge string to sign
# - challenge["challengeIdentifier"]: Unique ID for this challenge
signed_assertion = your_external_signer.sign(challenge)
# Step 3: Complete the action with signed challenge
wallet = client.wallets.create_wallet_complete(
body={"network": "EthereumSepolia"},
signed_challenge={
"challengeIdentifier": challenge["challengeIdentifier"],
"firstFactor": signed_assertion,
},
)
print(wallet)
When to Use Delegated vs Regular Client
| Use Case | Client Type |
|---|---|
| Single application with embedded signing | DfnsClient |
| Mobile app with local key storage | DfnsClient |
| Backend service with external HSM | DfnsDelegatedClient |
| Multi-step approval workflows | DfnsDelegatedClient |
| Service account orchestrating user actions | DfnsDelegatedClient |
Available Domains
The client provides access to the following API domains:
client.auth- Authentication and user managementclient.wallets- Wallet operationsclient.policies- Policy managementclient.permissions- Permission managementclient.webhooks- Webhook subscriptions- And more...
Each domain provides typed methods for all available API endpoints.
Error Handling
from dfns_sdk import DfnsClient, DfnsClientConfig, DfnsError
config = DfnsClientConfig(auth_token="your-auth-token")
client = DfnsClient(config)
try:
wallet = client.wallets.get_wallet(wallet_id="invalid-id")
except DfnsError as e:
print(f"Error: {e.message}")
print(f"Status: {e.status_code}")
print(f"Code: {e.error_code}")
License
MIT License - See LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dfns_sdk-0.0.2.tar.gz.
File metadata
- Download URL: dfns_sdk-0.0.2.tar.gz
- Upload date:
- Size: 52.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1ee3a47b5d149146aa1d618ca587c9819f848432e872a3af42aa8adbfc584d4
|
|
| MD5 |
b10b2839d73345bf8e28c1a9bf4033bc
|
|
| BLAKE2b-256 |
7f9f4a237ad5a3e17f86608560ee55bf03266b6a91ead0b7bbf2a30b78341253
|
Provenance
The following attestation bundles were made for dfns_sdk-0.0.2.tar.gz:
Publisher:
publish.yml on dfns/dfns-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dfns_sdk-0.0.2.tar.gz -
Subject digest:
b1ee3a47b5d149146aa1d618ca587c9819f848432e872a3af42aa8adbfc584d4 - Sigstore transparency entry: 1474319357
- Sigstore integration time:
-
Permalink:
dfns/dfns-sdk-python@856f5fe7b1ac807851cfa7c171c4c9c310477289 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/dfns
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@856f5fe7b1ac807851cfa7c171c4c9c310477289 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dfns_sdk-0.0.2-py3-none-any.whl.
File metadata
- Download URL: dfns_sdk-0.0.2-py3-none-any.whl
- Upload date:
- Size: 90.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
761765741d3ea9d53924801c32f480b7ac20d83f3b0bae087774b9bb6027988c
|
|
| MD5 |
9c08d8cedf0423fadc0ff504f4a1cf7b
|
|
| BLAKE2b-256 |
f791c0b204a62e86946e84efb2a0d6540c4b503a329506fbc1b2d26267c7694f
|
Provenance
The following attestation bundles were made for dfns_sdk-0.0.2-py3-none-any.whl:
Publisher:
publish.yml on dfns/dfns-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dfns_sdk-0.0.2-py3-none-any.whl -
Subject digest:
761765741d3ea9d53924801c32f480b7ac20d83f3b0bae087774b9bb6027988c - Sigstore transparency entry: 1474319441
- Sigstore integration time:
-
Permalink:
dfns/dfns-sdk-python@856f5fe7b1ac807851cfa7c171c4c9c310477289 -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/dfns
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@856f5fe7b1ac807851cfa7c171c4c9c310477289 -
Trigger Event:
push
-
Statement type: