Skip to content

Commit

Permalink
[Auth] Add missing PhoneMultiFactorInfo public interface (#5924)
Browse files Browse the repository at this point in the history
* Add missing PhoneMultiFactorInfo public interface

* Fix missing closing paren

* Changeset
  • Loading branch information
sam-gc committed Jan 25, 2022
1 parent 4983f4d commit e04b745
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/tame-timers-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@firebase/auth": patch
---

Add missing PhoneMultiFactorInfo public interface
5 changes: 5 additions & 0 deletions common/api-review/auth.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,11 @@ export class PhoneMultiFactorGenerator {
static FACTOR_ID: string;
}

// @public
export interface PhoneMultiFactorInfo extends MultiFactorInfo {
readonly phoneNumber: string;
}

// @public
export interface PhoneMultiFactorSignInInfoOptions {
multiFactorHint?: MultiFactorInfo;
Expand Down
10 changes: 5 additions & 5 deletions packages/auth/src/mfa/mfa_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { FactorId, MultiFactorInfo } from '../model/public_types';
import { FactorId, MultiFactorInfo, PhoneMultiFactorInfo } from '../model/public_types';
import {
PhoneMfaEnrollment,
MfaEnrollment
Expand All @@ -40,13 +40,13 @@ export abstract class MultiFactorInfoImpl implements MultiFactorInfo {
enrollment: MfaEnrollment
): MultiFactorInfoImpl {
if ('phoneInfo' in enrollment) {
return PhoneMultiFactorInfo._fromServerResponse(auth, enrollment);
return PhoneMultiFactorInfoImpl._fromServerResponse(auth, enrollment);
}
return _fail(auth, AuthErrorCode.INTERNAL_ERROR);
}
}

export class PhoneMultiFactorInfo extends MultiFactorInfoImpl {
export class PhoneMultiFactorInfoImpl extends MultiFactorInfoImpl implements PhoneMultiFactorInfo {
readonly phoneNumber: string;

private constructor(response: PhoneMfaEnrollment) {
Expand All @@ -57,7 +57,7 @@ export class PhoneMultiFactorInfo extends MultiFactorInfoImpl {
static _fromServerResponse(
_auth: AuthInternal,
enrollment: MfaEnrollment
): PhoneMultiFactorInfo {
return new PhoneMultiFactorInfo(enrollment);
): PhoneMultiFactorInfoImpl {
return new PhoneMultiFactorInfoImpl(enrollment);
}
}
9 changes: 9 additions & 0 deletions packages/auth/src/model/public_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,15 @@ export interface MultiFactorInfo {
readonly factorId: typeof FactorIdMap[keyof typeof FactorIdMap];
}

/**
* The subclass of the {@link MultiFactorInfo} interface for phone number
* second factors. The factorId of this second factor is {@link FactorId.PHONE}.
*/
export interface PhoneMultiFactorInfo extends MultiFactorInfo {
/** The phone number associated with the current second factor. */
readonly phoneNumber: string;
}

/**
* The class used to facilitate recovery from {@link MultiFactorError} when a user needs to
* provide a second factor to sign in.
Expand Down

0 comments on commit e04b745

Please sign in to comment.