@prosopo/procaptcha-react 2.1.6 → 2.1.7

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.
Files changed (50) hide show
  1. package/package.json +9 -9
  2. package/dist/cjs/components/Button.cjs +0 -76
  3. package/dist/cjs/components/CaptchaComponent.cjs +0 -198
  4. package/dist/cjs/components/CaptchaWidget.cjs +0 -186
  5. package/dist/cjs/components/Modal.cjs +0 -42
  6. package/dist/cjs/components/Procaptcha.cjs +0 -20
  7. package/dist/cjs/components/ProcaptchaWidget.cjs +0 -142
  8. package/dist/cjs/components/index.cjs +0 -9
  9. package/dist/cjs/index.cjs +0 -10
  10. package/dist/cjs/util/index.cjs +0 -18
  11. package/dist/components/Button.d.ts +0 -11
  12. package/dist/components/Button.d.ts.map +0 -1
  13. package/dist/components/Button.js +0 -61
  14. package/dist/components/Button.js.map +0 -1
  15. package/dist/components/CaptchaComponent.d.ts +0 -15
  16. package/dist/components/CaptchaComponent.d.ts.map +0 -1
  17. package/dist/components/CaptchaComponent.js +0 -78
  18. package/dist/components/CaptchaComponent.js.map +0 -1
  19. package/dist/components/CaptchaWidget.d.ts +0 -9
  20. package/dist/components/CaptchaWidget.d.ts.map +0 -1
  21. package/dist/components/CaptchaWidget.js +0 -106
  22. package/dist/components/CaptchaWidget.js.map +0 -1
  23. package/dist/components/Modal.d.ts +0 -8
  24. package/dist/components/Modal.d.ts.map +0 -1
  25. package/dist/components/Modal.js +0 -37
  26. package/dist/components/Modal.js.map +0 -1
  27. package/dist/components/Procaptcha.d.ts +0 -8
  28. package/dist/components/Procaptcha.d.ts.map +0 -1
  29. package/dist/components/Procaptcha.js +0 -7
  30. package/dist/components/Procaptcha.js.map +0 -1
  31. package/dist/components/ProcaptchaWidget.d.ts +0 -4
  32. package/dist/components/ProcaptchaWidget.d.ts.map +0 -1
  33. package/dist/components/ProcaptchaWidget.js +0 -54
  34. package/dist/components/ProcaptchaWidget.js.map +0 -1
  35. package/dist/components/collector.d.ts +0 -9
  36. package/dist/components/collector.d.ts.map +0 -1
  37. package/dist/components/collector.js +0 -26
  38. package/dist/components/collector.js.map +0 -1
  39. package/dist/components/index.d.ts +0 -6
  40. package/dist/components/index.d.ts.map +0 -1
  41. package/dist/components/index.js +0 -6
  42. package/dist/components/index.js.map +0 -1
  43. package/dist/index.d.ts +0 -3
  44. package/dist/index.d.ts.map +0 -1
  45. package/dist/index.js +0 -3
  46. package/dist/index.js.map +0 -1
  47. package/dist/util/index.d.ts +0 -9
  48. package/dist/util/index.d.ts.map +0 -1
  49. package/dist/util/index.js +0 -12
  50. package/dist/util/index.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prosopo/procaptcha-react",
3
- "version": "2.1.6",
3
+ "version": "2.1.7",
4
4
  "author": "PROSOPO LIMITED <info@prosopo.io>",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.js",
@@ -26,13 +26,13 @@
26
26
  },
27
27
  "browserslist": ["> 0.5%, last 2 versions, not dead"],
