strapi-identity 0.5.0 → 0.5.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.
@@ -2,7 +2,7 @@ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import { useState, useEffect } from "react";
3
3
  import { W as WarningAlert } from "./WarningAlert-VU011LVF.mjs";
4
4
  import { Box, Flex, Typography, Grid, Button } from "@strapi/design-system";
5
- import { g as getToken, a as getTranslation } from "./index-CKG2ZxYT.mjs";
5
+ import { g as getToken, a as getTranslation } from "./index-Bm3H4z3W.mjs";
6
6
  import { useIntl } from "react-intl";
7
7
  const AdminReset = ({ id }) => {
8
8
  const { formatMessage } = useIntl();
@@ -4,7 +4,7 @@ const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const WarningAlert = require("./WarningAlert-DFE5euMk.js");
6
6
  const designSystem = require("@strapi/design-system");
7
- const index = require("./index-BeqHh5Gz.js");
7
+ const index = require("./index-Ce4QOU6Y.js");
8
8
  const reactIntl = require("react-intl");
9
9
  const AdminReset = ({ id }) => {
10
10
  const { formatMessage } = reactIntl.useIntl();
@@ -3,7 +3,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const designSystem = require("@strapi/design-system");
6
- const index = require("./index-BeqHh5Gz.js");
6
+ const index = require("./index-Ce4QOU6Y.js");
7
7
  const reactIntl = require("react-intl");
8
8
  function RemoveModal({ open, onOpenChange, onSubmit }) {
9
9
  const { formatMessage } = reactIntl.useIntl();
@@ -1,7 +1,7 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { useState, useEffect } from "react";
3
3
  import { Modal, Flex, Typography, TextInput, Button, Box, Grid, Field, Toggle } from "@strapi/design-system";
4
- import { a as getTranslation, I as InputOTP, b as InputOTPGroup, c as InputOTPSlot, d as InputOTPSeparator, g as getToken, C as ConfirmModal, E as EmailOTPModal } from "./index-CKG2ZxYT.mjs";
4
+ import { a as getTranslation, I as InputOTP, b as InputOTPGroup, c as InputOTPSlot, d as InputOTPSeparator, g as getToken, C as ConfirmModal, E as EmailOTPModal } from "./index-Bm3H4z3W.mjs";
5
5
  import { useIntl } from "react-intl";
6
6
  function RemoveModal({ open, onOpenChange, onSubmit }) {
7
7
  const { formatMessage } = useIntl();
@@ -4,7 +4,7 @@ import { W as WarningAlert } from "./WarningAlert-VU011LVF.mjs";
4
4
  import { useNotification, Page, Layouts } from "@strapi/strapi/admin";
5
5
  import { Button, Flex, Typography, Grid, Field, Toggle, TextInput, Textarea } from "@strapi/design-system";
6
6
  import { Check } from "@strapi/icons";
7
- import { g as getToken, a as getTranslation } from "./index-CKG2ZxYT.mjs";
7
+ import { g as getToken, a as getTranslation } from "./index-Bm3H4z3W.mjs";
8
8
  import { useIntl } from "react-intl";
9
9
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
10
10
  var lodash$1 = { exports: {} };
@@ -6,7 +6,7 @@ const WarningAlert = require("./WarningAlert-DFE5euMk.js");
6
6
  const admin = require("@strapi/strapi/admin");
7
7
  const designSystem = require("@strapi/design-system");
8
8
  const icons = require("@strapi/icons");
9
- const index = require("./index-BeqHh5Gz.js");
9
+ const index = require("./index-Ce4QOU6Y.js");
10
10
  const reactIntl = require("react-intl");
11
11
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
12
12
  var lodash$1 = { exports: {} };
@@ -1351,7 +1351,7 @@ const VerifyPage = ({ fallbackIcon }) => {
1351
1351
  );
1352
1352
  }
1353
1353
  const rawTarget = new URLSearchParams(window.location.search).get("redirectTo") || "/admin";
1354
- const target = rawTarget.startsWith("/") ? rawTarget : "/admin";
1354
+ const target = /^\/[^/]/.test(rawTarget) ? rawTarget : "/admin";
1355
1355
  window.location.replace(target);
1356
1356
  } catch (error2) {
1357
1357
  setError(
@@ -1769,6 +1769,10 @@ const EnforcedPage = () => {
1769
1769
  signal: ac.signal
1770
1770
  })
1771
1771
  ]);
1772
+ if (meRes.status === 401) {
1773
+ window.location.replace("/admin/auth/login");
1774
+ return;
1775
+ }
1772
1776
  if (statusRes.ok) {
1773
1777
  const statusBody = await statusRes.json();
1774
1778
  if (statusBody.data?.status === "full") {
@@ -1784,10 +1788,10 @@ const EnforcedPage = () => {
1784
1788
  const meBody = await meRes.json();
1785
1789
  setUserEmail(meBody.data?.email || "");
1786
1790
  }
1791
+ setLoading(false);
1787
1792
  } catch (error) {
1788
1793
  if (error.name === "AbortError") return;
1789
1794
  console.error("Failed to check MFA status:", error);
1790
- } finally {
1791
1795
  setLoading(false);
1792
1796
  }
1793
1797
  })();
