In-browser SDK for Friendly Captcha v2
npm install @friendlycaptcha/sdk
The SDK that is used to integrate Friendly Captcha v2 into your website.
This is the code that runs on your website, inserting the captcha widget.
> ☝️ This is the SDK for Friendly Captcha v2 only. If you are looking for the v1 SDK, you can find that here.
``shellusing npm
npm install @friendlycaptcha/sdk
You can then use it in your library.
`js
import { FriendlyCaptchaSDK } from "@friendlycaptcha/sdk"// Re-use this SDK if you are creating multiple widgets.
const sdk = new FriendlyCaptchaSDK();
``js
// HTML element that you want to mount the widget under.
const mount = document.querySelector("#my-widget-mount");// Create the widget
const widget = sdk.createWidget({
element: mount,
sitekey: ""
});
`$3
You can also
require the SDK if your environment uses CommonJS.`js
var { FriendlyCaptchaSDK } = require("@friendlycaptcha/sdk");// Re-use this SDK if you are creating multiple widgets.
const sdk = new FriendlyCaptchaSDK();
`Documentation
The documentation can be found in our Developer Hub, and the Getting Started guide.
Development
If you want to develop this SDK itself the following commands are useful
`shell
install dependencies
npm installminimal build
npm run buildbuild for distribution (also builds docs)
npm run build:distrun the basic unit tests
npm run test
`$3
We include more proper end-to-end tests in the sdktest tool folder.$3
We automatically generate markdown docs and translate these into files that are in a format that works for Docusaurus. You will then need to update the docs manually by deleting the old files and adding the new ones. Something like this:`shell
rm -rf ../friendly-docs/docs/sdk/reference && mkdir ../friendly-docs/docs/sdk/reference && cp -r ./dist/docs/docusaurus/ ../friendly-docs/docs/sdk/reference/
`$3
`shell
print those files that would be changed
npm run license-check-and-add -- checkadd the headers
npm run license-check-and-add -- add
``Prior to us being able to accept your contribution you will need to sign our CLA (Contributor License Agreement).