@firebase-oss/ui-core 0.0.1 → 0.0.2-exp.ed61394

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -8,11 +8,43 @@ import { CountryCode } from 'libphonenumber-js';
8
8
  export { CountryCode } from 'libphonenumber-js';
9
9
  import * as z from 'zod';
10
10
 
11
+ /**
12
+ * Copyright 2025 Google LLC
13
+ *
14
+ * Licensed under the Apache License, Version 2.0 (the "License");
15
+ * you may not use this file except in compliance with the License.
16
+ * You may obtain a copy of the License at
17
+ *
18
+ * http://www.apache.org/licenses/LICENSE-2.0
19
+ *
20
+ * Unless required by applicable law or agreed to in writing, software
21
+ * distributed under the License is distributed on an "AS IS" BASIS,
22
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
+ * See the License for the specific language governing permissions and
24
+ * limitations under the License.
25
+ */
26
+
11
27
  type OnUpgradeCallback = (ui: FirebaseUI, oldUserId: string, credential: UserCredential) => Promise<void> | void;
12
28
  declare const autoUpgradeAnonymousCredentialHandler: (ui: FirebaseUI, credential: AuthCredential, onUpgrade?: OnUpgradeCallback) => Promise<UserCredential | undefined>;
13
29
  declare const autoUpgradeAnonymousProviderHandler: (ui: FirebaseUI, provider: AuthProvider, onUpgrade?: OnUpgradeCallback) => Promise<UserCredential | undefined>;
14
30
  declare const autoUpgradeAnonymousUserRedirectHandler: (ui: FirebaseUI, credential: UserCredential | null, onUpgrade?: OnUpgradeCallback) => Promise<void>;
15
31
 
32
+ /**
33
+ * Copyright 2025 Google LLC
34
+ *
35
+ * Licensed under the Apache License, Version 2.0 (the "License");
36
+ * you may not use this file except in compliance with the License.
37
+ * You may obtain a copy of the License at
38
+ *
39
+ * http://www.apache.org/licenses/LICENSE-2.0
40
+ *
41
+ * Unless required by applicable law or agreed to in writing, software
42
+ * distributed under the License is distributed on an "AS IS" BASIS,
43
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44
+ * See the License for the specific language governing permissions and
45
+ * limitations under the License.
46
+ */
47
+
16
48
  type CallableHandler<T extends (...args: any[]) => any = (...args: any[]) => any> = T;
17
49
  type InitHandler = (ui: FirebaseUI) => Promise<void> | void;
18
50
  type RedirectHandler = (ui: FirebaseUI, result: UserCredential | null) => Promise<void> | void;
@@ -29,17 +61,81 @@ type InitBehavior<T extends InitHandler = InitHandler> = {
29
61
  handler: T;
30
62
  };
31
63
 
64
+ /**
65
+ * Copyright 2025 Google LLC
66
+ *
67
+ * Licensed under the Apache License, Version 2.0 (the "License");
68
+ * you may not use this file except in compliance with the License.
69
+ * You may obtain a copy of the License at
70
+ *
71
+ * http://www.apache.org/licenses/LICENSE-2.0
72
+ *
73
+ * Unless required by applicable law or agreed to in writing, software
74
+ * distributed under the License is distributed on an "AS IS" BASIS,
75
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
76
+ * See the License for the specific language governing permissions and
77
+ * limitations under the License.
78
+ */
79
+
32
80
  declare const autoAnonymousLoginHandler: InitHandler;
33
81
 
82
+ /**
83
+ * Copyright 2025 Google LLC
84
+ *
85
+ * Licensed under the Apache License, Version 2.0 (the "License");
86
+ * you may not use this file except in compliance with the License.
87
+ * You may obtain a copy of the License at
88
+ *
89
+ * http://www.apache.org/licenses/LICENSE-2.0
90
+ *
91
+ * Unless required by applicable law or agreed to in writing, software
92
+ * distributed under the License is distributed on an "AS IS" BASIS,
93
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
94
+ * See the License for the specific language governing permissions and
95
+ * limitations under the License.
96
+ */
97
+
34
98
  type RecaptchaVerificationOptions$1 = {
35
99
  size?: "normal" | "invisible" | "compact";
36
100
  theme?: "light" | "dark";
37
101
  tabindex?: number;
38
102
  };
39
103
 
104
+ /**
105
+ * Copyright 2025 Google LLC
106
+ *
107
+ * Licensed under the Apache License, Version 2.0 (the "License");
108
+ * you may not use this file except in compliance with the License.
109
+ * You may obtain a copy of the License at
110
+ *
111
+ * http://www.apache.org/licenses/LICENSE-2.0
112
+ *
113
+ * Unless required by applicable law or agreed to in writing, software
114
+ * distributed under the License is distributed on an "AS IS" BASIS,
115
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
116
+ * See the License for the specific language governing permissions and
117
+ * limitations under the License.
118
+ */
119
+
40
120
  type ProviderSignInStrategyHandler = (ui: FirebaseUI, provider: AuthProvider) => Promise<never | UserCredential>;
41
121
  type ProviderLinkStrategyHandler = (ui: FirebaseUI, user: User, provider: AuthProvider) => Promise<never | UserCredential>;
42
122
 
