Stats: ipalKit({ stats: true }) adds the stats-visits collection, POST /api/ipal/hit, the
/admin/stats view (30-day visits chart, top/entry pages, referrers, devices), a dashboard card
and a nav link. <PageStats> (or <SiteProviders stats>) sends one beacon per page view. Without
consent nothing is stored on the device and no IP is kept: page views are joined by a hash with
an in-memory salt replaced daily. With analytics consent an ipal_vid cookie links visits across
days (server re-checks the consent cookie and policy version; withdrawal deletes the cookie).
Bots, logged-in panel users and prefetches aren't counted. Retention 90 days.
@payloadcms/next added to peerDependencies (DefaultTemplate). Docs: stats.md with privacy text.
Also in this release: meta.description auto-filled from page blocks, <NoSnippet>,
MetaDescriptionCheck in the SEO tab, data-nosnippet on banner/language switcher, GA4 CSP
wildcards, consent version passed to Analytics' default consent.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
176 lines
7.0 KiB
TypeScript
176 lines
7.0 KiB
TypeScript
import type { CollectionSlug, Field, 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 { AccessOption } from './modules/access/types.js'
|
|
import type { ContentOption } from './modules/content/types.js'
|
|
import type { FormsOption } from './modules/forms/types.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
|
|
|
|
/**
|
|
* 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
|
|
|
|
/** 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 }` (default 1095). Default off.
|
|
*/
|
|
consentLog?: { retentionDays?: number } | boolean
|
|
|
|
/**
|
|
* 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
|
|
|
|
/** Disable the plugin without uninstalling (keeps DB schema intact) */
|
|
enabled?: boolean
|
|
|
|
/**
|
|
* Forms — form-builder collections (forms, form-submissions) plus the
|
|
* callable submitForm (Turnstile + persistence + SMTP-from-panel email).
|
|
*/
|
|
forms?: FormsOption
|
|
|
|
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[]
|
|
|
|
/**
|
|
* System-page assignments (homepage, privacy, cookies) in SiteSettings.
|
|
* Provide the slug of the client's Pages collection to enable.
|
|
*/
|
|
pages?: PagesOption
|
|
|
|
/**
|
|
* 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
|
|
|
|
/**
|
|
* 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?:
|
|
| {
|
|
/** Auth collection slug. Defaults to 'users'. */
|
|
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
|
|
}
|
|
| 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
|
|
}
|