MCP site tools, Turnstile key alert, required 2FA injection, a11y, more tests
- MCP: new get_site_info and list_pages tools (public by design, published
and indexable content only); search results collapse the homepage to root.
New listContent() helper shared with searchContent.
- Dashboard alert when Turnstile is half-configured (it is silently off then).
- twoFactor.plugin is now required; the dynamic-import fallback (which never
worked under Next and caused a Turbopack warning) is gone.
- a11y: cookie category checkboxes are labelled, buttons have type, test-email
input is labelled; tab labels keep localized collection labels.
- IPAL_IP_HEADER: one-time production warning when unset, opt-in
ipalEnvRules({ ipHeader: true }).
- Tests: SEO/robots/sitemap/hreflang, CSP, Markdown, consent, MCP, and a real
Payload + SQLite integration test for forms and the roles guard (74 total).
- Drop unused mongodb-memory-server; dev .env.example for SQLite.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+12
-36
@@ -58,10 +58,10 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
|
||||
// --- enforced 2FA (TOTP) via @clocklimited/payload-2fa ---
|
||||
// Enforced by default (forceSetup) unless twoFactor is explicitly false. The
|
||||
// plugin is a PEER dependency imported dynamically — ipal-kit doesn't bundle
|
||||
// it, so projects that opt out (twoFactor: false) needn't install it, and the
|
||||
// import never runs under generate:importmap when 2FA is off. Wrapping access
|
||||
// control (not just admin UI) means TOTP gates data access — no API bypass.
|
||||
// package is an optional PEER the project injects — ipal-kit doesn't bundle
|
||||
// or import it, so projects that opt out (twoFactor: false) needn't install it.
|
||||
// Wrapping access control (not just admin UI) means TOTP gates data access —
|
||||
// no API bypass.
|
||||
if (options.twoFactor !== false) {
|
||||
const tf = options.twoFactor
|
||||
if (!tf?.issuer) {
|
||||
@@ -71,41 +71,17 @@ export const ipalKit = (options: IpalOptions): Plugin => {
|
||||
'opt out (discouraged).',
|
||||
)
|
||||
}
|
||||
// Prefer the INJECTED plugin factory (recommended): the project imports
|
||||
// payloadTotp from @clocklimited/payload-2fa and passes it in. Then the
|
||||
// plugin never imports the optional peer itself — no dynamic import, so
|
||||
// Next can't fail to bundle it (the cause of "Cannot find module
|
||||
// '@clocklimited/payload-2fa'" crashing even public frontend pages).
|
||||
let totp: TotpPluginFactory | undefined = tf.plugin
|
||||
|
||||
if (!totp) {
|
||||
// Fallback: dynamic import, resolvable because the package is an optional
|
||||
// peer. Variable specifier dodges the plugin's own TS2307. Works only
|
||||
// outside Next (payload CLI): webpack turns it into an empty context, and
|
||||
// serverExternalPackages fails on the package's own .css imports — in
|
||||
// Next the project MUST inject `plugin` (see docs/security.md).
|
||||
try {
|
||||
const pkg = '@clocklimited/payload-2fa'
|
||||
const mod = (await import(pkg)) as {
|
||||
payloadTotp?: TotpPluginFactory
|
||||
totpPlugin?: TotpPluginFactory
|
||||
}
|
||||
totp = mod.payloadTotp ?? mod.totpPlugin
|
||||
} catch (err) {
|
||||
throw new Error(
|
||||
'[ipal] 2FA is enforced but @clocklimited/payload-2fa could not be loaded. ' +
|
||||
'Inject it (required in Next): `import { payloadTotp } from "@clocklimited/payload-2fa"` ' +
|
||||
'then `twoFactor: { issuer, plugin: payloadTotp }`. Adding it to ' +
|
||||
'serverExternalPackages does NOT help (the package imports .css). Or set ' +
|
||||
`twoFactor: false to opt out (discouraged). Original error: ${String(err)}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
// The project INJECTS the factory (twoFactor.plugin = payloadTotp) — the
|
||||
// plugin never imports the optional peer itself, so Next has nothing it
|
||||
// can't bundle. See TotpPluginFactory / docs/security.md.
|
||||
const totp: TotpPluginFactory | undefined = tf.plugin
|
||||
|
||||
if (typeof totp !== 'function') {
|
||||
throw new Error(
|
||||
'[ipal] 2FA: expected payloadTotp (or totpPlugin) to be a function — check the ' +
|
||||
'injected `plugin` or the installed @clocklimited/payload-2fa version.',
|
||||
'[ipal] 2FA is enforced but no 2FA plugin was injected. Add ' +
|
||||
'`import { payloadTotp } from "@clocklimited/payload-2fa"` and pass ' +
|
||||
'`twoFactor: { issuer, plugin: payloadTotp }`. Or set twoFactor: false ' +
|
||||
'to opt out (discouraged).',
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user