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

visualcaptcha

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

visualcaptcha

Node.js module for visualCaptcha. Still requires you to have the front-end companion.

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
increased by22.21%
Maintainers
2
Weekly downloads
 
Created
Source

Build Status Coverage Status Codacy Code Climate

visualCaptcha-npm

Node.js NPM package for visualCaptcha's backend service

Installation with NPM

You need Node.js installed with npm.

npm install visualcaptcha

Run tests

Run next command to start mocha unit tests:

npm test

Usage

Initialization

On initialization visualCaptcha function requires req.session session object as first argument:

visualCaptcha = require( 'visualcaptcha' )( req.session, defaultImages, defaultAudios );

Where:

  • defaultImages is optional parameter. Defaults to the array inside ./images.json. The path is relative to ./images/
  • defaultAudios is optional parameter. Defaults to the array inside ./audios.json. The path is relative to ./audios/

visualCaptcha properties

  • session, JSON object — Object that will have a reference for the session object. It will have .visualCaptcha.images, .visualCaptcha.audios, .visualCaptcha.validImageOption, and .visualCaptcha.validAudioOption.

  • imageOptions, array — All the image options. These can be easily overwritten or extended using addImageOptions( ), or replaceImageOptions( ). By default, they're populated using the ./images.json file.

  • audioOptions, array — All the audio options. These can be easily overwritten or extended using addImageOptions( ), or replaceImageOptions( ). By default, they're populated using the ./audios.json file.

visualCaptcha methods

  • generate: function( numberOfOptions ) — Generate a new valid visualCaptcha front-end data. numberOfOptions — is optional parameter for number of generated images, defaults to 5.
  • getFrontendData: function() — Get data to be used by the frontend.
  • getValidImageOption: function() — Get the current validImageOption.
  • getValidAudioOption: function() — Get the current validAudioOption.
  • validateImage: function( sentOption ) — Validate the sent image value with the validImageOption.
  • validateAudio: function( sentOption ) — Validate the sent audio value with the validAudioOption.
  • getImageOptions: function() — Return generated image options.
  • getImageOptionAtIndex: function(index) — Return generated image option at index.
  • getAudioOption: function() — Alias for getValidAudioOption.
  • getAllImageOptions: function() — Return all the image options.
  • getAllAudioOptions: function() — Return all the audio options.
  • streamAudio: function( response, fileType ) — Stream audio file. Parameters:
    • response is a response object;
    • fileType is audio filetype, defaults to 'mp3', can also be 'ogg'.
  • streamImage: function( index, response, isRetina ) — Stream image file given an index in the session visualCaptcha images array. Parameters:
    • index is index of the image in the session images array to send;
    • response is a response object;
    • isRetina, boolean, defaults to false.

response object

The response object used in .streamAudio(), and .streamImage() was thought of for Express' response object, so it needs:

  • .set()
  • .write()
  • .status()
  • .send()
  • .end()
  • .headerSent (boolean)

License

View the LICENSE file.

Keywords

FAQs

Package last updated on 02 Mar 2018

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