Coder Social home page Coder Social logo

masonabc / recaptcha-v3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from abinnovision/recaptcha-v3

0.0 0.0 0.0 5.59 MB

Simple and easy to use reCAPTCHA (v3 only) library for the browser.

License: Apache License 2.0

Shell 0.77% JavaScript 2.59% TypeScript 96.64%

recaptcha-v3's Introduction

reCAPTCHA-v3

Build npm npm type definitions npm bundle size

A simple and easy to use reCAPTCHA (v3 only) library for the browser. (You may be also interested in wrapper libraries)

Install

With NPM:

$ npm install recaptcha-v3

With Yarn:

$ yarn add recaptcha-v3

Prerequisites

To use this package you only need a valid site key for your domain, which you can easily get here.

Usage

With promises:

import { load } from 'recaptcha-v3'

load('<site key>').then((recaptcha) => {
  recaptcha.execute('<action>').then((token) => {
      console.log(token) // Will print the token
    })
})

With async/await:

import { load } from 'recaptcha-v3'

async function asyncFunction() {
  const recaptcha = await load('<site key>')
  const token = await recaptcha.execute('<action>')

  console.log(token) // Will also print the token
}

Loader options

The loader takes care of loading the reCAPTCHA script from Google. Therefore the loader offers optional options for additional configuration:

Name Description Type Default value
useRecaptchaNet Due to limitations in certain countries it's required to use recaptcha.net instead of google.com. boolean false
useEnterprise Uses the enterprise version of the recaptcha api and handles the differences in the response. boolean false
autoHideBadge Will automatically hide the reCAPTCHA badge. Warning: The usage is only allowed if you follow the offical guide for hiding the badge from Google (see here) boolean false
renderParameters Will add the given parameters to the reCAPTCHA script. The given object will be converted into a query string and will then be added to the URL. Object {}
explicitRenderParameters Will set the parameters to the explicit rendering. See here Object {}

Load options usage

To use the options just pass an additional object to the load(...) method. For example:

import { load } from 'recaptcha-v3'

load('<site key>', {
  useRecaptchaNet: true,
  autoHideBadge: true
}).then((recaptcha) => {

})

Explicit render parameters

The ReCaptcha widget will be explicity loaded, which means you can add parameters to the rendering process.

Name Description Type
container The container if you want to render the inline widget string or Element
badge The positioning for the widget 'bottomright' or 'bottomleft' or 'inline'
size The size of the widget 'invisible'
tabindex The tab index of the widget number

Wrapper libraries

Wrapper libraries are available for:

recaptcha-v3's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar wipeair avatar depfu[bot] avatar almo7aya avatar mustafafaris avatar aentwist avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.