import type { IAccessInfo, IGrantsListItem, IQueryInfo } from '../types/index.js'; /** * Per-instance name/error policy threaded into the validation helpers from the * engine. Defaults are secure: ASCII charset, redacted (safe) error messages. */ export interface INameOptions { /** Allowed-name pattern (`engine.charset`). Defaults to the ASCII set. */ charset?: RegExp; /** `engine.safeErrors` — when `true` (default), messages omit dynamic input. */ safeErrors?: boolean; /** `engine.errorCodePrefix` — prepended to every `err.code` (default `''`). */ errorCodePrefix?: string; } /** * Checks whether the given access info can be commited to grants model. * @param info */ export declare function isInfoFulfilled(info: IAccessInfo | IQueryInfo): boolean; /** * Validates and normalizes a single name (role, resource or action segment). * Case-preserving; trims ends; allows the configured charset (ASCII by default). * Always rejects the structural separators (`/` `:`), the `$` sigil and the * reserved prototype-pollution keywords (`__proto__`, `prototype`, * `constructor`). * * With `allowQualified` (roles/resources) a single `/` is permitted, * splitting a `group/role` or `category/resource` name; each side must be a * valid segment and the prefix may not be the reserved `_` sentinel. * * @throws {AccessControlError} - If the name is not a valid string. */ export declare function normalizeName(name: unknown, allowQualified?: boolean, opts?: INameOptions): string; /** * Boolean form of {@link normalizeName} — used to test/skip keys (e.g. to skip * `$extend` while iterating a role's resources). * * @param name - Name to be checked. * @param [throwOnInvalid=true] - Whether to throw if the name is not valid. * @param [allowQualified=false] - Whether a single `/` group/category qualifier * is permitted. * @param [opts] - Charset / safe-errors policy. * @throws {AccessControlError} - If `throwOnInvalid` and the name is invalid. */ export declare function validName(name: string, throwOnInvalid?: boolean, allowQualified?: boolean, opts?: INameOptions): boolean; /** * Checks whether all of the given name(s) are valid. * * @param list - Name(s) to be checked. * @param [throwOnInvalid=true] - Whether to throw if a name is not valid. * @param [allowQualified=false] - Whether a single `/` qualifier is permitted. * @param [opts] - Charset / safe-errors policy. * @throws {AccessControlError} - If `throwOnInvalid` and a name is invalid. */ export declare function hasValidNames(list: string | string[], throwOnInvalid?: boolean, allowQualified?: boolean, opts?: INameOptions): boolean; /** * Normalizes the action (and possession) in the given query/access info. * Action may carry possession via the `:own`/`:any` convention (e.g. * `'create:own'`) or possession may be a separate property. Possession defaults * to `'any'`. Any valid name is a permitted action; the CRUD `Action` * constants are just convenience. * * @throws {AccessControlError} - If invalid action/possession found. */ export declare function normalizeActionPossession(info: IQueryInfo | IAccessInfo | Partial, opts?: INameOptions): IQueryInfo | IAccessInfo; /** * Normalizes the roles, resource and action in the given `IQueryInfo`. * @throws {AccessControlError} - If invalid role/resource/action found. */ export declare function normalizeQueryInfo(query: IQueryInfo, opts?: INameOptions): IQueryInfo; /** * Normalizes the roles, resources and attributes in the given `IAccessInfo`. * Attributes default to `['*']` when omitted (a deny rule with omitted * attributes therefore denies **all** attributes; deny-overrides). * * @param access * @param [all=false] - Whether to also validate/normalize `action`/`possession`. * @param [opts] - Charset / safe-errors policy. * @throws {AccessControlError} - If invalid role/resource found. */ export declare function normalizeAccessInfo(access: IAccessInfo | IGrantsListItem, all?: boolean, opts?: INameOptions): IAccessInfo; /** * Used to re-set (prepare) the `attributes` of an `IAccessInfo` object when it * is first initialized via the `.grant()` / `.deny()` chain. Omitted * attributes default to `['*']`; an explicit `[]` (or `''`) is kept, as every * other authoring path keeps it — an empty allow-list never widens to * everything. * @param access */ export declare function resetAttributes(access: IAccessInfo): IAccessInfo; //# sourceMappingURL=validation.d.ts.map