@prosopo/procaptcha-bundle 3.0.9 → 3.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/bundle/ProcaptchaWidget-48FxVPQd.js +187 -0
  3. package/dist/bundle/ProcaptchaWidget-B2BzhXLv.js +992 -0
  4. package/dist/bundle/builder-DNHtDoNG.js +44 -0
  5. package/dist/bundle/{captchaComponentProvider-CZppE3Vb.js → captchaComponentProvider-B7Vxx339.js} +256 -99
  6. package/dist/bundle/{captchaRenderer-CY8KuZK-.js → captchaRenderer-DdOlOCKw.js} +3 -3
  7. package/dist/bundle/{commonChunk-24zMb_mF.js → commonChunk-HCVkoCqn.js} +9 -12
  8. package/dist/bundle/{emotion-element-5486c51c.browser.esm-PRDDgd_k.js → emotion-element-5486c51c.browser.esm-D7qvHZDV.js} +1 -1
  9. package/dist/bundle/{fp.esm-BADUiinQ.js → fp.esm-DYWeNGcH.js} +648 -548
  10. package/dist/bundle/index-7Xh-Mf8v.js +1318 -0
  11. package/dist/bundle/{index-BiwZ4wVT.js → index-C00_J7av.js} +48 -12
  12. package/dist/bundle/{index-BzOMq-ud.js → index-DyYmvHVN.js} +1 -1
  13. package/dist/bundle/locales/ar/translation.json +12 -11
  14. package/dist/bundle/locales/az/translation.json +12 -11
  15. package/dist/bundle/locales/cs/translation.json +12 -11
  16. package/dist/bundle/locales/de/translation.json +12 -11
  17. package/dist/bundle/locales/el/translation.json +12 -11
  18. package/dist/bundle/locales/en/translation.json +4 -3
  19. package/dist/bundle/locales/es/translation.json +12 -11
  20. package/dist/bundle/locales/fi/translation.json +29 -28
  21. package/dist/bundle/locales/fr/translation.json +12 -11
  22. package/dist/bundle/locales/hi/translation.json +41 -40
  23. package/dist/bundle/locales/hu/translation.json +12 -11
  24. package/dist/bundle/locales/id/translation.json +12 -11
  25. package/dist/bundle/locales/it/translation.json +12 -11
  26. package/dist/bundle/locales/ja/translation.json +12 -11
  27. package/dist/bundle/locales/jv/translation.json +12 -11
  28. package/dist/bundle/locales/ko/translation.json +7 -6
  29. package/dist/bundle/locales/ml/translation.json +12 -11
  30. package/dist/bundle/locales/ms/translation.json +12 -11
  31. package/dist/bundle/locales/nl/translation.json +12 -11
  32. package/dist/bundle/locales/no/translation.json +12 -11
  33. package/dist/bundle/locales/pl/translation.json +12 -11
  34. package/dist/bundle/locales/pt/translation.json +12 -11
  35. package/dist/bundle/locales/pt-BR/translation.json +12 -11
  36. package/dist/bundle/locales/ro/translation.json +12 -11
  37. package/dist/bundle/locales/ru/translation.json +12 -11
  38. package/dist/bundle/locales/sr/translation.json +12 -11
  39. package/dist/bundle/locales/sv/translation.json +12 -11
  40. package/dist/bundle/locales/th/translation.json +12 -11
  41. package/dist/bundle/locales/tr/translation.json +7 -6
  42. package/dist/bundle/locales/uk/translation.json +12 -11
  43. package/dist/bundle/locales/vi/translation.json +12 -11
  44. package/dist/bundle/locales/zh-CN/translation.json +12 -11
  45. package/dist/bundle/nobleChunk-Qozzkbsq.js +3648 -0
  46. package/dist/bundle/procaptcha.bundle.js +2 -2
  47. package/dist/bundle/{utilCryptoChunk-CIPUtfoO.js → utilCryptoChunk-qm-BM2eT.js} +618 -647
  48. package/dist/bundle/{web2Chunk-7Vd8yt2r.js → web2Chunk-DCsWA5PR.js} +1150 -994
  49. package/dist/bundle/{web3Chunk-DrUvbVNW.js → web3Chunk-B8txCqUJ.js} +3 -3
  50. package/dist/index.js +142 -108
  51. package/dist/util/captcha/captchaComponentProvider.js +18 -10
  52. package/dist/util/captcha/captchaComponentsList.js +6 -5
  53. package/dist/util/captcha/captchaRenderer.js +58 -40
  54. package/dist/util/captcha/captchaType.js +9 -5
  55. package/dist/util/captcha/components/frictionlessCaptcha.js +19 -9
  56. package/dist/util/captcha/components/imageCaptcha.js +13 -5
  57. package/dist/util/captcha/components/powCaptcha.js +13 -5
  58. package/dist/util/config.js +15 -12
  59. package/dist/util/configCreator.js +21 -22
  60. package/dist/util/language.js +14 -13
  61. package/dist/util/timeout.js +13 -8
  62. package/dist/util/widgetFactory.js +77 -55
  63. package/dist/util/widgetThemeResolver.js +14 -17
  64. package/package.json +23 -20
  65. package/stats.html +1 -1
  66. package/vite.cjs.config.ts +2 -3
  67. package/vite.esm.config.ts +20 -0
  68. package/vite.test.config.ts +9 -5
  69. package/dist/bundle/ProcaptchaWidget-D_kzGjgO.js +0 -612
  70. package/dist/bundle/ProcaptchaWidget-DlrcrISF.js +0 -148
  71. package/dist/bundle/builder-CQlqPNRd.js +0 -37
  72. package/dist/bundle/index-BRg_gWPo.js +0 -1328
  73. package/dist/bundle/nobleChunk-Xl5XLrx3.js +0 -3635
  74. package/dist/components.d.ts +0 -5
  75. package/dist/components.d.ts.map +0 -1
  76. package/dist/components.js +0 -5
  77. package/dist/components.js.map +0 -1
  78. package/dist/index.d.ts +0 -16
  79. package/dist/index.d.ts.map +0 -1
  80. package/dist/index.js.map +0 -1
  81. package/dist/tests/util/captchaType.test.d.ts +0 -2
  82. package/dist/tests/util/captchaType.test.d.ts.map +0 -1
  83. package/dist/tests/util/captchaType.test.js +0 -36
  84. package/dist/tests/util/captchaType.test.js.map +0 -1
  85. package/dist/tests/util/config.test.d.ts +0 -2
  86. package/dist/tests/util/config.test.d.ts.map +0 -1
  87. package/dist/tests/util/config.test.js +0 -69
  88. package/dist/tests/util/config.test.js.map +0 -1
  89. package/dist/tests/util/renderLogic.test.d.ts +0 -2
  90. package/dist/tests/util/renderLogic.test.d.ts.map +0 -1
  91. package/dist/tests/util/renderLogic.test.js +0 -126
  92. package/dist/tests/util/renderLogic.test.js.map +0 -1
  93. package/dist/util/captcha/captchaComponentProvider.d.ts +0 -8
  94. package/dist/util/captcha/captchaComponentProvider.d.ts.map +0 -1
  95. package/dist/util/captcha/captchaComponentProvider.js.map +0 -1
  96. package/dist/util/captcha/captchaComponentsList.d.ts +0 -6
  97. package/dist/util/captcha/captchaComponentsList.d.ts.map +0 -1
  98. package/dist/util/captcha/captchaComponentsList.js.map +0 -1
  99. package/dist/util/captcha/captchaProps.d.ts +0 -9
  100. package/dist/util/captcha/captchaProps.d.ts.map +0 -1
  101. package/dist/util/captcha/captchaProps.js +0 -2
  102. package/dist/util/captcha/captchaProps.js.map +0 -1
  103. package/dist/util/captcha/captchaRenderer.d.ts +0 -24
  104. package/dist/util/captcha/captchaRenderer.d.ts.map +0 -1
  105. package/dist/util/captcha/captchaRenderer.js.map +0 -1
  106. package/dist/util/captcha/captchaType.d.ts +0 -3
  107. package/dist/util/captcha/captchaType.d.ts.map +0 -1
  108. package/dist/util/captcha/captchaType.js.map +0 -1
  109. package/dist/util/captcha/components/frictionlessCaptcha.d.ts +0 -4
  110. package/dist/util/captcha/components/frictionlessCaptcha.d.ts.map +0 -1
  111. package/dist/util/captcha/components/frictionlessCaptcha.js.map +0 -1
  112. package/dist/util/captcha/components/imageCaptcha.d.ts +0 -4
  113. package/dist/util/captcha/components/imageCaptcha.d.ts.map +0 -1
  114. package/dist/util/captcha/components/imageCaptcha.js.map +0 -1
  115. package/dist/util/captcha/components/powCaptcha.d.ts +0 -4
  116. package/dist/util/captcha/components/powCaptcha.d.ts.map +0 -1
  117. package/dist/util/captcha/components/powCaptcha.js.map +0 -1
  118. package/dist/util/config.d.ts +0 -6
  119. package/dist/util/config.d.ts.map +0 -1
  120. package/dist/util/config.js.map +0 -1
  121. package/dist/util/configCreator.d.ts +0 -5
  122. package/dist/util/configCreator.d.ts.map +0 -1
  123. package/dist/util/configCreator.js.map +0 -1
  124. package/dist/util/language.d.ts +0 -3
  125. package/dist/util/language.d.ts.map +0 -1
  126. package/dist/util/language.js.map +0 -1
  127. package/dist/util/timeout.d.ts +0 -3
  128. package/dist/util/timeout.d.ts.map +0 -1
  129. package/dist/util/timeout.js.map +0 -1
  130. package/dist/util/widgetFactory.d.ts +0 -18
  131. package/dist/util/widgetFactory.d.ts.map +0 -1
  132. package/dist/util/widgetFactory.js.map +0 -1
  133. package/dist/util/widgetThemeResolver.d.ts +0 -9
  134. package/dist/util/widgetThemeResolver.d.ts.map +0 -1
  135. package/dist/util/widgetThemeResolver.js.map +0 -1
