strapi-plugin-magic-sessionmanager 4.18.0 → 4.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +37 -35
  3. package/dist/admin/{Analytics-C8fV6LDV.js → Analytics-BElmzyNJ.js} +1 -1
  4. package/dist/admin/{Analytics-CBspdl1I.mjs → Analytics-BqFlgLnN.mjs} +1 -1
  5. package/dist/admin/{App-PLwqaRSQ.mjs → App-0thsC_P9.mjs} +1188 -170
  6. package/dist/admin/{App-D92MTQmn.js → App-D_J2eeEG.js} +1216 -198
  7. package/dist/admin/{OnlineUsersWidget-CwfBJdIX.mjs → OnlineUsersWidget-BgJ1ws-5.mjs} +1 -1
  8. package/dist/admin/{OnlineUsersWidget-CiKapC1B.js → OnlineUsersWidget-DMZBwqdY.js} +1 -1
  9. package/dist/admin/{Settings-Duil_4jv.js → Settings-FOkui_ke.js} +40 -270
  10. package/dist/admin/{Settings-CMgL-Aub.mjs → Settings-QN3Mu4AQ.mjs} +2 -232
  11. package/dist/admin/{de-CnInuvMY.js → de-CEyi4lpp.js} +66 -4
  12. package/dist/admin/{de-D2BqfY1f.mjs → de-uGKSKVYD.mjs} +66 -4
  13. package/dist/admin/{en-KnmmYHTF.js → en-CSXeJYKy.js} +66 -4
  14. package/dist/admin/{en-BPy208we.mjs → en-Yu7tfwqx.mjs} +66 -4
  15. package/dist/admin/{es-D1NGCAJK.js → es-BrKqXhAU.js} +66 -4
  16. package/dist/admin/{es-B4VNeT0A.mjs → es-iNG9Amf9.mjs} +66 -4
  17. package/dist/admin/{fr-AwhLN1BC.mjs → fr-CaFICHlf.mjs} +66 -4
  18. package/dist/admin/{fr-D1KNyogi.js → fr-DKZNfdlH.js} +66 -4
  19. package/dist/admin/{index-Bnt0Jq6O.js → index-DEYtqPc3.js} +9 -9
  20. package/dist/admin/{index-BmnC2BPs.mjs → index-h-ksmM8A.mjs} +9 -9
  21. package/dist/admin/index.js +1 -1
  22. package/dist/admin/index.mjs +1 -1
  23. package/dist/admin/{pt-D6m1TijL.mjs → pt-Bz2hWVrq.mjs} +66 -4
  24. package/dist/admin/{pt-EKThRXPY.js → pt-IEagyVDL.js} +66 -4
  25. package/dist/admin/settingsTabs-D02CuEvs.mjs +433 -0
  26. package/dist/admin/settingsTabs-N4TFn-mw.js +432 -0
  27. package/dist/server/index.js +41 -8
  28. package/dist/server/index.mjs +41 -8
  29. package/package.json +1 -1
  30. package/dist/admin/dashboardModel-BhUonEqc.mjs +0 -189
  31. package/dist/admin/dashboardModel-sksvIc1c.js +0 -188
@@ -6,7 +6,7 @@ import { Flex, Loader, Button, Box, Typography } from "@strapi/design-system";
6
6
  import { User, Lightning, Clock, Lock, WarningCircle } from "@strapi/icons";
7
7
  import * as StrapiAdmin from "@strapi/strapi/admin";
8
8
  import { useFetchClient } from "@strapi/strapi/admin";
