A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
fix(auth): support loopback origins, secure email logs, and SPA redirects
Hoàng Anh Tuấn90ad226568a0
diff --git a/apps/server/src/mcp/handler.ts b/apps/server/src/mcp/handler.tsindex 2c4143474..448763460 100644--- a/apps/server/src/mcp/handler.ts+++ b/apps/server/src/mcp/handler.ts@@ -3,10 +3,12 @@ import { randomUUID } from "node:crypto";import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";import { ORPCError } from "@orpc/server";import { consumeMcpRequestLimit, consumeMcpUserLimit } from "@reactive-resume/api/features/mcp/transport";+import { getTrustedOrigins } from "@reactive-resume/auth/trusted-origins";import { env } from "@reactive-resume/env/server";import { AuthError, authenticateRequest } from "./auth";import { createMcpServer } from "./server";+const TRUSTED_ORIGINS = getTrustedOrigins(env.APP_URL);const responseHeaders = {"Cache-Control": "no-store","X-Content-Type-Options": "nosniff",@@ -24,7 +26,7 @@ export async function handleMcp(request: Request, trustedClient = "unknown") {let transport: WebStandardStreamableHTTPServerTransport | undefined;try {const origin = request.headers.get("origin");- if (origin !== null && origin !== new URL(env.APP_URL).origin) {+ if (origin !== null && !TRUSTED_ORIGINS.includes(origin)) {return errorResponse(403, "Origin is not allowed. Use the configured application origin or a native MCP client.");}if (request.method !== "POST") {diff --git a/apps/web/locales/af-ZA.po b/apps/web/locales/af-ZA.poindex 092c58504..06cc9e51d 100644--- a/apps/web/locales/af-ZA.po+++ b/apps/web/locales/af-ZA.po@@ -11707,6 +11707,10 @@ msgstr "Asblik is leeg"msgid "Trimming words"msgstr "Snoei woorde"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/am-ET.po b/apps/web/locales/am-ET.poindex b762ab61d..80bce83bd 100644--- a/apps/web/locales/am-ET.po+++ b/apps/web/locales/am-ET.po@@ -11707,6 +11707,10 @@ msgstr "መጣያ ባዶ ነው።"msgid "Trimming words"msgstr "ቃላትን በመቀነስ ላይ"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/ar-SA.po b/apps/web/locales/ar-SA.poindex 57b31e5a5..e4228b472 100644--- a/apps/web/locales/ar-SA.po+++ b/apps/web/locales/ar-SA.po@@ -11707,6 +11707,10 @@ msgstr "سلة المهملات فارغة"msgid "Trimming words"msgstr "جارٍ تقليص الكلمات"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/az-AZ.po b/apps/web/locales/az-AZ.poindex bd675d40c..c13df5185 100644--- a/apps/web/locales/az-AZ.po+++ b/apps/web/locales/az-AZ.po@@ -11707,6 +11707,10 @@ msgstr "Zibil qutusu boşdur"msgid "Trimming words"msgstr "Sözlər ixtisar edilir"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/bg-BG.po b/apps/web/locales/bg-BG.poindex 265ad135c..b2d319673 100644--- a/apps/web/locales/bg-BG.po+++ b/apps/web/locales/bg-BG.po@@ -11707,6 +11707,10 @@ msgstr "Кошчето е празно"msgid "Trimming words"msgstr "Съкращаване на думи"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/bn-BD.po b/apps/web/locales/bn-BD.poindex fef82a931..71c2ae19e 100644--- a/apps/web/locales/bn-BD.po+++ b/apps/web/locales/bn-BD.po@@ -11707,6 +11707,10 @@ msgstr "আবর্জনা খালি"msgid "Trimming words"msgstr "শব্দ ছাঁটা হচ্ছে"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/ca-ES.po b/apps/web/locales/ca-ES.poindex 3c4499f38..fa72b8d96 100644--- a/apps/web/locales/ca-ES.po+++ b/apps/web/locales/ca-ES.po@@ -11707,6 +11707,10 @@ msgstr "La paperera està buida"msgid "Trimming words"msgstr "Retallant paraules"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/cs-CZ.po b/apps/web/locales/cs-CZ.poindex 21a8117aa..5a58e2640 100644--- a/apps/web/locales/cs-CZ.po+++ b/apps/web/locales/cs-CZ.po@@ -11707,6 +11707,10 @@ msgstr "Koš je prázdný"msgid "Trimming words"msgstr "Škrtají se slova"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/da-DK.po b/apps/web/locales/da-DK.poindex b5b6bc1c0..402cebb19 100644--- a/apps/web/locales/da-DK.po+++ b/apps/web/locales/da-DK.po@@ -11707,6 +11707,10 @@ msgstr "Papirkurven er tom"msgid "Trimming words"msgstr "Skærer ord væk"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/de-DE.po b/apps/web/locales/de-DE.poindex 1d7b1f22b..856292e95 100644--- a/apps/web/locales/de-DE.po+++ b/apps/web/locales/de-DE.po@@ -11707,6 +11707,10 @@ msgstr "Der Papierkorb ist leer"msgid "Trimming words"msgstr "Wörter werden gekürzt"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/el-GR.po b/apps/web/locales/el-GR.poindex 96b22317d..d2ee76bd8 100644--- a/apps/web/locales/el-GR.po+++ b/apps/web/locales/el-GR.po@@ -11707,6 +11707,10 @@ msgstr "Ο κάδος απορριμμάτων είναι άδειος"msgid "Trimming words"msgstr "Περικοπή λέξεων"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/en-GB.po b/apps/web/locales/en-GB.poindex fd12c99cf..7c8b52bed 100644--- a/apps/web/locales/en-GB.po+++ b/apps/web/locales/en-GB.po@@ -11707,6 +11707,10 @@ msgstr "Trash is empty"msgid "Trimming words"msgstr "Trimming words"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/en-US.po b/apps/web/locales/en-US.poindex f51b9d61f..fdc2d7fdd 100644--- a/apps/web/locales/en-US.po+++ b/apps/web/locales/en-US.po@@ -11702,6 +11702,10 @@ msgstr "Trash is empty"msgid "Trimming words"msgstr "Trimming words"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr "Trust this device for 30 days"+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/es-ES.po b/apps/web/locales/es-ES.poindex 839253918..1c2ced7aa 100644--- a/apps/web/locales/es-ES.po+++ b/apps/web/locales/es-ES.po@@ -11707,6 +11707,10 @@ msgstr "la papelera esta vacia"msgid "Trimming words"msgstr "Recortando palabras"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/fa-IR.po b/apps/web/locales/fa-IR.poindex c6e690f45..d398fbeeb 100644--- a/apps/web/locales/fa-IR.po+++ b/apps/web/locales/fa-IR.po@@ -11707,6 +11707,10 @@ msgstr "سطل زباله خالی است"msgid "Trimming words"msgstr "در حال کوتاه کردن کلمات"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/fi-FI.po b/apps/web/locales/fi-FI.poindex 4e6fb9319..590c68902 100644--- a/apps/web/locales/fi-FI.po+++ b/apps/web/locales/fi-FI.po@@ -11707,6 +11707,10 @@ msgstr "Roskakori on tyhjä"msgid "Trimming words"msgstr "Karsitaan sanoja"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/fr-FR.po b/apps/web/locales/fr-FR.poindex c849e8bc2..dfc9c3da9 100644--- a/apps/web/locales/fr-FR.po+++ b/apps/web/locales/fr-FR.po@@ -11707,6 +11707,10 @@ msgstr "La corbeille est vide"msgid "Trimming words"msgstr "Élagage des mots"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/he-IL.po b/apps/web/locales/he-IL.poindex 480028b15..366fe997c 100644--- a/apps/web/locales/he-IL.po+++ b/apps/web/locales/he-IL.po@@ -11707,6 +11707,10 @@ msgstr "האשפה ריקה"msgid "Trimming words"msgstr "מקצץ מילים"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/hi-IN.po b/apps/web/locales/hi-IN.poindex 807d7fdcd..f6c214a71 100644--- a/apps/web/locales/hi-IN.po+++ b/apps/web/locales/hi-IN.po@@ -11707,6 +11707,10 @@ msgstr "कचरा खाली है"msgid "Trimming words"msgstr "शब्द कम कर रहा है"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/hu-HU.po b/apps/web/locales/hu-HU.poindex 3c9f0c381..51dc48ce6 100644--- a/apps/web/locales/hu-HU.po+++ b/apps/web/locales/hu-HU.po@@ -11707,6 +11707,10 @@ msgstr "A kuka üres"msgid "Trimming words"msgstr "Szavak lefaragása"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/id-ID.po b/apps/web/locales/id-ID.poindex 8f4d52259..a6d661c8c 100644--- a/apps/web/locales/id-ID.po+++ b/apps/web/locales/id-ID.po@@ -11707,6 +11707,10 @@ msgstr "Sampah kosong"msgid "Trimming words"msgstr "Memangkas kata"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/it-IT.po b/apps/web/locales/it-IT.poindex 4dadf0551..9c49f7278 100644--- a/apps/web/locales/it-IT.po+++ b/apps/web/locales/it-IT.po@@ -11707,6 +11707,10 @@ msgstr "Il cestino è vuoto"msgid "Trimming words"msgstr "Taglio le parole"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/ja-JP.po b/apps/web/locales/ja-JP.poindex 77e046cae..ad0fb93a4 100644--- a/apps/web/locales/ja-JP.po+++ b/apps/web/locales/ja-JP.po@@ -11707,6 +11707,10 @@ msgstr "ゴミ箱が空です"msgid "Trimming words"msgstr "言葉を削っています"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/km-KH.po b/apps/web/locales/km-KH.poindex 1b65bae96..fcd50839b 100644--- a/apps/web/locales/km-KH.po+++ b/apps/web/locales/km-KH.po@@ -11707,6 +11707,10 @@ msgstr "ធុងសំរាមគឺទទេ"msgid "Trimming words"msgstr "កំពុងកាត់ពាក្យ"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/kn-IN.po b/apps/web/locales/kn-IN.poindex 00992fc40..895602830 100644--- a/apps/web/locales/kn-IN.po+++ b/apps/web/locales/kn-IN.po@@ -11707,6 +11707,10 @@ msgstr "ಕಸ ಖಾಲಿಯಾಗಿದೆ"msgid "Trimming words"msgstr "ಪದಗಳನ್ನು ಕತ್ತರಿಸಲಾಗುತ್ತಿದೆ"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/ko-KR.po b/apps/web/locales/ko-KR.poindex 8893836f0..e5b0a48d9 100644--- a/apps/web/locales/ko-KR.po+++ b/apps/web/locales/ko-KR.po@@ -11707,6 +11707,10 @@ msgstr "휴지통이 비어 있습니다."msgid "Trimming words"msgstr "단어 줄이는 중"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/lt-LT.po b/apps/web/locales/lt-LT.poindex d5668f844..df5a90f98 100644--- a/apps/web/locales/lt-LT.po+++ b/apps/web/locales/lt-LT.po@@ -11707,6 +11707,10 @@ msgstr "Šiukšliadėžė tuščia"msgid "Trimming words"msgstr "Trumpinami žodžiai"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/lv-LV.po b/apps/web/locales/lv-LV.poindex fcade7962..4ab15b206 100644--- a/apps/web/locales/lv-LV.po+++ b/apps/web/locales/lv-LV.po@@ -11707,6 +11707,10 @@ msgstr "Miskaste ir tukša"msgid "Trimming words"msgstr "Saīsina vārdus"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/ml-IN.po b/apps/web/locales/ml-IN.poindex b92d17b5b..43575110d 100644--- a/apps/web/locales/ml-IN.po+++ b/apps/web/locales/ml-IN.po@@ -11707,6 +11707,10 @@ msgstr "ട്രാഷ് ശൂന്യമാണ്"msgid "Trimming words"msgstr "വാക്കുകൾ കുറയ്ക്കുന്നു"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/mr-IN.po b/apps/web/locales/mr-IN.poindex 1a8306332..9a0a1960f 100644--- a/apps/web/locales/mr-IN.po+++ b/apps/web/locales/mr-IN.po@@ -11707,6 +11707,10 @@ msgstr "कचरा रिकामा आहे"msgid "Trimming words"msgstr "शब्द कमी करत आहे"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/ms-MY.po b/apps/web/locales/ms-MY.poindex a8a0987e4..45a65e074 100644--- a/apps/web/locales/ms-MY.po+++ b/apps/web/locales/ms-MY.po@@ -11707,6 +11707,10 @@ msgstr "Sampah kosong"msgid "Trimming words"msgstr "Memangkas perkataan"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/ne-NP.po b/apps/web/locales/ne-NP.poindex b0e620c2f..800dc1d4d 100644--- a/apps/web/locales/ne-NP.po+++ b/apps/web/locales/ne-NP.po@@ -11707,6 +11707,10 @@ msgstr "रद्दीटोकरी खाली छ"msgid "Trimming words"msgstr "शब्दहरू छाँट्दै"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/nl-NL.po b/apps/web/locales/nl-NL.poindex c39be5ec5..9120da3a3 100644--- a/apps/web/locales/nl-NL.po+++ b/apps/web/locales/nl-NL.po@@ -11707,6 +11707,10 @@ msgstr "Prullenbak is leeg"msgid "Trimming words"msgstr "Woorden schrappen"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/no-NO.po b/apps/web/locales/no-NO.poindex b18bcffb4..ad45aed34 100644--- a/apps/web/locales/no-NO.po+++ b/apps/web/locales/no-NO.po@@ -11707,6 +11707,10 @@ msgstr "Papirkurven er tom"msgid "Trimming words"msgstr "Kutter ord"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/or-IN.po b/apps/web/locales/or-IN.poindex c0038d520..08f1052c5 100644--- a/apps/web/locales/or-IN.po+++ b/apps/web/locales/or-IN.po@@ -11707,6 +11707,10 @@ msgstr "ଆବର୍ଜନା ଖାଲି ଅଛି |"msgid "Trimming words"msgstr "ଶବ୍ଦ କମାଉଛି"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/pl-PL.po b/apps/web/locales/pl-PL.poindex 8183b1439..14038663a 100644--- a/apps/web/locales/pl-PL.po+++ b/apps/web/locales/pl-PL.po@@ -11707,6 +11707,10 @@ msgstr "Kosz jest pusty"msgid "Trimming words"msgstr "Przycinanie słów"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/pt-BR.po b/apps/web/locales/pt-BR.poindex 685038d59..c2cd2e15c 100644--- a/apps/web/locales/pt-BR.po+++ b/apps/web/locales/pt-BR.po@@ -11707,6 +11707,10 @@ msgstr "A lixeira está vazia"msgid "Trimming words"msgstr "Cortando palavras"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/pt-PT.po b/apps/web/locales/pt-PT.poindex 2e265ca56..3b71cb411 100644--- a/apps/web/locales/pt-PT.po+++ b/apps/web/locales/pt-PT.po@@ -11707,6 +11707,10 @@ msgstr "A papeleira está vazia"msgid "Trimming words"msgstr "A cortar palavras"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/ro-RO.po b/apps/web/locales/ro-RO.poindex 7477fb400..b2f6f1db8 100644--- a/apps/web/locales/ro-RO.po+++ b/apps/web/locales/ro-RO.po@@ -11707,6 +11707,10 @@ msgstr "Coșul de gunoi este gol"msgid "Trimming words"msgstr "Se taie cuvinte"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/ru-RU.po b/apps/web/locales/ru-RU.poindex 02dd4240d..8d9bf9986 100644--- a/apps/web/locales/ru-RU.po+++ b/apps/web/locales/ru-RU.po@@ -11707,6 +11707,10 @@ msgstr "Корзина пуста"msgid "Trimming words"msgstr "Убираем лишние слова"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/sk-SK.po b/apps/web/locales/sk-SK.poindex c669e46fd..ac423839b 100644--- a/apps/web/locales/sk-SK.po+++ b/apps/web/locales/sk-SK.po@@ -11707,6 +11707,10 @@ msgstr "Kôš je prázdny"msgid "Trimming words"msgstr "Škrtáme slová"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/sl-SI.po b/apps/web/locales/sl-SI.poindex 7912b7db6..98e711db4 100644--- a/apps/web/locales/sl-SI.po+++ b/apps/web/locales/sl-SI.po@@ -11707,6 +11707,10 @@ msgstr "Koš je prazen"msgid "Trimming words"msgstr "Krajšanje besedila"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/sq-AL.po b/apps/web/locales/sq-AL.poindex c938ea70c..c921d04f8 100644--- a/apps/web/locales/sq-AL.po+++ b/apps/web/locales/sq-AL.po@@ -11707,6 +11707,10 @@ msgstr "Koshi është bosh"msgid "Trimming words"msgstr "Po shkurtohen fjalët"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/sr-SP.po b/apps/web/locales/sr-SP.poindex d8d492517..4bd196eeb 100644--- a/apps/web/locales/sr-SP.po+++ b/apps/web/locales/sr-SP.po@@ -11707,6 +11707,10 @@ msgstr "Отпад је празан"msgid "Trimming words"msgstr "Скраћивање текста"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/sv-SE.po b/apps/web/locales/sv-SE.poindex be6b9a081..a6f84336a 100644--- a/apps/web/locales/sv-SE.po+++ b/apps/web/locales/sv-SE.po@@ -11707,6 +11707,10 @@ msgstr "Papperskorgen är tom"msgid "Trimming words"msgstr "Kortar ner texten"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/ta-IN.po b/apps/web/locales/ta-IN.poindex 95e146afe..f3079ecc4 100644--- a/apps/web/locales/ta-IN.po+++ b/apps/web/locales/ta-IN.po@@ -11707,6 +11707,10 @@ msgstr "குப்பை காலியாக உள்ளது"msgid "Trimming words"msgstr "சொற்களைக் குறைக்கிறது"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/te-IN.po b/apps/web/locales/te-IN.poindex f6d973dc8..4d885cdd1 100644--- a/apps/web/locales/te-IN.po+++ b/apps/web/locales/te-IN.po@@ -11707,6 +11707,10 @@ msgstr "ట్రాష్ ఖాళీగా ఉంది"msgid "Trimming words"msgstr "పదాలను తగ్గిస్తోంది"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/th-TH.po b/apps/web/locales/th-TH.poindex 55664f35d..81344497a 100644--- a/apps/web/locales/th-TH.po+++ b/apps/web/locales/th-TH.po@@ -11707,6 +11707,10 @@ msgstr "ถังขยะว่างเปล่า"msgid "Trimming words"msgstr "กำลังตัดคำ"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/tr-TR.po b/apps/web/locales/tr-TR.poindex 9114f0801..0d9a52d24 100644--- a/apps/web/locales/tr-TR.po+++ b/apps/web/locales/tr-TR.po@@ -11707,6 +11707,10 @@ msgstr "Çöp kutusu boş"msgid "Trimming words"msgstr "Kelimeler kırpılıyor"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/uk-UA.po b/apps/web/locales/uk-UA.poindex e4563e71a..3c8e2e6a2 100644--- a/apps/web/locales/uk-UA.po+++ b/apps/web/locales/uk-UA.po@@ -11707,6 +11707,10 @@ msgstr "Кошик порожній"msgid "Trimming words"msgstr "Прибираю зайві слова"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/uz-UZ.po b/apps/web/locales/uz-UZ.poindex e376e1b46..eaeedd7c3 100644--- a/apps/web/locales/uz-UZ.po+++ b/apps/web/locales/uz-UZ.po@@ -11707,6 +11707,10 @@ msgstr "Chiqindi bo'sh"msgid "Trimming words"msgstr "Ortiqcha so'zlar qisqartirilmoqda"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/vi-VN.po b/apps/web/locales/vi-VN.poindex 6e2d9b0c8..4bea3e1e4 100644--- a/apps/web/locales/vi-VN.po+++ b/apps/web/locales/vi-VN.po@@ -11707,6 +11707,10 @@ msgstr "Thùng rác trống rỗng"msgid "Trimming words"msgstr "Đang lược bớt từ"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/zh-CN.po b/apps/web/locales/zh-CN.poindex 07eddb59b..517e1c030 100644--- a/apps/web/locales/zh-CN.po+++ b/apps/web/locales/zh-CN.po@@ -11707,6 +11707,10 @@ msgstr "垃圾箱已空"msgid "Trimming words"msgstr "正在删减字词"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/zh-TW.po b/apps/web/locales/zh-TW.poindex 7b03a40de..01b21715c 100644--- a/apps/web/locales/zh-TW.po+++ b/apps/web/locales/zh-TW.po@@ -11707,6 +11707,10 @@ msgstr "垃圾箱已空"msgid "Trimming words"msgstr "正在刪減字詞"+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/locales/zu-ZA.po b/apps/web/locales/zu-ZA.poindex 377811aac..b370e8980 100644--- a/apps/web/locales/zu-ZA.po+++ b/apps/web/locales/zu-ZA.po@@ -11702,6 +11702,10 @@ msgstr ""msgid "Trimming words"msgstr ""+#: src/features/auth/pages/verify-2fa.tsx+msgid "Trust this device for 30 days"+msgstr ""+#. placeholder {0}: result.suggestion#: src/features/resume/share/link-tab.tsxmsgid "Try {0}"diff --git a/apps/web/src/dialogs/resume/index.tsx b/apps/web/src/dialogs/resume/index.tsxindex e96047908..916401eb8 100644--- a/apps/web/src/dialogs/resume/index.tsx+++ b/apps/web/src/dialogs/resume/index.tsx@@ -196,8 +196,8 @@ const ResumeForm = withForm({<FormControlrender={<Input- min={1}- max={64}+ minLength={1}+ maxLength={64}name={field.name}value={field.state.value}onBlur={field.handleBlur}diff --git a/apps/web/src/features/auth/login-redirect.test.tsx b/apps/web/src/features/auth/login-redirect.test.tsxindex ccf6fbc7c..8cab1b41b 100644--- a/apps/web/src/features/auth/login-redirect.test.tsx+++ b/apps/web/src/features/auth/login-redirect.test.tsx@@ -188,9 +188,31 @@ describe("OAuth callback after two-factor verification", () => {fireEvent.change(input, { target: { value: code } });fireEvent.submit(form);await waitFor(() =>- expect(mocks.verifyBackupCode).toHaveBeenCalledWith(expect.objectContaining({ code: "82cNK-qaOiN" })),+ expect(mocks.verifyBackupCode).toHaveBeenCalledWith(+ expect.objectContaining({ code: "82cNK-qaOiN", trustDevice: false }),+ ),+ );+ });++ it.each([false, true])("trusts the device only when selected (backup: %s)", async (backup) => {+ const { container } = render(+ <I18nProvider i18n={i18n}>{backup ? <VerifyTwoFactorBackupPage /> : <VerifyTwoFactorPage />}</I18nProvider>,+ );+ const input = container.querySelector('input[name="code"]');+ const checkbox = screen.getByRole("checkbox", { name: "Trust this device for 30 days" });+ const form = container.querySelector("form");+ if (!input || !form) throw new Error("Verification form is missing");++ fireEvent.change(input, { target: { value: backup ? "82cNK-qaOiN" : "123456" } });+ fireEvent.click(checkbox);+ fireEvent.submit(form);+ await waitFor(() =>+ expect(backup ? mocks.verifyBackupCode : mocks.verifyTotp).toHaveBeenCalledWith(+ expect.objectContaining({ code: backup ? "82cNK-qaOiN" : "123456", trustDevice: true }),+ ),);});+it.each([false, true])("resumes the callback after verifying a code (backup: %s)", async (backup) => {const { container } = render(<I18nProvider i18n={i18n}>{backup ? <VerifyTwoFactorBackupPage /> : <VerifyTwoFactorPage />}</I18nProvider>,@@ -229,7 +251,7 @@ describe("OAuth account creation", () => {await waitFor(() => expect(screen.getByText(/>=8/)).toBeDefined());expect(mocks.signup).not.toHaveBeenCalled();});- it("continues a create prompt only after successful signup", async () => {+ it("continues a create prompt only after successful signup with a trimmed one-character name", async () => {mocks.callbackURL += "&prompt=create";mocks.signup.mockResolvedValueOnce({ data: { token: "session" }, error: null });mocks.continueOAuth.mockResolvedValueOnce({@@ -242,7 +264,7 @@ describe("OAuth account creation", () => {</I18nProvider>,);for (const [name, value] of Object.entries({- name: "New User",+ name: " A ",username: "newuser",email: "[email protected]",password: "password123",@@ -258,5 +280,6 @@ describe("OAuth account creation", () => {expect(mocks.continueOAuth).toHaveBeenCalledWith({ created: true, oauth_query: mocks.callbackURL.split("?")[1] }),);expect(mocks.signup.mock.calls[0]?.[0]).not.toHaveProperty("oauth_query");+ expect(mocks.signup).toHaveBeenCalledWith(expect.objectContaining({ name: "A" }));});});diff --git a/apps/web/src/features/auth/pages/register.tsx b/apps/web/src/features/auth/pages/register.tsxindex c1674f08f..e72ccda38 100644--- a/apps/web/src/features/auth/pages/register.tsx+++ b/apps/web/src/features/auth/pages/register.tsx@@ -13,7 +13,7 @@ import { Input } from "@reactive-resume/ui/components/input";import { toast } from "@reactive-resume/ui/components/toast";import { cn } from "@reactive-resume/utils/style";import { SocialAuth } from "../components/social-auth";-import { getOAuthSignInOptions, isOAuthRedirect } from "../redirect";+import { getAuthRedirectOptions, getOAuthSignInOptions, isOAuthRedirect } from "../redirect";import { PasswordInput } from "@/components/input/password-input";import { authClient } from "@/libs/auth/client";import { ENTER_CLASS } from "@/libs/motion";@@ -21,7 +21,7 @@ import { sessionQueryKey } from "@/libs/root-context";import { useAppForm } from "@/libs/tanstack-form";const formSchema = z.object({- name: z.string().min(3).max(64),+ name: z.string().trim().min(1).max(64),username: z.string().min(3)@@ -53,7 +53,7 @@ export function RegisterPage({ disableEmailAuth }: Props) {const oauthOptions = getOAuthSignInOptions(callbackURL);const createPrompt = new URLSearchParams(oauthOptions.oauth_query).get("prompt")?.split(" ").includes("create");const { data, error } = await authClient.signUp.email({- name: value.name,+ name: value.name.trim(),email: value.email,password: value.password,username: value.username,@@ -138,8 +138,8 @@ export function RegisterPage({ disableEmailAuth }: Props) {<FormControlrender={<Input- min={3}- max={64}+ minLength={1}+ maxLength={64}autoComplete="section-register name"placeholder={t({comment: "Example full name placeholder on registration form",@@ -166,8 +166,8 @@ export function RegisterPage({ disableEmailAuth }: Props) {<FormControlrender={<Input- min={3}- max={64}+ minLength={3}+ maxLength={64}autoComplete="section-register username"placeholder={t({comment: "Example username placeholder on registration form",@@ -248,6 +248,7 @@ export function RegisterPage({ disableEmailAuth }: Props) {function PostSignupScreen() {const { callbackURL } = useSearch({ from: "/auth" });+ const redirectOptions = getAuthRedirectOptions(callbackURL);return (// Replaces the form in place: fades up into the auth column, with the layout's 24px gap.<div className={cn(ENTER_CLASS, "grid gap-y-6")}>@@ -272,10 +273,10 @@ function PostSignupScreen() {<ButtonnativeButton={false}render={- <a href={callbackURL ?? "/dashboard"}>+ <Link to={redirectOptions.href} reloadDocument={redirectOptions.reloadDocument} replace><Trans comment="Button label to continue to dashboard after successful registration">Continue</Trans>{" "}<Icon name="arrow-right" size={16} />- </a>+ </Link>}/></div>diff --git a/apps/web/src/features/auth/pages/verify-2fa.tsx b/apps/web/src/features/auth/pages/verify-2fa.tsxindex 1e4e8d361..d24cc0ae6 100644--- a/apps/web/src/features/auth/pages/verify-2fa.tsx+++ b/apps/web/src/features/auth/pages/verify-2fa.tsx@@ -5,6 +5,7 @@ import { useQueryClient } from "@tanstack/react-query";import { Link, useNavigate, useRouter, useSearch } from "@tanstack/react-router";import z from "zod";import { Button } from "@reactive-resume/ui/components/button";+import { Checkbox } from "@reactive-resume/ui/components/checkbox";import { FormControl, FormItem, FormLabel, FormMessage } from "@reactive-resume/ui/components/form";import { Icon } from "@reactive-resume/ui/components/icon";import { Input } from "@reactive-resume/ui/components/input";@@ -17,10 +18,12 @@ import { useAppForm } from "@/libs/tanstack-form";const totpSchema = z.object({code: z.string().length(6, "Code must be 6 digits"),+ trustDevice: z.boolean(),});const backupCodeSchema = z.object({code: z.string().trim(),+ trustDevice: z.boolean(),});type TwoFactorVerificationPageProps = {@@ -34,7 +37,7 @@ function TwoFactorVerificationPage({ backupCode = false }: TwoFactorVerificationconst navigate = useNavigate();const form = useAppForm({- defaultValues: { code: "" },+ defaultValues: { code: "", trustDevice: false },validators: { onSubmit: backupCode ? backupCodeSchema : totpSchema },onSubmit: async ({ value }) => {const toastId = toast.add({@@ -43,9 +46,10 @@ function TwoFactorVerificationPage({ backupCode = false }: TwoFactorVerification});const rawCode = value.code.trim().replaceAll("-", "");const code = backupCode ? `${rawCode.slice(0, 5)}-${rawCode.slice(5)}` : value.code;+ const options = { code, trustDevice: value.trustDevice, ...getOAuthSignInOptions(callbackURL) };const { data, error } = backupCode- ? await authClient.twoFactor.verifyBackupCode({ code, ...getOAuthSignInOptions(callbackURL) })- : await authClient.twoFactor.verifyTotp({ code, ...getOAuthSignInOptions(callbackURL) });+ ? await authClient.twoFactor.verifyBackupCode(options)+ : await authClient.twoFactor.verifyTotp(options);if (error) {toast.add({@@ -137,6 +141,19 @@ function TwoFactorVerificationPage({ backupCode = false }: TwoFactorVerification)}</form.Field>+ <form.Field name="trustDevice">+ {(field) => (+ <FormItem className="flex items-center gap-2.5 justify-self-center">+ <FormControl+ render={<Checkbox name={field.name} checked={field.state.value} onCheckedChange={field.handleChange} />}+ />+ <FormLabel>+ <Trans>Trust this device for 30 days</Trans>+ </FormLabel>+ </FormItem>+ )}+ </form.Field>+<div className="flex gap-x-2"><Buttonvariant="secondary"diff --git a/apps/web/src/features/auth/redirect.test.ts b/apps/web/src/features/auth/redirect.test.tsindex 581c016bc..922205e9a 100644--- a/apps/web/src/features/auth/redirect.test.ts+++ b/apps/web/src/features/auth/redirect.test.ts@@ -29,6 +29,18 @@ describe("authentication callback", () => {const callbackURL = "/dashboard?next=https%3A%2F%2Fexample.com";expect(authSearchSchema.parse({ callbackURL }).callbackURL).toBe(callbackURL);});+ it("routes internal SPA paths without reloading document", () => {+ expect(getAuthRedirectOptions("/dashboard")).toEqual({+ href: "/dashboard",+ reloadDocument: false,+ replace: true,+ });+ expect(getAuthRedirectOptions("/builder/resume-123")).toEqual({+ href: "/builder/resume-123",+ reloadDocument: false,+ replace: true,+ });+ });});describe("signed OAuth sign-in context", () => {diff --git a/apps/web/src/features/auth/redirect.ts b/apps/web/src/features/auth/redirect.tsindex 1ec04a4c5..76e9691b6 100644--- a/apps/web/src/features/auth/redirect.ts+++ b/apps/web/src/features/auth/redirect.ts@@ -26,7 +26,8 @@ export const authSearchSchema = z.object({export function getAuthRedirectOptions(value: unknown) {const callbackURL = safeCallbackURL(value);// OAuth callbacks are server endpoints; they must run through a document request.- return { href: callbackURL ?? "/dashboard", reloadDocument: callbackURL !== undefined, replace: true } as const;+ const isServerCallback = callbackURL !== undefined && callbackURL.startsWith("/api/");+ return { href: callbackURL ?? "/dashboard", reloadDocument: isServerCallback, replace: true } as const;}export function getOAuthSignInOptions(callback: unknown) {diff --git a/apps/web/src/routes/agent/route.tsx b/apps/web/src/routes/agent/route.tsxindex 4b878307f..b8aecaae2 100644--- a/apps/web/src/routes/agent/route.tsx+++ b/apps/web/src/routes/agent/route.tsx@@ -2,7 +2,7 @@ import { createFileRoute, redirect } from "@tanstack/react-router";// The Agents pages became the assistant in the editor; their links redirect there (through 6.0.x).export const Route = createFileRoute("/agent")({- beforeLoad: ({ context }) => {- if (!context.session) throw redirect({ to: "/auth/login", replace: true });+ beforeLoad: ({ context, location }) => {+ if (!context.session) throw redirect({ to: "/auth/login", search: { callbackURL: location.href }, replace: true });},});diff --git a/apps/web/src/routes/builder/$resumeId/route.tsx b/apps/web/src/routes/builder/$resumeId/route.tsxindex 9a3cd1939..d1d0a9d41 100644--- a/apps/web/src/routes/builder/$resumeId/route.tsx+++ b/apps/web/src/routes/builder/$resumeId/route.tsx@@ -25,8 +25,8 @@ const searchSchema = z.object({export const Route = createFileRoute("/builder/$resumeId")({component: RouteComponent,validateSearch: searchSchema,- beforeLoad: ({ context }) => {- if (!context.session) throw redirect({ to: "/auth/login", replace: true });+ beforeLoad: ({ context, location }) => {+ if (!context.session) throw redirect({ to: "/auth/login", search: { callbackURL: location.href }, replace: true });return { session: context.session };},loader: async ({ params, context }) => {diff --git a/apps/web/src/routes/builder/letter/$coverLetterId.tsx b/apps/web/src/routes/builder/letter/$coverLetterId.tsxindex 774867e4a..86f9d95be 100644--- a/apps/web/src/routes/builder/letter/$coverLetterId.tsx+++ b/apps/web/src/routes/builder/letter/$coverLetterId.tsx@@ -24,8 +24,8 @@ const searchSchema = z.object({export const Route = createFileRoute("/builder/letter/$coverLetterId")({component: RouteComponent,validateSearch: searchSchema,- beforeLoad: ({ context }) => {- if (!context.session) throw redirect({ to: "/auth/login", replace: true });+ beforeLoad: ({ context, location }) => {+ if (!context.session) throw redirect({ to: "/auth/login", search: { callbackURL: location.href }, replace: true });return { session: context.session };},loader: async ({ params, context }) => {diff --git a/apps/web/src/routes/dashboard/route.tsx b/apps/web/src/routes/dashboard/route.tsxindex eb5898105..af7f7cbb4 100644--- a/apps/web/src/routes/dashboard/route.tsx+++ b/apps/web/src/routes/dashboard/route.tsx@@ -4,8 +4,8 @@ import { createNoindexFollowMeta } from "@/libs/seo";export const Route = createFileRoute("/dashboard")({component: RouteComponent,- beforeLoad: ({ context }) => {- if (!context.session) throw redirect({ to: "/auth/login", replace: true });+ beforeLoad: ({ context, location }) => {+ if (!context.session) throw redirect({ to: "/auth/login", search: { callbackURL: location.href }, replace: true });return { session: context.session };},head: () => ({diff --git a/packages/api/src/context.test.ts b/packages/api/src/context.test.tsindex 9871bf94b..7f74f716b 100644--- a/packages/api/src/context.test.ts+++ b/packages/api/src/context.test.ts@@ -106,6 +106,17 @@ describe("cookie request origins", () => {),).resolves.toMatchObject({ id: "token-user" });});++ it("accepts loopback alias origins for session cookies", async () => {+ reset();+ authMock.api.getSession.mockResolvedValue({ user: { id: "loopback-user" } });+ setupDbResolves({ id: "loopback-user" });+ const loopbackOrigin =+ new URL(env.APP_URL).hostname === "localhost" ? "http://127.0.0.1:3000" : "http://localhost:3000";+ await expect(+ resolveUserFromRequestHeaders(new Headers({ cookie: "session=valid", origin: loopbackOrigin })),+ ).resolves.toMatchObject({ id: "loopback-user" });+ });});describe("credential authorization", () => {diff --git a/packages/api/src/context.ts b/packages/api/src/context.tsindex 365d76402..cd10d6de5 100644--- a/packages/api/src/context.ts+++ b/packages/api/src/context.ts@@ -3,6 +3,7 @@ import type { User } from "better-auth";import { ORPCError, os } from "@orpc/server";import { eq } from "drizzle-orm";import { auth, verifyOAuthToken } from "@reactive-resume/auth/config";+import { getTrustedOrigins } from "@reactive-resume/auth/trusted-origins";import { db } from "@reactive-resume/db/client";import { user } from "@reactive-resume/db/schema";import { env } from "@reactive-resume/env/server";@@ -23,6 +24,7 @@ interface ORPCContext {authentication?: RequestAuthentication | null;}+const TRUSTED_ORIGINS = getTrustedOrigins(env.APP_URL);const fullPermissions: readonly RequestPermission[] = ["read", "write", "delete"];async function findActiveUser(id: string): Promise<User | null> {@@ -82,7 +84,7 @@ export async function resolveAuthenticationFromRequestHeaders(headers: Headers):const origin = headers.get("origin");if (headers.has("cookie") &&- ((origin && origin !== new URL(env.APP_URL).origin) || headers.get("sec-fetch-site") === "cross-site")+ ((origin && !TRUSTED_ORIGINS.includes(origin)) || headers.get("sec-fetch-site") === "cross-site")) {throw new ORPCError("FORBIDDEN", { message: "Cross-origin session requests are not allowed." });}diff --git a/packages/api/src/features/ai-providers/e2e.test.ts b/packages/api/src/features/ai-providers/e2e.test.tsindex a604c1c4c..3f7d0037f 100644--- a/packages/api/src/features/ai-providers/e2e.test.ts+++ b/packages/api/src/features/ai-providers/e2e.test.ts@@ -49,7 +49,11 @@ vi.mock("drizzle-orm", () => ({// Real AES-GCM credential encryption runs; it only needs a secret.vi.mock("@reactive-resume/env/server", () => ({- env: { ENCRYPTION_SECRET: "e2e-encryption-secret", FLAG_ALLOW_UNSAFE_AI_BASE_URL: true },+ env: {+ APP_URL: "http://localhost:3000",+ ENCRYPTION_SECRET: "e2e-encryption-secret",+ FLAG_ALLOW_UNSAFE_AI_BASE_URL: true,+ },}));vi.mock("@reactive-resume/auth/config", () => ({diff --git a/packages/api/src/features/storage/transport.ts b/packages/api/src/features/storage/transport.tsindex 0bfd1bc49..1ed58f7bf 100644--- a/packages/api/src/features/storage/transport.ts+++ b/packages/api/src/features/storage/transport.ts@@ -1,12 +1,14 @@import { randomUUID } from "node:crypto";import { del, get, issueSignedToken, list, presignUrl } from "@vercel/blob";import { z } from "zod";+import { getTrustedOrigins } from "@reactive-resume/auth/trusted-origins";import { getRedis, redisKey } from "@reactive-resume/db/redis";import { env } from "@reactive-resume/env/server";import { resolveAuthenticationFromRequestHeaders } from "../../context";import { createRateLimiter } from "../../redis";import { blobOptions, blobPath } from "./blob";+const TRUSTED_ORIGINS = getTrustedOrigins(env.APP_URL);const HEADER = "x-resume-staged-body";const TTL_SECONDS = 600;// Covers the 100 MiB thread attachment allowance, including base64 and RPC framing.@@ -21,7 +23,7 @@ const enabled = () => process.env.VERCEL === "1" && env.STORAGE_BACKEND === "blofunction authenticatedRequest(request: Request) {const origin = request.headers.get("origin");- if (origin && origin !== new URL(env.APP_URL).origin) return null;+ if (origin && !TRUSTED_ORIGINS.includes(origin)) return null;return resolveAuthenticationFromRequestHeaders(request.headers);}@@ -47,7 +49,7 @@ export async function prepareStagedBody(request: Request): Promise<Response> {const parsed = payloadSchema.safeParse(await request.json().catch(() => null));if (!parsed.success) return new Response("Invalid upload", { status: 400 });const target = new URL(parsed.data.path, env.APP_URL);- if (target.origin !== new URL(env.APP_URL).origin || !/^\/api\/rpc(?:\/|$)/.test(target.pathname)) {+ if (!TRUSTED_ORIGINS.includes(target.origin) || !/^\/api\/rpc(?:\/|$)/.test(target.pathname)) {return new Response("Invalid target", { status: 400 });}const redis = getRedis();diff --git a/packages/auth/package.json b/packages/auth/package.jsonindex 9f9dacc42..7ffb59a21 100644--- a/packages/auth/package.json+++ b/packages/auth/package.json@@ -5,6 +5,7 @@"private": true,"exports": {"./config": "./src/config.ts",+ "./trusted-origins": "./src/trusted-origins.ts","./types": "./src/types.ts"},"scripts": {diff --git a/packages/auth/src/config.ts b/packages/auth/src/config.tsindex e17288319..c3273d7df 100644--- a/packages/auth/src/config.ts+++ b/packages/auth/src/config.ts@@ -188,10 +188,7 @@ const getAuthConfig = () => {before: createAuthMiddleware(async (ctx) => {if (ctx.path === "/oauth2/delete-consent") {const origin = ctx.headers?.get("origin");- if (- (origin && origin !== new URL(authBaseUrl).origin) ||- ctx.headers?.get("sec-fetch-site") === "cross-site"- ) {+ if ((origin && !TRUSTED_ORIGINS.includes(origin)) || ctx.headers?.get("sec-fetch-site") === "cross-site") {throw new APIError("FORBIDDEN", { message: "Cross-origin consent changes are not allowed." });}const current = await auth.api.getSession({diff --git a/packages/auth/src/trusted-origins.test.ts b/packages/auth/src/trusted-origins.test.tsnew file mode 100644index 000000000..a893d22b2--- /dev/null+++ b/packages/auth/src/trusted-origins.test.ts@@ -0,0 +1,30 @@+import { afterEach, describe, expect, it } from "vitest";+import { getTrustedOrigins } from "./trusted-origins";++describe("getTrustedOrigins", () => {+ const originalNodeEnv = process.env.NODE_ENV;++ afterEach(() => {+ process.env.NODE_ENV = originalNodeEnv;+ });++ it("includes loopback aliases in non-production", () => {+ process.env.NODE_ENV = "development";+ const origins = getTrustedOrigins("http://localhost:3000");+ expect(origins).toContain("http://localhost:3000");+ expect(origins).toContain("http://127.0.0.1:3000");+ });++ it("does not include localhost when configured with external URL in production", () => {+ process.env.NODE_ENV = "production";+ const origins = getTrustedOrigins("https://resume.example.com");+ expect(origins).toEqual(["https://resume.example.com"]);+ });++ it("preserves custom port loopback alias", () => {+ process.env.NODE_ENV = "production";+ const origins = getTrustedOrigins("http://localhost:5173");+ expect(origins).toContain("http://localhost:5173");+ expect(origins).toContain("http://127.0.0.1:5173");+ });+});diff --git a/packages/auth/src/trusted-origins.ts b/packages/auth/src/trusted-origins.tsindex 038cd1681..cff241b09 100644--- a/packages/auth/src/trusted-origins.ts+++ b/packages/auth/src/trusted-origins.ts@@ -1,5 +1,10 @@export function getTrustedOrigins(appUrl: string): string[] {- const trustedOrigins = new Set<string>(["http://localhost:3000", "http://127.0.0.1:3000"]);+ const trustedOrigins = new Set<string>();++ if (process.env.NODE_ENV !== "production") {+ trustedOrigins.add("http://localhost:3000");+ trustedOrigins.add("http://127.0.0.1:3000");+ }const configuredUrl = new URL(appUrl);trustedOrigins.add(configuredUrl.origin);diff --git a/packages/email/src/transport.test.ts b/packages/email/src/transport.test.tsindex 4ffdba68e..75a0c9732 100644--- a/packages/email/src/transport.test.ts+++ b/packages/email/src/transport.test.ts@@ -1,4 +1,4 @@-import { describe, expect, it, vi } from "vitest";+import { afterEach, describe, expect, it, vi } from "vitest";const envMock = vi.hoisted(() => ({SMTP_HOST: undefined as string | undefined,@@ -34,19 +34,55 @@ const resetEnv = () => {createTransport.mockClear();sendMail.mockClear();};-describe("sendEmail", () => {- it("does not throw if the SMTP transport itself errors", async () => {+ const originalNodeEnv = process.env.NODE_ENV;++ afterEach(() => {+ process.env.NODE_ENV = originalNodeEnv;+ });++ it("skips email send and logs without body in production when SMTP is not configured", async () => {+ resetEnv();+ process.env.NODE_ENV = "production";+ const infoSpy = vi.spyOn(console, "info").mockImplementation(() => {});+ await expect(+ sendEmail({ to: "[email protected]", subject: "Reset password", react: fakeReact }),+ ).resolves.toBeUndefined();+ expect(infoSpy).toHaveBeenCalledWith("SMTP not configured; skipping email send.", {+ to: "[email protected]",+ subject: "Reset password",+ });+ infoSpy.mockRestore();+ });++ it("skips email send and logs with body in development when SMTP is not configured", async () => {+ resetEnv();+ process.env.NODE_ENV = "development";+ const infoSpy = vi.spyOn(console, "info").mockImplementation(() => {});+ await expect(+ sendEmail({ to: "[email protected]", subject: "Reset password", react: fakeReact }),+ ).resolves.toBeUndefined();+ expect(infoSpy).toHaveBeenCalledWith("SMTP not configured; skipping email send.", {+ to: "[email protected]",+ subject: "Reset password",+ text: "plain text body",+ html: "<p>html body</p>",+ });+ infoSpy.mockRestore();+ });++ it("does not throw or log sensitive details if the SMTP transport errors", async () => {resetEnv();+ process.env.NODE_ENV = "production";envMock.SMTP_HOST = "smtp.example.com";envMock.SMTP_USER = "user";envMock.SMTP_PASS = "pass";envMock.SMTP_FROM = "[email protected]";- sendMail.mockRejectedValueOnce(new Error("boom"));+ sendMail.mockRejectedValueOnce(new Error("SMTP rejected password=secret reset-token=private"));const errorSpy = vi.spyOn(console, "error").mockImplementation(() => {});await expect(sendEmail({ to: "[email protected]", subject: "hi", react: fakeReact })).resolves.toBeUndefined();- expect(errorSpy).toHaveBeenCalled();+ expect(errorSpy).toHaveBeenCalledExactlyOnceWith("There was an error sending mail.");errorSpy.mockRestore();});});diff --git a/packages/email/src/transport.ts b/packages/email/src/transport.tsindex 636b5753e..4c04e294d 100644--- a/packages/email/src/transport.ts+++ b/packages/email/src/transport.ts@@ -28,6 +28,10 @@ const getTransport = () => {export const sendEmail = async ({ to, subject, react }: SendEmailOptions) => {const transport = getTransport();+ if (!transport && process.env.NODE_ENV === "production") {+ console.info("SMTP not configured; skipping email send.", { to, subject });+ return;+ }const payload: SendMailOptions = {to,from: env.SMTP_FROM,@@ -48,8 +52,9 @@ export const sendEmail = async ({ to, subject, react }: SendEmailOptions) => {try {await transport.sendMail(payload);- } catch (error) {- console.error("There was an error sending mail.", error);+ } catch {+ // SMTP errors can contain credentials or authentication links.+ console.error("There was an error sending mail.");}};diff --git a/tests/e2e/fixtures/auth.ts b/tests/e2e/fixtures/auth.tsindex a111b56ef..e831315b9 100644--- a/tests/e2e/fixtures/auth.ts+++ b/tests/e2e/fixtures/auth.ts@@ -7,8 +7,8 @@ async function assertAuthResponse(response: Awaited<ReturnType<APIRequestContextthrow new Error(`Authentication request failed with ${response.status()}: ${await response.text()}`);}-export async function registerViaUi(page: Page, account: E2EAccount) {- await page.goto("/auth/register");+export async function registerViaUi(page: Page, account: E2EAccount, callbackURL?: string) {+ await page.goto(`/auth/register${callbackURL ? `?callbackURL=${encodeURIComponent(callbackURL)}` : ""}`);await page.getByRole("textbox", { name: "Name", exact: true }).fill(account.name);await page.getByLabel("Username").fill(account.username);await page.getByLabel("Email Address", { exact: true }).fill(account.email);@@ -18,8 +18,8 @@ export async function registerViaUi(page: Page, account: E2EAccount) {await page.waitForURL(/\/dashboard/);}-export async function loginViaUi(page: Page, account: E2EAccount) {- await page.goto("/auth/login");+export async function loginViaUi(page: Page, account: E2EAccount, path = "/auth/login") {+ await page.goto(path);await page.getByLabel("Email Address", { exact: true }).fill(account.email);await page.getByLabel("Password", { exact: true }).fill(account.password);await page.getByRole("button", { name: "Sign in" }).click();diff --git a/tests/e2e/specs/auth.spec.ts b/tests/e2e/specs/auth.spec.tsindex a6f16a656..e26dd07ed 100644--- a/tests/e2e/specs/auth.spec.ts+++ b/tests/e2e/specs/auth.spec.ts@@ -2,12 +2,21 @@ import { loginViaUi, logoutViaUi, registerViaUi } from "../fixtures/auth";import { expect, test } from "../fixtures/test";test("registers and logs in with email credentials", async ({ page, account }) => {- await registerViaUi(page, account);+ let documentRequests = 0;+ page.on("request", (request) => {+ if (request.isNavigationRequest() && request.frame() === page.mainFrame()) documentRequests++;+ });+ await registerViaUi(page, account, "/dashboard?from=signup#documents");await expect(page.getByRole("heading", { name: "Documents", level: 1 })).toBeVisible();+ await expect(page).toHaveURL(/\/dashboard\?from=signup#documents$/);+ expect(documentRequests).toBe(1);await logoutViaUi(page, account);await expect(page.getByRole("heading", { name: "Sign in to your account" })).toBeVisible();- await loginViaUi(page, account);+ const beforeLogin = documentRequests;+ await loginViaUi(page, account, "/dashboard?from=login#documents");await expect(page.getByRole("heading", { name: "Documents", level: 1 })).toBeVisible();+ await expect(page).toHaveURL(/\/dashboard\?from=login#documents$/);+ expect(documentRequests).toBe(beforeLogin + 1);});