react-grecaptcha-v3
Version:
Google Recaptcha V3 for React.js based application. Keep website performance high while prioritizing security.
1 lines • 6.02 kB
Source Map (JSON)
{"version":3,"sources":["/home/runner/work/react-grecaptcha-v3/react-grecaptcha-v3/dist/utils.cjs","../src/utils.ts"],"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key2","call","__toCommonJS","mod","value","utils_exports","getScriptSrc","maybeInjectScript","maybeRemoveScript","module","exports","import_globals","require","enterprise","useRecaptchaNet","siteKey","hostname","key","appendTo","scriptProps","document","el","querySelector","id","createElement","assign","head","body","appendChild","scriptId","removeChild"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAIA,YAAYC,OAAOC,cAAc;AACrC,IAAIC,mBAAmBF,OAAOG,wBAAwB;AACtD,IAAIC,oBAAoBJ,OAAOK,mBAAmB;AAClD,IAAIC,eAAeN,OAAOO,SAAS,CAACC,cAAc;AAClD,IAAIC,WAAW,SAACC,QAAQC;IACtB,IAAK,IAAIC,QAAQD,IACfZ,UAAUW,QAAQE,MAAM;QAAEC,KAAKF,GAAG,CAACC,KAAK;QAAEE,YAAY;IAAK;AAC/D;AACA,IAAIC,cAAc,SAACC,IAAIC,MAAMC,QAAQC;IACnC,IAAIF,QAAQ,CAAA,OAAOA,qCAAP,SAAOA,KAAG,MAAM,YAAY,OAAOA,SAAS,YAAY;YAC7D,kCAAA,2BAAA;;;gBAAA,IAAIG,OAAJ;gBACH,IAAI,CAACd,aAAae,IAAI,CAACL,IAAII,SAASA,SAASF,QAC3CnB,UAAUiB,IAAII,MAAM;oBAAEP,KAAK;+BAAMI,IAAI,CAACG,KAAK;;oBAAEN,YAAY,CAAEK,CAAAA,OAAOjB,iBAAiBe,MAAMG,KAAI,KAAMD,KAAKL,UAAU;gBAAC;;YAFvH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C,OAAO,GAAG;IACrBJ,cAAAA;IACAC,mBAAAA;IACAC,mBAAAA;AACF,CAAA","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key2 of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key2) && key2 !== except)\n __defProp(to, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc(from, key2)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar utils_exports = {};\n__export(utils_exports, {\n getScriptSrc: () => getScriptSrc,\n maybeInjectScript: () => maybeInjectScript,\n maybeRemoveScript: () => maybeRemoveScript\n});\nmodule.exports = __toCommonJS(utils_exports);\nvar import_globals = require(\"./global/globals\");\nconst getScriptSrc = ({\n enterprise,\n useRecaptchaNet,\n siteKey\n}) => {\n const hostname = useRecaptchaNet ? \"recaptcha.net\" : \"www.google.com\";\n if (enterprise) {\n return `https://${hostname}/recaptcha/enterprise.js?render=${siteKey}&onload=${import_globals.key}`;\n }\n return `https://${hostname}/recaptcha/api.js?render=${siteKey}&onload=${import_globals.key}`;\n};\nconst maybeInjectScript = ({\n appendTo,\n ...scriptProps\n}) => {\n const el = document.querySelector(`script[id=${scriptProps.id}]`) ?? document.createElement(\"script\");\n Object.assign(el, scriptProps);\n (appendTo === \"head\" ? document.head : document.body).appendChild(el);\n};\nconst maybeRemoveScript = (scriptId) => {\n const el = document.querySelector(`script[id=${scriptId}]`);\n if (el !== null) {\n document.head.removeChild(el);\n }\n};\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n getScriptSrc,\n maybeInjectScript,\n maybeRemoveScript\n});\n","import { key } from './global/globals'\n\nexport type ReCaptchaProps = Readonly<{\n siteKey: string\n useRecaptchaNet: boolean\n enterprise: boolean\n}>\nexport const getScriptSrc = ({\n enterprise,\n useRecaptchaNet,\n siteKey,\n}: ReCaptchaProps): string => {\n const hostname = useRecaptchaNet ? 'recaptcha.net' : 'www.google.com'\n if (enterprise) {\n return `https://${hostname}/recaptcha/enterprise.js?render=${siteKey}&onload=${key}`\n }\n return `https://${hostname}/recaptcha/api.js?render=${siteKey}&onload=${key}`\n}\n\nexport type CreatScriptProps = Readonly<{\n id: string\n async: boolean\n defer: boolean\n src: string\n nonce?: string\n}>\n\nexport type InjectScriptProps = CreatScriptProps & {\n appendTo: 'head' | 'body'\n}\nexport const maybeInjectScript = ({\n appendTo,\n ...scriptProps\n}: InjectScriptProps): void => {\n const el =\n document.querySelector(`script[id=${scriptProps.id}]`) ??\n document.createElement('script')\n Object.assign(el, scriptProps)\n ;(appendTo === 'head' ? document.head : document.body).appendChild(el)\n}\nexport const maybeRemoveScript = (scriptId: string): void => {\n const el = document.querySelector(`script[id=${scriptId}]`)\n if (el !== null) {\n document.head.removeChild(el)\n }\n}\n"]}