diff --git a/cli/src/commands/setup/register.ts b/cli/src/commands/setup/register.ts index 1e2a9fc0f4e..0fdd38d4c6d 100644 --- a/cli/src/commands/setup/register.ts +++ b/cli/src/commands/setup/register.ts @@ -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', @@ -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()) + } } }) \ No newline at end of file