A library to lazy load and interact with reCaptcha
> npm install @internetarchive/recaptcha-manager
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
.
npm run start
To run a local development server that serves the basic demo located in demo/index.html
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
To scan the project for linting errors, run
npm run lint
To automatically fix many linting errors, run
npm run format