import { CombinedHostRule, HostRule } from "../types/host-rules.js"; import "../types/index.js"; //#region lib/util/host-rules.d.ts /** * A {@link CombinedHostRule} returned by {@link find}, additionally reporting which of its `headers` came from an `admin` tier rule. * * `trustedHeaderNames` is deliberately not a field of `HostRule`, for the same reason `trustTier` is not: it must never be settable through configuration. */ export interface CombinedHostRuleWithTrustedHeaders extends CombinedHostRule { /** header names in `headers` that came from an `admin` tier rule (the self-hosted administrator's own config), and so already bypassed `allowedHeaders` at registration - `applyHostRule`'s request-time defence-in-depth must not re-check, and drop, them */ trustedHeaderNames?: string[]; } /** * Fields within `HostRule`s that must have their value registered for sanitising through `sanitize.addSecretForSanitizing()`. * * Kept in sync with `redactedFields` through tests. */ export declare const confidentialFields: (keyof HostRule)[]; export interface LegacyHostRule { hostName?: string; domainName?: string; baseUrl?: string; host?: string; endpoint?: string; } export declare function migrateRule(rule: LegacyHostRule & HostRule): HostRule; /** * Enforce the `allowedHeaders` allowlist on a set of host rules. * * Loudly remove anything that's not permitted, logging a WARN. Used by `add()` for an untrusted rule's `headers`; a `trusted` rule's are exempt, so never reach this. * * Headers that survive this allowlist are still subject to how {@link find} combines them: an admin's headers for a host are applied over those of any repository or preset rule matching the same request, so a repository can neither drop nor substitute them. */ export declare function filterAllowedHeaders(rules: HostRule[]): HostRule[]; export interface AddHostRuleOptions { /** * Whether this rule comes from the self-hosted administrator's own configuration, rather than from repository or preset config. * * Registers the rule into the `admin` tier - see {@link HostRuleTrustTier}. */ trusted?: boolean; /** * Whether this rule comes from organization-inherited config which the administrator has opted into trusting, through `inheritConfigTrusted`. * * Registers the rule into the `inherit` tier - see {@link HostRuleTrustTier}. Ignored when `trusted` is also set. */ inherited?: boolean; } export declare function add(params: HostRule, options?: AddHostRuleOptions): void; export interface HostRuleSearch { hostType?: string; url?: string; readOnly?: boolean; } export declare function matchesHost(url: string, matchHost: string): boolean; export declare function find(search: HostRuleSearch): CombinedHostRuleWithTrustedHeaders; export declare function hosts({ hostType }: { hostType: string; }): string[]; export declare function hostType({ url }: { url: string; }): string | null; export declare function findAll({ hostType }: { hostType: string; }): HostRule[]; /** * @returns a deep copy of all known host rules without any filtering */ export declare function getAll(): HostRule[]; export declare function clear(): void; //#endregion //# sourceMappingURL=host-rules.d.ts.map