Skip to content

Commit 8e95a51

Browse files
feat(firebase_auth)!: upgrade auth web to v9 sdk (#8236)
Co-authored-by: Elliot Hesp <[email protected]> Co-authored-by: Russell Wheatley <[email protected]>
1 parent 4b417af commit 8e95a51

File tree

8 files changed

+368
-241
lines changed

8 files changed

+368
-241
lines changed

packages/firebase_auth/firebase_auth_web/lib/firebase_auth_web.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ class FirebaseAuthWeb extends FirebaseAuthPlatform {
270270
@override
271271
Future<void> setPersistence(Persistence persistence) async {
272272
try {
273-
return _delegate.setPersistence(convertPlatformPersistence(persistence));
273+
return _delegate.setPersistence(persistence);
274274
} catch (e) {
275275
throw getFirebaseAuthException(e);
276276
}

packages/firebase_auth/firebase_auth_web/lib/src/interop/auth.dart

Lines changed: 77 additions & 55 deletions
Large diffs are not rendered by default.

packages/firebase_auth/firebase_auth_web/lib/src/interop/auth_interop.dart

Lines changed: 229 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,242 @@
66
// ignore_for_file: avoid_unused_constructor_parameters, non_constant_identifier_names, comment_references
77
// ignore_for_file: public_member_api_docs
88

9-
@JS('firebase.auth')
9+
@JS('firebase_auth')
1010
library firebase_interop.auth;
1111

1212
import 'package:js/js.dart';
1313
import 'package:firebase_core_web/firebase_core_web_interop.dart';
1414

15+
@JS()
16+
external AuthJsImpl getAuth([AppJsImpl? app]);
17+
18+
@JS()
19+
external AuthJsImpl initializeAuth(AppJsImpl app, dynamic debugErrorMap);
20+
21+
@JS('debugErrorMap')
22+
external Map get debugErrorMap;
23+
24+
@JS()
25+
external PromiseJsImpl<void> applyActionCode(AuthJsImpl auth, String oobCode);
26+
27+
@JS()
28+
external Persistence inMemoryPersistence;
29+
@JS()
30+
external Persistence browserSessionPersistence;
31+
@JS()
32+
external Persistence browserLocalPersistence;
33+
34+
@JS()
35+
external PromiseJsImpl<ActionCodeInfo> checkActionCode(
36+
AuthJsImpl auth, String oobCode);
37+
38+
@JS()
39+
external PromiseJsImpl<void> confirmPasswordReset(
40+
AuthJsImpl auth,
41+
String oobCode,
42+
String newPassword,
43+
);
44+
45+
@JS()
46+
external void connectAuthEmulator(
47+
AuthJsImpl auth,
48+
String origin,
49+
);
50+
51+
@JS()
52+
external PromiseJsImpl<void> setPersistence(
53+
AuthJsImpl auth, Persistence persistence);
54+
55+
@JS()
56+
external PromiseJsImpl<UserCredentialJsImpl> createUserWithEmailAndPassword(
57+
AuthJsImpl auth,
58+
String email,
59+
String password,
60+
);
61+
62+
@JS()
63+
external AdditionalUserInfoJsImpl getAdditionalUserInfo(
64+
UserCredentialJsImpl userCredential);
65+
66+
@JS()
67+
external PromiseJsImpl<void> deleteUser(
68+
UserJsImpl user,
69+
);
70+
71+
@JS()
72+
external PromiseJsImpl<List> fetchSignInMethodsForEmail(
73+
AuthJsImpl auth, String email);
74+
75+
@JS()
76+
external bool isSignInWithEmailLink(String emailLink);
77+
78+
@JS()
79+
external PromiseJsImpl<UserCredentialJsImpl> getRedirectResult(AuthJsImpl auth);
80+
81+
@JS()
82+
external PromiseJsImpl<void> sendSignInLinkToEmail(
83+
AuthJsImpl auth,
84+
String email, [
85+
ActionCodeSettings? actionCodeSettings,
86+
]);
87+
88+
@JS()
89+
external PromiseJsImpl<void> sendPasswordResetEmail(
90+
AuthJsImpl auth,
91+
String email, [
92+
ActionCodeSettings? actionCodeSettings,
93+
]);
94+
95+
@JS()
96+
external PromiseJsImpl<UserCredentialJsImpl> signInWithCredential(
97+
AuthJsImpl auth,
98+
OAuthCredential credential,
99+
);
100+
101+
@JS()
102+
external PromiseJsImpl<UserCredentialJsImpl> signInAnonymously(AuthJsImpl auth);
103+
104+
@JS()
105+
external PromiseJsImpl<UserCredentialJsImpl> signInWithCustomToken(
106+
AuthJsImpl auth,
107+
String token,
108+
);
109+
110+
@JS()
111+
external PromiseJsImpl<UserCredentialJsImpl> signInWithEmailAndPassword(
112+
AuthJsImpl auth,
113+
String email,
114+
String password,
115+
);
116+
117+
@JS()
118+
external PromiseJsImpl<UserCredentialJsImpl> signInWithEmailLink(
119+
AuthJsImpl auth,
120+
String email,
121+
String emailLink,
122+
);
123+
124+
@JS()
125+
external PromiseJsImpl<ConfirmationResultJsImpl> signInWithPhoneNumber(
126+
AuthJsImpl auth,
127+
String phoneNumber,
128+
ApplicationVerifierJsImpl applicationVerifier,
129+
);
130+
131+
@JS()
132+
external PromiseJsImpl<UserCredentialJsImpl> signInWithPopup(
133+
AuthJsImpl auth,
134+
AuthProviderJsImpl provider,
135+
);
136+
137+
@JS()
138+
external PromiseJsImpl<void> signInWithRedirect(
139+
AuthJsImpl auth,
140+
AuthProviderJsImpl provider,
141+
);
142+
143+
@JS()
144+
external PromiseJsImpl<String> verifyPasswordResetCode(
145+
AuthJsImpl auth,
146+
String code,
147+
);
148+
149+
@JS()
150+
external PromiseJsImpl<UserCredentialJsImpl> linkWithCredential(
151+
UserJsImpl user,
152+
OAuthCredential? credential,
153+
);
154+
155+
@JS()
156+
external PromiseJsImpl<ConfirmationResultJsImpl> linkWithPhoneNumber(
157+
UserJsImpl user,
158+
String phoneNumber,
159+
ApplicationVerifierJsImpl applicationVerifier,
160+
);
161+
162+
@JS()
163+
external PromiseJsImpl<UserCredentialJsImpl> linkWithPopup(
164+
UserJsImpl user,
165+
AuthProviderJsImpl provider,
166+
);
167+
168+
@JS()
169+
external PromiseJsImpl<void> linkWithRedirect(
170+
UserJsImpl user,
171+
AuthProviderJsImpl provider,
172+
);
173+
174+
@JS()
175+
external PromiseJsImpl<UserCredentialJsImpl> reauthenticateWithCredential(
176+
UserJsImpl user,
177+
OAuthCredential credential,
178+
);
179+
180+
@JS()
181+
external PromiseJsImpl<ConfirmationResultJsImpl> reauthenticateWithPhoneNumber(
182+
UserJsImpl user,
183+
String phoneNumber,
184+
ApplicationVerifierJsImpl applicationVerifier,
185+
);
186+
187+
@JS()
188+
external PromiseJsImpl<UserCredentialJsImpl> reauthenticateWithPopup(
189+
UserJsImpl user,
190+
AuthProviderJsImpl provider,
191+
);
192+
193+
@JS()
194+
external PromiseJsImpl<void> reauthenticateWithRedirect(
195+
UserJsImpl user,
196+
AuthProviderJsImpl provider,
197+
);
198+
199+
@JS()
200+
external PromiseJsImpl<void> sendEmailVerification([
201+
UserJsImpl user,
202+
ActionCodeSettings? actionCodeSettings,
203+
]);
204+
205+
@JS()
206+
external PromiseJsImpl<void> verifyBeforeUpdateEmail(
207+
UserJsImpl user,
208+
String newEmail, [
209+
ActionCodeSettings? actionCodeSettings,
210+
]);
211+
212+
@JS()
213+
external PromiseJsImpl<UserJsImpl> unlink(UserJsImpl user, String providerId);
214+
215+
@JS()
216+
external PromiseJsImpl<void> updateEmail(UserJsImpl user, String newEmail);
217+
218+
@JS()
219+
external PromiseJsImpl<void> updatePassword(
220+
UserJsImpl user,
221+
String newPassword,
222+
);
223+
224+
@JS()
225+
external PromiseJsImpl<void> updatePhoneNumber(
226+
UserJsImpl user,
227+
OAuthCredential? phoneCredential,
228+
);
229+
230+
@JS()
231+
external PromiseJsImpl<void> updateProfile(
232+
UserJsImpl user,
233+
UserProfile profile,
234+
);
235+
15236
@JS('Auth')
16237
abstract class AuthJsImpl {
17238
external AppJsImpl get app;
18-
external PromiseJsImpl<void> applyActionCode(String code);
19-
external PromiseJsImpl<ActionCodeInfo> checkActionCode(String code);
20-
external PromiseJsImpl<void> confirmPasswordReset(
21-
String code,
22-
String newPassword,
23-
);
24-
external PromiseJsImpl<UserCredentialJsImpl> createUserWithEmailAndPassword(
25-
String email,
26-
String password,
27-
);
28-
external PromiseJsImpl<List> fetchSignInMethodsForEmail(String email);
29239
external UserJsImpl get currentUser;
30-
external String? get tenantId;
31-
external set tenantId(String? s);
32-
external PromiseJsImpl<UserCredentialJsImpl> getRedirectResult();
33-
external bool isSignInWithEmailLink(String emailLink);
34-
external AuthSettings get settings;
35240
external String get languageCode;
36241
external set languageCode(String? s);
242+
external AuthSettings get settings;
243+
external String? get tenantId;
244+
external set tenantId(String? s);
37245
external Func0 onAuthStateChanged(
38246
dynamic nextOrObserver, [
39247
Func1? opt_error,
@@ -44,45 +252,8 @@ abstract class AuthJsImpl {
44252
Func1? opt_error,
45253
Func0? opt_completed,
46254
]);
47-
external PromiseJsImpl<void> sendSignInLinkToEmail(
48-
String email, [
49-
ActionCodeSettings? actionCodeSettings,
50-
]);
51-
external PromiseJsImpl<void> sendPasswordResetEmail(
52-
String email, [
53-
ActionCodeSettings? actionCodeSettings,
54-
]);
55-
external PromiseJsImpl<void> setPersistence(String persistence);
56-
external PromiseJsImpl<UserCredentialJsImpl> signInAnonymously();
57-
58-
external PromiseJsImpl<UserCredentialJsImpl> signInWithCredential(
59-
OAuthCredential credential,
60-
);
61-
external PromiseJsImpl<UserCredentialJsImpl> signInWithCustomToken(
62-
String token,
63-
);
64-
external PromiseJsImpl<UserCredentialJsImpl>
65-
signInAndRetrieveDataWithCustomToken(String token);
66-
external PromiseJsImpl<UserCredentialJsImpl> signInWithEmailAndPassword(
67-
String email,
68-
String password,
69-
);
70-
external PromiseJsImpl<UserCredentialJsImpl> signInWithEmailLink(
71-
String email,
72-
String emailLink,
73-
);
74-
external PromiseJsImpl<ConfirmationResultJsImpl> signInWithPhoneNumber(
75-
String phoneNumber,
76-
ApplicationVerifierJsImpl applicationVerifier,
77-
);
78-
external PromiseJsImpl<UserCredentialJsImpl> signInWithPopup(
79-
AuthProviderJsImpl provider,
80-
);
81-
external PromiseJsImpl<void> signInWithRedirect(AuthProviderJsImpl provider);
82255
external PromiseJsImpl<void> signOut();
83-
external PromiseJsImpl<void> useEmulator(String origin);
84256
external void useDeviceLanguage();
85-
external PromiseJsImpl<String> verifyPasswordResetCode(String code);
86257
}
87258

88259
@anonymous
@@ -119,68 +290,18 @@ abstract class UserJsImpl extends UserInfoJsImpl {
119290
external UserMetadata get metadata;
120291
external PromiseJsImpl<void> delete();
121292
external PromiseJsImpl<String> getIdToken([bool? opt_forceRefresh]);
122-
external PromiseJsImpl<UserCredentialJsImpl> linkWithCredential(
123-
OAuthCredential? credential,
124-
);
125-
external PromiseJsImpl<ConfirmationResultJsImpl> linkWithPhoneNumber(
126-
String phoneNumber,
127-
ApplicationVerifierJsImpl applicationVerifier,
128-
);
129-
external PromiseJsImpl<UserCredentialJsImpl> linkWithPopup(
130-
AuthProviderJsImpl provider,
131-
);
132-
external PromiseJsImpl<void> linkWithRedirect(AuthProviderJsImpl provider);
133-
134-
external PromiseJsImpl<UserCredentialJsImpl> reauthenticateWithCredential(
135-
OAuthCredential credential);
136-
external PromiseJsImpl<ConfirmationResultJsImpl>
137-
reauthenticateWithPhoneNumber(
138-
String phoneNumber,
139-
ApplicationVerifierJsImpl applicationVerifier,
140-
);
141-
external PromiseJsImpl<UserCredentialJsImpl> reauthenticateWithPopup(
142-
AuthProviderJsImpl provider,
143-
);
144-
external PromiseJsImpl<void> reauthenticateWithRedirect(
145-
AuthProviderJsImpl provider,
146-
);
293+
external PromiseJsImpl<IdTokenResultImpl> getIdTokenResult(
294+
[bool? opt_forceRefresh]);
147295
external PromiseJsImpl<void> reload();
148-
external PromiseJsImpl<void> sendEmailVerification([
149-
ActionCodeSettings? actionCodeSettings,
150-
]);
151-
external PromiseJsImpl<void> verifyBeforeUpdateEmail(
152-
String newEmail, [
153-
ActionCodeSettings? actionCodeSettings,
154-
]);
155-
external PromiseJsImpl<UserJsImpl> unlink(String providerId);
156-
external PromiseJsImpl<void> updateEmail(String newEmail);
157-
external PromiseJsImpl<void> updatePassword(String newPassword);
158-
external PromiseJsImpl<void> updatePhoneNumber(
159-
OAuthCredential? phoneCredential,
160-
);
161-
external PromiseJsImpl<void> updateProfile(UserProfile profile);
162-
external PromiseJsImpl<IdTokenResultImpl> getIdTokenResult([
163-
bool? forceRefresh,
164-
]);
165296
external Object toJSON();
166297
}
167298

168299
/// An enumeration of the possible persistence mechanism types.
169300
///
170301
/// See: <https://firebase.google.com/docs/reference/js/firebase.auth.Auth#.Persistence>
171-
@JS('Auth.Persistence')
302+
@JS('Persistence')
172303
class Persistence {
173-
/// Indicates that the state will be persisted even when the browser window
174-
/// is closed.
175-
external static String get LOCAL;
176-
177-
/// Indicates that the state will only be stored in memory and will be cleared
178-
/// when the window.
179-
external static String get NONE;
180-
181-
/// Indicates that the state will only persist in current session/tab,
182-
/// relevant to web only, and will be cleared when the tab is closed.
183-
external static String get SESSION;
304+
external String get type;
184305
}
185306

186307
/// Interface that represents the credentials returned by an auth provider.

0 commit comments

Comments
 (0)