strapi-plugin-magic-sessionmanager 4.7.1 → 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.
- package/CHANGELOG.md +27 -0
- package/README.md +17 -38
- package/dist/admin/Analytics-CaRlu5ad.js +332 -0
- package/dist/admin/Analytics-THqDbNX0.mjs +330 -0
- package/dist/admin/App-AbZwLHtF.js +1263 -0
- package/dist/admin/App-hSh7guii.mjs +1261 -0
- package/dist/admin/FormField-C8kIT2NE.mjs +59 -0
- package/dist/admin/FormField-b5KBvkrj.js +60 -0
- package/dist/admin/License-BXBVwUVu.mjs +299 -0
- package/dist/admin/License-CABdPwnd.js +301 -0
- package/dist/admin/OnlineUsersWidget-BnWFj9IM.mjs +230 -0
- package/dist/admin/OnlineUsersWidget-CPFAACSb.js +230 -0
- package/dist/admin/PluginPageLayout-BPFMcgrx.mjs +42 -0
- package/dist/admin/PluginPageLayout-DmNzMdqu.js +43 -0
- package/dist/admin/Settings-B4DNdeKx.js +2152 -0
- package/dist/admin/Settings-C4RsJosh.mjs +2150 -0
- package/dist/admin/{de-JBE-iylO.mjs → de-AwIFTd9i.mjs} +154 -20
- package/dist/admin/{de-BnqGCokx.js → de-D23nmqnl.js} +154 -20
- package/dist/admin/{en-BRmVwd8-.js → en-C5iYQ0mC.js} +155 -21
- package/dist/admin/{en-kQWtdEai.mjs → en-D6QEGeRh.mjs} +155 -21
- package/dist/admin/{es-CH691xcL.js → es-CIXnsG-p.js} +154 -20
- package/dist/admin/{es-DOQvBxih.mjs → es-CnFfVdKw.mjs} +154 -20
- package/dist/admin/{fr-CLExO0w_.js → fr-BglXE-W4.js} +154 -20
- package/dist/admin/{fr-CmfCpepX.mjs → fr-DefoR7uH.mjs} +154 -20
- package/dist/admin/index-BFVITQ-o.mjs +624 -0
- package/dist/admin/{index-Duc7cR_d.js → index-DlMm-NyK.js} +261 -188
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/admin/maskSensitiveValue-1uGWmrfG.mjs +20 -0
- package/dist/admin/maskSensitiveValue-B9vhxPad.js +19 -0
- package/dist/admin/{pt-BJ_F0yNi.js → pt-J5sf7jiY.js} +154 -20
- package/dist/admin/{pt-BSzZdyAH.mjs → pt-TODwvNQA.mjs} +154 -20
- package/dist/server/index.js +2812 -6159
- package/dist/server/index.mjs +2812 -6159
- package/package.json +21 -19
- package/scripts/geoip-updater.cjs +234 -15
- package/scripts/update-geoip-db.mjs +3 -0
- package/dist/admin/Analytics-CsrpxJwQ.mjs +0 -497
- package/dist/admin/Analytics-D03ZNNMR.js +0 -499
- package/dist/admin/App-B2VCS3cz.js +0 -1481
- package/dist/admin/App-qxKnK7G2.mjs +0 -1479
- package/dist/admin/License-ClW7sZLR.mjs +0 -318
- package/dist/admin/License-fixnQ7wF.js +0 -320
- package/dist/admin/OnlineUsersWidget-mR_OMiwi.mjs +0 -185
- package/dist/admin/OnlineUsersWidget-qb9utPBy.js +0 -185
- package/dist/admin/Settings-U3V4eGMo.mjs +0 -2038
- package/dist/admin/Settings-gv2BF54w.js +0 -2040
- package/dist/admin/StyledButtons-Cz8oYhmc.mjs +0 -418
- package/dist/admin/StyledButtons-DDuxnYz8.js +0 -419
- package/dist/admin/index-B_lFjUAg.mjs +0 -551
- package/dist/admin/sessionStatus-D_fWEzgj.js +0 -11
- package/dist/admin/sessionStatus-kwggjEMw.mjs +0 -12
|
@@ -0,0 +1,230 @@
|
|
|
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 index = require("./index-DlMm-NyK.js");
|
|
8
|
+
const icons = require("@strapi/icons");
|
|
9
|
+
const admin = require("@strapi/strapi/admin");
|
|
10
|
+
function getSessionUserKey(session) {
|
|
11
|
+
return session?.user?.documentId || session?.user?.id || session?.user?.email || session?.user?.username || null;
|
|
12
|
+
}
|
|
13
|
+
function normalizeUserCounts(response) {
|
|
14
|
+
const totalUsers = response?.data?.totalUsers;
|
|
15
|
+
const blockedUsers = response?.data?.blockedUsers;
|
|
16
|
+
if (response?.success !== true || !Number.isSafeInteger(totalUsers) || totalUsers < 0 || !Number.isSafeInteger(blockedUsers) || blockedUsers < 0 || blockedUsers > totalUsers) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return { totalUsers, blockedUsers };
|
|
20
|
+
}
|
|
21
|
+
function computeOnlineUserStats(sessions, {
|
|
22
|
+
now = Date.now(),
|
|
23
|
+
totalUsers = null,
|
|
24
|
+
blockedUsers = null
|
|
25
|
+
} = {}) {
|
|
26
|
+
const fifteenMin = 15 * 60 * 1e3;
|
|
27
|
+
const thirtyMin = 30 * 60 * 1e3;
|
|
28
|
+
const onlineNow = /* @__PURE__ */ new Set();
|
|
29
|
+
const last15min = /* @__PURE__ */ new Set();
|
|
30
|
+
const last30min = /* @__PURE__ */ new Set();
|
|
31
|
+
for (const session of sessions || []) {
|
|
32
|
+
if (!session?.isActive) continue;
|
|
33
|
+
const userKey = getSessionUserKey(session);
|
|
34
|
+
if (!userKey) continue;
|
|
35
|
+
const lastActive = session.lastActive ? new Date(session.lastActive) : new Date(session.loginTime);
|
|
36
|
+
const lastActiveMs = lastActive.getTime();
|
|
37
|
+
if (!Number.isFinite(lastActiveMs)) continue;
|
|
38
|
+
const timeSinceActive = now - lastActiveMs;
|
|
39
|
+
if (timeSinceActive < fifteenMin) {
|
|
40
|
+
onlineNow.add(userKey);
|
|
41
|
+
last15min.add(userKey);
|
|
42
|
+
last30min.add(userKey);
|
|
43
|
+
} else if (timeSinceActive < thirtyMin) {
|
|
44
|
+
last30min.add(userKey);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const hasTotalUsers = Number.isSafeInteger(totalUsers) && totalUsers >= 0;
|
|
48
|
+
const hasBlockedUsers = Number.isSafeInteger(blockedUsers) && blockedUsers >= 0;
|
|
49
|
+
return {
|
|
50
|
+
onlineNow: onlineNow.size,
|
|
51
|
+
last15min: last15min.size,
|
|
52
|
+
last30min: last30min.size,
|
|
53
|
+
offline: hasTotalUsers ? Math.max(0, totalUsers - onlineNow.size) : null,
|
|
54
|
+
totalUsers: hasTotalUsers ? totalUsers : null,
|
|
55
|
+
blocked: hasBlockedUsers ? blockedUsers : null
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
const OnlineUsersWidget = () => {
|
|
59
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
60
|
+
const { get } = admin.useFetchClient();
|
|
61
|
+
const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
|
|
62
|
+
const [stats, setStats] = react.useState({
|
|
63
|
+
onlineNow: 0,
|
|
64
|
+
offline: null,
|
|
65
|
+
last15min: 0,
|
|
66
|
+
last30min: 0,
|
|
67
|
+
totalUsers: null,
|
|
68
|
+
blocked: null
|
|
69
|
+
});
|
|
70
|
+
const [loading, setLoading] = react.useState(true);
|
|
71
|
+
const [loadError, setLoadError] = react.useState(false);
|
|
72
|
+
const [userCountsUnavailable, setUserCountsUnavailable] = react.useState(false);
|
|
73
|
+
const requestInProgress = react.useRef(false);
|
|
74
|
+
const fetchStats = react.useCallback(async ({ showLoading = true } = {}) => {
|
|
75
|
+
if (requestInProgress.current) return;
|
|
76
|
+
requestInProgress.current = true;
|
|
77
|
+
if (showLoading) setLoading(true);
|
|
78
|
+
try {
|
|
79
|
+
const { data: sessionResponse } = await get("/magic-sessionmanager/sessions");
|
|
80
|
+
const sessions = sessionResponse?.data;
|
|
81
|
+
if (!Array.isArray(sessions)) throw new Error("Invalid session response");
|
|
82
|
+
let userCounts = null;
|
|
83
|
+
let countsUnavailable = false;
|
|
84
|
+
try {
|
|
85
|
+
const { data: userStatsResponse } = await get("/magic-sessionmanager/users/stats");
|
|
86
|
+
userCounts = normalizeUserCounts(userStatsResponse);
|
|
87
|
+
if (!userCounts) throw new Error("Invalid user statistics response");
|
|
88
|
+
} catch (error) {
|
|
89
|
+
index.logSafeAdminError("onlineUsers.userCounts", error);
|
|
90
|
+
countsUnavailable = true;
|
|
91
|
+
}
|
|
92
|
+
setStats(computeOnlineUserStats(sessions, userCounts || {}));
|
|
93
|
+
setUserCountsUnavailable(countsUnavailable);
|
|
94
|
+
setLoadError(false);
|
|
95
|
+
} catch (error) {
|
|
96
|
+
index.logSafeAdminError("onlineUsers.loadSessions", error);
|
|
97
|
+
setLoadError(true);
|
|
98
|
+
} finally {
|
|
99
|
+
if (showLoading) setLoading(false);
|
|
100
|
+
requestInProgress.current = false;
|
|
101
|
+
}
|
|
102
|
+
}, [get]);
|
|
103
|
+
react.useEffect(() => {
|
|
104
|
+
void fetchStats();
|
|
105
|
+
const interval = setInterval(() => {
|
|
106
|
+
void fetchStats({ showLoading: false });
|
|
107
|
+
}, 3e4);
|
|
108
|
+
return () => clearInterval(interval);
|
|
109
|
+
}, [fetchStats]);
|
|
110
|
+
const StatCard = ({ icon: Icon, label, value, color }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
111
|
+
designSystem.Box,
|
|
112
|
+
{
|
|
113
|
+
padding: 4,
|
|
114
|
+
background: "neutral0",
|
|
115
|
+
hasRadius: true,
|
|
116
|
+
shadow: "tableShadow",
|
|
117
|
+
style: {
|
|
118
|
+
textDecoration: "none",
|
|
119
|
+
cursor: "default",
|
|
120
|
+
transition: "box-shadow 0.2s",
|
|
121
|
+
border: "1px solid rgba(128, 128, 128, 0.1)"
|
|
122
|
+
},
|
|
123
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-start", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, alignItems: "center", children: [
|
|
124
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
125
|
+
designSystem.Box,
|
|
126
|
+
{
|
|
127
|
+
padding: 2,
|
|
128
|
+
background: `${color}100`,
|
|
129
|
+
hasRadius: true,
|
|
130
|
+
style: {
|
|
131
|
+
display: "flex",
|
|
132
|
+
alignItems: "center",
|
|
133
|
+
justifyContent: "center"
|
|
134
|
+
},
|
|
135
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { width: "16px", height: "16px", fill: `${color}600` })
|
|
136
|
+
}
|
|
137
|
+
),
|
|
138
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 1, alignItems: "flex-start", children: [
|
|
139
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: label }),
|
|
140
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", fontWeight: "bold", textColor: "neutral800", children: value ?? t("common.unavailable", "Unavailable") })
|
|
141
|
+
] })
|
|
142
|
+
] }) })
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
if (loading) {
|
|
146
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t("common.loading", "Loading...") }) });
|
|
147
|
+
}
|
|
148
|
+
if (loadError) {
|
|
149
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, role: "alert", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
150
|
+
designSystem.Alert,
|
|
151
|
+
{
|
|
152
|
+
variant: "danger",
|
|
153
|
+
title: t("widget.error.title", "Session statistics could not be loaded"),
|
|
154
|
+
closeLabel: "",
|
|
155
|
+
action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: () => {
|
|
156
|
+
void fetchStats();
|
|
157
|
+
}, children: t("common.retry", "Retry") }),
|
|
158
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral700", tag: "span", children: t("widget.error.description", "Try again. If the problem continues, check Session Manager API access.") })
|
|
159
|
+
}
|
|
160
|
+
) });
|
|
161
|
+
}
|
|
162
|
+
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 0, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, children: [
|
|
163
|
+
userCountsUnavailable && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { role: "status", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
164
|
+
designSystem.Alert,
|
|
165
|
+
{
|
|
166
|
+
variant: "warning",
|
|
167
|
+
title: t("widget.partial.title", "Some user counts are unavailable"),
|
|
168
|
+
closeLabel: "",
|
|
169
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral700", tag: "span", children: t("widget.partial.description", "Session activity is shown, but total and blocked user counts could not be loaded.") })
|
|
170
|
+
}
|
|
171
|
+
) }),
|
|
172
|
+
/* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 3, gridCols: 2, children: [
|
|
173
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
174
|
+
StatCard,
|
|
175
|
+
{
|
|
176
|
+
icon: icons.Check,
|
|
177
|
+
label: t("widget.stats.onlineNow", "Online Now"),
|
|
178
|
+
value: stats.onlineNow,
|
|
179
|
+
color: "success"
|
|
180
|
+
}
|
|
181
|
+
) }),
|
|
182
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
183
|
+
StatCard,
|
|
184
|
+
{
|
|
185
|
+
icon: icons.Cross,
|
|
186
|
+
label: t("widget.stats.offline", "Offline"),
|
|
187
|
+
value: stats.offline,
|
|
188
|
+
color: "neutral"
|
|
189
|
+
}
|
|
190
|
+
) }),
|
|
191
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
192
|
+
StatCard,
|
|
193
|
+
{
|
|
194
|
+
icon: icons.Clock,
|
|
195
|
+
label: t("widget.stats.last15min", "Last 15 min"),
|
|
196
|
+
value: stats.last15min,
|
|
197
|
+
color: "primary"
|
|
198
|
+
}
|
|
199
|
+
) }),
|
|
200
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
201
|
+
StatCard,
|
|
202
|
+
{
|
|
203
|
+
icon: icons.Clock,
|
|
204
|
+
label: t("widget.stats.last30min", "Last 30 min"),
|
|
205
|
+
value: stats.last30min,
|
|
206
|
+
color: "secondary"
|
|
207
|
+
}
|
|
208
|
+
) }),
|
|
209
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
210
|
+
StatCard,
|
|
211
|
+
{
|
|
212
|
+
icon: icons.User,
|
|
213
|
+
label: t("widget.stats.totalUsers", "Total Users"),
|
|
214
|
+
value: stats.totalUsers,
|
|
215
|
+
color: "neutral"
|
|
216
|
+
}
|
|
217
|
+
) }),
|
|
218
|
+
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 1, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
219
|
+
StatCard,
|
|
220
|
+
{
|
|
221
|
+
icon: icons.Cross,
|
|
222
|
+
label: t("widget.stats.blocked", "Blocked"),
|
|
223
|
+
value: stats.blocked,
|
|
224
|
+
color: "danger"
|
|
225
|
+
}
|
|
226
|
+
) })
|
|
227
|
+
] })
|
|
228
|
+
] }) });
|
|
229
|
+
};
|
|
230
|
+
exports.default = OnlineUsersWidget;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Main, Flex } from "@strapi/design-system";
|
|
3
|
+
import styled from "styled-components";
|
|
4
|
+
import { Layouts } from "@strapi/strapi/admin";
|
|
5
|
+
import { e as paragraphRhythm } from "./index-BFVITQ-o.mjs";
|
|
6
|
+
const PageContent = styled(Flex)`
|
|
7
|
+
width: 100%;
|
|
8
|
+
min-width: 0;
|
|
9
|
+
|
|
10
|
+
${paragraphRhythm}
|
|
11
|
+
`;
|
|
12
|
+
const PluginPageLayout = ({
|
|
13
|
+
headingId,
|
|
14
|
+
title,
|
|
15
|
+
subtitle,
|
|
16
|
+
primaryAction,
|
|
17
|
+
children
|
|
18
|
+
}) => /* @__PURE__ */ jsxs(Main, { "aria-labelledby": headingId, children: [
|
|
19
|
+
/* @__PURE__ */ jsx(
|
|
20
|
+
Layouts.Header,
|
|
21
|
+
{
|
|
22
|
+
id: headingId,
|
|
23
|
+
title,
|
|
24
|
+
subtitle,
|
|
25
|
+
primaryAction
|
|
26
|
+
}
|
|
27
|
+
),
|
|
28
|
+
/* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsx(
|
|
29
|
+
PageContent,
|
|
30
|
+
{
|
|
31
|
+
direction: "column",
|
|
32
|
+
gap: 4,
|
|
33
|
+
padding: { initial: 3, small: 6 },
|
|
34
|
+
alignItems: "stretch",
|
|
35
|
+
"data-text-rhythm": "page",
|
|
36
|
+
children
|
|
37
|
+
}
|
|
38
|
+
) })
|
|
39
|
+
] });
|
|
40
|
+
export {
|
|
41
|
+
PluginPageLayout as P
|
|
42
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const designSystem = require("@strapi/design-system");
|
|
4
|
+
const styled = require("styled-components");
|
|
5
|
+
const admin = require("@strapi/strapi/admin");
|
|
6
|
+
const index = require("./index-DlMm-NyK.js");
|
|
7
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
8
|
+
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
9
|
+
const PageContent = styled__default.default(designSystem.Flex)`
|
|
10
|
+
width: 100%;
|
|
11
|
+
min-width: 0;
|
|
12
|
+
|
|
13
|
+
${index.paragraphRhythm}
|
|
14
|
+
`;
|
|
15
|
+
const PluginPageLayout = ({
|
|
16
|
+
headingId,
|
|
17
|
+
title,
|
|
18
|
+
subtitle,
|
|
19
|
+
primaryAction,
|
|
20
|
+
children
|
|
21
|
+
}) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Main, { "aria-labelledby": headingId, children: [
|
|
22
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
23
|
+
admin.Layouts.Header,
|
|
24
|
+
{
|
|
25
|
+
id: headingId,
|
|
26
|
+
title,
|
|
27
|
+
subtitle,
|
|
28
|
+
primaryAction
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
/* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
32
|
+
PageContent,
|
|
33
|
+
{
|
|
34
|
+
direction: "column",
|
|
35
|
+
gap: 4,
|
|
36
|
+
padding: { initial: 3, small: 6 },
|
|
37
|
+
alignItems: "stretch",
|
|
38
|
+
"data-text-rhythm": "page",
|
|
39
|
+
children
|
|
40
|
+
}
|
|
41
|
+
) })
|
|
42
|
+
] });
|
|
43
|
+
exports.PluginPageLayout = PluginPageLayout;
|