28
28
  "dependencies": {
29
- "@prosopo/common": "2.1.6",
30
- "@prosopo/locale-browser": "2.1.6",
31
- "@prosopo/procaptcha": "2.1.6",
32
- "@prosopo/procaptcha-common": "2.1.6",
33
- "@prosopo/types": "2.1.6",
34
- "@prosopo/util": "2.1.6",
35
- "@prosopo/web-components": "2.1.6",
29
+ "@prosopo/common": "2.1.7",
30
+ "@prosopo/locale-browser": "2.1.7",
31
+ "@prosopo/procaptcha": "2.1.7",
32
+ "@prosopo/procaptcha-common": "2.1.7",
33
+ "@prosopo/types": "2.1.7",
34
+ "@prosopo/util": "2.1.7",
35
+ "@prosopo/web-components": "2.1.7",
36
36
  "csstype": "3.1.3",
37
37
  "react": "18.3.1"
38
38
  },
@@ -49,7 +49,7 @@
49
49
  }
50
50
  },
51
51
  "devDependencies": {
52
- "@prosopo/config": "2.1.6",
52
+ "@prosopo/config": "2.1.7",
53
53
  "@vitest/coverage-v8": "2.1.1",
54
54
  "concurrently": "9.0.1",
55
55
  "npm-run-all": "4.1.5",
@@ -1,76 +0,0 @@
1
- "use strict";
2
- const jsxRuntime = require("@emotion/react/jsx-runtime");
3
- const webComponents = require("@prosopo/web-components");
4
- const React = require("react");
5
- const index = require("../util/index.cjs");
6
- const buttonStyleBase = {
7
- display: "inline-flex",
8
- alignItems: "center",
9
- justifyContent: "center",
10
- position: "relative",
11
- boxSizing: "border-box",
12
- outline: "0px",
13
- border: "0px",
14
- margin: "0px",
15
- cursor: "pointer",
16
- userSelect: "none",
17
- verticalAlign: "middle",
18
- appearance: void 0,
19
- textDecoration: "none",
20
- fontWeight: "500",
21
- fontSize: "0.875rem",
22
- lineHeight: "1.75",
23
- letterSpacing: "0.02857em",
24
- textTransform: "uppercase",
25
- minWidth: "64px",
26
- padding: "6px 16px",
27
- borderRadius: "4px",
28
- transition: "background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
29
- color: "rgb(0, 0, 0)",
30
- backgroundColor: "#ffffff",
31
- boxShadow: "rgba(0, 0, 0, 0.2) 0px 3px 1px -2px, rgba(0, 0, 0, 0.14) 0px 2px 2px 0px, rgba(0, 0, 0, 0.12) 0px 1px 5px 0px"
32
- };
33
- const Button = ({
34
- themeColor,
35
- buttonType,
36
- text,
37
- onClick
38
- }) => {
39
- const theme = React.useMemo(
40
- () => themeColor === "light" ? webComponents.lightTheme : webComponents.darkTheme,
41
- [themeColor]
42
- );
43
- const [hover, setHover] = React.useState(false);
44
- const buttonStyle = React.useMemo(() => {
45
- const baseStyle = {
46
- ...buttonStyleBase,
47
- color: hover ? theme.palette.primary.contrastText : theme.palette.background.contrastText
48
- };
49
- if (buttonType === "cancel") {
50
- return {
51
- ...baseStyle,
52
- backgroundColor: hover ? theme.palette.grey[600] : "transparent"
53
- };
54
- }
55
- return {
56
- ...baseStyle,
57
- backgroundColor: hover ? theme.palette.primary.main : theme.palette.background.default
58
- };
59
- }, [buttonType, hover, theme]);
60
- return /* @__PURE__ */ jsxRuntime.jsx(
61
- "button",
62
- {
63
- ...index({ dev: { cy: `button-${buttonType}` } }),
64
- onMouseEnter: () => setHover(true),
65
- onMouseLeave: () => setHover(false),
66
- style: buttonStyle,
67
- onClick: (e) => {
68
- e.preventDefault();
69
- onClick();
70
- },
71
- "aria-label": text,
72
- children: text
73
- }
74
- );
75
- };
76
- module.exports = Button;
@@ -1,198 +0,0 @@
1
- "use strict";
2
- const jsxRuntime = require("@emotion/react/jsx-runtime");
3
- const localeBrowser = require("@prosopo/locale-browser");
4
- const util = require("@prosopo/util");
5
- const webComponents = require("@prosopo/web-components");
6
- const React = require("react");
7
- const index = require("../util/index.cjs");
8
- const Button = require("./Button.cjs");
9
- const CaptchaWidget = require("./CaptchaWidget.cjs");
10
- const CaptchaComponent = ({
11
- challenge,
12
- index: index$1,
13
- solutions,
14
- onSubmit,
15
- onCancel,
16
- onClick,
17
- onNext,
18
- onReload,
19
- themeColor
20
- }) => {
21
- const { t } = localeBrowser.useTranslation();
22
- const captcha = challenge.captchas ? util.at(challenge.captchas, index$1) : null;
23
- const solution = solutions ? util.at(solutions, index$1) : [];
24
- const theme = React.useMemo(
25
- () => themeColor === "light" ? webComponents.lightTheme : webComponents.darkTheme,
26
- [themeColor]
27
- );
28
- return /* @__PURE__ */ jsxRuntime.jsx(React.Suspense, { fallback: /* @__PURE__ */ jsxRuntime.jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsxRuntime.jsx(
29
- "div",
30
- {
31
- style: {
32
- // introduce scroll bars when screen < minWidth of children
33
- overflowX: "auto",
34
- overflowY: "auto",
35
- width: "100%",
36
- maxWidth: "500px",
37
- maxHeight: "100%",
38
- display: "flex",
39
- flexDirection: "column",
40
- border: "1px solid #dddddd",
41
- boxShadow: "rgba(255, 255, 255, 0.2) 0px 0px 4px",
42
- borderRadius: "4px",
43
- padding: `${theme.spacing.unit}px`,
44
- backgroundColor: theme.palette.background.default
45
- },
46
- children: /* @__PURE__ */ jsxRuntime.jsxs(
47
- "div",
48
- {
49
- style: {
50
- backgroundColor: theme.palette.background.default,
51
- display: "flex",
52
- flexDirection: "column",
53
- minWidth: "300px"
54
- },
55
- children: [
56
- /* @__PURE__ */ jsxRuntime.jsx(
57
- "div",
58
- {
59
- style: {
60
- display: "flex",
61
- alignItems: "center",
62
- width: "100%"
63
- },
64
- children: /* @__PURE__ */ jsxRuntime.jsx(
65
- "div",
66
- {
67
- style: {
68
- backgroundColor: theme.palette.primary.main,
69
- width: "100%"
70
- },
71
- children: /* @__PURE__ */ jsxRuntime.jsxs(
72
- "div",
73
- {
74
- style: {
75
- paddingLeft: `${theme.spacing.half}px`,
76
- paddingRight: `${theme.spacing.half}px`
77
- },
78
- children: [
79
- /* @__PURE__ */ jsxRuntime.jsxs(
80
- "p",
81
- {
82
- style: {
83
- color: "#ffffff",
84
- fontWeight: 700,
85
- lineHeight: 1.5
86
- },
87
- children: [
88
- t("WIDGET.SELECT_ALL"),
89
- ":",
90
- " ",
91
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: `${t(util.at(challenge.captchas, index$1).target)} ` })
92
- ]
93
- }
94
- ),
95
- /* @__PURE__ */ jsxRuntime.jsx(
96
- "p",
97
- {
98
- style: {
99
- color: "#ffffff",
100
- fontWeight: 500,
101
- lineHeight: 0.8,
102
- fontSize: "0.8rem"
103
- },
104
- children: t("WIDGET.IF_NONE_CLICK_NEXT")
105
- }
106
- )
107
- ]
108
- }
109
- )
110
- }
111
- )
112
- }
113
- ),
114
- /* @__PURE__ */ jsxRuntime.jsx("div", { ...index({ dev: { cy: `captcha-${index$1}` } }), children: captcha && /* @__PURE__ */ jsxRuntime.jsx(
115
- CaptchaWidget.CaptchaWidget,
116
- {
117
- challenge: captcha,
118
- solution,
119
- onClick,
120
- themeColor
121
- }
122
- ) }),
123
- /* @__PURE__ */ jsxRuntime.jsx(
124
- "div",
125
- {
126
- style: {
127
- display: "flex",
128
- alignItems: "center",
129
- justifyContent: "center",
130
- width: "100%"
131
- },
132
- ...index({ dev: { cy: "dots-captcha" } })
133
- }
134
- ),
135
- /* @__PURE__ */ jsxRuntime.jsx(
136
- "div",
137
- {
138
- style: {
139
- padding: `0 ${theme.spacing}px`,
140
- display: "flex",
141
- width: "100%"
142
- }
143
- }
144
- ),
145
- /* @__PURE__ */ jsxRuntime.jsx(
146
- "div",
147
- {
148
- style: {
149
- padding: `0 ${theme.spacing}px`,
150
- display: "flex",
151
- alignItems: "center",
152
- justifyContent: "space-between",
153
- lineHeight: 1.75
154
- },
155
- children: /* @__PURE__ */ jsxRuntime.jsxs(
156
- "div",
157
- {
158
- style: {
159
- display: "grid",
160
- gridAutoFlow: "column",
161
- gridTemplateColumns: "repeat(3, minmax(0, 1fr)",
162
- width: "100%"
163
- },
164
- children: [
165
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { justifySelf: "left" }, children: /* @__PURE__ */ jsxRuntime.jsx(
166
- Button,
167
- {
168
- themeColor,
169
- buttonType: "cancel",
170
- onClick: onCancel,
171
- text: t("WIDGET.CANCEL"),
172
- "aria-label": t("WIDGET.CANCEL")
173
- }
174
- ) }),
175
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { justifySelf: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(webComponents.ReloadButton, { themeColor, onReload }) }),
176
- /* @__PURE__ */ jsxRuntime.jsx("div", { style: { justifySelf: "right" }, children: /* @__PURE__ */ jsxRuntime.jsx(
177
- Button,
178
- {
179
- themeColor,
180
- buttonType: "next",
181
- text: index$1 < challenge.captchas.length - 1 ? t("WIDGET.NEXT") : t("WIDGET.SUBMIT"),
182
- onClick: index$1 < challenge.captchas.length - 1 ? onNext : onSubmit,
183
- "aria-label": index$1 < challenge.captchas.length - 1 ? t("WIDGET.NEXT") : t("WIDGET.SUBMIT"),
184
- "data-cy": "button-next"
185
- }
186
- ) })
187
- ]
188
- }
189
- )
190
- }
191
- )
192
- ]
193
- }
194
- )
195
- }
196
- ) });
197
- };
198
- module.exports = CaptchaComponent;
@@ -1,186 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const jsxRuntime = require("@emotion/react/jsx-runtime");
4
- const common = require("@prosopo/common");
5
- const webComponents = require("@prosopo/web-components");
6
- const React = require("react");
7
- const getHash = (item) => {
8
- if (!item.hash) {
9
- throw new common.ProsopoDatasetError("CAPTCHA.MISSING_ITEM_HASH", {
10
- context: { item }
11
- });
12
- }
13
- return item.hash;
14
- };
15
- const CaptchaWidget = ({
16
- challenge,
17
- solution,
18
- onClick,
19
- themeColor
20
- }) => {
21
- const items = challenge.items;
22
- const theme = React.useMemo(
23
- () => themeColor === "light" ? webComponents.lightTheme : webComponents.darkTheme,
24
- [themeColor]
25
- );
26
- const isTouchDevice = "ontouchstart" in window;
27
- const fullSpacing = `${theme.spacing.unit}px`;
28
- const halfSpacing = `${theme.spacing.half}px`;
29
- const paddingForImageColumns = {
30
- 0: {
31
- paddingLeft: 0,
32
- paddingRight: halfSpacing,
33
- paddingTop: halfSpacing,
34
- paddingBottom: halfSpacing
35
- },
36
- 1: {
37
- paddingLeft: halfSpacing,
38
- paddingRight: halfSpacing,
39
- paddingTop: halfSpacing,
40
- paddingBottom: halfSpacing
41
- },
42
- 2: {
43
- paddingLeft: halfSpacing,
44
- paddingRight: 0,
45
- paddingTop: halfSpacing,
46
- paddingBottom: halfSpacing
47
- }
48
- };
49
- const paddingForImageRows = {
50
- 0: { paddingTop: fullSpacing },
51
- 2: { paddingBottom: fullSpacing }
52
- };
53
- return /* @__PURE__ */ jsxRuntime.jsx(
54
- "div",
55
- {
56
- style: {
57
- paddingRight: 0.5,
58
- paddingBottom: 0.5,
59
- // expand to full height / width of parent
60
- width: "100%",
61
- height: "100%",
62
- // display children in flex, spreading them evenly and wrapping when row length exceeded
63
- display: "flex",
64
- flexDirection: "row",
65
- flexWrap: "wrap"
66
- },
67
- children: items.map((item, index) => {
68
- const hash = getHash(item);
69
- const imageStyle = {
70
- ...paddingForImageColumns[index % 3],
71
- ...paddingForImageRows[Math.floor(index / 3)],
72
- // enable the items in the grid to grow in width to use up excess space
73
- flexGrow: 1,
74
- // make the width of each item 1/3rd of the width overall, i.e. 3 columns
75
- flexBasis: "33.3333%",
76
- // include the padding / margin / border in the width
77
- boxSizing: "border-box"
78
- };
79
- return /* @__PURE__ */ jsxRuntime.jsx("div", { style: imageStyle, children: /* @__PURE__ */ jsxRuntime.jsxs(
80
- "div",
81
- {
82
- style: {
83
- cursor: "pointer",
84
- height: "100%",
85
- width: "100%",
86
- border: 1,
87
- borderStyle: "solid",
88
- borderColor: theme.palette.grey[300]
89
- },
90
- onClick: isTouchDevice ? void 0 : () => onClick(hash),
91
- onTouchStart: isTouchDevice ? () => onClick(hash) : void 0,
92
- children: [
93
- /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
94
- "img",
95
- {
96
- style: {
97
- width: "100%",
98
- // image should be full width / height of the item
99
- backgroundColor: theme.palette.grey[300],
100
- // colour of the bands when letterboxing and image
101
- opacity: solution.includes(hash) && isTouchDevice ? "50%" : "100%",
102
- // iphone workaround
103
- display: "block",
104
- // removes whitespace below imgs
105
- objectFit: "contain",
106
- // contain the entire image in the img tag
107
- aspectRatio: "1/1",
108
- // force AR to be 1, letterboxing images with different aspect ratios
109
- height: "auto"
110
- // make the img tag responsive to its container
111
- },
112
- src: item.data,
113
- alt: `Captcha image ${index + 1}`
114
- }
115
- ) }),
116
- /* @__PURE__ */ jsxRuntime.jsx(
117
- "div",
118
- {
119
- style: {
120
- // relative to where the element _should_ be positioned
121
- position: "relative",
122
- // make the overlay the full height/width of an item
123
- width: "100%",
124
- height: "100%",
125
- // shift it up 100% to overlay the item element
126
- top: "-100%",
127
- visibility: solution.includes(hash) ? "visible" : "hidden",
128
- // transition on opacity upon (de)selection
129
- transition: "opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
130
- opacity: 1
131
- },
132
- children: /* @__PURE__ */ jsxRuntime.jsx(
133
- "div",
134
- {
135
- style: {
136
- // make the overlay absolute positioned compare to its container
137
- position: "absolute",
138
- // spread across 100% width/height of the item box
139
- top: 0,
140
- left: 0,
141
- bottom: 0,
142
- right: 0,
143
- height: "100%",
144
- width: "100%",
145
- // display overlays in center
146
- display: "flex",
147
- alignItems: "center",
148
- justifyContent: "center",
149
- // make bg half opacity, i.e. shadowing the item's img
150
- backgroundColor: "rgba(0,0,0,0.5)"
151
- },
152
- children: /* @__PURE__ */ jsxRuntime.jsx(
153
- "svg",
154
- {
155
- style: {
156
- backgroundColor: "transparent",
157
- // img must be displayed as block otherwise gets a bottom whitespace border
158
- display: "block",
159
- // how big the overlay icon is
160
- width: "35%",
161
- height: "35%",
162
- transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
163
- userSelect: "none",
164
- fill: "currentcolor"
165
- },
166
- focusable: "false",
167
- color: "#fff",
168
- "aria-hidden": "true",
169
- viewBox: "0 0 24 24",
170
- "data-testid": "CheckIcon",
171
- "aria-label": "Check icon",
172
- children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" })
173
- }
174
- )
175
- }
176
- )
177
- }
178
- )
179
- ]
180
- }
181
- ) }, item.hash);
182
- })
183
- }
184
- );
185
- };
186
- exports.CaptchaWidget = CaptchaWidget;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- const jsxRuntime = require("@emotion/react/jsx-runtime");
3
- const React = require("react");
4
- const ModalComponent = React.memo(
5
- (props, nextProps) => {
6
- const { show, children } = props;
7
- const display = show ? "block" : "none";
8
- const ModalOuterDivCss = {
9
- position: "fixed",
10
- zIndex: 2147483646,
11
- inset: 0,
12
- display
13
- };
14
- const ModalBackgroundCSS = {
15
- position: "fixed",
16
- display: "flex",
17
- alignItems: "center",
18
- justifyContent: "center",
19
- right: 0,
20
- bottom: 0,
21
- top: 0,
22
- left: 0,
23
- backgroundColor: "rgba(0, 0, 0, 0.5)",
24
- zIndex: -1
25
- };
26
- const ModalInnerDivCSS = {
27
- position: "absolute",
28
- top: "50%",
29
- left: "50%",
30
- transform: "translate(-50%, -50%)",
31
- width: "400px",
32
- backgroundColor: "transparent",
33
- border: "none",
34
- boxShadow: "rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px,"
35
- };
36
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "prosopo-modalOuter", style: ModalOuterDivCss, children: [
37
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "prosopo-modalBackground", style: ModalBackgroundCSS }),
38
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "prosopo-modalInner", style: ModalInnerDivCSS, children })
39
- ] });
40
- }
41
- );
42
- module.exports = ModalComponent;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- const jsxRuntime = require("@emotion/react/jsx-runtime");
3
- const webComponents = require("@prosopo/web-components");
4
- const React = require("react");
5
- const _interopNamespaceDefaultOnly = (e) => Object.freeze(Object.defineProperty({ __proto__: null, default: e }, Symbol.toStringTag, { value: "Module" }));
6
- const ProcaptchaWidget = React.lazy(async () => Promise.resolve().then(() => /* @__PURE__ */ _interopNamespaceDefaultOnly(require("./ProcaptchaWidget.cjs"))));
7
- const Procaptcha = (props) => /* @__PURE__ */ jsxRuntime.jsx(
8
- React.Suspense,
9
- {
10
- fallback: /* @__PURE__ */ jsxRuntime.jsx(
11
- webComponents.ProcaptchaPlaceholder,
12
- {
13
- config: props.config,
14
- callbacks: props.callbacks
15
- }
16
- ),
17
- children: /* @__PURE__ */ jsxRuntime.jsx(ProcaptchaWidget, { config: props.config, callbacks: props.callbacks })
18
- }
19
- );
20
- module.exports = Procaptcha;