strapi-identity 0.4.1 → 0.5.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 (60) hide show
  1. package/dist/admin/{AdminReset-BiWQDTRv.js → AdminReset-BoWx0F06.js} +1 -1
  2. package/dist/admin/{AdminReset-DOmsyqwQ.mjs → AdminReset-D4NNnBDS.mjs} +1 -1
  3. package/dist/admin/{ProfileToggle-BUqs_hxZ.js → ProfileToggle-DtjyJRWN.js} +1 -1
  4. package/dist/admin/{ProfileToggle-k0d-caPC.mjs → ProfileToggle-NJZgrDT_.mjs} +1 -1
  5. package/dist/admin/{SettingsPage-DVVkN1xw.js → SettingsPage-BXl7gVGV.js} +1 -1
  6. package/dist/admin/{SettingsPage-Dm_llkYv.mjs → SettingsPage-CZuOMYvG.mjs} +1 -1
  7. package/dist/admin/{index-B9P8S4CX.js → index-BeqHh5Gz.js} +22 -15
  8. package/dist/admin/{index-DpIJdETG.mjs → index-CKG2ZxYT.mjs} +22 -15
  9. package/dist/admin/index.js +1 -1
  10. package/dist/admin/index.mjs +1 -1
  11. package/dist/admin/src/components/ConfirmModal/ConfirmModal.d.ts +9 -0
  12. package/dist/admin/src/components/ConfirmModal/index.d.ts +1 -0
  13. package/dist/admin/src/components/EmailOTPModal/EmailOTPModal.d.ts +8 -0
  14. package/dist/admin/src/components/Initializer.d.ts +5 -0
  15. package/dist/admin/src/components/InputOTP.d.ts +11 -0
  16. package/dist/admin/src/components/RemoveModal/RemoveModal.d.ts +6 -0
  17. package/dist/admin/src/components/RemoveModal/index.d.ts +1 -0
  18. package/dist/admin/src/components/WarningAlert/WarningAlert.d.ts +10 -0
  19. package/dist/admin/src/components/WarningAlert/index.d.ts +1 -0
  20. package/dist/admin/src/injection/AdminReset.d.ts +4 -0
  21. package/dist/admin/src/injection/ProfileToggle.d.ts +2 -0
  22. package/dist/admin/src/pages/EnforcedPage.d.ts +13 -0
  23. package/dist/admin/src/pluginId.d.ts +1 -0
  24. package/dist/admin/src/public/VerifyPage.d.ts +12 -0
  25. package/dist/admin/src/settings/SettingsPage.d.ts +1 -0
  26. package/dist/admin/src/utils/getTranslation.d.ts +2 -0
  27. package/dist/admin/src/utils/tokenHelpers.d.ts +12 -0
  28. package/dist/server/index.js +75 -49
  29. package/dist/server/index.mjs +75 -49
  30. package/dist/server/src/bootstrap.d.ts +3 -0
  31. package/dist/server/src/config/index.d.ts +3 -0
  32. package/dist/server/src/content-types/config/index.d.ts +72 -0
  33. package/dist/server/src/content-types/config/schema.json.d.ts +72 -0
  34. package/dist/server/src/content-types/email-otp/index.d.ts +48 -0
  35. package/dist/server/src/content-types/email-otp/schema.json.d.ts +48 -0
  36. package/dist/server/src/content-types/index.d.ts +3 -0
  37. package/dist/server/src/content-types/mfa/index.d.ts +55 -0
  38. package/dist/server/src/content-types/mfa/schema.json.d.ts +55 -0
  39. package/dist/server/src/content-types/temp-mfa/index.d.ts +35 -0
  40. package/dist/server/src/content-types/temp-mfa/schema.json.d.ts +35 -0
  41. package/dist/server/src/controllers/admin.d.ts +4 -0
  42. package/dist/server/src/controllers/config.d.ts +4 -0
  43. package/dist/server/src/controllers/controller.d.ts +8 -0
  44. package/dist/server/src/controllers/index.d.ts +3 -0
  45. package/dist/server/src/destroy.d.ts +3 -0
  46. package/dist/server/src/middlewares/index.d.ts +3 -0
  47. package/dist/server/src/policies/has-mfa.d.ts +3 -0
  48. package/dist/server/src/policies/index.d.ts +3 -0
  49. package/dist/server/src/register.d.ts +3 -0
  50. package/dist/server/src/routes/admin/admin.json.d.ts +35 -0
  51. package/dist/server/src/routes/admin/config.json.d.ts +50 -0
  52. package/dist/server/src/routes/admin/index.d.ts +3 -0
  53. package/dist/server/src/routes/admin/mfa.json.d.ts +94 -0
  54. package/dist/server/src/routes/index.d.ts +3 -0
  55. package/dist/server/src/services/admin.d.ts +11 -0
  56. package/dist/server/src/services/config.d.ts +57 -0
  57. package/dist/server/src/services/email.d.ts +8 -0
  58. package/dist/server/src/services/index.d.ts +3 -0
  59. package/dist/server/src/services/mfa.d.ts +82 -0
  60. package/package.json +6 -5
