Skip to content

fix(auth,core): accept multiple origins for passkey verification - #800

Merged
ascorbic merged 4 commits into
emdash-cms:mainfrom
csfalcao:fix/passkey-multi-origin
Apr 29, 2026
Merged

ascorbic merged 4 commits into
emdash-cms:mainfrom
csfalcao:fix/passkey-multi-origin

Conversation

@csfalcao

Copy link
Copy Markdown
Contributor

What does this PR do?

Lifts the single-origin restriction on passkey verification so deployments serving the same EmDash instance from multiple hostnames (apex + preview/staging subdomains, all sharing one rpId) can verify passkeys without re-registering on each origin.

The strict equality check clientData.origin !== config.origin in register.ts and authenticate.ts is replaced with a list-membership check. PasskeyConfig.origin: string becomes origins: string[]. A new EMDASH_ALLOWED_ORIGINS env var (comma-separated) lets operators declare the additional accepted origins; siteUrl continues to control rpId.

Closes #799

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

AI-generated code disclosure

  • This PR includes AI-generated code

Implementation notes

Type change. packages/auth/src/passkey/types.ts now declares PasskeyConfig.origins: string[] instead of origin: string. Per the project's pre-release rules (no backward-compat, no migration paths), the rename is direct.

Verification. register.ts and authenticate.ts both replace clientData.origin !== config.origin with !config.origins.includes(clientData.origin). Same security posture — origin still has to be in an explicit list — just multi-entry instead of single.

Helper. getPasskeyConfig() in packages/core/src/auth/passkey-config.ts gains a fourth optional argument allowedOrigins?: string[]. The canonical origin (from siteUrl or url.origin) goes first; allowed origins follow, deduplicated; empty/falsy entries are dropped.

Env var. getEnvAllowedOrigins() in packages/core/src/api/public-url.ts mirrors the existing getEnvSiteUrl() pattern: reads process.env.EMDASH_ALLOWED_ORIGINS, parses each comma-separated entry through new URL(), normalizes to origin, drops non-http(s)/unparseable entries, caches.

Plumbed only where it's read. Only the 5 verify routes (setup/admin-verify, auth/passkey/verify, auth/passkey/register/verify, auth/signup/complete, auth/invite/complete) pass getEnvAllowedOrigins() into getPasskeyConfig. The 4 options-generating routes were left alone — they don't read origins.

