Skip to content

Commit 32806f9

Browse files
authored
feat: add store/get & upload/get capabilities (#82)
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 ```js { can: "store/get", with: "did:key:abc...", nb: { link: "bag...", } } ``` ### Response Error if `link` shard cid is not in space or... ```ts 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 ```js { can: "upload/get", with: "did:key:abc...", nb: { root: "bafyabc..." } } ``` ### Response `Error` if root is not in uploads for space or... ```ts 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 --------- Signed-off-by: Oli Evans <[email protected]>
1 parent 30893df commit 32806f9

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

w3-store.md

+124
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ The protocol is modeled as a set of capabilities which can be fulfilled by a [pr
2222
- [`store/` namespace](#store-namespace)
2323
- [`store/*`](#store)
2424
- [`store/add`](#storeadd)
25+
- [`store/get`](#storeget)
2526
- [`store/remove`](#storeremove)
2627
- [`store/list`](#storelist)
2728
- [`upload/` namespace](#upload-namespace)
2829
- [`upload/*`](#upload)
2930
- [`upload/add`](#uploadadd)
31+
- [`upload/get`](#uploadget)
3032
- [`upload/remove`](#uploadremove)
3133
- [`upload/list`](#uploadlist)
3234

@@ -143,6 +145,66 @@ If `status == 'upload'`, the response will include additional fields containing
143145

144146
The client should then make an HTTP `PUT` request to the `url` specified in the response, attaching all the included `headers`. The body of the request MUST be CAR data, whose size exactly equals the size specified in the `store/add` invocation's `size` caveat. Additionally, the CID of the uploaded CAR must match the invocation's `link` caveat. In other words, attempting to upload any data other than that authorized by the `store/add` invocation will fail.
145147

148+
### `store/get`
149+
150+
> Get metadata about a CAR shard from a space
151+
152+
The `store/get` capability can be invoked to get metadata about a CAR from a [space](#spaces).
153+
154+
This may be used to check for inclusion, or to get the `size` and `origin` properties for a shard.
155+
156+
#### Derivations
157+
158+
`store/get` can be derived from a [`store/*`](#store) or [`*`][ucan-spec-top] capability with a matching `with` field.
159+
160+
#### Caveats
161+
162+
When invoking `store/get`, the `link` caveat must be set to the CID of the CAR file to get metadata for.
163+
164+
If a delegation contains a `link` caveat, an invocation derived from it must have the same CAR CID in its `link` field. A delegation without a `link` caveat may be invoked with any `link` value.
165+
166+
| `field` | `value` | `required?` | `context` |
167+
| --------- | --------------------------------- | ----------- | --------------------------------------------- |
168+
| `link` | CAR CID string, e.g. `bag...` | | The CID of the CAR to get metadata for |
169+
170+
#### Invocation
171+
172+
```js
173+
{
174+
can: "store/get",
175+
with: "did:key:abc...",
176+
nb: {
177+
link: "bag...",
178+
}
179+
}
180+
```
181+
182+
#### Responses
183+
184+
*Note*: This section is non-normative and subject to change, pending the [formalization of receipts and invocations][invocation-spec-pr].
185+
186+
Executing a `store/get` invocation with a service provider should return a response object.
187+
188+
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.
189+
190+
On success, the response object will have the following shape:
191+
192+
```ts
193+
interface StoreListItem {
194+
/** CID of the stored CAR. */
195+
link: string
196+
197+
/** Size in bytes of the stored CAR */
198+
size: number
199+
200+
/** Link to a related CAR, used for sharded uploads */
201+
origin?: string,
202+
203+
/** ISO-8601 timestamp when CAR was added to the space */
204+
insertedAt: string,
205+
}
206+
```
207+
146208
### `store/remove`
147209

148210
> Remove a stored CAR from a space
@@ -340,6 +402,68 @@ interface UploadAddResponse {
340402
}
341403
```
342404

405+
### `upload/get`
406+
407+
> Get metadata about a upload from a space
408+
409+
The `upload/get` capability can be invoked to get metadata about an upload from a [space](#spaces).
410+
411+
This may be used to check for inclusion, or to get the set of CAR shards associated with a root CID.
412+
413+
The `with` resource URI must be set to the DID of the space to get the upload metadata from.
414+
415+
#### Derivations
416+
417+
`upload/get` can be derived from an [`upload/*`](#upload) or [`*`][ucan-spec-top] capability with a matching `with` resource URI.
418+
419+
#### Caveats
420+
421+
The `root` caveat must contain the root CID of the item to get metadata for.
422+
423+
| `field` | `value` | `required?` | `context` |
424+
| --------- | --------------------------------- | ----------- | ------------------------------------------------------------- |
425+
| `root` | data CID string, e.g. `bafy...` | | The root CID of the upload to get metadata for |
426+
427+
#### Invocation
428+
429+
To invoke `upload/get`, an agent prepares a UCAN with the following shape:
430+
431+
```js
432+
{
433+
can: "upload/get",
434+
with: "did:key:abc...",
435+
nb: {
436+
root: "bafyabc..."
437+
}
438+
}
439+
```
440+
441+
#### Responses
442+
443+
*Note*: This section is non-normative and subject to change, pending the [formalization of receipts and invocations][invocation-spec-pr].
444+
445+
Executing an `upload/get` invocation with a service provider should return a response object.
446+
447+
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.
448+
449+
On success, the response object will have the following shape:
450+
451+
```ts
452+
interface UploadListItem {
453+
/** Root CID of the uploaded data item. */
454+
root: string
455+
456+
/** CIDs of CARs that contain the complete DAG for the uploaded data item. */
457+
shards: string[]
458+
459+
/** ISO-8601 timestamp when the upload was added to the space. */
460+
insertedAt: string,
461+
462+
/** ISO-8601 timestamp when the upload entry was last modified. */
463+
updatedAt: string,
464+
}
465+
```
466+
343467
### `upload/remove`
344468

345469
> Remove an upload from a space.

0 commit comments

Comments
 (0)