Skip to content

Commit

Permalink
feat: upgrade to ucanto@9
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Oct 6, 2023
1 parent acaafd1 commit 0f95519
Show file tree
Hide file tree
Showing 47 changed files with 2,322 additions and 2,340 deletions.
20 changes: 10 additions & 10 deletions packages/access-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,27 @@
],
"dependencies": {
"@ipld/car": "^5.1.1",
"@ipld/dag-ucan": "^3.3.2",
"@ucanto/client": "^8.0.0",
"@ucanto/core": "^8.0.0",
"@ucanto/interface": "^8.0.0",
"@ucanto/principal": "^8.0.0",
"@ucanto/transport": "^8.0.0",
"@ucanto/validator": "^8.0.0",
"@ipld/dag-ucan": "^3.4.0",
"@ucanto/client": "^9.0.0",
"@ucanto/core": "^9.0.0",
"@ucanto/interface": "^9.0.0",
"@ucanto/principal": "^9.0.0",
"@ucanto/transport": "^9.0.0",
"@ucanto/validator": "^9.0.0",
"@web3-storage/capabilities": "workspace:^",
"@web3-storage/did-mailto": "workspace:^",
"bigint-mod-arith": "^3.1.2",
"conf": "10.2.0",
"inquirer": "^9.1.4",
"isomorphic-ws": "^5.0.0",
"kysely": "^0.23.4",
"multiformats": "^11.0.2",
"multiformats": "^12.1.2",
"one-webcrypto": "^1.0.3",
"ora": "^6.1.2",
"p-defer": "^4.0.0",
"p-wait-for": "^5.0.0",
"type-fest": "^3.3.0",
"uint8arrays": "^4.0.3",
"uint8arrays": "^4.0.6",
"ws": "^8.12.0",
"zod": "^3.20.2"
},
Expand All @@ -92,7 +92,7 @@
"@types/sinon": "^10.0.13",
"@types/varint": "^6.0.1",
"@types/ws": "^8.5.4",
"@ucanto/server": "^8.0.1",
"@ucanto/server": "^9.0.1",
"assert": "^2.0.0",
"hd-scripts": "^4.0.0",
"mocha": "^10.2.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/access-client/test/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ export function createServer(handlers = {}) {
},
...handlers,
},
validateAuthorization,
})

// @ts-ignore
return server
}

