@marcwelti/mw-core 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +141 -0
  2. package/dist/context/index.d.mts +95 -0
  3. package/dist/context/index.d.ts +95 -0
  4. package/dist/context/index.js +280 -0
  5. package/dist/context/index.js.map +1 -0
  6. package/dist/context/index.mjs +276 -0
  7. package/dist/context/index.mjs.map +1 -0
  8. package/dist/firebase/index.d.mts +176 -0
  9. package/dist/firebase/index.d.ts +176 -0
  10. package/dist/firebase/index.js +393 -0
  11. package/dist/firebase/index.js.map +1 -0
  12. package/dist/firebase/index.mjs +318 -0
  13. package/dist/firebase/index.mjs.map +1 -0
  14. package/dist/hooks/index.d.mts +97 -0
  15. package/dist/hooks/index.d.ts +97 -0
  16. package/dist/hooks/index.js +618 -0
  17. package/dist/hooks/index.js.map +1 -0
  18. package/dist/hooks/index.mjs +611 -0
  19. package/dist/hooks/index.mjs.map +1 -0
  20. package/dist/index.d.mts +12 -0
  21. package/dist/index.d.ts +12 -0
  22. package/dist/index.js +922 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/index.mjs +843 -0
  25. package/dist/index.mjs.map +1 -0
  26. package/dist/server/index.d.mts +216 -0
  27. package/dist/server/index.d.ts +216 -0
  28. package/dist/server/index.js +309 -0
  29. package/dist/server/index.js.map +1 -0
  30. package/dist/server/index.mjs +276 -0
  31. package/dist/server/index.mjs.map +1 -0
  32. package/dist/storage-BU_rfYCi.d.mts +43 -0
  33. package/dist/storage-BU_rfYCi.d.ts +43 -0
  34. package/dist/types/index.d.mts +108 -0
  35. package/dist/types/index.d.ts +108 -0
  36. package/dist/types/index.js +12 -0
  37. package/dist/types/index.js.map +1 -0
  38. package/dist/types/index.mjs +3 -0
  39. package/dist/types/index.mjs.map +1 -0
  40. package/package.json +91 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/firebase/config.ts","../src/firebase/auth.ts","../src/firebase/firestore.ts","../src/firebase/storage.ts","../src/firebase/analytics.ts","../src/hooks/useAuth.ts","../src/hooks/useFirestore.ts","../src/hooks/useStorage.ts","../src/context/AuthContext.tsx"],"names":["auth","firebaseSignOut","db","doc","storage","user","error","signOut","signInWithGoogle","resetPassword","updateProfile","useState","useEffect","useCallback"],"mappings":";;;;;;;;;;AAuBO,SAAS,iBAAA,GAAoC;AAClD,EAAA,MAAM,MAAA,GAAyB;AAAA,IAC7B,MAAA,EAAQ,OAAA,CAAQ,GAAA,CAAI,4BAAA,IAAgC,EAAA;AAAA,IACpD,UAAA,EAAY,OAAA,CAAQ,GAAA,CAAI,gCAAA,IAAoC,EAAA;AAAA,IAC5D,SAAA,EAAW,OAAA,CAAQ,GAAA,CAAI,+BAAA,IAAmC,EAAA;AAAA,IAC1D,aAAA,EAAe,OAAA,CAAQ,GAAA,CAAI,mCAAA,IAAuC,EAAA;AAAA,IAClE,iBAAA,EAAmB,OAAA,CAAQ,GAAA,CAAI,wCAAA,IAA4C,EAAA;AAAA,IAC3E,KAAA,EAAO,OAAA,CAAQ,GAAA,CAAI,2BAAA,IAA+B,EAAA;AAAA,IAClD,aAAA,EAAe,QAAQ,GAAA,CAAI;AAAA,GAC7B;AAGA,EAAA,MAAM,cAAA,GAA2C;AAAA,IAC/C,QAAA;AAAA,IACA,YAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA;AAAA,IACA,mBAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,MAAM,aAAA,GAAgB,eAAe,MAAA,CAAO,CAAC,UAAU,CAAC,MAAA,CAAO,KAAK,CAAC,CAAA;AAErE,EAAA,IAAI,aAAA,CAAc,SAAS,CAAA,EAAG;AAC5B,IAAA,OAAA,CAAQ,IAAA;AAAA,MACN,CAAA,0CAAA,EAA6C,aAAA,CAAc,IAAA,CAAK,IAAI,CAAC,CAAA,gEAAA;AAAA,KAEvE;AAAA,EACF;AAEA,EAAA,OAAO,MAAA;AACT;AAMO,SAAS,mBAAmB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s","sourcesContent":["import { initializeApp, getApps, getApp, FirebaseApp } from 'firebase/app';\nimport { getAuth, Auth } from 'firebase/auth';\nimport { getFirestore, Firestore } from 'firebase/firestore';\nimport { getStorage, FirebaseStorage } from 'firebase/storage';\n\n/**\n * Firebase configuration interface\n * All values should be provided via environment variables\n */\nexport interface FirebaseConfig {\n apiKey: string;\n authDomain: string;\n projectId: string;\n storageBucket: string;\n messagingSenderId: string;\n appId: string;\n measurementId?: string;\n}\n\n/**\n * Get Firebase configuration from environment variables\n * Works with Next.js NEXT_PUBLIC_ prefix\n */\nexport function getFirebaseConfig(): FirebaseConfig {\n const config: FirebaseConfig = {\n apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY || '',\n authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN || '',\n projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID || '',\n storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET || '',\n messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID || '',\n appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID || '',\n measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID,\n };\n\n // Validate required fields\n const requiredFields: (keyof FirebaseConfig)[] = [\n 'apiKey',\n 'authDomain',\n 'projectId',\n 'storageBucket',\n 'messagingSenderId',\n 'appId',\n ];\n\n const missingFields = requiredFields.filter((field) => !config[field]);\n\n if (missingFields.length > 0) {\n console.warn(\n `[mw-core] Missing Firebase config fields: ${missingFields.join(', ')}. ` +\n `Make sure to set NEXT_PUBLIC_FIREBASE_* environment variables.`\n );\n }\n\n return config;\n}\n\n/**\n * Initialize Firebase app (singleton pattern)\n * Safe to call multiple times - returns existing instance if already initialized\n */\nexport function initializeFirebase(config?: FirebaseConfig): FirebaseApp {\n if (getApps().length > 0) {\n return getApp();\n }\n\n const firebaseConfig = config || getFirebaseConfig();\n return initializeApp(firebaseConfig);\n}\n\n// Lazy initialization singletons\nlet _app: FirebaseApp | null = null;\nlet _auth: Auth | null = null;\nlet _db: Firestore | null = null;\nlet _storage: FirebaseStorage | null = null;\n\n/**\n * Get the Firebase app instance\n */\nexport function getFirebaseApp(): FirebaseApp {\n if (!_app) {\n _app = initializeFirebase();\n }\n return _app;\n}\n\n/**\n * Get the Firebase Auth instance\n */\nexport function getFirebaseAuth(): Auth {\n if (!_auth) {\n _auth = getAuth(getFirebaseApp());\n }\n return _auth;\n}\n\n/**\n * Get the Firestore database instance\n */\nexport function getFirebaseFirestore(): Firestore {\n if (!_db) {\n _db = getFirestore(getFirebaseApp());\n }\n return _db;\n}\n\n/**\n * Get the Firebase Storage instance\n */\nexport function getFirebaseStorage(): FirebaseStorage {\n if (!_storage) {\n _storage = getStorage(getFirebaseApp());\n }\n return _storage;\n}\n\n// Convenience exports for direct access\nexport const app = typeof window !== 'undefined' ? getFirebaseApp() : null;\nexport const auth = typeof window !== 'undefined' ? getFirebaseAuth() : null;\nexport const db = typeof window !== 'undefined' ? getFirebaseFirestore() : null;\nexport const storage = typeof window !== 'undefined' ? getFirebaseStorage() : null;\n\n","import {\n signInWithEmailAndPassword,\n createUserWithEmailAndPassword,\n signOut as firebaseSignOut,\n sendPasswordResetEmail,\n sendEmailVerification,\n updateProfile,\n GoogleAuthProvider,\n signInWithPopup,\n signInWithRedirect,\n getRedirectResult,\n onAuthStateChanged,\n User,\n UserCredential,\n Auth,\n} from 'firebase/auth';\nimport { getFirebaseAuth } from './config';\n\n/**\n * Sign in with email and password\n */\nexport async function signInWithEmail(\n email: string,\n password: string\n): Promise<UserCredential> {\n const auth = getFirebaseAuth();\n return signInWithEmailAndPassword(auth, email, password);\n}\n\n/**\n * Create a new account with email and password\n */\nexport async function signUpWithEmail(\n email: string,\n password: string,\n displayName?: string\n): Promise<UserCredential> {\n const auth = getFirebaseAuth();\n const credential = await createUserWithEmailAndPassword(auth, email, password);\n \n if (displayName && credential.user) {\n await updateProfile(credential.user, { displayName });\n }\n \n return credential;\n}\n\n/**\n * Sign out the current user\n */\nexport async function signOut(): Promise<void> {\n const auth = getFirebaseAuth();\n return firebaseSignOut(auth);\n}\n\n/**\n * Send a password reset email\n */\nexport async function resetPassword(email: string): Promise<void> {\n const auth = getFirebaseAuth();\n return sendPasswordResetEmail(auth, email);\n}\n\n/**\n * Send email verification to the current user\n */\nexport async function sendVerificationEmail(user: User): Promise<void> {\n return sendEmailVerification(user);\n}\n\n/**\n * Update the current user's profile\n */\nexport async function updateUserProfile(\n user: User,\n profile: { displayName?: string; photoURL?: string }\n): Promise<void> {\n return updateProfile(user, profile);\n}\n\n/**\n * Sign in with Google using popup\n */\nexport async function signInWithGoogle(): Promise<UserCredential> {\n const auth = getFirebaseAuth();\n const provider = new GoogleAuthProvider();\n provider.addScope('email');\n provider.addScope('profile');\n return signInWithPopup(auth, provider);\n}\n\n/**\n * Sign in with Google using redirect (better for mobile)\n */\nexport async function signInWithGoogleRedirect(): Promise<void> {\n const auth = getFirebaseAuth();\n const provider = new GoogleAuthProvider();\n provider.addScope('email');\n provider.addScope('profile');\n return signInWithRedirect(auth, provider);\n}\n\n/**\n * Get the result of a redirect sign-in\n */\nexport async function getGoogleRedirectResult(): Promise<UserCredential | null> {\n const auth = getFirebaseAuth();\n return getRedirectResult(auth);\n}\n\n/**\n * Subscribe to auth state changes\n */\nexport function subscribeToAuthState(\n callback: (user: User | null) => void\n): () => void {\n const auth = getFirebaseAuth();\n return onAuthStateChanged(auth, callback);\n}\n\n/**\n * Get the current user (may be null if not authenticated)\n */\nexport function getCurrentUser(): User | null {\n const auth = getFirebaseAuth();\n return auth.currentUser;\n}\n\n/**\n * Wait for the auth state to be determined\n * Useful for SSR/initial load\n */\nexport function waitForAuthState(): Promise<User | null> {\n return new Promise((resolve) => {\n const auth = getFirebaseAuth();\n const unsubscribe = onAuthStateChanged(auth, (user) => {\n unsubscribe();\n resolve(user);\n });\n });\n}\n\n// Re-export useful types\nexport type { User, UserCredential, Auth };\n\n","import {\n collection,\n doc,\n getDoc,\n getDocs,\n setDoc,\n updateDoc,\n deleteDoc,\n addDoc,\n query,\n where,\n orderBy,\n limit,\n startAfter,\n onSnapshot,\n DocumentData,\n DocumentReference,\n CollectionReference,\n QueryConstraint,\n DocumentSnapshot,\n QuerySnapshot,\n Timestamp,\n serverTimestamp,\n FieldValue,\n WhereFilterOp,\n OrderByDirection,\n Unsubscribe,\n} from 'firebase/firestore';\nimport { getFirebaseFirestore } from './config';\n\n/**\n * Get a document reference\n */\nexport function getDocRef<T = DocumentData>(\n collectionPath: string,\n documentId: string\n): DocumentReference<T> {\n const db = getFirebaseFirestore();\n return doc(db, collectionPath, documentId) as DocumentReference<T>;\n}\n\n/**\n * Get a collection reference\n */\nexport function getCollectionRef<T = DocumentData>(\n collectionPath: string\n): CollectionReference<T> {\n const db = getFirebaseFirestore();\n return collection(db, collectionPath) as CollectionReference<T>;\n}\n\n/**\n * Get a single document by ID\n */\nexport async function getDocument<T = DocumentData>(\n collectionPath: string,\n documentId: string\n): Promise<T | null> {\n const docRef = getDocRef<T>(collectionPath, documentId);\n const docSnap = await getDoc(docRef);\n \n if (docSnap.exists()) {\n return { id: docSnap.id, ...docSnap.data() } as T;\n }\n \n return null;\n}\n\n/**\n * Get all documents in a collection\n */\nexport async function getCollection<T = DocumentData>(\n collectionPath: string,\n constraints: QueryConstraint[] = []\n): Promise<T[]> {\n const collectionRef = getCollectionRef<T>(collectionPath);\n const q = query(collectionRef, ...constraints);\n const querySnapshot = await getDocs(q);\n \n return querySnapshot.docs.map((doc) => ({\n id: doc.id,\n ...doc.data(),\n })) as T[];\n}\n\n/**\n * Add a new document with auto-generated ID\n */\nexport async function addDocument<T = DocumentData>(\n collectionPath: string,\n data: Omit<T, 'id'>\n): Promise<string> {\n const collectionRef = getCollectionRef(collectionPath);\n const docRef = await addDoc(collectionRef, {\n ...data,\n createdAt: serverTimestamp(),\n updatedAt: serverTimestamp(),\n });\n return docRef.id;\n}\n\n/**\n * Set/create a document with a specific ID\n */\nexport async function setDocument<T = DocumentData>(\n collectionPath: string,\n documentId: string,\n data: Omit<T, 'id'>,\n merge: boolean = false\n): Promise<void> {\n const docRef = getDocRef(collectionPath, documentId);\n await setDoc(\n docRef,\n {\n ...data,\n updatedAt: serverTimestamp(),\n ...(merge ? {} : { createdAt: serverTimestamp() }),\n },\n { merge }\n );\n}\n\n/**\n * Update specific fields in a document\n */\nexport async function updateDocument<T = DocumentData>(\n collectionPath: string,\n documentId: string,\n data: Partial<T>\n): Promise<void> {\n const docRef = getDocRef(collectionPath, documentId);\n await updateDoc(docRef, {\n ...data,\n updatedAt: serverTimestamp(),\n });\n}\n\n/**\n * Delete a document\n */\nexport async function deleteDocument(\n collectionPath: string,\n documentId: string\n): Promise<void> {\n const docRef = getDocRef(collectionPath, documentId);\n await deleteDoc(docRef);\n}\n\n/**\n * Subscribe to a single document\n */\nexport function subscribeToDocument<T = DocumentData>(\n collectionPath: string,\n documentId: string,\n callback: (data: T | null) => void\n): Unsubscribe {\n const docRef = getDocRef<T>(collectionPath, documentId);\n \n return onSnapshot(docRef, (docSnap) => {\n if (docSnap.exists()) {\n callback({ id: docSnap.id, ...docSnap.data() } as T);\n } else {\n callback(null);\n }\n });\n}\n\n/**\n * Subscribe to a collection\n */\nexport function subscribeToCollection<T = DocumentData>(\n collectionPath: string,\n callback: (data: T[]) => void,\n constraints: QueryConstraint[] = []\n): Unsubscribe {\n const collectionRef = getCollectionRef<T>(collectionPath);\n const q = query(collectionRef, ...constraints);\n \n return onSnapshot(q, (querySnapshot) => {\n const data = querySnapshot.docs.map((doc) => ({\n id: doc.id,\n ...doc.data(),\n })) as T[];\n callback(data);\n });\n}\n\n// Export query helpers for convenience\nexport {\n query,\n where,\n orderBy,\n limit,\n startAfter,\n Timestamp,\n serverTimestamp,\n};\n\n// Re-export types\nexport type {\n DocumentData,\n DocumentReference,\n CollectionReference,\n QueryConstraint,\n DocumentSnapshot,\n QuerySnapshot,\n FieldValue,\n WhereFilterOp,\n OrderByDirection,\n Unsubscribe,\n};\n\n","import {\n ref,\n uploadBytes,\n uploadBytesResumable,\n getDownloadURL,\n deleteObject,\n listAll,\n getMetadata,\n updateMetadata,\n StorageReference,\n UploadTask,\n UploadMetadata,\n FullMetadata,\n ListResult,\n} from 'firebase/storage';\nimport { getFirebaseStorage } from './config';\n\n/**\n * Get a reference to a storage location\n */\nexport function getStorageRef(path: string): StorageReference {\n const storage = getFirebaseStorage();\n return ref(storage, path);\n}\n\n/**\n * Upload a file to storage\n */\nexport async function uploadFile(\n path: string,\n file: Blob | Uint8Array | ArrayBuffer,\n metadata?: UploadMetadata\n): Promise<string> {\n const storageRef = getStorageRef(path);\n await uploadBytes(storageRef, file, metadata);\n return getDownloadURL(storageRef);\n}\n\n/**\n * Upload a file with progress tracking\n */\nexport function uploadFileWithProgress(\n path: string,\n file: Blob | Uint8Array | ArrayBuffer,\n onProgress?: (progress: number) => void,\n metadata?: UploadMetadata\n): { task: UploadTask; promise: Promise<string> } {\n const storageRef = getStorageRef(path);\n const task = uploadBytesResumable(storageRef, file, metadata);\n \n if (onProgress) {\n task.on('state_changed', (snapshot) => {\n const progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;\n onProgress(progress);\n });\n }\n \n const promise = new Promise<string>((resolve, reject) => {\n task.on(\n 'state_changed',\n null,\n (error) => reject(error),\n async () => {\n const url = await getDownloadURL(task.snapshot.ref);\n resolve(url);\n }\n );\n });\n \n return { task, promise };\n}\n\n/**\n * Get the download URL for a file\n */\nexport async function getFileURL(path: string): Promise<string> {\n const storageRef = getStorageRef(path);\n return getDownloadURL(storageRef);\n}\n\n/**\n * Delete a file from storage\n */\nexport async function deleteFile(path: string): Promise<void> {\n const storageRef = getStorageRef(path);\n return deleteObject(storageRef);\n}\n\n/**\n * List all files in a directory\n */\nexport async function listFiles(path: string): Promise<ListResult> {\n const storageRef = getStorageRef(path);\n return listAll(storageRef);\n}\n\n/**\n * Get metadata for a file\n */\nexport async function getFileMetadata(path: string): Promise<FullMetadata> {\n const storageRef = getStorageRef(path);\n return getMetadata(storageRef);\n}\n\n/**\n * Update metadata for a file\n */\nexport async function updateFileMetadata(\n path: string,\n metadata: Partial<UploadMetadata>\n): Promise<FullMetadata> {\n const storageRef = getStorageRef(path);\n return updateMetadata(storageRef, metadata);\n}\n\n/**\n * Generate a unique file path with timestamp\n */\nexport function generateFilePath(\n folder: string,\n filename: string,\n userId?: string\n): string {\n const timestamp = Date.now();\n const extension = filename.split('.').pop() || '';\n const baseName = filename.replace(/\\.[^/.]+$/, '');\n const sanitizedName = baseName.replace(/[^a-zA-Z0-9]/g, '_');\n \n if (userId) {\n return `${folder}/${userId}/${timestamp}_${sanitizedName}.${extension}`;\n }\n \n return `${folder}/${timestamp}_${sanitizedName}.${extension}`;\n}\n\n// Re-export types\nexport type {\n StorageReference,\n UploadTask,\n UploadMetadata,\n FullMetadata,\n ListResult,\n};\n\n","import { getAnalytics, logEvent, Analytics, isSupported } from 'firebase/analytics';\nimport { getFirebaseApp } from './config';\n\nlet _analytics: Analytics | null = null;\n\n/**\n * Get the Firebase Analytics instance\n * Only works in browser environment\n */\nexport async function getFirebaseAnalytics(): Promise<Analytics | null> {\n if (typeof window === 'undefined') {\n return null;\n }\n\n if (_analytics) {\n return _analytics;\n }\n\n const supported = await isSupported();\n if (!supported) {\n console.warn('[mw-core] Firebase Analytics is not supported in this environment');\n return null;\n }\n\n _analytics = getAnalytics(getFirebaseApp());\n return _analytics;\n}\n\n/**\n * Log a custom event to Firebase Analytics\n */\nexport async function trackEvent(\n eventName: string,\n eventParams?: Record<string, unknown>\n): Promise<void> {\n const analytics = await getFirebaseAnalytics();\n if (analytics) {\n logEvent(analytics, eventName, eventParams);\n }\n}\n\n/**\n * Track a page view\n */\nexport async function trackPageView(\n pagePath: string,\n pageTitle?: string\n): Promise<void> {\n await trackEvent('page_view', {\n page_path: pagePath,\n page_title: pageTitle,\n });\n}\n\n/**\n * Track a user action\n */\nexport async function trackUserAction(\n action: string,\n category: string,\n label?: string,\n value?: number\n): Promise<void> {\n await trackEvent(action, {\n event_category: category,\n event_label: label,\n value,\n });\n}\n\n/**\n * Track sign up event\n */\nexport async function trackSignUp(method: string): Promise<void> {\n await trackEvent('sign_up', { method });\n}\n\n/**\n * Track login event\n */\nexport async function trackLogin(method: string): Promise<void> {\n await trackEvent('login', { method });\n}\n\n// Re-export types\nexport type { Analytics };\n\n","'use client';\n\nimport { useState, useEffect, useCallback } from 'react';\nimport { User, UserCredential } from 'firebase/auth';\nimport {\n subscribeToAuthState,\n signInWithEmail,\n signUpWithEmail,\n signOut as firebaseSignOut,\n signInWithGoogle as firebaseSignInWithGoogle,\n resetPassword as firebaseResetPassword,\n updateUserProfile,\n sendVerificationEmail,\n} from '../firebase/auth';\n\nexport interface UseAuthReturn {\n /** The current authenticated user, or null if not authenticated */\n user: User | null;\n /** Whether the auth state is still loading */\n loading: boolean;\n /** Any auth error that occurred */\n error: Error | null;\n /** Sign in with email and password */\n signIn: (email: string, password: string) => Promise<UserCredential>;\n /** Create a new account with email and password */\n signUp: (email: string, password: string, displayName?: string) => Promise<UserCredential>;\n /** Sign out the current user */\n signOut: () => Promise<void>;\n /** Sign in with Google */\n signInWithGoogle: () => Promise<UserCredential>;\n /** Send a password reset email */\n resetPassword: (email: string) => Promise<void>;\n /** Update the user's profile */\n updateProfile: (profile: { displayName?: string; photoURL?: string }) => Promise<void>;\n /** Send email verification */\n sendEmailVerification: () => Promise<void>;\n /** Clear any auth errors */\n clearError: () => void;\n}\n\n/**\n * React hook for Firebase Authentication\n * Provides auth state and authentication methods\n */\nexport function useAuth(): UseAuthReturn {\n const [user, setUser] = useState<User | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n const unsubscribe = subscribeToAuthState((user) => {\n setUser(user);\n setLoading(false);\n });\n\n return unsubscribe;\n }, []);\n\n const signIn = useCallback(async (email: string, password: string) => {\n setError(null);\n try {\n return await signInWithEmail(email, password);\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n }\n }, []);\n\n const signUp = useCallback(\n async (email: string, password: string, displayName?: string) => {\n setError(null);\n try {\n return await signUpWithEmail(email, password, displayName);\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n }\n },\n []\n );\n\n const signOut = useCallback(async () => {\n setError(null);\n try {\n await firebaseSignOut();\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n }\n }, []);\n\n const signInWithGoogle = useCallback(async () => {\n setError(null);\n try {\n return await firebaseSignInWithGoogle();\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n }\n }, []);\n\n const resetPassword = useCallback(async (email: string) => {\n setError(null);\n try {\n await firebaseResetPassword(email);\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n }\n }, []);\n\n const updateProfile = useCallback(\n async (profile: { displayName?: string; photoURL?: string }) => {\n setError(null);\n if (!user) {\n const error = new Error('No authenticated user');\n setError(error);\n throw error;\n }\n try {\n await updateUserProfile(user, profile);\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n }\n },\n [user]\n );\n\n const sendEmailVerificationFn = useCallback(async () => {\n setError(null);\n if (!user) {\n const error = new Error('No authenticated user');\n setError(error);\n throw error;\n }\n try {\n await sendVerificationEmail(user);\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n }\n }, [user]);\n\n const clearError = useCallback(() => {\n setError(null);\n }, []);\n\n return {\n user,\n loading,\n error,\n signIn,\n signUp,\n signOut,\n signInWithGoogle,\n resetPassword,\n updateProfile,\n sendEmailVerification: sendEmailVerificationFn,\n clearError,\n };\n}\n\n","'use client';\n\nimport { useState, useEffect, useCallback } from 'react';\nimport { QueryConstraint, Unsubscribe } from 'firebase/firestore';\nimport {\n getDocument,\n getCollection,\n addDocument,\n setDocument,\n updateDocument,\n deleteDocument,\n subscribeToDocument,\n subscribeToCollection,\n} from '../firebase/firestore';\n\n/**\n * Hook for fetching and subscribing to a single Firestore document\n */\nexport function useDocument<T>(\n collectionPath: string,\n documentId: string | null | undefined,\n options: { subscribe?: boolean } = {}\n) {\n const { subscribe = false } = options;\n const [data, setData] = useState<T | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n if (!documentId) {\n setData(null);\n setLoading(false);\n return;\n }\n\n setLoading(true);\n setError(null);\n\n if (subscribe) {\n const unsubscribe = subscribeToDocument<T>(\n collectionPath,\n documentId,\n (doc) => {\n setData(doc);\n setLoading(false);\n }\n );\n return unsubscribe;\n } else {\n getDocument<T>(collectionPath, documentId)\n .then((doc) => {\n setData(doc);\n setLoading(false);\n })\n .catch((err) => {\n setError(err);\n setLoading(false);\n });\n }\n }, [collectionPath, documentId, subscribe]);\n\n const refresh = useCallback(async () => {\n if (!documentId) return;\n setLoading(true);\n try {\n const doc = await getDocument<T>(collectionPath, documentId);\n setData(doc);\n } catch (err) {\n setError(err as Error);\n } finally {\n setLoading(false);\n }\n }, [collectionPath, documentId]);\n\n return { data, loading, error, refresh };\n}\n\n/**\n * Hook for fetching and subscribing to a Firestore collection\n */\nexport function useCollection<T>(\n collectionPath: string,\n constraints: QueryConstraint[] = [],\n options: { subscribe?: boolean } = {}\n) {\n const { subscribe = false } = options;\n const [data, setData] = useState<T[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n // Stringify constraints for dependency tracking\n const constraintsKey = JSON.stringify(\n constraints.map((c) => c.type)\n );\n\n useEffect(() => {\n setLoading(true);\n setError(null);\n\n if (subscribe) {\n const unsubscribe = subscribeToCollection<T>(\n collectionPath,\n (docs) => {\n setData(docs);\n setLoading(false);\n },\n constraints\n );\n return unsubscribe;\n } else {\n getCollection<T>(collectionPath, constraints)\n .then((docs) => {\n setData(docs);\n setLoading(false);\n })\n .catch((err) => {\n setError(err);\n setLoading(false);\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [collectionPath, constraintsKey, subscribe]);\n\n const refresh = useCallback(async () => {\n setLoading(true);\n try {\n const docs = await getCollection<T>(collectionPath, constraints);\n setData(docs);\n } catch (err) {\n setError(err as Error);\n } finally {\n setLoading(false);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [collectionPath, constraintsKey]);\n\n return { data, loading, error, refresh };\n}\n\n/**\n * Hook providing Firestore mutation operations\n */\nexport function useFirestoreMutation<T>(collectionPath: string) {\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const add = useCallback(\n async (data: Omit<T, 'id'>): Promise<string> => {\n setLoading(true);\n setError(null);\n try {\n const id = await addDocument<T>(collectionPath, data);\n return id;\n } catch (err) {\n setError(err as Error);\n throw err;\n } finally {\n setLoading(false);\n }\n },\n [collectionPath]\n );\n\n const set = useCallback(\n async (documentId: string, data: Omit<T, 'id'>, merge = false): Promise<void> => {\n setLoading(true);\n setError(null);\n try {\n await setDocument<T>(collectionPath, documentId, data, merge);\n } catch (err) {\n setError(err as Error);\n throw err;\n } finally {\n setLoading(false);\n }\n },\n [collectionPath]\n );\n\n const update = useCallback(\n async (documentId: string, data: Partial<T>): Promise<void> => {\n setLoading(true);\n setError(null);\n try {\n await updateDocument<T>(collectionPath, documentId, data);\n } catch (err) {\n setError(err as Error);\n throw err;\n } finally {\n setLoading(false);\n }\n },\n [collectionPath]\n );\n\n const remove = useCallback(\n async (documentId: string): Promise<void> => {\n setLoading(true);\n setError(null);\n try {\n await deleteDocument(collectionPath, documentId);\n } catch (err) {\n setError(err as Error);\n throw err;\n } finally {\n setLoading(false);\n }\n },\n [collectionPath]\n );\n\n const clearError = useCallback(() => {\n setError(null);\n }, []);\n\n return {\n add,\n set,\n update,\n remove,\n loading,\n error,\n clearError,\n };\n}\n\n","'use client';\n\nimport { useState, useCallback } from 'react';\nimport { UploadMetadata } from 'firebase/storage';\nimport {\n uploadFile,\n uploadFileWithProgress,\n deleteFile,\n getFileURL,\n generateFilePath,\n} from '../firebase/storage';\n\nexport interface UseStorageReturn {\n /** Upload a file */\n upload: (\n path: string,\n file: Blob | File,\n metadata?: UploadMetadata\n ) => Promise<string>;\n /** Upload a file with progress tracking */\n uploadWithProgress: (\n path: string,\n file: Blob | File,\n metadata?: UploadMetadata\n ) => Promise<string>;\n /** Delete a file */\n remove: (path: string) => Promise<void>;\n /** Get the download URL for a file */\n getURL: (path: string) => Promise<string>;\n /** Whether an upload is in progress */\n uploading: boolean;\n /** Upload progress (0-100) */\n progress: number;\n /** Any storage error */\n error: Error | null;\n /** Clear any errors */\n clearError: () => void;\n}\n\n/**\n * React hook for Firebase Storage operations\n */\nexport function useStorage(): UseStorageReturn {\n const [uploading, setUploading] = useState(false);\n const [progress, setProgress] = useState(0);\n const [error, setError] = useState<Error | null>(null);\n\n const upload = useCallback(\n async (\n path: string,\n file: Blob | File,\n metadata?: UploadMetadata\n ): Promise<string> => {\n setError(null);\n setUploading(true);\n setProgress(0);\n try {\n const url = await uploadFile(path, file, metadata);\n setProgress(100);\n return url;\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n } finally {\n setUploading(false);\n }\n },\n []\n );\n\n const uploadWithProgress = useCallback(\n async (\n path: string,\n file: Blob | File,\n metadata?: UploadMetadata\n ): Promise<string> => {\n setError(null);\n setUploading(true);\n setProgress(0);\n try {\n const { promise } = uploadFileWithProgress(\n path,\n file,\n (p) => setProgress(p),\n metadata\n );\n const url = await promise;\n return url;\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n } finally {\n setUploading(false);\n }\n },\n []\n );\n\n const remove = useCallback(async (path: string): Promise<void> => {\n setError(null);\n try {\n await deleteFile(path);\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n }\n }, []);\n\n const getURL = useCallback(async (path: string): Promise<string> => {\n setError(null);\n try {\n return await getFileURL(path);\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n }\n }, []);\n\n const clearError = useCallback(() => {\n setError(null);\n }, []);\n\n return {\n upload,\n uploadWithProgress,\n remove,\n getURL,\n uploading,\n progress,\n error,\n clearError,\n };\n}\n\n/**\n * Generate a unique storage path for a file\n */\nexport { generateFilePath };\n\n","'use client';\n\nimport React, {\n createContext,\n useContext,\n useState,\n useEffect,\n useCallback,\n useMemo,\n ReactNode,\n} from 'react';\nimport { User, UserCredential } from 'firebase/auth';\nimport {\n subscribeToAuthState,\n signInWithEmail,\n signUpWithEmail,\n signOut as firebaseSignOut,\n signInWithGoogle as firebaseSignInWithGoogle,\n resetPassword as firebaseResetPassword,\n updateUserProfile,\n sendVerificationEmail,\n} from '../firebase/auth';\n\nexport interface AuthContextValue {\n /** The current authenticated user, or null if not authenticated */\n user: User | null;\n /** Whether the auth state is still loading */\n loading: boolean;\n /** Whether the user is authenticated */\n isAuthenticated: boolean;\n /** Any auth error that occurred */\n error: Error | null;\n /** Sign in with email and password */\n signIn: (email: string, password: string) => Promise<UserCredential>;\n /** Create a new account with email and password */\n signUp: (email: string, password: string, displayName?: string) => Promise<UserCredential>;\n /** Sign out the current user */\n signOut: () => Promise<void>;\n /** Sign in with Google */\n signInWithGoogle: () => Promise<UserCredential>;\n /** Send a password reset email */\n resetPassword: (email: string) => Promise<void>;\n /** Update the user's profile */\n updateProfile: (profile: { displayName?: string; photoURL?: string }) => Promise<void>;\n /** Send email verification */\n sendEmailVerification: () => Promise<void>;\n /** Clear any auth errors */\n clearError: () => void;\n}\n\nconst AuthContext = createContext<AuthContextValue | undefined>(undefined);\n\nexport interface AuthProviderProps {\n children: ReactNode;\n /** Optional: Called when auth state changes */\n onAuthStateChange?: (user: User | null) => void;\n /** Optional: Loading component to show while auth state is loading */\n loadingComponent?: ReactNode;\n}\n\n/**\n * Auth Provider component that wraps your app and provides auth context\n * \n * @example\n * ```tsx\n * // app/layout.tsx\n * import { AuthProvider } from '@marcwelti/mw-core';\n * \n * export default function RootLayout({ children }) {\n * return (\n * <html>\n * <body>\n * <AuthProvider>\n * {children}\n * </AuthProvider>\n * </body>\n * </html>\n * );\n * }\n * ```\n */\nexport function AuthProvider({\n children,\n onAuthStateChange,\n loadingComponent,\n}: AuthProviderProps) {\n const [user, setUser] = useState<User | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n const unsubscribe = subscribeToAuthState((user) => {\n setUser(user);\n setLoading(false);\n onAuthStateChange?.(user);\n });\n\n return unsubscribe;\n }, [onAuthStateChange]);\n\n const signIn = useCallback(async (email: string, password: string) => {\n setError(null);\n try {\n return await signInWithEmail(email, password);\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n }\n }, []);\n\n const signUp = useCallback(\n async (email: string, password: string, displayName?: string) => {\n setError(null);\n try {\n return await signUpWithEmail(email, password, displayName);\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n }\n },\n []\n );\n\n const signOut = useCallback(async () => {\n setError(null);\n try {\n await firebaseSignOut();\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n }\n }, []);\n\n const signInWithGoogle = useCallback(async () => {\n setError(null);\n try {\n return await firebaseSignInWithGoogle();\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n }\n }, []);\n\n const resetPassword = useCallback(async (email: string) => {\n setError(null);\n try {\n await firebaseResetPassword(email);\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n }\n }, []);\n\n const updateProfile = useCallback(\n async (profile: { displayName?: string; photoURL?: string }) => {\n setError(null);\n if (!user) {\n const error = new Error('No authenticated user');\n setError(error);\n throw error;\n }\n try {\n await updateUserProfile(user, profile);\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n }\n },\n [user]\n );\n\n const sendEmailVerificationFn = useCallback(async () => {\n setError(null);\n if (!user) {\n const error = new Error('No authenticated user');\n setError(error);\n throw error;\n }\n try {\n await sendVerificationEmail(user);\n } catch (err) {\n const error = err as Error;\n setError(error);\n throw error;\n }\n }, [user]);\n\n const clearError = useCallback(() => {\n setError(null);\n }, []);\n\n const value = useMemo<AuthContextValue>(\n () => ({\n user,\n loading,\n isAuthenticated: !!user,\n error,\n signIn,\n signUp,\n signOut,\n signInWithGoogle,\n resetPassword,\n updateProfile,\n sendEmailVerification: sendEmailVerificationFn,\n clearError,\n }),\n [\n user,\n loading,\n error,\n signIn,\n signUp,\n signOut,\n signInWithGoogle,\n resetPassword,\n updateProfile,\n sendEmailVerificationFn,\n clearError,\n ]\n );\n\n // Show loading component while determining auth state\n if (loading && loadingComponent) {\n return <>{loadingComponent}</>;\n }\n\n return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;\n}\n\n/**\n * Hook to access auth context\n * Must be used within an AuthProvider\n * \n * @example\n * ```tsx\n * function MyComponent() {\n * const { user, signOut, isAuthenticated } = useAuthContext();\n * \n * if (!isAuthenticated) {\n * return <LoginForm />;\n * }\n * \n * return (\n * <div>\n * <p>Welcome, {user?.displayName}</p>\n * <button onClick={signOut}>Sign Out</button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useAuthContext(): AuthContextValue {\n const context = useContext(AuthContext);\n \n if (context === undefined) {\n throw new Error('useAuthContext must be used within an AuthProvider');\n }\n \n return context;\n}\n\n/**\n * HOC for protecting routes that require authentication\n * Redirects to login or shows loading state\n */\nexport function withAuth<P extends object>(\n WrappedComponent: React.ComponentType<P>,\n options: {\n LoadingComponent?: React.ComponentType;\n UnauthenticatedComponent?: React.ComponentType;\n } = {}\n) {\n const { LoadingComponent, UnauthenticatedComponent } = options;\n\n return function WithAuthComponent(props: P) {\n const { user, loading, isAuthenticated } = useAuthContext();\n\n if (loading) {\n return LoadingComponent ? <LoadingComponent /> : <div>Loading...</div>;\n }\n\n if (!isAuthenticated) {\n return UnauthenticatedComponent ? (\n <UnauthenticatedComponent />\n ) : (\n <div>Please sign in to continue</div>\n );\n }\n\n return <WrappedComponent {...props} />;\n };\n}\n\n"]}
@@ -0,0 +1,216 @@
1
+ import { App } from 'firebase-admin/app';
2
+ export { App } from 'firebase-admin/app';
3
+ import { Auth, DecodedIdToken } from 'firebase-admin/auth';
4
+ export { Auth, DecodedIdToken } from 'firebase-admin/auth';
5
+ import { Firestore } from 'firebase-admin/firestore';
6
+ export { Firestore } from 'firebase-admin/firestore';
7
+
8
+ /**
9
+ * Initialize Firebase Admin SDK (singleton)
10
+ */
11
+ declare function initializeAdminApp(): App;
12
+ /**
13
+ * Get Firebase Admin Auth instance
14
+ */
15
+ declare function getAdminAuth(): Auth;
16
+ /**
17
+ * Get Firebase Admin Firestore instance
18
+ */
19
+ declare function getAdminFirestore(): Firestore;
20
+
21
+ /**
22
+ * Session cookie configuration
23
+ */
24
+ interface SessionConfig {
25
+ /** Cookie domain (e.g., '.marc-welti.ch') */
26
+ domain: string;
27
+ /** Session duration in milliseconds (default: 5 days) */
28
+ expiresIn?: number;
29
+ /** Cookie path (default: '/') */
30
+ path?: string;
31
+ /** Use secure cookies (default: true in production) */
32
+ secure?: boolean;
33
+ }
34
+ /**
35
+ * Create a session cookie from a Firebase ID token
36
+ */
37
+ declare function createSessionCookie(idToken: string, config: SessionConfig): Promise<string>;
38
+ /**
39
+ * Generate the Set-Cookie header string for login
40
+ */
41
+ declare function generateLoginCookieHeader(sessionCookie: string, config: SessionConfig): string;
42
+ /**
43
+ * Generate the Set-Cookie header string for logout
44
+ */
45
+ declare function generateLogoutCookieHeader(config: SessionConfig): string;
46
+ /**
47
+ * Verify a session cookie and return decoded claims
48
+ */
49
+ declare function verifySessionCookie(sessionCookie: string, checkRevoked?: boolean): Promise<DecodedIdToken>;
50
+ /**
51
+ * Verify an ID token (for initial login)
52
+ */
53
+ declare function verifyIdToken(idToken: string): Promise<DecodedIdToken>;
54
+ /**
55
+ * Revoke all refresh tokens for a user (force logout everywhere)
56
+ */
57
+ declare function revokeUserTokens(uid: string): Promise<void>;
58
+ /**
59
+ * Session user data extracted from verified session
60
+ */
61
+ interface SessionUser {
62
+ uid: string;
63
+ email: string | undefined;
64
+ emailVerified: boolean;
65
+ displayName?: string;
66
+ photoURL?: string;
67
+ }
68
+ /**
69
+ * Verify session and return user data
70
+ */
71
+ declare function getSessionUser(sessionCookie: string | undefined): Promise<SessionUser | null>;
72
+
73
+ /**
74
+ * Handle login: verify ID token and create session cookie
75
+ * Returns the Set-Cookie header value
76
+ */
77
+ declare function handleLogin(idToken: string, config: SessionConfig): Promise<string>;
78
+ /**
79
+ * Handle logout: generate cookie clearing header
80
+ * Returns the Set-Cookie header value
81
+ */
82
+ declare function handleLogout(config: SessionConfig): string;
83
+ /**
84
+ * Handle session verification
85
+ * Returns session user data or null if invalid
86
+ */
87
+ declare function handleSession(sessionCookie: string | undefined): Promise<{
88
+ authenticated: boolean;
89
+ user?: SessionUser;
90
+ }>;
91
+ /**
92
+ * Default session config for marc-welti.ch
93
+ */
94
+ declare const DEFAULT_SESSION_CONFIG: SessionConfig;
95
+ /**
96
+ * Create session config with custom domain
97
+ */
98
+ declare function createSessionConfig(domain: string, options?: Partial<Omit<SessionConfig, 'domain'>>): SessionConfig;
99
+
100
+ /**
101
+ * Result of middleware authentication check
102
+ */
103
+ interface AuthResult {
104
+ authenticated: boolean;
105
+ user: SessionUser | null;
106
+ }
107
+ /**
108
+ * Verify session from cookie value
109
+ * Use this in Next.js middleware or API routes
110
+ */
111
+ declare function verifyAuth(sessionCookie: string | undefined): Promise<AuthResult>;
112
+ /**
113
+ * Check if a path matches any of the protected patterns
114
+ */
115
+ declare function isProtectedPath(pathname: string, protectedPaths: string[]): boolean;
116
+ /**
117
+ * Configuration for auth middleware
118
+ */
119
+ interface MiddlewareConfig {
120
+ /** Paths that require authentication */
121
+ protectedPaths: string[];
122
+ /** Path to redirect unauthenticated users to */
123
+ loginRedirectPath?: string;
124
+ /** Cookie name (default: 'session') */
125
+ cookieName?: string;
126
+ }
127
+ /**
128
+ * Default middleware configuration
129
+ */
130
+ declare const DEFAULT_MIDDLEWARE_CONFIG: MiddlewareConfig;
131
+ /**
132
+ * Create middleware config with custom options
133
+ */
134
+ declare function createMiddlewareConfig(protectedPaths: string[], options?: Partial<Omit<MiddlewareConfig, 'protectedPaths'>>): MiddlewareConfig;
135
+
136
+ /**
137
+ * User roles in the system
138
+ */
139
+ type UserRole = 'owner' | 'employee' | 'admin' | 'user';
140
+ /**
141
+ * Role hierarchy and permissions
142
+ *
143
+ * - owner: Marc only, full system access
144
+ * - employee: Team members, limited to assigned customers
145
+ * - admin: External developers/support, full technical access
146
+ * - user: Customers, customer-facing features only
147
+ */
148
+ declare const ROLE_DESCRIPTIONS: Record<UserRole, string>;
149
+ /**
150
+ * Check if user has one of the required roles
151
+ */
152
+ declare function hasRole(userRole: UserRole | undefined | null, requiredRoles: UserRole[]): boolean;
153
+ /**
154
+ * Check if user is an admin-level role (owner, admin, or employee)
155
+ */
156
+ declare function isStaff(userRole: UserRole | undefined | null): boolean;
157
+ /**
158
+ * Check if user has full admin access (owner or admin)
159
+ */
160
+ declare function isAdmin(userRole: UserRole | undefined | null): boolean;
161
+ /**
162
+ * Check if user is the owner
163
+ */
164
+ declare function isOwner(userRole: UserRole | undefined | null): boolean;
165
+ /**
166
+ * Get role display name
167
+ */
168
+ declare function getRoleDisplayName(role: UserRole): string;
169
+
170
+ /**
171
+ * Subscription tiers (independent, not hierarchical)
172
+ */
173
+ type SubscriptionTier = 'MasterClass' | 'MasterClassLight' | 'PremiumOnlineKurs' | 'MasterOnlineKurs' | 'OnlineKursPro' | 'PremiumTraining' | 'VIPTraining';
174
+ /**
175
+ * All available tiers
176
+ */
177
+ declare const ALL_TIERS: SubscriptionTier[];
178
+ /**
179
+ * Tier display names (internal only - not shown to customers)
180
+ */
181
+ declare const TIER_DISPLAY_NAMES: Record<SubscriptionTier, string>;
182
+ /**
183
+ * Check if user has access to a tier-gated feature
184
+ *
185
+ * @param userTier - The user's current subscription tier (or null if none)
186
+ * @param requiredTiers - List of tiers that have access to the feature
187
+ * @returns true if user's tier is in the required list
188
+ */
189
+ declare function hasAccess(userTier: SubscriptionTier | null | undefined, requiredTiers: SubscriptionTier[]): boolean;
190
+ /**
191
+ * Check if user has any active subscription
192
+ */
193
+ declare function hasSubscription(userTier: SubscriptionTier | null | undefined): boolean;
194
+ /**
195
+ * Get tier display name
196
+ */
197
+ declare function getTierDisplayName(tier: SubscriptionTier): string;
198
+ /**
199
+ * Subscription data stored in Firestore
200
+ */
201
+ interface UserSubscription {
202
+ tier: SubscriptionTier;
203
+ startDate: Date;
204
+ expirationDate?: Date;
205
+ isActive: boolean;
206
+ }
207
+ /**
208
+ * Check if subscription is expired
209
+ */
210
+ declare function isSubscriptionExpired(subscription: UserSubscription): boolean;
211
+ /**
212
+ * Check if subscription is currently active
213
+ */
214
+ declare function isSubscriptionActive(subscription: UserSubscription): boolean;
215
+
216
+ export { ALL_TIERS, type AuthResult, DEFAULT_MIDDLEWARE_CONFIG, DEFAULT_SESSION_CONFIG, type MiddlewareConfig, ROLE_DESCRIPTIONS, type SessionConfig, type SessionUser, type SubscriptionTier, TIER_DISPLAY_NAMES, type UserRole, type UserSubscription, createMiddlewareConfig, createSessionConfig, createSessionCookie, generateLoginCookieHeader, generateLogoutCookieHeader, getAdminAuth, getAdminFirestore, getRoleDisplayName, getSessionUser, getTierDisplayName, handleLogin, handleLogout, handleSession, hasAccess, hasRole, hasSubscription, initializeAdminApp, isAdmin, isOwner, isProtectedPath, isStaff, isSubscriptionActive, isSubscriptionExpired, revokeUserTokens, verifyAuth, verifyIdToken, verifySessionCookie };
@@ -0,0 +1,216 @@
1
+ import { App } from 'firebase-admin/app';
2
+ export { App } from 'firebase-admin/app';
3
+ import { Auth, DecodedIdToken } from 'firebase-admin/auth';
4
+ export { Auth, DecodedIdToken } from 'firebase-admin/auth';
5
+ import { Firestore } from 'firebase-admin/firestore';
6
+ export { Firestore } from 'firebase-admin/firestore';
7
+
8
+ /**
9
+ * Initialize Firebase Admin SDK (singleton)
10
+ */
11
+ declare function initializeAdminApp(): App;
12
+ /**
13
+ * Get Firebase Admin Auth instance
14
+ */
15
+ declare function getAdminAuth(): Auth;
16
+ /**
17
+ * Get Firebase Admin Firestore instance
18
+ */
19
+ declare function getAdminFirestore(): Firestore;
20
+
21
+ /**
22
+ * Session cookie configuration
23
+ */
24
+ interface SessionConfig {
25
+ /** Cookie domain (e.g., '.marc-welti.ch') */
26
+ domain: string;
27
+ /** Session duration in milliseconds (default: 5 days) */
28
+ expiresIn?: number;
29
+ /** Cookie path (default: '/') */
30
+ path?: string;
31
+ /** Use secure cookies (default: true in production) */
32
+ secure?: boolean;
33
+ }
34
+ /**
35
+ * Create a session cookie from a Firebase ID token
36
+ */
37
+ declare function createSessionCookie(idToken: string, config: SessionConfig): Promise<string>;
38
+ /**
39
+ * Generate the Set-Cookie header string for login
40
+ */
41
+ declare function generateLoginCookieHeader(sessionCookie: string, config: SessionConfig): string;
42
+ /**
43
+ * Generate the Set-Cookie header string for logout
44
+ */
45
+ declare function generateLogoutCookieHeader(config: SessionConfig): string;
46
+ /**
47
+ * Verify a session cookie and return decoded claims
48
+ */
49
+ declare function verifySessionCookie(sessionCookie: string, checkRevoked?: boolean): Promise<DecodedIdToken>;
50
+ /**
51
+ * Verify an ID token (for initial login)
52
+ */
53
+ declare function verifyIdToken(idToken: string): Promise<DecodedIdToken>;
54
+ /**
55
+ * Revoke all refresh tokens for a user (force logout everywhere)
56
+ */
57
+ declare function revokeUserTokens(uid: string): Promise<void>;
58
+ /**
59
+ * Session user data extracted from verified session
60
+ */
61
+ interface SessionUser {
62
+ uid: string;
63
+ email: string | undefined;
64
+ emailVerified: boolean;
65
+ displayName?: string;
66
+ photoURL?: string;
67
+ }
68
+ /**
69
+ * Verify session and return user data
70
+ */
71
+ declare function getSessionUser(sessionCookie: string | undefined): Promise<SessionUser | null>;
72
+
73
+ /**
74
+ * Handle login: verify ID token and create session cookie
75
+ * Returns the Set-Cookie header value
76
+ */
77
+ declare function handleLogin(idToken: string, config: SessionConfig): Promise<string>;
78
+ /**
79
+ * Handle logout: generate cookie clearing header
80
+ * Returns the Set-Cookie header value
81
+ */
82
+ declare function handleLogout(config: SessionConfig): string;
83
+ /**
84
+ * Handle session verification
85
+ * Returns session user data or null if invalid
86
+ */
87
+ declare function handleSession(sessionCookie: string | undefined): Promise<{
88
+ authenticated: boolean;
89
+ user?: SessionUser;
90
+ }>;
91
+ /**
92
+ * Default session config for marc-welti.ch
93
+ */
94
+ declare const DEFAULT_SESSION_CONFIG: SessionConfig;
95
+ /**
96
+ * Create session config with custom domain
97
+ */
98
+ declare function createSessionConfig(domain: string, options?: Partial<Omit<SessionConfig, 'domain'>>): SessionConfig;
99
+
100
+ /**
101
+ * Result of middleware authentication check
102
+ */
103
+ interface AuthResult {
104
+ authenticated: boolean;
105
+ user: SessionUser | null;
106
+ }
107
+ /**
108
+ * Verify session from cookie value
109
+ * Use this in Next.js middleware or API routes
110
+ */
111
+ declare function verifyAuth(sessionCookie: string | undefined): Promise<AuthResult>;
112
+ /**
113
+ * Check if a path matches any of the protected patterns
114
+ */
115
+ declare function isProtectedPath(pathname: string, protectedPaths: string[]): boolean;
116
+ /**
117
+ * Configuration for auth middleware
118
+ */
119
+ interface MiddlewareConfig {
120
+ /** Paths that require authentication */
121
+ protectedPaths: string[];
122
+ /** Path to redirect unauthenticated users to */
123
+ loginRedirectPath?: string;
124
+ /** Cookie name (default: 'session') */
125
+ cookieName?: string;
126
+ }
127
+ /**
128
+ * Default middleware configuration
129
+ */
130
+ declare const DEFAULT_MIDDLEWARE_CONFIG: MiddlewareConfig;
131
+ /**
132
+ * Create middleware config with custom options
133
+ */
134
+ declare function createMiddlewareConfig(protectedPaths: string[], options?: Partial<Omit<MiddlewareConfig, 'protectedPaths'>>): MiddlewareConfig;
135
+
136
+ /**
137
+ * User roles in the system
138
+ */
139
+ type UserRole = 'owner' | 'employee' | 'admin' | 'user';
140
+ /**
141
+ * Role hierarchy and permissions
142
+ *
143
+ * - owner: Marc only, full system access
144
+ * - employee: Team members, limited to assigned customers
145
+ * - admin: External developers/support, full technical access
146
+ * - user: Customers, customer-facing features only
147
+ */
148
+ declare const ROLE_DESCRIPTIONS: Record<UserRole, string>;
149
+ /**
150
+ * Check if user has one of the required roles
151
+ */
152
+ declare function hasRole(userRole: UserRole | undefined | null, requiredRoles: UserRole[]): boolean;
153
+ /**
154
+ * Check if user is an admin-level role (owner, admin, or employee)
155
+ */
156
+ declare function isStaff(userRole: UserRole | undefined | null): boolean;
157
+ /**
158
+ * Check if user has full admin access (owner or admin)
159
+ */
160
+ declare function isAdmin(userRole: UserRole | undefined | null): boolean;
161
+ /**
162
+ * Check if user is the owner
163
+ */
164
+ declare function isOwner(userRole: UserRole | undefined | null): boolean;
165
+ /**
166
+ * Get role display name
167
+ */
168
+ declare function getRoleDisplayName(role: UserRole): string;
169
+
170
+ /**
171
+ * Subscription tiers (independent, not hierarchical)
172
+ */
173
+ type SubscriptionTier = 'MasterClass' | 'MasterClassLight' | 'PremiumOnlineKurs' | 'MasterOnlineKurs' | 'OnlineKursPro' | 'PremiumTraining' | 'VIPTraining';
174
+ /**
175
+ * All available tiers
176
+ */
177
+ declare const ALL_TIERS: SubscriptionTier[];
178
+ /**
179
+ * Tier display names (internal only - not shown to customers)
180
+ */
181
+ declare const TIER_DISPLAY_NAMES: Record<SubscriptionTier, string>;
182
+ /**
183
+ * Check if user has access to a tier-gated feature
184
+ *
185
+ * @param userTier - The user's current subscription tier (or null if none)
186
+ * @param requiredTiers - List of tiers that have access to the feature
187
+ * @returns true if user's tier is in the required list
188
+ */
189
+ declare function hasAccess(userTier: SubscriptionTier | null | undefined, requiredTiers: SubscriptionTier[]): boolean;
190
+ /**
191
+ * Check if user has any active subscription
192
+ */
193
+ declare function hasSubscription(userTier: SubscriptionTier | null | undefined): boolean;
194
+ /**
195
+ * Get tier display name
196
+ */
197
+ declare function getTierDisplayName(tier: SubscriptionTier): string;
198
+ /**
199
+ * Subscription data stored in Firestore
200
+ */
201
+ interface UserSubscription {
202
+ tier: SubscriptionTier;
203
+ startDate: Date;
204
+ expirationDate?: Date;
205
+ isActive: boolean;
206
+ }
207
+ /**
208
+ * Check if subscription is expired
209
+ */
210
+ declare function isSubscriptionExpired(subscription: UserSubscription): boolean;
211
+ /**
212
+ * Check if subscription is currently active
213
+ */
214
+ declare function isSubscriptionActive(subscription: UserSubscription): boolean;
215
+
216
+ export { ALL_TIERS, type AuthResult, DEFAULT_MIDDLEWARE_CONFIG, DEFAULT_SESSION_CONFIG, type MiddlewareConfig, ROLE_DESCRIPTIONS, type SessionConfig, type SessionUser, type SubscriptionTier, TIER_DISPLAY_NAMES, type UserRole, type UserSubscription, createMiddlewareConfig, createSessionConfig, createSessionCookie, generateLoginCookieHeader, generateLogoutCookieHeader, getAdminAuth, getAdminFirestore, getRoleDisplayName, getSessionUser, getTierDisplayName, handleLogin, handleLogout, handleSession, hasAccess, hasRole, hasSubscription, initializeAdminApp, isAdmin, isOwner, isProtectedPath, isStaff, isSubscriptionActive, isSubscriptionExpired, revokeUserTokens, verifyAuth, verifyIdToken, verifySessionCookie };