Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.isBrowser = function (name) {
if (typeof (window) === 'undefined') return false
const satifyObject = {}
if (name === 'ios') { // bowser can't directly name iOS Safari
satifyObject.mobile = { safari: '>=0' }
} else {
satifyObject[name] = '>=0'
}
return bowser.getParser(window.navigator.userAgent).satisfies(satifyObject)
}
import moment from 'moment';
import TTLCache from './TTLCache';
import Bowser from 'bowser';
const browserEnv = Bowser.getParser(window.navigator.userAgent);
const onlyLocalStorage = browserEnv.satisfies({
Linux: {
Chrome: '>0'
},
'Chrome OS': {
Chrome: '>0'
}
});
global.browser = require('webextension-polyfill');
// constants
const ELIXR_CLIENT_ID = 'd2158e591bb347931751bef151ee3bf3e5c8cb9608924a7a';
const CURRENT_USER_URL = 'https://mixer.com/api/v1/users/current';
const PAGE_LIMIT = 100;
const FOLLOWS_URL = `https://mixer.com/api/v1/users/{userId}/follows?fields=id,token,name,type,user&where=online:eq:true&limit=${PAGE_LIMIT}`;
if (typeof navigator === 'object' && navigator.product === 'ReactNative')
{
if (typeof RTCPeerConnection === 'undefined')
{
logger.warn('detectDevice() | unsupported ReactNative without RTCPeerConnection');
return;
}
return ReactNative;
}
// Browser.
else if (typeof navigator === 'object' && typeof navigator.userAgent === 'string')
{
const ua = navigator.userAgent;
const browser = bowser.getParser(ua);
const engine = browser.getEngine();
// Chrome and Chromium.
if (browser.satisfies({ chrome: '>=74', chromium: '>=74' }))
{
return Chrome74;
}
else if (browser.satisfies({ chrome: '>=70', chromium: '>=70' }))
{
return Chrome70;
}
else if (browser.satisfies({ chrome: '>=67', chromium: '>=67' }))
{
return Chrome67;
}
else if (browser.satisfies({ chrome: '>=55', chromium: '>=55' }))
import bowser from 'bowser'
const parser = bowser.getParser(window.navigator.userAgent)
const platformType = parser.getPlatformType()
export const isHandheld = platformType === 'mobile' || platformType === 'tablet'
export const isFirefox = parser.getBrowserName() === 'Firefox'
browserVersionCheck() {
const activeBrowser = bowser.getParser(window.navigator.userAgent);
const isSupported = activeBrowser.satisfies(MINIMUM_BROWSER_VERSIONS);
if (!isSupported) {
notify.show(t("error.outdatedBrowser"), "warning");
}
}
fontSize: 50,
chars: 2,
userAgent: typeof window !== 'undefined' && window.navigator && window.navigator.userAgent,
...options
};
let backgroundColors: string[] = [];
let isInternetExplorer =
options.userAgent &&
Bowser.getParser(options.userAgent).satisfies({
ie: '>0',
edge: '>0'
});
let isSafari =
options.userAgent &&
Bowser.getParser(options.userAgent).satisfies({
safari: '>0'
});
Object.keys(Color.collection).forEach((backgroundColor: keyof ColorCollection) => {
if (
options.backgroundColors === undefined ||
options.backgroundColors.length === 0 ||
options.backgroundColors.indexOf(backgroundColor) !== -1
) {
backgroundColors.push(Color.collection[backgroundColor][options.backgroundColorLevel]);
}
});
return function(random: Random) {
let backgroundColor = random.pickone(backgroundColors);
let seedInitials = (initials(random.seed.trim()) as string).toLocaleUpperCase().slice(0, options.chars);
async function getBrowser() {
let name, version;
try {
({name, version} = await browser.runtime.getBrowserInfo());
} catch (e) {}
if (!name) {
({name, version} = Bowser.getParser(
window.navigator.userAgent
).getBrowser());
}
name = name.toLowerCase();
return {name, version};
}
function shouldEnableColorDomain() {
const OS_NAMES_TO_DETECT = ['windows', 'ios'];
const parser = Bowser.getParser(window.navigator.userAgent);
const currentOS = parser.getOSName(true);
return OS_NAMES_TO_DETECT.includes(currentOS);
}
componentDidMount() {
if( typeof document === 'undefined' ) return;
let ua = bowser.getParser(window.navigator.userAgent)
let {browser, platform, os} = ua.parsedResult;
this.setState({
browser: `${browser.name} ${browser.version}`,
os: `${os.name} ${os.versionName ? os.versionName : os.version}`,
platform: platform.type
})
}
constructor({network}) {
this.network = network;
this.environment = Bowser.getParser(window.navigator.userAgent);
this.failureText = '';
this.failureCode = '';
}