Skip to content

Commit 7d71ab5

Browse files
authored
V4 release (#585)
* removed deprecated APIs * v4 release note * bump the core sdk version to v6 in demo app
1 parent b2336f5 commit 7d71ab5

20 files changed

+120
-1632
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,17 @@ Localized versions of the widget are available through the CDN. To use a localiz
7070
localized JS library instead of the default library:
7171

7272
```html
73-
<script src="https://www.gstatic.com/firebasejs/ui/3.6.1/firebase-ui-auth__{LANGUAGE_CODE}.js"></script>
74-
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/3.6.1/firebase-ui-auth.css" />
73+
<script src="https://www.gstatic.com/firebasejs/ui/4.0.0/firebase-ui-auth__{LANGUAGE_CODE}.js"></script>
74+
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/4.0.0/firebase-ui-auth.css" />
7575
```
7676

7777
where `{LANGUAGE_CODE}` is replaced by the code of the language you want. For example, the French
7878
version of the library is available at
79-
`https://www.gstatic.com/firebasejs/ui/3.6.1/firebase-ui-auth__fr.js`. The list of available
79+
`https://www.gstatic.com/firebasejs/ui/4.0.0/firebase-ui-auth__fr.js`. The list of available
8080
languages and their respective language codes can be found at [LANGUAGES.md](LANGUAGES.md).
8181

8282
Right-to-left languages also require the right-to-left version of the stylesheet, available at
83-
`https://www.gstatic.com/firebasejs/ui/3.6.1/firebase-ui-auth-rtl.css`, instead of the default
83+
`https://www.gstatic.com/firebasejs/ui/4.0.0/firebase-ui-auth-rtl.css`, instead of the default
8484
stylesheet. The supported right-to-left languages are Arabic (ar), Farsi (fa), and Hebrew (iw).
8585

8686
### Option 2: npm Module

changelog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
important - Removed all FirebaseUI underlying dependencies on deprecated and removed APIs in Firebase version 6.0.0. FirebaseUI no longer supports versions older than 6.0.0.
2+
feature - Added the ability to immediately redirect to the provider's site or instead show the default 'Sign in with Provider' button when there is only a single federated provider enabled.

demo/public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<meta charset="UTF-8">
55
<title>FirebaseUI Auth Demo</title>
66
<link rel="manifest" href="manifest.json">
7-
<script src="https://www.gstatic.com/firebasejs/5.10/firebase.js"></script>
7+
<script src="https://www.gstatic.com/firebasejs/6.0.1/firebase.js"></script>
88
<script src="config.js"></script>
99
<script src="common.js"></script>
1010
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />

demo/public/widget.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8">
55
<title>FirebaseUI Auth Demo</title>
6-
<script src="https://www.gstatic.com/firebasejs/5.10/firebase.js"></script>
6+
<script src="https://www.gstatic.com/firebasejs/6.0.1/firebase.js"></script>
77
<script src="config.js"></script>
88
<script src="common.js"></script>
99
<script src="dist/firebaseui.js"></script>

javascript/testing/auth.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -189,24 +189,13 @@ FakeAuthClient.AuthAsyncMethod = {
189189
APPLY_ACTION_CODE: 'applyActionCode',
190190
CHECK_ACTION_CODE: 'checkActionCode',
191191
CONFIRM_PASSWORD_RESET: 'confirmPasswordReset',
192-
CREATE_USER_AND_RETRIEVE_DATA_WITH_EMAIL_AND_PASSWORD:
193-
'createUserAndRetrieveDataWithEmailAndPassword',
194192
CREATE_USER_WITH_EMAIL_AND_PASSWORD: 'createUserWithEmailAndPassword',
195-
FETCH_PROVIDERS_FOR_EMAIL: 'fetchProvidersForEmail',
196193
FETCH_SIGN_IN_METHODS_FOR_EMAIL: 'fetchSignInMethodsForEmail',
197194
GET_REDIRECT_RESULT: 'getRedirectResult',
198195
IS_SIGN_IN_WITH_EMAIL_LINK: 'isSignInWithEmailLink',
199196
SEND_PASSWORD_RESET_EMAIL: 'sendPasswordResetEmail',
200197
SEND_SIGN_IN_LINK_TO_EMAIL: 'sendSignInLinkToEmail',
201198
SET_PERSISTENCE: 'setPersistence',
202-
SIGN_IN_AND_RETRIEVE_DATA_WITH_CREDENTIAL:
203-
'signInAndRetrieveDataWithCredential',
204-
SIGN_IN_AND_RETRIEVE_DATA_WITH_CUSTOM_TOKEN:
205-
'signInAndRetrieveDataWithCustomToken',
206-
SIGN_IN_AND_RETRIEVE_DATA_WITH_EMAIL_AND_PASSWORD:
207-
'signInAndRetrieveDataWithEmailAndPassword',
208-
SIGN_IN_ANONYMOUSLY_AND_RETRIEVE_DATA:
209-
'signInAnonymouslyAndRetrieveData',
210199
SIGN_IN_ANONYMOUSLY: 'signInAnonymously',
211200
SIGN_IN_WITH_CREDENTIAL: 'signInWithCredential',
212201
SIGN_IN_WITH_CUSTOM_TOKEN: 'signInWithCustomToken',
@@ -227,13 +216,10 @@ FakeAuthClient.AuthAsyncMethod = {
227216
*/
228217
FakeAuthClient.UserAsyncMethod = {
229218
GET_ID_TOKEN: 'getIdToken',
230-
LINK_AND_RETRIEVE_DATA_WITH_CREDENTIAL: 'linkAndRetrieveDataWithCredential',
231219
LINK_WITH_CREDENTIAL: 'linkWithCredential',
232220
LINK_WITH_PHONE_NUMBER: 'linkWithPhoneNumber',
233221
LINK_WITH_POPUP: 'linkWithPopup',
234222
LINK_WITH_REDIRECT: 'linkWithRedirect',
235-
REAUTHENTICATE_AND_RETRIEVE_DATA_WITH_CREDENTIAL:
236-
'reauthenticateAndRetrieveDataWithCredential',
237223
REAUTHENTICATE_WITH_CREDENTIAL: 'reauthenticateWithCredential',
238224
REAUTHENTICATE_WITH_PHONE_NUMBER: 'reauthenticateWithPhoneNumber',
239225
REAUTHENTICATE_WITH_POPUP: 'reauthenticateWithPopup',

javascript/testing/auth_test.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ function testFakeAuthClient_success() {
5555
var password = 'password';
5656
var user = {'uid': 'USER_ID'};
5757
// This block will be called in UI interactions.
58-
auth.fetchProvidersForEmail(email).then(function(arr) {
58+
auth.fetchSignInMethodsForEmail(email).then(function(arr) {
5959
return auth.signInWithEmailAndPassword(email, password)
6060
.then(function(user) {
6161
return auth.signOut();
6262
});
6363
}, function(error) {
6464
return auth.createUserWithEmailAndPassword(email, password);
6565
});
66-
auth.fetchProvidersForEmail(email2).thenCatch(function(error) {
66+
auth.fetchSignInMethodsForEmail(email2).thenCatch(function(error) {
6767
return auth.createUserWithEmailAndPassword(email2, password);
6868
});
6969
auth.sendPasswordResetEmail(email2).thenCatch(function(error) {
@@ -79,10 +79,11 @@ function testFakeAuthClient_success() {
7979
});
8080

8181
// Simulate API calls in tests.
82-
auth.assertFetchProvidersForEmail([email], ['google.com', 'facebook.com']);
82+
auth.assertFetchSignInMethodsForEmail(
83+
[email], ['google.com', 'facebook.com']);
8384
auth.assertSignInWithEmailAndPassword([email, password], user);
8485
auth.assertSignOut([]);
85-
auth.assertFetchProvidersForEmail([email2], null, new Error());
86+
auth.assertFetchSignInMethodsForEmail([email2], null, new Error());
8687
auth.assertCreateUserWithEmailAndPassword([email2, password], user);
8788
// It also works when passing in a function.
8889
auth.assertCheckActionCode(['actionCode'], function() {
@@ -189,13 +190,14 @@ function testFakeAuthClient_unexpectedApiError() {
189190
var email = '[email protected]';
190191
var password = 'password';
191192
var user = {'uid': 'USER_ID'};
192-
auth.fetchProvidersForEmail(email).then(function(arr) {
193+
auth.fetchSignInMethodsForEmail(email).then(function(arr) {
193194
return auth.signInWithEmailAndPassword(email, password);
194195
}, function(error) {
195196
return auth.createUserWithEmailAndPassword(email, password);
196197
});
197198
// Simulate API calls.
198-
auth.assertFetchProvidersForEmail([email], ['google.com', 'facebook.com']);
199+
auth.assertFetchSignInMethodsForEmail(
200+
[email], ['google.com', 'facebook.com']);
199201
auth.process().then(function() {
200202
return auth.uninstall();
201203
}).thenCatch(function(e) {

javascript/widgets/authui.js

Lines changed: 7 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ firebaseui.auth.AuthUI.prototype.upgradeWithEmailLink = function(
10861086
p = this.getAuth().signInWithEmailLink(email, link)
10871087
.then(function(userCredential) {
10881088
return userCredential['user']
1089-
.linkAndRetrieveDataWithCredential(pendingCredential);
1089+
.linkWithCredential(pendingCredential);
10901090
})
10911091
.then(function(linkedUserCredential) {
10921092
return self.clearTempAuthState();
@@ -1103,7 +1103,7 @@ firebaseui.auth.AuthUI.prototype.upgradeWithEmailLink = function(
11031103
if (!signInMethods.length) {
11041104
// New email. Linking email credential to anonymous user should
11051105
// succeed.
1106-
return user.linkAndRetrieveDataWithCredential(credential);
1106+
return user.linkWithCredential(credential);
11071107
} else {
11081108
// Existing email will trigger merge conflict. In this case, we
11091109
// avoid consuming the one-time credential.
@@ -1150,7 +1150,7 @@ firebaseui.auth.AuthUI.prototype.signInWithEmailLink = function(
11501150
// If there is a pending credential, link it to signed in user.
11511151
if (pendingCredential) {
11521152
return userCredential['user']
1153-
.linkAndRetrieveDataWithCredential(pendingCredential)
1153+
.linkWithCredential(pendingCredential)
11541154
.then(function(linkedUserCredential) {
11551155
authResult = {
11561156
'user': linkedUserCredential['user'],
@@ -1278,7 +1278,7 @@ firebaseui.auth.AuthUI.prototype.startCreateUserWithEmailAndPassword =
12781278
// Auth user. Otherwise merge conflict will always occur when linking the
12791279
// credential to the external anonymous user after creation.
12801280
return /** @type {!firebase.Promise<!firebase.auth.UserCredential>} */ (
1281-
user.linkAndRetrieveDataWithCredential(credential));
1281+
user.linkWithCredential(credential));
12821282
} else {
12831283
// Start create user with email and password. This runs on the internal
12841284
// Auth instance as finish sign in will sign in with that same credential
@@ -1310,7 +1310,7 @@ firebaseui.auth.AuthUI.prototype.startSignInWithCredential =
13101310
// Auth user. Otherwise merge conflict will always occur when linking the
13111311
// credential to the external anonymous user after creation.
13121312
return /** @type {!firebase.Promise<!firebase.auth.UserCredential>} */ (
1313-
user.linkAndRetrieveDataWithCredential(credential)
1313+
user.linkWithCredential(credential)
13141314
.then(function(result) {
13151315
return result;
13161316
}, function(error) {
@@ -1332,7 +1332,7 @@ firebaseui.auth.AuthUI.prototype.startSignInWithCredential =
13321332
// Starts sign in with a Firebase Auth credential, typically an OAuth
13331333
// credential. This runs on the internal Auth instance as finish sign in
13341334
// will sign in with that same credential to developer Auth instance.
1335-
return self.getAuth().signInAndRetrieveDataWithCredential(credential);
1335+
return self.getAuth().signInWithCredential(credential);
13361336
}
13371337
};
13381338
// Initialize current user if auto upgrade is enabled beforing running
@@ -1501,89 +1501,6 @@ firebaseui.auth.AuthUI.prototype.startSignInAnonymously = function() {
15011501
};
15021502

15031503

1504-
/**
1505-
* Finishes FirebaseUI login with the given 3rd party credentials.
1506-
* @param {!firebase.auth.AuthCredential} credential The auth credential.
1507-
* @param {?firebase.User=} opt_user The optional user to sign in with if
1508-
* available.
1509-
* @return {!firebase.Promise<!firebase.User>}
1510-
*/
1511-
firebaseui.auth.AuthUI.prototype.finishSignInWithCredential =
1512-
function(credential, opt_user) {
1513-
// Check if instance is already destroyed.
1514-
this.checkIfDestroyed_();
1515-
var self = this;
1516-
var cb = function(user) {
1517-
// Anonymous user upgrade successful, sign out on internal instance and
1518-
// resolve with the user. No need to sign in again with the same credential
1519-
// on the external Auth instance.
1520-
// If user is signed in on internal instance, ignore the user on external
1521-
// instance, sign out on internal instance and finish the sign in on
1522-
// external instance.
1523-
if (self.currentUser_ &&
1524-
!self.currentUser_['isAnonymous'] &&
1525-
self.getConfig().autoUpgradeAnonymousUsers() &&
1526-
!self.getAuth().currentUser) {
1527-
return self.clearTempAuthState().then(function() {
1528-
return self.currentUser_;
1529-
});
1530-
} else if (user) {
1531-
// TODO: optimize and fail directly as this will fail in most cases
1532-
// with error credential already in use.
1533-
// There are cases where this is required. For example, when email
1534-
// mismatch occurs and the user continues with the new account.
1535-
return /** @type {!firebase.Promise<!firebase.User>} */ (
1536-
self.clearTempAuthState().then(function() {
1537-
return user.linkWithCredential(credential);
1538-
}).then(function() {
1539-
return user;
1540-
}, function(error) {
1541-
// Rethrow email already in use error so it can trigger the account
1542-
// linking flow.
1543-
if (error &&
1544-
error['code'] == 'auth/email-already-in-use' &&
1545-
error['email'] && error['credential']) {
1546-
throw error;
1547-
}
1548-
// For all other errors, run onUpgrade check.
1549-
return self.onUpgradeError(error, credential);
1550-
}));
1551-
} else {
1552-
// Finishes sign in with the supplied credential on the developer provided
1553-
// Auth instance. On completion, this will redirect to signInSuccessUrl or
1554-
// trigger the signInSuccess callback.
1555-
return self.clearTempAuthState().then(function() {
1556-
// updateCurrentUser is more efficient and less error prone than
1557-
// signInWithCredential.
1558-
// The former can resolve the operation without any network request
1559-
// whereas the latter will send 2 requests.
1560-
// In addition, updateCurrentUser has lower risk of failure in the
1561-
// following cases:
1562-
// 1. No network connection: operation can execute without any network
1563-
// call in most cases.
1564-
// 2. Will not run into expired OAuth credential errors unlike
1565-
// signInWithCredential. This may happen if the user waits too long
1566-
// before completing sign-in in the email mismatch flow.
1567-
// 3. Ability to copy a user for all providers. Some OAuth providers
1568-
// cannot be used headlessly or their credentials are one-time only.
1569-
if (!!opt_user) {
1570-
return self.getExternalAuth().updateCurrentUser(opt_user)
1571-
.then(function() {
1572-
// Return currentUser on external instance.
1573-
return self.getExternalAuth().currentUser;
1574-
});
1575-
}
1576-
// If no user is available fallback to signInWithCredential.
1577-
return self.getExternalAuth().signInWithCredential(credential);
1578-
});
1579-
}
1580-
};
1581-
// Initialize current user if auto upgrade is enabled beforing running
1582-
// callback and returning result.
1583-
return this.initializeForAutoUpgrade_(cb);
1584-
};
1585-
1586-
15871504
/**
15881505
* Finishes FirebaseUI login with the given 3rd party credentials.
15891506
* @param {!firebaseui.auth.AuthResult} authResult The Auth result.
@@ -1613,7 +1530,7 @@ firebaseui.auth.AuthUI.prototype.finishSignInAndRetrieveDataWithAuthResult =
16131530
// mismatch occurs and the user continues with the new account.
16141531
return /** @type {!firebase.Promise<!firebaseui.auth.AuthResult>} */ (
16151532
self.clearTempAuthState().then(function() {
1616-
return user.linkAndRetrieveDataWithCredential(
1533+
return user.linkWithCredential(
16171534
authResult['credential']);
16181535
}).then(function(userCredential) {
16191536
authResult['user'] = userCredential['user'];

0 commit comments

Comments
 (0)