Skip to content

feat(auth): validate stored bearer tokens on demand - #49

Open
b-pm wants to merge 13 commits into
beeper:mainfrom
b-pm:feat/auth-status-check-48
Open

b-pm wants to merge 13 commits into
beeper:mainfrom
b-pm:feat/auth-status-check-48

Conversation

@b-pm

@b-pm b-pm commented Oct 19, 2026

Copy link
Copy Markdown

Summary

Add an explicit live token check to auth status:

beeper auth status --check

The existing command remains a cheap local snapshot by default. With --check, the CLI sends the selected bearer to GET /v1/app/setup and reports:

  • valid for an accepted token
  • invalid for 401/403
  • unknown for target/network/non-auth failures
  • missing when no bearer is configured

The token itself is never returned in output.

Why

A recent #14 follow-up on headless Server 4.3.179 found that the email-login bearer can work for setup and recovery-key verification, then later be rejected with 401 Invalid token / Token not found. Today beeper auth status still says authenticated because it only checks whether a token exists on disk or in BEEPER_ACCESS_TOKEN.

This does not pretend to fix the underlying Server token-persistence bug. It makes CLI diagnostics honest so operators and agents can separate "token stored" from "token accepted."

Behavior

  • Environment token precedence is unchanged.
  • Default auth status behavior is unchanged and does no network I/O.
  • --check is read-only.
  • Non-auth failures are reported as unknown, not misclassified as invalid credentials.

Tests

Adds coverage for missing, valid, invalid, HTTP-error, and network-error states, including a check that returned diagnostics do not contain the token.

Fixes #48.
Related: #14.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T08:04:21.771732Z d419873 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a056089ea

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

b-pm commented Oct 19, 2026

Copy link
Copy Markdown
Author

@codex review current head please. The prior P1 human-rendering finding is fixed in 1d089dd and the review thread is resolved.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1d089ddd8a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/cli/src/lib/auth-health.ts Resolved

b-pm commented Oct 20, 2026

Copy link
Copy Markdown
Author

AI-assisted follow-up to the current-head review findings, now pushed to a8246861719b1d04ebf999e78695bf754e8e7709 on the existing fork branch (no force push).

  • Credentials: request failures now emit a fixed, secret-safe diagnostic rather than fetch's raw error message, which may echo the Authorization header.
  • Timeout: auth status --check now parses and forwards the global --timeout with ms/s/m/h support and bounded values.
  • Regression tests: malformed bearer containing a newline with a credential-echoing simulated fetch error; duration parsing; short timeout/AbortSignal; original network-error expectation updated.
  • No claim of production fix for the underlying headless token durability issue auth status: actively validate stored bearer tokens for headless Server targets #48. No real credentials, send, or live target used.

Local Bun workspace checks cannot execute in this environment; tests are NOT_RUN, not PASS. GitHub Actions action_required/zero-job state is likewise NO_RESULT if still present.

@codex review current head please, specifically both previously unresolved P2 findings and the new tests.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a824686171

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/cli/src/lib/auth-health.ts Resolved

b-pm commented Oct 20, 2026

Copy link
Copy Markdown
Author

Follow-up to the new P2 at #49 (comment). The existing helper now checks GET /v1/accounts, which Beeper's official accounts API documents as a bearer-authenticated request, instead of the public GET /v1/app/setup that may 200 in needs-login. Only HTTP status is evaluated; no account bodies/credentials are retained. Added a deterministic regression where setup returns 200 but protected accounts returns 401, which must result in invalid.

Current fork head: d4198735c5dcb6ca48f330874640c6072b574a67. Fixes for the prior two P2 findings (raw fetch credential echo and ignored timeout) are preserved. No force push. Bun/full CI still NO_RESULT in this execution environment.

AI coding assistance disclosed; requesting independent technical/maintainer review. @codex review current head, focusing on whether /v1/accounts enforces bearer validity on both Desktop and Server modes and on regression-test coverage.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: d4198735c5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

auth status: actively validate stored bearer tokens for headless Server targets

1 participant