@braintree/browser-detection 1.14.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,95 @@
1
+ # Browser Detection - Release Notes
2
+
3
+ # 1.16.0 (2023-05-08)
4
+
5
+ - Remove window.safari object validation from iOS webview.
6
+ - Update `is-ios` to account for user agent behavior on newer iPads
7
+ - Add `is-ipados` method
8
+ - Typoed version number so we are skipping all the way to 1.16.0
9
+
10
+ # 1.13.0 (2022-07-14)
11
+
12
+ - Update mobile webview definitions to ensure modern webviews are accounted for.
13
+
14
+ # 1.12.1 (2021-09-28)
15
+
16
+ - Correct `is-ios-safari` to return `false` for the Facebook browser
17
+
18
+ # 1.12.0 (2021-06-08)
19
+
20
+ - Add `is-duckduckgo` method
21
+ - Add `is-ios-google-search-app` method
22
+ - Add `is-opera` method
23
+ - Add `is-silk` method
24
+ - Fix issue where `is-chrome` would incorrectly report `true` for DuckDuckGo and Silk browsers
25
+ - Fix issue where `supports-popups` would incorrectly report `false` for DuckDuckGo
26
+
27
+ # 1.11.1 (2021-04-07)
28
+
29
+ - Fix issue where `is-ios-safari` was returning `true` for iOS Firefox browsers
30
+
31
+ # 1.11.0 (2020-10-27)
32
+
33
+ - Add `has-software-keyboard` method
34
+
35
+ # 1.10.1 (2020-10-19)
36
+
37
+ - Fix issue where typescript declarations did not get published
38
+
39
+ # 1.10.0 (2020-07-10)
40
+
41
+ - Add typescript types
42
+
43
+ ## v1.9.0 (2019-09-18)
44
+
45
+ - Add `is-firefox` method
46
+
47
+ ## v1.8.0 (2019-08-07)
48
+
49
+ - Add `is-chrome-os` method
50
+ - Fix README typo for iOS
51
+ - Update README code samples to use `const`
52
+
53
+ ## 1.7.0 (2017-10-18)
54
+
55
+ - Add `supports-payment-request-api` method
56
+
57
+ ## 1.6.0 (2017-07-25)
58
+
59
+ - Correct is-chrome to not return true on edge browser
60
+ - Correct supports-popups to not return true on iOS Firefox
61
+ - Add `is-samsung-browser` method
62
+ - Add `is-mobile-firefox` method
63
+ - Add `is-ios-firefox` method
64
+
65
+ ## 1.5.0 (2017-07-03)
66
+
67
+ - Add `is-ie` method
68
+ - Add `is-ie11` method
69
+ - Add `is-edge` method
70
+
71
+ ## 1.4.1 (2017-06-01)
72
+
73
+ - publish to npm as scoped package `@braintree/browser-detection`
74
+
75
+ ## 1.4.0 (2017-05-22)
76
+
77
+ - Add `is-ios-uiwebview` method
78
+ - Add `is-ios-wkwebview` method
79
+
80
+ ## 1.3.0 (2017-04-11)
81
+
82
+ - Add `is-ios-webview` method
83
+ - Add `is-ios-safari` method
84
+
85
+ ## 1.2.0 (2017-04-10)
86
+
87
+ - Add `is-ie10` method
88
+
89
+ ## 1.1.0 (2017-04-07)
90
+
91
+ - Add `is-chrome` method
92
+
93
+ ## 1.0.0 (2017-04-05)
94
+
95
+ - Initial public release of browser-detection
package/README.md CHANGED
@@ -24,6 +24,7 @@ browserDetection.isIosSafari();
24
24
  browserDetection.isIosWebview();
25
25
  browserDetection.isIosUIWebview();
26
26
  browserDetection.isIosWKWebview();
27
+ browserDetection.isIpadOS();
27
28
  browserDetection.isMobileFirefox();
28
29
  browserDetection.isOpera();
29
30
  browserDetection.isSamsungBrowser();
@@ -53,6 +54,7 @@ const isIosSafari = require("browser-detection/is-ios-safari");
53
54
  const isIosWebview = require("browser-detection/is-ios-webview");
54
55
  const isIosUIWebview = require("browser-detection/is-ios-uiwebview");
55
56
  const isIosWKWebview = require("browser-detection/is-ios-wkwebview");
57
+ const isIpadOS = require("browser-detection/is-ipados");
56
58
  const isMobileFirefox = require("browser-detection/is-mobile-firefox");
57
59
  const isOpera = require("browser-detection/is-opera");