9
- import { l as logSafeAdminError, n as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-BmnC2BPs.mjs";
9
+ import { l as logSafeAdminError, n as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-h-ksmM8A.mjs";
10
10
  function normalizeUserCounts(response) {
11
11
  const totalUsers = response?.data?.totalUsers;
12
12
  const blockedUsers = response?.data?.blockedUsers;
@@ -7,7 +7,7 @@ const styled = require("styled-components");
7
7
  const designSystem = require("@strapi/design-system");
8
8
  const icons = require("@strapi/icons");
9
9
  const StrapiAdmin = require("@strapi/strapi/admin");
10
- const index = require("./index-Bnt0Jq6O.js");
10
+ const index = require("./index-DEYtqPc3.js");
11
11
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
12
12
  function _interopNamespace(e) {
13
13
  if (e && e.__esModule) return e;
@@ -6,243 +6,13 @@ const designSystem = require("@strapi/design-system");
6
6
  const StrapiAdmin = require("@strapi/strapi/admin");
7
7
  const icons = require("@strapi/icons");
8
8
  const styled = require("styled-components");
9
- const index = require("./index-Bnt0Jq6O.js");
9
+ const index = require("./index-DEYtqPc3.js");
10
10
  const reactIntl = require("react-intl");
11
+ const settingsTabs = require("./settingsTabs-N4TFn-mw.js");
11
12
  const SectionCard = require("./SectionCard-BlWv8CRt.js");
12
- const dashboardModel = require("./dashboardModel-sksvIc1c.js");
13
13
  const symbols = require("@strapi/icons/symbols");
14
14
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
15
15
  const styled__default = /* @__PURE__ */ _interopDefault(styled);
16
- const SETTINGS_TAB_IDS = Object.freeze([
17
- "sessions",
18
- "login-protection",
19
- "location-data",
20
- "alerts",
21
- "data-retention",
22
- "admin-activity"
23
- ]);
24
- const PERMISSION_GATED_TABS = Object.freeze(["admin-activity"]);
25
- const DEFAULT_SETTINGS_TAB = "sessions";
26
- const SETTINGS_TAB_LABELS = Object.freeze({
27
- sessions: ["settings.config.tab.sessions", "Sessions"],
28
- "login-protection": ["settings.config.tab.loginProtection", "Login protection"],
29
- "location-data": ["settings.config.tab.locationData", "Location data"],
30
- alerts: ["settings.config.tab.alerts", "Alerts"],
31
- "data-retention": ["settings.config.tab.dataRetention", "Data and retention"],
32
- "admin-activity": ["settings.config.tab.adminActivity", "Admin activity"]
33
- });
34
- const SETTINGS_TAB_FIELDS = Object.freeze({
35
- sessions: [
36
- "inactivityTimeout",
37
- "maxSessionAgeDays",
38
- "lastSeenRateLimit",
39
- "cleanupInterval",
40
- "cleanupUseDbDirect",
41
- "strictSessionEnforcement",
42
- "sessionCreationGraceMs",
43
- "maxSessionsPerUser",
44
- "sessionLimitPolicy",
45
- "endOtherSessionsOnPasswordChange",
46
- "roleRules"
47
- ],
48
- "login-protection": [
49
- "maxFailedLogins",
50
- "maxFailedLoginsPerAccount",
51
- "lockoutWindowMinutes",
52
- "lockoutDurationMinutes",
53
- "lockoutTrustedAddresses",
54
- "lockoutNotifyUser",
55
- "recordUserSignInEvents",
56
- "impossibleTravelEnabled",
57
- "impossibleTravelSpeedKmh",
58
- "impossibleTravelMinDistanceKm",
59
- "impossibleTravelAction",
60
- "trustedProxies",
61
- "blockSuspiciousSessions",
62
- "geoLookupFailureMode",
63
- "enableGeofencing",
64
- "allowedCountries",
65
- "blockedCountries"
66
- ],
67
- "location-data": [
68
- "enableGeolocation",
69
- "enableSecurityScoring",
70
- "geoIpProvider",
71
- "geoIpDatabasePath"
72
- ],
73
- alerts: [
74
- "enableEmailAlerts",
75
- "alertOnSuspiciousLogin",
76
- "alertOnNewLocation",
77
- "alertOnVpnProxy",
78
- "emailTemplates",
79
- "enableWebhooks",
80
- "discordWebhookUrl",
81
- "slackWebhookUrl",
82
- "alertOnNewDevice",
83
- "alertOnImpossibleTravel",
84
- "webhookEvents",
85
- "genericWebhookEnabled",
86
- "genericWebhookUrl",
87
- "genericWebhookSecret"
88
- ],
89
- "data-retention": ["retentionDays", "sessionIpAnonymize"],
90
- "admin-activity": [
91
- "adminSignInHistory",
92
- "adminContentActivity",
93
- "securityLogStoreIp",
94
- "securityLogAnonymizeIp",
95
- "securityLogGeoLookup",
96
- "securityLogRetentionDays"
97
- ]
98
- });
99
- const PRESERVED_SETTINGS_KEYS = Object.freeze([
100
- "rateLimitWriteMax",
101
- "rateLimitReadMax",
102
- "rateLimitWindowSeconds"
103
- ]);
104
- const SETTINGS_FIELD_LABELS = Object.freeze({
105
- inactivityTimeout: ["settings.config.sessions.inactivity.label", "Inactivity timeout"],
106
- maxSessionAgeDays: ["settings.config.sessions.maxAge.label", "Maximum session age"],
107
- lastSeenRateLimit: [
108
- "settings.config.sessions.lastSeen.label",
109
- 'Update "Last active" at most every'
110
- ],
111
- cleanupInterval: ["settings.config.sessions.idleCheck.label", "Run idle check every"],
112
- cleanupUseDbDirect: ["settings.config.sessions.idleMethod.label", "Idle check method"],
113
- strictSessionEnforcement: ["settings.config.token.check.label", "Strict token check"],
114
- sessionCreationGraceMs: ["settings.config.token.grace.label", "Grace period after sign-in"],
115
- maxFailedLogins: ["settings.config.failed.lockout.label", "Lock an IP address after"],
116
- maxFailedLoginsPerAccount: ["settings.config.failed.account.label", "Lock an account after"],
117
- lockoutWindowMinutes: ["settings.config.failed.window.label", "Count failed sign-ins within"],
118
- lockoutDurationMinutes: ["settings.config.failed.duration.label", "Lock for"],
119
- lockoutTrustedAddresses: ["settings.config.failed.trusted.label", "Trusted addresses"],
120
- lockoutNotifyUser: [
121
- "settings.config.failed.notify.label",
122
- "Email the user when their account is locked"
123
- ],
124
- recordUserSignInEvents: [
125
- "settings.config.failed.record.label",
126
- "Record failed and refused sign-ins"
127
- ],
128
- maxSessionsPerUser: ["settings.config.sessionLimit.max.label", "Open sessions per user"],
129
- sessionLimitPolicy: ["settings.config.sessionLimit.policy.label", "When the limit is reached"],
130
- endOtherSessionsOnPasswordChange: [
131
- "settings.config.passwordChange.label",
132
- "End other sessions after a password change"
133
- ],
134
- roleRules: ["settings.roleRules.title", "Different rules for some roles"],
135
- impossibleTravelEnabled: ["settings.config.travel.enable.label", "Detect impossible travel"],
136
- impossibleTravelSpeedKmh: ["settings.config.travel.speed.label", "Faster than"],
137
- impossibleTravelMinDistanceKm: ["settings.config.travel.distance.label", "Over at least"],
138
- impossibleTravelAction: ["settings.config.travel.action.label", "Then"],
139
- alertOnNewDevice: ["settings.config.email.newDevice.label", "Sign-in from a new device"],
140
- alertOnImpossibleTravel: ["settings.config.email.travel.label", "Impossible travel"],
141
- webhookEvents: ["settings.webhookEvents.title", "Events to send"],
142
- genericWebhookEnabled: ["settings.signedWebhook.enable.label", "Send to the signed webhook"],
143
- genericWebhookUrl: ["settings.signedWebhook.url.label", "Webhook URL"],
144
- genericWebhookSecret: ["settings.signedWebhook.secret.label", "Signing secret"],
145
- sessionIpAnonymize: ["settings.config.privacy.shortIp.label", "Shorten IP addresses of sessions"],
146
- trustedProxies: ["settings.config.clientIp.trustProxy.label", "Trust proxy headers"],
147
- blockSuspiciousSessions: [
148
- "settings.config.suspicious.reject.label",
149
- "Reject suspicious sign-ins"
150
- ],
151
- geoLookupFailureMode: [
152
- "settings.config.suspicious.failureMode.label",
153
- "If the location cannot be determined"
154
- ],
155
- enableGeofencing: ["settings.config.countries.enable.label", "Use country rules"],
156
- allowedCountries: ["settings.config.countries.list.label", "Countries"],
157
- blockedCountries: ["settings.config.countries.list.label", "Countries"],
158
- enableGeolocation: ["settings.config.lookup.enable.label", "IP location lookup"],
159
- enableSecurityScoring: ["settings.config.lookup.scoring.label", "Security scoring"],
160
- geoIpProvider: ["settings.config.provider.label", "Provider"],
161
- geoIpDatabasePath: ["settings.config.database.fileName.label", "Database file name"],
162
- enableEmailAlerts: ["settings.config.email.enable.label", "Send security emails"],
163
- alertOnSuspiciousLogin: ["settings.config.email.suspicious.label", "Suspicious sign-in"],
164
- alertOnNewLocation: ["settings.config.email.newCountry.label", "Sign-in from a new country"],
165
- alertOnVpnProxy: ["settings.config.email.vpnProxy.label", "VPN or proxy"],
166
- emailTemplates: ["settings.config.email.templates.field", "Email templates"],
167
- enableWebhooks: ["settings.config.webhooks.enable.label", "Send team notifications"],
168
- discordWebhookUrl: ["settings.config.webhooks.discord.label", "Discord webhook URL"],
169
- slackWebhookUrl: ["settings.config.webhooks.slack.label", "Slack webhook URL"],
170
- retentionDays: ["settings.config.retention.keep.label", "Keep ended sessions for"],
171
- adminSignInHistory: ["settings.config.adminActivity.signIns.label", "Record admin sign-ins"],
172
- adminContentActivity: [
173
- "settings.config.adminActivity.content.label",
174
- "Record Content Manager activity"
175
- ],
176
- securityLogStoreIp: ["settings.config.adminActivity.storeIp.label", "Store IP addresses"],
177
- securityLogAnonymizeIp: [
178
- "settings.config.adminActivity.anonymize.label",
179
- "Anonymise the last part of IP addresses"
180
- ],
181
- securityLogGeoLookup: [
182
- "settings.config.adminActivity.geoLookup.label",
183
- "Look up the location of security events"
184
- ],
185
- securityLogRetentionDays: [
186
- "settings.config.adminActivity.retention.label",
187
- "Keep security events for"
188
- ]
189
- });
190
- const SELECT_PRESETS = Object.freeze({
191
- inactivityTimeout: Object.freeze([5, 10, 15, 30, 60, 120]),
192
- maxSessionAgeDays: Object.freeze([1, 7, 14, 30, 60, 90, 180, 365]),
193
- lastSeenRateLimit: Object.freeze([10, 30, 60, 120, 300]),
194
- cleanupInterval: Object.freeze([15, 30, 60, 120]),
195
- sessionCreationGraceMs: Object.freeze([0, 2e3, 5e3, 1e4, 3e4]),
196
- retentionDays: Object.freeze([7, 30, 60, 90, 180, 365, -1]),
197
- securityLogRetentionDays: Object.freeze([7, 30, 90, 180, 365])
198
- });
199
- function resolveSettingsTab(value, tabs = SETTINGS_TAB_IDS) {
200
- const candidate = Array.isArray(value) ? value[0] : value;
201
- return tabs.includes(candidate) ? candidate : DEFAULT_SETTINGS_TAB;
202
- }
203
- function getVisibleSettingsTabs(canViewAdminActivity) {
204
- return SETTINGS_TAB_IDS.filter(
205
- (tab) => canViewAdminActivity || !PERMISSION_GATED_TABS.includes(tab)
206
- );
207
- }
208
- function buildTabSearch(search, tab) {
209
- const params = new URLSearchParams(typeof search === "string" ? search : "");
210
- params.set("tab", resolveSettingsTab(tab));
211
- return `?${params.toString()}`;
212
- }
213
- function fieldHasError(errors, field) {
214
- return Object.keys(errors || {}).some((path) => path === field || path.startsWith(`${field}.`));
215
- }
216
- function tabHasFieldErrors(errors, tab) {
217
- return (SETTINGS_TAB_FIELDS[tab] || []).some((field) => fieldHasError(errors, field));
218
- }
219
- function getErrorTab(errors) {
220
- return SETTINGS_TAB_IDS.find((tab) => tabHasFieldErrors(errors, tab));
221
- }
222
- function buildSelectOptions(presets, current) {
223
- const options = presets.map((value) => ({ value, custom: false }));
224
- const number = typeof current === "number" ? current : Number.parseInt(String(current ?? ""), 10);
225
- if (Number.isInteger(number) && !presets.includes(number)) {
226
- options.push({ value: number, custom: true });
227
- }
228
- return options;
229
- }
230
- function buildSavePayload(draft, saved) {
231
- const payload = { ...draft || {} };
232
- for (const key of PRESERVED_SETTINGS_KEYS) {
233
- if (saved && Object.prototype.hasOwnProperty.call(saved, key)) payload[key] = saved[key];
234
- }
235
- return payload;
236
- }
237
- function usesLocalDatabase(provider) {
238
- return provider === void 0 || provider === null || provider === "" || provider === "auto" || provider === "local-mmdb";
239
- }
240
- function getRevealScrollDelta(listRect, tabRect) {
241
- if (!listRect || !tabRect) return 0;
242
- if (tabRect.left < listRect.left - 0.5) return Math.round(tabRect.left - listRect.left);
243
- if (tabRect.right > listRect.right + 0.5) return Math.round(tabRect.right - listRect.right);
244
- return 0;
245
- }
246
16
  const FieldFrame = styled__default.default.div`
247
17
  width: 100%;
248
18
  min-width: 0;
@@ -647,7 +417,7 @@ const SettingsTabLink = ({ tab, children }) => {
647
417
  return /* @__PURE__ */ jsxRuntime.jsx(
648
418
  TabLink,
649
419
  {
650
- href: buildTabSearch(search, tab),
420
+ href: settingsTabs.buildTabSearch(search, tab),
651
421
  onClick: (event) => {
652
422
  if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0)
653
423
  return;
@@ -730,7 +500,7 @@ const PresetSelect = ({
730
500
  disabled = false
731
501
  }) => {
732
502
  const { custom } = useOptionLabels();
733
- const options = buildSelectOptions(presets, value);
503
+ const options = settingsTabs.buildSelectOptions(presets, value);
734
504
  return /* @__PURE__ */ jsxRuntime.jsx(FormField, { id, name, label, description, error, children: /* @__PURE__ */ jsxRuntime.jsx(
735
505
  designSystem.SingleSelect,
736
506
  {
@@ -926,7 +696,7 @@ function sortLocks(locks) {
926
696
  }
927
697
  const TABLE_MIN_WIDTH$1 = 640;
928
698
  const keepActionKeys$1 = (event) => {
929
- if (dashboardModel.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
699
+ if (settingsTabs.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
930
700
  };
931
701
  const EMPTY_DRAFT = Object.freeze({
932
702
  role: "",
@@ -954,7 +724,7 @@ const RoleRulesSection = ({ form }) => {
954
724
  const [showErrors, setShowErrors] = react.useState(false);
955
725
  const addRef = react.useRef(null);
956
726
  const returnFocusRef = react.useRef(null);
957
- const [widthRef, width] = dashboardModel.useElementWidth();
727
+ const [widthRef, width] = settingsTabs.useElementWidth();
958
728
  react.useEffect(() => {
959
729
  let active = true;
960
730
  get(`/${index.pluginId}/roles`).then(({ data }) => {
@@ -1015,7 +785,7 @@ const RoleRulesSection = ({ form }) => {
1015
785
  const asTable = width === 0 || width >= TABLE_MIN_WIDTH$1;
1016
786
  const actions = (rule) => {
1017
787
  const name = roleName(rule.role);
1018
- return /* @__PURE__ */ jsxRuntime.jsxs(dashboardModel.RowActions, { onKeyDown: keepActionKeys$1, children: [
788
+ return /* @__PURE__ */ jsxRuntime.jsxs(settingsTabs.RowActions, { onKeyDown: keepActionKeys$1, children: [
1019
789
  /* @__PURE__ */ jsxRuntime.jsx(
1020
790
  designSystem.IconButton,
1021
791
  {
@@ -1286,7 +1056,7 @@ const SessionsTab = ({ form }) => {
1286
1056
  "A session unused for this long becomes idle and ends as 'Timed out' on its next request or at the next idle check. Also decides who counts as online."
1287
1057
  ),
1288
1058
  value: settings.inactivityTimeout,
1289
- presets: SELECT_PRESETS.inactivityTimeout,
1059
+ presets: settingsTabs.SELECT_PRESETS.inactivityTimeout,
1290
1060
  format: units.minutes,
1291
1061
  onChange: (value) => handleChange("inactivityTimeout", value)
1292
1062
  }
@@ -1302,7 +1072,7 @@ const SessionsTab = ({ form }) => {
1302
1072
  "Counted from sign-in, regardless of activity. Applied on the session's next request; until then the session can still show as active or idle."
1303
1073
  ),
1304
1074
  value: settings.maxSessionAgeDays,
1305
- presets: SELECT_PRESETS.maxSessionAgeDays,
1075
+ presets: settingsTabs.SELECT_PRESETS.maxSessionAgeDays,
1306
1076
  format: units.days,
1307
1077
  onChange: (value) => handleChange("maxSessionAgeDays", value)
1308
1078
  }
@@ -1324,7 +1094,7 @@ const SessionsTab = ({ form }) => {
1324
1094
  "Lower values make 'Last active' and idle detection more precise but write to the database more often."
1325
1095
  ),
1326
1096
  value: settings.lastSeenRateLimit,
1327
- presets: SELECT_PRESETS.lastSeenRateLimit,
1097
+ presets: settingsTabs.SELECT_PRESETS.lastSeenRateLimit,
1328
1098
  format: units.seconds,
1329
1099
  onChange: (value) => handleChange("lastSeenRateLimit", value)
1330
1100
  }
@@ -1345,7 +1115,7 @@ const SessionsTab = ({ form }) => {
1345
1115
  "The idle check ends idle sessions as 'Timed out'. It deletes nothing. It also runs once at server start."
1346
1116
  ),
1347
1117
  value: settings.cleanupInterval,
1348
- presets: SELECT_PRESETS.cleanupInterval,
1118
+ presets: settingsTabs.SELECT_PRESETS.cleanupInterval,
1349
1119
  format: units.minutes,
1350
1120
  onChange: (value) => handleChange("cleanupInterval", value)
1351
1121
  }
@@ -1432,7 +1202,7 @@ const SessionsTab = ({ form }) => {
1432
1202
  "Accepts a new token for a few seconds while its session record is being created. Only for tokens without a session record. Not used when Strapi's refresh-token mode (jwtManagement: 'refresh') is on."
1433
1203
  ),
1434
1204
  value: settings.sessionCreationGraceMs ?? 5e3,
1435
- presets: SELECT_PRESETS.sessionCreationGraceMs,
1205
+ presets: settingsTabs.SELECT_PRESETS.sessionCreationGraceMs,
1436
1206
  format: units.graceMs,
1437
1207
  onChange: (value) => handleChange("sessionCreationGraceMs", value)
1438
1208
  }
@@ -2471,7 +2241,7 @@ function getAdjustedFields(submitted, stored, previous) {
2471
2241
  }
2472
2242
  const TABLE_MIN_WIDTH = 640;
2473
2243
  const keepActionKeys = (event) => {
2474
- if (dashboardModel.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
2244
+ if (settingsTabs.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
2475
2245
  };
2476
2246
  const LockTarget = ({ lock }) => {
2477
2247
  const { t } = useSettingsTranslate();
@@ -2533,7 +2303,7 @@ const LockedNowCard = () => {
2533
2303
  isLoading: permissionsLoading,
2534
2304
  allowedActions: { canUnlock }
2535
2305
  } = StrapiAdmin.useRBAC(index.pluginPermissions.lockoutsUnlock);
2536
- const [widthRef, width] = dashboardModel.useElementWidth();
2306
+ const [widthRef, width] = settingsTabs.useElementWidth();
2537
2307
  const [locks, setLocks] = react.useState(null);
2538
2308
  const [error, setError] = react.useState(false);
2539
2309
  const [refreshing, setRefreshing] = react.useState(false);
@@ -2657,7 +2427,7 @@ const LockedNowCard = () => {
2657
2427
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(KindBadge, { kind: lock.kind }) }),
2658
2428
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: lock.failures }) }),
2659
2429
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: ends(lock) }),
2660
- showActions ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(dashboardModel.RowActions, { onKeyDown: keepActionKeys, children: unlockAction(lock) }) }) : null
2430
+ showActions ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(settingsTabs.RowActions, { onKeyDown: keepActionKeys, children: unlockAction(lock) }) }) : null
2661
2431
  ] }, lock.id)) })
2662
2432
  ] }) });
2663
2433
  } else {
@@ -2680,7 +2450,7 @@ const LockedNowCard = () => {
2680
2450
  }) })
2681
2451
  ] })
2682
2452
  ] }),
2683
- /* @__PURE__ */ jsxRuntime.jsx(dashboardModel.RowActions, { onKeyDown: keepActionKeys, children: unlockAction(lock) })
2453
+ /* @__PURE__ */ jsxRuntime.jsx(settingsTabs.RowActions, { onKeyDown: keepActionKeys, children: unlockAction(lock) })
2684
2454
  ] })
2685
2455
  },
2686
2456
  lock.id
@@ -2852,7 +2622,7 @@ const ImpossibleTravelCard = ({ form }) => {
2852
2622
  /* @__PURE__ */ jsxRuntime.jsx(
2853
2623
  AdvancedSection,
2854
2624
  {
2855
- hasError: fieldHasError(errors, "impossibleTravelSpeedKmh") || fieldHasError(errors, "impossibleTravelMinDistanceKm"),
2625
+ hasError: settingsTabs.fieldHasError(errors, "impossibleTravelSpeedKmh") || settingsTabs.fieldHasError(errors, "impossibleTravelMinDistanceKm"),
2856
2626
  disabled: !enabled,
2857
2627
  children: /* @__PURE__ */ jsxRuntime.jsxs(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: [
2858
2628
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -3357,8 +3127,8 @@ const LoginProtectionTab = ({ form }) => {
3357
3127
  const lookupOff = !settings.enableGeolocation;
3358
3128
  const locked = form.canChangeProtected === false;
3359
3129
  const policyLocked = locked;
3360
- const risk = dashboardModel.getRiskAvailability(form.geoIp.status);
3361
- const reject = dashboardModel.riskDependentControl(settings.blockSuspiciousSessions, risk.state);
3130
+ const risk = settingsTabs.getRiskAvailability(form.geoIp.status);
3131
+ const reject = settingsTabs.riskDependentControl(settings.blockSuspiciousSessions, risk.state);
3362
3132
  const autoStillRejects = reject.savedOnButInactive && (settings.geoLookupFailureMode || "auto") === "auto";
3363
3133
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
3364
3134
  /* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
@@ -3537,7 +3307,7 @@ const LoginProtectionTab = ({ form }) => {
3537
3307
  AdvancedSection,
3538
3308
  {
3539
3309
  label: t("settings.config.failed.trusted.section", "Trusted addresses"),
3540
- hasError: fieldHasError(errors, "lockoutTrustedAddresses"),
3310
+ hasError: settingsTabs.fieldHasError(errors, "lockoutTrustedAddresses"),
3541
3311
  children: /* @__PURE__ */ jsxRuntime.jsx(TrustedAddressesField, { form, disabled: policyLocked })
3542
3312
  }
3543
3313
  )
@@ -3608,7 +3378,7 @@ const LoginProtectionTab = ({ form }) => {
3608
3378
  children: !lookupOff && reject.disabled ? /* @__PURE__ */ jsxRuntime.jsx(RiskSourceNotice, { savedOn: reject.savedOnButInactive }) : null
3609
3379
  }
3610
3380
  ),
3611
- /* @__PURE__ */ jsxRuntime.jsxs(AdvancedSection, { hasError: fieldHasError(errors, "geoLookupFailureMode"), children: [
3381
+ /* @__PURE__ */ jsxRuntime.jsxs(AdvancedSection, { hasError: settingsTabs.fieldHasError(errors, "geoLookupFailureMode"), children: [
3612
3382
  /* @__PURE__ */ jsxRuntime.jsx(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
3613
3383
  FormField,
3614
3384
  {
@@ -3750,7 +3520,7 @@ const GeoIpDatabaseCard = ({ form }) => {
3750
3520
  };
3751
3521
  const lookupOff = !settings.enableGeolocation;
3752
3522
  const locked = form.canChangeProtected === false;
3753
- const localDatabase = usesLocalDatabase(settings.geoIpProvider);
3523
+ const localDatabase = settingsTabs.usesLocalDatabase(settings.geoIpProvider);
3754
3524
  const databaseDisabled = lookupOff || !localDatabase;
3755
3525
  const credentialSource = geoIpStatus?.credentialSource;
3756
3526
  const fromEnvironment = credentialSource === "env";
@@ -3967,7 +3737,7 @@ const GeoIpDatabaseCard = ({ form }) => {
3967
3737
  "Save your changes first, so the download uses the current settings."
3968
3738
  ) }) : null
3969
3739
  ] }),
3970
- /* @__PURE__ */ jsxRuntime.jsx(AdvancedSection, { hasError: fieldHasError(errors, "geoIpDatabasePath"), children: /* @__PURE__ */ jsxRuntime.jsx(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
3740
+ /* @__PURE__ */ jsxRuntime.jsx(AdvancedSection, { hasError: settingsTabs.fieldHasError(errors, "geoIpDatabasePath"), children: /* @__PURE__ */ jsxRuntime.jsx(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
3971
3741
  FormField,
3972
3742
  {
3973
3743
  id: "geoip-database-filename",
@@ -4070,7 +3840,7 @@ const RiskDataCard = ({ form }) => {
4070
3840
  const { t } = useSettingsTranslate();
4071
3841
  const { settings, geoIp } = form;
4072
3842
  const lookupOff = !settings.enableGeolocation;
4073
- const risk = dashboardModel.getRiskAvailability(geoIp.status);
3843
+ const risk = settingsTabs.getRiskAvailability(geoIp.status);
4074
3844
  const sourceLabels = {
4075
3845
  "anonymous-ip": t("settings.config.risk.source.anonymousIp", "Anonymous IP database"),
4076
3846
  "asn-heuristic": t("settings.config.risk.source.asn", "ASN heuristic")
@@ -4137,8 +3907,8 @@ const RiskDataCard = ({ form }) => {
4137
3907
  const LocationDataTab = ({ form }) => {
4138
3908
  const { t } = useSettingsTranslate();
4139
3909
  const { settings, handleChange } = form;
4140
- const risk = dashboardModel.getRiskAvailability(form.geoIp.status);
4141
- const scoring = dashboardModel.riskDependentControl(settings.enableSecurityScoring, risk.state);
3910
+ const risk = settingsTabs.getRiskAvailability(form.geoIp.status);
3911
+ const scoring = settingsTabs.riskDependentControl(settings.enableSecurityScoring, risk.state);
4142
3912
  const locked = form.canChangeProtected === false;
4143
3913
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
4144
3914
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
@@ -4959,8 +4729,8 @@ const AlertsTab = ({ form }) => {
4959
4729
  const emailTypesDisabled = lookupOff || !settings.enableEmailAlerts;
4960
4730
  const webhookFieldsDisabled = lookupOff || !settings.enableWebhooks;
4961
4731
  const locked = form.canChangeProtected === false;
4962
- const templateErrors = fieldHasError(errors, "emailTemplates");
4963
- const risk = dashboardModel.getRiskAvailability(form.geoIp.status);
4732
+ const templateErrors = settingsTabs.fieldHasError(errors, "emailTemplates");
4733
+ const risk = settingsTabs.getRiskAvailability(form.geoIp.status);
4964
4734
  const emailTypes = [
4965
4735
  {
4966
4736
  field: "alertOnSuspiciousLogin",
@@ -5047,7 +4817,7 @@ const AlertsTab = ({ form }) => {
5047
4817
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", tag: "div", textColor: "neutral800", children: t("settings.config.email.types.label", "Send an email for") }),
5048
4818
  !lookupOff && !settings.enableEmailAlerts ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t("settings.config.requires.emailAlerts", "Requires Send security emails") }) : null,
5049
4819
  /* @__PURE__ */ jsxRuntime.jsx(EmailTypeGrid, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: emailTypes.map(({ field, needsRiskData, needsTravel, hintId, label, hint }) => {
5050
- const control = needsRiskData ? dashboardModel.riskDependentControl(settings[field], risk.state) : { checked: settings[field], disabled: false, savedOnButInactive: false };
4820
+ const control = needsRiskData ? settingsTabs.riskDependentControl(settings[field], risk.state) : { checked: settings[field], disabled: false, savedOnButInactive: false };
5051
4821
  const travelOff = needsTravel && settings.impossibleTravelEnabled !== true;
5052
4822
  const disabled = emailTypesDisabled || control.disabled || travelOff;
5053
4823
  return /* @__PURE__ */ jsxRuntime.jsxs(AlertTypeCell, { checked: control.checked, disabled, children: [
@@ -5235,7 +5005,7 @@ const DataRetentionTab = ({ form }) => {
5235
5005
  "Checked once a day, the first time about 24 hours after the server starts. Open sessions are never deleted by retention. 'Forever' keeps them."
5236
5006
  ),
5237
5007
  value: settings.retentionDays,
5238
- presets: SELECT_PRESETS.retentionDays,
5008
+ presets: settingsTabs.SELECT_PRESETS.retentionDays,
5239
5009
  format: units.retentionDays,
5240
5010
  onChange: (value) => handleChange("retentionDays", value)
5241
5011
  }
@@ -5431,7 +5201,7 @@ const AdminActivityTab = ({ form }) => {
5431
5201
  "At least 7 days. Older events are deleted once a day; each deletion is itself recorded. Events of a deleted admin are deleted with the account."
5432
5202
  ),
5433
5203
  value: settings.securityLogRetentionDays,
5434
- presets: SELECT_PRESETS.securityLogRetentionDays,
5204
+ presets: settingsTabs.SELECT_PRESETS.securityLogRetentionDays,
5435
5205
  format: units.days,
5436
5206
  disabled: locked,
5437
5207
  onChange: (value) => handleChange("securityLogRetentionDays", value)
@@ -5486,7 +5256,7 @@ function useSettingsForm() {
5486
5256
  const hasChanges = !areSettingsEqual(settings, savedSettings);
5487
5257
  const errors = react.useMemo(() => validateSettings(settings), [settings]);
5488
5258
  const errorCount = Object.keys(errors).length;
5489
- const errorTab = getErrorTab(errors);
5259
+ const errorTab = settingsTabs.getErrorTab(errors);
5490
5260
  const canSave = hasChanges && errorCount === 0 && !saving;
5491
5261
  const settingsRef = react.useRef(settings);
5492
5262
  const savedSettingsRef = react.useRef(savedSettings);
@@ -5578,7 +5348,7 @@ function useSettingsForm() {
5578
5348
  });
5579
5349
  }, []);
5580
5350
  const handleSave = react.useCallback(async () => {
5581
- const submitted = buildSavePayload(settingsRef.current, savedSettingsRef.current);
5351
+ const submitted = settingsTabs.buildSavePayload(settingsRef.current, savedSettingsRef.current);
5582
5352
  const previous = savedSettingsRef.current;
5583
5353
  if (Object.keys(validateSettings(submitted)).length > 0) return false;
5584
5354
  setSaving(true);
@@ -5598,7 +5368,7 @@ function useSettingsForm() {
5598
5368
  setDraftVersion((version) => version + 1);
5599
5369
  const adjustedNames = [
5600
5370
  ...new Set(
5601
- getAdjustedFields(submitted, stored, previous).map((key) => SETTINGS_FIELD_LABELS[key]).filter(Boolean).map(([id, defaultMessage]) => t(id, defaultMessage))
5371
+ getAdjustedFields(submitted, stored, previous).map((key) => settingsTabs.SETTINGS_FIELD_LABELS[key]).filter(Boolean).map(([id, defaultMessage]) => t(id, defaultMessage))
5602
5372
  )
5603
5373
  ];
5604
5374
  toggleNotification({
@@ -5834,7 +5604,7 @@ const DraftSync = ({ values }) => {
5834
5604
  const writeTabToAddressBar = (tab) => {
5835
5605
  if (typeof window === "undefined" || !window.history?.replaceState) return;
5836
5606
  const { pathname, search, hash } = window.location;
5837
- const nextSearch = buildTabSearch(search, tab);
5607
+ const nextSearch = settingsTabs.buildTabSearch(search, tab);
5838
5608
  if (nextSearch === search) return;
5839
5609
  window.history.replaceState(window.history.state, "", `${pathname}${nextSearch}${hash}`);
5840
5610
  };
@@ -5849,10 +5619,10 @@ const SettingsPage = () => {
5849
5619
  allowedActions: { canUpdate: canChangeProtected }
5850
5620
  } = StrapiAdmin.useRBAC(index.pluginPermissions.settingsUpdate);
5851
5621
  const visibleTabs = react.useMemo(
5852
- () => getVisibleSettingsTabs(Boolean(canViewAdminActivity)),
5622
+ () => settingsTabs.getVisibleSettingsTabs(Boolean(canViewAdminActivity)),
5853
5623
  [canViewAdminActivity]
5854
5624
  );
5855
- const requestedTab = resolveSettingsTab(query?.tab, visibleTabs);
5625
+ const requestedTab = settingsTabs.resolveSettingsTab(query?.tab, visibleTabs);
5856
5626
  const [activeTab, setActiveTab] = react.useState(requestedTab);
5857
5627
  const [followedTab, setFollowedTab] = react.useState(requestedTab);
5858
5628
  const tabsRef = react.useRef(null);
@@ -5864,7 +5634,7 @@ const SettingsPage = () => {
5864
5634
  const list = tabsRef.current?.querySelector('[role="tablist"]');
5865
5635
  const tab = list?.querySelector('[role="tab"][aria-selected="true"]');
5866
5636
  if (!list || !tab) return;
5867
- const delta = getRevealScrollDelta(list.getBoundingClientRect(), tab.getBoundingClientRect());
5637
+ const delta = settingsTabs.getRevealScrollDelta(list.getBoundingClientRect(), tab.getBoundingClientRect());
5868
5638
  if (delta) list.scrollLeft += delta;
5869
5639
  }, [activeTab, form.loading]);
5870
5640
  const focusActiveTab = react.useCallback(() => {
@@ -5881,7 +5651,7 @@ const SettingsPage = () => {
5881
5651
  }, [handleSave, focusActiveTab]);
5882
5652
  const changeTab = react.useCallback(
5883
5653
  (tab) => {
5884
- const next = resolveSettingsTab(tab, visibleTabs);
5654
+ const next = settingsTabs.resolveSettingsTab(tab, visibleTabs);
5885
5655
  setActiveTab(next);
5886
5656
  writeTabToAddressBar(next);
5887
5657
  },
@@ -5971,7 +5741,7 @@ const SettingsPage = () => {
5971
5741
  SettingsTabsList,
5972
5742
  {
5973
5743
  "aria-label": t("settings.config.tabs.label", "Configuration sections"),
5974
- children: visibleTabs.map((tab) => /* @__PURE__ */ jsxRuntime.jsx(SettingsTabTrigger, { value: tab, children: /* @__PURE__ */ jsxRuntime.jsx(SettingsTabLabel, { children: t(SETTINGS_TAB_LABELS[tab][0], SETTINGS_TAB_LABELS[tab][1]) }) }, tab))
5744
+ children: visibleTabs.map((tab) => /* @__PURE__ */ jsxRuntime.jsx(SettingsTabTrigger, { value: tab, children: /* @__PURE__ */ jsxRuntime.jsx(SettingsTabLabel, { children: t(settingsTabs.SETTINGS_TAB_LABELS[tab][0], settingsTabs.SETTINGS_TAB_LABELS[tab][1]) }) }, tab))
5975
5745
  }
5976
5746
  ),
5977
5747
  visibleTabs.map((tab) => {