Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/access-client/test/agent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ describe('Agent', function () {
await bob.importSpaceFromDelegation(proof)
await bob.setCurrentSpace(space.did())

const proofs = bob.proofs([{ can: 'store/add', with: space.did() }])
const proofs = bob.proofs([{ can: 'space/blob/add', with: space.did() }])
assert(proofs.length)
})

Expand Down Expand Up @@ -354,7 +354,7 @@ describe('Agent', function () {
'RSA_DECRYPT_OAEP_3072_SHA256'
)
}
const proofs = bob.proofs([{ can: 'store/add', with: space.did() }])
const proofs = bob.proofs([{ can: 'space/blob/add', with: space.did() }])
assert(proofs.length)
})

Expand All @@ -373,13 +373,13 @@ describe('Agent', function () {
const proof = await alice.delegate({
audience: bob,
audienceMeta: { name: 'videos', type: 'app' },
abilities: ['store/add'],
abilities: ['space/blob/add'],
})

await bob.importSpaceFromDelegation(proof)
await bob.setCurrentSpace(space.did())

const proofs = bob.proofs([{ can: 'store/add', with: space.did() }])
const proofs = bob.proofs([{ can: 'space/blob/add', with: space.did() }])
assert(proofs.length)
})

Expand Down Expand Up @@ -606,7 +606,7 @@ describe('Agent', function () {
await alice.setCurrentSpace(space.did())

const delegation = await alice.delegate({
abilities: ['store/add'],
abilities: ['space/blob/add'],
audience: bob.issuer,
audienceMeta: {
name: 'sss',
Expand All @@ -633,7 +633,7 @@ describe('Agent', function () {
await bob.importSpaceFromDelegation(bobAuth)
await bob.setCurrentSpace(bobSpace.did())
const bobDelegation = await bob.delegate({
abilities: ['store/add'],
abilities: ['space/blob/add'],
audience: mallory.issuer,
audienceMeta: {
name: 'sss',
Expand Down
4 changes: 2 additions & 2 deletions packages/access-client/test/encoding.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('Encoding', function () {
audience: bob,
capabilities: [
{
can: 'store/add',
can: 'space/blob/add',
with: alice.did(),
},
],
Expand All @@ -101,7 +101,7 @@ describe('Encoding', function () {

assert.deepEqual(delegation.capabilities, [
{
can: 'store/add',
can: 'space/blob/add',
with: alice.did(),
},
])
Expand Down
6 changes: 3 additions & 3 deletions packages/capabilities/src/access.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const claim = capability({
export const delegate = capability({
can: 'access/delegate',
/**
* Field MUST be a space DID with a storage provider. Delegation will be stored just like any other DAG stored using store/add capability.
* Field MUST be a space DID with a storage provider. Delegation will be stored just like any other DAG stored using space/blob/add capability.
*
* @see https://github.com/storacha/specs/blob/main/w3-access.md#delegate-with
*/
Expand Down Expand Up @@ -179,8 +179,8 @@ function subsetsNbDelegations(claim, proof) {
* Checks that set of requested capabilities is a subset of the capabilities
* that had been allowed by the owner or the delegate.
*
* ⚠️ This function does not currently check that say `store/add` is allowed
* when say `store/*` was delegated, because it seems very unlikely that we
* ⚠️ This function does not currently check that say `space/blob/add` is allowed
* when say `space/blob/*` was delegated, because it seems very unlikely that we
* will ever encounter delegations for `access/authorize` at all.
*
* @param {Schema.Infer<CapabilityRequest>[]} claim
Expand Down
1 change: 0 additions & 1 deletion packages/capabilities/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ export const abilitiesAsStrings = [
UploadShard.shard.can,
UploadShard.list.can,
Store.store.can,
Store.add.can,
Store.get.can,
Store.remove.can,
Store.list.can,
Expand Down
5 changes: 2 additions & 3 deletions packages/capabilities/src/space.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ export const space = capability({
})

/**
* `space/info` can be derived from any of the `store/*`
* `space/info` can be derived from any of the `store/*` or `upload/*`
* capability that has matching `with`. This allows store service
* to identify account based on any user request.
*/
export const info = Store.add
.or(Store.list)
export const info = Store.list
.or(Store.remove)
.or(Upload.add)
.or(Upload.list)
Expand Down
55 changes: 1 addition & 54 deletions packages/capabilities/src/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,59 +33,6 @@ export const store = capability({
derives: equalWith,
})

/**
* `store/add` capability allows agent to store a CAR file into a (memory) space
* identified by did:key in the `with` field. Agent must precompute CAR locally
* and provide it's CID and size using `nb.link` and `nb.size` fields, allowing
* a service to provision a write location for the agent to PUT or POST desired
* CAR into.
*
* @deprecated
*/
export const add = capability({
can: 'store/add',
/**
* DID of the (memory) space where CAR is intended to
* be stored.
*/
with: SpaceDID,
nb: Schema.struct({
/**
* CID of the CAR file to be stored. Service will provision write target
* for this exact CAR file for agent to PUT or POST it. Attempt to write
* any other content will fail.
*/
link: CARLink,
/**
* Size of the CAR file to be stored. Service will provision write target
* for this exact size. Attempt to write a larger CAR file will fail.
*/
size: Schema.integer(),
/**
* Agent may optionally provide a link to a related CAR file using `origin`
* field. This is useful when storing large DAGs, agent could shard it
* across multiple CAR files and then link each shard with a previous one.
*
* Providing this relation tells service that given CAR is shard of the
* larger DAG as opposed to it being intentionally partial DAG. When DAG is
* not sharded, there will be only one `store/add` with `origin` left out.
*/
origin: Link.optional(),
}),
derives: (claim, from) => {
const result = equalLink(claim, from)
if (result.error) {
return result
} else if (claim.nb.size !== undefined && from.nb.size !== undefined) {
return claim.nb.size > from.nb.size
? fail(`Size constraint violation: ${claim.nb.size} > ${from.nb.size}`)
: ok({})
} else {
return ok({})
}
},
})

/**
* Capability to get store metadata by shard CID.
* Use to check for inclusion, or get shard size and origin
Expand Down Expand Up @@ -171,7 +118,7 @@ export const list = capability({
})

/** @deprecated */
export const all = add.or(remove).or(list)
export const all = remove.or(list)

// ⚠️ We export imports here so they are not omitted in generated typedes
// @see https://github.com/microsoft/TypeScript/issues/51548
Expand Down
42 changes: 0 additions & 42 deletions packages/capabilities/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,53 +877,12 @@ export interface RecordNotFound extends Error {
/** @deprecated */
export type Store = InferInvokedCapability<typeof StoreCaps.store>
/** @deprecated */
export type StoreAdd = InferInvokedCapability<typeof StoreCaps.add>
/** @deprecated */
export type StoreGet = InferInvokedCapability<typeof StoreCaps.get>
/** @deprecated */
export type StoreRemove = InferInvokedCapability<typeof StoreCaps.remove>
/** @deprecated */
export type StoreList = InferInvokedCapability<typeof StoreCaps.list>

/** @deprecated */
export type StoreAddSuccess = StoreAddSuccessDone | StoreAddSuccessUpload

/** @deprecated */
export type StoreAddSuccessStatusUpload = 'upload'
/** @deprecated */
export type StoreAddSuccessStatusDone = 'done'

/** @deprecated */
export interface StoreAddSuccessResult {
/**
* Status of the item to store. A "done" status indicates that it is not
* necessary to upload the item. An "upload" status indicates that the item
* should be uploaded to the provided URL.
*/
status: StoreAddSuccessStatusUpload | StoreAddSuccessStatusDone
/**
* Total bytes allocated in the space to accommodate this stored item.
* May be zero if the item is _already_ stored in _this_ space.
*/
allocated: number
/** DID of the space this item will be stored in. */
with: DID
/** CID of the item. */
link: CARLink
}

/** @deprecated */
export interface StoreAddSuccessDone extends StoreAddSuccessResult {
status: StoreAddSuccessStatusDone
}

/** @deprecated */
export interface StoreAddSuccessUpload extends StoreAddSuccessResult {
status: StoreAddSuccessStatusUpload
url: ToString<URL>
headers: Record<string, string>
}

/** @deprecated */
export interface StoreRemoveSuccess {
size: number
Expand Down Expand Up @@ -1256,7 +1215,6 @@ export type ServiceAbilityArray = [
UploadShard['can'],
UploadShardList['can'],
Store['can'],
StoreAdd['can'],
StoreGet['can'],
StoreRemove['can'],
StoreList['can'],
Expand Down
4 changes: 2 additions & 2 deletions packages/capabilities/src/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ const CARLink = Link.match({ code: CAR.code, version: 1 })
* identified by the given `root`.
*
* Usually when agent wants to upload a DAG it will encode it as a one or more
* CAR files (shards) and invoke `store/add` capability for each one. Once all
* CAR files (shards) and invoke `space/blob/add` capability for each one. Once all
* shards are stored it will invoke `upload/add` capability (providing link to
* a DAG root and all the shards) to add it the upload list.
*
* That said `upload/add` could be invoked without invoking `store/add`s e.g.
* That said `upload/add` could be invoked without invoking `space/blob/add`s e.g.
* because another (memory) space may already have those CARs.
*
* Note: If DAG with the given root is already in the upload list, invocation
Expand Down
4 changes: 2 additions & 2 deletions packages/capabilities/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function containedWithin(child, parent, constraint) {
}

/**
* @template {API.ParsedCapability<"store/add"|"store/get"|"store/remove", API.URI<'did:'>, {link?: API.Link<unknown, number, number, 0|1>}>} T
* @template {API.ParsedCapability<"space/blob/add"|"space/blob/get"|"space/blob/remove"|"store/get"|"store/remove", API.URI<'did:'>, {link?: API.Link<unknown, number, number, 0|1>}>} T
* @param {T} claimed
* @param {T} delegated
* @returns {API.Result<{}, API.Failure>}
Expand Down Expand Up @@ -270,7 +270,7 @@ function parseAbility(ability) {

/**
*
* TODO: needs to account for caps derived from different namespaces like 'account/info' can be derived from 'store/add'
* TODO: needs to account for caps derived from different namespaces like 'account/info' can be derived from 'space/blob/add'
*
* @param {import('@ucanto/interface').Ability} parent
* @param {import('@ucanto/interface').Ability} child
Expand Down
8 changes: 4 additions & 4 deletions packages/capabilities/test/capabilities/access.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ describe('access capabilities', function () {
with: alice.did(),
nb: {
iss: 'did:mailto:web.mail:alice',
att: [{ can: 'store/add' }],
att: [{ can: 'space/blob/add' }],
},
proofs: [
await Access.authorize.delegate({
Expand All @@ -244,7 +244,7 @@ describe('access capabilities', function () {
with: alice.did(),
nb: {
iss: 'did:mailto:web.mail:alice',
att: [{ can: 'store/add' }, { can: 'store/remove' }],
att: [{ can: 'space/blob/add' }, { can: 'space/blob/remove' }],
},
}),
],
Expand Down Expand Up @@ -594,7 +594,7 @@ describe('access capabilities', function () {
nb: {
iss: 'did:mailto:web.mail:alice',
aud: bob.did(),
att: [{ can: 'store/add' }],
att: [{ can: 'space/blob/add' }],
cause: parseLink('bafkqaaa'),
},
proofs: [
Expand All @@ -604,7 +604,7 @@ describe('access capabilities', function () {
with: alice.did(),
nb: {
iss: 'did:mailto:web.mail:alice',
att: [{ can: 'store/add' }, { can: 'store/remove' }],
att: [{ can: 'space/blob/add' }, { can: 'space/blob/remove' }],
},
}),
],
Expand Down
Loading
Loading