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
+13
-13
@@ -23,7 +23,7 @@ import { buildPasswordRuleHook, checkPassword, resolvePasswordRule } from '../sr
|
||||
import { isPasswordRuleHook, markedStaffRule, staffRuleOf } from '../src/modules/access/ruleMark.js'
|
||||
import { adoptLateAuthCollections, bothAllow, canHoldStaffRole, hasPluginRoles, openSignUpCollections, rolesAreAList, rolesNotOwn, sameStaffCollectionAccess, staffCollectionsNobodyManages, staffCollectionsOnOwnRoles, staffCollectionsOpenToOthers, staffCreateAccess, staffReadAccess, staffUpdateAccess, unknownStaffCollections } from '../src/modules/access/selfRegistration.js'
|
||||
import { requireSecondFactor } from '../src/modules/security/totp/secondFactor.js'
|
||||
import { ipalKit } from '../src/plugin.js'
|
||||
import { iapl } from '../src/plugin.js'
|
||||
import { buildTestConfig, withTotpParts } from './helpers.js'
|
||||
import { testDatabase } from './http/db.js'
|
||||
import { cookiesOf, startPayloadServer, type TestServer } from './http/server.js'
|
||||
@@ -31,7 +31,7 @@ import { totp } from './http/totp.js'
|
||||
|
||||
const TOTP_SECRET = 'JBSWY3DPEHPK3PXP'
|
||||
|
||||
/** A plugin the project lists AFTER ipalKit: its auth collections did not exist when ipalKit ran (review round 2, R2-3). */
|
||||
/** A plugin the project lists AFTER iapl: its auth collections did not exist when iapl ran (review round 2, R2-3). */
|
||||
const latePlugin: Plugin = (config: Config) => ({
|
||||
...config,
|
||||
collections: [
|
||||
@@ -98,7 +98,7 @@ export function accountRulesSuite(twoFactor: boolean): void {
|
||||
],
|
||||
db: testDatabase(twoFactor ? 'accounts_2fa' : 'accounts'),
|
||||
editor: lexicalEditor(),
|
||||
plugins: [ipalKit({ access: { authCollection: 'users', staffCollections: ['staff2', 'crew', 'agents', 'late-staff'] }, i18n, twoFactor: twoFactor ? { issuer: 'Example', plugin: payloadTotp, verifyLimit: false } : false }), latePlugin],
|
||||
plugins: [iapl({ access: { authCollection: 'users', staffCollections: ['staff2', 'crew', 'agents', 'late-staff'] }, i18n, twoFactor: twoFactor ? { issuer: 'Example', plugin: payloadTotp, verifyLimit: false } : false }), latePlugin],
|
||||
secret: 'integration-test-secret-0123456789',
|
||||
telemetry: false,
|
||||
})
|
||||
@@ -341,7 +341,7 @@ export function accountRulesSuite(twoFactor: boolean): void {
|
||||
})
|
||||
|
||||
// Review round 2 (R2-3): a staff collection a later plugin adds.
|
||||
test('a staff collection added by a plugin listed after ipalKit has the same rules', async () => {
|
||||
test('a staff collection added by a plugin listed after iapl has the same rules', async () => {
|
||||
// (the first-user spellings above created nothing: counted there)
|
||||
expect((await post('/late-staff', { email: '[email protected]', password: PASSWORD, roles: ['admin'] }, visitor)).status).toBe(403)
|
||||
expect((await post('/late-staff', { email: '[email protected]', password: PASSWORD, roles: ['admin'] }, editor)).status).toBe(403)
|
||||
@@ -484,7 +484,7 @@ export function accountRulesSuite(twoFactor: boolean): void {
|
||||
expect(checkPassword('abcd', { minLength: 4 })).toBeNull()
|
||||
expect(checkPassword('[email protected] ', { email: '[email protected]', minLength: 4 })).toBe('email')
|
||||
const hooks = async (options: Record<string, unknown>) =>
|
||||
(await ipalKit({ access: { authCollection: 'users' }, i18n, twoFactor: false, ...options } as never)({ admin: { user: 'users' }, collections: [{ slug: 'customers', auth: true, fields: [] }], secret: 'x' } as unknown as Config)).collections!.map((c) => [c.slug, c.hooks?.beforeOperation?.length ?? 0])
|
||||
(await iapl({ access: { authCollection: 'users' }, i18n, twoFactor: false, ...options } as never)({ admin: { user: 'users' }, collections: [{ slug: 'customers', auth: true, fields: [] }], secret: 'x' } as unknown as Config)).collections!.map((c) => [c.slug, c.hooks?.beforeOperation?.length ?? 0])
|
||||
expect(await hooks({})).toEqual([['customers', 0], ['users', 1]])
|
||||
expect(await hooks({ accounts: { password: false } })).toEqual([['customers', 0], ['users', 0]])
|
||||
expect(await hooks({ accounts: false })).toEqual([['customers', 0], ['users', 0]])
|
||||
@@ -493,7 +493,7 @@ export function accountRulesSuite(twoFactor: boolean): void {
|
||||
|
||||
describe('accounts.panelRole: the config', () => {
|
||||
const build = (options: Record<string, unknown>, incoming: Partial<Config> = {}) =>
|
||||
ipalKit({ access: { authCollection: 'users' }, i18n, twoFactor: false, ...options } as never)({ collections: [], secret: 'x', ...incoming } as unknown as Config)
|
||||
iapl({ access: { authCollection: 'users' }, i18n, twoFactor: false, ...options } as never)({ collections: [], secret: 'x', ...incoming } as unknown as Config)
|
||||
const adminRule = (config: Config) => config.collections!.find((c) => c.slug === 'users')!.access?.admin
|
||||
|
||||
test('on by default at editor; a role, false and accounts: false change it', async () => {
|
||||
@@ -507,7 +507,7 @@ export function accountRulesSuite(twoFactor: boolean): void {
|
||||
expect(adminRule(await build({ accounts: { panelRole: false } }))).toBeUndefined()
|
||||
expect(adminRule(await build({ accounts: false }))).toBeUndefined()
|
||||
// without `access` there are no roles to ask about
|
||||
expect(adminRule(await ipalKit({ i18n, twoFactor: false })({ collections: [], secret: 'x' } as unknown as Config))).toBeUndefined()
|
||||
expect(adminRule(await iapl({ i18n, twoFactor: false })({ collections: [], secret: 'x' } as unknown as Config))).toBeUndefined()
|
||||
})
|
||||
|
||||
test("the project's own rule wins: on its own collection, and through access.authAccess", async () => {
|
||||
@@ -537,7 +537,7 @@ export function accountRulesSuite(twoFactor: boolean): void {
|
||||
|
||||
describe('accounts.adminOnlyCreate / firstUserRoute: the config', () => {
|
||||
const build = (options: Record<string, unknown>, incoming: Partial<Config> = {}) =>
|
||||
ipalKit({ access: { authCollection: 'users', staffCollections: ['staff2'] }, i18n, twoFactor: false, ...options } as never)({
|
||||
iapl({ access: { authCollection: 'users', staffCollections: ['staff2'] }, i18n, twoFactor: false, ...options } as never)({
|
||||
collections: [{ slug: 'staff2', auth: true, fields: [] }, { slug: 'customers', access: { create: () => true }, auth: true, fields: [] }, { slug: 'pages', fields: [] }],
|
||||
secret: 'x',
|
||||
...incoming,
|
||||
@@ -646,7 +646,7 @@ export function accountRulesSuite(twoFactor: boolean): void {
|
||||
expect(of(noEndpoints, 'staff2').endpoints).toBe(false)
|
||||
// without `access` the rules still apply to the panel's login collection — as "an account of this collection":
|
||||
// without the plugin's roles nobody is an admin to it
|
||||
const noAccess = await ipalKit({ i18n, twoFactor: false })({ collections: [{ slug: 'users', auth: true, fields: [] }], secret: 'x' } as unknown as Config)
|
||||
const noAccess = await iapl({ i18n, twoFactor: false })({ collections: [{ slug: 'users', auth: true, fields: [] }], secret: 'x' } as unknown as Config)
|
||||
expect(of(noAccess, 'users').access?.create).toBeTypeOf('function')
|
||||
expect(await (of(noAccess, 'users').access!.create as (a: unknown) => unknown)({ req: { payload: { staffCollections: ['users'] }, user: { id: 1, collection: 'users' } } })).toBe(true)
|
||||
})
|
||||
@@ -685,8 +685,8 @@ export function accountRulesSuite(twoFactor: boolean): void {
|
||||
test('a config collection that becomes staff later keeps the rules it had at config time', async () => {
|
||||
const own = ({ req }: { req: { user: unknown } }) => Boolean(req.user)
|
||||
const rolesField = () => ({ name: 'roles', type: 'select', hasMany: true, options: ['user', 'editor', 'admin'] })
|
||||
const { ipalKit } = await import('../src/plugin.js')
|
||||
const built = await ipalKit({ access: { authCollection: 'users' }, i18n, twoFactor: false } as never)({
|
||||
const { iapl } = await import('../src/plugin.js')
|
||||
const built = await iapl({ access: { authCollection: 'users' }, i18n, twoFactor: false } as never)({
|
||||
admin: { user: 'users' },
|
||||
collections: [
|
||||
{ slug: 'users', auth: true, fields: [] },
|
||||
@@ -775,7 +775,7 @@ export function accountRulesSuite(twoFactor: boolean): void {
|
||||
// a late auth collection that is not staff: the first-user endpoint only
|
||||
expect(visitors.access.create).toBe(g)
|
||||
expect(asIs.access.create).toBe(g)
|
||||
// what ipalKit saw at config time, and what is not an auth collection: untouched
|
||||
// what iapl saw at config time, and what is not an auth collection: untouched
|
||||
expect(seen.access.create).toBe(g)
|
||||
expect([seen.endpoints.length, pages.endpoints.length]).toEqual([0, 0])
|
||||
// a second call (a request after the start) changes nothing
|
||||
@@ -817,7 +817,7 @@ export function accountRulesSuite(twoFactor: boolean): void {
|
||||
const withFactory = await build({ twoFactor: { issuer: 'A', plugin: wrapping } })
|
||||
expect(['create', 'update', 'delete', 'unlock', 'read', 'readVersions'].map((op) => staffRuleOf((of(withFactory, 'staff2').access as Record<string, unknown>)[op])?.slug)).toEqual(Array(6).fill('staff2'))
|
||||
expect(staffRuleOf(of(withFactory, 'customers').access?.create)).toBeUndefined() // the project's own rule
|
||||
// …and marking does not undo ipal-kit's 2FA guard: a plain 2FA config has nothing left to guard at start
|
||||
// …and marking does not undo IAPL's 2FA guard: a plain 2FA config has nothing left to guard at start
|
||||
const { ensurePayloadGuarded } = await import('../src/modules/security/totp/secondFactor.js')
|
||||
const plain = await build({ twoFactor: { issuer: 'A', plugin: ((o: { collection: string }) => (c: Config) => withTotpParts(c, o.collection)) as never } })
|
||||
expect([ensurePayloadGuarded({ config: plain } as never), ensurePayloadGuarded({ config: withFactory } as never)]).toEqual([[], []])
|
||||
|
||||
Reference in New Issue
Block a user