
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
voting-lib
Advanced tools
A library to manage voting systems, having its own voting rules and options while giving its consumer the choice on how to store the data and manage user security. No dependencies.
$ npm i voting-lib
Some steps are required to setup the library:
minVotingDuration: minimum duration of a voting in milisecondsmaxVotingDuration: maximum duration of a voting in milisecondsminCandidatesElection: minimum number of candidates for an electioncanVoterVoteForHimself: whether a voter can vote for himself (default: false)canCandidateStartVoting: whether a candidate can start a voting (default: false)These options can be configured by changing the OPTIONS object. Default values are provided.
Example:
import { OPTIONS } from 'voting-lib'
OPTIONS.minVotingDuration = 1000 * 60 * 60 * 24 // 1 day
OPTIONS.maxVotingDuration = 1000 * 60 * 60 * 24 * 7 // 1 week
OPTIONS.minCandidatesElection = 2
...
You should configure all the callbacks necessary to handle the data (wherever and however it is stored). This can be done using the method setCallbacks passing all or some of the callbacks.
persistVoting to persist a votingpersistVoters to persist voterspersistVote to persist a voteretrieveVoting to retrieve a votingretrieveVoter to retrieve a voterretrieveVotes to retrieve votes or votes stats (returning whole votes is discouraged for large data sets, use filters and counts to return stats instead)checkActiveVoters to check if a set of voters are activecountActiveVoters to count the number of active votershasVoted to check if a voter has already submited a vote for a given votingExample:
import { setCallbacks } from 'voting-lib'
setCallbacks({
persistVote: () => {...},
persistVoters: () => {...},
persistVoting: () => {...},
retrieveVoting: () => {...},
retrieveVoter: () => {...},
retrieveVotes: () => {...},
...
})
This method can be called any number of times to change all or some of the callbacks, but it is important that all the callbacks are set before calling any of the functions that manipulate the data.
Some helper functions are provided to help fine tune commonly used data generation and manipulation.
getCurrentDate used to retrieve the current dategenerateRandomUUID used to generate a random UUID (defaults to crypto.randomUUID)Example:
import { setHelpers } from 'voting-lib'
setHelpers({
getCurrentDate: () => {...},
generateRandomUUID: () => {...},
})
This method can be called any number of times to change all or some of the helpers.
See the examples folder for some examples of usage.
FAQs
A library to manage voting systems
The npm package voting-lib receives a total of 5 weekly downloads. As such, voting-lib popularity was classified as not popular.
We found that voting-lib demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.