@@ -30,12 +30,9 @@ import {
30
30
TotpMultiFactorGenerator ,
31
31
TotpSecret
32
32
} from './totp' ;
33
- import { Auth , FactorId } from '../../model/public_types' ;
33
+ import { FactorId } from '../../model/public_types' ;
34
34
import { AuthErrorCode } from '../../core/errors' ;
35
- import { FirebaseApp , initializeApp } from '@firebase/app' ;
36
35
import { AppName } from '../../model/auth' ;
37
- import { getAuth } from '../../platform_node' ;
38
- import { initializeAuth } from '../../core' ;
39
36
import { _castAuth } from '../../core/auth/auth_impl' ;
40
37
41
38
use ( chaiAsPromised ) ;
@@ -58,7 +55,7 @@ describe('core/mfa/assertions/totp/TotpMultiFactorGenerator', () => {
58
55
auth = await testAuth ( ) ;
59
56
const secret = TotpSecret . fromStartTotpMfaEnrollmentResponse (
60
57
startEnrollmentResponse ,
61
- auth . name
58
+ auth
62
59
) ;
63
60
const assertion = TotpMultiFactorGenerator . assertionForEnrollment (
64
61
secret ,
@@ -156,7 +153,7 @@ describe('core/mfa/totp/assertions/TotpMultiFactorAssertionImpl', () => {
156
153
auth = await testAuth ( ) ;
157
154
secret = TotpSecret . fromStartTotpMfaEnrollmentResponse (
158
155
startEnrollmentResponse ,
159
- auth . name
156
+ auth ,
160
157
) ;
161
158
assertion = TotpMultiFactorAssertionImpl . _fromSecret ( secret , '123456' ) ;
162
159
} ) ;
@@ -213,7 +210,7 @@ describe('core/mfa/totp/assertions/TotpMultiFactorAssertionImpl', () => {
213
210
} ) ;
214
211
} ) ;
215
212
216
- describe ( 'core/mfa/assertions/totp/TotpSecret' , ( ) => {
213
+ describe ( 'core/mfa/assertions/totp/TotpSecret' , async ( ) => {
217
214
const serverResponse : StartTotpMfaEnrollmentResponse = {
218
215
totpSessionInfo : {
219
216
sharedSecretKey : 'key123' ,
@@ -224,11 +221,13 @@ describe('core/mfa/assertions/totp/TotpSecret', () => {
224
221
finalizeEnrollmentTime : 1662586196
225
222
}
226
223
} ;
224
+ // this is the name used by the fake app in testAuth().
227
225
const fakeAppName : AppName = 'test-app' ;
228
226
const fakeEmail : string = 'user@email' ;
227
+ let auth = await testAuth ( ) ;
229
228
const secret = TotpSecret . fromStartTotpMfaEnrollmentResponse (
230
229
serverResponse ,
231
- fakeAppName
230
+ auth ,
232
231
) ;
233
232
234
233
describe ( 'fromStartTotpMfaEnrollmentResponse' , ( ) => {
@@ -240,19 +239,8 @@ describe('core/mfa/assertions/totp/TotpSecret', () => {
240
239
} ) ;
241
240
} ) ;
242
241
describe ( 'generateQrCodeUrl' , ( ) => {
243
- let app : FirebaseApp ;
244
- let auth : Auth ;
245
242
246
243
beforeEach ( async ( ) => {
247
- app = initializeApp (
248
- {
249
- apiKey : 'fake-key' ,
250
- appId : 'fake-app-id' ,
251
- authDomain : 'fake-auth-domain'
252
- } ,
253
- fakeAppName
254
- ) ;
255
- auth = initializeAuth ( app ) ;
256
244
await auth . updateCurrentUser (
257
245
testUser ( _castAuth ( auth ) , 'uid' , fakeEmail , true )
258
246
) ;
@@ -266,8 +254,6 @@ describe('core/mfa/assertions/totp/TotpSecret', () => {
266
254
} ) ;
267
255
it ( 'only accountName provided' , ( ) => {
268
256
const url = secret . generateQrCodeUrl ( 'user@myawesomeapp' , '' ) ;
269
- const auth2 = getAuth ( app ) ;
270
- console . log ( 'Current user is ' + auth2 ) ;
271
257
expect ( url ) . to . eq (
272
258
`otpauth://totp/${ fakeAppName } :user@myawesomeapp?secret=key123&issuer=${ fakeAppName } &algorithm=SHA1&digits=6`
273
259
) ;
0 commit comments