@dynamic-labs/utils 0.19.0-alpha.7 → 0.19.0-alpha.9
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 +53 -0
- package/package.json +3 -3
- package/src/errors/SocialAccountAlreadyExistsError.cjs +13 -0
- package/src/errors/SocialAccountAlreadyExistsError.d.ts +4 -0
- package/src/errors/SocialAccountAlreadyExistsError.js +9 -0
- package/src/errors/index.d.ts +1 -0
- package/src/getPathFromObject.cjs +34 -0
- package/src/getPathFromObject.d.ts +8 -0
- package/src/getPathFromObject.js +30 -0
- package/src/index.cjs +5 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -1
- package/src/isMobile.cjs +56 -1
- package/src/isMobile.d.ts +1 -0
- package/src/isMobile.js +56 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,57 @@
|
|
|
1
1
|
|
|
2
|
+
## [0.19.0-alpha.9](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.8...v0.19.0-alpha.9) (2023-09-21)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* allow enabling multi wallet in connect-only mode ([#3367](https://github.com/dynamic-labs/DynamicAuth/issues/3367)) ([8ef68a2](https://github.com/dynamic-labs/DynamicAuth/commit/8ef68a295738db5353fcddc54985744313a5474b))
|
|
8
|
+
* move injected wallets configuration to the cdn ([#3077](https://github.com/dynamic-labs/DynamicAuth/issues/3077)) ([291183b](https://github.com/dynamic-labs/DynamicAuth/commit/291183b8daf124577d1049152a2556b6f2a85758))
|
|
9
|
+
* passkey setup completed view ([#3358](https://github.com/dynamic-labs/DynamicAuth/issues/3358)) ([020faf6](https://github.com/dynamic-labs/DynamicAuth/commit/020faf63815e232c64ac8626f747b2997adbaa02))
|
|
10
|
+
* **rohithv/gvty-326:** check if email is real before sending ([#3361](https://github.com/dynamic-labs/DynamicAuth/issues/3361)) ([db554f3](https://github.com/dynamic-labs/DynamicAuth/commit/db554f344707e3c3701012ecc09b67be2aaebba4))
|
|
11
|
+
* safe guard wrong locale override keys ([#3329](https://github.com/dynamic-labs/DynamicAuth/issues/3329)) ([b2cf96b](https://github.com/dynamic-labs/DynamicAuth/commit/b2cf96b55fdd2705335ad942fe8e1c1109bf4134))
|
|
12
|
+
* secure account with passkey view ([#3356](https://github.com/dynamic-labs/DynamicAuth/issues/3356)) ([9d58c44](https://github.com/dynamic-labs/DynamicAuth/commit/9d58c4472f1967ff5201bae6556c7d88a33d6276))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* better handling of window opener to mitigate window opener for social linking ([#3379](https://github.com/dynamic-labs/DynamicAuth/issues/3379)) ([e784061](https://github.com/dynamic-labs/DynamicAuth/commit/e784061ab190d314976213e321516bbb256627e7))
|
|
18
|
+
* change buttom copy when cannot link a wallet ([#3364](https://github.com/dynamic-labs/DynamicAuth/issues/3364)) ([5428a60](https://github.com/dynamic-labs/DynamicAuth/commit/5428a60abcbbd9c47e9227a53610ee5975bac379))
|
|
19
|
+
* **DynamicWidget:** goToInitialView when closing send balance ([#3333](https://github.com/dynamic-labs/DynamicAuth/issues/3333)) ([7ea40ec](https://github.com/dynamic-labs/DynamicAuth/commit/7ea40ec3827c40e3340e5ecfa2153e59c05a79f1))
|
|
20
|
+
* **EmailMagicWalletConnector:** to only cancel the verification if user clicks back ([#3374](https://github.com/dynamic-labs/DynamicAuth/issues/3374)) ([1111a18](https://github.com/dynamic-labs/DynamicAuth/commit/1111a186b7b84066e89d385c0bd9c064d0326eae))
|
|
21
|
+
* **embedded-wallet:** display sign typed data message ([#3316](https://github.com/dynamic-labs/DynamicAuth/issues/3316)) ([0014c8b](https://github.com/dynamic-labs/DynamicAuth/commit/0014c8b4250cf9db92b554f02b4e46f3aba2d943))
|
|
22
|
+
* missing translation keys ([#3325](https://github.com/dynamic-labs/DynamicAuth/issues/3325)) ([0e7c383](https://github.com/dynamic-labs/DynamicAuth/commit/0e7c3838a0eb8b49298e59b2919e16994a2d6b19))
|
|
23
|
+
* only set scope/prompt in oauth query params when they're defined ([#3324](https://github.com/dynamic-labs/DynamicAuth/issues/3324)) ([9e8aa2d](https://github.com/dynamic-labs/DynamicAuth/commit/9e8aa2d186fff563607dc836017b918af79718ce))
|
|
24
|
+
* pass the network param on wallet transfers ([#3307](https://github.com/dynamic-labs/DynamicAuth/issues/3307)) ([faf89fd](https://github.com/dynamic-labs/DynamicAuth/commit/faf89fdbfa690a87ae91d7f09c3647b4160b53ad))
|
|
25
|
+
* send primaryWalletId when available to unlinkOauth ([#3342](https://github.com/dynamic-labs/DynamicAuth/issues/3342)) ([0da0ae2](https://github.com/dynamic-labs/DynamicAuth/commit/0da0ae23040f7683000223109446a516c6d7b212))
|
|
26
|
+
* twitter sign-in with dynamic ([#3313](https://github.com/dynamic-labs/DynamicAuth/issues/3313)) ([c77dae4](https://github.com/dynamic-labs/DynamicAuth/commit/c77dae41dbdc02c84f3d3f5f3338136efd5766f9))
|
|
27
|
+
* use social profile photo for profile icon whenever available ([#3298](https://github.com/dynamic-labs/DynamicAuth/issues/3298)) ([143303b](https://github.com/dynamic-labs/DynamicAuth/commit/143303ba5e24d16aaa362f1888e3942bdef59602))
|
|
28
|
+
* wallet transition in the bridge ([#3270](https://github.com/dynamic-labs/DynamicAuth/issues/3270)) ([143cf47](https://github.com/dynamic-labs/DynamicAuth/commit/143cf47e0cd4806780f5b3f527ace2d6c0208534)), closes [#3268](https://github.com/dynamic-labs/DynamicAuth/issues/3268) [#3243](https://github.com/dynamic-labs/DynamicAuth/issues/3243)
|
|
29
|
+
* **wallet-connect:** prevent connector from connecting after logout ([#3345](https://github.com/dynamic-labs/DynamicAuth/issues/3345)) ([9bada77](https://github.com/dynamic-labs/DynamicAuth/commit/9bada7775c5ac7a4fdb5ad8d4d21691335e06936))
|
|
30
|
+
|
|
31
|
+
## [0.19.0-alpha.8](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.7...v0.19.0-alpha.8) (2023-09-11)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* add onSignedMessage callback ([#3118](https://github.com/dynamic-labs/DynamicAuth/issues/3118)) ([acc36f6](https://github.com/dynamic-labs/DynamicAuth/commit/acc36f6cf584eb05a019027475a6e2e413fd6bd5))
|
|
37
|
+
* add social sign-in without embedded wallet ([#3172](https://github.com/dynamic-labs/DynamicAuth/issues/3172)) ([ff1acc6](https://github.com/dynamic-labs/DynamicAuth/commit/ff1acc6d9753ba745ac01c5ef6d26f2e4291b752))
|
|
38
|
+
* show default wallet icon when image breaks ([#3234](https://github.com/dynamic-labs/DynamicAuth/issues/3234)) ([657e6bb](https://github.com/dynamic-labs/DynamicAuth/commit/657e6bbc1cdcd840562d25194a827ea833237c1a))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Bug Fixes
|
|
42
|
+
|
|
43
|
+
* catch error sending sdkSettings and log warning ([#3274](https://github.com/dynamic-labs/DynamicAuth/issues/3274)) ([fcbe01b](https://github.com/dynamic-labs/DynamicAuth/commit/fcbe01bc733a73f38aebd6ffb0969b040dd2f781))
|
|
44
|
+
* detect if oauth popup is blocked and throw error ([#3250](https://github.com/dynamic-labs/DynamicAuth/issues/3250)) ([b87ddf3](https://github.com/dynamic-labs/DynamicAuth/commit/b87ddf399104e29c56566abbbecab6ff947992d6))
|
|
45
|
+
* display error message to user if social account already exits ([#3258](https://github.com/dynamic-labs/DynamicAuth/issues/3258)) ([bb52cb4](https://github.com/dynamic-labs/DynamicAuth/commit/bb52cb4ae42d89310d435584ed4ece126f9b6a4a))
|
|
46
|
+
* don't call callbacks if window closed due to oauth process complete ([#3252](https://github.com/dynamic-labs/DynamicAuth/issues/3252)) ([09a3c73](https://github.com/dynamic-labs/DynamicAuth/commit/09a3c73446aa337f24e0875cd4a0af617ea8ca84))
|
|
47
|
+
* issue where unexpected token would occur when bundlers defined process.env ([#3283](https://github.com/dynamic-labs/DynamicAuth/issues/3283)) ([d31d0a4](https://github.com/dynamic-labs/DynamicAuth/commit/d31d0a4011256f59cb3760acdc2c3dfe6c5b504a))
|
|
48
|
+
* login view layout updates ([#3231](https://github.com/dynamic-labs/DynamicAuth/issues/3231)) ([7762d06](https://github.com/dynamic-labs/DynamicAuth/commit/7762d067bdd4b3f313a15308262f18dac0b961ab))
|
|
49
|
+
* **MagicWalletConnector:** remove async from getWeb3Provider method ([#3230](https://github.com/dynamic-labs/DynamicAuth/issues/3230)) ([69356e9](https://github.com/dynamic-labs/DynamicAuth/commit/69356e9b0bd1800acdf24fc96c72b094b595eaa7))
|
|
50
|
+
* remove react component props from sending to sdk api ([#3282](https://github.com/dynamic-labs/DynamicAuth/issues/3282)) ([b0d8f2b](https://github.com/dynamic-labs/DynamicAuth/commit/b0d8f2b9dd0856a5a7bd862f6c3499b65ec29f64))
|
|
51
|
+
* seprate ls checks for dynamiccontext and wagmi settings ([#3275](https://github.com/dynamic-labs/DynamicAuth/issues/3275)) ([aa4e756](https://github.com/dynamic-labs/DynamicAuth/commit/aa4e756a10310ce216b5942d0d6845f7092a89a2))
|
|
52
|
+
* use context to handle social sign-in and display message while processing ([#3216](https://github.com/dynamic-labs/DynamicAuth/issues/3216)) ([0e3ce73](https://github.com/dynamic-labs/DynamicAuth/commit/0e3ce73eafbb8d5725377c9a8cbd86a82d6c525f))
|
|
53
|
+
* **wallet-connect-v2:** use appropriate default chain id with WC v2 ([#3218](https://github.com/dynamic-labs/DynamicAuth/issues/3218)) ([2e6e7be](https://github.com/dynamic-labs/DynamicAuth/commit/2e6e7beb801ea5a8dc7429970bcd1e705610d605))
|
|
54
|
+
|
|
2
55
|
## [0.19.0-alpha.7](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.6...v0.19.0-alpha.7) (2023-08-31)
|
|
3
56
|
|
|
4
57
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/utils",
|
|
3
|
-
"version": "0.19.0-alpha.
|
|
3
|
+
"version": "0.19.0-alpha.9",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"./package.json": "./package.json"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@dynamic-labs/logger": "0.19.0-alpha.
|
|
30
|
-
"@dynamic-labs/types": "0.19.0-alpha.
|
|
29
|
+
"@dynamic-labs/logger": "0.19.0-alpha.9",
|
|
30
|
+
"@dynamic-labs/types": "0.19.0-alpha.9"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {}
|
|
33
33
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var DynamicError = require('./DynamicError.cjs');
|
|
6
|
+
|
|
7
|
+
class SocialAccountAlreadyExistsError extends DynamicError.DynamicError {
|
|
8
|
+
constructor() {
|
|
9
|
+
super('Social account already exists');
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.SocialAccountAlreadyExistsError = SocialAccountAlreadyExistsError;
|
package/src/errors/index.d.ts
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* return the destination (value)
|
|
7
|
+
*
|
|
8
|
+
* @param {object} obj - object to search for the item
|
|
9
|
+
* @param {string} path - path in the obj to the item
|
|
10
|
+
* @returns {T[]} - array of found items
|
|
11
|
+
*/
|
|
12
|
+
const getPathFromObject = (obj, path) => {
|
|
13
|
+
const splitPath = path.split('.');
|
|
14
|
+
let result = obj;
|
|
15
|
+
const foundProviders = [];
|
|
16
|
+
for (const [index, p] of Object.entries(splitPath)) {
|
|
17
|
+
result = result[p];
|
|
18
|
+
if (typeof result !== 'object' || result === null) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
// we need to check if we have hit the end of the requested path
|
|
22
|
+
if (Number(index) === splitPath.length - 1) {
|
|
23
|
+
if (Array.isArray(result)) {
|
|
24
|
+
result.forEach((p) => foundProviders.push(p));
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
foundProviders.push(result);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return foundProviders;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.getPathFromObject = getPathFromObject;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* return the destination (value)
|
|
3
|
+
*
|
|
4
|
+
* @param {object} obj - object to search for the item
|
|
5
|
+
* @param {string} path - path in the obj to the item
|
|
6
|
+
* @returns {T[]} - array of found items
|
|
7
|
+
*/
|
|
8
|
+
export declare const getPathFromObject: <T>(obj: object, path: string) => T[];
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* return the destination (value)
|
|
3
|
+
*
|
|
4
|
+
* @param {object} obj - object to search for the item
|
|
5
|
+
* @param {string} path - path in the obj to the item
|
|
6
|
+
* @returns {T[]} - array of found items
|
|
7
|
+
*/
|
|
8
|
+
const getPathFromObject = (obj, path) => {
|
|
9
|
+
const splitPath = path.split('.');
|
|
10
|
+
let result = obj;
|
|
11
|
+
const foundProviders = [];
|
|
12
|
+
for (const [index, p] of Object.entries(splitPath)) {
|
|
13
|
+
result = result[p];
|
|
14
|
+
if (typeof result !== 'object' || result === null) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
// we need to check if we have hit the end of the requested path
|
|
18
|
+
if (Number(index) === splitPath.length - 1) {
|
|
19
|
+
if (Array.isArray(result)) {
|
|
20
|
+
result.forEach((p) => foundProviders.push(p));
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
foundProviders.push(result);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return foundProviders;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { getPathFromObject };
|
package/src/index.cjs
CHANGED
|
@@ -19,12 +19,14 @@ var EmailProviderError = require('./errors/EmailProviderError.cjs');
|
|
|
19
19
|
var MissingEnvironmentIdError = require('./errors/MissingEnvironmentIdError.cjs');
|
|
20
20
|
var GateBlockedError = require('./errors/GateBlockedError.cjs');
|
|
21
21
|
var UserHasAccountWithEmailError = require('./errors/UserHasAccountWithEmailError.cjs');
|
|
22
|
+
var SocialAccountAlreadyExistsError = require('./errors/SocialAccountAlreadyExistsError.cjs');
|
|
22
23
|
var CancellablePromise = require('./CancellablePromise/CancellablePromise.cjs');
|
|
23
24
|
var isFunction = require('./isFunction/isFunction.cjs');
|
|
24
25
|
var isMobile = require('./isMobile.cjs');
|
|
25
26
|
var localStorageAsync = require('./localStorageAsync.cjs');
|
|
26
27
|
var bufferToBase64 = require('./bufferToBase64.cjs');
|
|
27
28
|
var last = require('./last.cjs');
|
|
29
|
+
var getPathFromObject = require('./getPathFromObject.cjs');
|
|
28
30
|
|
|
29
31
|
|
|
30
32
|
|
|
@@ -45,12 +47,14 @@ exports.EmailProviderError = EmailProviderError.EmailProviderError;
|
|
|
45
47
|
exports.MissingEnvironmentIdError = MissingEnvironmentIdError.MissingEnvironmentIdError;
|
|
46
48
|
exports.GateBlockedError = GateBlockedError.GateBlockedError;
|
|
47
49
|
exports.UserHasAccountWithEmailError = UserHasAccountWithEmailError.UserHasAccountWithEmailError;
|
|
50
|
+
exports.SocialAccountAlreadyExistsError = SocialAccountAlreadyExistsError.SocialAccountAlreadyExistsError;
|
|
48
51
|
exports.CancellablePromise = CancellablePromise.CancellablePromise;
|
|
49
52
|
exports.isFunction = isFunction.isFunction;
|
|
50
53
|
exports.isAndroid = isMobile.isAndroid;
|
|
51
54
|
exports.isIOS = isMobile.isIOS;
|
|
52
55
|
exports.isIPad = isMobile.isIPad;
|
|
53
56
|
exports.isIPhone = isMobile.isIPhone;
|
|
57
|
+
exports.isIPhone8OrEarlier = isMobile.isIPhone8OrEarlier;
|
|
54
58
|
exports.isLegacySafari = isMobile.isLegacySafari;
|
|
55
59
|
exports.isMobile = isMobile.isMobile;
|
|
56
60
|
exports.isSamsungBrowser = isMobile.isSamsungBrowser;
|
|
@@ -59,3 +63,4 @@ exports.removeItemAsync = localStorageAsync.removeItemAsync;
|
|
|
59
63
|
exports.setItemAsync = localStorageAsync.setItemAsync;
|
|
60
64
|
exports.bufferToBase64 = bufferToBase64.bufferToBase64;
|
|
61
65
|
exports.last = last.last;
|
|
66
|
+
exports.getPathFromObject = getPathFromObject.getPathFromObject;
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -15,9 +15,11 @@ export { EmailProviderError } from './errors/EmailProviderError.js';
|
|
|
15
15
|
export { MissingEnvironmentIdError } from './errors/MissingEnvironmentIdError.js';
|
|
16
16
|
export { GateBlockedError } from './errors/GateBlockedError.js';
|
|
17
17
|
export { UserHasAccountWithEmailError } from './errors/UserHasAccountWithEmailError.js';
|
|
18
|
+
export { SocialAccountAlreadyExistsError } from './errors/SocialAccountAlreadyExistsError.js';
|
|
18
19
|
export { CancellablePromise } from './CancellablePromise/CancellablePromise.js';
|
|
19
20
|
export { isFunction } from './isFunction/isFunction.js';
|
|
20
|
-
export { isAndroid, isIOS, isIPad, isIPhone, isLegacySafari, isMobile, isSamsungBrowser } from './isMobile.js';
|
|
21
|
+
export { isAndroid, isIOS, isIPad, isIPhone, isIPhone8OrEarlier, isLegacySafari, isMobile, isSamsungBrowser } from './isMobile.js';
|
|
21
22
|
export { getItemAsync, removeItemAsync, setItemAsync } from './localStorageAsync.js';
|
|
22
23
|
export { bufferToBase64 } from './bufferToBase64.js';
|
|
23
24
|
export { last } from './last.js';
|
|
25
|
+
export { getPathFromObject } from './getPathFromObject.js';
|
package/src/isMobile.cjs
CHANGED
|
@@ -21,6 +21,9 @@ const isMobile = (maxTouchPointsOverride) => {
|
|
|
21
21
|
const isIPhone = () => typeof window === 'undefined' || typeof navigator === 'undefined'
|
|
22
22
|
? false
|
|
23
23
|
: /iPhone/.test(navigator.userAgent);
|
|
24
|
+
const isIPhone8OrEarlier = () => typeof window === 'undefined' || typeof navigator === 'undefined'
|
|
25
|
+
? false
|
|
26
|
+
: iPhoneLegacyRegex.some(({ regex }) => regex.test(navigator.userAgent));
|
|
24
27
|
/**
|
|
25
28
|
* @param [optional] maxTouchPointsOverride - this is used for testing since
|
|
26
29
|
* it seems that JSDOM doesn't support maxTouchPoints, so it was impossible
|
|
@@ -58,12 +61,64 @@ const isSamsungBrowser = () => {
|
|
|
58
61
|
return false;
|
|
59
62
|
}
|
|
60
63
|
return navigator.userAgent.includes('SamsungBrowser');
|
|
61
|
-
};
|
|
64
|
+
};
|
|
65
|
+
// regex from: https://github.com/matomo-org/device-detector/blob/master/regexes/device/mobiles.yml
|
|
66
|
+
const iPhoneLegacyRegex = [
|
|
67
|
+
{
|
|
68
|
+
model: 'iPhone 5',
|
|
69
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?5[C,_]12|5)$/,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
model: 'iPhone 5C',
|
|
73
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?5[C,_]34)$/,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
model: 'iPhone 5S',
|
|
77
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?6[C,_]12|5S)$/,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
model: 'iPhone 6 Plus',
|
|
81
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?7[C,_]1|1C2%257enohPi|6PLUS)$/,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
model: 'iPhone 6',
|
|
85
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?7[C,_]2|6)$/,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
model: 'iPhone 6s Plus',
|
|
89
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?8[C,_]2|6SPLUS)$/,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
model: 'iPhone 6s',
|
|
93
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?8[C,_]1|iPhone[ /]6s|6S)$/,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
model: 'iPhone SE',
|
|
97
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?8[C,_]4|SE)$/,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
model: 'iPhone 7',
|
|
101
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?9[C,_]13|iphone7|7)$/,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
model: 'iPhone 7 Plus',
|
|
105
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?9[C,_]24|7PLUS)$/,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
model: 'iPhone 8',
|
|
109
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?10[C,_]14|8)$/,
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
model: 'iPhone 8 Plus',
|
|
113
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?10[C,_]25|8PLUS)$/,
|
|
114
|
+
},
|
|
115
|
+
];
|
|
62
116
|
|
|
63
117
|
exports.isAndroid = isAndroid;
|
|
64
118
|
exports.isIOS = isIOS;
|
|
65
119
|
exports.isIPad = isIPad;
|
|
66
120
|
exports.isIPhone = isIPhone;
|
|
121
|
+
exports.isIPhone8OrEarlier = isIPhone8OrEarlier;
|
|
67
122
|
exports.isLegacySafari = isLegacySafari;
|
|
68
123
|
exports.isMobile = isMobile;
|
|
69
124
|
exports.isSamsungBrowser = isSamsungBrowser;
|
package/src/isMobile.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const isMobile: (maxTouchPointsOverride?: number) => boolean;
|
|
5
5
|
export declare const isIPhone: () => boolean;
|
|
6
|
+
export declare const isIPhone8OrEarlier: () => boolean;
|
|
6
7
|
/**
|
|
7
8
|
* @param [optional] maxTouchPointsOverride - this is used for testing since
|
|
8
9
|
* it seems that JSDOM doesn't support maxTouchPoints, so it was impossible
|
package/src/isMobile.js
CHANGED
|
@@ -17,6 +17,9 @@ const isMobile = (maxTouchPointsOverride) => {
|
|
|
17
17
|
const isIPhone = () => typeof window === 'undefined' || typeof navigator === 'undefined'
|
|
18
18
|
? false
|
|
19
19
|
: /iPhone/.test(navigator.userAgent);
|
|
20
|
+
const isIPhone8OrEarlier = () => typeof window === 'undefined' || typeof navigator === 'undefined'
|
|
21
|
+
? false
|
|
22
|
+
: iPhoneLegacyRegex.some(({ regex }) => regex.test(navigator.userAgent));
|
|
20
23
|
/**
|
|
21
24
|
* @param [optional] maxTouchPointsOverride - this is used for testing since
|
|
22
25
|
* it seems that JSDOM doesn't support maxTouchPoints, so it was impossible
|
|
@@ -54,6 +57,57 @@ const isSamsungBrowser = () => {
|
|
|
54
57
|
return false;
|
|
55
58
|
}
|
|
56
59
|
return navigator.userAgent.includes('SamsungBrowser');
|
|
57
|
-
};
|
|
60
|
+
};
|
|
61
|
+
// regex from: https://github.com/matomo-org/device-detector/blob/master/regexes/device/mobiles.yml
|
|
62
|
+
const iPhoneLegacyRegex = [
|
|
63
|
+
{
|
|
64
|
+
model: 'iPhone 5',
|
|
65
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?5[C,_]12|5)$/,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
model: 'iPhone 5C',
|
|
69
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?5[C,_]34)$/,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
model: 'iPhone 5S',
|
|
73
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?6[C,_]12|5S)$/,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
model: 'iPhone 6 Plus',
|
|
77
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?7[C,_]1|1C2%257enohPi|6PLUS)$/,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
model: 'iPhone 6',
|
|
81
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?7[C,_]2|6)$/,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
model: 'iPhone 6s Plus',
|
|
85
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?8[C,_]2|6SPLUS)$/,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
model: 'iPhone 6s',
|
|
89
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?8[C,_]1|iPhone[ /]6s|6S)$/,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
model: 'iPhone SE',
|
|
93
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?8[C,_]4|SE)$/,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
model: 'iPhone 7',
|
|
97
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?9[C,_]13|iphone7|7)$/,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
model: 'iPhone 7 Plus',
|
|
101
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?9[C,_]24|7PLUS)$/,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
model: 'iPhone 8',
|
|
105
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?10[C,_]14|8)$/,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
model: 'iPhone 8 Plus',
|
|
109
|
+
regex: /(?:MDCR_|ICRU_|Apple-)?(?:iPh(?:one)?10[C,_]25|8PLUS)$/,
|
|
110
|
+
},
|
|
111
|
+
];
|
|
58
112
|
|
|
59
|
-
export { isAndroid, isIOS, isIPad, isIPhone, isLegacySafari, isMobile, isSamsungBrowser };
|
|
113
|
+
export { isAndroid, isIOS, isIPad, isIPhone, isIPhone8OrEarlier, isLegacySafari, isMobile, isSamsungBrowser };
|