Skip to content

Commit d9c799c

Browse files
fix(cli)!: the CLI opens a sign-in page only for an http(s) address and never through a shell, and os mcp connect registers only an address that passes one parse (#36769)
Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: none — the published skill's `os mcp connect` row and its eval state no exit condition, no Windows lookup, no address character set and no output rule, so nothing they teach changes; `skills/**` is outside this order's file surface ## 维护者速读 - 用户能看到什么变化:命令行登录只为 http 或 https、且字符规范的登录地址自动打开浏览器;连接 Claude Code 时,只登记并打印通过同一套地址校验的服务地址,地址里带用户名或密码会被拒绝;服务器返回的名字、报错、登录地址和验证码一律以单行可见字符打印;在 Windows 上若找到的是 npm 安装的批处理包装,命令以退出码 1 停下并打印那一行。 - 为什么做:命令行工具启动外部程序一律不经过系统外壳、只交出校验过的地址,打印服务器文字时不让它改动终端显示,属于安全加固,由安全席位派发,维护者已裁定采用"停下并打印"方案并保留自定义地址的路径限制。 - 出错会怎样:最坏是浏览器没有自动打开、某个地址被拒绝登记、某段服务器文字显示成转义形式,或 Windows 上没有自动登记,用户照屏幕提示手动完成即可;整单可直接撤回。 - 要你做什么:无 ## What changes The rules: - **The CLI opens a sign-in page only for an http(s) address written in plain URL characters, and never through a shell.** `os login` and `os cloud login` hand the parsed address to the platform's opener as one argv element with `shell: false` (`open` on macOS, `xdg-open` elsewhere, `rundll32.exe url.dll,FileProtocolHandler` by its absolute path on Windows). An address outside the rule is printed, not opened, with a line saying so. "Browser opened automatically" is printed only when the opener was started; an opener that could not be started prints its own line. - **Server text prints as one line of printable characters.** Every string a server supplies that `os mcp connect`, `os login` or `os cloud login` prints or throws (an environment's name and id, an error text, the sign-in address, the user code, the account's email and id) goes through one sanitiser, `utils/terminal-text.ts`: control characters (C0 with CR, LF and TAB, DEL, C1), the Unicode line and paragraph separators and the bidirectional controls are shown as visible escapes, and the length is capped. The browser still opens the parsed address unchanged. `--json` records are unchanged. - **After the Endpoint, Name and Connect block, `os mcp connect` prints nothing from the control plane but the block's own name and address.** The Sign-in and Revoke lines now name "the environment" instead of its display name. - **`os mcp connect` registers and prints only an address that passes one parse, on both paths.** Whether it comes from `--url` or from the control plane, the address parses as an http(s) URL with no user name or password, is rebuilt from the parsed origin, holds no control character, and holds only letters, digits, `-._~:/`, `[` and `]` (an IPv6 host's brackets, and in a `--url` path prefix). An address from the control plane must also be a bare host (an optional scheme and port). Anything else exits 1, with nothing registered and no Connect line printed; each refusal names the characters accepted and a way on (the console for an environment; `claude mcp add` by hand for `--url`). The printed Connect line double-quotes an address holding a bracket, since sh-family shells read brackets as a pattern; the registered argv is unquoted. The `--url` path-prefix restriction stays, by the maintainer's word. - **`os mcp connect` starts `claude` from an argv array with `shell: false` on every platform.** On Windows it runs the `.exe`/`.com` that the first matching fully qualified `PATH` entry holds (rooted at a drive letter, or a UNC share), by its absolute path; the current directory, relative entries and entries rooted at the current drive are not searched. A batch-file shim there is not run (ruled option A): exit 1, the printed `claude mcp add` line, and both remedies. - **Every program the CLI starts carries no shell beyond four measured allowances**, each pinned by its statement and its inputs (Acceptance notes). **BREAKING (Windows): a batch-file `claude` is no longer run.** - FROM: on a Windows install whose `claude` is a batch-file shim (`claude.cmd`, which an npm global install writes), `os mcp connect` registered the server and exited 0. - TO: it registers nothing and exits 1, printing the `claude mcp add` line and saying why. - The fix: run the printed `claude mcp add …` line yourself, or install Claude Code's native Windows build and run `os mcp connect` again. **BREAKING: `os mcp connect` registers and prints only an address that passes the rule above.** - FROM: an address outside it was registered and printed as given; a user name or password in `--url` was dropped without a word. - TO: it is refused with exit 1; nothing is registered and no Connect line is printed. Each refusal names the characters accepted and a way on. - The fix: for `--url`, pass a base URL in those characters with no user name or password, or run `claude mcp add --transport http NAME URL` yourself with the server's MCP address; for an environment, check its address in the ObjectOS Cloud console. ADR-0087 disposition (stated in the changeset's marker): not-required, `no-migration-prescription` — no schema key, accepted value, export or stored row moves; there is nothing for a migration to rewrite and no tombstone. Changeset: `@objectstack/cli` patch, carrying the `!` summary, both declaration lines, the marker and both BREAKING blocks. The CLI reference (`content/docs/deployment/cli.mdx`, `os login`, `os cloud login`, `os mcp connect`) states the same rules. ## Tests Every case title states its rule or a number; sample inputs live in the data, never in a name. - `packages/cli/test/server-text-reaches-the-terminal-as-one-line.test.ts` (new): - `terminalText`, 5 cases: every C0, DEL and C1 code point, the separators and the bidirectional controls come out as visible escapes; an escape sequence loses its introducer; printable text, other scripts and emoji are unchanged and a second pass changes nothing; the cap counts its ellipsis. - A TypeScript-AST source pin over the six files those flows print from. Every argument of a print site (the `print*` helpers, `console.*`, `process.stdout|stderr.write`, `this.log|warn|error`), every `new Error(…)` message and every `message:` property must be made of literals, `terminalText(…)`, a declared text function whose own returns are held to the same rule, a `const` so made, or one of four declared line-safe expressions (the validated name and address, the line built from them, and the install-target refusal whose `message:` templates the pin also holds). Findings must be empty; every flow file has print sites and the total holds a floor of 100 (111 measured); a roster entry nothing uses reds. Detector battery: 19 loud cases (a floor per sink kind) and 14 quiet ones. The walk reads six files: the file ran in 93 ms. - `packages/cli/test/mcp-connect.test.ts` — on the registering and the `--print` path, a display name holding control characters leaves the Endpoint, Name and Connect lines byte-identical to a plain run, adds no line, leaves exactly one line starting `Connect`, and nothing after the block names the environment; environment ids, names and the control plane's error text in a refusal each stay on their line; the bracket quoting; the `--url` user name and password refusal on both paths; the way on in both refusals; the control-plane address refusals, numbered 1 to 16; an address with `_` and `~` registers. - `packages/cli/test/sign-in-page-opens-http-only-without-a-shell.test.ts` — both device flows: the printed sign-in address and user code carry no control byte and add no line, and the browser opens the parsed address unchanged; the server's error text reaches the thrown error as one line; the refused-address cases, numbered; a UNC share entry is searched, both spellings. - `packages/cli/test/cli-launches-without-a-shell.pin.test.ts` — the shell-program rule reads either side of `||`, `??` and `?:`; a `createRequire(…)` result, held or called inline, counts as `require`. Battery now 40 loud cases (11 / 11 / 8 / 10 per rule, each held to that floor) and 20 quiet. The header lists what the pin still cannot see. Measured: the file ran in under 1 s, its walk inside `beforeAll`. ## Acceptance notes - **Allow-listed in the source pin, measured, not changed here.** The rule names three text classes an allowed command line may carry: text the CLI wrote; text held to a fixed character set or a closed set of values; the invoking user's own argument to the same command. `commands/doctor.ts` `probeTool` (CLI-written constant probes; every caller passes a literal, pinned); `commands/dev.ts` `pnpm [--filter PACKAGE --fail-if-no-match] dev` (the invoking user's own argument, chosen over a character set because pnpm owns the filter grammar); `commands/init.ts` `PM install` (closed set); `utils/skills-catalog.ts` `npm pack` on Windows (exact-version charset and a quoted CLI-created directory). - `describeEnvironment` is shared, so `os deploy`'s and `os package publish --install`'s environment lines print the control plane's name and id as one line too. - Not measured on a Windows host: the opener's argv and the client lookup are pinned with a mocked file probe and a mocked runner. A `PATH` entry that is a link rather than a regular file is not measured. - The `--url` narrowing also refuses a base URL whose path prefix holds a percent-encoded or punctuation character; such a server has no spelling under the rule, and the refusal names registering it with `claude mcp add` by hand. ## Verification <details><summary>Reverse verification (fix committed first; each mutation through an anchor that must hit, the named files run, the restore proven blob == HEAD and an empty git diff HEAD)</summary> 19 mutation runs, 16 distinct ablations, each red and then restored: - One-line rule: the environment name unsanitised in the shared describer: 3 red. The user code unsanitised (cloud flow): 2 red (behaviour and source pin). The sign-in address unsanitised (`os login`): 2 red. The server's error text unsanitised in the thrown error: 2 red. An account email unsanitised (`os cloud login`): 1 red (source pin). The sanitiser disabled: 10 red. - Source-pin detector: text-function returns unchecked: 2 red. - Address rule: bracket quoting removed: 2 red. `--url` user name and password refusal removed: 2 red. The control-plane refusal's way on removed: 16 red. The `--url` refusal's way on removed: 1 red. - Windows lookup: UNC entries not searched: 1 red. - No-shell pin: a shell program behind `||`/`??` unread, in `?:` unread, an inline `createRequire` load unread, a held `createRequire` result unread: 1 red each. - Three first attempts were refused by the mutation tool before any test ran (each replacement already occurred in the file); each was re-run with a disjoint replacement. - After all of them: 0 changed paths, empty `git diff HEAD`. </details> <details><summary>Local runs (final head bde1e1b unless a line names another)</summary> - `pnpm --filter @objectstack/cli typecheck` (tsc + `check:test-typecheck`) → `VERDICT command-exit 0`, `check:test-typecheck: OK`. - The four files above → `Test Files 4 passed (4)` (mcp-connect 42, sign-in 41, the new pin 10, the no-shell pin 5). - CLI `unit` tier (`vitest run --project unit`) → `Test Files 442 passed (442) · Tests 6316 passed (6316)`. The `integration` tier is declared to CI. - `eslint --no-inline-config` over the ten touched TypeScript files → exit 0; `check-nul-bytes` → OK; control-byte scan over every touched file → no match; `check-platform-checklist --changed-from origin/main` → exit 0. - Derived gate list (`dispatch-gates.mjs --commands --repo objectstack-ai/objectstack`), 102 families, each exit captured before any pipe: 102 × exit 0. `--ran` reconciliation: `102 derived, 102 run, 0 NOT-MEASURED, 0 UNRUN`. The derivation warned that the tree is 7 commits behind `origin/main`; `main` was not merged, as no conflict or main-caused red asks for it. - Dogfood battery (the title carries `!`): `pnpm --filter '@objectstack/dogfood^...' build && pnpm --filter @objectstack/dogfood test` under the lock → `VERDICT command-exit 0` · `Test Files 487 passed | 3 skipped (490)` · `Tests 4125 passed | 68 skipped (4193)`, no failure. - Not measured: a Windows host. </details> Read first: `packages/cli/src/utils/terminal-text.ts`, `packages/cli/test/server-text-reaches-the-terminal-as-one-line.test.ts` (the sinks and the roster), `packages/cli/src/commands/mcp/connect.ts` (`run`, `mcpUrlFromBase`, `claudeMcpAddLine`). Two-minute check: `pnpm --filter @objectstack/cli exec vitest run --maxWorkers=2 test/server-text-reaches-the-terminal-as-one-line.test.ts test/mcp-connect.test.ts test/sign-in-page-opens-http-only-without-a-shell.test.ts test/cli-launches-without-a-shell.pin.test.ts` → `Test Files 4 passed (4) · Tests 98 passed (98)`. --- _Generated by [Claude Code](https://claude.ai/code/session_01ASNY8XNef4ywkQio6S9ju4)_ <!-- signed: security#1 · os-mickey · session_01ASNY8XNef4ywkQio6S9ju4 --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 47ed85d commit d9c799c

13 files changed

Lines changed: 2008 additions & 91 deletions
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
'@objectstack/cli': patch
3+
---
4+
5+
fix(cli)!: the CLI opens a sign-in page only for an http(s) address and never through a shell, and `os mcp connect` registers only an address that passes one parse
6+
7+
Clause-②: no (narrowing)
8+
Metadata-protocol: none
9+
10+
<!-- adr-0087: not-required (no-migration-prescription) No schema key, accepted value, export or stored row is added, removed, renamed or re-shaped. What moves is which sign-in addresses the CLI opens in a browser, how it starts the programs it launches, and which MCP addresses and Windows installs `os mcp connect` registers with; there is nothing for a migration to rewrite and no tombstone. -->
11+
12+
- **Sign-in pages.** `os login` and `os cloud login` open the device-flow sign-in page only when its address is an `http:` or `https:` URL written in plain URL characters. Any other address is printed, as it always was, with a line saying it was not opened. "Browser opened automatically" is printed only when the browser opener was started, and a line says so when it could not be started. The opener is started from an argument list, with no shell: `open` on macOS, `xdg-open` on Linux, and `rundll32.exe url.dll,FileProtocolHandler` (by its path under the Windows directory) on Windows.
13+
- **Server text prints as one line.** Every string a server supplies that `os mcp connect`, `os login` or `os cloud login` prints (an environment's name and id, an error text, the sign-in address and the user code) reaches the terminal as one line of printable characters, with control characters shown escaped and the length capped; the browser still opens the sign-in address the server gave. After its Endpoint, Name and Connect lines, `os mcp connect` prints nothing from the control plane but those lines' own name and address. `--json` records are unchanged.
14+
- **`os mcp connect` starts `claude` without a shell** on every platform. On Windows it runs the `claude.exe` (or `claude.com`) that the first matching fully qualified `PATH` entry holds (rooted at a drive letter, or a UNC share such as `\\server\share\bin`), by its full path; the current directory, relative entries and entries rooted at the current drive (`\bin`) are not searched. macOS and Linux behave as before.
15+
- **BREAKING (Windows): a batch-file `claude` is no longer run.**
16+
- FROM: on a Windows install whose `claude` is a batch-file shim (`claude.cmd`, which an npm global install writes), `os mcp connect` registered the server and exited 0.
17+
- TO: it registers nothing and exits 1, printing the `claude mcp add` line and saying why.
18+
- The fix: run the printed `claude mcp add …` line yourself, or install Claude Code's native Windows build and run `os mcp connect` again.
19+
- **BREAKING: `os mcp connect` registers and prints only an address that passes one parse, on both paths.** Whether the address comes from `--url` or from the control plane, it must parse as an `http` or `https` URL with no user name or password, it is rebuilt from the parsed origin, and it may hold only letters, digits, `-`, `.`, `_`, `~`, `:`, `/`, `[` and `]` (an IPv6 host's brackets, and in a `--url` path prefix); an address from the control plane must also be a bare host (an optional scheme and port, no path, query or fragment), and no address may hold a control character. The printed Connect line double-quotes an address that holds a bracket, since sh-family shells read brackets as a pattern.
20+
- FROM: such an address was registered and printed as given; a user name or password in `--url` was dropped without a word.
21+
- TO: it is refused with exit 1; nothing is registered and no Connect line is printed. Each refusal names the characters accepted and a way on.
22+
- The fix: for `--url`, pass a base URL in those characters with no user name or password, or run `claude mcp add --transport http NAME URL` yourself with the server's MCP address (a path prefix holding a percent-encoded or punctuation character has no spelling under the rule); for an environment, open it in the ObjectOS Cloud console and check its address.

‎content/docs/deployment/cli.mdx‎

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3484,7 +3484,13 @@ os register --url https://api.example.com
34843484

34853485
In an interactive terminal, login uses a browser-based device flow by default:
34863486
the CLI prints a one-time verification URL, opens the browser, and polls until
3487-
you approve access in your browser.
3487+
you approve access in your browser. The browser is opened only for an `http` or
3488+
`https` URL written in plain URL characters, and without a shell; any other
3489+
verification URL is printed but not opened, with a line saying so. Open it
3490+
yourself only if you recognise it. Text the server supplies (the verification
3491+
URL, the user code, an error) is printed as one line of printable characters,
3492+
with control characters shown escaped and the length capped; `--json` records
3493+
carry the server's fields as they are.
34883494
34893495
```bash
34903496
os login
@@ -3583,7 +3589,10 @@ os cloud login --email me@acme.com --password secret # CI
35833589
```
35843590

35853591
Like `os login`, in an interactive terminal it uses the browser-based device
3586-
flow: it prints a one-time verification URL and polls until you approve. If
3592+
flow: it prints a one-time verification URL, opens it in the browser under the
3593+
same rule as `os login` (only an `http` or `https` URL in plain URL characters,
3594+
without a shell), prints the server's text as one line as `os login` does, and
3595+
polls until you approve. If
35873596
cloud credentials already exist it exits successfully with "Already logged in";
35883597
pass `--force` to re-authenticate. Re-authenticating to the same control plane
35893598
as the same account keeps the active environment recorded in `cloud.json`; a
@@ -3852,15 +3861,36 @@ environments can be registered side by side. `--url` skips ObjectOS Cloud: it
38523861
takes the base URL of a self-hosted or local server (the command adds
38533862
`/api/v1/mcp` itself and refuses a URL that already ends in it) and registers it
38543863
as `objectstack`, the name `os dev`'s banner gives it. `--name` overrides either
3855-
name.
3864+
name. On both paths the URL must be an `http` or `https` URL with no user name
3865+
or password, made only of letters, digits, `-`, `.`, `_`, `~`, `:`, `/`, `[` and
3866+
`]` (an IPv6 host's brackets, and in a `--url` path prefix), so the printed line
3867+
is safe to paste into a shell; the line double-quotes an address that holds a
3868+
bracket, which sh-family shells read as a pattern. An address from the control
3869+
plane must also be a bare host, with an optional scheme and port. Any other
3870+
address is refused with exit 1, and nothing is registered or printed; the
3871+
refusal names the characters accepted and a way on (for `--url`, run
3872+
`claude mcp add --transport http NAME URL` yourself).
3873+
3874+
Every string the control plane supplies that the command prints (the
3875+
environment's name and id, an error text) is printed as one line of printable
3876+
characters, with control characters shown escaped and the length capped. After
3877+
the Endpoint, Name and Connect lines, nothing from the control plane is printed
3878+
but those lines' own name and address.
38563879
38573880
For Claude Code — the only `--client` value, and the default — the command runs
38583881
`claude mcp add --transport http NAME URL`. `--print` prints the endpoint and that
38593882
line and runs nothing, which is also how to connect any other client: add the
38603883
endpoint as a remote HTTP MCP server in its settings. Then, in Claude Code, run
3861-
`/mcp` and authenticate the server. If `claude` is not on your `PATH`, or
3862-
`claude mcp add` fails (for a name already registered, `claude mcp remove NAME` or
3863-
pick another `--name`), the command exits non-zero.
3884+
`/mcp` and authenticate the server. `claude` is started without a shell. On
3885+
Windows the command runs the `claude.exe` (or `claude.com`) that the first
3886+
matching fully qualified `PATH` entry holds (rooted at a drive letter, or a UNC
3887+
share); the current directory, relative entries and entries rooted at the
3888+
current drive are not searched. If that entry holds a batch-file shim instead
3889+
(`claude.cmd`, which an npm global install writes), the command does not run it
3890+
and exits 1: run the printed `claude mcp add` line yourself, or install Claude
3891+
Code's native Windows build and run `os mcp connect` again. If `claude` is not on
3892+
your `PATH`, or `claude mcp add` fails (for a name already registered,
3893+
`claude mcp remove NAME` or pick another `--name`), the command exits non-zero.
38643894

38653895
**No token is stored.** The command hands the client the URL alone and writes no
38663896
token into a client config. `-t, --token` (or the `os cloud login` session) is

‎packages/cli/src/commands/cloud/login.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ import { printHeader, printKV, printSuccess, printError, emitJson, errorCodeFiel
7777
import { loginWithBrowser, loginWithPassword } from '../../utils/auth-flows.js';
7878
import { DEFAULT_CLOUD_URL, readCloudConfig, tryReadCloudConfig, writeCloudConfig, type CloudConfig } from '../../utils/cloud-config.js';
7979
import { isSameControlPlane } from '../../utils/active-environment.js';
80+
import { terminalText } from '../../utils/terminal-text.js';
8081

8182
/**
8283
* The `cloud.json` a successful login writes: the new credential, plus the
@@ -209,7 +210,7 @@ export default class CloudLogin extends Command {
209210
if (flags.json) {
210211
await emitRecord({ success: false, error: 'Already logged in', email: existing.email, url: existing.url });
211212
} else {
212-
printSuccess(`Already logged in to ${existing.url} as ${existing.email || existing.userId}`);
213+
printSuccess(`Already logged in to ${terminalText(existing.url)} as ${terminalText(existing.email || existing.userId)}`);
213214
console.log('');
214215
console.log(' Run `os cloud logout` to switch accounts, or use --force to re-authenticate.');
215216
console.log('');
@@ -225,7 +226,7 @@ export default class CloudLogin extends Command {
225226

226227
if (!flags.json) {
227228
printHeader('ObjectOS Cloud Login');
228-
printKV('Server', url);
229+
printKV('Server', terminalText(url));
229230
console.log('');
230231
}
231232

@@ -261,8 +262,8 @@ export default class CloudLogin extends Command {
261262
await emitRecord({ success: true, email: result.user?.email, userId: result.user?.id, url });
262263
} else {
263264
printSuccess('Cloud authentication successful');
264-
if (result.user?.email) printKV('Email', result.user.email);
265-
if (result.user?.id) printKV('User ID', result.user.id);
265+
if (result.user?.email) printKV('Email', terminalText(result.user.email));
266+
if (result.user?.id) printKV('User ID', terminalText(result.user.id));
266267
console.log('');
267268
console.log(' Credentials stored in ~/.objectstack/cloud.json');
268269
console.log(' Next: `os deploy` to put this app on your cloud environment, `os cloud whoami` to verify.');
@@ -277,7 +278,7 @@ export default class CloudLogin extends Command {
277278
await emitRecord({ success: false, error: error.message, ...errorCodeFields(error) });
278279
this.exit(1);
279280
}
280-
printError(error.message || String(error));
281+
printError(terminalText(error.message || String(error)));
281282
this.exit(1);
282283
}
283284
}

‎packages/cli/src/commands/login.ts‎

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ import { Command, Flags } from '@oclif/core';
9797
import type { CliExitCode } from '../utils/format.js';
9898
import { printHeader, printSuccess, printError, printKV, emitJson, errorCodeFields } from '../utils/format.js';
9999
import { writeAuthConfig, readAuthConfig } from '../utils/auth-config.js';
100+
import { browserOpenNotice, openBrowser } from '../utils/open-browser.js';
101+
import { terminalText } from '../utils/terminal-text.js';
100102
import { ObjectStackClient } from '@objectstack/client';
101103
import * as readline from 'node:readline/promises';
102104
import { stdin as input, stdout as output } from 'node:process';
@@ -226,16 +228,6 @@ async function promptPassword(promptText: string): Promise<string> {
226228
});
227229
}
228230

229-
/**
230-
* Open a URL in the system default browser (cross-platform).
231-
*/
232-
async function openBrowser(url: string): Promise<void> {
233-
const { exec } = await import('node:child_process');
234-
const platform = process.platform;
235-
const cmd = platform === 'darwin' ? `open "${url}"` : platform === 'win32' ? `start "" "${url}"` : `xdg-open "${url}"`;
236-
exec(cmd, () => { /* best-effort */ });
237-
}
238-
239231
export default class AuthLogin extends Command {
240232
static override description = 'Authenticate and store session credentials';
241233

@@ -288,7 +280,7 @@ export default class AuthLogin extends Command {
288280
if (flags.json) {
289281
await emitRecord({ success: false, error: 'Already logged in', email: existing.email });
290282
} else {
291-
printSuccess(`Already logged in as ${existing.email || existing.userId}`);
283+
printSuccess(`Already logged in as ${terminalText(existing.email || existing.userId)}`);
292284
console.log('');
293285
console.log(' Run `os logout` first to switch accounts, or use --force to re-authenticate.');
294286
console.log('');
@@ -302,7 +294,7 @@ export default class AuthLogin extends Command {
302294

303295
if (!flags.json) {
304296
printHeader('ObjectStack Login');
305-
printKV('Server', flags.url);
297+
printKV('Server', terminalText(flags.url));
306298
console.log('');
307299
}
308300

@@ -370,7 +362,7 @@ export default class AuthLogin extends Command {
370362
await emitRecord({ success: false, error: error.message, ...errorCodeFields(error) });
371363
this.exit(1);
372364
}
373-
printError(error.message || String(error));
365+
printError(terminalText(error.message || String(error)));
374366
this.exit(1);
375367
}
376368
}
@@ -405,8 +397,8 @@ export default class AuthLogin extends Command {
405397
await emitRecord({ success: true, email: user?.email || email, userId: user?.id });
406398
} else {
407399
printSuccess('Authentication successful');
408-
printKV('Email', user?.email || email);
409-
if (user?.id) printKV('User ID', user.id);
400+
printKV('Email', terminalText(user?.email || email));
401+
if (user?.id) printKV('User ID', terminalText(user.id));
410402
console.log('');
411403
console.log(' Credentials stored in ~/.objectstack/credentials.json');
412404
console.log('');
@@ -429,7 +421,7 @@ export default class AuthLogin extends Command {
429421
});
430422
if (!res.ok) {
431423
const err = await res.json().catch(() => ({}));
432-
throw new Error(`Device request failed (${res.status}): ${(err as any)?.error_description || (err as any)?.message || res.statusText}`);
424+
throw new Error(`Device request failed (${terminalText(res.status)}): ${terminalText((err as any)?.error_description || (err as any)?.message || res.statusText)}`);
433425
}
434426
const deviceData = await res.json() as any;
435427
const {
@@ -455,15 +447,14 @@ export default class AuthLogin extends Command {
455447
} else {
456448
console.log(' To authorize this CLI, visit:');
457449
console.log('');
458-
console.log(` ${verificationUrl}`);
450+
console.log(` ${terminalText(verificationUrl)}`);
459451
console.log('');
460-
console.log(` User code: ${user_code}`);
452+
console.log(` User code: ${terminalText(user_code)}`);
461453
console.log('');
462454
}
463455

464456
if (!noBrowser && !jsonOutput) {
465-
await openBrowser(verificationUrl);
466-
console.log(' (Browser opened automatically. Press Ctrl+C to cancel.)');
457+
console.log(browserOpenNotice(openBrowser(verificationUrl)));
467458
console.log('');
468459
}
469460

@@ -521,8 +512,8 @@ export default class AuthLogin extends Command {
521512
await emitRecord({ success: true, email: user?.email, userId: user?.id });
522513
} else {
523514
printSuccess('Authentication successful');
524-
if (user?.email) printKV('Email', user.email);
525-
if (user?.id) printKV('User ID', user.id);
515+
if (user?.email) printKV('Email', terminalText(user.email));
516+
if (user?.id) printKV('User ID', terminalText(user.id));
526517
console.log('');
527518
console.log(' Credentials stored in ~/.objectstack/credentials.json');
528519
console.log('');
@@ -543,7 +534,7 @@ export default class AuthLogin extends Command {
543534
: 'Login timed out or device code is no longer valid. Please run `os login` again.',
544535
);
545536
} else if (!pollRes.ok) {
546-
throw new Error(`Polling failed (${pollRes.status}): ${pollJson?.error_description || pollJson?.message || pollRes.statusText}`);
537+
throw new Error(`Polling failed (${terminalText(pollRes.status)}): ${terminalText(pollJson?.error_description || pollJson?.message || pollRes.statusText)}`);
547538
}
548539

549540
if (!jsonOutput) {

0 commit comments

Comments
 (0)