Skip to content

Commit c356483

Browse files
authored
Merge branch 'firebase:master' into gregfenton-patch-issue-221
2 parents 4c839e5 + 2414b55 commit c356483

File tree

133 files changed

+2302
-159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+2302
-159
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
node-version:
16-
- 12.x
16+
- 14.x
1717
steps:
1818
- uses: actions/checkout@v1
1919
- uses: actions/setup-node@v1

analytics-next/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ function logEventParams() {
2727
const analytics = getAnalytics();
2828
logEvent(analytics, 'select_content', {
2929
content_type: 'image',
30-
content_id: 'P12453',
31-
items: [{ name: 'Kittens' }]
30+
content_id: 'P12453'
3231
});
3332
// [END analytics_log_event_params]
3433
}

analytics-next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
},
77
"license": "Apache-2.0",
88
"dependencies": {
9-
"firebase": "^9.0.0-beta.8"
9+
"firebase": "^9.12.1"
1010
}
1111
}

analytics/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
},
77
"license": "Apache-2.0",
88
"dependencies": {
9-
"firebase": "^8.9.1"
9+
"firebase": "^8.10.0"
1010
}
1111
}

appcheck-next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
},
77
"license": "Apache-2.0",
88
"dependencies": {
9-
"firebase": "^9.0.0-beta.8"
9+
"firebase": "^9.12.1"
1010
}
1111
}

appcheck/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
},
77
"license": "Apache-2.0",
88
"dependencies": {
9-
"firebase": "^8.9.1"
9+
"firebase": "^8.10.0"
1010
}
1111
}