58
60
  const isSamsungBrowser = require("browser-detection/is-samsung");
@@ -67,3 +69,17 @@ const supportsPopups = require("browser-detection/supports-popups");
67
69
  ```sh
68
70
  npm test
69
71
  ```
72
+
73
+ ### Notes on isIpadOs
74
+
75
+ `isIpadOS` is a new option for browser detection, and is also included in isIos. isIos defaults to checking for iPads to maintain consistent behavior with how it acted in the past. If `checkIpadOS` is set to false, then it will only check for older gen iPads and current iOS
76
+
77
+ ```js
78
+ const browserDetection = require("browser-detection");
79
+ const ua = window.navigator.userAgent;
80
+ // assume ua is from iPadOs 13 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15"
81
+ browserDetection.isIos(ua);
82
+ // will return true
83
+ browserDetection.isIos(ua, false);
84
+ // will return false
85
+ ```
@@ -15,6 +15,7 @@ import isIosSafari = require("./is-ios-safari");
15
15
  import isIosUIWebview = require("./is-ios-uiwebview");
16
16
  import isIosWebview = require("./is-ios-webview");
17
17
  import isIosWKWebview = require("./is-ios-wkwebview");
18
+ import isIpadOS = require("./is-ipados");
18
19
  import isMobileFirefox = require("./is-mobile-firefox");
19
20
  import isOpera = require("./is-opera");
20
21
  import isSamsungBrowser = require("./is-samsung");
@@ -22,4 +23,4 @@ import isSilk = require("./is-silk");
22
23
  import hasSoftwareKeyboard = require("./has-software-keyboard");
23
24
  import supportsPopups = require("./supports-popups");
24
25
  import supportsPaymentRequestApi = require("./supports-payment-request-api");
25
- export { isAndroid, isChromeOS, isChrome, isDuckDuckGo, isIe, isIe9, isIe10, isIe11, isEdge, isFirefox, isIos, isIosFirefox, isIosGoogleSearchApp, isIosSafari, isIosUIWebview, isIosWebview, isIosWKWebview, isMobileFirefox, isOpera, isSamsungBrowser, isSilk, hasSoftwareKeyboard, supportsPopups, supportsPaymentRequestApi, };
26
+ export { isAndroid, isChromeOS, isChrome, isDuckDuckGo, isIe, isIe9, isIe10, isIe11, isEdge, isFirefox, isIos, isIosFirefox, isIosGoogleSearchApp, isIosSafari, isIosUIWebview, isIosWebview, isIosWKWebview, isIpadOS, isMobileFirefox, isOpera, isSamsungBrowser, isSilk, hasSoftwareKeyboard, supportsPopups, supportsPaymentRequestApi, };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.supportsPaymentRequestApi = exports.supportsPopups = exports.hasSoftwareKeyboard = exports.isSilk = exports.isSamsungBrowser = exports.isOpera = exports.isMobileFirefox = exports.isIosWKWebview = exports.isIosWebview = exports.isIosUIWebview = exports.isIosSafari = exports.isIosGoogleSearchApp = exports.isIosFirefox = exports.isIos = exports.isFirefox = exports.isEdge = exports.isIe11 = exports.isIe10 = exports.isIe9 = exports.isIe = exports.isDuckDuckGo = exports.isChrome = exports.isChromeOS = exports.isAndroid = void 0;
3
+ exports.supportsPaymentRequestApi = exports.supportsPopups = exports.hasSoftwareKeyboard = exports.isSilk = exports.isSamsungBrowser = exports.isOpera = exports.isMobileFirefox = exports.isIpadOS = exports.isIosWKWebview = exports.isIosWebview = exports.isIosUIWebview = exports.isIosSafari = exports.isIosGoogleSearchApp = exports.isIosFirefox = exports.isIos = exports.isFirefox = exports.isEdge = exports.isIe11 = exports.isIe10 = exports.isIe9 = exports.isIe = exports.isDuckDuckGo = exports.isChrome = exports.isChromeOS = exports.isAndroid = void 0;
4
4
  var isAndroid = require("./is-android");
5
5
  exports.isAndroid = isAndroid;
6
6
  var isChromeOS = require("./is-chrome-os");
@@ -35,6 +35,8 @@ var isIosWebview = require("./is-ios-webview");
35
35
  exports.isIosWebview = isIosWebview;
36
36
  var isIosWKWebview = require("./is-ios-wkwebview");
37
37
  exports.isIosWKWebview = isIosWKWebview;
