
Research
PyPI Package Disguised as Instagram Growth Tool Harvests User Credentials
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
detect-browser-back-navigation
Advanced tools
Detects when user clicks on the back button.
The main use case is to creating modals, so you can close a modal when the user clicks on the phone back button, like in native mobile apps.
npm install detect-browser-back-navigation --save
yarn add detect-browser-back-navigation
Just call the default exported function with a callback on the first argument and the callback will fired whe the user clicks on the back button.
import detectBackButton from 'detect-browser-back-navigation';
const unsub = detectBackButton(() => {
console.log('BACK BUTTON PRESSED!');
});
Note: You must properly unsubscribe when the modal is closed, to remove event listeners and avoid fire the callback multiple times leading in bugs.
See below an example of how to create a modal in React:
import detectBackButton from 'detect-browser-back-navigation';
export default function Modal(props) {
const [show, setShow] = useState(false);
useEffect(() => {
if (show) {
const unsub = detectBackButton(() => close());
return unsub;
}
}, [show]);
function open() {
setShow(true);
}
function close() {
setShow(false);
}
if (!show) return null;
return (...);
}
Tip: This package also handles stacked back button calls, so you can display multiple modals and the package will callback correctly.
MIT
FAQs
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
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.