Skip to content

Commit 7003bd2

Browse files
authored
Merge pull request #18 from Code-Hex/fix/do-not-check-revoked-emulator
fixed the behavior of the validation method on the emulator
2 parents b63e1a8 + 805037a commit 7003bd2

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/auth.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class BaseAuth {
6363
const isEmulator = useEmulator(env);
6464
const decodedIdToken = await this.idTokenVerifier.verifyJWT(idToken, isEmulator);
6565
// Whether to check if the token was revoked.
66-
if (checkRevoked || isEmulator) {
66+
if (checkRevoked) {
6767
return await this.verifyDecodedJWTNotRevokedOrDisabled(decodedIdToken, AuthClientErrorCode.ID_TOKEN_REVOKED, env);
6868
}
6969
return decodedIdToken;
@@ -137,7 +137,7 @@ export class BaseAuth {
137137
const isEmulator = useEmulator(env);
138138
const decodedIdToken = await this.sessionCookieVerifier.verifyJWT(sessionCookie, isEmulator);
139139
// Whether to check if the token was revoked.
140-
if (checkRevoked || isEmulator) {
140+
if (checkRevoked) {
141141
return await this.verifyDecodedJWTNotRevokedOrDisabled(
142142
decodedIdToken,
143143
AuthClientErrorCode.SESSION_COOKIE_REVOKED,

tests/auth.test.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ describe('createSessionCookie()', () => {
7979

8080
await new Promise(resolve => setTimeout(() => resolve(auth.revokeRefreshTokens(uid2, env)), 1000));
8181

82-
// Check revocation is forced in emulator-mode and this should throw.
83-
await expect(auth.verifySessionCookie(sessionCookie, false, env)).rejects.toThrowError(
84-
new FirebaseAuthError(AuthClientErrorCode.SESSION_COOKIE_REVOKED)
85-
);
82+
await expect(auth.verifySessionCookie(sessionCookie, false, env)).resolves.toHaveProperty('uid', uid2);
8683

8784
await expect(auth.verifySessionCookie(sessionCookie, true, env)).rejects.toThrowError(
8885
new FirebaseAuthError(AuthClientErrorCode.SESSION_COOKIE_REVOKED)
@@ -166,10 +163,7 @@ describe('verifySessionCookie()', () => {
166163
expect(userRecord.uid).to.equal(uid);
167164
expect(userRecord.disabled).to.equal(true);
168165

169-
// If it is in emulator mode, a user-disabled error will be thrown.
170-
await expect(auth.verifySessionCookie(sessionCookie, false, env)).rejects.toThrowError(
171-
new FirebaseAuthError(AuthClientErrorCode.USER_DISABLED)
172-
);
166+
await expect(auth.verifySessionCookie(sessionCookie, false, env)).resolves.toHaveProperty('uid', uid);
173167

174168
await expect(auth.verifySessionCookie(sessionCookie, true, env)).rejects.toThrowError(
175169
new FirebaseAuthError(AuthClientErrorCode.USER_DISABLED)

0 commit comments

Comments
 (0)