strapi-security-suite
Version:
All-in-one authentication and session security plugin for Strapi v5
86 lines (85 loc) • 2.63 kB
JavaScript
;
const react = require("react");
const jsxRuntime = require("react/jsx-runtime");
const icons = require("@strapi/icons");
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
const v = glob[path];
if (v) {
return typeof v === "function" ? v() : Promise.resolve(v);
}
return new Promise((_, reject) => {
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
reject.bind(
null,
new Error(
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
)
)
);
});
};
const PLUGIN_ID = "strapi-security-suite";
const Initializer = ({ setPlugin }) => {
const ref = react.useRef(setPlugin);
react.useEffect(() => {
ref.current(PLUGIN_ID);
}, []);
return null;
};
const PluginIcon = () => /* @__PURE__ */ jsxRuntime.jsx(icons.User, {});
const index = {
register(app) {
app.addMenuLink({
to: `plugins/${PLUGIN_ID}`,
icon: PluginIcon,
intlLabel: {
id: `${PLUGIN_ID}.plugin.name`,
defaultMessage: PLUGIN_ID
},
Component: async () => {
const { App } = await Promise.resolve().then(() => require("../_chunks/App-_xsdnv0p.js"));
return App;
},
permissions: [
{
action: "plugin::strapi-security-suite.access",
subject: null
}
]
});
app.registerPlugin({
id: PLUGIN_ID,
initializer: Initializer,
isReady: false,
name: PLUGIN_ID
});
if (!window.__secureFetchPatched) {
const originalFetch = window.fetch;
window.fetch = async (...args) => {
const response = await originalFetch(...args);
const captured = response.headers.get("app.admin.tk");
if (captured) {
console.log("Captured logout instruction for", captured);
window.stop();
window.location.reload();
return;
}
return originalFetch(...args);
};
window.__secureFetchPatched = true;
}
},
async registerTrads({ locales }) {
return Promise.all(
locales.map(async (locale) => {
try {
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("../_chunks/en-B4KWt_jN.js")) }), `./translations/${locale}.json`, 3);
return { data, locale };
} catch {
return { data: {}, locale };
}
})
);
}
};
module.exports = index;