1.0.0 • Published 7 months ago

@internetarchive/recaptcha-manager v1.0.0

Weekly downloads
-
License
AGPL-3.0-only
Repository
github
Last release
7 months ago

Build Status

Internet Archive reCaptcha Manager

A library to lazy load and interact with reCaptcha

Installation

> npm install @internetarchive/recaptcha-manager

Usage

const recaptchaManager = new RecaptchaManager({
  defaultSiteKey: 'your-site-key',
});

// will load recaptcha library if it's not loaded
const recaptchaWidget = await recaptchaManager.getRecaptchaWidget({
  recaptchaParams: {
    tabindex: 0,
    theme: 'light',
    type: 'image',
  },
});

const token = await recaptchaWidget.execute();

// submit token with your post and validate on the backend

For more usage examples, see demo/app-root.ts and test/recaptcha-manager.test.ts.

Local Demo with web-dev-server

npm run start

To run a local development server that serves the basic demo located in demo/index.html

Testing with Web Test Runner

To run the suite of Web Test Runner tests, run

npm run test

To run the tests in watch mode (for <abbr title="test driven development">TDD</abbr>, for example), run

npm run test:watch

Linting with ESLint, Prettier, and Types

To scan the project for linting errors, run

npm run lint

To automatically fix many linting errors, run

npm run format