strapi-plugin-magic-sessionmanager 4.7.2 → 4.9.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 (71) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/README.md +380 -663
  3. package/dist/admin/Analytics-B6d-39Qh.js +420 -0
  4. package/dist/admin/Analytics-DxOWXHn8.mjs +418 -0
  5. package/dist/admin/App-ZsSGj7n8.mjs +1894 -0
  6. package/dist/admin/App-mRFV50K6.js +1896 -0
  7. package/dist/admin/License-BE6UQ_V3.mjs +443 -0
  8. package/dist/admin/License-DXt2oi6u.js +443 -0
  9. package/dist/admin/OnlineUsersWidget-CFvM3Vbp.js +273 -0
  10. package/dist/admin/OnlineUsersWidget-_tJ6aeWl.mjs +254 -0
  11. package/dist/admin/SectionCard-BlWv8CRt.js +54 -0
  12. package/dist/admin/SectionCard-D51bv4Hi.mjs +55 -0
  13. package/dist/admin/Settings-BUc12TP5.js +3570 -0
  14. package/dist/admin/Settings-dtW7cjTX.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-C_SyRULc.mjs +1750 -0
  24. package/dist/admin/index-D4kEnXSp.js +1751 -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 +3555 -6350
  32. package/dist/server/index.mjs +3555 -6350
  33. package/package.json +30 -19
  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 +266 -36
  45. package/scripts/update-geoip-db.mjs +3 -0
  46. package/dist/admin/Analytics-CsrpxJwQ.mjs +0 -497
  47. package/dist/admin/Analytics-D03ZNNMR.js +0 -499
  48. package/dist/admin/App-B2VCS3cz.js +0 -1481
  49. package/dist/admin/App-qxKnK7G2.mjs +0 -1479
  50. package/dist/admin/License-ClW7sZLR.mjs +0 -318
  51. package/dist/admin/License-fixnQ7wF.js +0 -320
  52. package/dist/admin/OnlineUsersWidget-mR_OMiwi.mjs +0 -185
  53. package/dist/admin/OnlineUsersWidget-qb9utPBy.js +0 -185
  54. package/dist/admin/Settings-U3V4eGMo.mjs +0 -2038
  55. package/dist/admin/Settings-gv2BF54w.js +0 -2040
  56. package/dist/admin/StyledButtons-Cz8oYhmc.mjs +0 -418
  57. package/dist/admin/StyledButtons-DDuxnYz8.js +0 -419
  58. package/dist/admin/de-BnqGCokx.js +0 -316
  59. package/dist/admin/de-JBE-iylO.mjs +0 -316
  60. package/dist/admin/en-BRmVwd8-.js +0 -316
  61. package/dist/admin/en-kQWtdEai.mjs +0 -316
  62. package/dist/admin/es-CH691xcL.js +0 -301
  63. package/dist/admin/es-DOQvBxih.mjs +0 -301
  64. package/dist/admin/fr-CLExO0w_.js +0 -301
  65. package/dist/admin/fr-CmfCpepX.mjs +0 -301
  66. package/dist/admin/index-B_lFjUAg.mjs +0 -551
  67. package/dist/admin/index-Duc7cR_d.js +0 -552
  68. package/dist/admin/pt-BJ_F0yNi.js +0 -301
  69. package/dist/admin/pt-BSzZdyAH.mjs +0 -301
  70. package/dist/admin/sessionStatus-D_fWEzgj.js +0 -11
  71. package/dist/admin/sessionStatus-kwggjEMw.mjs +0 -12
