@dynamic-labs/utils 0.17.0-RC.8 → 0.17.0-RC.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,19 @@
1
1
 
2
+ ## [0.17.0-RC.9](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.8...v0.17.0-RC.9) (2023-05-05)
3
+
4
+
5
+ ### Features
6
+
7
+ * **DYN-2231:** show in the user profile all existing fields ([#1988](https://github.com/dynamic-labs/DynamicAuth/issues/1988)) ([1f8cee2](https://github.com/dynamic-labs/DynamicAuth/commit/1f8cee22cf8338bd518961288c570c40e807cd52))
8
+ * **TransactionModal:** add insufficient funds warning ([#2031](https://github.com/dynamic-labs/DynamicAuth/issues/2031)) ([bf868e2](https://github.com/dynamic-labs/DynamicAuth/commit/bf868e239e74f4cd0ceda5e09b7538d97d4e431d))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **DYN-1820:** use missing_from_list error code ([#2040](https://github.com/dynamic-labs/DynamicAuth/issues/2040)) ([92c7ad5](https://github.com/dynamic-labs/DynamicAuth/commit/92c7ad565376573d963c65fa821c97a2102ec8d7))
14
+ * **MagicClientNetworkHandler:** save last used network id ([#2045](https://github.com/dynamic-labs/DynamicAuth/issues/2045)) ([6e1c571](https://github.com/dynamic-labs/DynamicAuth/commit/6e1c57127a824cd02d4b785fb8a387e4f221f044))
15
+ * **TransactionModal:** ensure alchemy will not fail when estimating for gas ([#2034](https://github.com/dynamic-labs/DynamicAuth/issues/2034)) ([86c0d7c](https://github.com/dynamic-labs/DynamicAuth/commit/86c0d7cc7b20ff12bc9fc2e33961e177d9decf2a))
16
+
2
17
  ## [0.17.0-RC.8](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.0-RC.7...v0.17.0-RC.8) (2023-05-03)
3
18
 
4
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/utils",
3
- "version": "0.17.0-RC.8",
3
+ "version": "0.17.0-RC.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -26,7 +26,7 @@
26
26
  "./package.json": "./package.json"
27
27
  },
28
28
  "dependencies": {
29
- "@dynamic-labs/types": "0.17.0-RC.8"
29
+ "@dynamic-labs/types": "0.17.0-RC.9"
30
30
  },
31
31
  "peerDependencies": {}
32
32
  }
package/src/index.cjs CHANGED
@@ -15,6 +15,8 @@ var UsernameAlreadyExistsError = require('./errors/UsernameAlreadyExistsError.cj
15
15
  var WalletNotDeployedError = require('./errors/WalletNotDeployedError.cjs');
16
16
  var WalletUsedError = require('./errors/WalletUsedError.cjs');
17
17
  var CancellablePromise = require('./CancellablePromise/CancellablePromise.cjs');
18
+ var isFunction = require('./isFunction/isFunction.cjs');
19
+ var isMobile = require('./isMobile.cjs');
18
20
 
19
21
 
20
22
 
@@ -31,3 +33,9 @@ exports.UsernameAlreadyExistsError = UsernameAlreadyExistsError.UsernameAlreadyE
31
33
  exports.WalletNotDeployedError = WalletNotDeployedError.WalletNotDeployedError;
32
34
  exports.WalletUsedError = WalletUsedError.WalletUsedError;
33
35
  exports.CancellablePromise = CancellablePromise.CancellablePromise;
36
+ exports.isFunction = isFunction.isFunction;
37
+ exports.isIOS = isMobile.isIOS;
38
+ exports.isIPad = isMobile.isIPad;
39
+ exports.isIPhone = isMobile.isIPhone;
40
+ exports.isMobile = isMobile.isMobile;
41
+ exports.isSamsungBrowser = isMobile.isSamsungBrowser;
package/src/index.d.ts CHANGED
@@ -2,3 +2,5 @@ export * from './parseChainId';
2
2
  export * from './parseEvmNetworks';
3
3
  export * from './errors';
4
4
  export * from './CancellablePromise';
5
+ export * from './isFunction';
6
+ export * from './isMobile';
package/src/index.js CHANGED
@@ -11,3 +11,5 @@ export { UsernameAlreadyExistsError } from './errors/UsernameAlreadyExistsError.
11
11
  export { WalletNotDeployedError } from './errors/WalletNotDeployedError.js';
12
12
  export { WalletUsedError } from './errors/WalletUsedError.js';
13
13
  export { CancellablePromise } from './CancellablePromise/CancellablePromise.js';
14
+ export { isFunction } from './isFunction/isFunction.js';
15
+ export { isIOS, isIPad, isIPhone, isMobile, isSamsungBrowser } from './isMobile.js';
@@ -0,0 +1 @@
1
+ export { isFunction } from './isFunction';
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ // eslint-disable-next-line @typescript-eslint/ban-types
6
+ const isFunction = (value) => typeof value === 'function';
7
+
8
+ exports.isFunction = isFunction;
@@ -0,0 +1 @@
1
+ export declare const isFunction: (value: Function | unknown) => value is Function;
@@ -0,0 +1,4 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-types
2
+ const isFunction = (value) => typeof value === 'function';
3
+
4
+ export { isFunction };
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * Sourced from http://detectmobilebrowsers.com/
7
+ */
8
+ /* eslint-disable max-len, no-useless-escape */
9
+ const userAgentRegex1 = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i;
10
+ const userAgentRegex2 = /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i;
11
+ // This is a regex that covers both iphone, android and any other mobile device.
12
+ const isMobile = (maxTouchPointsOverride) => {
13
+ if (typeof window === 'undefined' || typeof navigator === 'undefined') {
14
+ return false;
15
+ }
16
+ return (userAgentRegex1.test(navigator.userAgent) ||
17
+ userAgentRegex2.test(navigator.userAgent.substring(0, 4)) ||
18
+ isIPad(maxTouchPointsOverride) ||
19
+ isIPhone());
20
+ };
21
+ const isIPhone = () => typeof window === 'undefined' || typeof navigator === 'undefined'
22
+ ? false
23
+ : /iPhone/.test(navigator.userAgent);
24
+ /**
25
+ * @param [optional] maxTouchPointsOverride - this is used for testing since
26
+ * it seems that JSDOM doesn't support maxTouchPoints, so it was impossible
27
+ * to mock it
28
+ */
29
+ const isIPad = (maxTouchPointsOverride) => {
30
+ if (typeof window === 'undefined' || typeof navigator === 'undefined') {
31
+ return false;
32
+ }
33
+ const maxTouchPoints = maxTouchPointsOverride || navigator.maxTouchPoints;
34
+ return (/iPad/.test(navigator.userAgent) ||
35
+ (/Mac/.test(navigator.userAgent) && maxTouchPoints === 5));
36
+ };
37
+ const isIOS = (maxTouchPointsOverride) => {
38
+ if (typeof window === 'undefined' || typeof navigator === 'undefined') {
39
+ return false;
40
+ }
41
+ return isIPhone() || isIPad(maxTouchPointsOverride);
42
+ };
43
+ const isSamsungBrowser = () => {
44
+ if (typeof window === 'undefined' || typeof navigator === 'undefined') {
45
+ return false;
46
+ }
47
+ return navigator.userAgent.includes('SamsungBrowser');
48
+ };
49
+
50
+ exports.isIOS = isIOS;
51
+ exports.isIPad = isIPad;
52
+ exports.isIPhone = isIPhone;
53
+ exports.isMobile = isMobile;
54
+ exports.isSamsungBrowser = isSamsungBrowser;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Sourced from http://detectmobilebrowsers.com/
3
+ */
4
+ export declare const isMobile: (maxTouchPointsOverride?: number) => boolean;
5
+ export declare const isIPhone: () => boolean;
6
+ /**
7
+ * @param [optional] maxTouchPointsOverride - this is used for testing since
8
+ * it seems that JSDOM doesn't support maxTouchPoints, so it was impossible
9
+ * to mock it
10
+ */
11
+ export declare const isIPad: (maxTouchPointsOverride?: number) => boolean;
12
+ export declare const isIOS: (maxTouchPointsOverride?: number) => boolean;
13
+ export declare const isSamsungBrowser: () => boolean;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Sourced from http://detectmobilebrowsers.com/
3
+ */
4
+ /* eslint-disable max-len, no-useless-escape */
5
+ const userAgentRegex1 = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i;
6
+ const userAgentRegex2 = /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i;
7
+ // This is a regex that covers both iphone, android and any other mobile device.
8
+ const isMobile = (maxTouchPointsOverride) => {
9
+ if (typeof window === 'undefined' || typeof navigator === 'undefined') {
10
+ return false;
11
+ }
12
+ return (userAgentRegex1.test(navigator.userAgent) ||
13
+ userAgentRegex2.test(navigator.userAgent.substring(0, 4)) ||
14
+ isIPad(maxTouchPointsOverride) ||
15
+ isIPhone());
16
+ };
17
+ const isIPhone = () => typeof window === 'undefined' || typeof navigator === 'undefined'
18
+ ? false
19
+ : /iPhone/.test(navigator.userAgent);
20
+ /**
21
+ * @param [optional] maxTouchPointsOverride - this is used for testing since
22
+ * it seems that JSDOM doesn't support maxTouchPoints, so it was impossible
23
+ * to mock it
24
+ */
25
+ const isIPad = (maxTouchPointsOverride) => {
26
+ if (typeof window === 'undefined' || typeof navigator === 'undefined') {
27
+ return false;
28
+ }
29
+ const maxTouchPoints = maxTouchPointsOverride || navigator.maxTouchPoints;
30
+ return (/iPad/.test(navigator.userAgent) ||
31
+ (/Mac/.test(navigator.userAgent) && maxTouchPoints === 5));
32
+ };
33
+ const isIOS = (maxTouchPointsOverride) => {
34
+ if (typeof window === 'undefined' || typeof navigator === 'undefined') {
35
+ return false;
36
+ }
37
+ return isIPhone() || isIPad(maxTouchPointsOverride);
38
+ };
39
+ const isSamsungBrowser = () => {
40
+ if (typeof window === 'undefined' || typeof navigator === 'undefined') {
41
+ return false;
42
+ }
43
+ return navigator.userAgent.includes('SamsungBrowser');
44
+ };
45
+
46
+ export { isIOS, isIPad, isIPhone, isMobile, isSamsungBrowser };