
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.
> 🔐 A lightweight and flexible JavaScript library to generate random OTPs (One-Time Passwords) for use in both frontend and backend applications.
🔐 A lightweight and flexible JavaScript library to generate random OTPs (One-Time Passwords) for use in both frontend and backend applications.
otp_number_only(length)npm install otp-number
const { otp_number, otp_number_only } = require('otp-number');
// Generate a 6-digit OTP with digits, uppercase, and lowercase letters (default) const defaultOTP = otp_number(); console.log(defaultOTP); // Example: "aB3dE9"
// Generate an 8-digit numeric-only OTP using the helper function const numericOTP = otp_number_only(8); console.log(numericOTP); // Example: "12345678"
// Generate a 10-character OTP with only uppercase letters and digits const customOTP = otp_number(10, { digits: true, upperCase: true, lowerCase: false }); console.log(customOTP); // Example: "A1B2C3D4E5"
// Generate a 4-character OTP with only lowercase letters const lowercaseOTP = otp_number(4, { digits: false, upperCase: false, lowerCase: true }); console.log(lowercaseOTP); // Example: "wxyz"
// Attempting to generate an OTP with no character sets enabled will throw an error: try { otp_number(6, { digits: false, upperCase: false, lowerCase: false }); } catch (error) { console.error(error.message); // Output: "At least one character set must be enabled." }
const { otp_number_only } = require('otp-number');
console.log(otp_number_only(6)); // ➤ "920384"
## Browser (UMD)
<script src="dist/otp-generator.umd.js"></script>
<script>
const otp = OtpGenerator.otp_number(6, { digits: true, upperCase: true });
console.log("OTP:", otp);
</script>
## ⚙️ API
otp_number(length, options)
Parameter Type Default Description
length number 6 Length of the OTP
options.digits boolean true Include digits (0-9)
options.upperCase boolean false Include uppercase letters (A-Z)
options.lowerCase boolean false Include lowercase letters (a-z)
## 📌 Example Outputs
otp_number();
// ➤ "729314"
otp_number(6, { digits: true, upperCase: true });
// ➤ "5J8K2Q"
otp_number(4, { lowerCase: true });
// ➤ "kfza"
otp_number_only(length = 6)
A helper function that generates a numeric-only OTP string of the specified length. This is equivalent to calling otp_number(length, { digits: true }).
## 📁 Build (for Browser Support)
Install dev dependencies:
bash
Copy
Edit
npm install --save-dev rollup @rollup/plugin-commonjs @rollup/plugin-node-resolve
Build UMD:
bash
Copy
Edit
npx rollup -c
## 🔎 Keywords
otp, otp-number, random otp, otp generator, javascript otp, nodejs otp, one-time password, verification code, auth code, frontend backend otp, browser otp, 2FA
FAQs
> 🔐 A lightweight and flexible JavaScript library to generate random OTPs (One-Time Passwords) for use in both frontend and backend applications.
We found that otp-number 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.