Skip to content
Draft
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
7 changes: 7 additions & 0 deletions .changeset/fix-setup-email-app-setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@beeper/cli': patch
---

Fix headless `beeper setup --email` against `@beeper/desktop-api` 6.0.0.

The SDK moved `client.app.login` to `client.app.setup` and moved verification and recovery-key calls under that resource. Email setup now calls those methods, and the dependency is pinned to the 6.0.0 commit instead of the moving `next` branch.
8 changes: 4 additions & 4 deletions bun.lock

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

2 changes: 1 addition & 1 deletion packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2308,7 +2308,7 @@ Search contacts
beeper contacts search <query>
```

Search contacts on a specific account using merged account contacts, network search, and exact identifier lookup.
Search contacts on a specific account using merged account contacts, network search, and exact identifier lookup. The exact lookup only runs when the query is a phone number, email address, or username; pass one of those to resolve a specific person.

Arguments:

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
}
},
"dependencies": {
"@beeper/desktop-api": "github:beeper/desktop-api-js#next",
"@beeper/desktop-api": "github:beeper/desktop-api-js#fe1e736ccd101f687da03abfdaeb69ab57fa4bcf",
"@oclif/core": "^4.11.2",
"@oclif/plugin-autocomplete": "^3.2.49",
"@oclif/plugin-help": "^6.2.48",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/verify/approve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export default class AuthVerifyApprove extends BeeperCommand {
const { flags } = await this.parse(AuthVerifyApprove)
ensureWritable(flags)
const client = await createClient(flags)
await printData(await client.app.verifications.accept(await resolveVerificationID(client, flags.id)), flags.json ? 'json' : 'human')
await printData(await client.app.setup.verifications.accept(await resolveVerificationID(client, flags.id)), flags.json ? 'json' : 'human')
}
}
2 changes: 1 addition & 1 deletion packages/cli/src/commands/verify/cancel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export default class AuthVerifyCancel extends BeeperCommand {
const { flags } = await this.parse(AuthVerifyCancel)
ensureWritable(flags)
const client = await createClient(flags)
await printData(await client.app.verifications.cancel(await resolveVerificationID(client, flags.id), {}), flags.json ? 'json' : 'human')
await printData(await client.app.setup.verifications.cancel(await resolveVerificationID(client, flags.id), {}), flags.json ? 'json' : 'human')
}
}
2 changes: 1 addition & 1 deletion packages/cli/src/commands/verify/qr-confirm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export default class AuthVerifyQrConfirm extends BeeperCommand {
const { flags } = await this.parse(AuthVerifyQrConfirm)
ensureWritable(flags)
const client = await createClient(flags)
await printData(await client.app.verifications.qr.confirmScanned(await resolveVerificationID(client, flags.id)), flags.json ? 'json' : 'human')
await printData(await client.app.setup.verifications.qr.confirmScanned(await resolveVerificationID(client, flags.id)), flags.json ? 'json' : 'human')
}
}
2 changes: 1 addition & 1 deletion packages/cli/src/commands/verify/qr-scan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export default class AuthVerifyQrScan extends BeeperCommand {
const { flags } = await this.parse(AuthVerifyQrScan)
ensureWritable(flags)
const client = await createClient(flags)
await printData(await client.app.verifications.qr.scan({ data: flags.payload }), flags.json ? 'json' : 'human')
await printData(await client.app.setup.verifications.qr.scan({ data: flags.payload }), flags.json ? 'json' : 'human')
}
}
2 changes: 1 addition & 1 deletion packages/cli/src/commands/verify/recovery-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export default class AuthVerifyRecoveryKey extends BeeperCommand {
const { flags } = await this.parse(AuthVerifyRecoveryKey)
ensureWritable(flags)
const client = await createClient(flags)
await printData(await client.app.login.verification.recoveryKey.verify({ recoveryKey: flags.key }), flags.json ? 'json' : 'human')
await printData(await client.app.setup.recoveryKey.verify({ recoveryKey: flags.key }), flags.json ? 'json' : 'human')
}
}
4 changes: 2 additions & 2 deletions packages/cli/src/commands/verify/reset-recovery-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class AuthVerifyResetRecoveryKey extends BeeperCommand {
const { flags } = await this.parse(AuthVerifyResetRecoveryKey)
ensureWritable(flags)
const client = await createClient(flags)
const reset = await client.app.login.verification.recoveryKey.reset.create({})
const reset = await client.app.setup.recoveryKey.reset.create({})

if ((flags.json || !process.stdin.isTTY) && !flags.yes) {
throw new Error('Resetting the recovery key requires --yes in non-interactive mode so the new key can be confirmed.')
Expand All @@ -21,7 +21,7 @@ export default class AuthVerifyResetRecoveryKey extends BeeperCommand {
if (!await promptYesNoDefaultYes('I saved this recovery key. Use it for this account?')) throw new Error('Recovery key reset cancelled.')
}

const confirmed = await client.app.login.verification.recoveryKey.reset.confirm({ recoveryKey: reset.recoveryKey })
const confirmed = await client.app.setup.recoveryKey.reset.confirm({ recoveryKey: reset.recoveryKey })

await printData({ recoveryKey: reset.recoveryKey, session: confirmed.session }, flags.json ? 'json' : 'human')
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/verify/sas-confirm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export default class AuthVerifySasConfirm extends BeeperCommand {
const { flags } = await this.parse(AuthVerifySasConfirm)
ensureWritable(flags)
const client = await createClient(flags)
await printData(await client.app.verifications.sas.confirm(await resolveVerificationID(client, flags.id)), flags.json ? 'json' : 'human')
await printData(await client.app.setup.verifications.sas.confirm(await resolveVerificationID(client, flags.id)), flags.json ? 'json' : 'human')
}
}
2 changes: 1 addition & 1 deletion packages/cli/src/commands/verify/sas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export default class AuthVerifySas extends BeeperCommand {
const { flags } = await this.parse(AuthVerifySas)
ensureWritable(flags)
const client = await createClient(flags)
await printData(await client.app.verifications.sas.start(await resolveVerificationID(client, flags.id)), flags.json ? 'json' : 'human')
await printData(await client.app.setup.verifications.sas.start(await resolveVerificationID(client, flags.id)), flags.json ? 'json' : 'human')
}
}
2 changes: 1 addition & 1 deletion packages/cli/src/commands/verify/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export default class AuthVerifyStart extends BeeperCommand {
const { flags } = await this.parse(AuthVerifyStart)
ensureWritable(flags)
const client = await createClient(flags)
await printData(await client.app.verifications.create({ userID: flags.user }), flags.json ? 'json' : 'human')
await printData(await client.app.setup.verifications.create({ userID: flags.user }), flags.json ? 'json' : 'human')
}
}
10 changes: 5 additions & 5 deletions packages/cli/src/lib/app-api.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { createInterface } from 'node:readline/promises'
import { stdin as input, stdout as output } from 'node:process'
import { getAccessToken, resolveTarget, updateTargetCache } from './targets.js'
import type { LoginRegisterResponse, LoginResponseResponse } from '@beeper/desktop-api/resources/app/login'
import type { ResetCreateResponse } from '@beeper/desktop-api/resources/app/login/verification/recovery-key/reset'
import type { SetupRegisterResponse, SetupResponseResponse } from '@beeper/desktop-api/resources/app/setup'
import type { ResetCreateResponse } from '@beeper/desktop-api/resources/app/setup/recovery-key/reset'

export type AppLoginSuccess = LoginResponseResponse.Success | LoginRegisterResponse
export type AppRegistrationRequired = LoginResponseResponse.RegistrationRequired
export type AppLoginOutput = LoginResponseResponse | LoginRegisterResponse
export type AppLoginSuccess = SetupResponseResponse.Success | SetupRegisterResponse
export type AppRegistrationRequired = SetupResponseResponse.RegistrationRequired
export type AppLoginOutput = SetupResponseResponse | SetupRegisterResponse
export type AppRecoveryCodeResetBeginResponse = ResetCreateResponse
export type AppRequestMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'

Expand Down
12 changes: 6 additions & 6 deletions packages/cli/src/lib/app-state.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { AppSessionResponse } from '@beeper/desktop-api/resources/app'
import type { QrConfirmScannedResponse, SASConfirmResponse, SASStartResponse, VerificationAcceptResponse, VerificationCreateResponse } from '@beeper/desktop-api/resources/app/verifications'
import type { SetupRetrieveResponse } from '@beeper/desktop-api/resources/app/setup'
import type { QRConfirmScannedResponse, SASConfirmResponse, SASStartResponse, VerificationAcceptResponse, VerificationCreateResponse } from '@beeper/desktop-api/resources/app/setup/verifications'
import { appRequest, promptYesNo } from './app-api.js'

export type AppState = AppSessionResponse
export type AppState = SetupRetrieveResponse

export type ReadinessState = AppState['state']
| 'no-target'
Expand Down Expand Up @@ -59,12 +59,12 @@ export async function getAppState(options: { baseURL?: string; target?: string;
return appRequest<AppState>('GET', '/v1/app/setup', options)
}

type VerificationLister = { app: { verifications: { list(): PromiseLike<{ items: Array<{ id: string }> }> } } }
type VerificationLister = { app: { setup: { verifications: { list(): PromiseLike<{ items: Array<{ id: string }> }> } } } }

// The API has no "active" alias: action routes 409 unless the path carries the real verification ID.
export async function resolveVerificationID(client: VerificationLister, id?: string): Promise<string> {
if (id) return id
const active = (await client.app.verifications.list()).items[0]
const active = (await client.app.setup.verifications.list()).items[0]
if (!active) throw new Error('No active verification. Start one with `beeper verify`.')
return active.id
}
Expand Down Expand Up @@ -108,7 +108,7 @@ export async function driveVerification(options: { baseURL?: string; target?: st
}

if (actions.has('qr.confirmScanned') && id) {
state = (await appRequest<QrConfirmScannedResponse>('POST', `/v1/app/setup/verifications/${encodeURIComponent(id)}/qr/confirm-scanned`, options)).session
state = (await appRequest<QRConfirmScannedResponse>('POST', `/v1/app/setup/verifications/${encodeURIComponent(id)}/qr/confirm-scanned`, options)).session
continue
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function formatBugPanel(error: Error, version: string): string {
...stack.split('\n').map(line => `│ ${line}`),
'│',
`│ beeper-cli ${version} — please report at`,
'│ https://github.com/beeper/desktop-api-cli/issues',
'│ https://github.com/beeper/cli/issues',
`└${'─'.repeat(60)}`,
'',
].join('\n')
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const apiCopy = {
},
contacts: {
list: 'List merged contacts for a specific account with cursor-based pagination.',
search: 'Search contacts on a specific account using merged account contacts, network search, and exact identifier lookup.',
search: 'Search contacts on a specific account using merged account contacts, network search, and exact identifier lookup. The exact lookup only runs when the query is a phone number, email address, or username; pass one of those to resolve a specific person.',
},
messages: {
delete: 'Delete a message by final message ID. Pending message IDs are not accepted because messages cannot be deleted while sending.',
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/lib/setup-login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export type SetupLoginResult = {

export async function startEmailSetup(target: Target, email: string): Promise<{ setupRequestID: string }> {
const client = setupClient(target)
const start = await client.app.login.start()
await client.app.login.email({ setupRequestID: start.setupRequestID, email })
const start = await client.app.setup.start()
await client.app.setup.email({ setupRequestID: start.setupRequestID, email })
return { setupRequestID: start.setupRequestID }
}

Expand All @@ -27,13 +27,13 @@ export async function finishEmailSetup(target: Target, options: {
yes?: boolean
}): Promise<SetupLoginResult> {
const client = setupClient(target)
let output = await client.app.login.response({ setupRequestID: options.setupRequestID, response: options.code })
let output = await client.app.setup.response({ setupRequestID: options.setupRequestID, response: options.code })
if (isRegistrationRequired(output)) {
if ((options.json || !process.stdin.isTTY) && !options.yes) throw new Error('Registration requires --yes to accept the Beeper terms in non-interactive setup.')
const username = options.username ?? (options.json || !process.stdin.isTTY ? undefined : await promptUsername(output.usernameSuggestions))
if (!username) throw new Error('Registration requires --username.')
if (!options.yes && !await promptYesNoDefaultYes('Accept the Beeper terms and create this account?')) throw new Error('Registration cancelled.')
output = await client.app.login.register({
output = await client.app.setup.register({
acceptTerms: true,
leadToken: output.leadToken,
setupRequestID: output.setupRequestID,
Expand Down
Loading