strapi-plugin-magic-sessionmanager 4.19.1 → 4.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +136 -1
  3. package/dist/admin/{Analytics-BqFlgLnN.mjs → Analytics-B-MVQ6dQ.mjs} +1 -1
  4. package/dist/admin/{Analytics-BElmzyNJ.js → Analytics-B5GnwMtH.js} +1 -1
  5. package/dist/admin/{App-0thsC_P9.mjs → App-DzbP5VPQ.mjs} +2 -2
  6. package/dist/admin/{App-D_J2eeEG.js → App-xBOmg4g9.js} +2 -2
  7. package/dist/admin/{OnlineUsersWidget-BgJ1ws-5.mjs → OnlineUsersWidget-Bf3BICmx.mjs} +1 -1
  8. package/dist/admin/{OnlineUsersWidget-DMZBwqdY.js → OnlineUsersWidget-FuPPPCCV.js} +1 -1
  9. package/dist/admin/{Settings-FOkui_ke.js → Settings-WRIXHLDa.js} +280 -65
  10. package/dist/admin/{Settings-QN3Mu4AQ.mjs → Settings-hpkloyO6.mjs} +250 -35
  11. package/dist/admin/{de-uGKSKVYD.mjs → de-Bzd14FzX.mjs} +63 -1
  12. package/dist/admin/{de-CEyi4lpp.js → de-Uqb30N5n.js} +63 -1
  13. package/dist/admin/{en-CSXeJYKy.js → en-CDBcocLk.js} +63 -1
  14. package/dist/admin/{en-Yu7tfwqx.mjs → en-DovyVwa5.mjs} +63 -1
  15. package/dist/admin/{es-iNG9Amf9.mjs → es-BygJxl1J.mjs} +63 -1
  16. package/dist/admin/{es-BrKqXhAU.js → es-DA1X0RPv.js} +63 -1
  17. package/dist/admin/{fr-DKZNfdlH.js → fr-CPPA27jW.js} +63 -1
  18. package/dist/admin/{fr-CaFICHlf.mjs → fr-DONxL73-.mjs} +63 -1
  19. package/dist/admin/{index-h-ksmM8A.mjs → index-DsaGGK7x.mjs} +627 -61
  20. package/dist/admin/{index-DEYtqPc3.js → index-Q_D-5LlE.js} +612 -46
  21. package/dist/admin/index.js +1 -1
  22. package/dist/admin/index.mjs +2 -2
  23. package/dist/admin/{pt-IEagyVDL.js → pt-BMuwyaan.js} +63 -1
  24. package/dist/admin/{pt-Bz2hWVrq.mjs → pt-D2yGNz2N.mjs} +63 -1
  25. package/dist/admin/{settingsTabs-D02CuEvs.mjs → settingsTabs--7IsqMdn.mjs} +5 -1
  26. package/dist/admin/{settingsTabs-N4TFn-mw.js → settingsTabs-Dxlevody.js} +5 -1
  27. package/dist/server/index.js +1485 -19
  28. package/dist/server/index.mjs +1485 -19
  29. package/package.json +1 -1
@@ -6,9 +6,9 @@ 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-DEYtqPc3.js");
10
- const reactIntl = require("react-intl");
11
- const settingsTabs = require("./settingsTabs-N4TFn-mw.js");
9
+ const index = require("./index-Q_D-5LlE.js");
10
+ require("react-intl");
11
+ const settingsTabs = require("./settingsTabs-Dxlevody.js");
12
12
  const SectionCard = require("./SectionCard-BlWv8CRt.js");
13
13
  const symbols = require("@strapi/icons/symbols");
14
14
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
@@ -290,18 +290,6 @@ const SecretTextInput = ({
290
290
  }
291
291
  );
292
292
  };
