react-grecaptcha-v3
Version:
Google Recaptcha V3 for React.js based application. Keep website performance high while prioritizing security.
62 lines • 2.74 kB
JavaScript
function _object_without_properties(source, excluded) {
if (source == null) return {};
var target = {}, sourceKeys, key, i;
if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
sourceKeys = Reflect.ownKeys(source);
for(i = 0; i < sourceKeys.length; i++){
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
return target;
}
target = _object_without_properties_loose(source, excluded);
if (Object.getOwnPropertySymbols) {
sourceKeys = Object.getOwnPropertySymbols(source);
for(i = 0; i < sourceKeys.length; i++){
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
function _object_without_properties_loose(source, excluded) {
if (source == null) return {};
var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
for(i = 0; i < sourceKeys.length; i++){
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
return target;
}
import { key } from "./global/globals";
var getScriptSrc = function(param) {
var enterprise = param.enterprise, useRecaptchaNet = param.useRecaptchaNet, siteKey = param.siteKey;
var hostname = useRecaptchaNet ? "recaptcha.net" : "www.google.com";
if (enterprise) {
return "https://".concat(hostname, "/recaptcha/enterprise.js?render=").concat(siteKey, "&onload=").concat(key);
}
return "https://".concat(hostname, "/recaptcha/api.js?render=").concat(siteKey, "&onload=").concat(key);
};
var maybeInjectScript = function(_0) {
var appendTo = _0.appendTo, scriptProps = _object_without_properties(_0, [
"appendTo"
]);
var _document_querySelector;
var el = (_document_querySelector = document.querySelector("script[id=".concat(scriptProps.id, "]"))) !== null && _document_querySelector !== void 0 ? _document_querySelector : document.createElement("script");
Object.assign(el, scriptProps);
(appendTo === "head" ? document.head : document.body).appendChild(el);
};
var maybeRemoveScript = function(scriptId) {
var el = document.querySelector("script[id=".concat(scriptId, "]"));
if (el !== null) {
document.head.removeChild(el);
}
};
export { getScriptSrc, maybeInjectScript, maybeRemoveScript };
//# sourceMappingURL=utils.js.map