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

@pardjs/recaptcha-server

v0.2.0

Published

🔍The server side reCaptcha module to do verification.

Downloads

17

Readme

recaptcha-server

styled with prettier Greenkeeper badge Travis Coveralls

The server side recaptcha module to do verification. Use with Google reCaptcha

Usage

This verification used the v3 method, which returns a score (1.0 is very likely a good interaction, 0.0 is very likely a bot).

The lib by default use the 0.6 as the default passed minScore(not included)

import Recaptcha from '@pardjs/recaptcha-server';

// #RECAPTCHA_SECRET get from the google recaptcha site.
const recInstance = new Recaptcha('#RECAPTCHA_SECRET#');

// Verifiy the token directly
// #RECAPTCHA_TOKEN get from the client
const v3Result = await recInstance.verifyV3Async('#RECAPTCHA_TOKEN#'); request.
// Verifiy the token with custom min passed score
const v3Result = await recInstance.verifyV3Async('#RECAPTCHA_TOKEN#', 0.8);

// The v3Result example
// {
//   isPassed: true,
//   score: 0.9,
//   hostName: 'dozto.com',
//   action: 'contactUs',
//   checkedAt: 2019-04-03T08:51:34.038Z
// }

Error Types

There will be a type in the throwed error object, and there are the following defined types

RECAPTCHA_VERIFY_ERROR: The verification handled by google successfully, but faild in the verificatoin result.
RECAPTCHA_UNEXPECTED_ERROR: Unexpected error during process google reCaptcha verification.

Example

{ Error: [recaptcha-server] Failed to verify recaptcha: invalid-secret
  at Recaptcha.<anonymous> (/Users/ole3021/workspaces/pardjs/recaptcha-server/src/recaptcha-server.ts:3006:35)
  at step (/Users/ole3021/workspaces/pardjs/recaptcha-server/src/recaptcha-server.ts:2909:27)
  at Object.next (/Users/ole3021/workspaces/pardjs/recaptcha-server/src/recaptcha-server.ts:2797:20)
  at fulfilled (/Users/ole3021/workspaces/pardjs/recaptcha-server/src/recaptcha-server.ts:2736:32)
  at process._tickCallback (internal/process/next_tick.js:68:7) type: 'RECAPTCHA_UNEXPECTED_ERROR' }

error.type === 'RECAPTCHA_VERIFY_ERROR' // true