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: add store/get & upload/get capabilities #82

Merged
merged 3 commits into from
Dec 18, 2023
Merged

feat: add store/get & upload/get capabilities #82

merged 3 commits into from
Dec 18, 2023

Conversation

olizilla
Copy link
Contributor

@olizilla olizilla commented Oct 4, 2023

These capabilities are intended for checking inclusion, or getting the additional properties we store. This will allow clients to verify all the shards for an upload have been removed before removing an upload.

store/get delegation

{
  can: "store/get",
  with: "did:key:abc...",
  nb: {
    link: "bag...",
  }
}

Response

Error if link shard cid is not in space or...

interface StoreListItem {
  /** CID of the stored CAR. */
  link: string

  /** Size in bytes of the stored CAR */
  size: number

  /** Link to a related CAR, used for sharded uploads */
  origin?: string,

  /** ISO-8601 timestamp when CAR was added to the space */
  insertedAt: string,
}

upload/get delegation

{
  can: "upload/get",
  with: "did:key:abc...",
  nb: {
    root: "bafyabc..."
  }
}

Response

Error if root is not in uploads for space or...

interface UploadListItem {
  /** Root CID of the uploaded data item. */
  root: string

  /** CIDs of CARs that contain the complete DAG for the uploaded data item. */
  shards: string[]

  /** ISO-8601 timestamp when the upload was added to the space. */
  insertedAt: string,

  /** ISO-8601 timestamp when the upload entry was last modified. */
  updatedAt: string,
}

see also: storacha/w3up#942

License: MIT

These capabilities are intended for checking inclusion and allowing users to verify all the shards for an upload have been removed when removing an upload.

see also: storacha/w3up#942

License: MIT
Signed-off-by: Oli Evans <[email protected]>
License: MIT
Signed-off-by: Oli Evans <[email protected]>
Copy link
Member

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

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

Looks fine but we should update all of these to not use strings for CIDs....

Copy link
Contributor

@travis travis left a comment

Choose a reason for hiding this comment

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

could update these post-merge of course, but I do think these changes need doing


Executing a `store/get` invocation with a service provider should return a response object.

If a failure occurs, the response will have an `error` field with a value of `true`, and a `message` string field with details about the error.
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe I'm misunderstanding this, but won't the error response look like:

{ error: { name: "ErrorName", message: "An error message" } }

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah yes you right. I was blending this in with the rest of this spec, but things have changed!

I can't find a place in our other specs where we document the expected output shapes which seems odd too.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeaaaa I agree, I think it's a hole in our specs that we haven't documented the input/return types across the board, maybe even a DX issue worth fixing asap?


If a failure occurs, the response will have an `error` field with a value of `true`, and a `message` string field with details about the error.

On success, the response object will have the following shape:
Copy link
Contributor

Choose a reason for hiding this comment

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

and similarly, I think the response will look like:

{ ok: {link: "bagy...", size: 42, insertedAt: "2023-01-01T01:01:01" } }

w3-store.md Outdated

#### Caveats

The `root` caveat must contain the root CID of the data item to remove.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/remove/return/


| `field` | `value` | `required?` | `context` |
| --------- | --------------------------------- | ----------- | ------------------------------------------------------------- |
| `root` | data CID string, e.g. `bafy...` | | The root CID of the upload to get metadata for |
Copy link
Contributor

Choose a reason for hiding this comment

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

required should be true I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, but i think we need to make it clearer that these tables are referring to "when used as an invocation", as the root is not required in the schema, as folks should be allowed to make a delegation that grants you upload/get on any root. same for store.get. My gut feel is we should make the tables present the ucanto schema rather than the "when used as invocation" form.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(yep, as i deliberately differed from the other items in this spec where they have marked an optional field as required)

Copy link
Contributor

Choose a reason for hiding this comment

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

ahhhh got it, I agree re: presenting ucanto schema!!


Executing an `upload/get` invocation with a service provider should return a response object.

If a failure occurs, the response will have an `error` field with a value of `true`, and a `message` string field with details about the error.
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto re: response formats in this section

olizilla added a commit to storacha/w3up that referenced this pull request Oct 19, 2023
Capability definitions to allow clients to check for inclusion of cid in
store shards or upload roots. Also allows client to fetch the additional
properties we store. This will, for example, let a client verify all
shards for an upload have been removed before removing an upload.

_I'm aiming to simplify things with this PR so that we return insertedAt
info on the Upload/Store ListItem types, and return the same object
shape for a single object get. If this is pleasing, then I will continue
in this direction and make Remove also return the same shape if it
removes something_

TODO:
- [x] spec update storacha/specs#82
- [x] tests


License: MIT

---------

Signed-off-by: Oli Evans <[email protected]>
Co-authored-by: Alan Shaw <[email protected]>
w3-store.md Outdated Show resolved Hide resolved
@olizilla olizilla merged commit 32806f9 into main Dec 18, 2023
2 checks passed
@olizilla olizilla deleted the get-caps branch December 18, 2023 16:22
@olizilla
Copy link
Contributor Author

implemented in storacha/w3up#1178

@joaosa joaosa mentioned this pull request May 30, 2024
joaosa added a commit that referenced this pull request Jun 5, 2024
Adds the `blob/get` capability spec which is analogous to
#82

---------

Co-authored-by: Vasco Santos <[email protected]>
Co-authored-by: Alan Shaw <[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.

3 participants