-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add examples & context to capabilities package readme #375
Conversation
|
||
### Using the exported capabilities | ||
|
||
The capability object exposes three methods via the `TheCapabilityParser` interface: `create`, `invoke`, and `delegate`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could be good docs to have in ucanto itself (too) https://github.com/web3-storage/ucanto/
packages/capabilities/readme.md
Outdated
```ts | ||
import * as DID from '@ipld/dag-ucan/did' | ||
|
||
const issuer = loadSigningKey() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it could be illustrative to show a working version of this
import * as ed25519 from "@ucanto/principal/ed25519";
const issuer = await ed25519.generate();
|
||
The `delegate` method allows you to create a ucanto `Delegation`, which allows another principal to invoke the capability. | ||
|
||
`delegate` accepts the same input as `invoke`, however the `nb` field is optional. If `nb` is present, the values provided will act as constraints on the invocations that can be made using the delegation. For example, creating a `store/add` delegation with the `size` caveat set to `1048576` would limit invocations made using the delegation to uploads of no more than 1MiB. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, creating a
store/add
delegation with thesize
caveat set to1048576
would limit invocations made using the delegation to uploads of no more than 1MiB.
Love calling out the use cases like this. I think over time it may be worth having explicit examples of how to include that size
caveat using the delegate
method.
Another use case I anticipate is "How can I delegate the ability to store a specific CID"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM awesome explanations 😍
Co-authored-by: Benjamin Goering <[email protected]>
This closes #369 by adding some examples of using the capability objects exposed by the capabilities package and explaining what some of the fancy type signatures are for. Co-authored-by: Benjamin Goering <[email protected]>
🤖 I have created a release *beep* *boop* --- ## [2.1.0](storacha/w3ui@react-uploads-list-v2.0.1...react-uploads-list-v2.1.0) (2023-02-06) ### Features * "Headless" UI components ([#136](storacha/w3ui#136)) ([46583e0](storacha/w3ui@46583e0) ### Bug Fixes * load first page of uploads list in provider ([storacha#288](storacha/w3ui#288)) ([6778d6c](storacha/w3ui@6778d6c)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Travis Vachon <[email protected]>
🤖 I have created a release *beep* *boop* --- ## [2.1.0](storacha/w3ui@react-uploads-list-v2.0.1...react-uploads-list-v2.1.0) (2023-02-06) ### Features * "Headless" UI components ([#136](storacha/w3ui#136)) ([b702889](storacha/w3ui@b702889) ### Bug Fixes * load first page of uploads list in provider ([storacha#288](storacha/w3ui#288)) ([8a79ad9](storacha/w3ui@8a79ad9)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Travis Vachon <[email protected]>
This closes #369 by adding some examples of using the capability objects exposed by the capabilities package and explaining what some of the fancy type signatures are for.