UNPKG

@maximai/maxim-js

Version:

Maxim AI JS SDK. Visit https://getmaxim.ai for more info.

43 lines (42 loc) 1.64 kB
/** * Secure random number generation utilities that work across platforms. * On React Native, will use expo-crypto when available for better security. * Falls back to platform-appropriate alternatives when needed. */ /** * Generate cryptographically secure random bytes asynchronously. * Preferred method on React Native when expo-crypto is available. * * @param size Number of bytes to generate * @returns Promise resolving to secure random bytes */ export declare function getSecureRandomBytesAsync(size: number): Promise<Uint8Array>; /** * Generate random bytes synchronously. * On React Native without expo-crypto, this uses Math.random (less secure). * Use getSecureRandomBytesAsync() when possible for better security. * * @param size Number of bytes to generate * @returns Random bytes (secure on Node.js, less secure on RN without expo-crypto) */ export declare function getRandomBytes(size: number): Uint8Array; /** * Check if secure random number generation is available on the current platform. * * @returns True if cryptographically secure RNG is available */ export declare function isSecureRandomAvailable(): boolean; /** * Generate a cryptographically secure random hex string. * * @param length Length of the hex string (will use length/2 random bytes) * @returns Promise resolving to hex string */ export declare function getSecureRandomHexAsync(length: number): Promise<string>; /** * Generate a random hex string synchronously. * * @param length Length of the hex string (will use length/2 random bytes) * @returns Hex string */ export declare function getRandomHex(length: number): string;