@mcaptcha/core-glue

Core Glue

Shared code used in other JavaScript glue implementations

NPM 0.1.0 Build) codecov

Usage

A custom glue implementation

  const instanceUrl = "https://api.mcaptcha.org";
const siteKey: g.SiteKey = {
key: "randomSitekeyasShowninmCaptchaDashboard",
instanceUrl: new URL(instanceUrl),
};

/** callback function to update hidden input field. Varies for each
* framework/ glue implementation
*/
const cb = (token: string): void {
let input = document.getElementById("mcaptcha__token");
if (input) {
input.value = token;
}
}

const config: g.WidgetConfig = {
siteKey,
};

const r = new Receiver(config, cb.setToken);

// register listener when component is mounted/necessary HTML for
// callback function is rendered
r.listen();

// teardown
r.destroy();

Generated using TypeDoc