
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
Tab-elect solves the problem of only wanting one browser tab to run a job, and ensure that there is always one browser tab running it even if the previous running tab was closed. This package takes care of the inter-tab communication required to elect one tab as the leader and ensure that there is always a leader even if the previous leader quits. A browser tab gets notified when it has been elected as the new leader, and this allows the tab to run whatever code the leader should run. When another tab takes the leadership position, the previous leader gets notified that it has been deposed.
Tab-elect uses the atomic operations of IndexedDB to ensure that only one leader gets elected even if many candidates attempt to elect themselves simultaneously. BroadcastChannels are used to broadcast when a new leader has taken over; because of this there is a short amount of time during the transition from one leader to another that both instances think they are the leader.
var te = TabElect('campain name')
console.log('Am I the leader?', te.isLeader)
te.on('elected', function () {
console.log('I am the leader!')
})
te.on('deposed', function () {
console.log('I am no longer the leader')
})
te.on('error', function (err) {
console.log('Error', err)
})
var te = new TabElect(name)Constructs a new TabElect instance with the given name. name is used to group instances together so instances with different names will have different elections.
A boolean that indicates if this instance is the leader.
te.elect([cb])Attempt to elect this instance as the leader. cb is called with cb(err, elected) where err is null if there were no errors and elected is true if the instance is now the leader. This method throws an exception if it is called while the instance is the leader.
te.stepDown()Forces the instance to relinquish it's leadership status. All other tab-elect instances will attempt to become the next leader. If the instance is not the leader then this method throws an exception.
te.destroy()Destroys the instance and frees all internal resources. If this instance was the leader than a new leader will be elected. No more events will be emitted.
te.on('elected', function () {})The instance is the new leader
te.on('deposed', function () {})The instance is no longer the leader
te.on('error', function () {})A critical error occurred. This instance attempts to relinquish it's leader status and destroys itself.
MIT. Copyright (c) Austin Middleton.
FAQs
Leader election for browser tabs and workers
The npm package tab-elect receives a total of 223 weekly downloads. As such, tab-elect popularity was classified as not popular.
We found that tab-elect 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
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.