@@ -1,9 +1,9 @@
1
1
  var vn = Object.defineProperty;
2
2
  var rn = (e, n, f) => n in e ? vn(e, n, { enumerable: !0, configurable: !0, writable: !0, value: f }) : e[n] = f;
3
3
  var c = (e, n, f) => rn(e, typeof n != "symbol" ? n + "" : n, f);
4
- import { E as Pn } from "./web2Chunk-7Vd8yt2r.js";
5
- import { P as D } from "./commonChunk-24zMb_mF.js";
6
- import { u as zn } from "./utilCryptoChunk-CIPUtfoO.js";
4
+ import { P as D } from "./commonChunk-HCVkoCqn.js";
5
+ import { E as Pn } from "./web2Chunk-DCsWA5PR.js";
6
+ import { t as zn } from "./utilCryptoChunk-qm-BM2eT.js";
7
7
  import { v as I, s as cn, o as dn } from "./utilChunk-sqstc6C5.js";
8
8
  const R = { getRandomValues: zn }, sn = { crypto: R };
9
9
  class bn {
package/dist/index.js CHANGED
@@ -9,127 +9,161 @@ let procaptchaRoots = [];
9
9
  const widgetFactory = new WidgetFactory(new WidgetThemeResolver());
10
10
  const PROCAPTCHA_EXECUTE_EVENT = "procaptcha:execute";
11
11
  const implicitRender = async () => {
12
- const elements = Array.from(document.getElementsByClassName("procaptcha")).filter((element) => element.tagName.toLowerCase() !== "button");
13
- if (elements.length) {
14
- const siteKey = at(elements, 0).getAttribute("data-sitekey");
15
- const web3 = at(elements, 0).getAttribute("data-web3");
16
- if (!siteKey) {
17
- console.error("No siteKey found");
18
- return;
19
- }
20
- const captchaType = getCaptchaType(elements);
21
- const root = await widgetFactory.createWidgets(elements, {
22
- captchaType: captchaType,
23
- siteKey: siteKey,
24
- }, !(web3 === "true"));
25
- procaptchaRoots.push(...root);
12
+ const elements = Array.from(
13
+ document.getElementsByClassName("procaptcha")
14
+ ).filter((element) => element.tagName.toLowerCase() !== "button");
15
+ if (elements.length) {
16
+ const siteKey = at(elements, 0).getAttribute("data-sitekey");
17
+ const web3 = at(elements, 0).getAttribute("data-web3");
18
+ if (!siteKey) {
19
+ console.error("No siteKey found");
20
+ return;
26
21
  }
27
- const invisibleButtons = Array.from(document.getElementsByClassName("procaptcha")).filter((button) => button.tagName.toLowerCase() === "button");
28
- if (invisibleButtons.length) {
29
- for (const button of invisibleButtons) {
30
- const siteKey = button.getAttribute("data-sitekey") || "";
31
- const callback = button.getAttribute("data-callback") || "";
32
- const captchaType = getCaptchaType([button]);
33
- const root = await widgetFactory.createWidgets([button], {
34
- captchaType: captchaType,
35
- siteKey: siteKey,
36
- callback: callback,
37
- }, true, true);
38
- procaptchaRoots.push(...root);
39
- button.addEventListener("click", async (event) => {
40
- event.preventDefault();
41
- execute();
42
- });
43
- }
22
+ const captchaType = getCaptchaType(elements);
23
+ const root = await widgetFactory.createWidgets(
24
+ elements,
25
+ {
26
+ captchaType,
27
+ siteKey
28
+ },
29
+ !(web3 === "true")
30
+ );
31
+ procaptchaRoots.push(...root);
32
+ }
33
+ const invisibleButtons = Array.from(
34
+ document.getElementsByClassName("procaptcha")
35
+ ).filter((button) => button.tagName.toLowerCase() === "button");
36
+ if (invisibleButtons.length) {
37
+ for (const button of invisibleButtons) {
38
+ const siteKey = button.getAttribute("data-sitekey") || "";
39
+ const callback = button.getAttribute("data-callback") || "";
40
+ const captchaType = getCaptchaType([button]);
41
+ const root = await widgetFactory.createWidgets(
42
+ [button],
43
+ {
44
+ captchaType,
45
+ siteKey,
46
+ callback
47
+ },
48
+ true,
49
+ true
50
+ );
51
+ procaptchaRoots.push(...root);
52
+ button.addEventListener("click", async (event) => {
53
+ event.preventDefault();
54
+ execute();
55
+ });
44
56
  }
57
+ }
45
58
  };
46
- export const render = async (element, renderOptions) => {
47
- const hasInvisibleSize = Object.prototype.hasOwnProperty.call(renderOptions, "size") &&
48
- renderOptions.size === "invisible";
49
- const isWeb2 = !renderOptions.web3;
50
- if (hasInvisibleSize || element.tagName.toLowerCase() === "button") {
51
- const roots = await widgetFactory.createWidgets([element], renderOptions, isWeb2, true);
52
- procaptchaRoots.push(...roots);
53
- return;
54
- }
55
- const roots = await widgetFactory.createWidgets([element], renderOptions, isWeb2, false);
56
- procaptchaRoots.push(...roots);
59
+ const render = async (element, renderOptions) => {
60
+ const hasInvisibleSize = Object.prototype.hasOwnProperty.call(renderOptions, "size") && renderOptions.size === "invisible";
61
+ const isWeb2 = !renderOptions.web3;
62
+ if (hasInvisibleSize || element.tagName.toLowerCase() === "button") {
63
+ const roots2 = await widgetFactory.createWidgets(
64
+ [element],
65
+ renderOptions,
66
+ isWeb2,
67
+ true
68
+ );
69
+ procaptchaRoots.push(...roots2);
70
+ return;
71
+ }
72
+ const roots = await widgetFactory.createWidgets(
73
+ [element],
74
+ renderOptions,
75
+ isWeb2,
76
+ false
77
+ );
78
+ procaptchaRoots.push(...roots);
57
79
  };
58
- export default function ready(fn) {
59
- if (document && document.readyState !== "loading") {
60
- console.log("document.readyState ready!");
61
- fn();
62
- }
63
- else {
64
- console.log("DOMContentLoaded listener!");
65
- document.addEventListener("DOMContentLoaded", () => {
66
- console.log("DOMContentLoaded fired");
67
- console.log(window);
68
- fn();
69
- });
70
- }
71
- }
72
- export const execute = () => {
73
- const containers = findProcaptchaContainers();
74
- if (containers.length === 0) {
75
- console.error("No Procaptcha containers found for execution");
76
- return;
77
- }
78
- const executeEvent = new CustomEvent(PROCAPTCHA_EXECUTE_EVENT, {
79
- detail: {
80
- containerId: containers[0]?.id || "procaptcha-container",
81
- containerCount: containers.length,
82
- timestamp: Date.now(),
83
- },
84
- bubbles: true,
85
- cancelable: true,
80
+ function ready(fn) {
81
+ if (document && document.readyState !== "loading") {
82
+ console.log("document.readyState ready!");
83
+ fn();
84
+ } else {
85
+ console.log("DOMContentLoaded listener!");
86
+ document.addEventListener("DOMContentLoaded", () => {
87
+ console.log("DOMContentLoaded fired");
88
+ console.log(window);
89
+ fn();
86
90
  });
87
- document.dispatchEvent(executeEvent);
91
+ }
92
+ }
93
+ const execute = () => {
94
+ const containers = findProcaptchaContainers();
95
+ if (containers.length === 0) {
96
+ console.error("No Procaptcha containers found for execution");
97
+ return;
98
+ }
99
+ const executeEvent = new CustomEvent(PROCAPTCHA_EXECUTE_EVENT, {
100
+ detail: {
101
+ containerId: containers[0]?.id || "procaptcha-container",
102
+ containerCount: containers.length,
103
+ timestamp: Date.now()
104
+ },
105
+ bubbles: true,
106
+ cancelable: true
107
+ });
108
+ document.dispatchEvent(executeEvent);
88
109
  };
89
110
  function findProcaptchaContainers() {
90
- const containers = [];
91
- const invisibleContainers = Array.from(document.querySelectorAll('[data-size="invisible"]'));
92
- containers.push(...invisibleContainers);
93
- const idContainers = Array.from(document.querySelectorAll('#procaptcha-container, [id$="-procaptcha-container"]'));
94
- const classContainers = Array.from(document.getElementsByClassName("p-procaptcha"));
95
- containers.push(...classContainers);
96
- for (const container of idContainers) {
97
- if (!containers.includes(container)) {
98
- containers.push(container);
99
- }
111
+ const containers = [];
112
+ const invisibleContainers = Array.from(
113
+ document.querySelectorAll('[data-size="invisible"]')
114
+ );
115
+ containers.push(...invisibleContainers);
116
+ const idContainers = Array.from(
117
+ document.querySelectorAll(
118
+ '#procaptcha-container, [id$="-procaptcha-container"]'
119
+ )
120
+ );
121
+ const classContainers = Array.from(
122
+ document.getElementsByClassName("p-procaptcha")
123
+ );
124
+ containers.push(...classContainers);
125
+ for (const container of idContainers) {
126
+ if (!containers.includes(container)) {
127
+ containers.push(container);
100
128
  }
101
- return containers;
129
+ }
130
+ return containers;
102
131
  }
103
132
  const start = () => {
104
- const { onloadUrlCallback, renderExplicit } = extractParams(BUNDLE_NAME);
105
- let readyCalled = false;
106
- if (renderExplicit !== "explicit") {
107
- getProcaptchaScript(BUNDLE_NAME)?.addEventListener("load", () => {
108
- ready(implicitRender);
109
- readyCalled = true;
110
- });
111
- if (document.readyState === "complete" && !readyCalled) {
112
- ready(implicitRender);
113
- }
133
+ const { onloadUrlCallback, renderExplicit } = extractParams(BUNDLE_NAME);
134
+ let readyCalled = false;
135
+ if (renderExplicit !== "explicit") {
136
+ getProcaptchaScript(BUNDLE_NAME)?.addEventListener("load", () => {
137
+ ready(implicitRender);
138
+ readyCalled = true;
139
+ });
140
+ if (document.readyState === "complete" && !readyCalled) {
141
+ ready(implicitRender);
114
142
  }
115
- if (onloadUrlCallback) {
116
- getProcaptchaScript(BUNDLE_NAME)?.addEventListener("load", () => {
117
- const onloadCallback = getWindowCallback(onloadUrlCallback);
118
- ready(onloadCallback);
119
- });
120
- if (document.readyState === "complete" && !readyCalled) {
121
- const onloadCallback = getWindowCallback(onloadUrlCallback);
122
- ready(onloadCallback);
123
- }
143
+ }
144
+ if (onloadUrlCallback) {
145
+ getProcaptchaScript(BUNDLE_NAME)?.addEventListener("load", () => {
146
+ const onloadCallback = getWindowCallback(onloadUrlCallback);
147
+ ready(onloadCallback);
148
+ });
149
+ if (document.readyState === "complete" && !readyCalled) {
150
+ const onloadCallback = getWindowCallback(onloadUrlCallback);
151
+ ready(onloadCallback);
124
152
  }
153
+ }
125
154
  };
126
- export const reset = () => {
127
- for (const root of procaptchaRoots) {
128
- root.unmount();
129
- }
130
- procaptchaRoots = [];
131
- start();
155
+ const reset = () => {
156
+ for (const root of procaptchaRoots) {
157
+ root.unmount();
158
+ }
159
+ procaptchaRoots = [];
160
+ start();
132
161
  };
133
162
  window.procaptcha = { ready, render, reset, execute };
134
163
  start();
135
- //# sourceMappingURL=index.js.map
164
+ export {
165
+ ready as default,
166
+ execute,
167
+ render,
168
+ reset
169
+ };
@@ -1,15 +1,23 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import { CaptchaType } from "@prosopo/types";
3
3
  import { captchaComponentsList } from "./captchaComponentsList.js";
4
4
  class CaptchaComponentProvider {
5
- getCaptchaComponent(captchaType, captchaProps) {
6
- if (captchaType === CaptchaType.invisible) {
7
- throw new Error("Not Implemented");
8
- }
9
- const CaptchaComponent = captchaComponentsList[captchaType];
10
- console.log(`rendering ${captchaType}`);
11
- return (_jsx(CaptchaComponent, { config: captchaProps.config, callbacks: captchaProps.callbacks, i18n: captchaProps.i18n }));
5
+ getCaptchaComponent(captchaType, captchaProps) {
6
+ if (captchaType === CaptchaType.invisible) {
7
+ throw new Error("Not Implemented");
12
8
  }
9
+ const CaptchaComponent = captchaComponentsList[captchaType];
10
+ console.log(`rendering ${captchaType}`);
11
+ return /* @__PURE__ */ jsx(
12
+ CaptchaComponent,
13
+ {
14
+ config: captchaProps.config,
15
+ callbacks: captchaProps.callbacks,
16
+ i18n: captchaProps.i18n
17
+ }
18
+ );
19
+ }
13
20
  }
14
- export { CaptchaComponentProvider };
15
- //# sourceMappingURL=captchaComponentProvider.js.map
21
+ export {
22
+ CaptchaComponentProvider
23
+ };
@@ -3,9 +3,10 @@ import { FrictionlessCaptcha } from "./components/frictionlessCaptcha.js";
3
3
  import { ImageCaptcha } from "./components/imageCaptcha.js";
4
4
  import { PowCaptcha } from "./components/powCaptcha.js";
5
5
  const captchaComponentsList = {
6
- [CaptchaType.image]: ImageCaptcha,
7
- [CaptchaType.pow]: PowCaptcha,
8
- [CaptchaType.frictionless]: FrictionlessCaptcha,
6
+ [CaptchaType.image]: ImageCaptcha,
7
+ [CaptchaType.pow]: PowCaptcha,
8
+ [CaptchaType.frictionless]: FrictionlessCaptcha
9
+ };
10
+ export {
11
+ captchaComponentsList
9
12
  };
10
- export { captchaComponentsList };
11
- //# sourceMappingURL=captchaComponentsList.js.map
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import createCache from "@emotion/cache";
3
3
  import { CacheProvider } from "@emotion/react";
4
4
  import { createRoot } from "react-dom/client";
@@ -6,43 +6,61 @@ import { createConfig } from "../configCreator.js";
6
6
  import { setLanguage } from "../language.js";
7
7
  import { setValidChallengeLength } from "../timeout.js";
8
8
  class CaptchaRenderer {
9
- constructor(captchaComponentProvider) {
10
- this.captchaComponentProvider = captchaComponentProvider;
11
- }
12
- renderCaptcha(settings, container, renderOptions, callbacks, isWeb2, i18n, invisible = false) {
13
- const captchaType = renderOptions?.captchaType ||
14
- settings.defaultCaptchaType;
15
- const config = createConfig(renderOptions.siteKey, renderOptions.theme, renderOptions.language, isWeb2, invisible, renderOptions.userAccountAddress);
16
- this.readAndValidateSettings(container, config, renderOptions);
17
- const reactRoot = this.createReactRoot(container, settings.identifierPrefix);
18
- const emotionCache = this.makeEmotionCache(settings.emotionCacheKey, container);
19
- const captchaComponent = this.captchaComponentProvider.getCaptchaComponent(captchaType, {
20
- config: config,
21
- i18n: i18n,
22
- callbacks,
23
- });
24
- this.renderCaptchaComponent(reactRoot, emotionCache, captchaComponent);
25
- return reactRoot;
26
- }
27
- readAndValidateSettings(element, config, renderOptions) {
28
- setValidChallengeLength(renderOptions, element, config);
29
- setLanguage(renderOptions, element, config);
30
- }
31
- makeEmotionCache(cacheKey, container) {
32
- return createCache({
33
- key: cacheKey,
34
- prepend: true,
35
- container: container,
36
- });
37
- }
38
- createReactRoot(container, identifierPrefix) {
39
- return createRoot(container, {
40
- identifierPrefix: identifierPrefix,
41
- });
42
- }
43
- renderCaptchaComponent(reactRoot, emotionCache, captchaComponent) {
44
- reactRoot.render(_jsx(CacheProvider, { value: emotionCache, children: captchaComponent }));
45
- }
9
+ constructor(captchaComponentProvider) {
10
+ this.captchaComponentProvider = captchaComponentProvider;
11
+ }
12
+ renderCaptcha(settings, container, renderOptions, callbacks, isWeb2, i18n, invisible = false) {
13
+ const captchaType = renderOptions?.captchaType || settings.defaultCaptchaType;
14
+ const config = createConfig(
15
+ renderOptions.siteKey,
16
+ renderOptions.theme,
17
+ renderOptions.language,
18
+ isWeb2,
19
+ invisible,
20
+ renderOptions.userAccountAddress
21
+ );
22
+ this.readAndValidateSettings(container, config, renderOptions);
23
+ const reactRoot = this.createReactRoot(
24
+ container,
25
+ settings.identifierPrefix
26
+ );
27
+ const emotionCache = this.makeEmotionCache(
28
+ settings.emotionCacheKey,
29
+ container
30
+ );
31
+ const captchaComponent = this.captchaComponentProvider.getCaptchaComponent(
32
+ captchaType,
33
+ {
34
+ config,
35
+ i18n,
36
+ callbacks
37
+ }
38
+ );
39
+ this.renderCaptchaComponent(reactRoot, emotionCache, captchaComponent);
40
+ return reactRoot;
41
+ }
42
+ readAndValidateSettings(element, config, renderOptions) {
43
+ setValidChallengeLength(renderOptions, element, config);
44
+ setLanguage(renderOptions, element, config);
45
+ }
46
+ makeEmotionCache(cacheKey, container) {
47
+ return createCache({
48
+ key: cacheKey,
49
+ prepend: true,
50
+ container
51
+ });
52
+ }
53
+ createReactRoot(container, identifierPrefix) {
54
+ return createRoot(container, {
55
+ identifierPrefix
56
+ });
57
+ }
58
+ renderCaptchaComponent(reactRoot, emotionCache, captchaComponent) {
59
+ reactRoot.render(
60
+ /* @__PURE__ */ jsx(CacheProvider, { value: emotionCache, children: captchaComponent })
61
+ );
62
+ }
46
63
  }
47
- export { CaptchaRenderer };
48
- //# sourceMappingURL=captchaRenderer.js.map
64
+ export {
65
+ CaptchaRenderer
66
+ };
@@ -1,8 +1,12 @@
1
1
  import { CaptchaType } from "@prosopo/types";
2
2
  import { at } from "@prosopo/util";
3
- export function getCaptchaType(elements) {
4
- const features = Object.values(CaptchaType);
5
- const captchaType = features.find((feature) => feature === at(elements, 0).getAttribute("data-captcha-type")) || "frictionless";
6
- return captchaType;
3
+ function getCaptchaType(elements) {
4
+ const features = Object.values(CaptchaType);
5
+ const captchaType = features.find(
6
+ (feature) => feature === at(elements, 0).getAttribute("data-captcha-type")
7
+ ) || "frictionless";
8
+ return captchaType;
7
9
  }
8
- //# sourceMappingURL=captchaType.js.map
10
+ export {
11
+ getCaptchaType
12
+ };
@@ -1,14 +1,24 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import { getDefaultEvents } from "@prosopo/procaptcha-common";
3
3
  import { ProcaptchaFrictionless } from "@prosopo/procaptcha-frictionless";
4
4
  import { useState } from "react";
5
5
  const FrictionlessCaptcha = (props) => {
6
- const { config, callbacks, i18n } = props;
7
- const [componentKey, setComponentKey] = useState(0);
8
- const restart = () => {
9
- setComponentKey((prevKey) => prevKey + 1);
10
- };
11
- return (_jsx(ProcaptchaFrictionless, { config: config, callbacks: getDefaultEvents(callbacks), restart: restart, i18n: i18n }, componentKey));
6
+ const { config, callbacks, i18n } = props;
7
+ const [componentKey, setComponentKey] = useState(0);
8
+ const restart = () => {
9
+ setComponentKey((prevKey) => prevKey + 1);
10
+ };
11
+ return /* @__PURE__ */ jsx(
12
+ ProcaptchaFrictionless,
13
+ {
14
+ config,
15
+ callbacks: getDefaultEvents(callbacks),
16
+ restart,
17
+ i18n
18
+ },
19
+ componentKey
20
+ );
21
+ };
22
+ export {
23
+ FrictionlessCaptcha
12
24
  };
13
- export { FrictionlessCaptcha };
14
- //# sourceMappingURL=frictionlessCaptcha.js.map
@@ -1,9 +1,17 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import { getDefaultEvents } from "@prosopo/procaptcha-common";
3
3
  import { Procaptcha } from "@prosopo/procaptcha-react";
4
4
  const ImageCaptcha = (props) => {
5
- const { config, callbacks, i18n } = props;
6
- return (_jsx(Procaptcha, { config: config, callbacks: getDefaultEvents(callbacks), i18n: i18n }));
5
+ const { config, callbacks, i18n } = props;
6
+ return /* @__PURE__ */ jsx(
7
+ Procaptcha,
8
+ {
9
+ config,
10
+ callbacks: getDefaultEvents(callbacks),
11
+ i18n
12
+ }
13
+ );
14
+ };
15
+ export {
16
+ ImageCaptcha
7
17
  };
8
- export { ImageCaptcha };
9
- //# sourceMappingURL=imageCaptcha.js.map
@@ -1,9 +1,17 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx } from "react/jsx-runtime";
2
2
  import { getDefaultEvents } from "@prosopo/procaptcha-common";
3
3
  import { ProcaptchaPow } from "@prosopo/procaptcha-pow";
4
4
  const PowCaptcha = (props) => {
5
- const { config, callbacks, i18n } = props;
6
- return (_jsx(ProcaptchaPow, { config: config, callbacks: getDefaultEvents(callbacks), i18n: i18n }));
5
+ const { config, callbacks, i18n } = props;
6
+ return /* @__PURE__ */ jsx(
7
+ ProcaptchaPow,
8
+ {
9
+ config,
10
+ callbacks: getDefaultEvents(callbacks),
11
+ i18n
12
+ }
13
+ );
14
+ };
15
+ export {
16
+ PowCaptcha
7
17
  };
8
- export { PowCaptcha };
9
- //# sourceMappingURL=powCaptcha.js.map
@@ -1,13 +1,16 @@
1
- export const getProcaptchaScript = (name) => document.querySelector(`script[src*="${name}"]`);
2
- export const extractParams = (name) => {
3
- const script = getProcaptchaScript(name);
4
- if (script && script.src.indexOf(`${name}`) !== -1) {
5
- const params = new URLSearchParams(script.src.split("?")[1]);
6
- return {
7
- onloadUrlCallback: params.get("onload") || undefined,
8
- renderExplicit: params.get("render") || undefined,
9
- };
10
- }
11
- return { onloadUrlCallback: undefined, renderExplicit: undefined };
1
+ const getProcaptchaScript = (name) => document.querySelector(`script[src*="${name}"]`);
2
+ const extractParams = (name) => {
3
+ const script = getProcaptchaScript(name);
4
+ if (script && script.src.indexOf(`${name}`) !== -1) {
5
+ const params = new URLSearchParams(script.src.split("?")[1]);
6
+ return {
7
+ onloadUrlCallback: params.get("onload") || void 0,
8
+ renderExplicit: params.get("render") || void 0
9
+ };
10
+ }
11
+ return { onloadUrlCallback: void 0, renderExplicit: void 0 };
12
+ };
13
+ export {
14
+ extractParams,
15
+ getProcaptchaScript
12
16
  };
13
- //# sourceMappingURL=config.js.map
@@ -1,24 +1,23 @@
1
- import { EnvironmentTypesSchema, ProcaptchaConfigSchema, } from "@prosopo/types";
1
+ import { ProcaptchaConfigSchema, EnvironmentTypesSchema } from "@prosopo/types";
2
2
  function createConfig(siteKey, theme = "light", language, web2 = true, invisible = false, userAccountAddress) {
3
- if (!siteKey) {
4
- siteKey = process.env.PROSOPO_SITE_KEY || "";
5
- }
6
- return ProcaptchaConfigSchema.parse({
7
- defaultEnvironment: process.env.PROSOPO_DEFAULT_ENVIRONMENT
8
- ? EnvironmentTypesSchema.parse(process.env.PROSOPO_DEFAULT_ENVIRONMENT)
9
- : EnvironmentTypesSchema.enum.development,
10
- userAccountAddress: userAccountAddress || "",
11
- account: {
12
- address: siteKey,
13
- },
14
- serverUrl: process.env.PROSOPO_SERVER_URL || "",
15
- mongoAtlasUri: process.env.PROSOPO_MONGO_EVENTS_URI || "",
16
- devOnlyWatchEvents: process.env._DEV_ONLY_WATCH_EVENTS === "true" || false,
17
- web2,
18
- mode: invisible ? "invisible" : "visible",
19
- theme,
20
- language,
21
- });
3
+ if (!siteKey) {
4
+ siteKey = process.env.PROSOPO_SITE_KEY || "";
5
+ }
6
+ return ProcaptchaConfigSchema.parse({
7
+ defaultEnvironment: process.env.PROSOPO_DEFAULT_ENVIRONMENT ? EnvironmentTypesSchema.parse(process.env.PROSOPO_DEFAULT_ENVIRONMENT) : EnvironmentTypesSchema.enum.development,
8
+ userAccountAddress: userAccountAddress || "",
9
+ account: {
10
+ address: siteKey
11
+ },
12
+ serverUrl: process.env.PROSOPO_SERVER_URL || "",
13
+ mongoAtlasUri: process.env.PROSOPO_MONGO_EVENTS_URI || "",
14
+ devOnlyWatchEvents: process.env._DEV_ONLY_WATCH_EVENTS === "true" || false,
15
+ web2,
16
+ mode: invisible ? "invisible" : "visible",
17
+ theme,
18
+ language
19
+ });
22
20
  }
23
- export { createConfig };
24
- //# sourceMappingURL=configCreator.js.map
21
+ export {
22
+ createConfig
23
+ };
@@ -1,17 +1,18 @@
1
1
  import { LanguageSchema } from "@prosopo/locale";
2
- export const setLanguage = (renderOptions, element, config) => {
3
- const languageAttribute = renderOptions?.language || element.getAttribute("data-language");
4
- if (languageAttribute) {
5
- config.language = validateLanguage(languageAttribute);
6
- }
2
+ const setLanguage = (renderOptions, element, config) => {
3
+ const languageAttribute = renderOptions?.language || element.getAttribute("data-language");
4
+ if (languageAttribute) {
5
+ config.language = validateLanguage(languageAttribute);
6
+ }
7
7
  };
8
8
  const validateLanguage = (languageAttribute) => {
9
- try {
10
- return LanguageSchema.parse(languageAttribute);
11
- }
12
- catch (error) {
13
- console.error(`Invalid language attribute: ${languageAttribute}`);
14
- return LanguageSchema.parse("en");
15
- }
9
+ try {
10
+ return LanguageSchema.parse(languageAttribute);
11
+ } catch (error) {
12
+ console.error(`Invalid language attribute: ${languageAttribute}`);
13
+ return LanguageSchema.parse("en");
14
+ }
15
+ };
16
+ export {
17
+ setLanguage
16
18
  };
17
- //# sourceMappingURL=language.js.map