Skip to content

[Auth] Add missing PhoneMultiFactorInfo public interface #5924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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