# @mr_fozan/captcha

> A Node.js module to create and manage captcha sessions.

Latest version **1.0.2** (published 2024-07-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install @mr_fozan/captcha
pnpm add @mr_fozan/captcha
yarn add @mr_fozan/captcha
bun add @mr_fozan/captcha
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; large bundle.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2024-07-26 |
| First published | 2023-08-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 23.1 MB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | mr_fozan |
| Maintainers | mr_fozan |
| Keywords | captcha, nodejs, authentication |

## Links

- npm: https://www.npmjs.com/package/@mr_fozan/captcha
- Repository: https://github.com/Fozan-Developer/captcha
- Issues: https://github.com/Fozan-Developer/captcha/issues
- npm.io page: https://npm.io/package/@mr_fozan/captcha

## Dependencies (4)

- [fs](https://npm.io/package/fs.md) ^0.0.1-security
- [path](https://npm.io/package/path.md) ^0.12.7
- [canvas](https://npm.io/package/canvas.md) ^2.11.2
- [crypto](https://npm.io/package/crypto.md) ^1.0.1

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2024-07-26
- 1.0.1 — 2023-08-06
- 1.0.0 — 2023-08-06

## README

# 🛂 Captcha

[![npm package](https://img.shields.io/npm/v/@mr_fozan/captcha?logo=npm&style=flat-square)](https://www.npmjs.org/package/@mr_fozan/captcha)

**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](https://github.com/Fozan-Developer/captcha/blob/main/assets/codeSnap.png)

```js
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:**

```sh
npm install @mr_fozan/captcha
```

**Using Yarn:**

```sh
yarn add @mr_fozan/captcha
```

## 📖 Documentation

### Creating a Captcha

```js
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

```js
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](https://contrib.rocks/image?repo=Fozan-Developer/captcha)](https://github.com/Fozan-Developer/captcha/graphs/contributors)

## License

This project is licensed under the [MIT License](https://opensource.org/licenses/MIT).

---
_Source: https://npm.io/package/@mr_fozan/captcha · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
