diff --git a/src/auth/auth.spec.ts b/src/auth/auth.spec.ts index 72ca920..694810e 100644 --- a/src/auth/auth.spec.ts +++ b/src/auth/auth.spec.ts @@ -5,7 +5,6 @@ import { decodeToken } from './auth' import { DecodedToken } from '../types' -import { Logger, LogLevel } from '../logger' describe('isAccessTokenExpiring', () => { it('should return true if the token is expiring in an hour', () => { @@ -44,53 +43,19 @@ describe('isAccessTokenExpiring', () => { ).toBeFalsy() }) - it('should route opaque-token debug message through process.logger, not console.debug', () => { + it('should return false for an opaque (non-JWT) token without any output', () => { const debugSpy = jest.spyOn(console, 'debug').mockImplementation(() => {}) - const logger = new Logger(LogLevel.Debug) - const loggerSpy = jest.spyOn(logger, 'debug').mockImplementation(() => {}) - const originalLogger = process.logger - Object.defineProperty(process, 'logger', { - value: logger, - configurable: true, - writable: true - }) + const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {}) try { - isAccessTokenExpiring('1f8da55057bd4f50a6577f0bc2b38b1a-r') - expect(loggerSpy).toHaveBeenCalledWith( - 'isTokenExpiring: token is not a decodable JWT, treating it as not expiring.' - ) - expect(debugSpy).not.toHaveBeenCalled() - } finally { - Object.defineProperty(process, 'logger', { - value: originalLogger, - configurable: true, - writable: true - }) - debugSpy.mockRestore() - loggerSpy.mockRestore() - } - }) - - it('should not call console.debug for an opaque token when no logger is set', () => { - const debugSpy = jest.spyOn(console, 'debug').mockImplementation(() => {}) - const originalLogger = process.logger - Object.defineProperty(process, 'logger', { - value: undefined, - configurable: true, - writable: true - }) - - try { - isAccessTokenExpiring('1f8da55057bd4f50a6577f0bc2b38b1a-r') + expect( + isAccessTokenExpiring('1f8da55057bd4f50a6577f0bc2b38b1a-r') + ).toBeFalsy() expect(debugSpy).not.toHaveBeenCalled() + expect(errorSpy).not.toHaveBeenCalled() } finally { - Object.defineProperty(process, 'logger', { - value: originalLogger, - configurable: true, - writable: true - }) debugSpy.mockRestore() + errorSpy.mockRestore() } }) diff --git a/src/auth/auth.ts b/src/auth/auth.ts index 14cceb0..288160e 100644 --- a/src/auth/auth.ts +++ b/src/auth/auth.ts @@ -61,12 +61,8 @@ function isTokenExpiring(token: string, timeToLiveSeconds: number) { if (!(err instanceof InvalidTokenError)) throw err // Opaque tokens cannot be expiry-checked client-side. // Assume the token is usable and let the server reject it if expired. - // 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?.( - 'isTokenExpiring: token is not a decodable JWT, treating it as not expiring.' - ) + // Deliberately silent - this is routine (opaque tokens are the norm for + // SAS Logon Manager) and must never appear in CLI output. return false } diff --git a/src/types/system/process.d.ts b/src/types/system/process.d.ts deleted file mode 100644 index dde24f8..0000000 --- a/src/types/system/process.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare namespace NodeJS { - export interface Process { - logger?: import('../../logger/logger').Logger - } -} diff --git a/tsconfig.json b/tsconfig.json index 58d711d..1104fcb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,8 +14,5 @@ "sourceMap": true }, "exclude": ["node_modules", "**/*.spec.ts"], - "include": ["src"], - "ts-node": { - "files": true - } + "include": ["src"] }