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 blob/get #126

Merged
merged 13 commits into from
Jun 5, 2024
98 changes: 98 additions & 0 deletions w3-blob.md
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,104 @@ The `out.ok.size` MUST be set to the number of bytes that were freed from the sp

Receipt MUST not have any effects.

## Get Blob

Authorized agent MAY invoke `/space/content/get/blob` capability on the [space] subject (`sub` field) to get Blobs added to it at the time of invocation.

This may be used to check for inclusion, or to get the `size` property for a shard.
joaosa marked this conversation as resolved.
Show resolved Hide resolved

### Get Blob Invocation Example

Shown Invocation example illustrates Alice getting a blob stored on their space.

```js
{
joaosa marked this conversation as resolved.
Show resolved Hide resolved
"cmd": "/space/content/get/blob",
"sub": "did:key:zAlice",
"iss": "did:key:zAlice",
"aud": "did:web:web3.storage",
"args": {
// multihash of the blob as byte array
"digest": { "/": { "bytes": "mEi...sfKg" } },
}
}
```

### Get Blob Receipt Example

Shows an example receipt for the above `/space/content/get/blob` capability invocation.

> ℹ️ We use `// "/": "bafy..` comments to denote CID of the parent object.

```js
{ // "/": "bafy..get",
joaosa marked this conversation as resolved.
Show resolved Hide resolved
"iss": "did:web:web3.storage",
"aud": "did:key:zAlice",
"cmd": "/ucan/assert/result"
"sub": "did:web:web3.storage",
"args": {
// refers to the invocation from the example
"ran": { "/": "bafy..get" },
"out": {
"ok": {
"blob": {
"size": 100,
"content": { "/": { "bytes": "mEi...sfKg" } },
}
}
},
// set of tasks to be scheduled.
joaosa marked this conversation as resolved.
Show resolved Hide resolved
"next": []
}
}
```

### Get Blob Capability

#### Get Blob Capability Schema

```ts
type GetBlob = {
cmd: "/space/content/get/blob"
sub: SpaceDID
args: {
digest: Multihash
}
}

type Multihash = bytes
type SpaceDID = string
```

##### Get Digest

The `args.digest` field MUST be a [multihash] digest of the blob payload bytes. Implementation SHOULD support SHA2-256 algorithm. Implementation MAY in addition support other hashing algorithms.

### Get Blob Receipt

#### Get Blob Receipt Schema

```ts
type GetBlobReceipt = {
out: Result<GetBlobOk, GetBlobError>
next: []
}

type GetBlobOk = {
blob: blob
Copy link
Contributor

Choose a reason for hiding this comment

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

I saw in the implementation you add the cause here. And I actually think that is nice, so also should be in the spec response

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes perfect sense! adding it

joaosa marked this conversation as resolved.
Show resolved Hide resolved
}

type ISO8601Date = string

type GetBlobError = {
message: string
}
joaosa marked this conversation as resolved.
Show resolved Hide resolved
```

##### Get Blob Effects

Receipt MUST not have any effects.
joaosa marked this conversation as resolved.
Show resolved Hide resolved

# Coordination

## Publishing Blob
Expand Down
Loading