@dynamic-labs/utils 0.19.0-alpha.8 → 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 CHANGED
@@ -1,4 +1,33 @@
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
+
2
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)
3
32
 
4
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/utils",
3
- "version": "0.19.0-alpha.8",
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.8",
30
- "@dynamic-labs/types": "0.19.0-alpha.8"
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,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
@@ -26,6 +26,7 @@ var isMobile = require('./isMobile.cjs');
26
26
  var localStorageAsync = require('./localStorageAsync.cjs');
27
27
  var bufferToBase64 = require('./bufferToBase64.cjs');
28
28
  var last = require('./last.cjs');
29
+ var getPathFromObject = require('./getPathFromObject.cjs');
29
30
 
30
31
 
31
32
 
@@ -53,6 +54,7 @@ exports.isAndroid = isMobile.isAndroid;
53
54
  exports.isIOS = isMobile.isIOS;
54
55
  exports.isIPad = isMobile.isIPad;
55
56
  exports.isIPhone = isMobile.isIPhone;
57
+ exports.isIPhone8OrEarlier = isMobile.isIPhone8OrEarlier;
56
58
  exports.isLegacySafari = isMobile.isLegacySafari;
57
59
  exports.isMobile = isMobile.isMobile;
58
60
  exports.isSamsungBrowser = isMobile.isSamsungBrowser;
@@ -61,3 +63,4 @@ exports.removeItemAsync = localStorageAsync.removeItemAsync;
61
63
  exports.setItemAsync = localStorageAsync.setItemAsync;
62
64
  exports.bufferToBase64 = bufferToBase64.bufferToBase64;
63
65
  exports.last = last.last;
66
+ exports.getPathFromObject = getPathFromObject.getPathFromObject;
package/src/index.d.ts CHANGED
@@ -7,3 +7,4 @@ export * from './isMobile';
7
7
  export * from './localStorageAsync';
8
8
  export * from './bufferToBase64';
9
9
  export * from './last';
10
+ export * from './getPathFromObject';
package/src/index.js CHANGED
@@ -18,7 +18,8 @@ export { UserHasAccountWithEmailError } from './errors/UserHasAccountWithEmailEr
18
18
  export { SocialAccountAlreadyExistsError } from './errors/SocialAccountAlreadyExistsError.js';
19
19
  export { CancellablePromise } from './CancellablePromise/CancellablePromise.js';
20
20
  export { isFunction } from './isFunction/isFunction.js';
21
- export { isAndroid, isIOS, isIPad, isIPhone, isLegacySafari, isMobile, isSamsungBrowser } from './isMobile.js';
21
+ export { isAndroid, isIOS, isIPad, isIPhone, isIPhone8OrEarlier, isLegacySafari, isMobile, isSamsungBrowser } from './isMobile.js';
22
22
  export { getItemAsync, removeItemAsync, setItemAsync } from './localStorageAsync.js';
23
23
  export { bufferToBase64 } from './bufferToBase64.js';
24
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 };