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