Live video on the AT Protocol
1// awkward use of require()? you betcha. but import() with Metro causes it to try and 2// resolve the package at compile-time even if not installed, so here we are. 3let rnqc: any | null = null; 4let expoCrypto: any | null = null; 5try { 6 rnqc = require("react-native-quick-crypto"); 7} catch (err) {} 8try { 9 expoCrypto = require("expo-crypto"); 10} catch (err) {} 11 12if (!rnqc && !expoCrypto) { 13 throw new Error( 14 "Livestreaming requires one of react-native-quick-crypto or expo-crypto", 15 ); 16} else if (!rnqc && expoCrypto) { 17 // @atproto/crypto dependencies expect crypto.getRandomValues to be a function 18 if (typeof globalThis.crypto === "undefined") { 19 globalThis.crypto = {} as any; 20 } 21 if (typeof globalThis.crypto.getRandomValues === "undefined") { 22 globalThis.crypto.getRandomValues = expoCrypto.getRandomValues; 23 } 24}