From 949b5b3b03f8062b6b6f132091cef0086bb45127 Mon Sep 17 00:00:00 2001 From: Ajeyakrishna Date: Wed, 10 Jan 2024 22:52:38 +0530 Subject: [PATCH] chore: renames key names --- src/utils/verifyAuthToken.ts | 2 +- tests/unit/utils/verifyToken.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/verifyAuthToken.ts b/src/utils/verifyAuthToken.ts index a9200894..33a4328b 100644 --- a/src/utils/verifyAuthToken.ts +++ b/src/utils/verifyAuthToken.ts @@ -37,7 +37,7 @@ export async function verifyCronJobsToken(authHeader: string, env: env) { throw new Error(INVALID_TOKEN_FORMAT); } const authToken = parts[1]; - const isValid = await jwt.verify(authToken, env.CRON_JOBS_PRIVATE_KEY, { + const isValid = await jwt.verify(authToken, env.CRON_JOBS_PUBLIC_KEY, { algorithm: "RS256", }); if (!isValid) { diff --git a/tests/unit/utils/verifyToken.test.ts b/tests/unit/utils/verifyToken.test.ts index c411178f..c533b268 100644 --- a/tests/unit/utils/verifyToken.test.ts +++ b/tests/unit/utils/verifyToken.test.ts @@ -51,7 +51,7 @@ describe("verifyAuthToken", () => { describe("verifyCronJobsToken", () => { const authToken = "validToken"; - const mockEnv = { CRON_JOBS_PRIVATE_KEY: "publicKey" }; + const mockEnv = { CRON_JOBS_PUBLIC_KEY: "publicKey" }; afterEach(() => { jest.clearAllMocks(); @@ -65,7 +65,7 @@ describe("verifyCronJobsToken", () => { ).resolves.not.toThrow(); expect(jwt.verify).toHaveBeenCalledWith( authToken, - mockEnv.CRON_JOBS_PRIVATE_KEY, + mockEnv.CRON_JOBS_PUBLIC_KEY, { algorithm: "RS256" } ); });