strapi-plugin-magic-sessionmanager 4.8.0 → 4.9.1

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