Repository navigation
feat: localized block-based mail templating via ilingo & @authup/i18n - #3109
Conversation
Refactor the email templating mechanism for the identity workflows
(registration activation, password reset):
- @authup/i18n: new `authupMail` namespace (TranslatorTranslationMailKey,
catalogs/{en,de,fr,es}/mail.ts) holding transactional mail copy with
ilingo `{{var}}` placeholders; covered by the locale-parity test.
- server-core mail engine: typed block model (paragraph/code/action/note)
in core/mail/format — html and text multipart bodies derive from the
same block list with centralized escaping, <html lang>, and a hidden
preheader. Templates (core/mail/template) compose blocks and resolve
copy per locale through Ilingo + MemoryStore(CATALOGS); async render()
so file-/remote-backed override stores can slot in later.
- locale threading: useRequestLocale() resolves the first authored locale
from the vc-locale cookie or routup's q-ordered Accept-Language chain;
controllers pass it via IdentityWorkflowContext into the services.
- hardening: action URLs are dropped unless http(s) (javascript: defense
in depth); PASSWORD_RESET_EXPIRES_IN_MINUTES drives both reset_expires
and a localized expiry note; missing translations throw InternalError.
- wiring: MailTemplateRendererInjectionKey registered by MailModule
(singleton) and resolved by the controller factories.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (51)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThis PR implements a localized mail template system with block-based document rendering, i18n integration, and dependency injection wiring. Request locale is extracted from cookies or Accept-Language headers and threaded through registration and password recovery workflows. Mail templates are refactored from simple strings to typed, composable blocks that render to both HTML (with styling and XSS escaping) and plain text. The system adds a new ChangesLocalized Mail Template System
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
authup
@authup/client-web
@authup/server-core
@authup/access
@authup/client-web-kit
@authup/client-web-kit-theme
@authup/client-web-nuxt
@authup/client-web-theme
@authup/core-http-kit
@authup/core-kit
@authup/core-realtime-kit
@authup/errors
@authup/i18n
@authup/kit
@authup/server-adapter-kit
@authup/server-adapter-node
@authup/server-adapter-socket-io
@authup/server-adapter-web
@authup/server-kit
@authup/server-test-kit
@authup/specs
commit: |
Summary
Refactors and strengthens the email templating mechanism for the identity workflows (registration activation, password reset). Previously: mail copy was a hand-rolled per-locale record in
core/mail/templates.tswith its own locale narrowing + interpolation, a single hardcoded HTML shell, and — although four locales were authored — no caller ever passed a locale, so every recipient got English.Copy →
@authup/i18n/ ilingoauthupMailnamespace (TranslatorTranslationMailKey,catalogs/{en,de,fr,es}/mail.ts) with ilingo{{var}}placeholders (e.g.passwordResetExpiry→{{minutes}}).NamespaceTranslations<K>makes a missing key a compile error.Ilingo+MemoryStore({ data: CATALOGS })(new runtime deps:@authup/i18n,ilingo). A missing key throwsInternalErrorinstead of rendering a hole.Structure → typed block model (
core/mail/format+core/mail/template)paragraph/code/action/noteblocks viadefineMailTemplate; the html and text multipart bodies derive from the same block list, so they cannot drift.<html lang>from the resolved locale, hidden preheader for mail-client preview lines.render()/build()are async so a file-backed (FSStore) or remote override store can slot in later without an interface change (planned follow-up: operator-overridable templates from disk).Locale threading (localization actually works now)
useRequestLocale(event):vc-localecookie when it maps onto an authored locale (auto/unsupported fall through) → first supported language in routup's q-orderedgetRequestAcceptableLanguages(pt-BR, de;q=0.8→de).IdentityWorkflowContextinto the services.Hardening
javascript:defense in depth.PASSWORD_RESET_EXPIRES_IN_MINUTESdrives both the persistedreset_expiresand a localized "expires in 30 minutes" note; both mails gained a "you can safely ignore this email" hint.MailTemplateRendererInjectionKeyregistered byMailModule(singleton), resolved by controller factories — a custom renderer is a registration swap.Tests
packages/i18n: 77 passed (parity incl.authupMail).apps/server-core: full suite 859 passed / 87 files; new per-locale render smoke matrix (templates.spec.ts), renderer hardening specs (escaping, URL guard, lang attr, preheader, expiry), service-level locale-flow specs.🤖 Generated with Claude Code
Summary by CodeRabbit