Skip to content

Commit 5f183c4

Browse files
committed
fix(auth, types): augment multi-factor auth types
1 parent cba9e53 commit 5f183c4

File tree

1 file changed

+37
-5
lines changed

1 file changed

+37
-5
lines changed

packages/auth/lib/index.d.ts

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ export namespace FirebaseAuthTypes {
194194
ERROR: 'error';
195195
}
196196

197+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
198+
export interface MultiFactorSession {
199+
// this is has no documented contents, it is simply returned from some APIs and passed to others
200+
}
201+
197202
export interface PhoneMultiFactorGenerator {
198203
/**
199204
* Identifies second factors of type phone.
@@ -417,6 +422,22 @@ export namespace FirebaseAuthTypes {
417422
secret: string;
418423
}
419424

425+
export interface PhoneMultiFactorEnrollInfoOptions {
426+
phoneNumber: string;
427+
session: MultiFactorSession;
428+
}
429+
430+
export interface PhoneMultiFactorSignInInfoOptions {
431+
multiFactorHint?: MultiFactorInfo;
432+
433+
/**
434+
* Unused in react-native-firebase ipmlementation
435+
*/
436+
multiFactorUid?: string;
437+
438+
session: MultiFactorSession;
439+
}
440+
420441
/**
421442
* Facilitates the recovery when a user needs to provide a second factor to sign-in.
422443
*/
@@ -428,12 +449,12 @@ export namespace FirebaseAuthTypes {
428449
/**
429450
* Serialized session this resolver belongs to.
430451
*/
431-
session: string;
452+
session: MultiFactorSession;
432453

433454
/**
434455
* For testing purposes only
435456
*/
436-
_auth: FirebaseAuthTypes.Module;
457+
_auth?: FirebaseAuthTypes.Module;
437458

438459
/**
439460
* Resolve the multi factor flow.
@@ -473,9 +494,9 @@ export namespace FirebaseAuthTypes {
473494
enrolledFactors: MultiFactorInfo[];
474495

475496
/**
476-
* Return the session id for this user.
497+
* Return the session for this user.
477498
*/
478-
getSession(): Promise<string>;
499+
getSession(): Promise<MultiFactorSession>;
479500

480501
/**
481502
* Enroll an additional factor. Provide an optional display name that can be shown to the user.
@@ -1566,7 +1587,18 @@ export namespace FirebaseAuthTypes {
15661587
/**
15671588
* Obtain a verification id to complete the multi-factor sign-in flow.
15681589
*/
1569-
verifyPhoneNumberWithMultiFactorInfo(hint: MultiFactorInfo, session: string): Promise<string>;
1590+
verifyPhoneNumberWithMultiFactorInfo(
1591+
hint: MultiFactorInfo,
1592+
session: MultiFactorSession,
1593+
): Promise<string>;
1594+
1595+
/**
1596+
* Send an SMS to the user for verification of second factor
1597+
* @param phoneInfoOptions the phone number and session to use during enrollment
1598+
*/
1599+
verifyPhoneNumberForMultiFactor(
1600+
phoneInfoOptions: PhoneMultiFactorEnrollInfoOptions,
1601+
): Promise<string>;
15701602

15711603
/**
15721604
* Creates a new user with an email and password.

0 commit comments

Comments
 (0)