Repository navigation
[M2.2c3a] Deliver identity mail through encrypted durable jobs - #46
Merged
Merged
Conversation
6 tasks done
samuelmbabhazi
force-pushed
the
feat/m2.2c2-auth-throttling
branch
from
November 5, 2026 12:15
bef50e9 to
2a43b7b
Compare
samuelmbabhazi
changed the base branch from
feat/m2.2c2-auth-throttling
to
main
November 5, 2026 12:15
samuelmbabhazi
force-pushed
the
feat/m2.2c3a-private-mail-queue
branch
from
November 5, 2026 12:15
38054d9 to
0c74633
Compare
samuelmbabhazi
added a commit
that referenced
this pull request
Nov 5, 2026
## Task M2.2c3b, part of #21. Depends on #46; base `feat/m2.2c3a-private-mail-queue`. ## What changed and why Add SMTP delivery over implicit TLS with mandatory certificate-chain/hostname verification and TLS 1.2 minimum. Configure the SMTP host, sender, optional credentials and optional public CA bundle through validated/redacting application configuration. A ten-second inactivity timeout and twenty-second total deadline bound delivery; sockets close on both success and failure. Emails link to a clean verification/reset page and provide a separate code to paste, keeping bearer credentials out of URLs. Public API URLs must be bare origins and use HTTPS in production. emailjs is pinned to MIT-licensed version 5.0.4. Providers must support implicit TLS (normally port 465); STARTTLS/plaintext SMTP is outside this implementation. ## Validation - Thirty-eight integration tests pass, including four tests against a real loopback TLS SMTP server: successful authenticated delivery, untrusted certificate rejection, hostname mismatch rejection and header injection/expired credential handling. - Unit tests enforce the total deadline, transport-error redaction, socket cleanup and SMTP/public-origin configuration constraints. - Workspace types, builds and TypeScript tests pass; lint passes after fixture type checks. - No message was sent to an external email service; TLS keys and the test CA are generated at runtime and cleaned up. ## Security considerations There is no TLS verification bypass. SMTP credentials are exposed only to the transport and protocol logging is disabled. Untrusted certificates fail before SMTP authentication. Transport errors are opaque before the durable worker sees them. Production signup endpoints still await HTTP integration in M2.2c4. ## Checklist - [x] M2.2c3 delivery acceptance checked; HTTP flows remain open - [x] Lint, types, builds, unit and integration tests pass - [x] Real TLS negative tests and deadline tests included - [x] No shell invocation, committed key/certificate or credential URL - [x] Durable delivery remains coupled to audited commands - [x] Configuration example, SPEC and threat model updated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task
M2.2c3a, part of #21. Depends on #45; base
feat/m2.2c2-auth-throttling.What changed and why
Enqueue identity emails atomically with account/credential/audit changes using pg-boss and its upstream Prisma transaction adapter. Email addresses, credentials and expiration are envelope-encrypted with authenticated data tied to the job id. A separate worker retries delivery up to five times with capped backoff, skips expired credentials and sanitizes every persisted worker error.
Add the pg-boss lifecycle owner with bounded database connections and graceful shutdown. The MIT-licensed dependency is pinned to 12.38.0 and implements the queue already chosen in ADR 0004. Production SMTP wiring follows in M2.2c3b; no endpoint is exposed by this PR.
Validation
Security considerations
Queue and schema names are fixed. The upstream Prisma adapter executes pg-boss SQL with separately bound values inside the current transaction; request values never form SQL identifiers or query text. Only ciphertext reaches queue tables. Worker exceptions omit transport responses and validation details. Plaintext buffers are cleared after encryption/decryption. SMTP transport is an injected port, exercised separately in the next PR.
Checklist