1.0.2 • Published 12 months ago

@mr_fozan/captcha v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

🛂 Captcha

npm package

Captcha is a Node.js module that allows you to create and manage captcha sessions efficiently.

🚀 Quick Start

Here's a quick example of how to get started with the Captcha library:

CodeSnap

const Captcha = require('@mr_fozan/captcha');

// Create a new captcha instance with the desired number of variations
const captcha = new Captcha({ variations: 3 });

// Generate a new captcha
captcha.generate().then(result => {
  console.log('Generated Captcha:', result);

  // Example of verifying user input
  const isValid = captcha.verify(result.id, result.answer);
  console.log('Captcha verification result:', isValid);
}).catch(err => {
  console.error('Error generating captcha:', err);
});

📦 Installation

Using NPM:

npm install @mr_fozan/captcha

Using Yarn:

yarn add @mr_fozan/captcha

📖 Documentation

Creating a Captcha

const Captcha = require('@mr_fozan/captcha');

// Create a new captcha instance with the desired number of variations
const captcha = new Captcha({ variations: 3 });

// Generate a new captcha
const result = await captcha.generate();
console.log(result);

Response Structure:

  • id: Unique identifier for the captcha
  • answer: The correct answer for the captcha
  • variations: Array of answer options, including the correct one

Verifying Captcha Input

const Captcha = require('@mr_fozan/captcha');

// Create a new captcha instance
const captcha = new Captcha({ variations: 3 });

// The captcha ID and user input to verify
const captchaId = '001'; // Use the actual ID from the generated captcha
const userInput = '🍫';  // User's input for verification

// Verify the user's input
const result = captcha.verify(captchaId, userInput);
console.log(result);

Verification Parameters:

  • id: Unique identifier for the captcha
  • userInput: The response provided by the user

Verification Response:

  • response: Boolean indicating whether the captcha is correct (true or false)

👥 Contributors

Contributors

License

This project is licensed under the MIT License.

1.0.2

12 months ago

1.0.1

2 years ago

1.0.0

2 years ago