293
- function useSettingsTranslate() {
294
- const { formatMessage, locale } = reactIntl.useIntl();
295
- const t = react.useCallback(
296
- (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values),
297
- [formatMessage]
298
- );
299
- const tError = react.useCallback(
300
- (descriptor) => descriptor ? t(descriptor.messageId, descriptor.defaultMessage, descriptor.values) : void 0,
301
- [t]
302
- );
303
- return { t, tError, locale };
304
- }
305
293
  const EnvPreview = styled__default.default(designSystem.Box)`
306
294
  overflow-wrap: anywhere;
307
295
 
@@ -316,7 +304,7 @@ const useEncryptionKeyDraft = () => {
316
304
  return { encryptionKey, setEncryptionKey, showEncryptionKey, setShowEncryptionKey };
317
305
  };
318
306
  const EncryptionKeyCard = ({ draft, copyValue, notify }) => {
319
- const { t } = useSettingsTranslate();
307
+ const { t } = index.useSettingsTranslate();
320
308
  const { encryptionKey, setEncryptionKey, showEncryptionKey, setShowEncryptionKey } = draft;
321
309
  const handleGenerate = () => {
322
310
  try {
@@ -429,7 +417,7 @@ const SettingsTabLink = ({ tab, children }) => {
429
417
  );
430
418
  };
431
419
  function useOptionLabels() {
432
- const { t } = useSettingsTranslate();
420
+ const { t } = index.useSettingsTranslate();
433
421
  return react.useMemo(() => {
434
422
  const minutes = (count) => t("settings.config.unit.minutes", "{count} min", { count });
435
423
  const seconds = (count) => t("settings.config.unit.seconds", "{count} s", { count });
@@ -447,18 +435,18 @@ function useOptionLabels() {
447
435
  const IntroText = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "omega", textColor: "neutral600", tag: "p", children });
448
436
  const RequiresNotice = ({ tab, children }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", tag: "p", "data-requires": "", children: tab ? /* @__PURE__ */ jsxRuntime.jsx(SettingsTabLink, { tab, children }) : children });
449
437
  const ProtectedNotice = () => {
450
- const { t } = useSettingsTranslate();
438
+ const { t } = index.useSettingsTranslate();
451
439
  return /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t(
452
440
  "settings.config.protected.notice",
453
441
  "Read-only for your role: changing this needs the “Change protected settings” permission."
454
442
  ) });
455
443
  };
456
444
  const RequiresGeolocation = () => {
457
- const { t } = useSettingsTranslate();
445
+ const { t } = index.useSettingsTranslate();
458
446
  return /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { tab: "location-data", children: t("settings.config.requires.geolocation", "Requires IP location lookup") });
459
447
  };
460
448
  const RiskSourceNotice = ({ savedOn = false, tab = "location-data" }) => {
461
- const { t } = useSettingsTranslate();
449
+ const { t } = index.useSettingsTranslate();
462
450
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, "data-risk-source-notice": "", children: [
463
451
  /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { tab: tab || void 0, children: t("settings.config.requires.riskData", "Needs a risk data source") }),
464
452
  savedOn ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
@@ -474,7 +462,7 @@ const AdvancedTrigger = styled__default.default(designSystem.Accordion.Trigger)`
474
462
  }
