Skip to content

Commit

Permalink
fix: use digest as location claim content
Browse files Browse the repository at this point in the history
  • Loading branch information
joaosa committed Jun 3, 2024
1 parent 33c2202 commit e48b154
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
4 changes: 1 addition & 3 deletions packages/upload-api/src/blob/accept.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import * as Link from 'multiformats/link'
import { code as rawCode } from 'multiformats/codecs/raw'
import * as Server from '@ucanto/server'
import * as DID from '@ipld/dag-ucan/did'
import * as W3sBlob from '@web3-storage/capabilities/web3.storage/blob'
Expand Down Expand Up @@ -52,7 +50,7 @@ export function blobAcceptProvider(context) {
audience: DID.parse(space),
with: context.id.toDIDKey(),
nb: {
content: Link.create(rawCode, digest),
content: { digest: digest.bytes },
location: [createUrl.ok],
},
expiration: Infinity,
Expand Down
13 changes: 2 additions & 11 deletions packages/upload-api/test/handlers/web3.storage.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import * as API from '../../src/types.js'
import { equals } from 'uint8arrays'
import { create as createLink } from 'multiformats/link'
import { Absentee } from '@ucanto/principal'
import { Digest } from 'multiformats/hashes/digest'
import { sha256 } from 'multiformats/hashes/sha2'
import { code as rawCode } from 'multiformats/codecs/raw'
import { Assert } from '@web3-storage/content-claims/capability'
import * as BlobCapabilities from '@web3-storage/capabilities/blob'
import * as W3sBlobCapabilities from '@web3-storage/capabilities/web3.storage/blob'
Expand Down Expand Up @@ -604,10 +601,6 @@ export const test = {
const multihash = await sha256.digest(data)
const digest = multihash.bytes
const size = data.byteLength
const content = createLink(
rawCode,
new Digest(sha256.code, 32, digest, digest)
)

// create service connection
const connection = connect({
Expand Down Expand Up @@ -678,10 +671,8 @@ export const test = {
const delegation = blobAccept.fx.fork[0]
assert.equal(delegation.capabilities.length, 1)
assert.ok(delegation.capabilities[0].can, Assert.location.can)
assert.ok(
// @ts-expect-error nb unknown
content.equals(delegation.capabilities[0].nb.content)
)
// @ts-expect-error nb unknown
assert.deepEqual(digest, delegation.capabilities[0].nb.content.digest)
// @ts-expect-error nb unknown
const locations = delegation.capabilities[0].nb.location
assert.equal(locations.length, 1)
Expand Down

0 comments on commit e48b154

Please sign in to comment.