Skip to content

Commit 0c329f7

Browse files
committed
Address PR comments
1 parent 76186e8 commit 0c329f7

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

packages/app-check/src/api.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
import '../test/setup';
1818
import { expect } from 'chai';
19-
import { match, spy, stub } from 'sinon';
19+
import { spy, stub } from 'sinon';
2020
import {
2121
setTokenAutoRefreshEnabled,
2222
initializeAppCheck,
@@ -128,7 +128,6 @@ describe('api', () => {
128128
};
129129
stub(indexeddb, 'writeDebugTokenToIndexedDB').callsFake(fakeWrite);
130130
stub(indexeddb, 'readDebugTokenFromIndexedDB').resolves(token);
131-
const logStub = stub(logger.logger, 'warn');
132131
const consoleStub = stub(console, 'log');
133132
self.FIREBASE_APPCHECK_DEBUG_TOKEN = true;
134133
initializeAppCheck(app, {
@@ -139,13 +138,11 @@ describe('api', () => {
139138
// written to indexedDB.
140139
expect(await getDebugToken()).to.equal(token);
141140
expect(consoleStub.args[0][0]).to.include(token);
142-
expect(logStub).to.be.calledWith(match('is in debug mode'));
143-
expect(logStub).to.be.calledWith(match(token));
144141
self.FIREBASE_APPCHECK_DEBUG_TOKEN = undefined;
145142
});
146143
it('warns about debug mode on second call', async () => {
147-
const logStub = stub(logger.logger, 'warn');
148144
self.FIREBASE_APPCHECK_DEBUG_TOKEN = 'abcdefg';
145+
const consoleStub = stub(console, 'log');
149146
initializeAppCheck(app, {
150147
provider: new ReCaptchaV3Provider(FAKE_SITE_KEY)
151148
});
@@ -154,7 +151,7 @@ describe('api', () => {
154151
});
155152
const token = await getDebugToken();
156153
expect(token).to.equal('abcdefg');
157-
expect(logStub).to.be.calledWith(match('abcdefg'));
154+
expect(consoleStub.args[0][0]).to.include(token);
158155
self.FIREBASE_APPCHECK_DEBUG_TOKEN = undefined;
159156
});
160157

packages/app-check/src/api.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ import {
3636
} from './internal-api';
3737
import { readTokenFromStorage } from './storage';
3838
import { getDebugToken, initializeDebugMode, isDebugMode } from './debug';
39-
import { logger } from './logger';
4039

4140
declare module '@firebase/component' {
4241
interface NameServiceMapping {
@@ -67,14 +66,13 @@ export function initializeAppCheck(
6766
// Log a warning when `initializeAppCheck()` is called in debug mode,
6867
// and show the token.
6968
if (isDebugMode()) {
70-
logger.warn(
71-
`App Check is in debug mode. To turn off debug mode, unset ` +
72-
`the global variable FIREBASE_APPCHECK_DEBUG_TOKEN and ` +
73-
`restart the app.`
69+
// Do not block initialization to get the token for the message.
70+
void getDebugToken().then(token =>
71+
// Not using logger because I don't think we ever want this accidentally hidden.
72+
console.log(
73+
`App Check debug token: ${token}. You will need to add it to your app's App Check settings in the Firebase console for it to work.`
74+
)
7475
);
75-
// Make this a separate console statement so user will at least have the
76-
// first message if the token promise doesn't resolve in time.
77-
void getDebugToken().then(token => logger.warn(`Debug token is ${token}.`));
7876
}
7977

8078
if (provider.isInitialized()) {

packages/app-check/src/storage.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ export async function readOrCreateDebugTokenFromStorage(): Promise<string> {
8787
writeDebugTokenToIndexedDB(newToken).catch(e =>
8888
logger.warn(`Failed to persist debug token to IndexedDB. Error: ${e}`)
8989
);
90-
// Not using logger because I don't think we ever want this accidentally hidden?
91-
console.log(
92-
`App Check debug token: ${newToken}. You will need to add it to your app's App Check settings in the Firebase console for it to work`
93-
);
9490
return newToken;
9591
} else {
9692
return existingDebugToken;

0 commit comments

Comments
 (0)