@akala/core
Version:
98 lines (97 loc) • 3.96 kB
TypeScript
import { IsomorphicBuffer } from "./helpers.js";
/**
* Calculates the decoded byte length of a Base64 string.
* @param sBase64 The Base64 encoded string.
* @param nBlocksSize Optional size to round up to (for buffer alignment).
* @returns The decoded byte length.
*/
export declare function base64ByteLength(sBase64: string, nBlocksSize?: number): number;
/**
* Decodes a Base64 string into a Uint8Array.
* @param sBase64 The Base64 encoded string.
* @returns The decoded byte array.
*/
export declare function base64DecToArr(sBase64: string): Uint8Array<ArrayBuffer> | Buffer<ArrayBuffer>;
/**
* Encodes an Uint8Array to Base64URL format.
* @param aBytes The byte array to encode.
* @returns The Base64URL encoded string.
*/
export declare function base64UrlEncArr(aBytes: Uint8Array): string;
/**
* Encodes an ArrayBuffer to Base64URL format.
* @param aBytes The ArrayBuffer to encode.
* @returns The Base64URL encoded string.
*/
export declare function base64UrlEncArrBuff(aBytes: ArrayBuffer): string;
/**
* Encodes an ArrayBuffer/Uint8Array to Base64URL format.
* @param aBytes The byte array to encode.
* @returns The Base64URL encoded string.
*/
export declare function base64UrlEncIsomorphicBuffer(aBytes: IsomorphicBuffer): string;
/**
* Decodes a Base64URL string into an ArrayBuffer/Uint8Array.
* @param s The Base64URL encoded string.
* @returns The decoded byte array.
*/
export declare function base64UrlDecToArr(s: string): Uint8Array<ArrayBuffer> | Buffer<ArrayBuffer>;
/**
* Extracts the binary content from a PEM-formatted private key.
* @param pem The PEM string containing the private key.
* @returns The decoded binary content of the private key.
*/
export declare function extractPrivateKey(pem: string): Uint8Array<ArrayBuffer> | Buffer<ArrayBuffer>;
/**
* Extracts the binary content from a PEM-formatted public key.
* @param pem The PEM string containing the public key.
* @returns The decoded binary content of the public key.
*/
export declare function extractPublicKey(pem: string): Uint8Array<ArrayBuffer> | Buffer<ArrayBuffer>;
/**
* Encodes an ArrayBuffer/Uint8Array to Base64 string.
* @param aBytes The byte array to encode.
* @param nBlocksSize Optional size for line breaks in the output.
* @returns The Base64 encoded string.
*/
export declare function base64EncArr(aBytes: Uint8Array, nBlocksSize?: number): string;
/**
* Encodes an ArrayBuffer/Uint8Array to Base64 string.
* @param aBytes The byte array to encode.
* @param nBlocksSize Optional size for line breaks in the output.
* @returns The Base64 encoded string.
*/
export declare function base64EncArrBuff(aBytes: ArrayBuffer, nBlocksSize?: number): string;
/**
* Encodes an ArrayBuffer/Uint8Array to Base64 string.
* @param aBytes The byte array to encode.
* @param nBlocksSize Optional size for line breaks in the output.
* @returns The Base64 encoded string.
*/
export declare function base64EncIsomorphicBuffer(aBytes: IsomorphicBuffer, nBlocksSize?: number): string;
/**
* Converts a UTF-8 encoded byte array to a JavaScript string.
* @param aBytes The UTF-8 encoded byte array.
* @returns The decoded string.
*/
export declare function UTF8ArrToStr(aBytes: Uint8Array): string;
/**
* IsomorphicBuffer UTF-8 -> string (same name/signature).
*/
/**
* Converts a UTF-8 encoded byte array to a JavaScript string.
* @param aBytes The UTF-8 encoded byte array.
* @returns The decoded string.
*/
export declare function UTF8IsomorphicBufferToStr(aBytes: IsomorphicBuffer): string;
/**
* Compute UTF-8 byte length for a JS string (same name/signature).
* Uses correct UTF-8 ranges (1–4 bytes).
*/
export declare function strUTF8ByteLength(sDOMStr: string): number;
/**
* Converts a JavaScript string to a UTF-8 encoded ArrayBuffer.
* @param sDOMStr The input string to encode.
* @returns The UTF-8 encoded ArrayBuffer.
*/
export declare function strToUTF8Arr(sDOMStr: string): Uint8Array<ArrayBuffer>;