Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
use-bn-idle
Advanced tools
npm install use-bn-idle
Import the useBnIdle
hook in your component. It returns two functions, startTimer
and stopTimer
.
The startTimer
function is used to start the user idle detection based on seconds that we pass as an argument
The stopTimer
function is used to stop the user idle detection (manually).
The expired
callback function as a parameter for the useBnIdle
hook gets triggered if the user is inactive for a certain period of time that we specified in startTimer
function.
import {useBnIdle} from 'use-bn-idle';
const App = () => {
const [startTimer, stopTimer] = useBnIdle(() => {
//Will execute if the user is idle for a certain period of time.
//You can write logic like showing popup or log out the user.
console.log('Expired: Session Timeout');
})
useEffect(() => {
// start the user idle detection
startTimer(60); //passed 60 seconds as argument.
})
return <div>
<button onClick={stopTimer}>Stop Detection</button>
</div>
}
Return Values | Type | Description |
---|---|---|
startTimer(timeoutInSeconds) | Function | Used to start the user idle detection. It accepts seconds as a parameter. |
stopTimer() | Function | Used to stop the user idle detection. |
Parameters | Type | Description |
---|---|---|
expired | function | A callback function that executes if the user is idle for a specified time that we mentioned in startTimer . |
If the user is idle for a certain period of time based on the parameter timeoutInSeconds
of startTimer
function, then the expired
function gets invoked and then the user idle detection will stop automatically.
In order to restart the user idle detection, you should invoke the startTimer(timoutInSeconds)
function again.
FAQs
React User Idle Hook to find user idle/session timeout
The npm package use-bn-idle receives a total of 113 weekly downloads. As such, use-bn-idle popularity was classified as not popular.
We found that use-bn-idle 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.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.