Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await store.initProfile();
const canvas = document.querySelector(".a-canvas");
canvas.classList.add("a-hidden");
warmSerializeElement();
if (!window.WebAssembly) {
remountUI({ showWebAssemblyDialog: true });
return;
}
// If we are on iOS but we don't have the mediaDevices API, then we are likely in a Firefox or Chrome WebView,
// or a WebView preview used in apps like Twitter and Discord. So we show the dialog that tells users to open
// the room in the real Safari.
const detectedOS = detectOS(navigator.userAgent);
if (detectedOS === "iOS" && !navigator.mediaDevices) {
remountUI({ showSafariDialog: true });
return;
}
const hubId = qs.get("hub_id") || document.location.pathname.substring(1).split("/")[0];
console.log(`Hub ID: ${hubId}`);
const subscriptions = new Subscriptions(hubId);
if (navigator.serviceWorker) {
try {
navigator.serviceWorker
.register("/hub.service.js")
.then(() => {
navigator.serviceWorker.ready
await store.initProfile();
const canvas = document.querySelector(".a-canvas");
canvas.classList.add("a-hidden");
warmSerializeElement();
if (!window.WebAssembly) {
remountUI({ showWebAssemblyDialog: true });
return;
}
// If we are on iOS but we don't have the mediaDevices API, then we are likely in a Firefox or Chrome WebView,
// or a WebView preview used in apps like Twitter and Discord. So we show the dialog that tells users to open
// the room in the real Safari.
const detectedOS = detectOS(navigator.userAgent);
if (detectedOS === "iOS" && !navigator.mediaDevices) {
remountUI({ showSafariDialog: true });
return;
}
// HACK: On Safari for iOS & MacOS, if mic permission is not granted, subscriber webrtc negotiation fails.
// So we need to insist on microphone grants to continue.
const browser = detect();
if (["iOS", "Mac OS"].includes(detectedOS) && ["safari", "ios"].includes(browser.name)) {
try {
await navigator.mediaDevices.getUserMedia({ audio: true });
} catch (e) {
remountUI({ showSafariMicDialog: true });
return;
}
}
export function getBrowserEnvironmentType(): BrowserEnvironmentType {
const osName = detectBrowser.detectOS(navigator.userAgent).toLowerCase();
const browserName = detectBrowser.detect().name.toLowerCase();
return `${browserName}-${osName}` as BrowserEnvironmentType;
}