@mvp-factory/holy-auth-firebase
Version:
Firebase Authentication module with Google Sign-In support
108 lines • 2.76 kB
TypeScript
import type { User as FirebaseUser } from 'firebase/auth';
export interface FirebaseConfig {
apiKey: string;
authDomain: string;
projectId: string;
storageBucket?: string;
messagingSenderId?: string;
appId: string;
measurementId?: string;
}
export interface AuthUser {
uid: string;
email: string | null;
displayName: string | null;
photoURL: string | null;
emailVerified: boolean;
providerId?: string;
phoneNumber?: string | null;
isAnonymous?: boolean;
metadata?: {
creationTime?: string;
lastSignInTime?: string;
};
}
export interface AuthState {
isAuthenticated: boolean;
isLoading: boolean;
user: AuthUser | null;
token: string | null;
error: Error | null;
}
export interface SignInResult {
user: AuthUser;
token: string;
credential?: any;
additionalUserInfo?: {
isNewUser: boolean;
providerId: string;
profile?: any;
};
}
export interface AuthOptions {
persistence?: 'local' | 'session' | 'none';
customParameters?: Record<string, string>;
scopes?: string[];
autoSync?: boolean;
syncEndpoint?: string;
}
export interface AuthError extends Error {
code: string;
customData?: any;
}
export interface SessionSyncData {
uid: string;
email: string | null;
displayName: string | null;
photoURL: string | null;
emailVerified?: boolean;
phoneNumber?: string | null;
providerId?: string;
}
export interface SessionSyncResponse {
success: boolean;
message?: string;
user?: {
uid: string;
email: string;
name: string;
};
error?: string;
}
export interface TokenVerificationResult {
uid: string;
email: string | null;
email_verified: boolean;
name: string | null;
picture?: string | null;
auth_time: number;
iat: number;
exp: number;
iss: string;
aud: string;
sub: string;
}
export declare enum AuthProvider {
GOOGLE = "google.com",
FACEBOOK = "facebook.com",
TWITTER = "twitter.com",
GITHUB = "github.com",
EMAIL = "password",
PHONE = "phone",
ANONYMOUS = "anonymous"
}
export declare enum AuthEvent {
SIGN_IN = "sign_in",
SIGN_OUT = "sign_out",
USER_CREATED = "user_created",
TOKEN_REFRESH = "token_refresh",
AUTH_STATE_CHANGED = "auth_state_changed"
}
export type AuthEventListener = (event: AuthEvent, data?: any) => void;
export interface FirebaseAuthInstance {
currentUser: FirebaseUser | null;
onAuthStateChanged: (callback: (user: FirebaseUser | null) => void) => () => void;
signInWithPopup: (provider: any) => Promise<any>;
signOut: () => Promise<void>;
}
//# sourceMappingURL=FirebaseAuth.d.ts.map