Skip to content

feat(oauth): let oauthSessionCommand take the sign-ins a CLI kept before - #3361

Merged
leemour merged 2 commits into
mainfrom
feat/oauth-session-options
Nov 25, 2026
Merged

leemour merged 2 commits into
mainfrom
feat/oauth-session-options

Conversation

@leemour

@leemour leemour commented Nov 25, 2026

Copy link
Copy Markdown
Member

Task

Owner decision NEED-2934 B: zm and drive use cli-core's shared browser sign-in, oauthSessionCommand, instead of their own session code. Two agents stopped on gaps in cli-core. This PR closes them, so both CLIs can move and nobody signs in again.

Why

  • zm keeps {accessToken, refreshToken, expiresAt, scopes} entries, and older ones under zoom-cli:<old config folder> / <client id>:<profile>. The shared command read only the standard format under oauth:<provider>:<profile>.
  • drive keeps its own format under the bare profile name, needs principal saved with the entry, picks scopes with --grant, and keeps its profiles in its own config.
  • zm asks for a missing client id and reads a pasted redirect with --answer-stdin, and saves the client a sign-in used (WC-SECR-25).
  • One broken keyring entry failed the whole session list in both shared commands. Desktop reads profiles from it.

What

New optional oauthSessionCommand options (it is @experimental, so this is a 1.x minor):

  • codec: the entry's format.
  • legacyAccounts(env, profile): older entries, as an account or as { service, account }. Copied on read, removed at session end, only read in a run with moved folders.
  • startOptions: more session start options. preset reads them from command.opts().
  • preset may be async, and in start it gets the sign-in steps, so it can ask for what it lacks.
  • verify may return extra, saved in the entry by the codec.
  • afterSignIn(command, signedIn): runs after the sign-in is kept, with the client it used.
  • profiles(env): the profiles session list names.

Also:

  • session start --answer-stdin with a pasted redirect, for every CLI on the shared command.
  • session status gives expires_at.
  • session list rows gain state. A profile whose sign-in cannot be read is signed_in: null, state: "unknown", and the list goes on. Same fix in tokenSessionCommand.
  • credentialStorage: older entries under another service. An entry found in the private file is copied within the file, never into the keyring. remove removes older entries too, outside moved runs.
  • storageOf, timeLimit and withTimeLimit are exported. Five CLIs and cli-template copied them.

No per-CLI output shapes. zm and drive will list the shape change as breaking in their own changelogs.

Testing

  • pnpm typecheck, pnpm lint, pnpm docs:check.
  • vitest run on src/cli/oauth-session.test.ts, src/cli/token-session.test.ts, src/oauth, and the other files that use the session commands. New tests with memoryKeyring(): a custom codec read, an older entry under another service read and copied in the owner's run and removed at end, a moved run that reads it but never copies or removes it, a start option reaching the preset, verify's extra saved, afterSignIn getting the client, --answer-stdin asking for the client and reading the pasted redirect, and both lists with a keyring that cannot be reached.

🤖 Generated with Claude Code

leemour and others added 2 commits November 25, 2026 21:44
zm and drive move to the shared browser sign-in (NEED-2934 B), and nobody
may have to sign in again. oauthSessionCommand gains optional options:

- codec: the entry's format (zoomTokenCodec, driveSessionCodec).
- legacyAccounts(env, profile): older entries, as an account or as a
  service and an account. They are copied on read and removed at session
  end. A run with moved folders only reads them.
- startOptions: more session start options, which preset reads.
- preset may be async. In start it gets the sign-in steps, so it can ask
  for a missing client id with --answer-stdin.
- verify may return extra, saved in the entry (drive's principal).
- afterSignIn(command, signedIn): gets the client the sign-in used.
- profiles(env): the profiles session list names.

session start gains --answer-stdin with a pasted redirect. status gives
expires_at. session list rows gain state. Both the token and the oauth
list mark a profile unknown instead of failing when the keyring cannot
be reached or an entry is broken.

credentialStorage reads older entries under another service, copies one
found in the private file within the file, and removes older entries on
remove outside moved runs.

storageOf, timeLimit and withTimeLimit are exported, since CLIs copied
them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leemour
leemour merged commit e2282e6 into main Nov 25, 2026
40 of 41 checks passed
@leemour
leemour deleted the feat/oauth-session-options branch November 25, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant