@prosopo/procaptcha-react 0.1.9 → 0.1.13
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/.env.development +18 -0
- package/dist/components/CaptchaComponent.d.ts +11 -4
- package/dist/components/CaptchaComponent.d.ts.map +1 -1
- package/dist/components/CaptchaComponent.js +64 -59
- package/dist/components/CaptchaComponent.js.map +1 -1
- package/dist/components/CaptchaWidget.d.ts +5 -4
- package/dist/components/CaptchaWidget.d.ts.map +1 -1
- package/dist/components/CaptchaWidget.js +74 -26
- package/dist/components/CaptchaWidget.js.map +1 -1
- package/dist/components/ExtensionAccountSelect.d.ts +5 -6
- package/dist/components/ExtensionAccountSelect.d.ts.map +1 -1
- package/dist/components/ExtensionAccountSelect.js +26 -5
- package/dist/components/ExtensionAccountSelect.js.map +1 -1
- package/dist/components/Procaptcha.d.ts +10 -0
- package/dist/components/Procaptcha.d.ts.map +1 -0
- package/dist/components/Procaptcha.js +122 -0
- package/dist/components/Procaptcha.js.map +1 -0
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +3 -3
- package/dist/components/index.js.map +1 -1
- package/dist/components/theme.d.ts +3 -0
- package/dist/components/theme.d.ts.map +1 -0
- package/dist/components/theme.js +10 -0
- package/dist/components/theme.js.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.d.ts.map +1 -1
- package/dist/util/index.js +2 -4
- package/dist/util/index.js.map +1 -1
- package/package.json +47 -41
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -22
- package/LICENSE +0 -201
- package/dist/components/CaptchaManager.d.ts +0 -5
- package/dist/components/CaptchaManager.d.ts.map +0 -1
- package/dist/components/CaptchaManager.js +0 -47
- package/dist/components/CaptchaManager.js.map +0 -1
- package/dist/styles.d.ts +0 -2
- package/dist/styles.d.ts.map +0 -1
- package/dist/styles.js +0 -91
- package/dist/styles.js.map +0 -1
- package/tsconfig.json +0 -25
package/.env.development
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
DAPP_SITE_KEY=5Ea1uv1VkQRe2UUu7V8QffpricjfJZ7QvEfRJDPazkjdLyZE
|
|
2
|
+
PROTOCOL_CONTRACT_ADDRESS=5FtYnuNSYwTBqnC3jcrP6TSEhjeczyrSHXCPRWZgazkTUVHS
|
|
3
|
+
DATABASE_PASSWORD=root
|
|
4
|
+
DATABASE_USERNAME=root
|
|
5
|
+
DATABASE_NAME=prosopo
|
|
6
|
+
DATABASE_HOST=127.0.0.1
|
|
7
|
+
DATABASE_PORT=27017
|
|
8
|
+
SUBSTRATE_NODE_URL=ws://192.168.1.28:9944
|
|
9
|
+
API_BASE_URL=http://localhost:8282
|
|
10
|
+
API_PORT=8282
|
|
11
|
+
PAIR_TYPE=sr25519
|
|
12
|
+
SS58_FORMAT=5
|
|
13
|
+
PROVIDER_ADDRESS=5EjTA28bKSbFPPyMbUjNtArxyqjwq38r1BapVmLZShaqEedV
|
|
14
|
+
PROVIDER_MNEMONIC=puppy cream effort carbon despair leg pyramid cotton endorse immense drill peasant
|
|
15
|
+
PROVIDER_SEED=
|
|
16
|
+
PROVIDER_JSON=
|
|
17
|
+
FILE_SRV_PORT=3100
|
|
18
|
+
FILE_SRV_PATHS=[]
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { GetCaptchaResponse } from '@prosopo/api';
|
|
2
|
+
export interface CaptchaComponentProps {
|
|
3
|
+
challenge: GetCaptchaResponse;
|
|
4
|
+
index: number;
|
|
5
|
+
solutions: string[][];
|
|
6
|
+
onSubmit: () => void;
|
|
7
|
+
onCancel: () => void;
|
|
8
|
+
onClick: (hash: string) => void;
|
|
9
|
+
onNext: () => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const CaptchaComponent: (props: CaptchaComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
12
|
export default CaptchaComponent;
|
|
6
13
|
//# sourceMappingURL=CaptchaComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaptchaComponent.d.ts","sourceRoot":"","sources":["../../src/components/CaptchaComponent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CaptchaComponent.d.ts","sourceRoot":"","sources":["../../src/components/CaptchaComponent.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAUjD,MAAM,WAAW,qBAAqB;IAClC,SAAS,EAAE,kBAAkB,CAAA;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,EAAE,EAAE,CAAA;IACrB,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC/B,MAAM,EAAE,MAAM,IAAI,CAAA;CACrB;AAED,eAAO,MAAM,gBAAgB,UAAW,qBAAqB,4CAgI5D,CAAA;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -1,62 +1,67 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
-
// GNU General Public License for more details.
|
|
14
|
-
//
|
|
15
|
-
// You should have received a copy of the GNU General Public License
|
|
16
|
-
// along with procaptcha-react. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
-
import { useEffect, useContext, useReducer } from "react";
|
|
18
|
-
import Box from "@mui/material/Box";
|
|
19
|
-
import Button from "@mui/material/Button";
|
|
20
|
-
import Typography from "@mui/material/Typography";
|
|
21
|
-
import { ProsopoCaptchaStateClient, captchaStateReducer } from "@prosopo/procaptcha";
|
|
22
|
-
import { CaptchaContextManager } from "./CaptchaManager";
|
|
23
|
-
import { CaptchaWidget } from "./CaptchaWidget";
|
|
24
|
-
import { useTranslation } from "@prosopo/i18n";
|
|
25
|
-
import { useStyles } from "../styles";
|
|
26
|
-
import { addDataAttr } from "../util";
|
|
27
|
-
export function CaptchaComponent({ clientInterface }) {
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation } from '@prosopo/common';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import Button from '@mui/material/Button';
|
|
5
|
+
import CaptchaWidget from './CaptchaWidget';
|
|
6
|
+
import ThemeProvider from '@mui/material/styles/ThemeProvider';
|
|
7
|
+
import Typography from '@mui/material/Typography';
|
|
8
|
+
import addDataAttr from '../util';
|
|
9
|
+
import theme from './theme';
|
|
10
|
+
export const CaptchaComponent = (props) => {
|
|
28
11
|
const { t } = useTranslation();
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
12
|
+
const { challenge, index, solutions, onSubmit, onCancel, onClick, onNext } = props;
|
|
13
|
+
const captcha = challenge.captchas[index];
|
|
14
|
+
const solution = solutions[index];
|
|
15
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(Box, { sx: {
|
|
16
|
+
// center the popup horizontally and vertically
|
|
17
|
+
display: 'flex',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
justifyContent: 'center',
|
|
20
|
+
// fill entire screen
|
|
21
|
+
width: '100%',
|
|
22
|
+
height: '100%',
|
|
23
|
+
}, children: _jsx(Box, { sx: {
|
|
24
|
+
// introduce scroll bars when screen < minWidth of children
|
|
25
|
+
overflowX: 'auto',
|
|
26
|
+
overflowY: 'auto',
|
|
27
|
+
width: '100%',
|
|
28
|
+
// limit the popup width
|
|
29
|
+
maxWidth: '450px',
|
|
30
|
+
// maxHeight introduces vertical scroll bars if children content longer than window
|
|
31
|
+
maxHeight: '100%',
|
|
32
|
+
}, children: _jsxs(Box, { bgcolor: theme.palette.background.default, sx: {
|
|
33
|
+
display: 'flex',
|
|
34
|
+
flexDirection: 'column',
|
|
35
|
+
// the min width of the popup before scroll bars appear
|
|
36
|
+
minWidth: '300px',
|
|
37
|
+
}, children: [_jsxs(Box, { px: 2, py: 3, sx: {
|
|
38
|
+
// center the header
|
|
39
|
+
display: 'flex',
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
width: '100%',
|
|
42
|
+
}, bgcolor: theme.palette.primary.main, children: [_jsxs(Typography, { sx: {
|
|
43
|
+
color: '#ffffff',
|
|
44
|
+
fontWeight: 700,
|
|
45
|
+
}, children: [t('WIDGET.SELECT_ALL'), ': '] }), _jsx(Typography, { px: 1, sx: {
|
|
46
|
+
color: '#ffffff',
|
|
47
|
+
fontWeight: 700,
|
|
48
|
+
textTransform: 'uppercase',
|
|
49
|
+
fontSize: theme.typography.h6.fontSize,
|
|
50
|
+
}, children: `${props.challenge.captchas[props.index].captcha.target}` })] }), _jsx(Box, { ...addDataAttr({ dev: { cy: 'captcha-' + props.index } }), children: _jsx(CaptchaWidget, { challenge: captcha, solution: solution, onClick: onClick }) }), _jsx(Box, { px: 2, py: 1, sx: {
|
|
51
|
+
display: 'flex',
|
|
52
|
+
alignItems: 'center',
|
|
53
|
+
justifyContent: 'center',
|
|
54
|
+
width: '100%',
|
|
55
|
+
}, ...addDataAttr({ dev: { cy: 'dots-captcha' } }), children: challenge.captchas.map((_, i) => (_jsx(Box, { sx: {
|
|
56
|
+
width: 7,
|
|
57
|
+
height: 7,
|
|
58
|
+
borderRadius: '50%',
|
|
59
|
+
border: '1px solid #CFCFCF',
|
|
60
|
+
}, mx: 0.5, bgcolor: index === i ? theme.palette.background.default : '#CFCFCF' }, i))) }), _jsxs(Box, { px: 2, pt: 0, pb: 2, sx: {
|
|
61
|
+
display: 'flex',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
justifyContent: 'space-between',
|
|
64
|
+
}, children: [_jsx(Button, { onClick: onCancel, variant: "text", children: t('WIDGET.CANCEL') }), _jsx(Button, { color: "primary", onClick: index < challenge.captchas.length - 1 ? onNext : onSubmit, variant: "contained", ...addDataAttr({ dev: { cy: 'button-next' } }), children: index < challenge.captchas.length - 1 ? t('WIDGET.NEXT') : t('WIDGET.SUBMIT') })] })] }) }) }) }));
|
|
65
|
+
};
|
|
61
66
|
export default CaptchaComponent;
|
|
62
67
|
//# sourceMappingURL=CaptchaComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaptchaComponent.js","sourceRoot":"","sources":["../../src/components/CaptchaComponent.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"CaptchaComponent.js","sourceRoot":"","sources":["../../src/components/CaptchaComponent.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,GAAG,MAAM,mBAAmB,CAAA;AACnC,OAAO,MAAM,MAAM,sBAAsB,CAAA;AACzC,OAAO,aAAa,MAAM,iBAAiB,CAAA;AAC3C,OAAO,aAAa,MAAM,oCAAoC,CAAA;AAC9D,OAAO,UAAU,MAAM,0BAA0B,CAAA;AACjD,OAAO,WAAW,MAAM,SA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M,EAAE,mBAAmB;iCAC9B,EACD,EAAE,EAAE,GAAG,EACP,OAAO,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,IAR9D,CAAC,CASR,CACL,CAAC,GACA,EACN,MAAC,GAAG,IACA,EAAE,EAAE,CAAC,EACL,EAAE,EAAE,CAAC,EACL,EAAE,EAAE,CAAC,EACL,EAAE,EAAE;gCACA,OAAO,EAAE,MAAM;gCACf,UAAU,EAAE,QAAQ;gCACpB,cAAc,EAAE,eAAe;6BAClC,aAED,KAAC,MAAM,IAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAC,MAAM,YACpC,CAAC,CAAC,eAAe,CAAC,GACd,EACT,KAAC,MAAM,IACH,KAAK,EAAC,SAAS,EACf,OAAO,EAAE,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAClE,OAAO,EAAC,WAAW,KACf,WAAW,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,CAAC,YAE9C,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,GACzE,IACP,IACJ,GACJ,GACJ,GACM,CACnB,CAAA;AACL,CAAC,CAAA;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { CaptchaResponseCaptcha } from
|
|
2
|
-
export
|
|
1
|
+
import { CaptchaResponseCaptcha } from '@prosopo/procaptcha';
|
|
2
|
+
export interface CaptchaWidgetProps {
|
|
3
3
|
challenge: CaptchaResponseCaptcha;
|
|
4
4
|
solution: string[];
|
|
5
|
-
|
|
6
|
-
}
|
|
5
|
+
onClick: (hash: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const CaptchaWidget: (props: CaptchaWidgetProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
8
|
export default CaptchaWidget;
|
|
8
9
|
//# sourceMappingURL=CaptchaWidget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/CaptchaWidget.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/CaptchaWidget.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAA;AAM5D,MAAM,WAAW,kBAAkB;IAC/B,SAAS,EAAE,sBAAsB,CAAA;IACjC,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAClC;AASD,eAAO,MAAM,aAAa,UAAW,kBAAkB,4CA4GtD,CAAA;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -1,29 +1,77 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
// You should have received a copy of the GNU General Public License
|
|
17
|
-
// along with procaptcha-react. If not, see <http://www.gnu.org/licenses/>.
|
|
18
|
-
import Avatar from "@mui/material/Avatar";
|
|
19
|
-
import { useStyles } from "../styles";
|
|
20
|
-
import { addDataAttr } from "../util";
|
|
21
|
-
export function CaptchaWidget({ challenge, solution, onChange }) {
|
|
22
|
-
//const items = Array.from(Array(9).keys());
|
|
23
|
-
console.log("CHALLENGE", challenge);
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useTheme } from '@mui/material';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import CheckIcon from '@mui/icons-material/Check';
|
|
5
|
+
import Fade from '@mui/material/Fade';
|
|
6
|
+
const getHash = (item) => {
|
|
7
|
+
if (!item.hash) {
|
|
8
|
+
throw new Error('item.hash is undefined');
|
|
9
|
+
}
|
|
10
|
+
return item.hash;
|
|
11
|
+
};
|
|
12
|
+
export const CaptchaWidget = (props) => {
|
|
13
|
+
// env
|
|
14
|
+
const { challenge, solution, onClick } = props;
|
|
24
15
|
const items = challenge.captcha.items;
|
|
25
|
-
const
|
|
26
|
-
return (_jsx(_Fragment, { children:
|
|
27
|
-
|
|
16
|
+
const theme = useTheme();
|
|
17
|
+
return (_jsx(_Fragment, { children: _jsx(Box, { pr: 0.5, pb: 0.5, sx: {
|
|
18
|
+
// expand to full height / width of parent
|
|
19
|
+
width: '100%',
|
|
20
|
+
height: '100%',
|
|
21
|
+
// display children in flex, spreading them evenly and wrapping when row length exceeded
|
|
22
|
+
display: 'flex',
|
|
23
|
+
flexDirection: 'row',
|
|
24
|
+
flexWrap: 'wrap',
|
|
25
|
+
}, children: items.map((item, index) => {
|
|
26
|
+
const hash = getHash(item);
|
|
27
|
+
return (_jsx(Box, { pt: 0.5, pl: 0.5, sx: {
|
|
28
|
+
// enable the items in the grid to grow in width to use up excess space
|
|
29
|
+
flexGrow: 1,
|
|
30
|
+
// make the width of each item 1/3rd of the width overall, i.e. 3 columns
|
|
31
|
+
flexBasis: '33.3333%',
|
|
32
|
+
// include the padding / margin / border in the width
|
|
33
|
+
boxSizing: 'border-box',
|
|
34
|
+
}, children: _jsxs(Box, { sx: { cursor: 'pointer', height: '100%', width: '100%' }, onClick: () => onClick(hash), children: [_jsx(Box, { sx: { border: 1, borderColor: 'lightgray' }, children: _jsx("img", { style: {
|
|
35
|
+
width: '100%',
|
|
36
|
+
backgroundColor: 'lightgray',
|
|
37
|
+
display: 'block',
|
|
38
|
+
objectFit: 'contain',
|
|
39
|
+
aspectRatio: '1/1', // force AR to be 1, letterboxing images with different aspect ratios
|
|
40
|
+
}, src: item.data, alt: `Captcha image ${index + 1}` }) }), _jsx(Fade, { in: solution.includes(hash), children: _jsx(Box, { sx: {
|
|
41
|
+
// relative to where the element _should_ be positioned
|
|
42
|
+
position: 'relative',
|
|
43
|
+
// make the overlay the full height/width of an item
|
|
44
|
+
width: '100%',
|
|
45
|
+
height: '100%',
|
|
46
|
+
// shift it up 100% to overlay the item element
|
|
47
|
+
top: '-100%',
|
|
48
|
+
// transition on opacity upon (de)selection
|
|
49
|
+
transitionDuration: '300ms',
|
|
50
|
+
transitionProperty: 'opacity',
|
|
51
|
+
}, children: _jsx(Box, { sx: {
|
|
52
|
+
// make the overlay absolute positioned compare to its container
|
|
53
|
+
position: 'absolute',
|
|
54
|
+
// spread across 100% width/height of the item box
|
|
55
|
+
top: 0,
|
|
56
|
+
left: 0,
|
|
57
|
+
bottom: 0,
|
|
58
|
+
right: 0,
|
|
59
|
+
height: '100%',
|
|
60
|
+
width: '100%',
|
|
61
|
+
// display overlays in center
|
|
62
|
+
display: 'flex',
|
|
63
|
+
alignItems: 'center',
|
|
64
|
+
justifyContent: 'center',
|
|
65
|
+
// make bg half opacity, i.e. shadowing the item's img
|
|
66
|
+
backgroundColor: 'rgba(0,0,0,0.5)',
|
|
67
|
+
}, children: _jsx(CheckIcon, { htmlColor: theme.palette.background.default, sx: {
|
|
68
|
+
// img must be displayed as block otherwise get's a bottom whitespace border
|
|
69
|
+
display: 'block',
|
|
70
|
+
// how big the overlay icon is
|
|
71
|
+
width: '35%',
|
|
72
|
+
height: '35%',
|
|
73
|
+
} }) }) }) })] }) }, index));
|
|
74
|
+
}) }) }));
|
|
75
|
+
};
|
|
28
76
|
export default CaptchaWidget;
|
|
29
77
|
//# sourceMappingURL=CaptchaWidget.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaptchaWidget.js","sourceRoot":"","sources":["../../src/components/CaptchaWidget.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CaptchaWidget.js","sourceRoot":"","sources":["../../src/components/CaptchaWidget.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAS,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,GAAG,MAAM,mBAAmB,CAAA;AACnC,OAAO,SAAS,MAAM,2BAA2B,CAAA;AACjD,OAAO,IAAI,MAAM,oBAAoB,CAAA;AAQrC,MAAM,OAAO,GAAG,CAAC,IAAS,EAAE,EAAE;IAC1B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;KAC5C;IACD,OAAO,IAAI,CAAC,IAAI,CAAA;AACpB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAyB,EAAE,EAAE;IACvD,MAAM;IACN,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,KAAK,CAAA;IAC9C,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,CAAA;IACrC,MAAM,KAAK,GAAU,QAAQ,EAAE,CAAA;IAE/B,OAAO,CACH,4BACI,KAAC,GAAG,IACA,EAAE,EAAE,GAAG,EACP,EAAE,EAAE,GAAG,EACP,EAAE,EAAE;gBACA,0CAA0C;gBAC1C,KAAK,EAAE,MAAM;gBACb,MAAM,EAAE,MAAM;gBACd,wFAAwF;gBACxF,OAAO,EAAE,MAAM;gBACf,aAAa,EAAE,KAAK;gBACpB,QAAQ,EAAE,MAAM;aACnB,YAEA,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;gBACvB,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;gBAC1B,OAAO,CACH,KAAC,GAAG,IACA,EAAE,EAAE,GAAG,EACP,EAAE,EAAE,GAAG,EACP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AK,EAAE,MAAM;4CACb,6BAA6B;4CAC7B,OAAO,EAAE,MAAM;4CACf,UAAU,EAAE,QAAQ;4CACpB,cAAc,EAAE,QAAQ;4CACxB,sDAAsD;4CACtD,eAAe,EAAE,iBAAiB;yCACrC,YAED,KAAC,SAAS,IACN,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,EAC3C,EAAE,EAAE;gDACA,4EAA4E;gDAC5E,OAAO,EAAE,OAAO;gDAChB,8BAA8B;gDAC9B,KAAK,EAAE,KAAK;gDACZ,MAAM,EAAE,KAAK;6CAChB,GACH,GACA,GACJ,GACH,IACL,IAlED,KAAK,CAmER,CACT,CAAA;YACL,CAAC,CAAC,GACA,GACP,CACN,CAAA;AACL,CAAC,CAAA;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}) => JSX.Element;
|
|
1
|
+
export declare const ExtensionAccountSelect: ({ value, dappName, onChange, }: {
|
|
2
|
+
value?: string | undefined;
|
|
3
|
+
dappName: string;
|
|
4
|
+
onChange: (value: string) => void;
|
|
5
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
7
6
|
export default ExtensionAccountSelect;
|
|
8
7
|
//# sourceMappingURL=ExtensionAccountSelect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionAccountSelect.d.ts","sourceRoot":"","sources":["../../src/components/ExtensionAccountSelect.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExtensionAccountSelect.d.ts","sourceRoot":"","sources":["../../src/components/ExtensionAccountSelect.tsx"],"names":[],"mappings":"AAuBA,eAAO,MAAM,sBAAsB;;cAMrB,MAAM;sBACE,MAAM,KAAK,IAAI;6CAqCpC,CAAA;AAED,eAAe,sBAAsB,CAAA"}
|
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { useTranslation } from '@prosopo/common';
|
|
4
|
+
import { web3AccountsSubscribe, web3Enable } from '@polkadot/extension-dapp';
|
|
5
|
+
import Autocomplete from '@mui/material/Autocomplete';
|
|
6
|
+
import TextField from '@mui/material/TextField';
|
|
7
|
+
export const ExtensionAccountSelect = ({ value, dappName, onChange, }) => {
|
|
6
8
|
const { t } = useTranslation();
|
|
7
|
-
|
|
9
|
+
const [accounts, setAccounts] = useState([]);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const prom = web3Enable(dappName).then(() => {
|
|
12
|
+
return web3AccountsSubscribe(setAccounts);
|
|
13
|
+
});
|
|
14
|
+
return () => {
|
|
15
|
+
prom.then((unsub) => unsub());
|
|
16
|
+
};
|
|
17
|
+
}, []);
|
|
18
|
+
const account = accounts.find((a) => a.address === value) || null;
|
|
19
|
+
return (_jsx(Autocomplete, { disablePortal: true, id: "select-account", options: accounts, value: account, isOptionEqualToValue: (option, value) => option.address === value.address, onChange: (event, value) => {
|
|
20
|
+
if (value) {
|
|
21
|
+
console.log('Selected account:', value);
|
|
22
|
+
onChange(value.address);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
console.log('Deselected account');
|
|
26
|
+
onChange('');
|
|
27
|
+
}
|
|
28
|
+
}, sx: { width: 550 }, getOptionLabel: (option) => `${option.meta.name}: ${option.address}`, renderInput: (props) => _jsx(TextField, { ...props, label: t('WIDGET.SELECT_ACCOUNT') }) }));
|
|
8
29
|
};
|
|
9
30
|
export default ExtensionAccountSelect;
|
|
10
31
|
//# sourceMappingURL=ExtensionAccountSelect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionAccountSelect.js","sourceRoot":"","sources":["../../src/components/ExtensionAccountSelect.tsx"],"names":[],"mappings":";
|
|
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AAC,MAAM,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,EACzE,QAAQ,EAAE,CAAC,KAAqC,EAAE,KAAqC,EAAE,EAAE;YACvF,IAAI,KAAK,EAAE;gBACP,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAA;gBACvC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;aAC1B;iBAAM;gBACH,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;gBACjC,QAAQ,CAAC,EAAE,CAAC,CAAA;aACf;QACL,CAAC,EACD,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EAClB,cAAc,EAAE,CAAC,MAA+B,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,OAAO,EAAE,EAC7F,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAC,SAAS,OAAK,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,uBAAuB,CAAC,GAAI,GACrF,CACL,CAAA;AACL,CAAC,CAAA;AAED,eAAe,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ProcaptchaCallbacks, ProcaptchaConfigOptional } from '@prosopo/procaptcha';
|
|
2
|
+
/**
|
|
3
|
+
* The props for the Procaptcha component.
|
|
4
|
+
*/
|
|
5
|
+
export interface ProcaptchaProps {
|
|
6
|
+
config: ProcaptchaConfigOptional;
|
|
7
|
+
callbacks?: Partial<ProcaptchaCallbacks>;
|
|
8
|
+
}
|
|
9
|
+
export declare const Procaptcha: (props: ProcaptchaProps) => import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
//# 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,EAIH,mBAAmB,EACnB,wBAAwB,EAK3B,MAAM,qBAAqB,CAAA;AAS5B;;GAEG;AACH,MAAM,WAAW,eAAe;IAE5B,MAAM,EAAE,wBAAwB,CAAA;IAEhC,SAAS,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAA;CAC3C;AAqFD,eAAO,MAAM,UAAU,UAAW,eAAe,4CA2GhD,CAAA"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Manager, } from '@prosopo/procaptcha';
|
|
3
|
+
import { Alert, Backdrop, CircularProgress } from '@mui/material';
|
|
4
|
+
import { useRef, useState } from 'react';
|
|
5
|
+
import Box from '@mui/material/Box';
|
|
6
|
+
import CaptchaComponent from './CaptchaComponent';
|
|
7
|
+
import Checkbox from '@mui/material/Checkbox';
|
|
8
|
+
import Link from '@mui/material/Link';
|
|
9
|
+
import Typography from '@mui/material/Typography';
|
|
10
|
+
/**
|
|
11
|
+
* Wrap a ref to be the same format as useState.
|
|
12
|
+
* @param defaultValue the default value if the state is not already initialised
|
|
13
|
+
* @returns a ref in the same format as a state, e.g. [value, setValue]
|
|
14
|
+
*/
|
|
15
|
+
const useRefAsState = (defaultValue) => {
|
|
16
|
+
const ref = useRef(defaultValue);
|
|
17
|
+
const setter = (value) => {
|
|
18
|
+
ref.current = value;
|
|
19
|
+
};
|
|
20
|
+
const value = ref.current;
|
|
21
|
+
return [value, setter];
|
|
22
|
+
};
|
|
23
|
+
const useProcaptcha = () => {
|
|
24
|
+
// useRef == do not render on variable change
|
|
25
|
+
// useState == do render on variable change
|
|
26
|
+
// only need to render on visible variables changing
|
|
27
|
+
const [isHuman, setIsHuman] = useState(false);
|
|
28
|
+
const [index, setIndex] = useState(-1);
|
|
29
|
+
const [solutions, setSolutions] = useState([]);
|
|
30
|
+
const [captchaApi, setCaptchaApi] = useRefAsState(undefined);
|
|
31
|
+
const [showModal, setShowModal] = useState(false);
|
|
32
|
+
const [challenge, setChallenge] = useState(undefined);
|
|
33
|
+
const [loading, setLoading] = useState(false);
|
|
34
|
+
const [account, setAccount] = useState(undefined);
|
|
35
|
+
const [dappAccount, setDappAccount] = useState(undefined);
|
|
36
|
+
const [submission, setSubmission] = useRefAsState(undefined);
|
|
37
|
+
const [timeout, setTimeout] = useRefAsState(undefined);
|
|
38
|
+
const [blockNumber, setBlockNumber] = useRefAsState(undefined);
|
|
39
|
+
const map = {
|
|
40
|
+
isHuman: setIsHuman,
|
|
41
|
+
index: setIndex,
|
|
42
|
+
solutions: setSolutions,
|
|
43
|
+
captchaApi: setCaptchaApi,
|
|
44
|
+
showModal: setShowModal,
|
|
45
|
+
challenge: setChallenge,
|
|
46
|
+
loading: setLoading,
|
|
47
|
+
account: setAccount,
|
|
48
|
+
dappAccount: setDappAccount,
|
|
49
|
+
submission: setSubmission,
|
|
50
|
+
timeout: setTimeout,
|
|
51
|
+
blockNumber: setBlockNumber,
|
|
52
|
+
// don't provide method for updating config, should remain constant
|
|
53
|
+
};
|
|
54
|
+
return [
|
|
55
|
+
// the state
|
|
56
|
+
{
|
|
57
|
+
isHuman,
|
|
58
|
+
index,
|
|
59
|
+
solutions,
|
|
60
|
+
captchaApi,
|
|
61
|
+
showModal,
|
|
62
|
+
challenge,
|
|
63
|
+
loading,
|
|
64
|
+
account,
|
|
65
|
+
dappAccount,
|
|
66
|
+
submission,
|
|
67
|
+
timeout,
|
|
68
|
+
blockNumber,
|
|
69
|
+
},
|
|
70
|
+
// and method to update the state
|
|
71
|
+
(nextState) => {
|
|
72
|
+
if (nextState.solutions) {
|
|
73
|
+
// force a copy of the array to ensure a re-render
|
|
74
|
+
// nutshell: react doesn't look inside an array for changes, hence changes to the array need to result in a fresh array
|
|
75
|
+
nextState.solutions = nextState.solutions.slice();
|
|
76
|
+
}
|
|
77
|
+
for (const key in nextState) {
|
|
78
|
+
const setter = map[key];
|
|
79
|
+
if (!setter) {
|
|
80
|
+
throw new Error(`Unknown key ${key}, cannot set state`);
|
|
81
|
+
}
|
|
82
|
+
setter(nextState[key]);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
};
|
|
87
|
+
export const Procaptcha = (props) => {
|
|
88
|
+
console.log('config', props.config);
|
|
89
|
+
const config = props.config;
|
|
90
|
+
const callbacks = props.callbacks || {};
|
|
91
|
+
const [state, updateState] = useProcaptcha();
|
|
92
|
+
console.log('state', state);
|
|
93
|
+
const manager = Manager(config, state, updateState, callbacks);
|
|
94
|
+
return (_jsxs(Box, { sx: { maxWidth: '100%', maxHeight: '100%', overflowX: 'auto' }, children: [_jsx(Backdrop, { open: state.showModal, sx: { zIndex: (theme) => theme.zIndex.drawer + 1 }, 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 })) : (_jsx(Alert, { children: "No challenge set." })) }), _jsx(Box, { p: 1, sx: { maxWidth: '600px', minWidth: '200px' }, "data-cy": 'button-human', children: _jsxs(Box, { p: 1, border: 1, borderColor: "grey.300", borderRadius: 2, sx: {
|
|
95
|
+
display: 'flex',
|
|
96
|
+
justifyContent: 'space-between',
|
|
97
|
+
alignItems: 'center',
|
|
98
|
+
flexWrap: 'wrap',
|
|
99
|
+
color: 'black',
|
|
100
|
+
backgroundColor: 'white',
|
|
101
|
+
}, children: [_jsx(Box, { sx: { display: 'flex', flexDirection: 'column' }, children: _jsxs(Box, { sx: {
|
|
102
|
+
display: 'flex',
|
|
103
|
+
justifyContent: 'flex-start',
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
flexWrap: 'wrap',
|
|
106
|
+
}, children: [_jsxs(Box, { sx: {
|
|
107
|
+
height: '50px',
|
|
108
|
+
width: '50px',
|
|
109
|
+
display: 'flex',
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
justifyContent: 'center',
|
|
112
|
+
flexDirection: 'column',
|
|
113
|
+
}, children: [_jsx(Box, { sx: {
|
|
114
|
+
display: !state.loading ? 'block' : 'none',
|
|
115
|
+
}, children: _jsx(Checkbox, { onChange: manager.start, checked: state.isHuman, inputProps: { 'aria-label': 'controlled' }, sx: {
|
|
116
|
+
'& .MuiSvgIcon-root': { fontSize: 32 },
|
|
117
|
+
} }) }), _jsx(Box, { sx: {
|
|
118
|
+
display: state.loading ? 'block' : 'none',
|
|
119
|
+
}, children: _jsx(Box, { pt: '5px', children: _jsx(CircularProgress, { size: '24px', disableShrink: true }) }) })] }), _jsx(Box, { p: 1, children: _jsx(Typography, { children: "I am a human" }) })] }) }), _jsx(Box, { p: 1, sx: { flexGrow: '1', maxWidth: '140px', minWidth: '140px' }, children: _jsx(Link, { href: "https://prosopo.io", target: "_blank", children: _jsx(Box, { children: _jsx("div", { style: { width: '100%', display: 'flex', alignItems: 'middle' }, dangerouslySetInnerHTML: { __html: logo } }) }) }) })] }) })] }));
|
|
120
|
+
};
|
|
121
|
+
const logo = '<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2062.63 468.67"><defs><style>.cls-1{fill:#1d1d1b;}</style></defs><title>Prosopo Logo Black</title><path class="cls-1" d="M335.55,1825.19A147.75,147.75,0,0,1,483.3,1972.94h50.5c0-109.49-88.76-198.25-198.25-198.25v50.5Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M269.36,1891.39A147.74,147.74,0,0,1,417.1,2039.13h50.5c0-109.49-88.75-198.24-198.24-198.24v50.5Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M414,2157.17a147.75,147.75,0,0,1-147.74-147.74h-50.5c0,109.49,88.75,198.24,198.24,198.24v-50.5Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M480.17,2091a147.74,147.74,0,0,1-147.74-147.75H281.92c0,109.49,88.76,198.25,198.25,198.25V2091Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M862.8,2017.5q-27.39,22.86-78.25,22.86h-65v112.19H654.82v-312h134q46.32,0,73.86,24.13t27.55,74.72Q890.2,1994.64,862.8,2017.5ZM813,1905.1q-12.37-10.36-34.7-10.38H719.59v91.87h58.75q22.32,0,34.7-11.22t12.39-35.56Q825.43,1915.48,813,1905.1Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M1045.69,1916.42c.78.08,2.51.19,5.19.32v61.81c-3.81-.42-7.2-.71-10.16-.85s-5.36-.21-7.2-.21q-36.4,0-48.89,23.71-7,13.33-7,41.06v110.29H916.89V1921.82h57.58V1962q14-23.07,24.34-31.54,16.94-14.18,44-14.18C1044,1916.32,1044.92,1916.35,1045.69,1916.42Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M1265.64,2124.32q-29.21,36.06-88.69,36.06t-88.69-36.06Q1059,2088.26,1059,2037.5q0-49.9,29.22-86.5t88.69-36.59q59.47,0,88.69,36.59t29.21,86.5Q1294.85,2088.26,1265.64,2124.32ZM1217.38,2091q14.17-18.81,14.18-53.48t-14.18-53.37q-14.19-18.7-40.64-18.71T1136,1984.13q-14.29,18.72-14.29,53.37T1136,2091q14.28,18.81,40.75,18.81T1217.38,2091Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M1371.81,2078.88q1.92,16.1,8.29,22.87,11.28,12.06,41.7,12.06,17.85,0,28.39-5.29t10.53-15.88a17.12,17.12,0,0,0-8.48-15.45q-8.49-5.28-63.12-18.2-39.33-9.73-55.41-24.35-16.08-14.39-16.09-41.49,0-32,25.14-54.93t70.75-23q43.26,0,70.53,17.25t31.29,59.59H1455q-1.27-11.64-6.58-18.42-10-12.27-34-12.28-19.74,0-28.13,6.14t-8.38,14.4c0,6.91,3,11.93,8.92,15q8.89,4.89,63,16.73,36,8.46,54.05,25.61,17.77,17.35,17.78,43.39,0,34.3-25.56,56t-79,21.7q-54.51,0-80.49-23t-26-58.53Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M1745.54,2124.32q-29.22,36.06-88.7,36.06t-88.69-36.06q-29.2-36.06-29.21-86.82,0-49.9,29.21-86.5t88.69-36.59q59.49,0,88.7,36.59t29.21,86.5Q1774.75,2088.26,1745.54,2124.32ZM1697.27,2091q14.19-18.81,14.19-53.48t-14.19-53.37q-14.18-18.7-40.64-18.71t-40.75,18.71q-14.28,18.72-14.28,53.37t14.28,53.48q14.3,18.81,40.75,18.81T1697.27,2091Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M1992.75,1946.59q28.24,29.84,28.23,87.63,0,61-27.58,92.93t-71.06,32q-27.69,0-46-13.76-10-7.62-19.6-22.23v120.24H1797V1921.82h57.79v34.08q9.79-15,20.88-23.71,20.23-15.43,48.15-15.45Q1964.53,1916.74,1992.75,1946.59Zm-46.3,43.39q-12.3-20.52-39.88-20.53-33.15,0-45.54,31.11-6.43,16.51-6.42,41.92,0,40.21,21.58,56.51,12.82,9.53,30.37,9.53,25.45,0,38.83-19.48t13.36-51.86Q1958.75,2010.51,1946.45,1990Z" transform="translate(-215.73 -1774.69)"/><path class="cls-1" d="M2249.14,2124.32q-29.2,36.06-88.69,36.06t-88.69-36.06q-29.22-36.06-29.21-86.82,0-49.9,29.21-86.5t88.69-36.59q59.49,0,88.69,36.59t29.22,86.5Q2278.36,2088.26,2249.14,2124.32ZM2200.88,2091q14.19-18.81,14.18-53.48t-14.18-53.37q-14.18-18.7-40.64-18.71t-40.75,18.71q-14.28,18.72-14.29,53.37t14.29,53.48q14.3,18.81,40.75,18.81T2200.88,2091Z" transform="translate(-215.73 -1774.69)"/></svg>';
|
|
122
|
+
//# sourceMappingURL=Procaptcha.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Procaptcha.js","sourceRoot":"","sources":["../../src/components/Procaptcha.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGH,OAAO,GAOV,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACjE,OAAO,EAAE,MAAM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EAAE,QAAQ,EAAE,EAAE,EAAE;qDACzC,GACH,GACA,EACN,KAAC,GAAG,IACA,EAAE,EAAE;oDACA,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;iDAC5C,YAED,KAAC,GAAG,IAAC,EAAE,EAAE,KAAK,YACV,KAAC,gBAAgB,IAAC,IAAI,EAAE,MAAM,EAAE,aAAa,SAAG,GAC9C,GACJ,IACJ,EACN,KAAC,GAAG,IAAC,CAAC,EAAE,CAAC,YACL,KAAC,UAAU,+BAA0B,GACnC,IACJ,GAIJ,EACN,KAAC,GAAG,IAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAClE,KAAC,IAAI,IAAC,IAAI,EAAC,oBAAoB,EAAC,MAAM,EAAC,QAAQ,YAC3C,KAAC,GAAG,cACA,cACI,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,EAC/D,uBAAuB,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,GACtC,GACL,GACH,GACL,IACJ,GACJ,IACJ,CACT,CAAA;AACL,CAAC,CAAA;AAED,MAAM,IAAI,GACN,wjHAAwjH,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './CaptchaManager';
|
|
2
1
|
export * from './CaptchaWidget';
|
|
3
2
|
export * from './CaptchaComponent';
|
|
4
|
-
export
|
|
3
|
+
export { default as ExtensionAccountSelect } from './ExtensionAccountSelect';
|
|
4
|
+
export * from './Procaptcha';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAeA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAeA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAC5E,cAAc,cAAc,CAAA"}
|