@prosopo/procaptcha-react 2.9.96 → 2.9.98
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 -35
- package/.turbo/turbo-build$colon$tsc.log +21 -21
- package/.turbo/turbo-build.log +21 -36
- package/CHANGELOG.md +41 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/cjs/components/Button.cjs +68 -78
- package/dist/cjs/components/CaptchaComponent.cjs +164 -228
- package/dist/cjs/components/CaptchaWidget.cjs +104 -158
- package/dist/cjs/components/Modal.cjs +30 -23
- package/dist/cjs/components/Procaptcha.cjs +7 -7
- package/dist/cjs/components/ProcaptchaWidget.cjs +147 -163
- package/dist/cjs/components/index.cjs +6 -9
- package/dist/cjs/index.cjs +6 -9
- package/dist/cjs/util/index.cjs +17 -15
- package/dist/components/Button.js +67 -78
- package/dist/components/CaptchaComponent.d.ts.map +1 -1
- package/dist/components/CaptchaComponent.js +160 -225
- package/dist/components/CaptchaComponent.js.map +1 -1
- package/dist/components/CaptchaWidget.d.ts.map +1 -1
- package/dist/components/CaptchaWidget.js +103 -157
- package/dist/components/CaptchaWidget.js.map +1 -1
- package/dist/components/Modal.js +24 -21
- package/dist/components/Procaptcha.js +6 -6
- package/dist/components/ProcaptchaWidget.d.ts.map +1 -1
- package/dist/components/ProcaptchaWidget.js +146 -162
- package/dist/components/ProcaptchaWidget.js.map +1 -1
- package/dist/components/index.js +3 -8
- package/dist/index.js +4 -9
- package/dist/tests/button.unit.test.d.ts +2 -0
- package/dist/tests/button.unit.test.d.ts.map +1 -0
- package/dist/tests/button.unit.test.js +113 -0
- package/dist/tests/button.unit.test.js.map +1 -0
- package/dist/tests/captchaComponent.unit.test.d.ts +2 -0
- package/dist/tests/captchaComponent.unit.test.d.ts.map +1 -0
- package/dist/tests/captchaComponent.unit.test.js +141 -0
- package/dist/tests/captchaComponent.unit.test.js.map +1 -0
- package/dist/tests/captchaWidget.unit.test.d.ts +2 -0
- package/dist/tests/captchaWidget.unit.test.d.ts.map +1 -0
- package/dist/tests/captchaWidget.unit.test.js +191 -0
- package/dist/tests/captchaWidget.unit.test.js.map +1 -0
- package/dist/tests/collector.unit.test.d.ts +2 -0
- package/dist/tests/collector.unit.test.d.ts.map +1 -0
- package/dist/tests/collector.unit.test.js +109 -0
- package/dist/tests/collector.unit.test.js.map +1 -0
- package/dist/tests/harness.d.ts +12 -0
- package/dist/tests/harness.d.ts.map +1 -0
- package/dist/tests/harness.js +69 -0
- package/dist/tests/harness.js.map +1 -0
- package/dist/tests/modal.unit.test.d.ts +2 -0
- package/dist/tests/modal.unit.test.d.ts.map +1 -0
- package/dist/tests/modal.unit.test.js +72 -0
- package/dist/tests/modal.unit.test.js.map +1 -0
- package/dist/tests/procaptcha.unit.test.d.ts +2 -0
- package/dist/tests/procaptcha.unit.test.d.ts.map +1 -0
- package/dist/tests/procaptcha.unit.test.js +57 -0
- package/dist/tests/procaptcha.unit.test.js.map +1 -0
- package/dist/tests/procaptchaReact.test-d.d.ts +2 -0
- package/dist/tests/procaptchaReact.test-d.d.ts.map +1 -0
- package/dist/tests/procaptchaReact.test-d.js +72 -0
- package/dist/tests/procaptchaReact.test-d.js.map +1 -0
- package/dist/tests/procaptchaWidget.unit.test.d.ts +2 -0
- package/dist/tests/procaptchaWidget.unit.test.d.ts.map +1 -0
- package/dist/tests/procaptchaWidget.unit.test.js +403 -0
- package/dist/tests/procaptchaWidget.unit.test.js.map +1 -0
- package/dist/tests/render.d.ts +23 -0
- package/dist/tests/render.d.ts.map +1 -0
- package/dist/tests/render.js +77 -0
- package/dist/tests/render.js.map +1 -0
- package/dist/tests/setup.d.ts +5 -0
- package/dist/tests/setup.d.ts.map +1 -0
- package/dist/tests/setup.js +3 -0
- package/dist/tests/setup.js.map +1 -0
- package/dist/tests/util.unit.test.d.ts +2 -0
- package/dist/tests/util.unit.test.d.ts.map +1 -0
- package/dist/tests/util.unit.test.js +84 -0
- package/dist/tests/util.unit.test.js.map +1 -0
- package/dist/util/index.js +17 -16
- package/package.json +16 -12
- package/vite.test.config.ts +28 -0
|
@@ -1,161 +1,107 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
throw new common.ProsopoDatasetError("CAPTCHA.MISSING_ITEM_HASH", {
|
|
10
|
-
context: { item }
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
return item.hash;
|
|
1
|
+
let _prosopo_common = require("@prosopo/common");
|
|
2
|
+
let _prosopo_widget_skeleton = require("@prosopo/widget-skeleton");
|
|
3
|
+
let react = require("react");
|
|
4
|
+
let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
|
|
5
|
+
//#region src/components/CaptchaWidget.tsx
|
|
6
|
+
var getHash = (item) => {
|
|
7
|
+
if (!item.hash) throw new _prosopo_common.ProsopoDatasetError("CAPTCHA.MISSING_ITEM_HASH", { context: { item } });
|
|
8
|
+
return item.hash;
|
|
14
9
|
};
|
|
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
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
111
|
-
"div",
|
|
112
|
-
{
|
|
113
|
-
style: {
|
|
114
|
-
position: "absolute",
|
|
115
|
-
top: 0,
|
|
116
|
-
left: 0,
|
|
117
|
-
bottom: 0,
|
|
118
|
-
right: 0,
|
|
119
|
-
height: "100%",
|
|
120
|
-
width: "100%",
|
|
121
|
-
// display overlays in center
|
|
122
|
-
display: "flex",
|
|
123
|
-
alignItems: "center",
|
|
124
|
-
justifyContent: "center",
|
|
125
|
-
// make bg half opacity, i.e. shadowing the item's img
|
|
126
|
-
backgroundColor: "rgba(0,0,0,0.5)",
|
|
127
|
-
visibility: solution.some((s) => s[0] === hash) ? "visible" : "hidden"
|
|
128
|
-
},
|
|
129
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
130
|
-
"svg",
|
|
131
|
-
{
|
|
132
|
-
style: {
|
|
133
|
-
backgroundColor: "transparent",
|
|
134
|
-
// img must be displayed as block otherwise gets a bottom whitespace border
|
|
135
|
-
display: "block",
|
|
136
|
-
// how big the overlay icon is
|
|
137
|
-
width: "35%",
|
|
138
|
-
height: "35%",
|
|
139
|
-
transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
|
|
140
|
-
userSelect: "none",
|
|
141
|
-
fill: "currentcolor"
|
|
142
|
-
},
|
|
143
|
-
focusable: "false",
|
|
144
|
-
color: "#fff",
|
|
145
|
-
"aria-hidden": "true",
|
|
146
|
-
viewBox: "0 0 24 24",
|
|
147
|
-
"data-testid": "CheckIcon",
|
|
148
|
-
"aria-label": "Check icon",
|
|
149
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" })
|
|
150
|
-
}
|
|
151
|
-
)
|
|
152
|
-
}
|
|
153
|
-
)
|
|
154
|
-
]
|
|
155
|
-
}
|
|
156
|
-
) }, item.hash);
|
|
157
|
-
})
|
|
158
|
-
}
|
|
159
|
-
);
|
|
10
|
+
var CaptchaWidget = ({ challenge, solution, onClick, themeColor }) => {
|
|
11
|
+
const items = challenge.items;
|
|
12
|
+
const theme = (0, react.useMemo)(() => themeColor === "light" ? _prosopo_widget_skeleton.lightTheme : _prosopo_widget_skeleton.darkTheme, [themeColor]);
|
|
13
|
+
const fullSpacing = `${theme.spacing.unit}px`;
|
|
14
|
+
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
15
|
+
style: {
|
|
16
|
+
width: "100%",
|
|
17
|
+
height: "100%",
|
|
18
|
+
display: "flex",
|
|
19
|
+
flexDirection: "row",
|
|
20
|
+
flexWrap: "wrap",
|
|
21
|
+
justifyContent: "space-between",
|
|
22
|
+
paddingBottom: fullSpacing,
|
|
23
|
+
paddingTop: fullSpacing,
|
|
24
|
+
gap: "10px"
|
|
25
|
+
},
|
|
26
|
+
children: items.map((item, index) => {
|
|
27
|
+
const hash = getHash(item);
|
|
28
|
+
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
29
|
+
style: {
|
|
30
|
+
flexGrow: 1,
|
|
31
|
+
flexBasis: "calc(33.333% - 10px)",
|
|
32
|
+
boxSizing: "border-box"
|
|
33
|
+
},
|
|
34
|
+
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
|
|
35
|
+
style: {
|
|
36
|
+
position: "relative",
|
|
37
|
+
cursor: "pointer",
|
|
38
|
+
height: "100%",
|
|
39
|
+
width: "100%",
|
|
40
|
+
padding: 0,
|
|
41
|
+
margin: 0
|
|
42
|
+
},
|
|
43
|
+
onClick: (e) => {
|
|
44
|
+
if (!e.isTrusted) return;
|
|
45
|
+
onClick(hash, e.clientX, e.clientY);
|
|
46
|
+
},
|
|
47
|
+
children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("img", {
|
|
48
|
+
style: {
|
|
49
|
+
width: "100%",
|
|
50
|
+
display: "block",
|
|
51
|
+
objectFit: "cover",
|
|
52
|
+
aspectRatio: "1/1",
|
|
53
|
+
height: "auto",
|
|
54
|
+
overflow: "hidden",
|
|
55
|
+
borderStyle: "solid",
|
|
56
|
+
borderWidth: "1px",
|
|
57
|
+
borderColor: theme.palette.grey[300]
|
|
58
|
+
},
|
|
59
|
+
src: item.data,
|
|
60
|
+
alt: `Captcha image ${index + 1}`,
|
|
61
|
+
onError: (e) => {
|
|
62
|
+
const target = e.currentTarget;
|
|
63
|
+
const retryCount = Number(target.dataset.retryCount ?? "0") + 1;
|
|
64
|
+
target.dataset.retryCount = String(retryCount);
|
|
65
|
+
if (retryCount <= 3) target.src = `${item.data}?retry=${Date.now()}`;
|
|
66
|
+
}
|
|
67
|
+
}), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
68
|
+
style: {
|
|
69
|
+
position: "absolute",
|
|
70
|
+
top: 0,
|
|
71
|
+
left: 0,
|
|
72
|
+
bottom: 0,
|
|
73
|
+
right: 0,
|
|
74
|
+
height: "100%",
|
|
75
|
+
width: "100%",
|
|
76
|
+
display: "flex",
|
|
77
|
+
alignItems: "center",
|
|
78
|
+
justifyContent: "center",
|
|
79
|
+
backgroundColor: "rgba(0,0,0,0.5)",
|
|
80
|
+
visibility: solution.some((s) => s[0] === hash) ? "visible" : "hidden"
|
|
81
|
+
},
|
|
82
|
+
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("svg", {
|
|
83
|
+
style: {
|
|
84
|
+
backgroundColor: "transparent",
|
|
85
|
+
display: "block",
|
|
86
|
+
width: "35%",
|
|
87
|
+
height: "35%",
|
|
88
|
+
transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
|
|
89
|
+
userSelect: "none",
|
|
90
|
+
fill: "currentcolor"
|
|
91
|
+
},
|
|
92
|
+
focusable: "false",
|
|
93
|
+
color: "#fff",
|
|
94
|
+
"aria-hidden": "true",
|
|
95
|
+
viewBox: "0 0 24 24",
|
|
96
|
+
"data-testid": "CheckIcon",
|
|
97
|
+
"aria-label": "Check icon",
|
|
98
|
+
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" })
|
|
99
|
+
})
|
|
100
|
+
})]
|
|
101
|
+
})
|
|
102
|
+
}, item.hash);
|
|
103
|
+
})
|
|
104
|
+
});
|
|
160
105
|
};
|
|
106
|
+
//#endregion
|
|
161
107
|
exports.CaptchaWidget = CaptchaWidget;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
|
+
let react = require("react");
|
|
3
|
+
react = require_runtime.__toESM(react, 1);
|
|
4
|
+
let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
|
|
5
|
+
let _emotion_react = require("@emotion/react");
|
|
6
|
+
let react_dom = require("react-dom");
|
|
7
|
+
//#region src/components/Modal.tsx
|
|
8
|
+
var ModalInnerDivCSS = _emotion_react.css`
|
|
7
9
|
position: absolute;
|
|
8
10
|
top: 50%;
|
|
9
11
|
left: 50%;
|
|
@@ -23,21 +25,26 @@ const ModalInnerDivCSS = react.css`
|
|
|
23
25
|
transform: translate(-50%, -100%);
|
|
24
26
|
}
|
|
25
27
|
`;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
28
|
+
var ModalComponent = react.default.memo((props) => {
|
|
29
|
+
const { show, children } = props;
|
|
30
|
+
const ModalOuterDivCss = {
|
|
31
|
+
position: "fixed",
|
|
32
|
+
zIndex: 2147483646,
|
|
33
|
+
inset: 0,
|
|
34
|
+
display: show ? "flex" : "none",
|
|
35
|
+
alignItems: "center",
|
|
36
|
+
justifyContent: "center",
|
|
37
|
+
minHeight: "100vh"
|
|
38
|
+
};
|
|
39
|
+
return (0, react_dom.createPortal)(/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
40
|
+
className: "prosopo-modalOuter",
|
|
41
|
+
style: ModalOuterDivCss,
|
|
42
|
+
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
43
|
+
className: "prosopo-modalInner",
|
|
44
|
+
css: ModalInnerDivCSS,
|
|
45
|
+
children
|
|
46
|
+
})
|
|
47
|
+
}), document.body);
|
|
42
48
|
});
|
|
43
|
-
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.default = ModalComponent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
let react = require("react");
|
|
2
|
+
let _emotion_react_jsx_runtime = require("@emotion/react/jsx-runtime");
|
|
3
|
+
//#region src/components/Procaptcha.tsx
|
|
4
|
+
var ProcaptchaWidget = (0, react.lazy)(async () => Promise.resolve().then(() => require("./ProcaptchaWidget.cjs")));
|
|
5
|
+
var Procaptcha = (props) => /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(react.Suspense, { children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)(ProcaptchaWidget, { ...props }) });
|
|
6
|
+
//#endregion
|
|
7
|
+
exports.default = Procaptcha;
|