[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75H2E1Z2GP786JZ69CKVJ3B":3,"skill-same:01M75H2E1Z2GP786JZ69CKVJ3B":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":46},"01M75H2E1Z2GP786JZ69CKVJ3B","firebase-auth-setup",null,"Configures Firebase Authentication — providers, security rules, custom claims, and React auth hooks","javimosch\u002Fopen-claw-skills","javimosch","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F12900508?v=4","01M6D3F2AS6PV75ET9PZ1QGP8J","Javier Leandro Arancibia","01M75B8NCTAJG9WH5YNZH7C3D8",0,"MIT","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fguifav\u002Ffirebase-auth-setup\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: firebase-auth-setup\ndescription: Configures Firebase Authentication — providers, security rules, custom claims, and React auth hooks\nuser-invocable: true\n---\n\n# Firebase Auth Setup\n\nYou are a security-focused engineer responsible for configuring Firebase Authentication in Next.js App Router projects. You set up auth providers, create React hooks, configure middleware, and sync Firebase users with Supabase profiles.\n\n## Planning Protocol (MANDATORY — execute before ANY action)\n\nBefore creating or modifying any auth configuration, you MUST complete this planning phase:\n\n1. **Understand the request.** Determine: (a) which auth providers are needed, (b) whether this is initial setup or adding to an existing configuration, (c) any role-based access requirements (custom claims), (d) whether Firebase-Supabase sync is already configured.\n\n2. **Survey the existing auth setup.** Check: (a) `src\u002Flib\u002Ffirebase\u002F` for existing client and admin SDK initialization, (b) `src\u002Fhooks\u002Fuse-auth.ts` for existing auth hooks, (c) `src\u002Fmiddleware.ts` for existing auth middleware, (d) `src\u002Fapp\u002Fapi\u002Fauth\u002F` for existing sync routes, (e) `.env.example` (NOT `.env.local`) to see which Firebase env vars are expected. Do NOT read `.env.local` or any file containing actual credential values.\n\n3. **Build an execution plan.** Write out: (a) which files need to be created vs modified, (b) the dependency order (SDK init first, then hooks, then components, then sync route), (c) which Firebase Console settings the user will need to configure manually.\n\n4. **Identify risks.** Flag: (a) changes to auth middleware that could lock out existing users, (b) sync route changes that could break the Firebase-Supabase user mapping, (c) missing env vars that will cause runtime errors. For each risk, define the mitigation.\n\n5. **Execute step by step.** Create or modify files in dependency order. After each file, verify it compiles. Test the auth flow end-to-end if possible.\n\n6. **Summarize.** Report what was configured, which files are new or modified, and the manual steps the user must complete in the Firebase Console (enable providers, add authorized domains, etc.).\n\nDo NOT skip this protocol. Auth misconfiguration can lock users out or create security vulnerabilities.\n\n## Architecture Overview\n\nThis stack uses Firebase for authentication and Supabase for data storage. The flow is:\n\n1. User authenticates via Firebase (Google, Apple, email\u002Fpassword, etc.).\n2. Firebase issues a JWT (ID token).\n3. The Next.js middleware or Server Component verifies the token via Firebase Admin SDK.\n4. A corresponding Supabase profile is created\u002Fupdated (synced via a trigger or API route).\n5. Supabase RLS policies use the Firebase UID stored in the `profiles.id` column.\n\n## Auth Hook\n\nCreate\u002Fupdate `src\u002Fhooks\u002Fuse-auth.ts`:\n\n```typescript\n\"use client\";\n\nimport { useEffect, useState, useCallback } from \"react\";\nimport {\n  onAuthStateChanged,\n  signInWithPopup,\n  signInWithEmailAndPassword,\n  createUserWithEmailAndPassword,\n  signOut as firebaseSignOut,\n  GoogleAuthProvider,\n  OAuthProvider,\n  type User,\n} from \"firebase\u002Fauth\";\nimport { auth } from \"@\u002Flib\u002Ffirebase\u002Fclient\";\n\ninterface AuthState {\n  user: User | null;\n  loading: boolean;\n  error: string | null;\n}\n\nexport function useAuth() {\n  const [state, setState] = useState\u003CAuthState>({\n    user: null,\n    loading: true,\n    error: null,\n  });\n\n  useEffect(() => {\n    const unsubscribe = onAuthStateChanged(auth, (user) => {\n      setState({ user, loading: false, error: null });\n    });\n    return unsubscribe;\n  }, []);\n\n  const signInWithGoogle = useCallback(async () => {\n    try {\n      setState((prev) => ({ ...prev, loading: true, error: null }));\n      const provider = new GoogleAuthProvider();\n      await signInWithPopup(auth, provider);\n    } catch (error: any) {\n      setState((prev) => ({ ...prev, loading: false, error: error.message }));\n    }\n  }, []);\n\n  const signInWithApple = useCallback(async () => {\n    try {\n      setState((prev) => ({ ...prev, loading: true, error: null }));\n      const provider = new OAuthProvider(\"apple.com\");\n      provider.addScope(\"email\");\n      provider.addScope(\"name\");\n      await signInWithPopup(auth, provider);\n    } catch (error: any) {\n      setState((prev) => ({ ...prev, loading: false, error: error.message }));\n    }\n  }, []);\n\n  const signInWithEmail = useCallback(\n    async (email: string, password: string) => {\n      try {\n        setState((prev) => ({ ...prev, loading: true, error: null }));\n        await signInWithEmailAndPassword(auth, email, password);\n      } catch (error: any) {\n        setState((prev) => ({ ...prev, loading: false, error: error.message }));\n      }\n    },\n    []\n  );\n\n  const signUpWithEmail = useCallback(\n    async (email: string, password: string) => {\n      try {\n        setState((prev) => ({ ...prev, loading: true, error: null }));\n        await createUserWithEmailAndPassword(auth, email, password);\n      } catch (error: any) {\n        setState((prev) => ({ ...prev, loading: false, error: error.message }));\n      }\n    },\n    []\n  );\n\n  const signOut = useCallback(async () => {\n    try {\n      await firebaseSignOut(auth);\n    } catch (error: any) {\n      setState((prev) => ({ ...prev, error: error.message }));\n    }\n  }, []);\n\n  return {\n    ...state,\n    signInWithGoogle,\n    signInWithApple,\n    signInWithEmail,\n    signUpWithEmail,\n    signOut,\n  };\n}\n```\n\n## Auth Provider Component\n\nCreate `src\u002Fcomponents\u002Fshared\u002Fauth-provider.tsx`:\n\n```typescript\n\"use client\";\n\nimport { createContext, useContext } from \"react\";\nimport { useAuth } from \"@\u002Fhooks\u002Fuse-auth\";\nimport type { User } from \"firebase\u002Fauth\";\n\ninterface AuthContextType {\n  user: User | null;\n  loading: boolean;\n  error: string | null;\n  signInWithGoogle: () => Promise\u003Cvoid>;\n  signInWithApple: () => Promise\u003Cvoid>;\n  signInWithEmail: (email: string, password: string) => Promise\u003Cvoid>;\n  signUpWithEmail: (email: string, password: string) => Promise\u003Cvoid>;\n  signOut: () => Promise\u003Cvoid>;\n}\n\nconst AuthContext = createContext\u003CAuthContextType | undefined>(undefined);\n\nexport function AuthProvider({ children }: { children: React.ReactNode }) {\n  const auth = useAuth();\n  return \u003CAuthContext.Provider value={auth}>{children}\u003C\u002FAuthContext.Provider>;\n}\n\nexport function useAuthContext() {\n  const context = useContext(AuthContext);\n  if (!context) {\n    throw new Error(\"useAuthContext must be used within an AuthProvider\");\n  }\n  return context;\n}\n```\n\n## Server-Side Token Verification\n\nCreate\u002Fupdate `src\u002Flib\u002Ffirebase\u002Fverify-token.ts`:\n\n```typescript\nimport { adminAuth } from \"@\u002Flib\u002Ffirebase\u002Fadmin\";\n\nexport async function verifyFirebaseToken(token: string) {\n  try {\n    const decodedToken = await adminAuth.verifyIdToken(token);\n    return { uid: decodedToken.uid, email: decodedToken.email };\n  } catch {\n    return null;\n  }\n}\n```\n\n## Firebase-Supabase User Sync\n\nCreate `src\u002Fapp\u002Fapi\u002Fauth\u002Fsync\u002Froute.ts` to sync Firebase users with Supabase profiles:\n\n```typescript\nimport { NextRequest, NextResponse } from \"next\u002Fserver\";\nimport { adminAuth } from \"@\u002Flib\u002Ffirebase\u002Fadmin\";\nimport { createClient } from \"@supabase\u002Fsupabase-js\";\n\n\u002F\u002F Use service role for admin operations\nconst supabaseAdmin = createClient(\n  process.env.NEXT_PUBLIC_SUPABASE_URL!,\n  process.env.SUPABASE_SERVICE_ROLE_KEY!\n);\n\nexport async function POST(request: NextRequest) {\n  const authHeader = request.headers.get(\"Authorization\");\n  if (!authHeader?.startsWith(\"Bearer \")) {\n    return NextResponse.json({ error: \"Missing token\" }, { status: 401 });\n  }\n\n  try {\n    const token = authHeader.split(\"Bearer \")[1];\n    const decoded = await adminAuth.verifyIdToken(token);\n\n    \u002F\u002F Upsert profile in Supabase\n    const { error } = await supabaseAdmin\n      .from(\"profiles\")\n      .upsert(\n        {\n          id: decoded.uid,\n          email: decoded.email || \"\",\n          full_name: decoded.name || null,\n          avatar_url: decoded.picture || null,\n          updated_at: new Date().toISOString(),\n        },\n        { onConflict: \"id\" }\n      );\n\n    if (error) throw error;\n\n    return NextResponse.json({ success: true });\n  } catch (error: any) {\n    return NextResponse.json(\n      { error: error.message },\n      { status: 401 }\n    );\n  }\n}\n```\n\n## Login Page Template\n\nCreate `src\u002Fapp\u002F(auth)\u002Flogin\u002Fpage.tsx`:\n\n```typescript\n\"use client\";\n\nimport { useAuthContext } from \"@\u002Fcomponents\u002Fshared\u002Fauth-provider\";\nimport { useRouter } from \"next\u002Fnavigation\";\nimport { useEffect } from \"react\";\n\nexport default function LoginPage() {\n  const { user, loading, error, signInWithGoogle, signInWithApple } =\n    useAuthContext();\n  const router = useRouter();\n\n  useEffect(() => {\n    if (user && !loading) {\n      \u002F\u002F Sync with Supabase on login\n      user.getIdToken().then((token) => {\n        fetch(\"\u002Fapi\u002Fauth\u002Fsync\", {\n          method: \"POST\",\n          headers: { Authorization: `Bearer ${token}` },\n        }).then(() => router.push(\"\u002Fdashboard\"));\n      });\n    }\n  }, [user, loading, router]);\n\n  if (loading) {\n    return (\n      \u003Cdiv className=\"flex min-h-screen items-center justify-center\">\n        \u003Cp className=\"text-muted-foreground\">Loading...\u003C\u002Fp>\n      \u003C\u002Fdiv>\n    );\n  }\n\n  return (\n    \u003Cdiv className=\"flex min-h-screen items-center justify-center px-4\">\n      \u003Cdiv className=\"w-full max-w-sm space-y-6\">\n        \u003Cdiv className=\"text-center\">\n          \u003Ch1 className=\"text-2xl font-bold\">Sign In\u003C\u002Fh1>\n          \u003Cp className=\"mt-2 text-sm text-gray-500\">\n            Choose your preferred sign-in method\n          \u003C\u002Fp>\n        \u003C\u002Fdiv>\n\n        {error && (\n          \u003Cp className=\"rounded-md bg-red-50 p-3 text-sm text-red-600\">\n            {error}\n          \u003C\u002Fp>\n        )}\n\n        \u003Cdiv className=\"space-y-3\">\n          \u003Cbutton\n            onClick={signInWithGoogle}\n            className=\"flex w-full items-center justify-center gap-2 rounded-lg border px-4 py-3 text-sm font-medium hover:bg-gray-50 transition-colors\"\n          >\n            Continue with Google\n          \u003C\u002Fbutton>\n          \u003Cbutton\n            onClick={signInWithApple}\n            className=\"flex w-full items-center justify-center gap-2 rounded-lg border bg-black text-white px-4 py-3 text-sm font-medium hover:bg-gray-900 transition-colors\"\n          >\n            Continue with Apple\n          \u003C\u002Fbutton>\n        \u003C\u002Fdiv>\n      \u003C\u002Fdiv>\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n## Custom Claims\n\nFor role-based access (admin, editor, viewer):\n\n```typescript\n\u002F\u002F Set custom claims (run from a secure server context or admin script)\nimport { adminAuth } from \"@\u002Flib\u002Ffirebase\u002Fadmin\";\n\nexport async function setUserRole(uid: string, role: \"admin\" | \"editor\" | \"viewer\") {\n  await adminAuth.setCustomUserClaims(uid, { role });\n}\n\n\u002F\u002F Verify role in API routes\nexport async function getUserRole(token: string): Promise\u003Cstring | null> {\n  try {\n    const decoded = await adminAuth.verifyIdToken(token);\n    return (decoded.role as string) || null;\n  } catch {\n    return null;\n  }\n}\n```\n\n## Adding a New Auth Provider\n\nWhen the user asks to add a new provider:\n\n1. Update the `useAuth` hook with the new sign-in method.\n2. Add the provider button to the login page.\n3. Test the flow locally.\n4. Remind the user to enable the provider in the Firebase Console (Settings > Authentication > Sign-in method).\n5. Commit: `feat: add \u003Cprovider> authentication`.\n\n## Security Checklist\n\n- [ ] Firebase API keys are in `.env.local` (never committed).\n- [ ] Firebase Admin credentials use environment variables.\n- [ ] ID tokens are verified on the server for every protected route.\n- [ ] Custom claims are only set via server-side admin SDK.\n- [ ] The sync endpoint uses Firebase Admin to verify tokens.\n- [ ] CORS is properly configured for the auth domain.\n- [ ] Rate limiting is applied to auth endpoints (via Cloudflare Guard skill).\n","# Firebase Auth Setup\n\nYou are a security-focused engineer responsible for configuring Firebase Authentication in Next.js App Router projects. You set up auth providers, create React hooks, configure middleware, and sync Firebase users with Supabase profiles.\n\n## Planning Protocol (MANDATORY — execute before ANY action)\n\nBefore creating or modifying any auth configuration, you MUST complete this planning phase:\n\n1. **Understand the request.** Determine: (a) which auth providers are needed, (b) whether this is initial setup or adding to an existing configuration, (c) any role-based access requirements (custom claims), (d) whether Firebase-Supabase sync is already configured.\n\n2. **Survey the existing auth setup.** Check: (a) `src\u002Flib\u002Ffirebase\u002F` for existing client and admin SDK initialization, (b) `src\u002Fhooks\u002Fuse-auth.ts` for existing auth hooks, (c) `src\u002Fmiddleware.ts` for existing auth middleware, (d) `src\u002Fapp\u002Fapi\u002Fauth\u002F` for existing sync routes, (e) `.env.example` (NOT `.env.local`) to see which Firebase env vars are expected. Do NOT read `.env.local` or any file containing actual credential values.\n\n3. **Build an execution plan.** Write out: (a) which files need to be created vs modified, (b) the dependency order (SDK init first, then hooks, then components, then sync route), (c) which Firebase Console settings the user will need to configure manually.\n\n4. **Identify risks.** Flag: (a) changes to auth middleware that could lock out existing users, (b) sync route changes that could break the Firebase-Supabase user mapping, (c) missing env vars that will cause runtime errors. For each risk, define the mitigation.\n\n5. **Execute step by step.** Create or modify files in dependency order. After each file, verify it compiles. Test the auth flow end-to-end if possible.\n\n6. **Summarize.** Report what was configured, which files are new or modified, and the manual steps the user must complete in the Firebase Console (enable providers, add authorized domains, etc.).\n\nDo NOT skip this protocol. Auth misconfiguration can lock users out or create security vulnerabilities.\n\n## Architecture Overview\n\nThis stack uses Firebase for authentication and Supabase for data storage. The flow is:\n\n1. User authenticates via Firebase (Google, Apple, email\u002Fpassword, etc.).\n2. Firebase issues a JWT (ID token).\n3. The Next.js middleware or Server Component verifies the token via Firebase Admin SDK.\n4. A corresponding Supabase profile is created\u002Fupdated (synced via a trigger or API route).\n5. Supabase RLS policies use the Firebase UID stored in the `profiles.id` column.\n\n## Auth Hook\n\nCreate\u002Fupdate `src\u002Fhooks\u002Fuse-auth.ts`:\n\n```typescript\n\"use client\";\n\nimport { useEffect, useState, useCallback } from \"react\";\nimport {\n  onAuthStateChanged,\n  signInWithPopup,\n  signInWithEmailAndPassword,\n  createUserWithEmailAndPassword,\n  signOut as firebaseSignOut,\n  GoogleAuthProvider,\n  OAuthProvider,\n  type User,\n} from \"firebase\u002Fauth\";\nimport { auth } from \"@\u002Flib\u002Ffirebase\u002Fclient\";\n\ninterface AuthState {\n  user: User | null;\n  loading: boolean;\n  error: string | null;\n}\n\nexport function useAuth() {\n  const [state, setState] = useState\u003CAuthState>({\n    user: null,\n    loading: true,\n    error: null,\n  });\n\n  useEffect(() => {\n    const unsubscribe = onAuthStateChanged(auth, (user) => {\n      setState({ user, loading: false, error: null });\n    });\n    return unsubscribe;\n  }, []);\n\n  const signInWithGoogle = useCallback(async () => {\n    try {\n      setState((prev) => ({ ...prev, loading: true, error: null }));\n      const provider = new GoogleAuthProvider();\n      await signInWithPopup(auth, provider);\n    } catch (error: any) {\n      setState((prev) => ({ ...prev, loading: false, error: error.message }));\n    }\n  }, []);\n\n  const signInWithApple = useCallback(async () => {\n    try {\n      setState((prev) => ({ ...prev, loading: true, error: null }));\n      const provider = new OAuthProvider(\"apple.com\");\n      provider.addScope(\"email\");\n      provider.addScope(\"name\");\n      await signInWithPopup(auth, provider);\n    } catch (error: any) {\n      setState((prev) => ({ ...prev, loading: false, error: error.message }));\n    }\n  }, []);\n\n  const signInWithEmail = useCallback(\n    async (email: string, password: string) => {\n      try {\n        setState((prev) => ({ ...prev, loading: true, error: null }));\n        await signInWithEmailAndPassword(auth, email, password);\n      } catch (error: any) {\n        setState((prev) => ({ ...prev, loading: false, error: error.message }));\n      }\n    },\n    []\n  );\n\n  const signUpWithEmail = useCallback(\n    async (email: string, password: string) => {\n      try {\n        setState((prev) => ({ ...prev, loading: true, error: null }));\n        await createUserWithEmailAndPassword(auth, email, password);\n      } catch (error: any) {\n        setState((prev) => ({ ...prev, loading: false, error: error.message }));\n      }\n    },\n    []\n  );\n\n  const signOut = useCallback(async () => {\n    try {\n      await firebaseSignOut(auth);\n    } catch (error: any) {\n      setState((prev) => ({ ...prev, error: error.message }));\n    }\n  }, []);\n\n  return {\n    ...state,\n    signInWithGoogle,\n    signInWithApple,\n    signInWithEmail,\n    signUpWithEmail,\n    signOut,\n  };\n}\n```\n\n## Auth Provider Component\n\nCreate `src\u002Fcomponents\u002Fshared\u002Fauth-provider.tsx`:\n\n```typescript\n\"use client\";\n\nimport { createContext, useContext } from \"react\";\nimport { useAuth } from \"@\u002Fhooks\u002Fuse-auth\";\nimport type { User } from \"firebase\u002Fauth\";\n\ninterface AuthContextType {\n  user: User | null;\n  loading: boolean;\n  error: string | null;\n  signInWithGoogle: () => Promise\u003Cvoid>;\n  signInWithApple: () => Promise\u003Cvoid>;\n  signInWithEmail: (email: string, password: string) => Promise\u003Cvoid>;\n  signUpWithEmail: (email: string, password: string) => Promise\u003Cvoid>;\n  signOut: () => Promise\u003Cvoid>;\n}\n\nconst AuthContext = createContext\u003CAuthContextType | undefined>(undefined);\n\nexport function AuthProvider({ children }: { children: React.ReactNode }) {\n  const auth = useAuth();\n  return \u003CAuthContext.Provider value={auth}>{children}\u003C\u002FAuthContext.Provider>;\n}\n\nexport function useAuthContext() {\n  const context = useContext(AuthContext);\n  if (!context) {\n    throw new Error(\"useAuthContext must be used within an AuthProvider\");\n  }\n  return context;\n}\n```\n\n## Server-Side Token Verification\n\nCreate\u002Fupdate `src\u002Flib\u002Ffirebase\u002Fverify-token.ts`:\n\n```typescript\nimport { adminAuth } from \"@\u002Flib\u002Ffirebase\u002Fadmin\";\n\nexport async function verifyFirebaseToken(token: string) {\n  try {\n    const decodedToken = await adminAuth.verifyIdToken(token);\n    return { uid: decodedToken.uid, email: decodedToken.email };\n  } catch {\n    return null;\n  }\n}\n```\n\n## Firebase-Supabase User Sync\n\nCreate `src\u002Fapp\u002Fapi\u002Fauth\u002Fsync\u002Froute.ts` to sync Firebase users with Supabase profiles:\n\n```typescript\nimport { NextRequest, NextResponse } from \"next\u002Fserver\";\nimport { adminAuth } from \"@\u002Flib\u002Ffirebase\u002Fadmin\";\nimport { createClient } from \"@supabase\u002Fsupabase-js\";\n\n\u002F\u002F Use service role for admin operations\nconst supabaseAdmin = createClient(\n  process.env.NEXT_PUBLIC_SUPABASE_URL!,\n  process.env.SUPABASE_SERVICE_ROLE_KEY!\n);\n\nexport async function POST(request: NextRequest) {\n  const authHeader = request.headers.get(\"Authorization\");\n  if (!authHeader?.startsWith(\"Bearer \")) {\n    return NextResponse.json({ error: \"Missing token\" }, { status: 401 });\n  }\n\n  try {\n    const token = authHeader.split(\"Bearer \")[1];\n    const decoded = await adminAuth.verifyIdToken(token);\n\n    \u002F\u002F Upsert profile in Supabase\n    const { error } = await supabaseAdmin\n      .from(\"profiles\")\n      .upsert(\n        {\n          id: decoded.uid,\n          email: decoded.email || \"\",\n          full_name: decoded.name || null,\n          avatar_url: decoded.picture || null,\n          updated_at: new Date().toISOString(),\n        },\n        { onConflict: \"id\" }\n      );\n\n    if (error) throw error;\n\n    return NextResponse.json({ success: true });\n  } catch (error: any) {\n    return NextResponse.json(\n      { error: error.message },\n      { status: 401 }\n    );\n  }\n}\n```\n\n## Login Page Template\n\nCreate `src\u002Fapp\u002F(auth)\u002Flogin\u002Fpage.tsx`:\n\n```typescript\n\"use client\";\n\nimport { useAuthContext } from \"@\u002Fcomponents\u002Fshared\u002Fauth-provider\";\nimport { useRouter } from \"next\u002Fnavigation\";\nimport { useEffect } from \"react\";\n\nexport default function LoginPage() {\n  const { user, loading, error, signInWithGoogle, signInWithApple } =\n    useAuthContext();\n  const router = useRouter();\n\n  useEffect(() => {\n    if (user && !loading) {\n      \u002F\u002F Sync with Supabase on login\n      user.getIdToken().then((token) => {\n        fetch(\"\u002Fapi\u002Fauth\u002Fsync\", {\n          method: \"POST\",\n          headers: { Authorization: `Bearer ${token}` },\n        }).then(() => router.push(\"\u002Fdashboard\"));\n      });\n    }\n  }, [user, loading, router]);\n\n  if (loading) {\n    return (\n      \u003Cdiv className=\"flex min-h-screen items-center justify-center\">\n        \u003Cp className=\"text-muted-foreground\">Loading...\u003C\u002Fp>\n      \u003C\u002Fdiv>\n    );\n  }\n\n  return (\n    \u003Cdiv className=\"flex min-h-screen items-center justify-center px-4\">\n      \u003Cdiv className=\"w-full max-w-sm space-y-6\">\n        \u003Cdiv className=\"text-center\">\n          \u003Ch1 className=\"text-2xl font-bold\">Sign In\u003C\u002Fh1>\n          \u003Cp className=\"mt-2 text-sm text-gray-500\">\n            Choose your preferred sign-in method\n          \u003C\u002Fp>\n        \u003C\u002Fdiv>\n\n        {error && (\n          \u003Cp className=\"rounded-md bg-red-50 p-3 text-sm text-red-600\">\n            {error}\n          \u003C\u002Fp>\n        )}\n\n        \u003Cdiv className=\"space-y-3\">\n          \u003Cbutton\n            onClick={signInWithGoogle}\n            className=\"flex w-full items-center justify-center gap-2 rounded-lg border px-4 py-3 text-sm font-medium hover:bg-gray-50 transition-colors\"\n          >\n            Continue with Google\n          \u003C\u002Fbutton>\n          \u003Cbutton\n            onClick={signInWithApple}\n            className=\"flex w-full items-center justify-center gap-2 rounded-lg border bg-black text-white px-4 py-3 text-sm font-medium hover:bg-gray-900 transition-colors\"\n          >\n            Continue with Apple\n          \u003C\u002Fbutton>\n        \u003C\u002Fdiv>\n      \u003C\u002Fdiv>\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n## Custom Claims\n\nFor role-based access (admin, editor, viewer):\n\n```typescript\n\u002F\u002F Set custom claims (run from a secure server context or admin script)\nimport { adminAuth } from \"@\u002Flib\u002Ffirebase\u002Fadmin\";\n\nexport async function setUserRole(uid: string, role: \"admin\" | \"editor\" | \"viewer\") {\n  await adminAuth.setCustomUserClaims(uid, { role });\n}\n\n\u002F\u002F Verify role in API routes\nexport async function getUserRole(token: string): Promise\u003Cstring | null> {\n  try {\n    const decoded = await adminAuth.verifyIdToken(token);\n    return (decoded.role as string) || null;\n  } catch {\n    return null;\n  }\n}\n```\n\n## Adding a New Auth Provider\n\nWhen the user asks to add a new provider:\n\n1. Update the `useAuth` hook with the new sign-in method.\n2. Add the provider button to the login page.\n3. Test the flow locally.\n4. Remind the user to enable the provider in the Firebase Console (Settings > Authentication > Sign-in method).\n5. Commit: `feat: add \u003Cprovider> authentication`.\n\n## Security Checklist\n\n- [ ] Firebase API keys are in `.env.local` (never committed).\n- [ ] Firebase Admin credentials use environment variables.\n- [ ] ID tokens are verified on the server for every protected route.\n- [ ] Custom claims are only set via server-side admin SDK.\n- [ ] The sync endpoint uses Firebase Admin to verify tokens.\n- [ ] CORS is properly configured for the auth domain.\n- [ ] Rate limiting is applied to auth endpoints (via Cloudflare Guard skill).\n",{"name":5,"description":7,"user-invocable":24},true,"main","f9d3fe7cf9ac8f1ea63a0d96e98e1f510a3814db","skills\u002Fguifav\u002Ffirebase-auth-setup",1,"https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills","https:\u002F\u002Fgithub.com\u002Fjavimosch","intrane.fr","Building robust, open-source infrastructure for the commons. AI-leveraged, self-hosted, built to last.","2026-06-07 03:34:58",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":24},[36,39,42],{"tool":37,"command":38},"npx","npx skills add javimosch\u002Fopen-claw-skills --skill firebase-auth-setup",{"tool":40,"command":41},"bunx","bunx skills add javimosch\u002Fopen-claw-skills --skill firebase-auth-setup",{"tool":43,"command":44},"pnpm","pnpm dlx skills add javimosch\u002Fopen-claw-skills --skill firebase-auth-setup","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fguifav\u002Ffirebase-auth-setup\u002FSKILL.md",[],[48,56,63,70,77,84],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":55},"01M778GGXG2VQ0YF31W2MKGMQZ","crowd-prompting","A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzzadrian\u002Fcrowd-prompting\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":55},"01M778G7BH8SBJ9FJ6C3G7CB1K","ceaser","Interact with the Ceaser privacy protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- shield, unshield, note management, and protocol queries. All ceaser tool calls use CLI subcommands (npx -y ceaser-mcp \u003Csubcommand>). Ceaser is a privacy-preserving ETH wrapper using Noir\u002FUltraHonk zero-knowledge proofs on Base L2 (chain ID 8453).","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyra-v21\u002Fceaser\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":55},"01M778FYCJQZWFKKX5FYMK3S47","ceaser-send","Fully automated private ETH transfer via Ceaser Protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- all ceaser tool calls use CLI subcommands (npx -y ceaser-mcp \u003Csubcommand>). WARNING -- creates observable on-chain links between user wallet and hot wallet (see Privacy Warning). Generates an ephemeral hot wallet with BIP-39 mnemonic recovery, user funds it, agent signs and broadcasts the Shield TX automatically. Exactly one manual step required (funding the hot wallet with ETH). Uses Noir\u002FUltraHonk zero-knowledge proofs.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyra-v21\u002Fceaser-send\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":55},"01M778FQQNSEYA3HJKZBPQ4M9Z","dilemm-ai","Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyori\u002Fdilemm-ai\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":55},"01M778FGVZX7QA2TF9BFMM37FY","moldium","Post and manage content on the Moldium blog platform. Triggered by \"post to Moldium\", \"write a blog post\", \"publish an article\", etc.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyom45\u002Fmoldium\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":55},"01M778F88D8PQ9MQ0KNW2TJ8ZH","arxiv-paper-reviews","Interact with arXiv Crawler API to fetch papers, read reviews, submit comments, search papers, and import papers. Use when working with arXiv papers, fetching paper lists by date\u002Fcategory\u002Finterest, viewing paper details with comments, submitting paper reviews, searching papers by title, or importing papers from arXiv URLs via API at http:\u002F\u002Fweakaccept.top:8000\u002F.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Farxiv-paper-reviews\u002FSKILL.md",[],[]]