@@ -1,2038 +0,0 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { useState, useEffect } from "react";
3
- import { useIntl } from "react-intl";
4
- import { Flex, Loader, Typography, Button, Box, Accordion, Grid, SingleSelect, SingleSelectOption, Divider, Alert, TextInput, Badge, Toggle, NumberInput, Checkbox, Tabs } from "@strapi/design-system";
5
- import { useFetchClient, useNotification } from "@strapi/strapi/admin";
6
- import { Check, Cog, Trash, Shield, Code, Duplicate, Clock, Mail } from "@strapi/icons";
7
- import styled, { css, keyframes } from "styled-components";
8
- import { a as pluginId, g as getTranslation } from "./index-B_lFjUAg.mjs";
9
- import { D as DangerButton, S as ShowHideButton, G as GradientButton, C as CopyButton, T as TertiaryButton, c as SecondaryButton } from "./StyledButtons-Cz8oYhmc.mjs";
10
- const COUNTRIES = [
11
- { code: "DE", name: "Germany", flag: "🇩🇪" },
12
- { code: "AT", name: "Austria", flag: "🇦🇹" },
13
- { code: "CH", name: "Switzerland", flag: "🇨🇭" },
14
- { code: "US", name: "United States", flag: "🇺🇸" },
15
- { code: "CA", name: "Canada", flag: "🇨🇦" },
16
- { code: "MX", name: "Mexico", flag: "🇲🇽" },
17
- { code: "GB", name: "United Kingdom", flag: "🇬🇧" },
18
- { code: "IE", name: "Ireland", flag: "🇮🇪" },
19
- { code: "FR", name: "France", flag: "🇫🇷" },
20
- { code: "IT", name: "Italy", flag: "🇮🇹" },
21
- { code: "ES", name: "Spain", flag: "🇪🇸" },
22
- { code: "PT", name: "Portugal", flag: "🇵🇹" },
23
- { code: "NL", name: "Netherlands", flag: "🇳🇱" },
24
- { code: "BE", name: "Belgium", flag: "🇧🇪" },
25
- { code: "LU", name: "Luxembourg", flag: "🇱🇺" },
26
- { code: "SE", name: "Sweden", flag: "🇸🇪" },
27
- { code: "NO", name: "Norway", flag: "🇳🇴" },
28
- { code: "DK", name: "Denmark", flag: "🇩🇰" },
29
- { code: "FI", name: "Finland", flag: "🇫🇮" },
30
- { code: "PL", name: "Poland", flag: "🇵🇱" },
31
- { code: "CZ", name: "Czech Republic", flag: "🇨🇿" },
32
- { code: "SK", name: "Slovakia", flag: "🇸🇰" },
33
- { code: "HU", name: "Hungary", flag: "🇭🇺" },
34
- { code: "RO", name: "Romania", flag: "🇷🇴" },
35
- { code: "BG", name: "Bulgaria", flag: "🇧🇬" },
36
- { code: "GR", name: "Greece", flag: "🇬🇷" },
37
- { code: "HR", name: "Croatia", flag: "🇭🇷" },
38
- { code: "SI", name: "Slovenia", flag: "🇸🇮" },
39
- { code: "EE", name: "Estonia", flag: "🇪🇪" },
40
- { code: "LV", name: "Latvia", flag: "🇱🇻" },
41
- { code: "LT", name: "Lithuania", flag: "🇱🇹" },
42
- { code: "IS", name: "Iceland", flag: "🇮🇸" },
43
- { code: "TR", name: "Turkey", flag: "🇹🇷" },
44
- { code: "RU", name: "Russia", flag: "🇷🇺" },
45
- { code: "UA", name: "Ukraine", flag: "🇺🇦" },
46
- { code: "BR", name: "Brazil", flag: "🇧🇷" },
47
- { code: "AR", name: "Argentina", flag: "🇦🇷" },
48
- { code: "CL", name: "Chile", flag: "🇨🇱" },
49
- { code: "CO", name: "Colombia", flag: "🇨🇴" },
50
- { code: "AU", name: "Australia", flag: "🇦🇺" },
51
- { code: "NZ", name: "New Zealand", flag: "🇳🇿" },
52
- { code: "JP", name: "Japan", flag: "🇯🇵" },
53
- { code: "KR", name: "South Korea", flag: "🇰🇷" },
54
- { code: "CN", name: "China", flag: "🇨🇳" },
55
- { code: "HK", name: "Hong Kong", flag: "🇭🇰" },
56
- { code: "TW", name: "Taiwan", flag: "🇹🇼" },
57
- { code: "SG", name: "Singapore", flag: "🇸🇬" },
58
- { code: "IN", name: "India", flag: "🇮🇳" },
59
- { code: "ID", name: "Indonesia", flag: "🇮🇩" },
60
- { code: "TH", name: "Thailand", flag: "🇹🇭" },
61
- { code: "VN", name: "Vietnam", flag: "🇻🇳" },
62
- { code: "PH", name: "Philippines", flag: "🇵🇭" },
63
- { code: "MY", name: "Malaysia", flag: "🇲🇾" },
64
- { code: "AE", name: "United Arab Emirates", flag: "🇦🇪" },
65
- { code: "SA", name: "Saudi Arabia", flag: "🇸🇦" },
66
- { code: "IL", name: "Israel", flag: "🇮🇱" },
67
- { code: "EG", name: "Egypt", flag: "🇪🇬" },
68
- { code: "ZA", name: "South Africa", flag: "🇿🇦" },
69
- { code: "NG", name: "Nigeria", flag: "🇳🇬" },
70
- { code: "KE", name: "Kenya", flag: "🇰🇪" },
71
- { code: "MA", name: "Morocco", flag: "🇲🇦" }
72
- ];
73
- const normalizeCountryCode = (raw) => {
74
- if (typeof raw !== "string") return null;
75
- const up = raw.trim().toUpperCase();
76
- if (!/^[A-Z]{2}$/.test(up)) return null;
77
- return up;
78
- };
79
- const formatCountry = (code) => {
80
- if (!code) return "";
81
- const match = COUNTRIES.find((c) => c.code === code);
82
- return match ? `${match.flag} ${match.name} (${match.code})` : code;
83
- };
84
- const theme = {
85
- borderRadius: { md: "8px", lg: "12px" }
86
- };
87
- const fadeIn = keyframes`
88
- from { opacity: 0; transform: translateY(10px); }
89
- to { opacity: 1; transform: translateY(0); }
90
- `;
91
- keyframes`
92
- 0% { background-position: -200% 0; }
93
- 100% { background-position: 200% 0; }
94
- `;
95
- const Container = styled(Box)`
96
- ${css`animation: ${fadeIn} 0.5s;`}
97
- max-width: 1400px;
98
- margin: 0 auto;
99
- `;
100
- const StickySaveBar = styled(Box)`
101
- position: sticky;
102
- top: 0;
103
- z-index: 10;
104
- background: ${(p) => p.theme.colors.neutral0};
105
- border-bottom: 1px solid rgba(128, 128, 128, 0.2);
106
- box-shadow: 0 1px 3px rgba(0,0,0,0.1);
107
- `;
108
- const ToggleCard = styled(Box)`
109
- background: ${(props) => props.$active ? "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%)"};
110
- border-radius: ${theme.borderRadius.lg};
111
- padding: 24px;
112
- min-height: 120px;
113
- transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
114
- border: 2px solid ${(props) => props.$active ? "var(--colors-success600, #16A34A)" : "rgba(128, 128, 128, 0.2)"};
115
- box-shadow: ${(props) => props.$active ? "0 4px 20px rgba(34, 197, 94, 0.15)" : "0 2px 8px rgba(0, 0, 0, 0.06)"};
116
- position: relative;
117
- cursor: pointer;
118
- display: flex;
119
- align-items: center;
120
-
121
- &:hover {
122
- transform: translateY(-4px);
123
- box-shadow: ${(props) => props.$active ? "0 8px 30px rgba(34, 197, 94, 0.25)" : "0 6px 16px rgba(0, 0, 0, 0.12)"};
124
- border-color: ${(props) => props.$active ? "var(--colors-success600, #15803D)" : "rgba(128, 128, 128, 0.3)"};
125
- }
126
-
127
- &:active {
128
- transform: translateY(-2px);
129
- }
130
-
131
- ${(props) => props.$active && `
132
- &::before {
133
- content: 'ACTIVE';
134
- position: absolute;
135
- top: 12px;
136
- right: 12px;
137
- background: ${"var(--colors-success600, #16A34A)"};
138
- color: white;
139
- padding: 4px 10px;
140
- border-radius: 6px;
141
- font-size: 10px;
142
- font-weight: 700;
143
- letter-spacing: 0.5px;
144
- box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3);
145
- }
146
- `}
147
-
148
- ${(props) => !props.$active && `
149
- &::before {
150
- content: 'INACTIVE';
151
- position: absolute;
152
- top: 12px;
153
- right: 12px;
154
- background: ${"rgba(128, 128, 128, 0.4)"};
155
- color: white;
156
- padding: 4px 10px;
157
- border-radius: 6px;
158
- font-size: 10px;
159
- font-weight: 700;
160
- letter-spacing: 0.5px;
161
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
162
- }
163
- `}
164
- `;
165
- const GreenToggle = styled.div`
166
- ${(props) => props.$isActive && `
167
- button[role="switch"] {
168
- background-color: var(--colors-success600, #16A34A) !important;
169
- border-color: var(--colors-success600, #16A34A) !important;
170
-
171
- &:hover {
172
- background-color: var(--colors-success600, #15803D) !important;
173
- border-color: var(--colors-success600, #15803D) !important;
174
- }
175
-
176
- &:focus {
177
- background-color: var(--colors-success600, #16A34A) !important;
178
- border-color: var(--colors-success600, #16A34A) !important;
179
- box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2) !important;
180
- }
181
- }
182
-
183
- /* Toggle handle */
184
- button[role="switch"] > span {
185
- background-color: white !important;
186
- }
187
- `}
188
-
189
- ${(props) => !props.$isActive && `
190
- button[role="switch"] {
191
- background-color: rgba(128, 128, 128, 0.2);
192
-
193
- &:hover {
194
- background-color: rgba(128, 128, 128, 0.2);
195
- }
196
- }
197
- `}
198
- `;
199
- const TEMPLATE_VARIABLES = {
200
- suspiciousLogin: [
201
- { var: "{{user.email}}", desc: "User email address" },
202
- { var: "{{user.username}}", desc: "Username" },
203
- { var: "{{session.loginTime}}", desc: "Login timestamp" },
204
- { var: "{{session.ipAddress}}", desc: "IP address" },
205
- { var: "{{geo.city}}", desc: "City (if available)" },
206
- { var: "{{geo.country}}", desc: "Country (if available)" },
207
- { var: "{{geo.timezone}}", desc: "Timezone (if available)" },
208
- { var: "{{session.userAgent}}", desc: "Browser/Device info" },
209
- { var: "{{reason.isVpn}}", desc: "VPN detected (true/false)" },
210
- { var: "{{reason.isProxy}}", desc: "Proxy detected (true/false)" },
211
- { var: "{{reason.isThreat}}", desc: "Threat detected (true/false)" },
212
- { var: "{{reason.securityScore}}", desc: "Security score (0-100)" }
213
- ],
214
- newLocation: [
215
- { var: "{{user.email}}", desc: "User email address" },
216
- { var: "{{user.username}}", desc: "Username" },
217
- { var: "{{session.loginTime}}", desc: "Login timestamp" },
218
- { var: "{{session.ipAddress}}", desc: "IP address" },
219
- { var: "{{geo.city}}", desc: "City" },
220
- { var: "{{geo.country}}", desc: "Country" },
221
- { var: "{{geo.timezone}}", desc: "Timezone" },
222
- { var: "{{session.userAgent}}", desc: "Browser/Device info" }
223
- ],
224
- vpnProxy: [
225
- { var: "{{user.email}}", desc: "User email address" },
226
- { var: "{{user.username}}", desc: "Username" },
227
- { var: "{{session.loginTime}}", desc: "Login timestamp" },
228
- { var: "{{session.ipAddress}}", desc: "IP address" },
229
- { var: "{{geo.city}}", desc: "City (if available)" },
230
- { var: "{{geo.country}}", desc: "Country (if available)" },
231
- { var: "{{session.userAgent}}", desc: "Browser/Device info" },
232
- { var: "{{reason.isVpn}}", desc: "VPN detected (true/false)" },
233
- { var: "{{reason.isProxy}}", desc: "Proxy detected (true/false)" }
234
- ]
235
- };
236
- const validateTemplate = (template, templateType) => {
237
- const requiredVars = TEMPLATE_VARIABLES[templateType];
238
- const foundVars = [];
239
- requiredVars.forEach(({ var: variable }) => {
240
- if (template.includes(variable)) {
241
- foundVars.push(variable);
242
- }
243
- });
244
- return {
245
- isValid: foundVars.length > 0,
246
- foundVars,
247
- totalAvailable: requiredVars.length
248
- };
249
- };
250
- const getDefaultTemplates = () => ({
251
- suspiciousLogin: {
252
- subject: "[ALERT] Suspicious Login Alert - Session Manager",
253
- html: `
254
- <html>
255
- <body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
256
- <div style="max-width: 600px; margin: 0 auto; padding: 20px; background-color: #f9fafb; border-radius: 10px;">
257
- <h2 style="color: #dc2626;">[ALERT] Suspicious Login Detected</h2>
258
- <p>A potentially suspicious login was detected for your account.</p>
259
-
260
- <div style="background: white; padding: 15px; border-radius: 8px; margin: 20px 0;">
261
- <h3 style="margin-top: 0;">Account Information:</h3>
262
- <ul>
263
- <li><strong>Email:</strong> {{user.email}}</li>
264
- <li><strong>Username:</strong> {{user.username}}</li>
265
- </ul>
266
-
267
- <h3>Login Details:</h3>
268
- <ul>
269
- <li><strong>Time:</strong> {{session.loginTime}}</li>
270
- <li><strong>IP Address:</strong> {{session.ipAddress}}</li>
271
- <li><strong>Location:</strong> {{geo.city}}, {{geo.country}}</li>
272
- <li><strong>Timezone:</strong> {{geo.timezone}}</li>
273
- <li><strong>Device:</strong> {{session.userAgent}}</li>
274
- </ul>
275
-
276
- <h3 style="color: #dc2626;">Security Alert:</h3>
277
- <ul>
278
- <li>VPN Detected: {{reason.isVpn}}</li>
279
- <li>Proxy Detected: {{reason.isProxy}}</li>
280
- <li>Threat Detected: {{reason.isThreat}}</li>
281
- <li>Security Score: {{reason.securityScore}}/100</li>
282
- </ul>
283
- </div>
284
-
285
- <p>If this was you, you can safely ignore this email. If you don't recognize this activity, please secure your account immediately.</p>
286
-
287
- <hr style="border: none; border-top: 1px solid #e5e7eb; margin: 20px 0;"/>
288
- <p style="color: #666; font-size: 12px;">This is an automated security notification from Magic Session Manager.</p>
289
- </div>
290
- </body>
291
- </html>`,
292
- text: `[ALERT] Suspicious Login Detected
293
-
294
- A potentially suspicious login was detected for your account.
295
-
296
- Account: {{user.email}}
297
- Username: {{user.username}}
298
-
299
- Login Details:
300
- - Time: {{session.loginTime}}
301
- - IP: {{session.ipAddress}}
302
- - Location: {{geo.city}}, {{geo.country}}
303
-
304
- Security: VPN={{reason.isVpn}}, Proxy={{reason.isProxy}}, Threat={{reason.isThreat}}, Score={{reason.securityScore}}/100`
305
- },
306
- newLocation: {
307
- subject: "[LOCATION] New Location Login Detected",
308
- html: `
309
- <html>
310
- <body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
311
- <div style="max-width: 600px; margin: 0 auto; padding: 20px; background-color: #f0f9ff; border-radius: 10px;">
312
- <h2 style="color: #0284c7;">[LOCATION] Login from New Location</h2>
313
- <p>Your account was accessed from a new location.</p>
314
-
315
- <div style="background: white; padding: 15px; border-radius: 8px; margin: 20px 0;">
316
- <h3 style="margin-top: 0;">Account:</h3>
317
- <p><strong>{{user.email}}</strong></p>
318
-
319
- <h3>New Location Details:</h3>
320
- <ul>
321
- <li><strong>Time:</strong> {{session.loginTime}}</li>
322
- <li><strong>Location:</strong> {{geo.city}}, {{geo.country}}</li>
323
- <li><strong>IP Address:</strong> {{session.ipAddress}}</li>
324
- <li><strong>Device:</strong> {{session.userAgent}}</li>
325
- </ul>
326
- </div>
327
-
328
- <p>If this was you, no action is needed. If you don't recognize this login, please secure your account.</p>
329
-
330
- <hr style="border: none; border-top: 1px solid #e5e7eb; margin: 20px 0;"/>
331
- <p style="color: #666; font-size: 12px;">Magic Session Manager notification</p>
332
- </div>
333
- </body>
334
- </html>`,
335
- text: `[LOCATION] Login from New Location
336
-
337
- Your account was accessed from a new location.
338
-
339
- Account: {{user.email}}
340
-
341
- New Location Details:
342
- - Time: {{session.loginTime}}
343
- - Location: {{geo.city}}, {{geo.country}}
344
- - IP Address: {{session.ipAddress}}
345
- - Device: {{session.userAgent}}
346
-
347
- If this was you, no action is needed.`
348
- },
349
- vpnProxy: {
350
- subject: "[WARNING] VPN/Proxy Login Detected",
351
- html: `
352
- <html>
353
- <body style="font-family: Arial, sans-serif; line-height: 1.6; color: #333;">
354
- <div style="max-width: 600px; margin: 0 auto; padding: 20px; background-color: #fffbeb; border-radius: 10px;">
355
- <h2 style="color: #d97706;">[WARNING] VPN/Proxy Detected</h2>
356
- <p>A login from a VPN or proxy service was detected on your account.</p>
357
-
358
- <div style="background: white; padding: 15px; border-radius: 8px; margin: 20px 0;">
359
- <h3 style="margin-top: 0;">Account:</h3>
360
- <p><strong>{{user.email}}</strong></p>
361
-
362
- <h3>Login Details:</h3>
363
- <ul>
364
- <li><strong>Time:</strong> {{session.loginTime}}</li>
365
- <li><strong>IP Address:</strong> {{session.ipAddress}}</li>
366
- <li><strong>Location:</strong> {{geo.city}}, {{geo.country}}</li>
367
- <li><strong>Device:</strong> {{session.userAgent}}</li>
368
- <li><strong>VPN:</strong> {{reason.isVpn}}</li>
369
- <li><strong>Proxy:</strong> {{reason.isProxy}}</li>
370
- </ul>
371
- </div>
372
-
373
- <p>VPN/Proxy usage may indicate suspicious activity. If this was you, you can safely ignore this email.</p>
374
-
375
- <hr style="border: none; border-top: 1px solid #e5e7eb; margin: 20px 0;"/>
376
- <p style="color: #666; font-size: 12px;">Magic Session Manager notification</p>
377
- </div>
378
- </body>
379
- </html>`,
380
- text: `[WARNING] VPN/Proxy Detected
381
-
382
- A login from a VPN or proxy service was detected on your account.
383
-
384
- Account: {{user.email}}
385
-
386
- Login Details:
387
- - Time: {{session.loginTime}}
388
- - IP Address: {{session.ipAddress}}
389
- - Location: {{geo.city}}, {{geo.country}}
390
- - VPN: {{reason.isVpn}}, Proxy: {{reason.isProxy}}`
391
- }
392
- });
393
- const generateSecureKey = () => {
394
- const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+-=[]{}|;:,.<>?";
395
- let key = "";
396
- const array = new Uint8Array(32);
397
- crypto.getRandomValues(array);
398
- for (let i = 0; i < 32; i++) {
399
- key += chars[array[i] % chars.length];
400
- }
401
- return key;
402
- };
403
- const GeofencingPanel = ({
404
- settings,
405
- handleChange,
406
- t,
407
- geoIpStatus,
408
- geoIpCredentials,
409
- setGeoIpCredentials,
410
- onSaveGeoIpCredentials,
411
- onUpdateGeoIp,
412
- geoIpUpdating,
413
- geoIpSavingCredentials,
414
- hasChanges
415
- }) => {
416
- const [pendingCode, setPendingCode] = useState("");
417
- const mode = (() => {
418
- if (Array.isArray(settings.allowedCountries) && settings.allowedCountries.length > 0) {
419
- return "allowlist";
420
- }
421
- if (Array.isArray(settings.blockedCountries) && settings.blockedCountries.length > 0) {
422
- return "blocklist";
423
- }
424
- return "allowlist";
425
- })();
426
- const activeField = mode === "allowlist" ? "allowedCountries" : "blockedCountries";
427
- const activeList = Array.isArray(settings[activeField]) ? settings[activeField] : [];
428
- const setMode = (newMode) => {
429
- if (newMode === mode) return;
430
- if (newMode === "allowlist") {
431
- handleChange("blockedCountries", []);
432
- } else {
433
- handleChange("allowedCountries", []);
434
- }
435
- };
436
- const addCode = (raw) => {
437
- const code = normalizeCountryCode(raw);
438
- if (!code) return;
439
- if (activeList.includes(code)) return;
440
- handleChange(activeField, [...activeList, code]);
441
- setPendingCode("");
442
- };
443
- const removeCode = (code) => {
444
- handleChange(activeField, activeList.filter((c) => c !== code));
445
- };
446
- return /* @__PURE__ */ jsxs(Grid.Root, { gap: 5, children: [
447
- /* @__PURE__ */ jsx(Grid.Item, { col: 12, children: /* @__PURE__ */ jsx(
448
- Box,
449
- {
450
- padding: 3,
451
- background: settings.enableGeofencing ? "success100" : "neutral100",
452
- hasRadius: true,
453
- style: { borderLeft: `4px solid ${settings.enableGeofencing ? "#16A34A" : "#9CA3AF"}` },
454
- children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [
455
- /* @__PURE__ */ jsxs(Box, { children: [
456
- /* @__PURE__ */ jsx(Typography, { variant: "delta", style: { display: "block", marginBottom: "4px" }, children: t("settings.geofencing.enable.title", "Enable Geofencing") }),
457
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "12px" }, children: t(
458
- "settings.geofencing.enable.description",
459
- "When enabled, the pre-login guard compares the caller's country against the configured list and rejects logins that do not match."
460
- ) })
461
- ] }),
462
- /* @__PURE__ */ jsx(
463
- Toggle,
464
- {
465
- onLabel: "On",
466
- offLabel: "Off",
467
- checked: !!settings.enableGeofencing,
468
- onChange: () => handleChange("enableGeofencing", !settings.enableGeofencing)
469
- }
470
- )
471
- ] })
472
- }
473
- ) }),
474
- /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
475
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.geofencing.provider.title", "GeoIP Provider") }),
476
- /* @__PURE__ */ jsxs(
477
- SingleSelect,
478
- {
479
- value: settings.geoIpProvider || "auto",
480
- onChange: (value) => handleChange("geoIpProvider", value),
481
- children: [
482
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "auto", children: t("settings.geofencing.provider.auto", "Auto") }),
483
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "local-mmdb", children: t("settings.geofencing.provider.local", "Local MMDB") }),
484
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "ipapi", children: t("settings.geofencing.provider.ipapi", "ipapi.co") }),
485
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "disabled", children: t("settings.geofencing.provider.disabled", "Disabled") })
486
- ]
487
- }
488
- )
489
- ] }) }),
490
- /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
491
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.geofencing.failureMode.title", "Lookup Failure Mode") }),
492
- /* @__PURE__ */ jsxs(
493
- SingleSelect,
494
- {
495
- value: settings.geoLookupFailureMode || "auto",
496
- onChange: (value) => handleChange("geoLookupFailureMode", value),
497
- children: [
498
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "auto", children: t("settings.geofencing.failureMode.auto", "Auto") }),
499
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "allow", children: t("settings.geofencing.failureMode.allow", "Allow") }),
500
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "block", children: t("settings.geofencing.failureMode.block", "Block") })
501
- ]
502
- }
503
- )
504
- ] }) }),
505
- /* @__PURE__ */ jsx(Grid.Item, { col: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
506
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.geofencing.databasePath.title", "Local MMDB Path") }),
507
- /* @__PURE__ */ jsx(
508
- TextInput,
509
- {
510
- name: "geoIpDatabasePath",
511
- value: settings.geoIpDatabasePath || "",
512
- onChange: (e) => handleChange("geoIpDatabasePath", e.target.value),
513
- placeholder: "/var/lib/strapi/GeoLite2-City.mmdb"
514
- }
515
- )
516
- ] }) }),
517
- /* @__PURE__ */ jsx(Grid.Item, { col: 12, children: /* @__PURE__ */ jsx(Box, { padding: 3, background: "neutral100", hasRadius: true, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, alignItems: "stretch", children: [
518
- /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", gap: 3, children: [
519
- /* @__PURE__ */ jsxs(Box, { children: [
520
- /* @__PURE__ */ jsx(Typography, { variant: "delta", style: { display: "block", marginBottom: "4px" }, children: t("settings.geofencing.database.title", "Local GeoIP Database (City recommended)") }),
521
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "12px" }, children: geoIpStatus?.exists ? t("settings.geofencing.database.exists", "Database is installed locally. GeoLite2-City enables city-level lookup; Country remains supported.") : t("settings.geofencing.database.missing", "No local database installed yet. GeoLite2-City is recommended for city-level lookup.") })
522
- ] }),
523
- /* @__PURE__ */ jsx(Badge, { backgroundColor: geoIpStatus?.exists ? "success100" : "warning100", children: geoIpStatus?.exists ? t("settings.geofencing.database.installed", "Installed") : t("settings.geofencing.database.notInstalled", "Missing") })
524
- ] }),
525
- /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "12px" }, children: [
526
- t("settings.geofencing.database.path", "Path"),
527
- ": ",
528
- geoIpStatus?.databasePath || settings.geoIpDatabasePath || "data/GeoLite2-City.mmdb"
529
- ] }),
530
- /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "12px" }, children: [
531
- t("settings.geofencing.database.edition", "Edition"),
532
- ": ",
533
- geoIpStatus?.editionId || "GeoLite2-City"
534
- ] }),
535
- geoIpStatus?.metadata?.lastModified && /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "12px" }, children: [
536
- t("settings.geofencing.database.lastModified", "Last MaxMind update"),
537
- ": ",
538
- geoIpStatus.metadata.lastModified
539
- ] }),
540
- /* @__PURE__ */ jsxs(Grid.Root, { gap: 3, children: [
541
- /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsx(
542
- TextInput,
543
- {
544
- name: "maxmindAccountId",
545
- value: geoIpCredentials.accountId || "",
546
- onChange: (e) => setGeoIpCredentials((prev) => ({ ...prev, accountId: e.target.value })),
547
- placeholder: t("settings.geofencing.maxmind.accountId", "MaxMind Account ID")
548
- }
549
- ) }),
550
- /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsx(
551
- TextInput,
552
- {
553
- name: "maxmindLicenseKey",
554
- type: "password",
555
- value: geoIpCredentials.licenseKey || "",
556
- onChange: (e) => setGeoIpCredentials((prev) => ({ ...prev, licenseKey: e.target.value })),
557
- placeholder: geoIpStatus?.hasCredentials ? t("settings.geofencing.maxmind.licenseStored", "License key stored") : t("settings.geofencing.maxmind.licenseKey", "MaxMind License Key")
558
- }
559
- ) })
560
- ] }),
561
- /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", children: [
562
- /* @__PURE__ */ jsx(
563
- Button,
564
- {
565
- variant: "secondary",
566
- onClick: onSaveGeoIpCredentials,
567
- disabled: geoIpSavingCredentials || !geoIpCredentials.accountId || !geoIpCredentials.licenseKey,
568
- children: geoIpSavingCredentials ? t("settings.geofencing.credentials.saving", "Saving...") : t("settings.geofencing.credentials.save", "Save MaxMind Credentials")
569
- }
570
- ),
571
- /* @__PURE__ */ jsx(
572
- Button,
573
- {
574
- onClick: () => onUpdateGeoIp(false),
575
- disabled: geoIpUpdating || !geoIpStatus?.hasCredentials || hasChanges,
576
- children: geoIpUpdating ? t("settings.geofencing.database.updating", "Updating...") : t("settings.geofencing.database.update", "Download / Update DB")
577
- }
578
- ),
579
- /* @__PURE__ */ jsx(
580
- Button,
581
- {
582
- variant: "tertiary",
583
- onClick: () => onUpdateGeoIp(true),
584
- disabled: geoIpUpdating || !geoIpStatus?.hasCredentials || hasChanges,
585
- children: t("settings.geofencing.database.force", "Force Refresh")
586
- }
587
- )
588
- ] }),
589
- hasChanges && /* @__PURE__ */ jsx(Alert, { variant: "warning", closeLabel: "", title: "", onClose: () => {
590
- }, children: t("settings.geofencing.database.saveFirst", "Save settings before downloading so the server uses the latest database path.") })
591
- ] }) }) }),
592
- /* @__PURE__ */ jsx(Grid.Item, { col: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
593
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.geofencing.mode.title", "Mode") }),
594
- /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
595
- /* @__PURE__ */ jsx(
596
- Button,
597
- {
598
- variant: mode === "allowlist" ? "default" : "tertiary",
599
- onClick: () => setMode("allowlist"),
600
- disabled: !settings.enableGeofencing,
601
- children: t("settings.geofencing.mode.allowlist", "Allowlist (only selected countries)")
602
- }
603
- ),
604
- /* @__PURE__ */ jsx(
605
- Button,
606
- {
607
- variant: mode === "blocklist" ? "default" : "tertiary",
608
- onClick: () => setMode("blocklist"),
609
- disabled: !settings.enableGeofencing,
610
- children: t("settings.geofencing.mode.blocklist", "Blocklist (block selected countries)")
611
- }
612
- )
613
- ] }),
614
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "11px", marginTop: "8px" }, children: mode === "allowlist" ? t(
615
- "settings.geofencing.mode.allowlist.hint",
616
- "Only countries in the list may authenticate. Empty list = no geo restriction."
617
- ) : t(
618
- "settings.geofencing.mode.blocklist.hint",
619
- "Every country EXCEPT those in the list may authenticate."
620
- ) })
621
- ] }) }),
622
- /* @__PURE__ */ jsx(Grid.Item, { col: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
623
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: mode === "allowlist" ? t("settings.geofencing.allowed.title", "Allowed Countries") : t("settings.geofencing.blocked.title", "Blocked Countries") }),
624
- /* @__PURE__ */ jsx(Flex, { gap: 2, wrap: "wrap", style: { marginBottom: "12px", minHeight: "36px" }, children: activeList.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral500", children: t("settings.geofencing.empty", "No countries configured.") }) : activeList.map((code) => /* @__PURE__ */ jsxs(
625
- Badge,
626
- {
627
- onClick: settings.enableGeofencing ? () => removeCode(code) : void 0,
628
- style: {
629
- cursor: settings.enableGeofencing ? "pointer" : "not-allowed",
630
- padding: "6px 10px",
631
- background: mode === "allowlist" ? "#DCFCE7" : "#FEE2E2",
632
- color: mode === "allowlist" ? "#15803D" : "#B91C1C"
633
- },
634
- children: [
635
- formatCountry(code),
636
- settings.enableGeofencing ? " ✕" : ""
637
- ]
638
- },
639
- code
640
- )) }),
641
- /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
642
- /* @__PURE__ */ jsx(Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsx(
643
- SingleSelect,
644
- {
645
- disabled: !settings.enableGeofencing,
646
- value: pendingCode || "",
647
- onChange: (value) => {
648
- setPendingCode(value);
649
- if (value) addCode(value);
650
- },
651
- placeholder: t("settings.geofencing.pick", "Pick a country to add…"),
652
- children: COUNTRIES.filter((c) => !activeList.includes(c.code)).map((c) => /* @__PURE__ */ jsxs(SingleSelectOption, { value: c.code, children: [
653
- c.flag,
654
- " ",
655
- c.name,
656
- " (",
657
- c.code,
658
- ")"
659
- ] }, c.code))
660
- }
661
- ) }),
662
- /* @__PURE__ */ jsx(
663
- TextInput,
664
- {
665
- disabled: !settings.enableGeofencing,
666
- placeholder: t("settings.geofencing.manual", "Or type ISO-2 (e.g. JP)"),
667
- value: pendingCode.length <= 2 ? pendingCode : "",
668
- onChange: (e) => setPendingCode(e.target.value.toUpperCase().slice(0, 2)),
669
- style: { width: "180px" }
670
- }
671
- ),
672
- /* @__PURE__ */ jsx(
673
- Button,
674
- {
675
- disabled: !settings.enableGeofencing || !normalizeCountryCode(pendingCode),
676
- onClick: () => addCode(pendingCode),
677
- children: t("settings.geofencing.add", "Add")
678
- }
679
- )
680
- ] })
681
- ] }) }),
682
- !settings.enableGeofencing && /* @__PURE__ */ jsx(Grid.Item, { col: 12, children: /* @__PURE__ */ jsx(Alert, { variant: "default", closeLabel: "", title: "", onClose: () => {
683
- }, children: t(
684
- "settings.geofencing.disabled",
685
- "Geofencing is currently disabled. Enable it above to enforce the configured country list."
686
- ) }) }),
687
- settings.enableGeofencing && !settings.enableGeolocation && /* @__PURE__ */ jsx(Grid.Item, { col: 12, children: /* @__PURE__ */ jsx(Alert, { variant: "warning", closeLabel: "", title: "", onClose: () => {
688
- }, children: t(
689
- "settings.geofencing.needsGeolocation",
690
- "Geofencing requires Geolocation to be enabled (Security tab)."
691
- ) }) })
692
- ] });
693
- };
694
- const SettingsPage = () => {
695
- const { formatMessage } = useIntl();
696
- const { get, post, put } = useFetchClient();
697
- const { toggleNotification } = useNotification();
698
- const t = (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
699
- const [loading, setLoading] = useState(true);
700
- const [saving, setSaving] = useState(false);
701
- const [hasChanges, setHasChanges] = useState(false);
702
- const [cleaning, setCleaning] = useState(false);
703
- const [activeTemplateTab, setActiveTemplateTab] = useState("suspiciousLogin");
704
- const [encryptionKey, setEncryptionKey] = useState("");
705
- const [showEncryptionKey, setShowEncryptionKey] = useState(false);
706
- const [geoIpStatus, setGeoIpStatus] = useState(null);
707
- const [geoIpCredentials, setGeoIpCredentials] = useState({ accountId: "", licenseKey: "" });
708
- const [geoIpUpdating, setGeoIpUpdating] = useState(false);
709
- const [geoIpSavingCredentials, setGeoIpSavingCredentials] = useState(false);
710
- const [settings, setSettings] = useState({
711
- inactivityTimeout: 15,
712
- cleanupInterval: 30,
713
- lastSeenRateLimit: 30,
714
- retentionDays: 90,
715
- maxSessionAgeDays: 30,
716
- // Grace window (ms) during which a freshly-issued JWT is accepted
717
- // without a matching session row. Prevents strict-session enforcement
718
- // from blocking the very first request after login. 0 disables.
719
- sessionCreationGraceMs: 5e3,
720
- // Opt-in fast path for the periodic idle-session cleanup: single
721
- // SQL UPDATE instead of batched Document-Service writes. Bypasses
722
- // lifecycle hooks; required for very large installations.
723
- cleanupUseDbDirect: false,
724
- strictSessionEnforcement: false,
725
- trustedProxies: false,
726
- enableGeolocation: true,
727
- enableSecurityScoring: true,
728
- blockSuspiciousSessions: false,
729
- maxFailedLogins: 5,
730
- enableEmailAlerts: false,
731
- alertOnSuspiciousLogin: true,
732
- alertOnNewLocation: true,
733
- alertOnVpnProxy: true,
734
- enableWebhooks: false,
735
- discordWebhookUrl: "",
736
- slackWebhookUrl: "",
737
- enableGeofencing: false,
738
- allowedCountries: [],
739
- blockedCountries: [],
740
- geoIpProvider: "auto",
741
- geoIpDatabasePath: "",
742
- geoLookupFailureMode: "auto",
743
- emailTemplates: {
744
- suspiciousLogin: { subject: "", html: "", text: "" },
745
- newLocation: { subject: "", html: "", text: "" },
746
- vpnProxy: { subject: "", html: "", text: "" }
747
- }
748
- });
749
- useEffect(() => {
750
- fetchSettings();
751
- }, []);
752
- const fetchSettings = async () => {
753
- setLoading(true);
754
- try {
755
- const response = await get(`/${pluginId}/settings`);
756
- if (response?.data?.settings) {
757
- const loadedSettings = response.data.settings;
758
- if (!loadedSettings.emailTemplates || Object.keys(loadedSettings.emailTemplates).length === 0) {
759
- loadedSettings.emailTemplates = getDefaultTemplates();
760
- } else {
761
- const defaultTemplates = getDefaultTemplates();
762
- Object.keys(defaultTemplates).forEach((key) => {
763
- if (!loadedSettings.emailTemplates[key]) {
764
- loadedSettings.emailTemplates[key] = defaultTemplates[key];
765
- } else {
766
- loadedSettings.emailTemplates[key] = {
767
- subject: loadedSettings.emailTemplates[key].subject || defaultTemplates[key].subject,
768
- html: loadedSettings.emailTemplates[key].html || defaultTemplates[key].html,
769
- text: loadedSettings.emailTemplates[key].text || defaultTemplates[key].text
770
- };
771
- }
772
- });
773
- }
774
- setSettings((prev) => ({ ...prev, ...loadedSettings }));
775
- await fetchGeoIpStatus();
776
- } else {
777
- setSettings((prev) => ({ ...prev, emailTemplates: getDefaultTemplates() }));
778
- await fetchGeoIpStatus();
779
- }
780
- } catch (err) {
781
- console.error("[Settings] Error loading from backend:", err);
782
- toggleNotification({
783
- type: "warning",
784
- message: t("notifications.warning.settingsLoad", "Could not load settings from server. Using defaults.")
785
- });
786
- setSettings((prev) => ({ ...prev, emailTemplates: getDefaultTemplates() }));
787
- } finally {
788
- setLoading(false);
789
- }
790
- };
791
- const fetchGeoIpStatus = async () => {
792
- try {
793
- const response = await get(`/${pluginId}/geoip/status`);
794
- if (response?.data?.status) {
795
- const status = response.data.status;
796
- setGeoIpStatus(status);
797
- setGeoIpCredentials((prev) => ({
798
- accountId: prev.accountId || status.accountId || "",
799
- licenseKey: ""
800
- }));
801
- }
802
- } catch (err) {
803
- console.error("[Settings] Error loading GeoIP status:", err);
804
- }
805
- };
806
- const handleChange = (key, value) => {
807
- setSettings((prev) => ({ ...prev, [key]: value }));
808
- setHasChanges(true);
809
- };
810
- const handleSave = async () => {
811
- setSaving(true);
812
- try {
813
- const response = await put(`/${pluginId}/settings`, settings);
814
- if (response?.data?.success) {
815
- await fetchGeoIpStatus();
816
- toggleNotification({
817
- type: "success",
818
- message: t("notifications.success.saved", "Settings saved successfully to database!")
819
- });
820
- setHasChanges(false);
821
- } else {
822
- throw new Error("Save failed");
823
- }
824
- } catch (err) {
825
- console.error("[Settings] Error saving:", err);
826
- toggleNotification({
827
- type: "danger",
828
- message: t("notifications.error.save", "Failed to save settings to server")
829
- });
830
- } finally {
831
- setSaving(false);
832
- }
833
- };
834
- const handleSaveGeoIpCredentials = async () => {
835
- setGeoIpSavingCredentials(true);
836
- try {
837
- const response = await put(`/${pluginId}/geoip/credentials`, geoIpCredentials);
838
- if (response?.data?.success) {
839
- toggleNotification({
840
- type: "success",
841
- message: t("notifications.success.geoipCredentialsSaved", "MaxMind credentials saved.")
842
- });
843
- setGeoIpCredentials((prev) => ({ ...prev, licenseKey: "" }));
844
- await fetchGeoIpStatus();
845
- }
846
- } catch (err) {
847
- console.error("[Settings] Error saving GeoIP credentials:", err);
848
- toggleNotification({
849
- type: "danger",
850
- message: t("notifications.error.geoipCredentials", "Failed to save MaxMind credentials.")
851
- });
852
- } finally {
853
- setGeoIpSavingCredentials(false);
854
- }
855
- };
856
- const handleUpdateGeoIpDatabase = async (force = false) => {
857
- setGeoIpUpdating(true);
858
- try {
859
- const response = await post(`/${pluginId}/geoip/update`, { force });
860
- if (response?.data?.success) {
861
- toggleNotification({
862
- type: "success",
863
- message: response.data.result?.changed ? t("notifications.success.geoipUpdated", "GeoIP database updated.") : t("notifications.success.geoipCurrent", "GeoIP database is already current.")
864
- });
865
- await fetchGeoIpStatus();
866
- }
867
- } catch (err) {
868
- console.error("[Settings] Error updating GeoIP database:", err);
869
- toggleNotification({
870
- type: "danger",
871
- message: t("notifications.error.geoipUpdate", "Failed to update GeoIP database.")
872
- });
873
- } finally {
874
- setGeoIpUpdating(false);
875
- }
876
- };
877
- const handleReset = () => {
878
- fetchSettings();
879
- setHasChanges(false);
880
- };
881
- const handleCleanInactive = async () => {
882
- if (!confirm(t("settings.general.danger.confirm", "[WARNING] This will permanently delete ALL inactive sessions.\n\nContinue?"))) {
883
- return;
884
- }
885
- setCleaning(true);
886
- try {
887
- const { data } = await post(`/${pluginId}/sessions/clean-inactive`);
888
- toggleNotification({
889
- type: "success",
890
- message: t("notifications.success.cleaned", "Successfully deleted {count} inactive sessions!", { count: data.deletedCount })
891
- });
892
- } catch (err) {
893
- toggleNotification({
894
- type: "danger",
895
- message: t("notifications.error.clean", "Failed to delete inactive sessions")
896
- });
897
- } finally {
898
- setCleaning(false);
899
- }
900
- };
901
- if (loading) {
902
- return /* @__PURE__ */ jsx(Flex, { justifyContent: "center", padding: 8, children: /* @__PURE__ */ jsx(Loader, { children: t("common.loading", "Loading...") }) });
903
- }
904
- return /* @__PURE__ */ jsxs(Container, { children: [
905
- /* @__PURE__ */ jsx(StickySaveBar, { paddingTop: 5, paddingBottom: 5, paddingLeft: 6, paddingRight: 6, children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [
906
- /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, alignItems: "flex-start", children: [
907
- /* @__PURE__ */ jsxs(Typography, { variant: "alpha", fontWeight: "bold", style: { fontSize: "24px" }, children: [
908
- "⚙️ ",
909
- t("settings.title", "Session Manager Settings")
910
- ] }),
911
- /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: t("settings.subtitle", "Configure session tracking, security, and email notifications") })
912
- ] }),
913
- /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
914
- hasChanges && /* @__PURE__ */ jsx(Button, { onClick: handleReset, variant: "tertiary", size: "L", children: t("settings.reset", "Reset") }),
915
- /* @__PURE__ */ jsx(
916
- Button,
917
- {
918
- onClick: handleSave,
919
- loading: saving,
920
- startIcon: /* @__PURE__ */ jsx(Check, {}),
921
- size: "L",
922
- disabled: !hasChanges || saving,
923
- style: {
924
- background: hasChanges && !saving ? "linear-gradient(135deg, #667eea 0%, #764ba2 100%)" : "rgba(128, 128, 128, 0.2)",
925
- color: hasChanges && !saving ? "white" : "var(--colors-neutral500)",
926
- fontWeight: "600",
927
- padding: "12px 24px",
928
- border: "none",
929
- boxShadow: hasChanges && !saving ? "0 4px 12px rgba(102, 126, 234, 0.4)" : "none",
930
- transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)"
931
- },
932
- onMouseEnter: (e) => {
933
- if (hasChanges && !saving) {
934
- e.currentTarget.style.transform = "translateY(-2px)";
935
- e.currentTarget.style.boxShadow = "0 8px 20px rgba(102, 126, 234, 0.5)";
936
- }
937
- },
938
- onMouseLeave: (e) => {
939
- e.currentTarget.style.transform = "translateY(0)";
940
- e.currentTarget.style.boxShadow = hasChanges && !saving ? "0 4px 12px rgba(102, 126, 234, 0.4)" : "none";
941
- },
942
- children: saving ? t("settings.saving", "Saving...") : hasChanges ? t("settings.save", "Save Changes") : t("settings.noChanges", "No Changes")
943
- }
944
- )
945
- ] })
946
- ] }) }),
947
- /* @__PURE__ */ jsxs(Box, { paddingTop: 6, paddingLeft: 6, paddingRight: 6, paddingBottom: 10, children: [
948
- /* @__PURE__ */ jsxs(Accordion.Root, { type: "multiple", defaultValue: ["general", "security", "email"], children: [
949
- /* @__PURE__ */ jsxs(Accordion.Item, { value: "general", children: [
950
- /* @__PURE__ */ jsx(Accordion.Header, { children: /* @__PURE__ */ jsx(
951
- Accordion.Trigger,
952
- {
953
- icon: Cog,
954
- description: t("settings.general.description", "Basic session tracking configuration"),
955
- children: t("settings.general.title", "General Settings")
956
- }
957
- ) }),
958
- /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsxs(Box, { padding: 6, children: [
959
- /* @__PURE__ */ jsx(Typography, { variant: "sigma", fontWeight: "bold", style: { marginBottom: "16px", display: "block", color: "var(--colors-neutral700)" }, children: t("settings.general.timeout.title", "SESSION TIMEOUT") }),
960
- /* @__PURE__ */ jsxs(Grid.Root, { gap: 6, style: { marginBottom: "32px" }, children: [
961
- /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
962
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.general.timeout.inactivity", "Inactivity Timeout") }),
963
- /* @__PURE__ */ jsxs(
964
- SingleSelect,
965
- {
966
- value: String(settings.inactivityTimeout),
967
- onChange: (value) => handleChange("inactivityTimeout", parseInt(value)),
968
- children: [
969
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "5", children: t("settings.general.timeout.5min", "5 minutes (Very Strict)") }),
970
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "10", children: t("settings.general.timeout.10min", "10 minutes (Strict)") }),
971
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "15", children: t("settings.general.timeout.15min", "15 minutes (Recommended)") }),
972
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "30", children: t("settings.general.timeout.30min", "30 minutes (Moderate)") }),
973
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "60", children: t("settings.general.timeout.1hour", "1 hour (Relaxed)") }),
974
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "120", children: t("settings.general.timeout.2hours", "2 hours (Very Relaxed)") })
975
- ]
976
- }
977
- ),
978
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "11px", marginTop: "8px" }, children: t("settings.general.timeout.inactivityHint", "Sessions inactive for more than {minutes} minutes will be marked as offline", { minutes: settings.inactivityTimeout }) })
979
- ] }) }),
980
- /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
981
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.general.rateLimit.title", "Last Seen Rate Limit") }),
982
- /* @__PURE__ */ jsxs(
983
- SingleSelect,
984
- {
985
- value: String(settings.lastSeenRateLimit),
986
- onChange: (value) => handleChange("lastSeenRateLimit", parseInt(value)),
987
- children: [
988
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "10", children: t("settings.general.rateLimit.10sec", "10 seconds") }),
989
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "30", children: t("settings.general.rateLimit.30sec", "30 seconds (Recommended)") }),
990
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "60", children: t("settings.general.rateLimit.1min", "1 minute") }),
991
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "120", children: t("settings.general.rateLimit.2min", "2 minutes") }),
992
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "300", children: t("settings.general.rateLimit.5min", "5 minutes") })
993
- ]
994
- }
995
- ),
996
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "11px", marginTop: "8px" }, children: t("settings.general.rateLimit.hint", "Prevents excessive database writes. Updates throttled to once every {seconds} seconds", { seconds: settings.lastSeenRateLimit }) })
997
- ] }) })
998
- ] }),
999
- /* @__PURE__ */ jsx(Divider, { style: { marginBottom: "24px" } }),
1000
- /* @__PURE__ */ jsxs(Typography, { variant: "sigma", fontWeight: "bold", style: { marginBottom: "16px", display: "block", color: "var(--colors-neutral700)" }, children: [
1001
- "🧹 ",
1002
- t("settings.general.cleanup.title", "AUTO-CLEANUP & RETENTION")
1003
- ] }),
1004
- /* @__PURE__ */ jsxs(Grid.Root, { gap: 6, children: [
1005
- /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
1006
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.general.cleanup.interval", "Cleanup Interval") }),
1007
- /* @__PURE__ */ jsxs(
1008
- SingleSelect,
1009
- {
1010
- value: String(settings.cleanupInterval),
1011
- onChange: (value) => handleChange("cleanupInterval", parseInt(value)),
1012
- children: [
1013
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "15", children: t("settings.general.cleanup.15min", "15 minutes") }),
1014
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "30", children: t("settings.general.cleanup.30min", "30 minutes (Recommended)") }),
1015
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "60", children: t("settings.general.cleanup.1hour", "1 hour") }),
1016
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "120", children: t("settings.general.cleanup.2hours", "2 hours") })
1017
- ]
1018
- }
1019
- ),
1020
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "11px", marginTop: "8px" }, children: t("settings.general.cleanup.intervalHint", "Inactive sessions are automatically cleaned every {minutes} minutes", { minutes: settings.cleanupInterval }) })
1021
- ] }) }),
1022
- /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
1023
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.general.retention.title", "Retention Period") }),
1024
- /* @__PURE__ */ jsxs(
1025
- SingleSelect,
1026
- {
1027
- value: String(settings.retentionDays),
1028
- onChange: (value) => handleChange("retentionDays", parseInt(value)),
1029
- children: [
1030
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "7", children: t("settings.general.retention.7days", "7 days") }),
1031
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "30", children: t("settings.general.retention.30days", "30 days") }),
1032
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "60", children: t("settings.general.retention.60days", "60 days") }),
1033
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "90", children: t("settings.general.retention.90days", "90 days (Recommended)") }),
1034
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "180", children: t("settings.general.retention.180days", "180 days") }),
1035
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "365", children: t("settings.general.retention.1year", "1 year") }),
1036
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "-1", children: t("settings.general.retention.forever", "Forever") })
1037
- ]
1038
- }
1039
- ),
1040
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "11px", marginTop: "8px" }, children: settings.retentionDays === -1 ? t("settings.general.retention.hintNever", "Old sessions deleted after never") : t("settings.general.retention.hint", "Old sessions deleted after {days}", { days: `${settings.retentionDays} days` }) })
1041
- ] }) }),
1042
- /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
1043
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.general.grace.title", "Post-Login Grace Period") }),
1044
- /* @__PURE__ */ jsxs(
1045
- SingleSelect,
1046
- {
1047
- value: String(settings.sessionCreationGraceMs ?? 5e3),
1048
- onChange: (value) => handleChange("sessionCreationGraceMs", parseInt(value)),
1049
- children: [
1050
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "0", children: t("settings.general.grace.off", "Off (strict from first request)") }),
1051
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "2000", children: t("settings.general.grace.2s", "2 seconds") }),
1052
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "5000", children: t("settings.general.grace.5s", "5 seconds (Recommended)") }),
1053
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "10000", children: t("settings.general.grace.10s", "10 seconds") }),
1054
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "30000", children: t("settings.general.grace.30s", "30 seconds") })
1055
- ]
1056
- }
1057
- ),
1058
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "11px", marginTop: "8px" }, children: t(
1059
- "settings.general.grace.hint",
1060
- "Accepts a freshly-issued JWT without a matching session row for this window, preventing strict-enforcement races right after login."
1061
- ) })
1062
- ] }) }),
1063
- /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
1064
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.general.cleanupMode.title", "Cleanup Strategy") }),
1065
- /* @__PURE__ */ jsxs(
1066
- SingleSelect,
1067
- {
1068
- value: settings.cleanupUseDbDirect ? "db" : "document-service",
1069
- onChange: (value) => handleChange("cleanupUseDbDirect", value === "db"),
1070
- children: [
1071
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "document-service", children: t("settings.general.cleanupMode.ds", "Document Service (Recommended, safe)") }),
1072
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "db", children: t("settings.general.cleanupMode.db", "Direct SQL UPDATE (large-scale)") })
1073
- ]
1074
- }
1075
- ),
1076
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "11px", marginTop: "8px" }, children: t(
1077
- "settings.general.cleanupMode.hint",
1078
- "Direct SQL drains the entire idle-session backlog in one statement but bypasses lifecycle hooks. Only switch if you run >50 k active sessions."
1079
- ) })
1080
- ] }) }),
1081
- /* @__PURE__ */ jsx(Grid.Item, { col: 12, children: /* @__PURE__ */ jsx(Box, { padding: 4, background: "danger100", style: { borderRadius: theme.borderRadius.md, border: `2px solid rgba(220, 38, 38, 0.2)` }, children: /* @__PURE__ */ jsxs(Flex, { gap: 3, alignItems: "flex-start", children: [
1082
- /* @__PURE__ */ jsx(Trash, { style: { width: "18px", height: "18px", color: "var(--colors-danger600, #DC2626)", flexShrink: 0, marginTop: "2px" } }),
1083
- /* @__PURE__ */ jsxs(Box, { style: { flex: 1 }, children: [
1084
- /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "danger700", style: { marginBottom: "8px", display: "block" }, children: t("settings.general.danger.title", "Danger Zone") }),
1085
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger600", style: { fontSize: "13px", lineHeight: "1.7" }, children: t("settings.general.danger.description", "Clean All Inactive: Permanently deletes all inactive sessions. This cannot be undone.") })
1086
- ] }),
1087
- /* @__PURE__ */ jsx(
1088
- DangerButton,
1089
- {
1090
- onClick: handleCleanInactive,
1091
- loading: cleaning,
1092
- startIcon: /* @__PURE__ */ jsx(Trash, {}),
1093
- size: "S",
1094
- style: { flexShrink: 0 },
1095
- children: t("settings.general.danger.cleanNow", "Clean Now")
1096
- }
1097
- )
1098
- ] }) }) })
1099
- ] })
1100
- ] }) })
1101
- ] }),
1102
- /* @__PURE__ */ jsxs(Accordion.Item, { value: "security", children: [
1103
- /* @__PURE__ */ jsx(Accordion.Header, { children: /* @__PURE__ */ jsx(
1104
- Accordion.Trigger,
1105
- {
1106
- icon: Shield,
1107
- description: t("settings.security.description", "Security policies and threat protection"),
1108
- children: t("settings.security.title", "Security Settings")
1109
- }
1110
- ) }),
1111
- /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsxs(Box, { padding: 6, children: [
1112
- /* @__PURE__ */ jsx(Typography, { variant: "sigma", fontWeight: "bold", style: { marginBottom: "16px", display: "block", color: "var(--colors-neutral700)" }, children: t("settings.security.options", "SECURITY OPTIONS") }),
1113
- /* @__PURE__ */ jsx(
1114
- Box,
1115
- {
1116
- background: "neutral0",
1117
- padding: 6,
1118
- style: {
1119
- borderRadius: theme.borderRadius.lg,
1120
- marginBottom: "32px",
1121
- border: `2px solid ${"rgba(2, 132, 199, 0.12)"}`,
1122
- background: "rgba(2, 132, 199, 0.04)"
1123
- },
1124
- children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, children: [
1125
- /* @__PURE__ */ jsxs(Flex, { alignItems: "center", gap: 3, children: [
1126
- /* @__PURE__ */ jsx(Shield, { style: { width: 24, height: 24, color: "var(--colors-primary600, #0284C7)" } }),
1127
- /* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", children: t("settings.security.encryption.title", "JWT Encryption Key Generator") })
1128
- ] }),
1129
- /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", style: { lineHeight: 1.6 }, children: t("settings.security.encryption.description", "Generate a secure 32-character encryption key for JWT token storage. This key is used to encrypt tokens before saving them to the database.") }),
1130
- /* @__PURE__ */ jsx(
1131
- Alert,
1132
- {
1133
- variant: "default",
1134
- title: t("settings.security.encryption.important", "Important"),
1135
- style: { marginTop: 8 },
1136
- children: t("settings.security.encryption.envHint", "Add this key to your .env file as SESSION_ENCRYPTION_KEY for production.")
1137
- }
1138
- ),
1139
- /* @__PURE__ */ jsxs(Flex, { gap: 3, alignItems: "flex-end", children: [
1140
- /* @__PURE__ */ jsx(Box, { style: { flex: 1 }, children: /* @__PURE__ */ jsx(
1141
- TextInput,
1142
- {
1143
- label: t("settings.security.encryption.label", "Generated Encryption Key"),
1144
- value: encryptionKey,
1145
- onChange: (e) => setEncryptionKey(e.target.value),
1146
- placeholder: t("settings.security.encryption.placeholder", "Click 'Generate Key' to create a secure key"),
1147
- type: showEncryptionKey ? "text" : "password"
1148
- }
1149
- ) }),
1150
- /* @__PURE__ */ jsx(
1151
- ShowHideButton,
1152
- {
1153
- onClick: () => setShowEncryptionKey(!showEncryptionKey),
1154
- size: "L",
1155
- children: showEncryptionKey ? t("settings.security.encryption.hide", "Hide") : t("settings.security.encryption.show", "Show")
1156
- }
1157
- )
1158
- ] }),
1159
- /* @__PURE__ */ jsxs(Flex, { gap: 3, children: [
1160
- /* @__PURE__ */ jsx(
1161
- GradientButton,
1162
- {
1163
- startIcon: /* @__PURE__ */ jsx(Code, {}),
1164
- onClick: () => {
1165
- const key = generateSecureKey();
1166
- setEncryptionKey(key);
1167
- setShowEncryptionKey(true);
1168
- toggleNotification({
1169
- type: "success",
1170
- message: t("notifications.success.keyGenerated", "32-character encryption key generated!")
1171
- });
1172
- },
1173
- size: "L",
1174
- children: t("settings.security.encryption.generate", "Generate Key")
1175
- }
1176
- ),
1177
- /* @__PURE__ */ jsx(
1178
- CopyButton,
1179
- {
1180
- startIcon: /* @__PURE__ */ jsx(Duplicate, {}),
1181
- onClick: () => {
1182
- if (encryptionKey) {
1183
- navigator.clipboard.writeText(encryptionKey);
1184
- toggleNotification({
1185
- type: "success",
1186
- message: t("notifications.success.keyCopied", "Encryption key copied to clipboard!")
1187
- });
1188
- }
1189
- },
1190
- disabled: !encryptionKey,
1191
- size: "L",
1192
- children: t("settings.security.encryption.copy", "Copy to Clipboard")
1193
- }
1194
- ),
1195
- /* @__PURE__ */ jsx(
1196
- CopyButton,
1197
- {
1198
- startIcon: /* @__PURE__ */ jsx(Duplicate, {}),
1199
- onClick: () => {
1200
- if (encryptionKey) {
1201
- const envLine = `SESSION_ENCRYPTION_KEY=${encryptionKey}`;
1202
- navigator.clipboard.writeText(envLine);
1203
- toggleNotification({
1204
- type: "success",
1205
- message: t("notifications.success.envCopied", "Copied as .env format!")
1206
- });
1207
- }
1208
- },
1209
- disabled: !encryptionKey,
1210
- size: "L",
1211
- children: t("settings.security.encryption.copyEnv", "Copy for .env")
1212
- }
1213
- )
1214
- ] }),
1215
- encryptionKey && /* @__PURE__ */ jsxs(
1216
- Box,
1217
- {
1218
- padding: 4,
1219
- background: "neutral100",
1220
- style: {
1221
- borderRadius: theme.borderRadius.md,
1222
- border: "1px solid rgba(128, 128, 128, 0.2)",
1223
- fontFamily: "monospace",
1224
- fontSize: "12px",
1225
- wordBreak: "break-all"
1226
- },
1227
- children: [
1228
- /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", style: { marginBottom: 8, display: "block" }, children: t("settings.security.encryption.envLabel", "Add to .env file:") }),
1229
- /* @__PURE__ */ jsxs("code", { style: { color: "var(--colors-primary600, #075985)" }, children: [
1230
- "SESSION_ENCRYPTION_KEY=",
1231
- encryptionKey
1232
- ] })
1233
- ]
1234
- }
1235
- )
1236
- ] })
1237
- }
1238
- ),
1239
- /* @__PURE__ */ jsx(
1240
- Box,
1241
- {
1242
- background: "neutral0",
1243
- padding: 6,
1244
- style: {
1245
- borderRadius: theme.borderRadius.lg,
1246
- marginBottom: "32px",
1247
- border: `2px solid ${settings.strictSessionEnforcement ? "rgba(220, 38, 38, 0.25)" : "rgba(2, 132, 199, 0.12)"}`,
1248
- background: settings.strictSessionEnforcement ? "rgba(220, 38, 38, 0.04)" : "rgba(2, 132, 199, 0.04)"
1249
- },
1250
- children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, children: [
1251
- /* @__PURE__ */ jsxs(Flex, { alignItems: "center", gap: 3, children: [
1252
- /* @__PURE__ */ jsx(Shield, { style: { width: 24, height: 24, color: settings.strictSessionEnforcement ? "var(--colors-danger600, #DC2626)" : "var(--colors-primary600, #0284C7)" } }),
1253
- /* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", children: t("settings.security.enforcement.title", "Session Enforcement Policy") }),
1254
- /* @__PURE__ */ jsx(Badge, { backgroundColor: settings.strictSessionEnforcement ? "danger100" : "neutral100", textColor: settings.strictSessionEnforcement ? "danger700" : "neutral700", children: settings.strictSessionEnforcement ? t("settings.security.enforcement.badgeStrict", "STRICT") : t("settings.security.enforcement.badgeRelaxed", "RELAXED") })
1255
- ] }),
1256
- /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", style: { lineHeight: 1.6 }, children: t("settings.security.enforcement.description", "Controls how aggressively JWT tokens are tied to an active session record. Strict mode rejects any token without a matching session, which is more secure but breaks tokens issued before this plugin was installed.") }),
1257
- /* @__PURE__ */ jsxs(Grid.Root, { gap: 6, children: [
1258
- /* @__PURE__ */ jsx(Grid.Item, { col: 12, s: 12, children: /* @__PURE__ */ jsx(
1259
- ToggleCard,
1260
- {
1261
- $active: settings.strictSessionEnforcement,
1262
- onClick: () => handleChange("strictSessionEnforcement", !settings.strictSessionEnforcement),
1263
- children: /* @__PURE__ */ jsxs(Flex, { direction: "row", gap: 4, style: { width: "100%" }, alignItems: "center", children: [
1264
- /* @__PURE__ */ jsx(GreenToggle, { $isActive: settings.strictSessionEnforcement, children: /* @__PURE__ */ jsx(
1265
- Toggle,
1266
- {
1267
- checked: settings.strictSessionEnforcement,
1268
- onChange: () => handleChange("strictSessionEnforcement", !settings.strictSessionEnforcement)
1269
- }
1270
- ) }),
1271
- /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, style: { flex: 1 }, children: [
1272
- /* @__PURE__ */ jsx(
1273
- Typography,
1274
- {
1275
- variant: "delta",
1276
- fontWeight: "bold",
1277
- textColor: settings.strictSessionEnforcement ? "success700" : "neutral800",
1278
- style: { fontSize: "15px" },
1279
- children: t("settings.security.enforcement.strict.title", "Strict Session Enforcement")
1280
- }
1281
- ),
1282
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "12px", lineHeight: "1.5" }, children: t("settings.security.enforcement.strict.description", "Reject every authenticated request that does not have a matching session record. Recommended for production.") })
1283
- ] })
1284
- ] })
1285
- }
1286
- ) }),
1287
- /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
1288
- /* @__PURE__ */ jsxs(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: [
1289
- /* @__PURE__ */ jsx(Clock, { style: { width: 14, height: 14, verticalAlign: "middle", marginRight: 6 } }),
1290
- t("settings.security.enforcement.maxAge.title", "Max Session Age")
1291
- ] }),
1292
- /* @__PURE__ */ jsxs(
1293
- SingleSelect,
1294
- {
1295
- value: String(settings.maxSessionAgeDays),
1296
- onChange: (value) => handleChange("maxSessionAgeDays", parseInt(value)),
1297
- children: [
1298
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "1", children: t("settings.security.enforcement.maxAge.1day", "1 day (Very Strict)") }),
1299
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "7", children: t("settings.security.enforcement.maxAge.7days", "7 days") }),
1300
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "14", children: t("settings.security.enforcement.maxAge.14days", "14 days") }),
1301
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "30", children: t("settings.security.enforcement.maxAge.30days", "30 days (Recommended)") }),
1302
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "60", children: t("settings.security.enforcement.maxAge.60days", "60 days") }),
1303
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "90", children: t("settings.security.enforcement.maxAge.90days", "90 days") }),
1304
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "180", children: t("settings.security.enforcement.maxAge.180days", "180 days") }),
1305
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "365", children: t("settings.security.enforcement.maxAge.365days", "1 year") })
1306
- ]
1307
- }
1308
- ),
1309
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "11px", marginTop: "8px" }, children: t("settings.security.enforcement.maxAge.hint", "Sessions older than {days} days are automatically terminated, even if still active", { days: settings.maxSessionAgeDays }) })
1310
- ] }) }),
1311
- /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsx(
1312
- ToggleCard,
1313
- {
1314
- $active: settings.trustedProxies,
1315
- onClick: () => handleChange("trustedProxies", !settings.trustedProxies),
1316
- children: /* @__PURE__ */ jsxs(Flex, { direction: "row", gap: 4, style: { width: "100%" }, alignItems: "center", children: [
1317
- /* @__PURE__ */ jsx(GreenToggle, { $isActive: settings.trustedProxies, children: /* @__PURE__ */ jsx(
1318
- Toggle,
1319
- {
1320
- checked: settings.trustedProxies,
1321
- onChange: () => handleChange("trustedProxies", !settings.trustedProxies)
1322
- }
1323
- ) }),
1324
- /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 1, style: { flex: 1 }, children: [
1325
- /* @__PURE__ */ jsx(
1326
- Typography,
1327
- {
1328
- variant: "delta",
1329
- fontWeight: "bold",
1330
- textColor: settings.trustedProxies ? "success700" : "neutral800",
1331
- style: { fontSize: "15px" },
1332
- children: t("settings.security.enforcement.trustedProxies.title", "Trust Upstream Proxy")
1333
- }
1334
- ),
1335
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "12px", lineHeight: "1.5" }, children: t("settings.security.enforcement.trustedProxies.description", "Only enable when Strapi sits behind a trusted reverse proxy (nginx, Cloudflare). Otherwise clients can spoof X-Forwarded-For.") })
1336
- ] })
1337
- ] })
1338
- }
1339
- ) })
1340
- ] }),
1341
- !settings.strictSessionEnforcement && /* @__PURE__ */ jsx(
1342
- Alert,
1343
- {
1344
- variant: "warning",
1345
- title: t("settings.security.enforcement.warning.title", "Running in Relaxed Mode"),
1346
- children: t("settings.security.enforcement.warning.body", "Tokens without a matching session record are allowed through. Manual session termination is still enforced via the token hash, but we strongly recommend enabling strict mode in production.")
1347
- }
1348
- )
1349
- ] })
1350
- }
1351
- ),
1352
- /* @__PURE__ */ jsx(Box, { background: "neutral100", padding: 5, style: { borderRadius: theme.borderRadius.md, marginBottom: "32px" }, children: /* @__PURE__ */ jsxs(Grid.Root, { gap: 4, children: [
1353
- /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsx(
1354
- ToggleCard,
1355
- {
1356
- $active: settings.blockSuspiciousSessions,
1357
- onClick: () => handleChange("blockSuspiciousSessions", !settings.blockSuspiciousSessions),
1358
- children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, style: { width: "100%" }, alignItems: "center", children: [
1359
- /* @__PURE__ */ jsx(GreenToggle, { $isActive: settings.blockSuspiciousSessions, children: /* @__PURE__ */ jsx(
1360
- Toggle,
1361
- {
1362
- checked: settings.blockSuspiciousSessions,
1363
- onChange: () => handleChange("blockSuspiciousSessions", !settings.blockSuspiciousSessions)
1364
- }
1365
- ) }),
1366
- /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, alignItems: "center", style: { textAlign: "center" }, children: [
1367
- /* @__PURE__ */ jsx(
1368
- Typography,
1369
- {
1370
- variant: "delta",
1371
- fontWeight: "bold",
1372
- textColor: settings.blockSuspiciousSessions ? "success700" : "neutral800",
1373
- style: { fontSize: "16px" },
1374
- children: t("settings.security.blockSuspicious.title", "Block Suspicious Sessions")
1375
- }
1376
- ),
1377
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "13px", lineHeight: "1.6" }, children: t("settings.security.blockSuspicious.description", "Automatically block sessions from VPNs, proxies, or threat IPs") })
1378
- ] })
1379
- ] })
1380
- }
1381
- ) }),
1382
- /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsx(
1383
- ToggleCard,
1384
- {
1385
- $active: settings.enableGeolocation,
1386
- onClick: () => handleChange("enableGeolocation", !settings.enableGeolocation),
1387
- children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, style: { width: "100%" }, alignItems: "center", children: [
1388
- /* @__PURE__ */ jsx(GreenToggle, { $isActive: settings.enableGeolocation, children: /* @__PURE__ */ jsx(
1389
- Toggle,
1390
- {
1391
- checked: settings.enableGeolocation,
1392
- onChange: () => handleChange("enableGeolocation", !settings.enableGeolocation)
1393
- }
1394
- ) }),
1395
- /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, alignItems: "center", style: { textAlign: "center" }, children: [
1396
- /* @__PURE__ */ jsx(
1397
- Typography,
1398
- {
1399
- variant: "delta",
1400
- fontWeight: "bold",
1401
- textColor: settings.enableGeolocation ? "success700" : "neutral800",
1402
- style: { fontSize: "16px" },
1403
- children: t("settings.security.geolocation.title", "IP Geolocation")
1404
- }
1405
- ),
1406
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "13px", lineHeight: "1.6" }, children: t("settings.security.geolocation.description", "Fetch location data for each session") })
1407
- ] })
1408
- ] })
1409
- }
1410
- ) }),
1411
- /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsx(
1412
- ToggleCard,
1413
- {
1414
- $active: settings.enableSecurityScoring,
1415
- onClick: () => handleChange("enableSecurityScoring", !settings.enableSecurityScoring),
1416
- children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, style: { width: "100%" }, alignItems: "center", children: [
1417
- /* @__PURE__ */ jsx(GreenToggle, { $isActive: settings.enableSecurityScoring, children: /* @__PURE__ */ jsx(
1418
- Toggle,
1419
- {
1420
- checked: settings.enableSecurityScoring,
1421
- onChange: () => handleChange("enableSecurityScoring", !settings.enableSecurityScoring)
1422
- }
1423
- ) }),
1424
- /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, alignItems: "center", style: { textAlign: "center" }, children: [
1425
- /* @__PURE__ */ jsx(
1426
- Typography,
1427
- {
1428
- variant: "delta",
1429
- fontWeight: "bold",
1430
- textColor: settings.enableSecurityScoring ? "success700" : "neutral800",
1431
- style: { fontSize: "16px" },
1432
- children: t("settings.security.scoring.title", "Security Scoring")
1433
- }
1434
- ),
1435
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "13px", lineHeight: "1.6" }, children: t("settings.security.scoring.description", "Calculate security scores and detect threats") })
1436
- ] })
1437
- ] })
1438
- }
1439
- ) })
1440
- ] }) }),
1441
- /* @__PURE__ */ jsx(Grid.Root, { gap: 6, children: /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
1442
- /* @__PURE__ */ jsxs(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: [
1443
- "🚫 ",
1444
- t("settings.security.maxFailed.title", "Max Failed Login Attempts")
1445
- ] }),
1446
- /* @__PURE__ */ jsx(
1447
- NumberInput,
1448
- {
1449
- value: settings.maxFailedLogins,
1450
- onValueChange: (val) => handleChange("maxFailedLogins", val),
1451
- min: 0,
1452
- max: 20
1453
- }
1454
- ),
1455
- /* @__PURE__ */ jsx(Box, { padding: 2, background: "warning50", style: { borderRadius: "4px", marginTop: "8px" }, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "warning700", style: { fontSize: "11px" }, children: Number(settings.maxFailedLogins) === 0 ? t("settings.security.maxFailed.disabled", "Login lockout is disabled") : t("settings.security.maxFailed.hint", "User will be blocked after {count} failed attempts", { count: settings.maxFailedLogins }) }) })
1456
- ] }) }) })
1457
- ] }) })
1458
- ] }),
1459
- /* @__PURE__ */ jsxs(Accordion.Item, { value: "geofencing", children: [
1460
- /* @__PURE__ */ jsx(Accordion.Header, { children: /* @__PURE__ */ jsx(
1461
- Accordion.Trigger,
1462
- {
1463
- icon: Shield,
1464
- description: t("settings.geofencing.description", "Allow or block sign-ins by country"),
1465
- children: t("settings.geofencing.title", "Geofencing")
1466
- }
1467
- ) }),
1468
- /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsx(Box, { padding: 6, children: /* @__PURE__ */ jsx(
1469
- GeofencingPanel,
1470
- {
1471
- settings,
1472
- handleChange,
1473
- t,
1474
- geoIpStatus,
1475
- geoIpCredentials,
1476
- setGeoIpCredentials,
1477
- onSaveGeoIpCredentials: handleSaveGeoIpCredentials,
1478
- onUpdateGeoIp: handleUpdateGeoIpDatabase,
1479
- geoIpUpdating,
1480
- geoIpSavingCredentials,
1481
- hasChanges
1482
- }
1483
- ) }) })
1484
- ] }),
1485
- /* @__PURE__ */ jsxs(Accordion.Item, { value: "email", children: [
1486
- /* @__PURE__ */ jsx(Accordion.Header, { children: /* @__PURE__ */ jsx(
1487
- Accordion.Trigger,
1488
- {
1489
- icon: Mail,
1490
- description: t("settings.email.description", "Email alerts for security events"),
1491
- children: t("settings.email.title", "Email Notifications")
1492
- }
1493
- ) }),
1494
- /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsxs(Box, { padding: 6, children: [
1495
- /* @__PURE__ */ jsxs(Box, { background: "neutral100", padding: 5, style: { borderRadius: theme.borderRadius.md, marginBottom: "32px" }, children: [
1496
- /* @__PURE__ */ jsxs(Typography, { variant: "sigma", fontWeight: "bold", style: { marginBottom: "8px", display: "block", textAlign: "center", color: "var(--colors-neutral700)" }, children: [
1497
- "📧 ",
1498
- t("settings.email.alerts.title", "EMAIL ALERTS")
1499
- ] }),
1500
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { marginBottom: "20px", display: "block", textAlign: "center", fontSize: "12px" }, children: t("settings.email.alerts.subtitle", "Send security alerts to users via email") }),
1501
- /* @__PURE__ */ jsx(Grid.Root, { gap: 4, children: /* @__PURE__ */ jsx(Grid.Item, { col: 12, children: /* @__PURE__ */ jsx(
1502
- ToggleCard,
1503
- {
1504
- $active: settings.enableEmailAlerts,
1505
- onClick: () => handleChange("enableEmailAlerts", !settings.enableEmailAlerts),
1506
- children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, style: { width: "100%" }, alignItems: "center", children: [
1507
- /* @__PURE__ */ jsx(GreenToggle, { $isActive: settings.enableEmailAlerts, children: /* @__PURE__ */ jsx(
1508
- Toggle,
1509
- {
1510
- checked: settings.enableEmailAlerts,
1511
- onChange: () => handleChange("enableEmailAlerts", !settings.enableEmailAlerts)
1512
- }
1513
- ) }),
1514
- /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, alignItems: "center", style: { textAlign: "center" }, children: [
1515
- /* @__PURE__ */ jsx(
1516
- Typography,
1517
- {
1518
- variant: "delta",
1519
- fontWeight: "bold",
1520
- textColor: settings.enableEmailAlerts ? "success700" : "neutral800",
1521
- style: { fontSize: "16px" },
1522
- children: t("settings.email.enable.title", "Enable Email Alerts")
1523
- }
1524
- ),
1525
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "13px", lineHeight: "1.6" }, children: t("settings.email.enable.description", "Send security alerts for suspicious logins, new locations, and VPN/Proxy usage") })
1526
- ] })
1527
- ] })
1528
- }
1529
- ) }) })
1530
- ] }),
1531
- settings.enableEmailAlerts && /* @__PURE__ */ jsxs(Fragment, { children: [
1532
- /* @__PURE__ */ jsxs(Typography, { variant: "sigma", fontWeight: "bold", style: { marginBottom: "16px", display: "block", color: "var(--colors-neutral700)" }, children: [
1533
- "⚙️ ",
1534
- t("settings.email.types.title", "ALERT TYPES")
1535
- ] }),
1536
- /* @__PURE__ */ jsxs(Grid.Root, { gap: 4, style: { marginBottom: "32px" }, children: [
1537
- /* @__PURE__ */ jsx(Grid.Item, { col: 4, s: 12, children: /* @__PURE__ */ jsx(
1538
- Box,
1539
- {
1540
- padding: 4,
1541
- background: settings.alertOnSuspiciousLogin ? "danger50" : "neutral50",
1542
- style: {
1543
- borderRadius: theme.borderRadius.md,
1544
- border: `2px solid ${settings.alertOnSuspiciousLogin ? "rgba(239, 68, 68, 0.4)" : "rgba(128, 128, 128, 0.2)"}`,
1545
- transition: "all 0.2s",
1546
- cursor: "pointer"
1547
- },
1548
- onClick: () => handleChange("alertOnSuspiciousLogin", !settings.alertOnSuspiciousLogin),
1549
- children: /* @__PURE__ */ jsx(
1550
- Checkbox,
1551
- {
1552
- checked: settings.alertOnSuspiciousLogin,
1553
- onChange: () => handleChange("alertOnSuspiciousLogin", !settings.alertOnSuspiciousLogin),
1554
- children: /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", style: { fontSize: "14px" }, children: t("settings.email.types.suspicious", "Suspicious Login") })
1555
- }
1556
- )
1557
- }
1558
- ) }),
1559
- /* @__PURE__ */ jsx(Grid.Item, { col: 4, s: 12, children: /* @__PURE__ */ jsx(
1560
- Box,
1561
- {
1562
- padding: 4,
1563
- background: settings.alertOnNewLocation ? "primary50" : "neutral50",
1564
- style: {
1565
- borderRadius: theme.borderRadius.md,
1566
- border: `2px solid ${settings.alertOnNewLocation ? "rgba(14, 165, 233, 0.3)" : "rgba(128, 128, 128, 0.2)"}`,
1567
- transition: "all 0.2s",
1568
- cursor: "pointer"
1569
- },
1570
- onClick: () => handleChange("alertOnNewLocation", !settings.alertOnNewLocation),
1571
- children: /* @__PURE__ */ jsx(
1572
- Checkbox,
1573
- {
1574
- checked: settings.alertOnNewLocation,
1575
- onChange: () => handleChange("alertOnNewLocation", !settings.alertOnNewLocation),
1576
- children: /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", style: { fontSize: "14px" }, children: t("settings.email.types.newLocation", "New Location") })
1577
- }
1578
- )
1579
- }
1580
- ) }),
1581
- /* @__PURE__ */ jsx(Grid.Item, { col: 4, s: 12, children: /* @__PURE__ */ jsx(
1582
- Box,
1583
- {
1584
- padding: 4,
1585
- background: settings.alertOnVpnProxy ? "warning50" : "neutral50",
1586
- style: {
1587
- borderRadius: theme.borderRadius.md,
1588
- border: `2px solid ${settings.alertOnVpnProxy ? "rgba(234, 179, 8, 0.4)" : "rgba(128, 128, 128, 0.2)"}`,
1589
- transition: "all 0.2s",
1590
- cursor: "pointer"
1591
- },
1592
- onClick: () => handleChange("alertOnVpnProxy", !settings.alertOnVpnProxy),
1593
- children: /* @__PURE__ */ jsx(
1594
- Checkbox,
1595
- {
1596
- checked: settings.alertOnVpnProxy,
1597
- onChange: () => handleChange("alertOnVpnProxy", !settings.alertOnVpnProxy),
1598
- children: /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "semiBold", style: { fontSize: "14px" }, children: t("settings.email.types.vpnProxy", "VPN/Proxy") })
1599
- }
1600
- )
1601
- }
1602
- ) })
1603
- ] }),
1604
- /* @__PURE__ */ jsx(Divider, { style: { marginBottom: "24px" } }),
1605
- /* @__PURE__ */ jsx(Typography, { variant: "sigma", fontWeight: "bold", style: { marginBottom: "8px", display: "block", color: "var(--colors-neutral700)" }, children: t("settings.email.templates.title", "EMAIL TEMPLATES") }),
1606
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { marginBottom: "20px", display: "block", fontSize: "12px" }, children: t("settings.email.templates.subtitle", "Customize email notification templates with dynamic variables") }),
1607
- /* @__PURE__ */ jsxs(Tabs.Root, { value: activeTemplateTab, onValueChange: setActiveTemplateTab, children: [
1608
- /* @__PURE__ */ jsxs(Tabs.List, { "aria-label": "Email Templates", children: [
1609
- /* @__PURE__ */ jsx(Tabs.Trigger, { value: "suspiciousLogin", children: t("settings.email.templates.tab.suspicious", "Suspicious Login") }),
1610
- /* @__PURE__ */ jsx(Tabs.Trigger, { value: "newLocation", children: t("settings.email.templates.tab.newLocation", "New Location") }),
1611
- /* @__PURE__ */ jsx(Tabs.Trigger, { value: "vpnProxy", children: t("settings.email.templates.tab.vpnProxy", "VPN/Proxy") })
1612
- ] }),
1613
- Object.keys(settings.emailTemplates).map((templateKey) => /* @__PURE__ */ jsx(Tabs.Content, { value: templateKey, children: /* @__PURE__ */ jsxs(Box, { paddingTop: 4, children: [
1614
- /* @__PURE__ */ jsxs(Box, { style: { marginBottom: "24px" }, children: [
1615
- /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.email.templates.subject", "Email Subject") }),
1616
- /* @__PURE__ */ jsx(
1617
- TextInput,
1618
- {
1619
- value: settings.emailTemplates[templateKey].subject,
1620
- onChange: (e) => {
1621
- const newTemplates = { ...settings.emailTemplates };
1622
- newTemplates[templateKey].subject = e.target.value;
1623
- handleChange("emailTemplates", newTemplates);
1624
- },
1625
- placeholder: t("settings.email.templates.subjectPlaceholder", "Enter email subject...")
1626
- }
1627
- )
1628
- ] }),
1629
- /* @__PURE__ */ jsx(
1630
- Box,
1631
- {
1632
- padding: 3,
1633
- background: "primary100",
1634
- style: { borderRadius: theme.borderRadius.md, marginBottom: "20px", border: "2px solid rgba(14, 165, 233, 0.3)" },
1635
- children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, children: [
1636
- /* @__PURE__ */ jsxs(Flex, { alignItems: "center", gap: 2, children: [
1637
- /* @__PURE__ */ jsx(Code, { style: { width: "16px", height: "16px", color: "var(--colors-primary600, #0284C7)" } }),
1638
- /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "primary600", children: t("settings.email.templates.variables", "Available Variables (click to copy)") })
1639
- ] }),
1640
- /* @__PURE__ */ jsx(Flex, { gap: 2, wrap: "wrap", children: TEMPLATE_VARIABLES[templateKey].map(({ var: variable, desc }) => /* @__PURE__ */ jsx(
1641
- Button,
1642
- {
1643
- size: "S",
1644
- variant: "tertiary",
1645
- onClick: () => {
1646
- navigator.clipboard.writeText(variable);
1647
- toggleNotification({ type: "success", message: t("notifications.success.variableCopied", "{variable} copied!", { variable }) });
1648
- },
1649
- style: {
1650
- fontFamily: "monospace",
1651
- fontSize: "11px",
1652
- padding: "4px 8px"
1653
- },
1654
- title: desc,
1655
- children: variable
1656
- },
1657
- variable
1658
- )) })
1659
- ] })
1660
- }
1661
- ),
1662
- /* @__PURE__ */ jsxs(
1663
- Box,
1664
- {
1665
- background: "neutral0",
1666
- padding: 6,
1667
- style: { borderRadius: theme.borderRadius.lg, border: "2px solid rgba(128, 128, 128, 0.2)", width: "100%", marginBottom: "24px" },
1668
- children: [
1669
- /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", style: { marginBottom: "16px" }, children: [
1670
- /* @__PURE__ */ jsxs(Flex, { alignItems: "center", gap: 2, children: [
1671
- /* @__PURE__ */ jsxs(Typography, { variant: "delta", fontWeight: "bold", style: { fontSize: "18px" }, children: [
1672
- "🎨 ",
1673
- t("settings.email.templates.html.title", "HTML Template")
1674
- ] }),
1675
- /* @__PURE__ */ jsx(Badge, { variant: "success", children: t("settings.email.templates.html.badge", "Main Template") })
1676
- ] }),
1677
- /* @__PURE__ */ jsx(
1678
- TertiaryButton,
1679
- {
1680
- size: "S",
1681
- onClick: () => {
1682
- const defaultTemplates = getDefaultTemplates();
1683
- const newTemplates = { ...settings.emailTemplates };
1684
- newTemplates[templateKey].html = defaultTemplates[templateKey].html;
1685
- handleChange("emailTemplates", newTemplates);
1686
- toggleNotification({ type: "success", message: t("notifications.success.defaultLoaded", "Default template loaded!") });
1687
- },
1688
- children: t("settings.email.templates.html.loadDefault", "Load Default")
1689
- }
1690
- )
1691
- ] }),
1692
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { marginBottom: "16px", display: "block", fontSize: "14px" }, children: t("settings.email.templates.html.description", "HTML template for email notifications. Use variables like {{user.email}} for dynamic content.") }),
1693
- /* @__PURE__ */ jsxs(
1694
- Box,
1695
- {
1696
- style: {
1697
- border: "2px solid rgba(128, 128, 128, 0.2)",
1698
- borderRadius: "6px",
1699
- overflow: "hidden",
1700
- background: "#1e1e1e",
1701
- height: "500px",
1702
- display: "flex",
1703
- flexDirection: "column"
1704
- },
1705
- children: [
1706
- /* @__PURE__ */ jsx(
1707
- Box,
1708
- {
1709
- padding: 2,
1710
- background: "neutral700",
1711
- style: { borderBottom: "1px solid #333", flexShrink: 0 },
1712
- children: /* @__PURE__ */ jsx(Typography, { variant: "omega", style: { color: "#888", fontSize: "11px", fontFamily: "monospace" }, children: "template.html" })
1713
- }
1714
- ),
1715
- /* @__PURE__ */ jsx(
1716
- "textarea",
1717
- {
1718
- value: settings.emailTemplates[templateKey].html,
1719
- onChange: (e) => {
1720
- const newTemplates = { ...settings.emailTemplates };
1721
- newTemplates[templateKey].html = e.target.value;
1722
- handleChange("emailTemplates", newTemplates);
1723
- },
1724
- style: {
1725
- fontFamily: 'Monaco, Consolas, "Courier New", monospace',
1726
- height: "100%",
1727
- fontSize: "14px",
1728
- lineHeight: "1.8",
1729
- background: "#1e1e1e",
1730
- color: "#d4d4d4",
1731
- border: "none",
1732
- padding: "20px",
1733
- resize: "none",
1734
- width: "100%",
1735
- boxSizing: "border-box",
1736
- outline: "none",
1737
- margin: 0,
1738
- display: "block",
1739
- overflow: "auto"
1740
- },
1741
- placeholder: "Enter HTML template with variables like {{user.email}}..."
1742
- }
1743
- )
1744
- ]
1745
- }
1746
- ),
1747
- /* @__PURE__ */ jsxs(Flex, { gap: 2, style: { marginTop: "12px" }, wrap: "wrap", children: [
1748
- /* @__PURE__ */ jsx(
1749
- CopyButton,
1750
- {
1751
- size: "S",
1752
- onClick: () => {
1753
- navigator.clipboard.writeText(settings.emailTemplates[templateKey].html);
1754
- toggleNotification({ type: "success", message: t("notifications.success.htmlCopied", "HTML template copied!") });
1755
- },
1756
- children: t("settings.email.templates.html.copy", "Copy Template")
1757
- }
1758
- ),
1759
- /* @__PURE__ */ jsx(
1760
- SecondaryButton,
1761
- {
1762
- size: "S",
1763
- onClick: () => {
1764
- const validation = validateTemplate(settings.emailTemplates[templateKey].html, templateKey);
1765
- toggleNotification({
1766
- type: validation.isValid ? "success" : "warning",
1767
- message: validation.isValid ? t("notifications.success.validated", "Template valid! Found {found}/{total} variables.", { found: validation.foundVars.length, total: validation.totalAvailable }) : t("notifications.warning.noVariables", "[WARNING] No variables found. Add at least one variable.")
1768
- });
1769
- },
1770
- children: t("settings.email.templates.html.validate", "Validate")
1771
- }
1772
- ),
1773
- /* @__PURE__ */ jsx(
1774
- TertiaryButton,
1775
- {
1776
- size: "S",
1777
- onClick: () => {
1778
- const lines = settings.emailTemplates[templateKey].html.split("\n").length;
1779
- const chars = settings.emailTemplates[templateKey].html.length;
1780
- toggleNotification({
1781
- type: "info",
1782
- message: t("notifications.info.templateStats", "Template has {lines} lines and {chars} characters", { lines, chars })
1783
- });
1784
- },
1785
- children: t("settings.email.templates.html.info", "Template Info")
1786
- }
1787
- )
1788
- ] })
1789
- ]
1790
- }
1791
- ),
1792
- /* @__PURE__ */ jsxs(
1793
- Box,
1794
- {
1795
- background: "neutral0",
1796
- padding: 6,
1797
- style: { borderRadius: theme.borderRadius.lg, border: "2px solid rgba(128, 128, 128, 0.2)", width: "100%", marginBottom: "24px" },
1798
- children: [
1799
- /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", style: { marginBottom: "16px" }, children: [
1800
- /* @__PURE__ */ jsxs(Flex, { alignItems: "center", gap: 2, children: [
1801
- /* @__PURE__ */ jsxs(Typography, { variant: "delta", fontWeight: "bold", style: { fontSize: "18px" }, children: [
1802
- "📄 ",
1803
- t("settings.email.templates.text.title", "Text Template")
1804
- ] }),
1805
- /* @__PURE__ */ jsx(Badge, { variant: "secondary", children: t("settings.email.templates.text.badge", "Fallback") })
1806
- ] }),
1807
- /* @__PURE__ */ jsx(
1808
- TertiaryButton,
1809
- {
1810
- size: "S",
1811
- onClick: () => {
1812
- const defaultTemplates = getDefaultTemplates();
1813
- const newTemplates = { ...settings.emailTemplates };
1814
- newTemplates[templateKey].text = defaultTemplates[templateKey].text;
1815
- handleChange("emailTemplates", newTemplates);
1816
- toggleNotification({ type: "success", message: t("notifications.success.defaultLoaded", "Default template loaded!") });
1817
- },
1818
- children: t("settings.email.templates.text.loadDefault", "Load Default")
1819
- }
1820
- )
1821
- ] }),
1822
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { marginBottom: "16px", display: "block", fontSize: "14px" }, children: t("settings.email.templates.text.description", "Plain text version (no HTML) as fallback for older email clients") }),
1823
- /* @__PURE__ */ jsxs(
1824
- Box,
1825
- {
1826
- style: {
1827
- border: "2px solid rgba(128, 128, 128, 0.2)",
1828
- borderRadius: "6px",
1829
- overflow: "hidden",
1830
- background: "#1e1e1e",
1831
- height: "300px",
1832
- display: "flex",
1833
- flexDirection: "column"
1834
- },
1835
- children: [
1836
- /* @__PURE__ */ jsx(
1837
- Box,
1838
- {
1839
- padding: 2,
1840
- background: "neutral700",
1841
- style: { borderBottom: "1px solid #333", flexShrink: 0 },
1842
- children: /* @__PURE__ */ jsx(Typography, { variant: "omega", style: { color: "#888", fontSize: "11px", fontFamily: "monospace" }, children: "template.txt" })
1843
- }
1844
- ),
1845
- /* @__PURE__ */ jsx(
1846
- "textarea",
1847
- {
1848
- value: settings.emailTemplates[templateKey].text,
1849
- onChange: (e) => {
1850
- const newTemplates = { ...settings.emailTemplates };
1851
- newTemplates[templateKey].text = e.target.value;
1852
- handleChange("emailTemplates", newTemplates);
1853
- },
1854
- style: {
1855
- fontFamily: 'Monaco, Consolas, "Courier New", monospace',
1856
- height: "100%",
1857
- fontSize: "14px",
1858
- lineHeight: "1.8",
1859
- background: "#1e1e1e",
1860
- color: "#d4d4d4",
1861
- border: "none",
1862
- padding: "20px",
1863
- resize: "none",
1864
- width: "100%",
1865
- boxSizing: "border-box",
1866
- outline: "none",
1867
- margin: 0,
1868
- display: "block",
1869
- overflow: "auto"
1870
- },
1871
- placeholder: "Plain text version (no HTML)..."
1872
- }
1873
- )
1874
- ]
1875
- }
1876
- ),
1877
- /* @__PURE__ */ jsx(Flex, { gap: 2, style: { marginTop: "12px" }, wrap: "wrap", children: /* @__PURE__ */ jsx(
1878
- CopyButton,
1879
- {
1880
- size: "S",
1881
- onClick: () => {
1882
- navigator.clipboard.writeText(settings.emailTemplates[templateKey].text);
1883
- toggleNotification({ type: "success", message: t("notifications.success.textCopied", "Text template copied!") });
1884
- },
1885
- children: t("settings.email.templates.text.copy", "Copy Template")
1886
- }
1887
- ) })
1888
- ]
1889
- }
1890
- )
1891
- ] }) }, templateKey))
1892
- ] })
1893
- ] })
1894
- ] }) })
1895
- ] }),
1896
- /* @__PURE__ */ jsxs(Accordion.Item, { value: "webhooks", children: [
1897
- /* @__PURE__ */ jsx(Accordion.Header, { children: /* @__PURE__ */ jsx(
1898
- Accordion.Trigger,
1899
- {
1900
- icon: Code,
1901
- description: t("settings.webhooks.description", "Discord & Slack integration"),
1902
- children: t("settings.webhooks.title", "Webhook Integration")
1903
- }
1904
- ) }),
1905
- /* @__PURE__ */ jsx(Accordion.Content, { children: /* @__PURE__ */ jsxs(Box, { padding: 6, children: [
1906
- /* @__PURE__ */ jsx(Box, { background: "neutral100", padding: 5, style: { borderRadius: theme.borderRadius.md, marginBottom: "32px" }, children: /* @__PURE__ */ jsx(Grid.Root, { gap: 4, children: /* @__PURE__ */ jsx(Grid.Item, { col: 12, children: /* @__PURE__ */ jsx(
1907
- ToggleCard,
1908
- {
1909
- $active: settings.enableWebhooks,
1910
- onClick: () => handleChange("enableWebhooks", !settings.enableWebhooks),
1911
- children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 3, style: { width: "100%" }, alignItems: "center", children: [
1912
- /* @__PURE__ */ jsx(GreenToggle, { $isActive: settings.enableWebhooks, children: /* @__PURE__ */ jsx(
1913
- Toggle,
1914
- {
1915
- checked: settings.enableWebhooks,
1916
- onChange: () => handleChange("enableWebhooks", !settings.enableWebhooks)
1917
- }
1918
- ) }),
1919
- /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 2, alignItems: "center", style: { textAlign: "center" }, children: [
1920
- /* @__PURE__ */ jsx(
1921
- Typography,
1922
- {
1923
- variant: "delta",
1924
- fontWeight: "bold",
1925
- textColor: settings.enableWebhooks ? "success700" : "neutral800",
1926
- style: { fontSize: "16px" },
1927
- children: t("settings.webhooks.enable.title", "Enable Webhooks")
1928
- }
1929
- ),
1930
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "13px", lineHeight: "1.6" }, children: t("settings.webhooks.enable.description", "Send session events to Discord, Slack, or custom endpoints") })
1931
- ] })
1932
- ] })
1933
- }
1934
- ) }) }) }),
1935
- settings.enableWebhooks && /* @__PURE__ */ jsxs(Grid.Root, { gap: 6, children: [
1936
- /* @__PURE__ */ jsx(Grid.Item, { col: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
1937
- /* @__PURE__ */ jsxs(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "12px", display: "block" }, children: [
1938
- "🔗 ",
1939
- t("settings.webhooks.discord.title", "Discord Webhook URL")
1940
- ] }),
1941
- /* @__PURE__ */ jsx(
1942
- Box,
1943
- {
1944
- style: {
1945
- border: "2px solid rgba(128, 128, 128, 0.2)",
1946
- borderRadius: theme.borderRadius.md,
1947
- overflow: "hidden",
1948
- background: "var(--colors-neutral100)"
1949
- },
1950
- children: /* @__PURE__ */ jsx(
1951
- "textarea",
1952
- {
1953
- placeholder: t("settings.webhooks.discord.placeholder", "https://discord.com/api/webhooks/123456789/abcdefghijklmnopqrstuvwxyz..."),
1954
- value: settings.discordWebhookUrl,
1955
- onChange: (e) => handleChange("discordWebhookUrl", e.target.value),
1956
- rows: 3,
1957
- style: {
1958
- width: "100%",
1959
- padding: "14px 18px",
1960
- border: "none",
1961
- outline: "none",
1962
- fontFamily: "Monaco, Consolas, monospace",
1963
- fontSize: "14px",
1964
- lineHeight: "1.8",
1965
- color: "var(--colors-neutral800)",
1966
- background: "transparent",
1967
- resize: "vertical",
1968
- minHeight: "80px"
1969
- }
1970
- }
1971
- )
1972
- }
1973
- ),
1974
- /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", style: { marginTop: "10px" }, children: [
1975
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "12px" }, children: t("settings.webhooks.discord.hint", "Optional: Post session alerts to your Discord channel") }),
1976
- settings.discordWebhookUrl && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "primary600", style: { fontSize: "11px", fontFamily: "monospace" }, children: t("settings.webhooks.characters", "{count} characters", { count: settings.discordWebhookUrl.length }) })
1977
- ] })
1978
- ] }) }),
1979
- /* @__PURE__ */ jsx(Grid.Item, { col: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
1980
- /* @__PURE__ */ jsxs(Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "12px", display: "block" }, children: [
1981
- "💬 ",
1982
- t("settings.webhooks.slack.title", "Slack Webhook URL")
1983
- ] }),
1984
- /* @__PURE__ */ jsx(
1985
- Box,
1986
- {
1987
- style: {
1988
- border: "2px solid rgba(128, 128, 128, 0.2)",
1989
- borderRadius: theme.borderRadius.md,
1990
- overflow: "hidden",
1991
- background: "var(--colors-neutral100)"
1992
- },
1993
- children: /* @__PURE__ */ jsx(
1994
- "textarea",
1995
- {
1996
- placeholder: t("settings.webhooks.slack.placeholder", "https://hooks.slack.com/services/XXXX/XXXX/XXXX"),
1997
- value: settings.slackWebhookUrl,
1998
- onChange: (e) => handleChange("slackWebhookUrl", e.target.value),
1999
- rows: 3,
2000
- style: {
2001
- width: "100%",
2002
- padding: "14px 18px",
2003
- border: "none",
2004
- outline: "none",
2005
- fontFamily: "Monaco, Consolas, monospace",
2006
- fontSize: "14px",
2007
- lineHeight: "1.8",
2008
- color: "var(--colors-neutral800)",
2009
- background: "transparent",
2010
- resize: "vertical",
2011
- minHeight: "80px"
2012
- }
2013
- }
2014
- )
2015
- }
2016
- ),
2017
- /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", style: { marginTop: "10px" }, children: [
2018
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "12px" }, children: t("settings.webhooks.slack.hint", "Optional: Post session alerts to your Slack workspace") }),
2019
- settings.slackWebhookUrl && /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "primary600", style: { fontSize: "11px", fontFamily: "monospace" }, children: t("settings.webhooks.characters", "{count} characters", { count: settings.slackWebhookUrl.length }) })
2020
- ] })
2021
- ] }) })
2022
- ] })
2023
- ] }) })
2024
- ] })
2025
- ] }),
2026
- /* @__PURE__ */ jsx(Box, { padding: 5, background: "primary100", style: { borderRadius: theme.borderRadius.md, marginTop: "32px", border: "2px solid rgba(14, 165, 233, 0.3)" }, children: /* @__PURE__ */ jsxs(Flex, { gap: 3, alignItems: "flex-start", children: [
2027
- /* @__PURE__ */ jsx(Check, { style: { width: "20px", height: "20px", color: "var(--colors-success600, #16A34A)", flexShrink: 0, marginTop: "2px" } }),
2028
- /* @__PURE__ */ jsxs(Box, { style: { flex: 1 }, children: [
2029
- /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", style: { marginBottom: "8px", display: "block", color: "var(--colors-primary600, #075985)" }, children: t("settings.footer.title", "Database-Backed Settings") }),
2030
- /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "primary700", style: { fontSize: "13px", lineHeight: "1.8" }, children: t("settings.footer.description", "All settings are stored in your Strapi database and shared across all admin users. Changes take effect immediately - no server restart required! Email templates, webhooks, and security options are all managed from this interface.") })
2031
- ] })
2032
- ] }) })
2033
- ] })
2034
- ] });
2035
- };
2036
- export {
2037
- SettingsPage as default
2038
- };