You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3b502a9
Browse filesBrowse the repository at this point in the historyBrowse files
feat!: register a capability with a scope; PAYMENT_REQUIRED replaces POOL_UNFUNDED
`register_capability(capability, scope)` takes a required scope: "any", or a
`NamespaceScope(namespaces, signature)` the pool's owner signed, which the SDK
passes through. `Registration` and `RegisteredCapability` carry the optional
`namespaces` the gateway echoes. A 503 from a public gateway maps to
`PAYMENT_REQUIRED`, as a 402 does; the `POOL_UNFUNDED` code is gone.
The fake gateway requires `scope`, checks a namespace scope's shape and echoes
its namespaces in the 201 and the listing. The loopback contract suite
registers with scope "any" and checks a registration without a scope is 422.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+20-9Lines changed: 20 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -139,7 +139,7 @@ async with AsyncClient("https://decdn.link") as client:
139
139
140
140
A public gateway pays with the capabilities its operator registered on it, in
141
141
the order they were registered. When none can pay, a request the gateway must
142
-
pull fails with `POOL_UNFUNDED`, carrying `retry_after_secs` and the
142
+
pull fails with `PAYMENT_REQUIRED`, carrying `retry_after_secs` and the
143
143
`fallback_uri` to fetch with a paying client of your own; a response its cache
144
144
holds whole still comes, at no cost.
145
145
@@ -151,23 +151,35 @@ too; leaving the block closes the connection if the body was not read.
151
151
A loopback gateway pays with capabilities a pool owner issued to its delegate
152
152
keys. The gateway holds one pending key: `delegate()` returns the same address
153
153
until a capability claims it, and a fresh key after that. Have the owner
154
-
assign the pending key, then register the capability:
154
+
assign the pending key, then register the capability with the scope it pays
155
+
for:
155
156
156
157
```python
157
-
from decdn import AsyncClient, Client
158
+
from decdn import AsyncClient, Client, NamespaceScope
158
159
159
160
with Client("http://127.0.0.1:8484") as client:
160
161
delegate = client.loopback.delegate()
161
162
# The pool owner: decdn pool assign --pool <id> --signer <delegate.address> ...
asyncwith AsyncClient("http://127.0.0.1:8484") as client:
|`PAYMENT_REQUIRED`| 402: no capability the loopback gateway holds can pay |
219
-
|`POOL_UNFUNDED`| 503: no capability the public gateway holds can pay |
230
+
|`PAYMENT_REQUIRED`| 402 (loopback) or 503 (public): no capability the gateway holds can pay |
220
231
|`NOT_FOUND`| 404 |
221
232
|`RANGE_NOT_SATISFIABLE`| 416: the range starts past the end; `size` holds the entry's size |
222
233
|`FORBIDDEN`| 403 |
@@ -298,7 +309,7 @@ are the deployment the gateway verifies against.
298
309
|`client.manifest(hash_or_uri)`| A bundle's verified manifest, cached per client |
299
310
|`client.site_url(uri)`, `client.namespace_url(ns)`| The site URL of a bundle or entry; the URL a namespace's pointer serves at (`https://<ns>.<host>/`). Neither makes a request |
300
311
|`client.loopback.delegate()`| The loopback gateway's pending delegate key: the same address until a capability claims it |
301
-
|`client.loopback.register_capability(capability)`, `.capabilities()`| Registers a `dcap1:` capability issued to a key the gateway holds; lists the capabilities the gateway holds, in the order it pays with them|
312
+
|`client.loopback.register_capability(capability, scope)`, `.capabilities()`| Registers a `dcap1:` capability issued to a key the gateway holds, for scope `"any"` or a `NamespaceScope`; lists the capabilities the gateway holds, in the order it pays with them, with the `namespaces` of a scoped one|
302
313
|`client.pointer.set(namespace=, root=, seq=, signer=)`| Signs and publishes a namespace pointer on a public gateway |
303
314
|`pointer_typed_data`, `pointer_signing_hash`, `sign_pointer`, `recover_pointer_signer`| The pointer's EIP-712 typed data and signing hash, its signature, and the signer a signature recovers to |
304
315
|`parse_uri`, `format_uri`| Parse and canonically format a `decdn:` URI, following the Rust client's grammar exactly (`BAD_URI` on anything it refuses) |
0 commit comments