1
+ // [SNIPPET_REGISTRY disabled]
2
+ // [SNIPPETS_SEPARATION enabled]
3
+
4
+ // Docs: https://source.corp.google.com/piper///depot/google3/third_party/devsite/firebase/en/docs/auth/web/custom-dependencies.md
5
+
6
+ function getAuthEquivalent ( ) {
7
+ // [START auth_get_auth_equivalent]
8
+ const { initializeAuth, browserLocalPersistence, browserPopupRedirectResolver, browserSessionPersistence, indexedDBLocalPersistence} = require ( "firebase/auth" ) ;
9
+ const { initializeApp} = require ( "firebase/app" ) ;
10
+
11
+ const app = initializeApp ( { /** Your app config */ } ) ;
12
+ const auth = initializeAuth ( app , {
13
+ persistence : [ indexedDBLocalPersistence , browserLocalPersistence , browserSessionPersistence ] ,
14
+ popupRedirectResolver : browserPopupRedirectResolver ,
15
+ } ) ;
16
+ // [END auth_get_auth_equivalent]
17
+ }
18
+
19
+ function onlyBrowserLocal ( ) {
20
+ // [START auth_only_browser_local]
21
+ const { initializeAuth, browserLocalPersistence} = require ( "firebase/auth" ) ;
22
+ const { initializeApp} = require ( "firebase/app" ) ;
23
+
24
+ const app = initializeApp ( { /** Your app config */ } ) ;
25
+ const auth = initializeAuth ( app , {
26
+ persistence : browserLocalPersistence ,
27
+ // No popupRedirectResolver defined
28
+ } ) ;
29
+ // [END auth_only_browser_local]
30
+ }
31
+
32
+ function onlyIndexedDB ( ) {
33
+ // [START auth_only_indexed_db]
34
+ const { initializeAuth, indexedDBLocalPersistence} = require ( "firebase/auth" ) ;
35
+ const { initializeApp} = require ( "firebase/app" ) ;
36
+
37
+ const app = initializeApp ( { /** Your app config */ } ) ;
38
+ const auth = initializeAuth ( app , {
39
+ persistence : indexedDBLocalPersistence ,
40
+ // No popupRedirectResolver defined
41
+ } ) ;
42
+ // [END auth_only_indexed_db]
43
+ }
44
+
45
+ function signInRedirectManualDeps ( ) {
46
+ // [START auth_sign_in_redirect_manual_deps]
47
+ const { initializeAuth, browserLocalPersistence, browserPopupRedirectResolver, indexedDBLocalPersistence, signInWithRedirect, GoogleAuthProvider} = require ( "firebase/auth" ) ;
48
+ const { initializeApp} = require ( "firebase/app" ) ;
49
+
50
+ const app = initializeApp ( { /** Your app config */ } ) ;
51
+ const auth = initializeAuth ( app , {
52
+ persistence : [ indexedDBLocalPersistence , browserLocalPersistence ] ,
53
+ } ) ;
54
+
55
+ // Later
56
+ signInWithRedirect ( auth , new GoogleAuthProvider ( ) , browserPopupRedirectResolver ) ;
57
+ // [END auth_sign_in_redirect_manual_deps]
58
+ }
0 commit comments