strapi-plugin-magic-sessionmanager 4.5.12 → 4.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +90 -34
  3. package/dist/{_chunks/Analytics-DM4_UffY.js → admin/Analytics-BMkhiuRX.js} +3 -121
  4. package/dist/{_chunks/Analytics--qB2cKuD.mjs → admin/Analytics-CwNJ3TNI.mjs} +5 -123
  5. package/dist/{_chunks/App-DF-VsbDW.js → admin/App-DazHh7Zi.js} +67 -646
  6. package/dist/{_chunks/App-CL5q29Mi.mjs → admin/App-Sk0F9UEN.mjs} +69 -648
  7. package/dist/{_chunks/License-D9piCp34.mjs → admin/License-6SIpR7Rk.mjs} +34 -113
  8. package/dist/{_chunks/License-Dmm1d3fQ.js → admin/License-BwbmzbP_.js} +34 -113
  9. package/dist/{_chunks/OnlineUsersWidget-KchZ_ScS.js → admin/OnlineUsersWidget-BIfnbFcZ.js} +44 -36
  10. package/dist/{_chunks/OnlineUsersWidget-DHsthkt0.mjs → admin/OnlineUsersWidget-Qq_uCTi1.mjs} +44 -36
  11. package/dist/{_chunks/Settings-D6ILgR9X.mjs → admin/Settings-BA7S_8DF.mjs} +286 -112
  12. package/dist/{_chunks/Settings-CUNaxDWk.js → admin/Settings-CCYScjxv.js} +284 -110
  13. package/dist/{_chunks/de-CDA1V0rF.mjs → admin/de-6rIvkYOp.mjs} +37 -14
  14. package/dist/{_chunks/de-I-Q-pWqu.js → admin/de-DjP2WJ_V.js} +37 -14
  15. package/dist/{_chunks/en-Bd7_h-4e.js → admin/en-0pesBbOT.js} +37 -14
  16. package/dist/{_chunks/en-DzmOCyzQ.mjs → admin/en-8hiv31Dv.mjs} +37 -14
  17. package/dist/{_chunks/es-BcAx18XG.js → admin/es-DdBRpF7F.js} +37 -14
  18. package/dist/{_chunks/es-Cx-SN6qV.mjs → admin/es-LRQ148f5.mjs} +37 -14
  19. package/dist/{_chunks/fr-DXlXE5Eo.mjs → admin/fr-CKhx_qil.mjs} +37 -14
  20. package/dist/{_chunks/fr-DCzYMuJ-.js → admin/fr-DJ6DbeDy.js} +37 -14
  21. package/dist/{_chunks/index-CTxGMDHr.js → admin/index-DTskQVDl.js} +12 -25
  22. package/dist/{_chunks/index-CwxKazpc.mjs → admin/index-UTLA1r40.mjs} +12 -25
  23. package/dist/admin/index.js +3 -2
  24. package/dist/admin/index.mjs +1 -1
  25. package/dist/{_chunks/pt-21-MAb72.js → admin/pt-D0SMoAmo.js} +37 -14
  26. package/dist/{_chunks/pt-zsdTSjba.mjs → admin/pt-DXizUvcj.mjs} +37 -14
  27. package/dist/server/index.js +9680 -8914
  28. package/dist/server/index.mjs +9701 -8918
  29. package/package.json +25 -14
  30. package/scripts/geoip-updater.cjs +220 -0
  31. package/scripts/update-geoip-db.mjs +38 -0
  32. package/strapi-admin.js +2 -1
  33. package/strapi-server.js +2 -1
  34. package/dist/_chunks/UpgradePage-D697BVWo.mjs +0 -352
  35. package/dist/_chunks/UpgradePage-Dwrv7g8L.js +0 -354
  36. package/dist/_chunks/useLicense-B9WW9s_d.mjs +0 -86
  37. package/dist/_chunks/useLicense-BEbtA_Zo.js +0 -85
  38. /package/dist/{_chunks → admin}/StyledButtons-Cz8oYhmc.mjs +0 -0
  39. /package/dist/{_chunks → admin}/StyledButtons-DDuxnYz8.js +0 -0
@@ -7,8 +7,7 @@ const designSystem = require("@strapi/design-system");
7
7
  const admin = require("@strapi/strapi/admin");
8
8
  const icons = require("@strapi/icons");
9
9
  const styled = require("styled-components");
10
- const index = require("./index-CTxGMDHr.js");
11
- const useLicense = require("./useLicense-BEbtA_Zo.js");
10
+ const index = require("./index-DTskQVDl.js");
12
11
  const StyledButtons = require("./StyledButtons-DDuxnYz8.js");
13
12
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
14
13
  const styled__default = /* @__PURE__ */ _interopDefault(styled);
@@ -122,17 +121,17 @@ const ToggleCard = styled__default.default(designSystem.Box)`
122
121
  cursor: pointer;
123
122
  display: flex;
124
123
  align-items: center;
125
-
124
+
126
125
  &:hover {
127
126
  transform: translateY(-4px);
128
127
  box-shadow: ${(props) => props.$active ? "0 8px 30px rgba(34, 197, 94, 0.25)" : "0 6px 16px rgba(0, 0, 0, 0.12)"};
129
128
  border-color: ${(props) => props.$active ? "var(--colors-success600, #15803D)" : "rgba(128, 128, 128, 0.3)"};
130
129
  }
131
-
130
+
132
131
  &:active {
133
132
  transform: translateY(-2px);
134
133
  }
135
-
134
+
136
135
  ${(props) => props.$active && `
137
136
  &::before {
138
137
  content: 'ACTIVE';
@@ -149,7 +148,7 @@ const ToggleCard = styled__default.default(designSystem.Box)`
149
148
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.3);
150
149
  }
151
150
  `}
152
-
151
+
153
152
  ${(props) => !props.$active && `
154
153
  &::before {
155
154
  content: 'INACTIVE';
@@ -172,29 +171,29 @@ const GreenToggle = styled__default.default.div`
172
171
  button[role="switch"] {
173
172
  background-color: var(--colors-success600, #16A34A) !important;
174
173
  border-color: var(--colors-success600, #16A34A) !important;
175
-
174
+
176
175
  &:hover {
177
176
  background-color: var(--colors-success600, #15803D) !important;
178
177
  border-color: var(--colors-success600, #15803D) !important;
179
178
  }
180
-
179
+
181
180
  &:focus {
182
181
  background-color: var(--colors-success600, #16A34A) !important;
183
182
  border-color: var(--colors-success600, #16A34A) !important;
184
183
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.2) !important;
185
184
  }
186
185
  }
187
-
186
+
188
187
  /* Toggle handle */
189
188
  button[role="switch"] > span {
190
189
  background-color: white !important;
191
190
  }
192
191
  `}
193
-
192
+
194
193
  ${(props) => !props.$isActive && `
195
194
  button[role="switch"] {
196
195
  background-color: rgba(128, 128, 128, 0.2);
197
-
196
+
198
197
  &:hover {
199
198
  background-color: rgba(128, 128, 128, 0.2);
200
199
  }
@@ -261,14 +260,14 @@ const getDefaultTemplates = () => ({
261
260
  <div style="max-width: 600px; margin: 0 auto; padding: 20px; background-color: #f9fafb; border-radius: 10px;">
262
261
  <h2 style="color: #dc2626;">[ALERT] Suspicious Login Detected</h2>
263
262
  <p>A potentially suspicious login was detected for your account.</p>
264
-
263
+
265
264
  <div style="background: white; padding: 15px; border-radius: 8px; margin: 20px 0;">
266
265
  <h3 style="margin-top: 0;">Account Information:</h3>
267
266
  <ul>
268
267
  <li><strong>Email:</strong> {{user.email}}</li>
269
268
  <li><strong>Username:</strong> {{user.username}}</li>
270
269
  </ul>
271
-
270
+
272
271
  <h3>Login Details:</h3>
273
272
  <ul>
274
273
  <li><strong>Time:</strong> {{session.loginTime}}</li>
@@ -277,7 +276,7 @@ const getDefaultTemplates = () => ({
277
276
  <li><strong>Timezone:</strong> {{geo.timezone}}</li>
278
277
  <li><strong>Device:</strong> {{session.userAgent}}</li>
279
278
  </ul>
280
-
279
+
281
280
  <h3 style="color: #dc2626;">Security Alert:</h3>
282
281
  <ul>
283
282
  <li>VPN Detected: {{reason.isVpn}}</li>
@@ -286,9 +285,9 @@ const getDefaultTemplates = () => ({
286
285
  <li>Security Score: {{reason.securityScore}}/100</li>
287
286
  </ul>
288
287
  </div>
289
-
288
+
290
289
  <p>If this was you, you can safely ignore this email. If you don't recognize this activity, please secure your account immediately.</p>
291
-
290
+
292
291
  <hr style="border: none; border-top: 1px solid #e5e7eb; margin: 20px 0;"/>
293
292
  <p style="color: #666; font-size: 12px;">This is an automated security notification from Magic Session Manager.</p>
294
293
  </div>
@@ -316,11 +315,11 @@ Security: VPN={{reason.isVpn}}, Proxy={{reason.isProxy}}, Threat={{reason.isThre
316
315
  <div style="max-width: 600px; margin: 0 auto; padding: 20px; background-color: #f0f9ff; border-radius: 10px;">
317
316
  <h2 style="color: #0284c7;">[LOCATION] Login from New Location</h2>
318
317
  <p>Your account was accessed from a new location.</p>
319
-
318
+
320
319
  <div style="background: white; padding: 15px; border-radius: 8px; margin: 20px 0;">
321
320
  <h3 style="margin-top: 0;">Account:</h3>
322
321
  <p><strong>{{user.email}}</strong></p>
323
-
322
+
324
323
  <h3>New Location Details:</h3>
325
324
  <ul>
326
325
  <li><strong>Time:</strong> {{session.loginTime}}</li>
@@ -329,9 +328,9 @@ Security: VPN={{reason.isVpn}}, Proxy={{reason.isProxy}}, Threat={{reason.isThre
329
328
  <li><strong>Device:</strong> {{session.userAgent}}</li>
330
329
  </ul>
331
330
  </div>
332
-
331
+
333
332
  <p>If this was you, no action is needed. If you don't recognize this login, please secure your account.</p>
334
-
333
+
335
334
  <hr style="border: none; border-top: 1px solid #e5e7eb; margin: 20px 0;"/>
336
335
  <p style="color: #666; font-size: 12px;">Magic Session Manager notification</p>
337
336
  </div>
@@ -359,11 +358,11 @@ If this was you, no action is needed.`
359
358
  <div style="max-width: 600px; margin: 0 auto; padding: 20px; background-color: #fffbeb; border-radius: 10px;">
360
359
  <h2 style="color: #d97706;">[WARNING] VPN/Proxy Detected</h2>
361
360
  <p>A login from a VPN or proxy service was detected on your account.</p>
362
-
361
+
363
362
  <div style="background: white; padding: 15px; border-radius: 8px; margin: 20px 0;">
364
363
  <h3 style="margin-top: 0;">Account:</h3>
365
364
  <p><strong>{{user.email}}</strong></p>
366
-
365
+
367
366
  <h3>Login Details:</h3>
368
367
  <ul>
369
368
  <li><strong>Time:</strong> {{session.loginTime}}</li>
@@ -374,9 +373,9 @@ If this was you, no action is needed.`
374
373
  <li><strong>Proxy:</strong> {{reason.isProxy}}</li>
375
374
  </ul>
376
375
  </div>
377
-
376
+
378
377
  <p>VPN/Proxy usage may indicate suspicious activity. If this was you, you can safely ignore this email.</p>
379
-
378
+
380
379
  <hr style="border: none; border-top: 1px solid #e5e7eb; margin: 20px 0;"/>
381
380
  <p style="color: #666; font-size: 12px;">Magic Session Manager notification</p>
382
381
  </div>
@@ -405,7 +404,19 @@ const generateSecureKey = () => {
405
404
  }
406
405
  return key;
407
406
  };
408
- const GeofencingPanel = ({ settings, handleChange, t }) => {
407
+ const GeofencingPanel = ({
408
+ settings,
409
+ handleChange,
410
+ t,
411
+ geoIpStatus,
412
+ geoIpCredentials,
413
+ setGeoIpCredentials,
414
+ onSaveGeoIpCredentials,
415
+ onUpdateGeoIp,
416
+ geoIpUpdating,
417
+ geoIpSavingCredentials,
418
+ hasChanges
419
+ }) => {
409
420
  const [pendingCode, setPendingCode] = react.useState("");
410
421
  const mode = (() => {
411
422
  if (Array.isArray(settings.allowedCountries) && settings.allowedCountries.length > 0) {
@@ -464,6 +475,119 @@ const GeofencingPanel = ({ settings, handleChange, t }) => {
464
475
  ] })
465
476
  }
466
477
  ) }),
478
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
479
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.geofencing.provider.title", "GeoIP Provider") }),
480
+ /* @__PURE__ */ jsxRuntime.jsxs(
481
+ designSystem.SingleSelect,
482
+ {
483
+ value: settings.geoIpProvider || "auto",
484
+ onChange: (value) => handleChange("geoIpProvider", value),
485
+ children: [
486
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "auto", children: t("settings.geofencing.provider.auto", "Auto") }),
487
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "local-mmdb", children: t("settings.geofencing.provider.local", "Local MMDB") }),
488
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "ipapi", children: t("settings.geofencing.provider.ipapi", "ipapi.co") }),
489
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "disabled", children: t("settings.geofencing.provider.disabled", "Disabled") })
490
+ ]
491
+ }
492
+ )
493
+ ] }) }),
494
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
495
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.geofencing.failureMode.title", "Lookup Failure Mode") }),
496
+ /* @__PURE__ */ jsxRuntime.jsxs(
497
+ designSystem.SingleSelect,
498
+ {
499
+ value: settings.geoLookupFailureMode || "auto",
500
+ onChange: (value) => handleChange("geoLookupFailureMode", value),
501
+ children: [
502
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "auto", children: t("settings.geofencing.failureMode.auto", "Auto") }),
503
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "allow", children: t("settings.geofencing.failureMode.allow", "Allow") }),
504
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "block", children: t("settings.geofencing.failureMode.block", "Block") })
505
+ ]
506
+ }
507
+ )
508
+ ] }) }),
509
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
510
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.geofencing.databasePath.title", "Local MMDB Path") }),
511
+ /* @__PURE__ */ jsxRuntime.jsx(
512
+ designSystem.TextInput,
513
+ {
514
+ name: "geoIpDatabasePath",
515
+ value: settings.geoIpDatabasePath || "",
516
+ onChange: (e) => handleChange("geoIpDatabasePath", e.target.value),
517
+ placeholder: "/var/lib/strapi/GeoLite2-Country.mmdb"
518
+ }
519
+ )
520
+ ] }) }),
521
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 3, background: "neutral100", hasRadius: true, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, alignItems: "stretch", children: [
522
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", gap: 3, children: [
523
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
524
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "delta", style: { display: "block", marginBottom: "4px" }, children: t("settings.geofencing.database.title", "Local GeoIP Database") }),
525
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "12px" }, children: geoIpStatus?.exists ? t("settings.geofencing.database.exists", "Database is installed locally.") : t("settings.geofencing.database.missing", "No local database installed yet.") })
526
+ ] }),
527
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { backgroundColor: geoIpStatus?.exists ? "success100" : "warning100", children: geoIpStatus?.exists ? t("settings.geofencing.database.installed", "Installed") : t("settings.geofencing.database.notInstalled", "Missing") })
528
+ ] }),
529
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "12px" }, children: [
530
+ t("settings.geofencing.database.path", "Path"),
531
+ ": ",
532
+ geoIpStatus?.databasePath || settings.geoIpDatabasePath || "data/GeoLite2-Country.mmdb"
533
+ ] }),
534
+ geoIpStatus?.metadata?.lastModified && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "12px" }, children: [
535
+ t("settings.geofencing.database.lastModified", "Last MaxMind update"),
536
+ ": ",
537
+ geoIpStatus.metadata.lastModified
538
+ ] }),
539
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 3, children: [
540
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(
541
+ designSystem.TextInput,
542
+ {
543
+ name: "maxmindAccountId",
544
+ value: geoIpCredentials.accountId || "",
545
+ onChange: (e) => setGeoIpCredentials((prev) => ({ ...prev, accountId: e.target.value })),
546
+ placeholder: t("settings.geofencing.maxmind.accountId", "MaxMind Account ID")
547
+ }
548
+ ) }),
549
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(
550
+ designSystem.TextInput,
551
+ {
552
+ name: "maxmindLicenseKey",
553
+ type: "password",
554
+ value: geoIpCredentials.licenseKey || "",
555
+ onChange: (e) => setGeoIpCredentials((prev) => ({ ...prev, licenseKey: e.target.value })),
556
+ placeholder: geoIpStatus?.hasCredentials ? t("settings.geofencing.maxmind.licenseStored", "License key stored") : t("settings.geofencing.maxmind.licenseKey", "MaxMind License Key")
557
+ }
558
+ ) })
559
+ ] }),
560
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, wrap: "wrap", children: [
561
+ /* @__PURE__ */ jsxRuntime.jsx(
562
+ designSystem.Button,
563
+ {
564
+ variant: "secondary",
565
+ onClick: onSaveGeoIpCredentials,
566
+ disabled: geoIpSavingCredentials || !geoIpCredentials.accountId || !geoIpCredentials.licenseKey,
567
+ children: geoIpSavingCredentials ? t("settings.geofencing.credentials.saving", "Saving...") : t("settings.geofencing.credentials.save", "Save MaxMind Credentials")
568
+ }
569
+ ),
570
+ /* @__PURE__ */ jsxRuntime.jsx(
571
+ designSystem.Button,
572
+ {
573
+ onClick: () => onUpdateGeoIp(false),
574
+ disabled: geoIpUpdating || !geoIpStatus?.hasCredentials || hasChanges,
575
+ children: geoIpUpdating ? t("settings.geofencing.database.updating", "Updating...") : t("settings.geofencing.database.update", "Download / Update DB")
576
+ }
577
+ ),
578
+ /* @__PURE__ */ jsxRuntime.jsx(
579
+ designSystem.Button,
580
+ {
581
+ variant: "tertiary",
582
+ onClick: () => onUpdateGeoIp(true),
583
+ disabled: geoIpUpdating || !geoIpStatus?.hasCredentials || hasChanges,
584
+ children: t("settings.geofencing.database.force", "Force Refresh")
585
+ }
586
+ )
587
+ ] }),
588
+ hasChanges && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Alert, { variant: "warning", closeLabel: "", title: "", onClose: () => {
589
+ }, children: t("settings.geofencing.database.saveFirst", "Save settings before downloading so the server uses the latest database path.") })
590
+ ] }) }) }),
467
591
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
468
592
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: t("settings.geofencing.mode.title", "Mode") }),
469
593
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
@@ -570,7 +694,6 @@ const SettingsPage = () => {
570
694
  const { formatMessage } = reactIntl.useIntl();
571
695
  const { get, post, put } = admin.useFetchClient();
572
696
  const { toggleNotification } = admin.useNotification();
573
- const { isPremium, isAdvanced, isEnterprise } = useLicense.useLicense();
574
697
  const t = (id, defaultMessage, values) => formatMessage({ id: index.getTranslation(id), defaultMessage }, values);
575
698
  const [loading, setLoading] = react.useState(true);
576
699
  const [saving, setSaving] = react.useState(false);
@@ -579,6 +702,10 @@ const SettingsPage = () => {
579
702
  const [activeTemplateTab, setActiveTemplateTab] = react.useState("suspiciousLogin");
580
703
  const [encryptionKey, setEncryptionKey] = react.useState("");
581
704
  const [showEncryptionKey, setShowEncryptionKey] = react.useState(false);
705
+ const [geoIpStatus, setGeoIpStatus] = react.useState(null);
706
+ const [geoIpCredentials, setGeoIpCredentials] = react.useState({ accountId: "", licenseKey: "" });
707
+ const [geoIpUpdating, setGeoIpUpdating] = react.useState(false);
708
+ const [geoIpSavingCredentials, setGeoIpSavingCredentials] = react.useState(false);
582
709
  const [settings, setSettings] = react.useState({
583
710
  inactivityTimeout: 15,
584
711
  cleanupInterval: 30,
@@ -609,6 +736,9 @@ const SettingsPage = () => {
609
736
  enableGeofencing: false,
610
737
  allowedCountries: [],
611
738
  blockedCountries: [],
739
+ geoIpProvider: "auto",
740
+ geoIpDatabasePath: "",
741
+ geoLookupFailureMode: "auto",
612
742
  emailTemplates: {
613
743
  suspiciousLogin: { subject: "", html: "", text: "" },
614
744
  newLocation: { subject: "", html: "", text: "" },
@@ -641,8 +771,10 @@ const SettingsPage = () => {
641
771
  });
642
772
  }
643
773
  setSettings((prev) => ({ ...prev, ...loadedSettings }));
774
+ await fetchGeoIpStatus();
644
775
  } else {
645
776
  setSettings((prev) => ({ ...prev, emailTemplates: getDefaultTemplates() }));
777
+ await fetchGeoIpStatus();
646
778
  }
647
779
  } catch (err) {
648
780
  console.error("[Settings] Error loading from backend:", err);
@@ -655,6 +787,21 @@ const SettingsPage = () => {
655
787
  setLoading(false);
656
788
  }
657
789
  };
790
+ const fetchGeoIpStatus = async () => {
791
+ try {
792
+ const response = await get(`/${index.pluginId}/geoip/status`);
793
+ if (response?.data?.status) {
794
+ const status = response.data.status;
795
+ setGeoIpStatus(status);
796
+ setGeoIpCredentials((prev) => ({
797
+ accountId: prev.accountId || status.accountId || "",
798
+ licenseKey: ""
799
+ }));
800
+ }
801
+ } catch (err) {
802
+ console.error("[Settings] Error loading GeoIP status:", err);
803
+ }
804
+ };
658
805
  const handleChange = (key, value) => {
659
806
  setSettings((prev) => ({ ...prev, [key]: value }));
660
807
  setHasChanges(true);
@@ -664,6 +811,7 @@ const SettingsPage = () => {
664
811
  try {
665
812
  const response = await put(`/${index.pluginId}/settings`, settings);
666
813
  if (response?.data?.success) {
814
+ await fetchGeoIpStatus();
667
815
  toggleNotification({
668
816
  type: "success",
669
817
  message: t("notifications.success.saved", "Settings saved successfully to database!")
@@ -687,6 +835,49 @@ const SettingsPage = () => {
687
835
  setSaving(false);
688
836
  }
689
837
  };
838
+ const handleSaveGeoIpCredentials = async () => {
839
+ setGeoIpSavingCredentials(true);
840
+ try {
841
+ const response = await put(`/${index.pluginId}/geoip/credentials`, geoIpCredentials);
842
+ if (response?.data?.success) {
843
+ toggleNotification({
844
+ type: "success",
845
+ message: t("notifications.success.geoipCredentialsSaved", "MaxMind credentials saved.")
846
+ });
847
+ setGeoIpCredentials((prev) => ({ ...prev, licenseKey: "" }));
848
+ await fetchGeoIpStatus();
849
+ }
850
+ } catch (err) {
851
+ console.error("[Settings] Error saving GeoIP credentials:", err);
852
+ toggleNotification({
853
+ type: "danger",
854
+ message: t("notifications.error.geoipCredentials", "Failed to save MaxMind credentials.")
855
+ });
856
+ } finally {
857
+ setGeoIpSavingCredentials(false);
858
+ }
859
+ };
860
+ const handleUpdateGeoIpDatabase = async (force = false) => {
861
+ setGeoIpUpdating(true);
862
+ try {
863
+ const response = await post(`/${index.pluginId}/geoip/update`, { force });
864
+ if (response?.data?.success) {
865
+ toggleNotification({
866
+ type: "success",
867
+ message: response.data.result?.changed ? t("notifications.success.geoipUpdated", "GeoIP database updated.") : t("notifications.success.geoipCurrent", "GeoIP database is already current.")
868
+ });
869
+ await fetchGeoIpStatus();
870
+ }
871
+ } catch (err) {
872
+ console.error("[Settings] Error updating GeoIP database:", err);
873
+ toggleNotification({
874
+ type: "danger",
875
+ message: t("notifications.error.geoipUpdate", "Failed to update GeoIP database.")
876
+ });
877
+ } finally {
878
+ setGeoIpUpdating(false);
879
+ }
880
+ };
690
881
  const handleReset = () => {
691
882
  fetchSettings();
692
883
  setHasChanges(false);
@@ -758,29 +949,6 @@ const SettingsPage = () => {
758
949
  ] })
759
950
  ] }) }),
760
951
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { paddingTop: 6, paddingLeft: 6, paddingRight: 6, paddingBottom: 10, children: [
761
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, background: "primary50", hasRadius: true, style: { marginBottom: "24px", border: "1px solid rgba(14, 165, 233, 0.3)" }, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, alignItems: "center", children: [
762
- /* @__PURE__ */ jsxRuntime.jsx(icons.Information, { style: { width: "20px", height: "20px", color: "var(--colors-primary600, #0284C7)" } }),
763
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
764
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "omega", fontWeight: "bold", textColor: "primary700", style: { marginBottom: "4px" }, children: t("settings.license.title", "Current License Status") }),
765
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 3, children: [
766
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: isPremium ? "success100" : "neutral100", textColor: isPremium ? "success700" : "neutral600", children: [
767
- isPremium ? "✓" : "✗",
768
- " ",
769
- t("settings.license.premium", "Premium")
770
- ] }),
771
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: isAdvanced ? "primary100" : "neutral100", textColor: isAdvanced ? "primary700" : "neutral600", children: [
772
- isAdvanced ? "✓" : "✗",
773
- " ",
774
- t("settings.license.advanced", "Advanced")
775
- ] }),
776
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Badge, { backgroundColor: isEnterprise ? "secondary100" : "neutral100", textColor: isEnterprise ? "secondary700" : "neutral600", children: [
777
- isEnterprise ? "✓" : "✗",
778
- " ",
779
- t("settings.license.enterprise", "Enterprise")
780
- ] })
781
- ] })
782
- ] })
783
- ] }) }),
784
952
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Root, { type: "multiple", defaultValue: ["general", "security", "email"], children: [
785
953
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: "general", children: [
786
954
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -1215,66 +1383,64 @@ const SettingsPage = () => {
1215
1383
  ] })
1216
1384
  }
1217
1385
  ) }),
1218
- isPremium && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1219
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(
1220
- ToggleCard,
1221
- {
1222
- $active: settings.enableGeolocation,
1223
- onClick: () => handleChange("enableGeolocation", !settings.enableGeolocation),
1224
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, style: { width: "100%" }, alignItems: "center", children: [
1225
- /* @__PURE__ */ jsxRuntime.jsx(GreenToggle, { $isActive: settings.enableGeolocation, children: /* @__PURE__ */ jsxRuntime.jsx(
1226
- designSystem.Toggle,
1386
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(
1387
+ ToggleCard,
1388
+ {
1389
+ $active: settings.enableGeolocation,
1390
+ onClick: () => handleChange("enableGeolocation", !settings.enableGeolocation),
1391
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, style: { width: "100%" }, alignItems: "center", children: [
1392
+ /* @__PURE__ */ jsxRuntime.jsx(GreenToggle, { $isActive: settings.enableGeolocation, children: /* @__PURE__ */ jsxRuntime.jsx(
1393
+ designSystem.Toggle,
1394
+ {
1395
+ checked: settings.enableGeolocation,
1396
+ onChange: () => handleChange("enableGeolocation", !settings.enableGeolocation)
1397
+ }
1398
+ ) }),
1399
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, alignItems: "center", style: { textAlign: "center" }, children: [
1400
+ /* @__PURE__ */ jsxRuntime.jsx(
1401
+ designSystem.Typography,
1227
1402
  {
1228
- checked: settings.enableGeolocation,
1229
- onChange: () => handleChange("enableGeolocation", !settings.enableGeolocation)
1403
+ variant: "delta",
1404
+ fontWeight: "bold",
1405
+ textColor: settings.enableGeolocation ? "success700" : "neutral800",
1406
+ style: { fontSize: "16px" },
1407
+ children: t("settings.security.geolocation.title", "IP Geolocation")
1230
1408
  }
1231
- ) }),
1232
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, alignItems: "center", style: { textAlign: "center" }, children: [
1233
- /* @__PURE__ */ jsxRuntime.jsx(
1234
- designSystem.Typography,
1235
- {
1236
- variant: "delta",
1237
- fontWeight: "bold",
1238
- textColor: settings.enableGeolocation ? "success700" : "neutral800",
1239
- style: { fontSize: "16px" },
1240
- children: t("settings.security.geolocation.title", "IP Geolocation")
1241
- }
1242
- ),
1243
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "13px", lineHeight: "1.6" }, children: t("settings.security.geolocation.description", "Fetch location data for each session (Premium)") })
1244
- ] })
1409
+ ),
1410
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "13px", lineHeight: "1.6" }, children: t("settings.security.geolocation.description", "Fetch location data for each session") })
1245
1411
  ] })
1246
- }
1247
- ) }),
1248
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(
1249
- ToggleCard,
1250
- {
1251
- $active: settings.enableSecurityScoring,
1252
- onClick: () => handleChange("enableSecurityScoring", !settings.enableSecurityScoring),
1253
- children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, style: { width: "100%" }, alignItems: "center", children: [
1254
- /* @__PURE__ */ jsxRuntime.jsx(GreenToggle, { $isActive: settings.enableSecurityScoring, children: /* @__PURE__ */ jsxRuntime.jsx(
1255
- designSystem.Toggle,
1412
+ ] })
1413
+ }
1414
+ ) }),
1415
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(
1416
+ ToggleCard,
1417
+ {
1418
+ $active: settings.enableSecurityScoring,
1419
+ onClick: () => handleChange("enableSecurityScoring", !settings.enableSecurityScoring),
1420
+ children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 3, style: { width: "100%" }, alignItems: "center", children: [
1421
+ /* @__PURE__ */ jsxRuntime.jsx(GreenToggle, { $isActive: settings.enableSecurityScoring, children: /* @__PURE__ */ jsxRuntime.jsx(
1422
+ designSystem.Toggle,
1423
+ {
1424
+ checked: settings.enableSecurityScoring,
1425
+ onChange: () => handleChange("enableSecurityScoring", !settings.enableSecurityScoring)
1426
+ }
1427
+ ) }),
1428
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, alignItems: "center", style: { textAlign: "center" }, children: [
1429
+ /* @__PURE__ */ jsxRuntime.jsx(
1430
+ designSystem.Typography,
1256
1431
  {
1257
- checked: settings.enableSecurityScoring,
1258
- onChange: () => handleChange("enableSecurityScoring", !settings.enableSecurityScoring)
1432
+ variant: "delta",
1433
+ fontWeight: "bold",
1434
+ textColor: settings.enableSecurityScoring ? "success700" : "neutral800",
1435
+ style: { fontSize: "16px" },
1436
+ children: t("settings.security.scoring.title", "Security Scoring")
1259
1437
  }
1260
- ) }),
1261
- /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, alignItems: "center", style: { textAlign: "center" }, children: [
1262
- /* @__PURE__ */ jsxRuntime.jsx(
1263
- designSystem.Typography,
1264
- {
1265
- variant: "delta",
1266
- fontWeight: "bold",
1267
- textColor: settings.enableSecurityScoring ? "success700" : "neutral800",
1268
- style: { fontSize: "16px" },
1269
- children: t("settings.security.scoring.title", "Security Scoring")
1270
- }
1271
- ),
1272
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "13px", lineHeight: "1.6" }, children: t("settings.security.scoring.description", "Calculate security scores and detect threats (Premium)") })
1273
- ] })
1438
+ ),
1439
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", style: { fontSize: "13px", lineHeight: "1.6" }, children: t("settings.security.scoring.description", "Calculate security scores and detect threats") })
1274
1440
  ] })
1275
- }
1276
- ) })
1277
- ] })
1441
+ ] })
1442
+ }
1443
+ ) })
1278
1444
  ] }) }),
1279
1445
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
1280
1446
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", fontWeight: "bold", style: { marginBottom: "8px", display: "block" }, children: [
@@ -1286,11 +1452,11 @@ const SettingsPage = () => {
1286
1452
  {
1287
1453
  value: settings.maxFailedLogins,
1288
1454
  onValueChange: (val) => handleChange("maxFailedLogins", val),
1289
- min: 1,
1455
+ min: 0,
1290
1456
  max: 20
1291
1457
  }
1292
1458
  ),
1293
- /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 2, background: "warning50", style: { borderRadius: "4px", marginTop: "8px" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "warning700", style: { fontSize: "11px" }, children: t("settings.security.maxFailed.hint", "User will be blocked after {count} failed attempts", { count: settings.maxFailedLogins }) }) })
1459
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 2, background: "warning50", style: { borderRadius: "4px", marginTop: "8px" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "warning700", style: { fontSize: "11px" }, children: Number(settings.maxFailedLogins) === 0 ? t("settings.security.maxFailed.disabled", "Login lockout is disabled") : t("settings.security.maxFailed.hint", "User will be blocked after {count} failed attempts", { count: settings.maxFailedLogins }) }) })
1294
1460
  ] }) }) })
1295
1461
  ] }) })
1296
1462
  ] }),
@@ -1308,17 +1474,25 @@ const SettingsPage = () => {
1308
1474
  {
1309
1475
  settings,
1310
1476
  handleChange,
1311
- t
1477
+ t,
1478
+ geoIpStatus,
1479
+ geoIpCredentials,
1480
+ setGeoIpCredentials,
1481
+ onSaveGeoIpCredentials: handleSaveGeoIpCredentials,
1482
+ onUpdateGeoIp: handleUpdateGeoIpDatabase,
1483
+ geoIpUpdating,
1484
+ geoIpSavingCredentials,
1485
+ hasChanges
1312
1486
  }
1313
1487
  ) }) })
1314
1488
  ] }),
1315
- isAdvanced && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: "email", children: [
1489
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: "email", children: [
1316
1490
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(
1317
1491
  designSystem.Accordion.Trigger,
1318
1492
  {
1319
1493
  icon: icons.Mail,
1320
1494
  description: t("settings.email.description", "Email alerts for security events"),
1321
- children: t("settings.email.title", "Email Notifications (Advanced)")
1495
+ children: t("settings.email.title", "Email Notifications")
1322
1496
  }
1323
1497
  ) }),
1324
1498
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 6, children: [
@@ -1723,13 +1897,13 @@ const SettingsPage = () => {
1723
1897
  ] })
1724
1898
  ] }) })
1725
1899
  ] }),
1726
- isAdvanced && /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: "webhooks", children: [
1900
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Accordion.Item, { value: "webhooks", children: [
1727
1901
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(
1728
1902
  designSystem.Accordion.Trigger,
1729
1903
  {
1730
1904
  icon: icons.Code,
1731
1905
  description: t("settings.webhooks.description", "Discord & Slack integration"),
1732
- children: t("settings.webhooks.title", "Webhook Integration (Advanced)")
1906
+ children: t("settings.webhooks.title", "Webhook Integration")
1733
1907
  }
1734
1908
  ) }),
1735
1909
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Accordion.Content, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 6, children: [