Skip to content

Commit 9d16808

Browse files
wti806Feiyang1
authored andcommitted
Auth deprecation (#1726)
* Auth deprecation for V6 * updated externs and index.d.ts * [AUTOMATED]: Prettier Code Styling * fixed the deprecation message * added deprecation notation for the doc
1 parent aca9966 commit 9d16808

File tree

9 files changed

+220
-1137
lines changed

9 files changed

+220
-1137
lines changed

packages/auth-types/index.d.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface User extends UserInfo {
2727
linkAndRetrieveDataWithCredential(
2828
credential: AuthCredential
2929
): Promise<UserCredential>;
30-
linkWithCredential(credential: AuthCredential): Promise<User>;
30+
linkWithCredential(credential: AuthCredential): Promise<UserCredential>;
3131
linkWithPhoneNumber(
3232
phoneNumber: string,
3333
applicationVerifier: ApplicationVerifier
@@ -40,7 +40,9 @@ export interface User extends UserInfo {
4040
reauthenticateAndRetrieveDataWithCredential(
4141
credential: AuthCredential
4242
): Promise<UserCredential>;
43-
reauthenticateWithCredential(credential: AuthCredential): Promise<void>;
43+
reauthenticateWithCredential(
44+
credential: AuthCredential
45+
): Promise<UserCredential>;
4446
reauthenticateWithPhoneNumber(
4547
phoneNumber: string,
4648
applicationVerifier: ApplicationVerifier
@@ -277,12 +279,7 @@ export class FirebaseAuth {
277279
email: string,
278280
password: string
279281
): Promise<UserCredential>;
280-
createUserAndRetrieveDataWithEmailAndPassword(
281-
email: string,
282-
password: string
283-
): Promise<UserCredential>;
284282
currentUser: User | null;
285-
fetchProvidersForEmail(email: string): Promise<Array<string>>;
286283
fetchSignInMethodsForEmail(email: string): Promise<Array<string>>;
287284
isSignInWithEmailLink(emailLink: string): boolean;
288285
getRedirectResult(): Promise<UserCredential>;
@@ -311,18 +308,12 @@ export class FirebaseAuth {
311308
credential: AuthCredential
312309
): Promise<UserCredential>;
313310
signInAnonymously(): Promise<UserCredential>;
314-
signInAnonymouslyAndRetrieveData(): Promise<UserCredential>;
315-
signInWithCredential(credential: AuthCredential): Promise<User>;
311+
signInWithCredential(credential: AuthCredential): Promise<UserCredential>;
316312
signInWithCustomToken(token: string): Promise<UserCredential>;
317-
signInAndRetrieveDataWithCustomToken(token: string): Promise<UserCredential>;
318313
signInWithEmailAndPassword(
319314
email: string,
320315
password: string
321316
): Promise<UserCredential>;
322-
signInAndRetrieveDataWithEmailAndPassword(
323-
email: string,
324-
password: string
325-
): Promise<UserCredential>;
326317
signInWithEmailLink(
327318
email: string,
328319
emailLink?: string

packages/auth/src/auth.js

Lines changed: 16 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,36 +1432,6 @@ fireauth.Auth.prototype.signInWithCustomToken = function(token) {
14321432
};
14331433

14341434

1435-
/**
1436-
* Signs in a user asynchronously using a custom token and returns any
1437-
* additional user info data or credentials returned form the backend. It has
1438-
* been deprecated in favor of signInWithCustomToken.
1439-
* @param {string} token The custom token to sign in with.
1440-
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
1441-
*/
1442-
fireauth.Auth.prototype.signInAndRetrieveDataWithCustomToken = function(token) {
1443-
fireauth.deprecation.log(
1444-
fireauth.deprecation.Deprecations.SIGN_IN_WITH_CUSTOM_TOKEN);
1445-
return this.signInWithCustomToken(token);
1446-
};
1447-
1448-
1449-
/**
1450-
* Sign in using an email and password and returns any additional user info
1451-
* data or credentials returned form the backend. It has been deprecated in
1452-
* favor of signInWithEmailAndPassword.
1453-
* @param {string} email The email to sign in with.
1454-
* @param {string} password The password to sign in with.
1455-
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
1456-
*/
1457-
fireauth.Auth.prototype.signInAndRetrieveDataWithEmailAndPassword =
1458-
function(email, password) {
1459-
fireauth.deprecation.log(
1460-
fireauth.deprecation.Deprecations.SIGN_IN_WITH_EMAIL_AND_PASSWORD);
1461-
return this.signInWithEmailAndPassword(email, password);
1462-
};
1463-
1464-
14651435
/**
14661436
* Sign in using an email and password and returns any additional user info
14671437
* data or credentials returned form the backend.
@@ -1502,47 +1472,13 @@ fireauth.Auth.prototype.createUserWithEmailAndPassword =
15021472
};
15031473

15041474

1505-
/**
1506-
* Creates a new email and password account and returns any additional user
1507-
* info data or credentials returned form the backend. It has been deprecated
1508-
* in favor of createUserWithEmailAndPassword.
1509-
* @param {string} email The email to sign up with.
1510-
* @param {string} password The password to sign up with.
1511-
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
1512-
*/
1513-
fireauth.Auth.prototype.createUserAndRetrieveDataWithEmailAndPassword =
1514-
function(email, password) {
1515-
fireauth.deprecation.log(
1516-
fireauth.deprecation.Deprecations.CREATE_USER_WITH_EMAIL_AND_PASSWORD);
1517-
return this.createUserWithEmailAndPassword(email, password);
1518-
};
1519-
1520-
1521-
/**
1522-
* Logs into Firebase with the given 3rd party credentials. It has been
1523-
* deprecated in favor of signInAndRetrieveDataWithCredential.
1524-
* @param {!fireauth.AuthCredential} credential The auth credential.
1525-
* @return {!goog.Promise<!fireauth.AuthUser>}
1526-
*/
1527-
fireauth.Auth.prototype.signInWithCredential = function(credential) {
1528-
fireauth.deprecation.log(
1529-
fireauth.deprecation.Deprecations.SIGN_IN_WITH_CREDENTIAL);
1530-
// Get signInAndRetrieveDataWithCredential result and return the user only.
1531-
return this.signInAndRetrieveDataWithCredential(credential)
1532-
.then(function(result) {
1533-
return result['user'];
1534-
});
1535-
};
1536-
1537-
15381475
/**
15391476
* Logs into Firebase with the given 3rd party credentials and returns any
15401477
* additional user info data or credentials returned form the backend.
15411478
* @param {!fireauth.AuthCredential} credential The Auth credential.
15421479
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
15431480
*/
1544-
fireauth.Auth.prototype.signInAndRetrieveDataWithCredential =
1545-
function(credential) {
1481+
fireauth.Auth.prototype.signInWithCredential = function(credential) {
15461482
// Credential could be extended in the future, so leave it to credential to
15471483
// decide how to retrieve ID token.
15481484
var self = this;
@@ -1557,6 +1493,21 @@ fireauth.Auth.prototype.signInAndRetrieveDataWithCredential =
15571493
};
15581494

15591495

1496+
/**
1497+
* Logs into Firebase with the given 3rd party credentials and returns any
1498+
* additional user info data or credentials returned form the backend. It has
1499+
* been deprecated in favor of signInWithCredential.
1500+
* @param {!fireauth.AuthCredential} credential The Auth credential.
1501+
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
1502+
*/
1503+
fireauth.Auth.prototype.signInAndRetrieveDataWithCredential =
1504+
function(credential) {
1505+
fireauth.deprecation.log(
1506+
fireauth.deprecation.Deprecations.SIGN_IN_WITH_CREDENTIAL);
1507+
return this.signInWithCredential(credential);
1508+
};
1509+
1510+
15601511
/**
15611512
* Signs in a user anonymously and returns any additional user info data or
15621513
* credentials returned form the backend.
@@ -1607,19 +1558,6 @@ fireauth.Auth.prototype.signInAnonymously = function() {
16071558
};
16081559

16091560

1610-
/**
1611-
* Signs in a user anonymously and returns any additional user info data or
1612-
* credentials returned form the backend. It has been deprecated in favor of
1613-
* signInWithAnonymously.
1614-
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
1615-
*/
1616-
fireauth.Auth.prototype.signInAnonymouslyAndRetrieveData = function() {
1617-
fireauth.deprecation.log(
1618-
fireauth.deprecation.Deprecations.SIGN_IN_ANONYMOUSLY);
1619-
return this.signInAnonymously();
1620-
};
1621-
1622-
16231561
/**
16241562
* @return {string} The key used for storing Auth state.
16251563
*/
@@ -1866,22 +1804,6 @@ fireauth.Auth.prototype.registerPendingPromise_ = function(p) {
18661804
};
18671805

18681806

1869-
/**
1870-
* Gets the list of IDPs that can be used to log in for the given email address.
1871-
* It has been deprecated in favor of fetchSignInMethodsForEmail.
1872-
* @param {string} email The email address.
1873-
* @return {!goog.Promise<!Array<!fireauth.idp.ProviderId>>}
1874-
*/
1875-
fireauth.Auth.prototype.fetchProvidersForEmail = function(email) {
1876-
fireauth.deprecation.log(
1877-
fireauth.deprecation.Deprecations.FETCH_PROVIDERS_FOR_EMAIL);
1878-
return /** @type {!goog.Promise<!Array<!fireauth.idp.ProviderId>>} */ (
1879-
this.registerPendingPromise_(
1880-
this.getRpcHandler().fetchProvidersForIdentifier(email)
1881-
));
1882-
};
1883-
1884-
18851807
/**
18861808
* Gets the list of possible sign in methods for the given email address.
18871809
* @param {string} email The email address.

packages/auth/src/authuser.js

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,12 +1123,28 @@ fireauth.AuthUser.prototype.extractLinkedAccounts_ = function(resp) {
11231123
* Reauthenticates a user using a fresh credential, to be used before operations
11241124
* such as updatePassword that require tokens from recent login attempts. It
11251125
* also returns any additional user info data or credentials returned form the
1126-
* backend.
1126+
* backend. It has been deprecated in favor of reauthenticateWithCredential.
11271127
* @param {!fireauth.AuthCredential} credential
11281128
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
11291129
*/
11301130
fireauth.AuthUser.prototype.reauthenticateAndRetrieveDataWithCredential =
11311131
function(credential) {
1132+
fireauth.deprecation.log(
1133+
fireauth.deprecation.Deprecations.REAUTH_WITH_CREDENTIAL);
1134+
return this.reauthenticateWithCredential(credential);
1135+
};
1136+
1137+
1138+
/**
1139+
* Reauthenticates a user using a fresh credential, to be used before operations
1140+
* such as updatePassword that require tokens from recent login attempts. It
1141+
* also returns any additional user info data or credentials returned form the
1142+
* backend.
1143+
* @param {!fireauth.AuthCredential} credential
1144+
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
1145+
*/
1146+
fireauth.AuthUser.prototype.reauthenticateWithCredential =
1147+
function(credential) {
11321148
var self = this;
11331149
var userCredential = null;
11341150
// Register this pending promise but bypass user invalidation check.
@@ -1158,25 +1174,6 @@ fireauth.AuthUser.prototype.reauthenticateAndRetrieveDataWithCredential =
11581174
};
11591175

11601176

1161-
/**
1162-
* Reauthenticates a user using a fresh credential, to be used before operations
1163-
* such as updatePassword that require tokens from recent login attempts. It has
1164-
* been deprecated in favor of reauthenticateAndRetrieveDataWithCredential.
1165-
* @param {!fireauth.AuthCredential} credential
1166-
* @return {!goog.Promise<void>}
1167-
*/
1168-
fireauth.AuthUser.prototype.reauthenticateWithCredential =
1169-
function(credential) {
1170-
fireauth.deprecation.log(
1171-
fireauth.deprecation.Deprecations.REAUTH_WITH_CREDENTIAL);
1172-
// Get reauthenticateAndRetrieveDataWithCredential result and return void.
1173-
return this.reauthenticateAndRetrieveDataWithCredential(credential)
1174-
.then(function(result) {
1175-
// Do not return anything. Promise should resolve with void.
1176-
});
1177-
};
1178-
1179-
11801177
/**
11811178
* Reloads the user and then checks if a provider is already linked. If so,
11821179
* this returns a Promise that rejects. Note that state change listeners are not
@@ -1205,13 +1202,28 @@ fireauth.AuthUser.prototype.checkIfAlreadyLinked_ =
12051202

12061203
/**
12071204
* Links a provider to the current user and returns any additional user info
1208-
* data or credentials returned form the backend.
1205+
* data or credentials returned form the backend. It has been deprecated in
1206+
* favor of linkWithCredential.
12091207
* @param {!fireauth.AuthCredential} credential The credential from the Auth
12101208
* provider.
12111209
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
12121210
*/
12131211
fireauth.AuthUser.prototype.linkAndRetrieveDataWithCredential =
12141212
function(credential) {
1213+
fireauth.deprecation.log(
1214+
fireauth.deprecation.Deprecations.LINK_WITH_CREDENTIAL);
1215+
return this.linkWithCredential(credential);
1216+
};
1217+
1218+
1219+
/**
1220+
* Links a provider to the current user and returns any additional user info
1221+
* data or credentials returned form the backend.
1222+
* @param {!fireauth.AuthCredential} credential The credential from the Auth
1223+
* provider.
1224+
* @return {!goog.Promise<!fireauth.AuthEventManager.Result>}
1225+
*/
1226+
fireauth.AuthUser.prototype.linkWithCredential = function(credential) {
12151227
var self = this;
12161228
var userCredential = null;
12171229
// Register this pending promise. This will also check for user invalidation.
@@ -1238,24 +1250,6 @@ fireauth.AuthUser.prototype.linkAndRetrieveDataWithCredential =
12381250
};
12391251

12401252

1241-
/**
1242-
* Links a provider to the current user. It has been deprecated in favor of
1243-
* linkAndRetrieveDataWithCredential.
1244-
* @param {!fireauth.AuthCredential} credential The credential from the Auth
1245-
* provider.
1246-
* @return {!goog.Promise<!fireauth.AuthUser>}
1247-
*/
1248-
fireauth.AuthUser.prototype.linkWithCredential = function(credential) {
1249-
fireauth.deprecation.log(
1250-
fireauth.deprecation.Deprecations.LINK_WITH_CREDENTIAL);
1251-
// Get linkAndRetrieveDataWithCredential result and return the user only.
1252-
return this.linkAndRetrieveDataWithCredential(credential)
1253-
.then(function(result) {
1254-
return result['user'];
1255-
});
1256-
};
1257-
1258-
12591253
/**
12601254
* Links a phone number using the App verifier instance and returns a
12611255
* promise that resolves with the confirmation result which on confirmation
@@ -1280,7 +1274,7 @@ fireauth.AuthUser.prototype.linkWithPhoneNumber =
12801274
phoneNumber,
12811275
appVerifier,
12821276
// This will check again if the credential is linked.
1283-
goog.bind(self.linkAndRetrieveDataWithCredential, self));
1277+
goog.bind(self.linkWithCredential, self));
12841278
})));
12851279
};
12861280

@@ -1307,7 +1301,7 @@ fireauth.AuthUser.prototype.reauthenticateWithPhoneNumber =
13071301
self.getAuth_(),
13081302
phoneNumber,
13091303
appVerifier,
1310-
goog.bind(self.reauthenticateAndRetrieveDataWithCredential,
1304+
goog.bind(self.reauthenticateWithCredential,
13111305
self));
13121306
}),
13131307
// Skip invalidation check as reauthentication could revalidate a

packages/auth/src/deprecation.js

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,15 @@ goog.require('fireauth.util');
3030
* @enum {string}
3131
*/
3232
fireauth.deprecation.Deprecations = {
33-
CREATE_USER_WITH_EMAIL_AND_PASSWORD: 'firebase.auth.Auth.prototype.createUs' +
34-
'erAndRetrieveDataWithEmailAndPassword is deprecated. Please use fireba' +
35-
'se.auth.Auth.prototype.createUserWithEmailAndPassword instead.',
36-
FETCH_PROVIDERS_FOR_EMAIL: 'firebase.auth.Auth.prototype.fetchProvidersForE' +
37-
'mail is deprecated. Please use firebase.auth.Auth.prototype.fetchSignI' +
38-
'nMethodsForEmail instead.',
39-
LINK_WITH_CREDENTIAL: 'firebase.User.prototype.linkWithCredential is deprec' +
40-
'ated. Please use firebase.User.prototype.linkAndRetrieveDataWithCreden' +
33+
LINK_WITH_CREDENTIAL: 'firebase.User.prototype.linkAndRetrieveDataWithCrede' +
34+
'ntial is deprecated. Please use firebase.User.prototype.linkWithCreden' +
4135
'tial instead.',
42-
REAUTH_WITH_CREDENTIAL: 'firebase.User.prototype.reauthenticateWithCredenti' +
43-
'al is deprecated. Please use firebase.User.prototype.reauthenticateAnd' +
44-
'RetrieveDataWithCredential instead.',
45-
SIGN_IN_ANONYMOUSLY: 'firebase.auth.Auth.prototype.signInAnonymouslyAndRetr' +
46-
'ieveData is deprecated. Please use firebase.auth.Auth.prototype.signIn' +
47-
'Anonymously instead.',
48-
SIGN_IN_WITH_CREDENTIAL: 'firebase.auth.Auth.prototype.signInWithCredential' +
49-
' is deprecated. Please use firebase.auth.Auth.prototype.signInAndRetri' +
50-
'eveDataWithCredential instead.',
51-
SIGN_IN_WITH_CUSTOM_TOKEN: 'firebase.auth.Auth.prototype.signInAndRetrieveD' +
52-
'ataWithCustomToken is deprecated. Please use firebase.auth.Auth.protot' +
53-
'ype.signInWithCustomToken instead.',
54-
SIGN_IN_WITH_EMAIL_AND_PASSWORD: 'firebase.auth.Auth.prototype.signInAndRet' +
55-
'rieveDataWithEmailAndPassword is deprecated. Please use firebase.auth.' +
56-
'Auth.prototype.signInWithEmailAndPassword instead.'
36+
REAUTH_WITH_CREDENTIAL: 'firebase.User.prototype.reauthenticateAndRetrieveD' +
37+
'ataWithCredential is deprecated. Please use firebase.User.prototype.re' +
38+
'authenticateWithCredential instead.',
39+
SIGN_IN_WITH_CREDENTIAL: 'firebase.auth.Auth.prototype.signInAndRetrieveDat' +
40+
'aWithCredential is deprecated. Please use firebase.auth.Auth.prototype' +
41+
'.signInWithCredential instead.'
5742
};
5843

5944

0 commit comments

Comments
 (0)