strapi-plugin-magic-sessionmanager 4.7.2 → 4.8.0

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +17 -38
  3. package/dist/admin/Analytics-CaRlu5ad.js +332 -0
  4. package/dist/admin/Analytics-THqDbNX0.mjs +330 -0
  5. package/dist/admin/App-AbZwLHtF.js +1263 -0
  6. package/dist/admin/App-hSh7guii.mjs +1261 -0
  7. package/dist/admin/FormField-C8kIT2NE.mjs +59 -0
  8. package/dist/admin/FormField-b5KBvkrj.js +60 -0
  9. package/dist/admin/License-BXBVwUVu.mjs +299 -0
  10. package/dist/admin/License-CABdPwnd.js +301 -0
  11. package/dist/admin/OnlineUsersWidget-BnWFj9IM.mjs +230 -0
  12. package/dist/admin/OnlineUsersWidget-CPFAACSb.js +230 -0
  13. package/dist/admin/PluginPageLayout-BPFMcgrx.mjs +42 -0
  14. package/dist/admin/PluginPageLayout-DmNzMdqu.js +43 -0
  15. package/dist/admin/Settings-B4DNdeKx.js +2152 -0
  16. package/dist/admin/Settings-C4RsJosh.mjs +2150 -0
  17. package/dist/admin/{de-JBE-iylO.mjs → de-AwIFTd9i.mjs} +154 -20
  18. package/dist/admin/{de-BnqGCokx.js → de-D23nmqnl.js} +154 -20
  19. package/dist/admin/{en-BRmVwd8-.js → en-C5iYQ0mC.js} +155 -21
  20. package/dist/admin/{en-kQWtdEai.mjs → en-D6QEGeRh.mjs} +155 -21
  21. package/dist/admin/{es-CH691xcL.js → es-CIXnsG-p.js} +154 -20
  22. package/dist/admin/{es-DOQvBxih.mjs → es-CnFfVdKw.mjs} +154 -20
  23. package/dist/admin/{fr-CLExO0w_.js → fr-BglXE-W4.js} +154 -20
  24. package/dist/admin/{fr-CmfCpepX.mjs → fr-DefoR7uH.mjs} +154 -20
  25. package/dist/admin/index-BFVITQ-o.mjs +624 -0
  26. package/dist/admin/{index-Duc7cR_d.js → index-DlMm-NyK.js} +261 -188
  27. package/dist/admin/index.js +1 -1
  28. package/dist/admin/index.mjs +1 -1
  29. package/dist/admin/maskSensitiveValue-1uGWmrfG.mjs +20 -0
  30. package/dist/admin/maskSensitiveValue-B9vhxPad.js +19 -0
  31. package/dist/admin/{pt-BJ_F0yNi.js → pt-J5sf7jiY.js} +154 -20
  32. package/dist/admin/{pt-BSzZdyAH.mjs → pt-TODwvNQA.mjs} +154 -20
  33. package/dist/server/index.js +4396 -7820
  34. package/dist/server/index.mjs +4396 -7820
  35. package/package.json +21 -19
  36. package/scripts/geoip-updater.cjs +234 -15
  37. package/scripts/update-geoip-db.mjs +3 -0
  38. package/dist/admin/Analytics-CsrpxJwQ.mjs +0 -497
  39. package/dist/admin/Analytics-D03ZNNMR.js +0 -499
  40. package/dist/admin/App-B2VCS3cz.js +0 -1481
  41. package/dist/admin/App-qxKnK7G2.mjs +0 -1479
  42. package/dist/admin/License-ClW7sZLR.mjs +0 -318
  43. package/dist/admin/License-fixnQ7wF.js +0 -320
  44. package/dist/admin/OnlineUsersWidget-mR_OMiwi.mjs +0 -185
  45. package/dist/admin/OnlineUsersWidget-qb9utPBy.js +0 -185
  46. package/dist/admin/Settings-U3V4eGMo.mjs +0 -2038
  47. package/dist/admin/Settings-gv2BF54w.js +0 -2040
  48. package/dist/admin/StyledButtons-Cz8oYhmc.mjs +0 -418
  49. package/dist/admin/StyledButtons-DDuxnYz8.js +0 -419
  50. package/dist/admin/index-B_lFjUAg.mjs +0 -551
  51. package/dist/admin/sessionStatus-D_fWEzgj.js +0 -11
  52. package/dist/admin/sessionStatus-kwggjEMw.mjs +0 -12
