Merge claude/security-b-118: plugin status written alone, access answers announced (strict in 1.19.0), drafts left out of related documents

Merged onto ee241de (the prepared 1.17.2). Conflicts kept both sides: AGENT.md rows (consent version; drafts, status, access answers), security.md sections (job queue, visitor accounts; access callbacks), src/index.ts (the jobs exports).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 12:53:59 +01:00
co-authored by Claude Opus 5.5
29 changed files with 554 additions and 48 deletions
+33
View File
@@ -0,0 +1,33 @@
/**
* The answer of a project's access callback (`cookieScanner.access`, the doctor's `access`), read the same way
* everywhere (owner's decision Q4, 1.18.0).
*
* Today any truthy answer lets the request in, as before: `({ req }) => req.user` returns an account object, and
* a function that returns `'no'` or `{}` lets the request in too. From the next minor version only `true` will
* allow. Until then the first answer that is not a boolean is reported once per option in the server log, so a
* project sees it before the change. (A callback needs a request to be asked, so this cannot be checked at start:
* the warning comes with the first call.)
*/
const warned = new Set<string>()
export type AccessAnswerOptions = {
/** Where to report (default `console.warn`). */
warn?: (message: string) => void
}
/** True when the request may pass; warns once per `option` when the answer is not a boolean. */
export function accessAllowed(option: string, answer: unknown, { warn = (m) => console.warn(m) }: AccessAnswerOptions = {}): boolean {
if (typeof answer !== 'boolean' && !warned.has(option)) {
warned.add(option)
const kind = answer === null ? 'null' : Array.isArray(answer) ? 'an array' : typeof answer === 'object' ? 'an object' : `a ${typeof answer}`
warn(
`[iapl] ${option} returned ${kind}, not true or false. It is still read as ${answer ? 'allowed' : 'refused'}; from the next minor version only \`true\` allows. Return a boolean, e.g. \`({ req }) => Boolean(req.user)\` (docs/security.md "Access callbacks").`,
)
}
return Boolean(answer)
}
/** For tests: forget which options were reported. */
export function resetAccessWarnings(): void {
warned.clear()
}