strapi-plugin-magic-sessionmanager 4.8.0 → 4.9.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +90 -5
  2. package/README.md +379 -641
  3. package/dist/admin/Analytics-dyJmyxO-.mjs +418 -0
  4. package/dist/admin/Analytics-lVDnHBYp.js +420 -0
  5. package/dist/admin/App-CdgiY_Y7.js +1896 -0
  6. package/dist/admin/App-Cgf_CSjw.mjs +1894 -0
  7. package/dist/admin/License-1XUfQty5.js +443 -0
  8. package/dist/admin/License-C4WSYoqY.mjs +443 -0
  9. package/dist/admin/OnlineUsersWidget-DJC4V1KS.mjs +255 -0
  10. package/dist/admin/OnlineUsersWidget-DMPtuIpm.js +274 -0
  11. package/dist/admin/SectionCard-BlWv8CRt.js +54 -0
  12. package/dist/admin/SectionCard-D51bv4Hi.mjs +55 -0
  13. package/dist/admin/Settings-0QsyY7fe.js +3570 -0
  14. package/dist/admin/Settings-DgeuUiMF.mjs +3568 -0
  15. package/dist/admin/de-BFKoGEVT.js +544 -0
  16. package/dist/admin/de-j0oZH9Pz.mjs +544 -0
  17. package/dist/admin/en-UY4Tb5tE.mjs +544 -0
  18. package/dist/admin/en-s7Ksdkcg.js +544 -0
  19. package/dist/admin/es-07OGMe_5.js +544 -0
  20. package/dist/admin/es-DGBcZwQy.mjs +544 -0
  21. package/dist/admin/fr-B6-DWhGO.mjs +544 -0
  22. package/dist/admin/fr-ETj_2UBY.js +544 -0
  23. package/dist/admin/index-Ck19e8qw.mjs +1760 -0
  24. package/dist/admin/index-D-Nr0TCm.js +1761 -0
  25. package/dist/admin/index.js +1 -1
  26. package/dist/admin/index.mjs +2 -2
  27. package/dist/admin/maskSensitiveValue-BWcSjow7.js +9 -0
  28. package/dist/admin/maskSensitiveValue-lLRhN_S7.mjs +10 -0
  29. package/dist/admin/pt-C7PwrQtV.js +544 -0
  30. package/dist/admin/pt-YMRLm9gx.mjs +544 -0
  31. package/dist/server/index.js +1092 -463
  32. package/dist/server/index.mjs +1092 -463
  33. package/package.json +10 -1
  34. package/pics/analytics.png +0 -0
  35. package/pics/dashboard-dark.png +0 -0
  36. package/pics/dashboard.png +0 -0
  37. package/pics/dashboardsessionmodal.png +0 -0
  38. package/pics/mobile-dashboard.png +0 -0
  39. package/pics/mobile-session.png +0 -0
  40. package/pics/sessioninfopanel.png +0 -0
  41. package/pics/settings1.png +0 -0
  42. package/pics/settings2.png +0 -0
  43. package/pics/widget.png +0 -0
  44. package/scripts/geoip-updater.cjs +35 -24
  45. package/dist/admin/Analytics-CaRlu5ad.js +0 -332
  46. package/dist/admin/Analytics-THqDbNX0.mjs +0 -330
  47. package/dist/admin/App-AbZwLHtF.js +0 -1263
  48. package/dist/admin/App-hSh7guii.mjs +0 -1261
  49. package/dist/admin/FormField-C8kIT2NE.mjs +0 -59
  50. package/dist/admin/FormField-b5KBvkrj.js +0 -60
  51. package/dist/admin/License-BXBVwUVu.mjs +0 -299
  52. package/dist/admin/License-CABdPwnd.js +0 -301
  53. package/dist/admin/OnlineUsersWidget-BnWFj9IM.mjs +0 -230
  54. package/dist/admin/OnlineUsersWidget-CPFAACSb.js +0 -230
  55. package/dist/admin/PluginPageLayout-BPFMcgrx.mjs +0 -42
  56. package/dist/admin/PluginPageLayout-DmNzMdqu.js +0 -43
  57. package/dist/admin/Settings-B4DNdeKx.js +0 -2152
  58. package/dist/admin/Settings-C4RsJosh.mjs +0 -2150
  59. package/dist/admin/de-AwIFTd9i.mjs +0 -450
  60. package/dist/admin/de-D23nmqnl.js +0 -450
  61. package/dist/admin/en-C5iYQ0mC.js +0 -450
  62. package/dist/admin/en-D6QEGeRh.mjs +0 -450
  63. package/dist/admin/es-CIXnsG-p.js +0 -435
  64. package/dist/admin/es-CnFfVdKw.mjs +0 -435
  65. package/dist/admin/fr-BglXE-W4.js +0 -435
  66. package/dist/admin/fr-DefoR7uH.mjs +0 -435
  67. package/dist/admin/index-BFVITQ-o.mjs +0 -624
  68. package/dist/admin/index-DlMm-NyK.js +0 -625
  69. package/dist/admin/maskSensitiveValue-1uGWmrfG.mjs +0 -20
  70. package/dist/admin/maskSensitiveValue-B9vhxPad.js +0 -19
  71. package/dist/admin/pt-J5sf7jiY.js +0 -435
  72. package/dist/admin/pt-TODwvNQA.mjs +0 -435
