1.0.1 • Published 5 months ago

google-auth-integration v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

Google Auth Integration

A simple and lightweight package for generating and verifying Google Authenticator tokens with minimal setup.

Installation

npm install google-auth-integration

Usage

const auth = require('google-auth-integration');

// Setup with your secret key
auth.setup({
    secret: 'YOUR_SECRET_KEY'
});

// Generate a token
const token = auth.generateToken();
console.log('Generated token:', token);

// Verify a token
const isValid = auth.verify(token);
console.log('Is token valid?', isValid);

API Reference

setup(config)

Initializes the authenticator with the required configuration.

  • config.secret (string, required): Your secret key for token generation

generateToken()

Generates a new token using the configured secret.

  • Returns: string (6-digit token)

verify(token)

Verifies if a given token is valid.

  • token (string): The token to verify
  • Returns: boolean (true if valid, false otherwise)

Security Notes

  • Keep your secret key secure and never expose it in client-side code
  • Tokens are time-based and typically valid for 30 seconds
  • Use HTTPS when transmitting tokens

License

ISC