strapi-identity 0.0.1 → 0.0.2-debug.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.
package/README.md CHANGED
@@ -21,7 +21,14 @@ Detailed Multi-Factor Authentication (MFA) plugin for Strapi v5+. Secure your St
21
21
 
22
22
  To install this plugin, you'll need to include it in your Strapi project.
23
23
 
24
- 1. **Install the dependency** (if published to npm) or link the local plugin.
24
+ 1. **Install the dependency**:
25
+
26
+ ```bash
27
+ npm install strapi-identity
28
+ # or
29
+ yarn add strapi-identity
30
+ ```
31
+
25
32
  2. **Enable the plugin** in `config/plugins.ts`:
26
33
 
27
34
  ```typescript
@@ -29,7 +36,6 @@ export default {
29
36
  // ...
30
37
  'strapi-identity': {
31
38
  enabled: true,
32
- resolve: './src/plugins/strapi-identity', // If local
33
39
  },
34
40
  // ...
35
41
  };
@@ -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 getTranslation } from "./index-Df5ytRzw.mjs";
5
+ import { g as getTranslation } from "./index-Dx9hSw6F.mjs";
6
6
  import { g as getToken } from "./tokenHelpers-DagDzpso.mjs";
7
7
  import { useIntl } from "react-intl";
8
8
  const AdminReset = ({ id }) => {
@@ -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-CeYv7uJ3.js");
7
+ const index = require("./index-CYdMQdCl.js");
8
8
  const tokenHelpers = require("./tokenHelpers-jtoRu0q5.js");
9
9
  const reactIntl = require("react-intl");
10
10
  const AdminReset = ({ id }) => {
@@ -1,8 +1,9 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { useState, useEffect } from "react";
3
3
  import { Modal, Flex, Typography, Grid, Button, TextInput, Box, Field, Toggle } from "@strapi/design-system";
4
- import { g as getTranslation, I as InputOTP, a as InputOTPGroup, b as InputOTPSlot, c as InputOTPSeparator } from "./index-Df5ytRzw.mjs";
5
- import QRCode from "react-qr-code";
4
+ import styled from "styled-components";
5
+ import { g as getTranslation, I as InputOTP, a as InputOTPGroup, b as InputOTPSlot, c as InputOTPSeparator } from "./index-Dx9hSw6F.mjs";
6
+ import { QRCodeCanvas } from "qrcode.react";
6
7
  import { useIntl } from "react-intl";
7
8
  import { g as getToken } from "./tokenHelpers-DagDzpso.mjs";
8
9
  function ConfirmModal({
@@ -29,25 +30,16 @@ function ConfirmModal({
29
30
  id: getTranslation("profile.recovery_codes_warning"),
30
31
  defaultMessage: "If you lose both your authenticator app and your recovery codes, you will need to contact an administrator to regain access to your account."
31
32
  }) })
32
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
33
+ ] }) : /* @__PURE__ */ jsxs(Flex, { direction: "column", children: [
33
34
  /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "center", gap: 4, marginTop: 4, marginBottom: 4, children: [
34
35
  /* @__PURE__ */ jsx(Typography, { children: formatMessage({
35
36
  id: getTranslation("profile.scan_qr"),
36
37
  defaultMessage: "You will need an authenticator app to scan the QR code below."
37
38
  }) }),
38
- /* @__PURE__ */ jsx(QRCode, { value: qrCodeUri || "" }),
39
+ qrCodeUri && /* @__PURE__ */ jsx(QRCodeCanvas, { value: qrCodeUri, size: 256 }),
39
40
  secret && /* @__PURE__ */ jsx(Typography, { variant: "pi", children: secret || "" })
40
41
  ] }),
41
- /* @__PURE__ */ jsx(
42
- "hr",
43
- {
44
- style: {
45
- height: "1px",
46
- border: "0",
47
- backgroundColor: "#e5e5e5"
48
- }
49
- }
50
- ),
42
+ /* @__PURE__ */ jsx(Rule, {}),
51
43
  /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "center", gap: 4, marginTop: 4, marginBottom: 4, children: [
52
44
  /* @__PURE__ */ jsx(Typography, { children: formatMessage({
53
45
  id: getTranslation("profile.enter_otp"),
@@ -75,6 +67,11 @@ function ConfirmModal({
75
67
  ] })
76
68
  ] }) }) });
77
69
  }
70
+ const Rule = styled.hr`
71
+ height: 1px;
72
+ border: 0;
73
+ background-color: #e5e5e5;
74
+ `;
78
75
  function RemoveModal({ open, onOpenChange, onSubmit }) {
79
76
  const { formatMessage } = useIntl();
80
77
  const [showRecovery, setShowRecovery] = useState(false);
@@ -3,12 +3,13 @@ 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-CeYv7uJ3.js");
7
- const QRCode = require("react-qr-code");
6
+ const styled = require("styled-components");
7
+ const index = require("./index-CYdMQdCl.js");
8
+ const qrcode_react = require("qrcode.react");
8
9
  const reactIntl = require("react-intl");
9
10
  const tokenHelpers = require("./tokenHelpers-jtoRu0q5.js");
10
11
  const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
11
- const QRCode__default = /* @__PURE__ */ _interopDefault(QRCode);
12
+ const styled__default = /* @__PURE__ */ _interopDefault(styled);
12
13
  function ConfirmModal({
13
14
  open,
14
15
  onOpenChange,
@@ -33,25 +34,16 @@ function ConfirmModal({
33
34
  id: index.getTranslation("profile.recovery_codes_warning"),
34
35
  defaultMessage: "If you lose both your authenticator app and your recovery codes, you will need to contact an administrator to regain access to your account."
35
36
  }) })
36
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
37
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", children: [
37
38
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "center", gap: 4, marginTop: 4, marginBottom: 4, children: [
38
39
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
39
40
  id: index.getTranslation("profile.scan_qr"),
40
41
  defaultMessage: "You will need an authenticator app to scan the QR code below."
41
42
  }) }),
42
- /* @__PURE__ */ jsxRuntime.jsx(QRCode__default.default, { value: qrCodeUri || "" }),
43
+ qrCodeUri && /* @__PURE__ */ jsxRuntime.jsx(qrcode_react.QRCodeCanvas, { value: qrCodeUri, size: 256 }),
43
44
  secret && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", children: secret || "" })
44
45
  ] }),
45
- /* @__PURE__ */ jsxRuntime.jsx(
46
- "hr",
47
- {
48
- style: {
49
- height: "1px",
50
- border: "0",
51
- backgroundColor: "#e5e5e5"
52
- }
53
- }
54
- ),
46
+ /* @__PURE__ */ jsxRuntime.jsx(Rule, {}),
55
47
  /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "center", gap: 4, marginTop: 4, marginBottom: 4, children: [
56
48
  /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { children: formatMessage({
57
49
  id: index.getTranslation("profile.enter_otp"),
@@ -79,6 +71,11 @@ function ConfirmModal({
79
71
  ] })
80
72
  ] }) }) });
81
73
  }
74
+ const Rule = styled__default.default.hr`
75
+ height: 1px;
76
+ border: 0;
77
+ background-color: #e5e5e5;
78
+ `;
82
79
  function RemoveModal({ open, onOpenChange, onSubmit }) {
83
80
  const { formatMessage } = reactIntl.useIntl();
84
81
  const [showRecovery, setShowRecovery] = React.useState(false);
@@ -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-CeYv7uJ3.js");
9
+ const index = require("./index-CYdMQdCl.js");
10
10
  const tokenHelpers = require("./tokenHelpers-jtoRu0q5.js");
11
11
  const reactIntl = require("react-intl");
12
12
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
@@ -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 } from "@strapi/design-system";
6
6
  import { Check } from "@strapi/icons";
7
- import { g as getTranslation } from "./index-Df5ytRzw.mjs";
7
+ import { g as getTranslation } from "./index-Dx9hSw6F.mjs";
8
8
  import { g as getToken } from "./tokenHelpers-DagDzpso.mjs";
9
9
  import { useIntl } from "react-intl";
10
10
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
@@ -1391,7 +1391,7 @@ const plugin = {
1391
1391
  },
1392
1392
  id: "strapi-identity-settings",
1393
1393
  to: `/settings/${PLUGIN_ID}`,
1394
- Component: async () => Promise.resolve().then(() => require("./SettingsPage-IAGo8KRd.js")),
1394
+ Component: async () => Promise.resolve().then(() => require("./SettingsPage-b1nrDzRV.js")),
1395
1395
  permissions: [
1396
1396
  { action: "plugin::strapi-identity.settings.read" },
1397
1397
  { action: "plugin::strapi-identity.settings.read" }
@@ -1403,13 +1403,13 @@ const plugin = {
1403
1403
  id: "profile-toggle",
1404
1404
  route: "/admin/me",
1405
1405
  selector: '#main-content form[method="put"] > :nth-child(2) > div > div > div:nth-child(2)',
1406
- Component: async () => Promise.resolve().then(() => require("./ProfileToggle-CHVH6P3j.js"))
1406
+ Component: async () => Promise.resolve().then(() => require("./ProfileToggle-CsKhueBz.js"))
1407
1407
  });
1408
1408
  injections.registerRoute({
1409
1409
  id: "admin-reset",
1410
1410
  route: "/admin/settings/users/:id",
1411
1411
  selector: '#main-content form[method="put"] > :nth-child(2) > div > div:nth-child(2)',
1412
- Component: async () => Promise.resolve().then(() => require("./AdminReset-BohoWW_F.js"))
1412
+ Component: async () => Promise.resolve().then(() => require("./AdminReset-DOOd1ZBT.js"))
1413
1413
  });
1414
1414
  InjectVerify(app);
1415
1415
  },
@@ -1371,7 +1371,7 @@ const plugin = {
1371
1371
  },
1372
1372
  id: "strapi-identity-settings",
1373
1373
  to: `/settings/${PLUGIN_ID}`,
1374
- Component: async () => import("./SettingsPage-C_Ke-Agb.mjs"),
1374
+ Component: async () => import("./SettingsPage-mmaTI4X1.mjs"),
1375
1375
  permissions: [
1376
1376
  { action: "plugin::strapi-identity.settings.read" },
1377
1377
  { action: "plugin::strapi-identity.settings.read" }
@@ -1383,13 +1383,13 @@ const plugin = {
1383
1383
  id: "profile-toggle",
1384
1384
  route: "/admin/me",
1385
1385
  selector: '#main-content form[method="put"] > :nth-child(2) > div > div > div:nth-child(2)',
1386
- Component: async () => import("./ProfileToggle-DIVxRCbJ.mjs")
1386
+ Component: async () => import("./ProfileToggle-BWTNE6w1.mjs")
1387
1387
  });
1388
1388
  injections.registerRoute({
1389
1389
  id: "admin-reset",
1390
1390
  route: "/admin/settings/users/:id",
1391
1391
  selector: '#main-content form[method="put"] > :nth-child(2) > div > div:nth-child(2)',
1392
- Component: async () => import("./AdminReset-B7_r8Jh1.mjs")
1392
+ Component: async () => import("./AdminReset-C7Wbxz4Z.mjs")
1393
1393
  });
1394
1394
  InjectVerify(app);
1395
1395
  },
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
- const index = require("../_chunks/index-CeYv7uJ3.js");
2
+ const index = require("../_chunks/index-CYdMQdCl.js");
3
3
  require("strapi-admin-portal");
4
4
  module.exports = index.plugin;
@@ -1,4 +1,4 @@
1
- import { p } from "../_chunks/index-Df5ytRzw.mjs";
1
+ import { p } from "../_chunks/index-Dx9hSw6F.mjs";
2
2
  import "strapi-admin-portal";
3
3
  export {
4
4
  p as default
@@ -9074,15 +9074,11 @@ const jwt = /* @__PURE__ */ getDefaultExportFromCjs(jsonwebtokenExports);
9074
9074
  const register = ({ strapi: strapi2 }) => {
9075
9075
  const adminPlugin = strapi2.admin;
9076
9076
  const secret2 = strapi2.config.get("admin.auth.secret");
9077
- const configuredSecure = strapi2.config.get("admin.auth.cookie.secure");
9078
- const isProduction = process.env.NODE_ENV === "production";
9079
- const isSecure = typeof configuredSecure === "boolean" ? configuredSecure : isProduction;
9080
9077
  const domain = strapi2.config.get("admin.auth.domain");
9081
- const cookieOptions = { httpOnly: false, secure: isSecure, overwrite: true, domain };
9082
9078
  const loginRoute = adminPlugin.routes.admin.routes.find(
9083
9079
  ({ method, path }) => method === "POST" && path === "/login"
9084
9080
  );
9085
- if (loginRoute) replaceLogin(loginRoute, secret2, cookieOptions);
9081
+ if (loginRoute) replaceLogin(loginRoute, secret2, domain);
9086
9082
  strapi2.server.use(async (ctx, next) => {
9087
9083
  const mfaCookie = ctx.cookies.get("strapi_admin_mfa");
9088
9084
  if (mfaCookie && ctx.path.startsWith("/admin/auth")) {
@@ -9097,7 +9093,7 @@ const register = ({ strapi: strapi2 }) => {
9097
9093
  await next();
9098
9094
  });
9099
9095
  };
9100
- const replaceLogin = (route2, secret2, cookieOptions) => {
9096
+ const replaceLogin = (route2, secret2, domain) => {
9101
9097
  route2.config.middlewares = route2.config.middlewares || [];
9102
9098
  route2.config.middlewares.push(async (ctx, next) => {
9103
9099
  const { deviceId, rememberMe } = ctx.request.body;
@@ -9115,7 +9111,13 @@ const replaceLogin = (route2, secret2, cookieOptions) => {
9115
9111
  const newPayload = { userId: payload.userId, deviceId, rememberMe, type: "mfa" };
9116
9112
  const newToken = jwt.sign(newPayload, secret2, { expiresIn: "5m" });
9117
9113
  const expires = new Date(Date.now() + 5 * 60 * 1e3);
9118
- ctx.cookies.set("strapi_admin_mfa", newToken, { ...cookieOptions, expires });
9114
+ ctx.cookies.set("strapi_admin_mfa", newToken, {
9115
+ domain,
9116
+ httpOnly: false,
9117
+ overwrite: true,
9118
+ secure: ctx.request.secure,
9119
+ expires
9120
+ });
9119
9121
  ctx.body.data = { data: {}, error: null };
9120
9122
  });
9121
9123
  };
@@ -9420,13 +9422,10 @@ const controller = ({ strapi: strapi2 }) => ({
9420
9422
  );
9421
9423
  const accessResult = await sessionManager("admin").generateAccessToken(refreshToken);
9422
9424
  const { token: accessToken } = accessResult;
9423
- const configuredSecure = strapi2.config.get("admin.auth.cookie.secure");
9424
- const isProduction = process.env.NODE_ENV === "production";
9425
- const isSecure = typeof configuredSecure === "boolean" ? configuredSecure : isProduction;
9426
9425
  const domain = strapi2.config.get("admin.auth.domain");
9427
9426
  ctx.cookies.set("jwtToken", accessToken, {
9428
9427
  httpOnly: false,
9429
- secure: isSecure,
9428
+ secure: ctx.request.secure,
9430
9429
  overwrite: true,
9431
9430
  domain
9432
9431
  });
@@ -9068,15 +9068,11 @@ const jwt = /* @__PURE__ */ getDefaultExportFromCjs(jsonwebtokenExports);
9068
9068
  const register = ({ strapi: strapi2 }) => {
9069
9069
  const adminPlugin = strapi2.admin;
9070
9070
  const secret2 = strapi2.config.get("admin.auth.secret");
9071
- const configuredSecure = strapi2.config.get("admin.auth.cookie.secure");
9072
- const isProduction = process.env.NODE_ENV === "production";
9073
- const isSecure = typeof configuredSecure === "boolean" ? configuredSecure : isProduction;
9074
9071
  const domain = strapi2.config.get("admin.auth.domain");
9075
- const cookieOptions = { httpOnly: false, secure: isSecure, overwrite: true, domain };
9076
9072
  const loginRoute = adminPlugin.routes.admin.routes.find(
9077
9073
  ({ method, path }) => method === "POST" && path === "/login"
9078
9074
  );
9079
- if (loginRoute) replaceLogin(loginRoute, secret2, cookieOptions);
9075
+ if (loginRoute) replaceLogin(loginRoute, secret2, domain);
9080
9076
  strapi2.server.use(async (ctx, next) => {
9081
9077
  const mfaCookie = ctx.cookies.get("strapi_admin_mfa");
9082
9078
  if (mfaCookie && ctx.path.startsWith("/admin/auth")) {
@@ -9091,7 +9087,7 @@ const register = ({ strapi: strapi2 }) => {
9091
9087
  await next();
9092
9088
  });
9093
9089
  };
9094
- const replaceLogin = (route2, secret2, cookieOptions) => {
9090
+ const replaceLogin = (route2, secret2, domain) => {
9095
9091
  route2.config.middlewares = route2.config.middlewares || [];
9096
9092
  route2.config.middlewares.push(async (ctx, next) => {
9097
9093
  const { deviceId, rememberMe } = ctx.request.body;
@@ -9109,7 +9105,13 @@ const replaceLogin = (route2, secret2, cookieOptions) => {
9109
9105
  const newPayload = { userId: payload.userId, deviceId, rememberMe, type: "mfa" };
9110
9106
  const newToken = jwt.sign(newPayload, secret2, { expiresIn: "5m" });
9111
9107
  const expires = new Date(Date.now() + 5 * 60 * 1e3);
9112
- ctx.cookies.set("strapi_admin_mfa", newToken, { ...cookieOptions, expires });
9108
+ ctx.cookies.set("strapi_admin_mfa", newToken, {
9109
+ domain,
9110
+ httpOnly: false,
9111
+ overwrite: true,
9112
+ secure: ctx.request.secure,
9113
+ expires
9114
+ });
9113
9115
  ctx.body.data = { data: {}, error: null };
9114
9116
  });
9115
9117
  };
@@ -9414,13 +9416,10 @@ const controller = ({ strapi: strapi2 }) => ({
9414
9416
  );
9415
9417
  const accessResult = await sessionManager("admin").generateAccessToken(refreshToken);
9416
9418
  const { token: accessToken } = accessResult;
9417
- const configuredSecure = strapi2.config.get("admin.auth.cookie.secure");
9418
- const isProduction = process.env.NODE_ENV === "production";
9419
- const isSecure = typeof configuredSecure === "boolean" ? configuredSecure : isProduction;
9420
9419
  const domain = strapi2.config.get("admin.auth.domain");
9421
9420
  ctx.cookies.set("jwtToken", accessToken, {
9422
9421
  httpOnly: false,
9423
- secure: isSecure,
9422
+ secure: ctx.request.secure,
9424
9423
  overwrite: true,
9425
9424
  domain
9426
9425
  });
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.1",
2
+ "version": "0.0.2-debug.1",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "plugin",
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "input-otp": "^1.4.2",
41
41
  "otpauth": "^9.5.0",
42
- "react-qr-code": "^2.0.18",
42
+ "qrcode.react": "^4.2.0",
43
43
  "strapi-admin-portal": "^0.0.3"
44
44
  },
45
45
  "devDependencies": {