strapi-plugin-magic-sessionmanager 4.7.1 → 4.8.0

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