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