Skip to content

Commit

Permalink
Implement cli 'register' cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrazee committed Feb 4, 2022
1 parent f7aa636 commit 51acd2a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion cli/src/commands/setup/register.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Repo } from '../../lib/repo.js'
import { service } from '@bluesky-demo/common'
import * as ucan from 'ucans'
import cmd from '../../lib/command.js'
import { REPO_PATH } from '../../lib/env.js'

export default cmd({
name: 'register',
Expand All @@ -7,6 +11,20 @@ export default cmd({
args: [],
opts: [],
async command (args) {
throw new Error('TODO')
const repo = await Repo.load(REPO_PATH)
console.log('Registering with server...')
try {
// TODO - service needs to use `server`
const userStore = await repo.getLocalUserStore()
const blueskyDid = await service.getServerDid()
const token = await ucan.build({
audience: blueskyDid,
issuer: repo.keypair
})
await service.register(await userStore.getCarFile(), ucan.encode(token))
} catch (e: any) {
console.error(`Failed to register with server`)
console.error(e.toString())
}
}
})

0 comments on commit 51acd2a

Please sign in to comment.