Skip to content

Commit

Permalink
fix(auth, types): augment multi-factor auth types
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehardy committed Nov 5, 2022
1 parent cba9e53 commit 5f183c4
Showing 1 changed file with 37 additions and 5 deletions.
42 changes: 37 additions & 5 deletions packages/auth/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ export namespace FirebaseAuthTypes {
ERROR: 'error';
}

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface MultiFactorSession {
// this is has no documented contents, it is simply returned from some APIs and passed to others
}

export interface PhoneMultiFactorGenerator {
/**
* Identifies second factors of type phone.
Expand Down Expand Up @@ -417,6 +422,22 @@ export namespace FirebaseAuthTypes {
secret: string;
}

export interface PhoneMultiFactorEnrollInfoOptions {
phoneNumber: string;
session: MultiFactorSession;
}

export interface PhoneMultiFactorSignInInfoOptions {
multiFactorHint?: MultiFactorInfo;

/**
* Unused in react-native-firebase ipmlementation
*/
multiFactorUid?: string;

session: MultiFactorSession;
}

/**
* Facilitates the recovery when a user needs to provide a second factor to sign-in.
*/
Expand All @@ -428,12 +449,12 @@ export namespace FirebaseAuthTypes {
/**
* Serialized session this resolver belongs to.
*/
session: string;
session: MultiFactorSession;

/**
* For testing purposes only
*/
_auth: FirebaseAuthTypes.Module;
_auth?: FirebaseAuthTypes.Module;

/**
* Resolve the multi factor flow.
Expand Down Expand Up @@ -473,9 +494,9 @@ export namespace FirebaseAuthTypes {
enrolledFactors: MultiFactorInfo[];

/**
* Return the session id for this user.
* Return the session for this user.
*/
getSession(): Promise<string>;
getSession(): Promise<MultiFactorSession>;

/**
* Enroll an additional factor. Provide an optional display name that can be shown to the user.
Expand Down Expand Up @@ -1566,7 +1587,18 @@ export namespace FirebaseAuthTypes {
/**
* Obtain a verification id to complete the multi-factor sign-in flow.
*/
verifyPhoneNumberWithMultiFactorInfo(hint: MultiFactorInfo, session: string): Promise<string>;
verifyPhoneNumberWithMultiFactorInfo(
hint: MultiFactorInfo,
session: MultiFactorSession,
): Promise<string>;

/**
* Send an SMS to the user for verification of second factor
* @param phoneInfoOptions the phone number and session to use during enrollment
*/
verifyPhoneNumberForMultiFactor(
phoneInfoOptions: PhoneMultiFactorEnrollInfoOptions,
): Promise<string>;

/**
* Creates a new user with an email and password.
Expand Down

1 comment on commit 5f183c4

@vercel
Copy link

@vercel vercel bot commented on 5f183c4 Nov 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.