From b0e2c75019d673c702058916c46e87f75cbcf601 Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Tue, 7 Nov 2023 12:07:43 +0100 Subject: [PATCH] rename Auth to FirebaseAuth --- auth/lib/auth.dart | 2 ++ auth/lib/src/auth.dart | 26 +++++++++++++--------- auth/lib/src/auth_mixin.dart | 9 ++++---- auth/pubspec.yaml | 2 +- auth_browser/lib/auth_browser.dart | 4 ++-- auth_browser/lib/src/auth_browser.dart | 4 ++-- auth_browser/lib/src/auth_browser_api.dart | 2 +- auth_local/lib/auth_local.dart | 9 ++++---- auth_local/lib/src/auth_local.dart | 8 +++---- auth_local/pubspec.yaml | 4 ++-- auth_rest/lib/auth_rest.dart | 4 ++-- auth_rest/lib/src/auth_rest.dart | 10 ++++----- auth_test/lib/auth_test.dart | 6 ++--- 13 files changed, 50 insertions(+), 40 deletions(-) diff --git a/auth/lib/auth.dart b/auth/lib/auth.dart index 52eb447..5bb64fa 100644 --- a/auth/lib/auth.dart +++ b/auth/lib/auth.dart @@ -2,6 +2,8 @@ export 'package:tekartik_firebase_auth/src/auth.dart' show Auth, AuthService, + FirebaseAuth, + FirebaseAuthService, UserMetadata, UserInfo, User, diff --git a/auth/lib/src/auth.dart b/auth/lib/src/auth.dart index 0514299..4f11101 100644 --- a/auth/lib/src/auth.dart +++ b/auth/lib/src/auth.dart @@ -2,13 +2,19 @@ import 'dart:async'; import 'package:tekartik_firebase/firebase.dart'; -abstract class AuthService { +/// To deprecate: Use FirebaseAuthService +typedef AuthService = FirebaseAuthService; + +/// To deprecate: Use FirebaseAuthService +typedef Auth = FirebaseAuth; + +abstract class FirebaseAuthService { // true if it supports listing and finding users bool get supportsListUsers; bool get supportsCurrentUser; - Auth auth(App app); + FirebaseAuth auth(App app); } /// Represents an auth provider. @@ -33,7 +39,7 @@ abstract class AuthSignInResult { /// Represents a Auth Database and is the entry point for all /// Auth operations. -abstract class Auth { +abstract class FirebaseAuth { /// Retrieves a list of users (single batch only) with a size of [maxResults] /// and starting from the offset as specified by [pageToken]. /// @@ -49,7 +55,7 @@ abstract class Auth { /// Gets the user data for all the users. Future> getUsers(List uids); - /// only if [AuthService.supportsCurrentUser] is true + /// only if [FirebaseAuthService.supportsCurrentUser] is true User? get currentUser; /// Reload user (needed after email verification) @@ -61,7 +67,7 @@ abstract class Auth { /// none) Stream get onCurrentUser; - /// only if [AuthService.supportsCurrentUser] is true. + /// only if [FirebaseAuthService.supportsCurrentUser] is true. /// /// Credential can be null and the login happen later Future signIn(AuthProvider authProvider, @@ -83,7 +89,7 @@ abstract class UserRecord { /// The user's custom claims object if available, typically used to define user /// roles and propagated to an authenticated user's ID token. /// - /// This is set via [Auth.setCustomUserClaims]. + /// This is set via [FirebaseAuth.setCustomUserClaims]. dynamic get customClaims; /// Whether or not the user is disabled: true for disabled; false for enabled. @@ -108,7 +114,7 @@ abstract class UserRecord { /// typical when migrating from another Auth system, this will be an empty /// string. If no password is set, this will be`null`. /// - /// This is only available when the user is obtained from [Auth.listUsers]. + /// This is only available when the user is obtained from [FirebaseAuth.listUsers]. String? get passwordHash; /// The user’s password salt (base64-encoded), only if Firebase Auth hashing @@ -118,7 +124,7 @@ abstract class UserRecord { /// when migrating from another Auth system, this will be an empty string. /// If no password is set, this will be `null`. /// - /// This is only available when the user is obtained from [Auth.listUsers]. + /// This is only available when the user is obtained from [FirebaseAuth.listUsers]. String? get passwordSalt; /// The user's primary phone number or `null`. @@ -133,7 +139,7 @@ abstract class UserRecord { /// The date the user's tokens are valid after, formatted as a UTC string. /// /// This is updated every time the user's refresh token are revoked either from - /// the [Auth.revokeRefreshTokens] API or from the Firebase Auth backend on big + /// the [FirebaseAuth.revokeRefreshTokens] API or from the Firebase Auth backend on big /// account changes (password resets, password or email updates, etc). String? get tokensValidAfterTime; @@ -221,7 +227,7 @@ abstract class ListUsersResult { } /// Interface representing a decoded Firebase ID token, returned from the -/// [Auth.verifyIdToken] method. +/// [FirebaseAuth.verifyIdToken] method. abstract class DecodedIdToken { /// The uid corresponding to the user who the ID token belonged to. String get uid; diff --git a/auth/lib/src/auth_mixin.dart b/auth/lib/src/auth_mixin.dart index e5d1bce..26ae485 100644 --- a/auth/lib/src/auth_mixin.dart +++ b/auth/lib/src/auth_mixin.dart @@ -4,11 +4,12 @@ import 'package:tekartik_common_utils/stream/subject.dart'; import 'package:tekartik_firebase/firebase.dart'; import 'package:tekartik_firebase_auth/auth.dart'; -mixin AuthServiceMixin implements AuthService { +mixin AuthServiceMixin implements FirebaseAuthService { /// Most implementation need a single instance, keep it in memory! - static final _instances = {}; + static final _instances = {}; - T getInstance(App app, T Function() createIfNotFound) { + T getInstance( + App app, T Function() createIfNotFound) { var instance = _instances[app] as T?; if (instance == null) { instance = createIfNotFound(); @@ -18,7 +19,7 @@ mixin AuthServiceMixin implements AuthService { } } -mixin AuthMixin implements Auth, FirebaseAppService { +mixin AuthMixin implements FirebaseAuth, FirebaseAppService { final _currentUserSubject = Subject(); void currentUserAdd(User? user) { diff --git a/auth/pubspec.yaml b/auth/pubspec.yaml index eddabc6..589d3b2 100644 --- a/auth/pubspec.yaml +++ b/auth/pubspec.yaml @@ -1,6 +1,6 @@ name: tekartik_firebase_auth description: Firebase auth core -version: 0.9.0 +version: 0.9.1 publish_to: none diff --git a/auth_browser/lib/auth_browser.dart b/auth_browser/lib/auth_browser.dart index 263c0dd..9e53948 100644 --- a/auth_browser/lib/auth_browser.dart +++ b/auth_browser/lib/auth_browser.dart @@ -12,6 +12,6 @@ export 'package:tekartik_firebase_auth_browser/src/auth_browser_facebook.dart' export 'auth_browser_api.dart'; -AuthService get authServiceBrowser => auth_browser.authService; +FirebaseAuthService get authServiceBrowser => auth_browser.authService; @Deprecated('Use authServiceBrowser') -AuthService get authService => authServiceBrowser; +FirebaseAuthService get authService => authServiceBrowser; diff --git a/auth_browser/lib/src/auth_browser.dart b/auth_browser/lib/src/auth_browser.dart index 274537b..8f6f7a8 100644 --- a/auth_browser/lib/src/auth_browser.dart +++ b/auth_browser/lib/src/auth_browser.dart @@ -32,7 +32,7 @@ class AuthServiceBrowserImpl with AuthServiceMixin implements AuthServiceBrowser { @override - Auth auth(common.App app) { + FirebaseAuth auth(common.App app) { return getInstance(app, () { assert(app is firebase_browser.AppBrowser, 'invalid firebase app type'); final appBrowser = app as firebase_browser.AppBrowser; @@ -49,7 +49,7 @@ class AuthServiceBrowserImpl AuthServiceBrowser? _firebaseAuthServiceBrowser; -AuthService get authService => +FirebaseAuthService get authService => _firebaseAuthServiceBrowser ??= AuthServiceBrowserImpl(); class AuthProviderImpl implements AuthProvider { diff --git a/auth_browser/lib/src/auth_browser_api.dart b/auth_browser/lib/src/auth_browser_api.dart index 584f497..c0a82ea 100644 --- a/auth_browser/lib/src/auth_browser_api.dart +++ b/auth_browser/lib/src/auth_browser_api.dart @@ -29,4 +29,4 @@ abstract class AuthBrowser with AuthMixin { Future signInPopup(AuthProvider authProvider); } -abstract class AuthServiceBrowser implements AuthService {} +abstract class AuthServiceBrowser implements FirebaseAuthService {} diff --git a/auth_local/lib/auth_local.dart b/auth_local/lib/auth_local.dart index 1d151a2..fdc0c6c 100644 --- a/auth_local/lib/auth_local.dart +++ b/auth_local/lib/auth_local.dart @@ -11,12 +11,13 @@ export 'package:tekartik_firebase_auth_local/src/auth_local.dart' AuthLocalProvider, UserRecordLocal; -AuthService get authServiceLocal => auth_local.authService; +FirebaseAuthService get authServiceLocal => auth_local.authService; @Deprecated('Use authServiceLocal') -AuthService get authService => authServiceLocal; +FirebaseAuthService get authService => authServiceLocal; /// For unit test -AuthService newAuthServiceLocal() => auth_local.AuthServiceLocal(); +FirebaseAuthService newAuthServiceLocal() => auth_local.AuthServiceLocal(); /// Quick firestore test helper -Auth newAuthLocal() => newAuthServiceLocal().auth(newFirebaseAppLocal()); +FirebaseAuth newAuthLocal() => + newAuthServiceLocal().auth(newFirebaseAppLocal()); diff --git a/auth_local/lib/src/auth_local.dart b/auth_local/lib/src/auth_local.dart index 68c6cbb..71ac38d 100644 --- a/auth_local/lib/src/auth_local.dart +++ b/auth_local/lib/src/auth_local.dart @@ -169,7 +169,7 @@ class UserLocal extends UserInfoLocal implements User { bool get isAnonymous => false; } -abstract class AuthLocal implements Auth {} +abstract class AuthLocal implements FirebaseAuth {} class AuthLocalImpl with AuthMixin implements AuthLocal { final AppLocal? _appLocal; @@ -274,12 +274,12 @@ class DecodedIdTokenLocal implements DecodedIdToken { DecodedIdTokenLocal({required this.uid}); } -class AuthServiceLocal with AuthServiceMixin implements AuthService { +class AuthServiceLocal with AuthServiceMixin implements FirebaseAuthService { @override bool get supportsListUsers => true; @override - Auth auth(App app) { + FirebaseAuth auth(App app) { return getInstance(app, () { // assert(app is AppLocal, 'invalid app type - not AppLocal'); // final appLocal = app as AppLocal; @@ -296,4 +296,4 @@ AuthServiceLocal? _authServiceLocal; AuthServiceLocal get authServiceLocal => _authServiceLocal ??= AuthServiceLocal(); -AuthService get authService => authServiceLocal; +FirebaseAuthService get authService => authServiceLocal; diff --git a/auth_local/pubspec.yaml b/auth_local/pubspec.yaml index c5f66c9..3fc90c5 100644 --- a/auth_local/pubspec.yaml +++ b/auth_local/pubspec.yaml @@ -1,6 +1,6 @@ name: tekartik_firebase_auth_local description: Firebase local test -version: 0.10.0 +version: 0.10.1 publish_to: none environment: @@ -13,7 +13,7 @@ dependencies: url: https://github.com/tekartik/firebase_auth.dart path: auth ref: dart3a - version: '>=0.9.0' + version: '>=0.9.1' tekartik_firebase_local: git: url: https://github.com/tekartik/firebase.dart diff --git a/auth_rest/lib/auth_rest.dart b/auth_rest/lib/auth_rest.dart index 6b6f1d7..73da43b 100644 --- a/auth_rest/lib/auth_rest.dart +++ b/auth_rest/lib/auth_rest.dart @@ -13,9 +13,9 @@ export 'package:tekartik_firebase_auth_rest/src/auth_rest.dart' export 'package:tekartik_firebase_auth_rest/src/google_auth_rest.dart' show GoogleAuthOptions; -AuthService get authServiceRest => auth_rest.authService; +FirebaseAuthService get authServiceRest => auth_rest.authService; @Deprecated('Use authServiceRest') -AuthService get authService => authServiceRest; +FirebaseAuthService get authService => authServiceRest; /// Build an authorization header. String getAuthorizationHeader(String token) => 'Bearer $token'; diff --git a/auth_rest/lib/src/auth_rest.dart b/auth_rest/lib/src/auth_rest.dart index 8e22303..fdc5dc7 100644 --- a/auth_rest/lib/src/auth_rest.dart +++ b/auth_rest/lib/src/auth_rest.dart @@ -195,7 +195,7 @@ class UserRest extends UserInfoRest implements User { } /// Custom auth rest -abstract class AuthRest implements Auth { +abstract class AuthRest implements FirebaseAuth { Client? get client; /// Custom AuthRest @@ -209,7 +209,7 @@ abstract class AuthRest implements Auth { } /// Rest specific helper for adding a provider. -extension AuthRestExt on Auth { +extension AuthRestExt on FirebaseAuth { void addProvider(AuthProviderRest authProviderRest) => (this as AuthRest).addProviderImpl(authProviderRest); } @@ -420,12 +420,12 @@ class DecodedIdTokenLocal implements DecodedIdToken { DecodedIdTokenLocal({required this.uid}); } -class AuthServiceRest with AuthServiceMixin implements AuthService { +class AuthServiceRest with AuthServiceMixin implements FirebaseAuthService { @override bool get supportsListUsers => false; @override - Auth auth(App app) { + FirebaseAuth auth(App app) { return getInstance(app, () { // assert(app is AppLocal, 'invalid app type - not AppLocal'); // final appLocal = app as AppLocal; @@ -441,7 +441,7 @@ AuthServiceRest? _authServiceRest; AuthServiceRest get authServiceLocal => _authServiceRest ??= AuthServiceRest(); -AuthService get authService => authServiceLocal; +FirebaseAuthService get authService => authServiceLocal; class AuthAccountApi { final String apiKey; diff --git a/auth_test/lib/auth_test.dart b/auth_test/lib/auth_test.dart index 548fe83..38f36e9 100644 --- a/auth_test/lib/auth_test.dart +++ b/auth_test/lib/auth_test.dart @@ -7,7 +7,7 @@ bool skipConcurrentTransactionTests = false; void run( {required fb.Firebase firebase, - required AuthService authService, + required FirebaseAuthService authService, String? name, fb.AppOptions? options}) { var app = firebase.initializeApp(name: name, options: options); @@ -21,8 +21,8 @@ void run( } void runApp( - {required AuthService authService, - required Auth auth, + {required FirebaseAuthService authService, + required FirebaseAuth auth, required fb.App app}) { setUpAll(() async {}); group('auth', () {