@prosopo/procaptcha-react 2.1.4 → 2.1.6
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/Button.cjs +76 -0
- package/dist/cjs/components/CaptchaComponent.cjs +198 -0
- package/dist/cjs/components/CaptchaWidget.cjs +186 -0
- package/dist/cjs/components/Modal.cjs +42 -0
- package/dist/cjs/components/Procaptcha.cjs +20 -0
- package/dist/cjs/components/ProcaptchaWidget.cjs +142 -0
- package/dist/cjs/components/index.cjs +9 -0
- package/dist/cjs/index.cjs +10 -0
- package/dist/cjs/util/index.cjs +18 -0
- package/dist/components/Button.d.ts +11 -0
- package/dist/components/Button.d.ts.map +1 -0
- package/dist/components/Button.js +61 -0
- package/dist/components/Button.js.map +1 -0
- package/dist/components/CaptchaComponent.d.ts +15 -0
- package/dist/components/CaptchaComponent.d.ts.map +1 -0
- package/dist/components/CaptchaComponent.js +78 -0
- package/dist/components/CaptchaComponent.js.map +1 -0
- package/dist/components/CaptchaWidget.d.ts +9 -0
- package/dist/components/CaptchaWidget.d.ts.map +1 -0
- package/dist/components/CaptchaWidget.js +106 -0
- package/dist/components/CaptchaWidget.js.map +1 -0
- package/dist/components/Modal.d.ts +8 -0
- package/dist/components/Modal.d.ts.map +1 -0
- package/dist/components/Modal.js +37 -0
- package/dist/components/Modal.js.map +1 -0
- package/dist/components/Procaptcha.d.ts +8 -0
- package/dist/components/Procaptcha.d.ts.map +1 -0
- package/dist/components/Procaptcha.js +7 -0
- package/dist/components/Procaptcha.js.map +1 -0
- package/dist/components/ProcaptchaWidget.d.ts +4 -0
- package/dist/components/ProcaptchaWidget.d.ts.map +1 -0
- package/dist/components/ProcaptchaWidget.js +54 -0
- package/dist/components/ProcaptchaWidget.js.map +1 -0
- package/dist/components/collector.d.ts +9 -0
- package/dist/components/collector.d.ts.map +1 -0
- package/dist/components/collector.js +26 -0
- package/dist/components/collector.js.map +1 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +6 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/util/index.d.ts +9 -0
- package/dist/util/index.d.ts.map +1 -0
- package/dist/util/index.js +12 -0
- package/dist/util/index.js.map +1 -0
- package/package.json +10 -10
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("./components/index.cjs");
|
|
4
|
+
require("./util/index.cjs");
|
|
5
|
+
const ProcaptchaWidget = require("./components/ProcaptchaWidget.cjs");
|
|
6
|
+
const Procaptcha = require("./components/Procaptcha.cjs");
|
|
7
|
+
const CaptchaWidget = require("./components/CaptchaWidget.cjs");
|
|
8
|
+
exports.ProcaptchaWidget = ProcaptchaWidget;
|
|
9
|
+
exports.Procaptcha = Procaptcha;
|
|
10
|
+
exports.CaptchaWidget = CaptchaWidget.CaptchaWidget;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
function renameKeysForDataAttr(data = {}) {
|
|
3
|
+
return Object.keys(data).reduce(
|
|
4
|
+
// biome-ignore lint/performance/noAccumulatingSpread: TODO fix
|
|
5
|
+
(prev, curr) => ({ ...prev, [`data-${curr}`]: data[curr] }),
|
|
6
|
+
{}
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
function addDataAttr({
|
|
10
|
+
general,
|
|
11
|
+
dev
|
|
12
|
+
}) {
|
|
13
|
+
return {
|
|
14
|
+
...renameKeysForDataAttr(general),
|
|
15
|
+
...process.env.NODE_ENV !== "production" ? renameKeysForDataAttr(dev) : {}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
module.exports = addDataAttr;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import { type ButtonHTMLAttributes } from "react";
|
|
3
|
+
interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
4
|
+
themeColor: "light" | "dark";
|
|
5
|
+
buttonType: "cancel" | "next";
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
text: string;
|
|
8
|
+
}
|
|
9
|
+
declare const Button: React.FC<ButtonProps>;
|
|
10
|
+
export default Button;
|
|
11
|
+
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACN,KAAK,oBAAoB,EAIzB,MAAM,OAAO,CAAC;AAGf,UAAU,WAAY,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IACpE,UAAU,EAAE,OAAO,GAAG,MAAM,CAAC;IAC7B,UAAU,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACb;AAgCD,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA+CjC,CAAC;AACF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { darkTheme, lightTheme } from "@prosopo/web-components";
|
|
3
|
+
import { useMemo, useState, } from "react";
|
|
4
|
+
import addDataAttr from "../util/index.js";
|
|
5
|
+
const buttonStyleBase = {
|
|
6
|
+
display: "inline-flex",
|
|
7
|
+
alignItems: "center",
|
|
8
|
+
justifyContent: "center",
|
|
9
|
+
position: "relative",
|
|
10
|
+
boxSizing: "border-box",
|
|
11
|
+
outline: "0px",
|
|
12
|
+
border: "0px",
|
|
13
|
+
margin: "0px",
|
|
14
|
+
cursor: "pointer",
|
|
15
|
+
userSelect: "none",
|
|
16
|
+
verticalAlign: "middle",
|
|
17
|
+
appearance: undefined,
|
|
18
|
+
textDecoration: "none",
|
|
19
|
+
fontWeight: "500",
|
|
20
|
+
fontSize: "0.875rem",
|
|
21
|
+
lineHeight: "1.75",
|
|
22
|
+
letterSpacing: "0.02857em",
|
|
23
|
+
textTransform: "uppercase",
|
|
24
|
+
minWidth: "64px",
|
|
25
|
+
padding: "6px 16px",
|
|
26
|
+
borderRadius: "4px",
|
|
27
|
+
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",
|
|
28
|
+
color: "rgb(0, 0, 0)",
|
|
29
|
+
backgroundColor: "#ffffff",
|
|
30
|
+
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",
|
|
31
|
+
};
|
|
32
|
+
const Button = ({ themeColor, buttonType, text, onClick, }) => {
|
|
33
|
+
const theme = useMemo(() => (themeColor === "light" ? lightTheme : darkTheme), [themeColor]);
|
|
34
|
+
const [hover, setHover] = useState(false);
|
|
35
|
+
const buttonStyle = useMemo(() => {
|
|
36
|
+
const baseStyle = {
|
|
37
|
+
...buttonStyleBase,
|
|
38
|
+
color: hover
|
|
39
|
+
? theme.palette.primary.contrastText
|
|
40
|
+
: theme.palette.background.contrastText,
|
|
41
|
+
};
|
|
42
|
+
if (buttonType === "cancel") {
|
|
43
|
+
return {
|
|
44
|
+
...baseStyle,
|
|
45
|
+
backgroundColor: hover ? theme.palette.grey[600] : "transparent",
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
...baseStyle,
|
|
50
|
+
backgroundColor: hover
|
|
51
|
+
? theme.palette.primary.main
|
|
52
|
+
: theme.palette.background.default,
|
|
53
|
+
};
|
|
54
|
+
}, [buttonType, hover, theme]);
|
|
55
|
+
return (_jsx("button", { ...addDataAttr({ dev: { cy: `button-${buttonType}` } }), onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false), style: buttonStyle, onClick: (e) => {
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
onClick();
|
|
58
|
+
}, "aria-label": text, children: text }));
|
|
59
|
+
};
|
|
60
|
+
export default Button;
|
|
61
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.js","sourceRoot":"","sources":["../../src/components/Button.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAGN,OAAO,EACP,QAAQ,GACR,MAAM,OAAO,CAAC;AACf,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAS3C,MAAM,eAAe,GAAkB;IACtC,OAAO,EAAE,aAAa;IACtB,UAAU,EAAE,QAAQ;IACpB,cAAc,EAAE,QAAQ;IACxB,QAAQ,EAAE,UAAU;IACpB,SAAS,EAAE,YAAY;IACvB,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,SAAS;IACjB,UAAU,EAAE,MAAM;IAClB,aAAa,EAAE,QAAQ;IACvB,UAAU,EAAE,SAAS;IACrB,cAAc,EAAE,MAAM;IACtB,UAAU,EAAE,KAAK;IACjB,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,MAAM;IAClB,aAAa,EAAE,WAAW;IAC1B,aAAa,EAAE,WAAW;IAC1B,QAAQ,EAAE,MAAM;IAChB,OAAO,EAAE,UAAU;IACnB,YAAY,EAAE,KAAK;IACnB,UAAU,EACT,+MAA+M;IAChN,KAAK,EAAE,cAAc;IACrB,eAAe,EAAE,SAAS;IAC1B,SAAS,EACR,+GAA+G;CAChH,CA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C,EAClC,YAAY,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EACnC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;YACd,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,OAAO,EAAE,CAAC;QACX,CAAC,gBACW,IAAI,YAEf,IAAI,GACG,CACT,CAAC;AACH,CAAC,CAAC;AACF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CaptchaResponseBody } from "@prosopo/types";
|
|
2
|
+
export interface CaptchaComponentProps {
|
|
3
|
+
challenge: CaptchaResponseBody;
|
|
4
|
+
index: number;
|
|
5
|
+
solutions: string[][];
|
|
6
|
+
onSubmit: () => void;
|
|
7
|
+
onCancel: () => void;
|
|
8
|
+
onClick: (hash: string) => void;
|
|
9
|
+
onNext: () => void;
|
|
10
|
+
onReload: () => void;
|
|
11
|
+
themeColor: "light" | "dark";
|
|
12
|
+
}
|
|
13
|
+
declare const CaptchaComponent: ({ challenge, index, solutions, onSubmit, onCancel, onClick, onNext, onReload, themeColor, }: CaptchaComponentProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
14
|
+
export default CaptchaComponent;
|
|
15
|
+
//# sourceMappingURL=CaptchaComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CaptchaComponent.d.ts","sourceRoot":"","sources":["../../src/components/CaptchaComponent.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAQ1D,MAAM,WAAW,qBAAqB;IACrC,SAAS,EAAE,mBAAmB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,EAAE,OAAO,GAAG,MAAM,CAAC;CAC7B;AAED,QAAA,MAAM,gBAAgB,gGAUnB,qBAAqB,qDAiKvB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useTranslation } from "@prosopo/locale-browser";
|
|
3
|
+
import { at } from "@prosopo/util";
|
|
4
|
+
import { ReloadButton, darkTheme, lightTheme } from "@prosopo/web-components";
|
|
5
|
+
import { Suspense, useMemo } from "react";
|
|
6
|
+
import addDataAttr from "../util/index.js";
|
|
7
|
+
import Button from "./Button.js";
|
|
8
|
+
import { CaptchaWidget } from "./CaptchaWidget.js";
|
|
9
|
+
const CaptchaComponent = ({ challenge, index, solutions, onSubmit, onCancel, onClick, onNext, onReload, themeColor, }) => {
|
|
10
|
+
const { t } = useTranslation();
|
|
11
|
+
const captcha = challenge.captchas ? at(challenge.captchas, index) : null;
|
|
12
|
+
const solution = solutions ? at(solutions, index) : [];
|
|
13
|
+
const theme = useMemo(() => (themeColor === "light" ? lightTheme : darkTheme), [themeColor]);
|
|
14
|
+
return (_jsx(Suspense, { fallback: _jsx("div", { children: "Loading..." }), children: _jsx("div", { style: {
|
|
15
|
+
overflowX: "auto",
|
|
16
|
+
overflowY: "auto",
|
|
17
|
+
width: "100%",
|
|
18
|
+
maxWidth: "500px",
|
|
19
|
+
maxHeight: "100%",
|
|
20
|
+
display: "flex",
|
|
21
|
+
flexDirection: "column",
|
|
22
|
+
border: "1px solid #dddddd",
|
|
23
|
+
boxShadow: "rgba(255, 255, 255, 0.2) 0px 0px 4px",
|
|
24
|
+
borderRadius: "4px",
|
|
25
|
+
padding: `${theme.spacing.unit}px`,
|
|
26
|
+
backgroundColor: theme.palette.background.default,
|
|
27
|
+
}, children: _jsxs("div", { style: {
|
|
28
|
+
backgroundColor: theme.palette.background.default,
|
|
29
|
+
display: "flex",
|
|
30
|
+
flexDirection: "column",
|
|
31
|
+
minWidth: "300px",
|
|
32
|
+
}, children: [_jsx("div", { style: {
|
|
33
|
+
display: "flex",
|
|
34
|
+
alignItems: "center",
|
|
35
|
+
width: "100%",
|
|
36
|
+
}, children: _jsx("div", { style: {
|
|
37
|
+
backgroundColor: theme.palette.primary.main,
|
|
38
|
+
width: "100%",
|
|
39
|
+
}, children: _jsxs("div", { style: {
|
|
40
|
+
paddingLeft: `${theme.spacing.half}px`,
|
|
41
|
+
paddingRight: `${theme.spacing.half}px`,
|
|
42
|
+
}, children: [_jsxs("p", { style: {
|
|
43
|
+
color: "#ffffff",
|
|
44
|
+
fontWeight: 700,
|
|
45
|
+
lineHeight: 1.5,
|
|
46
|
+
}, children: [t("WIDGET.SELECT_ALL"), ":", "\u00A0", _jsx("span", { children: `${t(at(challenge.captchas, index).target)} ` })] }), _jsx("p", { style: {
|
|
47
|
+
color: "#ffffff",
|
|
48
|
+
fontWeight: 500,
|
|
49
|
+
lineHeight: 0.8,
|
|
50
|
+
fontSize: "0.8rem",
|
|
51
|
+
}, children: t("WIDGET.IF_NONE_CLICK_NEXT") })] }) }) }), _jsx("div", { ...addDataAttr({ dev: { cy: `captcha-${index}` } }), children: captcha && (_jsx(CaptchaWidget, { challenge: captcha, solution: solution, onClick: onClick, themeColor: themeColor })) }), _jsx("div", { style: {
|
|
52
|
+
display: "flex",
|
|
53
|
+
alignItems: "center",
|
|
54
|
+
justifyContent: "center",
|
|
55
|
+
width: "100%",
|
|
56
|
+
}, ...addDataAttr({ dev: { cy: "dots-captcha" } }) }), _jsx("div", { style: {
|
|
57
|
+
padding: `0 ${theme.spacing}px`,
|
|
58
|
+
display: "flex",
|
|
59
|
+
width: "100%",
|
|
60
|
+
} }), _jsx("div", { style: {
|
|
61
|
+
padding: `0 ${theme.spacing}px`,
|
|
62
|
+
display: "flex",
|
|
63
|
+
alignItems: "center",
|
|
64
|
+
justifyContent: "space-between",
|
|
65
|
+
lineHeight: 1.75,
|
|
66
|
+
}, children: _jsxs("div", { style: {
|
|
67
|
+
display: "grid",
|
|
68
|
+
gridAutoFlow: "column",
|
|
69
|
+
gridTemplateColumns: "repeat(3, minmax(0, 1fr)",
|
|
70
|
+
width: "100%",
|
|
71
|
+
}, children: [_jsx("div", { style: { justifySelf: "left" }, children: _jsx(Button, { themeColor: themeColor, buttonType: "cancel", onClick: onCancel, text: t("WIDGET.CANCEL"), "aria-label": t("WIDGET.CANCEL") }) }), _jsx("div", { style: { justifySelf: "center" }, children: _jsx(ReloadButton, { themeColor: themeColor, onReload: onReload }) }), _jsx("div", { style: { justifySelf: "right" }, children: _jsx(Button, { themeColor: themeColor, buttonType: "next", text: index < challenge.captchas.length - 1
|
|
72
|
+
? t("WIDGET.NEXT")
|
|
73
|
+
: t("WIDGET.SUBMIT"), onClick: index < challenge.captchas.length - 1 ? onNext : onSubmit, "aria-label": index < challenge.captchas.length - 1
|
|
74
|
+
? t("WIDGET.NEXT")
|
|
75
|
+
: t("WIDGET.SUBMIT"), "data-cy": "button-next" }) })] }) })] }) }) }));
|
|
76
|
+
};
|
|
77
|
+
export default CaptchaComponent;
|
|
78
|
+
//# sourceMappingURL=CaptchaComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CaptchaComponent.js","sourceRoot":"","sources":["../../src/components/CaptchaComponent.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,WAAW,MAAM,kBAAkB,CAA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AAC,CAAC,eAAe,CAAC,EAEtB,OAAO,EACN,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,gBAGzD,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;4CACpC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC;4CAClB,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,aAEd,aAAa,GACpB,GACG,IACD,GACD,IACD,GACD,GACI,CACX,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Captcha } from "@prosopo/types";
|
|
2
|
+
export interface CaptchaWidgetProps {
|
|
3
|
+
challenge: Captcha;
|
|
4
|
+
solution: string[];
|
|
5
|
+
onClick: (hash: string) => void;
|
|
6
|
+
themeColor: "light" | "dark";
|
|
7
|
+
}
|
|
8
|
+
export declare const CaptchaWidget: ({ challenge, solution, onClick, themeColor, }: CaptchaWidgetProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=CaptchaWidget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/CaptchaWidget.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAK9C,MAAM,WAAW,kBAAkB;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,UAAU,EAAE,OAAO,GAAG,MAAM,CAAC;CAC7B;AAYD,eAAO,MAAM,aAAa,kDAKvB,kBAAkB,qDAiKpB,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { ProsopoDatasetError } from "@prosopo/common";
|
|
3
|
+
import { darkTheme, lightTheme } from "@prosopo/web-components";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
const getHash = (item) => {
|
|
6
|
+
if (!item.hash) {
|
|
7
|
+
throw new ProsopoDatasetError("CAPTCHA.MISSING_ITEM_HASH", {
|
|
8
|
+
context: { item },
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
return item.hash;
|
|
12
|
+
};
|
|
13
|
+
export const CaptchaWidget = ({ challenge, solution, onClick, themeColor, }) => {
|
|
14
|
+
const items = challenge.items;
|
|
15
|
+
const theme = useMemo(() => (themeColor === "light" ? lightTheme : darkTheme), [themeColor]);
|
|
16
|
+
const isTouchDevice = "ontouchstart" in window;
|
|
17
|
+
const fullSpacing = `${theme.spacing.unit}px`;
|
|
18
|
+
const halfSpacing = `${theme.spacing.half}px`;
|
|
19
|
+
const paddingForImageColumns = {
|
|
20
|
+
0: {
|
|
21
|
+
paddingLeft: 0,
|
|
22
|
+
paddingRight: halfSpacing,
|
|
23
|
+
paddingTop: halfSpacing,
|
|
24
|
+
paddingBottom: halfSpacing,
|
|
25
|
+
},
|
|
26
|
+
1: {
|
|
27
|
+
paddingLeft: halfSpacing,
|
|
28
|
+
paddingRight: halfSpacing,
|
|
29
|
+
paddingTop: halfSpacing,
|
|
30
|
+
paddingBottom: halfSpacing,
|
|
31
|
+
},
|
|
32
|
+
2: {
|
|
33
|
+
paddingLeft: halfSpacing,
|
|
34
|
+
paddingRight: 0,
|
|
35
|
+
paddingTop: halfSpacing,
|
|
36
|
+
paddingBottom: halfSpacing,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const paddingForImageRows = {
|
|
40
|
+
0: { paddingTop: fullSpacing },
|
|
41
|
+
2: { paddingBottom: fullSpacing },
|
|
42
|
+
};
|
|
43
|
+
return (_jsx("div", { style: {
|
|
44
|
+
paddingRight: 0.5,
|
|
45
|
+
paddingBottom: 0.5,
|
|
46
|
+
width: "100%",
|
|
47
|
+
height: "100%",
|
|
48
|
+
display: "flex",
|
|
49
|
+
flexDirection: "row",
|
|
50
|
+
flexWrap: "wrap",
|
|
51
|
+
}, children: items.map((item, index) => {
|
|
52
|
+
const hash = getHash(item);
|
|
53
|
+
const imageStyle = {
|
|
54
|
+
...paddingForImageColumns[index % 3],
|
|
55
|
+
...paddingForImageRows[Math.floor(index / 3)],
|
|
56
|
+
flexGrow: 1,
|
|
57
|
+
flexBasis: "33.3333%",
|
|
58
|
+
boxSizing: "border-box",
|
|
59
|
+
};
|
|
60
|
+
return (_jsx("div", { style: imageStyle, children: _jsxs("div", { style: {
|
|
61
|
+
cursor: "pointer",
|
|
62
|
+
height: "100%",
|
|
63
|
+
width: "100%",
|
|
64
|
+
border: 1,
|
|
65
|
+
borderStyle: "solid",
|
|
66
|
+
borderColor: theme.palette.grey[300],
|
|
67
|
+
}, onClick: isTouchDevice ? undefined : () => onClick(hash), onTouchStart: isTouchDevice ? () => onClick(hash) : undefined, children: [_jsx("div", { children: _jsx("img", { style: {
|
|
68
|
+
width: "100%",
|
|
69
|
+
backgroundColor: theme.palette.grey[300],
|
|
70
|
+
opacity: solution.includes(hash) && isTouchDevice ? "50%" : "100%",
|
|
71
|
+
display: "block",
|
|
72
|
+
objectFit: "contain",
|
|
73
|
+
aspectRatio: "1/1",
|
|
74
|
+
height: "auto",
|
|
75
|
+
}, src: item.data, alt: `Captcha image ${index + 1}` }) }), _jsx("div", { style: {
|
|
76
|
+
position: "relative",
|
|
77
|
+
width: "100%",
|
|
78
|
+
height: "100%",
|
|
79
|
+
top: "-100%",
|
|
80
|
+
visibility: solution.includes(hash) ? "visible" : "hidden",
|
|
81
|
+
transition: "opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
|
|
82
|
+
opacity: 1,
|
|
83
|
+
}, children: _jsx("div", { style: {
|
|
84
|
+
position: "absolute",
|
|
85
|
+
top: 0,
|
|
86
|
+
left: 0,
|
|
87
|
+
bottom: 0,
|
|
88
|
+
right: 0,
|
|
89
|
+
height: "100%",
|
|
90
|
+
width: "100%",
|
|
91
|
+
display: "flex",
|
|
92
|
+
alignItems: "center",
|
|
93
|
+
justifyContent: "center",
|
|
94
|
+
backgroundColor: "rgba(0,0,0,0.5)",
|
|
95
|
+
}, children: _jsx("svg", { style: {
|
|
96
|
+
backgroundColor: "transparent",
|
|
97
|
+
display: "block",
|
|
98
|
+
width: "35%",
|
|
99
|
+
height: "35%",
|
|
100
|
+
transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
|
|
101
|
+
userSelect: "none",
|
|
102
|
+
fill: "currentcolor",
|
|
103
|
+
}, focusable: "false", color: "#fff", "aria-hidden": "true", viewBox: "0 0 24 24", "data-testid": "CheckIcon", "aria-label": "Check icon", children: _jsx("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) }) }) })] }) }, item.hash));
|
|
104
|
+
}) }));
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=CaptchaWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CaptchaWidget.js","sourceRoot":"","sources":["../../src/components/CaptchaWidget.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAUhC,MAAM,OAAO,GAAG,CAAC,IAAS,EAAE,EAAE;IAC7B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAChB,MAAM,IAAI,mBAAmB,CAAC,2BAA2B,EAAE;YAC1D,OAAO,EAAE,EAAE,IAAI,EAAE;SACjB,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC;AA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ModalProps = {
|
|
3
|
+
show: boolean;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
};
|
|
6
|
+
declare const ModalComponent: React.MemoExoticComponent<(props: ModalProps, nextProps: ModalProps) => import("@emotion/react/jsx-runtime").JSX.Element>;
|
|
7
|
+
export default ModalComponent;
|
|
8
|
+
//# sourceMappingURL=Modal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../src/components/Modal.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAClD,KAAK,UAAU,GAAG;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B,CAAC;AAEF,QAAA,MAAM,cAAc,oCACX,UAAU,aAAa,UAAU,sDA2CzC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
const ModalComponent = React.memo((props, nextProps) => {
|
|
4
|
+
const { show, children } = props;
|
|
5
|
+
const display = show ? "block" : "none";
|
|
6
|
+
const ModalOuterDivCss = {
|
|
7
|
+
position: "fixed",
|
|
8
|
+
zIndex: 2147483646,
|
|
9
|
+
inset: 0,
|
|
10
|
+
display,
|
|
11
|
+
};
|
|
12
|
+
const ModalBackgroundCSS = {
|
|
13
|
+
position: "fixed",
|
|
14
|
+
display: "flex",
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
justifyContent: "center",
|
|
17
|
+
right: 0,
|
|
18
|
+
bottom: 0,
|
|
19
|
+
top: 0,
|
|
20
|
+
left: 0,
|
|
21
|
+
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
22
|
+
zIndex: -1,
|
|
23
|
+
};
|
|
24
|
+
const ModalInnerDivCSS = {
|
|
25
|
+
position: "absolute",
|
|
26
|
+
top: "50%",
|
|
27
|
+
left: "50%",
|
|
28
|
+
transform: "translate(-50%, -50%)",
|
|
29
|
+
width: "400px",
|
|
30
|
+
backgroundColor: "transparent",
|
|
31
|
+
border: "none",
|
|
32
|
+
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,",
|
|
33
|
+
};
|
|
34
|
+
return (_jsxs("div", { className: "prosopo-modalOuter", style: ModalOuterDivCss, children: [_jsx("div", { className: "prosopo-modalBackground", style: ModalBackgroundCSS }), _jsx("div", { className: "prosopo-modalInner", style: ModalInnerDivCSS, children: children })] }));
|
|
35
|
+
});
|
|
36
|
+
export default ModalComponent;
|
|
37
|
+
//# sourceMappingURL=Modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/components/Modal.tsx"],"names":[],"mappings":";AAaA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAMlD,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAChC,CAAC,KAAiB,EAAE,SAAqB,EAAE,EAAE;IAC5C,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACjC,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IACxC,MAAM,gBAAgB,GAAkB;QACvC,QAAQ,EAAE,OAAO;QACjB,MAAM,EAAE,UAAU;QAClB,KAAK,EAAE,CAAC;QACR,OAAO;KACP,CAAC;IAEF,MAAM,kBAAkB,GAAkB;QACzC,QAAQ,EAAE,OAAO;QACjB,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;QACxB,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,GAAG,EAAE,CAAC;QACN,IAAI,EAAE,CAAC;QACP,eAAe,EAAE,oBAAoB;QACrC,MAAM,EAAE,CAAC,CAAC;KACV,CAAC;IACF,MAAM,gBAAgB,GAAkB;QACvC,QAAQ,EAAE,UAAU;QACpB,GAAG,EAAE,KAAK;QACV,IAAI,EAAE,KAAK;QACX,SAAS,EAAE,uBAAuB;QAClC,KAAK,EAAE,OAAO;QACd,eAAe,EAAE,aAAa;QAC9B,MAAM,EAAE,MAAM;QACd,SAAS,EACR,qHAAqH;KACtH,CAAC;IAEF,OAAO,CACN,eAAK,SAAS,EAAC,oBAAoB,EAAC,KAAK,EAAE,gBAAgB,aAC1D,cAAK,SAAS,EAAC,yBAAyB,EAAC,KAAK,EAAE,kBAAkB,GAAI,EACtE,cAAK,SAAS,EAAC,oBAAoB,EAAC,KAAK,EAAE,gBAAgB,YACzD,QAAQ,GACJ,IACD,CACN,CAAC;AACH,CAAC,CACD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ProcaptchaEvents } from "@prosopo/types";
|
|
2
|
+
import { type LazyExoticComponent } from "react";
|
|
3
|
+
import type { ReactElement } from "react";
|
|
4
|
+
declare const ProcaptchaWidget: LazyExoticComponent<(props: any, callbacks: Partial<ProcaptchaEvents>) => ReactElement>;
|
|
5
|
+
type ProcaptchaProps = React.ComponentProps<typeof ProcaptchaWidget>;
|
|
6
|
+
declare const Procaptcha: (props: ProcaptchaProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default Procaptcha;
|
|
8
|
+
//# sourceMappingURL=Procaptcha.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Procaptcha.d.ts","sourceRoot":"","sources":["../../src/components/Procaptcha.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAE,KAAK,mBAAmB,EAAkB,MAAM,OAAO,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,QAAA,MAAM,gBAAgB,EAAE,mBAAmB,CAE1C,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,CAAC,gBAAgB,CAAC,KAAK,YAAY,CACd,CAAC;AACtD,KAAK,eAAe,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAErE,QAAA,MAAM,UAAU,UAAW,eAAe,qDAWzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { ProcaptchaPlaceholder } from "@prosopo/web-components";
|
|
3
|
+
import { Suspense, lazy } from "react";
|
|
4
|
+
const ProcaptchaWidget = lazy(async () => import("./ProcaptchaWidget.js"));
|
|
5
|
+
const Procaptcha = (props) => (_jsx(Suspense, { fallback: _jsx(ProcaptchaPlaceholder, { config: props.config, callbacks: props.callbacks }), children: _jsx(ProcaptchaWidget, { config: props.config, callbacks: props.callbacks }) }));
|
|
6
|
+
export default Procaptcha;
|
|
7
|
+
//# sourceMappingURL=Procaptcha.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Procaptcha.js","sourceRoot":"","sources":["../../src/components/Procaptcha.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAA4B,QAAQ,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAIjE,MAAM,gBAAgB,GAGlB,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC,CAAC;AAGtD,MAAM,UAAU,GAAG,CAAC,KAAsB,EAAE,EAAE,CAAC,CAC9C,KAAC,QAAQ,IACR,QAAQ,EACP,KAAC,qBAAqB,IACrB,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,SAAS,EAAE,KAAK,CAAC,SAAS,GACzB,YAGH,KAAC,gBAAgB,IAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,GAAI,GAC5D,CACX,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProcaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAsB9E,QAAA,MAAM,gBAAgB,UAAW,eAAe,qDA2H/C,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { i18n, useTranslation } from "@prosopo/locale-browser";
|
|
3
|
+
import { Manager } from "@prosopo/procaptcha";
|
|
4
|
+
import { useProcaptcha } from "@prosopo/procaptcha-common";
|
|
5
|
+
import { ProcaptchaConfigSchema } from "@prosopo/types";
|
|
6
|
+
import { Checkbox, ContainerDiv, LoadingSpinner, WIDGET_BORDER, WIDGET_BORDER_RADIUS, WIDGET_DIMENSIONS, WIDGET_INNER_HEIGHT, WIDGET_MAX_WIDTH, WIDGET_PADDING, WIDGET_URL, WIDGET_URL_TEXT, WidthBasedStylesDiv, darkTheme, lightTheme, } from "@prosopo/web-components";
|
|
7
|
+
import { Logo } from "@prosopo/web-components";
|
|
8
|
+
import { useEffect, useRef, useState } from "react";
|
|
9
|
+
import CaptchaComponent from "./CaptchaComponent.js";
|
|
10
|
+
import Modal from "./Modal.js";
|
|
11
|
+
const ProcaptchaWidget = (props) => {
|
|
12
|
+
const { t } = useTranslation();
|
|
13
|
+
const config = ProcaptchaConfigSchema.parse(props.config);
|
|
14
|
+
const callbacks = props.callbacks || {};
|
|
15
|
+
const [state, updateState] = useProcaptcha(useState, useRef);
|
|
16
|
+
const manager = Manager(config, state, updateState, callbacks);
|
|
17
|
+
const themeColor = props.config.theme === "light" ? "light" : "dark";
|
|
18
|
+
const theme = props.config.theme === "light" ? lightTheme : darkTheme;
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (config.language) {
|
|
21
|
+
i18n.changeLanguage(config.language);
|
|
22
|
+
}
|
|
23
|
+
}, [config.language]);
|
|
24
|
+
return (_jsx("div", { children: _jsxs("div", { style: {
|
|
25
|
+
maxWidth: WIDGET_MAX_WIDTH,
|
|
26
|
+
maxHeight: "100%",
|
|
27
|
+
overflowX: "auto",
|
|
28
|
+
}, children: [_jsx(Modal, { show: state.showModal, children: state.challenge ? (_jsx(CaptchaComponent, { challenge: state.challenge, index: state.index, solutions: state.solutions, onSubmit: manager.submit, onCancel: manager.cancel, onClick: manager.select, onNext: manager.nextRound, onReload: manager.reload, themeColor: config.theme ?? "light" })) : (_jsx("div", { children: "No challenge set." })) }), _jsx(ContainerDiv, { children: _jsx(WidthBasedStylesDiv, { children: _jsxs("div", { style: WIDGET_DIMENSIONS, "data-cy": "button-human", children: [" ", _jsxs("div", { style: {
|
|
29
|
+
padding: WIDGET_PADDING,
|
|
30
|
+
border: WIDGET_BORDER,
|
|
31
|
+
backgroundColor: theme.palette.background.default,
|
|
32
|
+
borderColor: theme.palette.grey[300],
|
|
33
|
+
borderRadius: WIDGET_BORDER_RADIUS,
|
|
34
|
+
display: "flex",
|
|
35
|
+
alignItems: "center",
|
|
36
|
+
flexWrap: "wrap",
|
|
37
|
+
justifyContent: "space-between",
|
|
38
|
+
minHeight: `${WIDGET_INNER_HEIGHT}px`,
|
|
39
|
+
overflow: "hidden",
|
|
40
|
+
}, children: [_jsx("div", { style: { display: "inline-flex", flexDirection: "column" }, children: _jsx("div", { style: {
|
|
41
|
+
alignItems: "center",
|
|
42
|
+
flex: 1,
|
|
43
|
+
}, children: _jsx("div", { style: {
|
|
44
|
+
display: "flex",
|
|
45
|
+
alignItems: "center",
|
|
46
|
+
justifyContent: "center",
|
|
47
|
+
flexDirection: "column",
|
|
48
|
+
verticalAlign: "middle",
|
|
49
|
+
}, children: _jsx("div", { style: {
|
|
50
|
+
display: "flex",
|
|
51
|
+
}, children: state.loading ? (_jsx(LoadingSpinner, { themeColor: themeColor, "aria-label": "Loading spinner" })) : (_jsx(Checkbox, { themeColor: themeColor, onChange: manager.start, checked: state.isHuman, labelText: t("WIDGET.I_AM_HUMAN"), error: state.error, "aria-label": "human checkbox" })) }) }) }) }), _jsx("div", { style: { display: "inline-flex", flexDirection: "column" }, children: _jsx("a", { href: WIDGET_URL, target: "_blank", "aria-label": WIDGET_URL_TEXT, rel: "noreferrer", children: _jsx("div", { style: { flex: 1 }, children: _jsx(Logo, { themeColor: themeColor, "aria-label": "Prosopo logo" }) }) }) })] })] }) }) })] }) }));
|
|
52
|
+
};
|
|
53
|
+
export default ProcaptchaWidget;
|
|
54
|
+
//# sourceMappingURL=ProcaptchaWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProcaptchaWidget.js","sourceRoot":"","sources":["../../src/components/ProcaptchaWidget.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAwB,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EACN,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,SAAS,EACT,UAAU,GACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,E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K,EAAE;4DACN,OAAO,EAAE,MAAM;yDACf,YAEA,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAChB,KAAC,cAAc,IACd,UAAU,EAAE,UAAU,gBACX,iBAAiB,GAC3B,CACF,CAAC,CAAC,CAAC,CACH,KAAC,QAAQ,IACR,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,OAAO,CAAC,KAAK,EACvB,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,SAAS,EAAE,CAAC,CAAC,mBAAmB,CAAC,EACjC,KAAK,EAAE,KAAK,CAAC,KAAK,gBACP,gBAAgB,GAC1B,CACF,GACI,GACD,GACD,GACD,EACN,cACC,KAAK,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,YAE1D,YACC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAC,QAAQ,gBACH,eAAe,EAC3B,GAAG,EAAC,YAAY,YAEhB,cAAK,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,YACtB,KAAC,IAAI,IAAC,UAAU,EAAE,UAAU,gBAAa,cAAc,GAAG,GACrD,GACH,GACC,IACD,IACD,GACe,GACR,IACV,GACD,CACN,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Account, StoredEvents } from "@prosopo/types";
|
|
2
|
+
type CollectorProps = {
|
|
3
|
+
onProcessData: (data: StoredEvents) => void;
|
|
4
|
+
sendData: boolean;
|
|
5
|
+
account: Account | undefined;
|
|
6
|
+
};
|
|
7
|
+
declare const Collector: ({ onProcessData, sendData, account }: CollectorProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default Collector;
|
|
9
|
+
//# sourceMappingURL=collector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collector.d.ts","sourceRoot":"","sources":["../../src/components/collector.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACX,OAAO,EAIP,YAAY,EACZ,MAAM,gBAAgB,CAAC;AAGxB,KAAK,cAAc,GAAG;IACrB,aAAa,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;IAC5C,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;CAC7B,CAAC;AAEF,QAAA,MAAM,SAAS,yCAA0C,cAAc,qDAgCtE,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { startCollector } from "@prosopo/procaptcha";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
const Collector = ({ onProcessData, sendData, account }) => {
|
|
5
|
+
const [mouseEvents, setStoredMouseEvents] = useState([]);
|
|
6
|
+
const [touchEvents, setStoredTouchEvents] = useState([]);
|
|
7
|
+
const [keyboardEvents, setStoredKeyboardEvents] = useState([]);
|
|
8
|
+
const ref = useRef(null);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (ref?.current) {
|
|
11
|
+
startCollector(setStoredMouseEvents, setStoredTouchEvents, setStoredKeyboardEvents, ref.current);
|
|
12
|
+
}
|
|
13
|
+
}, []);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const userEvents = {
|
|
16
|
+
mouseEvents,
|
|
17
|
+
touchEvents,
|
|
18
|
+
keyboardEvents,
|
|
19
|
+
};
|
|
20
|
+
if (account)
|
|
21
|
+
onProcessData(userEvents);
|
|
22
|
+
}, [onProcessData, account]);
|
|
23
|
+
return _jsx("div", { ref: ref });
|
|
24
|
+
};
|
|
25
|
+
export default Collector;
|
|
26
|
+
//# sourceMappingURL=collector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collector.js","sourceRoot":"","sources":["../../src/components/collector.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAQrD,OAAO,EAAyB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAQ3E,MAAM,SAAS,GAAG,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAkB,EAAE,EAAE;IAC1E,MAAM,CAAC,WAAW,EAAE,oBAAoB,CAAC,GAAG,QAAQ,CAAsB,EAAE,CAAC,CAAC;IAC9E,MAAM,CAAC,WAAW,EAAE,oBAAoB,CAAC,GAAG,QAAQ,CAAsB,EAAE,CAAC,CAAC;IAC9E,MAAM,CAAC,cAAc,EAAE,uBAAuB,CAAC,GAAG,QAAQ,CAExD,EAAE,CAAC,CAAC;IAEN,MAAM,GAAG,GACR,MAAM,CAAiB,IAAI,CAAC,CAAC;IAE9B,SAAS,CAAC,GAAG,EAAE;QACd,IAAI,GAAG,EAAE,OAAO,EAAE,CAAC;YAClB,cAAc,CACb,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,GAAG,CAAC,OAAO,CACX,CAAC;QACH,CAAC;IACF,CAAC,EAAE,EAAE,CAAC,CAAC;IAGP,SAAS,CAAC,GAAG,EAAE;QACd,MAAM,UAAU,GAAG;YAClB,WAAW;YACX,WAAW;YACX,cAAc;SACd,CAAC;QACF,IAAI,OAAO;YAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;IAE7B,OAAO,cAAK,GAAG,EAAE,GAAG,GAAI,CAAC;AAC1B,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./CaptchaWidget.js";
|
|
2
|
+
export * from "./CaptchaComponent.js";
|
|
3
|
+
export { default as ProcaptchaWidget } from "./ProcaptchaWidget.js";
|
|
4
|
+
export { default as Procaptcha } from "./Procaptcha.js";
|
|
5
|
+
export * from "./Procaptcha.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from "./CaptchaWidget.js";
|
|
2
|
+
export * from "./CaptchaComponent.js";
|
|
3
|
+
export { default as ProcaptchaWidget } from "./ProcaptchaWidget.js";
|
|
4
|
+
export { default as Procaptcha } from "./Procaptcha.js";
|
|
5
|
+
export * from "./Procaptcha.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAaA,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,cAAc,iBAAiB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC"}
|