@solargis/lambda-captcha
Advanced tools
Comparing version 3.0.0 to 3.0.1
{ | ||
"name": "@solargis/lambda-captcha", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -39,2 +39,31 @@ # lambda-captcha | ||
### Generating a captcha in code mode | ||
```js | ||
const lambdaCaptcha = require('@solargis/lambda-captcha') | ||
const SECRET = process.env.CAPTCHA_SECRET | ||
function generateCaptcha() { | ||
const captchaConfig = lambdaCaptcha.LambdaCaptchaConfigManager.default(SECRET) | ||
const captcha = lambdaCaptcha.create({ | ||
...captchaConfig, | ||
mode: 'code', // default mode is 'math' | ||
codeLength: 5, // optional, default codeLength is 5 | ||
}) | ||
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 | ||
@@ -41,0 +70,0 @@ |
1412090
87