Skip to content

Commit

Permalink
feat: use digest in blob/accept location commitment (#1480)
Browse files Browse the repository at this point in the history
This upgrades the content-claims dependency, allowing us to use
multihash digest in location claim. It brings implementation in line
with the spec.
  • Loading branch information
Alan Shaw authored May 30, 2024
1 parent 5394ed5 commit ade45eb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/filecoin-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
"@ucanto/server": "^10.0.0",
"@ucanto/transport": "^9.1.1",
"@web3-storage/capabilities": "workspace:^",
"@web3-storage/content-claims": "^4.0.4",
"@web3-storage/content-claims": "^5.0.0",
"@web3-storage/data-segment": "^4.0.0",
"fr32-sha2-256-trunc254-padded-binary-tree-multihash": "^3.3.0",
"p-map": "^6.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/upload-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
"@web3-storage/access": "workspace:^",
"@web3-storage/blob-index": "workspace:^",
"@web3-storage/capabilities": "workspace:^",
"@web3-storage/content-claims": "^4.0.4",
"@web3-storage/content-claims": "^5.0.0",
"@web3-storage/did-mailto": "workspace:^",
"@web3-storage/filecoin-api": "workspace:^",
"multiformats": "^12.1.2",
Expand Down
5 changes: 1 addition & 4 deletions packages/upload-api/src/blob/accept.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import * as Server from '@ucanto/server'
import * as DID from '@ipld/dag-ucan/did'
import * as W3sBlob from '@web3-storage/capabilities/web3.storage/blob'
import { Assert } from '@web3-storage/content-claims/capability'
import { create as createLink } from 'multiformats/link'
import { Invocation } from '@ucanto/core'
import * as Digest from 'multiformats/hashes/digest'
import { code as rawCode } from 'multiformats/codecs/raw'
import * as API from '../types.js'
import {
AllocatedMemoryHadNotBeenWrittenTo,
Expand Down Expand Up @@ -40,7 +38,6 @@ export function blobAcceptProvider(context) {
}

const digest = Digest.decode(blob.digest)
const content = createLink(rawCode, digest)
const createUrl = await context.blobsStorage.createDownloadUrl(
digest.bytes
)
Expand All @@ -53,7 +50,7 @@ export function blobAcceptProvider(context) {
audience: DID.parse(space),
with: context.id.toDIDKey(),
nb: {
content,
content: { digest: digest.bytes },
location: [createUrl.ok],
},
expiration: Infinity,
Expand Down
2 changes: 1 addition & 1 deletion packages/upload-api/test/handlers/web3.storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ export const test = {
assert.equal(delegation.capabilities.length, 1)
assert.ok(delegation.capabilities[0].can, Assert.location.can)
// @ts-expect-error nb unknown
assert.ok(delegation.capabilities[0].nb.content.equals(content))
assert.ok(equals(delegation.capabilities[0].nb.content.digest, content.multihash.bytes))
// @ts-expect-error nb unknown
const locations = delegation.capabilities[0].nb.location
assert.equal(locations.length, 1)
Expand Down
26 changes: 9 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ade45eb

Please sign in to comment.