From 1f55c2406e06a2fd34699fde5e0eb1728c631108 Mon Sep 17 00:00:00 2001 From: rasm-its Date: Mon, 12 Oct 2026 12:17:45 +0200 Subject: [PATCH] Added white-label support --- agents.md | 2 + dist/exports/admin.d.ts | 8 ++ dist/exports/admin.js | 9 ++ dist/exports/admin.js.map | 1 + dist/modules/branding/adminGraphics.d.ts | 45 ++++++++ dist/modules/branding/adminGraphics.js | 103 ++++++++++++++++++ dist/modules/branding/adminGraphics.js.map | 1 + dist/modules/branding/index.d.ts | 1 + dist/modules/branding/index.js | 3 + dist/modules/branding/index.js.map | 1 + dist/plugin.js | 74 ++++++++++++- dist/plugin.js.map | 2 +- dist/types.d.ts | 31 ++++++ dist/types.js.map | 2 +- docs/README.md | 4 +- docs/agents-template.md | 2 + docs/white-label.md | 81 ++++++++++++++ package.json | 61 ++++++----- src/exports/admin.ts | 8 ++ src/modules/branding/adminGraphics.tsx | 120 +++++++++++++++++++++ src/modules/branding/index.ts | 1 + src/plugin.ts | 52 ++++++++- src/types.ts | 36 +++++++ 23 files changed, 610 insertions(+), 38 deletions(-) create mode 100644 dist/exports/admin.d.ts create mode 100644 dist/exports/admin.js create mode 100644 dist/exports/admin.js.map create mode 100644 dist/modules/branding/adminGraphics.d.ts create mode 100644 dist/modules/branding/adminGraphics.js create mode 100644 dist/modules/branding/adminGraphics.js.map create mode 100644 dist/modules/branding/index.d.ts create mode 100644 dist/modules/branding/index.js create mode 100644 dist/modules/branding/index.js.map create mode 100644 docs/white-label.md create mode 100644 src/exports/admin.ts create mode 100644 src/modules/branding/adminGraphics.tsx create mode 100644 src/modules/branding/index.ts diff --git a/agents.md b/agents.md index 78041f6..3fb2da2 100644 --- a/agents.md +++ b/agents.md @@ -236,6 +236,8 @@ Ten plik to skondensowane reguły. Szczegóły w `node_modules/@intecion/ipal-ki | Walidacja ENV na starcie (assertEnv) | `env.md` | | Czytelność dla AI: Markdown per strona, llms-full, boty AI w robots | `content.md`, `seo.md` | | Serwer MCP strony (Claude podłącza się do treści) | `mcp.md` | +| GTM + Meta Pixel — konfiguracja krok po kroku | `gtm-meta-pixel.md` | +| White-label panelu admina (logo/nazwa z SiteSettings) | `white-label.md` | | Bezpieczeństwo, CSP, COOP | `security.md` | | Formularze, Turnstile, submitForm, useForm/useContactForm | `forms.md`, `turnstile.md` | | i18n, strona jednojęzyczna, ścieżki | `i18n.md` | diff --git a/dist/exports/admin.d.ts b/dist/exports/admin.d.ts new file mode 100644 index 0000000..7743eeb --- /dev/null +++ b/dist/exports/admin.d.ts @@ -0,0 +1,8 @@ +/** + * Entry point: @intecion/ipal-kit/admin + * + * Admin-panel UI components (white-label branding). Separate export so Payload's + * importMap can resolve them by a stable path when ipalKit injects + * admin.components.graphics.Logo/Icon. + */ +export { AdminIcon, AdminLogo, IntecionCredit } from '../modules/branding/index.js'; diff --git a/dist/exports/admin.js b/dist/exports/admin.js new file mode 100644 index 0000000..5b91017 --- /dev/null +++ b/dist/exports/admin.js @@ -0,0 +1,9 @@ +/** + * Entry point: @intecion/ipal-kit/admin + * + * Admin-panel UI components (white-label branding). Separate export so Payload's + * importMap can resolve them by a stable path when ipalKit injects + * admin.components.graphics.Logo/Icon. + */ export { AdminIcon, AdminLogo, IntecionCredit } from '../modules/branding/index.js'; + +//# sourceMappingURL=admin.js.map \ No newline at end of file diff --git a/dist/exports/admin.js.map b/dist/exports/admin.js.map new file mode 100644 index 0000000..25a6fa1 --- /dev/null +++ b/dist/exports/admin.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../src/exports/admin.ts"],"sourcesContent":["/**\n * Entry point: @intecion/ipal-kit/admin\n *\n * Admin-panel UI components (white-label branding). Separate export so Payload's\n * importMap can resolve them by a stable path when ipalKit injects\n * admin.components.graphics.Logo/Icon.\n */\nexport { AdminIcon, AdminLogo, IntecionCredit } from '../modules/branding/index.js'\n"],"names":["AdminIcon","AdminLogo","IntecionCredit"],"mappings":"AAAA;;;;;;CAMC,GACD,SAASA,SAAS,EAAEC,SAAS,EAAEC,cAAc,QAAQ,+BAA8B"} \ No newline at end of file diff --git a/dist/modules/branding/adminGraphics.d.ts b/dist/modules/branding/adminGraphics.d.ts new file mode 100644 index 0000000..c3d8f7c --- /dev/null +++ b/dist/modules/branding/adminGraphics.d.ts @@ -0,0 +1,45 @@ +/** + * White-label admin branding: the Payload admin panel's logo (login + nav) and + * icon, pulled from the project's SiteSettings so each client sees THEIR brand, + * set by the editor in the panel — not hardcoded per project. Wired + * automatically by `ipalKit({ whiteLabel: true })` (it injects + * admin.components.graphics.Logo/Icon pointing here). + * + * Server Components — they read the SiteSettings global at render. Data access + * uses the project's `@payload-config` alias (universal in Payload 3 Next apps), + * loaded via a variable specifier so the PLUGIN's own typecheck doesn't try to + * resolve it (same pattern as the optional 2FA import). Everything is wrapped in + * try/catch: on the login screen before the DB is ready, or a build with no DB, + * the component falls back to the site name text, then to null (Payload's own + * default) — never throws, never blocks the panel. + * + * A0: no client brand in code. The logo/name come from the panel; if nothing is + * set, nothing is forced. + */ +type BrandingProps = { + /** SiteSettings global slug. Default 'site-settings'. */ + settingsSlug?: string; + /** Field holding the site name. Default 'siteName'. */ + nameField?: string; + /** Upload field to render as the image. Default 'logo' (Logo) / 'favicon' (Icon). */ + imageField?: string; +}; +/** Admin panel logo (login screen + nav). SiteSettings `logo`, falls back to `siteName`. */ +export declare function AdminLogo(props?: BrandingProps): Promise; +/** Admin panel icon (small nav glyph). SiteSettings `favicon`, falls back to initials. */ +export declare function AdminIcon(props?: BrandingProps): Promise; +/** + * Discreet vendor credit shown at the bottom of the admin nav: "Technology by + * Intecion.com". This is the PLUGIN VENDOR's credit (Intecion ships ipal-kit), + * not client data — so a sensible default here is fine and A0-safe. The client's + * own brand still owns the logo/name above (AdminLogo); this is a small line + * stating who provides the technology. Text/URL overridable; turn it off with + * `whiteLabel: { credit: false }`. + * + * Wired by ipalKit into admin.components.afterNavLinks. + */ +export declare function IntecionCredit(props?: { + text?: string; + url?: string; +}): import("react/jsx-runtime").JSX.Element; +export {}; diff --git a/dist/modules/branding/adminGraphics.js b/dist/modules/branding/adminGraphics.js new file mode 100644 index 0000000..c08b7c3 --- /dev/null +++ b/dist/modules/branding/adminGraphics.js @@ -0,0 +1,103 @@ +import { jsx as _jsx } from "react/jsx-runtime"; +import { getPayload } from 'payload'; +async function loadBranding(settingsSlug, nameField, imageField) { + try { + // Consumer alias — resolved in the project's build, hidden from plugin tsc. + const spec = '@payload-config'; + const mod = await import(spec); + const payload = await getPayload({ + config: mod.default + }); + const settings = await payload.findGlobal({ + slug: settingsSlug, + depth: 1 + }); + const name = typeof settings[nameField] === 'string' ? settings[nameField] : null; + const image = settings[imageField]; + const url = image && typeof image === 'object' && typeof image.url === 'string' ? image.url : null; + return { + name, + url + }; + } catch { + return { + name: null, + url: null + }; + } +} +/** Admin panel logo (login screen + nav). SiteSettings `logo`, falls back to `siteName`. */ export async function AdminLogo(props = {}) { + const { settingsSlug = 'site-settings', nameField = 'siteName', imageField = 'logo' } = props; + const { name, url } = await loadBranding(settingsSlug, nameField, imageField); + if (url) { + return /*#__PURE__*/ _jsx("img", { + src: url, + alt: name ?? '', + style: { + maxHeight: 60, + maxWidth: 240, + width: 'auto', + height: 'auto' + } + }); + } + if (name) return /*#__PURE__*/ _jsx("div", { + style: { + fontSize: '1.5rem', + fontWeight: 600 + }, + children: name + }); + return null // nothing configured → Payload's default + ; +} +/** Admin panel icon (small nav glyph). SiteSettings `favicon`, falls back to initials. */ export async function AdminIcon(props = {}) { + const { settingsSlug = 'site-settings', nameField = 'siteName', imageField = 'favicon' } = props; + const { name, url } = await loadBranding(settingsSlug, nameField, imageField); + if (url) { + return /*#__PURE__*/ _jsx("img", { + src: url, + alt: name ?? '', + style: { + maxHeight: 28, + maxWidth: 28, + width: 'auto', + height: 'auto' + } + }); + } + if (name) return /*#__PURE__*/ _jsx("div", { + style: { + fontWeight: 700 + }, + children: name.slice(0, 2).toUpperCase() + }); + return null; +} +/** + * Discreet vendor credit shown at the bottom of the admin nav: "Technology by + * Intecion.com". This is the PLUGIN VENDOR's credit (Intecion ships ipal-kit), + * not client data — so a sensible default here is fine and A0-safe. The client's + * own brand still owns the logo/name above (AdminLogo); this is a small line + * stating who provides the technology. Text/URL overridable; turn it off with + * `whiteLabel: { credit: false }`. + * + * Wired by ipalKit into admin.components.afterNavLinks. + */ export function IntecionCredit(props = {}) { + const { text = 'Technology by Intecion.com', url = 'https://intecion.com' } = props; + return /*#__PURE__*/ _jsx("a", { + href: url, + target: "_blank", + rel: "noopener noreferrer", + style: { + display: 'block', + padding: '0.75rem 1rem', + fontSize: '0.75rem', + opacity: 0.6, + textDecoration: 'none' + }, + children: text + }); +} + +//# sourceMappingURL=adminGraphics.js.map \ No newline at end of file diff --git a/dist/modules/branding/adminGraphics.js.map b/dist/modules/branding/adminGraphics.js.map new file mode 100644 index 0000000..2b310c3 --- /dev/null +++ b/dist/modules/branding/adminGraphics.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/modules/branding/adminGraphics.tsx"],"sourcesContent":["import { getPayload } from 'payload'\n\n/**\n * White-label admin branding: the Payload admin panel's logo (login + nav) and\n * icon, pulled from the project's SiteSettings so each client sees THEIR brand,\n * set by the editor in the panel — not hardcoded per project. Wired\n * automatically by `ipalKit({ whiteLabel: true })` (it injects\n * admin.components.graphics.Logo/Icon pointing here).\n *\n * Server Components — they read the SiteSettings global at render. Data access\n * uses the project's `@payload-config` alias (universal in Payload 3 Next apps),\n * loaded via a variable specifier so the PLUGIN's own typecheck doesn't try to\n * resolve it (same pattern as the optional 2FA import). Everything is wrapped in\n * try/catch: on the login screen before the DB is ready, or a build with no DB,\n * the component falls back to the site name text, then to null (Payload's own\n * default) — never throws, never blocks the panel.\n *\n * A0: no client brand in code. The logo/name come from the panel; if nothing is\n * set, nothing is forced.\n */\n\ntype BrandingProps = {\n /** SiteSettings global slug. Default 'site-settings'. */\n settingsSlug?: string\n /** Field holding the site name. Default 'siteName'. */\n nameField?: string\n /** Upload field to render as the image. Default 'logo' (Logo) / 'favicon' (Icon). */\n imageField?: string\n}\n\ntype MediaLike = { url?: string | null } | null | undefined\n\nasync function loadBranding(\n settingsSlug: string,\n nameField: string,\n imageField: string,\n): Promise<{ name: string | null; url: string | null }> {\n try {\n // Consumer alias — resolved in the project's build, hidden from plugin tsc.\n const spec = '@payload-config'\n const mod = (await import(spec)) as { default: unknown }\n const payload = await getPayload({ config: mod.default as never })\n const settings = (await payload.findGlobal({\n slug: settingsSlug as never,\n depth: 1,\n })) as Record\n\n const name = typeof settings[nameField] === 'string' ? (settings[nameField] as string) : null\n const image = settings[imageField] as MediaLike\n const url =\n image && typeof image === 'object' && typeof image.url === 'string' ? image.url : null\n return { name, url }\n } catch {\n return { name: null, url: null }\n }\n}\n\n/** Admin panel logo (login screen + nav). SiteSettings `logo`, falls back to `siteName`. */\nexport async function AdminLogo(props: BrandingProps = {}) {\n const { settingsSlug = 'site-settings', nameField = 'siteName', imageField = 'logo' } = props\n const { name, url } = await loadBranding(settingsSlug, nameField, imageField)\n if (url) {\n return (\n \n )\n }\n if (name) return
{name}
\n return null // nothing configured → Payload's default\n}\n\n/** Admin panel icon (small nav glyph). SiteSettings `favicon`, falls back to initials. */\nexport async function AdminIcon(props: BrandingProps = {}) {\n const { settingsSlug = 'site-settings', nameField = 'siteName', imageField = 'favicon' } = props\n const { name, url } = await loadBranding(settingsSlug, nameField, imageField)\n if (url) {\n return (\n \n )\n }\n if (name) return
{name.slice(0, 2).toUpperCase()}
\n return null\n}\n\n/**\n * Discreet vendor credit shown at the bottom of the admin nav: \"Technology by\n * Intecion.com\". This is the PLUGIN VENDOR's credit (Intecion ships ipal-kit),\n * not client data — so a sensible default here is fine and A0-safe. The client's\n * own brand still owns the logo/name above (AdminLogo); this is a small line\n * stating who provides the technology. Text/URL overridable; turn it off with\n * `whiteLabel: { credit: false }`.\n *\n * Wired by ipalKit into admin.components.afterNavLinks.\n */\nexport function IntecionCredit(props: { text?: string; url?: string } = {}) {\n const { text = 'Technology by Intecion.com', url = 'https://intecion.com' } = props\n return (\n \n {text}\n \n )\n}\n"],"names":["getPayload","loadBranding","settingsSlug","nameField","imageField","spec","mod","payload","config","default","settings","findGlobal","slug","depth","name","image","url","AdminLogo","props","img","src","alt","style","maxHeight","maxWidth","width","height","div","fontSize","fontWeight","AdminIcon","slice","toUpperCase","IntecionCredit","text","a","href","target","rel","display","padding","opacity","textDecoration"],"mappings":";AAAA,SAASA,UAAU,QAAQ,UAAS;AAgCpC,eAAeC,aACbC,YAAoB,EACpBC,SAAiB,EACjBC,UAAkB;IAElB,IAAI;QACF,4EAA4E;QAC5E,MAAMC,OAAO;QACb,MAAMC,MAAO,MAAM,MAAM,CAACD;QAC1B,MAAME,UAAU,MAAMP,WAAW;YAAEQ,QAAQF,IAAIG,OAAO;QAAU;QAChE,MAAMC,WAAY,MAAMH,QAAQI,UAAU,CAAC;YACzCC,MAAMV;YACNW,OAAO;QACT;QAEA,MAAMC,OAAO,OAAOJ,QAAQ,CAACP,UAAU,KAAK,WAAYO,QAAQ,CAACP,UAAU,GAAc;QACzF,MAAMY,QAAQL,QAAQ,CAACN,WAAW;QAClC,MAAMY,MACJD,SAAS,OAAOA,UAAU,YAAY,OAAOA,MAAMC,GAAG,KAAK,WAAWD,MAAMC,GAAG,GAAG;QACpF,OAAO;YAAEF;YAAME;QAAI;IACrB,EAAE,OAAM;QACN,OAAO;YAAEF,MAAM;YAAME,KAAK;QAAK;IACjC;AACF;AAEA,0FAA0F,GAC1F,OAAO,eAAeC,UAAUC,QAAuB,CAAC,CAAC;IACvD,MAAM,EAAEhB,eAAe,eAAe,EAAEC,YAAY,UAAU,EAAEC,aAAa,MAAM,EAAE,GAAGc;IACxF,MAAM,EAAEJ,IAAI,EAAEE,GAAG,EAAE,GAAG,MAAMf,aAAaC,cAAcC,WAAWC;IAClE,IAAIY,KAAK;QACP,qBACE,KAACG;YACCC,KAAKJ;YACLK,KAAKP,QAAQ;YACbQ,OAAO;gBAAEC,WAAW;gBAAIC,UAAU;gBAAKC,OAAO;gBAAQC,QAAQ;YAAO;;IAG3E;IACA,IAAIZ,MAAM,qBAAO,KAACa;QAAIL,OAAO;YAAEM,UAAU;YAAUC,YAAY;QAAI;kBAAIf;;IACvE,OAAO,KAAK,yCAAyC;;AACvD;AAEA,wFAAwF,GACxF,OAAO,eAAegB,UAAUZ,QAAuB,CAAC,CAAC;IACvD,MAAM,EAAEhB,eAAe,eAAe,EAAEC,YAAY,UAAU,EAAEC,aAAa,SAAS,EAAE,GAAGc;IAC3F,MAAM,EAAEJ,IAAI,EAAEE,GAAG,EAAE,GAAG,MAAMf,aAAaC,cAAcC,WAAWC;IAClE,IAAIY,KAAK;QACP,qBACE,KAACG;YACCC,KAAKJ;YACLK,KAAKP,QAAQ;YACbQ,OAAO;gBAAEC,WAAW;gBAAIC,UAAU;gBAAIC,OAAO;gBAAQC,QAAQ;YAAO;;IAG1E;IACA,IAAIZ,MAAM,qBAAO,KAACa;QAAIL,OAAO;YAAEO,YAAY;QAAI;kBAAIf,KAAKiB,KAAK,CAAC,GAAG,GAAGC,WAAW;;IAC/E,OAAO;AACT;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASC,eAAef,QAAyC,CAAC,CAAC;IACxE,MAAM,EAAEgB,OAAO,4BAA4B,EAAElB,MAAM,sBAAsB,EAAE,GAAGE;IAC9E,qBACE,KAACiB;QACCC,MAAMpB;QACNqB,QAAO;QACPC,KAAI;QACJhB,OAAO;YACLiB,SAAS;YACTC,SAAS;YACTZ,UAAU;YACVa,SAAS;YACTC,gBAAgB;QAClB;kBAECR;;AAGP"} \ No newline at end of file diff --git a/dist/modules/branding/index.d.ts b/dist/modules/branding/index.d.ts new file mode 100644 index 0000000..28ffe03 --- /dev/null +++ b/dist/modules/branding/index.d.ts @@ -0,0 +1 @@ +export { AdminIcon, AdminLogo, IntecionCredit } from './adminGraphics.js'; diff --git a/dist/modules/branding/index.js b/dist/modules/branding/index.js new file mode 100644 index 0000000..08d9f14 --- /dev/null +++ b/dist/modules/branding/index.js @@ -0,0 +1,3 @@ +export { AdminIcon, AdminLogo, IntecionCredit } from './adminGraphics.js'; + +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/modules/branding/index.js.map b/dist/modules/branding/index.js.map new file mode 100644 index 0000000..963df91 --- /dev/null +++ b/dist/modules/branding/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/modules/branding/index.ts"],"sourcesContent":["export { AdminIcon, AdminLogo, IntecionCredit } from './adminGraphics.js'\n"],"names":["AdminIcon","AdminLogo","IntecionCredit"],"mappings":"AAAA,SAASA,SAAS,EAAEC,SAAS,EAAEC,cAAc,QAAQ,qBAAoB"} \ No newline at end of file diff --git a/dist/plugin.js b/dist/plugin.js index a2b856e..e6078db 100644 --- a/dist/plugin.js +++ b/dist/plugin.js @@ -67,8 +67,8 @@ import { buildSeoPlugin, injectAutoFillMeta, injectSeoTabs } from './modules/seo // optional peer dependency at build time (it isn't in the plugin's own // node_modules). Avoids TS2307 without @ts-expect-error; the module // exists at runtime in projects that installed it. - // @ts-ignore - const mod = await import('@clocklimited/payload-2fa'); + const pkg = '@clocklimited/payload-2fa'; + const mod = await import(pkg); // The package exports `payloadTotp`; older/other builds may use // `totpPlugin`. Accept either so a rename doesn't break us. const totp = mod.payloadTotp ?? mod.totpPlugin; @@ -86,6 +86,76 @@ import { buildSeoPlugin, injectAutoFillMeta, injectSeoTabs } from './modules/seo throw new Error('[ipal] 2FA is enforced but @clocklimited/payload-2fa is not installed. ' + 'Run: pnpm add @clocklimited/payload-2fa — or set twoFactor: false to ' + `opt out (discouraged). Original error: ${String(err)}`); } } + // --- white-label admin branding --- + // Inject admin.components.graphics.Logo/Icon pointing at the plugin's + // /admin export. The components read SiteSettings at render, so each client + // sees their own brand from the panel (no brand in code). Project must run + // `pnpm generate:importmap` so Payload resolves the component paths. + if (options.whiteLabel) { + const wl = options.whiteLabel === true ? {} : options.whiteLabel; + const serverProps = {}; + if (wl.settingsSlug) { + serverProps.settingsSlug = wl.settingsSlug; + } + if (wl.nameField) { + serverProps.nameField = wl.nameField; + } + const logoProps = { + ...serverProps, + ...wl.logoField ? { + imageField: wl.logoField + } : {} + }; + const iconProps = { + ...serverProps, + ...wl.iconField ? { + imageField: wl.iconField + } : {} + }; + // Vendor credit ("Technology by Intecion.com") under the nav — on by + // default, hidden with credit:false, text/url overridable. + const creditOn = wl.credit !== false; + const creditProps = wl.credit && typeof wl.credit === 'object' ? { + ...wl.credit.text ? { + text: wl.credit.text + } : {}, + ...wl.credit.url ? { + url: wl.credit.url + } : {} + } : {}; + config.admin = { + ...config.admin ?? {}, + components: { + ...config.admin?.components ?? {}, + graphics: { + ...config.admin?.components?.graphics ?? {}, + Icon: { + path: '@intecion/ipal-kit/admin#AdminIcon', + serverProps: iconProps + }, + Logo: { + path: '@intecion/ipal-kit/admin#AdminLogo', + serverProps: logoProps + } + }, + ...creditOn ? { + afterNavLinks: [ + ...config.admin?.components?.afterNavLinks ?? [], + { + path: '@intecion/ipal-kit/admin#IntecionCredit', + serverProps: creditProps + } + ] + } : {} + }, + ...wl.titleSuffix ? { + meta: { + ...config.admin?.meta ?? {}, + titleSuffix: wl.titleSuffix + } + } : {} + }; + } // --- i18n --- config.localization = buildLocalizationConfig(options.i18n); // --- access: inject roles into the client's auth collection --- diff --git a/dist/plugin.js.map b/dist/plugin.js.map index 6fefea4..a714ce3 100644 --- a/dist/plugin.js.map +++ b/dist/plugin.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import type { Config, Plugin } from 'payload'\n\nimport type { IpalOptions } from './types.js'\n\nimport { buildCookieSettings } from './globals/CookieSettings/index.js'\nimport { buildNotifications } from './globals/Notifications/index.js'\nimport { buildSiteIntegrations } from './globals/SiteIntegrations/index.js'\nimport { buildSiteSettings } from './globals/SiteSettings/index.js'\nimport { injectRoles } from './modules/access/index.js'\nimport { buildArchiveFields } from './modules/content/index.js'\nimport { testEmailEndpoint } from './modules/email/test/testEmailEndpoint.js'\nimport { buildFormsPlugin } from './modules/forms/formsPluginConfig.js'\nimport { buildLocalizationConfig, validateI18nConfig } from './modules/i18n/index.js'\nimport { buildSystemPagesFields } from './modules/pages/index.js'\nimport { buildSeoPlugin, injectAutoFillMeta, injectSeoTabs } from './modules/seo/index.js'\n\n/**\n * IPAL (Intecion Payload Advanced Library) plugin for Payload CMS 3.\n *\n * @example\n * ```ts\n * import { ipalKit } from 'ipal-kit'\n *\n * export default buildConfig({\n * plugins: [\n * ipalKit({\n * i18n: {\n * locales: [\n * { code: 'pl', label: 'Polski' },\n * { code: 'en', label: 'English' },\n * ],\n * defaultLocale: 'pl',\n * },\n * access: { authCollection: 'users' },\n * }),\n * ],\n * })\n * ```\n */\nexport const ipalKit = (options: IpalOptions): Plugin => {\n // Validate eagerly — fail fast before Payload boots\n validateI18nConfig(options.i18n)\n\n return async (incomingConfig: Config): Promise => {\n // Early return when disabled — schema stays, behavior off\n if (options.enabled === false) {\n return incomingConfig\n }\n\n let config = { ...incomingConfig }\n\n // --- custom admin route (e.g. '/its' instead of '/admin') ---\n // Sets config.routes.admin; the project must move its app/(payload)//\n // folder to match (plugin can't create files in the project's app/).\n if (options.adminRoute) {\n config.routes = { ...(config.routes ?? {}), admin: options.adminRoute }\n }\n\n // --- enforced 2FA (TOTP) via @clocklimited/payload-2fa ---\n // Enforced by default (forceSetup) unless twoFactor is explicitly false. The\n // plugin is a PEER dependency imported dynamically — ipal-kit doesn't bundle\n // it, so projects that opt out (twoFactor: false) needn't install it, and the\n // import never runs under generate:importmap when 2FA is off. Wrapping access\n // control (not just admin UI) means TOTP gates data access — no API bypass.\n if (options.twoFactor !== false) {\n const tf = options.twoFactor\n if (!tf?.issuer) {\n throw new Error(\n '[ipal] twoFactor.issuer is required (name shown in the authenticator ' +\n 'app). Pass twoFactor: { issuer: \"Your Site\" }, or twoFactor: false to ' +\n 'opt out (discouraged).',\n )\n }\n try {\n // Dynamic specifier via a variable so TS doesn't try to resolve this\n // optional peer dependency at build time (it isn't in the plugin's own\n // node_modules). Avoids TS2307 without @ts-expect-error; the module\n // exists at runtime in projects that installed it.\n // @ts-ignore\n const mod = (await import('@clocklimited/payload-2fa')) as {\n payloadTotp?: (opts: Record) => Plugin\n totpPlugin?: (opts: Record) => Plugin\n }\n // The package exports `payloadTotp`; older/other builds may use\n // `totpPlugin`. Accept either so a rename doesn't break us.\n const totp = mod.payloadTotp ?? mod.totpPlugin\n if (typeof totp !== 'function') {\n throw new Error(\n 'expected export payloadTotp (or totpPlugin) to be a function — ' +\n 'check the installed @clocklimited/payload-2fa version',\n )\n }\n config = await totp({\n collection: tf.collectionSlug ?? 'users',\n forceSetup: true, // ENFORCED — every user must set up TOTP; no opt-out\n totp: { issuer: tf.issuer },\n })(config)\n } catch (err) {\n throw new Error(\n '[ipal] 2FA is enforced but @clocklimited/payload-2fa is not installed. ' +\n 'Run: pnpm add @clocklimited/payload-2fa — or set twoFactor: false to ' +\n `opt out (discouraged). Original error: ${String(err)}`,\n )\n }\n }\n\n // --- i18n ---\n config.localization = buildLocalizationConfig(options.i18n)\n\n // --- access: inject roles into the client's auth collection ---\n if (options.access) {\n config = injectRoles(config, options.access)\n }\n\n // --- seo: apply @payloadcms/plugin-seo directly ---\n // NOTE: apply the plugin function to the config immediately rather than\n // pushing it onto config.plugins. Payload has already iterated the plugins\n // array by the time IPAL runs, so nested plugins added to that list are\n // never executed. Calling the plugin as (config) => config applies its\n // transform now.\n if (options.seo) {\n config = await buildSeoPlugin({ seo: options.seo })(config)\n // Auto-fill empty meta from document content on save\n config = injectAutoFillMeta(config, options.seo)\n // Wrap fields into Content + SEO tabs (replaces plugin-seo's tabbedUI,\n // which breaks when other fields already exist in the collection)\n config = injectSeoTabs(config, options.seo)\n }\n\n // --- forms: apply @payloadcms/plugin-form-builder directly ---\n if (options.forms) {\n config = await buildFormsPlugin(options.forms)(config)\n }\n\n // --- globals ---\n // The System Pages tab collects every \"which page plays this role\"\n // assignment. Composing it here keeps SiteSettings unaware of which modules\n // are enabled — it just renders the fields it's given.\n const systemPageFields = [\n ...(options.pages ? buildSystemPagesFields(options.pages) : []),\n ...(options.content && options.pages\n ? buildArchiveFields(options.content, options.pages.slug)\n : []),\n ]\n\n config.globals = [\n ...(config.globals ?? []),\n buildSiteSettings({\n additionalFields: options.siteSettingsFields,\n systemPageFields,\n }),\n buildSiteIntegrations({ additionalFields: options.integrationsFields }),\n buildCookieSettings(),\n buildNotifications(),\n ]\n\n config.endpoints = [...(config.endpoints ?? []), testEmailEndpoint]\n\n // --- hooks: onInit ---\n const incomingOnInit = config.onInit\n config.onInit = async (payload) => {\n if (incomingOnInit) {await incomingOnInit(payload)}\n payload.logger.info('[ipal] Plugin initialized.')\n }\n\n return config\n }\n}\n"],"names":["buildCookieSettings","buildNotifications","buildSiteIntegrations","buildSiteSettings","injectRoles","buildArchiveFields","testEmailEndpoint","buildFormsPlugin","buildLocalizationConfig","validateI18nConfig","buildSystemPagesFields","buildSeoPlugin","injectAutoFillMeta","injectSeoTabs","ipalKit","options","i18n","incomingConfig","enabled","config","adminRoute","routes","admin","twoFactor","tf","issuer","Error","mod","totp","payloadTotp","totpPlugin","collection","collectionSlug","forceSetup","err","String","localization","access","seo","forms","systemPageFields","pages","content","slug","globals","additionalFields","siteSettingsFields","integrationsFields","endpoints","incomingOnInit","onInit","payload","logger","info"],"mappings":"AAIA,SAASA,mBAAmB,QAAQ,oCAAmC;AACvE,SAASC,kBAAkB,QAAQ,mCAAkC;AACrE,SAASC,qBAAqB,QAAQ,sCAAqC;AAC3E,SAASC,iBAAiB,QAAQ,kCAAiC;AACnE,SAASC,WAAW,QAAQ,4BAA2B;AACvD,SAASC,kBAAkB,QAAQ,6BAA4B;AAC/D,SAASC,iBAAiB,QAAQ,4CAA2C;AAC7E,SAASC,gBAAgB,QAAQ,uCAAsC;AACvE,SAASC,uBAAuB,EAAEC,kBAAkB,QAAQ,0BAAyB;AACrF,SAASC,sBAAsB,QAAQ,2BAA0B;AACjE,SAASC,cAAc,EAAEC,kBAAkB,EAAEC,aAA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AAiB9B,OAAO+B,MAAM;QACpC/B,OAAO+B,MAAM,GAAG,OAAOC;YACrB,IAAIF,gBAAgB;gBAAC,MAAMA,eAAeE;YAAQ;YAClDA,QAAQC,MAAM,CAACC,IAAI,CAAC;QACtB;QAEA,OAAOlC;IACT;AACF,EAAC"} \ No newline at end of file +{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import type { Config, Plugin } from 'payload'\n\nimport type { IpalOptions } from './types.js'\n\nimport { buildCookieSettings } from './globals/CookieSettings/index.js'\nimport { buildNotifications } from './globals/Notifications/index.js'\nimport { buildSiteIntegrations } from './globals/SiteIntegrations/index.js'\nimport { buildSiteSettings } from './globals/SiteSettings/index.js'\nimport { injectRoles } from './modules/access/index.js'\nimport { buildArchiveFields } from './modules/content/index.js'\nimport { testEmailEndpoint } from './modules/email/test/testEmailEndpoint.js'\nimport { buildFormsPlugin } from './modules/forms/formsPluginConfig.js'\nimport { buildLocalizationConfig, validateI18nConfig } from './modules/i18n/index.js'\nimport { buildSystemPagesFields } from './modules/pages/index.js'\nimport { buildSeoPlugin, injectAutoFillMeta, injectSeoTabs } from './modules/seo/index.js'\n\n/**\n * IPAL (Intecion Payload Advanced Library) plugin for Payload CMS 3.\n *\n * @example\n * ```ts\n * import { ipalKit } from 'ipal-kit'\n *\n * export default buildConfig({\n * plugins: [\n * ipalKit({\n * i18n: {\n * locales: [\n * { code: 'pl', label: 'Polski' },\n * { code: 'en', label: 'English' },\n * ],\n * defaultLocale: 'pl',\n * },\n * access: { authCollection: 'users' },\n * }),\n * ],\n * })\n * ```\n */\nexport const ipalKit = (options: IpalOptions): Plugin => {\n // Validate eagerly — fail fast before Payload boots\n validateI18nConfig(options.i18n)\n\n return async (incomingConfig: Config): Promise => {\n // Early return when disabled — schema stays, behavior off\n if (options.enabled === false) {\n return incomingConfig\n }\n\n let config = { ...incomingConfig }\n\n // --- custom admin route (e.g. '/its' instead of '/admin') ---\n // Sets config.routes.admin; the project must move its app/(payload)//\n // folder to match (plugin can't create files in the project's app/).\n if (options.adminRoute) {\n config.routes = { ...(config.routes ?? {}), admin: options.adminRoute }\n }\n\n // --- enforced 2FA (TOTP) via @clocklimited/payload-2fa ---\n // Enforced by default (forceSetup) unless twoFactor is explicitly false. The\n // plugin is a PEER dependency imported dynamically — ipal-kit doesn't bundle\n // it, so projects that opt out (twoFactor: false) needn't install it, and the\n // import never runs under generate:importmap when 2FA is off. Wrapping access\n // control (not just admin UI) means TOTP gates data access — no API bypass.\n if (options.twoFactor !== false) {\n const tf = options.twoFactor\n if (!tf?.issuer) {\n throw new Error(\n '[ipal] twoFactor.issuer is required (name shown in the authenticator ' +\n 'app). Pass twoFactor: { issuer: \"Your Site\" }, or twoFactor: false to ' +\n 'opt out (discouraged).',\n )\n }\n try {\n // Dynamic specifier via a variable so TS doesn't try to resolve this\n // optional peer dependency at build time (it isn't in the plugin's own\n // node_modules). Avoids TS2307 without @ts-expect-error; the module\n // exists at runtime in projects that installed it.\n const pkg = '@clocklimited/payload-2fa'\n const mod = (await import(pkg)) as {\n payloadTotp?: (opts: Record) => Plugin\n totpPlugin?: (opts: Record) => Plugin\n }\n // The package exports `payloadTotp`; older/other builds may use\n // `totpPlugin`. Accept either so a rename doesn't break us.\n const totp = mod.payloadTotp ?? mod.totpPlugin\n if (typeof totp !== 'function') {\n throw new Error(\n 'expected export payloadTotp (or totpPlugin) to be a function — ' +\n 'check the installed @clocklimited/payload-2fa version',\n )\n }\n config = await totp({\n collection: tf.collectionSlug ?? 'users',\n forceSetup: true, // ENFORCED — every user must set up TOTP; no opt-out\n totp: { issuer: tf.issuer },\n })(config)\n } catch (err) {\n throw new Error(\n '[ipal] 2FA is enforced but @clocklimited/payload-2fa is not installed. ' +\n 'Run: pnpm add @clocklimited/payload-2fa — or set twoFactor: false to ' +\n `opt out (discouraged). Original error: ${String(err)}`,\n )\n }\n }\n\n // --- white-label admin branding ---\n // Inject admin.components.graphics.Logo/Icon pointing at the plugin's\n // /admin export. The components read SiteSettings at render, so each client\n // sees their own brand from the panel (no brand in code). Project must run\n // `pnpm generate:importmap` so Payload resolves the component paths.\n if (options.whiteLabel) {\n const wl = options.whiteLabel === true ? {} : options.whiteLabel\n const serverProps: Record = {}\n if (wl.settingsSlug) {serverProps.settingsSlug = wl.settingsSlug}\n if (wl.nameField) {serverProps.nameField = wl.nameField}\n const logoProps = { ...serverProps, ...(wl.logoField ? { imageField: wl.logoField } : {}) }\n const iconProps = { ...serverProps, ...(wl.iconField ? { imageField: wl.iconField } : {}) }\n\n // Vendor credit (\"Technology by Intecion.com\") under the nav — on by\n // default, hidden with credit:false, text/url overridable.\n const creditOn = wl.credit !== false\n const creditProps =\n wl.credit && typeof wl.credit === 'object'\n ? {\n ...(wl.credit.text ? { text: wl.credit.text } : {}),\n ...(wl.credit.url ? { url: wl.credit.url } : {}),\n }\n : {}\n\n config.admin = {\n ...(config.admin ?? {}),\n components: {\n ...(config.admin?.components ?? {}),\n graphics: {\n ...(config.admin?.components?.graphics ?? {}),\n Icon: { path: '@intecion/ipal-kit/admin#AdminIcon', serverProps: iconProps },\n Logo: { path: '@intecion/ipal-kit/admin#AdminLogo', serverProps: logoProps },\n },\n ...(creditOn\n ? {\n afterNavLinks: [\n ...(config.admin?.components?.afterNavLinks ?? []),\n { path: '@intecion/ipal-kit/admin#IntecionCredit', serverProps: creditProps },\n ],\n }\n : {}),\n },\n ...(wl.titleSuffix\n ? { meta: { ...(config.admin?.meta ?? {}), titleSuffix: wl.titleSuffix } }\n : {}),\n }\n }\n\n // --- i18n ---\n config.localization = buildLocalizationConfig(options.i18n)\n\n // --- access: inject roles into the client's auth collection ---\n if (options.access) {\n config = injectRoles(config, options.access)\n }\n\n // --- seo: apply @payloadcms/plugin-seo directly ---\n // NOTE: apply the plugin function to the config immediately rather than\n // pushing it onto config.plugins. Payload has already iterated the plugins\n // array by the time IPAL runs, so nested plugins added to that list are\n // never executed. Calling the plugin as (config) => config applies its\n // transform now.\n if (options.seo) {\n config = await buildSeoPlugin({ seo: options.seo })(config)\n // Auto-fill empty meta from document content on save\n config = injectAutoFillMeta(config, options.seo)\n // Wrap fields into Content + SEO tabs (replaces plugin-seo's tabbedUI,\n // which breaks when other fields already exist in the collection)\n config = injectSeoTabs(config, options.seo)\n }\n\n // --- forms: apply @payloadcms/plugin-form-builder directly ---\n if (options.forms) {\n config = await buildFormsPlugin(options.forms)(config)\n }\n\n // --- globals ---\n // The System Pages tab collects every \"which page plays this role\"\n // assignment. Composing it here keeps SiteSettings unaware of which modules\n // are enabled — it just renders the fields it's given.\n const systemPageFields = [\n ...(options.pages ? buildSystemPagesFields(options.pages) : []),\n ...(options.content && options.pages\n ? buildArchiveFields(options.content, options.pages.slug)\n : []),\n ]\n\n config.globals = [\n ...(config.globals ?? []),\n buildSiteSettings({\n additionalFields: options.siteSettingsFields,\n systemPageFields,\n }),\n buildSiteIntegrations({ additionalFields: options.integrationsFields }),\n buildCookieSettings(),\n buildNotifications(),\n ]\n\n config.endpoints = [...(config.endpoints ?? []), testEmailEndpoint]\n\n // --- hooks: onInit ---\n const incomingOnInit = config.onInit\n config.onInit = async (payload) => {\n if (incomingOnInit) {await incomingOnInit(payload)}\n payload.logger.info('[ipal] Plugin initialized.')\n }\n\n return config\n }\n}\n"],"names":["buildCookieSettings","buildNotifications","buildSiteIntegrations","buildSiteSettings","injectRoles","buildArchiveFields","testEmailEndpoint","buildFormsPlugin","buildLocalizationConfig","validateI18nConfig","buildSystemPagesFields","buildSeoPlugin","injectAutoFillMeta","injectSeoTabs","ipalKit","options","i18n","incomingConfig","enabled","config","adminRoute","routes","admin","twoFactor","tf","issuer","Error","pkg","mod","totp","payloadTotp","totpPlugin","collection","collectionSlug","forceSetup","err","String","whiteLabel","wl","serverProps","settingsSlug","nameField","logoProps","logoField","imageField","iconProps","iconField","creditOn","credit","creditProps","text","url","components","graphics","Icon","path","Logo","afterNavLinks","titleSuffix","meta","localization","access","seo","forms","systemPageFields","pages","content","slug","globals","additionalFields","siteSettingsFields","integrationsFields","endpoints","incoming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f3C,SAAS,MAAMR,eAAe;gBAAEmD,KAAK/C,QAAQ+C,GAAG;YAAC,GAAG3C;YACpD,qDAAqD;YACrDA,SAASP,mBAAmBO,QAAQJ,QAAQ+C,GAAG;YAC/C,uEAAuE;YACvE,kEAAkE;YAClE3C,SAASN,cAAcM,QAAQJ,QAAQ+C,GAAG;QAC5C;QAEA,gEAAgE;QAChE,IAAI/C,QAAQgD,KAAK,EAAE;YACjB5C,SAAS,MAAMZ,iBAAiBQ,QAAQgD,KAAK,EAAE5C;QACjD;QAEA,kBAAkB;QAClB,mEAAmE;QACnE,4EAA4E;QAC5E,uDAAuD;QACvD,MAAM6C,mBAAmB;eACnBjD,QAAQkD,KAAK,GAAGvD,uBAAuBK,QAAQkD,KAAK,IAAI,EAAE;eAC1DlD,QAAQmD,OAAO,IAAInD,QAAQkD,KAAK,GAChC5D,mBAAmBU,QAAQmD,OAAO,EAAEnD,QAAQkD,KAAK,CAACE,IAAI,IACtD,EAAE;SACP;QAEDhD,OAAOiD,OAAO,GAAG;eACXjD,OAAOiD,OAAO,IAAI,EAAE;YACxBjE,kBAAkB;gBAChBkE,kBAAkBtD,QAAQuD,kBAAkB;gBAC5CN;YACF;YACA9D,sBAAsB;gBAAEmE,kBAAkBtD,QAAQwD,kBAAkB;YAAC;YACrEvE;YACAC;SACD;QAEDkB,OAAOqD,SAAS,GAAG;eAAKrD,OAAOqD,SAAS,IAAI,EAAE;YAAGlE;SAAkB;QAEnE,wBAAwB;QACxB,MAAMmE,iBAAiBtD,OAAOuD,MAAM;QACpCvD,OAAOuD,MAAM,GAAG,OAAOC;YACrB,IAAIF,gBAAgB;gBAAC,MAAMA,eAAeE;YAAQ;YAClDA,QAAQC,MAAM,CAACC,IAAI,CAAC;QACtB;QAEA,OAAO1D;IACT;AACF,EAAC"} \ No newline at end of file diff --git a/dist/types.d.ts b/dist/types.d.ts index d36a163..269dde0 100644 --- a/dist/types.d.ts +++ b/dist/types.d.ts @@ -72,4 +72,35 @@ export type IpalOptions = { /** Name shown in the authenticator app (e.g. company/site name). */ issuer: string; } | 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; }; diff --git a/dist/types.js.map b/dist/types.js.map index fce4d83..37be3e7 100644 --- a/dist/types.js.map +++ b/dist/types.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Field } from 'payload'\n\nimport type { AccessOption } from './modules/access/types.js'\nimport type { ContentOption } from './modules/content/types.js'\nimport type { FormsOption } from './modules/forms/types.js'\nimport type { I18nConfig } from './modules/i18n/types.js'\nimport type { PagesOption } from './modules/pages/types.js'\nimport type { SeoOption } from './modules/seo/types.js'\n\n/**\n * Configuration options for the IPAL plugin.\n * Passed by the client project in payload.config.ts.\n */\nexport type IpalOptions = {\n /**\n * Role-based access control. Injects a fixed `roles` field\n * (admin > editor > user) into the client's auth collection.\n */\n access?: AccessOption\n\n /**\n * Custom admin panel route, e.g. '/its' instead of the default '/admin'.\n * The plugin sets config.routes.admin. IMPORTANT: this alone isn't enough —\n * the project must ALSO move its panel folder to match:\n * app/(payload)/its/[[...segments]]/page.tsx (and the not-found). The plugin\n * can't create files in the project's app/. See docs/security.md.\n *\n * This is obscurity, not security: it hides the panel from dumb bots scanning\n * /admin, but real protection is strong auth + 2FA + rate limiting.\n */\n adminRoute?: string\n\n /**\n * Collections whose entries live under an archive page — blog posts, case\n * studies, anything with a listing. Adds an \"archive page\" assignment per\n * collection in SiteSettings; the assigned page's localized slug becomes the\n * URL segment (/pl/artykuly/moj-post, /en/articles/my-post). Requires `pages`.\n */\n content?: ContentOption\n\n /** Disable the plugin without uninstalling (keeps DB schema intact) */\n enabled?: boolean\n\n /**\n * Forms — form-builder collections (forms, form-submissions) plus the\n * callable submitForm (Turnstile + persistence + SMTP-from-panel email).\n */\n forms?: FormsOption\n\n /** Internationalization — locales, default locale, fallback behavior */\n i18n: I18nConfig\n\n /** Additional fields injected into SiteIntegrations global */\n integrationsFields?: Field[]\n\n /**\n * System-page assignments (homepage, privacy, cookies) in SiteSettings.\n * Provide the slug of the client's Pages collection to enable.\n */\n pages?: PagesOption\n\n /**\n * SEO — adds meta fields to chosen collections (via @payloadcms/plugin-seo)\n * and enables locale-aware metadata helpers.\n */\n seo?: SeoOption\n\n /** Additional fields injected into SiteSettings global */\n siteSettingsFields?: Field[]\n\n /**\n * Two-factor authentication (TOTP), ENFORCED for every user. Wires\n * @clocklimited/payload-2fa with forceSetup — no per-project opt-out. Every\n * user must configure an authenticator app after login; TOTP is checked before\n * data access (not just the admin UI). Requires the peer dep installed and an\n * issuer name (shown in the authenticator app).\n *\n * Pass `false` ONLY for a project that genuinely can't use 2FA (rare, discouraged)\n * — default is enforced. See docs/security.md.\n */\n twoFactor?:\n | {\n /** Auth collection slug. Defaults to 'users'. */\n collectionSlug?: string\n /** Name shown in the authenticator app (e.g. company/site name). */\n issuer: string\n }\n | false\n}\n"],"names":[],"mappings":"AASA;;;CAGC,GACD,WA2EC"} \ No newline at end of file +{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { Field } from 'payload'\n\nimport type { AccessOption } from './modules/access/types.js'\nimport type { ContentOption } from './modules/content/types.js'\nimport type { FormsOption } from './modules/forms/types.js'\nimport type { I18nConfig } from './modules/i18n/types.js'\nimport type { PagesOption } from './modules/pages/types.js'\nimport type { SeoOption } from './modules/seo/types.js'\n\n/**\n * Configuration options for the IPAL plugin.\n * Passed by the client project in payload.config.ts.\n */\nexport type IpalOptions = {\n /**\n * Role-based access control. Injects a fixed `roles` field\n * (admin > editor > user) into the client's auth collection.\n */\n access?: AccessOption\n\n /**\n * Custom admin panel route, e.g. '/its' instead of the default '/admin'.\n * The plugin sets config.routes.admin. IMPORTANT: this alone isn't enough —\n * the project must ALSO move its panel folder to match:\n * app/(payload)/its/[[...segments]]/page.tsx (and the not-found). The plugin\n * can't create files in the project's app/. See docs/security.md.\n *\n * This is obscurity, not security: it hides the panel from dumb bots scanning\n * /admin, but real protection is strong auth + 2FA + rate limiting.\n */\n adminRoute?: string\n\n /**\n * Collections whose entries live under an archive page — blog posts, case\n * studies, anything with a listing. Adds an \"archive page\" assignment per\n * collection in SiteSettings; the assigned page's localized slug becomes the\n * URL segment (/pl/artykuly/moj-post, /en/articles/my-post). Requires `pages`.\n */\n content?: ContentOption\n\n /** Disable the plugin without uninstalling (keeps DB schema intact) */\n enabled?: boolean\n\n /**\n * Forms — form-builder collections (forms, form-submissions) plus the\n * callable submitForm (Turnstile + persistence + SMTP-from-panel email).\n */\n forms?: FormsOption\n\n /** Internationalization — locales, default locale, fallback behavior */\n i18n: I18nConfig\n\n /** Additional fields injected into SiteIntegrations global */\n integrationsFields?: Field[]\n\n /**\n * System-page assignments (homepage, privacy, cookies) in SiteSettings.\n * Provide the slug of the client's Pages collection to enable.\n */\n pages?: PagesOption\n\n /**\n * SEO — adds meta fields to chosen collections (via @payloadcms/plugin-seo)\n * and enables locale-aware metadata helpers.\n */\n seo?: SeoOption\n\n /** Additional fields injected into SiteSettings global */\n siteSettingsFields?: Field[]\n\n /**\n * Two-factor authentication (TOTP), ENFORCED for every user. Wires\n * @clocklimited/payload-2fa with forceSetup — no per-project opt-out. Every\n * user must configure an authenticator app after login; TOTP is checked before\n * data access (not just the admin UI). Requires the peer dep installed and an\n * issuer name (shown in the authenticator app).\n *\n * Pass `false` ONLY for a project that genuinely can't use 2FA (rare, discouraged)\n * — default is enforced. See docs/security.md.\n */\n twoFactor?:\n | {\n /** Auth collection slug. Defaults to 'users'. */\n collectionSlug?: string\n /** Name shown in the authenticator app (e.g. company/site name). */\n issuer: string\n }\n | false\n\n /**\n * White-label the admin panel: show the CLIENT's brand (logo + name) in the\n * admin — login screen and nav — pulled from SiteSettings, set by the editor\n * in the panel (no brand hardcoded in code). `true` wires it with defaults\n * (SiteSettings `logo`/`favicon`/`siteName`); the object form overrides the\n * global slug, field names, or the browser-tab title suffix.\n *\n * Injects admin.components.graphics.Logo/Icon pointing at\n * `@intecion/ipal-kit/admin`. After enabling, run `pnpm generate:importmap`\n * so Payload can resolve the components. See docs/white-label.md.\n */\n whiteLabel?:\n | {\n /**\n * Vendor credit (\"Technology by Intecion.com\") at the bottom of the\n * admin nav. Default on; `false` hides it, or override text/url.\n */\n credit?:\n | {\n text?: string\n url?: string\n }\n | boolean\n /** Upload field for the small nav icon. Default 'favicon'. */\n iconField?: string\n /** Upload field for the login/nav logo. Default 'logo'. */\n logoField?: string\n /** Field with the site name. Default 'siteName'. */\n nameField?: string\n /** SiteSettings global slug. Default 'site-settings'. */\n settingsSlug?: string\n /** Static browser-tab title suffix (e.g. ' · Acme Admin'). */\n titleSuffix?: string\n }\n | boolean\n}\n"],"names":[],"mappings":"AASA;;;CAGC,GACD,WA+GC"} \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index 3f3efee..56b3aed 100644 --- a/docs/README.md +++ b/docs/README.md @@ -125,11 +125,13 @@ export default buildConfig({ | turnstile | Cloudflare Turnstile (widget + verify) | [turnstile.md](./turnstile.md) | | email | Wysyłka: SMTP z panelu lub Microsoft Graph (M365) | [email.md](./email.md) | | forms | Form-builder + submitForm + useForm/useContactForm (logika klienta) | [forms.md](./forms.md) | -| analytics | GA4 / GTM spięte z Consent Mode | [analytics.md](./analytics.md) | +| analytics | GA4 / GTM spięte z Consent Mode, pushDataLayer | [analytics.md](./analytics.md) | +| gtm-meta-pixel | Konfiguracja GTM + Meta Pixel krok po kroku (pod ten stack) | [gtm-meta-pixel.md](./gtm-meta-pixel.md) | | slug | Auto-slug z tytułu, per locale | [slug.md](./slug.md) | | notifications | Teksty wyników akcji (formularz) per język | [notifications.md](./notifications.md) | | storage | Media na Cloudflare R2 (offload z .env) | [storage.md](./storage.md) | | security | Nagłówki bezpieczeństwa HTTP (HSTS, X-Frame...) | [security.md](./security.md) | +| white-label | Branding panelu admina (logo + nazwa z SiteSettings) | [white-label.md](./white-label.md) | | content | Blog/archiwa: kolekcje pod stroną-archiwum, listing, paginacja, redirecty (resolveRedirect) | [content.md](./content.md) | Nowy projekt krok po kroku: [getting-started.md](./getting-started.md) diff --git a/docs/agents-template.md b/docs/agents-template.md index 67c75fb..037d257 100644 --- a/docs/agents-template.md +++ b/docs/agents-template.md @@ -252,6 +252,8 @@ Ten plik to skondensowane reguły. Szczegóły w `node_modules/@intecion/ipal-ki | Walidacja ENV na starcie (assertEnv) | `env.md` | | Czytelność dla AI: Markdown per strona, llms-full, boty AI w robots | `content.md`, `seo.md` | | Serwer MCP strony (Claude podłącza się do treści) | `mcp.md` | +| GTM + Meta Pixel — konfiguracja krok po kroku | `gtm-meta-pixel.md` | +| White-label panelu admina (logo/nazwa z SiteSettings) | `white-label.md` | | Bezpieczeństwo, CSP, COOP | `security.md` | | Formularze, Turnstile, submitForm, useForm/useContactForm | `forms.md`, `turnstile.md` | | i18n, strona jednojęzyczna, ścieżki | `i18n.md` | diff --git a/docs/white-label.md b/docs/white-label.md new file mode 100644 index 0000000..1c00ec4 --- /dev/null +++ b/docs/white-label.md @@ -0,0 +1,81 @@ +# white-label — branding panelu admina z panelu + +Panel admina pokazuje **markę klienta** (logo + nazwa) na ekranie logowania i w +nawigacji, pobraną z **SiteSettings** — czyli ustawioną przez redaktora w panelu, +nie zahardkodowaną w kodzie. Każdy klient loguje się do „swojego" panelu. + +Powiązane: [security.md](./security.md) (adminRoute), [accessibility.md](./accessibility.md). + +## Włączenie + +```ts +// payload.config.ts +ipalKit({ + i18n: { /* … */ }, + whiteLabel: true, +}) +``` + +`true` wpina branding z domyślnych pól SiteSettings: `logo` (logo panelu), +`favicon` (mała ikona nawigacji), `siteName` (nazwa / fallback tekstowy). + +> **Po włączeniu uruchom `pnpm generate:importmap`.** Plugin wstrzykuje +> `admin.components.graphics.Logo/Icon` wskazujące na `@intecion/ipal-kit/admin`; +> Payload musi zregenerować import map, żeby je znaleźć. Bez tego kroku panel +> użyje domyślnego logo Payload. + +## Konfiguracja (opcjonalnie) + +```ts +whiteLabel: { + settingsSlug: 'site-settings', // globalny slug ustawień + nameField: 'siteName', // pole z nazwą + logoField: 'logo', // upload na logo (login + nav) + iconField: 'favicon', // upload na ikonę nav + titleSuffix: ' · Acme Admin', // sufiks tytułu w karcie przeglądarki (statyczny) + credit: true, // kredyt dostawcy pod nawigacją (domyślnie on) +} +``` + +## Kredyt dostawcy — „Technology by Intecion.com" + +Pod nawigacją panelu (`afterNavLinks`) wyświetla się dyskretny kredyt +**„Technology by Intecion.com"** z linkiem do `https://intecion.com`. To kredyt +DOSTAWCY technologii (Intecion dostarcza ipal-kit) — marka klienta nadal rządzi +logiem i nazwą u góry; to tylko mała linijka „kto dostarcza technologię". + +Domyślnie włączony z `whiteLabel`. Sterowanie: + +```ts +whiteLabel: { credit: false } // ukryj +whiteLabel: { credit: { text: 'Powered by Intecion', url: 'https://intecion.com' } } // własny tekst/url +``` + +## Jak to działa + +- `AdminLogo` / `AdminIcon` to **Server Components** czytające SiteSettings przy + renderze (przez alias `@payload-config`, uniwersalny w projektach Payload 3 + + Next). +- **Bezpieczne fallbacki:** gdy baza jest niedostępna (ekran logowania zanim + wstanie DB, build bez bazy) albo logo nie jest ustawione → komponent pokazuje + nazwę (`siteName`), a gdy i jej brak → `null` (domyślne Payload). Nigdy nie + rzuca, nie blokuje panelu. +- **A0:** żadnej marki klienta w kodzie. Logo i nazwa pochodzą z panelu; jak nic + nie ustawiono, nic nie jest narzucane. + +## Granice + +- **`titleSuffix` jest statyczny** — tytuł karty przeglądarki ustawia się w + configu (build-time), więc nie czyta się z bazy. Logo i ikona (to, co widać) są + dynamiczne z SiteSettings; sufiks tytułu podajesz w opcji, jeśli chcesz. +- **To branding panelu, nie front** — wygląd strony publicznej robisz jak dotąd + (bloki, style projektu). White-label dotyczy wyłącznie panelu admina. +- Ścieżkę panelu (`/admin → /its`) ustawiasz osobno przez `adminRoute` — patrz + [security.md](./security.md). + +## Checklist + +- [ ] `ipalKit({ whiteLabel: true })` +- [ ] Redaktor wgrał `logo` i `favicon` w SiteSettings (+ `siteName`) +- [ ] `pnpm generate:importmap` +- [ ] Restart dev / rebuild → panel pokazuje markę klienta na loginie i w nav \ No newline at end of file diff --git a/package.json b/package.json index c665c7e..09e496f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@intecion/ipal-kit", - "version": "1.7.1", + "version": "1.7.0", "description": "Intecion Payload Advanced Library — a Payload CMS 3 plugin: i18n, SEO, forms, consent, analytics, blog/archives.", "license": "MIT", "repository": { @@ -33,13 +33,17 @@ "import": "./dist/exports/next-middleware.js", "types": "./dist/exports/next-middleware.d.ts", "default": "./dist/exports/next-middleware.js" + }, + "./admin": { + "import": "./dist/exports/admin.js", + "types": "./dist/exports/admin.d.ts", + "default": "./dist/exports/admin.js" } }, "main": "./dist/index.js", "types": "./dist/index.d.ts", "files": [ - "dist", - "docs" + "dist" ], "scripts": { "build": "pnpm copyfiles && pnpm build:types && pnpm build:swc", @@ -60,59 +64,54 @@ "test:int": "vitest" }, "dependencies": { - "@payloadcms/storage-s3": "^3.88.0", "lucide-react": "^0.400.0", "nodemailer": "^8.0.1", "server-only": "^0.0.1", "slugify": "^1.6.6" }, "peerDependencies": { - "@clocklimited/payload-2fa": "^3.0.0", - "@payloadcms/next": "^3.88.0", - "@payloadcms/plugin-form-builder": "^3.88.0", - "@payloadcms/plugin-seo": "^3.88.0", - "@payloadcms/ui": "^3.88.0", + "@payloadcms/plugin-form-builder": "^3.90.2", + "@payloadcms/plugin-seo": "^3.90.2", "next": ">=15", - "payload": "^3.88.0", - "react": "^19.0.0", - "react-dom": "^19.0.0" + "payload": "^3.90.2", + "react": "^19.0.0" }, "devDependencies": { "@eslint/eslintrc": "^3.2.0", - "@payloadcms/db-postgres": "3.88.0", - "@payloadcms/db-sqlite": "3.88.0", + "@payloadcms/db-postgres": "3.90.2", + "@payloadcms/db-sqlite": "3.90.2", "@payloadcms/eslint-config": "3.28.0", - "@payloadcms/next": "3.88.0", - "@payloadcms/plugin-form-builder": "3.88.0", - "@payloadcms/plugin-seo": "3.88.0", - "@payloadcms/richtext-lexical": "3.88.0", - "@payloadcms/ui": "3.88.0", - "@playwright/test": "1.58.2", + "@payloadcms/next": "3.90.2", + "@payloadcms/plugin-form-builder": "3.90.2", + "@payloadcms/plugin-seo": "3.90.2", + "@payloadcms/richtext-lexical": "3.90.2", + "@payloadcms/ui": "3.90.2", + "@playwright/test": "1.64.0", "@swc-node/register": "1.10.9", "@swc/cli": "0.6.0", - "@types/node": "22.19.9", + "@types/node": "22.20.5", "@types/nodemailer": "^8.0.1", - "@types/react": "19.2.14", - "@types/react-dom": "19.2.3", + "@types/react": "^19.2.14", + "@types/react-dom": "^19.2.3", "copyfiles": "2.4.1", "cross-env": "^7.0.3", "eslint": "^9.23.0", - "eslint-config-next": "16.2.6", + "eslint-config-next": "16.4.0", "graphql": "^16.8.1", "mongodb-memory-server": "10.1.4", - "next": "16.2.6", + "next": "16.4.0", "open": "^10.1.0", - "payload": "3.88.0", + "payload": "3.90.2", "prettier": "^3.4.2", "qs-esm": "8.0.1", - "react": "19.2.6", - "react-dom": "19.2.6", + "react": "19.3.0", + "react-dom": "19.3.0", "rimraf": "3.0.2", - "sharp": "0.34.2", + "sharp": "0.34.5", "sort-package-json": "^2.10.0", - "typescript": "5.7.3", + "typescript": "5.9.3", "vite-tsconfig-paths": "6.0.5", - "vitest": "4.0.18" + "vitest": "5.0.4" }, "engines": { "node": "^18.20.2 || >=20.9.0", diff --git a/src/exports/admin.ts b/src/exports/admin.ts new file mode 100644 index 0000000..b09d8e0 --- /dev/null +++ b/src/exports/admin.ts @@ -0,0 +1,8 @@ +/** + * Entry point: @intecion/ipal-kit/admin + * + * Admin-panel UI components (white-label branding). Separate export so Payload's + * importMap can resolve them by a stable path when ipalKit injects + * admin.components.graphics.Logo/Icon. + */ +export { AdminIcon, AdminLogo, IntecionCredit } from '../modules/branding/index.js' diff --git a/src/modules/branding/adminGraphics.tsx b/src/modules/branding/adminGraphics.tsx new file mode 100644 index 0000000..3aa7346 --- /dev/null +++ b/src/modules/branding/adminGraphics.tsx @@ -0,0 +1,120 @@ +import { getPayload } from 'payload' + +/** + * White-label admin branding: the Payload admin panel's logo (login + nav) and + * icon, pulled from the project's SiteSettings so each client sees THEIR brand, + * set by the editor in the panel — not hardcoded per project. Wired + * automatically by `ipalKit({ whiteLabel: true })` (it injects + * admin.components.graphics.Logo/Icon pointing here). + * + * Server Components — they read the SiteSettings global at render. Data access + * uses the project's `@payload-config` alias (universal in Payload 3 Next apps), + * loaded via a variable specifier so the PLUGIN's own typecheck doesn't try to + * resolve it (same pattern as the optional 2FA import). Everything is wrapped in + * try/catch: on the login screen before the DB is ready, or a build with no DB, + * the component falls back to the site name text, then to null (Payload's own + * default) — never throws, never blocks the panel. + * + * A0: no client brand in code. The logo/name come from the panel; if nothing is + * set, nothing is forced. + */ + +type BrandingProps = { + /** SiteSettings global slug. Default 'site-settings'. */ + settingsSlug?: string + /** Field holding the site name. Default 'siteName'. */ + nameField?: string + /** Upload field to render as the image. Default 'logo' (Logo) / 'favicon' (Icon). */ + imageField?: string +} + +type MediaLike = { url?: string | null } | null | undefined + +async function loadBranding( + settingsSlug: string, + nameField: string, + imageField: string, +): Promise<{ name: string | null; url: string | null }> { + try { + // Consumer alias — resolved in the project's build, hidden from plugin tsc. + const spec = '@payload-config' + const mod = (await import(spec)) as { default: unknown } + const payload = await getPayload({ config: mod.default as never }) + const settings = (await payload.findGlobal({ + slug: settingsSlug as never, + depth: 1, + })) as Record + + const name = typeof settings[nameField] === 'string' ? (settings[nameField] as string) : null + const image = settings[imageField] as MediaLike + const url = + image && typeof image === 'object' && typeof image.url === 'string' ? image.url : null + return { name, url } + } catch { + return { name: null, url: null } + } +} + +/** Admin panel logo (login screen + nav). SiteSettings `logo`, falls back to `siteName`. */ +export async function AdminLogo(props: BrandingProps = {}) { + const { settingsSlug = 'site-settings', nameField = 'siteName', imageField = 'logo' } = props + const { name, url } = await loadBranding(settingsSlug, nameField, imageField) + if (url) { + return ( + {name + ) + } + if (name) return
{name}
+ return null // nothing configured → Payload's default +} + +/** Admin panel icon (small nav glyph). SiteSettings `favicon`, falls back to initials. */ +export async function AdminIcon(props: BrandingProps = {}) { + const { settingsSlug = 'site-settings', nameField = 'siteName', imageField = 'favicon' } = props + const { name, url } = await loadBranding(settingsSlug, nameField, imageField) + if (url) { + return ( + {name + ) + } + if (name) return
{name.slice(0, 2).toUpperCase()}
+ return null +} + +/** + * Discreet vendor credit shown at the bottom of the admin nav: "Technology by + * Intecion.com". This is the PLUGIN VENDOR's credit (Intecion ships ipal-kit), + * not client data — so a sensible default here is fine and A0-safe. The client's + * own brand still owns the logo/name above (AdminLogo); this is a small line + * stating who provides the technology. Text/URL overridable; turn it off with + * `whiteLabel: { credit: false }`. + * + * Wired by ipalKit into admin.components.afterNavLinks. + */ +export function IntecionCredit(props: { text?: string; url?: string } = {}) { + const { text = 'Technology by Intecion.com', url = 'https://intecion.com' } = props + return ( + + {text} + + ) +} diff --git a/src/modules/branding/index.ts b/src/modules/branding/index.ts new file mode 100644 index 0000000..30e3b08 --- /dev/null +++ b/src/modules/branding/index.ts @@ -0,0 +1 @@ +export { AdminIcon, AdminLogo, IntecionCredit } from './adminGraphics.js' diff --git a/src/plugin.ts b/src/plugin.ts index 0f15c00..2bd530b 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -76,8 +76,8 @@ export const ipalKit = (options: IpalOptions): Plugin => { // optional peer dependency at build time (it isn't in the plugin's own // node_modules). Avoids TS2307 without @ts-expect-error; the module // exists at runtime in projects that installed it. - // @ts-ignore - const mod = (await import('@clocklimited/payload-2fa')) as { + const pkg = '@clocklimited/payload-2fa' + const mod = (await import(pkg)) as { payloadTotp?: (opts: Record) => Plugin totpPlugin?: (opts: Record) => Plugin } @@ -104,6 +104,54 @@ export const ipalKit = (options: IpalOptions): Plugin => { } } + // --- white-label admin branding --- + // Inject admin.components.graphics.Logo/Icon pointing at the plugin's + // /admin export. The components read SiteSettings at render, so each client + // sees their own brand from the panel (no brand in code). Project must run + // `pnpm generate:importmap` so Payload resolves the component paths. + if (options.whiteLabel) { + const wl = options.whiteLabel === true ? {} : options.whiteLabel + const serverProps: Record = {} + if (wl.settingsSlug) {serverProps.settingsSlug = wl.settingsSlug} + if (wl.nameField) {serverProps.nameField = wl.nameField} + const logoProps = { ...serverProps, ...(wl.logoField ? { imageField: wl.logoField } : {}) } + const iconProps = { ...serverProps, ...(wl.iconField ? { imageField: wl.iconField } : {}) } + + // Vendor credit ("Technology by Intecion.com") under the nav — on by + // default, hidden with credit:false, text/url overridable. + const creditOn = wl.credit !== false + const creditProps = + wl.credit && typeof wl.credit === 'object' + ? { + ...(wl.credit.text ? { text: wl.credit.text } : {}), + ...(wl.credit.url ? { url: wl.credit.url } : {}), + } + : {} + + config.admin = { + ...(config.admin ?? {}), + components: { + ...(config.admin?.components ?? {}), + graphics: { + ...(config.admin?.components?.graphics ?? {}), + Icon: { path: '@intecion/ipal-kit/admin#AdminIcon', serverProps: iconProps }, + Logo: { path: '@intecion/ipal-kit/admin#AdminLogo', serverProps: logoProps }, + }, + ...(creditOn + ? { + afterNavLinks: [ + ...(config.admin?.components?.afterNavLinks ?? []), + { path: '@intecion/ipal-kit/admin#IntecionCredit', serverProps: creditProps }, + ], + } + : {}), + }, + ...(wl.titleSuffix + ? { meta: { ...(config.admin?.meta ?? {}), titleSuffix: wl.titleSuffix } } + : {}), + } + } + // --- i18n --- config.localization = buildLocalizationConfig(options.i18n) diff --git a/src/types.ts b/src/types.ts index 678c5d1..cdca3bd 100644 --- a/src/types.ts +++ b/src/types.ts @@ -86,4 +86,40 @@ export type IpalOptions = { issuer: string } | 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 }