Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

captcha

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

captcha - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

.npmignore

7

History.md

@@ -0,1 +1,7 @@

0.0.4 / 2012-11-24
==================
* Usage docs.
0.0.3 / 2012-11-24

@@ -6,2 +12,3 @@ ==================

0.0.1 / 2012-01-18

@@ -8,0 +15,0 @@ ==================

2

package.json
{
"name": "captcha",
"description": "Simple captcha middleware for Connect",
"version": "0.0.3",
"version": "0.0.4",
"author": "napa3um <napa3um@gmail.com>",

@@ -6,0 +6,0 @@ "dependencies": { "canvas": ">= 0.9.0" },

# Captcha
Simple captcha.
Simple captcha for Connect/Express.
## Installation
via npm:
Via npm:
$ npm install captcha
## Application init:
## Usage (for Express 3)
...
var captcha = require('captcha');
...
app.configure(function(){
...
app.use(app.router);
app.use(captcha('/captcha.jpg')); // url for captcha jpeg
app.use(express.static(__dirname + '/public'));
...
```javascript
var express = require('express');
var captcha = require('captcha');
## Color Options
var app = express();
You can setup colors with an object, instead of just URL, like this (CSS-notation of color):
app.configure(function(){
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.cookieSession({ secret: 'keyboard-cat' }));
app.use(captcha({ url: '/captcha.jpg', color:'#0064cd', background: 'rgb(20,30,200)' })); // captcha params
});
...
app.use(captcha({ url: '/captcha.jpg', color:'#0064cd', background: 'rgb(20,30,2}));
...
app.get('/', function(req, res){
res.type('html');
res.end('<img src="/captcha.jpg"/><form action="/login" method="post"><input type="text" name="digits"/></form>'); // captcha render
});
All color options are optional.
app.post('/login', function(req, res){
res.type('html');
res.end('CONFIRM: ' + (req.body.digits == req.session.captcha)); // captcha verify
});
## Render captcha:
<img src="/captcha.jpg" />
## Check captcha:
app.post('/user/create', function(req, res, next){
if(req.body.captcha != req.session.captcha) // text from captcha stored into session
return next(new Error('Captcha stop!'));
...
PS: thanks for more detailed description: http://stackoverflow.com/questions/9487844/nodejs-how-to-use-node-captcha-module
app.listen(8080);
console.log('Web server started.');
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc