strapi-plugin-firebase-authentication
Version:
Allows easy integration between clients utilizing Firebase for authentication and Strapi
110 lines (109 loc) • 3.52 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 = "firebase-authentication";
const Initializer = ({ setPlugin }) => {
const ref = react.useRef(setPlugin);
react.useEffect(() => {
ref.current(PLUGIN_ID);
}, []);
return null;
};
const PluginIcon = () => /* @__PURE__ */ jsxRuntime.jsx(icons.Plant, {});
const prefixPluginTranslations = (trad, pluginId) => {
return Object.keys(trad).reduce((acc, current) => {
acc[`${pluginId}.${current}`] = trad[current];
return acc;
}, {});
};
const PERMISSIONS = {
// This permission regards the main component (App) and is used to tell
// If the plugin link should be displayed in the menu
// And also if the plugin is accessible. This use case is found when a user types the url of the
// plugin directly in the browser
"menu-link": [{ action: "plugin::firebase-authentication.menu-link", subject: null }]
};
const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
const index = {
register(app) {
app.addMenuLink({
to: `plugins/${PLUGIN_ID}`,
icon: PluginIcon,
intlLabel: {
id: `${PLUGIN_ID}.page.title`,
defaultMessage: PLUGIN_ID
},
Component: () => Promise.resolve().then(() => require("./App-B2LtHk9g.js")).then((mod) => ({
default: mod.App
})),
permissions: PERMISSIONS["menu-link"]
});
app.createSettingSection(
{
id: PLUGIN_ID,
intlLabel: {
id: getTranslation("SettingsNav.section-label"),
defaultMessage: "Firebase-Authentication Plugin"
}
},
[
{
intlLabel: {
id: getTranslation("Settings.firebase-authentication.plugin.title"),
defaultMessage: "Settings"
},
id: "settings",
to: `/settings/${PLUGIN_ID}`,
async Component() {
const component = await Promise.resolve().then(() => require("./index-DmTKNKJB.js"));
return component.default;
},
permissions: PERMISSIONS["menu-link"]
}
]
);
app.registerPlugin({
id: PLUGIN_ID,
initializer: Initializer,
isReady: false,
name: PLUGIN_ID
});
},
async registerTrads({ locales }) {
const importedTrads = await Promise.all(
locales.map((locale) => {
return __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("./en-TW4k9AeZ.js")) }), `./translations/${locale}.json`, 3).then(({ default: data }) => {
return {
data: prefixPluginTranslations(data, PLUGIN_ID),
locale
};
}).catch(() => {
return {
data: {},
locale
};
});
})
);
return Promise.resolve(importedTrads);
}
};
exports.PLUGIN_ID = PLUGIN_ID;
exports.index = index;