123
+ /**
124
+ * Copyright 2025 Google LLC
125
+ *
126
+ * Licensed under the Apache License, Version 2.0 (the "License");
127
+ * you may not use this file except in compliance with the License.
128
+ * You may obtain a copy of the License at
129
+ *
130
+ * http://www.apache.org/licenses/LICENSE-2.0
131
+ *
132
+ * Unless required by applicable law or agreed to in writing, software
133
+ * distributed under the License is distributed on an "AS IS" BASIS,
134
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
135
+ * See the License for the specific language governing permissions and
136
+ * limitations under the License.
137
+ */
138
+
43
139
  type OneTapSignInOptions$1 = {
44
140
  clientId: IdConfiguration["client_id"];
45
141
  autoSelect?: IdConfiguration["auto_select"];
@@ -50,6 +146,22 @@ type OneTapSignInOptions$1 = {
50
146
  };
51
147
  declare const oneTapSignInHandler: (ui: FirebaseUI, options: OneTapSignInOptions$1) => Promise<void>;
52
148
 
149
+ /**
150
+ * Copyright 2025 Google LLC
151
+ *
152
+ * Licensed under the Apache License, Version 2.0 (the "License");
153
+ * you may not use this file except in compliance with the License.
154
+ * You may obtain a copy of the License at
155
+ *
156
+ * http://www.apache.org/licenses/LICENSE-2.0
157
+ *
158
+ * Unless required by applicable law or agreed to in writing, software
159
+ * distributed under the License is distributed on an "AS IS" BASIS,
160
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
161
+ * See the License for the specific language governing permissions and
162
+ * limitations under the License.
163
+ */
164
+
53
165
  declare const requireDisplayNameHandler: (_: FirebaseUI, user: User, displayName: string) => Promise<void>;
54
166
 
55
167
  /**
@@ -68,6 +180,9 @@ declare const requireDisplayNameHandler: (_: FirebaseUI, user: User, displayName
68
180
  * limitations under the License.
69
181
  */
70
182
 
183
+ /**
184
+ * An array of country data objects containing name, dial code, country code, and emoji for all supported countries.
185
+ */
71
186
  declare const countryData: [{
72
187
  readonly name: "Afghanistan";
73
188
  readonly dialCode: "+93";
@@ -1299,15 +1414,45 @@ declare const countryData: [{
1299
1414
  readonly code: "AX";
1300
1415
  readonly emoji: "🇦🇽";
1301
1416
  }];
1417
+ /**
1418
+ * A country data object containing name, dial code, country code, and emoji for a supported country.
1419
+ */
1302
1420
  type CountryData = {
1421
+ /** The name of the country. */
1303
1422
  name: string;
1423
+ /** The dial code of the country. */
1304
1424
  dialCode: string;
1425
+ /** The country code of the country. */
1305
1426
  code: CountryCode;
1427
+ /** The emoji of the country. */
1306
1428
  emoji: string;
1307
1429
  };
1308
1430
 
1431
+ /**
1432
+ * Formats a phone number according to the specified country data.
1433
+ *
1434
+ * @param phoneNumber - The phone number to format.
1435
+ * @param countryData - The country data to use for formatting.
1436
+ * @returns {string} The formatted phone number in E164 format.
1437
+ */
1309
1438
  declare function formatPhoneNumber(phoneNumber: string, countryData: CountryData): string;
1310
1439
 
1440
+ /**
1441
+ * Copyright 2025 Google LLC
1442
+ *
1443
+ * Licensed under the Apache License, Version 2.0 (the "License");
1444
+ * you may not use this file except in compliance with the License.
1445
+ * You may obtain a copy of the License at
1446
+ *
1447
+ * http://www.apache.org/licenses/LICENSE-2.0
1448
+ *
1449
+ * Unless required by applicable law or agreed to in writing, software
1450
+ * distributed under the License is distributed on an "AS IS" BASIS,
1451
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1452
+ * See the License for the specific language governing permissions and
1453
+ * limitations under the License.
1454
+ */
1455
+
1311
1456
  type CountryCodesOptions = {
1312
1457
  allowedCountries?: CountryCode[];
1313
1458
  defaultCountry?: CountryCode;
@@ -3777,6 +3922,22 @@ declare const countryCodesHandler: (options?: CountryCodesOptions) => {
3777
3922
  };
3778
3923
  };
3779
3924
 
3925
+ /**
3926
+ * Copyright 2025 Google LLC
3927
+ *
3928
+ * Licensed under the Apache License, Version 2.0 (the "License");
3929
+ * you may not use this file except in compliance with the License.
3930
+ * You may obtain a copy of the License at
3931
+ *
3932
+ * http://www.apache.org/licenses/LICENSE-2.0
3933
+ *
3934
+ * Unless required by applicable law or agreed to in writing, software
3935
+ * distributed under the License is distributed on an "AS IS" BASIS,
3936
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3937
+ * See the License for the specific language governing permissions and
3938
+ * limitations under the License.
3939
+ */
3940
+
3780
3941
  type Registry = {
3781
3942
  autoAnonymousLogin: InitBehavior<typeof autoAnonymousLoginHandler>;
3782
3943
  autoUpgradeAnonymousCredential: CallableBehavior<typeof autoUpgradeAnonymousCredentialHandler>;
@@ -3789,23 +3950,94 @@ type Registry = {
3789
3950
  requireDisplayName: CallableBehavior<typeof requireDisplayNameHandler>;
3790
3951
  countryCodes: CallableBehavior<typeof countryCodesHandler>;
3791
3952
  };
3953
+ /** A behavior or set of behaviors from the registry. */
3792
3954
  type Behavior<T extends keyof Registry = keyof Registry> = Pick<Registry, T>;
3955
+ /** All available behaviors, with each behavior being optional. */
3793
3956
  type Behaviors = Partial<Registry>;
3957
+ /**
3958
+ * Enables automatic anonymous login when the app initializes.
3959
+ *
3960
+ * @returns A behavior that automatically signs in users anonymously on app initialization.
3961
+ */
3794
3962
  declare function autoAnonymousLogin(): Behavior<"autoAnonymousLogin">;
3963
+ /** Options for the auto-upgrade anonymous users behavior. */
3795
3964
  type AutoUpgradeAnonymousUsersOptions = {
3965
+ /** Optional callback function that is called when an anonymous user is upgraded. */
3796
3966
  onUpgrade?: OnUpgradeCallback;
3797
3967
  };
3968
+ /**
3969
+ * Automatically upgrades anonymous users to regular users when they sign in with a credential or provider.
3970
+ *
3971
+ * This behavior handles upgrading anonymous users for credential-based sign-ins, provider-based sign-ins,
3972
+ * and redirect-based authentication flows.
3973
+ *
3974
+ * @param options - Optional configuration including an upgrade callback.
3975
+ * @returns Behaviors for automatically upgrading anonymous users.
3976
+ */
3798
3977
  declare function autoUpgradeAnonymousUsers(options?: AutoUpgradeAnonymousUsersOptions): Behavior<"autoUpgradeAnonymousCredential" | "autoUpgradeAnonymousProvider" | "autoUpgradeAnonymousUserRedirectHandler">;
3978
+ /** Options for reCAPTCHA verification behavior. */
3799
3979
  type RecaptchaVerificationOptions = RecaptchaVerificationOptions$1;
3980
+ /**
3981
+ * Configures reCAPTCHA verification for phone authentication.
3982
+ *
3983
+ * @param options - Optional reCAPTCHA verification options.
3984
+ * @returns A behavior that handles reCAPTCHA verification for phone authentication.
3985
+ */
3800
3986
  declare function recaptchaVerification(options?: RecaptchaVerificationOptions): Behavior<"recaptchaVerification">;
3987
+ /**
3988
+ * Configures provider authentication to use redirect strategy instead of popup.
3989
+ *
3990
+ * @returns Behaviors for provider sign-in and linking using redirect strategy.
3991
+ */
3801
3992
  declare function providerRedirectStrategy(): Behavior<"providerSignInStrategy" | "providerLinkStrategy">;
3993
+ /**
3994
+ * Configures provider authentication to use popup strategy instead of redirect.
3995
+ *
3996
+ * This is the default strategy for provider authentication.
3997
+ *
3998
+ * @returns Behaviors for provider sign-in and linking using popup strategy.
3999
+ */
3802
4000
  declare function providerPopupStrategy(): Behavior<"providerSignInStrategy" | "providerLinkStrategy">;
4001
+ /** Options for Google One Tap sign-in behavior. */
3803
4002
  type OneTapSignInOptions = OneTapSignInOptions$1;
4003
+ /**
4004
+ * Enables Google One Tap sign-in functionality.
4005
+ *
4006
+ * @param options - Configuration options for Google One Tap sign-in.
4007
+ * @returns A behavior that handles Google One Tap sign-in initialization.
4008
+ */
3804
4009
  declare function oneTapSignIn(options: OneTapSignInOptions): Behavior<"oneTapSignIn">;
4010
+ /**
4011
+ * Requires users to provide a display name when creating an account.
4012
+ *
4013
+ * @returns A behavior that enforces display name requirement during user registration.
4014
+ */
3805
4015
  declare function requireDisplayName(): Behavior<"requireDisplayName">;
4016
+ /**
4017
+ * Configures country code selection for phone number input.
4018
+ *
4019
+ * @param options - Optional configuration for country code behavior.
4020
+ * @returns A behavior that provides country code functionality for phone authentication.
4021
+ */
3806
4022
  declare function countryCodes(options?: CountryCodesOptions): Behavior<"countryCodes">;
4023
+ /**
4024
+ * Checks if a specific behavior is enabled for the given FirebaseUI instance.
4025
+ *
4026
+ * @param ui - The FirebaseUI instance.
4027
+ * @param key - The behavior key to check.
4028
+ * @returns True if the behavior is enabled, false otherwise.
4029
+ */
3807
4030
  declare function hasBehavior<T extends keyof Registry>(ui: FirebaseUI, key: T): boolean;
4031
+ /**
4032
+ * Gets the handler function for a specific behavior.
4033
+ *
4034
+ * @param ui - The FirebaseUI instance.
4035
+ * @param key - The behavior key to retrieve.
4036
+ * @returns The handler function for the specified behavior.
4037
+ * @throws {Error} Throws an error if the behavior is not found.
4038
+ */
3808
4039
  declare function getBehavior<T extends keyof Registry>(ui: FirebaseUI, key: T): Registry[T]["handler"];
4040
+ /** Default behaviors that are enabled by default for all FirebaseUI instances. */
3809
4041
  declare const defaultBehaviors: Behavior<"recaptchaVerification">;
3810
4042
 
3811
4043
  /**
@@ -3825,27 +4057,77 @@ declare const defaultBehaviors: Behavior<"recaptchaVerification">;
3825
4057
  */
3826
4058
  type FirebaseUIState = "idle" | "pending" | "loading";
3827
4059
 
4060
+ /**
4061
+ * Configuration options for initializing FirebaseUI.
4062
+ */
3828
4063
  type FirebaseUIOptions = {
4064
+ /** A required Firebase App instance, e.g. from `initializeApp`. */
3829
4065
  app: FirebaseApp;
4066
+ /** An optional Firebase Auth instance, e.g. from `getAuth`. If not provided, it will be created using the app instance. */
3830
4067
  auth?: Auth;
4068
+ /** A default locale to use. Defaults to `enUs`. */
3831
4069
  locale?: RegisteredLocale;
4070
+ /** An optional array of behaviors, e.g. from `requireDisplayName`. */
3832
4071
  behaviors?: Behavior<any>[];
3833
4072
  };
4073
+ /**
4074
+ * The main FirebaseUI instance that provides access to Firebase Auth and UI state management.
4075
+ *
4076
+ * This type encapsulates all the necessary components for managing authentication UI state,
4077
+ * including Firebase app and auth instances, locale settings, behaviors, and multi-factor
4078
+ * authentication state.
4079
+ */
3834
4080
  type FirebaseUI = {
4081
+ /** The Firebase App instance. */
3835
4082
  app: FirebaseApp;
4083
+ /** The Firebase Auth instance. */
3836
4084
  auth: Auth;
4085
+ /** Sets the locale for translations. */
3837
4086
  setLocale: (locale: RegisteredLocale) => void;
4087
+ /** The current UI state (e.g., "idle", "pending", "loading"). */
3838
4088
  state: FirebaseUIState;
4089
+ /** Sets the UI state. */
3839
4090
  setState: (state: FirebaseUIState) => void;
4091
+ /** The current locale for translations. */
3840
4092
  locale: RegisteredLocale;
4093
+ /** The configured behaviors that customize authentication flows. */
3841
4094
  behaviors: Behaviors;
4095
+ /** The multi-factor resolver, if a multi-factor challenge is in progress. */
3842
4096
  multiFactorResolver?: MultiFactorResolver;
4097
+ /** Sets the multi-factor resolver. */
3843
4098
  setMultiFactorResolver: (multiFactorResolver?: MultiFactorResolver) => void;
4099
+ /** Any error that occurred during a redirect-based authentication flow. */
3844
4100
  redirectError?: Error;
4101
+ /** Sets the redirect error. */
3845
4102
  setRedirectError: (error?: Error) => void;
3846
4103
  };
3847
4104
  declare const $config: nanostores.PreinitializedMapStore<Record<string, DeepMapStore<FirebaseUI>>> & object;
4105
+ /**
4106
+ * A reactive store containing a FirebaseUI instance.
4107
+ *
4108
+ * This store allows for reactive updates to the FirebaseUI state, enabling UI components
4109
+ * to automatically update when the authentication state or configuration changes.
4110
+ */
3848
4111
  type FirebaseUIStore = DeepMapStore<FirebaseUI>;
4112
+ /**
4113
+ * Initializes a FirebaseUI instance with the provided configuration.
4114
+ *
4115
+ * Creates a reactive store containing the FirebaseUI instance, sets up behaviors,
4116
+ * and handles initialization and redirect flows if running client-side.
4117
+ *
4118
+ * Example:
4119
+ * ```typescript
4120
+ * const ui = initializeUI({
4121
+ * app: firebaseApp,
4122
+ * locale: enUs,
4123
+ * behaviors: [requireDisplayName()],
4124
+ * });
4125
+ * ```
4126
+ *
4127
+ * @param config - The configuration options for FirebaseUI.
4128
+ * @param name - Optional name for the FirebaseUI instance. Defaults to "[DEFAULT]".
4129
+ * @returns {FirebaseUIStore} A reactive store containing the initialized FirebaseUI instance.
4130
+ */
3849
4131
  declare function initializeUI(config: FirebaseUIOptions, name?: string): FirebaseUIStore;
3850
4132
 
3851
4133
  /**
@@ -3864,21 +4146,166 @@ declare function initializeUI(config: FirebaseUIOptions, name?: string): Firebas
3864
4146
  * limitations under the License.
3865
4147
  */
3866
4148
 
4149
+ /**
4150
+ * Signs in with an email and password.
4151
+ *
4152
+ * If the `autoUpgradeAnonymousUsers` behavior is enabled, it will attempt to upgrade an anonymous user to a regular user.
4153
+ *
4154
+ * @param ui - The FirebaseUI instance.
4155
+ * @param email - The email to sign in with.
4156
+ * @param password - The password to sign in with.
4157
+ * @returns {Promise<UserCredential>} A promise containing the user credential.
4158
+ */
3867
4159
  declare function signInWithEmailAndPassword(ui: FirebaseUI, email: string, password: string): Promise<UserCredential>;
4160
+ /**
4161
+ * Creates a new user account with an email and password.
4162
+ *
4163
+ * If the `requireDisplayName` behavior is enabled, a display name must be provided.
4164
+ * If the `autoUpgradeAnonymousUsers` behavior is enabled, it will attempt to upgrade an anonymous user to a regular user.
4165
+ *
4166
+ * @param ui - The FirebaseUI instance.
4167
+ * @param email - The email address for the new account.
4168
+ * @param password - The password for the new account.
4169
+ * @param displayName - Optional display name for the user.
4170
+ * @returns {Promise<UserCredential>} A promise containing the user credential.
4171
+ */
3868
4172
  declare function createUserWithEmailAndPassword(ui: FirebaseUI, email: string, password: string, displayName?: string): Promise<UserCredential>;
4173
+ /**
4174
+ * Verifies a phone number for authentication.
4175
+ *
4176
+ * Supports regular phone authentication, MFA enrollment, and MFA assertion flows.
4177
+ *
4178
+ * @param ui - The FirebaseUI instance.
4179
+ * @param phoneNumber - The phone number to verify.
4180
+ * @param appVerifier - The application verifier (reCAPTCHA).
4181
+ * @param mfaUser - Optional multi-factor user for MFA enrollment flow.
4182
+ * @param mfaHint - Optional multi-factor info hint for MFA assertion flow.
4183
+ * @returns {Promise<string>} A promise containing the verification ID.
4184
+ */
3869
4185
  declare function verifyPhoneNumber(ui: FirebaseUI, phoneNumber: string, appVerifier: ApplicationVerifier, mfaUser?: MultiFactorUser, mfaHint?: MultiFactorInfo): Promise<string>;
4186
+ /**
4187
+ * Confirms a phone number verification code and signs in the user.
4188
+ *
4189
+ * If the `autoUpgradeAnonymousUsers` behavior is enabled and the current user is anonymous, it will attempt to upgrade the anonymous user to a regular user.
4190
+ *
4191
+ * @param ui - The FirebaseUI instance.
4192
+ * @param verificationId - The verification ID from the phone verification process.
4193
+ * @param verificationCode - The verification code sent to the phone.
4194
+ * @returns {Promise<UserCredential>} A promise containing the user credential.
4195
+ */
3870
4196
  declare function confirmPhoneNumber(ui: FirebaseUI, verificationId: string, verificationCode: string): Promise<UserCredential>;
4197
+ /**
4198
+ * Sends a password reset email to the specified email address.
4199
+ *
4200
+ * @param ui - The FirebaseUI instance.
4201
+ * @param email - The email address to send the password reset email to.
4202
+ * @returns {Promise<void>} A promise that resolves when the email is sent.
4203
+ */
3871
4204
  declare function sendPasswordResetEmail(ui: FirebaseUI, email: string): Promise<void>;
4205
+ /**
4206
+ * Sends a sign-in link to the specified email address.
4207
+ *
4208
+ * The email address is stored in localStorage for later use during the sign-in process.
4209
+ *
4210
+ * @param ui - The FirebaseUI instance.
4211
+ * @param email - The email address to send the sign-in link to.
4212
+ * @returns {Promise<void>} A promise that resolves when the email is sent.
4213
+ */
3872
4214
  declare function sendSignInLinkToEmail(ui: FirebaseUI, email: string): Promise<void>;
4215
+ /**
4216
+ * Signs in a user using an email link.
4217
+ *
4218
+ * @param ui - The FirebaseUI instance.
4219
+ * @param email - The email address associated with the sign-in link.
4220
+ * @param link - The sign-in link from the email.
4221
+ * @returns {Promise<UserCredential>} A promise containing the user credential.
4222
+ */
3873
4223
  declare function signInWithEmailLink(ui: FirebaseUI, email: string, link: string): Promise<UserCredential>;
4224
+ /**
4225
+ * Signs in a user with an authentication credential.
4226
+ *
4227
+ * If the `autoUpgradeAnonymousUsers` behavior is enabled, it will attempt to upgrade an anonymous user to a regular user.
4228
+ *
4229
+ * @param ui - The FirebaseUI instance.
4230
+ * @param credential - The authentication credential to sign in with.
4231
+ * @returns {Promise<UserCredential>} A promise containing the user credential.
4232
+ */
3874
4233
  declare function signInWithCredential(ui: FirebaseUI, credential: AuthCredential): Promise<UserCredential>;
4234
+ /**
4235
+ * Signs in a user with a custom token.
4236
+ *
4237
+ * @param ui - The FirebaseUI instance.
4238
+ * @param customToken - The custom token to sign in with.
4239
+ * @returns {Promise<UserCredential>} A promise containing the user credential.
4240
+ */
3875
4241
  declare function signInWithCustomToken(ui: FirebaseUI, customToken: string): Promise<UserCredential>;
4242
+ /**
4243
+ * Signs in a user anonymously.
4244
+ *
4245
+ * @param ui - The FirebaseUI instance.
4246
+ * @returns {Promise<UserCredential>} A promise containing the user credential.
4247
+ */
3876
4248
  declare function signInAnonymously(ui: FirebaseUI): Promise<UserCredential>;
4249
+ /**
4250
+ * Signs in a user with an authentication provider (e.g., Google, Facebook, etc.).
4251
+ *
4252
+ * If the `autoUpgradeAnonymousProvider` behavior is enabled, it will attempt to upgrade an anonymous user to a regular user.
4253
+ * The sign-in strategy (popup or redirect) is determined by the `providerSignInStrategy` behavior.
4254
+ *
4255
+ * @param ui - The FirebaseUI instance.
4256
+ * @param provider - The authentication provider to sign in with.
4257
+ * @returns {Promise<UserCredential | never>} A promise containing the user credential, or never if using redirect strategy.
4258
+ */
3877
4259
  declare function signInWithProvider(ui: FirebaseUI, provider: AuthProvider): Promise<UserCredential | never>;
4260
+ /**
4261
+ * Completes the email link sign-in process using the current URL.
4262
+ *
4263
+ * Checks if the current URL is a valid email link sign-in URL and retrieves the email from localStorage.
4264
+ * Returns null if the URL is not a valid email link or if no email is found in localStorage.
4265
+ *
4266
+ * @param ui - The FirebaseUI instance.
4267
+ * @param currentUrl - The current URL to check for email link sign-in.
4268
+ * @returns {Promise<UserCredential | null>} A promise containing the user credential, or null if the sign-in cannot be completed.
4269
+ */
3878
4270
  declare function completeEmailLinkSignIn(ui: FirebaseUI, currentUrl: string): Promise<UserCredential | null>;
4271
+ /**
4272
+ * Generates a QR code data URL for TOTP (Time-based One-Time Password) multi-factor authentication.
4273
+ *
4274
+ * The QR code can be scanned by an authenticator app to set up TOTP MFA for the user.
4275
+ *
4276
+ * @param ui - The FirebaseUI instance.
4277
+ * @param secret - The TOTP secret to generate the QR code for.
4278
+ * @param accountName - Optional account name for the QR code. Defaults to the user's email if not provided.
4279
+ * @param issuer - Optional issuer name for the QR code.
4280
+ * @returns {string} A data URL containing the QR code image.
4281
+ * @throws {Error} Throws an error if the user is not authenticated.
4282
+ */
3879
4283
  declare function generateTotpQrCode(ui: FirebaseUI, secret: TotpSecret, accountName?: string, issuer?: string): string;
3880
- declare function signInWithMultiFactorAssertion(ui: FirebaseUI, assertion: MultiFactorAssertion): Promise<UserCredential | undefined>;
4284
+ /**
4285
+ * Signs in a user using a multi-factor assertion.
4286
+ *
4287
+ * Resolves the multi-factor challenge using the provided assertion and clears the multi-factor resolver from the UI state.
4288
+ *
4289
+ * @param ui - The FirebaseUI instance.
4290
+ * @param assertion - The multi-factor assertion to use for sign-in.
4291
+ * @returns {Promise<UserCredential>} A promise containing the user credential.
4292
+ */
4293
+ declare function signInWithMultiFactorAssertion(ui: FirebaseUI, assertion: MultiFactorAssertion): Promise<UserCredential>;
4294
+ /**
4295
+ * Enrolls a multi-factor authentication method for the current user.
4296
+ *
4297
+ * @param ui - The FirebaseUI instance.
4298
+ * @param assertion - The multi-factor assertion to enroll.
4299
+ * @param displayName - Optional display name for the enrolled MFA method.
4300
+ * @returns {Promise<void>} A promise that resolves when the enrollment is complete.
4301
+ */
3881
4302
  declare function enrollWithMultiFactorAssertion(ui: FirebaseUI, assertion: MultiFactorAssertion, displayName?: string): Promise<void>;
4303
+ /**
4304
+ * Generates a TOTP (Time-based One-Time Password) secret for multi-factor authentication enrollment.
4305
+ *
4306
+ * @param ui - The FirebaseUI instance.
4307
+ * @returns {Promise<TotpSecret>} A promise containing the TOTP secret.
4308
+ */
3882
4309
  declare function generateTotpSecret(ui: FirebaseUI): Promise<TotpSecret>;
3883
4310
 
3884
4311
  /**
@@ -3897,11 +4324,48 @@ declare function generateTotpSecret(ui: FirebaseUI): Promise<TotpSecret>;
3897
4324
  * limitations under the License.
3898
4325
  */
3899
4326
 
4327
+ /**
4328
+ * A custom error class that extends FirebaseError and provides a translated error message based on the configured locale.
4329
+ */
3900
4330
  declare class FirebaseUIError extends FirebaseError {
3901
4331
  constructor(ui: FirebaseUI, error: FirebaseError);
3902
4332
  }
4333
+ /**
4334
+ * Handles a Firebase error and throws a FirebaseUIError if it is a Firebase error.
4335
+ *
4336
+ * Addtionally, handles the following error codes:
4337
+ * - auth/account-exists-with-different-credential - stores the credential in sessionStorage.
4338
+ * - auth/multi-factor-auth-required - updates the UI instance with the multi-factor resolver.
4339
+ *
4340
+ * @param ui - The FirebaseUI instance.
4341
+ * @param error - The error to handle.
4342
+ * @returns {never} A never type.
4343
+ */
3903
4344
  declare function handleFirebaseError(ui: FirebaseUI, error: unknown): never;
3904
4345
 
4346
+ /**
4347
+ * Copyright 2025 Google LLC
4348
+ *
4349
+ * Licensed under the Apache License, Version 2.0 (the "License");
4350
+ * you may not use this file except in compliance with the License.
4351
+ * You may obtain a copy of the License at
4352
+ *
4353
+ * http://www.apache.org/licenses/LICENSE-2.0
4354
+ *
4355
+ * Unless required by applicable law or agreed to in writing, software
4356
+ * distributed under the License is distributed on an "AS IS" BASIS,
4357
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4358
+ * See the License for the specific language governing permissions and
4359
+ * limitations under the License.
4360
+ */
4361
+ /**
4362
+ * Register a framework with the FirebaseUI configuration.
4363
+ * @internal
4364
+ * @param framework The type of framework being registered.
4365
+ * @param version The version of the framework being registered.
4366
+ */
4367
+ declare function registerFramework(framework: string, version: string): void;
4368
+
3905
4369
  /**
3906
4370
  * Copyright 2025 Google LLC
3907
4371
  *
@@ -3918,53 +4382,151 @@ declare function handleFirebaseError(ui: FirebaseUI, error: unknown): never;
3918
4382
  * limitations under the License.
3919
4383
  */
3920
4384
 
3921
- declare const LoginTypes: readonly ["email", "phone", "anonymous", "emailLink", "google"];
3922
- type LoginType = (typeof LoginTypes)[number];
3923
- type AuthMode = "signIn" | "signUp";
4385
+ /**
4386
+ * Creates a Zod schema for sign-in form validation.
4387
+ *
4388
+ * Validates email format and password minimum length (6 characters).
4389
+ *
4390
+ * @param ui - The FirebaseUI instance.
4391
+ * @returns A Zod schema for sign-in form validation.
4392
+ */
3924
4393
  declare function createSignInAuthFormSchema(ui: FirebaseUI): z.ZodObject<{
3925
4394
  email: z.ZodEmail;
3926
4395
  password: z.ZodString;
3927
4396
  }, z.core.$strip>;
4397
+ /**
4398
+ * Creates a Zod schema for sign-up form validation.
4399
+ *
4400
+ * Validates email format, password minimum length (6 characters), and optionally requires a display name
4401
+ * if the `requireDisplayName` behavior is enabled.
4402
+ *
4403
+ * @param ui - The FirebaseUI instance.
4404
+ * @returns A Zod schema for sign-up form validation.
4405
+ */
3928
4406
  declare function createSignUpAuthFormSchema(ui: FirebaseUI): z.ZodObject<{
3929
4407
  email: z.ZodEmail;
3930
4408
  password: z.ZodString;
3931
4409
  displayName: z.ZodString | z.ZodOptional<z.ZodString>;
3932
4410
  }, z.core.$strip>;
4411
+ /**
4412
+ * Creates a Zod schema for forgot password form validation.
4413
+ *
4414
+ * Validates email format.
4415
+ *
4416
+ * @param ui - The FirebaseUI instance.
4417
+ * @returns A Zod schema for forgot password form validation.
4418
+ */
3933
4419
  declare function createForgotPasswordAuthFormSchema(ui: FirebaseUI): z.ZodObject<{
3934
4420
  email: z.ZodEmail;
3935
4421
  }, z.core.$strip>;
4422
+ /**
4423
+ * Creates a Zod schema for email link authentication form validation.
4424
+ *
4425
+ * Validates email format.
4426
+ *
4427
+ * @param ui - The FirebaseUI instance.
4428
+ * @returns A Zod schema for email link authentication form validation.
4429
+ */
3936
4430
  declare function createEmailLinkAuthFormSchema(ui: FirebaseUI): z.ZodObject<{
3937
4431
  email: z.ZodEmail;
3938
4432
  }, z.core.$strip>;
4433
+ /**
4434
+ * Creates a Zod schema for phone number form validation.
4435
+ *
4436
+ * Validates that the phone number is provided and has a maximum length of 10 characters.
4437
+ *
4438
+ * @param ui - The FirebaseUI instance.
4439
+ * @returns A Zod schema for phone number form validation.
4440
+ */
3939
4441
  declare function createPhoneAuthNumberFormSchema(ui: FirebaseUI): z.ZodObject<{
3940
4442
  phoneNumber: z.ZodString;
3941
4443
  }, z.core.$strip>;
4444
+ /**
4445
+ * Creates a Zod schema for phone verification code form validation.
4446
+ *
4447
+ * Validates that the verification ID is provided and the verification code is at least 6 characters long.
4448
+ *
4449
+ * @param ui - The FirebaseUI instance.
4450
+ * @returns A Zod schema for phone verification form validation.
4451
+ */
3942
4452
  declare function createPhoneAuthVerifyFormSchema(ui: FirebaseUI): z.ZodObject<{
3943
4453
  verificationId: z.ZodString;
3944
4454
  verificationCode: z.ZodString;
3945
4455
  }, z.core.$strip>;
4456
+ /**
4457
+ * Creates a Zod schema for multi-factor phone authentication number form validation.
4458
+ *
4459
+ * Extends the phone number schema with a required display name field.
4460
+ *
4461
+ * @param ui - The FirebaseUI instance.
4462
+ * @returns A Zod schema for multi-factor phone authentication number form validation.
4463
+ */
3946
4464
  declare function createMultiFactorPhoneAuthNumberFormSchema(ui: FirebaseUI): z.ZodObject<{
3947
4465
  phoneNumber: z.ZodString;
3948
4466
  displayName: z.ZodString;
3949
4467
  }, z.core.$strip>;
4468
+ /**
4469
+ * Creates a Zod schema for multi-factor phone authentication assertion form validation.
4470
+ *
4471
+ * Uses the same validation as the phone number form schema.
4472
+ *
4473
+ * @param ui - The FirebaseUI instance.
4474
+ * @returns A Zod schema for multi-factor phone authentication assertion form validation.
4475
+ */
4476
+ declare function createMultiFactorPhoneAuthAssertionFormSchema(ui: FirebaseUI): z.ZodObject<{
4477
+ phoneNumber: z.ZodString;
4478
+ }, z.core.$strip>;
4479
+ /**
4480
+ * Creates a Zod schema for multi-factor phone authentication verification form validation.
4481
+ *
4482
+ * Uses the same validation as the phone verification form schema.
4483
+ *
4484
+ * @param ui - The FirebaseUI instance.
4485
+ * @returns A Zod schema for multi-factor phone authentication verification form validation.
4486
+ */
3950
4487
  declare function createMultiFactorPhoneAuthVerifyFormSchema(ui: FirebaseUI): z.ZodObject<{
3951
4488
  verificationId: z.ZodString;
3952
4489
  verificationCode: z.ZodString;
3953
4490
  }, z.core.$strip>;
4491
+ /**
4492
+ * Creates a Zod schema for multi-factor TOTP authentication number form validation.
4493
+ *
4494
+ * Validates that a display name is provided.
4495
+ *
4496
+ * @param ui - The FirebaseUI instance.
4497
+ * @returns A Zod schema for multi-factor TOTP authentication number form validation.
4498
+ */
3954
4499
  declare function createMultiFactorTotpAuthNumberFormSchema(ui: FirebaseUI): z.ZodObject<{
3955
4500
  displayName: z.ZodString;
3956
4501
  }, z.core.$strip>;
4502
+ /**
4503
+ * Creates a Zod schema for multi-factor TOTP authentication verification form validation.
4504
+ *
4505
+ * Validates that the verification code is exactly 6 characters long.
4506
+ *
4507
+ * @param ui - The FirebaseUI instance.
4508
+ * @returns A Zod schema for multi-factor TOTP authentication verification form validation.
4509
+ */
3957
4510
  declare function createMultiFactorTotpAuthVerifyFormSchema(ui: FirebaseUI): z.ZodObject<{
3958
4511
  verificationCode: z.ZodString;
3959
4512
  }, z.core.$strip>;
4513
+ /** The inferred type for the sign-in authentication form schema. */
3960
4514
  type SignInAuthFormSchema = z.infer<ReturnType<typeof createSignInAuthFormSchema>>;
4515
+ /** The inferred type for the sign-up authentication form schema. */
3961
4516
  type SignUpAuthFormSchema = z.infer<ReturnType<typeof createSignUpAuthFormSchema>>;
4517
+ /** The inferred type for the forgot password authentication form schema. */
3962
4518
  type ForgotPasswordAuthFormSchema = z.infer<ReturnType<typeof createForgotPasswordAuthFormSchema>>;
4519
+ /** The inferred type for the email link authentication form schema. */
3963
4520
  type EmailLinkAuthFormSchema = z.infer<ReturnType<typeof createEmailLinkAuthFormSchema>>;
4521
+ /** The inferred type for the phone authentication number form schema. */
3964
4522
  type PhoneAuthNumberFormSchema = z.infer<ReturnType<typeof createPhoneAuthNumberFormSchema>>;
4523
+ /** The inferred type for the phone authentication verification form schema. */
3965
4524
  type PhoneAuthVerifyFormSchema = z.infer<ReturnType<typeof createPhoneAuthVerifyFormSchema>>;
4525
+ /** The inferred type for the multi-factor phone authentication number form schema. */
3966
4526
  type MultiFactorPhoneAuthNumberFormSchema = z.infer<ReturnType<typeof createMultiFactorPhoneAuthNumberFormSchema>>;
4527
+ /** The inferred type for the multi-factor TOTP authentication number form schema. */
3967
4528
  type MultiFactorTotpAuthNumberFormSchema = z.infer<ReturnType<typeof createMultiFactorTotpAuthNumberFormSchema>>;
4529
+ /** The inferred type for the multi-factor TOTP authentication verification form schema. */
3968
4530
  type MultiFactorTotpAuthVerifyFormSchema = z.infer<ReturnType<typeof createMultiFactorTotpAuthVerifyFormSchema>>;
3969
4531
 
3970
4532
  /**
@@ -3983,14 +4545,20 @@ type MultiFactorTotpAuthVerifyFormSchema = z.infer<ReturnType<typeof createMulti
3983
4545
  * limitations under the License.
3984
4546
  */
3985
4547
 
3986
- declare function getTranslation<T extends TranslationCategory>(ui: FirebaseUI, category: T, key: TranslationKey<T>): string;
3987
-
3988
4548
  /**
3989
- * Register a framework with the FirebaseUI configuration.
3990
- * @internal
3991
- * @param framework The type of framework being registered.
3992
- * @param version The version of the framework being registered.
4549
+ * Gets a translated string for a given category and key.
4550
+ *
4551
+ * Example:
4552
+ * ```typescript
4553
+ * const translation = getTranslation(ui, "errors", "userNotFound");
4554
+ * ```
4555
+ *
4556
+ * @param ui - The FirebaseUI instance.
4557
+ * @param category - The translation category.
4558
+ * @param key - The translation key.
4559
+ * @param replacements - Optional replacements for placeholders.
4560
+ * @returns The translated string.
3993
4561
  */
3994
- declare function registerFramework(framework: string, version: string): void;
4562
+ declare function getTranslation<T extends TranslationCategory>(ui: FirebaseUI, category: T, key: TranslationKey<T>, replacements?: Record<string, string>): string;
3995
4563
 
3996
- export { $config, type AuthMode, type AutoUpgradeAnonymousUsersOptions, type Behavior, type Behaviors, type CountryData, type EmailLinkAuthFormSchema, type FirebaseUI, FirebaseUIError, type FirebaseUIOptions, type FirebaseUIStore, type ForgotPasswordAuthFormSchema, type LoginType, LoginTypes, type MultiFactorPhoneAuthNumberFormSchema, type MultiFactorTotpAuthNumberFormSchema, type MultiFactorTotpAuthVerifyFormSchema, type OneTapSignInOptions, type PhoneAuthNumberFormSchema, type PhoneAuthVerifyFormSchema, type RecaptchaVerificationOptions, type SignInAuthFormSchema, type SignUpAuthFormSchema, autoAnonymousLogin, autoUpgradeAnonymousUsers, completeEmailLinkSignIn, confirmPhoneNumber, countryCodes, countryData, createEmailLinkAuthFormSchema, createForgotPasswordAuthFormSchema, createMultiFactorPhoneAuthNumberFormSchema, createMultiFactorPhoneAuthVerifyFormSchema, createMultiFactorTotpAuthNumberFormSchema, createMultiFactorTotpAuthVerifyFormSchema, createPhoneAuthNumberFormSchema, createPhoneAuthVerifyFormSchema, createSignInAuthFormSchema, createSignUpAuthFormSchema, createUserWithEmailAndPassword, defaultBehaviors, enrollWithMultiFactorAssertion, formatPhoneNumber, generateTotpQrCode, generateTotpSecret, getBehavior, getTranslation, handleFirebaseError, hasBehavior, initializeUI, oneTapSignIn, providerPopupStrategy, providerRedirectStrategy, recaptchaVerification, registerFramework, requireDisplayName, sendPasswordResetEmail, sendSignInLinkToEmail, signInAnonymously, signInWithCredential, signInWithCustomToken, signInWithEmailAndPassword, signInWithEmailLink, signInWithMultiFactorAssertion, signInWithProvider, verifyPhoneNumber };
4564
+ export { $config, type AutoUpgradeAnonymousUsersOptions, type Behavior, type Behaviors, type CountryData, type EmailLinkAuthFormSchema, type FirebaseUI, FirebaseUIError, type FirebaseUIOptions, type FirebaseUIStore, type ForgotPasswordAuthFormSchema, type MultiFactorPhoneAuthNumberFormSchema, type MultiFactorTotpAuthNumberFormSchema, type MultiFactorTotpAuthVerifyFormSchema, type OneTapSignInOptions, type PhoneAuthNumberFormSchema, type PhoneAuthVerifyFormSchema, type RecaptchaVerificationOptions, type SignInAuthFormSchema, type SignUpAuthFormSchema, autoAnonymousLogin, autoUpgradeAnonymousUsers, completeEmailLinkSignIn, confirmPhoneNumber, countryCodes, countryData, createEmailLinkAuthFormSchema, createForgotPasswordAuthFormSchema, createMultiFactorPhoneAuthAssertionFormSchema, createMultiFactorPhoneAuthNumberFormSchema, createMultiFactorPhoneAuthVerifyFormSchema, createMultiFactorTotpAuthNumberFormSchema, createMultiFactorTotpAuthVerifyFormSchema, createPhoneAuthNumberFormSchema, createPhoneAuthVerifyFormSchema, createSignInAuthFormSchema, createSignUpAuthFormSchema, createUserWithEmailAndPassword, defaultBehaviors, enrollWithMultiFactorAssertion, formatPhoneNumber, generateTotpQrCode, generateTotpSecret, getBehavior, getTranslation, handleFirebaseError, hasBehavior, initializeUI, oneTapSignIn, providerPopupStrategy, providerRedirectStrategy, recaptchaVerification, registerFramework, requireDisplayName, sendPasswordResetEmail, sendSignInLinkToEmail, signInAnonymously, signInWithCredential, signInWithCustomToken, signInWithEmailAndPassword, signInWithEmailLink, signInWithMultiFactorAssertion, signInWithProvider, verifyPhoneNumber };