@hcaptcha/react-hcaptcha
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -166,2 +166,2 @@ "use strict"; | ||
exports.default = HCaptcha; | ||
exports.default = HCaptcha; |
@@ -17,3 +17,3 @@ "use strict"; | ||
var CaptchaScript = function CaptchaScript(cb, hl) { | ||
var CaptchaScript = function CaptchaScript(cb, hl, endpoint) { | ||
// Create script to init hCaptcha | ||
@@ -26,6 +26,10 @@ var script = document.createElement("script"); | ||
if (typeof hl != "undefined" && hl != null) { | ||
if (hl) { | ||
script.src += "&hl=" + hl; | ||
} | ||
if (endpoint) { | ||
script.src += "&endpoint=" + encodeURIComponent(endpoint); | ||
} | ||
return script; | ||
@@ -53,5 +57,8 @@ }; | ||
_this.closeCaptcha = _this.closeCaptcha.bind(_this); | ||
_this.resetCaptcha = _this.resetCaptcha.bind(_this); | ||
// https://hcaptcha.com/docs/languages lists available codes. | ||
_this.languageOverride = props.languageOverride; | ||
// custom endpoint | ||
_this.endpoint = props.endpoint; | ||
@@ -81,3 +88,3 @@ _this._id = null; | ||
//Check if hCaptcha has already been loaded, if not create script tag and wait to render captcha element - hCaptcha | ||
var script = CaptchaScript(this.onloadScript, this.languageOverride); | ||
var script = CaptchaScript(this.onloadScript, this.languageOverride, this.endpoint); | ||
document.getElementById(hCaptchaVars.element_id).appendChild(script); | ||
@@ -94,2 +101,5 @@ } else { | ||
if (this._removed === false) this.removeFrame(); | ||
// Reset any stored variables / timers when unmounting | ||
hcaptcha.reset(this._id); | ||
} | ||
@@ -96,0 +106,0 @@ }, { |
@@ -18,3 +18,3 @@ const React = require('react'); | ||
// To force a language, use the code: https://hcaptcha.com/docs/languages | ||
this.languageOverride = null; // "fr"; | ||
this.languageOverride = null; // "fr"; | ||
} | ||
@@ -21,0 +21,0 @@ |
{ | ||
"name": "@hcaptcha/react-hcaptcha", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "A React library for hCaptcha", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
const React = require('react'); | ||
const CaptchaScript = (cb, hl) => { // Create script to init hCaptcha | ||
const CaptchaScript = (cb, hl, endpoint) => { // Create script to init hCaptcha | ||
let script = document.createElement("script") | ||
@@ -10,6 +10,10 @@ | ||
if (typeof hl != "undefined" && hl != null) { | ||
script.src += `&hl=${hl}` | ||
if (hl) { | ||
script.src += `&hl=${hl}` | ||
} | ||
if (endpoint) { | ||
script.src += `&endpoint=${encodeURIComponent(endpoint)}`; | ||
} | ||
return script; | ||
@@ -33,5 +37,8 @@ } | ||
this.closeCaptcha = this.closeCaptcha.bind(this) | ||
this.resetCaptcha = this.resetCaptcha.bind(this) | ||
// https://hcaptcha.com/docs/languages lists available codes. | ||
this.languageOverride = props.languageOverride | ||
// custom endpoint | ||
this.endpoint = props.endpoint | ||
@@ -56,3 +63,3 @@ this._id = null | ||
if (typeof hcaptcha === 'undefined') { //Check if hCaptcha has already been loaded, if not create script tag and wait to render captcha element - hCaptcha | ||
let script = CaptchaScript(this.onloadScript, this.languageOverride); | ||
let script = CaptchaScript(this.onloadScript, this.languageOverride, this.endpoint); | ||
document.getElementById(hCaptchaVars.element_id).appendChild(script); | ||
@@ -67,2 +74,5 @@ } else { | ||
if (this._removed === false) this.removeFrame() | ||
// Reset any stored variables / timers when unmounting | ||
hcaptcha.reset(this._id) | ||
} | ||
@@ -134,2 +144,2 @@ | ||
module.exports = HCaptcha; | ||
module.exports = HCaptcha; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
26608
12
494
0