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:
co-authored by
Claude Fable 5.2
parent
414a4702df
commit
0a4f001797
+18
-18
@@ -14,7 +14,7 @@ import type { I18nConfig } from '../src/modules/i18n/types.js'
|
||||
import { findImportMapFile, missingImportMapEntries } from '../src/modules/security/totp/importMapCheck.js'
|
||||
import { changedViewKeys, safeAdminBack, wrapTotpViews } from '../src/modules/security/totp/safeBack.js'
|
||||
import { SafeTotpView } from '../src/modules/security/totp/SafeTotpView.js'
|
||||
import { ipalKit } from '../src/plugin.js'
|
||||
import { iapl } from '../src/plugin.js'
|
||||
import { withTotpParts } from './helpers.js'
|
||||
|
||||
const i18n: I18nConfig = { defaultLocale: 'en', locales: [{ code: 'en', label: 'English' }] }
|
||||
@@ -146,9 +146,9 @@ describe('wrapTotpViews', () => {
|
||||
describe.each([
|
||||
['3.0.0-beta.7', payloadTotpBeta7],
|
||||
['3.0.0-beta.1', payloadTotpBeta1 as unknown as typeof payloadTotpBeta7],
|
||||
])('ipalKit with the real 2FA package %s', (_version, payloadTotp) => {
|
||||
])('iapl with the real 2FA package %s', (_version, payloadTotp) => {
|
||||
const build = (twoFactor: false | Record<string, unknown>, extra: Partial<Config> = {}, options: Record<string, unknown> = {}) =>
|
||||
ipalKit({
|
||||
iapl({
|
||||
access: { authCollection: 'users' },
|
||||
i18n,
|
||||
twoFactor: twoFactor === false ? false : ({ issuer: 'Example', plugin: payloadTotp, ...twoFactor } as never),
|
||||
@@ -172,13 +172,13 @@ describe.each([
|
||||
expect(component(config, 'SetupTOTPBackslash')?.path).toBe('@intecion/ipal-kit/admin#SafeTotpView')
|
||||
})
|
||||
|
||||
test('the package registered by the project too, before ipalKit: still guarded', async () => {
|
||||
test('the package registered by the project too, before iapl: still guarded', async () => {
|
||||
const first = payloadTotp({ collection: 'users', totp: { issuer: 'E' } } as never)({ collections: [{ slug: 'users', auth: true, fields: [] }], secret: 'x' } as never)
|
||||
expect(raw(first).length).toBe(4)
|
||||
expect(raw(await build({}, first as never))).toEqual([])
|
||||
})
|
||||
|
||||
test('ipalKit run over its own output (a config reused): still guarded', async () => {
|
||||
test('iapl run over its own output (a config reused): still guarded', async () => {
|
||||
const once = await build({})
|
||||
const twice = await build({}, { admin: once.admin } as never)
|
||||
expect(raw(twice)).toEqual([])
|
||||
@@ -187,7 +187,7 @@ describe.each([
|
||||
|
||||
test('the same incoming config object built twice', async () => {
|
||||
const incoming = { admin: { components: { views: {} } }, collections: [], secret: 'x' } as unknown as Config
|
||||
const plugin = () => ipalKit({ access: { authCollection: 'users' }, i18n, twoFactor: { issuer: 'E', plugin: payloadTotp } as never })(incoming)
|
||||
const plugin = () => iapl({ access: { authCollection: 'users' }, i18n, twoFactor: { issuer: 'E', plugin: payloadTotp } as never })(incoming)
|
||||
expect(raw(await plugin())).toEqual([])
|
||||
expect(raw(await plugin())).toEqual([])
|
||||
})
|
||||
@@ -221,7 +221,7 @@ describe.each([
|
||||
'ipal-totp-view:@clocklimited/payload-2fa/rsc#TOTPSetup': { type: 'component', path: '@clocklimited/payload-2fa/rsc#TOTPSetup' },
|
||||
'ipal-totp-view:@clocklimited/payload-2fa/rsc#TOTPVerify': { type: 'component', path: '@clocklimited/payload-2fa/rsc#TOTPVerify' },
|
||||
})
|
||||
// the tab title ipal-kit gives the screens is still there
|
||||
// the tab title IAPL gives the screens is still there
|
||||
expect((config.admin?.components?.views as Record<string, { meta?: { title?: string } }>).VerifyTOTP.meta?.title).toBeTruthy()
|
||||
})
|
||||
|
||||
@@ -306,13 +306,13 @@ describe('SafeTotpView', () => {
|
||||
})
|
||||
})
|
||||
|
||||
// "Setup required" (requireSetup), the back-link check (safeBack) and ipal-kit's own check (guard) are separate
|
||||
// "Setup required" (requireSetup), the back-link check (safeBack) and IAPL's own check (guard) are separate
|
||||
// switches: each combination builds, and each part is on exactly when its own switch says so.
|
||||
describe('requireSetup x safeBack x guard', () => {
|
||||
const combos = [undefined, false].flatMap((requireSetup) => [undefined, false].flatMap((safeBack) => [undefined, false].map((guard) => ({ guard, requireSetup, safeBack }))))
|
||||
|
||||
test.each(combos)('requireSetup: $requireSetup, safeBack: $safeBack, guard: $guard', async (options) => {
|
||||
const config = await ipalKit({ access: { authCollection: 'users' }, i18n, twoFactor: { issuer: 'E', plugin: payloadTotpBeta7, ...options } as never })({ collections: [], secret: 'x' } as unknown as Config)
|
||||
const config = await iapl({ access: { authCollection: 'users' }, i18n, twoFactor: { issuer: 'E', plugin: payloadTotpBeta7, ...options } as never })({ collections: [], secret: 'x' } as unknown as Config)
|
||||
const views = Object.values(config.admin?.components?.views ?? {}) as { Component: { path?: string } | string; path: string }[]
|
||||
const totpViews = views.filter((v) => /(?:setup|verify)-totp$/.test(v.path))
|
||||
expect(totpViews).toHaveLength(4)
|
||||
@@ -320,13 +320,13 @@ describe('requireSetup x safeBack x guard', () => {
|
||||
const wrapped = totpViews.filter((v) => typeof v.Component === 'object' && v.Component.path === '@intecion/ipal-kit/admin#SafeTotpView').length
|
||||
expect(wrapped).toBe(options.safeBack === false ? 0 : 4)
|
||||
|
||||
// setup required needs ipal-kit's own check; with either off there is no status field, hook or notice
|
||||
// setup required needs IAPL's own check; with either off there is no status field, hook or notice
|
||||
const setupOn = options.requireSetup !== false && options.guard !== false
|
||||
const users = config.collections?.find((c) => c.slug === 'users')
|
||||
// the data field whenever 2FA is on (the schema does not follow the switches); the panel's status field with the mode
|
||||
expect(Boolean(users?.fields.some((f) => 'name' in f && f.name === 'totpSetupFrom'))).toBe(true)
|
||||
expect(Boolean(users?.fields.some((f) => 'name' in f && f.name === 'totpSetupStatus'))).toBe(setupOn)
|
||||
// the administrator's reset (a lost phone) comes with ipal-kit's own check, also when setup is not required
|
||||
// the administrator's reset (a lost phone) comes with IAPL's own check, also when setup is not required
|
||||
expect(Boolean(config.endpoints?.some((e) => e.path === '/ipal/two-factor/reset'))).toBe(options.guard !== false)
|
||||
const provider = JSON.stringify(config.admin?.components?.providers ?? [])
|
||||
expect(provider.includes('"requireSetup":true')).toBe(setupOn)
|
||||
@@ -339,12 +339,12 @@ describe('requireSetup x safeBack x guard', () => {
|
||||
|
||||
describe('requireSetup.setupNotice', () => {
|
||||
const providers = async (requireSetup?: Record<string, unknown>) =>
|
||||
JSON.stringify((await ipalKit({ access: { authCollection: 'users' }, i18n, twoFactor: { issuer: 'E', plugin: payloadTotpBeta7, requireSetup } as never })({ collections: [], secret: 'x' } as unknown as Config)).admin?.components?.providers ?? [])
|
||||
JSON.stringify((await iapl({ access: { authCollection: 'users' }, i18n, twoFactor: { issuer: 'E', plugin: payloadTotpBeta7, requireSetup } as never })({ collections: [], secret: 'x' } as unknown as Config)).admin?.components?.providers ?? [])
|
||||
|
||||
test('on by default; false removes the notice, not the lock', async () => {
|
||||
expect(await providers()).toContain('"requireSetup":true')
|
||||
expect(await providers({ setupNotice: false })).not.toContain('"requireSetup":true')
|
||||
const config = await ipalKit({ access: { authCollection: 'users' }, i18n, twoFactor: { issuer: 'E', plugin: payloadTotpBeta7, requireSetup: { setupNotice: false } } as never })({ collections: [], secret: 'x' } as unknown as Config)
|
||||
const config = await iapl({ access: { authCollection: 'users' }, i18n, twoFactor: { issuer: 'E', plugin: payloadTotpBeta7, requireSetup: { setupNotice: false } } as never })({ collections: [], secret: 'x' } as unknown as Config)
|
||||
expect((config.custom as { ipal: { twoFactor: { requireSetup: boolean } } }).ipal.twoFactor.requireSetup).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -357,7 +357,7 @@ describe('a 2FA factory that hands back the same view objects on every call', ()
|
||||
const factory = (o: { collection: string }) => (c: Config) =>
|
||||
withTotpParts({ ...c, admin: { ...c.admin, components: { ...c.admin?.components, views: { ...c.admin?.components?.views, ...views } } } } as Config, o.collection)
|
||||
const build = (incoming: Partial<Config> = {}) =>
|
||||
ipalKit({ access: { authCollection: 'users' }, i18n, twoFactor: { issuer: 'E', plugin: factory as never } })({ collections: [], secret: 'x', ...incoming } as unknown as Config)
|
||||
iapl({ access: { authCollection: 'users' }, i18n, twoFactor: { issuer: 'E', plugin: factory as never } })({ collections: [], secret: 'x', ...incoming } as unknown as Config)
|
||||
const paths = (config: Config) => Object.values(config.admin?.components?.views ?? {}).map((v) => (v as { Component: { path: string } }).Component.path)
|
||||
|
||||
test('is guarded when registered once, twice, and over a config that already holds those objects', async () => {
|
||||
@@ -455,11 +455,11 @@ describe('the stale import-map check', () => {
|
||||
}
|
||||
})
|
||||
|
||||
test('in production ipalKit marks the redirect provider when the map lacks the wrapper; not otherwise', async () => {
|
||||
test('in production iapl marks the redirect provider when the map lacks the wrapper; not otherwise', async () => {
|
||||
const stale = await project('src/app/(payload)/admin', 'export const importMap = { "@intecion/ipal-kit/admin#TotpRedirectProvider": X }')
|
||||
const current = await project('src/app/(payload)/admin', `export const importMap = { "${ENTRY}": Y }`)
|
||||
const flagged = async (baseDir: string, twoFactor: Record<string, unknown> = {}) => {
|
||||
const config = await ipalKit({ access: { authCollection: 'users' }, i18n, twoFactor: { issuer: 'E', plugin: payloadTotpBeta7, ...twoFactor } as never })({
|
||||
const config = await iapl({ access: { authCollection: 'users' }, i18n, twoFactor: { issuer: 'E', plugin: payloadTotpBeta7, ...twoFactor } as never })({
|
||||
admin: { importMap: { baseDir } },
|
||||
collections: [],
|
||||
secret: 'x',
|
||||
@@ -502,10 +502,10 @@ describe('the stale import-map check', () => {
|
||||
}
|
||||
})
|
||||
|
||||
test('only ipal-kit\'s own redirect provider gets the flag, not a project\'s provider', async () => {
|
||||
test('only IAPL\'s own redirect provider gets the flag, not a project\'s provider', async () => {
|
||||
const stale = await project('src/app/(payload)/admin', 'export const importMap = {}')
|
||||
const providers = async (provider?: unknown) => {
|
||||
const config = await ipalKit({ access: { authCollection: 'users' }, i18n, twoFactor: { issuer: 'E', plugin: payloadTotpBeta7, provider } as never })({
|
||||
const config = await iapl({ access: { authCollection: 'users' }, i18n, twoFactor: { issuer: 'E', plugin: payloadTotpBeta7, provider } as never })({
|
||||
admin: { importMap: { baseDir: stale } },
|
||||
collections: [],
|
||||
secret: 'x',
|
||||
|
||||
Reference in New Issue
Block a user