Skip to content
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

Merged
merged 4 commits into from
Jan 20, 2023

Conversation

yusefnapora
Copy link
Contributor

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.


### Using the exported capabilities

The capability object exposes three methods via the `TheCapabilityParser` interface: `create`, `invoke`, and `delegate`.
Copy link
Contributor

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/

```ts
import * as DID from '@ipld/dag-ucan/did'

const issuer = loadSigningKey()
Copy link
Contributor

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.
Copy link
Contributor

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 the size caveat set to 1048576 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"?

Copy link
Contributor

@hugomrdias hugomrdias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM awesome explanations 😍

@yusefnapora yusefnapora changed the title docs: add examples & context to capabilities package readme chore: add examples & context to capabilities package readme Jan 20, 2023
@yusefnapora yusefnapora merged commit f7a9871 into main Jan 20, 2023
@yusefnapora yusefnapora deleted the docs/capabilities-readme branch January 20, 2023 19:32
gobengo added a commit that referenced this pull request Apr 11, 2023
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]>
Peeja pushed a commit to storacha/upload-service that referenced this pull request Jan 17, 2025
🤖 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]>
Peeja pushed a commit to storacha/upload-service that referenced this pull request Jan 29, 2025
🤖 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docs: add examples & context to capabilities readme
3 participants