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
@@ -2,6 +2,7 @@ import type { BasePayload } from 'payload'
|
||||
|
||||
import type { CookieCrawlOptions } from '../types.js'
|
||||
|
||||
import { readEnv } from '../../../shared/envName.js'
|
||||
import { DEFAULT_TRACKER_HOSTS } from './violations.js'
|
||||
|
||||
export const COOKIE_CRAWL_SLUG = 'cookie-crawl'
|
||||
@@ -27,8 +28,8 @@ const trimSlash = (v: string) => v.replace(/\/+$/, '')
|
||||
|
||||
/** Options + env + Payload config, read at call time (env can change between deploys, not between requests). */
|
||||
export function resolveCrawlConfig(options: CookieCrawlOptions, payload: BasePayload): ResolvedCrawlConfig {
|
||||
const serviceUrl = options.serviceUrl ?? process.env[COOKIE_SCAN_URL_ENV]?.trim()
|
||||
const token = options.token ?? process.env[COOKIE_SCAN_TOKEN_ENV]?.trim()
|
||||
const serviceUrl = options.serviceUrl ?? readEnv(COOKIE_SCAN_URL_ENV)?.trim()
|
||||
const token = options.token ?? readEnv(COOKIE_SCAN_TOKEN_ENV)?.trim()
|
||||
const siteUrl = options.siteUrl ?? (payload.config.serverURL || process.env.NEXT_PUBLIC_SERVER_URL?.trim())
|
||||
return {
|
||||
acceptSelector: options.acceptSelector ?? '[data-ipal="accept"]',
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { CookieDeclaration, CookieIntegration, CookieScanContext } from './
|
||||
import { adminTexts } from '../../admin-i18n/texts/index.js'
|
||||
import { validAnalyticsId } from '../../analytics/idFormats.js'
|
||||
import { LOCALE_COOKIE_NAME } from '../../i18n/negotiateLocale.js'
|
||||
import { VISITOR_COOKIE } from '../../stats/visitorCookie.js'
|
||||
import { THEME_STORAGE_KEY } from '../../theme/theme.js'
|
||||
import { getTurnstileConfig } from '../../turnstile/config.js'
|
||||
import { CONSENT_COOKIE } from '../storage.js'
|
||||
@@ -108,9 +109,9 @@ export const DEFAULT_COOKIE_INTEGRATIONS: CookieIntegration[] = [
|
||||
label: A('cookieIntegrationLocale'),
|
||||
},
|
||||
{
|
||||
declarations: [
|
||||
declarations: (ctx) => [
|
||||
{
|
||||
name: 'ipal_vid', // VISITOR_COOKIE — that file is a client component
|
||||
name: ctx.plugin.visitorCookie ?? VISITOR_COOKIE, // `iapl_vid` on a site with iapl({ storageNames: 'iapl' })
|
||||
category: 'analytics',
|
||||
purpose: T(
|
||||
'Built-in statistics: random visitor id that joins your visits across days. Set only with analytics consent.',
|
||||
|
||||
@@ -37,9 +37,8 @@ export type CookieScanContext = {
|
||||
/** Admin language of the request (`req.i18n.language`); names stored by a scan use it. Default `'en'`. */
|
||||
language?: string
|
||||
payload: BasePayload
|
||||
/** Plugin options that switch modules on. */
|
||||
/** Plugin options that switch modules on; `themeStorageKey` = `iapl({ theme: { storageKey } })`. */
|
||||
plugin: { localeCount: number; stats: boolean; themeStorageKey?: string }
|
||||
/** Plugin options that switch modules on; `themeStorageKey` = `iapl({ theme: { storageKey } })`; `visitorCookie` = the statistics cookie of this site (`iapl({ storageNames })`, default `ipal_vid`). */
|
||||
plugin: { localeCount: number; stats: boolean; themeStorageKey?: string; visitorCookie?: string }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@ export type ConsentCookieMap = Partial<Record<ConsentCategory, string[]>>
|
||||
* projects add theirs through <ConsentProvider cookieMap> (merged, not replaced).
|
||||
*/
|
||||
export const DEFAULT_COOKIE_MAP: ConsentCookieMap = {
|
||||
analytics: ['_ga', '_ga_*', '_gid', '_gat*', '_clck', '_clsk', 'CLID', '_hj*', 'ipal_vid'],
|
||||
analytics: ['_ga', '_ga_*', '_gid', '_gat*', '_clck', '_clsk', 'CLID', '_hj*', 'ipal_vid', 'iapl_vid'],
|
||||
functional: [LOCALE_COOKIE_NAME],
|
||||
marketing: ['_fbp', '_fbc', '_gcl_*', '_ttp', 'li_fat_id', '_uetsid', '_uetvid'],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user