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

recaptcha-v2

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

recaptcha-v2

Obtain a v2 reCAPTCHA form and verify it

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
660
increased by26.44%
Maintainers
1
Weekly downloads
 
Created
Source

node-recaptcha

node-recaptcha renders and verifies Recaptcha captchas.

NOTE: This release uses the latest v2 reCAPTCHA (http://www.google.com/recaptcha)

Installation

Via git:

$ git clone git://github.com/mrpetef10/node-recaptcha-v2.git ~/.node_libraries/node-recaptcha-v2

Via npm:

$ npm install recaptcha-v2

Setup

Before you can use this module, you must visit (http://www.google.com/recaptcha) to request a public and private API key for your domain.

Example Using Express

app.js:

var express  = require('express'),
    Recaptcha = require('recaptcha').Recaptcha;

var PUBLIC_KEY  = 'YOUR_PUBLIC_KEY',
    PRIVATE_KEY = 'YOUR_PRIVATE_KEY';

var app = express.createServer();

app.configure(function() {
    app.use(express.bodyParser());
});

app.get('/', function(req, res) {
    var recaptcha = new Recaptcha(PUBLIC_KEY, PRIVATE_KEY);

    res.render('form.jade', {
        layout: false,
        locals: {
            recaptcha_form: recaptcha.toHTML()
        }
    });
});

app.post('/', function(req, res) {
    var data = {
		remoteip:  req.connection.remoteAddress,
		response:  req.param("g-recaptcha-response"),
		secret: PRIVATE_KEY
    };
    var recaptcha = new Recaptcha(PUBLIC_KEY, PRIVATE_KEY, data);

    recaptcha.verify(function(success, error_code) {
        if (success) {
            res.send('Recaptcha response valid.');
        }
        else {
            // Redisplay the form.
            res.render('form.jade', {
                layout: false,
                locals: {
                    recaptcha_form: recaptcha.toHTML()
                }
            });
        }
    });
});

app.listen(3000);

views/form.jade:

form(method='POST', action='.')
  != recaptcha_form

  input(type='submit', value='Check Recaptcha')

Make sure express and jade are installed, then:

$ node app.js

Keywords

FAQs

Package last updated on 26 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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