Skip to content

feat(auth): implement supertokens authentication abstraction#1116

Open
KabinKhandThakuri wants to merge 11 commits into
mainfrom
feat/auth-abstraction
Open

feat(auth): implement supertokens authentication abstraction#1116
KabinKhandThakuri wants to merge 11 commits into
mainfrom
feat/auth-abstraction

Conversation

@KabinKhandThakuri

@KabinKhandThakuri KabinKhandThakuri commented May 28, 2026

Copy link
Copy Markdown
Contributor

Auth Abstraction Layer — Decouples @prefabs.tech/fastify-user from direct SuperTokens dependency by introducing a pluggable Auth Adapter interface.

What's included:

  • Auth abstraction ( src/auth/ ) — AuthAdapter interface + provider registry allowing custom auth backends via registerAuthProvider()
  • SuperTokens adapter — Maps SuperTokens SDK to the generic adapter; remains the default provider
  • Dynamic plugin registration — Plugin now initializes via initAuth(fastify, provider) instead of hardcoded SuperTokens
  • Handlers decoupled — All user handlers ( me.ts , changeEmail.ts , adminSignUp.ts , etc.) no longer import SuperTokens directly
  • Cleaner types — AuthUser , User , UserCreateInput , UserUpdateInput come from the abstraction; recipe-specific types deprecated

Breaking changes:

  • UserConfig.supertokens → now optional; use authProvider config to specify custom provider
  • AuthUser type removed from types/user.ts — import from @prefabs.tech/fastify-user/auth
  • supertokensErrorHandler , areRolesExist , createUserContext exports deprecated — use @prefabs.tech/fastify-user/supertokens sub-path
  • supertokens-node moved to optional peer dependency

@KabinKhandThakuri KabinKhandThakuri marked this pull request as draft May 28, 2026 10:21
@KabinKhandThakuri KabinKhandThakuri marked this pull request as ready for review June 3, 2026 06:30
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