Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@applitools/driver

Package Overview
Dependencies
Maintainers
36
Versions
216
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@applitools/driver - npm Package Compare versions

Comparing version 1.11.47 to 1.11.48

5

dist/driver.js

@@ -184,8 +184,7 @@ "use strict";

}
return (_e = this._driverInfo.userAgent) !== null && _e !== void 0 ? _e : null;
return (_e = this._driverInfo.userAgent) !== null && _e !== void 0 ? _e : undefined;
}
async getUserAgentLegacy({ force } = {}) {
var _a;
const userAgent = await this.getUserAgent({ force });
return utils.types.isObject(userAgent) ? (_a = userAgent === null || userAgent === void 0 ? void 0 : userAgent.legacy) !== null && _a !== void 0 ? _a : null : userAgent;
return utils.types.isObject(userAgent) ? userAgent === null || userAgent === void 0 ? void 0 : userAgent.legacy : userAgent;
}

@@ -192,0 +191,0 @@ async getEnvironment() {

158

dist/user-agent.js

@@ -28,30 +28,25 @@ "use strict";

const utils = __importStar(require("@applitools/utils"));
const MAJOR_MINOR = '(\\d+)(?:[_.](\\d+))?';
const PLATFORM_REGEXES = [
new RegExp(`(?:(Windows NT) ${MAJOR_MINOR})`),
new RegExp('(?:(Windows XP))'),
new RegExp('(?:(Windows 2000))'),
new RegExp('(?:(Windows NT))'),
new RegExp('(?:(Windows))'),
new RegExp(`(?:(Mac OS X) ${MAJOR_MINOR})`),
new RegExp(`(?:(Android) ${MAJOR_MINOR})`),
new RegExp(`(?:(CPU(?: i[a-zA-Z]+)? OS) ${MAJOR_MINOR})`),
new RegExp('(?:(Mac OS X))'),
new RegExp('(?:(Mac_PowerPC))'),
new RegExp('(?:(Linux))'),
new RegExp('(?:(CrOS))'),
new RegExp('(?:(SymbOS))'),
const majorMinorRegexpString = '(?<majorVersion>[^ .;_)]+)[_.;](?<minorVersion>[^ .;_)]*)';
const platformRegexpMapping = [
['Windows', new RegExp(`Windows(?:(?: NT)? ${majorMinorRegexpString}?)?`)],
['iOS', new RegExp(`CPU(?: i[a-zA-Z]+)? OS ${majorMinorRegexpString}`)],
['Mac OS X', new RegExp(`Mac OS X(?: ${majorMinorRegexpString})?`)],
['Android', new RegExp(`Android ${majorMinorRegexpString}`)],
['Macintosh', new RegExp(`Mac_PowerPC`)],
['Linux', new RegExp(`Linux`)],
['Chrome OS', new RegExp(`CrOS`)],
['SymbOS', new RegExp(`SymbOS`)],
];
const BROWSER_REGEXPES = [
new RegExp(`(?:(Opera)/${MAJOR_MINOR})`),
new RegExp(`(?:(Edg)/${MAJOR_MINOR})`),
new RegExp(`(?:(Edge)/${MAJOR_MINOR})`),
new RegExp(`(?:(Chrome)/${MAJOR_MINOR})`),
new RegExp(`(?:(Safari)/${MAJOR_MINOR})`),
new RegExp(`(?:(Firefox)/${MAJOR_MINOR})`),
new RegExp(`(?:MS(IE) ${MAJOR_MINOR})`),
const browserRegexpMapping = [
['IE', new RegExp(`rv:${majorMinorRegexpString}\\) like Gecko`)],
['IE', new RegExp(`MSIE ${majorMinorRegexpString}`)],
['Electron', new RegExp(`Electron/${majorMinorRegexpString}`)],
['Opera', new RegExp(`Opera/${majorMinorRegexpString}`)],
['Edge', new RegExp(`(?:Edg|Edge)/${majorMinorRegexpString}`)],
['Chrome', new RegExp(`Chrome/${majorMinorRegexpString}`)],
['Safari', new RegExp(`Safari/${majorMinorRegexpString}`)],
['Firefox', new RegExp(`Firefox/${majorMinorRegexpString}`)],
];
const HIDDEN_IE_REGEX = new RegExp(`(?:rv:${MAJOR_MINOR}\\) like Gecko)`);
const BROWSER_VERSION_REGEX = new RegExp(`(?:Version/${MAJOR_MINOR})`);
const WINDOWS_VERSIONS = {
const browserVersionRegexp = new RegExp(`(?:Version/${majorMinorRegexpString})`);
const windowsVersionsMapping = {
'0.1.0': '7',

@@ -78,64 +73,74 @@ '0.2.0': '8',

const userAgentEnvironment = userAgentObject && extractUserAgentObjectEnvironment(userAgentObject);
const environment = { ...userAgentEnvironment };
(_a = environment.platformName) !== null && _a !== void 0 ? _a : (environment.platformName = userAgentLegacyEnvironment.platformName);
(_b = environment.platformVersion) !== null && _b !== void 0 ? _b : (environment.platformVersion = userAgentLegacyEnvironment.platformVersion);
environment.browserName = (_c = userAgentLegacyEnvironment.browserName) !== null && _c !== void 0 ? _c : environment.browserName;
environment.browserVersion = (_d = userAgentLegacyEnvironment.browserVersion) !== null && _d !== void 0 ? _d : environment.browserVersion;
return environment;
return {
...userAgentEnvironment,
platformName: (_a = userAgentEnvironment === null || userAgentEnvironment === void 0 ? void 0 : userAgentEnvironment.platformName) !== null && _a !== void 0 ? _a : userAgentLegacyEnvironment.platformName,
platformVersion: (_b = userAgentEnvironment === null || userAgentEnvironment === void 0 ? void 0 : userAgentEnvironment.platformVersion) !== null && _b !== void 0 ? _b : userAgentLegacyEnvironment.platformVersion,
browserName: (_c = userAgentLegacyEnvironment.browserName) !== null && _c !== void 0 ? _c : userAgentEnvironment === null || userAgentEnvironment === void 0 ? void 0 : userAgentEnvironment.browserName,
browserVersion: (_d = userAgentLegacyEnvironment.browserVersion) !== null && _d !== void 0 ? _d : userAgentEnvironment === null || userAgentEnvironment === void 0 ? void 0 : userAgentEnvironment.browserVersion,
isReliable: !!((userAgentEnvironment === null || userAgentEnvironment === void 0 ? void 0 : userAgentEnvironment.platformName) && (userAgentEnvironment === null || userAgentEnvironment === void 0 ? void 0 : userAgentEnvironment.platformVersion)),
};
}
exports.extractUserAgentEnvironment = extractUserAgentEnvironment;
function extractUserAgentLegacyPlatform(userAgent) {
const platformRegExp = PLATFORM_REGEXES.find(regexp => regexp.test(userAgent));
if (!platformRegExp)
let info;
for (const [platformName, regexp] of platformRegexpMapping) {
const match = regexp.exec(userAgent);
if (match) {
info = { platformName, ...match.groups };
break;
}
}
if (!info)
return { platformName: 'Unknown' };
const [_, platformName, platformMajorVersion, platformMinorVersion] = platformRegExp.exec(userAgent);
if (platformName.startsWith('CPU')) {
return { platformName: 'iOS', platformVersion: platformMajorVersion };
if (info.platformName === 'Macintosh' || info.platformName === 'Chrome OS') {
info.minorVersion = undefined;
}
else if (platformName === 'Windows 2000' || platformName === 'Windows XP') {
return { platformName: 'Windows', platformVersion: '5' };
}
else if (platformName === 'Windows NT') {
const result = { platformName: 'Windows', platformVersion: platformMajorVersion };
if (!platformMajorVersion) {
result.platformVersion = '4';
else if (info.platformName === 'Windows') {
if (info.majorVersion === 'XP') {
info.majorVersion = '5';
info.minorVersion = '1';
}
else if (platformMajorVersion === '6' && platformMinorVersion === '1') {
result.platformVersion = '7';
else if (info.majorVersion === '6' && info.minorVersion === '1') {
info.majorVersion = '7';
info.minorVersion = undefined;
}
else if (platformMajorVersion === '6' && (platformMinorVersion === '2' || platformMinorVersion === '3')) {
result.platformVersion = '8';
else if (info.majorVersion === '6' && info.minorVersion === '2') {
info.majorVersion = '8';
info.minorVersion = undefined;
}
return result;
else if (info.majorVersion === '6' && info.minorVersion === '3') {
info.majorVersion = '8';
info.minorVersion = '1';
}
else if (info.majorVersion === '10') {
info.minorVersion = undefined;
}
else {
info.majorVersion = undefined;
info.minorVersion = undefined;
}
}
else if (platformName === 'Mac_PowerPC') {
return { platformName: 'Macintosh', platformVersion: platformMajorVersion };
}
else if (platformName === 'CrOS') {
return { platformName: 'Chrome OS', platformVersion: platformMajorVersion };
}
else {
return { platformName, platformVersion: platformMajorVersion };
}
return {
platformName: info.platformName,
platformVersion: info.minorVersion ? `${info.majorVersion}.${info.minorVersion}` : info.majorVersion,
};
}
function extractUserAgentLegacyBrowser(userAgent) {
const browserRegExp = BROWSER_REGEXPES.find(regexp => regexp.test(userAgent));
if (!browserRegExp) {
if (HIDDEN_IE_REGEX.test(userAgent)) {
const [_, browserVersion] = HIDDEN_IE_REGEX.exec(userAgent);
return { browserName: 'IE', browserVersion };
let info;
for (const [browserName, browserRegexp] of browserRegexpMapping) {
const browserMatch = browserRegexp.exec(userAgent);
if (browserMatch) {
info = { browserName, ...browserMatch.groups };
const versionMatch = browserVersionRegexp.exec(userAgent);
if (versionMatch)
info = { ...info, ...versionMatch.groups };
break;
}
else {
return { browserName: 'Unknown' };
}
}
const [_, browserName, browserVersion] = browserRegExp.exec(userAgent);
const result = { browserName, browserVersion };
if (result.browserName === 'Edg')
result.browserName = 'Edge';
if (BROWSER_VERSION_REGEX.test(userAgent)) {
const [_, browserVersion] = BROWSER_VERSION_REGEX.exec(userAgent);
result.browserVersion = browserVersion;
}
return result;
if (!info)
return { browserName: 'Unknown' };
return {
browserName: info.browserName,
browserVersion: info.minorVersion ? `${info.majorVersion}.${info.minorVersion}` : info.majorVersion,
};
}

@@ -156,3 +161,4 @@ function extractUserAgentObjectEnvironment(userAgent) {

if (environment.platformName === 'Windows') {
environment.platformVersion = WINDOWS_VERSIONS[environment.platformVersion];
environment.platformVersion =
windowsVersionsMapping[environment.platformVersion];
}

@@ -159,0 +165,0 @@ else if (environment.platformName === 'macOS') {

{
"name": "@applitools/driver",
"version": "1.11.47",
"version": "1.11.48",
"description": "Applitools universal framework wrapper",

@@ -5,0 +5,0 @@ "keywords": [

@@ -48,6 +48,6 @@ /// <reference types="node" />

force?: boolean;
}): Promise<UserAgent | null>;
}): Promise<UserAgent | undefined>;
getUserAgentLegacy({ force }?: {
force?: boolean;
}): Promise<string | null>;
}): Promise<string | undefined>;
getEnvironment(): Promise<Environment>;

@@ -54,0 +54,0 @@ getViewport(): Promise<Viewport>;

@@ -31,2 +31,3 @@ import type { Location, Size, Region } from '@applitools/utils';

deviceName?: string;
isReliable?: boolean;
isW3C?: boolean;

@@ -33,0 +34,0 @@ isEC?: boolean;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc