From d2fe2dcf943f284593f788e758b45989d37362fa Mon Sep 17 00:00:00 2001 From: russellwheatley Date: Mon, 10 Feb 2025 14:05:29 +0000 Subject: [PATCH 1/8] fix(auth): ensure all types are correct --- packages/auth/__tests__/auth.test.ts | 5 +++++ packages/auth/lib/modular/index.d.ts | 19 +++++++++++++++++-- packages/auth/lib/modular/index.js | 2 ++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/auth/__tests__/auth.test.ts b/packages/auth/__tests__/auth.test.ts index ccad2f6dd0..345d0d8d8c 100644 --- a/packages/auth/__tests__/auth.test.ts +++ b/packages/auth/__tests__/auth.test.ts @@ -58,6 +58,7 @@ import auth, { verifyBeforeUpdateEmail, getAdditionalUserInfo, getCustomAuthDomain, + FacebookAuthProvider, } from '../lib'; // @ts-ignore test @@ -408,6 +409,10 @@ describe('Auth', function () { expect(getCustomAuthDomain).toBeDefined(); }); + it('`FacebookAuthProvider` class is properly exposed to end user', function () { + expect(FacebookAuthProvider).toBeDefined(); + }); + describe('ActionCodeSettings', function () { beforeAll(function () { // @ts-ignore test diff --git a/packages/auth/lib/modular/index.d.ts b/packages/auth/lib/modular/index.d.ts index 19ec297625..c556a9e951 100644 --- a/packages/auth/lib/modular/index.d.ts +++ b/packages/auth/lib/modular/index.d.ts @@ -300,7 +300,7 @@ export function signInWithEmailLink( * Interface representing an application verifier. */ export interface ApplicationVerifier { - type: string; + readonly type: string; verify(): Promise; } @@ -315,7 +315,7 @@ export interface ApplicationVerifier { export function signInWithPhoneNumber( auth: Auth, phoneNumber: string, - appVerifier: ApplicationVerifier, + appVerifier?: ApplicationVerifier, ): Promise; /** @@ -662,3 +662,18 @@ export function getAdditionalUserInfo( * @returns A promise that resolves with the custom auth domain. */ export function getCustomAuthDomain(auth: Auth): Promise; + +export interface FacebookAuthProvider { + /** + * The provider ID of the provider. + */ + PROVIDER_ID: string; + /** + * Creates a new `AuthCredential`. + * + * @returns {@link auth.AuthCredential}. + * @param token A provider token. + * @param secret A provider secret. + */ + credential: (token: string | null, secret?: string) => AuthCredential; +} diff --git a/packages/auth/lib/modular/index.js b/packages/auth/lib/modular/index.js index 7b5aa9f9fe..e456ca16dc 100644 --- a/packages/auth/lib/modular/index.js +++ b/packages/auth/lib/modular/index.js @@ -16,6 +16,8 @@ */ import { getApp } from '@react-native-firebase/app'; +import FacebookAuthProvider from '../providers/FacebookAuthProvider'; +export { FacebookAuthProvider }; /** * @typedef {import('@firebase/app-types').FirebaseApp} FirebaseApp From d86bd7ad2efe11034285ffa1ad776326ad8b945e Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Tue, 11 Feb 2025 16:02:56 +0000 Subject: [PATCH 2/8] Definitions added with tests they are defined --- packages/auth/__tests__/auth.test.ts | 43 +++ packages/auth/lib/modular/index.d.ts | 310 +++++++++++++++++- packages/auth/lib/modular/index.js | 20 ++ .../lib/providers/FacebookAuthProvider.js | 2 +- packages/auth/type-test.ts | 5 +- 5 files changed, 364 insertions(+), 16 deletions(-) diff --git a/packages/auth/__tests__/auth.test.ts b/packages/auth/__tests__/auth.test.ts index 345d0d8d8c..36577e9c6b 100644 --- a/packages/auth/__tests__/auth.test.ts +++ b/packages/auth/__tests__/auth.test.ts @@ -2,6 +2,9 @@ import { afterAll, beforeAll, describe, expect, it, jest } from '@jest/globals'; import { FirebaseAuthTypes } from '../lib/index'; // @ts-ignore import User from '../lib/User'; +// @ts-ignore test +import FirebaseModule from '../../app/lib/internal/FirebaseModule'; + import auth, { firebase, getAuth, @@ -58,7 +61,15 @@ import auth, { verifyBeforeUpdateEmail, getAdditionalUserInfo, getCustomAuthDomain, + AppleAuthProvider, + EmailAuthProvider, FacebookAuthProvider, + GithubAuthProvider, + GoogleAuthProvider, + OAuthProvider, + OIDCAuthProvider, + PhoneAuthProvider, + TwitterAuthProvider, } from '../lib'; // @ts-ignore test @@ -409,10 +420,42 @@ describe('Auth', function () { expect(getCustomAuthDomain).toBeDefined(); }); + it('`AppleAuthProvider` class is properly exposed to end user', function () { + expect(AppleAuthProvider).toBeDefined(); + }); + + it('`EmailAuthProvider` class is properly exposed to end user', function () { + expect(EmailAuthProvider).toBeDefined(); + }); + it('`FacebookAuthProvider` class is properly exposed to end user', function () { expect(FacebookAuthProvider).toBeDefined(); }); + it('`GithubAuthProvider` class is properly exposed to end user', function () { + expect(GithubAuthProvider).toBeDefined(); + }); + + it('`GoogleAuthProvider` class is properly exposed to end user', function () { + expect(GoogleAuthProvider).toBeDefined(); + }); + + it('`OAuthProvider` class is properly exposed to end user', function () { + expect(OAuthProvider).toBeDefined(); + }); + + it('`OIDCProvider` class is properly exposed to end user', function () { + expect(OIDCAuthProvider).toBeDefined(); + }); + + it('`PhoneAuthProvider` class is properly exposed to end user', function () { + expect(PhoneAuthProvider).toBeDefined(); + }); + + it('`TwitterAuthProvider` class is properly exposed to end user', function () { + expect(TwitterAuthProvider).toBeDefined(); + }); + describe('ActionCodeSettings', function () { beforeAll(function () { // @ts-ignore test diff --git a/packages/auth/lib/modular/index.d.ts b/packages/auth/lib/modular/index.d.ts index c556a9e951..f684d80106 100644 --- a/packages/auth/lib/modular/index.d.ts +++ b/packages/auth/lib/modular/index.d.ts @@ -58,6 +58,8 @@ export function applyActionCode(auth: Auth, oobCode: string): Promise; * @param auth - The Auth instance. * @param callback - A callback function to run before the auth state changes. * @param onAbort - Optional. A callback function to run if the operation is aborted. + * + * */ export function beforeAuthStateChanged( auth: Auth, @@ -148,14 +150,21 @@ export function getMultiFactorResolver( * @param resolver - Optional. The popup redirect resolver. * @returns A promise that resolves with the user credentials or null. */ -// eslint-disable-next-line @typescript-eslint/no-empty-object-type -export interface PopupRedirectResolver {} - export function getRedirectResult( auth: Auth, resolver?: PopupRedirectResolver, ): Promise; +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +export interface PopupRedirectResolver {} + +/** FROM JS DOCS + * Loads the reCAPTCHA configuration into the Auth instance. + * Does not work in a Node.js environment + * @param auth - The Auth instance. + */ +export function initializeRecaptchaConfig(auth: Auth): Promise; + /** * Checks if an incoming link is a sign-in with email link suitable for signInWithEmailLink(). * @@ -189,6 +198,13 @@ export function onIdTokenChanged( nextOrObserver: CallbackOrObserver, ): () => void; +/** + * Revoke the given access token, Currently only supports Apple OAuth access tokens. + * @param auth + * @param token + */ +export declare function revokeAccessToken(auth: Auth, token: string): Promise; //TO DO: Add Support + /** * Sends a password reset email to the given email address. * @@ -208,13 +224,13 @@ export function sendPasswordResetEmail( * * @param auth - The Auth instance. * @param email - The user's email address. - * @param actionCodeSettings - Optional. Action code settings. + * @param actionCodeSettings - No longer optional from JS Docs. Action code settings. * @returns A promise that resolves when the email is sent. */ export function sendSignInLinkToEmail( auth: Auth, email: string, - actionCodeSettings?: FirebaseAuthTypes.ActionCodeSettings, + actionCodeSettings: FirebaseAuthTypes.ActionCodeSettings, ): Promise; /** @@ -309,12 +325,14 @@ export interface ApplicationVerifier { * * @param auth - The Auth instance. * @param phoneNumber - The user's phone number. + * @param forceResend - Forces a new message to be sent if it was already recently sent. * @param appVerifier - The application verifier. * @returns A promise that resolves with the confirmation result. */ export function signInWithPhoneNumber( auth: Auth, phoneNumber: string, + forceResend?: boolean, appVerifier?: ApplicationVerifier, ): Promise; @@ -360,7 +378,7 @@ export function signInWithRedirect( auth: Auth, provider: FirebaseAuthTypes.AuthProvider, resolver?: PopupRedirectResolver, -): Promise; +): Promise; // In JS Docs /** * Signs out the current user. @@ -377,7 +395,10 @@ export function signOut(auth: Auth): Promise; * @param user - The user to set as the current user. * @returns A promise that resolves when the user is set. */ -export function updateCurrentUser(auth: Auth, user: FirebaseAuthTypes.User): Promise; +export function updateCurrentUser( + auth: Auth, + user: FirebaseAuthTypes.User | null, // in JS Docs +): Promise; /** * Sets the current language to the default device/browser preference. @@ -386,6 +407,15 @@ export function updateCurrentUser(auth: Auth, user: FirebaseAuthTypes.User): Pro */ export function useDeviceLanguage(auth: Auth): void; +/** + * Validates the password against the password policy configured for the project or tenant. + * + * @param auth - The Auth instance. + * @param password - The password to validate. + * + */ +export function validatePassword(auth: Auth, password: string): Promise; //TO DO: ADD support. + /** * Sets the current language to the default device/browser preference. * @@ -464,7 +494,7 @@ export function linkWithCredential( export function linkWithPhoneNumber( user: FirebaseAuthTypes.User, phoneNumber: string, - appVerifier: ApplicationVerifier, + appVerifier?: ApplicationVerifier, // In JS Docs ): Promise; /** @@ -526,7 +556,7 @@ export function reauthenticateWithCredential( export function reauthenticateWithPhoneNumber( user: FirebaseAuthTypes.User, phoneNumber: string, - appVerifier: ApplicationVerifier, + appVerifier?: ApplicationVerifier, // in JS Docs ): Promise; /** @@ -642,7 +672,7 @@ export function updateProfile( export function verifyBeforeUpdateEmail( user: FirebaseAuthTypes.User, newEmail: string, - actionCodeSettings?: FirebaseAuthTypes.ActionCodeSettings, + actionCodeSettings?: FirebaseAuthTypes.ActionCodeSettings | null, ): Promise; /** @@ -663,17 +693,269 @@ export function getAdditionalUserInfo( */ export function getCustomAuthDomain(auth: Auth): Promise; -export interface FacebookAuthProvider { +/** + * Apple Authentication Provider. + * Not in JS Docs + * + */ +export class AppleAuthProvider { + APPLE_SIGN_IN_METHOD: string; + PROVIDER_ID: string; /** - * The provider ID of the provider. + * Creates a new `AuthCredential`. + * + * @returns {@link auth.AuthCredential}. + * @param token - A provider token. + * @param secret - A provider secret. */ + credential: (token: string | null, secret?: string) => AuthCredential; +} + +/** + * Apple Authentication Provider. + * Not in JS Docs + * + */ +export class EmailAuthProvider { + EMAIL_LINK_SIGN_IN_METHOD: string; + EMAIL_PASSWORD_SIGN_IN_METHOD: string; PROVIDER_ID: string; /** * Creates a new `AuthCredential`. * * @returns {@link auth.AuthCredential}. - * @param token A provider token. - * @param secret A provider secret. + * @param token - A provider token. + * @param secret - A provider secret. + */ + credential: (token: string, secret: string) => AuthCredential; + /** + * Initialize an AuthCredential using an email and + * an email link after a sign in with email link operation. + * + * @returns {@link auth.AuthCredential}. + * @param token - A provider token. + * @param secret - A provider secret. + */ + credentialWithlink: (token: string, secret: string) => AuthCredential; +} + +/** + * Facebook Authentication Provider. + * Defined as a class in JS Docs. + * + */ +export class FacebookAuthProvider { + FACEBOOK_SIGN_IN_METHOD: string; + PROVIDER_ID: string; + /** + * Creates a new `AuthCredential`. + * + * @returns {@link auth.AuthCredential}. + * @param token - A provider token. + * @param secret - A provider secret. */ credential: (token: string | null, secret?: string) => AuthCredential; + /** + * Used to extract the underlying OAuthCredential from a + * AuthError which was thrown during a sign-in, link, or reauthenticate operation. + * + * @returns {@link auth.AuthCredential or null}. + * @param error - A Firebase error. + */ + credentialFromError: (error: FirebaseAuthTypes.NativeFirebaseAuthError) => AuthCredential | null; + /** + * Used to extract the underlying OAuthCredential from a UserCredential. + * + * @returns {@link auth.AuthCredential or null}. + * @param userCredential - The user credential. + */ + credentialFromResult: (userCredential: FirebaseAuthTypes.UserCredential) => AuthCredential | null; } + +/** + * Github Authentication Provider. + * In JS Docs + * + */ +export class GithubAuthProvider { + GITHUB_SIGN_IN_METHOD: string; + PROVIDER_ID: string; + /** + * Creates a new `AuthCredential`. + * + * @returns {@link auth.AuthCredential}. + * @param token - A provider token. + * @param secret - A provider secret. + */ + credential: (token: string | null, secret?: string) => AuthCredential; +} + +/** + * Google Authentication Provider. + * In JS Docs + * + */ +export class GoogleAuthProvider { + GOOGLE_SIGN_IN_METHOD: string; + PROVIDER_ID: string; + /** + * Creates a new `AuthCredential`. + * + * @returns {@link auth.AuthCredential}. + * @param token - A provider token. + * @param secret - A provider secret. + */ + credential: (token: string | null, secret?: string) => AuthCredential; + /** + * Used to extract the underlying OAuthCredential from a + * AuthError which was thrown during a sign-in, link, or reauthenticate operation. + * + * @returns {@link auth.AuthCredential or null}. + * @param error - A Firebase error. + */ + credentialFromError: (error: FirebaseAuthTypes.NativeFirebaseAuthError) => AuthCredential | null; + /** + * Used to extract the underlying OAuthCredential from a UserCredential. + * + * @returns {@link auth.AuthCredential or null}. + * @param userCredential - The user credential. + */ + credentialFromResult: (userCredential: FirebaseAuthTypes.UserCredential) => AuthCredential | null; +} + +/** + * OAuth Authentication Provider. + * In JS Docs. + * + */ +export class OAuthProvider { + GITHUB_SIGN_IN_METHOD: string; + PROVIDER_ID: string; + /** + * Creates a new `AuthCredential`. + * + * @returns {@link auth.AuthCredential}. + * @param token - A provider token. + * @param secret - A provider secret. + */ + credential: (token: string | null, secret?: string) => AuthCredential; + /** + * Creates an OAuthCredential from a JSON string or a plain object. + * + * @returns {@link auth.AuthCredential or null}. + * @param error - A Firebase error. + */ + credentialFromJSON: (json: object | string) => AuthCredential; + /** + * Used to extract the underlying OAuthCredential from a + * AuthError which was thrown during a sign-in, link, or reauthenticate operation. + * + * @returns {@link auth.AuthCredential or null}. + * @param error - A Firebase error. + */ + credentialFromError: (error: FirebaseAuthTypes.NativeFirebaseAuthError) => AuthCredential | null; + /** + * Used to extract the underlying OAuthCredential from a UserCredential. + * + * @returns {@link auth.AuthCredential or null}. + * @param userCredential - The user credential. + */ + credentialFromResult: (userCredential: FirebaseAuthTypes.UserCredential) => AuthCredential | null; +} + +/** + * OIDC Authentication Provider. + * Not in JS Docs. + * + */ +export class OIDCAuthProvider { + OIDC_SIGN_IN_METHOD: string; + PROVIDER_ID: string; + /** + * Creates a new `AuthCredential`. + * + * @returns {@link auth.AuthCredential}. + * @param oidcSuffix - OIDC Suffix + * @param token - A provider token. + * @param secret - A provider secret. + */ + credential: (oidcSuffix: string, token: string | null, secret?: string) => AuthCredential; +} + +/** + * Phone Authentication Provider. + * Defined as a class in JS Docs. + * + */ +export class PhoneAuthProvider { + PHONE_SIGN_IN_METHOD: string; + PROVIDER_ID: string; + /** + * Creates a new `AuthCredential`. + * + * @returns {@link auth.AuthCredential}. + * @param token - A provider token. + * @param secret - A provider secret. + */ + credential: (token: string | null, secret?: string) => AuthCredential; + /** + * Used to extract the underlying OAuthCredential from a + * AuthError which was thrown during a sign-in, link, or reauthenticate operation. + * + * @returns {@link auth.AuthCredential or null}. + * @param error - A Firebase error. + */ + credentialFromError: (error: FirebaseAuthTypes.NativeFirebaseAuthError) => AuthCredential | null; + /** + * Used to extract the underlying OAuthCredential from a UserCredential. + * + * @returns {@link auth.AuthCredential or null}. + * @param userCredential - The user credential. + */ + credentialFromResult: (userCredential: FirebaseAuthTypes.UserCredential) => AuthCredential | null; + /** + * Used to extract the underlying OAuthCredential from a UserCredential. + * + * @returns {string}. A Promise for a verification ID that can be passed to + * PhoneAuthProvider.credential() to identify this flow. + * @param userCredential - The user credential. + */ + verifyPhoneNumber(phoneOptions: PhoneInfoOptions | string, applicationVerifier?: ApplicationVerifier): Promise; +} + +/** + * Twitter Authentication Provider. + * In JS Docs + * + */ +export class TwitterAuthProvider { + GOOGLE_SIGN_IN_METHOD: string; + PROVIDER_ID: string; + /** + * Creates a new `AuthCredential`. + * + * @returns {@link auth.AuthCredential}. + * @param token - A provider token. + * @param secret - A provider secret. + */ + credential: (token: string | null, secret?: string) => AuthCredential; + /** + * Used to extract the underlying OAuthCredential from a + * AuthError which was thrown during a sign-in, link, or reauthenticate operation. + * + * @returns {@link auth.AuthCredential or null}. + * @param error - A Firebase error. + */ + credentialFromError: (error: FirebaseAuthTypes.NativeFirebaseAuthError) => AuthCredential | null; + /** + * Used to extract the underlying OAuthCredential from a UserCredential. + * + * @returns {@link auth.AuthCredential or null}. + * @param userCredential - The user credential. + */ + credentialFromResult: (userCredential: FirebaseAuthTypes.UserCredential) => AuthCredential | null; +} + + + + diff --git a/packages/auth/lib/modular/index.js b/packages/auth/lib/modular/index.js index e456ca16dc..2d4d4e518e 100644 --- a/packages/auth/lib/modular/index.js +++ b/packages/auth/lib/modular/index.js @@ -189,6 +189,15 @@ export function onIdTokenChanged(auth, nextOrObserver) { return auth.onIdTokenChanged(nextOrObserver); } +/** + * Revoke the given access token, Currently only supports Apple OAuth access tokens. + * @param auth + * @param token + */ +export async function revokeAccessToken(auth, token){ + throw new Error('revokeAccessToken() is only supported on Web'); +} //TO DO: Add Support + /** * Sends a password reset email to the given email address. * @param {Auth} auth - The Auth instance. @@ -344,6 +353,17 @@ export function useDeviceLanguage(auth) { throw new Error('useDeviceLanguage is unsupported by the native Firebase SDKs'); } +/** + * Validates the password against the password policy configured for the project or tenant. + * + * @param auth - The Auth instance. + * @param password - The password to validate. + * + */ +export function validatePassword(auth, password){ + throw new Error('validatePassword is only supported on Web'); +}//TO DO: ADD support. + /** * Sets the current language to the default device/browser preference. * @param {Auth} auth - The Auth instance. diff --git a/packages/auth/lib/providers/FacebookAuthProvider.js b/packages/auth/lib/providers/FacebookAuthProvider.js index 50ae4d9bd5..577d20aec0 100644 --- a/packages/auth/lib/providers/FacebookAuthProvider.js +++ b/packages/auth/lib/providers/FacebookAuthProvider.js @@ -17,7 +17,7 @@ const providerId = 'facebook.com'; -export default class FacebookAuthProvider { +export default class FacebookAuthProvider{ constructor() { throw new Error('`new FacebookAuthProvider()` is not supported on the native Firebase SDKs.'); } diff --git a/packages/auth/type-test.ts b/packages/auth/type-test.ts index d8ea7cb688..c319839196 100644 --- a/packages/auth/type-test.ts +++ b/packages/auth/type-test.ts @@ -1,5 +1,5 @@ // import firebase from '@react-native-firebase/app'; -import firebase, { FirebaseAuthTypes } from '.'; +import firebase, { FirebaseAuthTypes, signInWithPhoneNumber } from '.'; console.log(firebase.default().currentUser); @@ -53,3 +53,6 @@ console.log(u ? u.toJSON() : ''); firebase.auth().signInAnonymously().then(); firebase.auth().signInWithEmailAndPassword('', '').then(); + +// Verify Modular API +signInWithPhoneNumber(firebase.auth(), '+1234567890'); From 47c76d07759921375fca80995108b70fc309f8ad Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Tue, 11 Feb 2025 16:35:19 +0000 Subject: [PATCH 3/8] formatting fixes --- packages/auth/lib/modular/index.d.ts | 46 ++++++++++++++-------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/packages/auth/lib/modular/index.d.ts b/packages/auth/lib/modular/index.d.ts index f684d80106..586e4de67e 100644 --- a/packages/auth/lib/modular/index.d.ts +++ b/packages/auth/lib/modular/index.d.ts @@ -689,7 +689,7 @@ export function getAdditionalUserInfo( * Returns the custom auth domain for the auth instance. * * @param auth - The Auth instance. - * @returns A promise that resolves with the custom auth domain. + * @returns {string} A promise that resolves with the custom auth domain. */ export function getCustomAuthDomain(auth: Auth): Promise; @@ -704,7 +704,7 @@ export class AppleAuthProvider { /** * Creates a new `AuthCredential`. * - * @returns {@link auth.AuthCredential}. + * @returns {@link auth.AuthCredential} * @param token - A provider token. * @param secret - A provider secret. */ @@ -723,7 +723,7 @@ export class EmailAuthProvider { /** * Creates a new `AuthCredential`. * - * @returns {@link auth.AuthCredential}. + * @returns {@link auth.AuthCredential} * @param token - A provider token. * @param secret - A provider secret. */ @@ -732,7 +732,7 @@ export class EmailAuthProvider { * Initialize an AuthCredential using an email and * an email link after a sign in with email link operation. * - * @returns {@link auth.AuthCredential}. + * @returns {@link auth.AuthCredential} * @param token - A provider token. * @param secret - A provider secret. */ @@ -750,7 +750,7 @@ export class FacebookAuthProvider { /** * Creates a new `AuthCredential`. * - * @returns {@link auth.AuthCredential}. + * @returns {@link auth.AuthCredential} * @param token - A provider token. * @param secret - A provider secret. */ @@ -759,14 +759,14 @@ export class FacebookAuthProvider { * Used to extract the underlying OAuthCredential from a * AuthError which was thrown during a sign-in, link, or reauthenticate operation. * - * @returns {@link auth.AuthCredential or null}. + * @returns {@link auth.AuthCredential or null} * @param error - A Firebase error. */ credentialFromError: (error: FirebaseAuthTypes.NativeFirebaseAuthError) => AuthCredential | null; /** * Used to extract the underlying OAuthCredential from a UserCredential. * - * @returns {@link auth.AuthCredential or null}. + * @returns {@link auth.AuthCredential or null} * @param userCredential - The user credential. */ credentialFromResult: (userCredential: FirebaseAuthTypes.UserCredential) => AuthCredential | null; @@ -783,7 +783,7 @@ export class GithubAuthProvider { /** * Creates a new `AuthCredential`. * - * @returns {@link auth.AuthCredential}. + * @returns {@link auth.AuthCredential} * @param token - A provider token. * @param secret - A provider secret. */ @@ -801,7 +801,7 @@ export class GoogleAuthProvider { /** * Creates a new `AuthCredential`. * - * @returns {@link auth.AuthCredential}. + * @returns {@link auth.AuthCredential} * @param token - A provider token. * @param secret - A provider secret. */ @@ -810,14 +810,14 @@ export class GoogleAuthProvider { * Used to extract the underlying OAuthCredential from a * AuthError which was thrown during a sign-in, link, or reauthenticate operation. * - * @returns {@link auth.AuthCredential or null}. + * @returns {@link auth.AuthCredential or null} * @param error - A Firebase error. */ credentialFromError: (error: FirebaseAuthTypes.NativeFirebaseAuthError) => AuthCredential | null; /** * Used to extract the underlying OAuthCredential from a UserCredential. * - * @returns {@link auth.AuthCredential or null}. + * @returns {@link auth.AuthCredential or null} * @param userCredential - The user credential. */ credentialFromResult: (userCredential: FirebaseAuthTypes.UserCredential) => AuthCredential | null; @@ -834,7 +834,7 @@ export class OAuthProvider { /** * Creates a new `AuthCredential`. * - * @returns {@link auth.AuthCredential}. + * @returns {@link auth.AuthCredential} * @param token - A provider token. * @param secret - A provider secret. */ @@ -842,7 +842,7 @@ export class OAuthProvider { /** * Creates an OAuthCredential from a JSON string or a plain object. * - * @returns {@link auth.AuthCredential or null}. + * @returns {@link auth.AuthCredential or null} * @param error - A Firebase error. */ credentialFromJSON: (json: object | string) => AuthCredential; @@ -850,14 +850,14 @@ export class OAuthProvider { * Used to extract the underlying OAuthCredential from a * AuthError which was thrown during a sign-in, link, or reauthenticate operation. * - * @returns {@link auth.AuthCredential or null}. + * @returns {@link auth.AuthCredential or null} * @param error - A Firebase error. */ credentialFromError: (error: FirebaseAuthTypes.NativeFirebaseAuthError) => AuthCredential | null; /** * Used to extract the underlying OAuthCredential from a UserCredential. * - * @returns {@link auth.AuthCredential or null}. + * @returns {@link auth.AuthCredential or null} * @param userCredential - The user credential. */ credentialFromResult: (userCredential: FirebaseAuthTypes.UserCredential) => AuthCredential | null; @@ -874,7 +874,7 @@ export class OIDCAuthProvider { /** * Creates a new `AuthCredential`. * - * @returns {@link auth.AuthCredential}. + * @returns {@link auth.AuthCredential} * @param oidcSuffix - OIDC Suffix * @param token - A provider token. * @param secret - A provider secret. @@ -893,7 +893,7 @@ export class PhoneAuthProvider { /** * Creates a new `AuthCredential`. * - * @returns {@link auth.AuthCredential}. + * @returns {@link auth.AuthCredential} * @param token - A provider token. * @param secret - A provider secret. */ @@ -902,21 +902,21 @@ export class PhoneAuthProvider { * Used to extract the underlying OAuthCredential from a * AuthError which was thrown during a sign-in, link, or reauthenticate operation. * - * @returns {@link auth.AuthCredential or null}. + * @returns {@link auth.AuthCredential or null} * @param error - A Firebase error. */ credentialFromError: (error: FirebaseAuthTypes.NativeFirebaseAuthError) => AuthCredential | null; /** * Used to extract the underlying OAuthCredential from a UserCredential. * - * @returns {@link auth.AuthCredential or null}. + * @returns {@link auth.AuthCredential or null} * @param userCredential - The user credential. */ credentialFromResult: (userCredential: FirebaseAuthTypes.UserCredential) => AuthCredential | null; /** * Used to extract the underlying OAuthCredential from a UserCredential. * - * @returns {string}. A Promise for a verification ID that can be passed to + * @returns {string} A Promise for a verification ID that can be passed to * PhoneAuthProvider.credential() to identify this flow. * @param userCredential - The user credential. */ @@ -934,7 +934,7 @@ export class TwitterAuthProvider { /** * Creates a new `AuthCredential`. * - * @returns {@link auth.AuthCredential}. + * @returns {@link auth.AuthCredential} * @param token - A provider token. * @param secret - A provider secret. */ @@ -943,14 +943,14 @@ export class TwitterAuthProvider { * Used to extract the underlying OAuthCredential from a * AuthError which was thrown during a sign-in, link, or reauthenticate operation. * - * @returns {@link auth.AuthCredential or null}. + * @returns {@link auth.AuthCredential or null} * @param error - A Firebase error. */ credentialFromError: (error: FirebaseAuthTypes.NativeFirebaseAuthError) => AuthCredential | null; /** * Used to extract the underlying OAuthCredential from a UserCredential. * - * @returns {@link auth.AuthCredential or null}. + * @returns {@link auth.AuthCredential or null} * @param userCredential - The user credential. */ credentialFromResult: (userCredential: FirebaseAuthTypes.UserCredential) => AuthCredential | null; From b8bce0ff3916d000813ded7002e505bf1fb189f4 Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Tue, 11 Feb 2025 17:21:04 +0000 Subject: [PATCH 4/8] fixed formatting --- packages/auth/lib/modular/index.d.ts | 53 +++++++++++++--------------- packages/auth/lib/modular/index.js | 16 ++++----- 2 files changed, 32 insertions(+), 37 deletions(-) diff --git a/packages/auth/lib/modular/index.d.ts b/packages/auth/lib/modular/index.d.ts index 586e4de67e..331091b5c3 100644 --- a/packages/auth/lib/modular/index.d.ts +++ b/packages/auth/lib/modular/index.d.ts @@ -59,7 +59,6 @@ export function applyActionCode(auth: Auth, oobCode: string): Promise; * @param callback - A callback function to run before the auth state changes. * @param onAbort - Optional. A callback function to run if the operation is aborted. * - * */ export function beforeAuthStateChanged( auth: Auth, @@ -158,7 +157,7 @@ export function getRedirectResult( // eslint-disable-next-line @typescript-eslint/no-empty-object-type export interface PopupRedirectResolver {} -/** FROM JS DOCS +/** * Loads the reCAPTCHA configuration into the Auth instance. * Does not work in a Node.js environment * @param auth - The Auth instance. @@ -203,7 +202,7 @@ export function onIdTokenChanged( * @param auth * @param token */ -export declare function revokeAccessToken(auth: Auth, token: string): Promise; //TO DO: Add Support +export declare function revokeAccessToken(auth: Auth, token: string): Promise; /** * Sends a password reset email to the given email address. @@ -224,7 +223,7 @@ export function sendPasswordResetEmail( * * @param auth - The Auth instance. * @param email - The user's email address. - * @param actionCodeSettings - No longer optional from JS Docs. Action code settings. + * @param actionCodeSettings - No longer optional, Action code settings. * @returns A promise that resolves when the email is sent. */ export function sendSignInLinkToEmail( @@ -378,7 +377,7 @@ export function signInWithRedirect( auth: Auth, provider: FirebaseAuthTypes.AuthProvider, resolver?: PopupRedirectResolver, -): Promise; // In JS Docs +): Promise; /** * Signs out the current user. @@ -395,10 +394,7 @@ export function signOut(auth: Auth): Promise; * @param user - The user to set as the current user. * @returns A promise that resolves when the user is set. */ -export function updateCurrentUser( - auth: Auth, - user: FirebaseAuthTypes.User | null, // in JS Docs -): Promise; +export function updateCurrentUser(auth: Auth, user: FirebaseAuthTypes.User | null): Promise; /** * Sets the current language to the default device/browser preference. @@ -414,7 +410,7 @@ export function useDeviceLanguage(auth: Auth): void; * @param password - The password to validate. * */ -export function validatePassword(auth: Auth, password: string): Promise; //TO DO: ADD support. +export function validatePassword(auth: Auth, password: string): Promise; /** * Sets the current language to the default device/browser preference. @@ -494,7 +490,7 @@ export function linkWithCredential( export function linkWithPhoneNumber( user: FirebaseAuthTypes.User, phoneNumber: string, - appVerifier?: ApplicationVerifier, // In JS Docs + appVerifier?: ApplicationVerifier, ): Promise; /** @@ -556,7 +552,7 @@ export function reauthenticateWithCredential( export function reauthenticateWithPhoneNumber( user: FirebaseAuthTypes.User, phoneNumber: string, - appVerifier?: ApplicationVerifier, // in JS Docs + appVerifier?: ApplicationVerifier, ): Promise; /** @@ -695,7 +691,7 @@ export function getCustomAuthDomain(auth: Auth): Promise; /** * Apple Authentication Provider. - * Not in JS Docs + * * */ export class AppleAuthProvider { @@ -713,7 +709,7 @@ export class AppleAuthProvider { /** * Apple Authentication Provider. - * Not in JS Docs + * * */ export class EmailAuthProvider { @@ -741,7 +737,7 @@ export class EmailAuthProvider { /** * Facebook Authentication Provider. - * Defined as a class in JS Docs. + * * */ export class FacebookAuthProvider { @@ -774,7 +770,7 @@ export class FacebookAuthProvider { /** * Github Authentication Provider. - * In JS Docs + * * */ export class GithubAuthProvider { @@ -792,7 +788,7 @@ export class GithubAuthProvider { /** * Google Authentication Provider. - * In JS Docs + * * */ export class GoogleAuthProvider { @@ -825,7 +821,7 @@ export class GoogleAuthProvider { /** * OAuth Authentication Provider. - * In JS Docs. + * * */ export class OAuthProvider { @@ -839,13 +835,13 @@ export class OAuthProvider { * @param secret - A provider secret. */ credential: (token: string | null, secret?: string) => AuthCredential; - /** + /** * Creates an OAuthCredential from a JSON string or a plain object. * * @returns {@link auth.AuthCredential or null} * @param error - A Firebase error. */ - credentialFromJSON: (json: object | string) => AuthCredential; + credentialFromJSON: (json: object | string) => AuthCredential; /** * Used to extract the underlying OAuthCredential from a * AuthError which was thrown during a sign-in, link, or reauthenticate operation. @@ -865,7 +861,7 @@ export class OAuthProvider { /** * OIDC Authentication Provider. - * Not in JS Docs. + * * */ export class OIDCAuthProvider { @@ -884,7 +880,7 @@ export class OIDCAuthProvider { /** * Phone Authentication Provider. - * Defined as a class in JS Docs. + * * */ export class PhoneAuthProvider { @@ -916,16 +912,19 @@ export class PhoneAuthProvider { /** * Used to extract the underlying OAuthCredential from a UserCredential. * - * @returns {string} A Promise for a verification ID that can be passed to + * @returns {string} A Promise for a verification ID that can be passed to * PhoneAuthProvider.credential() to identify this flow. * @param userCredential - The user credential. */ - verifyPhoneNumber(phoneOptions: PhoneInfoOptions | string, applicationVerifier?: ApplicationVerifier): Promise; + verifyPhoneNumber( + phoneOptions: PhoneInfoOptions | string, + applicationVerifier?: ApplicationVerifier, + ): Promise; } /** * Twitter Authentication Provider. - * In JS Docs + * * */ export class TwitterAuthProvider { @@ -955,7 +954,3 @@ export class TwitterAuthProvider { */ credentialFromResult: (userCredential: FirebaseAuthTypes.UserCredential) => AuthCredential | null; } - - - - diff --git a/packages/auth/lib/modular/index.js b/packages/auth/lib/modular/index.js index 2d4d4e518e..88ba375cac 100644 --- a/packages/auth/lib/modular/index.js +++ b/packages/auth/lib/modular/index.js @@ -191,10 +191,10 @@ export function onIdTokenChanged(auth, nextOrObserver) { /** * Revoke the given access token, Currently only supports Apple OAuth access tokens. - * @param auth - * @param token + * @param auth - The Auth Instance. + * @param token - The Access Token */ -export async function revokeAccessToken(auth, token){ +export async function revokeAccessToken(auth, token) { throw new Error('revokeAccessToken() is only supported on Web'); } //TO DO: Add Support @@ -354,15 +354,15 @@ export function useDeviceLanguage(auth) { } /** - * Validates the password against the password policy configured for the project or tenant. - * + * Validates the password against the password policy configured for the project or tenant. + * * @param auth - The Auth instance. * @param password - The password to validate. - * + * */ -export function validatePassword(auth, password){ +export function validatePassword(auth, password) { throw new Error('validatePassword is only supported on Web'); -}//TO DO: ADD support. +} //TO DO: ADD support. /** * Sets the current language to the default device/browser preference. From 3945f28187e853087ab73eaa59a7260ea3c2fd61 Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Tue, 11 Feb 2025 17:24:26 +0000 Subject: [PATCH 5/8] Undo potential breaking change' --- packages/auth/lib/modular/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/auth/lib/modular/index.d.ts b/packages/auth/lib/modular/index.d.ts index 331091b5c3..db46223315 100644 --- a/packages/auth/lib/modular/index.d.ts +++ b/packages/auth/lib/modular/index.d.ts @@ -223,13 +223,13 @@ export function sendPasswordResetEmail( * * @param auth - The Auth instance. * @param email - The user's email address. - * @param actionCodeSettings - No longer optional, Action code settings. + * @param actionCodeSettings - Optional, Action code settings. * @returns A promise that resolves when the email is sent. */ export function sendSignInLinkToEmail( auth: Auth, email: string, - actionCodeSettings: FirebaseAuthTypes.ActionCodeSettings, + actionCodeSettings?: FirebaseAuthTypes.ActionCodeSettings, ): Promise; /** From cb3f00fc2591e46b94e16527166428312315932d Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Tue, 11 Feb 2025 17:31:47 +0000 Subject: [PATCH 6/8] Last formatting fix --- packages/auth/lib/providers/FacebookAuthProvider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/auth/lib/providers/FacebookAuthProvider.js b/packages/auth/lib/providers/FacebookAuthProvider.js index 577d20aec0..50ae4d9bd5 100644 --- a/packages/auth/lib/providers/FacebookAuthProvider.js +++ b/packages/auth/lib/providers/FacebookAuthProvider.js @@ -17,7 +17,7 @@ const providerId = 'facebook.com'; -export default class FacebookAuthProvider{ +export default class FacebookAuthProvider { constructor() { throw new Error('`new FacebookAuthProvider()` is not supported on the native Firebase SDKs.'); } From 4ac4e31c08dd70e96e4e0cfa6ff86f1c7ae4ff2c Mon Sep 17 00:00:00 2001 From: MichaelVerdon Date: Tue, 11 Mar 2025 14:49:28 +0000 Subject: [PATCH 7/8] fix(auth): Exported from namespaced implementation. --- packages/auth/lib/modular/index.d.ts | 279 ++------------------------- 1 file changed, 15 insertions(+), 264 deletions(-) diff --git a/packages/auth/lib/modular/index.d.ts b/packages/auth/lib/modular/index.d.ts index db46223315..c19c84f24c 100644 --- a/packages/auth/lib/modular/index.d.ts +++ b/packages/auth/lib/modular/index.d.ts @@ -324,15 +324,15 @@ export interface ApplicationVerifier { * * @param auth - The Auth instance. * @param phoneNumber - The user's phone number. - * @param forceResend - Forces a new message to be sent if it was already recently sent. - * @param appVerifier - The application verifier. + * @param appVerifier - Optional. The application verifier. + * @param forceResend - Optional. (Native only) Forces a new message to be sent if it was already recently sent. * @returns A promise that resolves with the confirmation result. */ export function signInWithPhoneNumber( auth: Auth, phoneNumber: string, - forceResend?: boolean, appVerifier?: ApplicationVerifier, + forceResend?: boolean, ): Promise; /** @@ -690,267 +690,18 @@ export function getAdditionalUserInfo( export function getCustomAuthDomain(auth: Auth): Promise; /** - * Apple Authentication Provider. - * - * - */ -export class AppleAuthProvider { - APPLE_SIGN_IN_METHOD: string; - PROVIDER_ID: string; - /** - * Creates a new `AuthCredential`. - * - * @returns {@link auth.AuthCredential} - * @param token - A provider token. - * @param secret - A provider secret. - */ - credential: (token: string | null, secret?: string) => AuthCredential; -} - -/** - * Apple Authentication Provider. - * - * - */ -export class EmailAuthProvider { - EMAIL_LINK_SIGN_IN_METHOD: string; - EMAIL_PASSWORD_SIGN_IN_METHOD: string; - PROVIDER_ID: string; - /** - * Creates a new `AuthCredential`. - * - * @returns {@link auth.AuthCredential} - * @param token - A provider token. - * @param secret - A provider secret. - */ - credential: (token: string, secret: string) => AuthCredential; - /** - * Initialize an AuthCredential using an email and - * an email link after a sign in with email link operation. - * - * @returns {@link auth.AuthCredential} - * @param token - A provider token. - * @param secret - A provider secret. - */ - credentialWithlink: (token: string, secret: string) => AuthCredential; -} - -/** - * Facebook Authentication Provider. - * - * - */ -export class FacebookAuthProvider { - FACEBOOK_SIGN_IN_METHOD: string; - PROVIDER_ID: string; - /** - * Creates a new `AuthCredential`. - * - * @returns {@link auth.AuthCredential} - * @param token - A provider token. - * @param secret - A provider secret. - */ - credential: (token: string | null, secret?: string) => AuthCredential; - /** - * Used to extract the underlying OAuthCredential from a - * AuthError which was thrown during a sign-in, link, or reauthenticate operation. - * - * @returns {@link auth.AuthCredential or null} - * @param error - A Firebase error. - */ - credentialFromError: (error: FirebaseAuthTypes.NativeFirebaseAuthError) => AuthCredential | null; - /** - * Used to extract the underlying OAuthCredential from a UserCredential. - * - * @returns {@link auth.AuthCredential or null} - * @param userCredential - The user credential. - */ - credentialFromResult: (userCredential: FirebaseAuthTypes.UserCredential) => AuthCredential | null; -} - -/** - * Github Authentication Provider. - * - * - */ -export class GithubAuthProvider { - GITHUB_SIGN_IN_METHOD: string; - PROVIDER_ID: string; - /** - * Creates a new `AuthCredential`. - * - * @returns {@link auth.AuthCredential} - * @param token - A provider token. - * @param secret - A provider secret. - */ - credential: (token: string | null, secret?: string) => AuthCredential; -} - -/** - * Google Authentication Provider. - * - * - */ -export class GoogleAuthProvider { - GOOGLE_SIGN_IN_METHOD: string; - PROVIDER_ID: string; - /** - * Creates a new `AuthCredential`. - * - * @returns {@link auth.AuthCredential} - * @param token - A provider token. - * @param secret - A provider secret. - */ - credential: (token: string | null, secret?: string) => AuthCredential; - /** - * Used to extract the underlying OAuthCredential from a - * AuthError which was thrown during a sign-in, link, or reauthenticate operation. - * - * @returns {@link auth.AuthCredential or null} - * @param error - A Firebase error. - */ - credentialFromError: (error: FirebaseAuthTypes.NativeFirebaseAuthError) => AuthCredential | null; - /** - * Used to extract the underlying OAuthCredential from a UserCredential. - * - * @returns {@link auth.AuthCredential or null} - * @param userCredential - The user credential. - */ - credentialFromResult: (userCredential: FirebaseAuthTypes.UserCredential) => AuthCredential | null; -} - -/** - * OAuth Authentication Provider. - * - * - */ -export class OAuthProvider { - GITHUB_SIGN_IN_METHOD: string; - PROVIDER_ID: string; - /** - * Creates a new `AuthCredential`. - * - * @returns {@link auth.AuthCredential} - * @param token - A provider token. - * @param secret - A provider secret. - */ - credential: (token: string | null, secret?: string) => AuthCredential; - /** - * Creates an OAuthCredential from a JSON string or a plain object. - * - * @returns {@link auth.AuthCredential or null} - * @param error - A Firebase error. - */ - credentialFromJSON: (json: object | string) => AuthCredential; - /** - * Used to extract the underlying OAuthCredential from a - * AuthError which was thrown during a sign-in, link, or reauthenticate operation. - * - * @returns {@link auth.AuthCredential or null} - * @param error - A Firebase error. - */ - credentialFromError: (error: FirebaseAuthTypes.NativeFirebaseAuthError) => AuthCredential | null; - /** - * Used to extract the underlying OAuthCredential from a UserCredential. - * - * @returns {@link auth.AuthCredential or null} - * @param userCredential - The user credential. - */ - credentialFromResult: (userCredential: FirebaseAuthTypes.UserCredential) => AuthCredential | null; -} - -/** - * OIDC Authentication Provider. + * Various Providers. * * */ -export class OIDCAuthProvider { - OIDC_SIGN_IN_METHOD: string; - PROVIDER_ID: string; - /** - * Creates a new `AuthCredential`. - * - * @returns {@link auth.AuthCredential} - * @param oidcSuffix - OIDC Suffix - * @param token - A provider token. - * @param secret - A provider secret. - */ - credential: (oidcSuffix: string, token: string | null, secret?: string) => AuthCredential; -} - -/** - * Phone Authentication Provider. - * - * - */ -export class PhoneAuthProvider { - PHONE_SIGN_IN_METHOD: string; - PROVIDER_ID: string; - /** - * Creates a new `AuthCredential`. - * - * @returns {@link auth.AuthCredential} - * @param token - A provider token. - * @param secret - A provider secret. - */ - credential: (token: string | null, secret?: string) => AuthCredential; - /** - * Used to extract the underlying OAuthCredential from a - * AuthError which was thrown during a sign-in, link, or reauthenticate operation. - * - * @returns {@link auth.AuthCredential or null} - * @param error - A Firebase error. - */ - credentialFromError: (error: FirebaseAuthTypes.NativeFirebaseAuthError) => AuthCredential | null; - /** - * Used to extract the underlying OAuthCredential from a UserCredential. - * - * @returns {@link auth.AuthCredential or null} - * @param userCredential - The user credential. - */ - credentialFromResult: (userCredential: FirebaseAuthTypes.UserCredential) => AuthCredential | null; - /** - * Used to extract the underlying OAuthCredential from a UserCredential. - * - * @returns {string} A Promise for a verification ID that can be passed to - * PhoneAuthProvider.credential() to identify this flow. - * @param userCredential - The user credential. - */ - verifyPhoneNumber( - phoneOptions: PhoneInfoOptions | string, - applicationVerifier?: ApplicationVerifier, - ): Promise; -} - -/** - * Twitter Authentication Provider. - * - * - */ -export class TwitterAuthProvider { - GOOGLE_SIGN_IN_METHOD: string; - PROVIDER_ID: string; - /** - * Creates a new `AuthCredential`. - * - * @returns {@link auth.AuthCredential} - * @param token - A provider token. - * @param secret - A provider secret. - */ - credential: (token: string | null, secret?: string) => AuthCredential; - /** - * Used to extract the underlying OAuthCredential from a - * AuthError which was thrown during a sign-in, link, or reauthenticate operation. - * - * @returns {@link auth.AuthCredential or null} - * @param error - A Firebase error. - */ - credentialFromError: (error: FirebaseAuthTypes.NativeFirebaseAuthError) => AuthCredential | null; - /** - * Used to extract the underlying OAuthCredential from a UserCredential. - * - * @returns {@link auth.AuthCredential or null} - * @param userCredential - The user credential. - */ - credentialFromResult: (userCredential: FirebaseAuthTypes.UserCredential) => AuthCredential | null; -} +export { + AppleAuthProvider, + EmailAuthProvider, + FacebookAuthProvider, + GithubAuthProvider, + GoogleAuthProvider, + OAuthProvider, + OIDCAuthProvider, + PhoneAuthProvider, + TwitterAuthProvider, +} from '../index'; From 249b92be35d6daec125d2dd5d69c3e369d418b6b Mon Sep 17 00:00:00 2001 From: Mike Hardy Date: Sun, 23 Mar 2025 11:41:25 -0500 Subject: [PATCH 8/8] types: fix return type to be Promise until new arch sync is possible --- packages/auth/lib/modular/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/auth/lib/modular/index.d.ts b/packages/auth/lib/modular/index.d.ts index c19c84f24c..ee4cb6c58e 100644 --- a/packages/auth/lib/modular/index.d.ts +++ b/packages/auth/lib/modular/index.d.ts @@ -685,7 +685,7 @@ export function getAdditionalUserInfo( * Returns the custom auth domain for the auth instance. * * @param auth - The Auth instance. - * @returns {string} A promise that resolves with the custom auth domain. + * @returns {Promise} A promise that resolves with the custom auth domain. */ export function getCustomAuthDomain(auth: Auth): Promise;