Coverage for fastagency/ui/mesop/auth/firebase/firebase_auth_component.py: 92%
13 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-19 12:16 +0000
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-19 12:16 +0000
1from dataclasses import dataclass 1abc
2from typing import Any, Callable 1abc
4import mesop.labs as mel 1abc
6__all__ = ["firebase_auth_component"] 1abc
8MEL_WEB_COMPONENT_PATH = ( 1abc
9 "/__fast_agency_internal__/javascript/firebase_auth_component.js"
10)
13@dataclass 1abc
14class FirebaseConfig: 1abc
15 api_key: str 1abc
16 auth_domain: str 1abc
17 project_id: str 1abc
18 storage_bucket: str 1abc
19 messaging_sender_id: str 1abc
20 app_id: str 1abc
23@mel.web_component(path=MEL_WEB_COMPONENT_PATH) # type: ignore[misc] 1abc
24def firebase_auth_component( 1abc
25 on_auth_changed: Callable[[mel.WebEvent], Any], config: FirebaseConfig
26) -> Any:
27 return mel.insert_web_component(
28 name="firebase-auth-component",
29 events={
30 "authChanged": on_auth_changed,
31 },
32 properties={
33 "apiKey": config.api_key,
34 "authDomain": config.auth_domain,
35 "projectId": config.project_id,
36 "storageBucket": config.storage_bucket,
37 "messagingSenderId": config.messaging_sender_id,
38 "appId": config.app_id,
39 },
40 )