Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const isChromeOS = bowser.chromeos === true;
// Device flags
const isPhone = bowser.mobile === true;
const isTablet = bowser.tablet === true;
const isMobile = isPhone || isTablet;
const isDesktop = !isMobile;
const isiPhone = isiOS && bowser.iphone === true;
const isiPad = isiOS && bowser.ipad === true;
const isiPod = isiOS && bowser.ipod === true;
// Browser flags
const isChrome = bowser.chrome === true;
const isFirefox = bowser.firefox === true;
const isSafari = bowser.safari === true;
const isEdge = bowser.msedge === true;
const isIE = bowser.msie === true;
const isOpera = bowser.opera === true;
const checkDevice = () => {
if (isPhone) return 'phone';
if (isTablet) return 'tablet';
if (isDesktop) return 'desktop';
return '';
};
const checkOSName = () => {
if (isiOS) return 'ios';
if (isAndroid) return 'android';
if (isFirefoxOS) return 'firefoxos';
if (isWindowsPhone) return 'windowsphone';
if (isBlackberry) return 'blackberry';
export default function applyVariablesToNode () {
if (customPropertiesSupported() &&
!(bowser.msedge && bowser.version >= 15)) { // polyfill edge 15 until improved css variable support
applyVariablesToNodeStyle.apply(this, arguments)
} else {
applyVariablesPolyfillToNode.apply(this, arguments)
}
}
else
buttonHtml = `<button id="${this.unsubscribeButtonSelectorId}" class="action" type="button">${this.bell.options.text['dialog.main.button.unsubscribe']}</button>`;
contents = `<h1>${this.bell.options.text['dialog.main.title']}</h1><div class="divider"></div><div class="push-notification">${notificationIconHtml}<div class="push-notification-text-container"><div class="push-notification-text push-notification-text-short"></div><div class="push-notification-text"></div><div class="push-notification-text push-notification-text-medium"></div><div class="push-notification-text"></div><div class="push-notification-text push-notification-text-medium"></div></div></div><div class="action-container">${buttonHtml}</div>${footer}`;
}
else if (this.bell.state === Bell.STATES.BLOCKED) {
let imageUrl = null;
if (bowser.chrome) {
if (!bowser.mobile && !bowser.tablet)
imageUrl = '/bell/chrome-unblock.jpg';
}
else if (bowser.firefox)
imageUrl = '/bell/firefox-unblock.jpg';
else if (bowser.safari)
imageUrl = '/bell/safari-unblock.jpg';
else if (bowser.msedge)
imageUrl = '/bell/edge-unblock.png';
let instructionsHtml = '';
if (imageUrl) {
imageUrl = SdkEnvironment.getOneSignalApiUrl().origin + imageUrl;
instructionsHtml = `<a href="${imageUrl}"><img src="${imageUrl}"></a>`;
}
if ((bowser.mobile || bowser.tablet) && bowser.chrome) {
instructionsHtml = `<ol><li>Access <strong>Settings</strong> by tapping the three menu dots <strong>⋮</strong></li><li>Click <strong>Site settings</strong> under Advanced.</li><li>Click <strong>Notifications</strong>.</li><li>Find and click this entry for this website.</li><li>Click <strong>Notifications</strong> and set it to <strong>Allow</strong>.</li></ol>`;
}
contents = `<h1>${this.bell.options.text['dialog.blocked.title']}</h1><div class="divider"></div><div class="instructions"><p>${this.bell.options.text['dialog.blocked.message']}</p>${instructionsHtml}</div>${footer}`;
}
if (this.nestedContentSelector) {
addDomElement(this.nestedContentSelector, 'beforeend', contents);
}
getBrowserType(): BrowserType {
if (bowser.chrome) {
return BrowserType.Chrome;
} else if (bowser.firefox) {
return BrowserType.Firefox;
} else if (bowser.opera) {
return BrowserType.Opera;
} else if (bowser.msedge) {
return BrowserType.Edge;
} else if (bowser.safari) {
return BrowserType.Safari;
} else {
return BrowserType.Other;
}
},
getOperatingSystem(): OperatingSystemType {
export function signAsync (data, privateKey, privateKeyPassword = new Buffer(0)) {
checkIsBuffer(data, 'data');
checkIsBuffer(privateKey, 'privateKey');
checkIsBuffer(privateKeyPassword, 'privateKeyPassword');
if (browser.msie || browser.msedge) {
return new Promise((resolve, reject) => {
try {
resolve(sign(data, privateKey, privateKeyPassword));
} catch (e) {
reject(e.message);
}
});
} else {
return CryptoWorkerApi.sign(
toBase64(data),
toBase64(privateKey),
toBase64(privateKeyPassword))
.then(base64ToBuffer)
.catch((e) => throwVirgilError('90005', { error: e }));
}
}
export function decryptThenVerifyAsync (cipherData, recipientId, privateKey, publicKey) {
if (browser.msie || browser.msedge) {
return new Promise((resolve, reject) => {
try {
resolve(decryptThenVerify(cipherData, recipientId, privateKey, publicKey));
} catch (e) {
reject(e.message);
}
});
} else {
checkIsBuffer(cipherData, 'cipherData');
checkIsBuffer(recipientId, 'recipientId');
checkIsBuffer(privateKey, 'privateKey');
checkIsBuffer(publicKey, 'publicKey');
return CryptoWorkerApi.decryptThenVerify(
toBase64(cipherData),
toBase64(recipientId),
export function encryptWithPasswordAsync (initialData, password) {
if (browser.msie || browser.msedge) {
return new Promise((resolve, reject) => {
try {
resolve(encryptWithPassword(initialData, password));
} catch (e) {
reject(e.message);
}
});
} else {
return CryptoWorkerApi.encryptWithPassword(toBase64(initialData), toBase64(password))
.then(base64ToBuffer)
.catch((e) => throwVirgilError('90003', { error: e }));
}
}
function filterUnusedVendorRule (selector) {
if (!(bowser.msedge || bowser.msie) && selector.indexOf('-ms-') > -1) {
return false
}
if (!(bowser.webkit || bowser.msedge || bowser.blink) && selector.indexOf('-webkit-') > -1) {
return false
}
if (!bowser.gecko && selector.indexOf('-moz-') > -1) {
return false
}
return true
}
export function decryptWithPasswordAsync (encryptedData, password) {
if (browser.msie || browser.msedge) {
return new Promise((resolve, reject) => {
try {
resolve(decryptWithPassword(encryptedData, password));
} catch (e) {
reject(e.message);
}
});
} else {
return CryptoWorkerApi.decryptWithPassword(toBase64(encryptedData), toBase64(password))
.then(base64ToBuffer)
.catch((e) => throwVirgilError('90004', { error: e }));
}
}