Merge claude/login-page-whitelabel-616f3d: the sign-in logo as 1.17.0's login screen shows it (SVG as an image, no plate)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@@ -1171,7 +1171,7 @@ project → **plugin gap**, not a copy.
|
||||
| Mail | `email: mailAdapter()` + `serverURL` — mail works with no other setup, through the Intecion mail service; SMTP in the panel only when the client asks; your own mail: `payload.sendEmail` (`withMailKind` when it is account mail); never a second transport in the project. §7.2 | email.md |
|
||||
| Env validation, health | `assertEnv(iaplEnvRules({…}))` (`/env`), `healthRoute` | env.md |
|
||||
| 2FA, white-label, headers | `twoFactor: { issuer, plugin: payloadTotp }`, `whiteLabel`, `buildSecurityHeaders` | security.md, white-label.md |
|
||||
| Sign-in screens (login, forgot / reset password, first user, logout, the 2FA screens): a dark panel with the client's logo or the site's name beside the form, language links, both themes, phone | on with `whiteLabel` (`signIn`); a NEW site: `whiteLabel: { signIn: { allScreens: true } }` + `pnpm payload generate:importmap` (adds the provider `SignInLook`; without it only login and the 2FA screens get the look, through `AdminLogo` / `SafeTotpView`). Logo and name come from Site settings (no env var, no new field, no migration). The logo is a bitmap (JPEG, PNG, WebP, AVIF, GIF; an SVG logo shows the name unless `svgLogo: true`), checked by its bytes before it is printed (`checkLogo`), without a plate (`logoPlate: true` for a logo with dark letters). Options: `accent` (hex), `languages: false`; `signIn: false` = Payload's screens. Name / logo / icon are admin-only with the look (`brandAccess: 'editor'` = as before). Never build a login page, a custom `graphics.Logo` or login CSS by hand. Check: `curl -s $URL/admin/login \| grep -c iapl-signin__label` ≥ 1; `curl -si "$URL/api/ipal/admin-language?lng=xx"` → 400 | white-label.md → "The sign-in screens" |
|
||||
| Sign-in screens (login, forgot / reset password, first user, logout, the 2FA screens): a dark panel with the client's logo or the site's name beside the form, language links, both themes, phone | on with `whiteLabel` (`signIn`); a NEW site: `whiteLabel: { signIn: { allScreens: true } }` + `pnpm payload generate:importmap` (adds the provider `SignInLook`; without it only login and the 2FA screens get the look, through `AdminLogo` / `SafeTotpView`). Logo and name come from Site settings (no env var, no new field, no migration). The logo is whatever Site settings → Logo holds, an SVG too, as `<img>` — the same as on the login screen before (`svgLogo: false` refuses SVG); a file that is gone gives the name instead of a broken picture (`checkLogo`); no plate (`logoPlate: true` for a logo with dark letters). Options: `accent` (hex), `languages: false`; `signIn: false` = Payload's screens. Name / logo / icon are admin-only with the look (`brandAccess: 'editor'` = as before). Never build a login page, a custom `graphics.Logo` or login CSS by hand. Check: `curl -s $URL/admin/login \| grep -c iapl-signin__label` ≥ 1; `curl -si "$URL/api/ipal/admin-language?lng=xx"` → 400 | white-label.md → "The sign-in screens" |
|
||||
| Panel link preview + noindex (site name, description, preview image, technology support credit) | on by default (`adminMeta`, `agency`) — do not hand-write `admin.meta` for it; override single keys in `admin.meta` or `adminMeta: { … }` | white-label.md |
|
||||
| Rate limit (forms, MCP, search) | built in; IP from `IAPL_IP_HEADER`; several instances → `setRateLimitStore` | forms.md |
|
||||
|
||||
|
||||
@@ -64,13 +64,13 @@ description: Complete map of everything @intecion/ipal-kit provides — every ia
|
||||
| `whiteLabel.logoField` / `iconField` / `nameField` | `'logo'` / `'favicon'` / `'siteName'` | fields in Site settings | any upload/text field |
|
||||
| `whiteLabel.titleSuffix` | none | `admin.meta.titleSuffix` (tab title) | — |
|
||||
| `whiteLabel.credit` | on | `IntecionCredit` in `afterLogin` and `afterNavLinks`: "Technology support: Intecion.com" (en/pl, from `agency`) | `false`; `{ text, url }` overrides |
|
||||
| `whiteLabel.signIn` | on (with `whiteLabel`) | the sign-in look: a dark panel with the client's logo (Site settings → Logo: JPEG / PNG / WebP / AVIF / GIF, fetched and checked by its bytes before it is printed, ≤ 512 KB, fits 240 × 72, no plate) or the site's name beside the form, "Administration panel", language links; both themes, a band above the form on a phone. Login, the 2FA screens and e-mail verification get it through `AdminLogo` / `SafeTotpView` (already in the import map: an upgrade needs no edit). No env var, no new field, no migration | `false` = Payload's own screens |
|
||||
| `whiteLabel.signIn` | on (with `whiteLabel`) | the sign-in look: a dark panel with the client's logo (Site settings → Logo, any picture it holds — an SVG too — as `<img>`, exactly what the login screen showed before; fits 240 × 72, no plate) or the site's name beside the form, "Administration panel", language links; both themes, a band above the form on a phone. Login, the 2FA screens and e-mail verification get it through `AdminLogo` / `SafeTotpView` (already in the import map: an upgrade needs no edit). No env var, no new field, no migration | `false` = Payload's own screens |
|
||||
| `whiteLabel.signIn.allScreens` | `false` (the starter writes `true`) | the look on forgot / reset password, create first user, logout and "unauthorized" too: adds the provider `SignInLook` — ONE new import-map entry, run `pnpm payload generate:importmap`. Production start: when `importMap.js` on disk lacks it, the provider is left out and the log says `[iapl] The sign-in look covers only the login and 2FA screens …` | `true` |
|
||||
| `whiteLabel.signIn.accent` | `#0070c0` | hex colour of the button, links and focus ring (anything that is not a hex colour is ignored); or CSS variables `--iapl-signin-*` on `:root` in the admin's `custom.scss` | `'#0b6e4f'` |
|
||||
| `whiteLabel.signIn.logoPlate` | `false` (the logo straight on the dark panel: upload one that works on dark) | `true` = a white plate behind the logo (dark letters) | — |
|
||||
| `whiteLabel.signIn.checkLogo` | on | the logo's file is fetched as an anonymous visitor gets it and its first bytes read (10-minute memory); a deleted / broken / non-image / > 512 KB file → the site's name; nothing answers → the upload document is believed | `false` = no fetch |
|
||||
| `whiteLabel.signIn.checkLogo` | on | only against a broken picture: the logo's address is asked once as an anonymous visitor would (no redirect followed, 4 s, ≤ 512 KB read, 10-minute memory); a file that is gone (404 / 410) or is no picture (HTML, PDF) → the site's name; anything else (nothing answers, a redirect, another status, over 512 KB) → the upload is believed | `false` = no fetch |
|
||||
| `whiteLabel.signIn.languages` | shown with 2+ admin languages | links on the panel; `GET /api/ipal/admin-language?lng=<code>` writes Payload's `payload-lng` cookie and redirects (303) back to the admin path of the `Referer`; unknown language → 400 | `false` = no links, no endpoint |
|
||||
| `whiteLabel.signIn.svgLogo` | `false`: an SVG logo is NOT shown on the sign-in screens (the site's name is) — tell the client to upload a PNG / WebP logo | `true` = shown as a picture (`<img>` runs no script) | — |
|
||||
| `whiteLabel.signIn.svgLogo` | `true`: an SVG logo is shown as a picture (`<img>` runs no script), as on the login screen before | `false` = an SVG logo is not shown on the sign-in screens (the site's name is) | — |
|
||||
| `whiteLabel.brandAccess` | `'admin'` with the sign-in look (else `'editor'`) | field-level `access.update` on the name, logo and icon fields of Site settings: only admins change what the sign-in screens show; editors keep the rest. No schema change | `'editor'` = whoever edits Site settings |
|
||||
| `agency` | `{ name: 'Intecion.com', url: 'https://intecion.com' }` | the credit line, the panel's link description and preview image | `{ name, url }` = another agency; `false` = none anywhere |
|
||||
| `adminMeta` | on (with or without `whiteLabel`) | panel `<head>`: `robots` noindex/nofollow, `titleSuffix` "— <site> \| Panel", `og:site_name` + description from Site settings (refreshed on save), `og:image` `GET /api/ipal/admin-og` (1200×630 from the logo or name), icon `GET /api/ipal/admin-icon` (favicon or initials); no import map step | `false` = Payload defaults; `{ robots, titleSuffix, description, image, icons, language }` (each `false` or your value; `{site}`, `{agency}` placeholders); your own `admin.meta` keys always win. Check: `curl -s $URL/admin/login \| grep -E 'og:\|robots'` (white-label.md) |
|
||||
|
||||
@@ -626,7 +626,7 @@ Server only (`pnpm payload run`); never import it from client code, the Payload
|
||||
| `resolveRequireSetup(option)`, `strictExempt(fn)`, `SETUP_FROM_FIELD`, `DEFAULT_SETUP_WINDOW_HOURS` | `@intecion/ipal-kit` | `twoFactor.requireSetup` → `{ requireSetup, setupWindowMs, exempt? }` as the guard reads it (throws on a `windowHours` that is not a number ≥ 0 or `false`, and on an `async` `exempt`); the wrapper that makes an `exempt` function answer `true` only for exactly `true`; the field name `'totpSetupFrom'`; `72`. |
|
||||
| `fetchPublicImage(url, base, { timeoutMs? }?)`, `publicImageDataUri(url, base)`, `rasterImageType(bytes)`, `siteOrigin(serverURL)`, `PUBLIC_IMAGE_MAX_BYTES`, `PUBLIC_IMAGE_TIMEOUT_MS` | `@intecion/ipal-kit` | An image fetched the way an anonymous visitor gets it, as `{ bytes, type }` or a `data:` address, else `null`: no cookies; http(s) only; `image/*`; ONE address — a redirect is never followed (a 3xx is "no image"); the whole exchange within `PUBLIC_IMAGE_TIMEOUT_MS` (5000); at most `PUBLIC_IMAGE_MAX_BYTES` (512 KB), reading stops at the limit whatever `content-length` says. `base` is the site's configured origin (`siteOrigin(config.serverURL)` = `serverURL`, else `NEXT_PUBLIC_SERVER_URL`) — never build it from a request's `Host` / `X-Forwarded-Host`. Used for the logo and icon on the 2FA screens and by `/api/ipal/admin-og` and `/api/ipal/admin-icon`. `rasterImageType`: the bitmap type by the first bytes (PNG, JPEG, GIF, WebP, ICO, AVIF), `null` for anything else, SVG included. |
|
||||
| `resolveSignInLook(whiteLabel)` | `@intecion/ipal-kit` | `whiteLabel` option → `null` (white-label or `signIn` off) or `{ allScreens, props }` (`ResolvedSignInLook`; `props` = `SignInLookProps`, the plain values the components get: `accent`, `checkLogo`, `imageField`, `inlineImages`, `languages`, `logoPlate`, `nameField`, `settingsSlug`, `svgLogo`). Option type: `SignInLookOptions`. |
|
||||
| `loadSignInBrand({ payload, look, locale?, user? })`, `signInName(value, locale?)`, `signInLogo(media, { svgLogo? })`, `checkLogoFile(url, base, allowSvg?)`, `fitLogo(width, height, box?)`, `isSvgUpload(media)`, `SIGN_IN_LOGO_TYPES` | `@intecion/ipal-kit` | What the sign-in panel shows: `{ name, logo }` (`SignInBrand`, `SignInLogo = { src, width?, height? }`) read from Site settings, never throwing; the name as one line of plain text (control characters out, cut at `SIGN_IN_NAME_MAX` = 80); the logo of an upload document — only JPEG / PNG / WebP / AVIF / GIF (`SIGN_IN_LOGO_TYPES`; SVG with `svgLogo: true`), only an `http(s)` or site-relative address, fitted into `SIGN_IN_LOGO_BOX` (240 × 72) without enlarging, served from the smallest generated size ≥ 2× the shown width with the same proportions; the look at the file itself (`LogoCheck`: `{ bytes, type }`, `'bad'` = the server answered and it is no such picture or over 512 KB, `'unknown'` = nothing answered). A session that owes its 2FA code gets the checked picture inlined or no logo. |
|
||||
| `loadSignInBrand({ payload, look, locale?, user? })`, `signInName(value, locale?)`, `signInLogo(media, { svgLogo? })`, `checkLogoFile(url, base, allowSvg?)`, `fitLogo(width, height, box?)`, `isSvgUpload(media)` | `@intecion/ipal-kit` | What the sign-in panel shows: `{ name, logo }` (`SignInBrand`, `SignInLogo = { src, width?, height? }`) read from Site settings, never throwing; the name as one line of plain text (control characters out, cut at `SIGN_IN_NAME_MAX` = 80); the logo of an upload document — any picture (an SVG too unless `svgLogo: false`; `null` only for an upload whose type says it is no picture, or an address that is not `http(s)` or site-relative), fitted into `SIGN_IN_LOGO_BOX` (240 × 72) without enlarging, served from the smallest generated size ≥ 2× the shown width with the same proportions; the look at the file itself (`LogoCheck`: `{ bytes, type }`; `'bad'` = certainly no picture there: 404 / 410, a 2xx answer of another type, an SVG while refused; `'unknown'` = nothing answered, a redirect (never followed), another status, no type, over 512 KB — the upload is believed). A session that owes its 2FA code gets the checked picture inlined or no logo. |
|
||||
| `signInCss({ accent? })`, `isHexColour(value)`, `SIGN_IN_STYLE_ID` | `@intecion/ipal-kit` | The stylesheet of the sign-in look as a string (no `url()`, no font, no other host; every rule needs `.iapl-signin` on the page), the hex check `accent` must pass, and the `href` of its `<style>` (`'iapl-sign-in'`). |
|
||||
| `languageLinks(config, current)`, `LANGUAGE_NAMES`, `buildAdminLanguageEndpoint()`, `adminPathFromReferer(referer, adminRoute)`, `ADMIN_LANGUAGE_PATH` | `@intecion/ipal-kit` | The panel's languages as links (`LanguageLink[]`: `{ code, name, current, href }`; empty with one language; names in their own language, else the code); the public endpoint `GET /api/ipal/admin-language?lng=` (`'/ipal/admin-language'`) that writes `<cookiePrefix>-lng` for a supported language (else 400) and answers 303 to a path inside the admin route taken from the `Referer` (anything else → the admin root, never another host). |
|
||||
| `signInProviderActive(payload)`, `SIGN_IN_LOOK` | `@intecion/ipal-kit` | Whether the provider `'@intecion/ipal-kit/admin#SignInLook'` is in the config AND in the running import map — `AdminLogo` and `SafeTotpView` print the panel themselves only when it is not. |
|
||||
|
||||
@@ -299,8 +299,8 @@ the panel shows Site settings, Site integrations, Cookies, Form messages, the Fo
|
||||
- Sign-in screens (`whiteLabel.signIn`, on): a dark panel with the client's logo or the site's name beside the
|
||||
form; the logo and name are Site settings fields (no env var, no migration). `allScreens: true` (in the config
|
||||
above) adds the provider `SignInLook` to the import map and covers forgot / reset password, first user and
|
||||
logout. The logo: JPEG / PNG / WebP / AVIF / GIF (an SVG logo shows the name: `svgLogo: true` or upload a
|
||||
bitmap), drawn for a DARK ground (no plate; `logoPlate: true` for a logo with dark letters). `accent: '#hex'`,
|
||||
logout. The logo: any picture Site settings holds, an SVG too (`svgLogo: false` refuses SVG), drawn for a
|
||||
DARK ground (no plate; `logoPlate: true` for a logo with dark letters). `accent: '#hex'`,
|
||||
`languages: false`, `checkLogo: false`; `signIn: false` = Payload's screens. Name, logo and icon in Site
|
||||
settings are admin-only with the look (`brandAccess: 'editor'` gives them back to editors).
|
||||
Check: `/admin/login` and `/admin/forgot` show the panel, also at a phone width; do not write login CSS by hand.
|
||||
|
||||
@@ -679,8 +679,8 @@ PROGRAMISTA §6, items 73–75; email.md; AGENT.md §7.2) — nothing to run; re
|
||||
import map already has. **Check:** open `/admin/login` on a desktop and at a phone width, in both themes; sign
|
||||
in through 2FA.
|
||||
**Look at the logo:** it stands straight on a dark panel. A logo with dark letters: `signIn: { logoPlate: true }`
|
||||
(a white plate) or ask the client for a logo for dark grounds. An **SVG** logo is not shown there (the site's
|
||||
name is): upload a PNG / WebP logo, or `signIn: { svgLogo: true }`.
|
||||
(a white plate) or ask the client for a logo for dark grounds. Every logo that showed on the login screen
|
||||
before shows now (an SVG too); only a logo whose file is gone shows the site's name instead of a broken picture.
|
||||
**Editors lose three fields:** the name, logo and icon of Site settings are admin-only now (they are what the
|
||||
public sign-in page shows). A site whose editors must change them: `whiteLabel: { brandAccess: 'editor' }`.
|
||||
2. **Tell the owner the sign-in page looks different** and ask whether to keep it. No: `whiteLabel: { signIn: false }`
|
||||
|
||||
@@ -14,6 +14,7 @@ site; `after-*` from a production build with `signIn: { allScreens: true }`, `be
|
||||
| `before-*.png` | IAPL 1.17.0: login (light, dark, phone, Polish, wrong password), forgot password, 2FA code, 2FA setup; `-logo` = with a logo set |
|
||||
| `after-*-name.png` | the new look with no logo set: the site's name |
|
||||
| `after-*-logo.png` | the new look with a logo made for dark grounds (`placeholder-logo-for-dark.png`), no plate — the default |
|
||||
| `after-{login,2fa-code}-*-logo-svg.png` | an SVG logo from Site settings (`placeholder-logo-for-dark.svg`) on a built site: shown on login and, inlined, on the 2FA code screen — as 1.17.0 showed it |
|
||||
| `after-login-*-logo-dark-letters-no-plate.png` | a logo with dark letters (`placeholder-logo.png`) on the default: hard to read; such a site sets `logoPlate: true` |
|
||||
| `after-first-user-*.png` | create first user on an empty database (no site name yet: the host is shown) |
|
||||
| `legacy-unedited-*.png` | the reference site as it was at v1.16.7, **unedited**, built against this plugin: login has the look (through `AdminLogo`), forgot password and create first user are Payload's own until the project sets `allScreens` |
|
||||
@@ -50,7 +51,7 @@ without users: `--only=first-user`). The files are 8-bit PNGs (re-encoded to kee
|
||||
|---|---|---|
|
||||
| Split, panel inset and corners, grid, glows, colours | the same numbers (`css.ts`) | yes |
|
||||
| Label, logo box (240 × 72, 2× source), name as text, link to the site, alternative text | the same | yes |
|
||||
| Logo types (JPEG, PNG, WebP, AVIF, GIF; no SVG) and the look at the file before printing | the same; Payload accepts SVG uploads, so `svgLogo: true` exists; the file is checked by a fetch (IAWL reads the disk), and an unreachable address counts as "believe the upload" | yes, two notes |
|
||||
| Logo types and the look at the file before printing | **as IAPL's white label did in 1.17.0** (owner, 2026-11-26): any picture Site settings holds, an SVG too, as `<img>`; `svgLogo: false` refuses SVG. The file is asked once only to avoid a broken picture (gone / no picture → the name) | IAWL: JPEG, PNG, WebP, AVIF, GIF, no SVG (WordPress refuses the upload); file read from disk |
|
||||
| Plate | **no plate by default** (the owner's choice for new surfaces), `logoPlate: true` adds it | IAWL: plate by default, `logoMadeFor => 'dark'` removes it |
|
||||
| Button, link, focus and border colours; field and button heights; 28 rem column | the same | yes |
|
||||
| Phone band at 52 rem | the same | yes |
|
||||
|
||||
|
After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
|
After Width: | Height: | Size: 72 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 83 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
|
After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
|
After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
@@ -9,10 +9,10 @@ the 2FA screens (code, setup) show a dark panel with the client's logo — or th
|
||||
look IAPL now shares with IAWL. No edit, no `generate:importmap`, no migration, no new env var.
|
||||
Keep Payload's screens: `whiteLabel: { signIn: false }`. Sites without `whiteLabel`: nothing changes.
|
||||
|
||||
Three things to look at on such a site, each with a one-line way back:
|
||||
- **The logo stands straight on a dark panel** (no plate). A logo with dark letters: `signIn: { logoPlate: true }`.
|
||||
- **An SVG logo is not shown on the sign-in screens** (the site's name is; the rest of the site is untouched):
|
||||
upload a PNG / WebP logo or set `signIn: { svgLogo: true }`.
|
||||
**Every logo that showed on the login screen before shows on the new screens** (an SVG too): the logo is handled
|
||||
as the white label handled it until now. Two things to look at on such a site, each with a one-line way back:
|
||||
- **The logo stands straight on a dark panel** (no plate — the owner's decision). A logo with dark letters:
|
||||
`signIn: { logoPlate: true }`.
|
||||
- **Editors can no longer change the site's name, logo and icon** in Site settings (admins can): these are what the
|
||||
public sign-in page shows. `whiteLabel: { brandAccess: 'editor' }` gives them back.
|
||||
|
||||
@@ -39,11 +39,13 @@ Three things to look at on such a site, each with a one-line way back:
|
||||
"unauthorized". Adds the provider `SignInLook` (one import-map entry: `pnpm payload generate:importmap`). The
|
||||
project starter writes it for new sites. A production start that does not find the entry in `importMap.js`
|
||||
leaves the provider out and logs what to run; the panel keeps working.
|
||||
- **The logo follows IAWL's rules:** JPEG, PNG, WebP, AVIF or GIF; fetched and checked by its bytes before it is
|
||||
printed (at most 512 KB; a deleted or broken file gives the name); fits 240 × 72, served from a generated size
|
||||
at least twice as wide when the media collection has one; alternative text = the site's name.
|
||||
- **The logo:** whatever Site settings → Logo holds, an SVG too, as an `<img>`; fits 240 × 72 (it was up to
|
||||
420 × 120), served from a generated size at least twice as wide when the media collection has one; alternative
|
||||
text = the site's name. Its file is asked once before it is printed (no redirect followed, 4 s, 512 KB): a file
|
||||
that is gone, or is no picture, gives the site's name instead of a broken picture; in any doubt the upload is
|
||||
believed.
|
||||
- **Options:** `signIn.accent` (hex colour of the button, links and focus ring), `signIn.logoPlate` (a white plate),
|
||||
`signIn.svgLogo` (allow an SVG logo), `signIn.checkLogo: false`, `signIn.languages: false`,
|
||||
`signIn.svgLogo: false` (refuse an SVG logo), `signIn.checkLogo: false`, `signIn.languages: false`,
|
||||
`whiteLabel.brandAccess` (`'admin'` with the look, `'editor'` as before; field-level access, no schema change).
|
||||
CSS variables `--iapl-signin-*` for a project's `custom.scss`.
|
||||
- **Language links before sign-in:** `GET /api/ipal/admin-language?lng=<code>` writes Payload's language cookie for
|
||||
@@ -52,7 +54,7 @@ Three things to look at on such a site, each with a one-line way back:
|
||||
- **The 2FA code boxes have names** for screen readers ("Digit 2 of 6") and ask a phone for the numeric keyboard
|
||||
(with the sign-in look).
|
||||
- Exports: `SignInPanel`, `SignInLook` (`/admin`); `resolveSignInLook`, `loadSignInBrand`, `signInLogo`,
|
||||
`signInName`, `checkLogoFile`, `fitLogo`, `isSvgUpload`, `SIGN_IN_LOGO_TYPES`, `languageLinks`, `LANGUAGE_NAMES`, `signInCss`, `isHexColour`,
|
||||
`signInName`, `checkLogoFile`, `fitLogo`, `isSvgUpload`, `languageLinks`, `LANGUAGE_NAMES`, `signInCss`, `isHexColour`,
|
||||
`signInProviderActive`, `buildAdminLanguageEndpoint`, `adminPathFromReferer`, `SIGN_IN_LOOK`, `SIGN_IN_STYLE_ID`,
|
||||
`SIGN_IN_LOGO_BOX`, `SIGN_IN_NAME_MAX`, `ADMIN_LANGUAGE_PATH` and their types.
|
||||
|
||||
@@ -66,5 +68,5 @@ Three things to look at on such a site, each with a one-line way back:
|
||||
|
||||
## Requires project changes
|
||||
|
||||
None for the panel to work — but read the three points at the top. Recommended: `allScreens` (one config line, regenerate the import map). A project with its own CSS for the
|
||||
None for the panel to work — but read the two points at the top. Recommended: `allScreens` (one config line, regenerate the import map). A project with its own CSS for the
|
||||
login screen looks at the result after the update.
|
||||
|
||||
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="560" height="160" viewBox="0 0 560 160"><path d="M20 80a60 60 0 0 1 60-60h40v120H80a60 60 0 0 1-60-60z" fill="#b8c0cc"/><text x="150" y="78" font-family="Helvetica,Arial,sans-serif" font-weight="700" font-size="52" fill="#ffffff">Your logo</text><text x="150" y="124" font-family="Helvetica,Arial,sans-serif" font-size="34" fill="#b8c0cc">SVG placeholder</text></svg>
|
||||
|
After Width: | Height: | Size: 415 B |
@@ -135,15 +135,18 @@ uses too.** No new field, collection or global — so **no migration on Postgres
|
||||
With nothing set, the panel shows the label and the site's host: no Intecion and no Payload mark is put on a
|
||||
client's sign-in page (the credit line under the form is separate: `credit: false`).
|
||||
|
||||
**The logo — the same rules as on the WordPress sibling (IAWL):**
|
||||
**The logo — handled as the white label handled it on the login screen until now.** The rule: *a logo that showed
|
||||
on a site's login screen before the sign-in look shows on the new screens too.*
|
||||
|
||||
- **Types:** JPEG, PNG, WebP, AVIF, GIF. **No SVG** (`svgLogo: true` allows it; IAWL has no such switch because
|
||||
WordPress refuses the upload — Payload accepts SVG uploads, so a site whose logo is an SVG shows its **name** on
|
||||
the sign-in screens until it uploads a bitmap or sets the option).
|
||||
- **Looked at before it is printed:** the server fetches the file as an anonymous visitor would (at most 512 KB)
|
||||
and reads its first bytes. A deleted, broken, renamed, non-image or too large file gives the site's name, never
|
||||
a broken picture. A redirect is never followed by the server. The answer is remembered for ten minutes. When nothing answers at all (a container that cannot
|
||||
reach its own public address), the upload document is believed. `checkLogo: false` turns the look off.
|
||||
- **Types: whatever Site settings → Logo holds**, an SVG included, shown as a picture (`<img>`, where no picture
|
||||
runs script) — exactly what `AdminLogo` printed in 1.17.0. No list of allowed types. `svgLogo: false` refuses
|
||||
SVG for a project that wants bitmaps only. *IAWL differs:* it has no SVG because WordPress refuses the upload.
|
||||
- **Looked at before it is printed — only to avoid a broken picture.** The server asks the file's address once, as
|
||||
an anonymous visitor would. The site's name is shown instead when the file is **gone** (404 / 410) or the answer
|
||||
**is no picture** (an HTML page, a PDF) — the cases where 1.17.0 showed a broken picture. In every other case
|
||||
the upload is believed and the browser decides: nothing answers (a container that cannot reach its own public
|
||||
address), a redirect (never followed by the server), any other status (a firewall that refuses servers), a file
|
||||
over 512 KB. The answer is remembered for ten minutes. `checkLogo: false` turns the look off.
|
||||
- **Size:** fits 240 × 72 px (192 × 56 on a phone), never enlarged or cropped, `width` and `height` set (no
|
||||
layout shift). Served from the smallest generated size (`imageSizes` of the media collection) that is at least
|
||||
twice the shown width and has the same proportions; else the upload itself. Recommended: PNG or WebP, 480 px
|
||||
@@ -183,7 +186,7 @@ screens … Run "pnpm payload generate:importmap"`. Without `allScreens` the oth
|
||||
| `accent` | the shared blue `#0070c0` | a hex colour for the button, the links and the focus ring; it carries white text, so check its contrast (4.5:1) |
|
||||
| `logoPlate` | `false` | `true`: a white plate behind the logo (a logo with dark letters) |
|
||||
| `languages` | shown when the panel has 2+ languages | `false`: no language links, and no `/api/ipal/admin-language` endpoint |
|
||||
| `svgLogo` | `false` | `true`: an SVG logo is shown too (as a picture, where it cannot run script) |
|
||||
| `svgLogo` | `true` | `false`: an SVG logo is not shown on the sign-in screens; the site's name is |
|
||||
| `checkLogo` | `true` | `false`: the logo's file is not fetched and looked at before it is printed |
|
||||
|
||||
**Language links.** Plain links, no script: `GET /api/ipal/admin-language?lng=pl` writes Payload's own language
|
||||
@@ -198,11 +201,12 @@ The sign-in page is open to anyone, so what reaches it is narrow on purpose:
|
||||
|
||||
- **Text:** the site's name only, as plain text (escaped; one line, at most 80 characters). No description, no
|
||||
rich text, no link an editor can write: the panel's only links are the site's own root and the language links.
|
||||
- **Pictures:** the logo as an `<img>`, bitmaps only (above), checked by its bytes, at most 512 KB; only an
|
||||
`http(s)` or site-relative address is used. The plugin serves **no new file** for it: the logo is the media file
|
||||
- **Pictures:** the logo as an `<img>` — a picture in `<img>` never runs script, an SVG included, and it is never
|
||||
put into the page as markup; only an `http(s)` or site-relative address is used. The server's own look at the
|
||||
file asks one address, follows no redirect, waits 4 s and reads at most 512 KB. The plugin serves **no new file** for it: the logo is the media file
|
||||
at its own address, with the media collection's own headers and cache rules. On the 2FA screens (the session is
|
||||
refused `media`) the picture that was just checked is put into the page as a `data:` image; when it could not
|
||||
be fetched the name is shown (`inlineImages`, above).
|
||||
refused `media`) the picture that was just checked is put into the page as a `data:` image (at most 512 KB);
|
||||
when it could not be fetched — also when its address redirects — the name is shown (`inlineImages`, above).
|
||||
- **Who can change it: admins.** With the sign-in look on, the three brand fields of Site settings (name, logo,
|
||||
icon) get field-level access for admins only; an editor still edits every other Site setting and sees these
|
||||
three read-only. No schema change. `whiteLabel: { brandAccess: 'editor' }` gives them back to editors.
|
||||
@@ -242,7 +246,7 @@ Set the custom properties on `:root` in the admin's `custom.scss` (the defaults
|
||||
- **Your own panel:** `SignInPanel` (the panel with its stylesheet) and `SignInLook` (the provider) are exported
|
||||
from `@intecion/ipal-kit/admin`; wire them in `admin.components` with `serverProps: { look: { … } }`
|
||||
(`SignInLookProps`). From the main entry: `resolveSignInLook`, `loadSignInBrand`, `signInLogo`, `signInName`,
|
||||
`checkLogoFile` (`LogoCheck`), `SIGN_IN_LOGO_TYPES`, `fitLogo`, `isSvgUpload`, `languageLinks`, `LANGUAGE_NAMES`, `signInCss`, `isHexColour`, `signInProviderActive`,
|
||||
`checkLogoFile` (`LogoCheck`), `fitLogo`, `isSvgUpload`, `languageLinks`, `LANGUAGE_NAMES`, `signInCss`, `isHexColour`, `signInProviderActive`,
|
||||
`buildAdminLanguageEndpoint`, `adminPathFromReferer`, and the constants `SIGN_IN_LOOK`, `SIGN_IN_STYLE_ID`,
|
||||
`SIGN_IN_LOGO_BOX`, `SIGN_IN_NAME_MAX`, `ADMIN_LANGUAGE_PATH`; types `SignInLookOptions`, `ResolvedSignInLook`,
|
||||
`SignInLookProps`, `SignInBrand`, `SignInLogo`, `LanguageLink`, `SignInPanelProps`, `SignInLookProviderProps`.
|
||||
|
||||
@@ -64,13 +64,13 @@ description: Complete map of everything @intecion/ipal-kit provides — every ia
|
||||
| `whiteLabel.logoField` / `iconField` / `nameField` | `'logo'` / `'favicon'` / `'siteName'` | fields in Site settings | any upload/text field |
|
||||
| `whiteLabel.titleSuffix` | none | `admin.meta.titleSuffix` (tab title) | — |
|
||||
| `whiteLabel.credit` | on | `IntecionCredit` in `afterLogin` and `afterNavLinks`: "Technology support: Intecion.com" (en/pl, from `agency`) | `false`; `{ text, url }` overrides |
|
||||
| `whiteLabel.signIn` | on (with `whiteLabel`) | the sign-in look: a dark panel with the client's logo (Site settings → Logo: JPEG / PNG / WebP / AVIF / GIF, fetched and checked by its bytes before it is printed, ≤ 512 KB, fits 240 × 72, no plate) or the site's name beside the form, "Administration panel", language links; both themes, a band above the form on a phone. Login, the 2FA screens and e-mail verification get it through `AdminLogo` / `SafeTotpView` (already in the import map: an upgrade needs no edit). No env var, no new field, no migration | `false` = Payload's own screens |
|
||||
| `whiteLabel.signIn` | on (with `whiteLabel`) | the sign-in look: a dark panel with the client's logo (Site settings → Logo, any picture it holds — an SVG too — as `<img>`, exactly what the login screen showed before; fits 240 × 72, no plate) or the site's name beside the form, "Administration panel", language links; both themes, a band above the form on a phone. Login, the 2FA screens and e-mail verification get it through `AdminLogo` / `SafeTotpView` (already in the import map: an upgrade needs no edit). No env var, no new field, no migration | `false` = Payload's own screens |
|
||||
| `whiteLabel.signIn.allScreens` | `false` (the starter writes `true`) | the look on forgot / reset password, create first user, logout and "unauthorized" too: adds the provider `SignInLook` — ONE new import-map entry, run `pnpm payload generate:importmap`. Production start: when `importMap.js` on disk lacks it, the provider is left out and the log says `[iapl] The sign-in look covers only the login and 2FA screens …` | `true` |
|
||||
| `whiteLabel.signIn.accent` | `#0070c0` | hex colour of the button, links and focus ring (anything that is not a hex colour is ignored); or CSS variables `--iapl-signin-*` on `:root` in the admin's `custom.scss` | `'#0b6e4f'` |
|
||||
| `whiteLabel.signIn.logoPlate` | `false` (the logo straight on the dark panel: upload one that works on dark) | `true` = a white plate behind the logo (dark letters) | — |
|
||||
| `whiteLabel.signIn.checkLogo` | on | the logo's file is fetched as an anonymous visitor gets it and its first bytes read (10-minute memory); a deleted / broken / non-image / > 512 KB file → the site's name; nothing answers → the upload document is believed | `false` = no fetch |
|
||||
| `whiteLabel.signIn.checkLogo` | on | only against a broken picture: the logo's address is asked once as an anonymous visitor would (no redirect followed, 4 s, ≤ 512 KB read, 10-minute memory); a file that is gone (404 / 410) or is no picture (HTML, PDF) → the site's name; anything else (nothing answers, a redirect, another status, over 512 KB) → the upload is believed | `false` = no fetch |
|
||||
| `whiteLabel.signIn.languages` | shown with 2+ admin languages | links on the panel; `GET /api/ipal/admin-language?lng=<code>` writes Payload's `payload-lng` cookie and redirects (303) back to the admin path of the `Referer`; unknown language → 400 | `false` = no links, no endpoint |
|
||||
| `whiteLabel.signIn.svgLogo` | `false`: an SVG logo is NOT shown on the sign-in screens (the site's name is) — tell the client to upload a PNG / WebP logo | `true` = shown as a picture (`<img>` runs no script) | — |
|
||||
| `whiteLabel.signIn.svgLogo` | `true`: an SVG logo is shown as a picture (`<img>` runs no script), as on the login screen before | `false` = an SVG logo is not shown on the sign-in screens (the site's name is) | — |
|
||||
| `whiteLabel.brandAccess` | `'admin'` with the sign-in look (else `'editor'`) | field-level `access.update` on the name, logo and icon fields of Site settings: only admins change what the sign-in screens show; editors keep the rest. No schema change | `'editor'` = whoever edits Site settings |
|
||||
| `agency` | `{ name: 'Intecion.com', url: 'https://intecion.com' }` | the credit line, the panel's link description and preview image | `{ name, url }` = another agency; `false` = none anywhere |
|
||||
| `adminMeta` | on (with or without `whiteLabel`) | panel `<head>`: `robots` noindex/nofollow, `titleSuffix` "— <site> \| Panel", `og:site_name` + description from Site settings (refreshed on save), `og:image` `GET /api/ipal/admin-og` (1200×630 from the logo or name), icon `GET /api/ipal/admin-icon` (favicon or initials); no import map step | `false` = Payload defaults; `{ robots, titleSuffix, description, image, icons, language }` (each `false` or your value; `{site}`, `{agency}` placeholders); your own `admin.meta` keys always win. Check: `curl -s $URL/admin/login \| grep -E 'og:\|robots'` (white-label.md) |
|
||||
|
||||
@@ -626,7 +626,7 @@ Server only (`pnpm payload run`); never import it from client code, the Payload
|
||||
| `resolveRequireSetup(option)`, `strictExempt(fn)`, `SETUP_FROM_FIELD`, `DEFAULT_SETUP_WINDOW_HOURS` | `@intecion/ipal-kit` | `twoFactor.requireSetup` → `{ requireSetup, setupWindowMs, exempt? }` as the guard reads it (throws on a `windowHours` that is not a number ≥ 0 or `false`, and on an `async` `exempt`); the wrapper that makes an `exempt` function answer `true` only for exactly `true`; the field name `'totpSetupFrom'`; `72`. |
|
||||
| `fetchPublicImage(url, base, { timeoutMs? }?)`, `publicImageDataUri(url, base)`, `rasterImageType(bytes)`, `siteOrigin(serverURL)`, `PUBLIC_IMAGE_MAX_BYTES`, `PUBLIC_IMAGE_TIMEOUT_MS` | `@intecion/ipal-kit` | An image fetched the way an anonymous visitor gets it, as `{ bytes, type }` or a `data:` address, else `null`: no cookies; http(s) only; `image/*`; ONE address — a redirect is never followed (a 3xx is "no image"); the whole exchange within `PUBLIC_IMAGE_TIMEOUT_MS` (5000); at most `PUBLIC_IMAGE_MAX_BYTES` (512 KB), reading stops at the limit whatever `content-length` says. `base` is the site's configured origin (`siteOrigin(config.serverURL)` = `serverURL`, else `NEXT_PUBLIC_SERVER_URL`) — never build it from a request's `Host` / `X-Forwarded-Host`. Used for the logo and icon on the 2FA screens and by `/api/ipal/admin-og` and `/api/ipal/admin-icon`. `rasterImageType`: the bitmap type by the first bytes (PNG, JPEG, GIF, WebP, ICO, AVIF), `null` for anything else, SVG included. |
|
||||
| `resolveSignInLook(whiteLabel)` | `@intecion/ipal-kit` | `whiteLabel` option → `null` (white-label or `signIn` off) or `{ allScreens, props }` (`ResolvedSignInLook`; `props` = `SignInLookProps`, the plain values the components get: `accent`, `checkLogo`, `imageField`, `inlineImages`, `languages`, `logoPlate`, `nameField`, `settingsSlug`, `svgLogo`). Option type: `SignInLookOptions`. |
|
||||
| `loadSignInBrand({ payload, look, locale?, user? })`, `signInName(value, locale?)`, `signInLogo(media, { svgLogo? })`, `checkLogoFile(url, base, allowSvg?)`, `fitLogo(width, height, box?)`, `isSvgUpload(media)`, `SIGN_IN_LOGO_TYPES` | `@intecion/ipal-kit` | What the sign-in panel shows: `{ name, logo }` (`SignInBrand`, `SignInLogo = { src, width?, height? }`) read from Site settings, never throwing; the name as one line of plain text (control characters out, cut at `SIGN_IN_NAME_MAX` = 80); the logo of an upload document — only JPEG / PNG / WebP / AVIF / GIF (`SIGN_IN_LOGO_TYPES`; SVG with `svgLogo: true`), only an `http(s)` or site-relative address, fitted into `SIGN_IN_LOGO_BOX` (240 × 72) without enlarging, served from the smallest generated size ≥ 2× the shown width with the same proportions; the look at the file itself (`LogoCheck`: `{ bytes, type }`, `'bad'` = the server answered and it is no such picture or over 512 KB, `'unknown'` = nothing answered). A session that owes its 2FA code gets the checked picture inlined or no logo. |
|
||||
| `loadSignInBrand({ payload, look, locale?, user? })`, `signInName(value, locale?)`, `signInLogo(media, { svgLogo? })`, `checkLogoFile(url, base, allowSvg?)`, `fitLogo(width, height, box?)`, `isSvgUpload(media)` | `@intecion/ipal-kit` | What the sign-in panel shows: `{ name, logo }` (`SignInBrand`, `SignInLogo = { src, width?, height? }`) read from Site settings, never throwing; the name as one line of plain text (control characters out, cut at `SIGN_IN_NAME_MAX` = 80); the logo of an upload document — any picture (an SVG too unless `svgLogo: false`; `null` only for an upload whose type says it is no picture, or an address that is not `http(s)` or site-relative), fitted into `SIGN_IN_LOGO_BOX` (240 × 72) without enlarging, served from the smallest generated size ≥ 2× the shown width with the same proportions; the look at the file itself (`LogoCheck`: `{ bytes, type }`; `'bad'` = certainly no picture there: 404 / 410, a 2xx answer of another type, an SVG while refused; `'unknown'` = nothing answered, a redirect (never followed), another status, no type, over 512 KB — the upload is believed). A session that owes its 2FA code gets the checked picture inlined or no logo. |
|
||||
| `signInCss({ accent? })`, `isHexColour(value)`, `SIGN_IN_STYLE_ID` | `@intecion/ipal-kit` | The stylesheet of the sign-in look as a string (no `url()`, no font, no other host; every rule needs `.iapl-signin` on the page), the hex check `accent` must pass, and the `href` of its `<style>` (`'iapl-sign-in'`). |
|
||||
| `languageLinks(config, current)`, `LANGUAGE_NAMES`, `buildAdminLanguageEndpoint()`, `adminPathFromReferer(referer, adminRoute)`, `ADMIN_LANGUAGE_PATH` | `@intecion/ipal-kit` | The panel's languages as links (`LanguageLink[]`: `{ code, name, current, href }`; empty with one language; names in their own language, else the code); the public endpoint `GET /api/ipal/admin-language?lng=` (`'/ipal/admin-language'`) that writes `<cookiePrefix>-lng` for a supported language (else 400) and answers 303 to a path inside the admin route taken from the `Referer` (anything else → the admin root, never another host). |
|
||||
| `signInProviderActive(payload)`, `SIGN_IN_LOOK` | `@intecion/ipal-kit` | Whether the provider `'@intecion/ipal-kit/admin#SignInLook'` is in the config AND in the running import map — `AdminLogo` and `SafeTotpView` print the panel themselves only when it is not. |
|
||||
|
||||
@@ -299,8 +299,8 @@ the panel shows Site settings, Site integrations, Cookies, Form messages, the Fo
|
||||
- Sign-in screens (`whiteLabel.signIn`, on): a dark panel with the client's logo or the site's name beside the
|
||||
form; the logo and name are Site settings fields (no env var, no migration). `allScreens: true` (in the config
|
||||
above) adds the provider `SignInLook` to the import map and covers forgot / reset password, first user and
|
||||
logout. The logo: JPEG / PNG / WebP / AVIF / GIF (an SVG logo shows the name: `svgLogo: true` or upload a
|
||||
bitmap), drawn for a DARK ground (no plate; `logoPlate: true` for a logo with dark letters). `accent: '#hex'`,
|
||||
logout. The logo: any picture Site settings holds, an SVG too (`svgLogo: false` refuses SVG), drawn for a
|
||||
DARK ground (no plate; `logoPlate: true` for a logo with dark letters). `accent: '#hex'`,
|
||||
`languages: false`, `checkLogo: false`; `signIn: false` = Payload's screens. Name, logo and icon in Site
|
||||
settings are admin-only with the look (`brandAccess: 'editor'` gives them back to editors).
|
||||
Check: `/admin/login` and `/admin/forgot` show the panel, also at a phone width; do not write login CSS by hand.
|
||||
|
||||
@@ -679,8 +679,8 @@ PROGRAMISTA §6, items 73–75; email.md; AGENT.md §7.2) — nothing to run; re
|
||||
import map already has. **Check:** open `/admin/login` on a desktop and at a phone width, in both themes; sign
|
||||
in through 2FA.
|
||||
**Look at the logo:** it stands straight on a dark panel. A logo with dark letters: `signIn: { logoPlate: true }`
|
||||
(a white plate) or ask the client for a logo for dark grounds. An **SVG** logo is not shown there (the site's
|
||||
name is): upload a PNG / WebP logo, or `signIn: { svgLogo: true }`.
|
||||
(a white plate) or ask the client for a logo for dark grounds. Every logo that showed on the login screen
|
||||
before shows now (an SVG too); only a logo whose file is gone shows the site's name instead of a broken picture.
|
||||
**Editors lose three fields:** the name, logo and icon of Site settings are admin-only now (they are what the
|
||||
public sign-in page shows). A site whose editors must change them: `whiteLabel: { brandAccess: 'editor' }`.
|
||||
2. **Tell the owner the sign-in page looks different** and ask whether to keep it. No: `whiteLabel: { signIn: false }`
|
||||
|
||||
@@ -108,7 +108,7 @@ if (logoMode !== 'keep') {
|
||||
if (logoMode !== 'none') {
|
||||
const file = path.resolve(logoMode)
|
||||
const res = await api.post('/api/media', {
|
||||
multipart: { _payload: JSON.stringify({ alt: 'Placeholder logo' }), file: { buffer: readFileSync(file), mimeType: 'image/png', name: path.basename(file) } },
|
||||
multipart: { _payload: JSON.stringify({ alt: 'Placeholder logo' }), file: { buffer: readFileSync(file), mimeType: file.endsWith('.svg') ? 'image/svg+xml' : 'image/png', name: path.basename(file) } },
|
||||
})
|
||||
uploaded = (await res.json())?.doc?.id
|
||||
if (!uploaded) {throw new Error(`the logo was not uploaded (${res.status()})`)}
|
||||
|
||||
@@ -83,7 +83,6 @@ export {
|
||||
languageLinks,
|
||||
loadSignInBrand,
|
||||
SIGN_IN_LOGO_BOX,
|
||||
SIGN_IN_LOGO_TYPES,
|
||||
SIGN_IN_LOOK,
|
||||
SIGN_IN_NAME_MAX,
|
||||
SIGN_IN_STYLE_ID,
|
||||
|
||||
@@ -12,9 +12,10 @@ import { PUBLIC_IMAGE_MAX_BYTES, rasterImageType, siteOrigin } from '../publicIm
|
||||
* What may reach a page that anyone can open, before signing in:
|
||||
* - the name as plain text (React escapes it), one line of at most `SIGN_IN_NAME_MAX` characters: no markup,
|
||||
* no link, nothing an address inside it could turn into;
|
||||
* - the logo as an `<img>`, and only a bitmap: JPEG, PNG, WebP, AVIF or GIF, as the upload says AND as the
|
||||
* file's first bytes say (the file is looked at before it is printed; a deleted, broken or renamed file
|
||||
* gives the name, never a broken picture). No SVG unless the project asks (`svgLogo: true`);
|
||||
* - the logo as an `<img>` — every picture type a site's login screen showed before the sign-in look (1.17.0:
|
||||
* whatever Site settings → Logo held, an SVG included; in `<img>` no picture runs script). The file is
|
||||
* looked at before it is printed, only to avoid a broken picture: a deleted file or one that is no picture
|
||||
* gives the name. `svgLogo: false` refuses SVG for a project that wants bitmaps only;
|
||||
* - no account, no e-mail address, no hint whether an account exists: the forms are Payload's own.
|
||||
*/
|
||||
|
||||
@@ -45,8 +46,8 @@ export type SignInLookProps = {
|
||||
nameField?: string
|
||||
/** Slug of the settings global. Default `'site-settings'`. */
|
||||
settingsSlug?: string
|
||||
/** `true`: an SVG logo is shown too (as a picture). Default: bitmaps only, an SVG logo gives the name. */
|
||||
svgLogo?: true
|
||||
/** `false`: an SVG logo is not shown on the sign-in screens (the name is). Default: shown, as a picture. */
|
||||
svgLogo?: false
|
||||
}
|
||||
|
||||
export type SignInLogo = { height?: number; src: string; width?: number }
|
||||
@@ -54,9 +55,6 @@ export type SignInBrand = { logo: null | SignInLogo; name: string }
|
||||
|
||||
type MediaLike = { filename?: unknown; height?: unknown; mimeType?: unknown; sizes?: unknown; url?: unknown; width?: unknown }
|
||||
|
||||
/** The picture types a logo may have on the sign-in screens: the bitmaps a browser shows. */
|
||||
export const SIGN_IN_LOGO_TYPES = ['image/jpeg', 'image/png', 'image/webp', 'image/avif', 'image/gif'] as const
|
||||
|
||||
const usableAddress = (url: unknown): url is string => typeof url === 'string' && /^(?:https?:\/\/|\/(?!\/))/i.test(url.trim())
|
||||
|
||||
/** A localized text field may arrive as a string or a { locale: value } map. */
|
||||
@@ -103,7 +101,8 @@ function servedAddress(m: MediaLike, shownWidth: number): string {
|
||||
if (!size || typeof size.width !== 'number' || typeof size.height !== 'number' || !usableAddress(size.url)) {continue}
|
||||
if (size.width < 2 * shownWidth || size.width >= m.width || size.height < 1) {continue}
|
||||
if (Math.abs(size.width / size.height - m.width / m.height) > 0.02) {continue}
|
||||
if (typeof size.mimeType === 'string' && !(SIGN_IN_LOGO_TYPES as readonly string[]).includes(size.mimeType.toLowerCase())) {continue}
|
||||
// a generated size is a bitmap; anything else under `sizes` is not what the logo's own file is
|
||||
if (typeof size.mimeType === 'string' && (!size.mimeType.toLowerCase().startsWith('image/') || size.mimeType.toLowerCase().includes('svg'))) {continue}
|
||||
if (!best || size.width < best.width) {best = { url: size.url.trim(), width: size.width }}
|
||||
}
|
||||
return best?.url ?? full
|
||||
@@ -111,14 +110,15 @@ function servedAddress(m: MediaLike, shownWidth: number): string {
|
||||
|
||||
/**
|
||||
* The logo of an upload document, or null when there is nothing to show: no address, an address that is not
|
||||
* http(s) or site-relative, or a type that is not one of `SIGN_IN_LOGO_TYPES` (SVG only with `svgLogo: true`).
|
||||
* http(s) or site-relative, an upload whose type says it is no picture (a PDF), or an SVG with `svgLogo: false`.
|
||||
* An upload without a stated type is taken as 1.17.0 took it: its address is used.
|
||||
*/
|
||||
export function signInLogo(media: unknown, look: Pick<SignInLookProps, 'svgLogo'> = {}): null | SignInLogo {
|
||||
if (!media || typeof media !== 'object') {return null}
|
||||
const m = media as MediaLike
|
||||
if (!usableAddress(m.url)) {return null}
|
||||
if (isSvgUpload(m)) {return look.svgLogo === true ? { src: m.url.trim(), ...(fitLogo(m.width, m.height) ?? {}) } : null}
|
||||
if (typeof m.mimeType !== 'string' || !(SIGN_IN_LOGO_TYPES as readonly string[]).includes(m.mimeType.toLowerCase())) {return null}
|
||||
if (isSvgUpload(m)) {return look.svgLogo === false ? null : { src: m.url.trim(), ...(fitLogo(m.width, m.height) ?? {}) }}
|
||||
if (typeof m.mimeType === 'string' && m.mimeType && !m.mimeType.toLowerCase().startsWith('image/')) {return null}
|
||||
const fit = fitLogo(m.width, m.height)
|
||||
return { src: fit ? servedAddress(m, fit.width) : m.url.trim(), ...(fit ?? {}) }
|
||||
}
|
||||
@@ -126,17 +126,19 @@ export function signInLogo(media: unknown, look: Pick<SignInLookProps, 'svgLogo'
|
||||
export type LogoCheck = 'bad' | 'unknown' | { bytes: Buffer; type: string }
|
||||
|
||||
/**
|
||||
* Looks at the logo's file the way an anonymous visitor gets it (no cookies, at most 512 KB):
|
||||
* - the picture itself when it answers and its first bytes are one of the allowed bitmaps (an SVG, allowed
|
||||
* by `svgLogo: true`, is taken by its `image/svg+xml` type);
|
||||
* - `'bad'` when the server ANSWERS and it is no such picture: 404, another type, too large, broken bytes;
|
||||
* - `'unknown'` when nothing answers (the site cannot reach its own address from inside its container, a
|
||||
* timeout): the upload document is then believed, so a network quirk never takes the logo away.
|
||||
* Looks at the logo's file the way an anonymous visitor gets it (no cookies, at most 512 KB read). It exists to
|
||||
* avoid a broken picture, never to narrow what a site may show: a logo a browser shows is not taken away.
|
||||
* - the picture itself when the server answers 2xx with an `image/*` type and at most 512 KB;
|
||||
* - `'bad'` only when the file is certainly not a picture a browser would show at that address: it is gone
|
||||
* (404, 410), or the answer is 2xx with another type (an HTML page, a PDF), or it is an SVG and the project
|
||||
* refuses SVG (`svgLogo: false`);
|
||||
* - `'unknown'` for everything else — nothing answers (the site cannot reach its own address from inside its
|
||||
* container), a timeout, a redirect, any other status (a firewall that refuses the server but not
|
||||
* browsers), no type, more than 512 KB: the upload document is then believed and the browser decides.
|
||||
* A redirect is NEVER followed: the server asks only the address the upload itself has, so a logo address
|
||||
* that answers "go to http://169.254.169.254/…" (or any internal host) makes the server fetch nothing there.
|
||||
* Such a logo counts as `'unknown'`: the browser may follow it, the server does not.
|
||||
*/
|
||||
export async function checkLogoFile(url: string, base: null | string | undefined, allowSvg = false): Promise<LogoCheck> {
|
||||
export async function checkLogoFile(url: string, base: null | string | undefined, allowSvg = true): Promise<LogoCheck> {
|
||||
let target: URL
|
||||
try {
|
||||
target = new URL(url, base || undefined)
|
||||
@@ -151,16 +153,31 @@ export async function checkLogoFile(url: string, base: null | string | undefined
|
||||
return 'unknown'
|
||||
}
|
||||
try {
|
||||
if ((res.status >= 300 && res.status < 400) || res.type === 'opaqueredirect') {return 'unknown'}
|
||||
if (!res.ok) {return res.status >= 500 ? 'unknown' : 'bad'}
|
||||
if (res.status === 404 || res.status === 410) {return 'bad'}
|
||||
if (!res.ok || res.type === 'opaqueredirect') {return 'unknown'}
|
||||
const type = (res.headers.get('content-type') ?? '').split(';')[0].trim().toLowerCase()
|
||||
if (!type) {return 'unknown'}
|
||||
if (!type.startsWith('image/')) {return 'bad'}
|
||||
if (!allowSvg && type.includes('svg')) {return 'bad'}
|
||||
const declared = Number(res.headers.get('content-length'))
|
||||
if (Number.isFinite(declared) && declared > PUBLIC_IMAGE_MAX_BYTES) {return 'bad'}
|
||||
const bytes = Buffer.from(await res.arrayBuffer())
|
||||
if (!bytes.length || bytes.length > PUBLIC_IMAGE_MAX_BYTES) {return 'bad'}
|
||||
const declaredType = (res.headers.get('content-type') ?? '').split(';')[0].trim().toLowerCase()
|
||||
if (allowSvg && declaredType === 'image/svg+xml') {return { type: declaredType, bytes }}
|
||||
const type = rasterImageType(bytes)
|
||||
return type && (SIGN_IN_LOGO_TYPES as readonly string[]).includes(type) ? { type, bytes } : 'bad'
|
||||
if (Number.isFinite(declared) && declared > PUBLIC_IMAGE_MAX_BYTES) {return 'unknown'}
|
||||
// read chunk by chunk: a body without a stated length stops at the limit
|
||||
const reader = res.body?.getReader()
|
||||
if (!reader) {return 'unknown'}
|
||||
const chunks: Uint8Array[] = []
|
||||
let size = 0
|
||||
for (;;) {
|
||||
const { done, value } = await reader.read()
|
||||
if (done) {break}
|
||||
size += value.byteLength
|
||||
if (size > PUBLIC_IMAGE_MAX_BYTES) {return 'unknown'}
|
||||
chunks.push(value)
|
||||
}
|
||||
if (!size) {return 'bad'}
|
||||
const bytes = Buffer.concat(chunks)
|
||||
// an SVG served under another image type is still refused when the project refuses SVG
|
||||
if (!allowSvg && !rasterImageType(bytes) && /<svg[\s>]/i.test(bytes.subarray(0, 2048).toString('utf8'))) {return 'bad'}
|
||||
return { type, bytes }
|
||||
} catch {
|
||||
return 'unknown'
|
||||
} finally {
|
||||
@@ -220,7 +237,7 @@ export async function loadSignInBrand({ locale, look, payload, user }: LoadArgs)
|
||||
// collection: it gets the picture itself (the one just looked at), or the name.
|
||||
const pending = Boolean(user && !secondFactorPassed({ payload, user }))
|
||||
if (logo && (look.checkLogo !== false || pending) && !(pending && look.inlineImages === false)) {
|
||||
const checked = await checkedLogo(logo.src, origin, look.svgLogo === true)
|
||||
const checked = await checkedLogo(logo.src, origin, look.svgLogo !== false)
|
||||
if (checked === 'bad') {
|
||||
logo = null
|
||||
} else if (pending) {
|
||||
|
||||
@@ -7,7 +7,6 @@ export {
|
||||
languageLinks,
|
||||
loadSignInBrand,
|
||||
SIGN_IN_LOGO_BOX,
|
||||
SIGN_IN_LOGO_TYPES,
|
||||
SIGN_IN_LOOK,
|
||||
SIGN_IN_NAME_MAX,
|
||||
signInLogo,
|
||||
|
||||
@@ -17,8 +17,8 @@ export type SignInLookOptions = {
|
||||
*/
|
||||
allScreens?: boolean
|
||||
/**
|
||||
* `false`: the logo's file is not fetched and looked at before it is printed (its type by its first bytes,
|
||||
* at most 512 KB; a deleted or broken file gives the site's name). Default: checked, remembered ten minutes.
|
||||
* `false`: the logo's file is not fetched and looked at before it is printed (a deleted file, or one that is
|
||||
* no picture, gives the site's name instead of a broken picture). Default: checked, remembered ten minutes.
|
||||
*/
|
||||
checkLogo?: false
|
||||
/** `false`: no language links on the panel. Default: shown when the panel has more than one language. */
|
||||
@@ -29,8 +29,8 @@ export type SignInLookOptions = {
|
||||
*/
|
||||
logoPlate?: boolean
|
||||
/**
|
||||
* `true`: an SVG logo is shown too (as a picture, where it cannot run script). Default: only JPEG, PNG,
|
||||
* WebP, AVIF and GIF are shown; with an SVG logo the sign-in screens show the site's name.
|
||||
* `false`: an SVG logo is not shown on the sign-in screens; the site's name is. Default: shown, as it was on
|
||||
* the login screen before (as a picture, where it cannot run script).
|
||||
*/
|
||||
svgLogo?: boolean
|
||||
}
|
||||
@@ -57,7 +57,7 @@ export function resolveSignInLook(whiteLabel: boolean | undefined | WhiteLabelFi
|
||||
...(signIn.logoPlate === true ? { logoPlate: true as const } : {}),
|
||||
...(wl.nameField ? { nameField: wl.nameField } : {}),
|
||||
...(wl.settingsSlug ? { settingsSlug: wl.settingsSlug } : {}),
|
||||
...(signIn.svgLogo === true ? { svgLogo: true as const } : {}),
|
||||
...(signIn.svgLogo === false ? { svgLogo: false as const } : {}),
|
||||
}
|
||||
return { allScreens: signIn.allScreens === true, props }
|
||||
}
|
||||
|
||||
@@ -68,11 +68,11 @@ describe('whiteLabel.signIn: the option', () => {
|
||||
logoField: 'brandLogo',
|
||||
nameField: 'brandName',
|
||||
settingsSlug: 'settings',
|
||||
signIn: { accent: '#0B6E4F', allScreens: true, checkLogo: false, languages: false, logoPlate: true, svgLogo: true },
|
||||
signIn: { accent: '#0B6E4F', allScreens: true, checkLogo: false, languages: false, logoPlate: true, svgLogo: false },
|
||||
}),
|
||||
).toEqual({
|
||||
allScreens: true,
|
||||
props: { accent: '#0B6E4F', checkLogo: false, imageField: 'brandLogo', inlineImages: false, languages: false, logoPlate: true, nameField: 'brandName', settingsSlug: 'settings', svgLogo: true },
|
||||
props: { accent: '#0B6E4F', checkLogo: false, imageField: 'brandLogo', inlineImages: false, languages: false, logoPlate: true, nameField: 'brandName', settingsSlug: 'settings', svgLogo: false },
|
||||
})
|
||||
})
|
||||
|
||||
@@ -174,22 +174,25 @@ describe('what the public sign-in page may show', () => {
|
||||
expect(long.endsWith('…')).toBe(true)
|
||||
})
|
||||
|
||||
test('the logo: a bitmap by its type, an http(s) or site-relative address, never enlarged; SVG only when asked', () => {
|
||||
test('the logo: any picture the upload holds, at an http(s) or site-relative address, never enlarged; SVG out only when asked', () => {
|
||||
const png = (extra: Record<string, unknown>) => ({ mimeType: 'image/png', ...extra })
|
||||
expect(signInLogo(png({ height: 100, url: '/api/media/file/logo.png', width: 400 }))).toEqual({ height: 60, src: '/api/media/file/logo.png', width: 240 })
|
||||
expect(signInLogo({ height: 20, mimeType: 'image/webp', url: 'https://cdn.test/logo.webp', width: 60 })).toEqual({ height: 20, src: 'https://cdn.test/logo.webp', width: 60 })
|
||||
expect(signInLogo(png({ url: '/logo.png' }))).toEqual({ src: '/logo.png' })
|
||||
for (const mimeType of ['image/jpeg', 'image/png', 'image/webp', 'image/avif', 'image/gif', 'IMAGE/PNG']) {expect(signInLogo({ mimeType, url: '/l' })).toEqual({ src: '/l' })}
|
||||
for (const mimeType of ['application/pdf', 'text/html', 'image/x-icon', 'image/tiff', 'video/mp4', undefined, 7]) {expect(signInLogo({ mimeType, url: '/l' })).toBeNull()}
|
||||
// no list of types: what a browser shows as a picture is the browser's business; no stated type counts as before
|
||||
for (const mimeType of ['image/jpeg', 'image/png', 'image/webp', 'image/avif', 'image/gif', 'IMAGE/PNG', 'image/x-icon', 'image/bmp', 'image/tiff', undefined, null, '']) {
|
||||
expect(signInLogo({ mimeType, url: '/l' }), String(mimeType)).toEqual({ src: '/l' })
|
||||
}
|
||||
for (const mimeType of ['application/pdf', 'text/html', 'video/mp4']) {expect(signInLogo({ mimeType, url: '/l' })).toBeNull()}
|
||||
for (const url of ['javascript:alert(1)', 'data:text/html,<script>1</script>', '//evil.test/x.png', 'file:///etc/passwd', '', ' ']) {
|
||||
expect(signInLogo(png({ url }))).toBeNull()
|
||||
}
|
||||
expect(signInLogo('64f0…id-only')).toBeNull()
|
||||
expect(signInLogo(null)).toBeNull()
|
||||
const svg = { mimeType: 'image/svg+xml', url: '/api/media/file/logo.svg' }
|
||||
expect(signInLogo(svg)).toBeNull()
|
||||
expect(signInLogo(svg, { svgLogo: true })).toEqual({ src: svg.url })
|
||||
expect(signInLogo(png({ url: '/api/media/file/renamed.SVG?v=2' }))).toBeNull()
|
||||
expect(signInLogo(svg)).toEqual({ src: svg.url })
|
||||
expect(signInLogo(svg, { svgLogo: false })).toBeNull()
|
||||
expect(signInLogo(png({ url: '/api/media/file/renamed.SVG?v=2' }), { svgLogo: false })).toBeNull()
|
||||
expect(fitLogo(1000, 100)).toEqual({ height: 24, width: 240 })
|
||||
expect(fitLogo(0, 10)).toBeNull()
|
||||
})
|
||||
@@ -204,53 +207,90 @@ describe('what the public sign-in page may show', () => {
|
||||
expect(signInLogo(logoDoc({}))).toEqual({ height: 60, src: '/full.png', width: 240 })
|
||||
})
|
||||
|
||||
test('the file is looked at before it is printed: a deleted, broken, foreign or too large file gives the name', async () => {
|
||||
test('the file is looked at before it is printed: a deleted file, or one that is no picture, gives the name', async () => {
|
||||
const settings = { logo: { height: 160, mimeType: 'image/png', url: '/api/media/file/logo.png', width: 560 }, siteName: 'Acme' }
|
||||
const brand = () => {
|
||||
const brand = (look: Record<string, unknown> = {}) => {
|
||||
forgetCheckedLogos()
|
||||
return loadSignInBrand({ look: {}, payload: fakePayload(settings) })
|
||||
return loadSignInBrand({ look, payload: fakePayload(settings) })
|
||||
}
|
||||
serve(PNG)
|
||||
expect((await brand()).logo?.src).toBe(settings.logo.url)
|
||||
vi.restoreAllMocks()
|
||||
serve(null, { status: 404 })
|
||||
expect(await brand()).toEqual({ name: 'Acme', logo: null })
|
||||
vi.restoreAllMocks()
|
||||
serve(new TextEncoder().encode('<svg xmlns="http://www.w3.org/2000/svg"><script>alert(1)</script></svg>')) // says image/png, is not
|
||||
expect((await brand()).logo).toBeNull()
|
||||
vi.restoreAllMocks()
|
||||
serve(new TextEncoder().encode('<html>'), { headers: { 'content-type': 'text/html' } })
|
||||
expect((await brand()).logo).toBeNull()
|
||||
vi.restoreAllMocks()
|
||||
serve(PNG, { headers: { 'content-length': String(600 * 1024), 'content-type': 'image/png' } })
|
||||
expect((await brand()).logo).toBeNull()
|
||||
vi.restoreAllMocks()
|
||||
const answer = async (body: null | Uint8Array, init: ResponseInit, look?: Record<string, unknown>) => {
|
||||
vi.restoreAllMocks()
|
||||
serve(body, init)
|
||||
return (await brand(look)).logo
|
||||
}
|
||||
const html = new TextEncoder().encode('<html>')
|
||||
const svg = new TextEncoder().encode('<svg xmlns="http://www.w3.org/2000/svg"><script>alert(1)</script></svg>')
|
||||
expect((await answer(PNG, {}))?.src).toBe(settings.logo.url)
|
||||
// certainly not a picture at that address: the name
|
||||
expect(await answer(null, { status: 404 })).toBeNull()
|
||||
expect(await answer(null, { status: 410 })).toBeNull()
|
||||
expect(await answer(html, { headers: { 'content-type': 'text/html' } })).toBeNull()
|
||||
expect(await answer(new Uint8Array(0), {})).toBeNull()
|
||||
// an SVG, also one the server calls a PNG: a picture in <img> (it cannot run script there) — unless refused
|
||||
expect((await answer(svg, { headers: { 'content-type': 'image/svg+xml' } }))?.src).toBe(settings.logo.url)
|
||||
expect((await answer(svg, {}))?.src).toBe(settings.logo.url)
|
||||
expect(await answer(svg, { headers: { 'content-type': 'image/svg+xml' } }, { svgLogo: false })).toBeNull()
|
||||
expect(await answer(svg, {}, { svgLogo: false })).toBeNull()
|
||||
|
||||
// a redirect is never followed by the server (it could point at an internal address): one request, to the
|
||||
// logo's own address, asked not to follow; the upload document is believed and nothing is inlined from it
|
||||
vi.restoreAllMocks()
|
||||
const redirected = serve(null, { headers: { location: 'http://169.254.169.254/latest/meta-data/' }, status: 302 })
|
||||
expect((await brand()).logo?.src).toBe(settings.logo.url)
|
||||
expect(redirected).toHaveBeenCalledTimes(1)
|
||||
expect(String(redirected.mock.calls[0][0])).toBe('https://site.test/api/media/file/logo.png')
|
||||
expect((redirected.mock.calls[0][0] as URL).href).toBe('https://site.test/api/media/file/logo.png')
|
||||
expect((redirected.mock.calls[0][1] as RequestInit).redirect).toBe('manual')
|
||||
expect(await checkLogoFile('https://site.test/l.png', null)).toBe('unknown')
|
||||
vi.restoreAllMocks()
|
||||
// nothing answers (the site cannot reach its own address): the upload document is believed
|
||||
vi.spyOn(globalThis, 'fetch').mockRejectedValue(new Error('ECONNREFUSED'))
|
||||
expect((await brand()).logo?.src).toBe(settings.logo.url)
|
||||
vi.restoreAllMocks()
|
||||
// one look per address in ten minutes, and none with checkLogo: false
|
||||
vi.restoreAllMocks()
|
||||
const fetched = serve(PNG)
|
||||
forgetCheckedLogos()
|
||||
await loadSignInBrand({ look: {}, payload: fakePayload(settings) })
|
||||
await loadSignInBrand({ look: {}, payload: fakePayload(settings) })
|
||||
expect(fetched).toHaveBeenCalledTimes(1)
|
||||
forgetCheckedLogos()
|
||||
await loadSignInBrand({ look: { checkLogo: false }, payload: fakePayload(settings) })
|
||||
await brand({ checkLogo: false })
|
||||
expect(fetched).toHaveBeenCalledTimes(1)
|
||||
expect(await checkLogoFile('ftp://site.test/logo.png', null)).toBe('bad')
|
||||
expect(await checkLogoFile('/relative.png', null)).toBe('unknown')
|
||||
})
|
||||
|
||||
// The owner's rule (2026-11-26): the logo is handled as IAPL's white label handled it on the login screen in
|
||||
// 1.17.0 — `AdminLogo` printed `<img>` for whatever Site settings → Logo held. Nothing that showed there may
|
||||
// be missing on the new screens.
|
||||
test('a logo visible on the 1.17.0 login screen is visible after the upgrade', async () => {
|
||||
const big = new Uint8Array(700 * 1024).fill(1)
|
||||
big.set(PNG)
|
||||
const svgBody = new TextEncoder().encode('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><rect width="10" height="10"/></svg>')
|
||||
const ok = (body: Uint8Array, type: string) => () => Promise.resolve(new Response(body as never, { headers: { 'content-type': type } }))
|
||||
const cases: [string, Record<string, unknown>, () => Promise<Response>][] = [
|
||||
['an SVG logo', { mimeType: 'image/svg+xml', url: '/api/media/file/logo.svg' }, ok(svgBody, 'image/svg+xml')],
|
||||
['a PNG logo', { height: 80, mimeType: 'image/png', url: '/api/media/file/logo.png', width: 300 }, ok(PNG, 'image/png')],
|
||||
['a WebP logo on a CDN', { mimeType: 'image/webp', url: 'https://cdn.site.test/logo.webp' }, ok(new TextEncoder().encode('RIFF....WEBPVP8 '), 'image/webp')],
|
||||
['an ICO or BMP logo', { mimeType: 'image/bmp', url: '/api/media/file/logo.bmp' }, ok(new TextEncoder().encode('BM......'), 'image/bmp')],
|
||||
['an upload document without a type', { url: '/api/media/file/logo.png' }, ok(PNG, 'image/png')],
|
||||
['a logo larger than 512 KB', { mimeType: 'image/png', url: '/api/media/file/big.png' }, ok(big, 'image/png')],
|
||||
['a logo larger than 512 KB, length stated', { mimeType: 'image/png', url: '/api/media/file/big.png' }, () => Promise.resolve(new Response(PNG as never, { headers: { 'content-length': String(700 * 1024), 'content-type': 'image/png' } }))],
|
||||
['a logo whose address redirects (a CDN)', { mimeType: 'image/png', url: '/api/media/file/logo.png' }, () => Promise.resolve(new Response(null, { headers: { location: 'https://cdn.site.test/logo.png' }, status: 302 }))],
|
||||
['a site that cannot reach its own address', { mimeType: 'image/png', url: '/api/media/file/logo.png' }, () => Promise.reject(new Error('ECONNREFUSED'))],
|
||||
['a firewall that refuses the server, not browsers', { mimeType: 'image/png', url: '/api/media/file/logo.png' }, () => Promise.resolve(new Response('denied', { status: 403 }))],
|
||||
['a media server answering 500 to the server', { mimeType: 'image/png', url: '/api/media/file/logo.png' }, () => Promise.resolve(new Response('', { status: 503 }))],
|
||||
['a media server that states no type', { mimeType: 'image/png', url: '/api/media/file/logo.png' }, () => Promise.resolve(new Response(PNG as never))],
|
||||
]
|
||||
for (const [name, logo, respond] of cases) {
|
||||
vi.restoreAllMocks()
|
||||
forgetCheckedLogos()
|
||||
vi.spyOn(globalThis, 'fetch').mockImplementation(respond)
|
||||
const payload = fakePayload({ logo, siteName: 'Acme' })
|
||||
// 1.17.0: the plain logo component (no `signIn`) — unchanged code path
|
||||
const before = (await AdminLogo({ payload })) as { props: { src?: string }; type: unknown }
|
||||
expect(before.type, name).toBe('img')
|
||||
expect(before.props.src, name).toBe(logo.url)
|
||||
// after: the same address, in an <img> on the panel
|
||||
expect((await loadSignInBrand({ look: {}, payload })).logo?.src, name).toBe(logo.url)
|
||||
expect(await panel({ look: {}, payload }), name).toContain(`src="${String(logo.url)}"`)
|
||||
}
|
||||
})
|
||||
|
||||
test('markup in the name is text; the only links are the site, and the language endpoint', async () => {
|
||||
const payload = fakePayload({ siteName: '<script>alert(1)</script> <a href="https://evil.test">reset</a> https://evil.test' })
|
||||
const html = await panel({ i18n: { language: 'en', t: t as never }, look: {}, payload })
|
||||
|
||||