@sometic/auth-firebase
v1.0.10
Published
Firebase Auth provider adapter for Sometic.
Maintainers
Readme
@sometic/auth-firebase
Firebase Auth provider adapter for @sometic/auth.
createFirebaseAuthProvider wraps a Firebase Auth-like client (email/password sign-in, register, sign-out, ID token refresh, password reset, optional email verification) and maps users/tokens into Sometic sessions. Firebase remains a peer; this package never bundles the Firebase SDK.
It exists so apps that already use Firebase Auth can still share Sometic session epoch, HTTP refresh interceptors, and authorization helpers without forking orchestration. Pass your initialized Auth instance (or a test double matching FirebaseAuthLike).
Capabilities include sign-in, register, getSession, refresh (forced ID token), getUser, passwordReset, and emailVerification when sendEmailVerification is available. mapUser customizes how Firebase users become AuthUser records.
Compose with @sometic/auth, @sometic/http, and @sometic/core. Overview: introduction and auth providers.
Install
pnpm add @sometic/auth-firebase @sometic/auth firebasenpm install @sometic/auth-firebase @sometic/auth firebaseyarn add @sometic/auth-firebase @sometic/auth firebaseUsage
Wire Firebase Auth into Sometic:
import { getAuth } from "firebase/auth";
import { createAuth, createMemoryAuthStorage } from "@sometic/auth";
import { createFirebaseAuthProvider } from "@sometic/auth-firebase";
const provider = createFirebaseAuthProvider({
auth: getAuth(),
});
const auth = createAuth({
provider,
storage: createMemoryAuthStorage(),
});
await auth.whenReady();
await auth.signIn({ email: "[email protected]", password: "secret12" });Optional user mapping:
import { createFirebaseAuthProvider } from "@sometic/auth-firebase";
const provider = createFirebaseAuthProvider({
auth: getAuth(),
mapUser: (user) => ({
id: user.uid,
email: user.email ?? undefined,
displayName: user.displayName ?? undefined,
}),
});Peers / when not to use
Optional peer: firebase (^10 || ^11 || ^12). Depends on @sometic/auth.
Do not use this adapter if you are not on Firebase Auth. Prefer @sometic/auth-local, @sometic/auth-supabase, or @sometic/auth-oidc for those backends. OAuth social providers beyond email/password are not covered by this adapter’s capability set.
Docs
License
MIT
