/** * Byte and text conversions, written out rather than taken from a platform. * * This SDK runs in a browser and in Node, and the obvious helpers differ between * them: `btoa` is browser-first and deprecated in Node, `Buffer` does not exist * in a browser, and feature-detecting between the two puts an environment branch * in the middle of something that has to produce identical bytes everywhere. * These are a few lines each and have no such branch. */ /** UTF-8 bytes of a string. `TextEncoder` is global in Node 18+ and every browser. */ export declare const utf8: (value: string) => Uint8Array; /** * A standalone `ArrayBuffer` holding a copy of these bytes. * * Web Crypto takes `BufferSource`, and a `Uint8Array` is not always one as far as * the type system is concerned: since TypeScript 5.7 the array is generic in its * backing buffer, and the `ArrayBufferLike` that `TextEncoder` hands back could * in principle be a `SharedArrayBuffer`, which `BufferSource` excludes. Copying * into a buffer of known provenance settles it without an assertion, and without * putting a generic type parameter into the emitted declarations -- which would * make this package fail to typecheck for anyone on an older compiler. */ export declare const toArrayBuffer: (bytes: Uint8Array) => ArrayBuffer; /** Standard base64, with padding -- the form `CryptoJS`'s default formatter emits. */ export declare const toBase64: (bytes: Uint8Array) => string; /** Lower-case hex, two characters per byte. */ export declare const toHex: (bytes: Uint8Array) => string; /** * Cryptographically random bytes. * * `crypto.getRandomValues` is the one API that is present and seeded properly in * both environments -- global in Node 18+ and in browsers. `Math.random` is not * an acceptable substitute here: the value it would produce is the key under * which a customer's phone numbers are encrypted. */ export declare const randomBytes: (length: number) => Uint8Array; /** Web Crypto, or a clear error naming what is missing rather than a `TypeError`. */ export declare const subtle: () => SubtleCrypto;