Skip to content

Compose StackTokenStore explicitly instead of sniffing token methods off the adapter - #62

Merged
cuibonobo merged 1 commit into
mainfrom
claude/review-issues-51-43-wi38av
Aug 16, 2026
Merged

Compose StackTokenStore explicitly instead of sniffing token methods off the adapter#62
cuibonobo merged 1 commit into
mainfrom
claude/review-issues-51-43-wi38av

Conversation

@cuibonobo

Copy link
Copy Markdown
Member

Summary

Closes out the last open item under #43: the adapter swap and "tokens out of the portable stack file" goals already landed for free with the native SQLite adapter (adapter-local@0.7.0 composes record-adapter-sqlite's NativeTokenStore in a sibling <path>.tokens file), but the server was still going through LocalAdapter's token convenience methods rather than typing against @haverstack/core's StackTokenStore interface directly.

  • src/stack.tsStackContext now composes { adapter, stack, tokens } explicitly. tokens is a NativeTokenStore opened at stack.db.tokens, typed as StackTokenStore & { close(): Promise<void> } (the interface everywhere except the one lifecycle hook every implementation needs but the interface doesn't declare).
  • src/middleware/auth.ts — looks up sessions via ctx.tokens.lookupToken() instead of ctx.adapter.lookupToken().
  • src/routes/tokens.ts — issues/lists/revokes via ctx.tokens; TokenInfo now imports from @haverstack/core/wire instead of @haverstack/adapter-local.
  • src/index.ts / tests/setup.ts — close the token store on shutdown/cleanup alongside the stack.
  • docs/deployment.md — notes that stack.db.tokens belongs in operational backups but must be excluded from any "export your data" / stack-sharing flow, since restoring one should never resurrect a revoked token.

Other #43 items, verified rather than changed

Test plan

  • pnpm typecheck
  • pnpm lint
  • pnpm format:check
  • pnpm build
  • pnpm test — 115 tests passing

Closes #43.

https://claude.ai/code/session_018wnXZRudrMTCfubDJkkHSA


Generated by Claude Code

…off the adapter

Auth middleware and the /tokens routes now go through ctx.tokens, a
NativeTokenStore opened at stack.db.tokens and typed against core's
StackTokenStore interface, rather than calling LocalAdapter's
createToken/lookupToken/listTokens/revokeToken convenience methods
directly. TokenInfo now imports from @haverstack/core/wire.

This was already the last unaddressed item under #43 now that the
adapter swap and tokens-out-of-stack-file goals arrived for free with
the native SQLite adapter — deployment docs get a note on backing up
stack.db.tokens separately from "export your data" flows.
@cuibonobo
cuibonobo merged commit 90eb84f into main Aug 16, 2026
4 checks passed
@cuibonobo
cuibonobo deleted the claude/review-issues-51-43-wi38av branch August 16, 2026 22:16
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.

Core sync: native SQLite adapter, StackTokenStore composition, tokens out of the portable stack file (core #46, #45)

2 participants