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

get-private-browsing-name

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-private-browsing-name - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

.github/workflows/actions.yml

77

dist/index.js
"use strict";
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
require("core-js/modules/es.regexp.exec.js");
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

@@ -13,12 +15,12 @@

os: 'iOS',
regex: /iP(hone|od|ad)/
regex: [/iP(hone|od|ad)/]
}, {
os: 'Linux',
regex: /(Linux)|(X11)/
regex: [/(Linux)|(X11)/]
}, {
os: 'Mac OS',
regex: /(Mac_PowerPC)|(Macintosh)/
regex: [/(Mac_PowerPC)|(Macintosh)/]
}, {
os: 'Windows',
regex: /Win/
regex: [/Win/]
}];

@@ -31,11 +33,4 @@ const browserDict = [{

windowsMethod: 'Ctrl+Shift+p',
regex: /Edge\/([0-9\._]+)/
regex: [/Edge\/([0-9\._]+)/, /EdgiOS\/([0-9\._]+)/]
}, {
browser: 'edge-ios',
mode: 'InPrivate Browsing',
linkMethod: 'Open link in InPrivate window',
macMethod: 'Command⌘+Shift+p',
windowsMethod: 'Ctrl+Shift+p',
regex: /EdgiOS\/([0-9\._]+)/
}, {
browser: 'firefox',

@@ -46,3 +41,3 @@ mode: 'Private Browsing',

windowsMethod: 'Ctrl+Shift+p',
regex: /Firefox\/([0-9\.]+)(?:\s|$)/
regex: [/Firefox\/([0-9\.]+)(?:\s|$)/, /FxiOS/]
}, {

@@ -54,3 +49,3 @@ browser: 'safari',

windowsMethod: null,
regex: /Version\/([0-9\._]+).*Safari/
regex: [/Version\/([0-9\._]+).*Safari/]
}, {

@@ -62,3 +57,3 @@ browser: 'chrome',

windowsMethod: 'Ctrl+Shift+n',
regex: /(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/
regex: [/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/, /(CriOS)\/(\d+)\.(\d+)\.(\d+)\.(\d+)/]
}, {

@@ -70,17 +65,10 @@ browser: 'ie',

windowsMethod: 'Ctrl+Shift+p',
regex: /Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/
regex: [/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/, /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/, /MSIE\s(7\.0)/]
}, {
browser: 'ie',
mode: 'InPrivate Browsing',
linkMethod: null,
macMethod: 'Command⌘+Shift+p',
windowsMethod: 'Ctrl+Shift+p',
regex: /MSIE\s([0-9\.]+);.*Trident\/[4-7].0/
}, {
browser: 'ie',
mode: 'InPrivate Browsing',
linkMethod: null,
macMethod: 'Command⌘+Shift+p',
windowsMethod: 'Ctrl+Shift+p',
regex: /MSIE\s(7\.0)/
browser: 'opera',
mode: 'Private Browsing',
linkMethod: 'Open link in Private Window',
macMethod: 'Command⌘+Shift+n',
windowsMethod: 'Ctrl+Shift+n',
regex: [/(?:Chrome).*(OPR)\/(\d+)\.(\d+)\.(\d+)/, /Opera/]
}];

@@ -93,4 +81,10 @@

} = dict[i];
const match = regex.exec(str);
let match = false;
for (var j = 0, jcount = regex.length; j < jcount; j++) {
if (regex[j].exec(str)) {
match = true;
}
}
if (match) {

@@ -113,12 +107,15 @@ return dict[i];

const getMethodForBrowser = (os, browser) => {
if (os === 'Windows' || os === 'Linux') {
return browser.windowsMethod;
} else if (os === 'Mac OS' || os === 'iOS') {
return browser.macMethod;
} else {
return null;
}
};
const os = getOs(ua);
const browser = getBrowser(ua);
let detectedMethod = null;
if (os === 'Windows' || os === 'Linux') {
detectedMethod = browser.windowsMethod;
} else if (os === 'Mac OS' || os === 'iOS') {
detectedMethod = browser.macMethod;
}
const detectedMethod = browser && getMethodForBrowser(os, browser);
return browser && _objectSpread(_objectSpread({}, browser), {}, {

@@ -125,0 +122,0 @@ detectedMethod

{
"name": "get-private-browsing-name",
"version": "1.0.0",
"version": "1.1.0",
"description": "",

@@ -8,4 +8,3 @@ "main": "index.js",

"test": "jest",
"build": "babel src --out-dir dist",
"deploy": "babel src --out-dir dist && npm publish"
"build": "babel src/index.js --out-dir dist"
},

@@ -35,4 +34,5 @@ "repository": {

"dependencies": {
"@babel/polyfill": "^7.12.1"
"@babel/polyfill": "^7.12.1",
"core-js": "^3.22"
}
}

@@ -1,2 +0,5 @@

![npm](https://img.shields.io/npm/v/get-private-browsing-name) ![npm bundle size](https://img.shields.io/bundlephobia/min/get-private-browsing-name)
![Build Status](https://img.shields.io/github/workflow/status/taitems/get-private-browsing-name/Tests/master)
![npm](https://img.shields.io/npm/dw/get-private-browsing-name)
![npm](https://img.shields.io/npm/v/get-private-browsing-name)
![npm bundle size](https://img.shields.io/bundlephobia/min/get-private-browsing-name)
## Get Private Browsing Name

@@ -18,2 +21,3 @@

- **Mozilla Firefox:** Private Browsing
- **Opera:** Private Browsing

@@ -23,11 +27,2 @@ ### Test cases

| User Agent | Result |
| ---- | --- |
| Chrome on macOS | ✅ Pass |
| Apple iPhone XR (Safari) | ✅ Pass |
| Apple iPhone XS (Chrome) | 🛑 Fail |
| Apple iPhone XS Max (Firefox) | 🛑 Fail |
| Windows 10-based PC using Edge browser | ✅ Pass |
| Windows 7-based PC using a Chrome browser | ✅ Pass |
### Example

@@ -49,2 +44,7 @@

// }
```
```
### Changelog
#### `1.1.0` - Fixes hard crash. Adds Opera support. Fixes Chrome/Firefox-on-iOS tests.
#### `1.0.0` - Stable release
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