475
463
  `;
476
464
  const AdvancedSection = ({ label, hasError = false, disabled = false, children }) => {
477
- const { t } = useSettingsTranslate();
465
+ const { t } = index.useSettingsTranslate();
478
466
  const itemValue = react.useId();
479
467
  const [open, setOpen] = react.useState("");
480
468
  const [hadError, setHadError] = react.useState(false);
@@ -694,8 +682,8 @@ function sortLocks(locks) {
694
682
  return Number.isFinite(until) && until !== 0 ? until : String(a.id).localeCompare(b.id);
695
683
  });
696
684
  }
697
- const TABLE_MIN_WIDTH$1 = 640;
698
- const keepActionKeys$1 = (event) => {
685
+ const TABLE_MIN_WIDTH$2 = 640;
686
+ const keepActionKeys$2 = (event) => {
699
687
  if (settingsTabs.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
700
688
  };
701
689
  const EMPTY_DRAFT = Object.freeze({
@@ -705,14 +693,14 @@ const EMPTY_DRAFT = Object.freeze({
705
693
  maxFailedLoginsPerAccount: void 0
706
694
  });
707
695
  const RuleValue = ({ value, format }) => {
708
- const { t } = useSettingsTranslate();
696
+ const { t } = index.useSettingsTranslate();
709
697
  if (value === null || value === void 0) {
710
698
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral600", children: t("settings.roleRules.general", "General setting") });
711
699
  }
712
700
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: format(value) });
713
701
  };
714
702
  const RoleRulesSection = ({ form }) => {
715
- const { t, tError } = useSettingsTranslate();
703
+ const { t, tError } = index.useSettingsTranslate();
716
704
  const { get } = StrapiAdmin.useFetchClient();
717
705
  const { settings, handleChange } = form;
718
706
  const locked = form.canChangeProtected === false;
@@ -782,10 +770,10 @@ const RoleRulesSection = ({ form }) => {
782
770
  };
783
771
  const fieldError = (key) => showErrors ? tError(draftErrors[key]) : void 0;
784
772
  const availableRoles = (roles || []).filter((role) => !taken.includes(role.documentId));
785
- const asTable = width === 0 || width >= TABLE_MIN_WIDTH$1;
773
+ const asTable = width === 0 || width >= TABLE_MIN_WIDTH$2;
786
774
  const actions = (rule) => {
787
775
  const name = roleName(rule.role);
788
- return /* @__PURE__ */ jsxRuntime.jsxs(settingsTabs.RowActions, { onKeyDown: keepActionKeys$1, children: [
776
+ return /* @__PURE__ */ jsxRuntime.jsxs(settingsTabs.RowActions, { onKeyDown: keepActionKeys$2, children: [
789
777
  /* @__PURE__ */ jsxRuntime.jsx(
790
778
  designSystem.IconButton,
791
779
  {
@@ -1023,7 +1011,7 @@ const formatReasonCodes = (locale) => {
1023
1011
  }
1024
1012
  };
1025
1013
  const SessionsTab = ({ form }) => {
1026
- const { t, tError, locale } = useSettingsTranslate();
1014
+ const { t, tError, locale } = index.useSettingsTranslate();
1027
1015
  const units = useOptionLabels();
1028
1016
  const encryptionKeyDraft = useEncryptionKeyDraft();
1029
1017
  const { settings, handleChange, relaxedWarningDismissed, setRelaxedWarningDismissed, errors } = form;
@@ -2114,7 +2102,9 @@ const SETTINGS_DEFAULTS = Object.freeze({
2114
2102
  securityLogGeoLookup: false,
2115
2103
  securityLogRetentionDays: 90,
2116
2104
  ...POLICY_FORM_DEFAULTS,
2117
- ...SIGNALS_FORM_DEFAULTS
2105
+ ...SIGNALS_FORM_DEFAULTS,
2106
+ // Impersonation of app users (4.20), off by default.
2107
+ impersonationEnabled: false
2118
2108
  });
2119
2109
  const WRITE_ONLY_SETTINGS_KEYS = Object.freeze([
2120
2110
  "discordWebhookUrl",
@@ -2239,12 +2229,12 @@ function getAdjustedFields(submitted, stored, previous) {
2239
2229
  (key) => !WRITE_ONLY_SETTINGS_KEYS.includes(key) && !areSettingsEqual(source[key], stored?.[key]) && (previous === void 0 || !areSettingsEqual(source[key], previous?.[key]))
2240
2230
  );
2241
2231
  }
2242
- const TABLE_MIN_WIDTH = 640;
2243
- const keepActionKeys = (event) => {
2232
+ const TABLE_MIN_WIDTH$1 = 640;
2233
+ const keepActionKeys$1 = (event) => {
2244
2234
  if (settingsTabs.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
2245
2235
  };
2246
2236
  const LockTarget = ({ lock }) => {
2247
- const { t } = useSettingsTranslate();
2237
+ const { t } = index.useSettingsTranslate();
2248
2238
  if (lock.kind === "ip") {
2249
2239
  return /* @__PURE__ */ jsxRuntime.jsx(
2250
2240
  designSystem.Typography,
@@ -2285,7 +2275,7 @@ const LockTarget = ({ lock }) => {
2285
2275
  ] });
2286
2276
  };
2287
2277
  const KindBadge = ({ kind }) => {
2288
- const { t } = useSettingsTranslate();
2278
+ const { t } = index.useSettingsTranslate();
2289
2279
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: "neutral150", textColor: "neutral800", children: kind === "ip" ? t("settings.lockouts.kind.ip", "IP address") : t("settings.lockouts.kind.account", "Account") });
2290
2280
  };
2291
2281
  const lockName = (lock, t) => {
@@ -2295,7 +2285,7 @@ const lockName = (lock, t) => {
2295
2285
  return t("settings.lockouts.unknownAccount", "Account that does not exist");
2296
2286
  };
2297
2287
  const LockedNowCard = () => {
2298
- const { t } = useSettingsTranslate();
2288
+ const { t } = index.useSettingsTranslate();
2299
2289
  const { get, post } = StrapiAdmin.useFetchClient();
2300
2290
  const { toggleNotification } = StrapiAdmin.useNotification();
2301
2291
  const { formatDate } = index.useSessionFormatters();
@@ -2360,7 +2350,7 @@ const LockedNowCard = () => {
2360
2350
  }
2361
2351
  };
2362
2352
  const showActions = !permissionsLoading && canUnlock;
2363
- const asTable = width === 0 || width >= TABLE_MIN_WIDTH;
2353
+ const asTable = width === 0 || width >= TABLE_MIN_WIDTH$1;
2364
2354
  const unlockAction = (lock) => showActions ? /* @__PURE__ */ jsxRuntime.jsx(
2365
2355
  index.ConfirmAction,
2366
2356
  {
@@ -2427,7 +2417,7 @@ const LockedNowCard = () => {
2427
2417
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(KindBadge, { kind: lock.kind }) }),
2428
2418
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: lock.failures }) }),
2429
2419
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: ends(lock) }),
2430
- showActions ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(settingsTabs.RowActions, { onKeyDown: keepActionKeys, children: unlockAction(lock) }) }) : null
2420
+ showActions ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(settingsTabs.RowActions, { onKeyDown: keepActionKeys$1, children: unlockAction(lock) }) }) : null
2431
2421
  ] }, lock.id)) })
2432
2422
  ] }) });
2433
2423
  } else {
@@ -2450,7 +2440,7 @@ const LockedNowCard = () => {
2450
2440
  }) })
2451
2441
  ] })
2452
2442
  ] }),
2453
- /* @__PURE__ */ jsxRuntime.jsx(settingsTabs.RowActions, { onKeyDown: keepActionKeys, children: unlockAction(lock) })
2443
+ /* @__PURE__ */ jsxRuntime.jsx(settingsTabs.RowActions, { onKeyDown: keepActionKeys$1, children: unlockAction(lock) })
2454
2444
  ] })
2455
2445
  },
2456
2446
  lock.id
@@ -2509,7 +2499,7 @@ const LockedNowCard = () => {
2509
2499
  );
2510
2500
  };
2511
2501
  const TrustedAddressesField = ({ form, disabled = false }) => {
2512
- const { t, tError } = useSettingsTranslate();
2502
+ const { t, tError } = index.useSettingsTranslate();
2513
2503
  const { settings, handleChange, errors, draftVersion } = form;
2514
2504
  const [text, setText] = react.useState(
2515
2505
  () => formatTrustedAddressText(settings.lockoutTrustedAddresses)
@@ -2546,7 +2536,7 @@ const TrustedAddressesField = ({ form, disabled = false }) => {
2546
2536
  );
2547
2537
  };
2548
2538
  const ImpossibleTravelCard = ({ form }) => {
2549
- const { t, tError } = useSettingsTranslate();
2539
+ const { t, tError } = index.useSettingsTranslate();
2550
2540
  const { settings, handleChange, errors } = form;
2551
2541
  const lookupOff = !settings.enableGeolocation;
2552
2542
  const enabled = settings.impossibleTravelEnabled === true;
@@ -2827,7 +2817,7 @@ const ChipList = styled__default.default(designSystem.Flex)`
2827
2817
  }
