@dynamic-labs/utils 0.17.0-RC.10
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 +793 -0
- package/LICENSE +21 -0
- package/README.md +0 -0
- package/_virtual/_tslib.cjs +30 -0
- package/_virtual/_tslib.js +26 -0
- package/package.json +32 -0
- package/src/CancellablePromise/CancellablePromise.cjs +33 -0
- package/src/CancellablePromise/CancellablePromise.d.ts +9 -0
- package/src/CancellablePromise/CancellablePromise.js +29 -0
- package/src/CancellablePromise/index.d.ts +1 -0
- package/src/bufferToBase64.cjs +12 -0
- package/src/bufferToBase64.d.ts +1 -0
- package/src/bufferToBase64.js +8 -0
- package/src/errors/ChainalysisError.cjs +14 -0
- package/src/errors/ChainalysisError.d.ts +5 -0
- package/src/errors/ChainalysisError.js +10 -0
- package/src/errors/CustomError.cjs +23 -0
- package/src/errors/CustomError.d.ts +11 -0
- package/src/errors/CustomError.js +19 -0
- package/src/errors/DynamicError.cjs +10 -0
- package/src/errors/DynamicError.d.ts +3 -0
- package/src/errors/DynamicError.js +6 -0
- package/src/errors/EmailAlreadyExistsError.cjs +13 -0
- package/src/errors/EmailAlreadyExistsError.d.ts +4 -0
- package/src/errors/EmailAlreadyExistsError.js +9 -0
- package/src/errors/EmailVerificationError.cjs +13 -0
- package/src/errors/EmailVerificationError.d.ts +4 -0
- package/src/errors/EmailVerificationError.js +9 -0
- package/src/errors/NoAccessError.cjs +15 -0
- package/src/errors/NoAccessError.d.ts +9 -0
- package/src/errors/NoAccessError.js +11 -0
- package/src/errors/NotSupportedError.cjs +10 -0
- package/src/errors/NotSupportedError.d.ts +3 -0
- package/src/errors/NotSupportedError.js +6 -0
- package/src/errors/UsernameAlreadyExistsError.cjs +13 -0
- package/src/errors/UsernameAlreadyExistsError.d.ts +4 -0
- package/src/errors/UsernameAlreadyExistsError.js +9 -0
- package/src/errors/WalletNotDeployedError.cjs +13 -0
- package/src/errors/WalletNotDeployedError.d.ts +4 -0
- package/src/errors/WalletNotDeployedError.js +9 -0
- package/src/errors/WalletUsedError.cjs +13 -0
- package/src/errors/WalletUsedError.d.ts +4 -0
- package/src/errors/WalletUsedError.js +9 -0
- package/src/errors/index.d.ts +10 -0
- package/src/index.cjs +47 -0
- package/src/index.d.ts +8 -0
- package/src/index.js +17 -0
- package/src/isFunction/index.d.ts +1 -0
- package/src/isFunction/isFunction.cjs +8 -0
- package/src/isFunction/isFunction.d.ts +1 -0
- package/src/isFunction/isFunction.js +4 -0
- package/src/isMobile.cjs +54 -0
- package/src/isMobile.d.ts +13 -0
- package/src/isMobile.js +46 -0
- package/src/localStorageAsync.cjs +28 -0
- package/src/localStorageAsync.d.ts +3 -0
- package/src/localStorageAsync.js +22 -0
- package/src/parseChainId.cjs +7 -0
- package/src/parseChainId.d.ts +1 -0
- package/src/parseChainId.js +3 -0
- package/src/parseEvmNetworks.cjs +15 -0
- package/src/parseEvmNetworks.d.ts +2 -0
- package/src/parseEvmNetworks.js +11 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isFunction: (value: Function | unknown) => value is Function;
|
package/src/isMobile.cjs
ADDED
|
@@ -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;
|
package/src/isMobile.js
ADDED
|
@@ -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 };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../_virtual/_tslib.cjs');
|
|
6
|
+
|
|
7
|
+
const getItemAsync = (key) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
8
|
+
if (typeof window === 'undefined') {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
return window.localStorage.getItem(key) || undefined;
|
|
12
|
+
});
|
|
13
|
+
const setItemAsync = (key, value) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
if (typeof window === 'undefined') {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
return window.localStorage.setItem(key, value);
|
|
18
|
+
});
|
|
19
|
+
const removeItemAsync = (key) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
if (typeof window === 'undefined') {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return localStorage.removeItem(key);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
exports.getItemAsync = getItemAsync;
|
|
27
|
+
exports.removeItemAsync = removeItemAsync;
|
|
28
|
+
exports.setItemAsync = setItemAsync;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
|
+
|
|
3
|
+
const getItemAsync = (key) => __awaiter(void 0, void 0, void 0, function* () {
|
|
4
|
+
if (typeof window === 'undefined') {
|
|
5
|
+
return undefined;
|
|
6
|
+
}
|
|
7
|
+
return window.localStorage.getItem(key) || undefined;
|
|
8
|
+
});
|
|
9
|
+
const setItemAsync = (key, value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
10
|
+
if (typeof window === 'undefined') {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
return window.localStorage.setItem(key, value);
|
|
14
|
+
});
|
|
15
|
+
const removeItemAsync = (key) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
if (typeof window === 'undefined') {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
return localStorage.removeItem(key);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export { getItemAsync, removeItemAsync, setItemAsync };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseChainId: (chainId: number | string) => number;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var parseChainId = require('./parseChainId.cjs');
|
|
6
|
+
|
|
7
|
+
const parseEvmNetworks = (networks) => {
|
|
8
|
+
const clone = networks.slice();
|
|
9
|
+
return clone.map((network) => {
|
|
10
|
+
network.chainId = parseChainId.parseChainId(network.chainId);
|
|
11
|
+
return network;
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.parseEvmNetworks = parseEvmNetworks;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { parseChainId } from './parseChainId.js';
|
|
2
|
+
|
|
3
|
+
const parseEvmNetworks = (networks) => {
|
|
4
|
+
const clone = networks.slice();
|
|
5
|
+
return clone.map((network) => {
|
|
6
|
+
network.chainId = parseChainId(network.chainId);
|
|
7
|
+
return network;
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export { parseEvmNetworks };
|