@prosopo/procaptcha-bundle 4.1.40 → 4.1.41
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/.turbo/turbo-build$colon$cjs.log +20 -16
- package/.turbo/turbo-build$colon$tsc.log +27 -27
- package/.turbo/turbo-build.log +19 -16
- package/CHANGELOG.md +19 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/cjs/index.cjs +128 -166
- package/dist/cjs/util/captcha/captchaRenderer.cjs +48 -69
- package/dist/cjs/util/captcha/components/bundleCaptcha.cjs +19 -23
- package/dist/cjs/util/config.cjs +21 -22
- package/dist/cjs/util/configCreator.cjs +17 -21
- package/dist/cjs/util/language.cjs +29 -21
- package/dist/cjs/util/timeout.cjs +15 -12
- package/dist/cjs/util/widgetFactory.cjs +56 -90
- package/dist/cjs/util/widgetThemeResolver.cjs +15 -15
- package/dist/index.js +123 -167
- package/dist/util/captcha/captchaRenderer.js +44 -66
- package/dist/util/captcha/components/bundleCaptcha.js +17 -21
- package/dist/util/config.js +22 -24
- package/dist/util/configCreator.js +18 -22
- package/dist/util/language.js +29 -22
- package/dist/util/timeout.js +16 -13
- package/dist/util/widgetFactory.js +55 -89
- package/dist/util/widgetThemeResolver.js +15 -15
- package/package.json +11 -11
- package/tsconfig.tsbuildinfo +1 -1
package/dist/index.js
CHANGED
|
@@ -1,182 +1,138 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { at } from "@prosopo/util";
|
|
1
|
+
import "./_virtual/_rolldown/runtime.js";
|
|
3
2
|
import { extractParams, getProcaptchaScript } from "./util/config.js";
|
|
4
3
|
import { WidgetFactory } from "./util/widgetFactory.js";
|
|
5
4
|
import { WidgetThemeResolver } from "./util/widgetThemeResolver.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
ipv6
|
|
52
|
-
},
|
|
53
|
-
true,
|
|
54
|
-
true
|
|
55
|
-
);
|
|
56
|
-
procaptchaRoots.push(...root);
|
|
57
|
-
button.addEventListener("click", async (event) => {
|
|
58
|
-
event.preventDefault();
|
|
59
|
-
execute();
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
}
|
|
5
|
+
import { getWindowCallback } from "@prosopo/procaptcha-common";
|
|
6
|
+
import { at } from "@prosopo/util";
|
|
7
|
+
//#region src/index.ts
|
|
8
|
+
var BUNDLE_NAMES = ["procaptcha.bundle.iife.js", "procaptcha.bundle.js"];
|
|
9
|
+
var procaptchaRoots = [];
|
|
10
|
+
var widgetFactory = new WidgetFactory(new WidgetThemeResolver());
|
|
11
|
+
var PROCAPTCHA_EXECUTE_EVENT = "procaptcha:execute";
|
|
12
|
+
var PROCAPTCHA_READY_EVENT = "procaptcha:ready";
|
|
13
|
+
var implicitRender = async () => {
|
|
14
|
+
const elements = Array.from(document.getElementsByClassName("procaptcha")).filter((element) => element.tagName.toLowerCase() !== "button");
|
|
15
|
+
if (elements.length) {
|
|
16
|
+
const firstElement = at(elements, 0);
|
|
17
|
+
const siteKey = firstElement.getAttribute("data-sitekey");
|
|
18
|
+
const web3 = firstElement.getAttribute("data-web3");
|
|
19
|
+
const ipv4 = firstElement.getAttribute("data-ipv4") === "true";
|
|
20
|
+
const ipv6 = firstElement.getAttribute("data-ipv6") === "true";
|
|
21
|
+
if (!siteKey) {
|
|
22
|
+
console.error("No site key found");
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const root = await widgetFactory.createWidgets(elements, {
|
|
26
|
+
siteKey,
|
|
27
|
+
ipv4,
|
|
28
|
+
ipv6
|
|
29
|
+
}, !(web3 === "true"));
|
|
30
|
+
procaptchaRoots.push(...root);
|
|
31
|
+
}
|
|
32
|
+
const invisibleButtons = Array.from(document.getElementsByClassName("procaptcha")).filter((button) => button.tagName.toLowerCase() === "button");
|
|
33
|
+
if (invisibleButtons.length) for (const button of invisibleButtons) {
|
|
34
|
+
const siteKey = button.getAttribute("data-sitekey") || "";
|
|
35
|
+
const callback = button.getAttribute("data-callback") || "";
|
|
36
|
+
const ipv4 = button.getAttribute("data-ipv4") === "true";
|
|
37
|
+
const ipv6 = button.getAttribute("data-ipv6") === "true";
|
|
38
|
+
const root = await widgetFactory.createWidgets([button], {
|
|
39
|
+
siteKey,
|
|
40
|
+
callback,
|
|
41
|
+
ipv4,
|
|
42
|
+
ipv6
|
|
43
|
+
}, true, true);
|
|
44
|
+
procaptchaRoots.push(...root);
|
|
45
|
+
button.addEventListener("click", async (event) => {
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
execute();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
63
50
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
procaptchaRoots.push(...roots2);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
const roots = await widgetFactory.createWidgets(
|
|
78
|
-
[element],
|
|
79
|
-
renderOptions,
|
|
80
|
-
isWeb2,
|
|
81
|
-
false
|
|
82
|
-
);
|
|
83
|
-
procaptchaRoots.push(...roots);
|
|
51
|
+
var render = async (element, renderOptions) => {
|
|
52
|
+
const hasInvisibleSize = Object.prototype.hasOwnProperty.call(renderOptions, "size") && renderOptions.size === "invisible";
|
|
53
|
+
const isWeb2 = !renderOptions.web3;
|
|
54
|
+
if (hasInvisibleSize || element.tagName.toLowerCase() === "button") {
|
|
55
|
+
const roots = await widgetFactory.createWidgets([element], renderOptions, isWeb2, true);
|
|
56
|
+
procaptchaRoots.push(...roots);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const roots = await widgetFactory.createWidgets([element], renderOptions, isWeb2, false);
|
|
60
|
+
procaptchaRoots.push(...roots);
|
|
84
61
|
};
|
|
85
62
|
function ready(fn) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
63
|
+
if (document && document.readyState !== "loading") {
|
|
64
|
+
console.log("document.readyState ready!");
|
|
65
|
+
fn();
|
|
66
|
+
} else {
|
|
67
|
+
console.log("DOMContentLoaded listener!");
|
|
68
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
69
|
+
console.log("DOMContentLoaded fired");
|
|
70
|
+
console.log(window);
|
|
71
|
+
fn();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
97
74
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
75
|
+
var execute = () => {
|
|
76
|
+
const containers = findProcaptchaContainers();
|
|
77
|
+
if (containers.length === 0) {
|
|
78
|
+
console.error("No Procaptcha containers found for execution");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const executeEvent = new CustomEvent(PROCAPTCHA_EXECUTE_EVENT, {
|
|
82
|
+
detail: {
|
|
83
|
+
containerId: containers[0]?.id || "procaptcha-container",
|
|
84
|
+
containerCount: containers.length,
|
|
85
|
+
timestamp: Date.now()
|
|
86
|
+
},
|
|
87
|
+
bubbles: true,
|
|
88
|
+
cancelable: true
|
|
89
|
+
});
|
|
90
|
+
document.dispatchEvent(executeEvent);
|
|
114
91
|
};
|
|
115
92
|
function findProcaptchaContainers() {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
)
|
|
125
|
-
);
|
|
126
|
-
const classContainers = Array.from(
|
|
127
|
-
document.getElementsByClassName("p-procaptcha")
|
|
128
|
-
);
|
|
129
|
-
containers.push(...classContainers);
|
|
130
|
-
for (const container of idContainers) {
|
|
131
|
-
if (!containers.includes(container)) {
|
|
132
|
-
containers.push(container);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
return containers;
|
|
93
|
+
const containers = [];
|
|
94
|
+
const invisibleContainers = Array.from(document.querySelectorAll("[data-size=\"invisible\"]"));
|
|
95
|
+
containers.push(...invisibleContainers);
|
|
96
|
+
const idContainers = Array.from(document.querySelectorAll("#procaptcha-container, [id$=\"-procaptcha-container\"]"));
|
|
97
|
+
const classContainers = Array.from(document.getElementsByClassName("p-procaptcha"));
|
|
98
|
+
containers.push(...classContainers);
|
|
99
|
+
for (const container of idContainers) if (!containers.includes(container)) containers.push(container);
|
|
100
|
+
return containers;
|
|
136
101
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
102
|
+
var start = () => {
|
|
103
|
+
const { onloadUrlCallback, renderExplicit } = extractParams(BUNDLE_NAMES);
|
|
104
|
+
let readyCalled = false;
|
|
105
|
+
if (renderExplicit !== "explicit") {
|
|
106
|
+
getProcaptchaScript(BUNDLE_NAMES)?.addEventListener("load", () => {
|
|
107
|
+
ready(implicitRender);
|
|
108
|
+
readyCalled = true;
|
|
109
|
+
});
|
|
110
|
+
if (document.readyState === "complete" && !readyCalled) ready(implicitRender);
|
|
111
|
+
}
|
|
112
|
+
if (onloadUrlCallback) {
|
|
113
|
+
getProcaptchaScript(BUNDLE_NAMES)?.addEventListener("load", () => {
|
|
114
|
+
ready(getWindowCallback(onloadUrlCallback));
|
|
115
|
+
});
|
|
116
|
+
if (document.readyState === "complete" && !readyCalled) ready(getWindowCallback(onloadUrlCallback));
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
var reset = () => {
|
|
120
|
+
for (const root of procaptchaRoots) root.unmount();
|
|
121
|
+
procaptchaRoots = [];
|
|
122
|
+
start();
|
|
159
123
|
};
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
start();
|
|
124
|
+
window.procaptcha = {
|
|
125
|
+
ready,
|
|
126
|
+
render,
|
|
127
|
+
reset,
|
|
128
|
+
execute
|
|
166
129
|
};
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
},
|
|
172
|
-
bubbles: true,
|
|
173
|
-
cancelable: false
|
|
130
|
+
var procaptchaReadyEvent = new CustomEvent(PROCAPTCHA_READY_EVENT, {
|
|
131
|
+
detail: { timestamp: Date.now() },
|
|
132
|
+
bubbles: true,
|
|
133
|
+
cancelable: false
|
|
174
134
|
});
|
|
175
135
|
document.dispatchEvent(procaptchaReadyEvent);
|
|
176
136
|
start();
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
execute,
|
|
180
|
-
render,
|
|
181
|
-
reset
|
|
182
|
-
};
|
|
137
|
+
//#endregion
|
|
138
|
+
export { ready as default, execute, render, reset };
|
|
@@ -1,70 +1,48 @@
|
|
|
1
|
-
import
|
|
2
|
-
import createCache from "@emotion/cache";
|
|
3
|
-
import { CacheProvider } from "@emotion/react";
|
|
4
|
-
import { createRoot } from "react-dom/client";
|
|
5
|
-
import { createConfig } from "../configCreator.js";
|
|
1
|
+
import "../../_virtual/_rolldown/runtime.js";
|
|
6
2
|
import { setLanguage } from "../language.js";
|
|
3
|
+
import { createConfig } from "../configCreator.js";
|
|
7
4
|
import { setValidChallengeLength } from "../timeout.js";
|
|
8
5
|
import { BundleCaptcha } from "./components/bundleCaptcha.js";
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
makeEmotionCache(cacheKey, container) {
|
|
51
|
-
return createCache({
|
|
52
|
-
key: cacheKey,
|
|
53
|
-
prepend: true,
|
|
54
|
-
container
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
createReactRoot(container, identifierPrefix) {
|
|
58
|
-
return createRoot(container, {
|
|
59
|
-
identifierPrefix
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
renderCaptchaComponent(reactRoot, emotionCache, captchaComponent) {
|
|
63
|
-
reactRoot.render(
|
|
64
|
-
/* @__PURE__ */ jsx(CacheProvider, { value: emotionCache, children: captchaComponent })
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
export {
|
|
69
|
-
CaptchaRenderer
|
|
6
|
+
import createCache from "@emotion/cache";
|
|
7
|
+
import { CacheProvider } from "@emotion/react";
|
|
8
|
+
import { createRoot } from "react-dom/client";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
//#region src/util/captcha/captchaRenderer.tsx
|
|
11
|
+
var CaptchaRenderer = class {
|
|
12
|
+
renderCaptcha(settings, container, renderOptions, callbacks, isWeb2, i18n, invisible, widgetContainer, sourceElement) {
|
|
13
|
+
const config = createConfig(renderOptions.siteKey, renderOptions.theme, renderOptions.language, isWeb2, invisible, renderOptions.userAccountAddress, renderOptions.ipv4, renderOptions.ipv6);
|
|
14
|
+
this.readAndValidateSettings(sourceElement || container, config, renderOptions);
|
|
15
|
+
const reactRoot = this.createReactRoot(container, settings.identifierPrefix);
|
|
16
|
+
const emotionCache = this.makeEmotionCache(settings.emotionCacheKey, container);
|
|
17
|
+
const captchaComponent = /* @__PURE__ */ jsx(BundleCaptcha, {
|
|
18
|
+
config,
|
|
19
|
+
callbacks,
|
|
20
|
+
i18n,
|
|
21
|
+
container: widgetContainer
|
|
22
|
+
});
|
|
23
|
+
this.renderCaptchaComponent(reactRoot, emotionCache, captchaComponent);
|
|
24
|
+
return reactRoot;
|
|
25
|
+
}
|
|
26
|
+
readAndValidateSettings(element, config, renderOptions) {
|
|
27
|
+
setValidChallengeLength(renderOptions, element, config);
|
|
28
|
+
setLanguage(renderOptions, element, config);
|
|
29
|
+
}
|
|
30
|
+
makeEmotionCache(cacheKey, container) {
|
|
31
|
+
return createCache({
|
|
32
|
+
key: cacheKey,
|
|
33
|
+
prepend: true,
|
|
34
|
+
container
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
createReactRoot(container, identifierPrefix) {
|
|
38
|
+
return createRoot(container, { identifierPrefix });
|
|
39
|
+
}
|
|
40
|
+
renderCaptchaComponent(reactRoot, emotionCache, captchaComponent) {
|
|
41
|
+
reactRoot.render(/* @__PURE__ */ jsx(CacheProvider, {
|
|
42
|
+
value: emotionCache,
|
|
43
|
+
children: captchaComponent
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
70
46
|
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { CaptchaRenderer };
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
1
|
import { getDefaultEvents } from "@prosopo/procaptcha-common";
|
|
3
2
|
import { ProcaptchaFrictionless } from "@prosopo/procaptcha-frictionless";
|
|
4
3
|
import { useState } from "react";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
componentKey
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
export {
|
|
24
|
-
BundleCaptcha
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
//#region src/util/captcha/components/bundleCaptcha.tsx
|
|
6
|
+
var BundleCaptcha = (props) => {
|
|
7
|
+
const { config, callbacks, i18n, container } = props;
|
|
8
|
+
const [componentKey, setComponentKey] = useState(0);
|
|
9
|
+
const restart = () => {
|
|
10
|
+
setComponentKey((prevKey) => prevKey + 1);
|
|
11
|
+
};
|
|
12
|
+
return /* @__PURE__ */ jsx(ProcaptchaFrictionless, {
|
|
13
|
+
config,
|
|
14
|
+
callbacks: getDefaultEvents(callbacks),
|
|
15
|
+
restart,
|
|
16
|
+
i18n,
|
|
17
|
+
container
|
|
18
|
+
}, componentKey);
|
|
25
19
|
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { BundleCaptcha };
|
package/dist/util/config.js
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
return null;
|
|
1
|
+
//#region src/util/config.ts
|
|
2
|
+
var getProcaptchaScript = (names) => {
|
|
3
|
+
for (const name of names) {
|
|
4
|
+
const script = document.querySelector(`script[src*="${name}"]`);
|
|
5
|
+
if (script) return script;
|
|
6
|
+
}
|
|
7
|
+
return null;
|
|
11
8
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
getProcaptchaScript
|
|
9
|
+
var extractParams = (names) => {
|
|
10
|
+
const script = getProcaptchaScript(names);
|
|
11
|
+
if (script) {
|
|
12
|
+
const params = new URLSearchParams(script.src.split("?")[1]);
|
|
13
|
+
return {
|
|
14
|
+
onloadUrlCallback: params.get("onload") || void 0,
|
|
15
|
+
renderExplicit: params.get("render") || void 0
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
onloadUrlCallback: void 0,
|
|
20
|
+
renderExplicit: void 0
|
|
21
|
+
};
|
|
26
22
|
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { extractParams, getProcaptchaScript };
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EnvironmentTypesSchema, ProcaptchaConfigSchema } from "@prosopo/types";
|
|
2
|
+
//#region src/util/configCreator.ts
|
|
2
3
|
function createConfig(siteKey, theme = "light", language, web2 = true, invisible = false, userAccountAddress, ipv4 = false, ipv6 = false) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
language,
|
|
18
|
-
ipv4,
|
|
19
|
-
ipv6
|
|
20
|
-
});
|
|
4
|
+
if (!siteKey) siteKey = process.env.PROSOPO_SITE_KEY || "";
|
|
5
|
+
return ProcaptchaConfigSchema.parse({
|
|
6
|
+
defaultEnvironment: process.env.PROSOPO_DEFAULT_ENVIRONMENT ? EnvironmentTypesSchema.parse(process.env.PROSOPO_DEFAULT_ENVIRONMENT) : EnvironmentTypesSchema.enum.development,
|
|
7
|
+
userAccountAddress: userAccountAddress || "",
|
|
8
|
+
account: { address: siteKey },
|
|
9
|
+
serverUrl: process.env.PROSOPO_SERVER_URL || "",
|
|
10
|
+
mongoAtlasUri: process.env.PROSOPO_MONGO_EVENTS_URI || "",
|
|
11
|
+
web2,
|
|
12
|
+
mode: invisible ? "invisible" : "visible",
|
|
13
|
+
theme,
|
|
14
|
+
language,
|
|
15
|
+
ipv4,
|
|
16
|
+
ipv6
|
|
17
|
+
});
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { createConfig };
|
package/dist/util/language.js
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
import { LanguageSchema } from "@prosopo/locale";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
//#region src/util/language.ts
|
|
3
|
+
/**
|
|
4
|
+
* Prioritizes language selection from:
|
|
5
|
+
* 1. renderOptions.language
|
|
6
|
+
* 2. element's data-language attribute
|
|
7
|
+
* 3. Defaults to 'en'
|
|
8
|
+
*
|
|
9
|
+
* Validates the language against currently supported languages
|
|
10
|
+
*
|
|
11
|
+
* @param renderOptions
|
|
12
|
+
* @param element
|
|
13
|
+
* @param config
|
|
14
|
+
*/
|
|
15
|
+
var setLanguage = (renderOptions, element, config) => {
|
|
16
|
+
const resolved = resolveLanguage(renderOptions, element);
|
|
17
|
+
if (resolved) config.language = resolved;
|
|
7
18
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
return validateLanguage(languageAttribute);
|
|
19
|
+
var resolveLanguage = (renderOptions, element) => {
|
|
20
|
+
const languageAttribute = renderOptions?.language || element.getAttribute("data-language");
|
|
21
|
+
if (!languageAttribute) return;
|
|
22
|
+
return validateLanguage(languageAttribute);
|
|
14
23
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
23
|
-
export {
|
|
24
|
-
resolveLanguage,
|
|
25
|
-
setLanguage
|
|
24
|
+
var validateLanguage = (languageAttribute) => {
|
|
25
|
+
try {
|
|
26
|
+
return LanguageSchema.parse(languageAttribute);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(`Invalid language attribute: ${languageAttribute}`);
|
|
29
|
+
return LanguageSchema.parse("en");
|
|
30
|
+
}
|
|
26
31
|
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { resolveLanguage, setLanguage };
|
package/dist/util/timeout.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
//#region src/util/timeout.ts
|
|
2
|
+
/**
|
|
3
|
+
* Set the timeout for a solved captcha
|
|
4
|
+
*
|
|
5
|
+
* @param renderOptions
|
|
6
|
+
* @param element
|
|
7
|
+
* @param config
|
|
8
|
+
*/
|
|
9
|
+
var setValidChallengeLength = (renderOptions, element, config) => {
|
|
10
|
+
const challengeValidLengthAttribute = renderOptions?.["challenge-valid-length"] || element.getAttribute("data-challenge-valid-length");
|
|
11
|
+
if (challengeValidLengthAttribute) {
|
|
12
|
+
config.captchas.image.solutionTimeout = Number.parseInt(challengeValidLengthAttribute);
|
|
13
|
+
config.captchas.pow.solutionTimeout = Number.parseInt(challengeValidLengthAttribute);
|
|
14
|
+
}
|
|
14
15
|
};
|
|
16
|
+
//#endregion
|
|
17
|
+
export { setValidChallengeLength };
|