Skip to content

chore(auth): draw the login QR code with uqr, on stderr - #163

Merged
neoromantic merged 1 commit into
mainfrom
chore/replace-qrcode-terminal
Nov 17, 2026
Merged

neoromantic merged 1 commit into
mainfrom
chore/replace-qrcode-terminal

Conversation

@neoromantic

Copy link
Copy Markdown
Owner

What and why

tg auth login-qr drew its QR code with qrcode-terminal, which has had no release since 2018. This replaces it with uqr 0.1.3 (no dependencies) and removes src/types/qrcode-terminal.d.ts.

  • src/utils/qr.ts renders uqr's module matrix as half blocks (▀ ▄ █, two module rows per line), black on white through ANSI colours, with the standard four-module quiet zone. uqr's own renderUnicodeCompact draws light modules in the terminal's text colour, which only scans on dark themes; fixed colours scan on both.
  • The QR code, its header and its status lines (expiry, "Waiting for scan...", scanned, invalid password) go to stderr instead of stdout, so they no longer mix with the JSON result (Pretty output (and other options) should work for all commands #2).
  • AuthDependencies.qrGenerator (shaped after qrcode-terminal's callback API) becomes renderQr: (url) => string.

Before / After

Before: stdout got the === QR Code Login === header, a QR code that read as inverted on light themes, the status lines, then the JSON.
After: stdout gets only the JSON; stderr gets the header, a black-on-white QR code with a quiet zone, and the status lines. The login flow is otherwise unchanged.

Testing

  • New src/__tests__/qr.test.ts: reads the rendered text back into a module matrix and checks it equals encode()'s matrix for a made-up tg://login URL, plus the quiet zone on every side and two rows per line.
  • auth.test.ts: the QR login prints the rendered code to stderr and nothing to stdout (mocked client).
  • Cross-check by hand: uqr's matrix for a login URL equals qrencode -l L -m 4 output bit for bit when both use the same mask.
  • bun run build compiles dist/tg with uqr bundled; dist/tg --version runs.
  • bun run check, bun run test (2245 pass), bun run test:e2e (369 pass).

Fixes #10

🤖 Generated with Claude Code

qrcode-terminal has had no release since 2018. Render the code from
uqr's module matrix as black-on-white half blocks with a four-module
quiet zone, so it scans in dark and light themes, and print it and its
status lines to stderr so they stay apart from the JSON on stdout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@neoromantic
neoromantic force-pushed the chore/replace-qrcode-terminal branch from 3ec5433 to 69c5f3f Compare November 17, 2026 20:24
@neoromantic
neoromantic merged commit 7c04e8b into main Nov 17, 2026
5 checks passed
@neoromantic
neoromantic deleted the chore/replace-qrcode-terminal branch November 17, 2026 20:28
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.

Replace qrcode-terminal

1 participant