@capsitech/react-utilities 0.1.4 → 0.1.6
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/lib/Components/SuspenseRoute.d.ts +7 -7
- package/lib/Components/SuspenseRoute.js +29 -29
- package/lib/Components/index.d.ts +1 -1
- package/lib/Components/index.js +1 -1
- package/lib/Hooks/index.d.ts +45 -45
- package/lib/Hooks/index.js +98 -98
- package/lib/Hooks/useInfiniteScroll.d.ts +7 -7
- package/lib/Hooks/useInfiniteScroll.js +22 -22
- package/lib/Hooks/useNetworkState.d.ts +67 -67
- package/lib/Hooks/useNetworkState.js +41 -41
- package/lib/Hooks/useShortcuts.d.ts +4 -4
- package/lib/Hooks/useShortcuts.js +91 -91
- package/lib/Utilities/ApiUtility.axios.d.ts +60 -60
- package/lib/Utilities/ApiUtility.axios.js +305 -305
- package/lib/Utilities/BrowserInfo.d.ts +74 -74
- package/lib/Utilities/BrowserInfo.js +153 -153
- package/lib/Utilities/Countries.d.ts +14 -14
- package/lib/Utilities/Countries.js +290 -290
- package/lib/Utilities/CustomEventEmitter.d.ts +12 -12
- package/lib/Utilities/CustomEventEmitter.js +30 -30
- package/lib/Utilities/FastCompare.d.ts +1 -1
- package/lib/Utilities/FastCompare.js +128 -128
- package/lib/Utilities/HideablePromise.d.ts +5 -5
- package/lib/Utilities/HideablePromise.js +10 -10
- package/lib/Utilities/LoadScripts.d.ts +9 -9
- package/lib/Utilities/LoadScripts.js +51 -51
- package/lib/Utilities/MTDFraudPrevention.d.ts +28 -28
- package/lib/Utilities/MTDFraudPrevention.js +157 -157
- package/lib/Utilities/Nationalities.d.ts +5 -5
- package/lib/Utilities/Nationalities.js +245 -245
- package/lib/Utilities/RouteUtils.d.ts +129 -120
- package/lib/Utilities/RouteUtils.js +223 -206
- package/lib/Utilities/TimeZones.d.ts +10 -10
- package/lib/Utilities/TimeZones.js +1069 -1069
- package/lib/Utilities/Types.d.ts +19 -19
- package/lib/Utilities/Types.js +1 -1
- package/lib/Utilities/Utils.d.ts +174 -174
- package/lib/Utilities/Utils.js +331 -331
- package/lib/Utilities/dayjs.d.ts +18 -18
- package/lib/Utilities/dayjs.js +56 -56
- package/lib/Utilities/index.d.ts +14 -14
- package/lib/Utilities/index.js +14 -14
- package/lib/index.d.ts +3 -3
- package/lib/index.js +3 -3
- package/package.json +12 -25
|
@@ -1,157 +1,157 @@
|
|
|
1
|
-
import { getScreenColourDepth, getScreenHeight, getScreenScalingFactor, getScreenWidth, getTimezone, getWindowHeight, getWindowWidth } from './BrowserInfo';
|
|
2
|
-
/**
|
|
3
|
-
* Enum object of keys for each header in the Map returned by getFraudPreventionHeaders().headers
|
|
4
|
-
*/
|
|
5
|
-
export const fraudPreventionHeadersEnum = {
|
|
6
|
-
TIMEZONE: 'Gov-Client-Timezone',
|
|
7
|
-
SCREENS_DETAILS: 'Gov-Client-Screens',
|
|
8
|
-
WINDOW_SIZE: 'Gov-Client-Window-Size',
|
|
9
|
-
//BROWSER_PLUGINS: 'Gov-Client-Browser-Plugins',
|
|
10
|
-
//BROWSER_DONOTTRACK: 'Gov-Client-Browser-Do-Not-Track',
|
|
11
|
-
//DEVICE_LOCAL_IPS: 'Gov-Client-Local-IPs',
|
|
12
|
-
//DEVICE_LOCAL_IPS_TIMESTAMP: 'Gov-Client-Local-IPs-Timestamp',
|
|
13
|
-
//DEVICE_ID: 'Gov-Client-Device-ID',
|
|
14
|
-
//BROWSER_USER_AGENT: 'Gov-Client-Browser-JS-User-Agent',
|
|
15
|
-
};
|
|
16
|
-
const getScreenData = () => {
|
|
17
|
-
const screenDetails = `width=${getScreenWidth()}&height=${getScreenHeight()}&scaling-factor=${getScreenScalingFactor()}&colour-depth=${getScreenColourDepth()}`;
|
|
18
|
-
return encodeURI(screenDetails);
|
|
19
|
-
};
|
|
20
|
-
export const getScreenDetails = () => {
|
|
21
|
-
return {
|
|
22
|
-
width: getScreenWidth(),
|
|
23
|
-
height: getScreenHeight(),
|
|
24
|
-
colorDepth: getScreenColourDepth(),
|
|
25
|
-
scalingFactor: getScreenScalingFactor(),
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
const getWindowSize = () => {
|
|
29
|
-
const windowSize = `width=${getWindowWidth()}&height=${getWindowHeight()}`;
|
|
30
|
-
return encodeURI(windowSize);
|
|
31
|
-
};
|
|
32
|
-
export const windowDetails = () => {
|
|
33
|
-
return {
|
|
34
|
-
width: getWindowWidth(),
|
|
35
|
-
height: getWindowHeight(),
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Returns Map of HMRC Fraud prevention headers.
|
|
40
|
-
* @returns {Promise<IHeaderValues>} with two fields headers and errors - The headers are a Map object and the errors are an array. If there are no errors, the array is empty
|
|
41
|
-
*/
|
|
42
|
-
export const getFraudPreventionHeaders = async () => {
|
|
43
|
-
const headers = {};
|
|
44
|
-
const errors = [];
|
|
45
|
-
const headerFunctions = [
|
|
46
|
-
{ header: fraudPreventionHeadersEnum.TIMEZONE, callback: getTimezone },
|
|
47
|
-
{
|
|
48
|
-
header: fraudPreventionHeadersEnum.SCREENS_DETAILS,
|
|
49
|
-
callback: getScreenData,
|
|
50
|
-
},
|
|
51
|
-
{ header: fraudPreventionHeadersEnum.WINDOW_SIZE, callback: getWindowSize },
|
|
52
|
-
// {
|
|
53
|
-
// header: fraudPreventionHeadersEnum.BROWSER_PLUGINS,
|
|
54
|
-
// callback: () => encodeURI(getBrowserPluginsAsString()),
|
|
55
|
-
// },
|
|
56
|
-
// {
|
|
57
|
-
// header: fraudPreventionHeadersEnum.BROWSER_DONOTTRACK,
|
|
58
|
-
// callback: getBrowserDoNotTrackStatus,
|
|
59
|
-
// },
|
|
60
|
-
//{ header: fraudPreventionHeadersEnum.DEVICE_ID, callback: generateClientDeviceID},
|
|
61
|
-
//{ header: fraudPreventionHeadersEnum.BROWSER_USER_AGENT, callback: getUserAgent },
|
|
62
|
-
];
|
|
63
|
-
for (let i = 0; i < headerFunctions.length; i++) {
|
|
64
|
-
try {
|
|
65
|
-
const { header, callback } = headerFunctions[i];
|
|
66
|
-
headers[header] = callback();
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
errors.push({ header: headerFunctions[i], error });
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
// try {
|
|
73
|
-
// const ipAddress = await getDeviceLocalIPAsString();
|
|
74
|
-
// headers[fraudPreventionHeadersEnum.DEVICE_LOCAL_IPS] = encodeURI(ipAddress.deviceIpString);
|
|
75
|
-
// headers[fraudPreventionHeadersEnum.DEVICE_LOCAL_IPS_TIMESTAMP] = ipAddress.deviceIpTimeStamp;
|
|
76
|
-
// } catch (error) {
|
|
77
|
-
// errors.push({ header: 'IPs', error });
|
|
78
|
-
// }
|
|
79
|
-
return { headers, errors };
|
|
80
|
-
};
|
|
81
|
-
// /**
|
|
82
|
-
// * Returns "Gov-Client-Browser-JS-User-Agent" header.
|
|
83
|
-
// * @returns {IHeaderValue} which has headerValue key having the value of the header or error key if there is an error
|
|
84
|
-
// */
|
|
85
|
-
// export const getGovClientBrowserJSUserAgentHeader = (): IHeaderValue => {
|
|
86
|
-
// try {
|
|
87
|
-
// return { headerValue: getUserAgent() };
|
|
88
|
-
// } catch (error) {
|
|
89
|
-
// return { error };
|
|
90
|
-
// }
|
|
91
|
-
// };
|
|
92
|
-
// /**
|
|
93
|
-
// * Returns the value for Gov-Client-Browser-Plugins HMRC Fraud prevention header.
|
|
94
|
-
// */
|
|
95
|
-
// export const getGovClientBrowserPluginsHeader = (): IHeaderValue => {
|
|
96
|
-
// try {
|
|
97
|
-
// return { headerValue: encodeURI(getBrowserPluginsAsString()) };
|
|
98
|
-
// } catch (error) {
|
|
99
|
-
// return { error };
|
|
100
|
-
// }
|
|
101
|
-
// };
|
|
102
|
-
// /**
|
|
103
|
-
// * Returns the value for Gov-Client-Browser-Do-Not-Track HMRC Fraud prevention header.
|
|
104
|
-
// */
|
|
105
|
-
// export const getGovClientBrowserDoNotTrackHeader = (): IHeaderValue => {
|
|
106
|
-
// try {
|
|
107
|
-
// return { headerValue: getBrowserDoNotTrackStatus() };
|
|
108
|
-
// } catch (error) {
|
|
109
|
-
// return { error };
|
|
110
|
-
// }
|
|
111
|
-
// };
|
|
112
|
-
// /**
|
|
113
|
-
// * Returns the value for Gov-Client-Timezone HMRC Fraud prevention header.
|
|
114
|
-
// * @returns {IHeaderValue} with headerValue field or error field in case of an exception
|
|
115
|
-
// */
|
|
116
|
-
// export const getGovClientTimezoneHeader = (): IHeaderValue => {
|
|
117
|
-
// try {
|
|
118
|
-
// return { headerValue: getTimezone() };
|
|
119
|
-
// } catch (error) {
|
|
120
|
-
// return { error };
|
|
121
|
-
// }
|
|
122
|
-
// };
|
|
123
|
-
// /**
|
|
124
|
-
// * Returns Gov-Client-Local-IPs header value
|
|
125
|
-
// * @returns {Promise<IHeaderValue>} which has header key having the value of the header or error key if there is an error
|
|
126
|
-
// */
|
|
127
|
-
// export const getGovClientLocalIPsHeader = async (): Promise<IHeaderValue> => {
|
|
128
|
-
// try {
|
|
129
|
-
// const ipAddress = await getDeviceLocalIPAsString();
|
|
130
|
-
// return {
|
|
131
|
-
// headerValue: encodeURI(ipAddress.deviceIpString),
|
|
132
|
-
// };
|
|
133
|
-
// } catch (error) {
|
|
134
|
-
// return { error };
|
|
135
|
-
// }
|
|
136
|
-
// };
|
|
137
|
-
// /**
|
|
138
|
-
// * Returns the value for Gov-Client-Window-Size HMRC Fraud prevention header.
|
|
139
|
-
// */
|
|
140
|
-
// export const getGovClientWindowSizeHeader = () => {
|
|
141
|
-
// try {
|
|
142
|
-
// return { headerValue: getWindowSize() };
|
|
143
|
-
// } catch (error) {
|
|
144
|
-
// return { error };
|
|
145
|
-
// }
|
|
146
|
-
// };
|
|
147
|
-
// /**
|
|
148
|
-
// * Returns the value for Gov-Client-Screens HMRC Fraud prevention header.
|
|
149
|
-
// * @returns {object} with headerValue key having the value of the header or error key if there is an error
|
|
150
|
-
// */
|
|
151
|
-
// export const getGovClientScreensHeader = () => {
|
|
152
|
-
// try {
|
|
153
|
-
// return { headerValue: getScreenData() };
|
|
154
|
-
// } catch (error) {
|
|
155
|
-
// return { error };
|
|
156
|
-
// }
|
|
157
|
-
// };
|
|
1
|
+
import { getScreenColourDepth, getScreenHeight, getScreenScalingFactor, getScreenWidth, getTimezone, getWindowHeight, getWindowWidth } from './BrowserInfo';
|
|
2
|
+
/**
|
|
3
|
+
* Enum object of keys for each header in the Map returned by getFraudPreventionHeaders().headers
|
|
4
|
+
*/
|
|
5
|
+
export const fraudPreventionHeadersEnum = {
|
|
6
|
+
TIMEZONE: 'Gov-Client-Timezone',
|
|
7
|
+
SCREENS_DETAILS: 'Gov-Client-Screens',
|
|
8
|
+
WINDOW_SIZE: 'Gov-Client-Window-Size',
|
|
9
|
+
//BROWSER_PLUGINS: 'Gov-Client-Browser-Plugins',
|
|
10
|
+
//BROWSER_DONOTTRACK: 'Gov-Client-Browser-Do-Not-Track',
|
|
11
|
+
//DEVICE_LOCAL_IPS: 'Gov-Client-Local-IPs',
|
|
12
|
+
//DEVICE_LOCAL_IPS_TIMESTAMP: 'Gov-Client-Local-IPs-Timestamp',
|
|
13
|
+
//DEVICE_ID: 'Gov-Client-Device-ID',
|
|
14
|
+
//BROWSER_USER_AGENT: 'Gov-Client-Browser-JS-User-Agent',
|
|
15
|
+
};
|
|
16
|
+
const getScreenData = () => {
|
|
17
|
+
const screenDetails = `width=${getScreenWidth()}&height=${getScreenHeight()}&scaling-factor=${getScreenScalingFactor()}&colour-depth=${getScreenColourDepth()}`;
|
|
18
|
+
return encodeURI(screenDetails);
|
|
19
|
+
};
|
|
20
|
+
export const getScreenDetails = () => {
|
|
21
|
+
return {
|
|
22
|
+
width: getScreenWidth(),
|
|
23
|
+
height: getScreenHeight(),
|
|
24
|
+
colorDepth: getScreenColourDepth(),
|
|
25
|
+
scalingFactor: getScreenScalingFactor(),
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const getWindowSize = () => {
|
|
29
|
+
const windowSize = `width=${getWindowWidth()}&height=${getWindowHeight()}`;
|
|
30
|
+
return encodeURI(windowSize);
|
|
31
|
+
};
|
|
32
|
+
export const windowDetails = () => {
|
|
33
|
+
return {
|
|
34
|
+
width: getWindowWidth(),
|
|
35
|
+
height: getWindowHeight(),
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Returns Map of HMRC Fraud prevention headers.
|
|
40
|
+
* @returns {Promise<IHeaderValues>} with two fields headers and errors - The headers are a Map object and the errors are an array. If there are no errors, the array is empty
|
|
41
|
+
*/
|
|
42
|
+
export const getFraudPreventionHeaders = async () => {
|
|
43
|
+
const headers = {};
|
|
44
|
+
const errors = [];
|
|
45
|
+
const headerFunctions = [
|
|
46
|
+
{ header: fraudPreventionHeadersEnum.TIMEZONE, callback: getTimezone },
|
|
47
|
+
{
|
|
48
|
+
header: fraudPreventionHeadersEnum.SCREENS_DETAILS,
|
|
49
|
+
callback: getScreenData,
|
|
50
|
+
},
|
|
51
|
+
{ header: fraudPreventionHeadersEnum.WINDOW_SIZE, callback: getWindowSize },
|
|
52
|
+
// {
|
|
53
|
+
// header: fraudPreventionHeadersEnum.BROWSER_PLUGINS,
|
|
54
|
+
// callback: () => encodeURI(getBrowserPluginsAsString()),
|
|
55
|
+
// },
|
|
56
|
+
// {
|
|
57
|
+
// header: fraudPreventionHeadersEnum.BROWSER_DONOTTRACK,
|
|
58
|
+
// callback: getBrowserDoNotTrackStatus,
|
|
59
|
+
// },
|
|
60
|
+
//{ header: fraudPreventionHeadersEnum.DEVICE_ID, callback: generateClientDeviceID},
|
|
61
|
+
//{ header: fraudPreventionHeadersEnum.BROWSER_USER_AGENT, callback: getUserAgent },
|
|
62
|
+
];
|
|
63
|
+
for (let i = 0; i < headerFunctions.length; i++) {
|
|
64
|
+
try {
|
|
65
|
+
const { header, callback } = headerFunctions[i];
|
|
66
|
+
headers[header] = callback();
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
errors.push({ header: headerFunctions[i], error });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// try {
|
|
73
|
+
// const ipAddress = await getDeviceLocalIPAsString();
|
|
74
|
+
// headers[fraudPreventionHeadersEnum.DEVICE_LOCAL_IPS] = encodeURI(ipAddress.deviceIpString);
|
|
75
|
+
// headers[fraudPreventionHeadersEnum.DEVICE_LOCAL_IPS_TIMESTAMP] = ipAddress.deviceIpTimeStamp;
|
|
76
|
+
// } catch (error) {
|
|
77
|
+
// errors.push({ header: 'IPs', error });
|
|
78
|
+
// }
|
|
79
|
+
return { headers, errors };
|
|
80
|
+
};
|
|
81
|
+
// /**
|
|
82
|
+
// * Returns "Gov-Client-Browser-JS-User-Agent" header.
|
|
83
|
+
// * @returns {IHeaderValue} which has headerValue key having the value of the header or error key if there is an error
|
|
84
|
+
// */
|
|
85
|
+
// export const getGovClientBrowserJSUserAgentHeader = (): IHeaderValue => {
|
|
86
|
+
// try {
|
|
87
|
+
// return { headerValue: getUserAgent() };
|
|
88
|
+
// } catch (error) {
|
|
89
|
+
// return { error };
|
|
90
|
+
// }
|
|
91
|
+
// };
|
|
92
|
+
// /**
|
|
93
|
+
// * Returns the value for Gov-Client-Browser-Plugins HMRC Fraud prevention header.
|
|
94
|
+
// */
|
|
95
|
+
// export const getGovClientBrowserPluginsHeader = (): IHeaderValue => {
|
|
96
|
+
// try {
|
|
97
|
+
// return { headerValue: encodeURI(getBrowserPluginsAsString()) };
|
|
98
|
+
// } catch (error) {
|
|
99
|
+
// return { error };
|
|
100
|
+
// }
|
|
101
|
+
// };
|
|
102
|
+
// /**
|
|
103
|
+
// * Returns the value for Gov-Client-Browser-Do-Not-Track HMRC Fraud prevention header.
|
|
104
|
+
// */
|
|
105
|
+
// export const getGovClientBrowserDoNotTrackHeader = (): IHeaderValue => {
|
|
106
|
+
// try {
|
|
107
|
+
// return { headerValue: getBrowserDoNotTrackStatus() };
|
|
108
|
+
// } catch (error) {
|
|
109
|
+
// return { error };
|
|
110
|
+
// }
|
|
111
|
+
// };
|
|
112
|
+
// /**
|
|
113
|
+
// * Returns the value for Gov-Client-Timezone HMRC Fraud prevention header.
|
|
114
|
+
// * @returns {IHeaderValue} with headerValue field or error field in case of an exception
|
|
115
|
+
// */
|
|
116
|
+
// export const getGovClientTimezoneHeader = (): IHeaderValue => {
|
|
117
|
+
// try {
|
|
118
|
+
// return { headerValue: getTimezone() };
|
|
119
|
+
// } catch (error) {
|
|
120
|
+
// return { error };
|
|
121
|
+
// }
|
|
122
|
+
// };
|
|
123
|
+
// /**
|
|
124
|
+
// * Returns Gov-Client-Local-IPs header value
|
|
125
|
+
// * @returns {Promise<IHeaderValue>} which has header key having the value of the header or error key if there is an error
|
|
126
|
+
// */
|
|
127
|
+
// export const getGovClientLocalIPsHeader = async (): Promise<IHeaderValue> => {
|
|
128
|
+
// try {
|
|
129
|
+
// const ipAddress = await getDeviceLocalIPAsString();
|
|
130
|
+
// return {
|
|
131
|
+
// headerValue: encodeURI(ipAddress.deviceIpString),
|
|
132
|
+
// };
|
|
133
|
+
// } catch (error) {
|
|
134
|
+
// return { error };
|
|
135
|
+
// }
|
|
136
|
+
// };
|
|
137
|
+
// /**
|
|
138
|
+
// * Returns the value for Gov-Client-Window-Size HMRC Fraud prevention header.
|
|
139
|
+
// */
|
|
140
|
+
// export const getGovClientWindowSizeHeader = () => {
|
|
141
|
+
// try {
|
|
142
|
+
// return { headerValue: getWindowSize() };
|
|
143
|
+
// } catch (error) {
|
|
144
|
+
// return { error };
|
|
145
|
+
// }
|
|
146
|
+
// };
|
|
147
|
+
// /**
|
|
148
|
+
// * Returns the value for Gov-Client-Screens HMRC Fraud prevention header.
|
|
149
|
+
// * @returns {object} with headerValue key having the value of the header or error key if there is an error
|
|
150
|
+
// */
|
|
151
|
+
// export const getGovClientScreensHeader = () => {
|
|
152
|
+
// try {
|
|
153
|
+
// return { headerValue: getScreenData() };
|
|
154
|
+
// } catch (error) {
|
|
155
|
+
// return { error };
|
|
156
|
+
// }
|
|
157
|
+
// };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const AllNationalities: string[];
|
|
2
|
-
export declare function getNationalityOptions(): {
|
|
3
|
-
key: string;
|
|
4
|
-
text: string;
|
|
5
|
-
}[];
|
|
1
|
+
export declare const AllNationalities: string[];
|
|
2
|
+
export declare function getNationalityOptions(): {
|
|
3
|
+
key: string;
|
|
4
|
+
text: string;
|
|
5
|
+
}[];
|