agent-did-sdk 0.1.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.
Files changed (46) hide show
  1. agent_did_sdk-0.1.0/LICENSE +151 -0
  2. agent_did_sdk-0.1.0/PKG-INFO +240 -0
  3. agent_did_sdk-0.1.0/README.md +207 -0
  4. agent_did_sdk-0.1.0/pyproject.toml +65 -0
  5. agent_did_sdk-0.1.0/setup.cfg +4 -0
  6. agent_did_sdk-0.1.0/src/agent_did_sdk/__init__.py +113 -0
  7. agent_did_sdk-0.1.0/src/agent_did_sdk/core/__init__.py +0 -0
  8. agent_did_sdk-0.1.0/src/agent_did_sdk/core/http_security.py +57 -0
  9. agent_did_sdk-0.1.0/src/agent_did_sdk/core/identity.py +642 -0
  10. agent_did_sdk-0.1.0/src/agent_did_sdk/core/signer.py +48 -0
  11. agent_did_sdk-0.1.0/src/agent_did_sdk/core/time_utils.py +50 -0
  12. agent_did_sdk-0.1.0/src/agent_did_sdk/core/types.py +150 -0
  13. agent_did_sdk-0.1.0/src/agent_did_sdk/crypto/__init__.py +0 -0
  14. agent_did_sdk-0.1.0/src/agent_did_sdk/crypto/hash.py +67 -0
  15. agent_did_sdk-0.1.0/src/agent_did_sdk/crypto/multibase.py +116 -0
  16. agent_did_sdk-0.1.0/src/agent_did_sdk/py.typed +0 -0
  17. agent_did_sdk-0.1.0/src/agent_did_sdk/registry/__init__.py +0 -0
  18. agent_did_sdk-0.1.0/src/agent_did_sdk/registry/evm_registry.py +47 -0
  19. agent_did_sdk-0.1.0/src/agent_did_sdk/registry/evm_types.py +35 -0
  20. agent_did_sdk-0.1.0/src/agent_did_sdk/registry/in_memory.py +45 -0
  21. agent_did_sdk-0.1.0/src/agent_did_sdk/registry/types.py +26 -0
  22. agent_did_sdk-0.1.0/src/agent_did_sdk/registry/web3_client.py +108 -0
  23. agent_did_sdk-0.1.0/src/agent_did_sdk/resolver/__init__.py +0 -0
  24. agent_did_sdk-0.1.0/src/agent_did_sdk/resolver/http_source.py +83 -0
  25. agent_did_sdk-0.1.0/src/agent_did_sdk/resolver/in_memory.py +24 -0
  26. agent_did_sdk-0.1.0/src/agent_did_sdk/resolver/jsonrpc_source.py +98 -0
  27. agent_did_sdk-0.1.0/src/agent_did_sdk/resolver/types.py +59 -0
  28. agent_did_sdk-0.1.0/src/agent_did_sdk/resolver/universal.py +200 -0
  29. agent_did_sdk-0.1.0/src/agent_did_sdk.egg-info/PKG-INFO +240 -0
  30. agent_did_sdk-0.1.0/src/agent_did_sdk.egg-info/SOURCES.txt +44 -0
  31. agent_did_sdk-0.1.0/src/agent_did_sdk.egg-info/dependency_links.txt +1 -0
  32. agent_did_sdk-0.1.0/src/agent_did_sdk.egg-info/requires.txt +11 -0
  33. agent_did_sdk-0.1.0/src/agent_did_sdk.egg-info/top_level.txt +1 -0
  34. agent_did_sdk-0.1.0/tests/test_crypto.py +72 -0
  35. agent_did_sdk-0.1.0/tests/test_evm_registry.py +65 -0
  36. agent_did_sdk-0.1.0/tests/test_http_security.py +92 -0
  37. agent_did_sdk-0.1.0/tests/test_http_source.py +81 -0
  38. agent_did_sdk-0.1.0/tests/test_identity.py +434 -0
  39. agent_did_sdk-0.1.0/tests/test_in_memory_registry.py +53 -0
  40. agent_did_sdk-0.1.0/tests/test_in_memory_resolver.py +64 -0
  41. agent_did_sdk-0.1.0/tests/test_interop_vectors.py +70 -0
  42. agent_did_sdk-0.1.0/tests/test_jsonrpc_source.py +92 -0
  43. agent_did_sdk-0.1.0/tests/test_security_edge_cases.py +63 -0
  44. agent_did_sdk-0.1.0/tests/test_time.py +65 -0
  45. agent_did_sdk-0.1.0/tests/test_universal_resolver.py +142 -0
  46. agent_did_sdk-0.1.0/tests/test_web3_client.py +42 -0
