strapi-plugin-magic-sessionmanager 4.14.2 → 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 +64 -0
  2. package/README.md +151 -79
  3. package/dist/admin/{Analytics-Box2STtg.js → Analytics-Dbs5QXLb.js} +1 -1
  4. package/dist/admin/{Analytics-DfDdcjMe.mjs → Analytics-HK6_TEmk.mjs} +1 -1
  5. package/dist/admin/{App-DzxXcTYs.js → App-7SxOBJP5.js} +63 -29
  6. package/dist/admin/{App-B2JIOiNM.mjs → App-BOFzZ5d8.mjs} +64 -30
  7. package/dist/admin/{OnlineUsersWidget-BOd7p_MF.mjs → OnlineUsersWidget-CoCxnww-.mjs} +1 -1
  8. package/dist/admin/{OnlineUsersWidget-D4M4D6rm.js → OnlineUsersWidget-Dns_74xJ.js} +1 -1
  9. package/dist/admin/{Settings-DNgH9qRy.js → Settings-B6CrR-07.js} +257 -64
  10. package/dist/admin/{Settings-BFdr77zD.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-CmW1DJ0c.js → index-CNSJITRX.js} +9 -9
  20. package/dist/admin/{index-C2SrNW6I.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 +3 -3
  30. package/scripts/geoip-updater.cjs +58 -15
@@ -2,11 +2,12 @@ import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
2
2
  import { useState, useCallback, createContext, useContext, useMemo, useId, Fragment, useRef, useEffect, useLayoutEffect } from "react";
3
3
  import { Field, Typography, Switch, Box, TextInput, Flex, Button, Link, SingleSelect, SingleSelectOption, Accordion, Alert, Badge, Radio, Dialog, Tag, Combobox, ComboboxOption, NumberInput, Divider, Tabs, Textarea, Checkbox } from "@strapi/design-system";
4
4
  import { ConfirmDialog, useNotification, useFetchClient, useQueryParams, Page, Form, Blocker, useForm } from "@strapi/strapi/admin";
5
- import { EyeStriked, Eye, Key, Duplicate, Cross, Plus, Trash, Check } from "@strapi/icons";
5
+ import { EyeStriked, Eye, Key, Duplicate, Cross, Plus, Trash, Download, Check } from "@strapi/icons";
6
6
  import styled from "styled-components";
7
- import { F as ReadableParagraphs, b as getTranslation, m as logSafeAdminError, R as ReadableText, G as EqualGrid, n as PersistentAlert, P as PropertyList, H as formatSessionDate, C as ConfirmAction, I as refocusIfLost, l as pluginId, s as isCancelledRequest, J as requireSuccessfulMutation, w as PageShell } from "./index-C2SrNW6I.mjs";
7
+ import { F as ReadableParagraphs, b as getTranslation, m as logSafeAdminError, R as ReadableText, G as EqualGrid, n as PersistentAlert, P as PropertyList, H as formatSessionDate, C as ConfirmAction, I as refocusIfLost, l as pluginId, s as isCancelledRequest, J as requireSuccessfulMutation, w as PageShell } from "./index-lnZBc5n0.mjs";
8
8
  import { useIntl } from "react-intl";
9
9
  import { S as SectionCard } from "./SectionCard-D51bv4Hi.mjs";
10
+ import { g as getRiskAvailability, r as riskDependentControl } from "./riskData-CI1gm2yI.mjs";
10
11
  const SETTINGS_TAB_IDS = Object.freeze([
11
12
  "sessions",
12
13
  "login-protection",
@@ -589,6 +590,16 @@ const RequiresGeolocation = () => {
589
590
  const { t } = useSettingsTranslate();
590
591
  return /* @__PURE__ */ jsx(RequiresNotice, { tab: "location-data", children: t("settings.config.requires.geolocation", "Requires IP location lookup") });
591
592
  };
593
+ const RiskSourceNotice = ({ savedOn = false, tab = "location-data" }) => {
594
+ const { t } = useSettingsTranslate();
595
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 1, "data-risk-source-notice": "", children: [
596
+ /* @__PURE__ */ jsx(RequiresNotice, { tab: tab || void 0, children: t("settings.config.requires.riskData", "Needs a risk data source") }),
597
+ savedOn ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
598
+ "settings.config.requires.riskData.savedOn",
599
+ "Saved as on. It takes effect once a risk data source is set up."
600
+ ) }) : null
601
+ ] });
602
+ };
592
603
  const AdvancedTrigger = styled(Accordion.Trigger)`
593
604
  &&:focus-visible {
594
605
  outline: 2px solid ${({ theme }) => theme.colors.primary600};
@@ -1879,6 +1890,9 @@ const LoginProtectionTab = ({ form }) => {
1879
1890
  const maxFailedError = tError(errors.maxFailedLogins);
1880
1891
  const maxFailedValue = Number(settings.maxFailedLogins);
1881
1892
  const lookupOff = !settings.enableGeolocation;
1893
+ const risk = getRiskAvailability(form.geoIp.status);
1894
+ const reject = riskDependentControl(settings.blockSuspiciousSessions, risk.state);
1895
+ const autoStillRejects = reject.savedOnButInactive && (settings.geoLookupFailureMode || "auto") === "auto";
1882
1896
  return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
1883
1897
  /* @__PURE__ */ jsx(IntroText, { children: t(
1884
1898
  "settings.config.loginProtection.intro",
@@ -1978,6 +1992,23 @@ const LoginProtectionTab = ({ form }) => {
1978
1992
  subtitle: t("settings.config.suspicious.intro", "Refuses new sign-ins that look risky."),
1979
1993
  children: [
1980
1994
  lookupOff ? /* @__PURE__ */ jsx(RequiresGeolocation, {}) : null,
1995
+ !lookupOff && risk.state === "missing" ? /* @__PURE__ */ jsxs(
1996
+ PersistentAlert,
1997
+ {
1998
+ variant: "default",
1999
+ closeLabel: t("common.close", "Close"),
2000
+ title: t("settings.config.risk.missing.title", "No risk data source"),
2001
+ "data-risk-missing": "",
2002
+ children: [
2003
+ t(
2004
+ "settings.config.risk.missing.body",
2005
+ "VPN, proxy and Tor detection needs a risk data source. Until one is set up, no sign-in is refused as suspicious."
2006
+ ),
2007
+ " ",
2008
+ /* @__PURE__ */ jsx(SettingsTabLink, { tab: "location-data", children: t("settings.config.risk.missing.link", "Set up risk data") })
2009
+ ]
2010
+ }
2011
+ ) : null,
1981
2012
  /* @__PURE__ */ jsx(
1982
2013
  SettingsToggleRow,
1983
2014
  {
@@ -1985,45 +2016,48 @@ const LoginProtectionTab = ({ form }) => {
1985
2016
  title: t("settings.config.suspicious.reject.label", "Reject suspicious sign-ins"),
1986
2017
  description: t(
1987
2018
  "settings.config.suspicious.reject.hint",
1988
- "Refuses sign-ins from VPN, proxy or known threat addresses and, with security scoring on, scores below 50."
2019
+ "Refuses sign-ins from VPN, proxy or Tor addresses and, with security scoring on, scores below 50. Hosting networks only trigger alerts."
1989
2020
  ),
1990
- checked: settings.blockSuspiciousSessions,
1991
- disabled: lookupOff,
2021
+ checked: reject.checked,
2022
+ disabled: lookupOff || reject.disabled,
1992
2023
  onChange: (checked) => handleChange("blockSuspiciousSessions", checked),
1993
- children: settings.geoIpProvider === "local-mmdb" ? /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
1994
- "settings.config.suspicious.reject.localNote",
1995
- "The local database has no VPN, proxy or threat data and always scores 100, so only failed lookups can be refused."
1996
- ) }) : null
2024
+ children: !lookupOff && reject.disabled ? /* @__PURE__ */ jsx(RiskSourceNotice, { savedOn: reject.savedOnButInactive }) : null
1997
2025
  }
1998
2026
  ),
1999
- /* @__PURE__ */ jsx(AdvancedSection, { hasError: fieldHasError(errors, "geoLookupFailureMode"), children: /* @__PURE__ */ jsx(EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: /* @__PURE__ */ jsx(
2000
- FormField,
2001
- {
2002
- id: "geoip-lookup-failure-mode",
2003
- name: "geoLookupFailureMode",
2004
- label: t(
2005
- "settings.config.suspicious.failureMode.label",
2006
- "If the location cannot be determined"
2007
- ),
2008
- description: t(
2009
- "settings.config.suspicious.failureMode.hint",
2010
- "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."
2011
- ),
2012
- children: /* @__PURE__ */ jsxs(
2013
- SingleSelect,
2014
- {
2015
- value: settings.geoLookupFailureMode || "auto",
2016
- disabled: lookupOff,
2017
- onChange: (value) => handleChange("geoLookupFailureMode", value),
2018
- children: [
2019
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "auto", children: t("settings.config.suspicious.failureMode.auto", "Automatic") }),
2020
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "allow", children: t("settings.config.suspicious.failureMode.allow", "Allow sign-in") }),
2021
- /* @__PURE__ */ jsx(SingleSelectOption, { value: "block", children: t("settings.config.suspicious.failureMode.block", "Reject sign-in") })
2022
- ]
2023
- }
2024
- )
2025
- }
2026
- ) }) })
2027
+ /* @__PURE__ */ jsxs(AdvancedSection, { hasError: fieldHasError(errors, "geoLookupFailureMode"), children: [
2028
+ /* @__PURE__ */ jsx(EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: /* @__PURE__ */ jsx(
2029
+ FormField,
2030
+ {
2031
+ id: "geoip-lookup-failure-mode",
2032
+ name: "geoLookupFailureMode",
2033
+ label: t(
2034
+ "settings.config.suspicious.failureMode.label",
2035
+ "If the location cannot be determined"
2036
+ ),
2037
+ description: t(
2038
+ "settings.config.suspicious.failureMode.hint",
2039
+ "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."
2040
+ ),
2041
+ children: /* @__PURE__ */ jsxs(
2042
+ SingleSelect,
2043
+ {
2044
+ value: settings.geoLookupFailureMode || "auto",
2045
+ disabled: lookupOff,
2046
+ onChange: (value) => handleChange("geoLookupFailureMode", value),
2047
+ children: [
2048
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "auto", children: t("settings.config.suspicious.failureMode.auto", "Automatic") }),
2049
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "allow", children: t("settings.config.suspicious.failureMode.allow", "Allow sign-in") }),
2050
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "block", children: t("settings.config.suspicious.failureMode.block", "Reject sign-in") })
2051
+ ]
2052
+ }
2053
+ )
2054
+ }
2055
+ ) }),
2056
+ autoStillRejects ? /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral700", tag: "p", "data-auto-still-rejects": "", children: t(
2057
+ "settings.config.suspicious.failureMode.savedOnNote",
2058
+ "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."
2059
+ ) }) : null
2060
+ ] })
2027
2061
  ]
2028
2062
  }
2029
2063
  ),
@@ -2088,7 +2122,7 @@ const LoginProtectionTab = ({ form }) => {
2088
2122
  ] })
2089
2123
  ] });
2090
2124
  };
2091
- const BUILD_DATE_OPTIONS$1 = Object.freeze({ dateStyle: "medium" });
2125
+ const BUILD_DATE_OPTIONS$2 = Object.freeze({ dateStyle: "medium" });
2092
2126
  const PathValue = ({ path }) => {
2093
2127
  const parts = String(path).split("/");
2094
2128
  return /* @__PURE__ */ jsx(Typography, { variant: "omega", textColor: "neutral800", children: parts.map((part, index) => /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -2199,7 +2233,7 @@ const GeoIpDatabaseCard = ({ form }) => {
2199
2233
  geoIpStatus.metadata?.lastModified,
2200
2234
  locale,
2201
2235
  "",
2202
- BUILD_DATE_OPTIONS$1
2236
+ BUILD_DATE_OPTIONS$2
2203
2237
  )
2204
2238
  },
2205
2239
  {
@@ -2362,9 +2396,149 @@ const GeoIpDatabaseCard = ({ form }) => {
2362
2396
  }
2363
2397
  );
2364
2398
  };
2399
+ const BUILD_DATE_OPTIONS$1 = Object.freeze({ dateStyle: "medium" });
2400
+ const databaseState = (entry) => {
2401
+ if (entry?.usable) return "ready";
2402
+ if (entry?.exists) return "unusable";
2403
+ return "missing";
2404
+ };
2405
+ const BADGE_COLOURS = Object.freeze({
2406
+ ready: { backgroundColor: "success100", textColor: "success700" },
2407
+ unusable: { backgroundColor: "warning200", textColor: "neutral800" },
2408
+ missing: { backgroundColor: "neutral150", textColor: "neutral700" }
2409
+ });
2410
+ const RiskDatabase = ({ id, title, shortName, description, entry, form, lookupOff }) => {
2411
+ const { t, locale } = useSettingsTranslate();
2412
+ const buttonRef = useRef(null);
2413
+ const { geoIp } = form;
2414
+ const state = databaseState(entry);
2415
+ const stateLabels = {
2416
+ ready: t("settings.config.risk.database.ready", "Ready"),
2417
+ unusable: t("settings.config.risk.database.unusable", "Cannot be read"),
2418
+ missing: t("settings.config.risk.database.missing", "Not downloaded")
2419
+ };
2420
+ const built = formatSessionDate(entry?.metadata?.lastModified, locale, "", BUILD_DATE_OPTIONS$1);
2421
+ const pending = geoIp.riskUpdating === id;
2422
+ const disabled = lookupOff || Boolean(geoIp.riskUpdating) || geoIp.updating || !geoIp.status?.hasCredentials || entry?.fromEnvironment === true;
2423
+ const download = async () => {
2424
+ await geoIp.updateDatabase(false, id);
2425
+ window.requestAnimationFrame(
2426
+ () => window.requestAnimationFrame(() => refocusIfLost(buttonRef.current, buttonRef.current))
2427
+ );
2428
+ };
2429
+ return /* @__PURE__ */ jsx(
2430
+ Box,
2431
+ {
2432
+ padding: 4,
2433
+ hasRadius: true,
2434
+ borderColor: "neutral200",
2435
+ background: "neutral0",
2436
+ height: "100%",
2437
+ "data-risk-database": id,
2438
+ children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 3, height: "100%", children: [
2439
+ /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "flex-start", gap: 2, wrap: "wrap", children: [
2440
+ /* @__PURE__ */ jsx(Typography, { variant: "omega", fontWeight: "bold", textColor: "neutral800", tag: "h3", children: title }),
2441
+ /* @__PURE__ */ jsx(Badge, { ...BADGE_COLOURS[state], children: stateLabels[state] })
2442
+ ] }),
2443
+ /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", children: description }),
2444
+ state === "unusable" ? /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral800", tag: "p", children: t(
2445
+ "settings.config.risk.database.unusableHint",
2446
+ "The file exists but is not this MaxMind database. Download it again."
2447
+ ) }) : null,
2448
+ built ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: t("settings.config.risk.database.built", "Built {date}", { date: built }) }) : null,
2449
+ entry?.fromEnvironment ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", tag: "p", children: t(
2450
+ "settings.config.risk.database.fromEnvironment",
2451
+ "Read from the path in an environment variable. Update that file outside Strapi."
2452
+ ) }) : null,
2453
+ /* @__PURE__ */ jsx(Box, { marginTop: "auto", children: /* @__PURE__ */ jsx(
2454
+ Button,
2455
+ {
2456
+ ref: buttonRef,
2457
+ variant: "secondary",
2458
+ startIcon: /* @__PURE__ */ jsx(Download, {}),
2459
+ loading: pending,
2460
+ disabled,
2461
+ onClick: download,
2462
+ children: state === "missing" ? t("settings.config.risk.database.download", "Download {name}", { name: shortName }) : t("settings.config.risk.database.update", "Update {name}", { name: shortName })
2463
+ }
2464
+ ) })
2465
+ ] })
2466
+ }
2467
+ );
2468
+ };
2469
+ const RiskDataCard = ({ form }) => {
2470
+ const { t } = useSettingsTranslate();
2471
+ const { settings, geoIp } = form;
2472
+ const lookupOff = !settings.enableGeolocation;
2473
+ const risk = getRiskAvailability(geoIp.status);
2474
+ const sourceLabels = {
2475
+ "anonymous-ip": t("settings.config.risk.source.anonymousIp", "Anonymous IP database"),
2476
+ "asn-heuristic": t("settings.config.risk.source.asn", "ASN heuristic")
2477
+ };
2478
+ return /* @__PURE__ */ jsxs(
2479
+ SectionCard,
2480
+ {
2481
+ id: "risk-data",
2482
+ title: t("settings.config.risk.title", "Risk data (VPN, proxy, Tor)"),
2483
+ subtitle: t(
2484
+ "settings.config.risk.intro",
2485
+ "Location data cannot tell VPNs, proxies or Tor apart. A local MaxMind database can; lookups stay on this server."
2486
+ ),
2487
+ action: risk.state === "unknown" ? null : /* @__PURE__ */ jsx(
2488
+ Badge,
2489
+ {
2490
+ backgroundColor: risk.state === "available" ? "success100" : "neutral150",
2491
+ textColor: risk.state === "available" ? "success700" : "neutral700",
2492
+ children: risk.state === "available" ? sourceLabels[risk.source] : t("settings.config.risk.source.none", "Not set up")
2493
+ }
2494
+ ),
2495
+ children: [
2496
+ lookupOff ? /* @__PURE__ */ jsx(RequiresNotice, { children: t("settings.config.requires.geolocation", "Requires IP location lookup") }) : null,
2497
+ /* @__PURE__ */ jsxs(EqualGrid, { columns: 2, stackBelow: "medium", gap: 4, children: [
2498
+ /* @__PURE__ */ jsx(
2499
+ RiskDatabase,
2500
+ {
2501
+ id: "anonymous-ip",
2502
+ title: t("settings.config.risk.anonymousIp.title", "GeoIP2 Anonymous IP"),
2503
+ shortName: t("settings.config.risk.anonymousIp.short", "Anonymous IP"),
2504
+ description: t(
2505
+ "settings.config.risk.anonymousIp.hint",
2506
+ "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."
2507
+ ),
2508
+ entry: geoIp.status?.risk?.anonymousIp,
2509
+ form,
2510
+ lookupOff
2511
+ }
2512
+ ),
2513
+ /* @__PURE__ */ jsx(
2514
+ RiskDatabase,
2515
+ {
2516
+ id: "asn",
2517
+ title: t("settings.config.risk.asn.title", "GeoLite2 ASN (heuristic)"),
2518
+ shortName: t("settings.config.risk.asn.short", "ASN"),
2519
+ description: t(
2520
+ "settings.config.risk.asn.hint",
2521
+ "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."
2522
+ ),
2523
+ entry: geoIp.status?.risk?.asn,
2524
+ form,
2525
+ lookupOff
2526
+ }
2527
+ )
2528
+ ] }),
2529
+ geoIp.status && !geoIp.status.hasCredentials ? /* @__PURE__ */ jsx(RequiresNotice, { children: t(
2530
+ "settings.config.risk.credentials",
2531
+ "Downloads use the MaxMind credentials under Provider and database. Add them first."
2532
+ ) }) : null
2533
+ ]
2534
+ }
2535
+ );
2536
+ };
2365
2537
  const LocationDataTab = ({ form }) => {
2366
2538
  const { t } = useSettingsTranslate();
2367
2539
  const { settings, handleChange } = form;
2540
+ const risk = getRiskAvailability(form.geoIp.status);
2541
+ const scoring = riskDependentControl(settings.enableSecurityScoring, risk.state);
2368
2542
  return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
2369
2543
  /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: [
2370
2544
  /* @__PURE__ */ jsx(IntroText, { children: t(
@@ -2401,16 +2575,17 @@ const LocationDataTab = ({ form }) => {
2401
2575
  title: t("settings.config.lookup.scoring.label", "Security scoring"),
2402
2576
  description: t(
2403
2577
  "settings.config.lookup.scoring.hint",
2404
- "Applies the score thresholds: below 70 triggers a suspicious-sign-in email, below 50 a rejection if enabled. Local database results always score 100."
2578
+ "Applies the score thresholds: below 70 triggers a suspicious-sign-in email, below 50 a rejection if enabled."
2405
2579
  ),
2406
- checked: settings.enableSecurityScoring,
2407
- disabled: !settings.enableGeolocation,
2580
+ checked: scoring.checked,
2581
+ disabled: !settings.enableGeolocation || scoring.disabled,
2408
2582
  onChange: (checked) => handleChange("enableSecurityScoring", checked),
2409
- children: !settings.enableGeolocation ? /* @__PURE__ */ jsx(RequiresNotice, { children: t("settings.config.requires.geolocation", "Requires IP location lookup") }) : null
2583
+ children: !settings.enableGeolocation ? /* @__PURE__ */ jsx(RequiresNotice, { children: t("settings.config.requires.geolocation", "Requires IP location lookup") }) : scoring.disabled ? /* @__PURE__ */ jsx(RiskSourceNotice, { savedOn: scoring.savedOnButInactive, tab: null }) : null
2410
2584
  }
2411
2585
  )
2412
2586
  ] }),
2413
- /* @__PURE__ */ jsx(GeoIpDatabaseCard, { form })
2587
+ /* @__PURE__ */ jsx(GeoIpDatabaseCard, { form }),
2588
+ /* @__PURE__ */ jsx(RiskDataCard, { form })
2414
2589
  ] });
2415
2590
  };
2416
2591
  const CodeTextarea = styled(Textarea)`
