Skip to content

Commit bdb0f02

Browse files
committed
addressed review comments.
1 parent 0c70e50 commit bdb0f02

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

packages/auth/src/api/account_management/mfa.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ describe('api/account_management/startEnrollPhoneMfa', () => {
9191

9292
await expect(startEnrollPhoneMfa(auth, request)).to.be.rejectedWith(
9393
FirebaseError,
94-
"Firebase: This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key. (auth/invalid-user-token)."
94+
'auth/invalid-user-token'
9595
);
9696
expect(mock.calls[0].request).to.eql(request);
9797
});
@@ -155,7 +155,7 @@ describe('api/account_management/finalizeEnrollPhoneMfa', () => {
155155

156156
await expect(finalizeEnrollPhoneMfa(auth, request)).to.be.rejectedWith(
157157
FirebaseError,
158-
'Firebase: The verification ID used to create the phone auth credential is invalid. (auth/invalid-verification-id).'
158+
'auth/invalid-verification-id'
159159
);
160160
expect(mock.calls[0].request).to.eql(request);
161161
});
@@ -225,7 +225,7 @@ describe('api/account_management/startEnrollTotpMfa', () => {
225225

226226
await expect(startEnrollTotpMfa(auth, request)).to.be.rejectedWith(
227227
FirebaseError,
228-
"Firebase: This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key. (auth/invalid-user-token)."
228+
'auth/invalid-user-token'
229229
);
230230
expect(mock.calls[0].request).to.eql(request);
231231
});

packages/auth/src/mfa/assertions/totp.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('core/mfa/assertions/totp/TotpMultiFactorGenerator', () => {
5353
describe('assertionForEnrollment', () => {
5454
it('should generate a valid TOTP assertion for enrollment', async () => {
5555
auth = await testAuth();
56-
const secret = TotpSecret.fromStartTotpMfaEnrollmentResponse(
56+
const secret = TotpSecret._fromStartTotpMfaEnrollmentResponse(
5757
startEnrollmentResponse,
5858
auth
5959
);
@@ -149,7 +149,7 @@ describe('core/mfa/totp/assertions/TotpMultiFactorAssertionImpl', () => {
149149
beforeEach(async () => {
150150
mockFetch.setUp();
151151
auth = await testAuth();
152-
secret = TotpSecret.fromStartTotpMfaEnrollmentResponse(
152+
secret = TotpSecret._fromStartTotpMfaEnrollmentResponse(
153153
startEnrollmentResponse,
154154
auth
155155
);
@@ -223,7 +223,7 @@ describe('core/mfa/assertions/totp/TotpSecret', async () => {
223223
const fakeAppName: AppName = 'test-app';
224224
const fakeEmail: string = 'user@email';
225225
const auth = await testAuth();
226-
const secret = TotpSecret.fromStartTotpMfaEnrollmentResponse(
226+
const secret = TotpSecret._fromStartTotpMfaEnrollmentResponse(
227227
serverResponse,
228228
auth
229229
);

packages/auth/src/mfa/assertions/totp.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export class TotpMultiFactorGenerator {
9595
idToken: mfaSession.credential,
9696
totpEnrollmentInfo: {}
9797
});
98-
return TotpSecret.fromStartTotpMfaEnrollmentResponse(
98+
return TotpSecret._fromStartTotpMfaEnrollmentResponse(
9999
response,
100100
mfaSession.auth
101101
);
@@ -119,25 +119,20 @@ export class TotpMultiFactorAssertionImpl
119119
super(FactorId.TOTP);
120120
}
121121

122+
/** @internal */
122123
static _fromSecret(
123124
secret: TotpSecret,
124125
otp: string
125126
): TotpMultiFactorAssertionImpl {
126-
return new TotpMultiFactorAssertionImpl(
127-
(otp = otp),
128-
undefined,
129-
(secret = secret)
130-
);
127+
return new TotpMultiFactorAssertionImpl(otp, undefined, secret);
131128
}
132129

130+
/** @internal */
133131
static _fromEnrollmentId(
134132
enrollmentId: string,
135133
otp: string
136134
): TotpMultiFactorAssertionImpl {
137-
return new TotpMultiFactorAssertionImpl(
138-
(otp = otp),
139-
(enrollmentId = enrollmentId)
140-
);
135+
return new TotpMultiFactorAssertionImpl(otp, enrollmentId);
141136
}
142137

143138
/** @internal */
@@ -154,7 +149,7 @@ export class TotpMultiFactorAssertionImpl
154149
return finalizeEnrollTotpMfa(auth, {
155150
idToken,
156151
displayName,
157-
totpVerificationInfo: this.secret.makeTotpVerificationInfo(this.otp)
152+
totpVerificationInfo: this.secret._makeTotpVerificationInfo(this.otp)
158153
});
159154
}
160155

@@ -194,7 +189,8 @@ export class TotpSecret {
194189
private readonly auth: AuthInternal
195190
) {}
196191

197-
static fromStartTotpMfaEnrollmentResponse(
192+
/** @internal */
193+
static _fromStartTotpMfaEnrollmentResponse(
198194
response: StartTotpMfaEnrollmentResponse,
199195
auth: AuthInternal
200196
): TotpSecret {
@@ -209,7 +205,8 @@ export class TotpSecret {
209205
);
210206
}
211207

212-
makeTotpVerificationInfo(otp: string): TotpVerificationInfo {
208+
/** @internal */
209+
_makeTotpVerificationInfo(otp: string): TotpVerificationInfo {
213210
return { sessionInfo: this.sessionInfo, verificationCode: otp };
214211
}
215212

@@ -240,6 +237,7 @@ export class TotpSecret {
240237
}
241238
}
242239

240+
/** @internal */
243241
function _isEmptyString(input?: string): boolean {
244242
return typeof input === 'undefined' || input?.length === 0;
245243
}

0 commit comments

Comments
 (0)