import type { ParseContextType } from '../context/parseTypes.js'; import type { StackTrail } from '../context/StackTrail.js'; import type { OasSecurityRequirement } from '../oas/securityRequirement/SecurityRequirement.js'; /** * Check a `security` field before its requirements are parsed. Shared by * the 3.0, 3.1 and 3.2 parsers. * * - Missing: returns `undefined`. * - Not an array, or an entry that is not an object of scheme name to a * list of string scopes: throws, so the operation is dropped as * `INVALID_OPERATION`. At the root, {@link toSecurityCheck} catches it. * - Otherwise: returns the checked requirement objects. */ export declare const toSecurityRequirementObjects: (security: unknown) => Record[] | undefined; /** The document-level facts each operation's security is checked against. */ export type SecurityCheck = { /** The parsed root `security`; `undefined` when absent or malformed. */ rootSecurity: OasSecurityRequirement[] | undefined; /** Why the root `security` cannot be used, or `undefined` when it can. */ rootProblem: string | undefined; /** Scheme names in the document's `components.securitySchemes`. */ declaredSchemes: string[]; /** Declared scheme names that failed to parse. */ failedSchemes: string[]; /** Declared scheme names of a valid type core does not parse yet (`mutualTLS`). */ unmodeledSchemes: string[]; context: ParseContextType; }; export type ToSecurityCheckArgs = { /** Parses the root `security`; throws when it is malformed. */ parse: () => OasSecurityRequirement[] | undefined; /** The raw `components.securitySchemes`. */ declared: Record | undefined; /** The parsed `components.securitySchemes`. */ parsed: Record | undefined; /** Trail that ends in the root `security` key. */ stackTrail: StackTrail; context: ParseContextType; }; /** * Parse the document's root `security` and collect the scheme facts that * {@link toOperationsWithValidSecurity} checks each operation against. * * A root `security` that is malformed, or that names a scheme that failed * to parse or is not defined, logs one `INVALID_OPERATION` warning at * `security` and sets `rootProblem`. The document then has no `security`, * and the operations that inherit it are dropped. */ export declare const toSecurityCheck: ({ parse, declared, parsed, stackTrail, context }: ToSecurityCheckArgs) => SecurityCheck; type SecuredItem = { security: OasSecurityRequirement[] | undefined; stackTrail: StackTrail; }; export type ToOperationsWithValidSecurityArgs = { items: Item[]; check: SecurityCheck; }; /** * Drop each operation or webhook whose own `security` names a scheme that * failed to parse or is not defined, or that has no `security` and * inherits an unusable root. Each dropped item logs one `INVALID_OPERATION` * error on its own trail. `security: []` inherits nothing and is kept. * * A kept item depends on each scheme its security names (its own, else the * root's), as it would on a `$ref` to it, so it is registered as a consumer * of the scheme. When the parser removes the scheme later (one that is a * `$ref` that names nothing), the item goes with it, and so is never kept * without its auth. * * A scheme of a type core does not parse yet (`mutualTLS`) is not a * dependency: it is never in the parsed document, and its * `INVALID_SECURITY_SCHEME` error would remove every item that names it. */ export declare const toOperationsWithValidSecurity: ({ items, check }: ToOperationsWithValidSecurityArgs) => Item[]; export {};