@@ -1945,7 +1949,7 @@ const plugin = {
1945
1949
  },
1946
1950
  id: "strapi-identity-settings",
1947
1951
  to: `/${PLUGIN_ID}`,
1948
- Component: () => import("./SettingsPage-CZuOMYvG.mjs"),
1952
+ Component: () => import("./SettingsPage-CcHTu8-f.mjs"),
1949
1953
  permissions: [{ action: "plugin::strapi-identity.settings.update" }]
1950
1954
  });
1951
1955
  app.addMiddlewares([mfaRedirect]);
@@ -1954,14 +1958,14 @@ const plugin = {
1954
1958
  id: "profile-toggle",
1955
1959
  route: "/admin/me",
1956
1960
  selector: '#main-content form[method="put"] > :nth-child(2) > div > div > div:nth-child(2)',
1957
- Component: () => import("./ProfileToggle-NJZgrDT_.mjs")
1961
+ Component: () => import("./ProfileToggle-B1UK1opI.mjs")
1958
1962
  });
1959
1963
  injections.registerRoute({
1960
1964
  id: "admin-reset",
1961
1965
  route: "/admin/settings/users/:id",
1962
1966
  selector: '#main-content form[method="put"] > :nth-child(2) > div > div:nth-child(2)',
1963
1967
  permissions: [{ action: "plugin::strapi-identity.settings.update" }],
1964
- Component: () => import("./AdminReset-D4NNnBDS.mjs")
1968
+ Component: () => import("./AdminReset-DjVX7phX.mjs")
1965
1969
  });
1966
1970
  InjectVerify(app);
1967
1971
  InjectEnforced(app);
@@ -1985,10 +1989,20 @@ const plugin = {
1985
1989
  }
1986
1990
  };
1987
1991
  const mfaRedirect = () => {
1988
- return () => (next) => (action) => {
1989
- if (action && action.type === "admin/login" && (action.payload || {}).hasOwnProperty("token") && action.payload.token === void 0) {
1990
- window.location.replace("/admin/strapi-identity/verify");
1991
- return;
1992
+ return () => (next) => async (action) => {
1993
+ if (action && action.type === "admin/login" && (action.payload || {}).hasOwnProperty("token")) {
1994
+ if (action.payload.token === void 0) {
1995
+ window.location.replace("/admin/strapi-identity/verify");
1996
+ return;
1997
+ }
1998
+ const config = await fetch("/strapi-identity/config", {
1999
+ headers: { authorization: `Bearer ${action.payload.token}` }
2000
+ }).then((res) => res.json());
2001
+ if (config.data?.enabled && config.data?.enforce) {
2002
+ await next(action);
2003
+ window.location.replace("/admin/strapi-identity/enforced");
2004
+ return;
2005
+ }
1992
2006
  }
1993
2007
  return next(action);
1994
2008
  };
@@ -1371,7 +1371,7 @@ const VerifyPage = ({ fallbackIcon }) => {
1371
1371
  );
1372
1372
  }
1373
1373
  const rawTarget = new URLSearchParams(window.location.search).get("redirectTo") || "/admin";
1374
- const target = rawTarget.startsWith("/") ? rawTarget : "/admin";
1374
+ const target = /^\/[^/]/.test(rawTarget) ? rawTarget : "/admin";
1375
1375
  window.location.replace(target);
1376
1376
  } catch (error2) {
1377
1377
  setError(
@@ -1789,6 +1789,10 @@ const EnforcedPage = () => {
1789
1789
  signal: ac.signal
1790
1790
  })
1791
1791
  ]);
1792
+ if (meRes.status === 401) {
1793
+ window.location.replace("/admin/auth/login");
1794
+ return;
1795
+ }
1792
1796
  if (statusRes.ok) {
1793
1797
  const statusBody = await statusRes.json();
1794
1798
  if (statusBody.data?.status === "full") {
@@ -1804,10 +1808,10 @@ const EnforcedPage = () => {
1804
1808
  const meBody = await meRes.json();
1805
1809
  setUserEmail(meBody.data?.email || "");
1806
1810
  }
1811
+ setLoading(false);
1807
1812
  } catch (error) {
1808
1813
  if (error.name === "AbortError") return;
1809
1814
  console.error("Failed to check MFA status:", error);
1810
- } finally {
1811
1815
  setLoading(false);
1812
1816
  }
1813
1817
  })();
