From 1234a57fa62005c539bc2bb7ed156c631f58f323 Mon Sep 17 00:00:00 2001 From: Florian Wilde Date: Sat, 22 Aug 2026 06:06:20 +0200 Subject: [PATCH] fix: Typisierung von oeffnen(), CSP im Entwicklungsmodus, Nonce-Abweichung Drei Fehler, die sich beim Durchsehen der Typpruefung und der Browserkonsole gezeigt haben. 1. oeffnen() lieferte Record. Zusammen mit noUncheckedIndexedAccess wurde daraus bei jedem Zugriff string | null | undefined - und jede aufrufende Seite haette das wegkaesen muessen, obwohl die Felder immer da sind. Jetzt leitet ein Mapped Type die Klartextnamen aus VERSCHLUESSELTE_FELDER ab: oeffnen('Betreute', zeile).diagnosen ist sauber string | null. Das hat auf einen Schlag 17 Folgefehler in fremden Modulen erledigt. 2. Die CSP blockierte im Entwicklungsmodus die eigenen Skripte. 'strict-dynamic' schaltet die Freigabe nach Herkunft ab, also auch 'self' - und Hot-Reload und Fehleranzeige laden ohne Nonce. Man sah eine tote Seite statt der Fehlermeldung. Im Produktivbetrieb bleibt es bei Nonce plus 'strict-dynamic', im Entwicklungsmodus gilt die lockere Fassung. 3. Das Theme-Skript im Layout meldete bei jedem Seitenaufruf eine Hydrations-Abweichung: React gibt das nonce-Attribut absichtlich nicht an den Browser weiter, serverseitig steht es aber im HTML. suppressHydrationWarning am Skript selbst - das html-Element allein deckt das nicht ab. Nebenbei: Algorithm.Argon2id ist ein const enum und laesst sich mit isolatedModules nicht importieren. Die Angabe entfaellt, @node-rs/argon2 benutzt von sich aus Argon2id. Die Anmeldeseite laedt jetzt ohne einen einzigen Konsolenfehler. Etappe: 8 Phase: Haertung --- prisma/seed.ts | 5 ++-- src/app/api/auth/[...nextauth]/route.ts | 4 ++- src/app/layout.tsx | 13 ++++++++- src/lib/crypto/feld.ts | 35 ++++++++++++++++++++----- src/lib/crypto/hash.ts | 10 ++++--- src/middleware.ts | 20 ++++++++++---- 6 files changed, 68 insertions(+), 19 deletions(-) diff --git a/prisma/seed.ts b/prisma/seed.ts index 3297969..c5ae85e 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -23,13 +23,14 @@ * Der Seed ist idempotent: mehrfaches Ausfuehren aendert nichts. */ import { PrismaClient } from '@prisma/client' -import { hash, Algorithm } from '@node-rs/argon2' +import { hash } from '@node-rs/argon2' import { createCipheriv, randomBytes } from 'node:crypto' const db = new PrismaClient() +// Muss zu ARGON2_OPTIONEN in src/lib/crypto/hash.ts passen. +// Ohne Angabe benutzt @node-rs/argon2 von sich aus Argon2id. const ARGON2 = { - algorithm: Algorithm.Argon2id, memoryCost: 19_456, timeCost: 2, parallelism: 1, diff --git a/src/app/api/auth/[...nextauth]/route.ts b/src/app/api/auth/[...nextauth]/route.ts index 9dc6f40..b2636a1 100644 --- a/src/app/api/auth/[...nextauth]/route.ts +++ b/src/app/api/auth/[...nextauth]/route.ts @@ -6,4 +6,6 @@ */ export const runtime = 'nodejs' -export { GET, POST } from '@/auth' +import { handlers } from '@/auth' + +export const { GET, POST } = handlers diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 4351ff7..f4947a7 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -57,7 +57,18 @@ export default async function RootLayout({ children }: { children: React.ReactNo return ( -