import type { ProviderName } from '../types.js'; export interface KeyRule { /** Human-readable statement of what was violated. */ reason: string; /** The provider whose limit this is, or null when every provider shares it. */ provider: ProviderName | null; } /** * The first rule `key` breaks for this set of providers, or null when it is * usable everywhere. * * Provider-aware on purpose: the 64-byte ceiling is the key-value store's * alone, and rejecting a 100-character key for an app that only configured * Drive would be a false alarm. */ export declare function checkKey(key: string, providers: readonly ProviderName[]): KeyRule | null; /** Throws {@link ErrorCode.INVALID_KEY} when `key` is unusable. */ export declare function assertKey(key: string, providers: readonly ProviderName[]): void; /** * Rewrites an arbitrary string into a key that passes {@link checkKey}. * * For callers whose keys come from somewhere they do not control - a file name, * a user-entered label, an id from another system. * * A key that is already legal and fits in `maxBytes` comes back unchanged. * Anything else has its illegal characters replaced with `-`, is truncated to * leave room, and gets a 64-bit hash of the *original* string appended as * `--<14 base36 chars>`. The hash is what keeps distinct inputs distinct: * replacement alone maps `"a b"` and `"a-b"` onto the same key, and truncation * alone maps every long key with a shared prefix onto one. * * A legal input that happens to end in that suffix shape is hashed too, so a * passed-through key can never equal a rewritten one. The mapping is therefore * injective up to a 64-bit hash collision. * * Throws a `RangeError` when `maxBytes` is smaller than the suffix itself * ({@link SANITIZED_SUFFIX_BYTES}), since no output could then both fit and * stay distinct. */ export declare function sanitizeKey(raw: string, maxBytes?: number): string; /** `--` plus two zero-padded 7-character base36 halves. */ export declare const SANITIZED_SUFFIX_BYTES = 16; //# sourceMappingURL=keys.d.ts.map