export const validateAuthorization = () => ({ ok: {} })
12 changes: 6 additions & 6 deletions packages/capabilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
"dist/src/**/*.d.ts.map"
],
"dependencies": {
"@ucanto/core": "^8.0.0",
"@ucanto/interface": "^8.0.0",
"@ucanto/principal": "^8.0.0",
"@ucanto/transport": "^8.0.0",
"@ucanto/validator": "^8.0.0",
"@web3-storage/data-segment": "^3.0.1"
"@ucanto/core": "^9.0.0",
"@ucanto/interface": "^9.0.0",
"@ucanto/principal": "^9.0.0",
"@ucanto/transport": "^9.0.0",
"@ucanto/validator": "^9.0.0",
"@web3-storage/data-segment": "^3.2.0"
},
"devDependencies": {
"@types/assert": "^1.5.6",
Expand Down
27 changes: 27 additions & 0 deletions packages/capabilities/test/capabilities/access.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { access } from '@ucanto/validator'
import { Verifier } from '@ucanto/principal/ed25519'
import * as Access from '../../src/access.js'
import { alice, bob, service, mallory } from '../helpers/fixtures.js'
import { validateAuthorization } from '../helpers/utils.js'
import * as Ucanto from '@ucanto/interface'
import { delegate, invoke, parseLink } from '@ucanto/core'

Expand All @@ -24,6 +25,7 @@ describe('access capabilities', function () {
capability: Access.authorize,
principal: Verifier,
authority: service,
validateAuthorization,
})
if (result.error) {
assert.fail('error in self issue')
Expand Down Expand Up @@ -64,6 +66,7 @@ describe('access capabilities', function () {
capability: Access.authorize,
principal: Verifier,
authority: service,
validateAuthorization,
})

if (result.error) {
Expand Down Expand Up @@ -102,6 +105,7 @@ describe('access capabilities', function () {
capability: Access.authorize,
principal: Verifier,
authority: service,
validateAuthorization,
})

if (result.error) {
Expand Down Expand Up @@ -140,6 +144,7 @@ describe('access capabilities', function () {
capability: Access.authorize,
principal: Verifier,
authority: service,
validateAuthorization,
})

if (result.error) {
Expand Down Expand Up @@ -181,6 +186,7 @@ describe('access capabilities', function () {
capability: Access.authorize,
principal: Verifier,
authority: service,
validateAuthorization,
})

if (result.error) {
Expand Down Expand Up @@ -216,6 +222,7 @@ describe('access capabilities', function () {
capability: Access.authorize,
principal: Verifier,
authority: service,
validateAuthorization,
})

assert.equal(result.error, undefined, 'should be authorized')
Expand Down Expand Up @@ -247,6 +254,7 @@ describe('access capabilities', function () {
capability: Access.authorize,
principal: Verifier,
authority: service,
validateAuthorization,
})

assert.equal(result.error, undefined, 'should be authorized')
Expand Down Expand Up @@ -278,6 +286,7 @@ describe('access capabilities', function () {
capability: Access.authorize,
principal: Verifier,
authority: service,
validateAuthorization,
})

if (result.error) {
Expand Down Expand Up @@ -311,6 +320,7 @@ describe('access capabilities', function () {
capability: Access.authorize,
principal: Verifier,
authority: service,
validateAuthorization,
})

if (result.error) {
Expand Down Expand Up @@ -354,6 +364,7 @@ describe('access capabilities', function () {
capability: Access.confirm,
principal: Verifier,
authority: service,
validateAuthorization,
})
if (result.error) {
assert.fail('error in self issue')
Expand Down Expand Up @@ -396,6 +407,7 @@ describe('access capabilities', function () {
capability: Access.confirm,
principal: Verifier,
authority: service,
validateAuthorization,
})

if (result.error) {
Expand Down Expand Up @@ -436,6 +448,7 @@ describe('access capabilities', function () {
capability: Access.confirm,
principal: Verifier,
authority: service,
validateAuthorization,
})

if (result.error) {
Expand Down Expand Up @@ -476,6 +489,7 @@ describe('access capabilities', function () {
capability: Access.confirm,
principal: Verifier,
authority: service,
validateAuthorization,
})

if (result.error) {
Expand Down Expand Up @@ -519,6 +533,7 @@ describe('access capabilities', function () {
capability: Access.confirm,
principal: Verifier,
authority: service,
validateAuthorization,
})

if (result.error) {
Expand Down Expand Up @@ -555,6 +570,7 @@ describe('access capabilities', function () {
capability: Access.confirm,
principal: Verifier,
authority: service,
validateAuthorization,
})

assert.equal(result.error, undefined, 'should be authorized')
Expand Down Expand Up @@ -587,6 +603,7 @@ describe('access capabilities', function () {
capability: Access.confirm,
principal: Verifier,
authority: service,
validateAuthorization,
})

assert.equal(result.error, undefined, 'should be authorized')
Expand Down Expand Up @@ -619,6 +636,7 @@ describe('access capabilities', function () {
capability: Access.confirm,
principal: Verifier,
authority: service,
validateAuthorization,
})

if (result.error) {
Expand Down Expand Up @@ -653,6 +671,7 @@ describe('access capabilities', function () {
capability: Access.confirm,
principal: Verifier,
authority: service,
validateAuthorization,
})

if (result.error) {
Expand Down Expand Up @@ -704,6 +723,7 @@ describe('access capabilities', function () {
capability: Access.claim,
principal: Verifier,
authority: audience,
validateAuthorization,
})

assert.ok(result.ok, 'result of access(invocation) is not an error')
Expand Down Expand Up @@ -749,6 +769,7 @@ describe('access capabilities', function () {
capability: Access.claim,
principal: Verifier,
authority: service,
validateAuthorization,
})
assert.ok(result.ok, 'result of access(invocation) is not an error')
}
Expand Down Expand Up @@ -812,6 +833,7 @@ describe('access capabilities', function () {
capability: Access.claim,
principal: Verifier,
authority: audience,
validateAuthorization,
})
assert.ok(result.error, 'result of access(invocation) is an error')
assert.deepEqual(result.error.name, 'Unauthorized')
Expand Down Expand Up @@ -840,6 +862,7 @@ describe('access/delegate', () => {
capability: Access.delegate,
principal: Verifier,
authority: service,
validateAuthorization,
})
assert.ok(accessResult.ok, 'result of access(invocation) is not an error')
})
Expand Down Expand Up @@ -872,6 +895,7 @@ describe('access/delegate', () => {
capability: Access.delegate,
principal: Verifier,
authority: service,
validateAuthorization,
})
assert.ok(accessResult.ok, 'result of access(invocation) is not an error')
})
Expand Down Expand Up @@ -913,6 +937,7 @@ describe('access/delegate', () => {
capability: Access.delegate,
principal: Verifier,
authority: service,
validateAuthorization,
})
assert.ok(accessResult.ok, 'result of access(invocation) is not an error')
})
Expand Down Expand Up @@ -959,6 +984,7 @@ describe('access/delegate', () => {
capability: Access.delegate,
principal: Verifier,
authority: audience,
validateAuthorization,
})
assert.ok(result.error, 'result of access(invocation) is an error')
assert.deepEqual(result.error.failedProofs.length, 1)
Expand Down Expand Up @@ -993,6 +1019,7 @@ describe('access/delegate', () => {
capability: Access.delegate,
principal: Verifier,
authority: service,
validateAuthorization,
})
assert.ok(result.error, 'result is error')
assert.ok(
Expand Down
7 changes: 7 additions & 0 deletions packages/capabilities/test/capabilities/admin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { delegate } from '@ucanto/core'
import { Verifier } from '@ucanto/principal/ed25519'
import * as Admin from '../../src/admin.js'
import { service, alice, readmeCID } from '../helpers/fixtures.js'
import { validateAuthorization } from '../helpers/utils.js'

describe('admin/upload/inspect', async function () {
const agent = alice
Expand All @@ -20,6 +21,7 @@ describe('admin/upload/inspect', async function () {
capability: Admin.upload.inspect,
principal: Verifier,
authority: service,
validateAuthorization,
})
if (result.error) {
assert.fail('error in self issue')
Expand Down Expand Up @@ -52,6 +54,7 @@ describe('admin/upload/inspect', async function () {
capability: Admin.upload.inspect,
principal: Verifier,
authority: service,
validateAuthorization,
})
if (result.error) {
assert.fail(
Expand Down Expand Up @@ -81,6 +84,7 @@ describe('admin/upload/inspect', async function () {
capability: Admin.upload.inspect,
principal: Verifier,
authority: service,
validateAuthorization,
})

assert.equal(result.error?.message.includes('not authorized'), true)
Expand Down Expand Up @@ -114,6 +118,7 @@ describe('admin/store/inspect', function () {
capability: Admin.store.inspect,
principal: Verifier,
authority: service,
validateAuthorization,
})
if (result.error) {
assert.fail('error in self issue')
Expand Down Expand Up @@ -146,6 +151,7 @@ describe('admin/store/inspect', function () {
capability: Admin.store.inspect,
principal: Verifier,
authority: service,
validateAuthorization,
})
if (result.error) {
assert.fail(
Expand Down Expand Up @@ -175,6 +181,7 @@ describe('admin/store/inspect', function () {
capability: Admin.store.inspect,
principal: Verifier,
authority: service,
validateAuthorization,
})

assert.equal(result.error?.message.includes('not authorized'), true)
Expand Down
Loading

0 comments on commit 0f95519

Please sign in to comment.