npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

visualcaptcha-namespace

v0.0.8

Published

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

Downloads

9

Readme

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.
  • 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.
  • getAudio: function( response, fileType ) — Loads a file in the session visualCaptcha audio. Parameters:
    • response is Node's response object,
    • fileType is audio filetype, defaults to 'mp3', can also be 'ogg'.
  • streamAudio: function( response, fileType ) — Stream audio file. Parameters:
    • response is Node's response object;
    • fileType is audio filetype, defaults to 'mp3', can also be 'ogg'.
  • getImage: function( index, response, isRetina ) — Loads a 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 Node's response object;
    • isRetina, boolean, defaults to false.
  • 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 Node's response object;
    • isRetina, boolean, defaults to false.