@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
|
@@ -1,91 +1,57 @@
|
|
|
1
|
-
import { loadI18next } from "@prosopo/locale";
|
|
2
|
-
import { getDefaultCallbacks, setUserCallbacks } from "@prosopo/procaptcha-common";
|
|
3
|
-
import { lightTheme, darkTheme, createWidgetSkeleton } from "@prosopo/widget-skeleton";
|
|
4
1
|
import { resolveLanguage } from "./language.js";
|
|
5
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
identifierPrefix: "procaptcha-",
|
|
59
|
-
emotionCacheKey: "procaptcha",
|
|
60
|
-
webComponentTag: "prosopo-procaptcha"
|
|
61
|
-
},
|
|
62
|
-
widgetInteractiveArea,
|
|
63
|
-
renderOptions,
|
|
64
|
-
callbacks,
|
|
65
|
-
isWeb2,
|
|
66
|
-
this.i18n,
|
|
67
|
-
invisible,
|
|
68
|
-
widgetContainer,
|
|
69
|
-
container
|
|
70
|
-
);
|
|
71
|
-
return captchaRoot;
|
|
72
|
-
}
|
|
73
|
-
async getCaptchaRenderer(language) {
|
|
74
|
-
if (this._i18n === null) {
|
|
75
|
-
this._i18n = await loadI18next(false, language);
|
|
76
|
-
} else if (language && this._i18n.language !== language) {
|
|
77
|
-
await this._i18n.changeLanguage(language);
|
|
78
|
-
}
|
|
79
|
-
if (this.captchaRenderer === null) {
|
|
80
|
-
this.captchaRenderer = await this.createCaptchaRenderer();
|
|
81
|
-
}
|
|
82
|
-
return this.captchaRenderer;
|
|
83
|
-
}
|
|
84
|
-
async createCaptchaRenderer() {
|
|
85
|
-
const CaptchaRenderer = (await import("./captcha/captchaRenderer.js")).CaptchaRenderer;
|
|
86
|
-
return new CaptchaRenderer();
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
export {
|
|
90
|
-
WidgetFactory
|
|
2
|
+
import { getDefaultCallbacks, setUserCallbacks } from "@prosopo/procaptcha-common";
|
|
3
|
+
import { loadI18next } from "@prosopo/locale";
|
|
4
|
+
import { createWidgetSkeleton, darkTheme, lightTheme } from "@prosopo/widget-skeleton";
|
|
5
|
+
//#region src/util/widgetFactory.ts
|
|
6
|
+
var WidgetFactory = class {
|
|
7
|
+
constructor(widgetThemeResolver) {
|
|
8
|
+
this.widgetThemeResolver = widgetThemeResolver;
|
|
9
|
+
this.captchaRenderer = null;
|
|
10
|
+
this._i18n = null;
|
|
11
|
+
}
|
|
12
|
+
get i18n() {
|
|
13
|
+
if (this._i18n === null) throw new Error("I18n is not initialized");
|
|
14
|
+
return this._i18n;
|
|
15
|
+
}
|
|
16
|
+
async createWidgets(containers, renderOptions, isWeb2 = true, invisible = false) {
|
|
17
|
+
return Promise.all(containers.map((container) => {
|
|
18
|
+
const callbacks = getDefaultCallbacks(container);
|
|
19
|
+
setUserCallbacks(renderOptions, callbacks, container);
|
|
20
|
+
return this.createWidget(container, renderOptions, callbacks, isWeb2, invisible);
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
async createWidget(container, renderOptions, callbacks, isWeb2 = true, invisible = false) {
|
|
24
|
+
renderOptions.theme = this.widgetThemeResolver.resolveWidgetTheme(container, renderOptions);
|
|
25
|
+
const widgetTheme = "light" === renderOptions.theme ? lightTheme : darkTheme;
|
|
26
|
+
let widgetInteractiveArea;
|
|
27
|
+
let widgetContainer;
|
|
28
|
+
if (invisible) {
|
|
29
|
+
const newDiv = document.createElement("div");
|
|
30
|
+
container.appendChild(newDiv);
|
|
31
|
+
widgetInteractiveArea = newDiv;
|
|
32
|
+
widgetContainer = newDiv;
|
|
33
|
+
} else {
|
|
34
|
+
const widgetResult = createWidgetSkeleton(container, widgetTheme, "prosopo-procaptcha");
|
|
35
|
+
widgetInteractiveArea = widgetResult.widgetInteractiveArea;
|
|
36
|
+
widgetContainer = widgetResult.webComponent;
|
|
37
|
+
}
|
|
38
|
+
const language = resolveLanguage(renderOptions, container);
|
|
39
|
+
return (await this.getCaptchaRenderer(language)).renderCaptcha({
|
|
40
|
+
identifierPrefix: "procaptcha-",
|
|
41
|
+
emotionCacheKey: "procaptcha",
|
|
42
|
+
webComponentTag: "prosopo-procaptcha"
|
|
43
|
+
}, widgetInteractiveArea, renderOptions, callbacks, isWeb2, this.i18n, invisible, widgetContainer, container);
|
|
44
|
+
}
|
|
45
|
+
async getCaptchaRenderer(language) {
|
|
46
|
+
if (this._i18n === null) this._i18n = await loadI18next(false, language);
|
|
47
|
+
else if (language && this._i18n.language !== language) await this._i18n.changeLanguage(language);
|
|
48
|
+
if (this.captchaRenderer === null) this.captchaRenderer = await this.createCaptchaRenderer();
|
|
49
|
+
return this.captchaRenderer;
|
|
50
|
+
}
|
|
51
|
+
async createCaptchaRenderer() {
|
|
52
|
+
const CaptchaRenderer = (await import("./captcha/captchaRenderer.js")).CaptchaRenderer;
|
|
53
|
+
return new CaptchaRenderer();
|
|
54
|
+
}
|
|
91
55
|
};
|
|
56
|
+
//#endregion
|
|
57
|
+
export { WidgetFactory };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
WidgetThemeResolver
|
|
1
|
+
//#region src/util/widgetThemeResolver.ts
|
|
2
|
+
var WidgetThemeResolver = class {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.themesSet = /* @__PURE__ */ new Set(["light", "dark"]);
|
|
5
|
+
this.defaultTheme = "light";
|
|
6
|
+
}
|
|
7
|
+
resolveWidgetTheme(element, renderOptions) {
|
|
8
|
+
const themeAttribute = renderOptions.theme || element.getAttribute("data-theme") || this.defaultTheme;
|
|
9
|
+
return this.validateTheme(themeAttribute);
|
|
10
|
+
}
|
|
11
|
+
validateTheme(themeAttribute) {
|
|
12
|
+
return this.themesSet.has(themeAttribute) ? themeAttribute : this.defaultTheme;
|
|
13
|
+
}
|
|
16
14
|
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { WidgetThemeResolver };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/procaptcha-bundle",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.41",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
},
|
|
40
40
|
"browserslist": ["> 0.5%, last 2 versions, not dead"],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@prosopo/dotenv": "3.0.
|
|
43
|
-
"@prosopo/locale": "3.2.
|
|
44
|
-
"@prosopo/procaptcha-common": "2.11.
|
|
45
|
-
"@prosopo/procaptcha-frictionless": "2.12.
|
|
46
|
-
"@prosopo/types": "4.
|
|
47
|
-
"@prosopo/util": "3.3.
|
|
42
|
+
"@prosopo/dotenv": "3.0.50",
|
|
43
|
+
"@prosopo/locale": "3.2.8",
|
|
44
|
+
"@prosopo/procaptcha-common": "2.11.18",
|
|
45
|
+
"@prosopo/procaptcha-frictionless": "2.12.22",
|
|
46
|
+
"@prosopo/types": "4.10.0",
|
|
47
|
+
"@prosopo/util": "3.3.5",
|
|
48
48
|
"@prosopo/widget-skeleton": "2.8.4",
|
|
49
49
|
"dotenv": "16.4.5",
|
|
50
50
|
"fast-glob": "3.3.2",
|
|
@@ -68,20 +68,20 @@
|
|
|
68
68
|
"registry": "https://registry.npmjs.org"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@prosopo/config": "3.3.
|
|
71
|
+
"@prosopo/config": "3.3.5",
|
|
72
72
|
"@types/jsdom": "21.1.7",
|
|
73
73
|
"@types/node": "22.10.2",
|
|
74
74
|
"@types/react": "18.3.1",
|
|
75
75
|
"@types/react-dom": "18.3.1",
|
|
76
|
-
"@vitest/coverage-v8": "
|
|
76
|
+
"@vitest/coverage-v8": "4.1.10",
|
|
77
77
|
"concurrently": "9.0.1",
|
|
78
78
|
"del-cli": "6.0.0",
|
|
79
79
|
"npm-run-all": "4.1.5",
|
|
80
80
|
"tslib": "2.7.0",
|
|
81
81
|
"tsx": "4.20.3",
|
|
82
82
|
"typescript": "5.6.2",
|
|
83
|
-
"vite": "
|
|
84
|
-
"vitest": "
|
|
83
|
+
"vite": "8.1.5",
|
|
84
|
+
"vitest": "4.1.10"
|
|
85
85
|
},
|
|
86
86
|
"overrides": {
|
|
87
87
|
"@types/react": "18.3.1"
|