@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.
- package/CHANGELOG.md +38 -0
- package/dist/bundle/ProcaptchaWidget-48FxVPQd.js +187 -0
- package/dist/bundle/ProcaptchaWidget-B2BzhXLv.js +992 -0
- package/dist/bundle/builder-DNHtDoNG.js +44 -0
- package/dist/bundle/{captchaComponentProvider-CZppE3Vb.js → captchaComponentProvider-B7Vxx339.js} +256 -99
- package/dist/bundle/{captchaRenderer-CY8KuZK-.js → captchaRenderer-DdOlOCKw.js} +3 -3
- package/dist/bundle/{commonChunk-24zMb_mF.js → commonChunk-HCVkoCqn.js} +9 -12
- package/dist/bundle/{emotion-element-5486c51c.browser.esm-PRDDgd_k.js → emotion-element-5486c51c.browser.esm-D7qvHZDV.js} +1 -1
- package/dist/bundle/{fp.esm-BADUiinQ.js → fp.esm-DYWeNGcH.js} +648 -548
- package/dist/bundle/index-7Xh-Mf8v.js +1318 -0
- package/dist/bundle/{index-BiwZ4wVT.js → index-C00_J7av.js} +48 -12
- package/dist/bundle/{index-BzOMq-ud.js → index-DyYmvHVN.js} +1 -1
- package/dist/bundle/locales/ar/translation.json +12 -11
- package/dist/bundle/locales/az/translation.json +12 -11
- package/dist/bundle/locales/cs/translation.json +12 -11
- package/dist/bundle/locales/de/translation.json +12 -11
- package/dist/bundle/locales/el/translation.json +12 -11
- package/dist/bundle/locales/en/translation.json +4 -3
- package/dist/bundle/locales/es/translation.json +12 -11
- package/dist/bundle/locales/fi/translation.json +29 -28
- package/dist/bundle/locales/fr/translation.json +12 -11
- package/dist/bundle/locales/hi/translation.json +41 -40
- package/dist/bundle/locales/hu/translation.json +12 -11
- package/dist/bundle/locales/id/translation.json +12 -11
- package/dist/bundle/locales/it/translation.json +12 -11
- package/dist/bundle/locales/ja/translation.json +12 -11
- package/dist/bundle/locales/jv/translation.json +12 -11
- package/dist/bundle/locales/ko/translation.json +7 -6
- package/dist/bundle/locales/ml/translation.json +12 -11
- package/dist/bundle/locales/ms/translation.json +12 -11
- package/dist/bundle/locales/nl/translation.json +12 -11
- package/dist/bundle/locales/no/translation.json +12 -11
- package/dist/bundle/locales/pl/translation.json +12 -11
- package/dist/bundle/locales/pt/translation.json +12 -11
- package/dist/bundle/locales/pt-BR/translation.json +12 -11
- package/dist/bundle/locales/ro/translation.json +12 -11
- package/dist/bundle/locales/ru/translation.json +12 -11
- package/dist/bundle/locales/sr/translation.json +12 -11
- package/dist/bundle/locales/sv/translation.json +12 -11
- package/dist/bundle/locales/th/translation.json +12 -11
- package/dist/bundle/locales/tr/translation.json +7 -6
- package/dist/bundle/locales/uk/translation.json +12 -11
- package/dist/bundle/locales/vi/translation.json +12 -11
- package/dist/bundle/locales/zh-CN/translation.json +12 -11
- package/dist/bundle/nobleChunk-Qozzkbsq.js +3648 -0
- package/dist/bundle/procaptcha.bundle.js +2 -2
- package/dist/bundle/{utilCryptoChunk-CIPUtfoO.js → utilCryptoChunk-qm-BM2eT.js} +618 -647
- package/dist/bundle/{web2Chunk-7Vd8yt2r.js → web2Chunk-DCsWA5PR.js} +1150 -994
- package/dist/bundle/{web3Chunk-DrUvbVNW.js → web3Chunk-B8txCqUJ.js} +3 -3
- package/dist/index.js +142 -108
- package/dist/util/captcha/captchaComponentProvider.js +18 -10
- package/dist/util/captcha/captchaComponentsList.js +6 -5
- package/dist/util/captcha/captchaRenderer.js +58 -40
- package/dist/util/captcha/captchaType.js +9 -5
- package/dist/util/captcha/components/frictionlessCaptcha.js +19 -9
- package/dist/util/captcha/components/imageCaptcha.js +13 -5
- package/dist/util/captcha/components/powCaptcha.js +13 -5
- package/dist/util/config.js +15 -12
- package/dist/util/configCreator.js +21 -22
- package/dist/util/language.js +14 -13
- package/dist/util/timeout.js +13 -8
- package/dist/util/widgetFactory.js +77 -55
- package/dist/util/widgetThemeResolver.js +14 -17
- package/package.json +23 -20
- package/stats.html +1 -1
- package/vite.cjs.config.ts +2 -3
- package/vite.esm.config.ts +20 -0
- package/vite.test.config.ts +9 -5
- package/dist/bundle/ProcaptchaWidget-D_kzGjgO.js +0 -612
- package/dist/bundle/ProcaptchaWidget-DlrcrISF.js +0 -148
- package/dist/bundle/builder-CQlqPNRd.js +0 -37
- package/dist/bundle/index-BRg_gWPo.js +0 -1328
- package/dist/bundle/nobleChunk-Xl5XLrx3.js +0 -3635
- package/dist/components.d.ts +0 -5
- package/dist/components.d.ts.map +0 -1
- package/dist/components.js +0 -5
- package/dist/components.js.map +0 -1
- package/dist/index.d.ts +0 -16
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/tests/util/captchaType.test.d.ts +0 -2
- package/dist/tests/util/captchaType.test.d.ts.map +0 -1
- package/dist/tests/util/captchaType.test.js +0 -36
- package/dist/tests/util/captchaType.test.js.map +0 -1
- package/dist/tests/util/config.test.d.ts +0 -2
- package/dist/tests/util/config.test.d.ts.map +0 -1
- package/dist/tests/util/config.test.js +0 -69
- package/dist/tests/util/config.test.js.map +0 -1
- package/dist/tests/util/renderLogic.test.d.ts +0 -2
- package/dist/tests/util/renderLogic.test.d.ts.map +0 -1
- package/dist/tests/util/renderLogic.test.js +0 -126
- package/dist/tests/util/renderLogic.test.js.map +0 -1
- package/dist/util/captcha/captchaComponentProvider.d.ts +0 -8
- package/dist/util/captcha/captchaComponentProvider.d.ts.map +0 -1
- package/dist/util/captcha/captchaComponentProvider.js.map +0 -1
- package/dist/util/captcha/captchaComponentsList.d.ts +0 -6
- package/dist/util/captcha/captchaComponentsList.d.ts.map +0 -1
- package/dist/util/captcha/captchaComponentsList.js.map +0 -1
- package/dist/util/captcha/captchaProps.d.ts +0 -9
- package/dist/util/captcha/captchaProps.d.ts.map +0 -1
- package/dist/util/captcha/captchaProps.js +0 -2
- package/dist/util/captcha/captchaProps.js.map +0 -1
- package/dist/util/captcha/captchaRenderer.d.ts +0 -24
- package/dist/util/captcha/captchaRenderer.d.ts.map +0 -1
- package/dist/util/captcha/captchaRenderer.js.map +0 -1
- package/dist/util/captcha/captchaType.d.ts +0 -3
- package/dist/util/captcha/captchaType.d.ts.map +0 -1
- package/dist/util/captcha/captchaType.js.map +0 -1
- package/dist/util/captcha/components/frictionlessCaptcha.d.ts +0 -4
- package/dist/util/captcha/components/frictionlessCaptcha.d.ts.map +0 -1
- package/dist/util/captcha/components/frictionlessCaptcha.js.map +0 -1
- package/dist/util/captcha/components/imageCaptcha.d.ts +0 -4
- package/dist/util/captcha/components/imageCaptcha.d.ts.map +0 -1
- package/dist/util/captcha/components/imageCaptcha.js.map +0 -1
- package/dist/util/captcha/components/powCaptcha.d.ts +0 -4
- package/dist/util/captcha/components/powCaptcha.d.ts.map +0 -1
- package/dist/util/captcha/components/powCaptcha.js.map +0 -1
- package/dist/util/config.d.ts +0 -6
- package/dist/util/config.d.ts.map +0 -1
- package/dist/util/config.js.map +0 -1
- package/dist/util/configCreator.d.ts +0 -5
- package/dist/util/configCreator.d.ts.map +0 -1
- package/dist/util/configCreator.js.map +0 -1
- package/dist/util/language.d.ts +0 -3
- package/dist/util/language.d.ts.map +0 -1
- package/dist/util/language.js.map +0 -1
- package/dist/util/timeout.d.ts +0 -3
- package/dist/util/timeout.d.ts.map +0 -1
- package/dist/util/timeout.js.map +0 -1
- package/dist/util/widgetFactory.d.ts +0 -18
- package/dist/util/widgetFactory.d.ts.map +0 -1
- package/dist/util/widgetFactory.js.map +0 -1
- package/dist/util/widgetThemeResolver.d.ts +0 -9
- package/dist/util/widgetThemeResolver.d.ts.map +0 -1
- 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 {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
procaptchaRoots.push(...
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
129
|
+
}
|
|
130
|
+
return containers;
|
|
102
131
|
}
|
|
103
132
|
const start = () => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
164
|
+
export {
|
|
165
|
+
ready as default,
|
|
166
|
+
execute,
|
|
167
|
+
render,
|
|
168
|
+
reset
|
|
169
|
+
};
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import { jsx
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 {
|
|
15
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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 {
|
|
48
|
-
|
|
64
|
+
export {
|
|
65
|
+
CaptchaRenderer
|
|
66
|
+
};
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { CaptchaType } from "@prosopo/types";
|
|
2
2
|
import { at } from "@prosopo/util";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
10
|
+
export {
|
|
11
|
+
getCaptchaType
|
|
12
|
+
};
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import { jsx
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
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
|
-
|
|
6
|
-
|
|
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
|
|
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
|
-
|
|
6
|
-
|
|
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
|
package/dist/util/config.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 {
|
|
1
|
+
import { ProcaptchaConfigSchema, EnvironmentTypesSchema } from "@prosopo/types";
|
|
2
2
|
function createConfig(siteKey, theme = "light", language, web2 = true, invisible = false, userAccountAddress) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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 {
|
|
24
|
-
|
|
21
|
+
export {
|
|
22
|
+
createConfig
|
|
23
|
+
};
|
package/dist/util/language.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { LanguageSchema } from "@prosopo/locale";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|