react-session.manager.sk 3.0.0 → 3.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/README.md +29 -6
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ A React context provider for managing token-based user sessions in applications
|
|
|
17
17
|
- [Version Protection](#version-protection)
|
|
18
18
|
- [Axios Interceptors](#axios-interceptors)
|
|
19
19
|
- [Toast Notifications](#toast-notifications)
|
|
20
|
+
- [Development](#development)
|
|
20
21
|
- [Dependencies](#dependencies)
|
|
21
22
|
- [License](#license)
|
|
22
23
|
|
|
@@ -29,7 +30,7 @@ A React context provider for managing token-based user sessions in applications
|
|
|
29
30
|
- **Cross-tab synchronisation** — a login in one tab is picked up by all open tabs
|
|
30
31
|
- **Device fingerprinting** — generates a stable `deviceUID` and attaches it to every request header
|
|
31
32
|
- **App version enforcement** — detects when the server requires a newer client version and prompts the user to update
|
|
32
|
-
- **Axios interceptor** — centrally handles `
|
|
33
|
+
- **Axios interceptor** — centrally handles `401`, `403`, `426`, `455`, `500`, `503`, and network/timeout errors
|
|
33
34
|
- **Toast notifications** via [react-toastify](https://fkhadra.github.io/react-toastify/) for session, connection, and version events
|
|
34
35
|
- **Role-based access** helper via the `hasRole` context function
|
|
35
36
|
|
|
@@ -162,14 +163,36 @@ The provider registers a response interceptor on `AuthenticatedAxiosObject`:
|
|
|
162
163
|
|
|
163
164
|
| Status | Behaviour |
|
|
164
165
|
|---|---|
|
|
165
|
-
| `
|
|
166
|
-
| `
|
|
167
|
-
|
|
|
168
|
-
| `
|
|
166
|
+
| `401` | Unauthorized — clears auth state via `onSessionExpired` and shows an error toast. |
|
|
167
|
+
| `403` | Forbidden — shows an error toast. Auth state is not cleared. |
|
|
168
|
+
| `426` | App version too old — triggers the version protection flow described above. |
|
|
169
|
+
| `455` | Session no longer valid — clears auth state and shows an info toast prompting re-login. |
|
|
170
|
+
| `500` | Internal server error — shows an error toast. |
|
|
171
|
+
| `503` | Service unavailable — shows an error toast. |
|
|
172
|
+
| Timeout (`ECONNABORTED` / `ETIMEDOUT`) | Shows an error toast telling the user the server is taking too long to respond. |
|
|
173
|
+
| No response (other network error) | Shows an error toast telling the user the server is not responding. |
|
|
174
|
+
| `ERR_CANCELED` / `canceled` | Silently ignored (e.g. aborted requests). |
|
|
169
175
|
|
|
170
176
|
### Toast Notifications
|
|
171
177
|
|
|
172
|
-
All notifications are rendered via a `<ToastContainer>` mounted inside the provider. You can customise its behaviour with the `toastOptions` prop
|
|
178
|
+
All notifications are rendered via a `<ToastContainer>` mounted inside the provider. You can customise its behaviour with the `toastOptions` prop — it accepts any props that `<ToastContainer>` accepts, including `toastClassName` for custom CSS classes.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Development
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Install dependencies
|
|
186
|
+
npm ci
|
|
187
|
+
|
|
188
|
+
# Run the test suite (Node ≥ 22 required)
|
|
189
|
+
npm test
|
|
190
|
+
|
|
191
|
+
# Build the distributable bundle
|
|
192
|
+
npm run build
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Tests live in the `tests/` directory and use Node's built-in `node:test` runner. The CI workflow runs tests in a dedicated **test** job before **build-and-publish**, so a failing test blocks the release.
|
|
173
196
|
|
|
174
197
|
---
|
|
175
198
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-session.manager.sk",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "A react component used to manage token sessions with flask backend",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build": "webpack --mode production",
|
|
12
|
-
"test": "
|
|
12
|
+
"test": "node --test tests/*.test.mjs",
|
|
13
13
|
"lint": "eslint src/**/*.{js,jsx}",
|
|
14
14
|
"lint:fix": "eslint src/**/*.{js,jsx} --fix",
|
|
15
15
|
"format": "prettier --write src/**/*.{js,jsx,css}",
|