@@ -0,0 +1,151 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
45
+ in the Work by the copyright owner or by an individual or Legal Entity
46
+ authorized to submit on behalf of the copyright owner.
47
+
48
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
49
+ whom a Contribution has been received by the Licensor and subsequently
50
+ incorporated within the Work.
51
+
52
+ 2. Grant of Copyright License. Subject to the terms and conditions of
53
+ this License, each Contributor hereby grants to You a perpetual,
54
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
55
+ copyright license to reproduce, prepare Derivative Works of,
56
+ publicly display, publicly perform, sublicense, and distribute the
57
+ Work and such Derivative Works in Source or Object form.
58
+
59
+ 3. Grant of Patent License. Subject to the terms and conditions of
60
+ this License, each Contributor hereby grants to You a perpetual,
61
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
62
+ (except as stated in this section) patent license to make, have made,
63
+ use, offer to sell, sell, import, and otherwise transfer the Work,
64
+ where such license applies only to those patent claims licensable
65
+ by such Contributor that are necessarily infringed by their
66
+ Contribution(s) alone or by combination of their Contribution(s)
67
+ with the Work to which such Contribution(s) was submitted. If You
68
+ institute patent litigation against any entity (including a
69
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
70
+ or a Contribution incorporated within the Work constitutes direct
71
+ or contributory patent infringement, then any patent licenses
72
+ granted to You under this License for that Work shall terminate
73
+ as of the date such litigation is filed.
74
+
75
+ 4. Redistribution. You may reproduce and distribute copies of the
76
+ Work or Derivative Works thereof in any medium, with or without
77
+ modifications, and in Source or Object form, provided that You
78
+ meet the following conditions:
79
+
80
+ (a) You must give any other recipients of the Work or Derivative
81
+ Works a copy of this License; and
82
+
83
+ (b) You must cause any modified files to carry prominent notices
84
+ stating that You changed the files; and
85
+
86
+ (c) You must retain, in the Source form of any Derivative Works
87
+ that You distribute, all copyright, patent, trademark, and
88
+ attribution notices from the Source form of the Work,
89
+ excluding those notices that do not pertain to any part of
90
+ the Derivative Works; and
91
+
92
+ (d) If the Work includes a "NOTICE" text file as part of its
93
+ distribution, You must include a readable copy of the
94
+ attribution notices contained within such NOTICE file.
95
+
96
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
97
+ any Contribution intentionally submitted for inclusion in the Work
98
+ by You to the Licensor shall be under the terms and conditions of
99
+ this License, without any additional terms or conditions.
100
+
101
+ 6. Trademarks. This License does not grant permission to use the trade
102
+ names, trademarks, service marks, or product names of the Licensor,
103
+ except as required for reasonable and customary use in describing the
104
+ origin of the Work and reproducing the content of the NOTICE file.
105
+
106
+ 7. Disclaimer of Warranty. Unless required by applicable law or
107
+ agreed to in writing, Licensor provides the Work (and each
108
+ Contributor provides its Contributions) on an "AS IS" BASIS,
109
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
110
+ implied, including, without limitation, any warranties or conditions
111
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
112
+ PARTICULAR PURPOSE.
113
+
114
+ 8. Limitation of Liability. In no event and under no legal theory,
115
+ whether in tort (including negligence), contract, or otherwise,
116
+ unless required by applicable law (such as deliberate and grossly
117
+ negligent acts) or agreed to in writing, shall any Contributor be
118
+ liable to You for damages, including any direct, indirect, special,
119
+ incidental, or exemplary damages of any character arising as a
120
+ result of this License or out of the use or inability to use the
121
+ Work (including but not limited to damages for loss of goodwill,
122
+ work stoppage, computer failure or malfunction, or all other
123
+ commercial damages or losses), even if such Contributor has been
124
+ advised of the possibility of such damages.
125
+
126
+ 9. Accepting Warranty or Additional Liability. While redistributing
127
+ the Work or Derivative Works thereof, You may choose to offer,
128
+ and charge a fee for, acceptance of support, warranty, indemnity,
129
+ or other liability obligations and/or rights consistent with this
130
+ License. However, in accepting such obligations, You may act only
131
+ on Your own behalf and on Your sole responsibility, not on behalf
132
+ of any other Contributor, and only if You agree to indemnify,
133
+ defend, and hold each Contributor harmless for any liability
134
+ incurred by, or claims asserted against, such Contributor by reason
135
+ of your accepting any such warranty or additional liability.
136
+
137
+ END OF TERMS AND CONDITIONS
138
+
139
+ Copyright 2026 Agent-DID contributors
140
+
141
+ Licensed under the Apache License, Version 2.0 (the "License");
142
+ you may not use this file except in compliance with the License.
143
+ You may obtain a copy of the License at
144
+
145
+ http://www.apache.org/licenses/LICENSE-2.0
146
+
147
+ Unless required by applicable law or agreed to in writing, software
148
+ distributed under the License is distributed on an "AS IS" BASIS,
149
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
150
+ See the License for the specific language governing permissions and
151
+ limitations under the License.
@@ -0,0 +1,240 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-did-sdk
3
+ Version: 0.1.0
4
+ Summary: Python SDK for the Agent-DID Specification (RFC-001) — create, sign, resolve, verify and revoke Agent-DIDs
5
+ Author: Agent-DID contributors
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/edisonduran/agent-did#readme
8
+ Project-URL: Repository, https://github.com/edisonduran/agent-did.git
9
+ Project-URL: Bug-Tracker, https://github.com/edisonduran/agent-did/issues
10
+ Keywords: did,agent,identity,decentralized,web3,ai
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
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: Topic :: Security :: Cryptography
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: pydantic>=2.0
23
+ Requires-Dist: pynacl>=1.5
24
+ Requires-Dist: web3>=6.0
25
+ Requires-Dist: httpx>=0.27
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=8.0; extra == "dev"
28
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
29
+ Requires-Dist: pytest-cov>=5.0; extra == "dev"
30
+ Requires-Dist: ruff>=0.4; extra == "dev"
31
+ Requires-Dist: mypy>=1.10; extra == "dev"
32
+ Dynamic: license-file
33
+
34
+ # agent-did-sdk (Python)
35
+
36
+ Python SDK for the **Agent-DID Specification (RFC-001)** — create, sign, resolve, verify and revoke Agent-DIDs.
37
+
38
+ Functional parity with the TypeScript SDK (`@agentdid/sdk`), with a dedicated Python CI pipeline and shared interoperability fixtures.
39
+
40
+ Formal parity tracking is documented in `../docs/F2-01-TS-Python-Parity-Matrix.md`.
41
+
42
+ Pythonic surface conventions apply:
43
+
44
+ - constructor config uses `signer_address`
45
+ - instance methods use `snake_case`
46
+ - lifecycle-wide operations such as revoke/update/rotate/resolve remain class methods on `AgentIdentity`
47
+
48
+ ## Installation
49
+
50
+ ```bash
51
+ pip install agent-did-sdk
52
+ ```
53
+
54
+ For development:
55
+
56
+ ```bash
57
+ pip install -e ".[dev]"
58
+ ```
59
+
60
+ ## Quick Start
61
+
62
+ ```python
63
+ import asyncio
64
+ from agent_did_sdk import AgentIdentity, AgentIdentityConfig, CreateAgentParams
65
+
66
+ async def main():
67
+ identity = AgentIdentity(AgentIdentityConfig(signer_address="0xYourWalletAddress"))
68
+
69
+ result = await identity.create(CreateAgentParams(
70
+ name="MyAgent",
71
+ core_model="gpt-4-turbo",
72
+ system_prompt="You are a helpful assistant.",
73
+ capabilities=["search", "code-execution"],
74
+ ))
75
+
76
+ print(f"Agent DID: {result.document.id}")
77
+ print(f"Private Key: {result.agent_private_key}")
78
+
79
+ # Sign a message
80
+ signature = await identity.sign_message("Hello, World!", result.agent_private_key)
81
+
82
+ # Verify
83
+ is_valid = await AgentIdentity.verify_signature(
84
+ result.document.id, "Hello, World!", signature
85
+ )
86
+ print(f"Valid: {is_valid}")
87
+
88
+ asyncio.run(main())
89
+ ```
90
+
91
+ ## Features
92
+
93
+ | Feature | API | Status |
94
+ |---|---|---|
95
+ | Create Agent-DID document | `identity.create(params)` | ✅ |
96
+ | Sign messages (Ed25519) | `identity.sign_message(payload, key)` | ✅ |
97
+ | Sign HTTP requests (Bot Auth) | `identity.sign_http_request(params)` | ✅ |
98
+ | Verify message signatures | `AgentIdentity.verify_signature(did, payload, sig)` | ✅ |
99
+ | Verify HTTP signatures | `AgentIdentity.verify_http_request_signature(params)` | ✅ |
100
+ | Resolve DID → document | `AgentIdentity.resolve(did)` | ✅ |
101
+ | Revoke DID | `AgentIdentity.revoke_did(did)` | ✅ |
102
+ | Update document | `AgentIdentity.update_did_document(did, patch)` | ✅ |
103
+ | Rotate verification keys | `AgentIdentity.rotate_verification_method(did)` | ✅ |
104
+ | Document history/audit | `AgentIdentity.get_document_history(did)` | ✅ |
105
+ | EVM registry adapter | `EvmAgentRegistry` + `Web3AgentRegistryContractClient` | ✅ |
106
+ | Universal resolver (HTTP/RPC/IPFS) | `UniversalResolverClient` | ✅ |
107
+
108
+ ## Modules
109
+
110
+ | Module | Description |
111
+ |--------|-------------|
112
+ | `core.types` | Pydantic models for RFC-001 (AgentDIDDocument, etc.) |
113
+ | `core.identity` | `AgentIdentity` — main class for DID lifecycle |
114
+ | `core.time_utils` | ISO-8601 ↔ Unix timestamp utilities |
115
+ | `crypto.hash` | SHA-256 hashing with `hash://` URI format |
116
+ | `registry.*` | Agent registry (in-memory, EVM adapter, Web3 client) |
117
+ | `resolver.*` | DID resolver (in-memory, HTTP source, JSON-RPC source, universal) |
118
+
119
+ ## EVM Registry Integration
120
+
121
+ Connect the SDK to a real on-chain `AgentRegistry` contract:
122
+
123
+ ```python
124
+ from web3 import HTTPProvider, Web3
125
+
126
+ from agent_did_sdk import AgentIdentity, EvmAgentRegistry, Web3AgentRegistryContractClient
127
+ from agent_did_sdk.registry.evm_types import EvmAgentRegistryAdapterConfig
128
+
129
+ provider = Web3(HTTPProvider("http://127.0.0.1:8545"))
130
+ contract = provider.eth.contract(address=REGISTRY_ADDRESS, abi=ABI)
131
+
132
+ registry = EvmAgentRegistry(
133
+ EvmAgentRegistryAdapterConfig(
134
+ contract_client=Web3AgentRegistryContractClient(contract),
135
+ await_transaction_confirmation=True,
136
+ )
137
+ )
138
+
139
+ AgentIdentity.set_registry(registry)
140
+ ```
141
+
142
+ See full example: `examples/evm_registry_wiring.py`
143
+
144
+ ## Production Resolver
145
+
146
+ Configure a production-grade resolver with failover and caching:
147
+
148
+ ```python
149
+ from agent_did_sdk import AgentIdentity, ProductionHttpResolverProfileConfig
150
+
151
+ AgentIdentity.use_production_resolver_from_http(
152
+ ProductionHttpResolverProfileConfig(
153
+ registry=evm_registry,
154
+ cache_ttl_ms=60_000,
155
+ ipfs_gateways=["https://gateway.pinata.cloud", "https://ipfs.io"],
156
+ on_resolution_event=lambda event: print("Resolution:", event.stage),
157
+ )
158
+ )
159
+ ```
160
+
161
+ Minimal `did:wba` example: `examples/did_wba_resolution.py`
162
+
163
+ ## Testing
164
+
165
+ Canonical local workflow:
166
+
167
+ ```bash
168
+ cd sdk-python
169
+ python -m pip install -e ".[dev]"
170
+ ruff check src/ tests/ scripts/
171
+ mypy --strict src/
172
+ pytest --cov=agent_did_sdk --cov-fail-under=85 -q
173
+ ```
174
+
175
+ Repository-level convenience wrappers are also available from the repo root:
176
+
177
+ ```bash
178
+ npm run python:test
179
+ npm run python:conformance
180
+ ```
181
+
182
+ These `npm` commands are only monorepo shortcuts. The canonical Python commands remain the native `python`, `pytest`, `ruff`, and `mypy` commands shown above.
183
+
184
+ ```bash
185
+ cd sdk-python
186
+ pip install -e ".[dev]"
187
+ pytest --cov
188
+ ```
189
+
190
+ RFC-001 Python conformance:
191
+
192
+ ```bash
193
+ cd sdk-python
194
+ python scripts/conformance_rfc001.py
195
+ ```
196
+
197
+ Operational smokes:
198
+
199
+ ```bash
200
+ cd contracts
201
+ npm ci
202
+
203
+ cd ../sdk-python
204
+ python scripts/rpc_resolver_smoke.py
205
+ python scripts/resolver_ha_smoke.py
206
+ python scripts/revocation_policy_smoke.py
207
+ python scripts/e2e_smoke.py
208
+ ```
209
+
210
+ ## Maintainer Release to PyPI
211
+
212
+ The repository includes `.github/workflows/publish-python-sdk.yml` for PyPI Trusted Publishing.
213
+
214
+ Before the first release, create the `agent-did-sdk` project on PyPI and, optionally, TestPyPI, then register GitHub Trusted Publishers for:
215
+
216
+ - repository: `edisonduran/agent-did`
217
+ - workflow file: `.github/workflows/publish-python-sdk.yml`
218
+ - workflow trigger: tag `sdk-python-vX.Y.Z` for PyPI, `workflow_dispatch` for TestPyPI or manual PyPI release
219
+
220
+ If you want GitHub environment approvals, add matching environments later and bind them in both GitHub and PyPI Trusted Publishing settings.
221
+
222
+ Release preparation:
223
+
224
+ ```bash
225
+ cd sdk-python
226
+ python -m pip install -e ".[dev]"
227
+ python -m build
228
+ python -m twine check dist/*
229
+ ```
230
+
231
+ Release flow:
232
+
233
+ - bump `version` in `pyproject.toml`
234
+ - run the workflow manually with `repository=testpypi` to validate the package on TestPyPI
235
+ - publish to PyPI by pushing a tag named `sdk-python-vX.Y.Z`
236
+ - alternatively, run the workflow manually from `main` with `repository=pypi`
237
+
238
+ ## License
239
+
240
+ [Apache-2.0](../LICENSE) — see root LICENSE.
@@ -0,0 +1,207 @@
1
+ # agent-did-sdk (Python)
2
+
3
+ Python SDK for the **Agent-DID Specification (RFC-001)** — create, sign, resolve, verify and revoke Agent-DIDs.
4
+
5
+ Functional parity with the TypeScript SDK (`@agentdid/sdk`), with a dedicated Python CI pipeline and shared interoperability fixtures.
6
+
7
+ Formal parity tracking is documented in `../docs/F2-01-TS-Python-Parity-Matrix.md`.
8
+
9
+ Pythonic surface conventions apply:
10
+
11
+ - constructor config uses `signer_address`
12
+ - instance methods use `snake_case`
13
+ - lifecycle-wide operations such as revoke/update/rotate/resolve remain class methods on `AgentIdentity`
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ pip install agent-did-sdk
19
+ ```
20
+
21
+ For development:
22
+
23
+ ```bash
24
+ pip install -e ".[dev]"
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ ```python
30
+ import asyncio
31
+ from agent_did_sdk import AgentIdentity, AgentIdentityConfig, CreateAgentParams
32
+
33
+ async def main():
34
+ identity = AgentIdentity(AgentIdentityConfig(signer_address="0xYourWalletAddress"))
35
+
36
+ result = await identity.create(CreateAgentParams(
37
+ name="MyAgent",
38
+ core_model="gpt-4-turbo",
39
+ system_prompt="You are a helpful assistant.",
40
+ capabilities=["search", "code-execution"],
41
+ ))
42
+
43
+ print(f"Agent DID: {result.document.id}")
44
+ print(f"Private Key: {result.agent_private_key}")
45
+
46
+ # Sign a message
47
+ signature = await identity.sign_message("Hello, World!", result.agent_private_key)
48
+
49
+ # Verify
50
+ is_valid = await AgentIdentity.verify_signature(
51
+ result.document.id, "Hello, World!", signature
52
+ )
53
+ print(f"Valid: {is_valid}")
54
+
55
+ asyncio.run(main())
56
+ ```
57
+
58
+ ## Features
59
+
60
+ | Feature | API | Status |
61
+ |---|---|---|
62
+ | Create Agent-DID document | `identity.create(params)` | ✅ |
63
+ | Sign messages (Ed25519) | `identity.sign_message(payload, key)` | ✅ |
64
+ | Sign HTTP requests (Bot Auth) | `identity.sign_http_request(params)` | ✅ |
65
+ | Verify message signatures | `AgentIdentity.verify_signature(did, payload, sig)` | ✅ |
66
+ | Verify HTTP signatures | `AgentIdentity.verify_http_request_signature(params)` | ✅ |
67
+ | Resolve DID → document | `AgentIdentity.resolve(did)` | ✅ |
68
+ | Revoke DID | `AgentIdentity.revoke_did(did)` | ✅ |
69
+ | Update document | `AgentIdentity.update_did_document(did, patch)` | ✅ |
70
+ | Rotate verification keys | `AgentIdentity.rotate_verification_method(did)` | ✅ |
71
+ | Document history/audit | `AgentIdentity.get_document_history(did)` | ✅ |
72
+ | EVM registry adapter | `EvmAgentRegistry` + `Web3AgentRegistryContractClient` | ✅ |
73
+ | Universal resolver (HTTP/RPC/IPFS) | `UniversalResolverClient` | ✅ |
74
+
75
+ ## Modules
76
+
77
+ | Module | Description |
78
+ |--------|-------------|
79
+ | `core.types` | Pydantic models for RFC-001 (AgentDIDDocument, etc.) |
80
+ | `core.identity` | `AgentIdentity` — main class for DID lifecycle |
81
+ | `core.time_utils` | ISO-8601 ↔ Unix timestamp utilities |
82
+ | `crypto.hash` | SHA-256 hashing with `hash://` URI format |
83
+ | `registry.*` | Agent registry (in-memory, EVM adapter, Web3 client) |
84
+ | `resolver.*` | DID resolver (in-memory, HTTP source, JSON-RPC source, universal) |
85
+
86
+ ## EVM Registry Integration
87
+
88
+ Connect the SDK to a real on-chain `AgentRegistry` contract:
89
+
90
+ ```python
91
+ from web3 import HTTPProvider, Web3
92
+
93
+ from agent_did_sdk import AgentIdentity, EvmAgentRegistry, Web3AgentRegistryContractClient
94
+ from agent_did_sdk.registry.evm_types import EvmAgentRegistryAdapterConfig
95
+
96
+ provider = Web3(HTTPProvider("http://127.0.0.1:8545"))
97
+ contract = provider.eth.contract(address=REGISTRY_ADDRESS, abi=ABI)
98
+
99
+ registry = EvmAgentRegistry(
100
+ EvmAgentRegistryAdapterConfig(
101
+ contract_client=Web3AgentRegistryContractClient(contract),
102
+ await_transaction_confirmation=True,
103
+ )
104
+ )
105
+
106
+ AgentIdentity.set_registry(registry)
107
+ ```
108
+
109
+ See full example: `examples/evm_registry_wiring.py`
110
+
111
+ ## Production Resolver
112
+
113
+ Configure a production-grade resolver with failover and caching:
114
+
115
+ ```python
116
+ from agent_did_sdk import AgentIdentity, ProductionHttpResolverProfileConfig
117
+
118
+ AgentIdentity.use_production_resolver_from_http(
119
+ ProductionHttpResolverProfileConfig(
120
+ registry=evm_registry,
121
+ cache_ttl_ms=60_000,
122
+ ipfs_gateways=["https://gateway.pinata.cloud", "https://ipfs.io"],
123
+ on_resolution_event=lambda event: print("Resolution:", event.stage),
124
+ )
125
+ )
126
+ ```
127
+
128
+ Minimal `did:wba` example: `examples/did_wba_resolution.py`
129
+
130
+ ## Testing
131
+
132
+ Canonical local workflow:
133
+
134
+ ```bash
135
+ cd sdk-python
136
+ python -m pip install -e ".[dev]"
137
+ ruff check src/ tests/ scripts/
138
+ mypy --strict src/
139
+ pytest --cov=agent_did_sdk --cov-fail-under=85 -q
140
+ ```
141
+
142
+ Repository-level convenience wrappers are also available from the repo root:
143
+
144
+ ```bash
145
+ npm run python:test
146
+ npm run python:conformance
147
+ ```
148
+
149
+ These `npm` commands are only monorepo shortcuts. The canonical Python commands remain the native `python`, `pytest`, `ruff`, and `mypy` commands shown above.
150
+
151
+ ```bash
152
+ cd sdk-python
153
+ pip install -e ".[dev]"
154
+ pytest --cov
155
+ ```
156
+
157
+ RFC-001 Python conformance:
158
+
159
+ ```bash
160
+ cd sdk-python
161
+ python scripts/conformance_rfc001.py
162
+ ```
163
+
164
+ Operational smokes:
165
+
166
+ ```bash
167
+ cd contracts
168
+ npm ci
169
+
170
+ cd ../sdk-python
171
+ python scripts/rpc_resolver_smoke.py
172
+ python scripts/resolver_ha_smoke.py
173
+ python scripts/revocation_policy_smoke.py
174
+ python scripts/e2e_smoke.py
175
+ ```
176
+
177
+ ## Maintainer Release to PyPI
178
+
179
+ The repository includes `.github/workflows/publish-python-sdk.yml` for PyPI Trusted Publishing.
180
+
181
+ Before the first release, create the `agent-did-sdk` project on PyPI and, optionally, TestPyPI, then register GitHub Trusted Publishers for:
182
+
183
+ - repository: `edisonduran/agent-did`
184
+ - workflow file: `.github/workflows/publish-python-sdk.yml`
185
+ - workflow trigger: tag `sdk-python-vX.Y.Z` for PyPI, `workflow_dispatch` for TestPyPI or manual PyPI release
186
+
187
+ If you want GitHub environment approvals, add matching environments later and bind them in both GitHub and PyPI Trusted Publishing settings.
188
+
189
+ Release preparation:
190
+
191
+ ```bash
192
+ cd sdk-python
193
+ python -m pip install -e ".[dev]"
194
+ python -m build
195
+ python -m twine check dist/*
196
+ ```
197
+
198
+ Release flow:
199
+
200
+ - bump `version` in `pyproject.toml`
201
+ - run the workflow manually with `repository=testpypi` to validate the package on TestPyPI
202
+ - publish to PyPI by pushing a tag named `sdk-python-vX.Y.Z`
203
+ - alternatively, run the workflow manually from `main` with `repository=pypi`
204
+
205
+ ## License
206
+
207
+ [Apache-2.0](../LICENSE) — see root LICENSE.
@@ -0,0 +1,65 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "agent-did-sdk"
7
+ version = "0.1.0"
8
+ description = "Python SDK for the Agent-DID Specification (RFC-001) — create, sign, resolve, verify and revoke Agent-DIDs"
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ requires-python = ">=3.10"
12
+ authors = [
13
+ { name = "Agent-DID contributors" },
14
+ ]
15
+ keywords = ["did", "agent", "identity", "decentralized", "web3", "ai"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Topic :: Security :: Cryptography",
24
+ "Typing :: Typed",
25
+ ]
26
+
27
+ dependencies = [
28
+ "pydantic>=2.0",
29
+ "pynacl>=1.5",
30
+ "web3>=6.0",
31
+ "httpx>=0.27",
32
+ ]
33
+
34
+ [project.optional-dependencies]
35
+ dev = [
36
+ "pytest>=8.0",
37
+ "pytest-asyncio>=0.23",
38
+ "pytest-cov>=5.0",
39
+ "ruff>=0.4",
40
+ "mypy>=1.10",
41
+ ]
42
+
43
+ [project.urls]
44
+ Homepage = "https://github.com/edisonduran/agent-did#readme"
45
+ Repository = "https://github.com/edisonduran/agent-did.git"
46
+ Bug-Tracker = "https://github.com/edisonduran/agent-did/issues"
47
+
48
+ [tool.setuptools.packages.find]
49
+ where = ["src"]
50
+
51
+ [tool.pytest.ini_options]
52
+ testpaths = ["tests"]
53
+ asyncio_mode = "auto"
54
+
55
+ [tool.ruff]
56
+ target-version = "py310"
57
+ line-length = 120
58
+
59
+ [tool.ruff.lint]
60
+ select = ["E", "F", "I", "W", "UP"]
61
+
62
+ [tool.mypy]
63
+ strict = true
64
+ python_version = "3.10"
65
+ plugins = ["pydantic.mypy"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+