@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/dist/index.js CHANGED
@@ -1,182 +1,138 @@
1
- import { getWindowCallback } from "@prosopo/procaptcha-common";
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
- const BUNDLE_NAMES = ["procaptcha.bundle.iife.js", "procaptcha.bundle.js"];
7
- let procaptchaRoots = [];
8
- const widgetFactory = new WidgetFactory(new WidgetThemeResolver());
9
- const PROCAPTCHA_EXECUTE_EVENT = "procaptcha:execute";
10
- const PROCAPTCHA_READY_EVENT = "procaptcha:ready";
11
- const implicitRender = async () => {
12
- const elements = Array.from(
13
- document.getElementsByClassName("procaptcha")
14
- ).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(
26
- elements,
27
- {
28
- siteKey,
29
- ipv4,
30
- ipv6
31
- },
32
- !(web3 === "true")
33
- );
34
- procaptchaRoots.push(...root);
35
- }
36
- const invisibleButtons = Array.from(
37
- document.getElementsByClassName("procaptcha")
38
- ).filter((button) => button.tagName.toLowerCase() === "button");
39
- if (invisibleButtons.length) {
40
- for (const button of invisibleButtons) {
41
- const siteKey = button.getAttribute("data-sitekey") || "";
42
- const callback = button.getAttribute("data-callback") || "";
43
- const ipv4 = button.getAttribute("data-ipv4") === "true";
44
- const ipv6 = button.getAttribute("data-ipv6") === "true";
45
- const root = await widgetFactory.createWidgets(
46
- [button],
47
- {
48
- siteKey,
49
- callback,
50
- ipv4,
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
- const render = async (element, renderOptions) => {
65
- const hasInvisibleSize = Object.prototype.hasOwnProperty.call(renderOptions, "size") && renderOptions.size === "invisible";
66
- const isWeb2 = !renderOptions.web3;
67
- if (hasInvisibleSize || element.tagName.toLowerCase() === "button") {
68
- const roots2 = await widgetFactory.createWidgets(
69
- [element],
70
- renderOptions,
71
- isWeb2,
72
- true
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
- if (document && document.readyState !== "loading") {
87
- console.log("document.readyState ready!");
88
- fn();
89
- } else {
90
- console.log("DOMContentLoaded listener!");
91
- document.addEventListener("DOMContentLoaded", () => {
92
- console.log("DOMContentLoaded fired");
93
- console.log(window);
94
- fn();
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
- const execute = () => {
99
- const containers = findProcaptchaContainers();
100
- if (containers.length === 0) {
101
- console.error("No Procaptcha containers found for execution");
102
- return;
103
- }
104
- const executeEvent = new CustomEvent(PROCAPTCHA_EXECUTE_EVENT, {
105
- detail: {
106
- containerId: containers[0]?.id || "procaptcha-container",
107
- containerCount: containers.length,
108
- timestamp: Date.now()
109
- },
110
- bubbles: true,
111
- cancelable: true
112
- });
113
- document.dispatchEvent(executeEvent);
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
- const containers = [];
117
- const invisibleContainers = Array.from(
118
- document.querySelectorAll('[data-size="invisible"]')
119
- );
120
- containers.push(...invisibleContainers);
121
- const idContainers = Array.from(
122
- document.querySelectorAll(
123
- '#procaptcha-container, [id$="-procaptcha-container"]'
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
- const start = () => {
138
- const { onloadUrlCallback, renderExplicit } = extractParams(BUNDLE_NAMES);
139
- let readyCalled = false;
140
- if (renderExplicit !== "explicit") {
141
- getProcaptchaScript(BUNDLE_NAMES)?.addEventListener("load", () => {
142
- ready(implicitRender);
143
- readyCalled = true;
144
- });
145
- if (document.readyState === "complete" && !readyCalled) {
146
- ready(implicitRender);
147
- }
148
- }
149
- if (onloadUrlCallback) {
150
- getProcaptchaScript(BUNDLE_NAMES)?.addEventListener("load", () => {
151
- const onloadCallback = getWindowCallback(onloadUrlCallback);
152
- ready(onloadCallback);
153
- });
154
- if (document.readyState === "complete" && !readyCalled) {
155
- const onloadCallback = getWindowCallback(onloadUrlCallback);
156
- ready(onloadCallback);
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
- const reset = () => {
161
- for (const root of procaptchaRoots) {
162
- root.unmount();
163
- }
164
- procaptchaRoots = [];
165
- start();
124
+ window.procaptcha = {
125
+ ready,
126
+ render,
127
+ reset,
128
+ execute
166
129
  };
167
- window.procaptcha = { ready, render, reset, execute };
168
- const procaptchaReadyEvent = new CustomEvent(PROCAPTCHA_READY_EVENT, {
169
- detail: {
170
- timestamp: Date.now()
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
- export {
178
- ready as default,
179
- execute,
180
- render,
181
- reset
182
- };
137
+ //#endregion
138
+ export { ready as default, execute, render, reset };
@@ -1,70 +1,48 @@
1
- import { jsx } from "react/jsx-runtime";
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
- class CaptchaRenderer {
10
- renderCaptcha(settings, container, renderOptions, callbacks, isWeb2, i18n, invisible, widgetContainer, sourceElement) {
11
- const config = createConfig(
12
- renderOptions.siteKey,
13
- renderOptions.theme,
14
- renderOptions.language,
15
- isWeb2,
16
- invisible,
17
- renderOptions.userAccountAddress,
18
- renderOptions.ipv4,
19
- renderOptions.ipv6
20
- );
21
- this.readAndValidateSettings(
22
- sourceElement || container,
23
- config,
24
- renderOptions
25
- );
26
- const reactRoot = this.createReactRoot(
27
- container,
28
- settings.identifierPrefix
29
- );
30
- const emotionCache = this.makeEmotionCache(
31
- settings.emotionCacheKey,
32
- container
33
- );
34
- const captchaComponent = /* @__PURE__ */ jsx(
35
- BundleCaptcha,
36
- {
37
- config,
38
- callbacks,
39
- i18n,
40
- container: widgetContainer
41
- }
42
- );
43
- this.renderCaptchaComponent(reactRoot, emotionCache, captchaComponent);
44
- return reactRoot;
45
- }
46
- readAndValidateSettings(element, config, renderOptions) {
47
- setValidChallengeLength(renderOptions, element, config);
48
- setLanguage(renderOptions, element, config);
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
- const BundleCaptcha = (props) => {
6
- const { config, callbacks, i18n, container } = 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
- container
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 };
@@ -1,26 +1,24 @@
1
- const getProcaptchaScript = (names) => {
2
- for (const name of names) {
3
- const script = document.querySelector(
4
- `script[src*="${name}"]`
5
- );
6
- if (script) {
7
- return script;
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
- const extractParams = (names) => {
13
- const script = getProcaptchaScript(names);
14
- if (script) {
15
- const params = new URLSearchParams(script.src.split("?")[1]);
16
- return {
17
- onloadUrlCallback: params.get("onload") || void 0,
18
- renderExplicit: params.get("render") || void 0
19
- };
20
- }
21
- return { onloadUrlCallback: void 0, renderExplicit: void 0 };
22
- };
23
- export {
24
- extractParams,
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 { ProcaptchaConfigSchema, EnvironmentTypesSchema } from "@prosopo/types";
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
- 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
- web2,
15
- mode: invisible ? "invisible" : "visible",
16
- theme,
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
- export {
23
- createConfig
24
- };
19
+ //#endregion
20
+ export { createConfig };
@@ -1,26 +1,33 @@
1
1
  import { LanguageSchema } from "@prosopo/locale";
2
- const setLanguage = (renderOptions, element, config) => {
3
- const resolved = resolveLanguage(renderOptions, element);
4
- if (resolved) {
5
- config.language = resolved;
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
- const resolveLanguage = (renderOptions, element) => {
9
- const languageAttribute = renderOptions?.language || element.getAttribute("data-language");
10
- if (!languageAttribute) {
11
- return void 0;
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
- const validateLanguage = (languageAttribute) => {
16
- try {
17
- return LanguageSchema.parse(languageAttribute);
18
- } catch (error) {
19
- console.error(`Invalid language attribute: ${languageAttribute}`);
20
- return LanguageSchema.parse("en");
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 };
@@ -1,14 +1,17 @@
1
- const setValidChallengeLength = (renderOptions, element, config) => {
2
- const challengeValidLengthAttribute = renderOptions?.["challenge-valid-length"] || element.getAttribute("data-challenge-valid-length");
3
- if (challengeValidLengthAttribute) {
4
- config.captchas.image.solutionTimeout = Number.parseInt(
5
- challengeValidLengthAttribute
6
- );
7
- config.captchas.pow.solutionTimeout = Number.parseInt(
8
- challengeValidLengthAttribute
9
- );
10
- }
11
- };
12
- export {
13
- setValidChallengeLength
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 };