Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-recaptcha3

Package Overview
Dependencies
Maintainers
4
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-recaptcha3

Angular v10+ integration with google recaptcha v3

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
335
increased by8.41%
Maintainers
4
Weekly downloads
 
Created
Source

angular-recaptcha3

Angular v10+ integration with google recaptcha v2-3.

Setup

import { ReCaptchaModule } from 'angular-recaptcha3';

@NgModule({
    imports: [
        ReCaptchaModule.forRoot(RECAPTCHA_OPTION)
    ]
})
const RECAPTCHA_OPTION = {
    language?: string;
    invisible?: IRecaptchaOption;
    normal?: IRecaptchaOption;
}

interface IRecaptchaOption {
    sitekey: string;
    theme?: string;
    type?: string;
    tabindex?: number;
    badge?: string;
}

Option description: https://developers.google.com/recaptcha/docs/display

Language codes: https://developers.google.com/recaptcha/docs/language

Example AppModule:

import { ReCaptchaModule } from 'angular-recaptcha3';

@NgModule({
    imports: [
        ReCaptchaModule.forRoot({
            invisible: {
                sitekey: 'your key', 
            },
            normal: {
                sitekey: 'your key', 
            },
            language: 'en'
        }),
    ]
})

To initialize the recaptcha you need to insert in the template

<recaptcha 
    [size]="'invisible'"
    (captchaResponse)="onCaptchaResponse($event)"
    (captchaExpired)="onCaptchaExpired()">
</recaptcha>

<recaptcha 
    [size]="'normal'"
    [hide]="false" 
    (captchaResponse)="onCaptchaResponse($event)">
</recaptcha>
onCaptchaExpired(event) {
    console.log(event);
}

onCaptchaResponse(event) {
    console.log(event);
}

Recaptcha has parametrs:

  • hide
  • sitekey
  • size
  • theme
  • type
  • tabindex
  • badge
  • language

Actions

reCAPTCHA v3 introduces a new concept: actions. When you specify an action name in each place you execute reCAPTCHA you enable two new features:

a detailed break-down of data for your top ten actions in the admin console adaptive risk analysis based on the context of the action (abusive behavior can vary) Importantly, when you verify the reCAPTCHA response you should also verify that the action name matches the one you expect.

    constructor(
        private recaptchaService: ReCaptchaService
    ) { }
    // ...
    recaptchaService.execute({action: 'homepage'}).then(token => {
        //...
    });

Note: actions may only contain alphanumeric characters and slashes, and must not be user-specific.

A more detailed description of ReCaptcha: https://developers.google.com/recaptcha/intro

Keywords

FAQs

Package last updated on 24 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc