2.0.0 • Published 6 years ago

recaptcha-jwt v2.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

Recaptcha-jwt is a lib that validates recaptcha and returns a JWT token if the validation succeeded.

Installation

$ npm install recaptcha-jwt

Create Recaptcha-jwt object

var RecaptchaJwt = require('recaptcha-jwt');

var r = new RecaptchaJwt({ recaptcha: { secret: '123' }, jwt: { secret: '123' } });

Supported setup options

  • recaptcha.secret: Recaptcha secret, required
  • recaptcha.ssl: Sll true or false
  • recaptcha.mock: Enable mock mode, always validate the token.
  • jwt.secret: Jwt secret, required
  • jwt.expiresIn: Expiration. Default 600 seconds.
  • jwt.mock: Enable mock mode, always validate the token.

Validate recaptcha and get jwt token

var RecaptchaJwt = require('recaptcha-jwt');

var r = new RecaptchaJwt({ recaptcha: { secret: '123' }, jwt: { secret: '123' } });

r.validateCaptcha('some_captcha')
                .then(jwt => {
                    console.log(jwt);
                });

Validate JWT token

var RecaptchaJwt = require('recaptcha-jwt');

var r = new RecaptchaJwt({ recaptcha: { secret: '123' }, jwt: { secret: '123' } });

r.validateJwt('some_jwt')
                .then(content => {
                    console.log(content);
                });

Validate JWT token and content

var RecaptchaJwt = require('recaptcha-jwt');

var r = new RecaptchaJwt({ recaptcha: { secret: '123' }, jwt: { secret: '123' } });

r.validateJwtAndContent('some_jwt', 'some_content')
                .then(content => {
                    console.log(content);
                });

Create JWT

var RecaptchaJwt = require('recaptcha-jwt');

var r = new RecaptchaJwt({ recaptcha: { secret: '123' }, jwt: { secret: '123' } });

r.getJwt('some_content')
                .then(jwt => {
                    console.log(jwt);
                });
2.0.0

6 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago