@@ -22,7 +22,7 @@ import { Auth, User } from '../../../src/model/public_types';
22
22
import { getAuth , connectAuthEmulator } from '../../../' ; // Use browser OR node dist entrypoint depending on test env.
23
23
import { _generateEventId } from '../../../src/core/util/event_id' ;
24
24
import { getAppConfig , getEmulatorUrl } from './settings' ;
25
- import { resetEmulator } from './emulator_rest_helpers' ;
25
+ import { getOobCodes , OobCodeSession , resetEmulator } from './emulator_rest_helpers' ;
26
26
import { StartTotpMfaEnrollmentResponse } from '../../../src/api/account_management/mfa' ;
27
27
28
28
//import * as otpauth from "https://deno.land/x/[email protected] /dist/otpauth.esm.js";
@@ -62,6 +62,8 @@ export function getTestInstance(requireEmulator = false): Auth {
62
62
63
63
auth . cleanUp = async ( ) => {
64
64
// If we're in an emulated environment, the emulator will clean up for us
65
+
66
+ console . log ( 'Auth cleanup should not be called' ) ;
65
67
if ( emulatorUrl ) {
66
68
await resetEmulator ( ) ;
67
69
} else {
@@ -83,7 +85,7 @@ export function getTestInstance(requireEmulator = false): Auth {
83
85
84
86
export async function cleanUpTestInstance ( auth : Auth ) : Promise < void > {
85
87
await auth . signOut ( ) ;
86
- await ( auth as IntegrationTestAuth ) . cleanUp ( ) ;
88
+ // await (auth as IntegrationTestAuth).cleanUp();
87
89
}
88
90
89
91
function stubConsoleToSilenceEmulatorWarnings ( ) : sinon . SinonStub {
@@ -99,17 +101,26 @@ function stubConsoleToSilenceEmulatorWarnings(): sinon.SinonStub {
99
101
} ) ;
100
102
}
101
103
102
- export async function mockTotp ( sharedSecretKey : string , periodSec : number , verificationCodeLength : number ) {
103
- console . log ( "**** starting to mock totp" ) ;
104
+ export async function code ( toEmail : string ) : Promise < OobCodeSession > {
105
+ const codes = await getOobCodes ( ) ;
106
+ console . log ( 'codes: ' , codes ) ;
107
+
108
+ return codes . reverse ( ) . find ( ( { email } ) => email === toEmail ) ! ;
109
+ }
104
110
105
- let digits = 9 ;
106
- let period = 30 ;
107
- let secret = "private" ;
108
- const headers = new Headers ( ) ;
111
+
112
+ export function getTotpCode ( sharedSecretKey : string , periodSec : number , verificationCodeLength : number , hashingAlgorithm : string ) {
113
+
114
+ let token = totp ( sharedSecretKey , { period : periodSec , digits : verificationCodeLength , algorithm : 'SHA-1' } ) ;
109
115
110
- let token = totp ( sharedSecretKey , { period : periodSec , digits : verificationCodeLength } ) ;
111
- console . log ( "***" + token ) ;
112
116
113
117
return token
114
118
119
+ }
120
+
121
+ export function delay ( dt :number ) {
122
+
123
+ console . log ( 'Delay called' ) ;
124
+
125
+ return new Promise ( resolve => setTimeout ( resolve , dt ) ) ;
115
126
}
0 commit comments