
Security News
GitHub Actions Checkout Now Blocks Risky pull_request_target Checkouts
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.
totp-library
Advanced tools
This library provides functions for generating and validating Time-Based One-Time Passwords (TOTP) for implementing two-factor authentication in Node.js applications. It uses QR codes for easy setup and follows the TOTP standard.
npm install totp-library
import { generateSecretKey, createQrCode, validateCode } from "totp-library";
const userEmail = "user@example.com";
const secretKey = generateSecretKey();
const companyName = "Your_Company_Name";
createQrCode(userEmail, secretKey, companyName)
.then((qrCode) => {
if (qrCode) {
console.log("QR Code generated successfully.");
console.log(qrCode);
} else {
console.log("Error generating QR Code.");
}
})
.catch((error) => console.error("QR Code generation error:", error));
const isCodeValid = validateCode("Enter_User_Code", secretKey);
if (isCodeValid) {
console.log("Verification successful. Access granted!");
} else {
console.log("Verification failed. Access denied!");
}
generateSecretKey(): string
createQrCode(email: string, secretKey: string, companyName: string): Promise<string>
validateCode(userProvidedCode: string, secretKey: string): boolean
For a complete example, see the provided code at the end of this README.
// User details
const userEmail = "user@example.com";
// Generate a new secret key
const secretKey = generateSecretKey();
// Create and display QR code
createQrCode(userEmail, secretKey, "Your Company Name")
.then((qrCode) => {
if (qrCode) {
console.log("QR Code generated successfully.");
console.log(qrCode);
} else {
console.log("Error generating QR Code.");
}
})
.catch((error) => console.error("QR Code generation error:", error));
// Validate user-provided code
const isCodeValid = validateCode("Enter_User_Code", secretKey);
if (isCodeValid) {
console.log("Verification successful. Access granted!");
} else {
console.log("Verification failed. Access denied!");
}
FAQs
authenticator integration
We found that totp-library 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
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.