Skip to content

Commit cac4047

Browse files
wti806bojeil-google
authored andcommitted
Release v3.0 (#384)
* - Deprecated signInSuccess callback. - Refactored and replaced deprecated/removed methods for compatibility with firebase-js-sdk v5.0.0. PiperOrigin-RevId: 195502634 Change-Id: I186cc5e9091c44a97c85dd73f75e130561f97128 * updated changelog and readme, bumped core sdk dependency to 5.0 * bump core sdk version in demo app
1 parent dc57287 commit cac4047

27 files changed

+4166
-3640
lines changed

README.md

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

6565
```html
66-
<script src="https://www.gstatic.com/firebasejs/ui/2.7.0/firebase-ui-auth__{LANGUAGE_CODE}.js"></script>
67-
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/2.7.0/firebase-ui-auth.css" />
66+
<script src="https://www.gstatic.com/firebasejs/ui/3.0.0/firebase-ui-auth__{LANGUAGE_CODE}.js"></script>
67+
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/3.0.0/firebase-ui-auth.css" />
6868
```
6969

7070
where `{LANGUAGE_CODE}` is replaced by the code of the language you want. For example, the French
7171
version of the library is available at
72-
`https://www.gstatic.com/firebasejs/ui/2.7.0/firebase-ui-auth__fr.js`. The list of available
72+
`https://www.gstatic.com/firebasejs/ui/3.0.0/firebase-ui-auth__fr.js`. The list of available
7373
languages and their respective language codes can be found at [LANGUAGES.md](LANGUAGES.md).
7474

7575
Right-to-left languages also require the right-to-left version of the stylesheet, available at
76-
`https://www.gstatic.com/firebasejs/ui/2.7.0/firebase-ui-auth-rtl.css`, instead of the default
76+
`https://www.gstatic.com/firebasejs/ui/3.0.0/firebase-ui-auth-rtl.css`, instead of the default
7777
stylesheet. The supported right-to-left languages are Arabic (ar), Farsi (fa), and Hebrew (iw).
7878

7979
### 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+
deprecated - Deprecated signInSuccess callback.
2+
fixed - Refactored and replaced deprecated/removed methods for compatibility with firebase-js-sdk v5.0.0.

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/live/4.8/firebase.js"></script>
7+
<script src="https://www.gstatic.com/firebasejs/live/5.0/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" />

javascript/testing/auth.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ FakeAuthClient.AuthAsyncMethod = {
193193
'createUserAndRetrieveDataWithEmailAndPassword',
194194
CREATE_USER_WITH_EMAIL_AND_PASSWORD: 'createUserWithEmailAndPassword',
195195
FETCH_PROVIDERS_FOR_EMAIL: 'fetchProvidersForEmail',
196+
FETCH_SIGN_IN_METHODS_FOR_EMAIL: 'fetchSignInMethodsForEmail',
196197
GET_REDIRECT_RESULT: 'getRedirectResult',
197198
SEND_PASSWORD_RESET_EMAIL: 'sendPasswordResetEmail',
198199
SET_PERSISTENCE: 'setPersistence',

javascript/utils/idp.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,23 @@ firebaseui.auth.idp.AuthProviders = {
4242
};
4343

4444

45+
/**
46+
* Map of provider to sign in methods.
47+
* @package {Object<string, Object<string, string>>}
48+
*/
49+
firebaseui.auth.idp.SignInMethods = {
50+
'facebook.com': {'FACEBOOK_SIGN_IN_METHOD': 'facebook.com'},
51+
'github.com': {'GITHUB_SIGN_IN_METHOD': 'github.com'},
52+
'google.com': {'GOOGLE_SIGN_IN_METHOD': 'google.com'},
53+
'password': {
54+
'EMAIL_PASSWORD_SIGN_IN_METHOD': 'password',
55+
'EMAIL_LINK_SIGN_IN_METHOD': 'emailLink'
56+
},
57+
'twitter.com': {'TWITTER_SIGN_IN_METHOD': 'twitter.com'},
58+
'phone': {'PHONE_SIGN_IN_METHOD': 'phone'}
59+
};
60+
61+
4562
/**
4663
* @param {string} providerId
4764
* @return {firebase.auth.AuthProvider} The IdP.

javascript/widgets/authui.js

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ firebaseui.auth.AuthUI = function(auth, opt_appId) {
156156
this.currentUser_ = null;
157157
/** @private {boolean} Whether initial external Auth state is ready. */
158158
this.initialStateReady_ = false;
159+
/** @private {boolean} Whether the deprecation warning has been shown. */
160+
this.warningShown_ = false;
159161
};
160162

161163

@@ -759,6 +761,7 @@ firebaseui.auth.AuthUI.prototype.updateConfig = function(name, value) {
759761
// Check if instance is already destroyed.
760762
this.checkIfDestroyed_();
761763
this.config_.update(name, value);
764+
this.checkForDeprecation_();
762765
};
763766

764767

@@ -770,6 +773,22 @@ firebaseui.auth.AuthUI.prototype.setConfig = function(config) {
770773
// Check if instance is already destroyed.
771774
this.checkIfDestroyed_();
772775
this.config_.setConfig(config);
776+
this.checkForDeprecation_();
777+
};
778+
779+
780+
/**
781+
* Checks for deprecated configs passed and logs any warnings when detected.
782+
* @private
783+
*/
784+
firebaseui.auth.AuthUI.prototype.checkForDeprecation_ = function() {
785+
if (!this.warningShown_ &&
786+
this.getConfig().getSignInSuccessCallback()) {
787+
var deprecateWarning = 'signInSuccess callback is deprecated. Please use ' +
788+
'signInSuccessWithAuthResult callback instead.';
789+
firebaseui.auth.log.warning(deprecateWarning);
790+
this.warningShown_ = true;
791+
}
773792
};
774793

775794

@@ -882,7 +901,7 @@ firebaseui.auth.AuthUI.prototype.startSignInWithEmailAndPassword =
882901
// flow, the same credential will be used to complete sign in on the
883902
// external Auth instance.
884903
return /** @type {!firebase.Promise<!firebase.auth.UserCredential>} */ (
885-
this.getAuth().signInAndRetrieveDataWithEmailAndPassword(email, password)
904+
this.getAuth().signInWithEmailAndPassword(email, password)
886905
.then(function(result) {
887906
var cb = function(user) {
888907
if (user) {
@@ -932,7 +951,7 @@ firebaseui.auth.AuthUI.prototype.startCreateUserWithEmailAndPassword =
932951
// Auth instance as finish sign in will sign in with that same credential
933952
// to developer Auth instance.
934953
return /** @type {!firebase.Promise<!firebase.auth.UserCredential>} */ (
935-
self.getAuth().createUserAndRetrieveDataWithEmailAndPassword(
954+
self.getAuth().createUserWithEmailAndPassword(
936955
email, password));
937956
}
938957
};
@@ -1285,7 +1304,7 @@ firebaseui.auth.AuthUI.prototype.signInWithExistingEmailAndPasswordForLinking =
12851304
// Starts sign in with email/password on the internal Auth instance for
12861305
// linking purposes. This is needed to avoid triggering the onAuthStateChanged
12871306
// callbacks interrupting the linking flow.
1288-
return this.getAuth().signInAndRetrieveDataWithEmailAndPassword(
1307+
return this.getAuth().signInWithEmailAndPassword(
12891308
email, password);
12901309
};
12911310

javascript/widgets/authui_test.js

Lines changed: 89 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,10 @@ function assertConfigEquals(config, widgetConfig) {
872872

873873

874874
function testConfig() {
875+
testStubs.set(
876+
firebaseui.auth.log,
877+
'warning',
878+
goog.testing.recordFunction());
875879
createAndInstallTestInstances();
876880
// Check configuration set correctly for each app.
877881
assertConfigEquals(
@@ -883,10 +887,55 @@ function testConfig() {
883887
assertConfigEquals(
884888
config3,
885889
app3.getConfig());
890+
app1.setConfig(config1);
891+
/** @suppress {missingRequire} */
892+
assertEquals(0, firebaseui.auth.log.warning.getCallCount());
893+
// Verifies that signInSuccess callback throws deprecation warning.
894+
var callbacks = {
895+
'signInSuccess': function(currentUser, credential, redirectUrl) {
896+
return true;
897+
}
898+
};
899+
app1.setConfig({
900+
'callbacks': callbacks
901+
});
902+
assertConfigEquals(
903+
{
904+
'signInSuccessUrl': 'http://localhost/home1',
905+
'widgetUrl': 'http://localhost/firebase1',
906+
'callbacks': callbacks
907+
},
908+
app1.getConfig());
909+
var deprecateWarning = 'signInSuccess callback is deprecated. Please use ' +
910+
'signInSuccessWithAuthResult callback instead.';
911+
/** @suppress {missingRequire} */
912+
assertEquals(1, firebaseui.auth.log.warning.getCallCount());
913+
/** @suppress {missingRequire} */
914+
assertEquals(deprecateWarning,
915+
firebaseui.auth.log.warning.getLastCall().getArgument(0));
916+
app1.setConfig({
917+
'callbacks': callbacks
918+
});
919+
// Deprecation warning should be only shown once.
920+
/** @suppress {missingRequire} */
921+
assertEquals(1, firebaseui.auth.log.warning.getCallCount());
922+
// Verifies that warning is shown for new instance.
923+
app2.setConfig({
924+
'callbacks': callbacks
925+
});
926+
/** @suppress {missingRequire} */
927+
assertEquals(2, firebaseui.auth.log.warning.getCallCount());
928+
/** @suppress {missingRequire} */
929+
assertEquals(deprecateWarning,
930+
firebaseui.auth.log.warning.getLastCall().getArgument(0));
886931
}
887932

888933

889934
function testUpdateConfig() {
935+
testStubs.set(
936+
firebaseui.auth.log,
937+
'warning',
938+
goog.testing.recordFunction());
890939
createAndInstallTestInstances();
891940
// Original config.
892941
var config = {
@@ -915,6 +964,34 @@ function testUpdateConfig() {
915964
assertConfigEquals(
916965
expectedConfig,
917966
app1.getConfig());
967+
/** @suppress {missingRequire} */
968+
assertEquals(0, firebaseui.auth.log.warning.getCallCount());
969+
// Verifies that signInSuccess callback throws deprecation warning.
970+
var callbacks = {
971+
'signInSuccess': function(currentUser, credential, redirectUrl) {
972+
return true;
973+
}
974+
};
975+
app1.updateConfig('callbacks', callbacks);
976+
assertConfigEquals(
977+
{
978+
'signInSuccessUrl': 'http://localhost/home1',
979+
'widgetUrl': 'http://localhost/firebase1',
980+
'siteName': 'Other_Site_Name',
981+
'callbacks': callbacks
982+
},
983+
app1.getConfig());
984+
var deprecateWarning = 'signInSuccess callback is deprecated. Please use ' +
985+
'signInSuccessWithAuthResult callback instead.';
986+
/** @suppress {missingRequire} */
987+
assertEquals(1, firebaseui.auth.log.warning.getCallCount());
988+
/** @suppress {missingRequire} */
989+
assertEquals(deprecateWarning,
990+
firebaseui.auth.log.warning.getLastCall().getArgument(0));
991+
// Deprecation warning should be only shown once.
992+
app1.updateConfig('callbacks', callbacks);
993+
/** @suppress {missingRequire} */
994+
assertEquals(1, firebaseui.auth.log.warning.getCallCount());
918995
}
919996

920997

@@ -1350,7 +1427,7 @@ function testStartSignInWithEmailAndPassword_success() {
13501427
assertObjectEquals(expectedUserCredential, userCredential);
13511428
asyncTestCase.signal();
13521429
});
1353-
app.getAuth().assertSignInAndRetrieveDataWithEmailAndPassword(
1430+
app.getAuth().assertSignInWithEmailAndPassword(
13541431
['[email protected]', 'password'],
13551432
function() {
13561433
app.getAuth().setUser(expectedUser);
@@ -1380,7 +1457,7 @@ function testStartSignInWithEmailAndPassword_error() {
13801457
assertEquals(expectedError, error);
13811458
asyncTestCase.signal();
13821459
});
1383-
app.getAuth().assertSignInAndRetrieveDataWithEmailAndPassword(
1460+
app.getAuth().assertSignInWithEmailAndPassword(
13841461
['[email protected]', 'password'],
13851462
null,
13861463
expectedError);
@@ -1427,7 +1504,7 @@ function testStartSignInWithEmailAndPassword_upgradeAnon_isAnonymous_success() {
14271504
});
14281505
// Simulate anonymous user logged in on external instance.
14291506
testAuth.setUser(anonymousUser);
1430-
app.getAuth().assertSignInAndRetrieveDataWithEmailAndPassword(
1507+
app.getAuth().assertSignInWithEmailAndPassword(
14311508
['[email protected]', 'password'],
14321509
function() {
14331510
app.getAuth().setUser(expectedUser);
@@ -1480,7 +1557,7 @@ function testStartSignInWithEmailAndPassword_upgradeAnon_isAnon_error() {
14801557
asyncTestCase.signal();
14811558
});
14821559
// Simulate wrong password error on sign-in.
1483-
app.getAuth().assertSignInAndRetrieveDataWithEmailAndPassword(
1560+
app.getAuth().assertSignInWithEmailAndPassword(
14841561
['[email protected]', 'password'],
14851562
null,
14861563
expectedError);
@@ -1511,7 +1588,7 @@ function testStartSignInWithEmailAndPassword_upgradeAnon_nonAnon_success() {
15111588
assertObjectEquals(expectedUserCredential, userCredential);
15121589
asyncTestCase.signal();
15131590
});
1514-
app.getAuth().assertSignInAndRetrieveDataWithEmailAndPassword(
1591+
app.getAuth().assertSignInWithEmailAndPassword(
15151592
['[email protected]', 'password'],
15161593
function() {
15171594
app.getAuth().setUser(expectedUser);
@@ -1551,7 +1628,7 @@ function testStartSignInWithEmailAndPassword_upgradeAnonymous_noUser_success() {
15511628
assertObjectEquals(expectedUserCredential, userCredential);
15521629
asyncTestCase.signal();
15531630
});
1554-
app.getAuth().assertSignInAndRetrieveDataWithEmailAndPassword(
1631+
app.getAuth().assertSignInWithEmailAndPassword(
15551632
['[email protected]', 'password'],
15561633
function() {
15571634
app.getAuth().setUser(expectedUser);
@@ -1587,7 +1664,7 @@ function testStartCreateUserWithEmailAndPassword_success() {
15871664
assertObjectEquals(expectedUserCredential, userCredential);
15881665
asyncTestCase.signal();
15891666
});
1590-
app.getAuth().assertCreateUserAndRetrieveDataWithEmailAndPassword(
1667+
app.getAuth().assertCreateUserWithEmailAndPassword(
15911668
['[email protected]', 'password'],
15921669
function() {
15931670
app.getAuth().setUser(expectedUser);
@@ -1617,7 +1694,7 @@ function testStartCreateUserWithEmailAndPassword_error() {
16171694
assertEquals(expectedError, error);
16181695
asyncTestCase.signal();
16191696
});
1620-
app.getAuth().assertCreateUserAndRetrieveDataWithEmailAndPassword(
1697+
app.getAuth().assertCreateUserWithEmailAndPassword(
16211698
['[email protected]', 'password'],
16221699
null,
16231700
expectedError);
@@ -1694,7 +1771,7 @@ function testStartCreateUserWithEmailAndPassword__upgradeAnon_noUser_success() {
16941771
app.getExternalAuth().runAuthChangeHandler();
16951772
// createUserWithEmailAndPassword called on internal Auth instance as no user
16961773
// available.
1697-
app.getAuth().assertCreateUserAndRetrieveDataWithEmailAndPassword(
1774+
app.getAuth().assertCreateUserWithEmailAndPassword(
16981775
['[email protected]', 'password'],
16991776
function() {
17001777
app.getAuth().setUser(expectedUser);
@@ -1780,7 +1857,7 @@ function testStartCreateUserWithEmailAndPassword_upgradeAnon_nonAnon_success() {
17801857
});
17811858
// Trigger initial onAuthStateChanged listener.
17821859
app.getExternalAuth().runAuthChangeHandler();
1783-
app.getAuth().assertCreateUserAndRetrieveDataWithEmailAndPassword(
1860+
app.getAuth().assertCreateUserWithEmailAndPassword(
17841861
['[email protected]', 'password'],
17851862
function() {
17861863
app.getAuth().setUser(expectedUser);
@@ -3812,7 +3889,7 @@ function testSignInWithExistingEmailAndPasswordForLinking_success() {
38123889
assertObjectEquals(expectedUserCredential, userCredential);
38133890
asyncTestCase.signal();
38143891
});
3815-
app.getAuth().assertSignInAndRetrieveDataWithEmailAndPassword(
3892+
app.getAuth().assertSignInWithEmailAndPassword(
38163893
['[email protected]', 'password'],
38173894
function() {
38183895
app.getAuth().setUser(expectedUser);
@@ -3843,7 +3920,7 @@ function testSignInWithExistingEmailAndPasswordForLinking_error() {
38433920
assertEquals(expectedError, error);
38443921
asyncTestCase.signal();
38453922
});
3846-
app.getAuth().assertSignInAndRetrieveDataWithEmailAndPassword(
3923+
app.getAuth().assertSignInWithEmailAndPassword(
38473924
['[email protected]', 'password'],
38483925
null,
38493926
expectedError);

0 commit comments

Comments
 (0)