Skip to content

Commit

Permalink
feat!: upgrade access-api @ucanto/* and @ipld/dag-ucan major versions (
Browse files Browse the repository at this point in the history
…#246)

Motivation:
* second attempt at this
#238
* after first was reverted
#245

Warning:
* the versions of ucanto we're upgrading to were backward-incompatible.
storacha/ucanto#149
* Old 'SignerArchive' exports will probably no longer import using the
new `@ucanto/principal@^4.0.0` `SignerArchive`
* in slack, @alanshaw said he thinks this is unlikely to cause problems:
"There’s no code in production that uses toArchive"

Blockers
* [x] Wait for these two to land first (@hugomrdias says so)
  * [x] @hugomrdias #207
  * [x] @alanshaw #228
* [x] then will need to resolve merge conflicts on this branch
* [x] @gobengo resolve conflicts after
#207
* [x] @gobengo resolve conflicts after
#228

Co-authored-by: Irakli Gozalishvili <contact@gozala.io>
  • Loading branch information
gobengo and Gozala committed Dec 7, 2022
1 parent fb8c09d commit 5e663d1
Show file tree
Hide file tree
Showing 11 changed files with 115 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
16 changes: 8 additions & 8 deletions packages/access-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@
],
"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",
"@ipld/dag-ucan": "^3.0.1",
"@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 @@ -87,7 +87,7 @@
"@types/mocha": "^10.0.1",
"@types/node": "^18.11.9",
"@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
1 change: 0 additions & 1 deletion packages/access-client/src/agent-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export class AgentData {
return new AgentData(
{
meta: raw.meta,
// @ts-expect-error
principal: Signer.from(raw.principal),
currentSpace: raw.currentSpace,
spaces: raw.spaces,
Expand Down
3 changes: 1 addition & 2 deletions packages/access-client/src/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const PRINCIPAL = DID.parse(
* import { connection } from '@web3-storage/access/agent'
* ```
*
* @template {string} T - DID method
* @template {Ucanto.DID} T - DID method
* @param {object} [options]
* @param {Ucanto.Principal<T>} [options.principal] - w3access API Principal
* @param {URL} [options.url] - w3access API URL
Expand Down Expand Up @@ -403,7 +403,6 @@ export class Agent {
nb: {
identity: URI.from(`mailto:${email}`),
product: 'product:free',
// @ts-expect-error expected did:key but connection can be did:any
service: service.did(),
},
})
Expand Down
3 changes: 2 additions & 1 deletion packages/access-client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import type {
DID,
Signer,
SignerArchive,
SigAlg,
} from '@ucanto/interface'

import type {
Expand Down Expand Up @@ -92,7 +93,7 @@ export type AgentDataExport = Pick<
AgentDataModel,
'meta' | 'currentSpace' | 'spaces'
> & {
principal: SignerArchive<Signer>
principal: SignerArchive<DID, SigAlg>
delegations: Map<
CIDString,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ describe('IndexedDB store', () => {
// principal private key is not extractable
const archive = exportData.principal
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(exportData.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
12 changes: 6 additions & 6 deletions packages/upload-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@
],
"dependencies": {
"@ipld/car": "^5.0.0",
"@ipld/dag-ucan": "^2.0.1",
"@ipld/dag-ucan": "^3.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.1",
"@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 5e663d1

Please sign in to comment.