Skip to content

Option B — feat(auth): add createVerifier hook to the oauth config - #3

Open
muralx wants to merge 1 commit into
mainfrom
feat/create-verifier-hook
Open

Option B — feat(auth): add createVerifier hook to the oauth config#3
muralx wants to merge 1 commit into
mainfrom
feat/create-verifier-hook

Conversation

@muralx

@muralx muralx commented Aug 4, 2026

Copy link
Copy Markdown

One of two alternative shapes for the same capability — see #2 for the other (widening verify into a union). This variant keeps verify untouched and adds a creation hook instead. We intend to propose whichever reads better to the Skybridge maintainers upstream.

Shape

OAuthConfig gains an optional createVerifier(config), called once at boot at the exact point the framework builds its verifier today, defaulting to the built-in createJwksVerifier(config.verify). The config stays a data description of the deployment; createVerifier is the method that turns that data into the verifier, and a provider package returns both halves together — async preparation happens in the (already-async) provider, with the hook doing synchronous assembly at boot.

  • Pro: verify keeps its existing type and required issuer — no union, no type alias, provider signatures untouched; one uniform creation path in setupOAuth. Net diff is 4 files, +148/−2.
  • Con: an app hand-wiring a verifier without a provider package writes a one-line wrapper function instead of assigning the verifier object directly.

Changes

  • createVerifier?: (config: OAuthConfig) => OAuthTokenVerifier on OAuthConfig, with docs on the contract (resolve AuthInfo or throw the SDK error classes, as with requireBearerAuth).
  • setupOAuth: const verifier = (config.createVerifier ?? ((c) => createJwksVerifier(c.verify)))(config); the issuer boot guard is unchanged and still applies.
  • Tests: custom verifier threads authInfo; 401 challenge with resource_metadata on rejection; metadata endpoints intact; hook called exactly once at boot with the resolved config; verify.issuer still required alongside a custom hook.
  • Docs: custom-provider.mdx.

All 402 core tests pass; tsc and biome ci clean; the new tests were verified to fail with the implementation reverted.

OAuthConfig gains an optional createVerifier(config), called once at
boot at the point where the framework builds its verifier today; it
defaults to the built-in createJwksVerifier(config.verify). verify keeps
its existing type and required issuer, so provider signatures and
everything reading verify.issuer are untouched.

A provider package pairs the config it returns with a createVerifier
closing over state it prepared (providers are async; the hook is sync at
boot). The returned verifier follows the requireBearerAuth contract:
resolve AuthInfo or throw the SDK error classes. Metadata routes,
per-tool schemes, and challenge handling are unchanged.
@muralx
muralx force-pushed the feat/create-verifier-hook branch from 8a63a4d to f321ca2 Compare August 4, 2026 14:19
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.

1 participant