@@ -1,624 +0,0 @@
1
- import { useRef, useEffect, useState } from "react";
2
- import { jsx, jsxs } from "react/jsx-runtime";
3
- import { useIntl } from "react-intl";
4
- import styled, { css } from "styled-components";
5
- import { Typography, Box, Alert, Button, Flex, Badge, Divider } from "@strapi/design-system";
6
- import { Server, Clock, User, Cross, Check, Phone, Monitor, Information } from "@strapi/icons";
7
- import { useRBAC, useFetchClient, useNotification } from "@strapi/strapi/admin";
8
- const strapi = { "name": "magic-sessionmanager", "displayName": "Magic Sessionmanager" };
9
- const pluginPkg = {
10
- strapi
11
- };
12
- const pluginId$1 = "magic-sessionmanager";
13
- const PLUGIN_ID = pluginId$1;
14
- const Initializer = ({ setPlugin }) => {
15
- const ref = useRef(setPlugin);
16
- useEffect(() => {
17
- if (ref.current) {
18
- ref.current(pluginId$1);
19
- }
20
- }, []);
21
- return null;
22
- };
23
- const PluginIcon = () => /* @__PURE__ */ jsx("svg", { viewBox: "0 0 32 32", fill: "currentColor", width: "24", height: "24", children: /* @__PURE__ */ jsx("path", { d: "M26 5H6a3 3 0 0 0-3 3v14a3 3 0 0 0 3 3h20a3 3 0 0 0 3-3V8a3 3 0 0 0-3-3M20 27h-8a1 1 0 0 0 0 2h8a1 1 0 0 0 0-2" }) });
24
- const parseUserAgent = (userAgent) => {
25
- if (!userAgent) {
26
- return {
27
- device: "Unknown",
28
- deviceIcon: "question",
29
- browser: "Unknown",
30
- os: "Unknown"
31
- };
32
- }
33
- const ua = userAgent.toLowerCase();
34
- let device = "Desktop";
35
- let deviceIcon = "desktop";
36
- if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(userAgent)) {
37
- device = "Tablet";
38
- deviceIcon = "tablet";
39
- } else if (/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(userAgent)) {
40
- device = "Mobile";
41
- deviceIcon = "mobile";
42
- }
43
- let browser = "Unknown";
44
- if (ua.includes("edg/")) {
45
- browser = "Edge";
46
- } else if (ua.includes("chrome/") && !ua.includes("edg/")) {
47
- browser = "Chrome";
48
- } else if (ua.includes("firefox/")) {
49
- browser = "Firefox";
50
- } else if (ua.includes("safari/") && !ua.includes("chrome/")) {
51
- browser = "Safari";
52
- } else if (ua.includes("opera/") || ua.includes("opr/")) {
53
- browser = "Opera";
54
- } else if (ua.includes("curl/")) {
55
- browser = "cURL";
56
- deviceIcon = "gear";
57
- device = "API Client";
58
- } else if (ua.includes("postman")) {
59
- browser = "Postman";
60
- deviceIcon = "code";
61
- device = "API Client";
62
- } else if (ua.includes("insomnia")) {
63
- browser = "Insomnia";
64
- deviceIcon = "code";
65
- device = "API Client";
66
- }
67
- let os = "Unknown";
68
- if (ua.includes("android")) {
69
- os = "Android";
70
- } else if (ua.includes("iphone") || ua.includes("ipad")) {
71
- os = "iOS";
72
- } else if (ua.includes("windows")) {
73
- os = "Windows";
74
- } else if (ua.includes("mac os x") || ua.includes("macintosh")) {
75
- os = "macOS";
76
- } else if (ua.includes("linux")) {
77
- os = "Linux";
78
- }
79
- return {
80
- device,
81
- deviceIcon,
82
- browser,
83
- os
84
- };
85
- };
86
- function getSessionStatus(session = {}) {
87
- if (session.isActive) {
88
- return session.isTrulyActive ? "active" : "idle";
89
- }
90
- if (session.terminationReason === "logout") return "loggedout";
91
- if (session.terminationReason === "idle") return "idle";
92
- if (session.terminationReason) return "terminated";
93
- return session.logoutTime ? "loggedout" : "terminated";
94
- }
95
- const DEFAULT_SESSION_FILTER = "all";
96
- const VALID_SESSION_FILTERS = /* @__PURE__ */ new Set(["all", "active", "idle", "loggedout", "terminated"]);
97
- function filterSessionsByStatus(sessions, status = DEFAULT_SESSION_FILTER) {
98
- if (!Array.isArray(sessions) || !VALID_SESSION_FILTERS.has(status)) return [];
99
- if (status === "all") return sessions;
100
- return sessions.filter((session) => getSessionStatus(session) === status);
101
- }
102
- function getManageableSessions(sessions) {
103
- if (!Array.isArray(sessions)) return [];
104
- return sessions.filter((session) => session?.isActive === true);
105
- }
106
- const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
107
- const pluginId = "magic-sessionmanager";
108
- const pluginPermissions = {
109
- access: [{ action: `plugin::${pluginId}.access`, subject: null }]
110
- };
111
- const SAFE_SCOPE = /^[A-Za-z0-9_.:-]{1,48}$/;
112
- function logSafeAdminError(scope, error) {
113
- const safeScope = typeof scope === "string" && SAFE_SCOPE.test(scope) ? scope : "admin";
114
- let status;
115
- try {
116
- status = error && typeof error === "object" ? error.response?.status : void 0;
117
- } catch {
118
- status = void 0;
119
- }
120
- const statusSuffix = Number.isInteger(status) && status >= 400 && status <= 599 ? ` (HTTP ${status})` : "";
121
- console.error(`[${safeScope}] Request failed${statusSuffix}`);
122
- }
123
- const paragraphRhythm = css`
124
- p {
125
- max-width: 72ch;
126
- margin-block: 0;
127
- line-height: 1.6;
128
- text-wrap: pretty;
129
- }
130
-
131
- p + p {
132
- margin-block-start: 12px;
133
- }
134
-
135
- li {
136
- max-width: 72ch;
137
- line-height: 1.6;
138
- text-wrap: pretty;
139
- }
140
-
141
- li + li {
142
- margin-block-start: 6px;
143
- }
144
- `;
145
- const ReadableText = styled(Typography)`
146
- display: block;
147
- width: 100%;
148
- min-width: 0;
149
- max-width: 72ch;
150
- margin: 0;
151
- line-height: 1.6;
152
- text-wrap: pretty;
153
-
154
- & + & {
155
- margin-block-start: 12px;
156
- }
157
- `;
158
- const ParagraphGroup = styled.div`
159
- display: block;
160
- width: 100%;
161
- min-width: 0;
162
- `;
163
- const InlineParagraphGroup = styled.span`
164
- display: block;
165
- width: 100%;
166
- min-width: 0;
167
- `;
168
- const ReadableParagraphs = ({ id, text, ...typographyProps }) => {
169
- const ParagraphContainer = typographyProps.tag === "span" ? InlineParagraphGroup : ParagraphGroup;
170
- const paragraphs = String(text ?? "").split(/\n\s*\n/).map((paragraph) => paragraph.trim()).filter(Boolean);
171
- return /* @__PURE__ */ jsx(ParagraphContainer, { id, "data-readable-paragraphs": "", children: paragraphs.map((paragraph, index2) => /* @__PURE__ */ jsx(
172
- ReadableText,
173
- {
174
- ...typographyProps,
175
- tag: typographyProps.tag || "p",
176
- children: paragraph
177
- },
178
- `${id || "readable-paragraph"}-${index2}`
179
- )) });
180
- };
181
- const PanelContainer = styled(Box)`
182
- width: 100%;
183
- min-width: 0;
184
-
185
- ${paragraphRhythm}
186
- `;
187
- const StatusCard = styled(Box)`
188
- padding: 20px;
189
- border-radius: 4px;
190
- border: 1px solid ${(p) => p.theme.colors.neutral150};
191
- background: ${(p) => p.theme.colors.neutral0};
192
- `;
193
- const BlockedWarning = styled(Box)`
194
- padding: 16px;
195
- border-radius: 4px;
196
- background: ${(p) => p.theme.colors.danger100};
197
- border: 1px solid ${(p) => p.theme.colors.danger200};
198
- `;
199
- const SessionCard = styled(Box)`
200
- padding: 16px;
201
- background: ${(p) => p.theme.colors.neutral0};
202
- border-radius: 4px;
203
- border: 1px solid ${(p) => p.theme.colors.neutral150};
204
- `;
205
- const EmptyState = styled(Box)`
206
- padding: 32px;
207
- background: ${(p) => p.theme.colors.neutral0};
208
- border-radius: 4px;
209
- border: 1px solid ${(p) => p.theme.colors.neutral150};
210
- text-align: center;
211
- `;
212
- const EmptyIcon = styled(Box)`
213
- width: 48px;
214
- height: 48px;
215
- margin: 0 auto 12px;
216
- display: flex;
217
- align-items: center;
218
- justify-content: center;
219
- background: ${(p) => p.theme.colors.neutral100};
220
- border-radius: 50%;
221
- color: ${(p) => p.theme.colors.neutral500};
222
- `;
223
- const IconWrapper = styled(Box)`
224
- width: 32px;
225
- height: 32px;
226
- display: flex;
227
- align-items: center;
228
- justify-content: center;
229
- background: ${(p) => p.theme.colors.neutral100};
230
- border-radius: 8px;
231
- flex-shrink: 0;
232
-
233
- svg {
234
- width: 16px;
235
- height: 16px;
236
- color: ${(p) => p.theme.colors.neutral600};
237
- }
238
- `;
239
- const MutedIcon = styled.div`
240
- display: flex;
241
- color: ${(p) => p.theme.colors.neutral500};
242
- `;
243
- const SessionInfoPanel = ({ documentId, model, document }) => {
244
- const { formatMessage } = useIntl();
245
- const { allowedActions: { canAccess }, isLoading: permissionsLoading } = useRBAC(pluginPermissions.access);
246
- const [sessions, setSessions] = useState([]);
247
- const [loading, setLoading] = useState(true);
248
- const [loadError, setLoadError] = useState(false);
249
- const [reloadKey, setReloadKey] = useState(0);
250
- const [isBlocked, setIsBlocked] = useState(false);
251
- const [actionLoading, setActionLoading] = useState(false);
252
- const { get, post: postRequest } = useFetchClient();
253
- const { toggleNotification } = useNotification();
254
- const t = (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
255
- const unavailableValue = t("common.unavailable", "Unavailable");
256
- const userId = document?.documentId || documentId;
257
- useEffect(() => {
258
- if (model !== "plugin::users-permissions.user" || !userId || permissionsLoading || !canAccess) {
259
- setLoading(false);
260
- return;
261
- }
262
- let cancelled = false;
263
- const fetchData = async () => {
264
- setLoading(true);
265
- setLoadError(false);
266
- try {
267
- const { data } = await get(`/magic-sessionmanager/user/${userId}/sessions`);
268
- if (cancelled) return;
269
- setSessions(getManageableSessions(data.data || []));
270
- setIsBlocked(document?.blocked || false);
271
- } catch (err) {
272
- if (!cancelled) setLoadError(true);
273
- logSafeAdminError("userSessions.load", err);
274
- } finally {
275
- if (!cancelled) setLoading(false);
276
- }
277
- };
278
- fetchData();
279
- return () => {
280
- cancelled = true;
281
- };
282
- }, [userId, model, document, get, reloadKey, canAccess, permissionsLoading]);
283
- const handleLogoutAll = async () => {
284
- if (!userId) return;
285
- if (!confirm(t("panel.confirm.terminateAll", "End all active sessions for this user?"))) return;
286
- setActionLoading(true);
287
- try {
288
- const response = await postRequest(`/magic-sessionmanager/user/${userId}/terminate-all`);
289
- if (response.data?.success) {
290
- toggleNotification({
291
- type: "success",
292
- message: t("notifications.success.terminatedAll", "All sessions terminated successfully")
293
- });
294
- setSessions([]);
295
- }
296
- } catch (error) {
297
- toggleNotification({
298
- type: "warning",
299
- message: t("notifications.error.terminateAll", "Failed to terminate sessions")
300
- });
301
- logSafeAdminError("userSessions.terminateAll", error);
302
- } finally {
303
- setActionLoading(false);
304
- }
305
- };
306
- const handleToggleBlock = async () => {
307
- if (!userId) return;
308
- const confirmation = isBlocked ? t("panel.confirm.unblockUser", "Unblock this user?") : t("panel.confirm.blockUser", "Block this user and end all active sessions?");
309
- if (!confirm(confirmation)) return;
310
- setActionLoading(true);
311
- try {
312
- const response = await postRequest(`/magic-sessionmanager/user/${userId}/toggle-block`);
313
- if (response.data?.success) {
314
- const newBlockedStatus = response.data.blocked;
315
- setIsBlocked(newBlockedStatus);
316
- toggleNotification({
317
- type: "success",
318
- message: newBlockedStatus ? t("notifications.success.blocked", "User blocked successfully") : t("notifications.success.unblocked", "User unblocked successfully")
319
- });
320
- if (newBlockedStatus) {
321
- setSessions([]);
322
- }
323
- }
324
- } catch (error) {
325
- toggleNotification({
326
- type: "warning",
327
- message: t("notifications.error.block", "Failed to update user status")
328
- });
329
- logSafeAdminError("userSessions.toggleBlock", error);
330
- } finally {
331
- setActionLoading(false);
332
- }
333
- };
334
- const getDeviceIcon = (deviceType) => {
335
- if (deviceType === "Mobile" || deviceType === "Tablet") return Phone;
336
- if (deviceType === "Desktop" || deviceType === "Laptop") return Monitor;
337
- if (deviceType === "API Client") return Server;
338
- return Information;
339
- };
340
- if (model !== "plugin::users-permissions.user") {
341
- return null;
342
- }
343
- if (permissionsLoading || !canAccess) {
344
- return null;
345
- }
346
- if (!userId) {
347
- return {
348
- title: t("panel.title", "Session Info"),
349
- content: /* @__PURE__ */ jsx(PanelContainer, { children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t("panel.user.saveBeforeManagingSessions", "Save this user before managing sessions.") }) }) })
350
- };
351
- }
352
- if (loading) {
353
- return {
354
- title: t("panel.title", "Session Info"),
355
- content: /* @__PURE__ */ jsx(Box, { padding: 4, background: "neutral0", children: /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t("panel.loading", "Loading...") }) })
356
- };
357
- }
358
- if (loadError) {
359
- return {
360
- title: t("panel.title", "Session Info"),
361
- content: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsx(
362
- Alert,
363
- {
364
- variant: "danger",
365
- title: t("panel.error.title", "Sessions could not be loaded"),
366
- closeLabel: t("common.close", "Close"),
367
- action: /* @__PURE__ */ jsx(Button, { size: "S", variant: "secondary", onClick: () => setReloadKey((key) => key + 1), children: t("common.retry", "Retry") }),
368
- children: /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral700", tag: "span", children: t("panel.error.description", "Try again. If the problem continues, check permissions for this user.") })
369
- }
370
- ) })
371
- };
372
- }
373
- const onlineCount = sessions.filter((session) => getSessionStatus(session) === "active").length;
374
- const isOnline = onlineCount > 0;
375
- return {
376
- title: t("panel.title", "Session Info"),
377
- content: /* @__PURE__ */ jsx(PanelContainer, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, alignItems: "stretch", children: [
378
- /* @__PURE__ */ jsx(StatusCard, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, alignItems: "center", children: [
379
- /* @__PURE__ */ jsx(Badge, { variant: isOnline ? "success" : "neutral", size: "M", children: isOnline ? t("panel.status.active", "Online") : t("panel.status.offline", "Offline") }),
380
- /* @__PURE__ */ jsx(
381
- Typography,
382
- {
383
- variant: "omega",
384
- fontWeight: "semiBold",
385
- textColor: isOnline ? "success700" : "neutral700",
386
- children: t(
387
- "panel.sessions.currentCount",
388
- "{count, plural, one {# current session} other {# current sessions}}",
389
- { count: sessions.length }
390
- )
391
- }
392
- )
393
- ] }) }),
394
- isBlocked && /* @__PURE__ */ jsxs(BlockedWarning, { children: [
395
- /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "danger700", children: t("panel.blocked.title", "User is blocked") }),
396
- /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "danger600", tag: "p", children: t("panel.blocked.description", "Authentication disabled") })
397
- ] }),
398
- sessions.length > 0 ? /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, alignItems: "stretch", children: [
399
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "semiBold", textColor: "neutral600", children: t("panel.sessions.title", "Current Sessions") }),
400
- sessions.slice(0, 5).map((session) => {
401
- const userAgent = typeof session.userAgent === "string" ? session.userAgent.trim() : "";
402
- const hasUserAgent = Boolean(userAgent && userAgent.toLowerCase() !== "unknown");
403
- const parsedDevice = hasUserAgent ? parseUserAgent(userAgent) : null;
404
- const nativeDeviceType = typeof session.deviceType === "string" && session.deviceType.trim().toLowerCase() !== "unknown" ? session.deviceType.trim() : "";
405
- const nativeDeviceName = typeof session.deviceName === "string" && session.deviceName.trim().toLowerCase() !== "unknown" ? session.deviceName.trim() : "";
406
- const availableValue = (value) => typeof value === "string" && value.trim() && value.trim().toLowerCase() !== "unknown" ? value.trim() : "";
407
- const deviceInfo = {
408
- device: nativeDeviceName || nativeDeviceType || availableValue(parsedDevice?.device) || unavailableValue,
409
- browser: availableValue(session.browserName) || availableValue(parsedDevice?.browser) || unavailableValue,
410
- os: availableValue(session.osName) || availableValue(parsedDevice?.os) || unavailableValue
411
- };
412
- const DeviceIcon = getDeviceIcon(nativeDeviceType || parsedDevice?.device);
413
- const sessionStatus = getSessionStatus(session);
414
- const isSessionOnline = sessionStatus === "active";
415
- return /* @__PURE__ */ jsx(SessionCard, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, alignItems: "flex-start", children: [
416
- /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
417
- /* @__PURE__ */ jsx(IconWrapper, { children: /* @__PURE__ */ jsx(DeviceIcon, {}) }),
418
- /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "neutral800", children: deviceInfo.device })
419
- ] }),
420
- /* @__PURE__ */ jsx(Badge, { variant: isSessionOnline ? "success" : "warning", size: "S", children: isSessionOnline ? t("panel.sessions.active", "Active") : t("panel.sessions.idle", "Idle") }),
421
- /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", children: [
422
- deviceInfo.browser,
423
- " on ",
424
- deviceInfo.os
425
- ] }),
426
- /* @__PURE__ */ jsx(Divider, {}),
427
- /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
428
- /* @__PURE__ */ jsx(MutedIcon, { children: /* @__PURE__ */ jsx(Server, { width: "14px", height: "14px" }) }),
429
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: session.ipAddress || unavailableValue })
430
- ] }),
431
- /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
432
- /* @__PURE__ */ jsx(MutedIcon, { children: /* @__PURE__ */ jsx(Clock, { width: "14px", height: "14px" }) }),
433
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: new Date(session.loginTime).toLocaleString("en-US", {
434
- month: "short",
435
- day: "numeric",
436
- hour: "2-digit",
437
- minute: "2-digit"
438
- }) })
439
- ] }),
440
- session.minutesSinceActive !== void 0 && session.minutesSinceActive < 60 && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "success600", fontWeight: "semiBold", children: session.minutesSinceActive === 0 ? t("panel.sessions.activeNow", "Active now") : t("panel.sessions.activeAgo", "Active {minutes} min ago", { minutes: session.minutesSinceActive }) })
441
- ] }) }, session.id);
442
- }),
443
- sessions.length > 5 && /* @__PURE__ */ jsx(Box, { padding: 3, background: "primary100", hasRadius: true, style: { textAlign: "center" }, children: /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "primary600", fontWeight: "semiBold", children: [
444
- "+",
445
- sessions.length - 5,
446
- " ",
447
- t("panel.sessions.more", "more session"),
448
- sessions.length - 5 !== 1 ? "s" : ""
449
- ] }) })
450
- ] }) : /* @__PURE__ */ jsxs(EmptyState, { children: [
451
- /* @__PURE__ */ jsx(EmptyIcon, { children: /* @__PURE__ */ jsx(User, { width: "24px", height: "24px" }) }),
452
- /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral700", style: { display: "block" }, children: t("panel.empty.title", "No current sessions") }),
453
- /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral500", tag: "p", children: t("panel.empty.description", "User has not logged in yet") })
454
- ] }),
455
- /* @__PURE__ */ jsx(Divider, {}),
456
- /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, alignItems: "stretch", children: [
457
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "semiBold", textColor: "neutral600", children: t("panel.actions.title", "Actions") }),
458
- /* @__PURE__ */ jsx(
459
- Button,
460
- {
461
- fullWidth: true,
462
- variant: "danger-light",
463
- startIcon: /* @__PURE__ */ jsx(Cross, {}),
464
- onClick: handleLogoutAll,
465
- loading: actionLoading,
466
- disabled: actionLoading || sessions.length === 0,
467
- type: "button",
468
- children: t("panel.actions.terminateAll", "Terminate All Sessions")
469
- }
470
- ),
471
- /* @__PURE__ */ jsx(
472
- Button,
473
- {
474
- fullWidth: true,
475
- variant: isBlocked ? "secondary" : "danger-light",
476
- startIcon: isBlocked ? /* @__PURE__ */ jsx(Check, {}) : /* @__PURE__ */ jsx(Cross, {}),
477
- onClick: handleToggleBlock,
478
- loading: actionLoading,
479
- disabled: actionLoading,
480
- type: "button",
481
- children: isBlocked ? t("panel.actions.unblockUser", "Unblock User") : t("panel.actions.blockUser", "Block User")
482
- }
483
- )
484
- ] })
485
- ] }) })
486
- };
487
- };
488
- const prefixPluginTranslations = (data, pluginId2) => {
489
- const prefixed = {};
490
- Object.keys(data).forEach((key) => {
491
- prefixed[`${pluginId2}.${key}`] = data[key];
492
- });
493
- return prefixed;
494
- };
495
- const name = pluginPkg.strapi.name;
496
- const index = {
497
- register(app) {
498
- const pluginPermissions2 = [{ action: `plugin::${pluginId$1}.access`, subject: null }];
499
- app.addMenuLink({
500
- to: `plugins/${pluginId$1}`,
501
- icon: PluginIcon,
502
- intlLabel: {
503
- id: `${pluginId$1}.plugin.name`,
504
- defaultMessage: pluginPkg.strapi.displayName
505
- },
506
- Component: () => import("./App-hSh7guii.mjs"),
507
- permissions: pluginPermissions2
508
- });
509
- app.addSettingsLink(
510
- {
511
- id: pluginId$1,
512
- intlLabel: { id: `${pluginId$1}.settings.section`, defaultMessage: "Session Manager" }
513
- },
514
- [
515
- {
516
- intlLabel: {
517
- id: `${pluginId$1}.settings.general`,
518
- defaultMessage: "General"
519
- },
520
- id: "general",
521
- to: `${pluginId$1}/general`,
522
- Component: () => import("./Settings-C4RsJosh.mjs"),
523
- permissions: pluginPermissions2
524
- },
525
- {
526
- intlLabel: {
527
- id: `${pluginId$1}.settings.analytics`,
528
- defaultMessage: "Analytics"
529
- },
530
- id: "analytics",
531
- to: `${pluginId$1}/analytics`,
532
- Component: () => import("./Analytics-THqDbNX0.mjs"),
533
- permissions: pluginPermissions2
534
- },
535
- {
536
- intlLabel: {
537
- id: `${pluginId$1}.settings.license`,
538
- defaultMessage: "Activation"
539
- },
540
- id: "license",
541
- to: `${pluginId$1}/license`,
542
- Component: () => import("./License-BXBVwUVu.mjs"),
543
- permissions: pluginPermissions2
544
- }
545
- ]
546
- );
547
- app.registerPlugin({
548
- id: pluginId$1,
549
- initializer: Initializer,
550
- isReady: true,
551
- name
552
- });
553
- if ("widgets" in app) {
554
- app.widgets.register({
555
- icon: PluginIcon,
556
- title: {
557
- id: `${pluginId$1}.widget.online-users.title`,
558
- defaultMessage: "Online Users"
559
- },
560
- component: async () => {
561
- const component = await import("./OnlineUsersWidget-BnWFj9IM.mjs");
562
- return component.default;
563
- },
564
- id: "online-users-widget",
565
- pluginId: pluginId$1,
566
- permissions: pluginPermissions2
567
- });
568
- console.log(`[${pluginId$1}] [SUCCESS] Online Users Widget registered`);
569
- }
570
- },
571
- bootstrap(app) {
572
- console.log(`[${pluginId$1}] Bootstrapping plugin...`);
573
- try {
574
- const contentManagerPlugin = app.getPlugin("content-manager");
575
- if (contentManagerPlugin && contentManagerPlugin.apis) {
576
- console.log(`[${pluginId$1}] Injecting SessionInfoPanel into edit view sidebar...`);
577
- contentManagerPlugin.apis.addEditViewSidePanel([SessionInfoPanel]);
578
- console.log(`[${pluginId$1}] [SUCCESS] SessionInfoPanel injected successfully`);
579
- } else {
580
- console.warn(`[${pluginId$1}] Content Manager plugin or APIs not available`);
581
- }
582
- } catch (error) {
583
- logSafeAdminError("plugin.bootstrap", error);
584
- }
585
- },
586
- async registerTrads({ locales }) {
587
- const importedTrads = {
588
- en: () => import("./en-D6QEGeRh.mjs"),
589
- de: () => import("./de-AwIFTd9i.mjs"),
590
- es: () => import("./es-CnFfVdKw.mjs"),
591
- fr: () => import("./fr-DefoR7uH.mjs"),
592
- pt: () => import("./pt-TODwvNQA.mjs")
593
- };
594
- const translatedLanguages = Object.keys(importedTrads).filter(
595
- (lang) => locales.includes(lang)
596
- );
597
- const translations = await Promise.all(
598
- translatedLanguages.map(
599
- (language) => importedTrads[language]().then(({ default: data }) => ({
600
- data: prefixPluginTranslations(data, pluginId$1),
601
- locale: language
602
- })).catch(() => ({
603
- data: {},
604
- locale: language
605
- }))
606
- )
607
- );
608
- return Promise.resolve(translations);
609
- }
610
- };
611
- export {
612
- DEFAULT_SESSION_FILTER as D,
613
- ReadableText as R,
614
- getTranslation as a,
615
- parseUserAgent as b,
616
- pluginPermissions as c,
617
- ReadableParagraphs as d,
618
- paragraphRhythm as e,
619
- filterSessionsByStatus as f,
620
- getSessionStatus as g,
621
- index as i,
622
- logSafeAdminError as l,
623
- pluginId$1 as p
624
- };