Skip to content

Commit d50aad9

Browse files
authored
feat(auth)!: remove deprecated functions (#17562)
This PR removes all deprecated methods from the firebase_auth package in preparation for a breaking change release. ## Removed Methods - `ActionCodeSettings.dynamicLinkDomain` - Firebase Dynamic Links is deprecated and will be shut down - `MicrosoftAuthProvider.credential()` - Use `signInWithProvider(MicrosoftAuthProvider)` instead - `FirebaseAuth.instanceFor()` persistence parameter - Use `setPersistence()` instead - `FirebaseAuth.fetchSignInMethodsForEmail()` - Removed for security best practices - `User.updateEmail()` - Use `verifyBeforeUpdateEmail()` instead ## Migration Guide ### ActionCodeSettings ```dart // Before ActionCodeSettings( url: 'https://example.com', dynamicLinkDomain: 'example.page.link', ) // After ActionCodeSettings( url: 'https://example.com', linkDomain: 'your-custom-domain.com', // Use custom Firebase Hosting domain ) ``` ### Microsoft Authentication ```dart // Before final credential = MicrosoftAuthProvider.credential(accessToken); await FirebaseAuth.instance.signInWithCredential(credential); // After final provider = MicrosoftAuthProvider(); await FirebaseAuth.instance.signInWithProvider(provider); ``` ### FirebaseAuth Instance ```dart // Before FirebaseAuth.instanceFor(app: app, persistence: Persistence.local); // After final auth = FirebaseAuth.instanceFor(app: app); auth.setPersistence(Persistence.local); ``` ### Email Updates ```dart // Before await user.updateEmail('[email protected]'); // After await user.verifyBeforeUpdateEmail('[email protected]'); ``` ### Email Sign-in Methods The `fetchSignInMethodsForEmail()` method has been removed for security reasons. Consider implementing alternative authentication flows that don't require email enumeration.
1 parent 1b71626 commit d50aad9

File tree

14 files changed

+12
-225
lines changed

14 files changed

+12
-225
lines changed

packages/firebase_auth/firebase_auth/lib/firebase_auth.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export 'package:firebase_auth_platform_interface/firebase_auth_platform_interfac
4848
YahooAuthProvider,
4949
YahooAuthCredential,
5050
MicrosoftAuthProvider,
51-
MicrosoftAuthCredential,
5251
OAuthProvider,
5352
OAuthCredential,
5453
PhoneAuthProvider,

packages/firebase_auth/firebase_auth/lib/src/firebase_auth.dart

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ class FirebaseAuth extends FirebasePluginPlatform {
4343
/// Returns an instance using a specified [FirebaseApp].
4444
factory FirebaseAuth.instanceFor({
4545
required FirebaseApp app,
46-
@Deprecated(
47-
'Will be removed in future release. Use setPersistence() instead.',
48-
)
49-
Persistence? persistence,
5046
}) {
5147
return _firebaseAuthInstances.putIfAbsent(app.name, () {
5248
return FirebaseAuth._(app: app);
@@ -235,24 +231,6 @@ class FirebaseAuth extends FirebasePluginPlatform {
235231
);
236232
}
237233

238-
/// Returns a list of sign-in methods that can be used to sign in a given
239-
/// user (identified by its main email address).
240-
///
241-
/// This method is useful when you support multiple authentication mechanisms
242-
/// if you want to implement an email-first authentication flow.
243-
///
244-
/// An empty `List` is returned if the user could not be found.
245-
///
246-
/// A [FirebaseAuthException] maybe thrown with the following error code:
247-
/// - **invalid-email**:
248-
/// - Thrown if the email address is not valid.
249-
@Deprecated('fetchSignInMethodsForEmail() has been deprecated. '
250-
'Migrating off of this method is recommended as a security best-practice. Learn more in the Identity Platform documentation: '
251-
' https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection.')
252-
Future<List<String>> fetchSignInMethodsForEmail(String email) {
253-
return _delegate.fetchSignInMethodsForEmail(email);
254-
}
255-
256234
/// Returns a UserCredential from the redirect-based sign-in flow.
257235
///
258236
/// If sign-in succeeded, returns the signed in user. If sign-in was
@@ -473,7 +451,7 @@ class FirebaseAuth extends FirebasePluginPlatform {
473451
/// - Thrown if there already exists an account with the email address
474452
/// asserted by the credential.
475453
// ignore: deprecated_member_use_from_same_package
476-
/// Resolve this by calling [fetchSignInMethodsForEmail] and then asking
454+
/// Resolve this by asking
477455
/// the user to sign in using one of the returned providers.
478456
/// Once the user is signed in, the original credential can be linked to
479457
/// the user with [linkWithCredential].

packages/firebase_auth/firebase_auth/lib/src/user.dart

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class User {
163163
/// user, an `email` and `credential` ([AuthCredential]) fields are also
164164
/// provided. You have to link the credential to the existing user with
165165
/// that email if you wish to continue signing in with that credential. To
166-
/// do so, call [fetchSignInMethodsForEmail], sign in to `email` via one of
166+
/// do so, sign in to `email` via one of
167167
/// the providers returned and then [User.linkWithCredential] the original
168168
/// credential to that newly signed in user.
169169
/// - **operation-not-allowed**:
@@ -225,8 +225,8 @@ class User {
225225
/// user, an `email` and `credential` ([AuthCredential]) fields are also
226226
/// provided. You have to link the credential to the existing user with
227227
/// that email if you wish to continue signing in with that credential.
228-
/// To do so, call [fetchSignInMethodsForEmail], sign in to `email` via one
229-
/// of the providers returned and then [User.linkWithCredential] the
228+
/// To do so, sign in to `email` via one
229+
/// of the providers and then [User.linkWithCredential] the
230230
/// original credential to that newly signed in user.
231231
/// - **operation-not-allowed**:
232232
/// - Thrown if you have not enabled the provider in the Firebase Console. Go
@@ -392,8 +392,8 @@ class User {
392392
/// user, an `email` and `credential` ([AuthCredential]) fields are also
393393
/// provided. You have to link the credential to the existing user with
394394
/// that email if you wish to continue signing in with that credential.
395-
/// To do so, call [fetchSignInMethodsForEmail], sign in to `email` via one
396-
/// of the providers returned and then [User.linkWithCredential] the
395+
/// To do so, sign in to `email` via one
396+
/// of the providers and then [User.linkWithCredential] the
397397
/// original credential to that newly signed in user.
398398
/// - **operation-not-allowed**:
399399
/// - Thrown if you have not enabled the provider in the Firebase Console. Go
@@ -440,8 +440,8 @@ class User {
440440
/// user, an `email` and `credential` ([AuthCredential]) fields are also
441441
/// provided. You have to link the credential to the existing user with
442442
/// that email if you wish to continue signing in with that credential.
443-
/// To do so, call [fetchSignInMethodsForEmail], sign in to `email` via one
444-
/// of the providers returned and then [User.linkWithCredential] the
443+
/// To do so, sign in to `email` via one
444+
/// of the providers and then [User.linkWithCredential] the
445445
/// original credential to that newly signed in user.
446446
/// - **operation-not-allowed**:
447447
/// - Thrown if you have not enabled the provider in the Firebase Console. Go
@@ -584,20 +584,6 @@ class User {
584584
/// user to have recently signed in. If this requirement isn't met, ask the
585585
/// user to authenticate again and then call [User.reauthenticateWithCredential].
586586
///
587-
/// A [FirebaseAuthException] maybe thrown with the following error code:
588-
/// - **invalid-email**:
589-
/// - Thrown if the email used is invalid.
590-
/// - **email-already-in-use**:
591-
/// - Thrown if the email is already used by another user.
592-
/// - **requires-recent-login**:
593-
/// - Thrown if the user's last sign-in time does not meet the security
594-
/// threshold. Use [User.reauthenticateWithCredential] to resolve. This
595-
/// does not apply if the user is anonymous.
596-
@Deprecated(
597-
'updateEmail() has been deprecated. Please use verifyBeforeUpdateEmail() instead.')
598-
Future<void> updateEmail(String newEmail) async {
599-
await _delegate.updateEmail(newEmail);
600-
}
601587
602588
/// Updates the user's password.
603589
///

packages/firebase_auth/firebase_auth/test/firebase_auth_test.dart

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -348,17 +348,6 @@ void main() {
348348
});
349349
});
350350

351-
group('fetchSignInMethodsForEmail()', () {
352-
test('should call delegate method', () async {
353-
// Necessary as we otherwise get a "null is not a Future<void>" error
354-
when(mockAuthPlatform.fetchSignInMethodsForEmail(any))
355-
.thenAnswer((i) async => []);
356-
// ignore: deprecated_member_use_from_same_package
357-
await auth.fetchSignInMethodsForEmail(kMockEmail);
358-
verify(mockAuthPlatform.fetchSignInMethodsForEmail(kMockEmail));
359-
});
360-
});
361-
362351
group('getRedirectResult()', () {
363352
test('should call delegate method', () async {
364353
// Necessary as we otherwise get a "null is not a Future<void>" error
@@ -1052,15 +1041,6 @@ class MockFirebaseAuth extends Mock
10521041
);
10531042
}
10541043

1055-
@override
1056-
Future<List<String>> fetchSignInMethodsForEmail(String? email) {
1057-
return super.noSuchMethod(
1058-
Invocation.method(#checkActionCode, [email]),
1059-
returnValue: neverEndingFuture<List<String>>(),
1060-
returnValueForMissingStub: neverEndingFuture<List<String>>(),
1061-
);
1062-
}
1063-
10641044
@override
10651045
bool isSignInWithEmailLink(String? emailLink) {
10661046
return super.noSuchMethod(

packages/firebase_auth/firebase_auth/test/user_test.dart

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,6 @@ void main() {
247247
verify(mockUserPlatform.unlink(providerId));
248248
});
249249
});
250-
group('updateEmail()', () {
251-
test('should call updateEmail()', () async {
252-
// Necessary as we otherwise get a "null is not a Future<void>" error
253-
when(mockUserPlatform.updateEmail(any)).thenAnswer((i) async {});
254-
255-
const String newEmail = 'newEmail';
256-
// ignore: deprecated_member_use_from_same_package
257-
await auth.currentUser!.updateEmail(newEmail);
258-
259-
verify(mockUserPlatform.updateEmail(newEmail));
260-
});
261-
});
262250

263251
group('updatePassword()', () {
264252
test('should call updatePassword()', () async {
@@ -485,15 +473,6 @@ class MockUserPlatform extends Mock
485473
);
486474
}
487475

488-
@override
489-
Future<void> updateEmail(String? newEmail) {
490-
return super.noSuchMethod(
491-
Invocation.method(#updateEmail, [newEmail]),
492-
returnValue: neverEndingFuture<void>(),
493-
returnValueForMissingStub: neverEndingFuture<void>(),
494-
);
495-
}
496-
497476
@override
498477
Future<void> updatePassword(String? newPassword) {
499478
return super.noSuchMethod(

packages/firebase_auth/firebase_auth_platform_interface/lib/src/action_code_settings.dart

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ class ActionCodeSettings {
1414
this.androidPackageName,
1515
this.androidMinimumVersion,
1616
this.androidInstallApp = false,
17-
@Deprecated(
18-
'Firebase Dynamic Links is deprecated and will be shut down as early as August * 2025. '
19-
'Instead, use ActionCodeSettings.linkDomain to set a a custom domain. '
20-
'Learn more at: https://firebase.google.com/support/dynamic-links-faq')
21-
this.dynamicLinkDomain,
2217
this.linkDomain,
2318
this.handleCodeInApp = false,
2419
this.iOSBundleId,
@@ -42,13 +37,6 @@ class ActionCodeSettings {
4237
/// The iOS app to open if it is installed on the device.
4338
final String? iOSBundleId;
4439

45-
/// Sets an optional Dynamic Link domain.
46-
@Deprecated(
47-
'Firebase Dynamic Links is deprecated and will be shut down as early as August * 2025. '
48-
'Instead, use ActionCodeSettings.linkDomain to set a a custom domain. '
49-
'Learn more at: https://firebase.google.com/support/dynamic-links-faq')
50-
final String? dynamicLinkDomain;
51-
5240
/// The default is false. When true, the action code link will be sent
5341
/// as a Universal Link or Android App Link and will be opened by the
5442
/// app if installed.
@@ -65,8 +53,6 @@ class ActionCodeSettings {
6553
Map<String, dynamic> asMap() {
6654
return <String, dynamic>{
6755
'url': url,
68-
// ignore: deprecated_member_use_from_same_package
69-
'dynamicLinkDomain': dynamicLinkDomain,
7056
'linkDomain': linkDomain,
7157
'handleCodeInApp': handleCodeInApp,
7258
if (iOSBundleId != null)

packages/firebase_auth/firebase_auth_platform_interface/lib/src/method_channel/method_channel_firebase_auth.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,6 @@ class MethodChannelFirebaseAuth extends FirebaseAuthPlatform {
482482
androidPackageName: actionCodeSettings.androidPackageName,
483483
androidInstallApp: actionCodeSettings.androidInstallApp,
484484
androidMinimumVersion: actionCodeSettings.androidMinimumVersion,
485-
// ignore: deprecated_member_use_from_same_package
486-
dynamicLinkDomain: actionCodeSettings.dynamicLinkDomain,
487485
linkDomain: actionCodeSettings.linkDomain,
488486
),
489487
);
@@ -509,8 +507,6 @@ class MethodChannelFirebaseAuth extends FirebaseAuthPlatform {
509507
androidPackageName: actionCodeSettings.androidPackageName,
510508
androidInstallApp: actionCodeSettings.androidInstallApp,
511509
androidMinimumVersion: actionCodeSettings.androidMinimumVersion,
512-
// ignore: deprecated_member_use_from_same_package
513-
dynamicLinkDomain: actionCodeSettings.dynamicLinkDomain,
514510
),
515511
);
516512
} catch (e, stack) {

packages/firebase_auth/firebase_auth_platform_interface/lib/src/method_channel/method_channel_user.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ class MethodChannelUser extends UserPlatform {
198198
androidPackageName: actionCodeSettings.androidPackageName,
199199
androidInstallApp: actionCodeSettings.androidInstallApp,
200200
androidMinimumVersion: actionCodeSettings.androidMinimumVersion,
201-
// ignore: deprecated_member_use_from_same_package
202-
dynamicLinkDomain: actionCodeSettings.dynamicLinkDomain,
203201
linkDomain: actionCodeSettings.linkDomain,
204202
),
205203
);
@@ -310,8 +308,6 @@ class MethodChannelUser extends UserPlatform {
310308
androidPackageName: actionCodeSettings.androidPackageName,
311309
androidInstallApp: actionCodeSettings.androidInstallApp,
312310
androidMinimumVersion: actionCodeSettings.androidMinimumVersion,
313-
// ignore: deprecated_member_use_from_same_package
314-
dynamicLinkDomain: actionCodeSettings.dynamicLinkDomain,
315311
linkDomain: actionCodeSettings.linkDomain,
316312
),
317313
);

packages/firebase_auth/firebase_auth_platform_interface/lib/src/providers/microsoft_auth.dart

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,6 @@ class MicrosoftAuthProvider extends AuthProvider {
3636
/// Creates a new instance.
3737
MicrosoftAuthProvider() : super(_kProviderId);
3838

39-
/// Create a new [MicrosoftAuthCredential] from a provided [accessToken];
40-
@Deprecated(
41-
'`credential()` has been deprecated. Sign-in cannot be directly achieved with OAuth access token based credentials for Microsoft. Please use `signInWithProvider(MicrosoftAuthProvider)` instead.',
42-
)
43-
static OAuthCredential credential(String accessToken) {
44-
return MicrosoftAuthCredential._credential(
45-
accessToken,
46-
);
47-
}
48-
4939
/// This corresponds to the sign-in method identifier.
5040
static String get MICROSOFT_SIGN_IN_METHOD {
5141
return _kProviderId;
@@ -84,17 +74,3 @@ class MicrosoftAuthProvider extends AuthProvider {
8474
return this;
8575
}
8676
}
87-
88-
// ignore: deprecated_member_use_from_same_package
89-
/// [MicrosoftAuthProvider.credential] returns a [MicrosoftAuthCredential] instance.
90-
class MicrosoftAuthCredential extends OAuthCredential {
91-
MicrosoftAuthCredential._({
92-
required String accessToken,
93-
}) : super(
94-
providerId: _kProviderId,
95-
signInMethod: _kProviderId,
96-
accessToken: accessToken);
97-
factory MicrosoftAuthCredential._credential(String accessToken) {
98-
return MicrosoftAuthCredential._(accessToken: accessToken);
99-
}
100-
}

packages/firebase_auth/firebase_auth_platform_interface/test/action_code_settings_test.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ void main() {
1010
const String kMockBundleId = 'com.test.bundle';
1111
const String kMockPackageName = 'com.test.package';
1212

13-
const String kMockDynamicLinkDomain = 'domain.com';
1413
const String kMockLinkDomain = 'new.domain.com';
1514
const bool kMockHandleCodeInApp = true;
1615
const String kMockUrl = 'https://test.url';
@@ -22,8 +21,6 @@ void main() {
2221
androidPackageName: kMockPackageName,
2322
androidMinimumVersion: kMockMinimumVersion,
2423
androidInstallApp: kMockInstallApp,
25-
// ignore: deprecated_member_use_from_same_package
26-
dynamicLinkDomain: kMockDynamicLinkDomain,
2724
linkDomain: kMockLinkDomain,
2825
handleCodeInApp: kMockHandleCodeInApp,
2926
iOSBundleId: kMockBundleId,
@@ -33,9 +30,6 @@ void main() {
3330
test('returns an instance of [ActionCodeInfo]', () {
3431
expect(actionCodeSettings, isA<ActionCodeSettings>());
3532
expect(actionCodeSettings.url, equals(kMockUrl));
36-
// ignore: deprecated_member_use_from_same_package
37-
expect(actionCodeSettings.dynamicLinkDomain,
38-
equals(kMockDynamicLinkDomain));
3933
expect(actionCodeSettings.linkDomain, equals(kMockLinkDomain));
4034
expect(
4135
actionCodeSettings.handleCodeInApp, equals(kMockHandleCodeInApp));
@@ -53,7 +47,6 @@ void main() {
5347
expect(result, isA<Map<String, dynamic>>());
5448

5549
expect(result['url'], equals(kMockUrl));
56-
expect(result['dynamicLinkDomain'], equals(kMockDynamicLinkDomain));
5750
expect(result['linkDomain'], equals(kMockLinkDomain));
5851
expect(result['handleCodeInApp'], equals(kMockHandleCodeInApp));
5952
expect(result['android']['packageName'], equals(kMockPackageName));

0 commit comments

Comments
 (0)