From 7fb76465f0e3d5b0b59577e5ae1876c7be248709 Mon Sep 17 00:00:00 2001 From: chahinebrini Date: Wed, 13 May 2026 21:25:43 +0200 Subject: [PATCH] fix(mail): explicit imports for MS-OAuth handlers (createOauthPendingState et al.) Runtime-Error im /init und /callback weil Nitro auto-import nur server/utils/ scannt, nicht server/db/. Die Helper-Funktionen (createOauthPendingState, consumeOauthPendingState, upsertOauthMicrosoftConnection, countMailConnections) sowie ms-oauth-utility-Functions (exchangeCodeForTokens, extractEmailFromId Token, generate*-Helpers, MS_*-Konstanten) wurden im Code implizit referenziert aber nicht explizit importiert. pnpm build:backend hat das nicht gefangen (Nitro Bundle-Step ist toleranter als strict tsc). Erster Symptom auf staging: ReferenceError: createOauthPendingState is not defined at .../routes/api/mail/oauth/microsoft/init.post.mjs:36:3 Fix: explizite import-Statements in beiden Endpoints. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../server/api/mail/oauth/microsoft/callback.post.ts | 12 ++++++++++++ backend/server/api/mail/oauth/microsoft/init.post.ts | 10 ++++++++++ 2 files changed, 22 insertions(+) diff --git a/backend/server/api/mail/oauth/microsoft/callback.post.ts b/backend/server/api/mail/oauth/microsoft/callback.post.ts index c1bf419..eb45e9b 100644 --- a/backend/server/api/mail/oauth/microsoft/callback.post.ts +++ b/backend/server/api/mail/oauth/microsoft/callback.post.ts @@ -1,3 +1,15 @@ +import { + consumeOauthPendingState, + countMailConnections, + upsertOauthMicrosoftConnection, +} from "../../../../db/mail"; +import { encrypt } from "../../../../utils/crypto"; +import { + exchangeCodeForTokens, + extractEmailFromIdToken, + MS_OAUTH_SCOPES, +} from "../../../../utils/ms-oauth"; + /** * POST /api/mail/oauth/microsoft/callback * diff --git a/backend/server/api/mail/oauth/microsoft/init.post.ts b/backend/server/api/mail/oauth/microsoft/init.post.ts index 1c358d4..15c39d2 100644 --- a/backend/server/api/mail/oauth/microsoft/init.post.ts +++ b/backend/server/api/mail/oauth/microsoft/init.post.ts @@ -1,3 +1,13 @@ +import { createOauthPendingState } from "../../../../db/mail"; +import { + MS_AUTH_BASE, + MS_REDIRECT_URI, + MS_OAUTH_SCOPES, + generateCodeVerifier, + computeCodeChallenge, + generateStateId, +} from "../../../../utils/ms-oauth"; + /** * POST /api/mail/oauth/microsoft/init *