/** * Cross-platform utilities for Node.js and browser environments. * * Replaces Node-only APIs: * - `node:crypto` → Web Crypto API + @noble/hashes * - `Buffer` → TextEncoder / TextDecoder / Uint8Array helpers * * Also provides polyfill injections for third-party packages that * unconditionally reference Node/browser globals at module-load time * (e.g. @docknetwork/crypto-wasm → `Buffer`, snarkjs → * `URL.createObjectURL`). */ /** * Ensure `globalThis.Buffer` exists for third-party packages that * reference it at module-load time (e.g. @docknetwork/crypto-wasm). * * In Node.js `Buffer` is already a global; in browsers it is not. * Call this before any code that depends on `@docknetwork/crypto-wasm` * or other Node-oriented packages. */ export declare const ensureBufferPolyfill: (_placeholder?: undefined) => void; /** * Ensure `URL.createObjectURL` does not throw at module-load time. * * snarkjs (used by the Groth16 prover) calls `URL.createObjectURL(blob)` * at module-load time whenever `globalThis.Blob` exists, in order to * build a worker source string for its optional multi-thread path. * * In Cloudflare Workers `Blob` exists but `URL.createObjectURL` is a * stub that throws "URL.createObjectURL() is not implemented" when * invoked (and `nodejs_compat` does not add a real implementation). * Because `globalThis.Worker` is also absent in Workers, snarkjs * forces `singleThread = true` and never actually consumes the * returned URL — so a non-throwing placeholder is safe. * * In Node.js and browsers a real implementation exists and is left * untouched. */ export declare const ensureUrlCreateObjectUrlPolyfill: (_placeholder?: undefined) => void; /** Encode a string as UTF-8 Uint8Array. */ export declare const utf8ToBytes: (str: string) => Uint8Array; /** Decode UTF-8 bytes to a string. */ export declare const bytesToUtf8: (bytes: Uint8Array | ArrayBuffer) => string; /** Encode a hex string (with or without `0x` prefix) to Uint8Array. */ export declare const hexToBytes: (hex: string) => Uint8Array; /** Encode Uint8Array to hex string (no `0x` prefix). */ export declare const bytesToHex: (bytes: Uint8Array) => string; /** Encode a string to base64 (UTF-8 safe, works in browser and Node). */ export declare const toBase64: (source: string) => string; /** SHA-256 hash, returned as Uint8Array. */ export declare const sha256Bytes: (data: Uint8Array) => Uint8Array; /** SHA-256 hash, returned as hex string (no `0x` prefix). */ export declare const sha256Hex: (data: Uint8Array) => string; /** SHA-256 hash of a string, returned as base64. */ export declare const sha256Base64: (s: string) => string; /** Cryptographically secure random bytes (32 bytes by default). */ export declare const randomBytes: (length?: number) => Uint8Array; /** Cryptographically secure random bytes as hex string (no `0x` prefix). */ export declare const randomHex: (length?: number) => string; //# sourceMappingURL=platform.d.ts.map