@@ -1,185 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useState, useCallback, useEffect } from "react";
3
- import { useIntl } from "react-intl";
4
- import { Box, Typography, Flex, Grid } from "@strapi/design-system";
5
- import { Check, Cross, Clock, User } from "@strapi/icons";
6
- import { useFetchClient } from "@strapi/strapi/admin";
7
- import { g as getTranslation } from "./index-B_lFjUAg.mjs";
8
- function getSessionUserKey(session) {
9
- return session?.user?.documentId || session?.user?.id || session?.user?.email || session?.user?.username || null;
10
- }
11
- function computeOnlineUserStats(sessions, {
12
- now = Date.now(),
13
- totalUsers = 0,
14
- blockedUsers = 0
15
- } = {}) {
16
- const fifteenMin = 15 * 60 * 1e3;
17
- const thirtyMin = 30 * 60 * 1e3;
18
- const onlineNow = /* @__PURE__ */ new Set();
19
- const last15min = /* @__PURE__ */ new Set();
20
- const last30min = /* @__PURE__ */ new Set();
21
- for (const session of sessions || []) {
22
- if (!session?.isActive) continue;
23
- const userKey = getSessionUserKey(session);
24
- if (!userKey) continue;
25
- const lastActive = session.lastActive ? new Date(session.lastActive) : new Date(session.loginTime);
26
- const lastActiveMs = lastActive.getTime();
27
- if (!Number.isFinite(lastActiveMs)) continue;
28
- const timeSinceActive = now - lastActiveMs;
29
- if (timeSinceActive < fifteenMin) {
30
- onlineNow.add(userKey);
31
- last15min.add(userKey);
32
- last30min.add(userKey);
33
- } else if (timeSinceActive < thirtyMin) {
34
- last30min.add(userKey);
35
- }
36
- }
37
- return {
38
- onlineNow: onlineNow.size,
39
- last15min: last15min.size,
40
- last30min: last30min.size,
41
- offline: Math.max(0, totalUsers - onlineNow.size),
42
- totalUsers,
43
- blocked: blockedUsers
44
- };
45
- }
46
- const OnlineUsersWidget = () => {
47
- const { formatMessage } = useIntl();
48
- const { get } = useFetchClient();
49
- const t = (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
50
- const [stats, setStats] = useState({
51
- onlineNow: 0,
52
- offline: 0,
53
- last15min: 0,
54
- last30min: 0,
55
- totalUsers: 0,
56
- blocked: 0
57
- });
58
- const [loading, setLoading] = useState(true);
59
- const fetchStats = useCallback(async () => {
60
- try {
61
- const { data } = await get("/magic-sessionmanager/sessions");
62
- const sessions = data.data || [];
63
- try {
64
- const { data: usersData } = await get("/content-manager/collection-types/plugin::users-permissions.user?pageSize=1");
65
- const totalUsers = usersData?.pagination?.total || 0;
66
- const { data: blockedData } = await get("/content-manager/collection-types/plugin::users-permissions.user?filters[$and][0][blocked][$eq]=true&pageSize=1");
67
- const blockedUsers = blockedData?.pagination?.total || 0;
68
- setStats(computeOnlineUserStats(sessions, {
69
- totalUsers,
70
- blockedUsers
71
- }));
72
- } catch (err) {
73
- console.error("[OnlineUsersWidget] Error fetching user count:", err);
74
- setStats(computeOnlineUserStats(sessions));
75
- }
76
- } catch (err) {
77
- console.error("[OnlineUsersWidget] Error:", err);
78
- } finally {
79
- setLoading(false);
80
- }
81
- }, [get]);
82
- useEffect(() => {
83
- fetchStats();
84
- const interval = setInterval(fetchStats, 3e4);
85
- return () => clearInterval(interval);
86
- }, [fetchStats]);
87
- const StatCard = ({ icon: Icon, label, value, color }) => /* @__PURE__ */ jsx(
88
- Box,
89
- {
90
- as: "a",
91
- padding: 4,
92
- background: "neutral0",
93
- hasRadius: true,
94
- shadow: "tableShadow",
95
- style: {
96
- textDecoration: "none",
97
- cursor: "default",
98
- transition: "box-shadow 0.2s",
99
- border: "1px solid rgba(128, 128, 128, 0.1)"
100
- },
101
- children: /* @__PURE__ */ jsx(Flex, { justifyContent: "space-between", alignItems: "flex-start", children: /* @__PURE__ */ jsxs(Flex, { gap: 3, alignItems: "center", children: [
102
- /* @__PURE__ */ jsx(
103
- Box,
104
- {
105
- padding: 2,
106
- background: `${color}100`,
107
- hasRadius: true,
108
- style: {
109
- display: "flex",
110
- alignItems: "center",
111
- justifyContent: "center"
112
- },
113
- children: /* @__PURE__ */ jsx(Icon, { width: "16px", height: "16px", fill: `${color}600` })
114
- }
115
- ),
116
- /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "flex-start", children: [
117
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: label }),
118
- /* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", textColor: "neutral800", children: value })
119
- ] })
120
- ] }) })
121
- }
122
- );
123
- if (loading) {
124
- return /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t("common.loading", "Loading...") }) });
125
- }
126
- return /* @__PURE__ */ jsx(Box, { padding: 0, children: /* @__PURE__ */ jsx(Flex, { direction: "column", gap: 3, children: /* @__PURE__ */ jsxs(Grid.Root, { gap: 3, gridCols: 2, children: [
127
- /* @__PURE__ */ jsx(Grid.Item, { col: 1, children: /* @__PURE__ */ jsx(
128
- StatCard,
129
- {
130
- icon: Check,
131
- label: t("widget.stats.onlineNow", "Online Now"),
132
- value: stats.onlineNow,
133
- color: "success"
134
- }
135
- ) }),
136
- /* @__PURE__ */ jsx(Grid.Item, { col: 1, children: /* @__PURE__ */ jsx(
137
- StatCard,
138
- {
139
- icon: Cross,
140
- label: t("widget.stats.offline", "Offline"),
141
- value: stats.offline,
142
- color: "neutral"
143
- }
144
- ) }),
145
- /* @__PURE__ */ jsx(Grid.Item, { col: 1, children: /* @__PURE__ */ jsx(
146
- StatCard,
147
- {
148
- icon: Clock,
149
- label: t("widget.stats.last15min", "Last 15 min"),
150
- value: stats.last15min,
151
- color: "primary"
152
- }
153
- ) }),
154
- /* @__PURE__ */ jsx(Grid.Item, { col: 1, children: /* @__PURE__ */ jsx(
155
- StatCard,
156
- {
157
- icon: Clock,
158
- label: t("widget.stats.last30min", "Last 30 min"),
159
- value: stats.last30min,
160
- color: "secondary"
161
- }
162
- ) }),
163
- /* @__PURE__ */ jsx(Grid.Item, { col: 1, children: /* @__PURE__ */ jsx(
164
- StatCard,
165
- {
166
- icon: User,
167
- label: t("widget.stats.totalUsers", "Total Users"),
168
- value: stats.totalUsers,
169
- color: "neutral"
170
- }
171
- ) }),
172
- /* @__PURE__ */ jsx(Grid.Item, { col: 1, children: /* @__PURE__ */ jsx(
173
- StatCard,
174
- {
175
- icon: Cross,
176
- label: t("widget.stats.blocked", "Blocked"),
177
- value: stats.blocked,
178
- color: "danger"
179
- }
180
- ) })
181
- ] }) }) });
182
- };
183
- export {
184
- OnlineUsersWidget as default
185
- };
@@ -1,185 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const jsxRuntime = require("react/jsx-runtime");
4
- const react = require("react");
5
- const reactIntl = require("react-intl");
6
- const designSystem = require("@strapi/design-system");
7
- const icons = require("@strapi/icons");
8
- const admin = require("@strapi/strapi/admin");
9
- const index = require("./index-Duc7cR_d.js");
10
- function getSessionUserKey(session) {
11
- return session?.user?.documentId || session?.user?.id || session?.user?.email || session?.user?.username || null;
12
- }
13
- function computeOnlineUserStats(sessions, {
14
- now = Date.now(),
15
- totalUsers = 0,
16
- blockedUsers = 0
17
- } = {}) {
18
- const fifteenMin = 15 * 60 * 1e3;
19
- const thirtyMin = 30 * 60 * 1e3;
20
- const onlineNow = /* @__PURE__ */ new Set();
21
- const last15min = /* @__PURE__ */ new Set();
22
- const last30min = /* @__PURE__ */ new Set();
23
- for (const session of sessions || []) {
24
- if (!session?.isActive) continue;
25
- const userKey = getSessionUserKey(session);
26
- if (!userKey) continue;
27
- const lastActive = session.lastActive ? new Date(session.lastActive) : new Date(session.loginTime);
28
- const lastActiveMs = lastActive.getTime();
29
- if (!Number.isFinite(lastActiveMs)) continue;
30
- const timeSinceActive = now - lastActiveMs;
31
- if (timeSinceActive < fifteenMin) {
32
- onlineNow.add(userKey);
33
- last15min.add(userKey);
34
- last30min.add(userKey);
35
- } else if (timeSinceActive < thirtyMin) {
36
- last30min.add(userKey);
37
- }
38
- }
39
- return {
40
- onlineNow: onlineNow.size,
41
- last15min: last15min.size,
42
- last30min: last30min.size,
43
- offline: Math.max(0, totalUsers - onlineNow.size),
44
- totalUsers,
45
- blocked: blockedUsers
46
- };
47
- }
48
- const OnlineUsersWidget = () => {
49
- const { formatMessage } = reactIntl.useIntl();
50
- const { get } = admin.useFetchClient();
51
- const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
52
- const [stats, setStats] = react.useState({
53
- onlineNow: 0,
54
- offline: 0,
55
- last15min: 0,
56
- last30min: 0,
57
- totalUsers: 0,
58
- blocked: 0
59
- });
60
- const [loading, setLoading] = react.useState(true);
61
- const fetchStats = react.useCallback(async () => {
62
- try {
63
- const { data } = await get("/magic-sessionmanager/sessions");
64
- const sessions = data.data || [];
65
- try {
66
- const { data: usersData } = await get("/content-manager/collection-types/plugin::users-permissions.user?pageSize=1");
67
- const totalUsers = usersData?.pagination?.total || 0;
68
- const { data: blockedData } = await get("/content-manager/collection-types/plugin::users-permissions.user?filters[$and][0][blocked][$eq]=true&pageSize=1");
69
- const blockedUsers = blockedData?.pagination?.total || 0;
70
- setStats(computeOnlineUserStats(sessions, {
71
- totalUsers,
72
- blockedUsers
73
- }));
74
- } catch (err) {
75
- console.error("[OnlineUsersWidget] Error fetching user count:", err);
76
- setStats(computeOnlineUserStats(sessions));
77
- }
78
- } catch (err) {
79
- console.error("[OnlineUsersWidget] Error:", err);
80
- } finally {
81
- setLoading(false);
82
- }
83
- }, [get]);
84
- react.useEffect(() => {
85
- fetchStats();
86
- const interval = setInterval(fetchStats, 3e4);
87
- return () => clearInterval(interval);
88
- }, [fetchStats]);
89
- const StatCard = ({ icon: Icon, label, value, color }) => /* @__PURE__ */ jsxRuntime.jsx(
90
- designSystem.Box,
91
- {
92
- as: "a",
93
- padding: 4,
94
- background: "neutral0",
95
- hasRadius: true,
96
- shadow: "tableShadow",
97
- style: {
98
- textDecoration: "none",
99
- cursor: "default",
100
- transition: "box-shadow 0.2s",
101
- border: "1px solid rgba(128, 128, 128, 0.1)"
102
- },
103
- children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-start", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, alignItems: "center", children: [
104
- /* @__PURE__ */ jsxRuntime.jsx(
105
- designSystem.Box,
106
- {
107
- padding: 2,
108
- background: `${color}100`,
109
- hasRadius: true,
110
- style: {
111
- display: "flex",
112
- alignItems: "center",
113
- justifyContent: "center"
114
- },
115
- children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { width: "16px", height: "16px", fill: `${color}600` })
116
- }
117
- ),
118
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "flex-start", children: [
119
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: label }),
120
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", fontWeight: "bold", textColor: "neutral800", children: value })
121
- ] })
122
- ] }) })
123
- }
124
- );
125
- if (loading) {
126
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("common.loading", "Loading...") }) });
127
- }
128
- return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 0, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", gap: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 3, gridCols: 2, children: [
129
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
130
- StatCard,
131
- {
132
- icon: icons.Check,
133
- label: t("widget.stats.onlineNow", "Online Now"),
134
- value: stats.onlineNow,
135
- color: "success"
136
- }
137
- ) }),
138
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
139
- StatCard,
140
- {
141
- icon: icons.Cross,
142
- label: t("widget.stats.offline", "Offline"),
143
- value: stats.offline,
144
- color: "neutral"
145
- }
146
- ) }),
147
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
148
- StatCard,
149
- {
150
- icon: icons.Clock,
151
- label: t("widget.stats.last15min", "Last 15 min"),
152
- value: stats.last15min,
153
- color: "primary"
154
- }
155
- ) }),
156
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
157
- StatCard,
158
- {
159
- icon: icons.Clock,
160
- label: t("widget.stats.last30min", "Last 30 min"),
161
- value: stats.last30min,
162
- color: "secondary"
163
- }
164
- ) }),
165
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
166
- StatCard,
167
- {
168
- icon: icons.User,
169
- label: t("widget.stats.totalUsers", "Total Users"),
170
- value: stats.totalUsers,
171
- color: "neutral"
172
- }
173
- ) }),
174
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
175
- StatCard,
176
- {
177
- icon: icons.Cross,
178
- label: t("widget.stats.blocked", "Blocked"),
179
- value: stats.blocked,
180
- color: "danger"
181
- }
182
- ) })
183
- ] }) }) });
184
- };
185
- exports.default = OnlineUsersWidget;