@@ -2799,14 +2974,16 @@ const AlertsTab = ({ form }) => {
2799
2974
  const emailTypesDisabled = lookupOff || !settings.enableEmailAlerts;
2800
2975
  const webhookFieldsDisabled = lookupOff || !settings.enableWebhooks;
2801
2976
  const templateErrors = fieldHasError(errors, "emailTemplates");
2977
+ const risk = getRiskAvailability(form.geoIp.status);
2802
2978
  const emailTypes = [
2803
2979
  {
2804
2980
  field: "alertOnSuspiciousLogin",
2981
+ needsRiskData: true,
2805
2982
  hintId: hintIds.suspicious,
2806
2983
  label: t("settings.config.email.suspicious.label", "Suspicious sign-in"),
2807
2984
  hint: t(
2808
2985
  "settings.config.email.suspicious.hint",
2809
- "VPN, proxy or threat address, or a score below 70 with scoring on."
2986
+ "VPN, proxy, Tor or hosting address, or a score below 70 with scoring on."
2810
2987
  )
2811
2988
  },
2812
2989
  {
@@ -2820,11 +2997,12 @@ const AlertsTab = ({ form }) => {
2820
2997
  },
2821
2998
  {
2822
2999
  field: "alertOnVpnProxy",
3000
+ needsRiskData: true,
2823
3001
  hintId: hintIds.vpnProxy,
2824
3002
  label: t("settings.config.email.vpnProxy.label", "VPN or proxy"),
2825
3003
  hint: t(
2826
3004
  "settings.config.email.vpnProxy.hint",
2827
- "Needs ipapi.co data; the local database does not detect VPNs or proxies."
3005
+ "Sign-in from a VPN, or from a public or residential proxy."
2828
3006
  )
2829
3007
  }
2830
3008
  ];
@@ -2863,19 +3041,24 @@ const AlertsTab = ({ form }) => {
2863
3041
  /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 3, children: [
2864
3042
  /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", tag: "div", textColor: "neutral800", children: t("settings.config.email.types.label", "Send an email for") }),
2865
3043
  !lookupOff && !settings.enableEmailAlerts ? /* @__PURE__ */ jsx(RequiresNotice, { children: t("settings.config.requires.emailAlerts", "Requires Send security emails") }) : null,
2866
- /* @__PURE__ */ jsx(EmailTypeGrid, { children: /* @__PURE__ */ jsx("div", { children: emailTypes.map(({ field, hintId, label, hint }) => /* @__PURE__ */ jsxs(AlertTypeCell, { checked: settings[field], disabled: emailTypesDisabled, children: [
2867
- /* @__PURE__ */ jsx(
2868
- Checkbox,
2869
- {
2870
- checked: settings[field],
2871
- disabled: emailTypesDisabled,
2872
- "aria-describedby": hintId,
2873
- onCheckedChange: (checked) => handleChange(field, checked === true),
2874
- children: label
2875
- }
2876
- ),
2877
- /* @__PURE__ */ jsx(ReadableText, { id: hintId, variant: "pi", textColor: "neutral600", tag: "p", children: hint })
2878
- ] }, field)) }) })
3044
+ /* @__PURE__ */ jsx(EmailTypeGrid, { children: /* @__PURE__ */ jsx("div", { children: emailTypes.map(({ field, needsRiskData, hintId, label, hint }) => {
3045
+ const control = needsRiskData ? riskDependentControl(settings[field], risk.state) : { checked: settings[field], disabled: false, savedOnButInactive: false };
3046
+ const disabled = emailTypesDisabled || control.disabled;
3047
+ return /* @__PURE__ */ jsxs(AlertTypeCell, { checked: control.checked, disabled, children: [
3048
+ /* @__PURE__ */ jsx(
3049
+ Checkbox,
3050
+ {
3051
+ checked: control.checked,
3052
+ disabled,
3053
+ "aria-describedby": hintId,
3054
+ onCheckedChange: (checked) => handleChange(field, checked === true),
3055
+ children: label
3056
+ }
3057
+ ),
3058
+ /* @__PURE__ */ jsx(ReadableText, { id: hintId, variant: "pi", textColor: "neutral600", tag: "p", children: hint }),
3059
+ !lookupOff && control.disabled ? /* @__PURE__ */ jsx(RiskSourceNotice, { savedOn: control.savedOnButInactive }) : null
3060
+ ] }, field);
3061
+ }) }) })
2879
3062
  ] }),
2880
3063
  /* @__PURE__ */ jsxs(
2881
3064
  AdvancedSection,
@@ -2920,6 +3103,11 @@ const AlertsTab = ({ form }) => {
2920
3103
  }
2921
3104
  ),
2922
3105
  !lookupOff && !settings.enableWebhooks ? /* @__PURE__ */ jsx(RequiresNotice, { children: t("settings.config.requires.webhooks", "Requires Send team notifications") }) : null,
3106
+ !lookupOff && risk.state === "missing" ? /* @__PURE__ */ jsx(ReadableText, { variant: "pi", textColor: "neutral600", tag: "p", "data-risk-webhook-note": "", children: t(
3107
+ "settings.config.webhooks.noRiskData",
3108
+ "Without a risk data source, {suspicious} is never sent.",
3109
+ WEBHOOK_EVENTS
3110
+ ) }) : null,
2923
3111
  /* @__PURE__ */ jsxs(EqualGrid, { columns: 2, stackBelow: "medium", gap: 6, children: [
2924
3112
  /* @__PURE__ */ jsx(
2925
3113
  FormField,
@@ -3096,6 +3284,7 @@ function useSettingsForm() {
3096
3284
  const [geoIpStatusError, setGeoIpStatusError] = useState(false);
3097
3285
  const [geoIpCredentials, setGeoIpCredentials] = useState({ accountId: "", licenseKey: "" });
3098
3286
  const [geoIpUpdating, setGeoIpUpdating] = useState(false);
3287
+ const [riskUpdating, setRiskUpdating] = useState(null);
3099
3288
  const [geoIpSavingCredentials, setGeoIpSavingCredentials] = useState(false);
3100
3289
  const [settings, setSettings] = useState(INITIAL_SETTINGS);
3101
3290
  const [savedSettings, setSavedSettings] = useState(settings);
@@ -3314,17 +3503,20 @@ function useSettingsForm() {
3314
3503
  }
3315
3504
  }, [put, t, toggleNotification, fetchGeoIpStatus]);
3316
3505
  const handleUpdateGeoIpDatabase = useCallback(
3317
- async (force = false) => {
3318
- setGeoIpUpdating(true);
3506
+ async (force = false, database = "location") => {
3507
+ const setPending = database === "location" ? setGeoIpUpdating : setRiskUpdating;
3508
+ setPending(database === "location" ? true : database);
3319
3509
  try {
3320
- const response = await post(`/${pluginId}/geoip/update`, { force });
3510
+ const body = database === "location" ? { force } : { force, database };
3511
+ const response = await post(`/${pluginId}/geoip/update`, body);
3321
3512
  requireSuccessfulMutation(response.data);
3322
3513
  const status = await fetchGeoIpStatus();
3323
3514
  const result = response.data.result || {};
3515
+ const riskEntry = database === "anonymous-ip" ? status?.risk?.anonymousIp : database === "asn" ? status?.risk?.asn : null;
3324
3516
  const values = {
3325
- edition: status?.editionId || "—",
3517
+ edition: (riskEntry || status)?.editionId || "—",
3326
3518
  date: formatSessionDate(
3327
- result.lastModified || status?.metadata?.lastModified,
3519
+ result.lastModified || (riskEntry || status)?.metadata?.lastModified,
3328
3520
  locale,
3329
3521
  "—",
3330
3522
  BUILD_DATE_OPTIONS
@@ -3352,7 +3544,7 @@ function useSettingsForm() {
3352
3544
  )
3353
3545
  });
3354
3546
  } finally {
3355
- setGeoIpUpdating(false);
3547
+ setPending(database === "location" ? false : null);
3356
3548
  }
3357
3549
  },
3358
3550
  [post, t, locale, toggleNotification, fetchGeoIpStatus]
@@ -3384,6 +3576,7 @@ function useSettingsForm() {
3384
3576
  credentials: geoIpCredentials,
3385
3577
  setCredentials: setGeoIpCredentials,
3386
3578
  updating: geoIpUpdating,
3579
+ riskUpdating,
3387
3580
  savingCredentials: geoIpSavingCredentials,
3388
3581
  fetchStatus: fetchGeoIpStatus,
3389
3582
  saveCredentials: handleSaveGeoIpCredentials,
@@ -235,7 +235,7 @@ const de = {
235
235
  "modal.state.endedNoTime": "Beendet · {reason}.",
236
236
  "modal.state.maxAgeNote": "Sitzungen, die älter als das maximale Sitzungsalter sind, enden bei ihrer nächsten Anfrage.",
237
237
  "modal.security.notStored": "Für frühere Anmeldungen nicht gespeichert",
238
- "modal.security.scoreNote": "Höher ist sicherer. Unter 70 kann eine E-Mail zu einer verdächtigen Anmeldung auslösen und unter 50 eine Ablehnung, sofern diese Einstellungen aktiviert sind. Ergebnisse der lokalen Datenbank sind immer 100.",
238
+ "modal.security.scoreNote": "Höher ist sicherer. Unter 70 kann eine E-Mail zu einer verdächtigen Anmeldung auslösen und unter 50 eine Ablehnung, sofern diese Einstellungen aktiviert sind.",
239
239
  "modal.security.riskLevel": "Risikostufe",
240
240
  "modal.security.lookup": "Standort abfragen",
241
241
  "modal.security.lookupHint": "Sendet die IP-Adresse an den konfigurierten Abfragedienst; das kann ipapi.co sein.",
@@ -357,8 +357,7 @@ const de = {
357
357
  "settings.config.suspicious.title": "Verdächtige Anmeldungen",
358
358
  "settings.config.suspicious.intro": "Weist neue Anmeldungen ab, die riskant wirken.",
359
359
  "settings.config.suspicious.reject.label": "Verdächtige Anmeldungen ablehnen",
360
- "settings.config.suspicious.reject.hint": "Weist Anmeldungen über VPN, Proxy oder bekannte Bedrohungsadressen ab und, bei aktivierter Sicherheitsbewertung, Werte unter 50.",
361
- "settings.config.suspicious.reject.localNote": "Die lokale Datenbank hat keine VPN-, Proxy- oder Bedrohungsdaten und liefert immer 100, daher können nur fehlgeschlagene Abfragen abgewiesen werden.",
360
+ "settings.config.suspicious.reject.hint": "Weist Anmeldungen über VPN-, Proxy- oder Tor-Adressen ab und, bei aktivierter Sicherheitsbewertung, Werte unter 50. Hosting-Netze lösen nur Benachrichtigungen aus.",
362
361
  "settings.config.suspicious.failureMode.label": "Wenn der Standort nicht ermittelt werden kann",
363
362
  "settings.config.suspicious.failureMode.hint": "„Automatisch“ lehnt nur ab, wenn „Verdächtige Anmeldungen ablehnen“ aktiv ist. Eine abgelehnte Anmeldung erhält die Meldung, dass die Anmeldung vorübergehend nicht verfügbar ist. Mit „Anmeldung ablehnen“ greift der automatische Anbieter nicht mehr auf ipapi.co zurück.",
364
363
  "settings.config.suspicious.failureMode.auto": "Automatisch",
@@ -390,7 +389,7 @@ const de = {
390
389
  "settings.config.lookup.enable.hint": "Ermittelt Land und Stadt bei jeder Anmeldung und für aufgelistete Sitzungen ohne Standort.",
391
390
  "settings.config.lookup.enable.privacy": "Mit dem Anbieter „Automatisch“ oder ipapi.co können IP-Adressen an ipapi.co gesendet werden.",
392
391
  "settings.config.lookup.scoring.label": "Sicherheitsbewertung",
393
- "settings.config.lookup.scoring.hint": "Wendet die Schwellenwerte an: unter 70 wird eine E-Mail zu einer verdächtigen Anmeldung ausgelöst, unter 50 eine Ablehnung, falls aktiviert. Ergebnisse der lokalen Datenbank liefern immer 100.",
392
+ "settings.config.lookup.scoring.hint": "Wendet die Schwellenwerte an: unter 70 wird eine E-Mail zu einer verdächtigen Anmeldung ausgelöst, unter 50 eine Ablehnung, falls aktiviert.",
394
393
  "settings.config.provider.title": "Anbieter und Datenbank",
395
394
  "settings.config.provider.label": "Anbieter",
396
395
  "settings.config.provider.hint": "„Automatisch“ verwendet die lokale Datenbank, sonst ipapi.co, sofern fehlgeschlagene Abfragen nicht auf „ablehnen“ stehen. „Lokale Datenbank“ hält Abfragen auf diesem Server. ipapi.co sendet IP-Adressen an diesen Dienst. „Aus“ schaltet Abfragen aus.",
@@ -433,11 +432,11 @@ const de = {
433
432
  "settings.config.email.enable.label": "Sicherheits-E-Mails senden",
434
433
  "settings.config.email.types.label": "E-Mail senden bei",
435
434
  "settings.config.email.suspicious.label": "Verdächtige Anmeldung",
436
- "settings.config.email.suspicious.hint": "VPN, Proxy oder Bedrohungsadresse oder, bei aktivierter Bewertung, ein Wert unter 70.",
435
+ "settings.config.email.suspicious.hint": "VPN-, Proxy-, Tor- oder Hosting-Adresse oder, bei aktivierter Bewertung, ein Wert unter 70.",
437
436
  "settings.config.email.newCountry.label": "Anmeldung aus einem neuen Land",
438
437
  "settings.config.email.newCountry.hint": "Das Land unterscheidet sich von allen der letzten 50 Sitzungen des Benutzers. Erfordert mindestens ein früheres Land.",
439
438
  "settings.config.email.vpnProxy.label": "VPN oder Proxy",
440
- "settings.config.email.vpnProxy.hint": "Erfordert Daten von ipapi.co; die lokale Datenbank erkennt keine VPNs oder Proxys.",
439
+ "settings.config.email.vpnProxy.hint": "Anmeldung über ein VPN oder über einen öffentlichen oder privaten (Residential-)Proxy.",
441
440
  "settings.config.email.templates.label": "E-Mail-Vorlagen bearbeiten",
442
441
  "settings.config.email.templates.field": "E-Mail-Vorlagen",
443
442
  "settings.config.email.templates.warning": "Sobald eine Vorlage Inhalt hat, werden nur Ihre gespeicherten Vorlagen verwendet, und leere werden leer gesendet. Füllen Sie alle drei aus oder keine.",
@@ -619,7 +618,40 @@ const de = {
619
618
  "adminPanel.you": "Sie",
620
619
  "views.admins": "Admin-Panel",
621
620
  "views.label": "Sitzungsansichten",
622
- "views.users": "App-Benutzer"
621
+ "views.users": "App-Benutzer",
622
+ "modal.security.riskData": "VPN, Proxy und Sicherheitsbewertung",
623
+ "modal.security.riskUnavailable": "Nicht verfügbar",
624
+ "modal.security.riskUnavailableNote": "Erfordert eine Risikodatenquelle. Standortdaten allein erkennen keine VPNs, Proxys oder Tor, daher wurde keine Bewertung berechnet.",
625
+ "modal.security.riskSetup": "Risikodaten einrichten",
626
+ "settings.config.requires.riskData": "Erfordert eine Risikodatenquelle",
627
+ "settings.config.requires.riskData.savedOn": "Als aktiviert gespeichert. Die Einstellung wirkt, sobald eine Risikodatenquelle eingerichtet ist.",
628
+ "settings.config.risk.missing.title": "Keine Risikodatenquelle",
629
+ "settings.config.risk.missing.body": "Die Erkennung von VPN, Proxy und Tor erfordert eine Risikodatenquelle. Bis eine eingerichtet ist, wird keine Anmeldung als verdächtig abgelehnt.",
630
+ "settings.config.risk.missing.link": "Risikodaten einrichten",
631
+ "settings.config.suspicious.failureMode.savedOnNote": "Automatisch lehnt Anmeldungen, deren Standort nicht ermittelt werden kann, weiterhin ab, weil „Verdächtige Anmeldungen ablehnen“ als aktiviert gespeichert ist. Wählen Sie „Anmeldung zulassen“, um das zu ändern.",
632
+ "settings.config.webhooks.noRiskData": "Ohne Risikodatenquelle wird {suspicious} nie gesendet.",
633
+ "settings.config.risk.title": "Risikodaten (VPN, Proxy, Tor)",
634
+ "settings.config.risk.intro": "Standortdaten erkennen keine VPNs, Proxys oder Tor. Eine lokale MaxMind-Datenbank kann das; die Abfragen bleiben auf diesem Server.",
635
+ "settings.config.risk.source.anonymousIp": "Anonymous-IP-Datenbank",
636
+ "settings.config.risk.source.asn": "ASN-Heuristik",
637
+ "settings.config.risk.source.none": "Nicht eingerichtet",
638
+ "settings.config.risk.anonymousIp.title": "GeoIP2 Anonymous IP",
639
+ "settings.config.risk.anonymousIp.short": "Anonymous IP",
640
+ "settings.config.risk.anonymousIp.hint": "Kostenpflichtige MaxMind-Datenbank. Erkennt VPNs, öffentliche und private (Residential-)Proxys, Tor-Exit-Nodes und Hosting-Anbieter. Der Download schlägt fehl, wenn Ihr MaxMind-Konto sie nicht enthält.",
641
+ "settings.config.risk.asn.title": "GeoLite2 ASN (Heuristik)",
642
+ "settings.config.risk.asn.short": "ASN",
643
+ "settings.config.risk.asn.hint": "Kostenlose MaxMind-Datenbank. Markiert Anmeldungen aus großen Hosting- und Cloud-Netzen wie AWS, Azure oder Hetzner für Benachrichtigungen. Eine Heuristik: Sie erkennt keine VPNs, Proxys oder Tor und lehnt nie eine Anmeldung ab. Wird nur ohne die Anonymous-IP-Datenbank verwendet.",
644
+ "settings.config.risk.database.ready": "Bereit",
645
+ "settings.config.risk.database.unusable": "Nicht lesbar",
646
+ "settings.config.risk.database.missing": "Nicht heruntergeladen",
647
+ "settings.config.risk.database.unusableHint": "Die Datei existiert, ist aber nicht diese MaxMind-Datenbank. Laden Sie sie erneut herunter.",
648
+ "settings.config.risk.database.built": "Erstellt am {date}",
649
+ "settings.config.risk.database.fromEnvironment": "Wird aus dem Pfad einer Umgebungsvariable gelesen. Aktualisieren Sie diese Datei außerhalb von Strapi.",
650
+ "settings.config.risk.database.download": "{name} herunterladen",
651
+ "settings.config.risk.database.update": "{name} aktualisieren",
652
+ "settings.config.risk.credentials": "Downloads verwenden die MaxMind-Zugangsdaten unter „Anbieter und Datenbank“. Hinterlegen Sie diese zuerst.",
653
+ "modal.security.hosting": "Hosting-Netz",
654
+ "modal.security.asnHeuristicNote": "Aus der ASN-Heuristik: Sie erkennt nur große Hosting- und Cloud-Netze, keine VPNs, Proxys oder Tor."
623
655
  };
624
656
  export {
625
657
  de as default