# lambda-captcha

> Generates captchas that can be verified decentrally.

Latest version **2.1.2** (published 2021-05-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install lambda-captcha
pnpm add lambda-captcha
yarn add lambda-captcha
bun add lambda-captcha
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.2 |
| Published | 2021-05-16 |
| First published | 2019-10-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 1.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | fourcube |

## Links

- npm: https://www.npmjs.com/package/lambda-captcha
- npm.io page: https://npm.io/package/lambda-captcha

## Dependencies (1)

- [opentype.js](https://npm.io/package/opentype.js.md) ^1.1.0

## Recent versions

- 2.1.2 (latest) — 2021-05-16
- 2.1.1 — 2020-08-25
- 2.0.0 — 2019-10-16
- 1.1.0 — 2019-10-15
- 1.0.0 — 2019-10-01

## README

# lambda-captcha

Generates captchas that can be verified decentrally.

## Description

This is heavily inspired by [svg-captcha](https://github.com/lemonce/svg-captcha/), but written in TypeScript. It also allows you to pass the generated captcha expressions together with the user-supplied captcha solution,
so you can verify the results independently. The captcha expressions are encrypted, so they are not
machine readable.

## Usage

### Generating a captcha

```js
const lambdaCaptcha = require('lambda-captcha')
const SECRET = process.env.CAPTCHA_SECRET

function generateCaptcha() {
  const captchaConfig = lambdaCaptcha.LambdaCaptchaConfigManager.default(SECRET)
  const captcha = lambdaCaptcha.create(captchaConfig)

  return {
    // The captcha SVG that you can display inside e.g. a form
    captchaSvg: captcha.captchaSvg,
    
    // This is the un-encrypted expression of the captcha.
    captchaExpression: captcha.expr,
    
    // This is the encrypted expression of the captcha.
    // Pass it along with your server side verification requests.
    encryptedCaptchaExpression: captcha.encryptedExpr
  }
}
```

### Verifying a captcha

```js
const lambdaCaptcha = require('lambda-captcha')
const SECRET = process.env.CAPTCHA_SECRET

function verify(encryptedCaptchaExpression, captchaSolution) {
  const captchaResult = lambdaCaptcha.verify(captchaExpression, captchaSolution, SECRET)
  return captchaResult // either true on success or false if the solution was wrong
}
```

## Testing

`npm run test`

or 

`npm run tdd`

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