/** * Base64 codec tiers, and the tables they share. * * Split out of the public `Base64` module for the same reason the hex codec is: * a runtime selects one tier at import, so the others are unreachable from a * test unless they can be called directly. Keeping them here lets the * conformance suite compare every tier a runtime can execute, without widening * `Base64`'s public surface. * * @internal */ import * as Errors from '../../Errors.js'; import type * as Bytes from '../../Bytes.js'; /** @internal */ export type Options = { /** Whether to pad the encoded string. */ pad?: boolean | undefined; /** Whether to use the URL-safe alphabet. */ url?: boolean | undefined; }; /** * Encodes via `Uint8Array.prototype.toBase64`, where the runtime has it. * `undefined` otherwise, so the conformance suite can ask whether this tier * exists rather than inferring it from the runtime. * * @internal */ export declare const fromBytesNative: ((value: Bytes.Bytes, options?: Options) => string) | undefined; /** * Encodes in plain JavaScript, for runtimes without the native method. * * @internal */ export declare function fromBytesLoop(value: Bytes.Bytes, options?: Options): string; /** * Encodes with whichever tier this runtime provides. * * @internal */ export declare function fromBytes(value: Bytes.Bytes, options?: Options): string; /** * `Uint8Array.fromBase64` is deliberately unused. * * Its `alphabet` option is strict and mutually exclusive -- `base64` refuses * `-`/`_`, `base64url` refuses `+`/`/` -- while ox decodes either alphabet * transparently. There is no single native call with that behavior, so matching * it would mean normalizing the string first or trying both alphabets and * throwing on one. Both cost more than they would save, and neither has been * measured; the loop is the only decode tier until one is. */ /** * Decodes in plain JavaScript, for runtimes without the native method. * * @internal */ export declare function toBytesLoop(value: string, bodyEnd: number): Bytes.Bytes; /** * Decodes with whichever tier this runtime provides. * * @internal */ export declare function toBytes(value: string): Bytes.Bytes; /** Thrown when a Base64 string contains an invalid character. */ export declare class InvalidCharacterError extends Errors.BaseError { readonly name = "Base64.InvalidCharacterError"; constructor({ character }: { character: string; }); } /** Thrown when a Base64 string has an impossible length. */ export declare class InvalidLengthError extends Errors.BaseError { readonly name = "Base64.InvalidLengthError"; constructor({ length }: { length: number; }); } /** Thrown when a Base64 string contains too many trailing `=` padding characters. */ export declare class InvalidPaddingError extends Errors.BaseError { readonly name = "Base64.InvalidPaddingError"; constructor({ padding }: { padding: number; }); } //# sourceMappingURL=base64.d.ts.map