From e48b154efed933a80e2f10d78813d204626396c5 Mon Sep 17 00:00:00 2001 From: Joao Andrade Date: Mon, 3 Jun 2024 12:23:52 +0100 Subject: [PATCH] fix: use digest as location claim content --- packages/upload-api/src/blob/accept.js | 4 +--- packages/upload-api/test/handlers/web3.storage.js | 13 ++----------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/packages/upload-api/src/blob/accept.js b/packages/upload-api/src/blob/accept.js index e7a3b5618..6e2d31b7a 100644 --- a/packages/upload-api/src/blob/accept.js +++ b/packages/upload-api/src/blob/accept.js @@ -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' @@ -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, diff --git a/packages/upload-api/test/handlers/web3.storage.js b/packages/upload-api/test/handlers/web3.storage.js index 6e59bdd38..e5ed85fe8 100644 --- a/packages/upload-api/test/handlers/web3.storage.js +++ b/packages/upload-api/test/handlers/web3.storage.js @@ -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' @@ -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({ @@ -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)