@@ -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-B9P8S4CX.js");
7
+ const index = require("./index-BeqHh5Gz.js");
8
8
  const reactIntl = require("react-intl");
9
9
  const AdminReset = ({ id }) => {
10
10
  const { formatMessage } = reactIntl.useIntl();
@@ -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-DpIJdETG.mjs";
5
+ import { g as getToken, a as getTranslation } from "./index-CKG2ZxYT.mjs";
6
6
  import { useIntl } from "react-intl";
7
7
  const AdminReset = ({ id }) => {
8
8
  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-B9P8S4CX.js");
6
+ const index = require("./index-BeqHh5Gz.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-DpIJdETG.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-CKG2ZxYT.mjs";
5
5
  import { useIntl } from "react-intl";
6
6
  function RemoveModal({ open, onOpenChange, onSubmit }) {
7
7
  const { formatMessage } = useIntl();
@@ -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-B9P8S4CX.js");
9
+ const index = require("./index-BeqHh5Gz.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: {} };
@@ -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-DpIJdETG.mjs";
7
+ import { g as getToken, a as getTranslation } from "./index-CKG2ZxYT.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: {} };
@@ -1370,7 +1370,8 @@ const VerifyPage = ({ fallbackIcon }) => {
1370
1370
  `${response.status} ${response.statusText}: ${data.error || "Unknown error"}`
1371
1371
  );
1372
1372
  }
1373
- const target = new URLSearchParams(window.location.search).get("redirectTo") || "/admin";
1373
+ const rawTarget = new URLSearchParams(window.location.search).get("redirectTo") || "/admin";
1374
+ const target = rawTarget.startsWith("/") ? rawTarget : "/admin";
1374
1375
  window.location.replace(target);
1375
1376
  } catch (error2) {
1376
1377
  setError(
@@ -1383,20 +1384,26 @@ const VerifyPage = ({ fallbackIcon }) => {
1383
1384
  }
1384
1385
  };
1385
1386
  React.useEffect(() => {
1386
- const mfaToken = document.cookie.split("; ").reduce((acc, cookie) => {
1387
- const [name, value] = cookie.split("=");
1388
- return name === "strapi_admin_mfa" ? value.trim() : acc;
1389
- }, null);
1390
- if (auth?.token || !mfaToken) {
1387
+ if (auth?.token) {
1391
1388
  window.location.replace("/admin");
1392
1389
  return;
1393
1390
  }
1394
- try {
1395
- const payloadBase64 = mfaToken.split(".")[1];
1396
- const decoded = JSON.parse(atob(payloadBase64));
1397
- setMfaType(decoded.mfaType || null);
1398
- } catch {
1399
- }
1391
+ const ac = new AbortController();
1392
+ (async () => {
1393
+ try {
1394
+ const response = await fetch("/strapi-identity/verify/info", { signal: ac.signal });
1395
+ if (!response.ok) {
1396
+ window.location.replace("/admin");
1397
+ return;
1398
+ }
1399
+ const data = await response.json();
1400
+ setMfaType(data.data?.mfaType || null);
1401
+ } catch (error2) {
1402
+ if (error2 instanceof DOMException && error2.name === "AbortError") return;
1403
+ window.location.replace("/admin");
1404
+ }
1405
+ })();
1406
+ return () => ac.abort();
1400
1407
  }, [auth?.token]);
1401
1408
  const handleResend = async () => {
1402
1409
  setResendLoading(true);
@@ -1958,7 +1965,7 @@ const plugin = {
1958
1965
  },
1959
1966
  id: "strapi-identity-settings",
1960
1967
  to: `/${PLUGIN_ID}`,
1961
- Component: () => Promise.resolve().then(() => require("./SettingsPage-DVVkN1xw.js")),
1968
+ Component: () => Promise.resolve().then(() => require("./SettingsPage-BXl7gVGV.js")),
1962
1969
  permissions: [{ action: "plugin::strapi-identity.settings.update" }]
1963
1970
  });
1964
1971
  app.addMiddlewares([mfaRedirect]);
@@ -1967,14 +1974,14 @@ const plugin = {
1967
1974
  id: "profile-toggle",
1968
1975
  route: "/admin/me",
1969
1976
  selector: '#main-content form[method="put"] > :nth-child(2) > div > div > div:nth-child(2)',
1970
- Component: () => Promise.resolve().then(() => require("./ProfileToggle-BUqs_hxZ.js"))
1977
+ Component: () => Promise.resolve().then(() => require("./ProfileToggle-DtjyJRWN.js"))
1971
1978
  });
1972
1979
  injections.registerRoute({
1973
1980
  id: "admin-reset",
1974
1981
  route: "/admin/settings/users/:id",
1975
1982
  selector: '#main-content form[method="put"] > :nth-child(2) > div > div:nth-child(2)',
1976
1983
  permissions: [{ action: "plugin::strapi-identity.settings.update" }],
1977
- Component: () => Promise.resolve().then(() => require("./AdminReset-BiWQDTRv.js"))
1984
+ Component: () => Promise.resolve().then(() => require("./AdminReset-BoWx0F06.js"))
1978
1985
  });
1979
1986
  InjectVerify(app);
1980
1987
  InjectEnforced(app);
@@ -1350,7 +1350,8 @@ const VerifyPage = ({ fallbackIcon }) => {
1350
1350
  `${response.status} ${response.statusText}: ${data.error || "Unknown error"}`
1351
1351
  );
1352
1352
  }
1353
- const target = new URLSearchParams(window.location.search).get("redirectTo") || "/admin";
1353
+ const rawTarget = new URLSearchParams(window.location.search).get("redirectTo") || "/admin";
1354
+ const target = rawTarget.startsWith("/") ? rawTarget : "/admin";
1354
1355
  window.location.replace(target);
1355
1356
  } catch (error2) {
1356
1357
  setError(
@@ -1363,20 +1364,26 @@ const VerifyPage = ({ fallbackIcon }) => {
1363
1364
  }
1364
1365
  };
1365
1366
  useEffect(() => {
1366
- const mfaToken = document.cookie.split("; ").reduce((acc, cookie) => {
1367
- const [name, value] = cookie.split("=");
1368
- return name === "strapi_admin_mfa" ? value.trim() : acc;
1369
- }, null);
1370
- if (auth?.token || !mfaToken) {
1367
+ if (auth?.token) {
1371
1368
  window.location.replace("/admin");
1372
1369
  return;
1373
1370
  }
1374
- try {
1375
- const payloadBase64 = mfaToken.split(".")[1];
1376
- const decoded = JSON.parse(atob(payloadBase64));
1377
- setMfaType(decoded.mfaType || null);
1378
- } catch {
1379
- }
1371
+ const ac = new AbortController();
1372
+ (async () => {
1373
+ try {
1374
+ const response = await fetch("/strapi-identity/verify/info", { signal: ac.signal });
1375
+ if (!response.ok) {
1376
+ window.location.replace("/admin");
1377
+ return;
1378
+ }
1379
+ const data = await response.json();
1380
+ setMfaType(data.data?.mfaType || null);
1381
+ } catch (error2) {
1382
+ if (error2 instanceof DOMException && error2.name === "AbortError") return;
1383
+ window.location.replace("/admin");
1384
+ }
1385
+ })();
1386
+ return () => ac.abort();
1380
1387
  }, [auth?.token]);
1381
1388
  const handleResend = async () => {
1382
1389
  setResendLoading(true);
@@ -1938,7 +1945,7 @@ const plugin = {
1938
1945
  },
1939
1946
  id: "strapi-identity-settings",
1940
1947
  to: `/${PLUGIN_ID}`,
1941
- Component: () => import("./SettingsPage-Dm_llkYv.mjs"),
1948
+ Component: () => import("./SettingsPage-CZuOMYvG.mjs"),
1942
1949
  permissions: [{ action: "plugin::strapi-identity.settings.update" }]
1943
1950
  });
1944
1951
  app.addMiddlewares([mfaRedirect]);
@@ -1947,14 +1954,14 @@ const plugin = {
1947
1954
  id: "profile-toggle",
1948
1955
  route: "/admin/me",
1949
1956
  selector: '#main-content form[method="put"] > :nth-child(2) > div > div > div:nth-child(2)',
1950
- Component: () => import("./ProfileToggle-k0d-caPC.mjs")
1957
+ Component: () => import("./ProfileToggle-NJZgrDT_.mjs")
1951
1958
  });
1952
1959
  injections.registerRoute({
1953
1960
  id: "admin-reset",
1954
1961
  route: "/admin/settings/users/:id",
1955
1962
  selector: '#main-content form[method="put"] > :nth-child(2) > div > div:nth-child(2)',
1956
1963
  permissions: [{ action: "plugin::strapi-identity.settings.update" }],
1957
- Component: () => import("./AdminReset-DOmsyqwQ.mjs")
1964
+ Component: () => import("./AdminReset-D4NNnBDS.mjs")
1958
1965
  });
1959
1966
  InjectVerify(app);
1960
1967
  InjectEnforced(app);
@@ -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-B9P8S4CX.js");
3
+ const index = require("./index-BeqHh5Gz.js");
4
4
  require("strapi-admin-portal");
5
5
  exports.default = index.plugin;
@@ -1,4 +1,4 @@
1
- import { p } from "./index-DpIJdETG.mjs";
1
+ import { p } from "./index-CKG2ZxYT.mjs";
2
2
  import "strapi-admin-portal";
3
3
  export {
4
4
  p as default
@@ -0,0 +1,9 @@
1
+ export interface ConfirmModalProps {
2
+ open?: boolean;
3
+ onOpenChange?: (open: boolean) => void;
4
+ onSubmit?: React.FormEventHandler<HTMLFormElement>;
5
+ qrCodeUri?: string | null;
6
+ secret?: string | null;
7
+ passcodes?: string[] | null;
8
+ }
9
+ export default function ConfirmModal({ open, onOpenChange, onSubmit, qrCodeUri, secret, passcodes, }: ConfirmModalProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export { default, type ConfirmModalProps } from './ConfirmModal';
@@ -0,0 +1,8 @@
1
+ export interface EmailOTPModalProps {
2
+ mode: 'setup' | 'disable';
3
+ open: boolean;
4
+ email: string;
5
+ onOpenChange: (open: boolean) => void;
6
+ onSuccess: () => void;
7
+ }
8
+ export default function EmailOTPModal({ mode, open, email, onOpenChange, onSuccess, }: EmailOTPModalProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,5 @@
1
+ type InitializerProps = {
2
+ setPlugin: (id: string) => void;
3
+ };
4
+ declare const Initializer: ({ setPlugin }: InitializerProps) => null;
5
+ export { Initializer };
@@ -0,0 +1,11 @@
1
+ import { OTPInput } from 'input-otp';
2
+ import * as React from 'react';
3
+ declare function InputOTP({ className, containerClassName, ...props }: React.ComponentPropsWithoutRef<typeof OTPInput> & {
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;
7
+ declare function InputOTPSlot({ index, className, ...props }: React.ComponentProps<'div'> & {
8
+ index: number;
9
+ }): import("react/jsx-runtime").JSX.Element;
10
+ declare function InputOTPSeparator({ ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
11
+ export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };
@@ -0,0 +1,6 @@
1
+ export interface RemoveModalProps {
2
+ open: boolean;
3
+ onOpenChange: (open: boolean) => void;
4
+ onSubmit: React.FormEventHandler<HTMLFormElement>;
5
+ }
6
+ export default function RemoveModal({ open, onOpenChange, onSubmit }: RemoveModalProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export { default, type RemoveModalProps } from './RemoveModal';
@@ -0,0 +1,10 @@
1
+ export interface WarningAlertProps {
2
+ open: boolean;
3
+ title?: string;
4
+ children: React.ReactNode;
5
+ confirmText?: string;
6
+ loading?: boolean;
7
+ onConfirm: () => void;
8
+ onCancel: () => void;
9
+ }
10
+ export default function WarningAlert({ open, title, children, confirmText, loading, onConfirm, onCancel, }: WarningAlertProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export { default, type WarningAlertProps } from './WarningAlert';
@@ -0,0 +1,4 @@
1
+ declare const AdminReset: ({ id }: {
2
+ id?: string;
3
+ }) => import("react/jsx-runtime").JSX.Element;
4
+ export default AdminReset;
@@ -0,0 +1,2 @@
1
+ declare const ProfileToggle: () => import("react/jsx-runtime").JSX.Element | null;
2
+ export default ProfileToggle;
@@ -0,0 +1,13 @@
1
+ import { StrapiApp } from '@strapi/strapi/admin';
2
+ import { RouteObject } from 'react-router-dom';
3
+ export interface InjectPublicRouter extends Omit<StrapiApp['router'], 'router'> {
4
+ router: {
5
+ routes: RouteObject[];
6
+ };
7
+ }
8
+ /**
9
+ * Inject the enforced MFA page route into the Strapi admin router
10
+ */
11
+ export declare const InjectEnforced: (app: StrapiApp) => Promise<void>;
12
+ declare const EnforcedPage: () => import("react/jsx-runtime").JSX.Element | null;
13
+ export { EnforcedPage };
@@ -0,0 +1 @@
1
+ export declare const PLUGIN_ID = "strapi-identity";
@@ -0,0 +1,12 @@
1
+ import { StrapiApp } from '@strapi/strapi/admin';
2
+ import { RouteObject } from 'react-router-dom';
3
+ export interface InjectPublicRouter extends Omit<StrapiApp['router'], 'router'> {
4
+ router: {
5
+ routes: RouteObject[];
6
+ };
7
+ }
8
+ /**
9
+ * Inject the verify page route into the Strapi router
10
+ * @param router StrapiApp router instance
11
+ */
12
+ export declare const InjectVerify: (app: StrapiApp) => Promise<void>;
@@ -0,0 +1 @@
1
+ export default function SettingsPage(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,2 @@
1
+ declare const getTranslation: (id: string) => string;
2
+ export { getTranslation };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Retrieves the value of a specified cookie.
3
+ *
4
+ * @param name - The name of the cookie to retrieve.
5
+ * @returns The decoded cookie value if found, otherwise null.
6
+ */
7
+ export declare const getCookieValue: (name: string) => string | null;
8
+ /**
9
+ * Retrieves the JWT token from localStorage or cookies.
10
+ * @returns The JWT token if found, otherwise null.
11
+ */
12
+ export declare const getToken: () => string | null;