IAPL rename: the old names keep working, and a second cookie name and counter key for new sites
- exports: ipalKit, IpalOptions, ipalEnvRules, IpalEnvFeatures, ipalT, ipalVar, IPAL_TOKENS, IPAL_BREAKPOINTS, IpalTokenName, IpalGlobalSlug are aliases of the iapl names - env: IAPL_* is read first, IPAL_* as fallback (readEnv; EnvRule.aliases for assertEnv); the crawler service reads IPAL_CRAWLER_SITES too - doctor: reads ipal-doctor.json when it is the only one, the old pointer block, ipal-audit-skip and old skill folders; new rule legacy-names (info) and storage-names (warning) - iapl-skills: installs iapl-*, removes the 16 old folders by exact name, rewrites the old pointer block in place; a project's own ipal-* skill stays - storageNames: 'ipal' (default) | 'iapl': the cookie the scanner declares and the 2FA counter's kv prefix; <PageStats visitorCookie>, IAPL_VISITOR_COOKIE, verifyLimit.keyPrefix - test/legacyNames.test.ts: 24 tests for all of the above Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
0a4f001797
commit
425fac14fb
+6
-2
@@ -61,6 +61,7 @@ import { searchSettingsFields } from './modules/seo/searchSettings.js'
|
||||
import { migrateTitleSeparator } from './modules/seo/titleSeparator.js'
|
||||
import { applyCollectionOverride } from './modules/shared/collectionOverride.js'
|
||||
import { buildStatsCollection, buildStatsEndpoint } from './modules/stats/index.js'
|
||||
import { visitorCookieFor } from './modules/stats/visitorCookie.js'
|
||||
|
||||
/** The admin provider @clocklimited/payload-2fa registers; IAPL swaps it (twoFactor.provider). */
|
||||
const TOTP_PACKAGE_PROVIDER = '@clocklimited/payload-2fa/rsc#TOTPProvider'
|
||||
@@ -309,7 +310,7 @@ export const iapl = (options: IaplOptions): Plugin => {
|
||||
// `req.user` from ANY auth collection and act on the 2FA collection by id.
|
||||
// Only accounts of the 2FA collection may use them (guardTotpEndpoint) —
|
||||
// whatever the package registered, also paths a later version adds.
|
||||
const limitVerify = tf.verifyLimit === false ? undefined : buildVerifyLimit(target, tf.verifyLimit)
|
||||
const limitVerify = tf.verifyLimit === false ? undefined : buildVerifyLimit(target, { ...(options.storageNames === 'iapl' ? { keyPrefix: 'iapl' } : {}), ...tf.verifyLimit })
|
||||
const extraOrigins = typeof tf.sameOrigin === 'object' ? (tf.sameOrigin.origins ?? []) : []
|
||||
const guards = {
|
||||
...(limitVerify ? { limitVerify: (req: PayloadRequest) => limitVerify(req) } : {}),
|
||||
@@ -767,7 +768,7 @@ export const iapl = (options: IaplOptions): Plugin => {
|
||||
...(config.collections ?? []),
|
||||
applyCollectionOverride(hideFromNav(withFillLocales('collection', buildCookieReviewCollection(scannerOptions), fillLocales['cookie-review'])), scannerOptions.collectionOverrides),
|
||||
]
|
||||
const scanPlugin = { localeCount: options.i18n.locales.length, stats: Boolean(options.stats), ...(options.theme?.storageKey ? { themeStorageKey: options.theme.storageKey } : {}) }
|
||||
const scanPlugin = { localeCount: options.i18n.locales.length, stats: Boolean(options.stats), visitorCookie: visitorCookieFor(options.storageNames), ...(options.theme?.storageKey ? { themeStorageKey: options.theme.storageKey } : {}) }
|
||||
config.endpoints = [...(config.endpoints ?? []), ...buildCookieScanEndpoints(scannerOptions, scanPlugin)]
|
||||
// One approval for everything found (default on): the "Approve cookies" view and its endpoint.
|
||||
const approval = scannerOptions.approval === false ? null : (scannerOptions.approval ?? {})
|
||||
@@ -1002,3 +1003,6 @@ export const iapl = (options: IaplOptions): Plugin => {
|
||||
return config
|
||||
}
|
||||
}
|
||||
|
||||
/** @deprecated The name before 1.17.0; the same function as `iapl`. Removed in 2.0. */
|
||||
export const ipalKit = iapl
|
||||
|
||||
Reference in New Issue
Block a user