2828
2818
  `;
2829
2819
  const CountryListEditor = ({ settings, handleChange }) => {
2830
- const { t, tError, locale } = useSettingsTranslate();
2820
+ const { t, tError, locale } = index.useSettingsTranslate();
2831
2821
  const modeLabelId = react.useId();
2832
2822
  const listLabelId = react.useId();
2833
2823
  const [mode, setMode] = react.useState(() => inferGeofencingMode(settings));
@@ -3110,7 +3100,7 @@ const describeLockout = (t, { ip, account, window: window2, duration }) => {
3110
3100
  return parts.join(" ");
3111
3101
  };
3112
3102
  const LoginProtectionTab = ({ form }) => {
3113
- const { t, tError } = useSettingsTranslate();
3103
+ const { t, tError } = index.useSettingsTranslate();
3114
3104
  const { settings, handleChange, errors } = form;
3115
3105
  const maxFailedError = tError(errors.maxFailedLogins);
3116
3106
  const maxFailedValue = Number(settings.maxFailedLogins);
@@ -3503,7 +3493,7 @@ const PathValue = ({ path }) => {
3503
3493
  ] }, index2)) });
3504
3494
  };
3505
3495
  const GeoIpDatabaseCard = ({ form }) => {
3506
- const { t, tError, locale } = useSettingsTranslate();
3496
+ const { t, tError, locale } = index.useSettingsTranslate();
3507
3497
  const { settings, handleChange, errors, hasChanges, geoIp } = form;
3508
3498
  const geoIpStatus = geoIp.status;
3509
3499
  const accountIdRef = react.useRef(null);
@@ -3778,7 +3768,7 @@ const BADGE_COLOURS = Object.freeze({
3778
3768
  missing: { backgroundColor: "neutral150", textColor: "neutral700" }
3779
3769
  });
3780
3770
  const RiskDatabase = ({ id, title, shortName, description, entry, form, lookupOff }) => {
3781
- const { t, locale } = useSettingsTranslate();
3771
+ const { t, locale } = index.useSettingsTranslate();
3782
3772
  const buttonRef = react.useRef(null);
3783
3773
  const { geoIp } = form;
3784
3774
  const state = databaseState(entry);
@@ -3837,7 +3827,7 @@ const RiskDatabase = ({ id, title, shortName, description, entry, form, lookupOf
3837
3827
  );
3838
3828
  };
3839
3829
  const RiskDataCard = ({ form }) => {
3840
- const { t } = useSettingsTranslate();
3830
+ const { t } = index.useSettingsTranslate();
3841
3831
  const { settings, geoIp } = form;
3842
3832
  const lookupOff = !settings.enableGeolocation;
3843
3833
  const risk = settingsTabs.getRiskAvailability(geoIp.status);
@@ -3905,7 +3895,7 @@ const RiskDataCard = ({ form }) => {
3905
3895
  );
3906
3896
  };
3907
3897
  const LocationDataTab = ({ form }) => {
3908
- const { t } = useSettingsTranslate();
3898
+ const { t } = index.useSettingsTranslate();
3909
3899
  const { settings, handleChange } = form;
3910
3900
  const risk = settingsTabs.getRiskAvailability(form.geoIp.status);
3911
3901
  const scoring = settingsTabs.riskDependentControl(settings.enableSecurityScoring, risk.state);
@@ -4046,7 +4036,7 @@ const TEMPLATE_TAB_LABELS = {
4046
4036
  };
4047
4037
  const BlockLabel = ({ children }) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", tag: "div", textColor: "neutral800", children });
4048
4038
  const TemplateEditor = ({ templateKey, template, templates, handleChange, copyValue, errors }) => {
4049
- const { t, tError } = useSettingsTranslate();
4039
+ const { t, tError } = index.useSettingsTranslate();
4050
4040
  const { toggleNotification } = StrapiAdmin.useNotification();
4051
4041
  const defaults = getDefaultTemplates()[templateKey];
4052
4042
  const setField = (field, value) => {
@@ -4246,7 +4236,7 @@ const TemplateEditor = ({ templateKey, template, templates, handleChange, copyVa
4246
4236
  ] });
4247
4237
  };
4248
4238
  const EmailTemplatesCard = ({ form }) => {
4249
- const { t } = useSettingsTranslate();
4239
+ const { t } = index.useSettingsTranslate();
4250
4240
  const { settings, handleChange, copyValue, errors } = form;
4251
4241
  const [activeTemplateTab, setActiveTemplateTab] = react.useState("suspiciousLogin");
4252
4242
  const templates = settings.emailTemplates;
@@ -4324,7 +4314,7 @@ const WebhookUrlField = ({
4324
4314
  error,
4325
4315
  disabled = false
4326
4316
  }) => {
4327
- const { t } = useSettingsTranslate();
4317
+ const { t } = index.useSettingsTranslate();
4328
4318
  const { settings, handleChange } = form;
4329
4319
  const stored = settings[hasKey] === true;
4330
4320
  const draft = settings[field];
@@ -4402,7 +4392,7 @@ const WriteOnlyField = ({
4402
4392
  disabled = false,
4403
4393
  extra
4404
4394
  }) => {
4405
- const { t, tError } = useSettingsTranslate();
4395
+ const { t, tError } = index.useSettingsTranslate();
4406
4396
  const { settings, handleChange, errors } = form;
4407
4397
  const draft = settings[field];
4408
4398
  const [editing, setEditing] = react.useState(false);
@@ -4484,7 +4474,7 @@ const WriteOnlyField = ({
4484
4474
  );
4485
4475
  };
4486
4476
  const SignedWebhookCard = ({ form }) => {
4487
- const { t } = useSettingsTranslate();
4477
+ const { t } = index.useSettingsTranslate();
4488
4478
  const { post } = StrapiAdmin.useFetchClient();
4489
4479
  const { settings, handleChange } = form;
4490
4480
  const [testing, setTesting] = react.useState(false);
@@ -4647,7 +4637,7 @@ const EventGrid = styled__default.default.div`
4647
4637
  }
4648
4638
  `;
4649
4639
  const WebhookEventsCard = ({ form }) => {
4650
- const { t } = useSettingsTranslate();
4640
+ const { t } = index.useSettingsTranslate();
4651
4641
  const { settings, handleChange } = form;
4652
4642
  const locked = form.canChangeProtected === false;
4653
4643
  const selected = Array.isArray(settings.webhookEvents) ? settings.webhookEvents : [];
@@ -4716,7 +4706,7 @@ const AlertTypeCell = ({ checked, disabled, children }) => /* @__PURE__ */ jsxRu
4716
4706
  }
4717
4707
  );
4718
4708
  const AlertsTab = ({ form }) => {
4719
- const { t, tError } = useSettingsTranslate();
4709
+ const { t, tError } = index.useSettingsTranslate();
4720
4710
  const { settings, handleChange, errors } = form;
4721
4711
  const hintIds = {
4722
4712
  suspicious: react.useId(),
@@ -4944,7 +4934,7 @@ const DangerButton = styled__default.default(designSystem.Button)`
4944
4934
  white-space: nowrap;
4945
4935
  `;
4946
4936
  const DataRetentionTab = ({ form }) => {
4947
- const { t } = useSettingsTranslate();
4937
+ const { t } = index.useSettingsTranslate();
4948
4938
  const units = useOptionLabels();
4949
4939
  const { settings, handleChange, handleCleanInactive } = form;
4950
4940
  const {
@@ -5084,7 +5074,7 @@ const DataRetentionTab = ({ form }) => {
5084
5074
  ] });
5085
5075
  };
5086
5076
  const AdminActivityTab = ({ form }) => {
5087
- const { t } = useSettingsTranslate();
5077
+ const { t } = index.useSettingsTranslate();
5088
5078
  const units = useOptionLabels();
5089
5079
  const { settings, handleChange } = form;
5090
5080
  const locked = form.canChangeProtected === false;
@@ -5212,15 +5202,239 @@ const AdminActivityTab = ({ form }) => {
5212
5202
  )
5213
5203
  ] });
5214
5204
  };
5215
- async function copyText(value, clipboard = globalThis.navigator?.clipboard) {
5216
- if (typeof value !== "string") {
5217
- throw new TypeError("clipboard_value_must_be_text");
5218
- }
5219
- if (!clipboard || typeof clipboard.writeText !== "function") {
5220
- throw new Error("clipboard_unavailable");
5205
+ const TABLE_MIN_WIDTH = 720;
5206
+ const keepActionKeys = (event) => {
5207
+ if (settingsTabs.shouldIsolateActionKey(event.key, true)) event.stopPropagation();
5208
+ };
5209
+ const ActiveImpersonationsCard = () => {
5210
+ const { t } = index.useSettingsTranslate();
5211
+ const { get, post } = StrapiAdmin.useFetchClient();
5212
+ const { toggleNotification } = StrapiAdmin.useNotification();
5213
+ const { formatDate } = index.useSessionFormatters();
5214
+ const [widthRef, width] = settingsTabs.useElementWidth();
5215
+ const [rows, setRows] = react.useState(null);
5216
+ const [error, setError] = react.useState(false);
5217
+ const [refreshing, setRefreshing] = react.useState(false);
5218
+ const refreshRef = react.useRef(null);
5219
+ const requestRef = react.useRef(0);
5220
+ const apply = react.useCallback(async (request, pending) => {
5221
+ try {
5222
+ const { data } = await pending;
5223
+ if (request !== requestRef.current) return;
5224
+ if (!Array.isArray(data?.data)) throw new Error("Invalid impersonation list");
5225
+ setRows(data.data);
5226
+ setError(false);
5227
+ } catch (err) {
5228
+ if (index.isCancelledRequest(err) || request !== requestRef.current) return;
5229
+ index.logSafeAdminError("impersonation.list", err);
5230
+ setError(true);
5231
+ } finally {
5232
+ if (request === requestRef.current) setRefreshing(false);
5233
+ }
5234
+ }, []);
5235
+ const load = react.useCallback(() => {
5236
+ const request = ++requestRef.current;
5237
+ setRefreshing(true);
5238
+ return apply(request, get(`/${index.pluginId}/impersonation/active`));
5239
+ }, [apply, get]);
5240
+ react.useEffect(() => {
5241
+ apply(++requestRef.current, get(`/${index.pluginId}/impersonation/active`));
5242
+ }, [apply, get]);
5243
+ const end = async (row) => {
5244
+ try {
5245
+ await post(`/${index.pluginId}/impersonation/${row.id}/end`, {});
5246
+ toggleNotification({
5247
+ type: "success",
5248
+ message: t("impersonation.ended", "Impersonation ended.")
5249
+ });
5250
+ } catch (err) {
5251
+ index.logSafeAdminError("impersonation.end", err);
5252
+ toggleNotification({
5253
+ type: "danger",
5254
+ message: t("impersonation.error.end", "The impersonation could not be ended.")
5255
+ });
5256
+ throw err;
5257
+ } finally {
5258
+ await load();
5259
+ }
5260
+ };
5261
+ const endAction = (row) => /* @__PURE__ */ jsxRuntime.jsx(
5262
+ index.ConfirmAction,
5263
+ {
5264
+ fallbackFocusRef: refreshRef,
5265
+ title: t("impersonation.confirm.title", "End the impersonation of {user}?", {
5266
+ user: row.targetLabel
5267
+ }),
5268
+ body: t(
5269
+ "impersonation.confirm.body",
5270
+ "The short-lived sign-in stops working at once. This is recorded in the security log."
5271
+ ),
5272
+ confirmLabel: t("impersonation.end", "End impersonation"),
5273
+ onConfirm: () => end(row),
5274
+ trigger: /* @__PURE__ */ jsxRuntime.jsx(
5275
+ designSystem.IconButton,
5276
+ {
5277
+ variant: "ghost",
5278
+ label: t("impersonation.endLabel", "End impersonation of {user}", {
5279
+ user: row.targetLabel
5280
+ }),
5281
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.SignOut, {})
5282
+ }
5283
+ )
5284
+ },
5285
+ row.id
5286
+ );
5287
+ const time = (iso) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { tag: "time", dateTime: iso, variant: "omega", textColor: "neutral800", children: formatDate(iso, { hour: "2-digit", minute: "2-digit" }) });
5288
+ const startedBy = (row) => row.startedByYou ? t("impersonation.list.you", "You") : row.actorLabel || "—";
5289
+ let content;
5290
+ if (rows === null && !error) {
5291
+ content = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", padding: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Loader, { small: true, children: t("impersonation.list.loading", "Loading impersonations…") }) });
5292
+ } else if (error && rows === null) {
5293
+ content = /* @__PURE__ */ jsxRuntime.jsx(
5294
+ index.PersistentAlert,
5295
+ {
5296
+ variant: "danger",
5297
+ closeLabel: t("common.close", "Close"),
5298
+ title: t("impersonation.list.error", "Impersonations could not be loaded."),
5299
+ action: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "tertiary", onClick: load, children: t("common.tryAgain", "Try again") }),
5300
+ children: t(
5301
+ "impersonation.list.errorBody",
5302
+ "Running impersonations still end on time; only this list is missing."
5303
+ )
5304
+ }
5305
+ );
5306
+ } else if (rows.length === 0) {
5307
+ content = /* @__PURE__ */ jsxRuntime.jsx(
5308
+ designSystem.EmptyStateLayout,
5309
+ {
5310
+ icon: /* @__PURE__ */ jsxRuntime.jsx(symbols.EmptyPermissions, { width: "16rem", height: "8rem" }),
5311
+ content: t(
5312
+ "impersonation.list.empty",
5313
+ "No impersonation is running. Start one from a user’s entry in the Content Manager."
5314
+ )
5315
+ }
5316
+ );
5317
+ } else if (width === 0 || width >= TABLE_MIN_WIDTH) {
5318
+ content = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { hasRadius: true, borderColor: "neutral150", "data-impersonations-table": "", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: 5, rowCount: rows.length + 1, "aria-busy": refreshing, children: [
5319
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
5320
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("impersonation.list.col.user", "User") }) }),
5321
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("impersonation.list.col.startedBy", "Started by") }) }),
5322
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("impersonation.list.col.reason", "Reason") }) }),
5323
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: t("impersonation.list.col.ends", "Ends") }) }),
5324
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: t("impersonation.list.col.actions", "Actions") }) })
5325
+ ] }) }),
5326
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: rows.map((row) => /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { "data-impersonation-row": "", children: [
5327
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", fontWeight: "semiBold", children: row.targetLabel }) }),
5328
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: startedBy(row) }) }),
5329
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { style: { maxWidth: 0, width: "40%" }, children: /* @__PURE__ */ jsxRuntime.jsx(
5330
+ designSystem.Typography,
5331
+ {
5332
+ variant: "omega",
5333
+ textColor: "neutral800",
5334
+ tag: "p",
5335
+ style: { overflowWrap: "anywhere" },
5336
+ children: row.reason
5337
+ }
5338
+ ) }),
5339
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: time(row.expiresAt) }),
5340
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(settingsTabs.RowActions, { onKeyDown: keepActionKeys, children: endAction(row) }) })
5341
+ ] }, row.id)) })
5342
+ ] }) });
5343
+ } else {
5344
+ content = /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, tag: "ul", "data-impersonations-list": "", children: rows.map((row) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { tag: "li", padding: 4, hasRadius: true, borderColor: "neutral150", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-start", gap: 3, children: [
5345
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, minWidth: 0, children: [
5346
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", fontWeight: "semiBold", children: row.targetLabel }),
5347
+ /* @__PURE__ */ jsxRuntime.jsx(
5348
+ designSystem.Typography,
5349
+ {
5350
+ variant: "pi",
5351
+ textColor: "neutral800",
5352
+ tag: "p",
5353
+ style: { overflowWrap: "anywhere" },
5354
+ children: row.reason
5355
+ }
5356
+ ),
5357
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: t("impersonation.list.summary", "{admin}, until {time}", {
5358
+ admin: startedBy(row),
5359
+ time: formatDate(row.expiresAt, { hour: "2-digit", minute: "2-digit" })
5360
+ }) })
5361
+ ] }),
5362
+ /* @__PURE__ */ jsxRuntime.jsx(settingsTabs.RowActions, { onKeyDown: keepActionKeys, children: endAction(row) })
5363
+ ] }) }, row.id)) });
5221
5364
  }
5222
- await clipboard.writeText(value);
5223
- }
5365
+ return /* @__PURE__ */ jsxRuntime.jsx(
5366
+ SectionCard.SectionCard,
5367
+ {
5368
+ id: "active-impersonations",
5369
+ title: t("impersonation.list.title", "Active impersonations"),
5370
+ subtitle: t(
5371
+ "impersonation.list.intro",
5372
+ "Each one ends by itself at the time shown. End stops it at once."
5373
+ ),
5374
+ action: /* @__PURE__ */ jsxRuntime.jsx(
5375
+ designSystem.Button,
5376
+ {
5377
+ ref: refreshRef,
5378
+ variant: "tertiary",
5379
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.ArrowClockwise, {}),
5380
+ onClick: load,
5381
+ loading: refreshing && rows !== null,
5382
+ children: t("impersonation.list.refresh", "Refresh")
5383
+ }
5384
+ ),
5385
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: widthRef, "aria-live": "polite", children: [
5386
+ error && rows !== null ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { paddingBottom: 3, children: /* @__PURE__ */ jsxRuntime.jsx(
5387
+ index.PersistentAlert,
5388
+ {
5389
+ variant: "warning",
5390
+ closeLabel: t("common.close", "Close"),
5391
+ title: t("impersonation.list.refreshErrorTitle", "Not refreshed"),
5392
+ children: t(
5393
+ "impersonation.list.refreshError",
5394
+ "The list could not be refreshed. It shows the last known impersonations."
5395
+ )
5396
+ }
5397
+ ) }) : null,
5398
+ content
5399
+ ] })
5400
+ }
5401
+ );
5402
+ };
5403
+ const ImpersonationTab = ({ form }) => {
5404
+ const { t } = index.useSettingsTranslate();
5405
+ const { settings, handleChange } = form;
5406
+ const locked = form.canChangeProtected === false;
5407
+ const {
5408
+ isLoading,
5409
+ allowedActions: { canUsers }
5410
+ } = StrapiAdmin.useRBAC(index.pluginPermissions.impersonateUsers);
5411
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
5412
+ /* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
5413
+ "settings.impersonation.intro",
5414
+ "Support staff can act as an app user for up to an hour to reproduce a problem, with a reason that is recorded. Who may do this is set per role under Settings > Roles > Session Manager."
5415
+ ) }),
5416
+ locked ? /* @__PURE__ */ jsxRuntime.jsx(ProtectedNotice, {}) : null,
5417
+ /* @__PURE__ */ jsxRuntime.jsx(SectionCard.SectionCard, { title: t("settings.impersonation.title", "Impersonation of app users"), children: /* @__PURE__ */ jsxRuntime.jsx(
5418
+ SettingsToggleRow,
5419
+ {
5420
+ id: "impersonation-enabled",
5421
+ title: t("settings.impersonation.enable.label", "Allow impersonation"),
5422
+ description: t(
5423
+ "settings.impersonation.enable.hint",
5424
+ "Off by default. Turning it off ends every running impersonation at once."
5425
+ ),
5426
+ checked: settings.impersonationEnabled === true,
5427
+ disabled: locked,
5428
+ onChange: (checked) => handleChange("impersonationEnabled", checked),
5429
+ children: /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral700", tag: "p", "data-privacy-note": "", children: t(
5430
+ "settings.impersonation.notice",
5431
+ "Acting as a person processes their personal data. Tell your users in the privacy notice, and in Germany check whether the works council must agree, because the log shows what each admin did."
5432
+ ) })
5433
+ }
5434
+ ) }),
5435
+ !isLoading && canUsers ? /* @__PURE__ */ jsxRuntime.jsx(ActiveImpersonationsCard, {}) : null
5436
+ ] });
5437
+ };
5224
5438
  const INITIAL_SETTINGS = { ...SETTINGS_DEFAULTS, emailTemplates: fillMissingTemplates({}) };
5225
5439
  const BUILD_DATE_OPTIONS = Object.freeze({ dateStyle: "medium" });
5226
5440
  const getServerMessage = (error) => {
@@ -5237,7 +5451,7 @@ const formatList = (names, locale) => {
5237
5451
  }
5238
5452
  };
5239
5453
  function useSettingsForm() {
5240
- const { t, locale } = useSettingsTranslate();
5454
+ const { t, locale } = index.useSettingsTranslate();
5241
5455
  const { get, post, put } = StrapiAdmin.useFetchClient();
5242
5456
  const { toggleNotification } = StrapiAdmin.useNotification();
5243
5457
  const [loading, setLoading] = react.useState(true);
@@ -5269,7 +5483,7 @@ function useSettingsForm() {
5269
5483
  const copyValue = react.useCallback(
5270
5484
  async (value, successMessage, scope) => {
5271
5485
  try {
5272
- await copyText(value);
5486
+ await index.copyText(value);
5273
5487
  toggleNotification({ type: "success", message: successMessage });
5274
5488
  } catch (error) {
5275
5489
  index.logSafeAdminError(scope, error);
@@ -5592,6 +5806,7 @@ const TAB_COMPONENTS = {
5592
5806
  "location-data": LocationDataTab,
5593
5807
  alerts: AlertsTab,
5594
5808
  "data-retention": DataRetentionTab,
5809
+ impersonation: ImpersonationTab,
5595
5810
  "admin-activity": AdminActivityTab
5596
5811
  };
5597
5812
  const DraftSync = ({ values }) => {
@@ -5609,7 +5824,7 @@ const writeTabToAddressBar = (tab) => {
5609
5824
  window.history.replaceState(window.history.state, "", `${pathname}${nextSearch}${hash}`);
5610
5825
  };
5611
5826
  const SettingsPage = () => {
5612
- const { t } = useSettingsTranslate();
5827
+ const { t } = index.useSettingsTranslate();
5613
5828
  const form = useSettingsForm();
5614
5829
  const [{ query }] = StrapiAdmin.useQueryParams();
5615
5830
  const {