@prosopo/procaptcha-common 2.7.9 → 2.7.11

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 (44) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/callbacks/defaultCallbacks.js +149 -114
  3. package/dist/callbacks/defaultEvents.js +6 -4
  4. package/dist/elements/form.js +13 -8
  5. package/dist/elements/window.js +11 -7
  6. package/dist/extensionLoader.js +4 -4
  7. package/dist/index.js +21 -9
  8. package/dist/providers.js +33 -26
  9. package/dist/reactComponents/Checkbox.js +104 -56
  10. package/dist/reactComponents/Reload.js +79 -40
  11. package/dist/state/builder.js +82 -83
  12. package/package.json +18 -15
  13. package/vite.cjs.config.ts +2 -2
  14. package/vite.esm.config.ts +20 -0
  15. package/dist/callbacks/defaultCallbacks.d.ts +0 -4
  16. package/dist/callbacks/defaultCallbacks.d.ts.map +0 -1
  17. package/dist/callbacks/defaultCallbacks.js.map +0 -1
  18. package/dist/callbacks/defaultEvents.d.ts +0 -14
  19. package/dist/callbacks/defaultEvents.d.ts.map +0 -1
  20. package/dist/callbacks/defaultEvents.js.map +0 -1
  21. package/dist/elements/form.d.ts +0 -3
  22. package/dist/elements/form.d.ts.map +0 -1
  23. package/dist/elements/form.js.map +0 -1
  24. package/dist/elements/window.d.ts +0 -2
  25. package/dist/elements/window.d.ts.map +0 -1
  26. package/dist/elements/window.js.map +0 -1
  27. package/dist/extensionLoader.d.ts +0 -2
  28. package/dist/extensionLoader.d.ts.map +0 -1
  29. package/dist/extensionLoader.js.map +0 -1
  30. package/dist/index.d.ts +0 -9
  31. package/dist/index.d.ts.map +0 -1
  32. package/dist/index.js.map +0 -1
  33. package/dist/providers.d.ts +0 -4
  34. package/dist/providers.d.ts.map +0 -1
  35. package/dist/providers.js.map +0 -1
  36. package/dist/reactComponents/Checkbox.d.ts +0 -13
  37. package/dist/reactComponents/Checkbox.d.ts.map +0 -1
  38. package/dist/reactComponents/Checkbox.js.map +0 -1
  39. package/dist/reactComponents/Reload.d.ts +0 -8
  40. package/dist/reactComponents/Reload.d.ts.map +0 -1
  41. package/dist/reactComponents/Reload.js.map +0 -1
  42. package/dist/state/builder.d.ts +0 -9
  43. package/dist/state/builder.d.ts.map +0 -1
  44. package/dist/state/builder.js.map +0 -1
@@ -1,9 +1,9 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
1
+ import { jsxs, jsx } from "@emotion/react/jsx-runtime";
2
2
  import { css } from "@emotion/react";
3
3
  import styled from "@emotion/styled";
