From 45e7ad42037fb9f854a2e90e59df2ec06f5b8f4c Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Tue, 13 Dec 2022 19:21:05 +0000 Subject: [PATCH] fix: fix client cli service did resolve (#292) We removed service DID resolution from the agent so CLI needs to pass in the DID now. --- packages/access-api/package.json | 2 +- packages/access-client/package.json | 4 +- .../access-client/src/cli/cmd-create-space.js | 4 +- packages/access-client/src/cli/index.js | 26 +++++++----- packages/access-client/src/cli/utils.js | 2 +- packages/access-ws/package.json | 2 +- packages/capabilities/package.json | 2 +- pnpm-lock.yaml | 40 ++++++++++--------- 8 files changed, 45 insertions(+), 37 deletions(-) diff --git a/packages/access-api/package.json b/packages/access-api/package.json index 393342cdf..5dc2e061c 100644 --- a/packages/access-api/package.json +++ b/packages/access-api/package.json @@ -42,7 +42,7 @@ "@types/assert": "^1.5.6", "@types/git-rev-sync": "^2.0.0", "@types/mocha": "^10.0.1", - "@types/node": "^18.11.13", + "@types/node": "^18.11.14", "@types/qrcode": "^1.5.0", "better-sqlite3": "8.0.1", "buffer": "^6.0.3", diff --git a/packages/access-client/package.json b/packages/access-client/package.json index 55edddb6c..2cb1d7cc2 100644 --- a/packages/access-client/package.json +++ b/packages/access-client/package.json @@ -82,13 +82,13 @@ "uint8arrays": "^4.0.2", "varint": "^6.0.0", "ws": "^8.11.0", - "zod": "^3.20.0" + "zod": "^3.20.2" }, "devDependencies": { "@types/assert": "^1.5.6", "@types/inquirer": "^9.0.3", "@types/mocha": "^10.0.1", - "@types/node": "^18.11.13", + "@types/node": "^18.11.14", "@types/varint": "^6.0.1", "@types/ws": "^8.5.3", "@ucanto/server": "^4.0.2", diff --git a/packages/access-client/src/cli/cmd-create-space.js b/packages/access-client/src/cli/cmd-create-space.js index f84ca1d1e..8fb3243f9 100644 --- a/packages/access-client/src/cli/cmd-create-space.js +++ b/packages/access-client/src/cli/cmd-create-space.js @@ -10,13 +10,13 @@ import { getService } from './utils.js' * @param {{ profile: any; env: string }} opts */ export async function cmdCreateSpace(opts) { - const { url } = await getService(opts.env) + const { url, servicePrincipal } = await getService(opts.env) const store = new StoreConf({ profile: opts.profile }) const data = await store.load() if (data) { const spinner = ora('Registering with the service').start() - const agent = Agent.from(data, { store, url }) + const agent = Agent.from(data, { store, url, servicePrincipal }) spinner.stopAndPersist() const { email, name } = await inquirer.prompt([ diff --git a/packages/access-client/src/cli/index.js b/packages/access-client/src/cli/index.js index 8b1b5d9fc..ded9edacc 100755 --- a/packages/access-client/src/cli/index.js +++ b/packages/access-client/src/cli/index.js @@ -22,13 +22,17 @@ const prog = sade(NAME) prog .version(pkg.version) .option('-p, --profile', 'Select the config profile to use.', 'main') - .option('--env', 'Env', 'production') + .option( + '--env', + 'Environment "production", "staging", "dev" or "local"', + 'production' + ) prog.command('link [channel]').describe('Link.').action(cmdLink) prog .command('setup') .option('--reset', 'Reset current store.', false) - .describe('Print config file content.') + .describe('Setup agent keypair.') .action(cmdSetup) prog.command('whoami').describe('Print config file content.').action(cmdWhoami) prog @@ -42,16 +46,16 @@ prog .action(async (opts) => { const store = new StoreConf({ profile: opts.profile }) const data = await store.load() - const { url } = await getService(opts.env) + const { url, servicePrincipal } = await getService(opts.env) if (data) { - const agent = Agent.from(data, { store, url }) + const agent = Agent.from(data, { store, url, servicePrincipal }) const space = await selectSpace(agent) try { const result = await agent.getSpaceInfo(space) console.log(result) } catch (error_) { const error = /** @type {Error} */ (error_) - console.log(error.message) + console.log('Error', error.message) } } else { console.error(`Run "${NAME} setup" first`) @@ -65,9 +69,9 @@ prog .action(async (opts) => { const store = new StoreConf({ profile: opts.profile }) const data = await store.load() - const { url } = await getService(opts.env) + const { url, servicePrincipal } = await getService(opts.env) if (data) { - const agent = Agent.from(data, { store, url }) + const agent = Agent.from(data, { store, url, servicePrincipal }) const space = await selectSpace(agent) await agent.setCurrentSpace(space) @@ -135,9 +139,9 @@ prog .action(async (opts) => { const store = new StoreConf({ profile: opts.profile }) const data = await store.load() - const { url } = await getService(opts.env) + const { url, servicePrincipal } = await getService(opts.env) if (data) { - const agent = Agent.from(data, { store, url }) + const agent = Agent.from(data, { store, url, servicePrincipal }) const del = fs.readFileSync(path.resolve(opts.delegation), { encoding: 'utf8', @@ -155,9 +159,9 @@ prog .action(async (opts) => { const store = new StoreConf({ profile: opts.profile }) const data = await store.load() - const { url } = await getService(opts.env) + const { url, servicePrincipal } = await getService(opts.env) if (data) { - const agent = Agent.from(data, { store, url }) + const agent = Agent.from(data, { store, url, servicePrincipal }) const { email } = await inquirer.prompt([ { diff --git a/packages/access-client/src/cli/utils.js b/packages/access-client/src/cli/utils.js index e686850f0..08ce4e2d2 100644 --- a/packages/access-client/src/cli/utils.js +++ b/packages/access-client/src/cli/utils.js @@ -30,7 +30,7 @@ export async function getService(env) { // @ts-ignore const { did } = await rsp.json() audience = Verifier.parse(did) - return { url, audience } + return { url, servicePrincipal: audience } } } diff --git a/packages/access-ws/package.json b/packages/access-ws/package.json index eb8888d51..a1f3dbbf0 100644 --- a/packages/access-ws/package.json +++ b/packages/access-ws/package.json @@ -23,7 +23,7 @@ "@cloudflare/workers-types": "^3.18.0", "@sentry/cli": "2.7.0", "@types/git-rev-sync": "^2.0.0", - "@types/node": "^18.11.13", + "@types/node": "^18.11.14", "ava": "^5.1.0", "buffer": "^6.0.3", "dotenv": "^16.0.3", diff --git a/packages/capabilities/package.json b/packages/capabilities/package.json index 94a61b11e..b6430de77 100644 --- a/packages/capabilities/package.json +++ b/packages/capabilities/package.json @@ -66,7 +66,7 @@ "devDependencies": { "@types/assert": "^1.5.6", "@types/mocha": "^10.0.0", - "@types/node": "^18.11.13", + "@types/node": "^18.11.14", "assert": "^2.0.0", "hd-scripts": "^3.0.2", "mocha": "^10.2.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9e72939e4..cfc05b9a4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -33,7 +33,7 @@ importers: '@types/assert': ^1.5.6 '@types/git-rev-sync': ^2.0.0 '@types/mocha': ^10.0.1 - '@types/node': ^18.11.13 + '@types/node': ^18.11.14 '@types/qrcode': ^1.5.0 '@ucanto/core': ^4.0.2 '@ucanto/interface': ^4.0.2 @@ -92,7 +92,7 @@ importers: '@types/assert': 1.5.6 '@types/git-rev-sync': 2.0.0 '@types/mocha': 10.0.1 - '@types/node': 18.11.13 + '@types/node': 18.11.14 '@types/qrcode': 1.5.0 better-sqlite3: 8.0.1 buffer: 6.0.3 @@ -118,7 +118,7 @@ importers: '@types/assert': ^1.5.6 '@types/inquirer': ^9.0.3 '@types/mocha': ^10.0.1 - '@types/node': ^18.11.13 + '@types/node': ^18.11.14 '@types/varint': ^6.0.1 '@types/ws': ^8.5.3 '@ucanto/client': ^4.0.2 @@ -153,7 +153,7 @@ importers: varint: ^6.0.0 watch: ^1.0.2 ws: ^8.11.0 - zod: ^3.20.0 + zod: ^3.20.2 dependencies: '@ipld/car': 5.0.1 '@ipld/dag-cbor': 8.0.0 @@ -179,12 +179,12 @@ importers: uint8arrays: 4.0.2 varint: 6.0.0 ws: 8.11.0 - zod: 3.20.0 + zod: 3.20.2 devDependencies: '@types/assert': 1.5.6 '@types/inquirer': 9.0.3 '@types/mocha': 10.0.1 - '@types/node': 18.11.13 + '@types/node': 18.11.14 '@types/varint': 6.0.1 '@types/ws': 8.5.3 '@ucanto/server': 4.0.2 @@ -204,7 +204,7 @@ importers: '@cloudflare/workers-types': ^3.18.0 '@sentry/cli': 2.7.0 '@types/git-rev-sync': ^2.0.0 - '@types/node': ^18.11.13 + '@types/node': ^18.11.14 '@web3-storage/worker-utils': 0.4.3-dev ava: ^5.1.0 buffer: ^6.0.3 @@ -227,7 +227,7 @@ importers: '@cloudflare/workers-types': 3.18.0 '@sentry/cli': 2.7.0 '@types/git-rev-sync': 2.0.0 - '@types/node': 18.11.13 + '@types/node': 18.11.14 ava: 5.1.0 buffer: 6.0.3 dotenv: 16.0.3 @@ -246,7 +246,7 @@ importers: specifiers: '@types/assert': ^1.5.6 '@types/mocha': ^10.0.0 - '@types/node': ^18.11.13 + '@types/node': ^18.11.14 '@ucanto/core': ^4.0.2 '@ucanto/interface': ^4.0.2 '@ucanto/principal': ^4.0.2 @@ -268,7 +268,7 @@ importers: devDependencies: '@types/assert': 1.5.6 '@types/mocha': 10.0.1 - '@types/node': 18.11.13 + '@types/node': 18.11.14 assert: 2.0.0 hd-scripts: 3.0.2 mocha: 10.2.0 @@ -1316,13 +1316,13 @@ packages: /@types/better-sqlite3/7.6.2: resolution: {integrity: sha512-RgmaapusqTq6IMAr4McMyAsC6RshYTCjXCnzwVV59WctUxC8bNPyUfT9t5F81lKcU41lLurhjqjoMHfauzfqGg==} dependencies: - '@types/node': 18.11.13 + '@types/node': 18.11.14 dev: true /@types/better-sqlite3/7.6.3: resolution: {integrity: sha512-YS64N9SNDT/NAvou3QNdzAu3E2om/W/0dhORimtPGLef+zSK5l1vDzfsWb4xgXOgfhtOI5ZDTRxnvRPb22AIVQ==} dependencies: - '@types/node': 18.11.13 + '@types/node': 18.11.14 dev: true /@types/cookie/0.5.0: @@ -1363,6 +1363,10 @@ packages: /@types/node/18.11.13: resolution: {integrity: sha512-IASpMGVcWpUsx5xBOrxMj7Bl8lqfuTY7FKAnPmu5cHkfQVWF8GulWS1jbRqA934qZL35xh5xN/+Xe/i26Bod4w==} + /@types/node/18.11.14: + resolution: {integrity: sha512-0KXV57tENYmmJMl+FekeW9V3O/rlcqGQQJ/hNh9r8pKIj304pskWuEd8fCyNT86g/TpO0gcOTiLzsHLEURFMIQ==} + dev: true + /@types/normalize-package-data/2.4.1: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} dev: true @@ -1374,7 +1378,7 @@ packages: /@types/qrcode/1.5.0: resolution: {integrity: sha512-x5ilHXRxUPIMfjtM+1vf/GPTRWZ81nqscursm5gMznJeK9M0YnZ1c3bEvRLQ0zSSgedLx1J6MGL231ObQGGhaA==} dependencies: - '@types/node': 18.11.13 + '@types/node': 18.11.14 dev: true /@types/retry/0.12.1: @@ -1392,19 +1396,19 @@ packages: /@types/through/0.0.30: resolution: {integrity: sha512-FvnCJljyxhPM3gkRgWmxmDZyAQSiBQQWLI0A0VFL0K7W1oRUrPJSqNO0NvTnLkBcotdlp3lKvaT0JrnyRDkzOg==} dependencies: - '@types/node': 18.11.13 + '@types/node': 18.11.14 dev: true /@types/varint/6.0.1: resolution: {integrity: sha512-fQdOiZpDMBvaEdl12P1x7xlTPRAtd7qUUtVaWgkCy8DC//wCv19nqFFtrnR3y/ac6VFY0UUvYuQqfKzZTSE26w==} dependencies: - '@types/node': 18.11.13 + '@types/node': 18.11.14 dev: true /@types/ws/8.5.3: resolution: {integrity: sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w==} dependencies: - '@types/node': 18.11.13 + '@types/node': 18.11.14 dev: true /@types/yargs-parser/21.0.0: @@ -7391,6 +7395,6 @@ packages: stack-trace: 0.0.10 dev: true - /zod/3.20.0: - resolution: {integrity: sha512-ZWxs7oM5ixoo1BMoxTNeDMYSih/F/FUnExsnRtHT04rG6q0Bd74TKS45RGXw07TOalOZyyzdKaYH38k8yTEv9A==} + /zod/3.20.2: + resolution: {integrity: sha512-1MzNQdAvO+54H+EaK5YpyEy0T+Ejo/7YLHS93G3RnYWh5gaotGHwGeN/ZO687qEDU2y4CdStQYXVHIgrUl5UVQ==} dev: false