@@ -1965,7 +1969,7 @@ const plugin = {
1965
1969
  },
1966
1970
  id: "strapi-identity-settings",
1967
1971
  to: `/${PLUGIN_ID}`,
1968
- Component: () => Promise.resolve().then(() => require("./SettingsPage-BXl7gVGV.js")),
1972
+ Component: () => Promise.resolve().then(() => require("./SettingsPage-DZDW9kNI.js")),
1969
1973
  permissions: [{ action: "plugin::strapi-identity.settings.update" }]
1970
1974
  });
1971
1975
  app.addMiddlewares([mfaRedirect]);
@@ -1974,14 +1978,14 @@ const plugin = {
1974
1978
  id: "profile-toggle",
1975
1979
  route: "/admin/me",
1976
1980
  selector: '#main-content form[method="put"] > :nth-child(2) > div > div > div:nth-child(2)',
1977
- Component: () => Promise.resolve().then(() => require("./ProfileToggle-DtjyJRWN.js"))
1981
+ Component: () => Promise.resolve().then(() => require("./ProfileToggle-4u6WWddz.js"))
1978
1982
  });
1979
1983
  injections.registerRoute({
1980
1984
  id: "admin-reset",
1981
1985
  route: "/admin/settings/users/:id",
1982
1986
  selector: '#main-content form[method="put"] > :nth-child(2) > div > div:nth-child(2)',
1983
1987
  permissions: [{ action: "plugin::strapi-identity.settings.update" }],
1984
- Component: () => Promise.resolve().then(() => require("./AdminReset-BoWx0F06.js"))
1988
+ Component: () => Promise.resolve().then(() => require("./AdminReset-DsKz040S.js"))
1985
1989
  });
1986
1990
  InjectVerify(app);
1987
1991
  InjectEnforced(app);
@@ -2005,10 +2009,20 @@ const plugin = {
2005
2009
  }
2006
2010
  };
2007
2011
  const mfaRedirect = () => {
2008
- return () => (next) => (action) => {
2009
- if (action && action.type === "admin/login" && (action.payload || {}).hasOwnProperty("token") && action.payload.token === void 0) {
2010
- window.location.replace("/admin/strapi-identity/verify");
2011
- return;
2012
+ return () => (next) => async (action) => {
2013
+ if (action && action.type === "admin/login" && (action.payload || {}).hasOwnProperty("token")) {
2014
+ if (action.payload.token === void 0) {
2015
+ window.location.replace("/admin/strapi-identity/verify");
2016
+ return;
2017
+ }
2018
+ const config = await fetch("/strapi-identity/config", {
2019
+ headers: { authorization: `Bearer ${action.payload.token}` }
2020
+ }).then((res) => res.json());
2021
+ if (config.data?.enabled && config.data?.enforce) {
2022
+ await next(action);
2023
+ window.location.replace("/admin/strapi-identity/enforced");
2024
+ return;
2025
+ }
2012
2026
  }
2013
2027
  return next(action);
2014
2028
  };
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const index = require("./index-BeqHh5Gz.js");
3
+ const index = require("./index-Ce4QOU6Y.js");
4
4
  require("strapi-admin-portal");
5
5
  exports.default = index.plugin;
@@ -1,4 +1,4 @@
1
- import { p } from "./index-CKG2ZxYT.mjs";
1
+ import { p } from "./index-Bm3H4z3W.mjs";
2
2
  import "strapi-admin-portal";
3
3
  export {
4
4
  p as default
@@ -10382,7 +10382,9 @@ const mfa = [
10382
10382
  policies: [
10383
10383
  "has-mfa"
10384
10384
  ],
10385
- middlewares: []
10385
+ middlewares: [
10386
+ "admin::rateLimit"
10387
+ ]
10386
10388
  }
10387
10389
  },
10388
10390
  {
@@ -10375,7 +10375,9 @@ const mfa = [
10375
10375
  policies: [
10376
10376
  "has-mfa"
10377
10377
  ],
10378
- middlewares: []
10378
+ middlewares: [
10379
+ "admin::rateLimit"
10380
+ ]
10379
10381
  }
10380
10382
  },
10381
10383
  {
@@ -60,7 +60,7 @@ declare const _default: [
60
60
  "config": {
61
61
  "auth": false,
62
62
  "policies": ["has-mfa"],
63
- "middlewares": []
63
+ "middlewares": ["admin::rateLimit"]
64
64
  }
65
65
  },
66
66
  {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.0",
2
+ "version": "0.5.1",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "plugin",