4
- import { WIDGET_CHECKBOX_SPINNER_CSS_CLASS, } from "@prosopo/widget-skeleton";
5
- import { useMemo, useState, } from "react";
6
- const checkboxBefore = css `{
4
+ import { WIDGET_CHECKBOX_SPINNER_CSS_CLASS } from "@prosopo/widget-skeleton";
5
+ import { useState, useMemo } from "react";
6
+ const checkboxBefore = css`{
7
7
  &:before {
8
8
  content: '""';
9
9
  position: absolute;
@@ -12,34 +12,42 @@ const checkboxBefore = css `{
12
12
  }
13
13
  }`;
14
14
  const baseStyle = {
15
- width: "28px",
16
- height: "28px",
17
- minWidth: "14px",
18
- minHeight: "14px",
19
- top: "auto",
20
- left: "auto",
21
- opacity: "1",
22
- borderRadius: "12.5%",
23
- appearance: "none",
24
- cursor: "pointer",
25
- margin: "0",
26
- borderStyle: "solid",
27
- borderWidth: "1px",
15
+ width: "28px",
16
+ height: "28px",
17
+ minWidth: "14px",
18
+ minHeight: "14px",
19
+ top: "auto",
20
+ left: "auto",
21
+ opacity: "1",
22
+ borderRadius: "12.5%",
23
+ appearance: "none",
24
+ cursor: "pointer",
25
+ margin: "0",
26
+ borderStyle: "solid",
27
+ borderWidth: "1px"
28
28
  };
29
29
  const ID_LETTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
30
- const FAQ_LINK = process.env.PROSOPO_DOCS_URL
31
- ? `${new URL(`${process.env.PROSOPO_DOCS_URL}/en/basics/faq/`).href}/`
32
- : "https://docs.prosopo.io/en/basics/faq/";
30
+ const FAQ_LINK = process.env.PROSOPO_DOCS_URL ? `${new URL(`${process.env.PROSOPO_DOCS_URL}/en/basics/faq/`).href}/` : "https://docs.prosopo.io/en/basics/faq/";
33
31
  const generateRandomId = () => {
34
- return Array.from({ length: 8 }, () => ID_LETTERS[Math.floor(Math.random() * ID_LETTERS.length)]).join("");
32
+ return Array.from(
33
+ { length: 8 },
34
+ () => ID_LETTERS[Math.floor(Math.random() * ID_LETTERS.length)]
35
+ ).join("");
35
36
  };
36
- export const Checkbox = ({ theme, onChange, checked, labelText, error, loading, }) => {
37
- const checkboxStyleBase = {
38
- ...baseStyle,
39
- border: `1px solid ${theme.palette.background.contrastText}`,
40
- };
41
- const [hover, setHover] = useState(false);
42
- const ResponsiveLabel = styled.label `
37
+ const Checkbox = ({
38
+ theme,
39
+ onChange,
40
+ checked,
41
+ labelText,
42
+ error,
43
+ loading
44
+ }) => {
45
+ const checkboxStyleBase = {
46
+ ...baseStyle,
47
+ border: `1px solid ${theme.palette.background.contrastText}`
48
+ };
49
+ const [hover, setHover] = useState(false);
50
+ const ResponsiveLabel = styled.label`
43
51
  color: ${theme.palette.background.contrastText};
44
52
  position: relative;
45
53
  display: flex;
@@ -59,32 +67,72 @@ export const Checkbox = ({ theme, onChange, checked, labelText, error, loading,
59
67
  font-size: 16px;
60
68
  }
61
69
  `;
62
- const checkboxStyle = useMemo(() => {
63
- return {
64
- ...checkboxStyleBase,
65
- borderColor: hover
66
- ? theme.palette.background.contrastText
67
- : theme.palette.border,
68
- appearance: checked ? "auto" : "none",
69
- flex: 1,
70
- margin: "15px",
71
- minWidth: "28px",
72
- minHeight: "28px",
73
- };
74
- }, [hover, theme, checked]);
75
- const id = generateRandomId();
76
- return (_jsxs("span", { style: {
77
- display: "inline-flex",
78
- alignItems: "center",
79
- minHeight: "58px",
80
- }, children: [loading ? (_jsx("div", { className: WIDGET_CHECKBOX_SPINNER_CSS_CLASS, "aria-label": "Loading spinner" })) : (_jsx("input", { name: id, id: id, onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false), css: checkboxBefore, type: "checkbox", "aria-live": "assertive", "aria-label": labelText, onChange: (e) => {
81
- e.preventDefault();
82
- e.stopPropagation();
83
- setHover(false);
84
- onChange();
85
- }, checked: checked, style: checkboxStyle, disabled: error !== undefined, className: loading ? "checkbox__loading-spinner" : "", "data-cy": "captcha-checkbox" })), error ? (_jsx(ResponsiveLabel, { htmFor: id, children: _jsx("a", { css: {
86
- color: theme.palette.error.main,
87
- }, href: FAQ_LINK, children: error }) })) : (_jsx(ResponsiveLabel, { htmFor: id, children: labelText }))] }));
70
+ const checkboxStyle = useMemo(() => {
71
+ return {
72
+ ...checkboxStyleBase,
73
+ borderColor: hover ? theme.palette.background.contrastText : theme.palette.border,
74
+ appearance: checked ? "auto" : "none",
75
+ flex: 1,
76
+ margin: "15px",
77
+ minWidth: "28px",
78
+ minHeight: "28px"
79
+ };
80
+ }, [hover, theme, checked]);
81
+ const id = generateRandomId();
82
+ return /* @__PURE__ */ jsxs(
83
+ "span",
84
+ {
85
+ style: {
86
+ display: "inline-flex",
87
+ alignItems: "center",
88
+ minHeight: "58px"
89
+ },
90
+ children: [
91
+ loading ? /* @__PURE__ */ jsx(
92
+ "div",
93
+ {
94
+ className: WIDGET_CHECKBOX_SPINNER_CSS_CLASS,
95
+ "aria-label": "Loading spinner"
96
+ }
97
+ ) : /* @__PURE__ */ jsx(
98
+ "input",
99
+ {
100
+ name: id,
101
+ id,
102
+ onMouseEnter: () => setHover(true),
103
+ onMouseLeave: () => setHover(false),
104
+ css: checkboxBefore,
105
+ type: "checkbox",
106
+ "aria-live": "assertive",
107
+ "aria-label": labelText,
108
+ onChange: (e) => {
109
+ e.preventDefault();
110
+ e.stopPropagation();
111
+ setHover(false);
112
+ onChange();
113
+ },
114
+ checked,
115
+ style: checkboxStyle,
116
+ disabled: error !== void 0,
117
+ className: loading ? "checkbox__loading-spinner" : "",
118
+ "data-cy": "captcha-checkbox"
119
+ }
120
+ ),
121
+ error ? /* @__PURE__ */ jsx(ResponsiveLabel, { htmFor: id, children: /* @__PURE__ */ jsx(
122
+ "a",
123
+ {
124
+ css: {
125
+ color: theme.palette.error.main
126
+ },
127
+ href: FAQ_LINK,
128
+ children: error
129
+ }
130
+ ) }) : /* @__PURE__ */ jsx(ResponsiveLabel, { htmFor: id, children: labelText })
131
+ ]
132
+ }
133
+ );
134
+ };
135
+ export {
136
+ Checkbox,
137
+ Checkbox as default
88
138
  };
89
- export default Checkbox;
90
- //# sourceMappingURL=Checkbox.js.map
@@ -1,44 +1,83 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
- import { darkTheme, lightTheme } from "@prosopo/widget-skeleton";
1
+ import { jsx, jsxs } from "@emotion/react/jsx-runtime";
2
+ import { lightTheme, darkTheme } from "@prosopo/widget-skeleton";
3
3
  import { useMemo, useState } from "react";
4
4
  const buttonStyleBase = {
5
- border: "none",
6
- paddingTop: "6px",
7
- paddingBottom: "6px",
8
- cursor: "pointer",
9
- height: "39px",
10
- width: "39px",
11
- borderRadius: "50%",
12
- display: "flex",
5
+ border: "none",
6
+ paddingTop: "6px",
7
+ paddingBottom: "6px",
8
+ cursor: "pointer",
9
+ height: "39px",
10
+ width: "39px",
11
+ borderRadius: "50%",
12
+ display: "flex"
13
13
  };
14
- export const ReloadButton = ({ themeColor, onReload, }) => {
15
- const theme = useMemo(() => (themeColor === "light" ? lightTheme : darkTheme), [themeColor]);
16
- const [hover, setHover] = useState(false);
17
- const buttonStyle = useMemo(() => {
18
- const baseStyle = {
19
- ...buttonStyleBase,
20
- backgroundColor: theme.palette.background.default,
21
- color: hover
22
- ? theme.palette.primary.contrastText
23
- : theme.palette.background.contrastText,
24
- border: `1px solid ${theme.palette.grey[500]}`,
25
- borderRadius: "50%",
26
- transition: "background-color 0.3s",
27
- boxShadow: `0px 1px 3px 0px ${theme.palette.grey[500]}`,
28
- justifyContent: "center",
29
- alignItems: "center",
30
- margin: "0 auto",
31
- };
32
- return {
33
- ...baseStyle,
34
- backgroundColor: hover
35
- ? theme.palette.grey[700]
36
- : theme.palette.background.default,
37
- };
38
- }, [hover, theme]);
39
- return (_jsx("button", { className: "reload-button", "aria-label": "Reload", type: "button", style: buttonStyle, onMouseEnter: () => setHover(true), onMouseLeave: () => setHover(false), onClick: (e) => {
40
- e.preventDefault();
41
- onReload();
42
- }, children: _jsxs("svg", { width: "16px", height: "16px", viewBox: "0 0 16 16", version: "1.1", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", style: { display: "flex" }, children: [_jsx("title", { children: "reload" }), _jsx("path", { shapeRendering: "optimizeQuality", fill: hover ? theme.palette.primary.contrastText : theme.palette.grey[700], transform: "scale(0.0416)", d: "M234.666667,149.333333 L234.666667,106.666667 L314.564847,106.664112 C287.579138,67.9778918 242.745446,42.6666667 192,42.6666667 C109.525477,42.6666667 42.6666667,109.525477 42.6666667,192 C42.6666667,274.474523 109.525477,341.333333 192,341.333333 C268.201293,341.333333 331.072074,284.258623 340.195444,210.526102 L382.537159,215.817985 C370.807686,310.617565 289.973536,384 192,384 C85.961328,384 1.42108547e-14,298.038672 1.42108547e-14,192 C1.42108547e-14,85.961328 85.961328,1.42108547e-14 192,1.42108547e-14 C252.316171,1.42108547e-14 306.136355,27.8126321 341.335366,71.3127128 L341.333333,1.42108547e-14 L384,1.42108547e-14 L384,149.333333 L234.666667,149.333333 Z" })] }) }));
14
+ const ReloadButton = ({
15
+ themeColor,
16
+ onReload
17
+ }) => {
18
+ const theme = useMemo(
19
+ () => themeColor === "light" ? lightTheme : darkTheme,
20
+ [themeColor]
21
+ );
22
+ const [hover, setHover] = useState(false);
23
+ const buttonStyle = useMemo(() => {
24
+ const baseStyle = {
25
+ ...buttonStyleBase,
26
+ backgroundColor: theme.palette.background.default,
27
+ color: hover ? theme.palette.primary.contrastText : theme.palette.background.contrastText,
28
+ border: `1px solid ${theme.palette.grey[500]}`,
29
+ borderRadius: "50%",
30
+ transition: "background-color 0.3s",
31
+ boxShadow: `0px 1px 3px 0px ${theme.palette.grey[500]}`,
32
+ justifyContent: "center",
33
+ alignItems: "center",
34
+ margin: "0 auto"
35
+ };
36
+ return {
37
+ ...baseStyle,
38
+ backgroundColor: hover ? theme.palette.grey[700] : theme.palette.background.default
39
+ };
40
+ }, [hover, theme]);
41
+ return /* @__PURE__ */ jsx(
42
+ "button",
43
+ {
44
+ className: "reload-button",
45
+ "aria-label": "Reload",
46
+ type: "button",
47
+ style: buttonStyle,
48
+ onMouseEnter: () => setHover(true),
49
+ onMouseLeave: () => setHover(false),
50
+ onClick: (e) => {
51
+ e.preventDefault();
52
+ onReload();
53
+ },
54
+ children: /* @__PURE__ */ jsxs(
55
+ "svg",
56
+ {
57
+ width: "16px",
58
+ height: "16px",
59
+ viewBox: "0 0 16 16",
60
+ version: "1.1",
61
+ xmlns: "http://www.w3.org/2000/svg",
62
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
63
+ style: { display: "flex" },
64
+ children: [
65
+ /* @__PURE__ */ jsx("title", { children: "reload" }),
66
+ /* @__PURE__ */ jsx(
67
+ "path",
68
+ {
69
+ shapeRendering: "optimizeQuality",
70
+ fill: hover ? theme.palette.primary.contrastText : theme.palette.grey[700],
71
+ transform: "scale(0.0416)",
72
+ d: "M234.666667,149.333333 L234.666667,106.666667 L314.564847,106.664112 C287.579138,67.9778918 242.745446,42.6666667 192,42.6666667 C109.525477,42.6666667 42.6666667,109.525477 42.6666667,192 C42.6666667,274.474523 109.525477,341.333333 192,341.333333 C268.201293,341.333333 331.072074,284.258623 340.195444,210.526102 L382.537159,215.817985 C370.807686,310.617565 289.973536,384 192,384 C85.961328,384 1.42108547e-14,298.038672 1.42108547e-14,192 C1.42108547e-14,85.961328 85.961328,1.42108547e-14 192,1.42108547e-14 C252.316171,1.42108547e-14 306.136355,27.8126321 341.335366,71.3127128 L341.333333,1.42108547e-14 L384,1.42108547e-14 L384,149.333333 L234.666667,149.333333 Z"
73
+ }
74
+ )
75
+ ]
76
+ }
77
+ )
78
+ }
79
+ );
80
+ };
81
+ export {
82
+ ReloadButton
43
83
  };
44
- //# sourceMappingURL=Reload.js.map
@@ -1,87 +1,86 @@
1
- export const buildUpdateState = (state, onStateUpdate) => (nextState) => {
2
- Object.assign(state, nextState);
3
- onStateUpdate(nextState);
1
+ const buildUpdateState = (state, onStateUpdate) => (nextState) => {
2
+ Object.assign(state, nextState);
3
+ onStateUpdate(nextState);
4
4
  };
5
5
  const useRefAsState = (useRef, defaultValue) => {
6
- const ref = useRef(defaultValue);
7
- const setter = (value) => {
8
- ref.current = value;
9
- };
10
- const value = ref.current;
11
- return [value, setter];
6
+ const ref = useRef(defaultValue);
7
+ const setter = (value2) => {
8
+ ref.current = value2;
9
+ };
10
+ const value = ref.current;
11
+ return [value, setter];
12
12
  };
13
- export const useProcaptcha = (useState, useRef) => {
14
- const [isHuman, setIsHuman] = useState(false);
15
- const [index, setIndex] = useState(0);
16
- const [solutions, setSolutions] = useState([]);
17
- const [captchaApi, setCaptchaApi] = useRefAsState(useRef, undefined);
18
- const [showModal, setShowModal] = useState(false);
19
- const [challenge, setChallenge] = useState(undefined);
20
- const [loading, setLoading] = useState(false);
21
- const [account, setAccount] = useState(undefined);
22
- const [dappAccount, setDappAccount] = useState(undefined);
23
- const [submission, setSubmission] = useRefAsState(useRef, undefined);
24
- const [timeout, setTimeout] = useRefAsState(useRef, undefined);
25
- const [successfullChallengeTimeout, setSuccessfullChallengeTimeout] = useRefAsState(useRef, undefined);
26
- const [sendData, setSendData] = useState(false);
27
- const [attemptCount, setAttemptCount] = useState(0);
28
- const [error, setError] = useState(undefined);
29
- const [sessionId, setSessionId] = useState(undefined);
30
- return [
31
- {
32
- isHuman,
33
- index,
34
- solutions,
35
- captchaApi,
36
- showModal,
37
- challenge,
38
- loading,
39
- account,
40
- dappAccount,
41
- submission,
42
- timeout,
43
- successfullChallengeTimeout,
44
- sendData,
45
- attemptCount,
46
- error,
47
- sessionId,
48
- },
49
- (nextState) => {
50
- if (nextState.account !== undefined)
51
- setAccount(nextState.account);
52
- if (nextState.isHuman !== undefined)
53
- setIsHuman(nextState.isHuman);
54
- if (nextState.index !== undefined)
55
- setIndex(nextState.index);
56
- if (nextState.solutions !== undefined)
57
- setSolutions(nextState.solutions.slice());
58
- if (nextState.captchaApi !== undefined)
59
- setCaptchaApi(nextState.captchaApi);
60
- if (nextState.showModal !== undefined)
61
- setShowModal(nextState.showModal);
62
- if (nextState.challenge !== undefined)
63
- setChallenge(nextState.challenge);
64
- if (nextState.loading !== undefined)
65
- setLoading(nextState.loading);
66
- if (nextState.showModal !== undefined)
67
- setShowModal(nextState.showModal);
68
- if (nextState.dappAccount !== undefined)
69
- setDappAccount(nextState.dappAccount);
70
- if (nextState.submission !== undefined)
71
- setSubmission(nextState.submission);
72
- if (nextState.timeout !== undefined)
73
- setTimeout(nextState.timeout);
74
- if (nextState.successfullChallengeTimeout !== undefined)
75
- setSuccessfullChallengeTimeout(nextState.timeout);
76
- if (nextState.sendData !== undefined)
77
- setSendData(nextState.sendData);
78
- if (nextState.attemptCount !== undefined)
79
- setAttemptCount(nextState.attemptCount);
80
- if (nextState.error !== undefined)
81
- setError(nextState.error);
82
- if (nextState.sessionId !== undefined)
83
- setSessionId(nextState.sessionId);
84
- },
85
- ];
13
+ const useProcaptcha = (useState, useRef) => {
14
+ const [isHuman, setIsHuman] = useState(false);
15
+ const [index, setIndex] = useState(0);
16
+ const [solutions, setSolutions] = useState([]);
17
+ const [captchaApi, setCaptchaApi] = useRefAsState(useRef, void 0);
18
+ const [showModal, setShowModal] = useState(false);
19
+ const [challenge, setChallenge] = useState(
20
+ void 0
21
+ );
22
+ const [loading, setLoading] = useState(false);
23
+ const [account, setAccount] = useState(void 0);
24
+ const [dappAccount, setDappAccount] = useState(void 0);
25
+ const [submission, setSubmission] = useRefAsState(useRef, void 0);
26
+ const [timeout, setTimeout] = useRefAsState(
27
+ useRef,
28
+ void 0
29
+ );
30
+ const [successfullChallengeTimeout, setSuccessfullChallengeTimeout] = useRefAsState(useRef, void 0);
31
+ const [sendData, setSendData] = useState(false);
32
+ const [attemptCount, setAttemptCount] = useState(0);
33
+ const [error, setError] = useState(void 0);
34
+ const [sessionId, setSessionId] = useState(void 0);
35
+ return [
36
+ // the state
37
+ {
38
+ isHuman,
39
+ index,
40
+ solutions,
41
+ captchaApi,
42
+ showModal,
43
+ challenge,
44
+ loading,
45
+ account,
46
+ dappAccount,
47
+ submission,
48
+ timeout,
49
+ successfullChallengeTimeout,
50
+ sendData,
51
+ attemptCount,
52
+ error,
53
+ sessionId
54
+ },
55
+ // and method to update the state
56
+ (nextState) => {
57
+ if (nextState.account !== void 0) setAccount(nextState.account);
58
+ if (nextState.isHuman !== void 0) setIsHuman(nextState.isHuman);
59
+ if (nextState.index !== void 0) setIndex(nextState.index);
60
+ if (nextState.solutions !== void 0)
61
+ setSolutions(nextState.solutions.slice());
62
+ if (nextState.captchaApi !== void 0)
63
+ setCaptchaApi(nextState.captchaApi);
64
+ if (nextState.showModal !== void 0) setShowModal(nextState.showModal);
65
+ if (nextState.challenge !== void 0) setChallenge(nextState.challenge);
66
+ if (nextState.loading !== void 0) setLoading(nextState.loading);
67
+ if (nextState.showModal !== void 0) setShowModal(nextState.showModal);
68
+ if (nextState.dappAccount !== void 0)
69
+ setDappAccount(nextState.dappAccount);
70
+ if (nextState.submission !== void 0)
71
+ setSubmission(nextState.submission);
72
+ if (nextState.timeout !== void 0) setTimeout(nextState.timeout);
73
+ if (nextState.successfullChallengeTimeout !== void 0)
74
+ setSuccessfullChallengeTimeout(nextState.timeout);
75
+ if (nextState.sendData !== void 0) setSendData(nextState.sendData);
76
+ if (nextState.attemptCount !== void 0)
77
+ setAttemptCount(nextState.attemptCount);
78
+ if (nextState.error !== void 0) setError(nextState.error);
79
+ if (nextState.sessionId !== void 0) setSessionId(nextState.sessionId);
80
+ }
81
+ ];
82
+ };
83
+ export {
84
+ buildUpdateState,
85
+ useProcaptcha
86
86
  };
87
- //# sourceMappingURL=builder.js.map
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@prosopo/procaptcha-common",
3
- "version": "2.7.9",
3
+ "version": "2.7.11",
4
4
  "author": "PROSOPO LIMITED <info@prosopo.io>",
5
5
  "license": "Apache-2.0",
6
- "main": "./dist/index.js",
6
+ "main": "dist/index.js",
7
7
  "type": "module",
8
8
  "sideEffects": false,
9
9
  "engines": {
@@ -12,35 +12,38 @@
12
12
  },
13
13
  "exports": {
14
14
  ".": {
15
+ "types": "./dist/index.d.ts",
15
16
  "import": "./dist/index.js",
16
17
  "require": "./dist/cjs/index.cjs"
17
18
  }
18
19
  },
19
- "types": "./dist/index.d.ts",
20
+ "types": "dist/index.d.ts",
20
21
  "source": "./src/index.ts",
21
22
  "scripts": {
22
- "test": "echo \"No test specified\"",
23
- "clean": "tsc --build --clean",
24
- "build": "tsc --build --verbose",
25
- "build:cjs": "npx vite --config vite.cjs.config.ts build"
23
+ "clean": "del-cli --verbose dist tsconfig.tsbuildinfo",
24
+ "build": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.esm.config.ts --mode $NODE_ENV",
25
+ "build:tsc": "tsc --build --verbose",
26
+ "build:cjs": "NODE_ENV=${NODE_ENV:-production}; vite build --config vite.cjs.config.ts --mode $NODE_ENV",
27
+ "typecheck": "tsc --build --declaration --emitDeclarationOnly --force",
28
+ "test": "echo no tests"
26
29
  },
27
30
  "browserslist": ["> 0.5%, last 2 versions, not dead"],
28
31
  "dependencies": {
29
- "@prosopo/account": "2.7.9",
30
- "@prosopo/common": "3.0.2",
31
- "@prosopo/load-balancer": "2.6.14",
32
- "@prosopo/types": "3.0.3",
33
- "@prosopo/util": "3.0.2",
34
- "@prosopo/widget-skeleton": "2.6.0",
32
+ "@prosopo/account": "2.7.11",
33
+ "@prosopo/common": "3.1.1",
34
+ "@prosopo/load-balancer": "2.6.16",
35
+ "@prosopo/types": "3.0.5",
36
+ "@prosopo/util": "3.0.4",
37
+ "@prosopo/widget-skeleton": "2.6.2",
38
+ "express": "4.21.2",
39
+ "@prosopo/config": "3.1.2",
35
40
  "@typegoose/auto-increment": "4.13.0",
36
41
  "axios": "1.10.0",
37
42
  "esbuild": "0.25.6",
38
- "express": "4.21.2",
39
43
  "openpgp": "5.11.3",
40
44
  "webpack-dev-server": "5.2.2"
41
45
  },
42
46
  "devDependencies": {
43
- "@prosopo/config": "3.1.0",
44
47
  "@types/react": "18.3.1",
45
48
  "@vitest/coverage-v8": "3.0.9",
46
49
  "concurrently": "9.0.1",
@@ -16,7 +16,7 @@ import { ViteCommonJSConfig } from "@prosopo/config";
16
16
 
17
17
  export default function () {
18
18
  return ViteCommonJSConfig(
19
- "procaptcha-common",
20
- path.resolve("./tsconfig.cjs.json"),
19
+ path.basename("."),
20
+ path.resolve("./tsconfig.json"),
21
21
  );
22
22
  }
@@ -0,0 +1,20 @@
1
+ // Copyright 2021-2025 Prosopo (UK) Ltd.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ import path from "node:path";
16
+ import { ViteEsmConfig } from "@prosopo/config";
17
+
18
+ export default function () {
19
+ return ViteEsmConfig(path.basename("."), path.resolve("./tsconfig.json"));
20
+ }
@@ -1,4 +0,0 @@
1
- import { type Callbacks, type ProcaptchaRenderOptions } from "@prosopo/types";
2
- export declare const getDefaultCallbacks: (element?: Element) => Callbacks;
3
- export declare function setUserCallbacks(renderOptions: ProcaptchaRenderOptions | undefined, callbacks: Callbacks, element: Element): void;
4
- //# sourceMappingURL=defaultCallbacks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultCallbacks.d.ts","sourceRoot":"","sources":["../../src/callbacks/defaultCallbacks.ts"],"names":[],"mappings":"AAaA,OAAO,EAEN,KAAK,SAAS,EACd,KAAK,uBAAuB,EAE5B,MAAM,gBAAgB,CAAC;AAIxB,eAAO,MAAM,mBAAmB,aAAc,OAAO,KAAG,SAiCtD,CAAC;AAyBH,wBAAgB,gBAAgB,CAC/B,aAAa,EAAE,uBAAuB,GAAG,SAAS,EAClD,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,OAAO,QA+FhB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultCallbacks.js","sourceRoot":"","sources":["../../src/callbacks/defaultCallbacks.ts"],"names":[],"mappings":"AAaA,OAAO,EACN,SAAS,GAIT,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAiB,EAAa,EAAE,CAAC,CAAC;IACrE,OAAO,EAAE,CAAC,KAAsB,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC;IAClE,kBAAkB,EAAE,GAAG,EAAE;QACxB,wBAAwB,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IAClC,CAAC;IACD,mBAAmB,EAAE,GAAG,EAAE;QACzB,OAAO,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC;IACtC,CAAC;IACD,SAAS,EAAE,GAAG,EAAE;QACf,wBAAwB,EAAE,CAAC;IAC5B,CAAC;IACD,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE;QACzB,wBAAwB,EAAE,CAAC;QAC3B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IACD,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AI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;AACF,CAAC,CAAC"}
@@ -1,14 +0,0 @@
1
- import type { Callbacks } from "@prosopo/types";
2
- export declare const getDefaultEvents: (callbacks: Partial<Callbacks>) => {
3
- onHuman: (token: import("@prosopo/types").ProcaptchaToken) => void;
4
- onExtensionNotFound: () => void;
5
- onChallengeExpired: () => void;
6
- onExpired: () => void;
7
- onError: (error: Error) => void;
8
- onClose: () => void;
9
- onOpen: () => void;
10
- onFailed: () => void;
11
- onReload: () => void;
12
- onReset: () => void;
13
- };
14
- //# sourceMappingURL=defaultEvents.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultEvents.d.ts","sourceRoot":"","sources":["../../src/callbacks/defaultEvents.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAGhD,eAAO,MAAM,gBAAgB,cAAe,OAAO,CAAC,SAAS,CAAC;;;;;;;;;;;CAG5D,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaultEvents.js","sourceRoot":"","sources":["../../src/callbacks/defaultEvents.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,SAA6B,EAAE,EAAE,CAAC,CAAC;IACnE,GAAG,mBAAmB,CAAC,SAAS,CAAC;IACjC,GAAG,SAAS;CACZ,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- export declare function getParentForm(widgetElement: Element): HTMLFormElement | null;
2
- export declare const removeProcaptchaResponse: () => void;
3
- //# sourceMappingURL=form.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../src/elements/form.ts"],"names":[],"mappings":"AAgBA,wBAAgB,aAAa,CAAC,aAAa,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAO5E;AAED,eAAO,MAAM,wBAAwB,YAKpC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"form.js","sourceRoot":"","sources":["../../src/elements/form.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,UAAU,aAAa,CAAC,aAAsB;IACnD,MAAM,cAAc,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;IAEnD,MAAM,gBAAgB,GACrB,cAAc,YAAY,UAAU,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC;IAE5E,OAAO,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAoB,CAAC;AAC5D,CAAC;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC5C,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CACzB,QAAQ,CAAC,iBAAiB,CAAC,SAAS,CAAC,kBAAkB,CAAC,CACxD,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,CAAC;AAClC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const getWindowCallback: (callbackName: string) => any;
2
- //# sourceMappingURL=window.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../../src/elements/window.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,iBAAiB,iBAAkB,MAAM,QASrD,CAAC"}