import type { UrlMatcher, UrlMatcherType } from '../interfaces/Entry.mjs'; /** * The parts of a url that matching needs, normalised once so every matcher * sees the same thing. */ export interface UrlMatchContext { /** The full, normalised url. Default ports are stripped. */ href: string; /** Scheme, host and port. */ origin: string; /** Lowercased, with any trailing dot removed. */ hostname: string; pathname: string; } /** * How specific each matcher type is, used to rank entries that all match the * same url. Higher is more specific, and so a better guess. * * `Regex` sits below `UrlPrefix` because two regexes cannot be compared for * narrowness statically, but above the host-level types because writing one at * all is a deliberate act. */ export declare const MATCHER_SPECIFICITY: Record; /** * Parses a url into the shape the matchers consume. * * This deliberately uses the native `URL` rather than the injected * `UrlParserLib`: that interface is otpauth-shaped (`path` pre-split, no * origin, no port) and widening it would break every implementer. It exists * for exotic engines importing otpauth uris, which is not this code path. * @param url - The url to parse. * @returns The parsed context, or null when the url cannot be matched against. */ export declare const buildUrlMatchContext: (url: string) => UrlMatchContext | null; /** * Decides whether a single matcher covers a url. * @param matcher - The matcher to apply. * @param ctx - The url being matched. * @returns True when the matcher covers the url. */ export declare const matcherMatchesUrl: (matcher: UrlMatcher, ctx: UrlMatchContext) => boolean; /** * Finds the matcher that makes an entry belong to a url. * * When several of an entry's matchers cover the url, the most specific one * wins rather than the first. An entry carrying both `github.com` and * `https://github.com/login` should report the login-page match on the login * page: it is the better thing to show the user, and it is what ranks the * entry correctly against the others. Ties keep the order the user chose. * @param matchers - The entry's matchers, in the order the user put them. * @param ctx - The url being matched. * @returns The most specific matcher covering the url, or null when none does. */ export declare const findMatcherForUrl: (matchers: UrlMatcher[], ctx: UrlMatchContext) => UrlMatcher | null; /** * Proposes the matchers to attach to an entry for a given site. * * The suggestion is the full hostname, which is always safe: it can be * narrower than the user wanted, never broader. Narrowing `www.bbc.co.uk` to * `bbc.co.uk` would need a public suffix list, which the lib deliberately does * not carry; a consumer that wants it can offer a better default itself. * @param url - The url to suggest matchers for. * @returns The suggested matchers, or an empty array for an unmatchable url. */ export declare const suggestMatchersForUrl: (url: string) => UrlMatcher[];