| import 'package:firebase_app_check/firebase_app_check.dart'; |
| import 'package:firebase_core/firebase_core.dart'; |
| import 'package:jaspr/client.dart'; |
| |
| import 'app.dart'; |
| import 'firebase_options.dart'; |
| import 'main.client.options.dart'; |
| |
| const _useFirebaseAppCheckDebug = bool.fromEnvironment( |
| 'USE_FIREBASE_APPCHECK_DEBUG', |
| ); |
| const _firebaseAppCheckSiteKey = String.fromEnvironment( |
| 'FIREBASE_APPCHECK_SITE_KEY', |
| ); |
| const _firebaseAppCheckDebugToken = String.fromEnvironment( |
| 'FIREBASE_APPCHECK_DEBUG_TOKEN', |
| ); |
| |
| Future<void> main() async { |
| Jaspr.initializeApp(options: defaultClientOptions); |
| |
| await Firebase.initializeApp( |
| options: DefaultFirebaseOptions.currentPlatform, |
| ); |
| |
| if (_useFirebaseAppCheckDebug) { |
| await FirebaseAppCheck.instance.activate( |
| providerWeb: WebDebugProvider( |
| debugToken: _firebaseAppCheckDebugToken.isEmpty ? null : _firebaseAppCheckDebugToken, |
| ), |
| ); |
| } else { |
| if (_firebaseAppCheckSiteKey.isEmpty) { |
| throw StateError( |
| 'Missing FIREBASE_APPCHECK_SITE_KEY in .env.local or --dart-define to initialize the reCAPTCHA v3 provider.', |
| ); |
| } |
| await FirebaseAppCheck.instance.activate( |
| providerWeb: ReCaptchaV3Provider( |
| _firebaseAppCheckSiteKey, |
| ), |
| ); |
| } |
| await FirebaseAppCheck.instance.setTokenAutoRefreshEnabled(true); |
| |
| runApp(App()); |
| } |