Skip to content

Commit 938db7d

Browse files
committed
removing debug logs
1 parent 76be134 commit 938db7d

File tree

3 files changed

+13
-89
lines changed

3 files changed

+13
-89
lines changed

packages/auth/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@
118118
"rollup": "2.72.1",
119119
"rollup-plugin-sourcemaps": "0.6.3",
120120
"rollup-plugin-typescript2": "0.31.2",
121-
"typescript": "4.2.2"
121+
"typescript": "4.2.2",
122+
"totp-generator": "0.0.14"
122123
},
123124
"repository": {
124125
"directory": "packages/auth",

packages/auth/test/helpers/integration/helpers.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ export function getTestInstance(requireEmulator = false): Auth {
6262

6363
auth.cleanUp = async () => {
6464
// If we're in an emulated environment, the emulator will clean up for us
65-
66-
console.log('Auth cleanup should not be called');
6765
if (emulatorUrl) {
6866
await resetEmulator();
6967
} else {
@@ -107,8 +105,6 @@ function stubConsoleToSilenceEmulatorWarnings(): sinon.SinonStub {
107105

108106
export async function code(toEmail: string): Promise<OobCodeSession> {
109107
const codes = await getOobCodes();
110-
console.log('codes: ', codes);
111-
112108
return codes.reverse().find(({ email }) => email === toEmail)!;
113109
}
114110

@@ -124,8 +120,6 @@ return token
124120

125121
export function delay(dt:number){
126122

127-
console.log('Delay called');
128-
129123
return new Promise(resolve => setTimeout(resolve, dt));
130124
}
131125

packages/auth/test/integration/flows/totp.test.ts

Lines changed: 11 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,22 @@
1717

1818
import { expect, use } from 'chai';
1919
import chaiAsPromised from 'chai-as-promised';
20-
import * as sinon from 'sinon';
2120
import sinonChai from 'sinon-chai';
2221

2322
//import { mockTotp } from '../../helpers/integration/helpers';
24-
import {Auth, createUserWithEmailAndPassword, multiFactor, signInWithEmailAndPassword, UserCredential, sendEmailVerification, applyActionCode, getMultiFactorResolver} from '@firebase/auth';
23+
import {Auth, createUserWithEmailAndPassword, multiFactor, signInWithEmailAndPassword, UserCredential, getMultiFactorResolver} from '@firebase/auth';
2524
import { FirebaseError, getApp } from '@firebase/app';
2625
import {
2726
cleanUpTestInstance,
28-
code,
2927
getTestInstance,
3028
getTotpCode,
3129
delay,
32-
randomEmail,
33-
verifyEmail,
3430
email
3531
} from '../../helpers/integration/helpers';
3632
import { MultiFactorAssertionImpl } from '../../../src/mfa/mfa_assertion';
3733

38-
import { MultiFactorSessionImpl } from '../../../src/mfa/mfa_session';
3934
import { TotpMultiFactorGenerator, TotpSecret } from '../../../src/mfa/assertions/totp';
4035
import * as MFA from '../../../src/api/account_management/mfa';
41-
import { async } from '@firebase/util';
42-
import { UserCredentialImpl } from '../../../src/core/user/user_credential_impl';
43-
import { resolve } from 'dns';
44-
import { UserCredentialInternal } from '../../../internal';
45-
import { verify } from 'crypto';
4636

4737

4838

@@ -72,87 +62,45 @@ describe(' Integration tests: Mfa TOTP', () => {
7262

7363
it('should not enroll if incorrect totp supplied', async () => {
7464
let session;
75-
console.log(email);
76-
console.log('session info for: ', getApp().options.projectId);
77-
console.log('auth current User:', auth.currentUser);
78-
79-
await expect(createUserWithEmailAndPassword(auth, email, 'password')).to.be.rejectedWith('auth/email-already-in-use');
65+
//await expect(createUserWithEmailAndPassword(auth, email, 'password')).to.be.rejectedWith('auth/email-already-in-use');
8066

8167
const cr = await signInWithEmailAndPassword(auth, email, 'password');
82-
83-
console.log('signed In for totp');
8468
const mfaUser = multiFactor(cr.user);
85-
86-
console.log('session info for: ');
8769
session = await mfaUser.getSession();
88-
console.log(JSON.stringify(session));
89-
90-
9170
totpSecret = await TotpMultiFactorGenerator.generateSecret(
9271
session
9372
);
94-
95-
console.log("**** totpSecret****");
96-
console.log(totpSecret.secretKey);
97-
console.log(totpSecret.codeLength);
98-
console.log(totpSecret.codeIntervalSeconds);
99-
console.log(totpSecret.hashingAlgorithm);
100-
10173
const totpVerificationCode = getTotpCode(totpSecret.secretKey, totpSecret.codeIntervalSeconds, totpSecret.codeLength, totpSecret.hashingAlgorithm);
10274

10375
const multiFactorAssertion = TotpMultiFactorGenerator.assertionForEnrollment(
10476
totpSecret,
10577
totpVerificationCode + '0'
10678
);
10779

108-
console.log(totpVerificationCode);
10980
await expect(mfaUser.enroll(multiFactorAssertion, displayName)).to.be.rejectedWith('auth/invalid-verification-code');
11081
await auth.signOut();
11182
})
11283
it('should enroll using correct otp', async () => {
11384

11485
let session;
115-
console.log(email);
116-
console.log('session info for: ', getApp().options.projectId);
117-
console.log('auth current User:', auth.currentUser);
118-
await expect(createUserWithEmailAndPassword(auth, email, 'password')).to.be.rejectedWith('auth/email-already-in-use');
86+
//await expect(createUserWithEmailAndPassword(auth, email, 'password')).to.be.rejectedWith('auth/email-already-in-use');
11987
const cr = await signInWithEmailAndPassword(auth, email, 'password');
12088

121-
console.log('signed In for totp');
12289
const mfaUser = multiFactor(cr.user);
123-
124-
console.log('session info for: ');
125-
126-
90+
12791
session = await mfaUser.getSession();
12892

12993

130-
console.log('session');
131-
console.log(JSON.stringify(session));
132-
133-
13494
totpSecret = await TotpMultiFactorGenerator.generateSecret(
13595
session
13696
);
137-
138-
console.log("**** totpSecret****");
139-
140-
console.log(totpSecret.secretKey);
141-
console.log(totpSecret.codeLength);
142-
console.log(totpSecret.codeIntervalSeconds);
143-
console.log(totpSecret.hashingAlgorithm);
144-
145-
146-
14797

14898
const totpVerificationCode = getTotpCode(totpSecret.secretKey, totpSecret.codeIntervalSeconds, totpSecret.codeLength, totpSecret.hashingAlgorithm);
14999

150100
const multiFactorAssertion = TotpMultiFactorGenerator.assertionForEnrollment(
151101
totpSecret,
152102
totpVerificationCode
153103
);
154-
console.log(totpVerificationCode);
155-
156104
await expect(mfaUser.enroll(multiFactorAssertion, displayName)).to.be.fulfilled;
157105

158106
await auth.signOut();
@@ -163,38 +111,28 @@ describe(' Integration tests: Mfa TOTP', () => {
163111
let session;
164112
let cr;
165113
let resolver;
166-
console.log(email);
167-
console.log('session info for: ', getApp().options.projectId);
168-
await expect(createUserWithEmailAndPassword(auth, email, 'password')).to.be.rejectedWith('auth/email-already-in-use');
114+
//await expect(createUserWithEmailAndPassword(auth, email, 'password')).to.be.rejectedWith('auth/email-already-in-use');
169115
// Added a delay so that getTotpCode() actually generates a new totp code
170116
await delay(30*1000);
171117
try{
172118

173119
const userCredential = await signInWithEmailAndPassword(auth, email, 'password');
174120

175-
console.log('success: ', userCredential);
176-
177121
throw new Error('Signin should not have been successful');
178122

179123
} catch(error ){
180124

181125

182-
console.log('error occured: ', (error as any).code);
183126
expect((error as any).code).to.eql('auth/multi-factor-auth-required');
184127

185128
resolver = getMultiFactorResolver(auth,error as any);
186-
console.log(resolver.hints, totpSecret.secretKey);
187129
expect(resolver.hints).to.have.length(1);
188130

189131
const totpVerificationCode = getTotpCode(totpSecret.secretKey, totpSecret.codeIntervalSeconds, totpSecret.codeLength, totpSecret.hashingAlgorithm);
190-
console.log(totpVerificationCode, resolver.hints[0].uid )
191132
const assertion = TotpMultiFactorGenerator.assertionForSignIn(
192133
resolver.hints[0].uid,
193134
totpVerificationCode + '0'
194135
);
195-
196-
console.log(assertion);
197-
198136

199137
await expect(resolver.resolveSignIn(assertion)).to.be.rejectedWith('auth/invalid-verification-code');
200138

@@ -209,40 +147,31 @@ describe(' Integration tests: Mfa TOTP', () => {
209147

210148
let resolver;
211149

212-
console.log(email);
213-
console.log('session info for: ', getApp().options.projectId);
214-
215-
await expect(createUserWithEmailAndPassword(auth, email, 'password')).to.be.rejectedWith('auth/email-already-in-use');
216-
// Added a delay so that getTotpCode() actually generates a new totp code
217150
await delay(30*1000);
151+
152+
//await expect(createUserWithEmailAndPassword(auth, email, 'password')).to.be.rejectedWith('auth/email-already-in-use');
153+
// Added a delay so that getTotpCode() actually generates a new totp code
154+
218155
try{
219156

220157
const userCredential = await signInWithEmailAndPassword(auth, email, 'password');
221158

222-
console.log('success: ', userCredential);
223159

224160
throw new Error('Signin should not have been successful');
225161

226162
} catch(error ){
227163

228-
229-
console.log('error occured: ', (error as any).code);
164+
expect(error).to.be.an.instanceOf(FirebaseError);
230165
expect((error as any).code).to.eql('auth/multi-factor-auth-required');
231166

232167
resolver = getMultiFactorResolver(auth,error as any);
233-
console.log(resolver.hints, totpSecret.secretKey);
234168
expect(resolver.hints).to.have.length(1);
235169

236170
const totpVerificationCode = getTotpCode(totpSecret.secretKey, totpSecret.codeIntervalSeconds, totpSecret.codeLength, totpSecret.hashingAlgorithm);
237-
console.log(totpVerificationCode, resolver.hints[0].uid )
238171
const assertion = TotpMultiFactorGenerator.assertionForSignIn(
239172
resolver.hints[0].uid,
240173
totpVerificationCode
241-
);
242-
243-
console.log(assertion);
244-
245-
174+
);
246175
const userCredential = await resolver.resolveSignIn(assertion);
247176

248177
const mfaUser = multiFactor(userCredential.user);

0 commit comments

Comments
 (0)