auth-next/apple.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ function appleSignInPopup(provider) {
3838
const accessToken = credential.accessToken;
3939
const idToken = credential.idToken;
4040

41+
// IdP data available using getAdditionalUserInfo(result)
4142
// ...
4243
})
4344
.catch((error) => {
4445
// Handle Errors here.
4546
const errorCode = error.code;
4647
const errorMessage = error.message;
4748
// The email of the user's account used.
48-
const email = error.email;
49+
const email = error.customData.email;
4950
// The credential that was used.
5051
const credential = OAuthProvider.credentialFromError(error);
5152

@@ -85,7 +86,7 @@ function appleSignInRedirectResult() {
8586
const errorCode = error.code;
8687
const errorMessage = error.message;
8788
// The email of the user's account used.
88-
const email = error.email;
89+
const email = error.customData.email;
8990
// The credential that was used.
9091
const credential = OAuthProvider.credentialFromError(error);
9192

@@ -123,7 +124,7 @@ function appleReauthenticatePopup() {
123124
const errorCode = error.code;
124125
const errorMessage = error.message;
125126
// The email of the user's account used.
126-
const email = error.email;
127+
const email = error.customData.email;
127128
// The credential that was used.
128129
const credential = OAuthProvider.credentialFromError(error);
129130

@@ -169,7 +170,7 @@ function appleNonceNode() {
169170
crypto.randomFillSync(buf);
170171
nonce = decoder.write(buf);
171172
}
172-
return nonce.substr(0, length);
173+
return nonce.slice(0, length);
173174
};
174175

175176
const unhashedNonce = generateNonce(10);

auth-next/cordova.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55

66
function createGoogleProvider() {
77
// [START auth_create_google_provider]
8-
const { GoogleAuthProvider } = require("firebase/auth");
8+
const { GoogleAuthProvider } = require("firebase/auth/cordova");
99

1010
const provider = new GoogleAuthProvider();
1111
// [END auth_create_google_provider]
1212
}
1313

1414
function cordovaSignInRedirect() {
1515
// [START auth_cordova_sign_in_redirect]
16-
const { getAuth, signInWithRedirect, getRedirectResult, GoogleAuthProvider } = require("firebase/auth");
16+
const { getAuth, signInWithRedirect, getRedirectResult, GoogleAuthProvider } = require("firebase/auth/cordova");
1717

1818
const auth = getAuth();
1919
signInWithRedirect(auth, new GoogleAuthProvider())
@@ -40,7 +40,7 @@ function cordovaSignInRedirect() {
4040

4141
function cordovaRedirectResult() {
4242
// [START auth_cordova_redirect_result]
43-
const { getAuth, getRedirectResult, GoogleAuthProvider } = require("firebase/auth");
43+
const { getAuth, getRedirectResult, GoogleAuthProvider } = require("firebase/auth/cordova");
4444

4545
const auth = getAuth();
4646
getRedirectResult(auth)

auth-next/custom-dependencies.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
}

auth-next/facebook.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ function facebookSignInPopup(provider) {
3333
const credential = FacebookAuthProvider.credentialFromResult(result);
3434
const accessToken = credential.accessToken;
3535

36+
// IdP data available using getAdditionalUserInfo(result)
3637
// ...
3738
})
3839
.catch((error) => {
3940
// Handle Errors here.
4041
const errorCode = error.code;
4142
const errorMessage = error.message;
4243
// The email of the user's account used.
43-
const email = error.email;
44+
const email = error.customData.email;
4445
// The AuthCredential type that was used.
4546
const credential = FacebookAuthProvider.credentialFromError(error);
4647

@@ -61,12 +62,14 @@ function facebookSignInRedirectResult() {
6162
const token = credential.accessToken;
6263

6364
const user = result.user;
65+
// IdP data available using getAdditionalUserInfo(result)
66+
// ...
6467
}).catch((error) => {
6568
// Handle Errors here.
6669
const errorCode = error.code;
6770
const errorMessage = error.message;
6871
// The email of the user's account used.
69-
const email = error.email;
72+
const email = error.customData.email;
7073
// AuthCredential type that was used.
7174
const credential = FacebookAuthProvider.credentialFromError(error);
7275
// ...
@@ -102,7 +105,7 @@ function checkLoginState_wrapper() {
102105
const errorCode = error.code;
103106
const errorMessage = error.message;
104107
// The email of the user's account used.
105-
const email = error.email;
108+
const email = error.customData.email;
106109
// The AuthCredential type that was used.
107110
const credential = FacebookAuthProvider.credentialFromError(error);
108111
// ...
@@ -156,10 +159,19 @@ function authWithCredential(credential) {
156159
const errorCode = error.code;
157160
const errorMessage = error.message;
158161
// The email of the user's account used.
159-
const email = error.email;
162+
const email = error.customData.email;
160163
// The AuthCredential type that was used.
161164
const credential = FacebookAuthProvider.credentialFromError(error);
162165
// ...
163166
});
164167
// [END auth_facebook_signin_credential]
165168
}
169+
170+
function facebookProviderCredential(accessToken) {
171+
// [START auth_facebook_provider_credential]
172+
const { FacebookAuthProvider } = require("firebase/auth");
173+
174+
const credential = FacebookAuthProvider.credential(accessToken);
175+
// [END auth_facebook_provider_credential]
176+
}
177+

auth-next/github.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ function githubSignInPopup(provider) {
4040

4141
// The signed-in user info.
4242
const user = result.user;
43+
// IdP data available using getAdditionalUserInfo(result)
4344
// ...
4445
}).catch((error) => {
4546
// Handle Errors here.
4647
const errorCode = error.code;
4748
const errorMessage = error.message;
4849
// The email of the user's account used.
49-
const email = error.email;
50+
const email = error.customData.email;
5051
// The AuthCredential type that was used.
5152
const credential = GithubAuthProvider.credentialFromError(error);
5253
// ...
@@ -70,12 +71,14 @@ function githubSignInRedirectResult() {
7071

7172
// The signed-in user info.
7273
const user = result.user;
74+
// IdP data available using getAdditionalUserInfo(result)
75+
// ...
7376
}).catch((error) => {
7477
// Handle Errors here.
7578
const errorCode = error.code;
7679
const errorMessage = error.message;
7780
// The email of the user's account used.
78-
const email = error.email;
81+
const email = error.customData.email;
7982
// The AuthCredential type that was used.
8083
const credential = GithubAuthProvider.credentialFromError(error);
8184
// ...

auth-next/google-signin.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ function googleSignInPopup(provider) {
3333
const token = credential.accessToken;
3434
// The signed-in user info.
3535
const user = result.user;
36+
// IdP data available using getAdditionalUserInfo(result)
3637
// ...
3738
}).catch((error) => {
3839
// Handle Errors here.
3940
const errorCode = error.code;
4041
const errorMessage = error.message;
4142
// The email of the user's account used.
42-
const email = error.email;
43+
const email = error.customData.email;
4344
// The AuthCredential type that was used.
4445
const credential = GoogleAuthProvider.credentialFromError(error);
4546
// ...
@@ -60,12 +61,14 @@ function googleSignInRedirectResult() {
6061

6162
// The signed-in user info.
6263
const user = result.user;
64+
// IdP data available using getAdditionalUserInfo(result)
65+
// ...
6366
}).catch((error) => {
6467
// Handle Errors here.
6568
const errorCode = error.code;
6669
const errorMessage = error.message;
6770
// The email of the user's account used.
68-
const email = error.email;
71+
const email = error.customData.email;
6972
// The AuthCredential type that was used.
7073
const credential = GoogleAuthProvider.credentialFromError(error);
7174
// ...
@@ -87,7 +90,7 @@ function googleBuildAndSignIn(id_token) {
8790
const errorCode = error.code;
8891
const errorMessage = error.message;
8992
// The email of the user's account used.
90-
const email = error.email;
93+
const email = error.customData.email;
9194
// The AuthCredential type that was used.
9295
const credential = GoogleAuthProvider.credentialFromError(error);
9396
// ...
@@ -123,7 +126,7 @@ function onSignIn_wrapper() {
123126
const errorCode = error.code;
124127
const errorMessage = error.message;
125128
// The email of the user's account used.
126-
const email = error.email;
129+
const email = error.customData.email;
127130
// The credential that was used.
128131
const credential = GoogleAuthProvider.credentialFromError(error);
129132
// ...
@@ -157,4 +160,13 @@ function isUserEqual_wrapper() {
157160
// [END auth_google_checksameuser]
158161
}
159162

163+
function googleProviderCredential(idToken) {
164+
// [START auth_google_provider_credential]
165+
const { GoogleAuthProvider } = require("firebase/auth");
166+
167+
const credential = GoogleAuthProvider.credential(idToken);
168+
// [END auth_google_provider_credential]
169+
}
170+
171+
160172

auth-next/index.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function makeFacebookCredential(response) {
2626
function makeEmailCredential(email, password) {
2727
// [START auth_make_email_credential]
2828
const { EmailAuthProvider } = require("firebase/auth");
29-
29+
3030
const credential = EmailAuthProvider.credential(email, password);
3131
// [END auth_make_email_credential]
3232
}
@@ -52,7 +52,7 @@ function authStateListener() {
5252
onAuthStateChanged(auth, (user) => {
5353
if (user) {
5454
// User is signed in, see docs for a list of available properties
55-
// https://firebase.google.com/docs/reference/js/firebase.User
55+
// https://firebase.google.com/docs/reference/js/v8/firebase.User
5656
const uid = user.uid;
5757
// ...
5858
} else {
@@ -72,7 +72,7 @@ function currentUser() {
7272

7373
if (user) {
7474
// User is signed in, see docs for a list of available properties
75-
// https://firebase.google.com/docs/reference/js/firebase.User
75+
// https://firebase.google.com/docs/reference/js/v8/firebase.User
7676
// ...
7777
} else {
7878
// No user is signed in.
@@ -107,7 +107,7 @@ function authWithCredential(credential) {
107107
const errorCode = error.code;
108108
const errorMessage = error.message;
109109
// The email of the user's account used.
110-
const email = error.email;
110+
const email = error.customData.email;
111111
// ...
112112
});
113113
// [END auth_signin_credential]
@@ -121,3 +121,17 @@ function signInRedirect(provider) {
121121
signInWithRedirect(auth, provider);
122122
// [END auth_signin_redirect]
123123
}
124+
125+
function initializeWithCustomDomain() {
126+
// [START auth_init_custom_domain]
127+
const { initializeApp } = require("firebase/app");
128+
129+
const firebaseConfig = {
130+
apiKey: "...",
131+
// By default, authDomain is '[YOUR_APP].firebaseapp.com'.
132+
// You may replace it with a custom domain.
133+
authDomain: '[YOUR_CUSTOM_DOMAIN]'
134+
};
135+
const firebaseApp = initializeApp(firebaseConfig);
136+
// [END auth_init_custom_domain]
137+
}

0 commit comments

Comments
 (0)