@mcaptcha/core-glue
TypeScript icon, indicating that this package has built-in type declarations

0.1.0-alpha-5 • Public • Published

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();

Package Sidebar

Install

npm i @mcaptcha/core-glue

Homepage

mcaptcha.org

Weekly Downloads

3,056

Version

0.1.0-alpha-5

License

(MIT OR Apache-2.0)

Unpacked Size

11.3 kB

Total Files

5

Last publish

Collaborators

  • mcaptcha-user
  • realaravinth