Skip to content

Commit

Permalink
fix: blob remove should have args digest instead of content
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Apr 22, 2024
1 parent 1331af0 commit a1486fe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions packages/capabilities/src/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,21 @@ export const remove = capability({
/**
* A multihash digest of the blob payload bytes, uniquely identifying blob.
*/
content: Schema.bytes(),
digest: Schema.bytes(),
}),
derives: (claimed, delegated) => {
if (claimed.with !== delegated.with) {
return fail(
`Expected 'with: "${delegated.with}"' instead got '${claimed.with}'`
)
} else if (
delegated.nb.content &&
!equals(delegated.nb.content, claimed.nb.content)
delegated.nb.digest &&
!equals(delegated.nb.digest, claimed.nb.digest)
) {
return fail(
`Link ${
claimed.nb.content ? `${claimed.nb.content}` : ''
} violates imposed ${delegated.nb.content} constraint.`
claimed.nb.digest ? `${claimed.nb.digest}` : ''
} violates imposed ${delegated.nb.digest} constraint.`
)
}
return ok({})
Expand Down
4 changes: 2 additions & 2 deletions packages/upload-api/src/blob/remove.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { RecordNotFoundErrorName } from '../errors.js'
export function blobRemoveProvider(context) {
return Server.provide(Blob.remove, async ({ capability }) => {
const space = capability.with
const { content } = capability.nb
const res = await context.allocationsStorage.remove(space, content)
const { digest } = capability.nb
const res = await context.allocationsStorage.remove(space, digest)
if (res.error && res.error.name === RecordNotFoundErrorName) {
return {
ok: {
Expand Down
4 changes: 2 additions & 2 deletions packages/upload-api/test/handlers/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export const test = {
audience: context.id,
with: spaceDid,
nb: {
content: digest,
digest,
},
proofs: [proof],
})
Expand Down Expand Up @@ -408,7 +408,7 @@ export const test = {
audience: context.id,
with: spaceDid,
nb: {
content: digest,
digest,
},
proofs: [proof],
})
Expand Down

0 comments on commit a1486fe

Please sign in to comment.