38
+ var isIpadOS = require("./is-ipados");
39
+ exports.isIpadOS = isIpadOS;
38
40
  var isMobileFirefox = require("./is-mobile-firefox");
39
41
  exports.isMobileFirefox = isMobileFirefox;
40
42
  var isOpera = require("./is-opera");
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
package/dist/is-edge.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
package/dist/is-ie.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
package/dist/is-ie10.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
package/dist/is-ie11.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
package/dist/is-ie9.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined, statusBarVisible?: boolean | undefined) => boolean;
1
+ declare const _default: (ua?: string, statusBarVisible?: boolean) => boolean;
2
2
  export = _default;
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined, statusBarVisible?: boolean | undefined) => boolean;
1
+ declare const _default: (ua?: string, statusBarVisible?: boolean) => boolean;
2
2
  export = _default;
package/dist/is-ios.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string, checkIpadOS?: boolean, document?: object) => boolean;
2
2
  export = _default;
package/dist/is-ios.js CHANGED
@@ -1,5 +1,8 @@
1
1
  "use strict";
2
- module.exports = function isIos(ua) {
2
+ var isIpadOS = require("./is-ipados");
3
+ module.exports = function isIos(ua, checkIpadOS, document) {
4
+ if (checkIpadOS === void 0) { checkIpadOS = true; }
3
5
  ua = ua || window.navigator.userAgent;
4
- return /iPhone|iPod|iPad/i.test(ua);
6
+ var iOsTest = /iPhone|iPod|iPad/i.test(ua);
7
+ return checkIpadOS ? iOsTest || isIpadOS(ua, document) : iOsTest;
5
8
  };
@@ -0,0 +1,2 @@
1
+ declare const _default: (ua?: string, document?: object) => boolean;
2
+ export = _default;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ module.exports = function isIpadOS(ua, document) {
3
+ ua = ua || window.navigator.userAgent;
4
+ document = document || window.document;
5
+ // "ontouchend" is used to determine if a browser is on an iPad, otherwise
6
+ // user-agents for iPadOS behave/identify as a desktop browser
7
+ return /Mac|iPad/i.test(ua) && "ontouchend" in document;
8
+ };
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
package/dist/is-silk.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
@@ -1,2 +1,2 @@
1
- declare const _default: (ua?: string | undefined) => boolean;
1
+ declare const _default: (ua?: string) => boolean;
2
2
  export = _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: (ua?: string | undefined) => string;
2
+ export = _default;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ var isIos = require("./is-ios");
3
+ module.exports = function whichIosVersion(ua) {
4
+ ua = ua || window.navigator.userAgent;
5
+ var versionRegex = /(?:iPhone OS )(\d+)/;
6
+ var isIphone = !(ua.includes("iPad") || ua.includes("Macintosh"));
7
+ if (isIos(ua) && isIphone) {
8
+ var version = (ua.match(versionRegex) || [])[1] || "no ios version";
9
+ return version;
10
+ }
11
+ return "no ios version";
12
+ };
package/is-ipados.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require("./dist/is-ipados");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@braintree/browser-detection",
3
- "version": "1.14.0",
3
+ "version": "1.16.0",
4
4
  "description": "A small lib to detect browser compatibility for braintree products",
5
5
  "main": "dist/browser-detection.js",
6
6
  "types": "dist/browser-detection.d.ts",
@@ -9,16 +9,17 @@
9
9
  "*.js"
10
10
  ],
11
11
  "devDependencies": {
12
- "@types/jest": "^27.4.1",
13
- "@types/node": "^17.0.23",
14
- "@typescript-eslint/eslint-plugin": "^5.19.0",
15
- "eslint": "^8.13.0",
12
+ "@types/jest": "^29.4.0",
13
+ "@types/node": "^18.14.6",
14
+ "@typescript-eslint/eslint-plugin": "^5.54.1",
15
+ "eslint": "^8.35.0",
16
16
  "eslint-config-braintree": "^6.0.0-typescript-prep-rc.2",
17
- "eslint-plugin-prettier": "^4.0.0",
18
- "jest": "^27.5.1",
19
- "prettier": "^2.6.2",
20
- "ts-jest": "^27.1.4",
21
- "typescript": "^4.6.3"
17
+ "eslint-plugin-prettier": "^4.2.1",
18
+ "jest": "^29.5.0",
19
+ "jest-environment-jsdom": "^29.5.0",
20
+ "prettier": "^2.8.4",
21
+ "ts-jest": "^29.0.5",
22
+ "typescript": "^4.9.5"
22
23
  },
23
24
  "scripts": {
24
25
  "prepublishOnly": "npm run build",