Skip to content

Commit 403046d

Browse files
committed
changeset and format
1 parent 89acb49 commit 403046d

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

.changeset/spicy-bags-sparkle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/app-check': patch
3+
---
4+
5+
Clear App Check exchange promise correctly after request succeeds.

packages/app-check/src/api.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ import {
2323
PartialObserver
2424
} from './public-types';
2525
import { ERROR_FACTORY, AppCheckError } from './errors';
26-
import { getState, setState, AppCheckState, getDebugState, setStateProperty } from './state';
26+
import {
27+
getState,
28+
setState,
29+
AppCheckState,
30+
getDebugState,
31+
setStateProperty
32+
} from './state';
2733
import { FirebaseApp, getApp, _getProvider } from '@firebase/app';
2834
import { getModularInstance, ErrorFn, NextFn } from '@firebase/util';
2935
import { AppCheckService } from './factory';

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,7 @@ describe('internal api', () => {
390390

391391
const getTokenPromise = getToken(appCheck as AppCheckService, true);
392392

393-
expect(getState(app).exchangeTokenPromise).to.be.instanceOf(
394-
Promise
395-
);
393+
expect(getState(app).exchangeTokenPromise).to.be.instanceOf(Promise);
396394

397395
await getTokenPromise;
398396

@@ -625,7 +623,7 @@ describe('internal api', () => {
625623
afterEach(async () => {
626624
clearState();
627625
});
628-
626+
629627
it('adds token listeners', async () => {
630628
const clock = useFakeTimers();
631629
const listener = (): void => {};

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export async function getToken(
129129
shouldCallListeners = true;
130130
}
131131
const tokenFromDebugExchange: AppCheckTokenInternal =
132-
// This was checked for above and assigned via setStateProperty()
132+
// This was checked for above and assigned via setStateProperty()
133133
await state.exchangeTokenPromise!;
134134
// Write debug token to indexedDB.
135135
await writeTokenToStorage(app, tokenFromDebugExchange);
@@ -221,7 +221,10 @@ export function addTokenListener(
221221
error: onError,
222222
type
223223
};
224-
setStateProperty(app, 'tokenObservers', [...state.tokenObservers, tokenObserver]);
224+
setStateProperty(app, 'tokenObservers', [
225+
...state.tokenObservers,
226+
tokenObserver
227+
]);
225228

226229
// Invoke the listener async immediately if there is a valid token
227230
// in memory.

0 commit comments

Comments
 (0)