bin ipal-doctor + @intecion/ipal-kit/doctor: static rules (versions, Node 22, AGENT.md §3 layout and naming, database names, env rules, headers, X-Powered-By, CSP, 2FA, cookie scanner, adminMeta, AGENTS.md, skills, seeds, block library via blockLibraryManifest, ipal-audit --quick), registry rules (latest plugin, pnpm audit --prod), live rules (--url, ipal-seo-check), deep rules (--deep via payload run; GET /api/ipal/doctor, off until IPAL_DOCTOR_TOKEN). Human / JSON output, --strict, exit codes 0/1/2/3, --sites drift table, ipal-doctor.json with reasons, until, files, seen. Fixes found on the way: sitemap leaves out the System pages 404 page; ipal-audit finds array labels after fields, any form seed, runs grep in UTF-8; ipal-seo-check counts duplicate titles per language. Reference site at zero findings (static), CI steps on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
303 lines
13 KiB
TypeScript
303 lines
13 KiB
TypeScript
import type { CollectionSlug, Field, PayloadComponent, Plugin } from 'payload'
|
|
|
|
/**
|
|
* Factory shape of @clocklimited/payload-2fa's `payloadTotp` export — injected
|
|
* so the plugin never imports the optional peer itself. `collection` is
|
|
* `CollectionSlug` (not `string`): payloadTotp requires it, and in a project
|
|
* with generated payload-types it's a narrowed union — `string` would make
|
|
* `plugin: payloadTotp` fail to type-check.
|
|
*/
|
|
export type TotpPluginFactory = (options: {
|
|
collection: CollectionSlug
|
|
forceSetup: boolean
|
|
totp: { issuer: string }
|
|
}) => Plugin
|
|
import type { GlobalOverrides } from './globals/overrides.js'
|
|
import type { AccessOption } from './modules/access/types.js'
|
|
import type { AdminMetaOptions, AgencyOption } from './modules/branding/adminMeta.js'
|
|
import type { ConsentLogOptions } from './modules/consent/consentLog.js'
|
|
import type { CookieScannerOptions } from './modules/consent/scanner/types.js'
|
|
import type { ContentOption } from './modules/content/types.js'
|
|
import type { DoctorEndpointOptions } from './modules/doctor/status.js'
|
|
import type { FormsOption } from './modules/forms/types.js'
|
|
import type { RevalidatePathFn } from './modules/hooks/buildRevalidateHook.js'
|
|
import type { I18nConfig } from './modules/i18n/types.js'
|
|
import type { PagesOption } from './modules/pages/types.js'
|
|
import type { SeoOption } from './modules/seo/types.js'
|
|
import type { StatsOptions } from './modules/stats/collection.js'
|
|
|
|
/**
|
|
* Configuration options for the IPAL plugin.
|
|
* Passed by the client project in payload.config.ts.
|
|
*/
|
|
export type IpalOptions = {
|
|
/**
|
|
* Role-based access control. Injects a fixed `roles` field
|
|
* (admin > editor > user) into the client's auth collection.
|
|
*/
|
|
access?: AccessOption
|
|
|
|
/**
|
|
* Admin panel <head> for link previews and search engines (default on):
|
|
* noindex/nofollow, title suffix "— <site> | Panel", siteName and a short
|
|
* description from Site settings, a preview image drawn from the site's logo
|
|
* (GET /api/ipal/admin-og) and the site's favicon (GET /api/ipal/admin-icon).
|
|
* Keys the project sets in its own `admin.meta` always win. `false` = Payload's defaults.
|
|
*/
|
|
adminMeta?: AdminMetaOptions | false
|
|
|
|
/**
|
|
* Custom admin panel route, e.g. '/its' instead of the default '/admin'.
|
|
* The plugin sets config.routes.admin. IMPORTANT: this alone isn't enough —
|
|
* the project must ALSO move its panel folder to match:
|
|
* app/(payload)/its/[[...segments]]/page.tsx (and the not-found). The plugin
|
|
* can't create files in the project's app/. See docs/security.md.
|
|
*
|
|
* This is obscurity, not security: it hides the panel from dumb bots scanning
|
|
* /admin, but real protection is strong auth + 2FA + rate limiting.
|
|
*/
|
|
adminRoute?: string
|
|
|
|
/**
|
|
* Who supports the technology, named in the admin credit, the panel's link
|
|
* description and its preview image. Default `{ name: 'Intecion.com', url: 'https://intecion.com' }`.
|
|
* `false` = no agency anywhere.
|
|
*/
|
|
agency?: AgencyOption | false
|
|
|
|
/** Internationalization — locales, default locale, fallback behavior */
|
|
/**
|
|
* Consent log (proof of consent, GDPR Art. 7(1)): adds the `consent-records`
|
|
* collection and POST /api/ipal/consent. Pass `<ConsentProvider logEndpoint="/api/ipal/consent">`.
|
|
* Stores a random id, choices, policy version and time — no personal data.
|
|
* `true` or `{ retentionDays, collectionOverrides }` (default 1095 days). Default off.
|
|
*/
|
|
consentLog?: boolean | ConsentLogOptions
|
|
|
|
/**
|
|
* Collections whose entries live under an archive page — blog posts, case
|
|
* studies, anything with a listing. Adds an "archive page" assignment per
|
|
* collection in SiteSettings; the assigned page's localized slug becomes the
|
|
* URL segment (/pl/artykuly/moj-post, /en/articles/my-post). Requires `pages`.
|
|
*/
|
|
content?: ContentOption
|
|
|
|
/**
|
|
* Cookie scanner (docs/cookie-scanner.md): the `cookie-review` collection, a
|
|
* "Scan cookies" action above its list and GET/POST /api/ipal/cookie-scan. A
|
|
* scan lists the cookies of the integrations this project switches on, plus
|
|
* names looked up in the bundled Open Cookie Database, as drafts an editor
|
|
* accepts (→ Cookie Settings → Cookies), edits or rejects. Never deletes,
|
|
* never overwrites edited text, never publishes by itself.
|
|
* `true` or CookieScannerOptions. Default off.
|
|
*/
|
|
cookieScanner?: boolean | CookieScannerOptions
|
|
|
|
/**
|
|
* GET /api/ipal/doctor — read-only counts for `ipal-doctor --url` (users without 2FA, cookies
|
|
* waiting for approval, versions). Answers 404 until IPAL_DOCTOR_TOKEN (≥ 32 characters) is set;
|
|
* then a `Bearer` token is required. `false` = no endpoint; `{ tokenVar, access }` to adapt it.
|
|
* docs/doctor.md.
|
|
*/
|
|
doctor?: DoctorEndpointOptions | false
|
|
|
|
/**
|
|
* `false` = plugin off without uninstalling: its collections, globals and
|
|
* fields stay (DB schema and migrations unchanged), but it adds no endpoints,
|
|
* onInit work or admin components.
|
|
*/
|
|
enabled?: boolean
|
|
|
|
/**
|
|
* Text written in one language fills the same field in every language that is
|
|
* still empty; a language with its own text is never overwritten. Default on
|
|
* for the cookie list (`cookie-settings`: `cookies.purpose`, `cookies.duration`)
|
|
* and the cookie review (`cookie-review`: `purpose`, `retention`). `false` turns
|
|
* it off; an object sets the fields per slug (`[]` = off for that slug).
|
|
* Building blocks: buildFillEmptyLocalesGlobalHook / …CollectionHook.
|
|
*/
|
|
fillEmptyLocales?: { 'cookie-review'?: string[]; 'cookie-settings'?: string[] } | boolean
|
|
|
|
/**
|
|
* Forms — form-builder collections (forms, form-submissions) plus the
|
|
* callable submitForm (Turnstile + persistence + SMTP-from-panel email).
|
|
*/
|
|
forms?: FormsOption
|
|
|
|
/**
|
|
* Change any of the plugin's globals (site-settings, site-integrations,
|
|
* cookie-settings, notifications): an object merges over the plugin's
|
|
* (`access` / `admin` / `hooks` key by key, your keys win), a function gets
|
|
* the global and returns the one to use. E.g. let any logged-in user edit
|
|
* Notifications: `{ notifications: { access: { update: authenticated } } }`.
|
|
*/
|
|
globalOverrides?: GlobalOverrides
|
|
|
|
i18n: I18nConfig
|
|
|
|
/**
|
|
* IndexNow (seo/indexNow.ts): on publish, submit the page's URLs in every
|
|
* language to Bing & co. (feeds ChatGPT Search / Copilot). Adds the hook to the
|
|
* pages collection and every `content` collection. Production only. Needs the
|
|
* key file route createIndexNowKeyRoute. Default false.
|
|
*/
|
|
indexNow?: boolean
|
|
|
|
/** Additional fields injected into SiteIntegrations global */
|
|
integrationsFields?: Field[]
|
|
|
|
/**
|
|
* Image lightbox labels in the Notifications global (a "Lightbox" group:
|
|
* close, previous, next, counter, dialog name, trigger name), localized per
|
|
* language and read with getNotificationTexts(...).lightbox. Off by default —
|
|
* the components work without it on English fallbacks and the `texts` prop;
|
|
* turn it on so editors translate the labels. Adds columns: run a migration
|
|
* on Postgres. See docs/lightbox.md.
|
|
*/
|
|
lightbox?: boolean
|
|
|
|
/**
|
|
* System-page assignments (homepage, privacy, cookies) in SiteSettings.
|
|
* Provide the slug of the client's Pages collection to enable.
|
|
*/
|
|
pages?: PagesOption
|
|
|
|
/**
|
|
* next/cache `revalidatePath`, INJECTED (the plugin never imports next/cache).
|
|
* When given, saving any of the plugin's globals (Site Settings, Site
|
|
* Integrations, Cookie Settings, Notifications) revalidates the whole site
|
|
* layout, so logo, menu, consent texts and analytics IDs change at once
|
|
* instead of after the ISR window. See buildGlobalRevalidateHook.
|
|
*/
|
|
revalidatePath?: RevalidatePathFn
|
|
|
|
/**
|
|
* Site Settings → "Search & AI" tab (verification codes, AI crawler policy,
|
|
* llms.txt intro). On by default; `false` removes it; a function gets the
|
|
* plugin's fields and returns the tab's fields. Works without `seo`; wins
|
|
* over `seo.searchSettings`.
|
|
*/
|
|
searchSettings?: ((defaults: Field[]) => Field[]) | false
|
|
|
|
/**
|
|
* SEO — adds meta fields to chosen collections (via @payloadcms/plugin-seo)
|
|
* and enables locale-aware metadata helpers.
|
|
*/
|
|
seo?: SeoOption
|
|
|
|
/** Additional fields injected into SiteSettings global */
|
|
siteSettingsFields?: Field[]
|
|
|
|
/**
|
|
* Built-in statistics (docs/stats.md): the `stats-visits` collection,
|
|
* POST /api/ipal/hit, the /admin/stats view and a 30-day chart on the
|
|
* dashboard. The site mounts <PageStats> inside <ConsentProvider>.
|
|
* Cookieless and IP-free for everyone; visitors who accept analytics cookies
|
|
* also get a history across days. `true` or `{ retentionDays, timeZone,
|
|
* dashboard }`. Default off.
|
|
*/
|
|
stats?: boolean | StatsOptions
|
|
|
|
/**
|
|
* Light / dark theme. `storageKey`: the localStorage key of the visitor's
|
|
* choice — default `theme` (the next-themes key and values, so a project using
|
|
* next-themes too shares one choice). getSiteShell().theme passes it to
|
|
* <ThemeScript>, which puts it on <html> for useTheme / ThemeSwitcher.
|
|
*/
|
|
theme?: ThemeOptions
|
|
|
|
/**
|
|
* Two-factor authentication (TOTP), ENFORCED for every user. Wires
|
|
* @clocklimited/payload-2fa with forceSetup — no per-project opt-out. Every
|
|
* user must configure an authenticator app after login; TOTP is checked before
|
|
* data access (not just the admin UI). Requires the peer dep installed and an
|
|
* issuer name (shown in the authenticator app).
|
|
*
|
|
* Pass `false` ONLY for a project that genuinely can't use 2FA (rare, discouraged)
|
|
* — default is enforced. See docs/security.md.
|
|
*/
|
|
twoFactor?:
|
|
| {
|
|
/**
|
|
* Let `collectionSlug` differ from the panel's login collection
|
|
* (admin.user). Off by default: a mismatch means panel users skip 2FA,
|
|
* so the plugin refuses to start. Set true only when you protect a
|
|
* second auth collection on purpose.
|
|
*/
|
|
allowCollectionMismatch?: boolean
|
|
/**
|
|
* Auth collection TOTP wraps. Default: the panel's login collection —
|
|
* admin.user, else the first auth collection (with the one the plugin
|
|
* injects). Must be an auth collection.
|
|
*/
|
|
collectionSlug?: CollectionSlug
|
|
/** Name shown in the authenticator app (e.g. company/site name). */
|
|
issuer: string
|
|
/**
|
|
* The 2FA plugin factory, INJECTED from the project:
|
|
* `import { payloadTotp } from '@clocklimited/payload-2fa'`. Injecting it
|
|
* (the same pattern as NextResponse / revalidatePath) means ipal-kit never
|
|
* imports the optional peer itself — Next can't bundle such an import
|
|
* ("Cannot find module '@clocklimited/payload-2fa'", even on public
|
|
* pages), and serverExternalPackages is no fix (the package imports its
|
|
* own .css). The payload CLI loads the same config, so it gets the
|
|
* injected factory too. See docs/security.md.
|
|
*/
|
|
plugin: TotpPluginFactory
|
|
/**
|
|
* Admin provider that sends users to the TOTP setup / verify screens.
|
|
* Default: ipal-kit's `@intecion/ipal-kit/admin#TotpRedirectProvider`
|
|
* (reads the path in the browser). The package's own provider needs an
|
|
* `x-pathname` request header on every /admin request; without it the
|
|
* setup screen redirects to itself (`setup-totp?back=null`). Pass your
|
|
* own component path (it gets clientProps `forceSetup` and the package's
|
|
* serverProps `pluginOptions`), or `false` to keep the package's provider
|
|
* (then set `x-pathname` on /admin yourself). Run generate:importmap.
|
|
*/
|
|
provider?: false | PayloadComponent
|
|
}
|
|
| false
|
|
|
|
/**
|
|
* White-label the admin panel: show the CLIENT's brand (logo + name) in the
|
|
* admin — login screen and nav — pulled from SiteSettings, set by the editor
|
|
* in the panel (no brand hardcoded in code). `true` wires it with defaults
|
|
* (SiteSettings `logo`/`favicon`/`siteName`); the object form overrides the
|
|
* global slug, field names, or the browser-tab title suffix.
|
|
*
|
|
* Injects admin.components.graphics.Logo/Icon pointing at
|
|
* `@intecion/ipal-kit/admin`. After enabling, run `pnpm generate:importmap`
|
|
* so Payload can resolve the components. See docs/white-label.md.
|
|
*/
|
|
whiteLabel?:
|
|
| {
|
|
/**
|
|
* Vendor credit ("Technology by Intecion.com") at the bottom of the
|
|
* admin nav. Default on; `false` hides it, or override text/url.
|
|
*/
|
|
credit?:
|
|
| {
|
|
text?: string
|
|
url?: string
|
|
}
|
|
| boolean
|
|
/** Upload field for the small nav icon. Default 'favicon'. */
|
|
iconField?: string
|
|
/** Upload field for the login/nav logo. Default 'logo'. */
|
|
logoField?: string
|
|
/** Field with the site name. Default 'siteName'. */
|
|
nameField?: string
|
|
/** SiteSettings global slug. Default 'site-settings'. */
|
|
settingsSlug?: string
|
|
/** Static browser-tab title suffix (e.g. ' · Acme Admin'). */
|
|
titleSuffix?: string
|
|
}
|
|
| boolean
|
|
}
|
|
|
|
/** `ipalKit({ theme })` — every key optional. */
|
|
export type ThemeOptions = {
|
|
/** localStorage key of the visitor's light / dark choice. Default `'theme'`. */
|
|
storageKey?: string
|
|
}
|