strapi-plugin-magic-link-v5 5.3.5 → 5.3.7
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/dist/_chunks/{index-Cx9e2h19.mjs → index-BUHivW2a.mjs} +19 -6
- package/dist/_chunks/{index-8wsWImGa.mjs → index-C5VJ3M0F.mjs} +3 -3
- package/dist/_chunks/{index-CrTiXLRe.js → index-C9OJSkTr.js} +1 -1
- package/dist/_chunks/{index-CMA6rFEs.mjs → index-CuGZgFmB.mjs} +1 -1
- package/dist/_chunks/{index-BD7sPPVF.js → index-DK6dkTEP.js} +3 -3
- package/dist/_chunks/{index-OEvO68kw.mjs → index-DY0oHIyx.mjs} +1 -1
- package/dist/_chunks/{index-UIfKHe3H.js → index-JjtRSZnt.js} +1 -1
- package/dist/_chunks/{index-EZVtOYIf.js → index-wXx2DRow.js} +19 -6
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +76 -17
- package/dist/server/index.mjs +76 -17
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import { useIntl } from "react-intl";
|
|
|
5
5
|
import { Box, Typography, Flex, Button, Accordion, SingleSelect, SingleSelectOption, Grid, Toggle, NumberInput, TextInput, Divider, Textarea, Badge } from "@strapi/design-system";
|
|
6
6
|
import { Check, Cog, Lightning, Shield, Mail, CheckCircle, Code, Link, Lock, Key } from "@strapi/icons";
|
|
7
7
|
import { useNotification, useFetchClient } from "@strapi/strapi/admin";
|
|
8
|
-
import { g as getTrad } from "./index-
|
|
8
|
+
import { g as getTrad } from "./index-C5VJ3M0F.mjs";
|
|
9
9
|
import { u as usePluginLanguage, L as LicenseGuard, a as LanguageProvider } from "./LicenseGuard-B_r3b1Vh.mjs";
|
|
10
10
|
const EMAIL_TEMPLATES = {
|
|
11
11
|
modern: {
|
|
@@ -848,7 +848,14 @@ _Falls du diesen Link nicht angefordert hast, ignoriere diese Nachricht._`,
|
|
|
848
848
|
e.preventDefault();
|
|
849
849
|
setIsSaving(true);
|
|
850
850
|
try {
|
|
851
|
-
|
|
851
|
+
const toSave = { ...settings, ui_language: language };
|
|
852
|
+
if (typeof toSave.context_whitelist === "string") {
|
|
853
|
+
toSave.context_whitelist = toSave.context_whitelist.split(",").map((s) => s.trim()).filter(Boolean);
|
|
854
|
+
}
|
|
855
|
+
if (typeof toSave.context_blacklist === "string") {
|
|
856
|
+
toSave.context_blacklist = toSave.context_blacklist.split(",").map((s) => s.trim()).filter(Boolean);
|
|
857
|
+
}
|
|
858
|
+
await put("/magic-link/settings", toSave);
|
|
852
859
|
toggleNotification({
|
|
853
860
|
type: "success",
|
|
854
861
|
message: formatMessage({ id: getTrad("settings.save.success") })
|
|
@@ -1142,9 +1149,12 @@ _Falls du diesen Link nicht angefordert hast, ignoriere diese Nachricht._`,
|
|
|
1142
1149
|
TextInput,
|
|
1143
1150
|
{
|
|
1144
1151
|
hint: formatMessage({ id: getTrad("settings.context.whitelist.hint") }),
|
|
1145
|
-
value: (settings.context_whitelist || []).join(", "),
|
|
1152
|
+
value: typeof settings.context_whitelist === "string" ? settings.context_whitelist : (settings.context_whitelist || []).join(", "),
|
|
1146
1153
|
onChange: (e) => {
|
|
1147
|
-
|
|
1154
|
+
updateSetting("context_whitelist", e.target.value);
|
|
1155
|
+
},
|
|
1156
|
+
onBlur: (e) => {
|
|
1157
|
+
const value = typeof settings.context_whitelist === "string" ? settings.context_whitelist : "";
|
|
1148
1158
|
const list = value ? value.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
1149
1159
|
updateSetting("context_whitelist", list);
|
|
1150
1160
|
},
|
|
@@ -1159,9 +1169,12 @@ _Falls du diesen Link nicht angefordert hast, ignoriere diese Nachricht._`,
|
|
|
1159
1169
|
TextInput,
|
|
1160
1170
|
{
|
|
1161
1171
|
hint: formatMessage({ id: getTrad("settings.context.blacklist.hint") }),
|
|
1162
|
-
value: (settings.context_blacklist || []).join(", "),
|
|
1172
|
+
value: typeof settings.context_blacklist === "string" ? settings.context_blacklist : (settings.context_blacklist || []).join(", "),
|
|
1163
1173
|
onChange: (e) => {
|
|
1164
|
-
|
|
1174
|
+
updateSetting("context_blacklist", e.target.value);
|
|
1175
|
+
},
|
|
1176
|
+
onBlur: (e) => {
|
|
1177
|
+
const value = typeof settings.context_blacklist === "string" ? settings.context_blacklist : "";
|
|
1165
1178
|
const list = value ? value.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
1166
1179
|
updateSetting("context_blacklist", list);
|
|
1167
1180
|
},
|
|
@@ -59,7 +59,7 @@ const index = {
|
|
|
59
59
|
},
|
|
60
60
|
Component: () => import(
|
|
61
61
|
/* webpackChunkName: "magic-link-tokens" */
|
|
62
|
-
"./index-
|
|
62
|
+
"./index-CuGZgFmB.mjs"
|
|
63
63
|
),
|
|
64
64
|
permissions: []
|
|
65
65
|
// Leeres Array = keine Permission-Prüfung nötig
|
|
@@ -82,7 +82,7 @@ const index = {
|
|
|
82
82
|
to: `${PLUGIN_ID}/config`,
|
|
83
83
|
Component: () => import(
|
|
84
84
|
/* webpackChunkName: "magic-link-settings" */
|
|
85
|
-
"./index-
|
|
85
|
+
"./index-BUHivW2a.mjs"
|
|
86
86
|
),
|
|
87
87
|
permissions: pluginPermissions.readSettings
|
|
88
88
|
},
|
|
@@ -121,7 +121,7 @@ const index = {
|
|
|
121
121
|
to: `${PLUGIN_ID}/whatsapp`,
|
|
122
122
|
Component: () => import(
|
|
123
123
|
/* webpackChunkName: "magic-link-whatsapp" */
|
|
124
|
-
"./index-
|
|
124
|
+
"./index-DY0oHIyx.mjs"
|
|
125
125
|
),
|
|
126
126
|
permissions: []
|
|
127
127
|
}
|
|
@@ -7,7 +7,7 @@ const styled = require("styled-components");
|
|
|
7
7
|
const reactIntl = require("react-intl");
|
|
8
8
|
const designSystem = require("@strapi/design-system");
|
|
9
9
|
const icons = require("@strapi/icons");
|
|
10
|
-
const index = require("./index-
|
|
10
|
+
const index = require("./index-DK6dkTEP.js");
|
|
11
11
|
const admin = require("@strapi/strapi/admin");
|
|
12
12
|
const LicenseGuard = require("./LicenseGuard-BEEd9IpN.js");
|
|
13
13
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
@@ -5,7 +5,7 @@ import styled, { keyframes, css } from "styled-components";
|
|
|
5
5
|
import { useIntl } from "react-intl";
|
|
6
6
|
import { Box, Flex, Typography, Button, TextInput, Textarea, Checkbox, IconButton, Loader, Searchbar, SingleSelect, SingleSelectOption, Thead, Tr, Th, Tbody, Td, Pagination, PreviousLink, PageLink, NextLink, Table, Badge, VisuallyHidden, Main } from "@strapi/design-system";
|
|
7
7
|
import { Cross, Sparkle, Check, Shield, Clock, Lock, Trash, ArrowClockwise, CaretDown, User, Monitor, Calendar, Plus, Earth, WarningCircle, Server, Eye, Mail, Cog, Key, Link } from "@strapi/icons";
|
|
8
|
-
import { g as getTrad, P as PLUGIN_ID } from "./index-
|
|
8
|
+
import { g as getTrad, P as PLUGIN_ID } from "./index-C5VJ3M0F.mjs";
|
|
9
9
|
import { useFetchClient, useNotification } from "@strapi/strapi/admin";
|
|
10
10
|
import { L as LicenseGuard, a as LanguageProvider } from "./LicenseGuard-B_r3b1Vh.mjs";
|
|
11
11
|
const CreateTokenModal = ({ isOpen, onClose, onSubmit, formData, setFormData }) => {
|
|
@@ -60,7 +60,7 @@ const index = {
|
|
|
60
60
|
},
|
|
61
61
|
Component: () => Promise.resolve().then(() => require(
|
|
62
62
|
/* webpackChunkName: "magic-link-tokens" */
|
|
63
|
-
"./index-
|
|
63
|
+
"./index-C9OJSkTr.js"
|
|
64
64
|
)),
|
|
65
65
|
permissions: []
|
|
66
66
|
// Leeres Array = keine Permission-Prüfung nötig
|
|
@@ -83,7 +83,7 @@ const index = {
|
|
|
83
83
|
to: `${PLUGIN_ID}/config`,
|
|
84
84
|
Component: () => Promise.resolve().then(() => require(
|
|
85
85
|
/* webpackChunkName: "magic-link-settings" */
|
|
86
|
-
"./index-
|
|
86
|
+
"./index-wXx2DRow.js"
|
|
87
87
|
)),
|
|
88
88
|
permissions: pluginPermissions.readSettings
|
|
89
89
|
},
|
|
@@ -122,7 +122,7 @@ const index = {
|
|
|
122
122
|
to: `${PLUGIN_ID}/whatsapp`,
|
|
123
123
|
Component: () => Promise.resolve().then(() => require(
|
|
124
124
|
/* webpackChunkName: "magic-link-whatsapp" */
|
|
125
|
-
"./index-
|
|
125
|
+
"./index-JjtRSZnt.js"
|
|
126
126
|
)),
|
|
127
127
|
permissions: []
|
|
128
128
|
}
|
|
@@ -5,7 +5,7 @@ import { useIntl } from "react-intl";
|
|
|
5
5
|
import { Flex, Loader, Box, Typography, Button, TextInput, Badge } from "@strapi/design-system";
|
|
6
6
|
import { Phone, Check, Message, ArrowClockwise } from "@strapi/icons";
|
|
7
7
|
import { useNotification, useFetchClient } from "@strapi/strapi/admin";
|
|
8
|
-
import { g as getTrad } from "./index-
|
|
8
|
+
import { g as getTrad } from "./index-C5VJ3M0F.mjs";
|
|
9
9
|
const theme = {
|
|
10
10
|
colors: {
|
|
11
11
|
primary: { 700: "#075985", 100: "#E0F2FE", 50: "#F0F9FF" },
|
|
@@ -7,7 +7,7 @@ const reactIntl = require("react-intl");
|
|
|
7
7
|
const designSystem = require("@strapi/design-system");
|
|
8
8
|
const icons = require("@strapi/icons");
|
|
9
9
|
const admin = require("@strapi/strapi/admin");
|
|
10
|
-
const index = require("./index-
|
|
10
|
+
const index = require("./index-DK6dkTEP.js");
|
|
11
11
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
12
12
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
13
13
|
const theme = {
|
|
@@ -7,7 +7,7 @@ const reactIntl = require("react-intl");
|
|
|
7
7
|
const designSystem = require("@strapi/design-system");
|
|
8
8
|
const icons = require("@strapi/icons");
|
|
9
9
|
const admin = require("@strapi/strapi/admin");
|
|
10
|
-
const index = require("./index-
|
|
10
|
+
const index = require("./index-DK6dkTEP.js");
|
|
11
11
|
const LicenseGuard = require("./LicenseGuard-BEEd9IpN.js");
|
|
12
12
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
13
13
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
@@ -852,7 +852,14 @@ _Falls du diesen Link nicht angefordert hast, ignoriere diese Nachricht._`,
|
|
|
852
852
|
e.preventDefault();
|
|
853
853
|
setIsSaving(true);
|
|
854
854
|
try {
|
|
855
|
-
|
|
855
|
+
const toSave = { ...settings, ui_language: language };
|
|
856
|
+
if (typeof toSave.context_whitelist === "string") {
|
|
857
|
+
toSave.context_whitelist = toSave.context_whitelist.split(",").map((s) => s.trim()).filter(Boolean);
|
|
858
|
+
}
|
|
859
|
+
if (typeof toSave.context_blacklist === "string") {
|
|
860
|
+
toSave.context_blacklist = toSave.context_blacklist.split(",").map((s) => s.trim()).filter(Boolean);
|
|
861
|
+
}
|
|
862
|
+
await put("/magic-link/settings", toSave);
|
|
856
863
|
toggleNotification({
|
|
857
864
|
type: "success",
|
|
858
865
|
message: formatMessage({ id: index.getTrad("settings.save.success") })
|
|
@@ -1146,9 +1153,12 @@ _Falls du diesen Link nicht angefordert hast, ignoriere diese Nachricht._`,
|
|
|
1146
1153
|
designSystem.TextInput,
|
|
1147
1154
|
{
|
|
1148
1155
|
hint: formatMessage({ id: index.getTrad("settings.context.whitelist.hint") }),
|
|
1149
|
-
value: (settings.context_whitelist || []).join(", "),
|
|
1156
|
+
value: typeof settings.context_whitelist === "string" ? settings.context_whitelist : (settings.context_whitelist || []).join(", "),
|
|
1150
1157
|
onChange: (e) => {
|
|
1151
|
-
|
|
1158
|
+
updateSetting("context_whitelist", e.target.value);
|
|
1159
|
+
},
|
|
1160
|
+
onBlur: (e) => {
|
|
1161
|
+
const value = typeof settings.context_whitelist === "string" ? settings.context_whitelist : "";
|
|
1152
1162
|
const list = value ? value.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
1153
1163
|
updateSetting("context_whitelist", list);
|
|
1154
1164
|
},
|
|
@@ -1163,9 +1173,12 @@ _Falls du diesen Link nicht angefordert hast, ignoriere diese Nachricht._`,
|
|
|
1163
1173
|
designSystem.TextInput,
|
|
1164
1174
|
{
|
|
1165
1175
|
hint: formatMessage({ id: index.getTrad("settings.context.blacklist.hint") }),
|
|
1166
|
-
value: (settings.context_blacklist || []).join(", "),
|
|
1176
|
+
value: typeof settings.context_blacklist === "string" ? settings.context_blacklist : (settings.context_blacklist || []).join(", "),
|
|
1167
1177
|
onChange: (e) => {
|
|
1168
|
-
|
|
1178
|
+
updateSetting("context_blacklist", e.target.value);
|
|
1179
|
+
},
|
|
1180
|
+
onBlur: (e) => {
|
|
1181
|
+
const value = typeof settings.context_blacklist === "string" ? settings.context_blacklist : "";
|
|
1169
1182
|
const list = value ? value.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
1170
1183
|
updateSetting("context_blacklist", list);
|
|
1171
1184
|
},
|
package/dist/admin/index.js
CHANGED
package/dist/admin/index.mjs
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -23591,20 +23591,22 @@ var auth$1 = {
|
|
|
23591
23591
|
} catch (e2) {
|
|
23592
23592
|
context = {};
|
|
23593
23593
|
}
|
|
23594
|
-
const
|
|
23594
|
+
const sensitiveKeys = ["password", "secret", "apiKey", "token", "resetPasswordToken", "confirmationToken"];
|
|
23595
23595
|
const sanitizedContext = {};
|
|
23596
|
-
for (const
|
|
23597
|
-
if (
|
|
23598
|
-
|
|
23599
|
-
|
|
23600
|
-
|
|
23601
|
-
|
|
23602
|
-
|
|
23603
|
-
|
|
23604
|
-
|
|
23605
|
-
|
|
23606
|
-
|
|
23607
|
-
|
|
23596
|
+
for (const [key, val] of Object.entries(context)) {
|
|
23597
|
+
if (sensitiveKeys.includes(key)) continue;
|
|
23598
|
+
if (val === void 0) continue;
|
|
23599
|
+
if (typeof val === "string") {
|
|
23600
|
+
sanitizedContext[key] = val.substring(0, 2e3);
|
|
23601
|
+
} else if (typeof val === "boolean") {
|
|
23602
|
+
sanitizedContext[key] = val;
|
|
23603
|
+
} else if (typeof val === "number" && !isNaN(val)) {
|
|
23604
|
+
sanitizedContext[key] = val;
|
|
23605
|
+
} else if (typeof val === "object" && val !== null) {
|
|
23606
|
+
try {
|
|
23607
|
+
const jsonStr = JSON.stringify(val).substring(0, 5e3);
|
|
23608
|
+
sanitizedContext[key] = JSON.parse(jsonStr);
|
|
23609
|
+
} catch {
|
|
23608
23610
|
}
|
|
23609
23611
|
}
|
|
23610
23612
|
}
|
|
@@ -23809,10 +23811,30 @@ var auth$1 = {
|
|
|
23809
23811
|
delete sanitizedUser.resetPasswordToken;
|
|
23810
23812
|
delete sanitizedUser.confirmationToken;
|
|
23811
23813
|
delete sanitizedUser.roles;
|
|
23814
|
+
const mfaSensitiveKeys = ["password", "secret", "apiKey", "token", "resetPasswordToken", "confirmationToken", "requiresTOTP", "totpVerified", "userId"];
|
|
23815
|
+
const mfaSanitizedContext = {};
|
|
23816
|
+
for (const [key, val] of Object.entries(context)) {
|
|
23817
|
+
if (mfaSensitiveKeys.includes(key)) continue;
|
|
23818
|
+
if (val === void 0) continue;
|
|
23819
|
+
if (typeof val === "string") {
|
|
23820
|
+
mfaSanitizedContext[key] = val.substring(0, 2e3);
|
|
23821
|
+
} else if (typeof val === "boolean") {
|
|
23822
|
+
mfaSanitizedContext[key] = val;
|
|
23823
|
+
} else if (typeof val === "number" && !isNaN(val)) {
|
|
23824
|
+
mfaSanitizedContext[key] = val;
|
|
23825
|
+
} else if (typeof val === "object" && val !== null) {
|
|
23826
|
+
try {
|
|
23827
|
+
const jsonStr = JSON.stringify(val).substring(0, 5e3);
|
|
23828
|
+
mfaSanitizedContext[key] = JSON.parse(jsonStr);
|
|
23829
|
+
} catch {
|
|
23830
|
+
}
|
|
23831
|
+
}
|
|
23832
|
+
}
|
|
23812
23833
|
const settings = await magicLink2.settings();
|
|
23813
23834
|
const jwtToken = jwtService.issue({
|
|
23814
23835
|
id: user.id,
|
|
23815
|
-
mfaVerified: true
|
|
23836
|
+
mfaVerified: true,
|
|
23837
|
+
context: mfaSanitizedContext
|
|
23816
23838
|
});
|
|
23817
23839
|
let expirationTime = settings.jwt_token_expires_in || "30d";
|
|
23818
23840
|
let expiresAt = /* @__PURE__ */ new Date();
|
|
@@ -23843,7 +23865,8 @@ var auth$1 = {
|
|
|
23843
23865
|
userAgent: requestInfo.userAgent,
|
|
23844
23866
|
source: "Magic Link + TOTP (MFA)",
|
|
23845
23867
|
lastUsedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
23846
|
-
mfaVerified: true
|
|
23868
|
+
mfaVerified: true,
|
|
23869
|
+
context: mfaSanitizedContext
|
|
23847
23870
|
});
|
|
23848
23871
|
await pluginStore.set({ key: "jwt_sessions", value: jwtSessions });
|
|
23849
23872
|
} catch (error2) {
|
|
@@ -23853,6 +23876,7 @@ var auth$1 = {
|
|
|
23853
23876
|
jwt: jwtToken,
|
|
23854
23877
|
user: sanitizedUser,
|
|
23855
23878
|
mfaVerified: true,
|
|
23879
|
+
context: mfaSanitizedContext,
|
|
23856
23880
|
expires_at: expiresAt.toISOString()
|
|
23857
23881
|
});
|
|
23858
23882
|
},
|
|
@@ -25526,8 +25550,42 @@ var otp$3 = {
|
|
|
25526
25550
|
return ctx.badRequest("User not found");
|
|
25527
25551
|
}
|
|
25528
25552
|
const user = users[0];
|
|
25553
|
+
let tokenContext = {};
|
|
25554
|
+
if (magicLinkToken) {
|
|
25555
|
+
try {
|
|
25556
|
+
const magicLinkService = strapi.plugin("magic-link").service("magic-link");
|
|
25557
|
+
const token2 = await magicLinkService.fetchToken(magicLinkToken);
|
|
25558
|
+
if (token2 && token2.context) {
|
|
25559
|
+
tokenContext = token2.context;
|
|
25560
|
+
}
|
|
25561
|
+
} catch (e2) {
|
|
25562
|
+
strapi.log.warn("[OTP] Could not retrieve magic link token context:", e2.message);
|
|
25563
|
+
}
|
|
25564
|
+
}
|
|
25565
|
+
const sensitiveKeys = ["password", "secret", "apiKey", "token", "resetPasswordToken", "confirmationToken"];
|
|
25566
|
+
const sanitizedContext = {};
|
|
25567
|
+
for (const [key, val] of Object.entries(tokenContext)) {
|
|
25568
|
+
if (sensitiveKeys.includes(key)) continue;
|
|
25569
|
+
if (val === void 0) continue;
|
|
25570
|
+
if (typeof val === "string") {
|
|
25571
|
+
sanitizedContext[key] = val.substring(0, 2e3);
|
|
25572
|
+
} else if (typeof val === "boolean") {
|
|
25573
|
+
sanitizedContext[key] = val;
|
|
25574
|
+
} else if (typeof val === "number" && !isNaN(val)) {
|
|
25575
|
+
sanitizedContext[key] = val;
|
|
25576
|
+
} else if (typeof val === "object" && val !== null) {
|
|
25577
|
+
try {
|
|
25578
|
+
const jsonStr = JSON.stringify(val).substring(0, 5e3);
|
|
25579
|
+
sanitizedContext[key] = JSON.parse(jsonStr);
|
|
25580
|
+
} catch {
|
|
25581
|
+
}
|
|
25582
|
+
}
|
|
25583
|
+
}
|
|
25529
25584
|
const jwtService = strapi.plugin("users-permissions").service("jwt");
|
|
25530
|
-
const jwt2 = jwtService.issue({
|
|
25585
|
+
const jwt2 = jwtService.issue({
|
|
25586
|
+
id: user.id,
|
|
25587
|
+
context: sanitizedContext
|
|
25588
|
+
});
|
|
25531
25589
|
const pluginStore = strapi.store({
|
|
25532
25590
|
type: "plugin",
|
|
25533
25591
|
name: "magic-link"
|
|
@@ -25550,7 +25608,8 @@ var otp$3 = {
|
|
|
25550
25608
|
id: user.id,
|
|
25551
25609
|
username: user.username,
|
|
25552
25610
|
email: user.email
|
|
25553
|
-
}
|
|
25611
|
+
},
|
|
25612
|
+
context: sanitizedContext
|
|
25554
25613
|
});
|
|
25555
25614
|
} catch (error2) {
|
|
25556
25615
|
strapi.log.error("Error verifying OTP:", error2);
|
package/dist/server/index.mjs
CHANGED
|
@@ -23557,20 +23557,22 @@ var auth$1 = {
|
|
|
23557
23557
|
} catch (e2) {
|
|
23558
23558
|
context = {};
|
|
23559
23559
|
}
|
|
23560
|
-
const
|
|
23560
|
+
const sensitiveKeys = ["password", "secret", "apiKey", "token", "resetPasswordToken", "confirmationToken"];
|
|
23561
23561
|
const sanitizedContext = {};
|
|
23562
|
-
for (const
|
|
23563
|
-
if (
|
|
23564
|
-
|
|
23565
|
-
|
|
23566
|
-
|
|
23567
|
-
|
|
23568
|
-
|
|
23569
|
-
|
|
23570
|
-
|
|
23571
|
-
|
|
23572
|
-
|
|
23573
|
-
|
|
23562
|
+
for (const [key, val] of Object.entries(context)) {
|
|
23563
|
+
if (sensitiveKeys.includes(key)) continue;
|
|
23564
|
+
if (val === void 0) continue;
|
|
23565
|
+
if (typeof val === "string") {
|
|
23566
|
+
sanitizedContext[key] = val.substring(0, 2e3);
|
|
23567
|
+
} else if (typeof val === "boolean") {
|
|
23568
|
+
sanitizedContext[key] = val;
|
|
23569
|
+
} else if (typeof val === "number" && !isNaN(val)) {
|
|
23570
|
+
sanitizedContext[key] = val;
|
|
23571
|
+
} else if (typeof val === "object" && val !== null) {
|
|
23572
|
+
try {
|
|
23573
|
+
const jsonStr = JSON.stringify(val).substring(0, 5e3);
|
|
23574
|
+
sanitizedContext[key] = JSON.parse(jsonStr);
|
|
23575
|
+
} catch {
|
|
23574
23576
|
}
|
|
23575
23577
|
}
|
|
23576
23578
|
}
|
|
@@ -23775,10 +23777,30 @@ var auth$1 = {
|
|
|
23775
23777
|
delete sanitizedUser.resetPasswordToken;
|
|
23776
23778
|
delete sanitizedUser.confirmationToken;
|
|
23777
23779
|
delete sanitizedUser.roles;
|
|
23780
|
+
const mfaSensitiveKeys = ["password", "secret", "apiKey", "token", "resetPasswordToken", "confirmationToken", "requiresTOTP", "totpVerified", "userId"];
|
|
23781
|
+
const mfaSanitizedContext = {};
|
|
23782
|
+
for (const [key, val] of Object.entries(context)) {
|
|
23783
|
+
if (mfaSensitiveKeys.includes(key)) continue;
|
|
23784
|
+
if (val === void 0) continue;
|
|
23785
|
+
if (typeof val === "string") {
|
|
23786
|
+
mfaSanitizedContext[key] = val.substring(0, 2e3);
|
|
23787
|
+
} else if (typeof val === "boolean") {
|
|
23788
|
+
mfaSanitizedContext[key] = val;
|
|
23789
|
+
} else if (typeof val === "number" && !isNaN(val)) {
|
|
23790
|
+
mfaSanitizedContext[key] = val;
|
|
23791
|
+
} else if (typeof val === "object" && val !== null) {
|
|
23792
|
+
try {
|
|
23793
|
+
const jsonStr = JSON.stringify(val).substring(0, 5e3);
|
|
23794
|
+
mfaSanitizedContext[key] = JSON.parse(jsonStr);
|
|
23795
|
+
} catch {
|
|
23796
|
+
}
|
|
23797
|
+
}
|
|
23798
|
+
}
|
|
23778
23799
|
const settings = await magicLink2.settings();
|
|
23779
23800
|
const jwtToken = jwtService.issue({
|
|
23780
23801
|
id: user.id,
|
|
23781
|
-
mfaVerified: true
|
|
23802
|
+
mfaVerified: true,
|
|
23803
|
+
context: mfaSanitizedContext
|
|
23782
23804
|
});
|
|
23783
23805
|
let expirationTime = settings.jwt_token_expires_in || "30d";
|
|
23784
23806
|
let expiresAt = /* @__PURE__ */ new Date();
|
|
@@ -23809,7 +23831,8 @@ var auth$1 = {
|
|
|
23809
23831
|
userAgent: requestInfo.userAgent,
|
|
23810
23832
|
source: "Magic Link + TOTP (MFA)",
|
|
23811
23833
|
lastUsedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
23812
|
-
mfaVerified: true
|
|
23834
|
+
mfaVerified: true,
|
|
23835
|
+
context: mfaSanitizedContext
|
|
23813
23836
|
});
|
|
23814
23837
|
await pluginStore.set({ key: "jwt_sessions", value: jwtSessions });
|
|
23815
23838
|
} catch (error2) {
|
|
@@ -23819,6 +23842,7 @@ var auth$1 = {
|
|
|
23819
23842
|
jwt: jwtToken,
|
|
23820
23843
|
user: sanitizedUser,
|
|
23821
23844
|
mfaVerified: true,
|
|
23845
|
+
context: mfaSanitizedContext,
|
|
23822
23846
|
expires_at: expiresAt.toISOString()
|
|
23823
23847
|
});
|
|
23824
23848
|
},
|
|
@@ -25492,8 +25516,42 @@ var otp$3 = {
|
|
|
25492
25516
|
return ctx.badRequest("User not found");
|
|
25493
25517
|
}
|
|
25494
25518
|
const user = users[0];
|
|
25519
|
+
let tokenContext = {};
|
|
25520
|
+
if (magicLinkToken) {
|
|
25521
|
+
try {
|
|
25522
|
+
const magicLinkService = strapi.plugin("magic-link").service("magic-link");
|
|
25523
|
+
const token2 = await magicLinkService.fetchToken(magicLinkToken);
|
|
25524
|
+
if (token2 && token2.context) {
|
|
25525
|
+
tokenContext = token2.context;
|
|
25526
|
+
}
|
|
25527
|
+
} catch (e2) {
|
|
25528
|
+
strapi.log.warn("[OTP] Could not retrieve magic link token context:", e2.message);
|
|
25529
|
+
}
|
|
25530
|
+
}
|
|
25531
|
+
const sensitiveKeys = ["password", "secret", "apiKey", "token", "resetPasswordToken", "confirmationToken"];
|
|
25532
|
+
const sanitizedContext = {};
|
|
25533
|
+
for (const [key, val] of Object.entries(tokenContext)) {
|
|
25534
|
+
if (sensitiveKeys.includes(key)) continue;
|
|
25535
|
+
if (val === void 0) continue;
|
|
25536
|
+
if (typeof val === "string") {
|
|
25537
|
+
sanitizedContext[key] = val.substring(0, 2e3);
|
|
25538
|
+
} else if (typeof val === "boolean") {
|
|
25539
|
+
sanitizedContext[key] = val;
|
|
25540
|
+
} else if (typeof val === "number" && !isNaN(val)) {
|
|
25541
|
+
sanitizedContext[key] = val;
|
|
25542
|
+
} else if (typeof val === "object" && val !== null) {
|
|
25543
|
+
try {
|
|
25544
|
+
const jsonStr = JSON.stringify(val).substring(0, 5e3);
|
|
25545
|
+
sanitizedContext[key] = JSON.parse(jsonStr);
|
|
25546
|
+
} catch {
|
|
25547
|
+
}
|
|
25548
|
+
}
|
|
25549
|
+
}
|
|
25495
25550
|
const jwtService = strapi.plugin("users-permissions").service("jwt");
|
|
25496
|
-
const jwt2 = jwtService.issue({
|
|
25551
|
+
const jwt2 = jwtService.issue({
|
|
25552
|
+
id: user.id,
|
|
25553
|
+
context: sanitizedContext
|
|
25554
|
+
});
|
|
25497
25555
|
const pluginStore = strapi.store({
|
|
25498
25556
|
type: "plugin",
|
|
25499
25557
|
name: "magic-link"
|
|
@@ -25516,7 +25574,8 @@ var otp$3 = {
|
|
|
25516
25574
|
id: user.id,
|
|
25517
25575
|
username: user.username,
|
|
25518
25576
|
email: user.email
|
|
25519
|
-
}
|
|
25577
|
+
},
|
|
25578
|
+
context: sanitizedContext
|
|
25520
25579
|
});
|
|
25521
25580
|
} catch (error2) {
|
|
25522
25581
|
strapi.log.error("Error verifying OTP:", error2);
|
package/package.json
CHANGED