Socket
Socket
Sign inDemoInstall

vanilla-hcaptcha

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4 to 0.0.5

2

dist/hcaptcha-component.min.js

@@ -1,1 +0,1 @@

function loadHCaptcha(t){const e=document.createElement("script");e.src="https://hcaptcha.com/1/api.js?render=explicit",e.async=!0,e.addEventListener("load",t,!0),document.head.append(e)}function createEvent(t){let e;return"function"==typeof Event?e=new Event(t):(e=document.createEvent("Event")).initEvent(t,!1,!1),e}class HCaptcha extends HTMLElement{connectedCallback(){const t=()=>{const t={sitekey:this.getAttribute("site-key"),theme:null!==this.getAttribute("dark")?"dark":"light",size:this.getAttribute("size"),tabindex:this.getAttribute("tabindex"),callback:t=>{const e=createEvent("verified");e.key=t,this.dispatchEvent(e)},"expired-callback":()=>{const t=createEvent("expired");this.dispatchEvent(t)},"error-callback":t=>{const e=createEvent("error");e.error=t,this.dispatchEvent(e)}},e=window.hcaptcha.render(this,t);this.render=(()=>{window.hcaptcha.execute(e)});const c=createEvent("loaded");c.hcaptchaId=e,this.dispatchEvent(c)};window.hcaptcha?t():loadHCaptcha(t.bind(this))}}customElements.define("h-captcha",HCaptcha);try{module.exports=HCaptcha}catch(t){}
function loadHCaptcha(t){const e=document.createElement("script");e.src="https://hcaptcha.com/1/api.js?render=explicit",e.async=!0,e.addEventListener("load",t,!0),document.head.append(e)}function createEvent(t){let e;return"function"==typeof Event?e=new Event(t):(e=document.createEvent("Event")).initEvent(t,!1,!1),e}class HCaptcha extends HTMLElement{connectedCallback(){const t=()=>{const t={sitekey:this.getAttribute("site-key"),theme:null!==this.getAttribute("dark")?"dark":"light",size:this.getAttribute("size"),tabindex:this.getAttribute("tabindex"),callback:t=>{const e=createEvent("verified");e.key=t,this.dispatchEvent(e)},"expired-callback":()=>{const t=createEvent("expired");this.dispatchEvent(t),this.reset()},"error-callback":t=>{const e=createEvent("error");e.error=t,this.dispatchEvent(e),this.reset()}},e=window.hcaptcha.render(this,t);this.render=(()=>{window.hcaptcha.execute(e)}),this.reset=(()=>{window.hcaptcha.reset(e)}),this.remove=(()=>{super.remove(),window.hcaptcha.remove(e)});const c=createEvent("loaded");c.hcaptchaId=e,this.dispatchEvent(c)};window.hcaptcha?t():loadHCaptcha(t.bind(this))}}customElements.define("h-captcha",HCaptcha);try{module.exports=HCaptcha}catch(t){}

@@ -36,2 +36,3 @@ function loadHCaptcha(cb) {

this.dispatchEvent(event);
this.reset();
},

@@ -42,2 +43,3 @@ "error-callback": (error) => {

this.dispatchEvent(event);
this.reset();
}

@@ -49,2 +51,9 @@ }

};
this.reset = () => {
window.hcaptcha.reset(hcaptchaId);
};
this.remove = () => {
super.remove();
window.hcaptcha.remove(hcaptchaId);
};
const event = createEvent('loaded');

@@ -51,0 +60,0 @@ event.hcaptchaId = hcaptchaId;

@@ -13,3 +13,5 @@ require('./dist/hcaptcha-component.min.js');

},
execute: () => {}
execute: () => {},
reset: () => {},
remove: () => {}
};

@@ -56,2 +58,18 @@ document.body.innerHTML = `

});
test('Proxy reset method', () => {
const spyReset = jest.spyOn(window.hcaptcha, 'reset');
const signupCaptcha = document.getElementById('signupCaptcha');
signupCaptcha.reset();
expect(spyReset).toHaveBeenCalledWith(mockCaptchaId);
spyReset.mockRestore();
});
test('Proxy remove method', () => {
const spyRemove = jest.spyOn(window.hcaptcha, 'remove');
const signupCaptcha = document.getElementById('signupCaptcha');
signupCaptcha.remove();
expect(spyRemove).toHaveBeenCalledWith(mockCaptchaId);
spyRemove.mockRestore();
});
});
{
"name": "vanilla-hcaptcha",
"description": "Vanilla Web Component for hCaptcha. 0 dependencies. <1kb gzipped.",
"version": "0.0.4",
"version": "0.0.5",
"main": "dist/hcaptcha-component.min.js",

@@ -6,0 +6,0 @@ "author": {

@@ -145,3 +145,10 @@ # hCaptcha - Vanilla Web Component

#### Methods
|Method|Description|
|---|---|
|`reset()`|Resets the hCaptcha which requires user to fill captcha again.|
|`remove()`|Removes the component from DOM.|
## Develop & Test

@@ -148,0 +155,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc