@@ -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 ,
@@ -90,9 +87,7 @@ describe('core/mfa/assertions/totp/TotpMultiFactorGenerator', () => {
90
87
'enrollment-id-token' ,
91
88
undefined
92
89
) ;
93
- await TotpMultiFactorGenerator . generateSecret (
94
- session
95
- ) ;
90
+ await TotpMultiFactorGenerator . generateSecret ( session ) ;
96
91
} catch ( e ) {
97
92
expect ( e . code ) . to . eql ( `auth/${ AuthErrorCode . INTERNAL_ERROR } ` ) ;
98
93
}
@@ -156,7 +151,7 @@ describe('core/mfa/totp/assertions/TotpMultiFactorAssertionImpl', () => {
156
151
auth = await testAuth ( ) ;
157
152
secret = TotpSecret . fromStartTotpMfaEnrollmentResponse (
158
153
startEnrollmentResponse ,
159
- auth . name
154
+ auth
160
155
) ;
161
156
assertion = TotpMultiFactorAssertionImpl . _fromSecret ( secret , '123456' ) ;
162
157
} ) ;
@@ -213,7 +208,7 @@ describe('core/mfa/totp/assertions/TotpMultiFactorAssertionImpl', () => {
213
208
} ) ;
214
209
} ) ;
215
210
216
- describe ( 'core/mfa/assertions/totp/TotpSecret' , ( ) => {
211
+ describe ( 'core/mfa/assertions/totp/TotpSecret' , async ( ) => {
217
212
const serverResponse : StartTotpMfaEnrollmentResponse = {
218
213
totpSessionInfo : {
219
214
sharedSecretKey : 'key123' ,
@@ -224,11 +219,13 @@ describe('core/mfa/assertions/totp/TotpSecret', () => {
224
219
finalizeEnrollmentTime : 1662586196
225
220
}
226
221
} ;
222
+ // this is the name used by the fake app in testAuth().
227
223
const fakeAppName : AppName = 'test-app' ;
228
224
const fakeEmail : string = 'user@email' ;
225
+ const auth = await testAuth ( ) ;
229
226
const secret = TotpSecret . fromStartTotpMfaEnrollmentResponse (
230
227
serverResponse ,
231
- fakeAppName
228
+ auth
232
229
) ;
233
230
234
231
describe ( 'fromStartTotpMfaEnrollmentResponse' , ( ) => {
@@ -240,19 +237,7 @@ describe('core/mfa/assertions/totp/TotpSecret', () => {
240
237
} ) ;
241
238
} ) ;
242
239
describe ( 'generateQrCodeUrl' , ( ) => {
243
- let app : FirebaseApp ;
244
- let auth : Auth ;
245
-
246
240
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
241
await auth . updateCurrentUser (
257
242
testUser ( _castAuth ( auth ) , 'uid' , fakeEmail , true )
258
243
) ;
@@ -266,8 +251,6 @@ describe('core/mfa/assertions/totp/TotpSecret', () => {
266
251
} ) ;
267
252
it ( 'only accountName provided' , ( ) => {
268
253
const url = secret . generateQrCodeUrl ( 'user@myawesomeapp' , '' ) ;
269
- const auth2 = getAuth ( app ) ;
270
- console . log ( 'Current user is ' + auth2 ) ;
271
254
expect ( url ) . to . eq (
272
255
`otpauth://totp/${ fakeAppName } :user@myawesomeapp?secret=key123&issuer=${ fakeAppName } &algorithm=SHA1&digits=6`
273
256
) ;
0 commit comments