Skip to content

Commit

Permalink
feat!: upgrade to @ucanto/{interface,principal}@^4.0.0 (#238)
Browse files Browse the repository at this point in the history
Motivation:
* part of #237
* we need this version of ucanto libs because they include updated types
to handle non-key-dids and dids with more than one key

Parts
* [x] build/test works in packages/access-client
* [x] build/test works in packages/upload-client
* [x] [blocked by needed ucanto
release](storacha/ucanto#163)
* [x] build/test works in packages/access-api
* [x] [blocked by needed ucanto
release](storacha/ucanto#163)

Co-authored-by: Irakli Gozalishvili <contact@gozala.io>
  • Loading branch information
gobengo and Gozala authored Dec 2, 2022
1 parent 717fcaa commit 309aff0
Show file tree
Hide file tree
Showing 12 changed files with 121 additions and 113 deletions.
12 changes: 6 additions & 6 deletions packages/access-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
"author": "Hugo Dias <hugomrdias@gmail.com> (hugodias.me)",
"license": "(Apache-2.0 OR MIT)",
"dependencies": {
"@ipld/dag-ucan": "^2.0.1",
"@ucanto/core": "^3.0.2",
"@ucanto/interface": "^3.0.1",
"@ucanto/principal": "^3.0.1",
"@ucanto/server": "^3.0.4",
"@ucanto/transport": "^3.0.2",
"@ipld/dag-ucan": "^3.0.1",
"@ucanto/core": "^4.0.2",
"@ucanto/interface": "^4.0.2",
"@ucanto/principal": "^4.0.2",
"@ucanto/server": "^4.0.2",
"@ucanto/transport": "^4.0.2",
"@web3-storage/access": "workspace:^",
"@web3-storage/capabilities": "workspace:^",
"@web3-storage/worker-utils": "0.4.3-dev",
Expand Down
2 changes: 1 addition & 1 deletion packages/access-api/test/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function send(ucan, mf) {

/**
* @param {Types.Signer} issuer
* @param {Types.Principal<"key">} service
* @param {Types.Principal<UCAN.DID>} service
* @param {Types.ConnectionView<import('@web3-storage/access/types').Service>} conn
* @param {string} email
*/
Expand Down
17 changes: 9 additions & 8 deletions packages/access-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"test:node": "mocha 'test/**/!(*.browser).test.js' -n experimental-vm-modules -n no-warnings",
"test:browser": "playwright-test 'test/**/!(*.node).test.js'",
"testw": "watch 'pnpm test' src test --interval 1",
"rc": "npm version prerelease --preid rc"
"rc": "npm version prerelease --preid rc",
"w3access": "./src/cli/index.js"
},
"exports": {
".": "./src/index.js",
Expand Down Expand Up @@ -56,12 +57,12 @@
"dependencies": {
"@ipld/car": "^5.0.1",
"@ipld/dag-ucan": "^2.0.1",
"@ucanto/client": "^3.0.2",
"@ucanto/core": "^3.0.2",
"@ucanto/interface": "^3.0.1",
"@ucanto/principal": "^3.0.1",
"@ucanto/transport": "^3.0.2",
"@ucanto/validator": "^3.0.4",
"@ucanto/client": "^4.0.2",
"@ucanto/core": "^4.0.2",
"@ucanto/interface": "^4.0.2",
"@ucanto/principal": "^4.0.2",
"@ucanto/transport": "^4.0.2",
"@ucanto/validator": "^4.0.2",
"@web3-storage/capabilities": "workspace:^",
"bigint-mod-arith": "^3.1.2",
"conf": "^10.2.0",
Expand All @@ -83,7 +84,7 @@
"@types/mocha": "^10.0.0",
"@types/node": "^18.11.10",
"@types/ws": "^8.5.3",
"@ucanto/server": "^3.0.4",
"@ucanto/server": "^4.0.2",
"assert": "^2.0.0",
"delay": "^5.0.0",
"hd-scripts": "^3.0.2",
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 @@ -33,7 +33,7 @@ const HOST = 'https://access.web3.storage'
* import { connection } from '@web3-storage/access/agent'
* ```
*
* @template {string} T - DID method
* @template {Ucanto.DID} T - DID method
* @param {Ucanto.Principal<T>} principal - w3access API Principal
* @param {typeof fetch} _fetch - fetch implementation to use
* @param {URL} url - w3access API URL
Expand Down Expand Up @@ -70,7 +70,7 @@ export function connection(principal, _fetch, url, channel) {
* @template {Ucanto.Signer} T - Ucanto Signer ie. ed25519, RSA or others
*/
export class Agent {
/** @type {Ucanto.Principal<"key">|undefined} */
/** @type {Ucanto.Principal<Ucanto.DID>|undefined} */
#service

/** @type {typeof fetch} */
Expand Down
1 change: 1 addition & 0 deletions packages/access-client/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,5 @@ prog
console.error(`Run "${NAME} setup" first`)
}
})

prog.parse(process.argv)
1 change: 0 additions & 1 deletion packages/access-client/src/stores/store-indexeddb.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ export class StoreIndexedDB {
const raw = {
id: DATA_ID,
meta: data.meta,
// @ts-expect-error
principal: data.principal.toArchive(),
currentSpace: data.currentSpace,
spaces: data.spaces,
Expand Down
6 changes: 3 additions & 3 deletions packages/access-client/src/stores/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
DelegationMeta,
SpaceMeta,
} from '../types.js'
import { RSASigner } from '@ucanto/principal/rsa'
import { SignerArchive, DID } from '@ucanto/interface'
import { SignerArchive, DID, DIDKey } from '@ucanto/interface'
import { RSA } from '@ucanto/principal'

/**
* Store interface that all stores need to implement
Expand Down Expand Up @@ -50,7 +50,7 @@ export interface IStore<T> {
export interface StoreDataIDB {
id: number
meta: AgentMeta
principal: SignerArchive<RSASigner>
principal: SignerArchive<DIDKey, typeof RSA.signatureCode>
currentSpace?: DID
spaces: Map<DID, SpaceMeta>
delegations: Map<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ describe('IndexedDB store', () => {
// principal private key is not extractable
const archive = data.principal.toArchive()
assert(!(archive instanceof Uint8Array))
assert(archive.key instanceof CryptoKey)
assert.equal(archive.key.extractable, false)
// eslint-disable-next-line no-unused-vars
const [[_, key], ...keys] = [...Object.entries(archive.keys)]
assert.deepEqual(keys, [])
assert(key instanceof CryptoKey)
assert.equal(key.extractable, false)

// no accounts or delegations yet
assert.equal(data.spaces.size, 0)
Expand Down
10 changes: 5 additions & 5 deletions packages/capabilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@
"dist/src/**/*.d.ts.map"
],
"dependencies": {
"@ucanto/core": "^3.0.2",
"@ucanto/interface": "^3.0.1",
"@ucanto/principal": "^3.0.1",
"@ucanto/transport": "^3.0.2",
"@ucanto/validator": "^3.0.4"
"@ucanto/core": "^4.0.2",
"@ucanto/interface": "^4.0.2",
"@ucanto/principal": "^4.0.2",
"@ucanto/transport": "^4.0.2",
"@ucanto/validator": "^4.0.2"
},
"devDependencies": {
"@types/assert": "^1.5.6",
Expand Down
4 changes: 2 additions & 2 deletions packages/capabilities/src/voucher.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export const Product = URI.uri()
export const Identity = URI.match({ protocol: 'mailto:' })

/**
* Services are identified using did:key identifier.
* Services are identified using a decentralized identifier.
*/
export const Service = DID.match({ method: 'key' })
export const Service = DID.match({})

/**
* Capability can only be delegated (but not invoked) allowing audience to
Expand Down
10 changes: 5 additions & 5 deletions packages/upload-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
"@ipld/car": "^5.0.0",
"@ipld/dag-ucan": "^2.0.1",
"@ipld/unixfs": "^2.0.0",
"@ucanto/client": "^3.0.1",
"@ucanto/interface": "^3.0.0",
"@ucanto/transport": "^3.0.1",
"@ucanto/client": "^4.0.2",
"@ucanto/interface": "^4.0.2",
"@ucanto/transport": "^4.0.2",
"@web3-storage/capabilities": "workspace:^",
"multiformats": "^10.0.2",
"p-queue": "^7.3.0",
Expand All @@ -77,8 +77,8 @@
"devDependencies": {
"@types/assert": "^1.5.6",
"@types/mocha": "^10.0.0",
"@ucanto/principal": "^3.0.0",
"@ucanto/server": "^3.0.1",
"@ucanto/principal": "^4.0.2",
"@ucanto/server": "^4.0.2",
"assert": "^2.0.0",
"blockstore-core": "^2.0.2",
"c8": "^7.12.0",
Expand Down
Loading

0 comments on commit 309aff0

Please sign in to comment.