strapi-plugin-magic-sessionmanager 4.14.0 → 4.14.2

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,3 +1,46 @@
1
+ ## [4.14.2](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.14.1...v4.14.2) (2026-11-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **admin:** keep loads working when a component mounts again ([#24](https://github.com/Schero94/Magic-Sessionmanager/issues/24)) ([4a18a47](https://github.com/Schero94/Magic-Sessionmanager/commit/4a18a473c21aeb4ae0a5671f55456ce2b0abefcc))
7
+
8
+
9
+ ### Fixed
10
+
11
+ * The Online users widget, the Analytics page and the Configuration page no longer show "could not be loaded" after the component is mounted a second time. `useFetchClient` aborts the requests of an unmounted component; the widget and the Analytics page then skipped their next load because the aborted one still counted as running, and the Configuration page set the error of the aborted load after the next load had started. React StrictMode mounts every component twice in development, and React 19 and a future StrictMode admin do the same. Each load now belongs to one mount: an aborted or outdated load sets no state.
12
+
13
+ ### Tests
14
+
15
+ * `npm run test:admin`: StrictMode tests for every admin entry point (no duplicate requests, no leaked timers, listeners, connections or observers after unmount, no console errors or warnings), also run against React 19 in an informational CI job.
16
+
17
+ ## [4.14.1](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.14.0...v4.14.1) (2026-11-18)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * set the Strapi peer floor to 5.50.0, the first version the plugin works on ([#23](https://github.com/Schero94/Magic-Sessionmanager/issues/23)) ([a9f522f](https://github.com/Schero94/Magic-Sessionmanager/commit/a9f522fc1b4fc694b6d1cfdf3c682db25c6ee363))
23
+
24
+
25
+ Release type: patch (`fix`). This corrects an untested compatibility claim; it is not a breaking change, because the plugin never worked fully on the Strapi versions now excluded.
26
+
27
+ ### Fixed
28
+
29
+ * **Strapi peer floor corrected from `^5.0.0` to `^5.50.0`** (`@strapi/strapi` and `@strapi/plugin-users-permissions`). The old range was never tested. Strapi 5.50.0 added the session-manager methods the plugin calls (`listSessions`, `revokeSessionById`) and the `metadata` column of `admin::session` ([strapi/strapi#26628](https://github.com/strapi/strapi/pull/26628)). Measured with the real-HTTP suites on isolated hosts: on 5.24.0, 5.30.0, 5.40.0, 5.45.0 and 5.49.0, sign-in with `jwtManagement: 'refresh'` fails closed with 503, session list and revoke routes fail, and the Admin panel sessions routes return 500 in both JWT modes; 5.0.4 and 5.23.6 have no session manager or `admin::session` at all; 5.0.0 to 5.0.3 declare Node.js 20 or older, outside this plugin's `engines`. On 5.50.0 and 5.62.0 every suite passes.
30
+ * The plugin logs one clear error at start-up on Strapi older than 5.50.0 (`Strapi 5.x.y is not supported: Magic Session Manager requires Strapi 5.50.0 or later …`) instead of failing later on single requests.
31
+ * README badge, Compatibility table and project site now say Strapi 5.50+.
32
+
33
+ ### Upgrade note
34
+
35
+ * Strapi 5.50.0 or later: nothing to do.
36
+ * Strapi older than 5.50.0: upgrade Strapi first (`npx @strapi/upgrade minor`), rebuild the admin and restart. npm 7+ refuses to install this release next to an older Strapi because of the peer range; until you upgrade Strapi, stay on your current plugin version.
37
+
38
+ ### Tests
39
+
40
+ * New CI job `strapi-floor` installs Strapi 5.50.0 and Users & Permissions 5.50.0 into a separate directory and runs the HTTP access suite (legacy, refresh, fallback logout), the admin panel sessions suite and the native session capture suite against it.
41
+ * `tests/strapi-version-floor.test.js` checks the floor constant, the start-up error, that the peers and the CI job name the same floor.
42
+ * The native capture suite's provider-callback case now also sends the provider token in the query string, which Strapi 5.50 reads (5.62 reads the grant session), so it runs on both versions.
43
+
1
44
  # [4.14.0](https://github.com/Schero94/Magic-Sessionmanager/compare/v4.13.1...v4.14.0) (2026-11-18)
2
45
 
3
46
 
package/README.md CHANGED
@@ -14,7 +14,7 @@ Free and open source under the MIT license. Every feature works without an accou
14
14
  [![npm downloads](https://img.shields.io/npm/dm/strapi-plugin-magic-sessionmanager.svg)](https://www.npmjs.com/package/strapi-plugin-magic-sessionmanager)
15
15
  [![CI build status](https://img.shields.io/github/actions/workflow/status/Schero94/Magic-Sessionmanager/test.yml?branch=main&label=CI&logo=github)](https://github.com/Schero94/Magic-Sessionmanager/actions/workflows/test.yml?query=branch%3Amain)
16
16
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/Schero94/Magic-Sessionmanager/blob/main/LICENSE)
17
- [![Strapi 5.0+](https://img.shields.io/badge/Strapi-5.0%2B-4945FF.svg)](https://github.com/Schero94/Magic-Sessionmanager#compatibility)
17
+ [![Strapi 5.50+](https://img.shields.io/badge/Strapi-5.50%2B-4945FF.svg)](https://github.com/Schero94/Magic-Sessionmanager#compatibility)
18
18
  [![Documentation site](https://img.shields.io/badge/docs-project%20site-6d4aff.svg)](https://schero94.github.io/Magic-Sessionmanager/)
19
19
 
20
20
  Live docs: [https://schero94.github.io/Magic-Sessionmanager/](https://schero94.github.io/Magic-Sessionmanager/) · [npm](https://www.npmjs.com/package/strapi-plugin-magic-sessionmanager) · [Changelog](https://github.com/Schero94/Magic-Sessionmanager/blob/main/CHANGELOG.md) · [Report a bug](https://github.com/Schero94/Magic-Sessionmanager/issues/new/choose) · [Discussions](https://github.com/Schero94/Magic-Sessionmanager/discussions)
@@ -224,7 +224,7 @@ Shown on the edit view of a Users & Permissions user only.
224
224
 
225
225
  ### Online users widget
226
226
 
227
- Strapi 5.13 and later. Four tiles: **Online users** (of all registered users), **Active sessions**, **Idle sessions** and **Blocked users**, plus a link **Open Session Manager**. The widget refreshes every 30 seconds.
227
+ Part of every supported Strapi version (the widgets API exists since Strapi 5.13). Four tiles: **Online users** (of all registered users), **Active sessions**, **Idle sessions** and **Blocked users**, plus a link **Open Session Manager**. The widget refreshes every 30 seconds.
228
228
 
229
229
  ### Settings › Session Manager
230
230
 
@@ -248,17 +248,17 @@ Two links: **Configuration** and **Analytics**.
248
248
 
249
249
  ## Compatibility
250
250
 
251
- | Item | Supported |
252
- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
253
- | Strapi | 5 (`@strapi/strapi` peer range `^5.0.0`). Acceptance host: Strapi 5.62.0. |
254
- | Node.js | `^22.22.2 \|\| >=24.15.0` (`engines.node`) |
255
- | Users & Permissions | `jwtManagement: 'refresh'` and `'legacy-support'` |
256
- | Homepage widget | Strapi 5.13 and later (older versions have no widgets API; the rest works) |
257
- | Admin panel sessions | Strapi 5 with Strapi's session manager (`strapi.sessionManager`, admin origin); tested with 5.62.0. Without it the view says it is not available and the sign-out routes return 503. |
258
- | Required peers | `@strapi/strapi` `^5.0.0`, `@strapi/plugin-users-permissions` `^5.0.0`, `react` / `react-dom` `^18.0.0`, `react-router-dom` `^6.0.0`, `styled-components` `^6.0.0`. A new Strapi 5 app already has all of them. |
259
- | Optional peers | `@strapi/design-system` `^2.0.0`, `@strapi/icons` `^2.0.0`, `react-intl` `^6.0.0`. Strapi's admin brings them; they are marked optional so npm, Yarn and pnpm do not warn. |
260
- | Package managers | npm, Yarn 1 and pnpm. Installing into a fresh Strapi 5.61 app prints no warning about this plugin. |
261
- | Databases | PostgreSQL, MySQL, SQLite (several processes need PostgreSQL or MySQL, see [Running several instances](#running-several-instances-railway-replicas-pm2-cluster)). |
251
+ | Item | Supported |
252
+ | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
253
+ | Strapi | 5.50.0 and later 5.x (`@strapi/strapi` peer range `^5.50.0`). Tested in CI on 5.50.0 (floor) and 5.62.0 (acceptance host). Strapi 5.0 to 5.49 are not supported, see [Upgrading › Strapi older than 5.50](#strapi-older-than-550). |
254
+ | Node.js | `^22.22.2 \|\| >=24.15.0` (`engines.node`) |
255
+ | Users & Permissions | `jwtManagement: 'refresh'` and `'legacy-support'` |
256
+ | Homepage widget | Included (Strapi's widgets API exists since 5.13). |
257
+ | Admin panel sessions | Uses Strapi's session manager (`strapi.sessionManager('admin')`) and the device label in `admin::session` metadata, both available from Strapi 5.50.0; tested on 5.50.0 and 5.62.0. |
258
+ | Required peers | `@strapi/strapi` `^5.50.0`, `@strapi/plugin-users-permissions` `^5.50.0`, `react` / `react-dom` `^18.0.0`, `react-router-dom` `^6.0.0`, `styled-components` `^6.0.0`. A new Strapi 5 app already has all of them. |
259
+ | Optional peers | `@strapi/design-system` `^2.0.0`, `@strapi/icons` `^2.0.0`, `react-intl` `^6.0.0`. Strapi's admin brings them; they are marked optional so npm, Yarn and pnpm do not warn. |
260
+ | Package managers | npm, Yarn 1 and pnpm. Installing into a fresh Strapi 5.61 app prints no warning about this plugin. |
261
+ | Databases | PostgreSQL, MySQL, SQLite (several processes need PostgreSQL or MySQL, see [Running several instances](#running-several-instances-railway-replicas-pm2-cluster)). |
262
262
 
263
263
  ---
264
264
 
@@ -920,6 +920,18 @@ Session history lives in the content-type tables `magic_sessions` and `magic_ses
920
920
 
921
921
  ## Migration and upgrading
922
922
 
923
+ ### Strapi older than 5.50
924
+
925
+ Earlier releases said "Strapi 5.0+" (`^5.0.0`) without testing older versions. The real floor is **Strapi 5.50.0**: the plugin calls `listSessions` and `revokeSessionById` on Strapi's session manager and reads the device label in `admin::session` metadata, which Strapi added in 5.50.0 ([strapi/strapi#26628](https://github.com/strapi/strapi/pull/26628)). Measured with this repository's real-HTTP suites:
926
+
927
+ | Strapi | Result |
928
+ | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
929
+ | 5.0.0 to 5.23.x | No session manager and no `admin::session` table (added in 5.24.0). 5.0.0 to 5.0.3 also declare Node.js 20 or older, outside this plugin's `engines`. |
930
+ | 5.24.0 to 5.49.x | With `jwtManagement: 'refresh'`, sign-in fails closed with 503 and session routes fail; the Admin panel view returns 500 in both modes. |
931
+ | 5.50.0, 5.62.0 | All suites pass (both JWT modes, the fallback logout, admin panel sessions, native session capture); the packed plugin installs without peer warnings and the admin panel builds on 5.50.0. |
932
+
933
+ On Strapi below 5.50.0 the plugin logs one error at start-up (`Strapi 5.x.y is not supported: Magic Session Manager requires Strapi 5.50.0 or later …`). Upgrade Strapi to 5.50.0 or later ([Strapi upgrade tool](https://docs.strapi.io/cms/upgrade-tool)), rebuild the admin and restart. If you cannot upgrade Strapi yet, stay on your current plugin version; it never worked fully on those versions either.
934
+
923
935
  ### To the next release (license removal, from 4.10.x)
924
936
 
925
937
  Nothing to do for most apps.
@@ -948,6 +960,7 @@ Version 4.0.0 moved to Strapi 5 and its Document Service API. Upgrade Strapi its
948
960
  ```bash
949
961
  npm ci --legacy-peer-deps
950
962
  npm test # node --test tests/*.test.js tests/*.test.mjs
963
+ npm run test:admin # admin entry points in React.StrictMode (jsdom, fake network)
951
964
  npm run test:concurrency # 8 processes on one database (SQLite; PostgreSQL with MSM_TEST_PG_URL)
952
965
  npm run test:ts:front
953
966
  npm run test:ts:back
@@ -956,6 +969,8 @@ npm run verify
956
969
  npm run verify:runtime
957
970
  ```
958
971
 
972
+ `npm run test:admin` renders every admin entry point (the session dashboard and the admin panel sessions view with their dialogs, the Configuration and Analytics settings pages, the Online users widget and the Content Manager side panel) inside `React.StrictMode` with the providers of the Strapi admin, in jsdom with a fake network. It fails on a mutation sent twice, a read repeated without aborting the first one, an interval, listener, connection or observer left after unmount, and any console error or warning. A separate CI job runs the same tests against React 19 for information only: the plugin's peer range is React 18, like the Strapi 5 admin.
973
+
959
974
  HTTP integration tests need Strapi host dependencies: set `SESSION_HTTP_STRAPI_NODE_MODULES` to the `node_modules` of a Strapi 5 host; without it they skip with a message. This repository's own `node_modules` works (its devDependencies include Strapi 5.62 and Users & Permissions), which is what CI uses:
960
975
 
961
976
  ```bash
@@ -963,6 +978,8 @@ SESSION_HTTP_REQUIRED=1 SESSION_HTTP_STRAPI_NODE_MODULES=$PWD/node_modules node
963
978
  # PostgreSQL: add SESSION_HTTP_DB=postgres MSM_TEST_PG_URL=postgres://user:pass@127.0.0.1:5432/db
964
979
  ```
965
980
 
981
+ CI runs the same suites a second time against Strapi 5.50.0, the peer floor, installed into a separate directory (`SESSION_HTTP_STRAPI_NODE_MODULES=<dir>/node_modules`), so the floor stays tested.
982
+
966
983
  The admin panel suite signs synthetic admins in through `POST /admin/login` and checks listing, signing out one browser and everywhere, self sign-out, the Super Admin guard, RBAC denials, the rate limit, that the next request and the refresh are rejected, and that admin sessions never reach the app-user numbers.
967
984
 
968
985
  Quick manual check: sign in to your app as an end user (`POST /api/auth/local`), open Session Manager and find the session as **Active**, click **End session** and confirm, then call any Content API route with the same token: it returns 401 and the row shows **Ended · Ended manually**.
@@ -976,7 +993,7 @@ Releases use Conventional Commits and semantic-release on Node.js 22 with npm Tr
976
993
  Issues and pull requests are welcome.
977
994
 
978
995
  - Bugs and feature ideas: [open an issue](https://github.com/Schero94/Magic-Sessionmanager/issues/new/choose) (templates included). Questions: [Discussions](https://github.com/Schero94/Magic-Sessionmanager/discussions).
979
- - Pull requests: branch from `main`, write a failing test first, and use Conventional Commits (`fix:`, `feat:`, `docs:`; a breaking change needs a `BREAKING CHANGE:` footer). Before you push, run `npm run lint`, `npm run format:check`, `npm test`, both type checks and `npm run build && npm run verify`.
996
+ - Pull requests: branch from `main`, write a failing test first, and use Conventional Commits (`fix:`, `feat:`, `docs:`; a breaking change needs a `BREAKING CHANGE:` footer). Before you push, run `npm run lint`, `npm run format:check`, `npm test`, `npm run test:admin`, both type checks and `npm run build && npm run verify`.
980
997
  - Use synthetic data only in tests, screenshots and issues: `*.example.test` addresses and IP addresses from `203.0.113.0/24`. Never paste real tokens.
981
998
 
982
999
  ---
@@ -9,7 +9,7 @@ const styled = require("styled-components");
9
9
  const designSystem = require("@strapi/design-system");
10
10
  const icons = require("@strapi/icons");
11
11
  const symbols = require("@strapi/icons/symbols");
12
- const index = require("./index-BBZNey0n.js");
12
+ const index = require("./index-CmW1DJ0c.js");
13
13
  const SectionCard = require("./SectionCard-BlWv8CRt.js");
14
14
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
15
15
  const styled__default = /* @__PURE__ */ _interopDefault(styled);
@@ -178,23 +178,29 @@ const AnalyticsPage = () => {
178
178
  const [updatedAt, setUpdatedAt] = react.useState(null);
179
179
  const [loadError, setLoadError] = react.useState(false);
180
180
  const [forbidden, setForbidden] = react.useState(false);
181
- const requestPendingRef = react.useRef(false);
181
+ const requestPendingRef = react.useRef(null);
182
182
  const fetchAnalytics = react.useCallback(async () => {
183
183
  if (requestPendingRef.current) return;
184
- requestPendingRef.current = true;
184
+ const request = {};
185
+ requestPendingRef.current = request;
186
+ const isCurrent = () => requestPendingRef.current === request;
185
187
  try {
186
188
  const { data } = await get(`/${index.pluginId}/sessions/analytics`);
189
+ if (!isCurrent()) return;
187
190
  setAnalytics(analyticsFromServer(data));
188
191
  setUpdatedAt(Date.now());
189
192
  setLoadError(false);
190
193
  } catch (err) {
194
+ if (!isCurrent() || index.isCancelledRequest(err)) return;
191
195
  index.logSafeAdminError("analytics.load", err);
192
196
  if (isForbidden(err)) setForbidden(true);
193
197
  setLoadError(true);
194
198
  } finally {
195
- requestPendingRef.current = false;
196
- setRefreshing(false);
197
- setLoading(false);
199
+ if (isCurrent()) {
200
+ requestPendingRef.current = null;
201
+ setRefreshing(false);
202
+ setLoading(false);
203
+ }
198
204
  }
199
205
  }, [get]);
200
206
  const handleRefresh = () => {
@@ -204,6 +210,9 @@ const AnalyticsPage = () => {
204
210
  };
205
211
  react.useEffect(() => {
206
212
  void fetchAnalytics();
213
+ return () => {
214
+ requestPendingRef.current = null;
215
+ };
207
216
  }, [fetchAnalytics]);
208
217
  if (loading) {
209
218
  return /* @__PURE__ */ jsxRuntime.jsx(StrapiAdmin.Page.Loading, {});
@@ -7,7 +7,7 @@ import styled from "styled-components";
7
7
  import { Typography, Flex, LinkButton, Button, EmptyStateLayout, VisuallyHidden } from "@strapi/design-system";
8
8
  import { ArrowClockwise, ChartBubble, User, Clock, Calendar } from "@strapi/icons";
9
9
  import { EmptyDocuments } from "@strapi/icons/symbols";
10
- import { K as normalizeDeviceType, u as useSessionFormatters, l as pluginId, m as logSafeAdminError, n as PersistentAlert, R as ReadableText, w as PageShell, x as StatGrid, y as StatCard, G as EqualGrid, b as getTranslation, L as getDeviceTypeMessage } from "./index-BcQdNWzu.mjs";
10
+ import { K as normalizeDeviceType, u as useSessionFormatters, l as pluginId, s as isCancelledRequest, m as logSafeAdminError, n as PersistentAlert, R as ReadableText, w as PageShell, x as StatGrid, y as StatCard, G as EqualGrid, b as getTranslation, L as getDeviceTypeMessage } from "./index-C2SrNW6I.mjs";
11
11
  import { S as SectionCard } from "./SectionCard-D51bv4Hi.mjs";
12
12
  const ANALYTICS_UNKNOWN_KEY = "unknown";
13
13
  const VERSION_TOKEN = /^v?\d[\w.]*$/i;
@@ -174,23 +174,29 @@ const AnalyticsPage = () => {
174
174
  const [updatedAt, setUpdatedAt] = useState(null);
175
175
  const [loadError, setLoadError] = useState(false);
176
176
  const [forbidden, setForbidden] = useState(false);
177
- const requestPendingRef = useRef(false);
177
+ const requestPendingRef = useRef(null);
178
178
  const fetchAnalytics = useCallback(async () => {
179
179
  if (requestPendingRef.current) return;
180
- requestPendingRef.current = true;
180
+ const request = {};
181
+ requestPendingRef.current = request;
182
+ const isCurrent = () => requestPendingRef.current === request;
181
183
  try {
182
184
  const { data } = await get(`/${pluginId}/sessions/analytics`);
185
+ if (!isCurrent()) return;
183
186
  setAnalytics(analyticsFromServer(data));
184
187
  setUpdatedAt(Date.now());
185
188
  setLoadError(false);
186
189
  } catch (err) {
190
+ if (!isCurrent() || isCancelledRequest(err)) return;
187
191
  logSafeAdminError("analytics.load", err);
188
192
  if (isForbidden(err)) setForbidden(true);
189
193
  setLoadError(true);
190
194
  } finally {
191
- requestPendingRef.current = false;
192
- setRefreshing(false);
193
- setLoading(false);
195
+ if (isCurrent()) {
196
+ requestPendingRef.current = null;
197
+ setRefreshing(false);
198
+ setLoading(false);
199
+ }
194
200
  }
195
201
  }, [get]);
196
202
  const handleRefresh = () => {
@@ -200,6 +206,9 @@ const AnalyticsPage = () => {
200
206
  };
201
207
  useEffect(() => {
202
208
  void fetchAnalytics();
209
+ return () => {
210
+ requestPendingRef.current = null;
211
+ };
203
212
  }, [fetchAnalytics]);
204
213
  if (loading) {
205
214
  return /* @__PURE__ */ jsx(Page.Loading, {});
@@ -7,7 +7,7 @@ import { Typography, Flex, Loader, Button, Modal, Accordion, Box, IconButton, Li
7
7
  import { Earth, Duplicate, Cross, Eye, Trash, More, CaretDown, Download, ArrowClockwise, Check, Clock, User, ChartBubble, Cog, SignOut } from "@strapi/icons";
8
8
  import { EmptyDocuments } from "@strapi/icons/symbols";
9
9
  import styled, { useTheme } from "styled-components";
10
- import { g as getSessionEndReason, a as getEndReasonPresentation, b as getTranslation, p as presentText, i as isSessionFilter, D as DEFAULT_SESSION_FILTER, c as isEndReasonFilter, d as DEFAULT_END_REASON_FILTER, e as getDevicePresentation, u as useSessionFormatters, f as getSessionStatus, h as isNativeOnlySession, j as getSessionEndReasonPresentation, k as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, l as pluginId, m as logSafeAdminError, n as PersistentAlert, R as ReadableText, o as pluginPermissions, M as MissingValue, V as ValueOrMissing, q as SESSION_STATES, r as SESSION_STATUS_PRESENTATION, s as isCancelledRequest, v as SESSION_FILTER_OPTIONS, E as END_REASON_FILTER_OPTIONS, w as PageShell, x as StatGrid, y as StatCard, z as restoreDialogFocus, A as requireSessionList, B as getBadgeColors } from "./index-BcQdNWzu.mjs";
10
+ import { g as getSessionEndReason, a as getEndReasonPresentation, b as getTranslation, p as presentText, i as isSessionFilter, D as DEFAULT_SESSION_FILTER, c as isEndReasonFilter, d as DEFAULT_END_REASON_FILTER, e as getDevicePresentation, u as useSessionFormatters, f as getSessionStatus, h as isNativeOnlySession, j as getSessionEndReasonPresentation, k as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, l as pluginId, m as logSafeAdminError, n as PersistentAlert, R as ReadableText, o as pluginPermissions, M as MissingValue, V as ValueOrMissing, q as SESSION_STATES, r as SESSION_STATUS_PRESENTATION, s as isCancelledRequest, v as SESSION_FILTER_OPTIONS, E as END_REASON_FILTER_OPTIONS, w as PageShell, x as StatGrid, y as StatCard, z as restoreDialogFocus, A as requireSessionList, B as getBadgeColors } from "./index-C2SrNW6I.mjs";
11
11
  const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
12
12
  const { formatMessage } = useIntl();
13
13
  const key = reason || getSessionEndReason(session);
@@ -9,7 +9,7 @@ const designSystem = require("@strapi/design-system");
9
9
  const icons = require("@strapi/icons");
10
10
  const symbols = require("@strapi/icons/symbols");
11
11
  const styled = require("styled-components");
12
- const index = require("./index-BBZNey0n.js");
12
+ const index = require("./index-CmW1DJ0c.js");
13
13
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
14
14
  const styled__default = /* @__PURE__ */ _interopDefault(styled);
15
15
  const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
@@ -6,7 +6,7 @@ import { Flex, Loader, Button, Box, Typography } from "@strapi/design-system";
6
6
  import { User, Lightning, Clock, Lock, WarningCircle } from "@strapi/icons";
7
7
  import * as StrapiAdmin from "@strapi/strapi/admin";
8
8
  import { useFetchClient } from "@strapi/strapi/admin";
9
- import { m as logSafeAdminError, s as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-BcQdNWzu.mjs";
9
+ import { m as logSafeAdminError, s as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-C2SrNW6I.mjs";
10
10
  function normalizeUserCounts(response) {
11
11
  const totalUsers = response?.data?.totalUsers;
12
12
  const blockedUsers = response?.data?.blockedUsers;
@@ -134,16 +134,19 @@ const OnlineUsersWidget = () => {
134
134
  const [userCounts, setUserCounts] = useState(null);
135
135
  const [loading, setLoading] = useState(true);
136
136
  const [loadError, setLoadError] = useState(false);
137
- const requestInProgress = useRef(false);
137
+ const requestInProgress = useRef(null);
138
138
  const fetchStats = useCallback(
139
139
  async ({ showLoading = true } = {}) => {
140
140
  if (requestInProgress.current) return;
141
- requestInProgress.current = true;
141
+ const request = {};
142
+ requestInProgress.current = request;
143
+ const isCurrent = () => requestInProgress.current === request;
142
144
  try {
143
145
  const [sessionResult, countResult] = await Promise.allSettled([
144
146
  get("/magic-sessionmanager/sessions/stats"),
145
147
  get("/magic-sessionmanager/users/stats")
146
148
  ]);
149
+ if (!isCurrent()) return;
147
150
  if (sessionResult.status === "rejected") throw sessionResult.reason;
148
151
  setStats(widgetStatsFromCounts(sessionResult.value?.data));
149
152
  setLoadError(false);
@@ -158,12 +161,14 @@ const OnlineUsersWidget = () => {
158
161
  if (showLoading) setUserCounts(null);
159
162
  }
160
163
  } catch (error) {
161
- if (isCancelledRequest(error)) return;
164
+ if (!isCurrent() || isCancelledRequest(error)) return;
162
165
  logSafeAdminError("onlineUsers.loadSessions", error);
163
166
  if (showLoading) setLoadError(true);
164
167
  } finally {
165
- if (showLoading) setLoading(false);
166
- requestInProgress.current = false;
168
+ if (isCurrent()) {
169
+ if (showLoading) setLoading(false);
170
+ requestInProgress.current = null;
171
+ }
167
172
  }
168
173
  },
169
174
  [get]
@@ -173,7 +178,10 @@ const OnlineUsersWidget = () => {
173
178
  const interval = setInterval(() => {
174
179
  void fetchStats({ showLoading: false });
175
180
  }, REFRESH_INTERVAL_MS);
176
- return () => clearInterval(interval);
181
+ return () => {
182
+ clearInterval(interval);
183
+ requestInProgress.current = null;
184
+ };
177
185
  }, [fetchStats]);
178
186
  if (loading) {
179
187
  return /* @__PURE__ */ jsx(LoadingState, { label: t("widget.loading", "Loading online users") });
@@ -7,7 +7,7 @@ const styled = require("styled-components");
7
7
  const designSystem = require("@strapi/design-system");
8
8
  const icons = require("@strapi/icons");
9
9
  const StrapiAdmin = require("@strapi/strapi/admin");
10
- const index = require("./index-BBZNey0n.js");
10
+ const index = require("./index-CmW1DJ0c.js");
11
11
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
12
12
  function _interopNamespace(e) {
13
13
  if (e && e.__esModule) return e;
@@ -155,16 +155,19 @@ const OnlineUsersWidget = () => {
155
155
  const [userCounts, setUserCounts] = react.useState(null);
156
156
  const [loading, setLoading] = react.useState(true);
157
157
  const [loadError, setLoadError] = react.useState(false);
158
- const requestInProgress = react.useRef(false);
158
+ const requestInProgress = react.useRef(null);
159
159
  const fetchStats = react.useCallback(
160
160
  async ({ showLoading = true } = {}) => {
161
161
  if (requestInProgress.current) return;
162
- requestInProgress.current = true;
162
+ const request = {};
163
+ requestInProgress.current = request;
164
+ const isCurrent = () => requestInProgress.current === request;
163
165
  try {
164
166
  const [sessionResult, countResult] = await Promise.allSettled([
165
167
  get("/magic-sessionmanager/sessions/stats"),
166
168
  get("/magic-sessionmanager/users/stats")
167
169
  ]);
170
+ if (!isCurrent()) return;
168
171
  if (sessionResult.status === "rejected") throw sessionResult.reason;
169
172
  setStats(widgetStatsFromCounts(sessionResult.value?.data));
170
173
  setLoadError(false);
@@ -179,12 +182,14 @@ const OnlineUsersWidget = () => {
179
182
  if (showLoading) setUserCounts(null);
180
183
  }
181
184
  } catch (error) {
182
- if (index.isCancelledRequest(error)) return;
185
+ if (!isCurrent() || index.isCancelledRequest(error)) return;
183
186
  index.logSafeAdminError("onlineUsers.loadSessions", error);
184
187
  if (showLoading) setLoadError(true);
185
188
  } finally {
186
- if (showLoading) setLoading(false);
187
- requestInProgress.current = false;
189
+ if (isCurrent()) {
190
+ if (showLoading) setLoading(false);
191
+ requestInProgress.current = null;
192
+ }
188
193
  }
189
194
  },
190
195
  [get]
@@ -194,7 +199,10 @@ const OnlineUsersWidget = () => {
194
199
  const interval = setInterval(() => {
195
200
  void fetchStats({ showLoading: false });
196
201
  }, REFRESH_INTERVAL_MS);
197
- return () => clearInterval(interval);
202
+ return () => {
203
+ clearInterval(interval);
204
+ requestInProgress.current = null;
205
+ };
198
206
  }, [fetchStats]);
199
207
  if (loading) {
200
208
  return /* @__PURE__ */ jsxRuntime.jsx(LoadingState, { label: t("widget.loading", "Loading online users") });
@@ -4,7 +4,7 @@ import { Field, Typography, Switch, Box, TextInput, Flex, Button, Link, SingleSe
4
4
  import { ConfirmDialog, useNotification, useFetchClient, useQueryParams, Page, Form, Blocker, useForm } from "@strapi/strapi/admin";
5
5
  import { EyeStriked, Eye, Key, Duplicate, Cross, Plus, Trash, Check } from "@strapi/icons";
6
6
  import styled from "styled-components";
7
- import { F as ReadableParagraphs, b as getTranslation, m as logSafeAdminError, R as ReadableText, G as EqualGrid, n as PersistentAlert, P as PropertyList, H as formatSessionDate, C as ConfirmAction, I as refocusIfLost, l as pluginId, J as requireSuccessfulMutation, w as PageShell } from "./index-BcQdNWzu.mjs";
7
+ import { F as ReadableParagraphs, b as getTranslation, m as logSafeAdminError, R as ReadableText, G as EqualGrid, n as PersistentAlert, P as PropertyList, H as formatSessionDate, C as ConfirmAction, I as refocusIfLost, l as pluginId, s as isCancelledRequest, J as requireSuccessfulMutation, w as PageShell } from "./index-C2SrNW6I.mjs";
8
8
  import { useIntl } from "react-intl";
9
9
  import { S as SectionCard } from "./SectionCard-D51bv4Hi.mjs";
10
10
  const SETTINGS_TAB_IDS = Object.freeze([
@@ -3107,6 +3107,7 @@ function useSettingsForm() {
3107
3107
  const settingsRef = useRef(settings);
3108
3108
  const savedSettingsRef = useRef(savedSettings);
3109
3109
  const revisionRef = useRef(null);
3110
+ const loadRequestRef = useRef(0);
3110
3111
  useLayoutEffect(() => {
3111
3112
  settingsRef.current = settings;
3112
3113
  savedSettingsRef.current = savedSettings;
@@ -3149,10 +3150,13 @@ function useSettingsForm() {
3149
3150
  }
3150
3151
  }, [get]);
3151
3152
  const fetchSettings = useCallback(async () => {
3153
+ const request = loadRequestRef.current + 1;
3154
+ loadRequestRef.current = request;
3152
3155
  setLoading(true);
3153
3156
  setLoadError(false);
3154
3157
  try {
3155
3158
  const response = await get(`/${pluginId}/settings`);
3159
+ if (request !== loadRequestRef.current) return;
3156
3160
  if (!response?.data?.settings || typeof response.data.settings !== "object" || Array.isArray(response.data.settings)) {
3157
3161
  throw new Error("Invalid settings response");
3158
3162
  }
@@ -3162,10 +3166,11 @@ function useSettingsForm() {
3162
3166
  setSavedSettings(nextSettings);
3163
3167
  await fetchGeoIpStatus();
3164
3168
  } catch (err) {
3169
+ if (request !== loadRequestRef.current || isCancelledRequest(err)) return;
3165
3170
  logSafeAdminError("settings.load", err);
3166
3171
  setLoadError(true);
3167
3172
  } finally {
3168
- setLoading(false);
3173
+ if (request === loadRequestRef.current) setLoading(false);
3169
3174
  }
3170
3175
  }, [get, fetchGeoIpStatus]);
3171
3176
  const fetchSettingsRef = useRef(fetchSettings);
@@ -6,7 +6,7 @@ const designSystem = require("@strapi/design-system");
6
6
  const StrapiAdmin = require("@strapi/strapi/admin");
7
7
  const icons = require("@strapi/icons");
8
8
  const styled = require("styled-components");
9
- const index = require("./index-BBZNey0n.js");
9
+ const index = require("./index-CmW1DJ0c.js");
10
10
  const reactIntl = require("react-intl");
11
11
  const SectionCard = require("./SectionCard-BlWv8CRt.js");
12
12
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
@@ -3111,6 +3111,7 @@ function useSettingsForm() {
3111
3111
  const settingsRef = react.useRef(settings);
3112
3112
  const savedSettingsRef = react.useRef(savedSettings);
3113
3113
  const revisionRef = react.useRef(null);
3114
+ const loadRequestRef = react.useRef(0);
3114
3115
  react.useLayoutEffect(() => {
3115
3116
  settingsRef.current = settings;
3116
3117
  savedSettingsRef.current = savedSettings;
@@ -3153,10 +3154,13 @@ function useSettingsForm() {
3153
3154
  }
3154
3155
  }, [get]);
3155
3156
  const fetchSettings = react.useCallback(async () => {
3157
+ const request = loadRequestRef.current + 1;
3158
+ loadRequestRef.current = request;
3156
3159
  setLoading(true);
3157
3160
  setLoadError(false);
3158
3161
  try {
3159
3162
  const response = await get(`/${index.pluginId}/settings`);
3163
+ if (request !== loadRequestRef.current) return;
3160
3164
  if (!response?.data?.settings || typeof response.data.settings !== "object" || Array.isArray(response.data.settings)) {
3161
3165
  throw new Error("Invalid settings response");
3162
3166
  }
@@ -3166,10 +3170,11 @@ function useSettingsForm() {
3166
3170
  setSavedSettings(nextSettings);
3167
3171
  await fetchGeoIpStatus();
3168
3172
  } catch (err) {
3173
+ if (request !== loadRequestRef.current || index.isCancelledRequest(err)) return;
3169
3174
  index.logSafeAdminError("settings.load", err);
3170
3175
  setLoadError(true);
3171
3176
  } finally {
3172
- setLoading(false);
3177
+ if (request === loadRequestRef.current) setLoading(false);
3173
3178
  }
3174
3179
  }, [get, fetchGeoIpStatus]);
3175
3180
  const fetchSettingsRef = react.useRef(fetchSettings);
@@ -1579,7 +1579,7 @@ const index = {
1579
1579
  id: `${pluginId}.plugin.name`,
1580
1580
  defaultMessage: pluginPkg.strapi.displayName
1581
1581
  },
1582
- Component: () => import("./App-BRj2qIUs.mjs"),
1582
+ Component: () => import("./App-B2JIOiNM.mjs"),
1583
1583
  permissions: pluginPermissions$1
1584
1584
  });
1585
1585
  app.addSettingsLink(
@@ -1595,7 +1595,7 @@ const index = {
1595
1595
  },
1596
1596
  id: "general",
1597
1597
  to: `${pluginId}/general`,
1598
- Component: () => import("./Settings-BNPO9cXS.mjs"),
1598
+ Component: () => import("./Settings-BFdr77zD.mjs"),
1599
1599
  permissions: pluginPermissions$1
1600
1600
  },
1601
1601
  {
@@ -1605,7 +1605,7 @@ const index = {
1605
1605
  },
1606
1606
  id: "analytics",
1607
1607
  to: `${pluginId}/analytics`,
1608
- Component: () => import("./Analytics-oW2QbDj4.mjs"),
1608
+ Component: () => import("./Analytics-DfDdcjMe.mjs"),
1609
1609
  permissions: pluginPermissions$1
1610
1610
  }
1611
1611
  ]
@@ -1631,7 +1631,7 @@ const index = {
1631
1631
  href: `/plugins/${pluginId}`
1632
1632
  },
1633
1633
  component: async () => {
1634
- const component = await import("./OnlineUsersWidget-wxDYyK5v.mjs");
1634
+ const component = await import("./OnlineUsersWidget-BOd7p_MF.mjs");
1635
1635
  return component.default;
1636
1636
  },
1637
1637
  id: "online-users-widget",
@@ -1582,7 +1582,7 @@ const index = {
1582
1582
  id: `${pluginId}.plugin.name`,
1583
1583
  defaultMessage: pluginPkg.strapi.displayName
1584
1584
  },
1585
- Component: () => Promise.resolve().then(() => require("./App-DcxqQfMT.js")),
1585
+ Component: () => Promise.resolve().then(() => require("./App-DzxXcTYs.js")),
1586
1586
  permissions: pluginPermissions$1
1587
1587
  });
1588
1588
  app.addSettingsLink(
@@ -1598,7 +1598,7 @@ const index = {
1598
1598
  },
1599
1599
  id: "general",
1600
1600
  to: `${pluginId}/general`,
1601
- Component: () => Promise.resolve().then(() => require("./Settings-XdBlPves.js")),
1601
+ Component: () => Promise.resolve().then(() => require("./Settings-DNgH9qRy.js")),
1602
1602
  permissions: pluginPermissions$1
1603
1603
  },
1604
1604
  {
@@ -1608,7 +1608,7 @@ const index = {
1608
1608
  },
1609
1609
  id: "analytics",
1610
1610
  to: `${pluginId}/analytics`,
1611
- Component: () => Promise.resolve().then(() => require("./Analytics-DSG3shUY.js")),
1611
+ Component: () => Promise.resolve().then(() => require("./Analytics-Box2STtg.js")),
1612
1612
  permissions: pluginPermissions$1
1613
1613
  }
1614
1614
  ]
@@ -1634,7 +1634,7 @@ const index = {
1634
1634
  href: `/plugins/${pluginId}`
1635
1635
  },
1636
1636
  component: async () => {
1637
- const component = await Promise.resolve().then(() => require("./OnlineUsersWidget-CCTnV-aE.js"));
1637
+ const component = await Promise.resolve().then(() => require("./OnlineUsersWidget-D4M4D6rm.js"));
1638
1638
  return component.default;
1639
1639
  },
1640
1640
  id: "online-users-widget",
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const index = require("./index-BBZNey0n.js");
3
+ const index = require("./index-CmW1DJ0c.js");
4
4
  exports.default = index.index;
@@ -1,4 +1,4 @@
1
- import { N } from "./index-BcQdNWzu.mjs";
1
+ import { N } from "./index-C2SrNW6I.mjs";
2
2
  export {
3
3
  N as default
4
4
  };
@@ -858,6 +858,43 @@ var require_block_revocation_scope = __commonJS({
858
858
  }
859
859
  });
860
860
 
861
+ // server/src/utils/strapi-version.js
862
+ var require_strapi_version = __commonJS({
863
+ "server/src/utils/strapi-version.js"(exports2, module2) {
864
+ "use strict";
865
+ var MIN_STRAPI_VERSION = "5.50.0";
866
+ function parseVersion(version) {
867
+ if (typeof version !== "string") return null;
868
+ const match = version.trim().match(/^(\d+)\.(\d+)\.(\d+)/);
869
+ return match ? match.slice(1, 4).map(Number) : null;
870
+ }
871
+ function isSupportedStrapiVersion(version) {
872
+ const current = parseVersion(version);
873
+ if (!current) return null;
874
+ const floor = (
875
+ /** @type {number[]} */
876
+ parseVersion(MIN_STRAPI_VERSION)
877
+ );
878
+ if (current[0] !== floor[0]) return false;
879
+ for (let i = 1; i < 3; i += 1) {
880
+ if (current[i] !== floor[i]) return current[i] > floor[i];
881
+ }
882
+ return true;
883
+ }
884
+ function checkStrapiVersion(strapi2, log) {
885
+ const version = typeof strapi2?.config?.get === "function" ? strapi2.config.get("info.strapi") : void 0;
886
+ const supported = isSupportedStrapiVersion(version);
887
+ if (supported === false) {
888
+ log.error(
889
+ `Strapi ${version} is not supported: Magic Session Manager requires Strapi ${MIN_STRAPI_VERSION} or later (session-manager listSessions/revokeSessionById and admin session metadata). Upgrade Strapi; sign-in in refresh mode and the admin panel sessions view fail on this version.`
890
+ );
891
+ }
892
+ return supported;
893
+ }
894
+ module2.exports = { MIN_STRAPI_VERSION, isSupportedStrapiVersion, checkStrapiVersion };
895
+ }
896
+ });
897
+
861
898
  // server/src/register.js
862
899
  var require_register = __commonJS({
863
900
  "server/src/register.js"(exports2, module2) {
@@ -865,10 +902,12 @@ var require_register = __commonJS({
865
902
  var { createLogger } = require_logger();
866
903
  var { createContentApiPermissionsLifecycle } = require_content_api_permissions();
867
904
  var { isCallerRevocationScope } = require_block_revocation_scope();
905
+ var { checkStrapiVersion } = require_strapi_version();
868
906
  var USER_UID = "plugin::users-permissions.user";
869
907
  module2.exports = async ({ strapi: strapi2 }) => {
870
908
  const log = createLogger(strapi2);
871
909
  log.info("[START] Plugin registration starting...");
910
+ checkStrapiVersion(strapi2, log);
872
911
  strapi2.admin.services.permission.actionProvider.registerMany([
873
912
  {
874
913
  section: "plugins",
@@ -864,6 +864,43 @@ var require_block_revocation_scope = __commonJS({
864
864
  }
865
865
  });
866
866
 
867
+ // server/src/utils/strapi-version.js
868
+ var require_strapi_version = __commonJS({
869
+ "server/src/utils/strapi-version.js"(exports, module) {
870
+ "use strict";
871
+ var MIN_STRAPI_VERSION = "5.50.0";
872
+ function parseVersion(version) {
873
+ if (typeof version !== "string") return null;
874
+ const match = version.trim().match(/^(\d+)\.(\d+)\.(\d+)/);
875
+ return match ? match.slice(1, 4).map(Number) : null;
876
+ }
877
+ function isSupportedStrapiVersion(version) {
878
+ const current = parseVersion(version);
879
+ if (!current) return null;
880
+ const floor = (
881
+ /** @type {number[]} */
882
+ parseVersion(MIN_STRAPI_VERSION)
883
+ );
884
+ if (current[0] !== floor[0]) return false;
885
+ for (let i = 1; i < 3; i += 1) {
886
+ if (current[i] !== floor[i]) return current[i] > floor[i];
887
+ }
888
+ return true;
889
+ }
890
+ function checkStrapiVersion(strapi2, log) {
891
+ const version = typeof strapi2?.config?.get === "function" ? strapi2.config.get("info.strapi") : void 0;
892
+ const supported = isSupportedStrapiVersion(version);
893
+ if (supported === false) {
894
+ log.error(
895
+ `Strapi ${version} is not supported: Magic Session Manager requires Strapi ${MIN_STRAPI_VERSION} or later (session-manager listSessions/revokeSessionById and admin session metadata). Upgrade Strapi; sign-in in refresh mode and the admin panel sessions view fail on this version.`
896
+ );
897
+ }
898
+ return supported;
899
+ }
900
+ module.exports = { MIN_STRAPI_VERSION, isSupportedStrapiVersion, checkStrapiVersion };
901
+ }
902
+ });
903
+
867
904
  // server/src/register.js
868
905
  var require_register = __commonJS({
869
906
  "server/src/register.js"(exports, module) {
@@ -871,10 +908,12 @@ var require_register = __commonJS({
871
908
  var { createLogger } = require_logger();
872
909
  var { createContentApiPermissionsLifecycle } = require_content_api_permissions();
873
910
  var { isCallerRevocationScope } = require_block_revocation_scope();
911
+ var { checkStrapiVersion } = require_strapi_version();
874
912
  var USER_UID = "plugin::users-permissions.user";
875
913
  module.exports = async ({ strapi: strapi2 }) => {
876
914
  const log = createLogger(strapi2);
877
915
  log.info("[START] Plugin registration starting...");
916
+ checkStrapiVersion(strapi2, log);
878
917
  strapi2.admin.services.permission.actionProvider.registerMany([
879
918
  {
880
919
  section: "plugins",
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.14.0",
2
+ "version": "4.14.2",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "strapi-plugin",
@@ -50,6 +50,7 @@
50
50
  "scripts": {
51
51
  "clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\"",
52
52
  "test": "node --test tests/*.test.js tests/*.test.mjs",
53
+ "test:admin": "node --import ./tests/admin/harness/setup.mjs --test \"tests/admin/*.test.jsx\"",
53
54
  "test:concurrency": "node scripts/concurrency/run.mjs",
54
55
  "test:ts:front": "tsc --noEmit --allowJs --jsx react-jsx --moduleResolution bundler --module esnext -p admin/jsconfig.json",
55
56
  "test:ts:back": "tsc --noEmit --allowJs --moduleResolution node --module commonjs -p server/jsconfig.json",
@@ -89,6 +90,7 @@
89
90
  "eslint-config-prettier": "^10.1.8",
90
91
  "eslint-plugin-react-hooks": "^7.1.1",
91
92
  "globals": "^17.14.0",
93
+ "jsdom": "^31.0.1",
92
94
  "pg": "^8.23.1",
93
95
  "prettier": "^3.9.10",
94
96
  "react": "^18.3.1",
@@ -101,8 +103,8 @@
101
103
  "peerDependencies": {
102
104
  "@strapi/design-system": "^2.0.0",
103
105
  "@strapi/icons": "^2.0.0",
104
- "@strapi/plugin-users-permissions": "^5.0.0",
105
- "@strapi/strapi": "^5.0.0",
106
+ "@strapi/plugin-users-permissions": "^5.50.0",
107
+ "@strapi/strapi": "^5.50.0",
106
108
  "react": "^18.0.0",
107
109
  "react-dom": "^18.0.0",
108
110
  "react-intl": "^6.0.0",