strapi-identity 0.5.0 → 0.6.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.
@@ -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-D1Rr9LMh.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-CHIUAjKH.js");
8
8
  const reactIntl = require("react-intl");
9
9
  const AdminReset = ({ id }) => {
10
10
  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-D1Rr9LMh.mjs";
5
5
  import { useIntl } from "react-intl";
6
6
  function RemoveModal({ open, onOpenChange, onSubmit }) {
7
7
  const { formatMessage } = 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-CHIUAjKH.js");
7
7
  const reactIntl = require("react-intl");
8
8
  function RemoveModal({ open, onOpenChange, onSubmit }) {
9
9
  const { formatMessage } = reactIntl.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-D1Rr9LMh.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-CHIUAjKH.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: {} };
@@ -1348,6 +1348,7 @@ const Logo = ({ fallbackIcon }) => {
1348
1348
  };
1349
1349
  const VerifyPage = ({ fallbackIcon }) => {
1350
1350
  const auth = admin.useAuth("MFA", (auth2) => auth2);
1351
+ const dispatch = useDispatch();
1351
1352
  const { formatMessage } = reactIntl.useIntl();
1352
1353
  const [error, setError] = React.useState(null);
1353
1354
  const [useRecoveryCode, setUseRecoveryCode] = React.useState(false);
@@ -1370,9 +1371,8 @@ const VerifyPage = ({ fallbackIcon }) => {
1370
1371
  `${response.status} ${response.statusText}: ${data.error || "Unknown error"}`
1371
1372
  );
1372
1373
  }
1373
- const rawTarget = new URLSearchParams(window.location.search).get("redirectTo") || "/admin";
1374
- const target = rawTarget.startsWith("/") ? rawTarget : "/admin";
1375
- window.location.replace(target);
1374
+ const { token, rememberMe } = data.data;
1375
+ dispatch({ type: "admin/login", payload: { token, persist: rememberMe } });
1376
1376
  } catch (error2) {
1377
1377
  setError(
1378
1378
  formatMessage({
@@ -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-ehAdX5ev.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-DqOHS9Xv.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-LoJC7kqo.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
  };
@@ -1328,6 +1328,7 @@ const Logo = ({ fallbackIcon }) => {
1328
1328
  };
1329
1329
  const VerifyPage = ({ fallbackIcon }) => {
1330
1330
  const auth = useAuth("MFA", (auth2) => auth2);
1331
+ const dispatch = useDispatch();
1331
1332
  const { formatMessage } = useIntl();
1332
1333
  const [error, setError] = useState(null);
1333
1334
  const [useRecoveryCode, setUseRecoveryCode] = useState(false);
@@ -1350,9 +1351,8 @@ const VerifyPage = ({ fallbackIcon }) => {
1350
1351
  `${response.status} ${response.statusText}: ${data.error || "Unknown error"}`
1351
1352
  );
1352
1353
  }
1353
- const rawTarget = new URLSearchParams(window.location.search).get("redirectTo") || "/admin";
1354
- const target = rawTarget.startsWith("/") ? rawTarget : "/admin";
1355
- window.location.replace(target);
1354
+ const { token, rememberMe } = data.data;
1355
+ dispatch({ type: "admin/login", payload: { token, persist: rememberMe } });
1356
1356
  } catch (error2) {
1357
1357
  setError(
1358
1358
  formatMessage({
@@ -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-DWuVgPPr.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-C5glSkS5.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-DzpiB_dK.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
  };
@@ -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-CHIUAjKH.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-D1Rr9LMh.mjs";
2
2
  import "strapi-admin-portal";
3
3
  export {
4
4
  p as default
@@ -6,4 +6,4 @@ export interface ConfirmModalProps {
6
6
  secret?: string | null;
7
7
  passcodes?: string[] | null;
8
8
  }
9
- export default function ConfirmModal({ open, onOpenChange, onSubmit, qrCodeUri, secret, passcodes, }: ConfirmModalProps): import("react/jsx-runtime").JSX.Element;
9
+ export default function ConfirmModal({ open, onOpenChange, onSubmit, qrCodeUri, secret, passcodes, }: ConfirmModalProps): import("react").JSX.Element;
@@ -5,4 +5,4 @@ export interface EmailOTPModalProps {
5
5
  onOpenChange: (open: boolean) => void;
6
6
  onSuccess: () => void;
7
7
  }
8
- export default function EmailOTPModal({ mode, open, email, onOpenChange, onSuccess, }: EmailOTPModalProps): import("react/jsx-runtime").JSX.Element;
8
+ export default function EmailOTPModal({ mode, open, email, onOpenChange, onSuccess, }: EmailOTPModalProps): import("react").JSX.Element;
@@ -2,10 +2,10 @@ import { OTPInput } from 'input-otp';
2
2
  import * as React from 'react';
3
3
  declare function InputOTP({ className, containerClassName, ...props }: React.ComponentPropsWithoutRef<typeof OTPInput> & {
4
4
  containerClassName?: string;
5
- }): import("react/jsx-runtime").JSX.Element;
6
- declare function InputOTPGroup({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
5
+ }): React.JSX.Element;
6
+ declare function InputOTPGroup({ className, ...props }: React.ComponentProps<'div'>): React.JSX.Element;
7
7
  declare function InputOTPSlot({ index, className, ...props }: React.ComponentProps<'div'> & {
8
8
  index: number;
9
- }): import("react/jsx-runtime").JSX.Element;
10
- declare function InputOTPSeparator({ ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
9
+ }): React.JSX.Element;
10
+ declare function InputOTPSeparator({ ...props }: React.ComponentProps<'div'>): React.JSX.Element;
11
11
  export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };
@@ -3,4 +3,4 @@ export interface RemoveModalProps {
3
3
  onOpenChange: (open: boolean) => void;
4
4
  onSubmit: React.FormEventHandler<HTMLFormElement>;
5
5
  }
6
- export default function RemoveModal({ open, onOpenChange, onSubmit }: RemoveModalProps): import("react/jsx-runtime").JSX.Element;
6
+ export default function RemoveModal({ open, onOpenChange, onSubmit }: RemoveModalProps): import("react").JSX.Element;
@@ -7,4 +7,4 @@ export interface WarningAlertProps {
7
7
  onConfirm: () => void;
8
8
  onCancel: () => void;
9
9
  }
10
- export default function WarningAlert({ open, title, children, confirmText, loading, onConfirm, onCancel, }: WarningAlertProps): import("react/jsx-runtime").JSX.Element;
10
+ export default function WarningAlert({ open, title, children, confirmText, loading, onConfirm, onCancel, }: WarningAlertProps): import("react").JSX.Element;
@@ -1,4 +1,4 @@
1
1
  declare const AdminReset: ({ id }: {
2
2
  id?: string;
3
- }) => import("react/jsx-runtime").JSX.Element;
3
+ }) => import("react").JSX.Element;
4
4
  export default AdminReset;
@@ -1,2 +1,2 @@
1
- declare const ProfileToggle: () => import("react/jsx-runtime").JSX.Element | null;
1
+ declare const ProfileToggle: () => import("react").JSX.Element | null;
2
2
  export default ProfileToggle;
@@ -9,5 +9,5 @@ export interface InjectPublicRouter extends Omit<StrapiApp['router'], 'router'>
9
9
  * Inject the enforced MFA page route into the Strapi admin router
10
10
  */
11
11
  export declare const InjectEnforced: (app: StrapiApp) => Promise<void>;
12
- declare const EnforcedPage: () => import("react/jsx-runtime").JSX.Element | null;
12
+ declare const EnforcedPage: () => import("react").JSX.Element | null;
13
13
  export { EnforcedPage };
@@ -1 +1 @@
1
- export default function SettingsPage(): import("react/jsx-runtime").JSX.Element;
1
+ export default function SettingsPage(): import("react").JSX.Element;
@@ -9966,13 +9966,10 @@ const controller = ({ strapi: strapi2 }) => ({
9966
9966
  );
9967
9967
  const accessResult = await sessionManager("admin").generateAccessToken(refreshToken);
9968
9968
  const { token: accessToken } = accessResult;
9969
- const domain = strapi2.config.get("admin.auth.domain");
9970
- const opt = { httpOnly: false, secure, overwrite: true, domain };
9971
- ctx.cookies.set("jwtToken", accessToken, opt);
9972
9969
  ctx.cookies.set("strapi_admin_mfa", null, { expires: /* @__PURE__ */ new Date(0) });
9973
9970
  ctx.status = 200;
9974
9971
  ctx.body = {
9975
- data: { token: accessToken, accessToken },
9972
+ data: { token: accessToken, accessToken, rememberMe: payload.rememberMe || false },
9976
9973
  error: null
9977
9974
  };
9978
9975
  } catch (error) {
@@ -10382,7 +10379,9 @@ const mfa = [
10382
10379
  policies: [
10383
10380
  "has-mfa"
10384
10381
  ],
10385
- middlewares: []
10382
+ middlewares: [
10383
+ "admin::rateLimit"
10384
+ ]
10386
10385
  }
10387
10386
  },
10388
10387
  {
@@ -9959,13 +9959,10 @@ const controller = ({ strapi: strapi2 }) => ({
9959
9959
  );
9960
9960
  const accessResult = await sessionManager("admin").generateAccessToken(refreshToken);
9961
9961
  const { token: accessToken } = accessResult;
9962
- const domain = strapi2.config.get("admin.auth.domain");
9963
- const opt = { httpOnly: false, secure, overwrite: true, domain };
9964
- ctx.cookies.set("jwtToken", accessToken, opt);
9965
9962
  ctx.cookies.set("strapi_admin_mfa", null, { expires: /* @__PURE__ */ new Date(0) });
9966
9963
  ctx.status = 200;
9967
9964
  ctx.body = {
9968
- data: { token: accessToken, accessToken },
9965
+ data: { token: accessToken, accessToken, rememberMe: payload.rememberMe || false },
9969
9966
  error: null
9970
9967
  };
9971
9968
  } catch (error) {
@@ -10375,7 +10372,9 @@ const mfa = [
10375
10372
  policies: [
10376
10373
  "has-mfa"
10377
10374
  ],
10378
- middlewares: []
10375
+ middlewares: [
10376
+ "admin::rateLimit"
10377
+ ]
10379
10378
  }
10380
10379
  },
10381
10380
  {
@@ -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.6.0",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "plugin",
@@ -34,19 +34,20 @@
34
34
  "watch:link": "strapi-plugin watch:link",
35
35
  "verify": "strapi-plugin verify",
36
36
  "test:ts:front": "run -T tsc -p admin/tsconfig.json",
37
- "test:ts:back": "run -T tsc -p server/tsconfig.json"
37
+ "test:ts:back": "run -T tsc -p server/tsconfig.json",
38
+ "postversion": "git push && git push --tags"
38
39
  },
39
40
  "dependencies": {
40
41
  "input-otp": "^1.4.2",
41
- "otpauth": "^9.5.0",
42
+ "otpauth": "^9.5.1",
42
43
  "qrcode.react": "^4.2.0",
43
44
  "strapi-admin-portal": "^0.3.0"
44
45
  },
45
46
  "devDependencies": {
46
- "@strapi/sdk-plugin": "^6.1.0",
47
- "@strapi/typescript-utils": "^5.43.0",
47
+ "@strapi/sdk-plugin": "^6.1.1",
48
+ "@strapi/typescript-utils": "^5.47.1",
48
49
  "@types/bcryptjs": "^2.4.6",
49
- "@types/react": "^18.3.28",
50
+ "@types/react": "^18.3.30",
50
51
  "@types/react-dom": "^18.3.7",
51
52
  "prettier": "^3.8.3",
52
53
  "typescript": "^5.9.3"