Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix client cli service did resolve #292

Merged
merged 1 commit into from
Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/access-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/access-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/access-client/src/cli/cmd-create-space.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
26 changes: 15 additions & 11 deletions packages/access-client/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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`)
Expand All @@ -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)
Expand Down Expand Up @@ -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',
Expand All @@ -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([
{
Expand Down
2 changes: 1 addition & 1 deletion packages/access-client/src/cli/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/access-ws/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/capabilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
40 changes: 22 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.