Icard/angular-clarity-master(work.../node_modules/ngx-captcha/fesm2020/ngx-captcha.mjs.map

1 line
44 KiB
Plaintext
Raw Normal View History

2024-07-16 14:55:36 +00:00
{"version":3,"file":"ngx-captcha.mjs","sources":["../../src/lib/services/script.service.ts","../../src/lib/components/base-re-captcha-component.directive.ts","../../src/lib/models/recaptcha-type.enum.ts","../../src/lib/components/invisible-recaptcha.component.ts","../../src/lib/components/recaptcha-2.component.ts","../../src/lib/services/recaptcha_v3.service.ts","../../src/lib/ngx-captcha.module.ts","../../src/public_api.ts","../../src/ngx-captcha.ts"],"sourcesContent":["import { Injectable, NgZone } from \"@angular/core\";\r\nimport { RecaptchaConfiguration } from \"../models/recaptcha-configuration\";\r\n\r\n@Injectable({\r\n providedIn: \"root\",\r\n})\r\nexport class ScriptService {\r\n private readonly scriptElemId: string = \"ngx-catpcha-script\";\r\n\r\n /**\r\n * Name of the global google recaptcha script\r\n */\r\n protected readonly windowGrecaptcha = \"grecaptcha\";\r\n\r\n /**\r\n * Name of enterpise property in the global google recaptcha script\r\n */\r\n protected readonly windowGrecaptchaEnterprise = \"enterprise\";\r\n\r\n /**\r\n * Name of the global callback\r\n */\r\n protected readonly windowOnLoadCallbackProperty =\r\n \"ngx_captcha_onload_callback\";\r\n\r\n /**\r\n * Name of the global callback for enterprise\r\n */\r\n protected readonly windowOnLoadEnterpriseCallbackProperty =\r\n \"ngx_captcha_onload_enterprise_callback\";\r\n\r\n protected readonly globalDomain: string = \"recaptcha.net\";\r\n\r\n protected readonly defaultDomain: string = \"google.com\";\r\n\r\n protected readonly enterpriseApi: string = \"enterprise.js\";\r\n\r\n protected readonly defaultApi: string = \"api.js\";\r\n\r\n constructor(protected zone: NgZone) {}\r\n\r\n registerCaptchaScript(\r\n config: RecaptchaConfiguration,\r\n render: string,\r\n onLoad: (grecaptcha: any) => void,\r\n language?: string\r\n ): void {\r\n if (this.grecaptchaScriptLoaded(config.useEnterprise)) {\r\n // recaptcha script is already loaded\r\n // just call the callback\r\n if (config.useEnterprise) {\r\n this.zone.run(() => {\r\n onLoad(\r\n (window as any)[this.windowGrecaptcha][\r\n this.windowGrecaptchaEnterprise\r\n ]\r\n );\r\n });\r\n } else {\r\n this.zone.run(() => {\r\n onLoad((window as any)[this.windowGrecaptcha]);\r\n });\r\n }\r\n return;\r\n }\r\n\r\n // we need to patch the callback through global variable, otherwise callback is not accessible\r\n // note: https://github.com/Enngage/ngx-captcha/issues/2\r\n if (config.useEnterprise) {\r\n (window as any)[this.getCallbackName(true)] = <any>(\r\n (() =>\r\n this.zone.run(\r\n onLoad.bind(\r\n this,\r\n (window as any)[this.windowGrecaptcha][\r\n this.windowGrecaptchaEnterprise\r\n ]\r\n )\r\n ))\r\n );\r\n } else {\r\n (window as any)[this.getCallbackName(false)] = <any>(\r\n (() =>\r\n this.zone.run(\r\n onLoad.bind(this, (window as any)[this.windowGrecaptcha])\r\n ))\r\n );\r\n }\r\n\r\n // prepare script elem\r\n const scriptElem = document.createElement(\"script\");\r\n scriptElem.id = this.scriptElemId;\r\n scriptElem.innerHTML = \"\";\r\n scriptElem.src = this.getCaptchaScriptUrl(config, render, language);\r\n scriptElem.async = true;\r\n scriptElem.defer = true;\r\n\r\n // add script to header\r\n document.getElementsByTagName(\"head\")[0].appendChild(scriptElem);\r\n }\r\n\r\n cleanup(): void {\r\n const elem = document.getElementById(this.scriptElemId);\r\n\r\n if (elem) {\r\n elem.remove();\r\n }\r\n (window as any)[this.getCallbackName()] = undefined;\r\n (window as any)[this.windowGrecaptcha] = undefined;\r\n }\r\n\r\n /**\r\n * Indicates if google recaptcha script is available and ready to be used\r\n */\r\n private grecaptchaScriptLoaded(useEnterprise?: boolean): boolea