Skip to content

Commit a1287dd

Browse files
Bump jsonwebtoken from 8.5.1 to 9.0.0 (#5410)
* Bump jsonwebtoken from 8.5.1 to 9.0.0 Bumps [jsonwebtoken](https://github.com/auth0/node-jsonwebtoken) from 8.5.1 to 9.0.0. - [Release notes](https://github.com/auth0/node-jsonwebtoken/releases) - [Changelog](https://github.com/auth0/node-jsonwebtoken/blob/master/CHANGELOG.md) - [Commits](auth0/node-jsonwebtoken@v8.5.1...v9.0.0) --- updated-dependencies: - dependency-name: jsonwebtoken dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * Use fake secret for jwt.sign() and fix tests Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Lisa Jian <[email protected]>
1 parent 127ca3f commit a1287dd

File tree

4 files changed

+138
-56
lines changed

4 files changed

+138
-56
lines changed

npm-shrinkwrap.json

Lines changed: 111 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
"google-auth-library": "^7.11.0",
121121
"inquirer": "^8.2.0",
122122
"js-yaml": "^3.13.1",
123-
"jsonwebtoken": "^8.5.1",
123+
"jsonwebtoken": "^9.0.0",
124124
"leven": "^3.1.0",
125125
"libsodium-wrappers": "^0.7.10",
126126
"lodash": "^4.17.21",

src/emulator/auth/operations.ts

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ function createSessionCookie(
669669
exp: expiresAt,
670670
iss: `https://session.firebase.google.com/${payload.aud}`,
671671
},
672-
"",
672+
"fake-secret",
673673
{
674674
// Generate a unsigned (insecure) JWT. Admin SDKs should treat this like
675675
// a real token (if in emulator mode). This won't work in production.
@@ -2391,18 +2391,26 @@ function generateJwt(
23912391
},
23922392
};
23932393

2394-
const jwtStr = signJwt(customPayloadFields, "", {
2395-
// Generate a unsigned (insecure) JWT. This is accepted by many other
2396-
// emulators (e.g. Cloud Firestore Emulator) but will not work in
2397-
// production of course. This removes the need to sign / verify tokens.
2398-
algorithm: "none",
2399-
expiresIn: expiresInSeconds,
2394+
const jwtStr = signJwt(
2395+
customPayloadFields,
2396+
// secretOrPrivateKey is required for jsonwebtoken v9, see
2397+
// https://github.com/auth0/node-jsonwebtoken/wiki/Migration-Notes:-v8-to-v9
2398+
// Tokens generated by the auth emulator are intentionally insecure and are
2399+
// not meant to be used in production. Thus, a fake secret is used here.
2400+
"fake-secret",
2401+
{
2402+
// Generate a unsigned (insecure) JWT. This is accepted by many other
2403+
// emulators (e.g. Cloud Firestore Emulator) but will not work in
2404+
// production of course. This removes the need to sign / verify tokens.
2405+
algorithm: "none",
2406+
expiresIn: expiresInSeconds,
24002407

2401-
subject: user.localId,
2402-
// TODO: Should this point to an emulator URL?
2403-
issuer: `https://securetoken.google.com/${projectId}`,
2404-
audience: projectId,
2405-
});
2408+
subject: user.localId,
2409+
// TODO: Should this point to an emulator URL?
2410+
issuer: `https://securetoken.google.com/${projectId}`,
2411+
audience: projectId,
2412+
}
2413+
);
24062414
return jwtStr;
24072415
}
24082416

@@ -3245,7 +3253,7 @@ function generateBlockingFunctionJwt(
32453253
jwt.oauth_refresh_token = oauthTokens.oauthRefreshToken;
32463254
}
32473255

3248-
const jwtStr = signJwt(jwt, "", {
3256+
const jwtStr = signJwt(jwt, "fake-secret", {
32493257
algorithm: "none",
32503258
});
32513259

src/test/emulators/auth/customToken.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describeAuthEmulator("sign-in with custom token", ({ authApi }) => {
1515
it("should create new account from custom token (unsigned)", async () => {
1616
const uid = "someuid";
1717
const claims = { abc: "def", ultimate: { answer: 42 } };
18-
const token = signJwt({ uid, claims }, "", {
18+
const token = signJwt({ uid, claims }, "fake-secret", {
1919
algorithm: "none",
2020
expiresIn: 3600,
2121

@@ -149,7 +149,7 @@ describeAuthEmulator("sign-in with custom token", ({ authApi }) => {
149149
});
150150

151151
it("should error if custom token addresses the wrong audience", async () => {
152-
const token = signJwt({ uid: "foo" }, "", {
152+
const token = signJwt({ uid: "foo" }, "fake-secret", {
153153
algorithm: "none",
154154
expiresIn: 3600,
155155

@@ -173,7 +173,7 @@ describeAuthEmulator("sign-in with custom token", ({ authApi }) => {
173173
{
174174
/* no uid */
175175
},
176-
"",
176+
"fake-secret",
177177
{
178178
algorithm: "none",
179179
expiresIn: 3600,
@@ -252,7 +252,7 @@ describeAuthEmulator("sign-in with custom token", ({ authApi }) => {
252252
const tenant = await registerTenant(authApi(), PROJECT_ID, { disableAuth: false });
253253
const uid = "someuid";
254254
const claims = { abc: "def", ultimate: { answer: 42 } };
255-
const token = signJwt({ uid, claims, tenant_id: "not-matching-tenant-id" }, "", {
255+
const token = signJwt({ uid, claims, tenant_id: "not-matching-tenant-id" }, "fake-secret", {
256256
algorithm: "none",
257257
expiresIn: 3600,
258258

@@ -275,7 +275,7 @@ describeAuthEmulator("sign-in with custom token", ({ authApi }) => {
275275
const tenant = await registerTenant(authApi(), PROJECT_ID, { disableAuth: false });
276276
const uid = "someuid";
277277
const claims = { abc: "def", ultimate: { answer: 42 } };
278-
const token = signJwt({ uid, claims, tenant_id: tenant.tenantId }, "", {
278+
const token = signJwt({ uid, claims, tenant_id: tenant.tenantId }, "fake-secret", {
279279
algorithm: "none",
280280
expiresIn: 3600,
281281

0 commit comments

Comments
 (0)