From 6dedc0b95c6c201609b354aebe5f78189e5cbc1b Mon Sep 17 00:00:00 2001 From: Sam Olsen Date: Mon, 24 Jan 2022 14:40:33 -0800 Subject: [PATCH 1/3] Add missing PhoneMultiFactorInfo public interface --- common/api-review/auth.api.md | 5 +++++ packages/auth/src/mfa/mfa_info.ts | 10 +++++----- packages/auth/src/model/public_types.ts | 9 +++++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/common/api-review/auth.api.md b/common/api-review/auth.api.md index 5f8cb8ab6dc..354ab2b2ee8 100644 --- a/common/api-review/auth.api.md +++ b/common/api-review/auth.api.md @@ -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; diff --git a/packages/auth/src/mfa/mfa_info.ts b/packages/auth/src/mfa/mfa_info.ts index f89bcf990b4..f5d0beb7d37 100644 --- a/packages/auth/src/mfa/mfa_info.ts +++ b/packages/auth/src/mfa/mfa_info.ts @@ -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 @@ -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) { @@ -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); } } diff --git a/packages/auth/src/model/public_types.ts b/packages/auth/src/model/public_types.ts index 714c6a9da75..1510721dbc5 100644 --- a/packages/auth/src/model/public_types.ts +++ b/packages/auth/src/model/public_types.ts @@ -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. From 6692ec627736b1f118bcbdb977e94e06436457d2 Mon Sep 17 00:00:00 2001 From: Sam Olsen Date: Mon, 24 Jan 2022 14:42:02 -0800 Subject: [PATCH 2/3] Fix missing closing paren --- packages/auth/src/model/public_types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/auth/src/model/public_types.ts b/packages/auth/src/model/public_types.ts index 1510721dbc5..426aac426de 100644 --- a/packages/auth/src/model/public_types.ts +++ b/packages/auth/src/model/public_types.ts @@ -630,7 +630,7 @@ export interface MultiFactorInfo { /** * The subclass of the {@link MultiFactorInfo} interface for phone number - * second factors. The factorId of this second factor is {@link FactorId.PHONE. + * 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. */ From 867223b673684a62a0ee236de7d43f880c602aae Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 24 Jan 2022 14:42:39 -0800 Subject: [PATCH 3/3] Changeset --- .changeset/tame-timers-visit.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/tame-timers-visit.md diff --git a/.changeset/tame-timers-visit.md b/.changeset/tame-timers-visit.md new file mode 100644 index 00000000000..7618e58fb7a --- /dev/null +++ b/.changeset/tame-timers-visit.md @@ -0,0 +1,5 @@ +--- +"@firebase/auth": patch +--- + +Add missing PhoneMultiFactorInfo public interface