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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@adobe-commerce/recaptcha

v1.2.2

Published

Module allows to efficiently verify that users are humans, not bots or spammers

Readme

ReCaptcha Module

Purpose

This module integrates Google reCAPTCHA into Adobe Commerce storefronts. It supports both reCAPTCHA v3 and reCAPTCHA Enterprise, providing methods for configuring, initializing, and verifying reCAPTCHA on protected forms.

The module queries the recaptchaFormConfig GraphQL endpoint to fetch per-form configuration, automatically detecting which reCAPTCHA type (v3 or Enterprise) is configured and loading the appropriate script.

Installation

npm i @adobe-commerce/recaptcha

Quick Start

import { setEndpoint, setConfig, initReCaptcha, verifyReCaptcha, enableLogger } from '@adobe-commerce/recaptcha';

// 1. Set the backend GraphQL endpoint
setEndpoint('https://your-store.com/graphql');

// 2. Fetch and store reCAPTCHA configuration
await setConfig([{ badgeId: 'generateCustomerToken' }]);

// 3. Initialize reCAPTCHA (loads script, renders badges)
initReCaptcha();

// 4. Get a token when submitting a protected form
const token = await verifyReCaptcha();

Public Methods

setEndpoint(url: string)

Sets the GraphQL endpoint URL used to fetch reCAPTCHA configuration.

setConfig(configList: PropsFormTypes[])

Fetches reCAPTCHA configuration from the backend via recaptchaFormConfig and stores it in session storage.

  • Queries all known form types and determines which are enabled
  • Normalizes the response into a unified config shape
  • Detects the reCAPTCHA type (v3 or Enterprise) from the re_captcha_type field
  • Skips forms with empty website_key
  • Warns and disables reCAPTCHA if mixed types (both v3 and Enterprise) are detected across forms
await setConfig([
  { badgeId: 'generateCustomerToken' },
  { badgeId: 'contactUs' },
]);

initReCaptcha(lazyLoadTimeout?: number)

Initializes reCAPTCHA by loading the appropriate Google script and rendering badges.

  • Loads enterprise.js for Enterprise or api.js for v3
  • For inline badge position, renders invisible widgets into DOM elements matching each form's badgeId
  • Default lazy load timeout: 3000ms

verifyReCaptcha(): Promise<string | undefined>

Generates and returns a reCAPTCHA token for form submission.

  • Uses grecaptcha.enterprise.execute() for Enterprise or grecaptcha.execute() for v3
  • Returns undefined if reCAPTCHA is not enabled or not configured

enableLogger(enabled: boolean)

Enables or disables debug logging. When enabled, logs are prefixed with [ReCaptcha] and include:

  • Config fetch and normalization details
  • Which reCAPTCHA type is detected and which forms are enabled
  • Script loading URLs
  • Badge rendering activity
  • Token generation attempts
  • Warnings for skipped forms (missing keys) or mixed type configurations

Supported Form Types

The module queries these form types from the backend:

| Form Type | Badge ID | |---|---| | PLACE_ORDER | placeOrder | | CONTACT | contactUs | | CUSTOMER_LOGIN | generateCustomerToken | | CUSTOMER_FORGOT_PASSWORD | requestPasswordResetEmail | | CUSTOMER_CREATE | createCustomerV2 | | CUSTOMER_EDIT | updateCustomerV2 | | NEWSLETTER | subscribeEmailToNewsletter | | PRODUCT_REVIEW | createProductReview | | SENDFRIEND | SENDFRIEND | | BRAINTREE | BRAINTREE |

Mixed Type Configuration

If the Commerce Admin has some forms configured with reCAPTCHA v3 and others with Enterprise, the module will:

  1. Log a warning with instructions to update the Commerce Admin configuration
  2. Disable reCAPTCHA entirely (returns no config, no script loaded)

All forms must use the same reCAPTCHA type. Configure this in the Commerce Admin under Stores > Configuration > Security > Google reCAPTCHA Storefront.