/** * Bitstring Utilities for StatusList2021 * * Implements GZIP compression + base64url encoding for efficient status lists. * Per W3C StatusList2021 spec, each bit represents credential status: * - 0: Not revoked/suspended * - 1: Revoked/suspended * * Related Spec: W3C StatusList2021 * Python Reference: Delegation-Revocation.md */ /** * Platform-agnostic bitstring operations * * Implementations must provide compression/decompression functions * since these are platform-specific (Node.js uses zlib, Cloudflare uses CompressionStream) */ /** * Compression function interface */ export interface CompressionFunction { /** * Compress data using GZIP * @param data - Data to compress * @returns Compressed data */ compress(data: Uint8Array): Promise; } /** * Decompression function interface */ export interface DecompressionFunction { /** * Decompress GZIP data * @param data - Compressed data * @returns Decompressed data */ decompress(data: Uint8Array): Promise; } /** * Bitstring encoder/decoder * * Manages a bitstring for credential status tracking. * Platform-agnostic - requires compression functions to be injected. */ export declare class BitstringManager { private compressor; private decompressor; private bits; private size; constructor(size: number, compressor: CompressionFunction, decompressor: DecompressionFunction); /** * Set a bit at a specific index * * @param index - The bit index (0-based) * @param value - true to set (revoked), false to clear (active) */ setBit(index: number, value: boolean): void; /** * Get a bit at a specific index * * @param index - The bit index (0-based) * @returns true if set (revoked), false if clear (active) */ getBit(index: number): boolean; /** * Get all set bit indices * * @returns Array of indices where bits are set to 1 */ getSetBits(): number[]; /** * Encode bitstring to base64url (GZIP compressed) * * Per StatusList2021 spec: * 1. GZIP compress the bitstring * 2. Base64url encode the compressed data * * @returns Base64url-encoded compressed bitstring */ encode(): Promise; /** * Decode base64url bitstring (GZIP compressed) * * @param encodedList - Base64url-encoded compressed bitstring * @returns BitstringManager instance */ static decode(encodedList: string, compressor: CompressionFunction, decompressor: DecompressionFunction): Promise; /** * Get the raw bitstring */ getRawBits(): Uint8Array; /** * Get the size (number of bits) */ getSize(): number; /** * Base64url encode (RFC 4648) * * Platform-agnostic implementation. */ private base64urlEncode; /** * Base64url decode (RFC 4648) */ private static base64urlDecode; /** * Convert bytes to base64 * * Platform-agnostic implementation (works in Node and browsers/Cloudflare) */ private bytesToBase64; /** * Convert base64 or base64url to bytes * Handles both standard base64 (+/) and base64url (-_) formats */ private static base64ToBytes; /** * Create a bitstring from a list of indices to set * * @param size - Total size of the bitstring * @param setBits - Indices to set to 1 * @param compressor - Compression function * @param decompressor - Decompression function * @returns BitstringManager instance */ static fromSetBits(size: number, setBits: number[], compressor: CompressionFunction, decompressor: DecompressionFunction): BitstringManager; } /** * Helper to check if an index is set in an encoded status list * * Convenience function for quick status checks without creating a full manager. * * @param encodedList - Base64url-encoded compressed bitstring * @param index - The bit index to check * @param decompressor - Decompression function * @returns true if bit is set (revoked), false otherwise */ export declare function isIndexSet(encodedList: string, index: number, decompressor: DecompressionFunction): Promise; //# sourceMappingURL=bitstring.d.ts.map