Skip to content

Commit

Permalink
fix: upload API test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alanshaw committed Nov 4, 2024
1 parent c747f49 commit 6b0d72d
Show file tree
Hide file tree
Showing 65 changed files with 1,277 additions and 2,532 deletions.
6 changes: 3 additions & 3 deletions packages/access-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@
"@ipld/car": "^5.1.1",
"@ipld/dag-ucan": "^3.4.0",
"@scure/bip39": "^1.2.1",
"@storacha/capabilities": "workspace:^",
"@storacha/did-mailto": "workspace:^",
"@storacha/one-webcrypto": "^1.0.1",
"@ucanto/client": "^9.0.1",
"@ucanto/core": "^10.0.1",
"@ucanto/interface": "^10.0.1",
"@ucanto/principal": "^9.0.1",
"@ucanto/transport": "^9.1.1",
"@ucanto/validator": "^9.0.2",
"@storacha/capabilities": "workspace:^",
"@storacha/did-mailto": "workspace:^",
"bigint-mod-arith": "^3.1.2",
"conf": "11.0.2",
"multiformats": "^12.1.2",
Expand All @@ -118,6 +118,7 @@
"uint8arrays": "^4.0.6"
},
"devDependencies": {
"@storacha/eslint-config": "workspace:^",
"@types/assert": "^1.5.6",
"@types/inquirer": "^9.0.4",
"@types/mocha": "^10.0.1",
Expand All @@ -126,7 +127,6 @@
"@types/varint": "^6.0.1",
"@types/ws": "^8.5.4",
"@ucanto/server": "^10.0.0",
"@storacha/eslint-config": "workspace:^",
"assert": "^2.0.0",
"mocha": "^10.2.0",
"playwright-test": "^12.3.4",
Expand Down
4 changes: 2 additions & 2 deletions packages/access-client/src/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class Agent {
}
}
const receipt = await this.invokeAndExecute(UCAN.revoke, {
// per https://github.com/storacha/upload-service/blob/main/packages/capabilities/src/ucan.js#L38C6-L38C6 the resource here should be
// per https://github.com/storacha/w3up/blob/main/packages/capabilities/src/ucan.js#L38C6-L38C6 the resource here should be
// the current issuer - using the space DID here works for simple cases but falls apart when a delegee tries to revoke a delegation
// they have re-delegated, since they don't have "ucan/revoke" capabilities on the space
with: this.issuer.did(),
Expand Down Expand Up @@ -577,7 +577,7 @@ export class Agent {
// @ts-ignore
capability: cap.create({
with: space,
nb: options.nb,
nb: 'nb' in options ? options.nb : undefined,
}),
issuer: this.issuer,
proofs: [...proofs],
Expand Down
2 changes: 1 addition & 1 deletion packages/access-client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export type InvokeOptions<
Match<{ can: A; with: R & Resource; nb: Caveats }, UnknownMatch>
>
> = UCANBasicOptions &
InferNb<InferInvokedCapability<CAP>['nb']> & {
Omit<InferInvokedCapability<CAP>, 'can'|'with'> & {
/**
* Resource for the capability, normally a Space DID
* Defaults to the current selected Space
Expand Down
4 changes: 2 additions & 2 deletions packages/blob-index/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@
},
"dependencies": {
"@ipld/dag-cbor": "^9.0.6",
"@storacha/capabilities": "workspace:^",
"@storacha/one-webcrypto": "^1.0.1",
"@ucanto/core": "^10.0.1",
"@ucanto/interface": "^10.0.1",
"@storacha/capabilities": "workspace:^",
"carstream": "^2.1.0",
"multiformats": "^13.0.1",
"uint8arrays": "^5.0.3"
},
"devDependencies": {
"@ucanto/transport": "^9.1.1",
"@storacha/eslint-config": "workspace:^",
"@ucanto/transport": "^9.1.1",
"c8": "^7.14.0",
"entail": "^2.1.2",
"typescript": "5.2.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/capabilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@
"uint8arrays": "^5.0.3"
},
"devDependencies": {
"@storacha/eslint-config": "workspace:^",
"@types/assert": "^1.5.6",
"@types/mocha": "^10.0.0",
"@types/node": "^20.8.4",
"@storacha/eslint-config": "workspace:^",
"assert": "^2.0.0",
"mocha": "^10.2.0",
"playwright-test": "^12.3.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/capabilities/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import * as Filecoin from '@storacha/capabilities/filecoin'
import * as Aggregator from '@storacha/capabilities/filecoin/aggregator'
import * as DealTracker from '@storacha/capabilities/filecoin/deal-tracker'
import * as Dealer from '@storacha/capabilities/filecoin/dealer'
import * as Index from '@storacha/capabilities/index'
import * as Index from '@storacha/capabilities/space/index'

// This package has a "main" entrypoint but we recommend the usage of the specific imports above
```
Expand Down
2 changes: 1 addition & 1 deletion packages/capabilities/src/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const allocate = capability({
/** Blob to allocate. */
blob: content,
/** Link to the add blob task that initiated the allocation. */
cause: Link,
cause: Schema.link({ version: 1 }),
/** DID of the user space where the allocation takes place. */
space: SpaceDID,
}),
Expand Down
6 changes: 3 additions & 3 deletions packages/capabilities/src/space/blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*
* @module
*/
import { equals as SpaceBlob } from 'uint8arrays/equals'
import { equals as SpaceBlobCapabilities } from 'uint8arrays/equals'
import { capability, Schema, fail, ok } from '@ucanto/validator'
import { equalBlob, equalWith, SpaceDID } from '../utils.js'

Expand Down Expand Up @@ -94,7 +94,7 @@ export const remove = capability({
)
} else if (
delegated.nb.digest &&
!SpaceBlob(delegated.nb.digest, claimed.nb.digest)
!SpaceBlobCapabilities(delegated.nb.digest, claimed.nb.digest)
) {
return fail(
`Link ${
Expand Down Expand Up @@ -160,7 +160,7 @@ export const get = capability({
)
} else if (
delegated.nb.digest &&
!SpaceBlob(delegated.nb.digest, claimed.nb.digest)
!SpaceBlobCapabilities(delegated.nb.digest, claimed.nb.digest)
) {
return fail(
`Link ${
Expand Down
24 changes: 11 additions & 13 deletions packages/capabilities/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ export interface BlobModel {
}

// Blob add
export interface BlobAddSuccess {
export interface SpaceBlobAddSuccess {
site: UCANAwait<'.out.ok.site'>
}

Expand All @@ -550,39 +550,37 @@ export interface AwaitError extends Ucanto.Failure {
}

// TODO: We need Ucanto.Failure because provideAdvanced can't handle errors without it
export type BlobAddFailure =
export type SpaceBlobAddFailure =
| BlobSizeOutsideOfSupportedRange
| AwaitError
| StorageGetError
| Ucanto.Failure

export interface BlobListItem {
export interface BlobItem {
blob: BlobModel
cause: Link
insertedAt: ISO8601Date
}

// Blob remove
export interface BlobRemoveSuccess {
export interface SpaceBlobRemoveSuccess {
size: number
}

// TODO: make types more specific
export type BlobRemoveFailure = Ucanto.Failure
export type SpaceBlobRemoveFailure = Ucanto.Failure

// Blob list
export interface BlobListSuccess extends ListResponse<BlobListItem> {}
export interface SpaceBlobListSuccess extends ListResponse<BlobItem> {}

// TODO: make types more specific
export type BlobListFailure = Ucanto.Failure
export type SpaceBlobListFailure = Ucanto.Failure

// Blob get
export interface BlobGetSuccess {
blob: { digest: Uint8Array; size: number }
cause: UnknownLink
}
export interface SpaceBlobGetSuccess extends BlobItem {}

// TODO: make types more specific
export type BlobGetFailure = Ucanto.Failure
export type SpaceBlobGetFailure = Ucanto.Failure

// Blob allocate
export interface BlobAllocateSuccess {
Expand All @@ -593,7 +591,7 @@ export interface BlobAllocateSuccess {
export interface BlobAddress {
url: ToString<URL>
headers: Record<string, string>
expiresAt: ISO8601Date
expires: number
}

// If user space has not enough space to allocate the blob.
Expand Down
3 changes: 1 addition & 2 deletions packages/capabilities/src/utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as API from '@ucanto/interface'
import { DID, Schema, fail, ok } from '@ucanto/validator'
import { equals } from 'uint8arrays/equals'

/** @import * as API from '@ucanto/interface' */

// e.g. did:web:storacha.network or did:web:staging.storacha.network
export const ProviderDID = DID.match({ method: 'web' })

Expand Down
2 changes: 1 addition & 1 deletion packages/did-mailto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
"test-watch": "pnpm build && mocha --bail --timeout 10s --watch --parallel -n no-warnings -n experimental-vm-modules -n experimental-fetch --watch-files src,test"
},
"devDependencies": {
"@storacha/eslint-config": "workspace:^",
"@types/assert": "^1.5.6",
"@types/mocha": "^10.0.1",
"@storacha/eslint-config": "workspace:^",
"mocha": "^10.2.0",
"typescript": "5.2.2"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/filecoin-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,26 +155,26 @@
},
"dependencies": {
"@ipld/dag-ucan": "^3.4.0",
"@storacha/capabilities": "workspace:^",
"@ucanto/client": "^9.0.1",
"@ucanto/core": "^10.0.1",
"@ucanto/interface": "^10.0.1",
"@ucanto/server": "^10.0.0",
"@ucanto/transport": "^9.1.1",
"@storacha/capabilities": "workspace:^",
"@web3-storage/content-claims": "^5.0.0",
"@web3-storage/data-segment": "^5.2.0",
"fr32-sha2-256-trunc254-padded-binary-tree-multihash": "^3.3.0",
"p-map": "^6.0.0"
},
"devDependencies": {
"@storacha/eslint-config": "workspace:^",
"@storacha/filecoin-client": "workspace:^",
"@storacha/one-webcrypto": "^1.0.1",
"@types/assert": "^1.5.10",
"@types/mocha": "^10.0.1",
"@ucanto/client": "^9.0.1",
"@ucanto/principal": "^9.0.1",
"@web-std/blob": "^3.0.5",
"@storacha/eslint-config": "workspace:^",
"@storacha/filecoin-client": "workspace:^",
"c8": "^10.1.2",
"mocha": "^10.2.0",
"multiformats": "^12.1.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/filecoin-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@
],
"dependencies": {
"@ipld/dag-ucan": "^3.4.0",
"@storacha/capabilities": "workspace:^",
"@ucanto/client": "^9.0.1",
"@ucanto/core": "^10.0.1",
"@ucanto/interface": "^10.0.1",
"@ucanto/transport": "^9.1.1",
"@storacha/capabilities": "workspace:^"
"@ucanto/transport": "^9.1.1"
},
"devDependencies": {
"@ipld/dag-json": "^10.1.4",
"@storacha/eslint-config": "workspace:^",
"@types/assert": "^1.5.6",
"@types/mocha": "^10.0.1",
"@ucanto/principal": "^9.0.1",
"@ucanto/server": "^10.0.0",
"@web3-storage/data-segment": "^4.0.0",
"@storacha/eslint-config": "workspace:^",
"assert": "^2.0.0",
"c8": "^7.13.0",
"hundreds": "^0.0.9",
Expand Down
16 changes: 8 additions & 8 deletions packages/upload-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,30 +193,30 @@
"test-watch": "pnpm build && mocha --bail --timeout 10s --watch --parallel -n no-warnings -n experimental-vm-modules -n experimental-fetch --watch-files src,test"
},
"dependencies": {
"@storacha/access": "workspace:^",
"@storacha/blob-index": "workspace:^",
"@storacha/capabilities": "workspace:^",
"@storacha/did-mailto": "workspace:^",
"@storacha/filecoin-api": "workspace:^",
"@ucanto/client": "^9.0.1",
"@ucanto/interface": "^10.0.1",
"@ucanto/principal": "^9.0.1",
"@ucanto/server": "^10.0.0",
"@ucanto/transport": "^9.1.1",
"@ucanto/validator": "^9.0.2",
"@storacha/access": "workspace:^",
"@storacha/blob-index": "workspace:^",
"@storacha/capabilities": "workspace:^",
"@web3-storage/content-claims": "^5.1.0",
"@storacha/did-mailto": "workspace:^",
"@storacha/filecoin-api": "workspace:^",
"@web3-storage/content-claims": "^5.1.3",
"multiformats": "^12.1.2",
"uint8arrays": "^5.0.3"
},
"devDependencies": {
"@ipld/car": "^5.1.1",
"@ipld/dag-ucan": "^3.4.0",
"@storacha/blob-index": "workspace:^",
"@storacha/eslint-config": "workspace:^",
"@storacha/one-webcrypto": "^1.0.1",
"@types/mocha": "^10.0.1",
"@ucanto/core": "^10.0.1",
"@web-std/blob": "^3.0.5",
"@storacha/blob-index": "workspace:^",
"@storacha/eslint-config": "workspace:^",
"@web3-storage/sigv4": "^1.0.2",
"is-subset": "^0.1.1",
"mocha": "^10.2.0",
Expand Down
Loading

0 comments on commit 6b0d72d

Please sign in to comment.