/** * Shared helpers that work in both Node and browser (no Buffer or Node crypto). * Uses atob/btoa (Node 16+ and browser) and TextEncoder/TextDecoder. */ /** * Encodes a UTF-8 string to base64 (environment-agnostic). */ export declare function bytesToBase64(bytes: Uint8Array): string; /** * Decodes base64 to Uint8Array (environment-agnostic). */ export declare function base64ToBytes(base64: string): Uint8Array; /** * Converts PEM string to binary (Uint8Array) for Web Crypto importKey. */ export declare function pemToBinary(pem: string): Uint8Array; /** * Wraps binary in PEM headers (SPKI for public, PKCS#8 for private). */ export declare function binaryToPem(binary: Uint8Array, type: 'public' | 'private'): string; /** * Decodes a base64-encoded string into a UTF-8 string. * * @param {string} str - The base64-encoded string to decode. * @returns {string} The decoded UTF-8 string. * @throws {Error} If the input string cannot be decoded. */ export declare const decode: (str: string) => string; /** * Encodes a UTF-8 string into a base64-encoded string. * * @param {string} str - The UTF-8 string to encode. * @returns {string} The base64-encoded string. * @throws {Error} If the input string cannot be encoded. */ export declare const encode: (str: string) => string; /** * Checks headers/footers only; does not parse or validate key material. Checks a PEM-formatted public key. * * @param {string} key - The key string to validate. * @returns {boolean} True if the key has PEM public key, false otherwise. */ export declare function isValidPEMPublicKey(key: unknown): boolean; /** * Checks headers/footers only; does not parse or validate key material. Checks a PEM-formatted private key. * * @param {string} key - The key string to validate. * @returns {boolean} True if the key has PEM private key, false otherwise. */ export declare function isValidPEMPrivateKey(key: unknown): boolean; /** Checks a complete SPKI/PKCS#8 PEM envelope before native key parsing. */ export declare function hasPEMEnvelope(key: unknown, type: 'public' | 'private'): key is string; /** * Validates if a string is a valid PEM key (either public or private). * * @param {string} key - The key string to validate. * @returns {boolean} True if the key has PEM key, false otherwise. */ export declare function isValidPEMKey(key: unknown): boolean; /** * Splits a string into chunks for encryption. * RSA can only encrypt data smaller than the key modulus minus padding. * For RSA-OAEP with SHA-1 and a 2048-bit key, this is 214 bytes. * * @param {string} text - The text to split into chunks. * @param {number} chunkSize - The size of each chunk in bytes (default 214 for 2048-bit RSA-OAEP/SHA-1). * @returns {string[]} Array of text chunks. */ export declare function splitIntoChunks(text: string, chunkSize?: number): string[]; /** * Joins chunks back into a single string. * * @param {string[]} chunks - Array of text chunks. * @returns {string} The combined text. */ export declare function joinChunks(chunks: string[]): string;