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

captcha-server

v2.0.4

Published

It provides easy access to Completely Automated Public Turing test to tell Computers and Humans Apart (CAPTCHA)

Downloads

14

Readme

captcha-server2.0

Ready to use CAPTCHAs for your website.

captcha image

Features

  • Customizable phrase length and possible characters
  • Captcha will be generated on your server. Therefore, no tracking by third parties.
  • No need to write extra APIs
  • User can specify various event-handlers.

Getting Started

1. Server Side ( Back-end )

  1. install captcha-server.
    npm install captcha-server --save
    if you want to use v1.0.0 then run
    npm install [email protected] --save
  2. create new captcha.
    var captchaServer = require('captcha-server');
    var captcha = new captchaServer(5, 'ABCDEFGHIJK012345');
    captcha constructor takes two optional parameters:
    • number of characters in captcha
    • possible characters in phrase
  3. add captcha router to your express app.
    app.use('/', captcha.router());
    It adds two APIs ( for serving and tesing the captcha ) to your app.
    If you are not using Express framework, use captcha-server1.0.0
    But you have to wrrite your own APIs with v1.0.0
  4. get information from captcha.
    you can get information about captcha using following functions:
    • captcha.passed() returns true or false based on whether user has passed the captcha or not.
    • captcha.failCount() returns the number of times user has submitted wrong answer.
    • captcha.reloadCount() returns the number of times captcha has been reloaded. Note that captcha reloads automatically if user submits wrong answer.
  5. provide optional event listeners.
    captcha-server2.0.0 provides following events:
    captcha.on('reload', function(){
     // do something everytime captcha reloads
     console.log('reloaded');
     console.log(captcha.passed(), captcha.failCount(), captcha.reloadCount());
     });
    
     captcha.on('test', function(isPassed){
       // do something everytime user submits an answer
       // isPassed contains true or false based on right or wrong answer.
       console.log('tested ' + isPassed);
       console.log(captcha.passed(), captcha.failCount(), captcha.reloadCount());
     });
    
     captcha.on('pass', function(){
       // do something when user submits right answer
       console.log('passed');
       console.log(captcha.passed(), captcha.failCount(), captcha.reloadCount());
     });
    
     captcha.on('fail', function(){
       // do something everytime user submits wrong answer
       console.log('failed');
       console.log(captcha.passed(), captcha.failCount(), captcha.reloadCount());
     });
    Back-end of your app is ready to serve CAPTCHAs

2. Client Side ( Front-end )

captcha-client is used.

Installation

Add following tag to your html <script src="https://cdn.jsdelivr.net/gh/rupindr/captcha-client/captcha-client-1.0.0.min.js" ></script>

Usage

  1. Create a div where you want to place the captcha.
    <div id="captcha-container" ></div>
  2. Create a new captcha object.
    It takes two parameters:
    • DOM element that is container for captcha
    • API address where captcha-server is running.
    when object is created, div #captcha-container will be popoulated with a captcha.
   var captcha = new CaptchaClient(document.getElementById('captcha-container'), 'https://localhost:3001');
  1. Adding event listeners.
    captcha-client provides following events:
      captcha.on('load', function(){
          console.log("Loaded");
          // do something when captcha loads first time
      });
      captcha.on('reload', function(){
          console.log("Reloaded");
          // do something when captcha is reloaded
      });
      captcha.on('pass', function(){
          alert("Passed");
          // do something when captcha test is passed by user
      });
      captcha.on('fail', function(){
          alert("Try Again");
          // do something when user enters wrong characters
      });
      captcha.on('test', function(passed){
          console.log('Tested. Result is: ' + passed);
          // do something when user clicks on the submit button of captcha
      });
  1. Checking if captcha test is passed or not:
    Use property isPassed.
        if(captcha.isPassed){ //returns true if captcha is passed
            //do something
        }

Check out Captcha Example to see how to integrate front-end and back-end.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.