diff --git a/js/components/src/crypto-polyfill.native.tsx b/js/components/src/crypto-polyfill.native.tsx index 6b2976fc..e1c13fca 100644 --- a/js/components/src/crypto-polyfill.native.tsx +++ b/js/components/src/crypto-polyfill.native.tsx @@ -13,7 +13,14 @@ if (!rnqc && !expoCrypto) { throw new Error( "Livestreaming requires one of react-native-quick-crypto or expo-crypto", ); -} else if (!rnqc && expoCrypto) { +} +if (rnqc) { + console.log("Using react-native-quick-crypto for crypto polyfill"); + // we import this in the main app, but in case this file is used standalone: + globalThis.crypto = rnqc as any as Crypto; +} +if (expoCrypto) { + console.log("Using expo-crypto for crypto polyfill"); // @atproto/crypto dependencies expect crypto.getRandomValues to be a function if (typeof globalThis.crypto === "undefined") { globalThis.crypto = {} as any; diff --git a/js/components/src/livestream-store/stream-key.tsx b/js/components/src/livestream-store/stream-key.tsx index 8ab14443..90aa96a9 100644 --- a/js/components/src/livestream-store/stream-key.tsx +++ b/js/components/src/livestream-store/stream-key.tsx @@ -1,3 +1,6 @@ +// Just to be 100% sure it's imported successfully +import "../crypto-polyfill"; + import { bytesToMultibase, Secp256k1Keypair } from "@atproto/crypto"; import { useEffect, useState } from "react"; import { Platform } from "react-native";