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.
Files changed (52) hide show
  1. package/CHANGELOG.md +27 -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 +2812 -6159
  34. package/dist/server/index.mjs +2812 -6159
  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,551 +0,0 @@
1
- import { useRef, useEffect, useState } from "react";
2
- import { useFetchClient, useNotification } from "@strapi/strapi/admin";
3
- import { jsx, jsxs } from "react/jsx-runtime";
4
- import { useIntl } from "react-intl";
5
- import styled from "styled-components";
6
- import { Box, Typography, Flex, Badge, Divider } from "@strapi/design-system";
7
- import { Server, Clock, User, Cross, Check, Phone, Monitor } from "@strapi/icons";
8
- const strapi = { "name": "magic-sessionmanager", "displayName": "Magic Sessionmanager" };
9
- const pluginPkg = {
10
- strapi
11
- };
12
- const pluginId = "magic-sessionmanager";
13
- const PLUGIN_ID = pluginId;
14
- const Initializer = ({ setPlugin }) => {
15
- const ref = useRef(setPlugin);
16
- const { get } = useFetchClient();
17
- useEffect(() => {
18
- if (ref.current) {
19
- ref.current(pluginId);
20
- }
21
- }, []);
22
- useEffect(() => {
23
- const HEARTBEAT_INTERVAL = 4 * 60 * 1e3;
24
- const heartbeat = async () => {
25
- try {
26
- await get(`/${pluginId}/license/status`);
27
- } catch (error) {
28
- }
29
- };
30
- const initialTimeout = setTimeout(heartbeat, 60 * 1e3);
31
- const interval = setInterval(heartbeat, HEARTBEAT_INTERVAL);
32
- return () => {
33
- clearTimeout(initialTimeout);
34
- clearInterval(interval);
35
- };
36
- }, [get]);
37
- return null;
38
- };
39
- 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" }) });
40
- const parseUserAgent = (userAgent) => {
41
- if (!userAgent) {
42
- return {
43
- device: "Unknown",
44
- deviceIcon: "question",
45
- browser: "Unknown",
46
- os: "Unknown"
47
- };
48
- }
49
- const ua = userAgent.toLowerCase();
50
- let device = "Desktop";
51
- let deviceIcon = "desktop";
52
- if (/(tablet|ipad|playbook|silk)|(android(?!.*mobi))/i.test(userAgent)) {
53
- device = "Tablet";
54
- deviceIcon = "tablet";
55
- } else if (/Mobile|Android|iP(hone|od)|IEMobile|BlackBerry|Kindle|Silk-Accelerated|(hpw|web)OS|Opera M(obi|ini)/.test(userAgent)) {
56
- device = "Mobile";
57
- deviceIcon = "mobile";
58
- }
59
- let browser = "Unknown";
60
- if (ua.includes("edg/")) {
61
- browser = "Edge";
62
- } else if (ua.includes("chrome/") && !ua.includes("edg/")) {
63
- browser = "Chrome";
64
- } else if (ua.includes("firefox/")) {
65
- browser = "Firefox";
66
- } else if (ua.includes("safari/") && !ua.includes("chrome/")) {
67
- browser = "Safari";
68
- } else if (ua.includes("opera/") || ua.includes("opr/")) {
69
- browser = "Opera";
70
- } else if (ua.includes("curl/")) {
71
- browser = "cURL";
72
- deviceIcon = "gear";
73
- device = "API Client";
74
- } else if (ua.includes("postman")) {
75
- browser = "Postman";
76
- deviceIcon = "code";
77
- device = "API Client";
78
- } else if (ua.includes("insomnia")) {
79
- browser = "Insomnia";
80
- deviceIcon = "code";
81
- device = "API Client";
82
- }
83
- let os = "Unknown";
84
- if (ua.includes("android")) {
85
- os = "Android";
86
- } else if (ua.includes("iphone") || ua.includes("ipad")) {
87
- os = "iOS";
88
- } else if (ua.includes("windows")) {
89
- os = "Windows";
90
- } else if (ua.includes("mac os x") || ua.includes("macintosh")) {
91
- os = "macOS";
92
- } else if (ua.includes("linux")) {
93
- os = "Linux";
94
- }
95
- return {
96
- device,
97
- deviceIcon,
98
- browser,
99
- os
100
- };
101
- };
102
- const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
103
- const PanelContainer = styled(Box)`
104
- width: 100%;
105
- `;
106
- const StatusCard = styled(Box)`
107
- padding: 20px;
108
- border-radius: 12px;
109
- border: 1px solid ${(props) => props.$isOnline ? "rgba(34, 197, 94, 0.3)" : "rgba(128, 128, 128, 0.2)"};
110
- background: ${(props) => props.$isOnline ? "linear-gradient(135deg, rgba(22, 163, 74, 0.06) 0%, rgba(22, 163, 74, 0.12) 100%)" : "linear-gradient(135deg, rgba(128, 128, 128, 0.04) 0%, rgba(128, 128, 128, 0.08) 100%)"};
111
- transition: all 0.2s ease;
112
- `;
113
- const BlockedWarning = styled(Box)`
114
- padding: 16px;
115
- border-radius: 10px;
116
- background: linear-gradient(135deg, rgba(220, 38, 38, 0.06) 0%, rgba(220, 38, 38, 0.12) 100%);
117
- border: 1px solid rgba(239, 68, 68, 0.4);
118
- `;
119
- const SessionCard = styled(Box)`
120
- padding: 16px;
121
- background: ${(p) => p.theme.colors.neutral0};
122
- border-radius: 10px;
123
- border: 1px solid rgba(128, 128, 128, 0.2);
124
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
125
- transition: all 0.2s ease;
126
-
127
- &:hover {
128
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
129
- border-color: var(--colors-primary600, #0EA5E9);
130
- }
131
- `;
132
- const EmptyState = styled(Box)`
133
- padding: 32px;
134
- background: var(--colors-neutral100);
135
- border-radius: 12px;
136
- border: 2px dashed rgba(128, 128, 128, 0.2);
137
- text-align: center;
138
- `;
139
- const EmptyIcon = styled(Box)`
140
- width: 48px;
141
- height: 48px;
142
- margin: 0 auto 12px;
143
- display: flex;
144
- align-items: center;
145
- justify-content: center;
146
- background: rgba(128, 128, 128, 0.2);
147
- border-radius: 50%;
148
- color: var(--colors-neutral500);
149
- `;
150
- const SectionLabel = styled(Typography)`
151
- text-transform: uppercase;
152
- letter-spacing: 0.5px;
153
- font-size: 11px !important;
154
- font-weight: 700 !important;
155
- color: var(--colors-neutral600);
156
- margin-bottom: 12px;
157
- display: block;
158
- `;
159
- const ActionButton = styled.button`
160
- width: 100%;
161
- padding: 12px 16px;
162
- border-radius: 8px;
163
- font-size: 14px;
164
- font-weight: 600;
165
- cursor: pointer;
166
- display: flex;
167
- align-items: center;
168
- justify-content: center;
169
- gap: 8px;
170
- transition: all 0.2s ease;
171
-
172
- ${(props) => props.$variant === "danger" && `
173
- background: ${(p) => p.theme.colors.neutral0};
174
- color: var(--colors-danger600, #DC2626);
175
- border: 2px solid var(--colors-danger600, #DC2626);
176
-
177
- &:hover:not(:disabled) {
178
- background: var(--colors-danger600, #DC2626);
179
- color: white;
180
- }
181
- `}
182
-
183
- ${(props) => props.$variant === "success" && `
184
- background: ${(p) => p.theme.colors.neutral0};
185
- color: var(--colors-success600, #16A34A);
186
- border: 2px solid var(--colors-success600, #16A34A);
187
-
188
- &:hover:not(:disabled) {
189
- background: var(--colors-success600, #16A34A);
190
- color: white;
191
- }
192
- `}
193
-
194
- &:disabled {
195
- opacity: 0.5;
196
- cursor: not-allowed;
197
- }
198
-
199
- svg {
200
- width: 16px;
201
- height: 16px;
202
- }
203
- `;
204
- const IconWrapper = styled(Box)`
205
- width: 32px;
206
- height: 32px;
207
- display: flex;
208
- align-items: center;
209
- justify-content: center;
210
- background: var(--colors-neutral100);
211
- border-radius: 8px;
212
- flex-shrink: 0;
213
-
214
- svg {
215
- width: 16px;
216
- height: 16px;
217
- color: var(--colors-neutral600);
218
- }
219
- `;
220
- const SessionInfoPanel = ({ documentId, model, document }) => {
221
- const { formatMessage } = useIntl();
222
- const [sessions, setSessions] = useState([]);
223
- const [loading, setLoading] = useState(true);
224
- const [isBlocked, setIsBlocked] = useState(false);
225
- const [actionLoading, setActionLoading] = useState(false);
226
- const { get, post: postRequest } = useFetchClient();
227
- const { toggleNotification } = useNotification();
228
- const t = (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
229
- const userId = document?.documentId || documentId;
230
- useEffect(() => {
231
- if (model !== "plugin::users-permissions.user" || !userId) {
232
- setLoading(false);
233
- return;
234
- }
235
- const fetchData = async () => {
236
- try {
237
- const { data } = await get(`/magic-sessionmanager/user/${userId}/sessions`);
238
- const activeSessions = (data.data || []).filter((s) => s.isTrulyActive);
239
- setSessions(activeSessions);
240
- setIsBlocked(document?.blocked || false);
241
- } catch (err) {
242
- console.error("[SessionInfoPanel] Error:", err);
243
- } finally {
244
- setLoading(false);
245
- }
246
- };
247
- fetchData();
248
- }, [userId, model, document, get]);
249
- const handleLogoutAll = async () => {
250
- if (!userId) return;
251
- setActionLoading(true);
252
- try {
253
- const response = await postRequest(`/magic-sessionmanager/user/${userId}/terminate-all`);
254
- if (response.data?.success) {
255
- toggleNotification({
256
- type: "success",
257
- message: t("notifications.success.terminatedAll", "All sessions terminated successfully")
258
- });
259
- setSessions([]);
260
- }
261
- } catch (error) {
262
- toggleNotification({
263
- type: "warning",
264
- message: t("notifications.error.terminateAll", "Failed to terminate sessions")
265
- });
266
- console.error("[SessionInfoPanel] Logout all error:", error);
267
- } finally {
268
- setActionLoading(false);
269
- }
270
- };
271
- const handleToggleBlock = async () => {
272
- if (!userId) return;
273
- setActionLoading(true);
274
- try {
275
- const response = await postRequest(`/magic-sessionmanager/user/${userId}/toggle-block`);
276
- if (response.data?.success) {
277
- const newBlockedStatus = response.data.blocked;
278
- setIsBlocked(newBlockedStatus);
279
- toggleNotification({
280
- type: "success",
281
- message: newBlockedStatus ? t("notifications.success.blocked", "User blocked successfully") : t("notifications.success.unblocked", "User unblocked successfully")
282
- });
283
- if (newBlockedStatus) {
284
- setSessions([]);
285
- }
286
- }
287
- } catch (error) {
288
- toggleNotification({
289
- type: "warning",
290
- message: t("notifications.error.block", "Failed to update user status")
291
- });
292
- console.error("[SessionInfoPanel] Toggle block error:", error);
293
- } finally {
294
- setActionLoading(false);
295
- }
296
- };
297
- const getDeviceIcon = (deviceType) => {
298
- if (deviceType === "Mobile" || deviceType === "Tablet") return Phone;
299
- if (deviceType === "Desktop" || deviceType === "Laptop") return Monitor;
300
- return Server;
301
- };
302
- if (model !== "plugin::users-permissions.user") {
303
- return null;
304
- }
305
- if (loading) {
306
- return {
307
- title: t("panel.title", "Session Info"),
308
- content: /* @__PURE__ */ jsx(Box, { padding: 4, background: "neutral0", children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t("panel.loading", "Loading...") }) })
309
- };
310
- }
311
- const isOnline = sessions.length > 0;
312
- return {
313
- title: t("panel.title", "Session Info"),
314
- content: /* @__PURE__ */ jsx(PanelContainer, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, alignItems: "stretch", children: [
315
- /* @__PURE__ */ jsx(StatusCard, { $isOnline: isOnline, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, alignItems: "center", children: [
316
- /* @__PURE__ */ jsx(
317
- Badge,
318
- {
319
- backgroundColor: isOnline ? "success600" : "neutral600",
320
- textColor: "neutral0",
321
- size: "M",
322
- style: { fontSize: "12px", padding: "6px 14px", fontWeight: "700" },
323
- children: isOnline ? t("panel.status.active", "ONLINE") : t("panel.status.offline", "OFFLINE")
324
- }
325
- ),
326
- /* @__PURE__ */ jsxs(
327
- Typography,
328
- {
329
- variant: "omega",
330
- fontWeight: "semiBold",
331
- textColor: isOnline ? "success700" : "neutral700",
332
- children: [
333
- sessions.length,
334
- " ",
335
- t("panel.sessions.label", "active session"),
336
- sessions.length !== 1 ? "s" : ""
337
- ]
338
- }
339
- )
340
- ] }) }),
341
- isBlocked && /* @__PURE__ */ jsxs(BlockedWarning, { children: [
342
- /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "danger700", children: t("panel.blocked.title", "User is blocked") }),
343
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger600", style: { marginTop: "4px" }, children: t("panel.blocked.description", "Authentication disabled") })
344
- ] }),
345
- sessions.length > 0 ? /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, alignItems: "stretch", children: [
346
- /* @__PURE__ */ jsx(SectionLabel, { children: t("panel.sessions.title", "Active Sessions") }),
347
- sessions.slice(0, 5).map((session) => {
348
- const deviceInfo = parseUserAgent(session.userAgent);
349
- const DeviceIcon = getDeviceIcon(deviceInfo.device);
350
- return /* @__PURE__ */ jsx(SessionCard, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, alignItems: "flex-start", children: [
351
- /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
352
- /* @__PURE__ */ jsx(IconWrapper, { children: /* @__PURE__ */ jsx(DeviceIcon, {}) }),
353
- /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "neutral800", children: deviceInfo.device })
354
- ] }),
355
- /* @__PURE__ */ jsx(Badge, { backgroundColor: "success600", textColor: "neutral0", size: "S", children: t("panel.sessions.active", "Active") }),
356
- /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", children: [
357
- deviceInfo.browser,
358
- " on ",
359
- deviceInfo.os
360
- ] }),
361
- /* @__PURE__ */ jsx(Divider, {}),
362
- /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
363
- /* @__PURE__ */ jsx(Server, { width: "14px", height: "14px", style: { color: "var(--colors-neutral500)" } }),
364
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: session.ipAddress })
365
- ] }),
366
- /* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
367
- /* @__PURE__ */ jsx(Clock, { width: "14px", height: "14px", style: { color: "var(--colors-neutral500)" } }),
368
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: new Date(session.loginTime).toLocaleString("en-US", {
369
- month: "short",
370
- day: "numeric",
371
- hour: "2-digit",
372
- minute: "2-digit"
373
- }) })
374
- ] }),
375
- 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 }) })
376
- ] }) }, session.id);
377
- }),
378
- 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: [
379
- "+",
380
- sessions.length - 5,
381
- " ",
382
- t("panel.sessions.more", "more session"),
383
- sessions.length - 5 !== 1 ? "s" : ""
384
- ] }) })
385
- ] }) : /* @__PURE__ */ jsxs(EmptyState, { children: [
386
- /* @__PURE__ */ jsx(EmptyIcon, { children: /* @__PURE__ */ jsx(User, { width: "24px", height: "24px" }) }),
387
- /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", textColor: "neutral700", style: { display: "block" }, children: t("panel.empty.title", "No active sessions") }),
388
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", style: { display: "block", marginTop: "4px" }, children: t("panel.empty.description", "User has not logged in yet") })
389
- ] }),
390
- /* @__PURE__ */ jsx(Divider, {}),
391
- /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, alignItems: "stretch", children: [
392
- /* @__PURE__ */ jsx(SectionLabel, { children: t("panel.actions.title", "Actions") }),
393
- /* @__PURE__ */ jsxs(
394
- ActionButton,
395
- {
396
- $variant: "danger",
397
- onClick: handleLogoutAll,
398
- disabled: actionLoading || sessions.length === 0,
399
- type: "button",
400
- children: [
401
- /* @__PURE__ */ jsx(Cross, {}),
402
- t("panel.actions.terminateAll", "Terminate All Sessions")
403
- ]
404
- }
405
- ),
406
- /* @__PURE__ */ jsxs(
407
- ActionButton,
408
- {
409
- $variant: isBlocked ? "success" : "danger",
410
- onClick: handleToggleBlock,
411
- disabled: actionLoading,
412
- type: "button",
413
- children: [
414
- isBlocked ? /* @__PURE__ */ jsx(Check, {}) : /* @__PURE__ */ jsx(Cross, {}),
415
- isBlocked ? t("panel.actions.unblockUser", "Unblock User") : t("panel.actions.blockUser", "Block User")
416
- ]
417
- }
418
- )
419
- ] })
420
- ] }) })
421
- };
422
- };
423
- const prefixPluginTranslations = (data, pluginId2) => {
424
- const prefixed = {};
425
- Object.keys(data).forEach((key) => {
426
- prefixed[`${pluginId2}.${key}`] = data[key];
427
- });
428
- return prefixed;
429
- };
430
- const name = pluginPkg.strapi.name;
431
- const index = {
432
- register(app) {
433
- const pluginPermissions = [{ action: `plugin::${pluginId}.access`, subject: null }];
434
- app.addMenuLink({
435
- to: `plugins/${pluginId}`,
436
- icon: PluginIcon,
437
- intlLabel: {
438
- id: `${pluginId}.plugin.name`,
439
- defaultMessage: pluginPkg.strapi.displayName
440
- },
441
- Component: () => import("./App-qxKnK7G2.mjs"),
442
- permissions: pluginPermissions
443
- });
444
- app.createSettingSection(
445
- {
446
- intlLabel: { id: `${pluginId}.settings.section`, defaultMessage: "Sessions" },
447
- id: pluginId,
448
- to: pluginId
449
- },
450
- [
451
- {
452
- intlLabel: {
453
- id: `${pluginId}.settings.general`,
454
- defaultMessage: "General"
455
- },
456
- id: "general",
457
- to: `${pluginId}/general`,
458
- Component: () => import("./Settings-U3V4eGMo.mjs"),
459
- permissions: pluginPermissions
460
- },
461
- {
462
- intlLabel: {
463
- id: `${pluginId}.settings.analytics`,
464
- defaultMessage: "Analytics"
465
- },
466
- id: "analytics",
467
- to: `${pluginId}/analytics`,
468
- Component: () => import("./Analytics-CsrpxJwQ.mjs"),
469
- permissions: pluginPermissions
470
- },
471
- {
472
- intlLabel: {
473
- id: `${pluginId}.settings.license`,
474
- defaultMessage: "Activation"
475
- },
476
- id: "license",
477
- to: `${pluginId}/license`,
478
- Component: () => import("./License-ClW7sZLR.mjs"),
479
- permissions: pluginPermissions
480
- }
481
- ]
482
- );
483
- app.registerPlugin({
484
- id: pluginId,
485
- initializer: Initializer,
486
- isReady: true,
487
- name
488
- });
489
- if ("widgets" in app) {
490
- app.widgets.register({
491
- icon: PluginIcon,
492
- title: {
493
- id: `${pluginId}.widget.online-users.title`,
494
- defaultMessage: "Online Users"
495
- },
496
- component: async () => {
497
- const component = await import("./OnlineUsersWidget-mR_OMiwi.mjs");
498
- return component.default;
499
- },
500
- id: "online-users-widget",
501
- pluginId
502
- });
503
- console.log(`[${pluginId}] [SUCCESS] Online Users Widget registered`);
504
- }
505
- },
506
- bootstrap(app) {
507
- console.log(`[${pluginId}] Bootstrapping plugin...`);
508
- try {
509
- const contentManagerPlugin = app.getPlugin("content-manager");
510
- if (contentManagerPlugin && contentManagerPlugin.apis) {
511
- console.log(`[${pluginId}] Injecting SessionInfoPanel into edit view sidebar...`);
512
- contentManagerPlugin.apis.addEditViewSidePanel([SessionInfoPanel]);
513
- console.log(`[${pluginId}] [SUCCESS] SessionInfoPanel injected successfully`);
514
- } else {
515
- console.warn(`[${pluginId}] Content Manager plugin or APIs not available`);
516
- }
517
- } catch (error) {
518
- console.error(`[${pluginId}] Error injecting SessionInfoPanel:`, error);
519
- }
520
- },
521
- async registerTrads({ locales }) {
522
- const importedTrads = {
523
- en: () => import("./en-kQWtdEai.mjs"),
524
- de: () => import("./de-JBE-iylO.mjs"),
525
- es: () => import("./es-DOQvBxih.mjs"),
526
- fr: () => import("./fr-CmfCpepX.mjs"),
527
- pt: () => import("./pt-BSzZdyAH.mjs")
528
- };
529
- const translatedLanguages = Object.keys(importedTrads).filter(
530
- (lang) => locales.includes(lang)
531
- );
532
- const translations = await Promise.all(
533
- translatedLanguages.map(
534
- (language) => importedTrads[language]().then(({ default: data }) => ({
535
- data: prefixPluginTranslations(data, pluginId),
536
- locale: language
537
- })).catch(() => ({
538
- data: {},
539
- locale: language
540
- }))
541
- )
542
- );
543
- return Promise.resolve(translations);
544
- }
545
- };
546
- export {
547
- pluginId as a,
548
- getTranslation as g,
549
- index as i,
550
- parseUserAgent as p
551
- };
@@ -1,11 +0,0 @@
1
- "use strict";
2
- function getSessionStatus(session = {}) {
3
- if (session.isActive) {
4
- return session.isTrulyActive ? "active" : "idle";
5
- }
6
- if (session.terminationReason === "logout") return "loggedout";
7
- if (session.terminationReason === "idle") return "idle";
8
- if (session.terminationReason) return "terminated";
9
- return session.logoutTime ? "loggedout" : "terminated";
10
- }
11
- exports.getSessionStatus = getSessionStatus;
@@ -1,12 +0,0 @@
1
- function getSessionStatus(session = {}) {
2
- if (session.isActive) {
3
- return session.isTrulyActive ? "active" : "idle";
4
- }
5
- if (session.terminationReason === "logout") return "loggedout";
6
- if (session.terminationReason === "idle") return "idle";
7
- if (session.terminationReason) return "terminated";
8
- return session.logoutTime ? "loggedout" : "terminated";
9
- }
10
- export {
11
- getSessionStatus as g
12
- };