diff --git a/app/__test__/modules/AppAuth.spec.ts b/app/__test__/modules/AppAuth.spec.ts index be1c7e1..14640f0 100644 --- a/app/__test__/modules/AppAuth.spec.ts +++ b/app/__test__/modules/AppAuth.spec.ts @@ -39,7 +39,10 @@ describe("AppAuth", () => { test("creates user on register", async () => { const auth = new AppAuth( { - enabled: true + enabled: true, + jwt: { + secret: "123456" + } }, ctx ); @@ -57,6 +60,9 @@ describe("AppAuth", () => { disableConsoleLog(); const res = await app.request("/password/register", { method: "POST", + headers: { + "Content-Type": "application/json" + }, body: JSON.stringify({ email: "some@body.com", password: "123456" diff --git a/app/package.json b/app/package.json index 88f2d89..861f721 100644 --- a/app/package.json +++ b/app/package.json @@ -45,7 +45,6 @@ "@uiw/react-codemirror": "^4.23.6", "@xyflow/react": "^12.3.2", "aws4fetch": "^1.0.18", - "codemirror-lang-liquid": "^1.0.0", "dayjs": "^1.11.13", "fast-xml-parser": "^4.4.0", "hono": "^4.6.12", @@ -57,12 +56,10 @@ "react-hook-form": "^7.53.1", "react-icons": "5.2.1", "react-json-view-lite": "^2.0.1", - "reactflow": "^11.11.4", "tailwind-merge": "^2.5.4", "tailwindcss-animate": "^1.0.7", "wouter": "^3.3.5", - "zod": "^3.23.8", - "zod-to-json-schema": "^3.23.2" + "zod": "^3.23.8" }, "devDependencies": { "@aws-sdk/client-s3": "^3.613.0", diff --git a/app/src/auth/authenticate/Authenticator.ts b/app/src/auth/authenticate/Authenticator.ts index 9040440..426023b 100644 --- a/app/src/auth/authenticate/Authenticator.ts +++ b/app/src/auth/authenticate/Authenticator.ts @@ -11,7 +11,7 @@ import { } from "core/utils"; import type { Context, Hono } from "hono"; import { deleteCookie, getSignedCookie, setSignedCookie } from "hono/cookie"; -import { decode, sign, verify } from "hono/jwt"; +import { sign, verify } from "hono/jwt"; import type { CookieOptions } from "hono/utils/cookie"; import { omit } from "lodash-es"; @@ -177,7 +177,12 @@ export class Authenticator = Record< payload.exp = Math.floor(Date.now() / 1000) + this.config.jwt.expires; } - return sign(payload, this.config.jwt?.secret ?? "", this.config.jwt?.alg ?? "HS256"); + const secret = this.config.jwt.secret; + if (!secret || secret.length === 0) { + throw new Error("Cannot sign JWT without a secret"); + } + + return sign(payload, secret, this.config.jwt?.alg ?? "HS256"); } async verify(jwt: string): Promise { diff --git a/bun.lockb b/bun.lockb index 9717d29..7adde63 100755 Binary files a/bun.lockb and b/bun.lockb differ