Skip to content

session.endpoint warning fires for a deliberate refreshOn-only sessionAuth block #148

Description

@garretpremo

Spawned from #147 (non-blocking review observations).

Summary

The session.endpoint warning added in #147 fires for a configuration that #135 deliberately supports, so a correctly-configured project sees it on every CLI invocation.

if (rawSessionAuth && !mergedSessionAuth) {
    console.warn(
        '[apijack] sessionAuth is set but missing session.endpoint — SessionAuthStrategy will not be used.',
    );
}

An endpoint-less sessionAuth: { refreshOn: [401] } block is intentional under #135refreshOn is sourced from rawSessionAuth precisely so it survives the mergedSessionAuth narrowing, asserted at tests/auth/refresh-wiring.test.ts:57. CLAUDE.md's "settings.json auth.refreshOn takes precedence over sessionAuth.refreshOn when both are set" further implies sessionAuth.refreshOn alone is a supported route. Those users are now warned about a config that works as intended.

The warning's actual target is the typo case (sessions: for session:), where the block carries handshake keys but no reachable endpoint.

Suggested approach

Gate the warning on the block carrying keys beyond refreshOn — that keeps the typo diagnostic and stays quiet for the deliberate refresh-only config. Worth confirming against real usage before changing, since the alternative reading is that an endpoint-less block should always be loud and the docs should stop implying otherwise.

Also in scope (same file, both cosmetic)

  • src/auth/refresh-wiring.ts module JSDoc still reads "Kept pure so both sites stay in lockstep (sessionAuth.refreshOn is unreachable for projects using a custom AuthStrategy #135)". The function now has an I/O side effect, so "pure" is no longer literally true — the lockstep rationale still holds and should stay.
  • The warning names what's missing but not what was found. Echoing the offending block's top-level keys (e.g. found: sessions, cookies) would point a typo'd user straight at the mistake instead of leaving them to diff their config against the docs.

Acceptance criteria

  • A deliberate endpoint-less sessionAuth: { refreshOn: [...] } block produces no warning
  • A block with handshake keys but no reachable session.endpoint (the typo case) still warns
  • The warning names the offending block's top-level keys
  • refreshOn behavior from sessionAuth.refreshOn is unreachable for projects using a custom AuthStrategy #135 is unchanged in both cases
  • The refresh-wiring.ts JSDoc no longer claims purity

Metadata

Metadata

Assignees

No one assigned

    Labels

    merged to devIssue has been merged to dev. Will be closed once merged to mainready-for-implementIssue has been triaged and can be implemented

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions