strapi-plugin-magic-sessionmanager 4.14.3 → 4.15.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 (30) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +124 -77
  3. package/dist/admin/{Analytics-DSpn7W5A.js → Analytics-Dbs5QXLb.js} +1 -1
  4. package/dist/admin/{Analytics-CFEgpg-G.mjs → Analytics-HK6_TEmk.mjs} +1 -1
  5. package/dist/admin/{App-UlRrLKcx.js → App-7SxOBJP5.js} +59 -26
  6. package/dist/admin/{App-BBne8xI6.mjs → App-BOFzZ5d8.mjs} +59 -26
  7. package/dist/admin/{OnlineUsersWidget-C3YMTEGD.mjs → OnlineUsersWidget-CoCxnww-.mjs} +1 -1
  8. package/dist/admin/{OnlineUsersWidget-GFcYyZ9L.js → OnlineUsersWidget-Dns_74xJ.js} +1 -1
  9. package/dist/admin/{Settings-DVhW9XHB.js → Settings-B6CrR-07.js} +257 -64
  10. package/dist/admin/{Settings-BbUNvjno.mjs → Settings-DYRShQ8W.mjs} +258 -65
  11. package/dist/admin/{de-BlKn1pSD.mjs → de-B3mPtxsW.mjs} +39 -7
  12. package/dist/admin/{de-B0CBR1Dw.js → de-bkkCvSxX.js} +39 -7
  13. package/dist/admin/{en-IT0YTY8f.mjs → en-BnU8BNkN.mjs} +39 -7
  14. package/dist/admin/{en-D0ZGIIjz.js → en-DMICyIow.js} +39 -7
  15. package/dist/admin/{es-BCGzaaCh.mjs → es-BxMgfJ1Y.mjs} +39 -7
  16. package/dist/admin/{es-CWee-XCR.js → es-OSzHGRIu.js} +39 -7
  17. package/dist/admin/{fr-rQS1M7jE.js → fr-Bu_8miJ4.js} +39 -7
  18. package/dist/admin/{fr-xBIH4Byq.mjs → fr-WPrbtx8k.mjs} +39 -7
  19. package/dist/admin/{index-1KmiZSfy.js → index-CNSJITRX.js} +9 -9
  20. package/dist/admin/{index-MOJkFXcZ.mjs → index-lnZBc5n0.mjs} +9 -9
  21. package/dist/admin/index.js +1 -1
  22. package/dist/admin/index.mjs +1 -1
  23. package/dist/admin/{pt-C-yTLhnS.js → pt-B08xnb0K.js} +39 -7
  24. package/dist/admin/{pt-DWDeIDVa.mjs → pt-C41KyEDN.mjs} +39 -7
  25. package/dist/admin/riskData-BVs9GpgD.js +26 -0
  26. package/dist/admin/riskData-CI1gm2yI.mjs +27 -0
  27. package/dist/server/index.js +565 -178
  28. package/dist/server/index.mjs +565 -178
  29. package/package.json +1 -1
  30. package/scripts/geoip-updater.cjs +58 -15
@@ -7,7 +7,8 @@ import { Typography, Flex, Loader, Button, Modal, Accordion, Box, IconButton, Li
7
7
  import { Earth, Duplicate, Cross, Eye, Trash, More, CaretDown, Download, ArrowClockwise, Check, Clock, User, ChartBubble, Cog, SignOut } from "@strapi/icons";
8
8
  import { EmptyDocuments } from "@strapi/icons/symbols";
9
9
  import styled, { useTheme } from "styled-components";
10
- import { g as getSessionEndReason, a as getEndReasonPresentation, b as getTranslation, p as presentText, i as isSessionFilter, D as DEFAULT_SESSION_FILTER, c as isEndReasonFilter, d as DEFAULT_END_REASON_FILTER, e as getDevicePresentation, u as useSessionFormatters, f as getSessionStatus, h as isNativeOnlySession, j as getSessionEndReasonPresentation, k as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, l as pluginId, m as logSafeAdminError, n as PersistentAlert, R as ReadableText, o as pluginPermissions, M as MissingValue, V as ValueOrMissing, q as SESSION_STATES, r as SESSION_STATUS_PRESENTATION, s as isCancelledRequest, v as SESSION_FILTER_OPTIONS, E as END_REASON_FILTER_OPTIONS, w as PageShell, x as StatGrid, y as StatCard, z as restoreDialogFocus, A as requireSessionList, B as getBadgeColors } from "./index-MOJkFXcZ.mjs";
10
+ import { g as getSessionEndReason, a as getEndReasonPresentation, b as getTranslation, p as presentText, i as isSessionFilter, D as DEFAULT_SESSION_FILTER, c as isEndReasonFilter, d as DEFAULT_END_REASON_FILTER, e as getDevicePresentation, u as useSessionFormatters, f as getSessionStatus, h as isNativeOnlySession, j as getSessionEndReasonPresentation, k as DeviceIcon, S as StatusBadge, P as PropertyList, C as ConfirmAction, t as toValidDate, l as pluginId, m as logSafeAdminError, n as PersistentAlert, R as ReadableText, o as pluginPermissions, M as MissingValue, V as ValueOrMissing, q as SESSION_STATES, r as SESSION_STATUS_PRESENTATION, s as isCancelledRequest, v as SESSION_FILTER_OPTIONS, E as END_REASON_FILTER_OPTIONS, w as PageShell, x as StatGrid, y as StatCard, z as restoreDialogFocus, A as requireSessionList, B as getBadgeColors } from "./index-lnZBc5n0.mjs";
11
+ import { i as isRiskSource, R as RISK_SETTINGS_PATH } from "./riskData-CI1gm2yI.mjs";
11
12
  const EndReason = ({ session, reason, variant = "omega", textColor = "neutral800" }) => {
12
13
  const { formatMessage } = useIntl();
13
14
  const key = reason || getSessionEndReason(session);
@@ -301,16 +302,19 @@ function normalizeGeoData(geo, fallback = {}) {
301
302
  const city = presentText(geo.city);
302
303
  const timezone = presentText(geo.timezone);
303
304
  if (!country && !city && !timezone) return null;
305
+ const riskSource = isRiskSource(geo.riskSource) ? geo.riskSource : null;
304
306
  const rawScore = typeof geo.securityScore === "number" ? geo.securityScore : fallback?.securityScore;
305
- const securityScore = typeof rawScore === "number" && Number.isFinite(rawScore) ? rawScore : null;
307
+ const securityScore = riskSource && typeof rawScore === "number" && Number.isFinite(rawScore) ? rawScore : null;
306
308
  return {
307
309
  country,
308
310
  city,
309
311
  timezone,
312
+ riskSource,
310
313
  securityScore,
311
- riskLevel: normalizeRiskLevel(geo.riskLevel),
312
- isVpn: booleanOrNull(geo.isVpn),
313
- isProxy: booleanOrNull(geo.isProxy)
314
+ riskLevel: riskSource ? normalizeRiskLevel(geo.riskLevel) : "",
315
+ isVpn: riskSource === "anonymous-ip" ? booleanOrNull(geo.isVpn) : null,
316
+ isProxy: riskSource === "anonymous-ip" ? booleanOrNull(geo.isProxy) : null,
317
+ isHosting: riskSource ? booleanOrNull(geo.isHosting) : null
314
318
  };
315
319
  }
316
320
  function getStoredGeoData(session) {
@@ -328,6 +332,7 @@ function getStoredGeoData(session) {
328
332
  riskLevel: _ignoredLevel,
329
333
  isVpn: _ignoredVpn,
330
334
  isProxy: _ignoredProxy,
335
+ isHosting: _ignoredHosting,
331
336
  ...facts
332
337
  } = geoLocation;
333
338
  return normalizeGeoData(facts, { securityScore: session?.securityScore });
@@ -571,27 +576,42 @@ const SessionDetailModal = ({ session, now, onClose, onCloseAutoFocus, onEndSess
571
576
  };
572
577
  const yesNoText = (value) => typeof value === "boolean" ? /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", children: value ? t("common.yes", "Yes") : t("common.no", "No") }) : void 0;
573
578
  const notStoredForPast = /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: t("modal.security.notStored", "Not stored for past sign-ins") });
574
- const score = typeof geo?.securityScore === "number" ? geo.securityScore : typeof session.securityScore === "number" && Number.isFinite(session.securityScore) ? session.securityScore : null;
575
- const riskMessage = liveGeo ? RISK_LEVEL_MESSAGES[liveGeo.riskLevel] : null;
579
+ const score = typeof geo?.securityScore === "number" ? geo.securityScore : null;
580
+ const riskUnavailable = Boolean(geo) && !geo.riskSource;
581
+ const riskMessage = liveGeo?.riskSource ? RISK_LEVEL_MESSAGES[liveGeo.riskLevel] : null;
582
+ const notAvailable = /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral600", children: t("modal.security.riskUnavailable", "Not available") });
576
583
  const locationItems = [
577
584
  { id: "country", label: t("modal.security.country", "Country"), value: geo?.country },
578
585
  { id: "city", label: t("modal.security.city", "City"), value: geo?.city },
579
586
  { id: "timezone", label: t("modal.security.timezone", "Time zone"), value: geo?.timezone },
580
- {
581
- id: "score",
582
- label: t("modal.security.score", "Security score"),
583
- value: score === null ? null : t("modal.security.scoreValue", "{score}/100", { score })
584
- },
585
- {
586
- id: "vpn",
587
- label: t("modal.security.vpn", "VPN"),
588
- render: liveGeo ? yesNoText(liveGeo.isVpn) : storedGeo ? notStoredForPast : void 0
589
- },
590
- {
591
- id: "proxy",
592
- label: t("modal.security.proxy", "Proxy"),
593
- render: liveGeo ? yesNoText(liveGeo.isProxy) : storedGeo ? notStoredForPast : void 0
594
- },
587
+ ...riskUnavailable ? [
588
+ {
589
+ id: "riskData",
590
+ label: t("modal.security.riskData", "VPN, proxy and security score"),
591
+ render: notAvailable
592
+ }
593
+ ] : [
594
+ {
595
+ id: "score",
596
+ label: t("modal.security.score", "Security score"),
597
+ value: score === null ? null : t("modal.security.scoreValue", "{score}/100", { score })
598
+ },
599
+ {
600
+ id: "vpn",
601
+ label: t("modal.security.vpn", "VPN"),
602
+ render: liveGeo ? yesNoText(liveGeo.isVpn) ?? notAvailable : storedGeo ? notStoredForPast : void 0
603
+ },
604
+ {
605
+ id: "proxy",
606
+ label: t("modal.security.proxy", "Proxy"),
607
+ render: liveGeo ? yesNoText(liveGeo.isProxy) ?? notAvailable : storedGeo ? notStoredForPast : void 0
608
+ },
609
+ liveGeo ? {
610
+ id: "hosting",
611
+ label: t("modal.security.hosting", "Hosting network"),
612
+ render: yesNoText(liveGeo.isHosting)
613
+ } : null
614
+ ],
595
615
  riskMessage ? {
596
616
  id: "risk",
597
617
  label: t("modal.security.riskLevel", "Risk level"),
@@ -710,10 +730,23 @@ const SessionDetailModal = ({ session, now, onClose, onCloseAutoFocus, onEndSess
710
730
  ) }),
711
731
  /* @__PURE__ */ jsxs(DetailSection, { title: t("modal.section.security", "Location and security"), children: [
712
732
  hasLocationData ? /* @__PURE__ */ jsx(PropertyList, { items: locationItems }) : null,
713
- score !== null ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", "data-score-note": "", children: t(
714
- "modal.security.scoreNote",
715
- "Higher is safer. Below 70 can trigger a suspicious-sign-in email and below 50 a rejection, if those settings are on. Local database results are always 100."
716
- ) }) : null,
733
+ score !== null ? /* @__PURE__ */ jsxs(Typography, { variant: "pi", textColor: "neutral600", "data-score-note": "", children: [
734
+ t(
735
+ "modal.security.scoreNote",
736
+ "Higher is safer. Below 70 can trigger a suspicious-sign-in email and below 50 a rejection, if those settings are on."
737
+ ),
738
+ geo?.riskSource === "asn-heuristic" ? ` ${t(
739
+ "modal.security.asnHeuristicNote",
740
+ "From the ASN heuristic: it only recognises large hosting and cloud networks, not VPNs, proxies or Tor."
741
+ )}` : null
742
+ ] }) : null,
743
+ riskUnavailable ? /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, "data-risk-unavailable": "", children: [
744
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t(
745
+ "modal.security.riskUnavailableNote",
746
+ "Needs a risk data source. Location data alone cannot tell VPNs, proxies or Tor apart, so no score was calculated."
747
+ ) }),
748
+ /* @__PURE__ */ jsx(TargetLink, { tag: NavLink, to: RISK_SETTINGS_PATH, children: t("modal.security.riskSetup", "Set up risk data") })
749
+ ] }) : null,
717
750
  lookupControls
718
751
  ] }),
719
752
  /* @__PURE__ */ jsx(Accordion.Root, { collapsible: true, size: "S", children: /* @__PURE__ */ jsxs(Accordion.Item, { value: "technical", children: [
@@ -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 { m as logSafeAdminError, s as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-MOJkFXcZ.mjs";
9
+ import { m as logSafeAdminError, s as isCancelledRequest, b as getTranslation, R as ReadableText, M as MissingValue } from "./index-lnZBc5n0.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-1KmiZSfy.js");
10
+ const index = require("./index-CNSJITRX.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,9 +6,10 @@ 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-1KmiZSfy.js");
9
+ const index = require("./index-CNSJITRX.js");
10
10
  const reactIntl = require("react-intl");
11
11
  const SectionCard = require("./SectionCard-BlWv8CRt.js");
12
+ const riskData = require("./riskData-BVs9GpgD.js");
12
13
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
13
14
  const styled__default = /* @__PURE__ */ _interopDefault(styled);
14
15
  const SETTINGS_TAB_IDS = Object.freeze([
@@ -593,6 +594,16 @@ const RequiresGeolocation = () => {
593
594
  const { t } = useSettingsTranslate();
594
595
  return /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { tab: "location-data", children: t("settings.config.requires.geolocation", "Requires IP location lookup") });
595
596
  };
597
+ const RiskSourceNotice = ({ savedOn = false, tab = "location-data" }) => {
598
+ const { t } = useSettingsTranslate();
599
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "flex-start", gap: 1, "data-risk-source-notice": "", children: [
600
+ /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { tab: tab || void 0, children: t("settings.config.requires.riskData", "Needs a risk data source") }),
601
+ savedOn ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
602
+ "settings.config.requires.riskData.savedOn",
603
+ "Saved as on. It takes effect once a risk data source is set up."
604
+ ) }) : null
605
+ ] });
606
+ };
596
607
  const AdvancedTrigger = styled__default.default(designSystem.Accordion.Trigger)`
597
608
  &&:focus-visible {
598
609
  outline: 2px solid ${({ theme }) => theme.colors.primary600};
@@ -1883,6 +1894,9 @@ const LoginProtectionTab = ({ form }) => {
1883
1894
  const maxFailedError = tError(errors.maxFailedLogins);
1884
1895
  const maxFailedValue = Number(settings.maxFailedLogins);
1885
1896
  const lookupOff = !settings.enableGeolocation;
1897
+ const risk = riskData.getRiskAvailability(form.geoIp.status);
1898
+ const reject = riskData.riskDependentControl(settings.blockSuspiciousSessions, risk.state);
1899
+ const autoStillRejects = reject.savedOnButInactive && (settings.geoLookupFailureMode || "auto") === "auto";
1886
1900
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
1887
1901
  /* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
1888
1902
  "settings.config.loginProtection.intro",
@@ -1982,6 +1996,23 @@ const LoginProtectionTab = ({ form }) => {
1982
1996
  subtitle: t("settings.config.suspicious.intro", "Refuses new sign-ins that look risky."),
1983
1997
  children: [
1984
1998
  lookupOff ? /* @__PURE__ */ jsxRuntime.jsx(RequiresGeolocation, {}) : null,
1999
+ !lookupOff && risk.state === "missing" ? /* @__PURE__ */ jsxRuntime.jsxs(
2000
+ index.PersistentAlert,
2001
+ {
2002
+ variant: "default",
2003
+ closeLabel: t("common.close", "Close"),
2004
+ title: t("settings.config.risk.missing.title", "No risk data source"),
2005
+ "data-risk-missing": "",
2006
+ children: [
2007
+ t(
2008
+ "settings.config.risk.missing.body",
2009
+ "VPN, proxy and Tor detection needs a risk data source. Until one is set up, no sign-in is refused as suspicious."
2010
+ ),
2011
+ " ",
2012
+ /* @__PURE__ */ jsxRuntime.jsx(SettingsTabLink, { tab: "location-data", children: t("settings.config.risk.missing.link", "Set up risk data") })
2013
+ ]
2014
+ }
2015
+ ) : null,
1985
2016
  /* @__PURE__ */ jsxRuntime.jsx(
1986
2017
  SettingsToggleRow,
1987
2018
  {
@@ -1989,45 +2020,48 @@ const LoginProtectionTab = ({ form }) => {
1989
2020
  title: t("settings.config.suspicious.reject.label", "Reject suspicious sign-ins"),
1990
2021
  description: t(
1991
2022
  "settings.config.suspicious.reject.hint",
1992
- "Refuses sign-ins from VPN, proxy or known threat addresses and, with security scoring on, scores below 50."
2023
+ "Refuses sign-ins from VPN, proxy or Tor addresses and, with security scoring on, scores below 50. Hosting networks only trigger alerts."
1993
2024
  ),
1994
- checked: settings.blockSuspiciousSessions,
1995
- disabled: lookupOff,
2025
+ checked: reject.checked,
2026
+ disabled: lookupOff || reject.disabled,
1996
2027
  onChange: (checked) => handleChange("blockSuspiciousSessions", checked),
1997
- children: settings.geoIpProvider === "local-mmdb" ? /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
1998
- "settings.config.suspicious.reject.localNote",
1999
- "The local database has no VPN, proxy or threat data and always scores 100, so only failed lookups can be refused."
2000
- ) }) : null
2028
+ children: !lookupOff && reject.disabled ? /* @__PURE__ */ jsxRuntime.jsx(RiskSourceNotice, { savedOn: reject.savedOnButInactive }) : null
2001
2029
  }
2002
2030
  ),
2003
- /* @__PURE__ */ jsxRuntime.jsx(AdvancedSection, { hasError: fieldHasError(errors, "geoLookupFailureMode"), children: /* @__PURE__ */ jsxRuntime.jsx(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
2004
- FormField,
2005
- {
2006
- id: "geoip-lookup-failure-mode",
2007
- name: "geoLookupFailureMode",
2008
- label: t(
2009
- "settings.config.suspicious.failureMode.label",
2010
- "If the location cannot be determined"
2011
- ),
2012
- description: t(
2013
- "settings.config.suspicious.failureMode.hint",
2014
- "Automatic rejects only when 'Reject suspicious sign-ins' is on. A rejected sign-in gets 'Login temporarily unavailable'. With 'Reject sign-in', the Automatic provider no longer falls back to ipapi.co."
2015
- ),
2016
- children: /* @__PURE__ */ jsxRuntime.jsxs(
2017
- designSystem.SingleSelect,
2018
- {
2019
- value: settings.geoLookupFailureMode || "auto",
2020
- disabled: lookupOff,
2021
- onChange: (value) => handleChange("geoLookupFailureMode", value),
2022
- children: [
2023
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "auto", children: t("settings.config.suspicious.failureMode.auto", "Automatic") }),
2024
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "allow", children: t("settings.config.suspicious.failureMode.allow", "Allow sign-in") }),
2025
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "block", children: t("settings.config.suspicious.failureMode.block", "Reject sign-in") })
2026
- ]
2027
- }
2028
- )
2029
- }
2030
- ) }) })
2031
+ /* @__PURE__ */ jsxRuntime.jsxs(AdvancedSection, { hasError: fieldHasError(errors, "geoLookupFailureMode"), children: [
2032
+ /* @__PURE__ */ jsxRuntime.jsx(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
2033
+ FormField,
2034
+ {
2035
+ id: "geoip-lookup-failure-mode",
2036
+ name: "geoLookupFailureMode",
2037
+ label: t(
2038
+ "settings.config.suspicious.failureMode.label",
2039
+ "If the location cannot be determined"
2040
+ ),
2041
+ description: t(
2042
+ "settings.config.suspicious.failureMode.hint",
2043
+ "Automatic rejects only when 'Reject suspicious sign-ins' is on. A rejected sign-in gets 'Login temporarily unavailable'. With 'Reject sign-in', the Automatic provider no longer falls back to ipapi.co."
2044
+ ),
2045
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
2046
+ designSystem.SingleSelect,
2047
+ {
2048
+ value: settings.geoLookupFailureMode || "auto",
2049
+ disabled: lookupOff,
2050
+ onChange: (value) => handleChange("geoLookupFailureMode", value),
2051
+ children: [
2052
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "auto", children: t("settings.config.suspicious.failureMode.auto", "Automatic") }),
2053
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "allow", children: t("settings.config.suspicious.failureMode.allow", "Allow sign-in") }),
2054
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "block", children: t("settings.config.suspicious.failureMode.block", "Reject sign-in") })
2055
+ ]
2056
+ }
2057
+ )
2058
+ }
2059
+ ) }),
2060
+ autoStillRejects ? /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral700", tag: "p", "data-auto-still-rejects": "", children: t(
2061
+ "settings.config.suspicious.failureMode.savedOnNote",
2062
+ "Automatic still rejects sign-ins whose location cannot be determined, because 'Reject suspicious sign-ins' is saved as on. Choose 'Allow sign-in' to change that."
2063
+ ) }) : null
2064
+ ] })
2031
2065
  ]
2032
2066
  }
2033
2067
  ),
@@ -2092,7 +2126,7 @@ const LoginProtectionTab = ({ form }) => {
2092
2126
  ] })
2093
2127
  ] });
2094
2128
  };
2095
- const BUILD_DATE_OPTIONS$1 = Object.freeze({ dateStyle: "medium" });
2129
+ const BUILD_DATE_OPTIONS$2 = Object.freeze({ dateStyle: "medium" });
2096
2130
  const PathValue = ({ path }) => {
2097
2131
  const parts = String(path).split("/");
2098
2132
  return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", textColor: "neutral800", children: parts.map((part, index2) => /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
@@ -2203,7 +2237,7 @@ const GeoIpDatabaseCard = ({ form }) => {
2203
2237
  geoIpStatus.metadata?.lastModified,
2204
2238
  locale,
2205
2239
  "",
2206
- BUILD_DATE_OPTIONS$1
2240
+ BUILD_DATE_OPTIONS$2
2207
2241
  )
2208
2242
  },
2209
2243
  {
@@ -2366,9 +2400,149 @@ const GeoIpDatabaseCard = ({ form }) => {
2366
2400
  }
2367
2401
  );
2368
2402
  };
2403
+ const BUILD_DATE_OPTIONS$1 = Object.freeze({ dateStyle: "medium" });
2404
+ const databaseState = (entry) => {
2405
+ if (entry?.usable) return "ready";
2406
+ if (entry?.exists) return "unusable";
2407
+ return "missing";
2408
+ };
2409
+ const BADGE_COLOURS = Object.freeze({
2410
+ ready: { backgroundColor: "success100", textColor: "success700" },
2411
+ unusable: { backgroundColor: "warning200", textColor: "neutral800" },
2412
+ missing: { backgroundColor: "neutral150", textColor: "neutral700" }
2413
+ });
2414
+ const RiskDatabase = ({ id, title, shortName, description, entry, form, lookupOff }) => {
2415
+ const { t, locale } = useSettingsTranslate();
2416
+ const buttonRef = react.useRef(null);
2417
+ const { geoIp } = form;
2418
+ const state = databaseState(entry);
2419
+ const stateLabels = {
2420
+ ready: t("settings.config.risk.database.ready", "Ready"),
2421
+ unusable: t("settings.config.risk.database.unusable", "Cannot be read"),
2422
+ missing: t("settings.config.risk.database.missing", "Not downloaded")
2423
+ };
2424
+ const built = index.formatSessionDate(entry?.metadata?.lastModified, locale, "", BUILD_DATE_OPTIONS$1);
2425
+ const pending = geoIp.riskUpdating === id;
2426
+ const disabled = lookupOff || Boolean(geoIp.riskUpdating) || geoIp.updating || !geoIp.status?.hasCredentials || entry?.fromEnvironment === true;
2427
+ const download = async () => {
2428
+ await geoIp.updateDatabase(false, id);
2429
+ window.requestAnimationFrame(
2430
+ () => window.requestAnimationFrame(() => index.refocusIfLost(buttonRef.current, buttonRef.current))
2431
+ );
2432
+ };
2433
+ return /* @__PURE__ */ jsxRuntime.jsx(
2434
+ designSystem.Box,
2435
+ {
2436
+ padding: 4,
2437
+ hasRadius: true,
2438
+ borderColor: "neutral200",
2439
+ background: "neutral0",
2440
+ height: "100%",
2441
+ "data-risk-database": id,
2442
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, height: "100%", children: [
2443
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "flex-start", gap: 2, wrap: "wrap", children: [
2444
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", textColor: "neutral800", tag: "h3", children: title }),
2445
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { ...BADGE_COLOURS[state], children: stateLabels[state] })
2446
+ ] }),
2447
+ /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: description }),
2448
+ state === "unusable" ? /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral800", tag: "p", children: t(
2449
+ "settings.config.risk.database.unusableHint",
2450
+ "The file exists but is not this MaxMind database. Download it again."
2451
+ ) }) : null,
2452
+ built ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: t("settings.config.risk.database.built", "Built {date}", { date: built }) }) : null,
2453
+ entry?.fromEnvironment ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
2454
+ "settings.config.risk.database.fromEnvironment",
2455
+ "Read from the path in an environment variable. Update that file outside Strapi."
2456
+ ) }) : null,
2457
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginTop: "auto", children: /* @__PURE__ */ jsxRuntime.jsx(
2458
+ designSystem.Button,
2459
+ {
2460
+ ref: buttonRef,
2461
+ variant: "secondary",
2462
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Download, {}),
2463
+ loading: pending,
2464
+ disabled,
2465
+ onClick: download,
2466
+ children: state === "missing" ? t("settings.config.risk.database.download", "Download {name}", { name: shortName }) : t("settings.config.risk.database.update", "Update {name}", { name: shortName })
2467
+ }
2468
+ ) })
2469
+ ] })
2470
+ }
2471
+ );
2472
+ };
2473
+ const RiskDataCard = ({ form }) => {
2474
+ const { t } = useSettingsTranslate();
2475
+ const { settings, geoIp } = form;
2476
+ const lookupOff = !settings.enableGeolocation;
2477
+ const risk = riskData.getRiskAvailability(geoIp.status);
2478
+ const sourceLabels = {
2479
+ "anonymous-ip": t("settings.config.risk.source.anonymousIp", "Anonymous IP database"),
2480
+ "asn-heuristic": t("settings.config.risk.source.asn", "ASN heuristic")
2481
+ };
2482
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2483
+ SectionCard.SectionCard,
2484
+ {
2485
+ id: "risk-data",
2486
+ title: t("settings.config.risk.title", "Risk data (VPN, proxy, Tor)"),
2487
+ subtitle: t(
2488
+ "settings.config.risk.intro",
2489
+ "Location data cannot tell VPNs, proxies or Tor apart. A local MaxMind database can; lookups stay on this server."
2490
+ ),
2491
+ action: risk.state === "unknown" ? null : /* @__PURE__ */ jsxRuntime.jsx(
2492
+ designSystem.Badge,
2493
+ {
2494
+ backgroundColor: risk.state === "available" ? "success100" : "neutral150",
2495
+ textColor: risk.state === "available" ? "success700" : "neutral700",
2496
+ children: risk.state === "available" ? sourceLabels[risk.source] : t("settings.config.risk.source.none", "Not set up")
2497
+ }
2498
+ ),
2499
+ children: [
2500
+ lookupOff ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t("settings.config.requires.geolocation", "Requires IP location lookup") }) : null,
2501
+ /* @__PURE__ */ jsxRuntime.jsxs(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 4, children: [
2502
+ /* @__PURE__ */ jsxRuntime.jsx(
2503
+ RiskDatabase,
2504
+ {
2505
+ id: "anonymous-ip",
2506
+ title: t("settings.config.risk.anonymousIp.title", "GeoIP2 Anonymous IP"),
2507
+ shortName: t("settings.config.risk.anonymousIp.short", "Anonymous IP"),
2508
+ description: t(
2509
+ "settings.config.risk.anonymousIp.hint",
2510
+ "Paid MaxMind database. Detects VPNs, public and residential proxies, Tor exit nodes and hosting providers. The download fails if your MaxMind account does not include it."
2511
+ ),
2512
+ entry: geoIp.status?.risk?.anonymousIp,
2513
+ form,
2514
+ lookupOff
2515
+ }
2516
+ ),
2517
+ /* @__PURE__ */ jsxRuntime.jsx(
2518
+ RiskDatabase,
2519
+ {
2520
+ id: "asn",
2521
+ title: t("settings.config.risk.asn.title", "GeoLite2 ASN (heuristic)"),
2522
+ shortName: t("settings.config.risk.asn.short", "ASN"),
2523
+ description: t(
2524
+ "settings.config.risk.asn.hint",
2525
+ "Free MaxMind database. Flags sign-ins from large hosting and cloud networks such as AWS, Azure or Hetzner for alerts. A heuristic: it does not detect VPNs, proxies or Tor and never refuses a sign-in. Used only without the Anonymous IP database."
2526
+ ),
2527
+ entry: geoIp.status?.risk?.asn,
2528
+ form,
2529
+ lookupOff
2530
+ }
2531
+ )
2532
+ ] }),
2533
+ geoIp.status && !geoIp.status.hasCredentials ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t(
2534
+ "settings.config.risk.credentials",
2535
+ "Downloads use the MaxMind credentials under Provider and database. Add them first."
2536
+ ) }) : null
2537
+ ]
2538
+ }
2539
+ );
2540
+ };
2369
2541
  const LocationDataTab = ({ form }) => {
2370
2542
  const { t } = useSettingsTranslate();
2371
2543
  const { settings, handleChange } = form;
2544
+ const risk = riskData.getRiskAvailability(form.geoIp.status);
2545
+ const scoring = riskData.riskDependentControl(settings.enableSecurityScoring, risk.state);
2372
2546
  return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
2373
2547
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
2374
2548
  /* @__PURE__ */ jsxRuntime.jsx(IntroText, { children: t(
@@ -2405,16 +2579,17 @@ const LocationDataTab = ({ form }) => {
2405
2579
  title: t("settings.config.lookup.scoring.label", "Security scoring"),
2406
2580
  description: t(
2407
2581
  "settings.config.lookup.scoring.hint",
2408
- "Applies the score thresholds: below 70 triggers a suspicious-sign-in email, below 50 a rejection if enabled. Local database results always score 100."
2582
+ "Applies the score thresholds: below 70 triggers a suspicious-sign-in email, below 50 a rejection if enabled."
2409
2583
  ),
2410
- checked: settings.enableSecurityScoring,
2411
- disabled: !settings.enableGeolocation,
2584
+ checked: scoring.checked,
2585
+ disabled: !settings.enableGeolocation || scoring.disabled,
2412
2586
  onChange: (checked) => handleChange("enableSecurityScoring", checked),
2413
- children: !settings.enableGeolocation ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t("settings.config.requires.geolocation", "Requires IP location lookup") }) : null
2587
+ children: !settings.enableGeolocation ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t("settings.config.requires.geolocation", "Requires IP location lookup") }) : scoring.disabled ? /* @__PURE__ */ jsxRuntime.jsx(RiskSourceNotice, { savedOn: scoring.savedOnButInactive, tab: null }) : null
2414
2588
  }
2415
2589
  )
2416
2590
  ] }),
2417
- /* @__PURE__ */ jsxRuntime.jsx(GeoIpDatabaseCard, { form })
2591
+ /* @__PURE__ */ jsxRuntime.jsx(GeoIpDatabaseCard, { form }),
2592
+ /* @__PURE__ */ jsxRuntime.jsx(RiskDataCard, { form })
2418
2593
  ] });
2419
2594
  };
2420
2595
  const CodeTextarea = styled__default.default(designSystem.Textarea)`
@@ -2803,14 +2978,16 @@ const AlertsTab = ({ form }) => {
2803
2978
  const emailTypesDisabled = lookupOff || !settings.enableEmailAlerts;
2804
2979
  const webhookFieldsDisabled = lookupOff || !settings.enableWebhooks;
2805
2980
  const templateErrors = fieldHasError(errors, "emailTemplates");
2981
+ const risk = riskData.getRiskAvailability(form.geoIp.status);
2806
2982
  const emailTypes = [
2807
2983
  {
2808
2984
  field: "alertOnSuspiciousLogin",
2985
+ needsRiskData: true,
2809
2986
  hintId: hintIds.suspicious,
2810
2987
  label: t("settings.config.email.suspicious.label", "Suspicious sign-in"),
2811
2988
  hint: t(
2812
2989
  "settings.config.email.suspicious.hint",
2813
- "VPN, proxy or threat address, or a score below 70 with scoring on."
2990
+ "VPN, proxy, Tor or hosting address, or a score below 70 with scoring on."
2814
2991
  )
2815
2992
  },
2816
2993
  {
@@ -2824,11 +3001,12 @@ const AlertsTab = ({ form }) => {
2824
3001
  },
2825
3002
  {
2826
3003
  field: "alertOnVpnProxy",
3004
+ needsRiskData: true,
2827
3005
  hintId: hintIds.vpnProxy,
2828
3006
  label: t("settings.config.email.vpnProxy.label", "VPN or proxy"),
2829
3007
  hint: t(
2830
3008
  "settings.config.email.vpnProxy.hint",
2831
- "Needs ipapi.co data; the local database does not detect VPNs or proxies."
3009
+ "Sign-in from a VPN, or from a public or residential proxy."
2832
3010
  )
2833
3011
  }
2834
3012
  ];
@@ -2867,19 +3045,24 @@ const AlertsTab = ({ form }) => {
2867
3045
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 3, children: [
2868
3046
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", tag: "div", textColor: "neutral800", children: t("settings.config.email.types.label", "Send an email for") }),
2869
3047
  !lookupOff && !settings.enableEmailAlerts ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t("settings.config.requires.emailAlerts", "Requires Send security emails") }) : null,
2870
- /* @__PURE__ */ jsxRuntime.jsx(EmailTypeGrid, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: emailTypes.map(({ field, hintId, label, hint }) => /* @__PURE__ */ jsxRuntime.jsxs(AlertTypeCell, { checked: settings[field], disabled: emailTypesDisabled, children: [
2871
- /* @__PURE__ */ jsxRuntime.jsx(
2872
- designSystem.Checkbox,
2873
- {
2874
- checked: settings[field],
2875
- disabled: emailTypesDisabled,
2876
- "aria-describedby": hintId,
2877
- onCheckedChange: (checked) => handleChange(field, checked === true),
2878
- children: label
2879
- }
2880
- ),
2881
- /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { id: hintId, variant: "pi", textColor: "neutral600", tag: "p", children: hint })
2882
- ] }, field)) }) })
3048
+ /* @__PURE__ */ jsxRuntime.jsx(EmailTypeGrid, { children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: emailTypes.map(({ field, needsRiskData, hintId, label, hint }) => {
3049
+ const control = needsRiskData ? riskData.riskDependentControl(settings[field], risk.state) : { checked: settings[field], disabled: false, savedOnButInactive: false };
3050
+ const disabled = emailTypesDisabled || control.disabled;
3051
+ return /* @__PURE__ */ jsxRuntime.jsxs(AlertTypeCell, { checked: control.checked, disabled, children: [
3052
+ /* @__PURE__ */ jsxRuntime.jsx(
3053
+ designSystem.Checkbox,
3054
+ {
3055
+ checked: control.checked,
3056
+ disabled,
3057
+ "aria-describedby": hintId,
3058
+ onCheckedChange: (checked) => handleChange(field, checked === true),
3059
+ children: label
3060
+ }
3061
+ ),
3062
+ /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { id: hintId, variant: "pi", textColor: "neutral600", tag: "p", children: hint }),
3063
+ !lookupOff && control.disabled ? /* @__PURE__ */ jsxRuntime.jsx(RiskSourceNotice, { savedOn: control.savedOnButInactive }) : null
3064
+ ] }, field);
3065
+ }) }) })
2883
3066
  ] }),
2884
3067
  /* @__PURE__ */ jsxRuntime.jsxs(
2885
3068
  AdvancedSection,
@@ -2924,6 +3107,11 @@ const AlertsTab = ({ form }) => {
2924
3107
  }
2925
3108
  ),
2926
3109
  !lookupOff && !settings.enableWebhooks ? /* @__PURE__ */ jsxRuntime.jsx(RequiresNotice, { children: t("settings.config.requires.webhooks", "Requires Send team notifications") }) : null,
3110
+ !lookupOff && risk.state === "missing" ? /* @__PURE__ */ jsxRuntime.jsx(index.ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", "data-risk-webhook-note": "", children: t(
3111
+ "settings.config.webhooks.noRiskData",
3112
+ "Without a risk data source, {suspicious} is never sent.",
3113
+ WEBHOOK_EVENTS
3114
+ ) }) : null,
2927
3115
  /* @__PURE__ */ jsxRuntime.jsxs(index.EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: [
2928
3116
  /* @__PURE__ */ jsxRuntime.jsx(
2929
3117
  FormField,
@@ -3100,6 +3288,7 @@ function useSettingsForm() {
3100
3288
  const [geoIpStatusError, setGeoIpStatusError] = react.useState(false);
3101
3289
  const [geoIpCredentials, setGeoIpCredentials] = react.useState({ accountId: "", licenseKey: "" });
3102
3290
  const [geoIpUpdating, setGeoIpUpdating] = react.useState(false);
3291
+ const [riskUpdating, setRiskUpdating] = react.useState(null);
3103
3292
  const [geoIpSavingCredentials, setGeoIpSavingCredentials] = react.useState(false);
3104
3293
  const [settings, setSettings] = react.useState(INITIAL_SETTINGS);
3105
3294
  const [savedSettings, setSavedSettings] = react.useState(settings);
@@ -3318,17 +3507,20 @@ function useSettingsForm() {
3318
3507
  }
3319
3508
  }, [put, t, toggleNotification, fetchGeoIpStatus]);
3320
3509
  const handleUpdateGeoIpDatabase = react.useCallback(
3321
- async (force = false) => {
3322
- setGeoIpUpdating(true);
3510
+ async (force = false, database = "location") => {
3511
+ const setPending = database === "location" ? setGeoIpUpdating : setRiskUpdating;
3512
+ setPending(database === "location" ? true : database);
3323
3513
  try {
3324
- const response = await post(`/${index.pluginId}/geoip/update`, { force });
3514
+ const body = database === "location" ? { force } : { force, database };
3515
+ const response = await post(`/${index.pluginId}/geoip/update`, body);
3325
3516
  index.requireSuccessfulMutation(response.data);
3326
3517
  const status = await fetchGeoIpStatus();
3327
3518
  const result = response.data.result || {};
3519
+ const riskEntry = database === "anonymous-ip" ? status?.risk?.anonymousIp : database === "asn" ? status?.risk?.asn : null;
3328
3520
  const values = {
3329
- edition: status?.editionId || "—",
3521
+ edition: (riskEntry || status)?.editionId || "—",
3330
3522
  date: index.formatSessionDate(
3331
- result.lastModified || status?.metadata?.lastModified,
3523
+ result.lastModified || (riskEntry || status)?.metadata?.lastModified,
3332
3524
  locale,
3333
3525
  "—",
3334
3526
  BUILD_DATE_OPTIONS
@@ -3356,7 +3548,7 @@ function useSettingsForm() {
3356
3548
  )
3357
3549
  });
3358
3550
  } finally {
3359
- setGeoIpUpdating(false);
3551
+ setPending(database === "location" ? false : null);
3360
3552
  }
3361
3553
  },
3362
3554
  [post, t, locale, toggleNotification, fetchGeoIpStatus]
@@ -3388,6 +3580,7 @@ function useSettingsForm() {
3388
3580
  credentials: geoIpCredentials,
3389
3581
  setCredentials: setGeoIpCredentials,
3390
3582
  updating: geoIpUpdating,
3583
+ riskUpdating,
3391
3584
  savingCredentials: geoIpSavingCredentials,
3392
3585
  fetchStatus: fetchGeoIpStatus,
3393
3586
  saveCredentials: handleSaveGeoIpCredentials,