@prosopo/procaptcha-react 2.9.96 → 2.9.97
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 +18 -33
- package/.turbo/turbo-build$colon$tsc.log +21 -21
- package/.turbo/turbo-build.log +19 -34
- package/CHANGELOG.md +17 -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 +165 -228
- package/dist/cjs/components/CaptchaWidget.cjs +112 -158
- package/dist/cjs/components/Modal.cjs +30 -23
- package/dist/cjs/components/Procaptcha.cjs +7 -7
- package/dist/cjs/components/ProcaptchaWidget.cjs +145 -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.js +161 -225
- package/dist/components/CaptchaWidget.js +111 -157
- package/dist/components/Modal.js +24 -21
- package/dist/components/Procaptcha.js +6 -6
- package/dist/components/ProcaptchaWidget.js +144 -162
- package/dist/components/index.js +3 -8
- package/dist/index.js +4 -9
- package/dist/util/index.js +17 -16
- package/package.json +11 -11
|
@@ -1,161 +1,115 @@
|
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
+
`${theme.spacing.half}`;
|
|
15
|
+
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
16
|
+
style: {
|
|
17
|
+
width: "100%",
|
|
18
|
+
height: "100%",
|
|
19
|
+
display: "flex",
|
|
20
|
+
flexDirection: "row",
|
|
21
|
+
flexWrap: "wrap",
|
|
22
|
+
justifyContent: "space-between",
|
|
23
|
+
paddingBottom: fullSpacing,
|
|
24
|
+
paddingTop: fullSpacing,
|
|
25
|
+
gap: "10px"
|
|
26
|
+
},
|
|
27
|
+
children: items.map((item, index) => {
|
|
28
|
+
const hash = getHash(item);
|
|
29
|
+
return /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
30
|
+
style: {
|
|
31
|
+
flexGrow: 1,
|
|
32
|
+
flexBasis: "calc(33.333% - 10px)",
|
|
33
|
+
boxSizing: "border-box"
|
|
34
|
+
},
|
|
35
|
+
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsxs)("div", {
|
|
36
|
+
style: {
|
|
37
|
+
position: "relative",
|
|
38
|
+
cursor: "pointer",
|
|
39
|
+
height: "100%",
|
|
40
|
+
width: "100%",
|
|
41
|
+
padding: 0,
|
|
42
|
+
margin: 0
|
|
43
|
+
},
|
|
44
|
+
onClick: (e) => {
|
|
45
|
+
if (!e.isTrusted) return;
|
|
46
|
+
if ("touches" in e && e.touches.length > 0 && e.touches[0]) {
|
|
47
|
+
onClick(hash, e.touches[0].clientX, e.touches[0].clientY);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if ("clientX" in e && "clientY" in e) {
|
|
51
|
+
onClick(hash, e.clientX, e.clientY);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
onClick(hash, 0, 0);
|
|
55
|
+
},
|
|
56
|
+
children: [/* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("img", {
|
|
57
|
+
style: {
|
|
58
|
+
width: "100%",
|
|
59
|
+
display: "block",
|
|
60
|
+
objectFit: "cover",
|
|
61
|
+
aspectRatio: "1/1",
|
|
62
|
+
height: "auto",
|
|
63
|
+
overflow: "hidden",
|
|
64
|
+
borderStyle: "solid",
|
|
65
|
+
borderWidth: "1px",
|
|
66
|
+
borderColor: theme.palette.grey[300]
|
|
67
|
+
},
|
|
68
|
+
src: item.data,
|
|
69
|
+
alt: `Captcha image ${index + 1}`,
|
|
70
|
+
onError: (e) => {
|
|
71
|
+
const target = e.currentTarget;
|
|
72
|
+
target._retryCount = (target._retryCount || 0) + 1;
|
|
73
|
+
if (target._retryCount <= 3) target.src = `${item.data}?retry=${Date.now()}`;
|
|
74
|
+
}
|
|
75
|
+
}), /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("div", {
|
|
76
|
+
style: {
|
|
77
|
+
position: "absolute",
|
|
78
|
+
top: 0,
|
|
79
|
+
left: 0,
|
|
80
|
+
bottom: 0,
|
|
81
|
+
right: 0,
|
|
82
|
+
height: "100%",
|
|
83
|
+
width: "100%",
|
|
84
|
+
display: "flex",
|
|
85
|
+
alignItems: "center",
|
|
86
|
+
justifyContent: "center",
|
|
87
|
+
backgroundColor: "rgba(0,0,0,0.5)",
|
|
88
|
+
visibility: solution.some((s) => s[0] === hash) ? "visible" : "hidden"
|
|
89
|
+
},
|
|
90
|
+
children: /* @__PURE__ */ (0, _emotion_react_jsx_runtime.jsx)("svg", {
|
|
91
|
+
style: {
|
|
92
|
+
backgroundColor: "transparent",
|
|
93
|
+
display: "block",
|
|
94
|
+
width: "35%",
|
|
95
|
+
height: "35%",
|
|
96
|
+
transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
|
|
97
|
+
userSelect: "none",
|
|
98
|
+
fill: "currentcolor"
|
|
99
|
+
},
|
|
100
|
+
focusable: "false",
|
|
101
|
+
color: "#fff",
|
|
102
|
+
"aria-hidden": "true",
|
|
103
|
+
viewBox: "0 0 24 24",
|
|
104
|
+
"data-testid": "CheckIcon",
|
|
105
|
+
"aria-label": "Check icon",
|
|
106
|
+
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" })
|
|
107
|
+
})
|
|
108
|
+
})]
|
|
109
|
+
})
|
|
110
|
+
}, item.hash);
|
|
111
|
+
})
|
|
112
|
+
});
|
|
160
113
|
};
|
|
114
|
+
//#endregion
|
|
161
115
|
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;
|