Skip to content

fix(auth): route opaque-token debug through process.logger - #263

Merged
allanbowe merged 1 commit into
mainfrom
fix/opaque-token-logger
Aug 18, 2026
Merged

fix(auth): route opaque-token debug through process.logger#263
allanbowe merged 1 commit into
mainfrom
fix/opaque-token-logger

Conversation

@sasjs-dev

@sasjs-dev sasjs-dev Bot commented Aug 18, 2026

Copy link
Copy Markdown

Addresses review feedback: isTokenExpiring was printing console.debug for every opaque (non-JWT) refresh-token check, leaking to stdout in CI with no way to silence it via the configured logger. Routes through process.logger?.debug?.() instead. Adds type augmentation, ts-node config, and two tests.

… console.debug

console.debug leaks to stdout in CI and can't be silenced via the
configured logger. Route the 'token is not a decodable JWT' message
through process.logger?.debug?.() so it respects the log level and
is a no-op when no logger is installed.

- Add process.d.ts type augmentation for process.logger
- Enable ts-node files:true so .d.ts is loaded during build scripts
- Add tests: logger routing + no-op when logger unset
Comment thread src/auth/auth.ts
// Route through process.logger so the message respects the configured
// log level and doesn't pollute stdout in CI/test runs. Falls back to a
// no-op when no logger has been installed (e.g. library-only usage).
process.logger?.debug?.(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Optional chaining on .debug is harmless and arguably good defensive practice (protects against a test/library stubbing process.logger = {}), but note it's technically redundant: a real Logger instance always defines debug as an own arrow-function property. Not requesting a change — just flagging in case the intent was to guard something else.

@4gl-reviewer 4gl-reviewer 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.

Hermes Agent Code Review

Verdict: ✅ APPROVE

Small, focused fix that correctly routes the opaque-token debug line away from console.debug (which bypassed the configured log level and polluted stdout in CI/test runs) through process.logger?.debug?.().

Looks Good

  • The process.logger?. guard cleanly no-ops when no logger is installed (library-only usage), and this case is explicitly tested (auth.spec.ts lines 75–95).
  • src/types/system/process.d.ts correctly augments NodeJS.Process with an optional logger, and the relative import path (../../logger/logger) resolves correctly. Picked up via typeRoots in tsconfig.json.
  • The ts-node: { files: true } addition is the right fix so ts-node loads the ambient .d.ts augmentation (ts-node otherwise ignores declaration files unless files: true).
  • Tests are thorough: both the logger-present case (asserts the message hits logger.debug and not console.debug) and the logger-absent case (asserts console.debug is not called) are covered, with process.logger restored in finally blocks.
  • All 24 tests in auth.spec.ts pass locally.

Suggestions (non-blocking)

  • The second optional chain in process.logger?.debug?.() is redundant for a real Logger instance (debug is always defined as an own property) but harmless as defense-in-depth. See inline comment.

No security, correctness, or performance concerns.

Reviewed by Hermes Agent (GitHub App)

@allanbowe
allanbowe merged commit 3955dc4 into main Aug 18, 2026
4 checks passed
@allanbowe
allanbowe deleted the fix/opaque-token-logger branch August 18, 2026 14:36
@sasjs-gha

sasjs-gha Bot commented Aug 18, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 3.6.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@sasjs-gha sasjs-gha Bot added the released label Aug 18, 2026
sasjs-gha Bot pushed a commit that referenced this pull request Aug 19, 2026
## [3.6.2](v3.6.1...v3.6.2) (2026-08-19)

### Bug Fixes

* **auth:** remove unnecessary opaque-token debug message ([011eb7e](011eb7e)), closes [#263](#263)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant