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

feat!: allow invocation configuration to be generated on demand #1507

Merged
merged 9 commits into from
Jun 18, 2024

Conversation

alanshaw
Copy link
Member

@alanshaw alanshaw commented Jun 17, 2024

Since the blob protocol landed, it's become harder to obtain a delegation to upload a specific CAR.

It was tricky before because of sharding, but assuming you created a CAR below the shard threshold, its easy enough to obtain a store/add delegation tied to the CAR CID.

With the blob protocol, we now generate an index, and blob/add that as well. It means we can't just create a CAR and delegate can: blob/add, nb: { link, size } for the CAR, because we also need to delegate blob/add for the index, but we don't know the index CID or it's size up front...

It's ok if the delegation is not restricted to the specific CAR, but for certain use cases it's necessary to delegate just what is needed.

This PR alters the client to allow invocation configuration to be generated on demand, when the proofs are required. This is a backwards compatible change.

So, for example instead of calling: uploadFile({ issuer, with, proofs }, file) you now call:

const configure = caps => {
  const proofs = []
  for (const { can, nb } of caps) {
    // decide if want to delegate and create delegation
    proofs.push(...)
  }
  if (!proofs.length) throw new Error('no proofs available')
  return { issuer, with, proofs }
}

uploadFile(configure, file)

...and configure will be called for each proof that is needed (blob/add, index/add and upload/add).

It means also that we no longer have to recommend folks to create a CAR, get the CID and then upload it, they can just use uploadFile and pass in the invocation config function to obtain the correct delegations when required.

@alanshaw alanshaw changed the title feat: allow invocation configuration to be generated on demand feat!: allow invocation configuration to be generated on demand Jun 17, 2024
Copy link
Contributor

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

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

LGTM, I am curious if there is other option explored with the client refactor we can consider.

Worth adding docs for this to the readme, maybe with an example

packages/upload-client/src/blob/add.js Show resolved Hide resolved
@alanshaw alanshaw merged commit fd74cbb into main Jun 18, 2024
5 checks passed
@alanshaw alanshaw deleted the feat/allow-invocation-configured-on-demand branch June 18, 2024 10:59
alanshaw pushed a commit that referenced this pull request Jun 19, 2024
🤖 I have created a release *beep* *boop*
---


##
[17.0.0](upload-client-v16.1.1...upload-client-v17.0.0)
(2024-06-19)


### ⚠ BREAKING CHANGES

* allow invocation configuration to be generated on demand
([#1507](#1507))

### Features

* allow invocation configuration to be generated on demand
([#1507](#1507))
([fd74cbb](fd74cbb))
* configure UnixFS encoder
([#1509](#1509))
([1a5e648](1a5e648))


### Fixes

* stop writing to DUDEWHERE
([#1500](#1500))
([cf0a1d6](cf0a1d6))

---
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>
alanshaw pushed a commit that referenced this pull request Jul 29, 2024
🤖 I have created a release *beep* *boop*
---


##
[16.0.0](w3up-client-v15.0.0...w3up-client-v16.0.0)
(2024-07-29)


### ⚠ BREAKING CHANGES

* allow invocation configuration to be generated on demand
([#1507](#1507))

### Features

* allow invocation configuration to be generated on demand
([#1507](#1507))
([fd74cbb](fd74cbb))
* configure UnixFS encoder
([#1509](#1509))
([1a5e648](1a5e648))


### Fixes

* badgers on README
([ffe49f2](ffe49f2))

---
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: Alan Shaw <alan.shaw@protocol.ai>
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.

2 participants