IAPL rename, scripted: preferred names in src, bin, scripts, services, tests; bin files and skill folders moved

Replaced by an explicit list of forms only (ten exported names, runtime env names, project file
names and marks, commands, skill names, the log prefix, the brand in prose). Package name, import
paths, routes, CSS tokens, data attributes, custom keys, context flags, the cookie and kv keys are
not touched. package.json keeps the five old bin names beside the five new ones.
The old names stop working in this commit and come back as aliases in the next; docs follow.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-11-25 17:24:21 +01:00
co-authored by Claude Fable 5.2
parent 414a4702df
commit 0a4f001797
262 changed files with 955 additions and 950 deletions
+1 -1
View File
@@ -124,7 +124,7 @@ export function buildSecurityHeaders(args: BuildSecurityHeadersArgs = {}): Secur
headers.push({ key: 'Cross-Origin-Opener-Policy', value: coop })
}
// Staging / preview (IPAL_NOINDEX=1): keep every response out of search engines.
// Staging / preview (IAPL_NOINDEX=1): keep every response out of search engines.
if (isSiteNoindex()) {
headers.push({ key: 'X-Robots-Tag', value: 'noindex, nofollow' })
}
+2 -2
View File
@@ -37,7 +37,7 @@ const CLIENT_PROPS = ['browseByFolderSlugs', 'clientConfig', 'collectionSlug', '
* the wrapped factory) gets only what can cross to the browser — Payload's client props, its own
* `clientProps`, `searchParams` and `back`, both checked.
*
* ipalKit registers it (twoFactor.safeBack, on by default). A project that registers 2FA views
* iapl registers it (twoFactor.safeBack, on by default). A project that registers 2FA views
* itself can use it too: `wrapTotpViews`, or give it `ipalTotpView` and list that path in
* `admin.dependencies`.
*/
@@ -53,7 +53,7 @@ export function SafeTotpView(props: SafeTotpViewProps): React.ReactNode {
if (!getFromImportMap({ importMap: props.importMap, PayloadComponent: ipalTotpView, schemaPath: '', silent: true })) {
throw new Error(
`[ipal] The admin import map has no "${totpViewImportKey(ipalTotpView)}" (the 2FA screen ipal-kit puts its back-link check in front of). ` +
`[iapl] The admin import map has no "${totpViewImportKey(ipalTotpView)}" (the 2FA screen IAPL puts its back-link check in front of). ` +
'Run `pnpm payload generate:importmap` and commit the result.',
)
}
@@ -8,7 +8,7 @@ import { useEffect } from 'react'
import type { TotpUser } from './totpRedirect.js'
import { formatDateTime, ipalT } from '../../admin-i18n/t.js'
import { formatDateTime, iaplT } from '../../admin-i18n/t.js'
import { totpAdminPath, totpRedirectTarget } from './totpRedirect.js'
export type TotpRedirectProviderProps = {
@@ -94,10 +94,10 @@ export function TotpRedirectProvider({ children, forceSetup = true, requireSetup
const deadline = setupWindowHours > 0 && Number.isFinite(start) ? start + setupWindowHours * 3_600_000 : null
const closed = deadline !== null && deadline < Date.now()
const notice = closed
? ipalT(t as never, 'twoFactorSetupClosed')
? iaplT(t as never, 'twoFactorSetupClosed')
: deadline !== null
? ipalT(t as never, 'twoFactorSetupDeadline', { date: formatDateTime(new Date(deadline).toISOString(), i18n.language) })
: ipalT(t as never, 'twoFactorSetupRequired')
? iaplT(t as never, 'twoFactorSetupDeadline', { date: formatDateTime(new Date(deadline).toISOString(), i18n.language) })
: iaplT(t as never, 'twoFactorSetupRequired')
setup = (
<div
id="ipal-two-factor-notice"
@@ -3,7 +3,7 @@
import { toast, useConfig, useTranslation } from '@payloadcms/ui'
import { useState } from 'react'
import { ipalT } from '../../admin-i18n/t.js'
import { iaplT } from '../../admin-i18n/t.js'
type Props = {
/** `reopen`: the account has no TOTP (window passed or still open). `reset`: it has one (lost phone). */
@@ -14,7 +14,7 @@ type Props = {
/** The admin's button on an account: clears its TOTP so it can (or must) set it up again. */
export function TwoFactorResetButton({ kind, userId }: Props) {
const { t } = useTranslation()
const text = (key: Parameters<typeof ipalT>[1]) => ipalT(t as never, key)
const text = (key: Parameters<typeof iaplT>[1]) => iaplT(t as never, key)
const { config } = useConfig()
const [busy, setBusy] = useState(false)
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* Is the project's committed admin import map older than the config?
*
* ipalKit registers `SafeTotpView` in front of the 2FA screens. Payload resolves view components
* iapl registers `SafeTotpView` in front of the 2FA screens. Payload resolves view components
* through the import map file, and a path that is not in it renders NOTHING: the 2FA screen comes
* back empty (HTTP 200, no code form), so nobody can sign in — after an upgrade where
* `pnpm payload generate:importmap` was forgotten. In development Payload regenerates the file
+4 -4
View File
@@ -7,7 +7,7 @@
* URL sends the user off-site straight after a genuine login step (GHSA-rffw-fq79-g3ch in the
* original `payload-totp`, fixed there in 3.0.5; the fork does not have the fix).
*
* ipal-kit therefore cleans the value on the server before the package's view sees it
* IAPL therefore cleans the value on the server before the package's view sees it
* (SafeTotpView.tsx): `twoFactor.safeBack` — on by default, a function replaces the rule,
* `false` turns it off.
*/
@@ -75,7 +75,7 @@ export const safeAdminBack: SafeBackRule = (back, { adminRoute, origin }) => {
/** The package's views that take `back` — matched by the route the package gives them. */
const TOTP_VIEW_PATH = /^\/?(?:setup|verify)-totp$/
/** Import-map path of the wrapper ipalKit registers. */
/** Import-map path of the wrapper iapl registers. */
export const SAFE_TOTP_VIEW = '@intecion/ipal-kit/admin#SafeTotpView'
/** A view component as it stands in a Payload config. */
@@ -94,9 +94,9 @@ export const totpViewImportKey = (component: TotpViewComponent): string => {
export const totpViewDependencyKey = (component: TotpViewComponent) => `ipal-totp-view:${totpViewImportKey(component)}`
/**
* Puts ipal-kit's wrapper in front of the 2FA views for which `added(key)` is true and whose
* Puts IAPL's wrapper in front of the 2FA views for which `added(key)` is true and whose
* route is `setup-totp` / `verify-totp`: the wrapper cleans `back` and renders the original
* view, which it finds in the import map (`admin.dependencies` keeps it there). ipal-kit still
* view, which it finds in the import map (`admin.dependencies` keeps it there). IAPL still
* never imports the optional package. The original's `serverProps` stay server props; its
* `clientProps` travel as `ipalTotpClientProps`, so the wrapper can hand them to a client view.
*/
+1 -1
View File
@@ -101,7 +101,7 @@ export function reportRefusedOrigin(req: RequestLike, extra: string[] = []): boo
`or pass twoFactor: { sameOrigin: { origins: ['${originOf(origin)}'] } }, or make the proxy send X-Forwarded-Host. `
: 'The browser did not name an origin this site knows. '
req.payload?.logger?.warn(
`[ipal] 2FA: a code from ${origin ? `origin "${origin}"` : `a ${key} request`} was refused and not counted — it is not one of this site's own origins (${known}). ` +
`[iapl] 2FA: a code from ${origin ? `origin "${origin}"` : `a ${key} request`} was refused and not counted — it is not one of this site's own origins (${known}). ` +
how +
'If it is a foreign page, this is the protection working. twoFactor: { sameOrigin: false } turns the check off (docs/security.md "Verify and setup attempts only from the site\'s own origin"). Said once per origin.',
)
+14 -14
View File
@@ -3,14 +3,14 @@ import type { BasePayload, CollectionConfig, Config, GlobalConfig } from 'payloa
import { carryStaffRule } from '../../access/ruleMark.js'
/**
* ipal-kit's own second-factor check, next to the access wrapper of
* IAPL's own second-factor check, next to the access wrapper of
* @clocklimited/payload-2fa.
*
* Why it exists: the package wraps the `access` functions of the collections
* and globals that are in the config at the moment it runs. Whatever is added
* afterwards — ipal-kit's globals and collections, a plugin listed after
* ipalKit — was left unwrapped, so a staff password without the TOTP code
* opened it over the API. This check does not depend on that order: ipalKit
* afterwards — IAPL's globals and collections, a plugin listed after
* iapl — was left unwrapped, so a staff password without the TOTP code
* opened it over the API. This check does not depend on that order: iapl
* applies it to everything in the config when it finishes, and again in onInit
* to whatever other plugins added later; `userMeetsRole` asks it too.
*
@@ -19,7 +19,7 @@ import { carryStaffRule } from '../../access/ruleMark.js'
* 2. 2FA off or `twoFactor.guard: false` → there is no check (the project's choice);
* 3. an account of another auth collection → 2FA is about ONE collection; such an
* account is not staff unless the project names its collection in
* `access.staffCollections` (then it is staff WITHOUT a second factor — ipalKit
* `access.staffCollections` (then it is staff WITHOUT a second factor — iapl
* logs a warning at start);
* 4. `_strategy === 'totp'` → set by the package's strategy after password and code;
* 5. `_strategy === 'api-key'` → an API key is its own credential (the package's rule);
@@ -52,7 +52,7 @@ import { carryStaffRule } from '../../access/ruleMark.js'
* and its code. The package alone only redirects such an account in the panel.
*/
/** What ipalKit records in `config.custom.ipal.twoFactor` when 2FA is on and the guard is not switched off. */
/** What iapl records in `config.custom.ipal.twoFactor` when 2FA is on and the guard is not switched off. */
export type TwoFactorGuardConfig = {
collection: string
/** The project's exemption for accounts that never set TOTP up (a service account logging in with a password). */
@@ -169,8 +169,8 @@ type ConfigCustom = { totp?: { pluginOptions?: { disableAccessWrapper?: boolean
* Per-entity opt-out, operation by operation — the project's decision that
* this collection or global may be reached with the password alone:
* - the 2FA package's own key: `custom.totp.disableAccessWrapper.<operation>: true`
* (the package leaves that operation unwrapped; so does ipal-kit);
* - ipal-kit's key, for entities the package never sees (added after it ran):
* (the package leaves that operation unwrapped; so does IAPL);
* - IAPL's key, for entities the package never sees (added after it ran):
* `custom.ipal.secondFactor: false` (every operation) or `{ <operation>: false }`.
*/
function optedOut(entity: GuardedEntity, operation: string): boolean {
@@ -183,7 +183,7 @@ function optedOut(entity: GuardedEntity, operation: string): boolean {
}
/**
* Before the 2FA package runs: ipal-kit's opt-out written in the package's own
* Before the 2FA package runs: IAPL's opt-out written in the package's own
* key as well, so the package leaves those operations unwrapped too.
*/
export function passOptOutsToPackage(config: Config): Config {
@@ -255,7 +255,7 @@ export function guardConfigAccess(config: Config): Config {
}
/**
* The same for a running Payload, in place: what plugins listed after ipalKit
* The same for a running Payload, in place: what plugins listed after iapl
* added, and what Payload itself adds when it sanitizes the config. Returns
* the slugs it had to guard.
*
@@ -309,7 +309,7 @@ export function ensurePayloadGuarded(payload: Pick<BasePayload, 'config'>): null
* onInit) `onConfig` is called — before any request or Local API call can use
* the new config. Without it the first HTTP request would do the same (the
* guard strategy), but a Local API call made before that request would meet
* unguarded entities from plugins listed after ipalKit. Never throws.
* unguarded entities from plugins listed after iapl. Never throws.
*/
export function watchPayloadConfig(payload: BasePayload, onConfig: (payload: BasePayload) => void): void {
try {
@@ -334,13 +334,13 @@ export function watchPayloadConfig(payload: BasePayload, onConfig: (payload: Bas
}
}
/** Name of the auth strategy ipalKit adds to the 2FA collection (see buildGuardStrategy). */
/** Name of the auth strategy iapl adds to the 2FA collection (see buildGuardStrategy). */
export const GUARD_STRATEGY_NAME = 'ipal-second-factor-guard'
/**
* An auth strategy that authenticates nobody. Payload runs every strategy at
* the start of every request, before any access function, so this is the one
* place ipal-kit is called on each request with the config that is live right
* place IAPL is called on each request with the config that is live right
* now. It makes sure that config is guarded — also after a dev hot reload,
* where Payload swaps in a freshly built config and does not run onInit, and
* when Payload was started with `disableOnInit`.
@@ -443,7 +443,7 @@ export function guardNewEntityEndpoints<T extends { endpoints?: unknown; slug: s
* after the injected factory ran. A missing part means a version this guard
* was not written for: it would refuse every staff request, or — worse — the
* package itself may no longer protect what it used to. Returns what is
* missing; ipalKit refuses to start with it.
* missing; iapl refuses to start with it.
*/
export function missingTotpParts(config: Config, collection: string): string[] {
const target = (config.collections ?? []).find((c) => c.slug === collection)
+10 -10
View File
@@ -5,7 +5,7 @@ import { serverText } from '../../integrations/texts.js'
import { secondFactorPassed, SETUP_FROM_FIELD } from './secondFactor.js'
/**
* "2FA setup required": the pieces ipalKit adds to the 2FA collection and the
* "2FA setup required": the pieces iapl adds to the 2FA collection and the
* config when the mode is on (the default with `twoFactor`).
*
* - the date field `totpSetupFrom` — when the current setup window opened;
@@ -58,7 +58,7 @@ export function resolveRequireSetup(option: false | RequireSetupOptions | undefi
const given = option?.windowHours
if (given !== undefined && given !== false && (typeof given !== 'number' || !Number.isFinite(given) || given < 0)) {
throw new Error(
`[ipal] twoFactor.requireSetup.windowHours must be a number of hours (0 or more) or false, got ${JSON.stringify(given) ?? String(given)}. ` +
`[iapl] twoFactor.requireSetup.windowHours must be a number of hours (0 or more) or false, got ${JSON.stringify(given) ?? String(given)}. ` +
'Use 72 (the default), another number, or false / 0 for no time limit.',
)
}
@@ -84,12 +84,12 @@ const ASYNC_FUNCTION: unknown = (async () => {}).constructor
*/
export function strictExempt(exempt: unknown): NonNullable<RequireSetupOptions['exempt']> {
if (typeof exempt !== 'function') {
throw new Error('[ipal] twoFactor.requireSetup.exempt must be a function: ({ user }) => boolean.')
throw new Error('[iapl] twoFactor.requireSetup.exempt must be a function: ({ user }) => boolean.')
}
// by the constructor itself, not by its name
if (exempt.constructor === ASYNC_FUNCTION) {
throw new Error(
'[ipal] twoFactor.requireSetup.exempt must not be async: it is called in access checks, which cannot wait, and a Promise ' +
'[iapl] twoFactor.requireSetup.exempt must not be async: it is called in access checks, which cannot wait, and a Promise ' +
'would count as "exempt" for every account. Return true or false at once (decide from the fields on `user`).',
)
}
@@ -97,7 +97,7 @@ export function strictExempt(exempt: unknown): NonNullable<RequireSetupOptions['
const kind = what.replace(/\(.*\)$/, '')
if (exemptComplaints.has(kind)) {return}
exemptComplaints.add(kind)
console.error(`[ipal] twoFactor.requireSetup.exempt ${what}; it must return true or false at once. The account is NOT exempt.`)
console.error(`[iapl] twoFactor.requireSetup.exempt ${what}; it must return true or false at once. The account is NOT exempt.`)
}
return (args) => {
let answer: unknown
@@ -121,7 +121,7 @@ export function strictExempt(exempt: unknown): NonNullable<RequireSetupOptions['
* The fields for the 2FA collection: the window start (data) and, unless `statusField: false`,
* its status / reset control (panel).
*
* ipalKit adds the data field **whenever 2FA is on**, also with `requireSetup: false` or
* iapl adds the data field **whenever 2FA is on**, also with `requireSetup: false` or
* `guard: false`: the collection's schema then does not depend on those switches — on Postgres /
* SQLite switching the mode off would otherwise drop the column with the next migration, and
* switching it on again would hand every account without TOTP a new window.
@@ -206,13 +206,13 @@ export async function backfillSetupFrom(payload: BasePayload, collection: string
// Only the missing column gets this message — a database that cannot be reached is another problem.
if (/column .+ does not exist|no such column|unknown column|has no column/i.test(reason)) {
payload.logger.error(
`[ipal] 2FA: the column for "${SETUP_FROM_FIELD}" is missing on "${collection}" (${reason}). NOBODY CAN LOG IN to the panel until the ` +
`[iapl] 2FA: the column for "${SETUP_FROM_FIELD}" is missing on "${collection}" (${reason}). NOBODY CAN LOG IN to the panel until the ` +
'migration that adds it has run — administrators with 2FA included. Run `pnpm payload migrate:create`, commit the migration, and ' +
'have it applied when the new container starts (`prodMigrations` in the database adapter, or `pnpm payload migrate && pnpm start`) — ' +
'not in a pre-deployment command, which runs in the old container (docs/deployment.md §4.3, docs/security.md "Setup required" → Data).',
)
} else {
payload.logger.warn(`[ipal] 2FA: could not start the setup window for existing accounts (${reason}).`)
payload.logger.warn(`[iapl] 2FA: could not start the setup window for existing accounts (${reason}).`)
}
return 0
}
@@ -282,11 +282,11 @@ export function buildTwoFactorResetEndpoint(collection: string, options: TwoFact
const data = { [SETUP_FROM_FIELD]: new Date().toISOString(), totpSecret: null, ...(useSessions ? { sessions: [] } : {}) }
await req.payload.update({ id: userId, collection: collection as never, data: data as never, overrideAccess: true, req })
} catch (err) {
req.payload.logger.error(`[ipal] 2FA reset failed: ${err instanceof Error ? err.message : String(err)}`)
req.payload.logger.error(`[iapl] 2FA reset failed: ${err instanceof Error ? err.message : String(err)}`)
return Response.json({ message: serverText(i18n, 'twoFactorResetFailed'), ok: false }, { status: 400 })
}
const actor = (req.user as { email?: string; id?: unknown }).email ?? String((req.user as { id?: unknown }).id)
req.payload.logger.info(`[ipal] 2FA reset for ${collection} ${String(userId)} by ${actor}.`)
req.payload.logger.info(`[iapl] 2FA reset for ${collection} ${String(userId)} by ${actor}.`)
return Response.json({ message: serverText(i18n, 'twoFactorResetDone'), ok: true })
},
method: 'post',
+1 -1
View File
@@ -1,7 +1,7 @@
/**
* Texts of the 2FA screens and the user field (@clocklimited/payload-2fa reads
* them as `totpPlugin:*` through Payload's i18n). The package ships long,
* informal texts; these follow docs/dev/admin-ux.md. ipalKit merges them over
* informal texts; these follow docs/dev/admin-ux.md. iapl merges them over
* the package's and under the project's own `i18n.translations`, so a project
* still overrides any key. `setup.description` is rendered as HTML by the package.
*/
+2 -2
View File
@@ -62,7 +62,7 @@ async function hitStored(payload: { kv?: unknown; logger?: { warn: (m: string) =
} catch (err) {
if (!warnedStore) {
warnedStore = true
payload.logger?.warn(`[ipal] 2FA: the verify limit could not be stored (${err instanceof Error ? err.message : String(err)}); counting in memory only.`)
payload.logger?.warn(`[iapl] 2FA: the verify limit could not be stored (${err instanceof Error ? err.message : String(err)}); counting in memory only.`)
}
return null
}
@@ -98,7 +98,7 @@ export function buildVerifyLimit(collection: string, options: VerifyLimitOptions
const worst = kept && kept.count > mine.count ? kept : mine
if (worst.count <= max) {return null}
const retryAfter = Math.max(1, Math.ceil((worst.resetAt - now) / 1000))
req.payload.logger.warn(`[ipal] 2FA: too many verify attempts for ${collection} ${id}; refused for ${retryAfter} s.`)
req.payload.logger.warn(`[iapl] 2FA: too many verify attempts for ${collection} ${id}; refused for ${retryAfter} s.`)
return Response.json(
{ message: serverText(req.i18n as never, 'twoFactorTooManyAttempts', { minutes: Math.ceil(retryAfter / 60) }), ok: false },
{ headers: { 'Retry-After': String(retryAfter) }, status: 429 },