@prosopo/procaptcha-react 0.2.25 → 0.2.32
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/cjs/components/CaptchaComponent.cjs +41 -64
- package/dist/cjs/components/CaptchaWidget.cjs +36 -41
- package/dist/cjs/components/ExtensionAccountSelect.cjs +26 -26
- package/dist/cjs/components/Procaptcha.cjs +134 -140
- package/dist/cjs/components/theme.cjs +12 -27
- package/dist/components/CaptchaComponent.d.ts.map +1 -1
- package/dist/components/CaptchaComponent.js +43 -43
- package/dist/components/CaptchaComponent.js.map +1 -1
- package/dist/components/CaptchaPlaceholder.d.ts +6 -0
- package/dist/components/CaptchaPlaceholder.d.ts.map +1 -0
- package/dist/components/CaptchaPlaceholder.js +77 -0
- package/dist/components/CaptchaPlaceholder.js.map +1 -0
- package/dist/components/CaptchaWidget.d.ts.map +1 -1
- package/dist/components/CaptchaWidget.js +2 -1
- package/dist/components/CaptchaWidget.js.map +1 -1
- package/dist/components/LoadingSpinner.js +1 -1
- package/dist/components/LoadingSpinner.js.map +1 -1
- package/dist/components/Procaptcha.d.ts +5 -6
- package/dist/components/Procaptcha.d.ts.map +1 -1
- package/dist/components/Procaptcha.js +6 -168
- package/dist/components/Procaptcha.js.map +1 -1
- package/dist/components/ProcaptchaWidget.d.ts +8 -0
- package/dist/components/ProcaptchaWidget.d.ts.map +1 -0
- package/dist/components/ProcaptchaWidget.js +170 -0
- package/dist/components/ProcaptchaWidget.js.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -1
- package/package.json +7 -9
- package/dist/cjs/components/Button.cjs +0 -68
- package/dist/cjs/components/Checkbox.cjs +0 -56
- package/dist/cjs/components/LoadingSpinner.cjs +0 -30
- package/dist/cjs/components/Modal.cjs +0 -35
- package/dist/cjs/components/collector.cjs +0 -25
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const jsxRuntime = require("
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const material = require("@mui/material");
|
|
3
4
|
const CaptchaWidget = require("./CaptchaWidget.cjs");
|
|
4
5
|
const util = require("@prosopo/util");
|
|
5
6
|
const theme = require("./theme.cjs");
|
|
6
|
-
const
|
|
7
|
+
const react = require("react");
|
|
7
8
|
const common = require("@prosopo/common");
|
|
8
|
-
const Button = require("./Button.cjs");
|
|
9
9
|
const index = require("../util/index.cjs");
|
|
10
10
|
const CaptchaComponent = ({
|
|
11
11
|
challenge,
|
|
@@ -20,48 +20,46 @@ const CaptchaComponent = ({
|
|
|
20
20
|
const { t } = common.useTranslation();
|
|
21
21
|
const captcha = challenge.captchas ? util.at(challenge.captchas, index$1) : null;
|
|
22
22
|
const solution = solutions ? util.at(solutions, index$1) : [];
|
|
23
|
-
const theme$1 =
|
|
23
|
+
const theme$1 = react.useMemo(() => themeColor === "light" ? theme.lightTheme : theme.darkTheme, [themeColor]);
|
|
24
24
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
25
|
-
|
|
25
|
+
material.Box,
|
|
26
26
|
{
|
|
27
|
-
|
|
27
|
+
sx: {
|
|
28
28
|
// introduce scroll bars when screen < minWidth of children
|
|
29
29
|
overflowX: "auto",
|
|
30
30
|
overflowY: "auto",
|
|
31
31
|
width: "100%",
|
|
32
32
|
maxWidth: "500px",
|
|
33
|
-
maxHeight: "100%"
|
|
34
|
-
display: "flex",
|
|
35
|
-
flexDirection: "column"
|
|
33
|
+
maxHeight: "100%"
|
|
36
34
|
},
|
|
37
35
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
38
|
-
|
|
36
|
+
material.Box,
|
|
39
37
|
{
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
bgcolor: theme$1.palette.background.default,
|
|
39
|
+
sx: {
|
|
42
40
|
display: "flex",
|
|
43
41
|
flexDirection: "column",
|
|
44
42
|
minWidth: "300px"
|
|
45
43
|
},
|
|
46
44
|
children: [
|
|
47
45
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
48
|
-
|
|
46
|
+
material.Box,
|
|
49
47
|
{
|
|
50
|
-
|
|
48
|
+
px: 2,
|
|
49
|
+
py: 3,
|
|
50
|
+
sx: {
|
|
51
51
|
display: "flex",
|
|
52
52
|
alignItems: "center",
|
|
53
|
-
width: "100%"
|
|
54
|
-
backgroundColor: theme$1.palette.primary.main,
|
|
55
|
-
padding: "24px 16px"
|
|
53
|
+
width: "100%"
|
|
56
54
|
},
|
|
55
|
+
bgcolor: theme$1.palette.primary.main,
|
|
57
56
|
children: [
|
|
58
57
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
59
|
-
|
|
58
|
+
material.Typography,
|
|
60
59
|
{
|
|
61
|
-
|
|
60
|
+
sx: {
|
|
62
61
|
color: "#ffffff",
|
|
63
|
-
fontWeight: 700
|
|
64
|
-
lineHeight: 1.5
|
|
62
|
+
fontWeight: 700
|
|
65
63
|
},
|
|
66
64
|
children: [
|
|
67
65
|
t("WIDGET.SELECT_ALL"),
|
|
@@ -70,13 +68,14 @@ const CaptchaComponent = ({
|
|
|
70
68
|
}
|
|
71
69
|
),
|
|
72
70
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
73
|
-
|
|
71
|
+
material.Typography,
|
|
74
72
|
{
|
|
75
|
-
|
|
73
|
+
px: 1,
|
|
74
|
+
sx: {
|
|
76
75
|
color: "#ffffff",
|
|
77
76
|
fontWeight: 700,
|
|
78
77
|
textTransform: "capitalize",
|
|
79
|
-
|
|
78
|
+
fontSize: theme$1.typography.h6.fontSize
|
|
80
79
|
},
|
|
81
80
|
children: `${util.at(challenge.captchas, index$1).captcha.target}`
|
|
82
81
|
}
|
|
@@ -84,19 +83,13 @@ const CaptchaComponent = ({
|
|
|
84
83
|
]
|
|
85
84
|
}
|
|
86
85
|
),
|
|
87
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
88
|
-
CaptchaWidget.CaptchaWidget,
|
|
89
|
-
{
|
|
90
|
-
challenge: captcha,
|
|
91
|
-
solution,
|
|
92
|
-
onClick,
|
|
93
|
-
themeColor
|
|
94
|
-
}
|
|
95
|
-
) }),
|
|
86
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Box, { ...index({ dev: { cy: "captcha-" + index$1 } }), children: captcha && /* @__PURE__ */ jsxRuntime.jsx(CaptchaWidget.CaptchaWidget, { challenge: captcha, solution, onClick }) }),
|
|
96
87
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
97
|
-
|
|
88
|
+
material.Box,
|
|
98
89
|
{
|
|
99
|
-
|
|
90
|
+
px: 2,
|
|
91
|
+
py: 1,
|
|
92
|
+
sx: {
|
|
100
93
|
display: "flex",
|
|
101
94
|
alignItems: "center",
|
|
102
95
|
justifyContent: "center",
|
|
@@ -105,43 +98,27 @@ const CaptchaComponent = ({
|
|
|
105
98
|
...index({ dev: { cy: "dots-captcha" } })
|
|
106
99
|
}
|
|
107
100
|
),
|
|
108
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
109
|
-
"div",
|
|
110
|
-
{
|
|
111
|
-
style: {
|
|
112
|
-
padding: "8px 16px",
|
|
113
|
-
display: "flex",
|
|
114
|
-
width: "100%"
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
),
|
|
118
101
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
119
|
-
|
|
102
|
+
material.Box,
|
|
120
103
|
{
|
|
121
|
-
|
|
122
|
-
|
|
104
|
+
px: 2,
|
|
105
|
+
pt: 0,
|
|
106
|
+
pb: 2,
|
|
107
|
+
sx: {
|
|
123
108
|
display: "flex",
|
|
124
109
|
alignItems: "center",
|
|
125
|
-
justifyContent: "space-between"
|
|
126
|
-
lineHeight: 1.75
|
|
110
|
+
justifyContent: "space-between"
|
|
127
111
|
},
|
|
128
112
|
children: [
|
|
113
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Button, { onClick: onCancel, variant: "text", children: t("WIDGET.CANCEL") }),
|
|
129
114
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
130
|
-
Button,
|
|
131
|
-
{
|
|
132
|
-
themeColor,
|
|
133
|
-
buttonType: "cancel",
|
|
134
|
-
onClick: onCancel,
|
|
135
|
-
text: t("WIDGET.CANCEL")
|
|
136
|
-
}
|
|
137
|
-
),
|
|
138
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
139
|
-
Button,
|
|
115
|
+
material.Button,
|
|
140
116
|
{
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
117
|
+
color: "primary",
|
|
118
|
+
onClick: index$1 < challenge.captchas.length - 1 ? onNext : onSubmit,
|
|
119
|
+
variant: "contained",
|
|
120
|
+
...index({ dev: { cy: "button-next" } }),
|
|
121
|
+
children: index$1 < challenge.captchas.length - 1 ? t("WIDGET.NEXT") : t("WIDGET.SUBMIT")
|
|
145
122
|
}
|
|
146
123
|
)
|
|
147
124
|
]
|
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const material = require("@mui/material");
|
|
5
|
+
const CheckIcon = require("@mui/icons-material/Check.js");
|
|
6
|
+
const normalizeIcon = (Icon) => {
|
|
7
|
+
return Icon.default ? Icon.default : Icon;
|
|
8
|
+
};
|
|
9
|
+
const CheckIconNormalized = normalizeIcon(CheckIcon);
|
|
6
10
|
const getHash = (item) => {
|
|
7
11
|
if (!item.hash) {
|
|
8
12
|
throw new Error("item.hash is undefined");
|
|
9
13
|
}
|
|
10
14
|
return item.hash;
|
|
11
15
|
};
|
|
12
|
-
const CaptchaWidget = ({ challenge, solution, onClick
|
|
16
|
+
const CaptchaWidget = ({ challenge, solution, onClick }) => {
|
|
13
17
|
const items = challenge.captcha.items;
|
|
14
|
-
const theme
|
|
18
|
+
const theme = material.useTheme();
|
|
15
19
|
const isTouchDevice = "ontouchstart" in window;
|
|
16
20
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
17
|
-
|
|
21
|
+
material.Box,
|
|
18
22
|
{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
component: "div",
|
|
24
|
+
pr: 0.5,
|
|
25
|
+
pb: 0.5,
|
|
26
|
+
sx: {
|
|
22
27
|
// expand to full height / width of parent
|
|
23
28
|
width: "100%",
|
|
24
29
|
height: "100%",
|
|
@@ -30,11 +35,11 @@ const CaptchaWidget = ({ challenge, solution, onClick, themeColor }) => {
|
|
|
30
35
|
children: items.map((item, index) => {
|
|
31
36
|
const hash = getHash(item);
|
|
32
37
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
33
|
-
|
|
38
|
+
material.Box,
|
|
34
39
|
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
pt: 0.5,
|
|
41
|
+
pl: 0.5,
|
|
42
|
+
sx: {
|
|
38
43
|
// enable the items in the grid to grow in width to use up excess space
|
|
39
44
|
flexGrow: 1,
|
|
40
45
|
// make the width of each item 1/3rd of the width overall, i.e. 3 columns
|
|
@@ -43,19 +48,19 @@ const CaptchaWidget = ({ challenge, solution, onClick, themeColor }) => {
|
|
|
43
48
|
boxSizing: "border-box"
|
|
44
49
|
},
|
|
45
50
|
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
46
|
-
|
|
51
|
+
material.Box,
|
|
47
52
|
{
|
|
48
|
-
|
|
53
|
+
sx: { cursor: "pointer", height: "100%", width: "100%" },
|
|
49
54
|
onClick: isTouchDevice ? void 0 : () => onClick(hash),
|
|
50
55
|
onTouchStart: isTouchDevice ? () => onClick(hash) : void 0,
|
|
51
56
|
children: [
|
|
52
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
57
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Box, { sx: { border: 1, borderColor: theme.palette.grey[300] }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
53
58
|
"img",
|
|
54
59
|
{
|
|
55
60
|
style: {
|
|
56
61
|
width: "100%",
|
|
57
62
|
// image should be full width / height of the item
|
|
58
|
-
backgroundColor: theme
|
|
63
|
+
backgroundColor: theme.palette.grey[300],
|
|
59
64
|
// colour of the bands when letterboxing and image
|
|
60
65
|
opacity: solution.includes(hash) && isTouchDevice ? "50%" : "100%",
|
|
61
66
|
// iphone workaround
|
|
@@ -70,10 +75,10 @@ const CaptchaWidget = ({ challenge, solution, onClick, themeColor }) => {
|
|
|
70
75
|
alt: `Captcha image ${index + 1}`
|
|
71
76
|
}
|
|
72
77
|
) }),
|
|
73
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
74
|
-
|
|
78
|
+
/* @__PURE__ */ jsxRuntime.jsx(material.Fade, { in: solution.includes(hash), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
79
|
+
material.Box,
|
|
75
80
|
{
|
|
76
|
-
|
|
81
|
+
sx: {
|
|
77
82
|
// relative to where the element _should_ be positioned
|
|
78
83
|
position: "relative",
|
|
79
84
|
// make the overlay the full height/width of an item
|
|
@@ -81,15 +86,14 @@ const CaptchaWidget = ({ challenge, solution, onClick, themeColor }) => {
|
|
|
81
86
|
height: "100%",
|
|
82
87
|
// shift it up 100% to overlay the item element
|
|
83
88
|
top: "-100%",
|
|
84
|
-
visibility: solution.includes(hash) ? "visible" : "hidden",
|
|
85
89
|
// transition on opacity upon (de)selection
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
transitionDuration: "300ms",
|
|
91
|
+
transitionProperty: "opacity"
|
|
88
92
|
},
|
|
89
93
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
90
|
-
|
|
94
|
+
material.Box,
|
|
91
95
|
{
|
|
92
|
-
|
|
96
|
+
sx: {
|
|
93
97
|
// make the overlay absolute positioned compare to its container
|
|
94
98
|
position: "absolute",
|
|
95
99
|
// spread across 100% width/height of the item box
|
|
@@ -107,31 +111,22 @@ const CaptchaWidget = ({ challenge, solution, onClick, themeColor }) => {
|
|
|
107
111
|
backgroundColor: "rgba(0,0,0,0.5)"
|
|
108
112
|
},
|
|
109
113
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
110
|
-
|
|
114
|
+
CheckIconNormalized,
|
|
111
115
|
{
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// img must be displayed as block otherwise
|
|
116
|
+
htmlColor: theme.palette.background.default,
|
|
117
|
+
sx: {
|
|
118
|
+
// img must be displayed as block otherwise get's a bottom whitespace border
|
|
115
119
|
display: "block",
|
|
116
120
|
// how big the overlay icon is
|
|
117
121
|
width: "35%",
|
|
118
|
-
height: "35%"
|
|
119
|
-
|
|
120
|
-
userSelect: "none",
|
|
121
|
-
fill: "currentcolor"
|
|
122
|
-
},
|
|
123
|
-
focusable: "false",
|
|
124
|
-
color: "#fff",
|
|
125
|
-
"aria-hidden": "true",
|
|
126
|
-
viewBox: "0 0 24 24",
|
|
127
|
-
"data-testid": "CheckIcon",
|
|
128
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" })
|
|
122
|
+
height: "35%"
|
|
123
|
+
}
|
|
129
124
|
}
|
|
130
125
|
)
|
|
131
126
|
}
|
|
132
127
|
)
|
|
133
128
|
}
|
|
134
|
-
)
|
|
129
|
+
) })
|
|
135
130
|
]
|
|
136
131
|
}
|
|
137
132
|
)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const jsxRuntime = require("
|
|
4
|
-
const
|
|
3
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
const material = require("@mui/material");
|
|
5
|
+
const react = require("react");
|
|
5
6
|
const common = require("@prosopo/common");
|
|
6
7
|
const extensionDapp = require("@polkadot/extension-dapp");
|
|
7
8
|
const ExtensionAccountSelect = ({
|
|
@@ -10,8 +11,8 @@ const ExtensionAccountSelect = ({
|
|
|
10
11
|
onChange
|
|
11
12
|
}) => {
|
|
12
13
|
const { t } = common.useTranslation();
|
|
13
|
-
const [accounts, setAccounts] =
|
|
14
|
-
|
|
14
|
+
const [accounts, setAccounts] = react.useState([]);
|
|
15
|
+
react.useEffect(() => {
|
|
15
16
|
const prom = extensionDapp.web3Enable(dappName).then(() => {
|
|
16
17
|
return extensionDapp.web3AccountsSubscribe(setAccounts);
|
|
17
18
|
});
|
|
@@ -20,28 +21,27 @@ const ExtensionAccountSelect = ({
|
|
|
20
21
|
};
|
|
21
22
|
}, []);
|
|
22
23
|
const account = accounts.find((a) => a.address === value) || null;
|
|
23
|
-
return (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
24
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
25
|
+
material.Autocomplete,
|
|
26
|
+
{
|
|
27
|
+
disablePortal: true,
|
|
28
|
+
id: "select-account",
|
|
29
|
+
options: accounts,
|
|
30
|
+
value: account,
|
|
31
|
+
isOptionEqualToValue: (option, value2) => option.address === value2.address,
|
|
32
|
+
onChange: (event, value2) => {
|
|
33
|
+
if (value2) {
|
|
34
|
+
console.log("Selected account:", value2);
|
|
35
|
+
onChange(value2.address);
|
|
36
|
+
} else {
|
|
37
|
+
console.log("Deselected account");
|
|
38
|
+
onChange("");
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
sx: { width: 550 },
|
|
42
|
+
getOptionLabel: (option) => `${option.meta.name}: ${option.address}`,
|
|
43
|
+
renderInput: (props) => /* @__PURE__ */ jsxRuntime.jsx(material.TextField, { ...props, label: t("WIDGET.SELECT_ACCOUNT") })
|
|
44
|
+
}
|
|
45
45
|
);
|
|
46
46
|
};
|
|
47
47
|
exports.ExtensionAccountSelect = ExtensionAccountSelect;
|