Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
A Webpack Federation Module containing the modules and modals in React.
A Webpack Federation Module containing the modules and modals in React.
There is a component called BaseModal
that has the basic structure for the Portal, making use of the basic structure of components from @cloudbeds/ui-library
import React from 'mfdCommon/react';
import { CbModal, CbModalOverlay, CbModalContent } from 'mfdCommon/@cloudbeds/ui-library';
export const BaseModal = ({ history, children, isCentered, ...props }) => {
const navigateBack = () => history.back();
return (
<CbModal onClose={navigateBack} zIndex={10} isCentered={isCentered} isOpen closeOnEsc>
<CbModalContent zIndex={10} {...props}>
{children}
</CbModalContent>
<CbModalOverlay bg="rgba(0,0,0,.7)" backdropFilter="blur(5px)" zIndex={10} onClick={navigateBack} />
</CbModal>
);
};
Thus, any modal made must use the structure offered by BaseModal
, applying the content as a child. Note that history
always needs to be sent via prop to BaseModal
. Only way for the onClickOutside feature to work properly.
import React from 'mfdCommon/react';
import { CbModalHeader, CbModalBody } from 'mfdCommon/@cloudbeds/ui-library';
import { BaseModal } from './BaseModal';
export const BasicModal = ({ history, ...props }) => (
<BaseModal history={history} isCentered>
<CbModalHeader>BasicModal Header</CbModalHeader>
<CbModalBody {...props}>BasicModal Body</CbModalBody>
</BaseModal>
);
Once created, you need to insert the modal into the array that will be imported by mfdCommon and injected into myfrontdesk-front
import React from 'mfdCommon/react';
import { BasicModal } from './BasicModal';
export const data = [
{
path: '/basic-modal',
element: <BasicModal />,
},
];
Note that it is only necessary to insert the route, which must contain the "/" and the component that will be loaded in that route.
Inside mfdCommon it is not necessary to do anything, but it is important to know some features:
Within the properties available in the loaded Microfrontend, there are methods related to the modal, whether to open or close, or to define the props that will be available.
In the case of navigation, it is not necessary to open or close the modal by the methods, being possible to use the native navigation feature of the application, respecting only the url
const props: MicroFrontendProps = {
...microFrontend?.props,
services: {
monitoringManager: MonitoringManager,
},
modal: {
open: path => navigate(path),
close: () => navigate(-1),
setProps: props => setModalProps(props),
},
};
In the sequence it is possible to see how the modal array is loaded and how the routes are being injected into the application
...
useEffect(() => {
...
loadRemoteModule(REMOTE_MODALS).then(response => setModals(response.data));
}, [])
...
<Routes>
{modals?.map(modal => {
const pathUrl = `${pathname.replace(modal.path, '')}${modal.path}`;
return (
<Route
key={`${modal.path}-route`}
path={pathUrl}
element={
<>
{React.isValidElement(modal.element)
? React.cloneElement(modal.element, {...modalProps, history})
: modal.element}
</>
}
/>
);
})}
</Routes>
In the sequence it is possible to see two ways of navigating to the modal, a first using the method offered via props and a second using the Microfrontend routing service itself.
openModal(path: string) {
this.$store.props.modal.open(path)
}
or
navigateTo(path) {
const baseUrl = String(window.location.hash).replace('#', '');
this.$router.push({ path: `${baseUrl}${path}` });
}
FAQs
A Webpack Federation Module containing the modules and modals in React.
The npm package mfd-shell receives a total of 0 weekly downloads. As such, mfd-shell popularity was classified as not popular.
We found that mfd-shell demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.