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

ngx-recaptcha-easy

v9.0.0

Published

Simple library project to make RE-CAPTCHA usable on Angluar.

Downloads

2

Readme

NgxRecaptcha

Simple library project to make RE-CAPTCHA usable on Angluar.

Supporting also visible, inivisble reCAPTCHA and custom CAPTCHA.

Version 0.0.x is compliant with Angular >=8

Version 9.0.x is compliant with Angular >=9

Import module


import { NgxRecaptchaModule } from 'ngx-recaptcha-easy'

...
@NgModule({
  imports: [
            ...
            NgxRecaptchaModule
            ]
  })
...

View

Use in template like below

 <ngx-recaptcha site_key="<GOOGLE_RECAPTCHA_SITE_KEY>"></ngx-recaptcha>

Options

Required attributes

  • site_key the Google reCaptcha public key.

Optional attributes (see also API at https://developers.google.com/recaptcha/intro)

  • language
  • theme
  • type
  • size
  • tabindex
  • global If true, the reCaptcha script will be loaded from www.recaptcha.net instead of www.google.com
  • script_url the Google reCaptcha javascript or any other javascript that renders a CAPTCHA. Default is https://(www.recaptcha.net|www.google.com)/recaptcha/api.js?hl=(language)&render=explicit& onload=reCaptchaOnloadCallback. If another javascript is provided that Google's ReCAPTCHA then make sure it is fully compliant.

EventHandler

  • (loaded)
    This callback invokes grecaptcher.init() to initialize the re-captcha.
    This also should call grecaptcher.execute() when using size=invisible.
  • (error)
    This callback will receive any error loading the re-captcha script.
  • (captchaResponse)
    Will provide the CAPTCHA token
  • (captchaExpired)
    Will notify when the CAPTCHA token has expired.

Methods

Renew

Renew / reset the CAPTCHA token

this.captcha.reset();

Read

Re-read an existing CAPTCHA token

let token = this.captcha.getResponse();

DEMO

Run the DEMO

Clone this project git clone ...

Install dependencies with npm install

Start DMEO npm start

Example for a custom CAPTCHA script

You may define your own custom implementation of a CAPTCHA javascript.
The url to the script should then be provided in attribute script_url.
e.g. script_url=assets/custom-captcha.js
The javascript must be fully compliant to the Google ReCAPTCHA so,
the component can easily switch between them.

Here is a full example

var captcha = (function (window) {

    const render = (element, options) => {
        console.log('element:', element)
        const el = document.createElement('input')
        el.value = ''
        el.addEventListener('input', (event) => {
            options.callback(el.value)
        })
        el.placeholder = 'Set value 1234'
        element.appendChild(el)
        element.widgetIds = element.widgetIds || []
        const widgetId = 'custom-captcha-' + (+new Date())
        element.widgetIds.push(widgetId)
        el.id = widgetId
        return widgetId
    }
    const execute = (elementId) => {
        console.log('execute', elementId)
    }
    const getResponse = (elementId) => {
        console.log('getResponse', elementId)
        return document.querySelector(`#${elementId}`).value
    }
    const reset = (elementId) => {
        console.log('reset', elementId)
        document.querySelector(`#${elementId}`).value = ''
    }
    const ready = () => {

    }
    const getScriptURL = () => {
        var script = document.currentScript || document.querySelector('script[src*="custom-captcha.js"]')
        return script.src
    }
    const a = {
        render: render,
        execute: execute,
        getResponse: getResponse,
        reset: reset,
        ready: ready
    }
    console.log('getScriptURL', getScriptURL())
    window.grecaptcha = window.captcha = a

    const currentUrl = getScriptURL()
    if (-1 == currentUrl.indexOf('onload=')) {
        throw `Missing onload callback`
    }
    const onLoadCallback = currentUrl.split('onload=')[1].split('&')[0]
    if (onLoadCallback) {
        try { window[onLoadCallback]() } catch (e) { console.error(e) }
    }
    return a
})(window)