react-session.manager.sk 1.1.3 → 2.0.1
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/.babelrc +4 -4
- package/.github/workflows/npm-publish.yml +32 -0
- package/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +2 -11
- package/package.json +12 -12
- package/src/components/ErrorBoundary.js +128 -0
- package/src/components/FingerPrint.js +11 -11
- package/src/components/versionCompare.js +39 -39
- package/src/index.js +415 -295
- package/src/styling/toast.css +56 -56
- package/webpack.config.js +36 -36
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license React
|
|
3
|
-
* react-is.production.
|
|
3
|
+
* react-is.production.js
|
|
4
4
|
*
|
|
5
|
-
* Copyright (c)
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -17,12 +17,3 @@
|
|
|
17
17
|
* This source code is licensed under the MIT license found in the
|
|
18
18
|
* LICENSE file in the root directory of this source tree.
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
|
-
/** @license React v16.13.1
|
|
22
|
-
* react-is.production.min.js
|
|
23
|
-
*
|
|
24
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
25
|
-
*
|
|
26
|
-
* This source code is licensed under the MIT license found in the
|
|
27
|
-
* LICENSE file in the root directory of this source tree.
|
|
28
|
-
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-session.manager.sk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "A react component used to manage token sessions with flask backend",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -10,20 +10,20 @@
|
|
|
10
10
|
"author": "Skulldorom",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"@babel/core": "^7.
|
|
14
|
-
"@babel/preset-env": "^7.
|
|
15
|
-
"@babel/preset-react": "^7.
|
|
16
|
-
"babel-loader": "^
|
|
13
|
+
"@babel/core": "^7.28.0",
|
|
14
|
+
"@babel/preset-env": "^7.28.0",
|
|
15
|
+
"@babel/preset-react": "^7.27.1",
|
|
16
|
+
"babel-loader": "^10.0.0",
|
|
17
17
|
"css-loader": "^7.1.2",
|
|
18
|
-
"webpack": "^5.
|
|
19
|
-
"webpack-cli": "^
|
|
18
|
+
"webpack": "^5.100.2",
|
|
19
|
+
"webpack-cli": "^6.0.1"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@emotion/react": "^11.
|
|
23
|
-
"@emotion/styled": "^11.
|
|
24
|
-
"@mui/icons-material": "^
|
|
25
|
-
"@mui/material": "^
|
|
22
|
+
"@emotion/react": "^11.14.0",
|
|
23
|
+
"@emotion/styled": "^11.14.1",
|
|
24
|
+
"@mui/icons-material": "^7.2.0",
|
|
25
|
+
"@mui/material": "^7.2.0",
|
|
26
26
|
"clientjs": "^0.2.1",
|
|
27
|
-
"react-toastify": "^
|
|
27
|
+
"react-toastify": "^11.0.5"
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { toast } from "react-toastify";
|
|
3
|
+
import { Error as ErrorIcon } from "@mui/icons-material";
|
|
4
|
+
|
|
5
|
+
class ErrorBoundary extends React.Component {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(props);
|
|
8
|
+
this.state = { hasError: false, error: null, errorInfo: null };
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
static getDerivedStateFromError(error) {
|
|
12
|
+
// Update state so the next render will show the fallback UI
|
|
13
|
+
return { hasError: true };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
componentDidCatch(error, errorInfo) {
|
|
17
|
+
console.error("ErrorBoundary caught an error:", error, errorInfo);
|
|
18
|
+
|
|
19
|
+
this.setState({
|
|
20
|
+
error: error,
|
|
21
|
+
errorInfo: errorInfo,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Show a toast notification for the error
|
|
25
|
+
toast.error(
|
|
26
|
+
"Something went wrong. Please refresh the page or try again later.",
|
|
27
|
+
{
|
|
28
|
+
toastId: "error-boundary",
|
|
29
|
+
icon: <ErrorIcon />,
|
|
30
|
+
autoClose: 10000,
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
// Log error to external service if needed
|
|
35
|
+
if (this.props.onError) {
|
|
36
|
+
this.props.onError(error, errorInfo);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
handleRetry = () => {
|
|
41
|
+
this.setState({ hasError: false, error: null, errorInfo: null });
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
render() {
|
|
45
|
+
if (this.state.hasError) {
|
|
46
|
+
// Custom error UI
|
|
47
|
+
if (this.props.fallback) {
|
|
48
|
+
return this.props.fallback;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
style={{
|
|
54
|
+
padding: "20px",
|
|
55
|
+
textAlign: "center",
|
|
56
|
+
backgroundColor: "#f8f9fa",
|
|
57
|
+
border: "1px solid #dee2e6",
|
|
58
|
+
borderRadius: "8px",
|
|
59
|
+
margin: "20px",
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
<ErrorIcon
|
|
63
|
+
style={{ fontSize: "48px", color: "#dc3545", marginBottom: "16px" }}
|
|
64
|
+
/>
|
|
65
|
+
<h2 style={{ color: "#343a40", marginBottom: "16px" }}>
|
|
66
|
+
Something went wrong
|
|
67
|
+
</h2>
|
|
68
|
+
<p style={{ color: "#6c757d", marginBottom: "20px" }}>
|
|
69
|
+
An unexpected error occurred. Please try refreshing the page.
|
|
70
|
+
</p>
|
|
71
|
+
<button
|
|
72
|
+
onClick={this.handleRetry}
|
|
73
|
+
style={{
|
|
74
|
+
backgroundColor: "#007bff",
|
|
75
|
+
color: "white",
|
|
76
|
+
border: "none",
|
|
77
|
+
padding: "10px 20px",
|
|
78
|
+
borderRadius: "4px",
|
|
79
|
+
cursor: "pointer",
|
|
80
|
+
marginRight: "10px",
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
Try Again
|
|
84
|
+
</button>
|
|
85
|
+
<button
|
|
86
|
+
onClick={() => window.location.reload()}
|
|
87
|
+
style={{
|
|
88
|
+
backgroundColor: "#28a745",
|
|
89
|
+
color: "white",
|
|
90
|
+
border: "none",
|
|
91
|
+
padding: "10px 20px",
|
|
92
|
+
borderRadius: "4px",
|
|
93
|
+
cursor: "pointer",
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
96
|
+
Refresh Page
|
|
97
|
+
</button>
|
|
98
|
+
|
|
99
|
+
{process.env.NODE_ENV === "development" && this.state.error && (
|
|
100
|
+
<details style={{ marginTop: "20px", textAlign: "left" }}>
|
|
101
|
+
<summary style={{ cursor: "pointer", fontWeight: "bold" }}>
|
|
102
|
+
Error Details (Development)
|
|
103
|
+
</summary>
|
|
104
|
+
<pre
|
|
105
|
+
style={{
|
|
106
|
+
backgroundColor: "#f8f9fa",
|
|
107
|
+
padding: "10px",
|
|
108
|
+
borderRadius: "4px",
|
|
109
|
+
overflow: "auto",
|
|
110
|
+
fontSize: "12px",
|
|
111
|
+
marginTop: "10px",
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
{this.state.error && this.state.error.toString()}
|
|
115
|
+
<br />
|
|
116
|
+
{this.state.errorInfo?.componentStack}
|
|
117
|
+
</pre>
|
|
118
|
+
</details>
|
|
119
|
+
)}
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return this.props.children;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export default ErrorBoundary;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ClientJS } from "clientjs";
|
|
2
|
-
|
|
3
|
-
export default function getDeviceFingerprint() {
|
|
4
|
-
if (localStorage.getItem("deviceFingerprint"))
|
|
5
|
-
return localStorage.getItem("deviceFingerprint");
|
|
6
|
-
|
|
7
|
-
const client = new ClientJS();
|
|
8
|
-
const fingerprint = client.getFingerprint();
|
|
9
|
-
localStorage.setItem("deviceFingerprint", fingerprint);
|
|
10
|
-
return fingerprint;
|
|
11
|
-
}
|
|
1
|
+
import { ClientJS } from "clientjs";
|
|
2
|
+
|
|
3
|
+
export default function getDeviceFingerprint() {
|
|
4
|
+
if (localStorage.getItem("deviceFingerprint"))
|
|
5
|
+
return localStorage.getItem("deviceFingerprint");
|
|
6
|
+
|
|
7
|
+
const client = new ClientJS();
|
|
8
|
+
const fingerprint = client.getFingerprint();
|
|
9
|
+
localStorage.setItem("deviceFingerprint", fingerprint);
|
|
10
|
+
return fingerprint;
|
|
11
|
+
}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
// Javascript implementation
|
|
2
|
-
|
|
3
|
-
// Method to compare two versions.
|
|
4
|
-
// Returns 1 if v2 is smaller, -1
|
|
5
|
-
// if v1 is smaller, 0 if equal
|
|
6
|
-
export default function versionCompare(v1, v2) {
|
|
7
|
-
// vnum stores each numeric
|
|
8
|
-
// part of version
|
|
9
|
-
var vnum1 = 0,
|
|
10
|
-
vnum2 = 0;
|
|
11
|
-
|
|
12
|
-
// loop until both string are
|
|
13
|
-
// processed
|
|
14
|
-
for (var i = 0, j = 0; i < v1.length || j < v2.length; ) {
|
|
15
|
-
// storing numeric part of
|
|
16
|
-
// version 1 in vnum1
|
|
17
|
-
while (i < v1.length && v1[i] !== ".") {
|
|
18
|
-
vnum1 = vnum1 * 10 + (v1[i] - "0");
|
|
19
|
-
i++;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// storing numeric part of
|
|
23
|
-
// version 2 in vnum2
|
|
24
|
-
while (j < v2.length && v2[j] !== ".") {
|
|
25
|
-
vnum2 = vnum2 * 10 + (v2[j] - "0");
|
|
26
|
-
j++;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (vnum1 > vnum2) return true;
|
|
30
|
-
if (vnum2 > vnum1) return false;
|
|
31
|
-
|
|
32
|
-
// if equal, reset variables and
|
|
33
|
-
// go for next numeric part
|
|
34
|
-
vnum1 = vnum2 = 0;
|
|
35
|
-
i++;
|
|
36
|
-
j++;
|
|
37
|
-
}
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
1
|
+
// Javascript implementation
|
|
2
|
+
|
|
3
|
+
// Method to compare two versions.
|
|
4
|
+
// Returns 1 if v2 is smaller, -1
|
|
5
|
+
// if v1 is smaller, 0 if equal
|
|
6
|
+
export default function versionCompare(v1, v2) {
|
|
7
|
+
// vnum stores each numeric
|
|
8
|
+
// part of version
|
|
9
|
+
var vnum1 = 0,
|
|
10
|
+
vnum2 = 0;
|
|
11
|
+
|
|
12
|
+
// loop until both string are
|
|
13
|
+
// processed
|
|
14
|
+
for (var i = 0, j = 0; i < v1.length || j < v2.length; ) {
|
|
15
|
+
// storing numeric part of
|
|
16
|
+
// version 1 in vnum1
|
|
17
|
+
while (i < v1.length && v1[i] !== ".") {
|
|
18
|
+
vnum1 = vnum1 * 10 + (v1[i] - "0");
|
|
19
|
+
i++;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// storing numeric part of
|
|
23
|
+
// version 2 in vnum2
|
|
24
|
+
while (j < v2.length && v2[j] !== ".") {
|
|
25
|
+
vnum2 = vnum2 * 10 + (v2[j] - "0");
|
|
26
|
+
j++;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (vnum1 > vnum2) return true;
|
|
30
|
+
if (vnum2 > vnum1) return false;
|
|
31
|
+
|
|
32
|
+
// if equal, reset variables and
|
|
33
|
+
// go for next numeric part
|
|
34
|
+
vnum1 = vnum2 = 0;
|
|
35
|
+
i++;
|
|
36
|
+
j++;
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
}
|