Tests. Following "TDD for bugs":

  • packages/auth/src/passkey/authenticate.test.ts — cross-subdomain reject and accept tests (the reject case fails on the old code; the accept case is the fix's reason for existing). register.ts is not separately tested because its origin-check is the identical 3-line block — the auth tests cover the shared semantics.
  • packages/core/tests/unit/auth/passkey-config.test.ts — 5 new tests covering append, canonical-first when no siteUrl, dedupe of repeated canonical, empty-entry skip, empty allowedOrigins. Existing assertions migrated from config.origin to config.origins[0].
  • packages/core/tests/unit/api/public-url.test.ts — 7 new tests covering getEnvAllowedOrigins(): unset, comma-list, whitespace trim, origin normalization, protocol filter, unparseable skip, cache invalidation.

Docs. docs/src/content/docs/reference/configuration.mdx gets a new "Multi-origin passkey verification" subsection under Site URL, plus an EMDASH_ALLOWED_ORIGINS row in the Environment Variables table.

Test output

@emdash-cms/auth — 49 tests pass
  src/passkey/authenticate.test.ts (4 tests)  ✓ rejects an origin that is not in the accepted list
                                              ✓ accepts an assertion from a subdomain when its origin is listed under a shared rpId

emdash (core)
  tests/unit/auth/passkey-config.test.ts      ✓ 22 tests (was 17)
  tests/unit/api/public-url.test.ts           ✓ 21 tests (was 14)

Closes emdash-cms#799

PasskeyConfig.origin (single string) becomes origins (string[]); register
and authenticate verify against the list via .includes(). getPasskeyConfig
takes an optional allowedOrigins 4th argument; verify routes pass the
parsed contents of EMDASH_ALLOWED_ORIGINS.

This unblocks deployments where one EmDash instance is reachable under
several hostnames sharing a registrable parent (apex + preview/staging),
which WebAuthn supports via shared rpId but EmDash previously rejected
with a strict origin-equality check.
@changeset-bot

changeset-bot Bot commented Apr 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6fb9df8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
emdash Minor
@emdash-cms/auth Minor
@emdash-cms/cloudflare Minor
@emdash-cms/fixture-perf-site Patch
@emdash-cms/perf-demo-site Patch
@emdash-cms/cache-demo-site Patch
@emdash-cms/auth-atproto Patch
@emdash-cms/admin Minor
@emdash-cms/blocks Minor
@emdash-cms/gutenberg-to-portable-text Minor
@emdash-cms/x402 Minor
create-emdash Minor
@emdash-cms/plugin-embeds Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Apr 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@800

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@800

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@800

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@800

emdash

npm i https://pkg.pr.new/emdash@800

create-emdash

npm i https://pkg.pr.new/create-emdash@800

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@800

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@800

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@800

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@800

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@800

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@800

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@800

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@800

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@800

commit: 6fb9df8

@ascorbic

Copy link
Copy Markdown
Member

/ultrareview

@ask-bonk ask-bonk Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid bug fix. The core change (single-origin → list-membership) is small, the type rename is clean, and the test coverage at both the auth-package boundary (cross-subdomain reject + accept) and the core helper (canonical-first, dedupe, empty-skip) hits the right invariants. I confirmed the security posture is preserved: rpId is still derived from siteUrl (so the credential is bound to the registrable parent), verifyRelyingPartyIdHash(config.rpId) still runs after the origin check, and clientData.origin is normalized by the browser the same way new URL().origin normalizes the configured list.

Findings, in priority order:

1. Config-vs-env asymmetry (medium). EmDashConfig.siteUrl is a config-level option (validated at startup in integration/index.ts), but there's no parallel EmDashConfig.allowedOrigins. That means Cloudflare Workers users — who can't read process.env and therefore set siteUrl in astro.config.mjs instead — have no path to multi-origin support. The PR's own JSDoc on getEnvAllowedOrigins even acknowledges this gap ("unavailable on Cloudflare Workers"), but doesn't close it.

Recommend adding allowedOrigins?: string[] to EmDashConfig (in packages/core/src/astro/integration/runtime.ts next to siteUrl at line 272), validating it in integration/index.ts next to siteUrl, and merging it with the env value in the 5 verify routes:

getPasskeyConfig(
  url, siteName, siteUrl,
  [...(emdash?.config?.allowedOrigins ?? []), ...getEnvAllowedOrigins()],
);

getPasskeyConfig already dedupes. This is the same model siteUrl already uses, and without it the changeset's claim of "multi-origin support" is partial.

2. Docs claim isn't enforced (low). The new docs section says "Each origin must share the registrable parent domain with siteUrl — this is a WebAuthn requirement, not an EmDash one." That's true at the browser layer (the authenticator only signs assertions for an rpId that's a registrable suffix of the document origin), but it's worth noting that an operator who lists an unrelated origin in EMDASH_ALLOWED_ORIGINS won't get an error from EmDash — they just won't get any working assertions either. Suggestion inline.

3. Cache reset helper is misnamed (nit). _resetEnvSiteUrlCache() now also clears _envAllowedOrigins. The name and JSDoc still suggest single-purpose. Suggestion inline.

4. register.ts origin-check is untested (low). The justification in the PR description is reasonable (the 3-line block is identical to authenticate.ts), but the two implementations have already diverged once — register.ts throws plain Error while authenticate.ts throws PasskeyAuthenticationError with a code. A one-line test would lock in the parity at near-zero cost.

None of these block the fix. (1) is the only one I'd want to see addressed before this is called "complete".

/** @internal Reset cached env values — test-only. */
export function _resetEnvSiteUrlCache(): void {
_envSiteUrl = null;
_envAllowedOrigins = null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function name is now misleading — it resets both caches, not just the site-url one. The JSDoc one line above still says "cached env value" (singular). Either rename or split. If you keep one helper, at least update the doc comment and consider:

Suggested change
_envAllowedOrigins = null;
/** @internal Reset cached env values — test-only. */
export function _resetEnvCache(): void {
_envSiteUrl = null;
_envAllowedOrigins = null;
}
// Backward-compat alias for existing tests; remove next pass.
export const _resetEnvSiteUrlCache = _resetEnvCache;

Not blocking, but the next time another env helper is added the pattern starts looking accidental.


export function getEnvAllowedOrigins(): string[] {
if (_envAllowedOrigins !== null) return _envAllowedOrigins;
const raw = typeof process !== "undefined" ? process.env?.EMDASH_ALLOWED_ORIGINS || "" : "";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: process.env?.EMDASH_ALLOWED_ORIGINS || "" makes the empty string and the unset case indistinguishable, which is fine here, but means you can't tell from _envAllowedOrigins alone whether the user explicitly set EMDASH_ALLOWED_ORIGINS= to override an upstream value. Probably not worth changing — just flagging for the future if config + env are ever merged.

More importantly: this function only works when process.env is available. On Cloudflare Workers it always returns []. Without a corresponding EmDashConfig.allowedOrigins field (see top-level review comment), Workers deployments have no way to opt into multi-origin verification. That's the main gap I'd want closed before this is called complete.

throw new Error(`Invalid origin: expected ${config.origin}, got ${clientData.origin}`);
// Verify origin against the accepted list
if (!config.origins.includes(clientData.origin)) {
throw new Error(`Invalid origin: ${clientData.origin} not in [${config.origins.join(", ")}]`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function isn't directly covered by the new tests (the PR description acknowledges this). The two implementations have already diverged once — register.ts throws plain Error while authenticate.ts throws a typed PasskeyAuthenticationError with a code. A one-line test against verifyRegistrationResponse rejecting an off-list origin would lock in the parity at near-zero cost and catch future drift. Not blocking.

EMDASH_ALLOWED_ORIGINS=https://preview.example.com,https://staging.example.com
```

Each entry must be a valid `http:` or `https:` URL; entries are reduced to their origin (path/query stripped). Each origin must share the registrable parent domain with `siteUrl` -- this is a WebAuthn requirement, not an EmDash one.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth being explicit that EmDash does not validate the registrable-parent constraint. The browser enforces it (the authenticator only signs assertions for an rpId that's a registrable suffix of the document origin), but if an operator lists https://unrelated.example in EMDASH_ALLOWED_ORIGINS, EmDash won't error — they just won't get any working assertions from there.

Suggested change
Each entry must be a valid `http:` or `https:` URL; entries are reduced to their origin (path/query stripped). Each origin must share the registrable parent domain with `siteUrl` -- this is a WebAuthn requirement, not an EmDash one.
Each entry must be a valid `http:` or `https:` URL; entries are reduced to their origin (path/query stripped). Each origin must share the registrable parent domain with `siteUrl` -- this is a WebAuthn requirement enforced by the browser, not by EmDash. Listing an unrelated origin will not produce an error here, but the browser will refuse to sign assertions for it.

@ask-bonk

ask-bonk Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Review submitted successfully — #800 (review)

Posted review with 4 inline comments. Summary of findings:

  1. Medium — config-vs-env asymmetry. EmDashConfig.siteUrl works at the config level for Workers users, but there's no parallel EmDashConfig.allowedOrigins. Cloudflare Workers deployments can't read process.env, so they have no path to multi-origin support. The PR's own JSDoc admits this. Recommended adding the field and merging both sources in the 5 verify routes.
  2. Low — docs claim isn't enforced. The "WebAuthn requirement, not EmDash" wording could mislead — EmDash won't error on a misconfigured origin, the browser just won't sign assertions there. Suggested clearer wording.
  3. Nit — cache reset helper misnamed. _resetEnvSiteUrlCache() now also resets _envAllowedOrigins. Suggested rename + alias.
  4. Low — register.ts origin-check is untested. The two implementations have diverged once (different exception types); a one-line test would lock in parity.

Security posture is preserved: rpId is still derived from siteUrl, the rpIdHash check still runs after origin verification, and origin normalization (via new URL().origin) matches the browser's clientData.origin normalization.

github run

@ascorbic ascorbic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Good addition, I just have a few comments

Comment thread packages/core/src/api/public-url.ts Outdated
Comment on lines +85 to +87
* Like `getEnvSiteUrl`, uses `process.env` (Vite leaves it untouched at
* runtime) and is unavailable on Cloudflare Workers, where `env` bindings
* provide values instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process.env is available on Workers, because we have nodejs_compat enabled

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in V2 (f580326) — dropped the wrong claim from getEnvAllowedOrigins's docstring.

Heads-up: the same incorrect claim still sits in the pre-existing getEnvSiteUrl docstring (public-url.ts lines 22-23). Out of scope for this PR per the no-drive-by rule, but happy to fold that one-line fix in if you'd prefer — let me know.

*/
let _envAllowedOrigins: string[] | null = null;

export function getEnvAllowedOrigins(): string[] {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do the same as siteUrl and allow passing the value in config too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in V2 (f580326). Added EmDashConfig.allowedOrigins?: string[] next to siteUrl in integration/runtime.ts. Config and EMDASH_ALLOWED_ORIGINS are merged at runtime (rather than precedence-style like siteUrl) — the rationale: each entry is an independent permission, so list-union is the natural operation. This lets versioned astro.config.mjs declare stable origins while env adds environment-specific extras (e.g. ephemeral PR-preview URLs).

Plumbing follows your earlier architectural note about env vars being runtime: getConfiguredAllowedOrigins(config) (in the new auth/allowed-origins.ts) merges both sources tagged-by-source, then validateAllowedOrigins(siteUrl, tagged) validates the effective set at the runtime chokepoint. Config-side validation also runs at integration init — but only the shape rules (parseable, http/https, no trailing dots, no empty labels), since siteUrl may come from EMDASH_SITE_URL post-build. When config.siteUrl IS present at init, the full validator runs for fail-fast.

Comment on lines +27 to 30
* @param allowedOrigins Optional list of additional accepted origins for verification.
* Each must share `rpId` with the canonical origin (WebAuthn requirement).
* Typical use: apex + preview subdomain on the same registrable domain.
* @throws If `siteUrl` is non-empty but not parseable by `new URL()`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to validate this: require siteUrl to be set, and for all allowedOrigins to be subdomains.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in V2 (f580326). Validation lives in auth/allowed-origins.ts as a shared module with two entry points:

  • validateOriginShape(tagged) — per-entry rules only (parseable URL, http/https, no trailing-dot hostname, no empty labels). Used by integration init when config.siteUrl is absent (since env can supply it post-build).
  • validateAllowedOrigins(siteUrl, tagged) — full validation, including Rule A (allowedOrigins non-empty ⇒ siteUrl required), Rule B (each origin must be the same hostname as siteUrl or a subdomain — leading-dot suffix check, so fakeexample.com and example.com.evil.com both reject), and rejecting IP-literal siteUrl or trailing-dot siteUrl when allowedOrigins is non-empty.

Errors are source-attributed (config.allowedOrigins vs EMDASH_ALLOWED_ORIGINS) so operators see where the offending value came from. Coverage: 27 unit tests in tests/unit/auth/allowed-origins.test.ts — including suffix-attacker (example.com.evil.com), prefix-attacker (fakeexample.com), apex-listed-under-subdomain-siteUrl, IP-literal v4/v6, dedupe across sources, and source-attribution-of-the-offending-entry.

Two related judgment calls I held off on, both worth flagging:

  • http:// rejection for non-localhost origins: the browser refuses http:// WebAuthn outside localhost anyway, so listing one is dead config. Adding ~5 lines of rejection would catch it at startup. Held off because it goes beyond your ask — happy to add if you want it.
  • Trailing-dot rejection in siteUrl outside the multi-origin path: same class of mismatch, but pre-existing concern beyond this PR. Could be a separate one-liner in integration/index.ts's siteUrl validator.

Addresses review feedback on PR emdash-cms#800:

- Add EmDashConfig.allowedOrigins config field as a parallel to siteUrl
  (maintainer ascorbic: "Can we do the same as siteUrl and allow passing
  the value in config too").
- Validate the merged effective set (config + EMDASH_ALLOWED_ORIGINS) at
  the runtime chokepoint in 5 verify routes. Validation throws loud,
  source-attributed errors covering: Rule A (allowedOrigins requires
  siteUrl), Rule B (each origin must be the same hostname as siteUrl or a
  subdomain), and shape rules (parseable URL, http/https only, no
  trailing-dot hostname, no empty labels). Reject IP-literal siteUrl and
  trailing-dot siteUrl when allowedOrigins is non-empty (multi-origin
  rpId requires a real domain).
- Validate config.allowedOrigins shape at integration init; defer
  siteUrl-dependent rules to runtime when config.siteUrl is absent
  (EMDASH_SITE_URL may supply it post-build per existing siteUrl pattern
  in integration/index.ts).
- Throw loud on invalid EMDASH_ALLOWED_ORIGINS entries instead of silent
  skip; an allowlist that drops typos masks real config errors.
- Rename internal _resetEnvSiteUrlCache to _resetEnvCache (it now resets
  both site-url and allowed-origins caches).
- Fix the docstring on getEnvAllowedOrigins that incorrectly claimed
  process.env was unavailable on Workers (it is, with nodejs_compat).
- Add focused register.test.ts off-list-origin test to lock in
  origin-check parity with authenticate.ts.
@csfalcao

Copy link
Copy Markdown
Contributor Author

V2 pushed (f580326)

Addresses all three of your comments. Summary:

Architecture changes

  • New packages/core/src/auth/allowed-origins.ts module — pure resolution + validation, source-tagged
  • getPasskeyConfig() stays a pure builder (validation moved out)
  • Validation runs at the runtime chokepoint (5 verify routes); config-side shape rules also run at integration init when config.siteUrl is present

Surface additions

  • EmDashConfig.allowedOrigins?: string[] (declared in astro.config.mjs)
  • Existing EMDASH_ALLOWED_ORIGINS env var still works; merges with config
  • getEnvAllowedOrigins() now throws on invalid entries (was: silent skip — wrong for an allowlist)
  • Internal _resetEnvSiteUrlCache → _resetEnvCache (it now resets both caches)

Validation rules (all with source-attributed errors)

  • Per-entry: parseable URL, http/https only, no trailing-dot hostname, no empty labels in hostname
  • Rule A: allowedOrigins non-empty ⇒ siteUrl required
  • Rule B: each origin must be the same hostname as siteUrl or a true subdomain (leading-dot suffix check)
  • Reject IP-literal siteUrl and trailing-dot siteUrl when allowedOrigins is non-empty

Test coverage

  • 27 new tests in tests/unit/auth/allowed-origins.test.ts (security cases: suffix-attacker, prefix-attacker, apex-under-subdomain, IP literals, source attribution, dedupe across sources)
  • New packages/auth/src/passkey/register.test.ts locks in origin-check parity with authenticate.ts (Bot review ci: release #4)
  • Updated public-url.test.ts for the rename + new throw cases (21/21 ✓)

Local verification

  • pnpm --filter emdash typecheck ✓
  • pnpm --filter @emdash-cms/auth typecheck ✓
  • pnpm --filter @emdash-cms/auth test 5/5 files ✓
  • pnpm --filter emdash test matches main baseline (2 pre-existing failures in invite.test.ts and passkey-verify-route.test.ts, none added by V2)
  • pnpm --silent lint:json 12 diagnostics (one fewer than V1; nothing new in files I touched)
  • pnpm format applied

Replied inline to each of your three comments above with where the change landed and the rationale where I deviated (merge vs precedence for allowedOrigins, validation placement).

@ascorbic ascorbic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ascorbic

Copy link
Copy Markdown
Member

/bonk fix the formatting issue

@ask-bonk ask-bonk Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the previous review feedback so thoroughly. The V2 architecture (allowed-origins.ts as a pure validation module, config+env merging, source-attributed errors) is clean and the test coverage is comprehensive.

However, there is one blocking issue that prevents this from compiling:

Comment on lines +333 to 335
*/
allowedOrigins?: string[];
* Headers to trust for client IP resolution when running behind a reverse

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The /** JSDoc opener for trustedProxyHeaders was accidentally deleted during insertion. The line * Headers to trust... is now outside any comment, which is a syntax error. pnpm typecheck fails with ~13 cascading errors starting here.

Suggested change
*/
allowedOrigins?: string[];
* Headers to trust for client IP resolution when running behind a reverse
/**
* Headers to trust for client IP resolution when running behind a reverse

@ask-bonk

ask-bonk Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Posted a review on PR #800: #800 (review)

Finding: One blocking syntax error in packages/core/src/astro/integration/runtime.ts. When the allowedOrigins property and its JSDoc were inserted, the /** opener for the next property's JSDoc (trustedProxyHeaders) was accidentally deleted. The line * Headers to trust... now sits outside any comment, causing a TypeScript syntax error and cascading typecheck failures (~13 errors starting at line 335).

Fix is straightforward: restore /** on the line before * Headers to trust....

github run

@ascorbic
ascorbic enabled auto-merge (squash) April 29, 2026 06:22
@ascorbic
ascorbic merged commit e2d5d16 into emdash-cms:main Apr 29, 2026
28 checks passed
@emdashbot emdashbot Bot mentioned this pull request Apr 29, 2026
ascorbic added a commit that referenced this pull request Apr 29, 2026
* perf: cache site:* settings prefix scan across requests

Site settings change rarely but were re-fetched on every public page
load. A globalThis-scoped holder caches the resolved settings until the
next site:* write bumps its version, dropping one prefix-scan query per
public route. Cross-isolate staleness is bounded by isolate lifetime.

* fix(core): invalidate site-settings cache on partial-write failure

OptionsRepository.setMany iterates row-by-row without a transaction. If
a write fails mid-loop, earlier rows are committed but
invalidateSiteSettingsCache() never ran — leaving the globalThis cache
pointing at pre-write data while the DB has post-write data on some
rows. Wrapping the call in try/finally guarantees invalidation runs
whether the write succeeded or threw.

Adversarial-review finding from PR #800-class perf branch.

* ci: update query-count snapshots

* ci: update query-count snapshots

---------

Co-authored-by: emdashbot[bot] <emdashbot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Passkey verification rejects valid origins under shared rpId (multi-subdomain deployments)

2 participants