@prosopo/procaptcha-react 0.1.8 → 0.1.10
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/.eslintrc.js +32 -18
- package/.prettierrc.js +7 -0
- package/dist/components/CaptchaComponent.d.ts +11 -4
- package/dist/components/CaptchaComponent.d.ts.map +1 -1
- package/dist/components/CaptchaComponent.js +61 -43
- 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 +73 -26
- package/dist/components/CaptchaWidget.js.map +1 -1
- package/dist/components/ExtensionAccountSelect.d.ts +4 -5
- package/dist/components/ExtensionAccountSelect.d.ts.map +1 -1
- package/dist/components/ExtensionAccountSelect.js +43 -5
- package/dist/components/ExtensionAccountSelect.js.map +1 -1
- package/dist/components/Procaptcha.d.ts +11 -0
- package/dist/components/Procaptcha.d.ts.map +1 -0
- package/dist/components/Procaptcha.js +104 -0
- package/dist/components/Procaptcha.js.map +1 -0
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -1
- 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.map +1 -1
- package/dist/util/index.js +1 -3
- package/dist/util/index.js.map +1 -1
- package/package.json +7 -4
- package/tsconfig.json +0 -8
- 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/.eslintrc.js
CHANGED
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
env: {
|
|
3
|
+
browser: true,
|
|
4
|
+
es2021: true,
|
|
5
5
|
},
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier', 'plugin:prettier/recommended'],
|
|
7
|
+
parser: '@typescript-eslint/parser',
|
|
8
|
+
parserOptions: {
|
|
9
|
+
ecmaVersion: 'latest',
|
|
10
|
+
sourceType: 'module',
|
|
11
|
+
},
|
|
12
|
+
plugins: ['unused-imports', '@typescript-eslint', 'prettier'],
|
|
13
|
+
rules: {
|
|
14
|
+
'no-unused-vars': 'off',
|
|
15
|
+
'unused-imports/no-unused-imports': 'error',
|
|
16
|
+
'unused-imports/no-unused-vars': [
|
|
17
|
+
'warn',
|
|
18
|
+
{
|
|
19
|
+
vars: 'all',
|
|
20
|
+
varsIgnorePattern: '^_',
|
|
21
|
+
args: 'after-used',
|
|
22
|
+
argsIgnorePattern: '^_',
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
//"indent": ["error", 4],
|
|
26
|
+
//"indent": "off",
|
|
27
|
+
'sort-imports': [
|
|
28
|
+
'error',
|
|
29
|
+
{
|
|
30
|
+
ignoreDeclarationSort: true,
|
|
31
|
+
allowSeparatedGroups: false,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
'prettier/prettier': ['error'],
|
|
14
35
|
},
|
|
15
|
-
"plugins": [
|
|
16
|
-
"@typescript-eslint"
|
|
17
|
-
],
|
|
18
|
-
"rules": {
|
|
19
|
-
"indent": ["error", 4],
|
|
20
|
-
"@typescript-eslint/no-empty-function": "warn"
|
|
21
|
-
}
|
|
22
36
|
}
|
package/.prettierrc.js
ADDED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { GetCaptchaResponse } from '@prosopo/procaptcha';
|
|
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) => 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":"AAkBA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAQxD,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,gBAuH5D,CAAA;AAED,eAAe,gBAAgB,CAAA"}
|
|
@@ -14,49 +14,67 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
14
14
|
//
|
|
15
15
|
// You should have received a copy of the GNU General Public License
|
|
16
16
|
// along with procaptcha-react. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
|
|
26
|
-
import { addDataAttr } from "../util";
|
|
27
|
-
export function CaptchaComponent({ clientInterface }) {
|
|
17
|
+
import Box from '@mui/material/Box';
|
|
18
|
+
import Button from '@mui/material/Button';
|
|
19
|
+
import Typography from '@mui/material/Typography';
|
|
20
|
+
import { CaptchaWidget } from './CaptchaWidget';
|
|
21
|
+
import { useTranslation } from '@prosopo/i18n';
|
|
22
|
+
import { addDataAttr } from '../util';
|
|
23
|
+
import ThemeProvider from '@mui/material/styles/ThemeProvider';
|
|
24
|
+
import theme from './theme';
|
|
25
|
+
export const CaptchaComponent = (props) => {
|
|
28
26
|
const { t } = useTranslation();
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
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
|
-
}
|
|
27
|
+
// console.log('CaptchaComponent', props)
|
|
28
|
+
const { challenge, index, solutions, onSubmit, onCancel, onClick, onNext } = props;
|
|
29
|
+
const captcha = challenge.captchas[index];
|
|
30
|
+
const solution = solutions[index];
|
|
31
|
+
return (_jsx(ThemeProvider, { theme: theme, children: _jsx(Box, { sx: {
|
|
32
|
+
// center the popup horizontally and vertically
|
|
33
|
+
display: 'flex',
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
justifyContent: 'center',
|
|
36
|
+
// fill entire screen
|
|
37
|
+
width: '100%',
|
|
38
|
+
height: '100%',
|
|
39
|
+
}, children: _jsx(Box, { sx: {
|
|
40
|
+
// introduce scroll bars when screen < minWidth of children
|
|
41
|
+
overflowX: 'auto',
|
|
42
|
+
overflowY: 'auto',
|
|
43
|
+
width: '100%',
|
|
44
|
+
// limit the popup width
|
|
45
|
+
maxWidth: '450px',
|
|
46
|
+
// maxHeight introduces vertical scroll bars if children content longer than window
|
|
47
|
+
maxHeight: '100%',
|
|
48
|
+
}, children: _jsxs(Box, { bgcolor: theme.palette.background.default, sx: {
|
|
49
|
+
display: 'flex',
|
|
50
|
+
flexDirection: 'column',
|
|
51
|
+
// the min width of the popup before scroll bars appear
|
|
52
|
+
minWidth: '300px',
|
|
53
|
+
}, children: [_jsx(Box, { px: 2, py: 3, sx: {
|
|
54
|
+
// center the header
|
|
55
|
+
display: 'flex',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
width: '100%',
|
|
58
|
+
}, bgcolor: theme.palette.primary.main, children: _jsx(Typography, { sx: {
|
|
59
|
+
color: '#ffffff',
|
|
60
|
+
fontWeight: 700,
|
|
61
|
+
}, children: t('WIDGET.SELECT_ALL', {
|
|
62
|
+
target: props.challenge.captchas[props.index].captcha.target,
|
|
63
|
+
}) }) }), _jsx(Box, { ...addDataAttr({ dev: { cy: 'captcha-' + props.index } }), children: _jsx(CaptchaWidget, { challenge: captcha, solution: solution, onClick: onClick }) }), _jsx(Box, { px: 2, py: 1, sx: {
|
|
64
|
+
display: 'flex',
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
justifyContent: 'center',
|
|
67
|
+
width: '100%',
|
|
68
|
+
}, ...addDataAttr({ dev: { cy: 'dots-captcha' } }), children: challenge.captchas.map((_, i) => (_jsx(Box, { sx: {
|
|
69
|
+
width: 7,
|
|
70
|
+
height: 7,
|
|
71
|
+
borderRadius: '50%',
|
|
72
|
+
border: '1px solid #CFCFCF',
|
|
73
|
+
}, mx: 0.5, bgcolor: index === i ? theme.palette.background.default : '#CFCFCF' }, i))) }), _jsxs(Box, { px: 2, pt: 0, pb: 2, sx: {
|
|
74
|
+
display: 'flex',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
justifyContent: 'space-between',
|
|
77
|
+
}, 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') })] })] }) }) }) }));
|
|
78
|
+
};
|
|
61
79
|
export default CaptchaComponent;
|
|
62
80
|
//# sourceMappingURL=CaptchaComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaptchaComponent.js","sourceRoot":"","sources":["../../src/components/CaptchaComponent.tsx"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,uFAAuF;AACvF,EAAE;AACF,2EAA2E;AAC3E,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,sEAAsE;AACtE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,4EAA4E;AAC5E,OAAO,
|
|
1
|
+
{"version":3,"file":"CaptchaComponent.js","sourceRoot":"","sources":["../../src/components/CaptchaComponent.tsx"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,uFAAuF;AACvF,EAAE;AACF,2EAA2E;AAC3E,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,sEAAsE;AACtE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,4EAA4E;AAC5E,OAAO,GAAG,MAAM,mBAAmB,CAAA;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E,CAAC;oCACR,MAAM,EAAE,CAAC;oCACT,YAAY,EAAE,KAAK;oCACnB,MAAM,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) => 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;AAO5D,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,gBA6GtD,CAAA;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -1,29 +1,76 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
// GNU General Public License for more details.
|
|
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 CheckIcon from '@mui/icons-material/Check';
|
|
3
|
+
import { Box, Fade } from '@mui/material';
|
|
4
|
+
import useTheme from '@mui/styles/useTheme';
|
|
5
|
+
const getHash = (item) => {
|
|
6
|
+
if (!item.hash) {
|
|
7
|
+
throw new Error('item.hash is undefined');
|
|
8
|
+
}
|
|
9
|
+
return item.hash;
|
|
10
|
+
};
|
|
11
|
+
export const CaptchaWidget = (props) => {
|
|
12
|
+
// console.log('CaptchaWidget', props)
|
|
13
|
+
const { challenge, solution, onClick } = props;
|
|
24
14
|
const items = challenge.captcha.items;
|
|
25
|
-
const
|
|
26
|
-
return (_jsx(_Fragment, { children:
|
|
27
|
-
|
|
15
|
+
const theme = useTheme();
|
|
16
|
+
return (_jsx(_Fragment, { children: _jsx(Box, { pr: 0.5, pb: 0.5, sx: {
|
|
17
|
+
// expand to full height / width of parent
|
|
18
|
+
width: '100%',
|
|
19
|
+
height: '100%',
|
|
20
|
+
// display children in flex, spreading them evenly and wrapping when row length exceeded
|
|
21
|
+
display: 'flex',
|
|
22
|
+
flexDirection: 'row',
|
|
23
|
+
flexWrap: 'wrap',
|
|
24
|
+
}, children: items.map((item, index) => {
|
|
25
|
+
const hash = getHash(item);
|
|
26
|
+
return (_jsx(Box, { pt: 0.5, pl: 0.5, sx: {
|
|
27
|
+
// enable the items in the grid to grow in width to use up excess space
|
|
28
|
+
flexGrow: 1,
|
|
29
|
+
// make the width of each item 1/3rd of the width overall, i.e. 3 columns
|
|
30
|
+
flexBasis: '33.3333%',
|
|
31
|
+
// include the padding / margin / border in the width
|
|
32
|
+
boxSizing: 'border-box',
|
|
33
|
+
}, 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: {
|
|
34
|
+
width: '100%',
|
|
35
|
+
backgroundColor: 'lightgray',
|
|
36
|
+
display: 'block',
|
|
37
|
+
objectFit: 'contain',
|
|
38
|
+
aspectRatio: '1/1', // force AR to be 1, letterboxing images with different aspect ratios
|
|
39
|
+
}, src: item.data, alt: `Captcha image ${index + 1}` }) }), _jsx(Fade, { in: solution.includes(hash), children: _jsx(Box, { sx: {
|
|
40
|
+
// relative to where the element _should_ be positioned
|
|
41
|
+
position: 'relative',
|
|
42
|
+
// make the overlay the full height/width of an item
|
|
43
|
+
width: '100%',
|
|
44
|
+
height: '100%',
|
|
45
|
+
// shift it up 100% to overlay the item element
|
|
46
|
+
top: '-100%',
|
|
47
|
+
// transition on opacity upon (de)selection
|
|
48
|
+
transitionDuration: '300ms',
|
|
49
|
+
transitionProperty: 'opacity',
|
|
50
|
+
}, children: _jsx(Box, { sx: {
|
|
51
|
+
// make the overlay absolute positioned compare to its container
|
|
52
|
+
position: 'absolute',
|
|
53
|
+
// spread across 100% width/height of the item box
|
|
54
|
+
top: 0,
|
|
55
|
+
left: 0,
|
|
56
|
+
bottom: 0,
|
|
57
|
+
right: 0,
|
|
58
|
+
height: '100%',
|
|
59
|
+
width: '100%',
|
|
60
|
+
// display overlays in center
|
|
61
|
+
display: 'flex',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
justifyContent: 'center',
|
|
64
|
+
// make bg half opacity, i.e. shadowing the item's img
|
|
65
|
+
backgroundColor: 'rgba(0,0,0,0.5)',
|
|
66
|
+
}, children: _jsx(CheckIcon, { htmlColor: theme.palette.background.default, sx: {
|
|
67
|
+
// img must be displayed as block otherwise get's a bottom whitespace border
|
|
68
|
+
display: 'block',
|
|
69
|
+
// how big the overlay icon is
|
|
70
|
+
width: '35%',
|
|
71
|
+
height: '35%',
|
|
72
|
+
} }) }) }) })] }) }, index));
|
|
73
|
+
}) }) }));
|
|
74
|
+
};
|
|
28
75
|
export default CaptchaWidget;
|
|
29
76
|
//# 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":";AAiBA,OAAO,SAAS,MAAM,2BAA2B,CAAA;AACjD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAS,MAAM,eAAe,CAAA;AAChD,OAAO,QAAQ,MAAM,sBAAsB,CAAA;AAS3C,MAAM,OAAO,GAAG,CAAC,IAAU,EAAE,EAAE;IAC3B,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,sCAAsC;IACtC,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,EA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AAC;4CACR,MAAM,EAAE,MAAM;4CACd,KAAK,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,IAnED,KAAK,CAoER,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
|
-
onChange: (value: TExtensionAccount | null) => void;
|
|
1
|
+
export declare const ExtensionAccountSelect: ({ value, dappName, onChange, }: {
|
|
2
|
+
value?: string | undefined;
|
|
3
|
+
dappName: string;
|
|
4
|
+
onChange: (value: string) => void;
|
|
6
5
|
}) => 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":"AAsBA,eAAO,MAAM,sBAAsB;;cAMrB,MAAM;sBACE,MAAM,KAAK,IAAI;iBAuCpC,CAAA;AAED,eAAe,sBAAsB,CAAA"}
|
|
@@ -1,10 +1,48 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
3
|
+
// This file is part of procaptcha-react <https://github.com/prosopo/procaptcha-react>.
|
|
4
|
+
//
|
|
5
|
+
// procaptcha-react is free software: you can redistribute it and/or modify
|
|
6
|
+
// it under the terms of the GNU General Public License as published by
|
|
7
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
// (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// procaptcha-react is distributed in the hope that it will be useful,
|
|
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, useState } from 'react';
|
|
18
|
+
import Autocomplete from '@mui/material/Autocomplete';
|
|
19
|
+
import TextField from '@mui/material/TextField';
|
|
20
|
+
import { useTranslation } from '@prosopo/i18n';
|
|
21
|
+
import { web3AccountsSubscribe, web3Enable } from '@polkadot/extension-dapp';
|
|
22
|
+
export const ExtensionAccountSelect = ({ value, dappName, onChange, }) => {
|
|
6
23
|
const { t } = useTranslation();
|
|
7
|
-
|
|
24
|
+
const [accounts, setAccounts] = useState([]);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const prom = web3Enable(dappName).then(() => {
|
|
27
|
+
console.log('subscribe');
|
|
28
|
+
return web3AccountsSubscribe(setAccounts);
|
|
29
|
+
});
|
|
30
|
+
return () => {
|
|
31
|
+
console.log('unsubscribe');
|
|
32
|
+
prom.then((unsub) => unsub());
|
|
33
|
+
};
|
|
34
|
+
}, []);
|
|
35
|
+
const account = accounts.find((a) => a.address === value) || null;
|
|
36
|
+
return (_jsx(Autocomplete, { disablePortal: true, id: "select-account", options: accounts, value: account, isOptionEqualToValue: (option, value) => option.address === value.address, onChange: (event, value) => {
|
|
37
|
+
if (value) {
|
|
38
|
+
console.log('Selected account:', value);
|
|
39
|
+
onChange(value.address);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.log('Deselected account');
|
|
43
|
+
onChange('');
|
|
44
|
+
}
|
|
45
|
+
}, sx: { width: 550 }, getOptionLabel: (option) => `${option.meta.name}: ${option.address}`, renderInput: (props) => _jsx(TextField, { ...props, label: t('WIDGET.SELECT_ACCOUNT') }) }));
|
|
8
46
|
};
|
|
9
47
|
export default ExtensionAccountSelect;
|
|
10
48
|
//# sourceMappingURL=ExtensionAccountSelect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionAccountSelect.js","sourceRoot":"","sources":["../../src/components/ExtensionAccountSelect.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ExtensionAccountSelect.js","sourceRoot":"","sources":["../../src/components/ExtensionAccountSelect.tsx"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,uFAAuF;AACvF,EAAE;AACF,2EAA2E;AAC3E,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,sEAAsE;AACtE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,4EAA4E;AAC5E,OAAO,EAAkB,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3D,OAAO,YAAY,MAAM,4BAA4B,CAAA;AACrD,OAAO,SAAS,MAAM,yBAAyB,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAG5E,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EACnC,KAAK,EAC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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,11 @@
|
|
|
1
|
+
import { ProcaptchaCallbacks } from '@prosopo/procaptcha';
|
|
2
|
+
import { ProcaptchaConfigOptional } from '@prosopo/procaptcha';
|
|
3
|
+
/**
|
|
4
|
+
* The props for the Procaptcha component.
|
|
5
|
+
*/
|
|
6
|
+
export interface ProcaptchaProps {
|
|
7
|
+
config: ProcaptchaConfigOptional;
|
|
8
|
+
callbacks?: Partial<ProcaptchaCallbacks>;
|
|
9
|
+
}
|
|
10
|
+
export declare const Procaptcha: (props: ProcaptchaProps) => JSX.Element;
|
|
11
|
+
//# sourceMappingURL=Procaptcha.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Procaptcha.d.ts","sourceRoot":"","sources":["../../src/components/Procaptcha.tsx"],"names":[],"mappings":"AAKA,OAAO,EAGH,mBAAmB,EAGtB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAW,wBAAwB,EAA4C,MAAM,qBAAqB,CAAA;AAIjH;;GAEG;AACH,MAAM,WAAW,eAAe;IAE5B,MAAM,EAAE,wBAAwB,CAAA;IAEhC,SAAS,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAA;CAC3C;AA4ED,eAAO,MAAM,UAAU,UAAW,eAAe,gBAkGhD,CAAA"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Typography from '@mui/material/Typography';
|
|
3
|
+
import Box from '@mui/material/Box';
|
|
4
|
+
import Checkbox from '@mui/material/Checkbox';
|
|
5
|
+
import { useRef, useState } from 'react';
|
|
6
|
+
import Link from '@mui/material/Link';
|
|
7
|
+
import { Manager } from '@prosopo/procaptcha';
|
|
8
|
+
import { Alert, Backdrop, CircularProgress } from '@mui/material';
|
|
9
|
+
import CaptchaComponent from './CaptchaComponent';
|
|
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 [submission, setSubmission] = useRefAsState(undefined);
|
|
36
|
+
const map = {
|
|
37
|
+
isHuman: setIsHuman,
|
|
38
|
+
index: setIndex,
|
|
39
|
+
solutions: setSolutions,
|
|
40
|
+
captchaApi: setCaptchaApi,
|
|
41
|
+
showModal: setShowModal,
|
|
42
|
+
challenge: setChallenge,
|
|
43
|
+
loading: setLoading,
|
|
44
|
+
account: setAccount,
|
|
45
|
+
submission: setSubmission,
|
|
46
|
+
// don't provide method for updating config, should remain constant
|
|
47
|
+
};
|
|
48
|
+
return [
|
|
49
|
+
// the state
|
|
50
|
+
{
|
|
51
|
+
isHuman,
|
|
52
|
+
index,
|
|
53
|
+
solutions,
|
|
54
|
+
captchaApi,
|
|
55
|
+
showModal,
|
|
56
|
+
challenge,
|
|
57
|
+
loading,
|
|
58
|
+
account,
|
|
59
|
+
submission,
|
|
60
|
+
},
|
|
61
|
+
// and method to update the state
|
|
62
|
+
(nextState) => {
|
|
63
|
+
if (nextState.solutions) {
|
|
64
|
+
// force a copy of the array to ensure a re-render
|
|
65
|
+
// nutshell: react doesn't look inside an array for changes, hence changes to the array need to result in a fresh array
|
|
66
|
+
nextState.solutions = nextState.solutions.slice();
|
|
67
|
+
}
|
|
68
|
+
for (const key in nextState) {
|
|
69
|
+
const setter = map[key];
|
|
70
|
+
if (!setter) {
|
|
71
|
+
throw new Error(`Unknown key ${key}, cannot set state`);
|
|
72
|
+
}
|
|
73
|
+
setter(nextState[key]);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
};
|
|
78
|
+
export const Procaptcha = (props) => {
|
|
79
|
+
const config = props.config;
|
|
80
|
+
const callbacks = props.callbacks || {};
|
|
81
|
+
const [state, updateState] = useProcaptcha();
|
|
82
|
+
const manager = Manager(config, state, updateState, callbacks);
|
|
83
|
+
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' }, children: _jsxs(Box, { p: 1, border: 1, borderColor: "grey.300", borderRadius: 2, sx: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap' }, children: [_jsx(Box, { sx: { display: 'flex', flexDirection: 'column' }, children: _jsxs(Box, { sx: {
|
|
84
|
+
display: 'flex',
|
|
85
|
+
justifyContent: 'flex-start',
|
|
86
|
+
alignItems: 'center',
|
|
87
|
+
flexWrap: 'wrap',
|
|
88
|
+
}, children: [_jsxs(Box, { sx: {
|
|
89
|
+
height: '50px',
|
|
90
|
+
width: '50px',
|
|
91
|
+
display: 'flex',
|
|
92
|
+
alignItems: 'center',
|
|
93
|
+
justifyContent: 'center',
|
|
94
|
+
flexDirection: 'column',
|
|
95
|
+
}, children: [_jsx(Box, { sx: {
|
|
96
|
+
display: !state.loading ? 'block' : 'none',
|
|
97
|
+
}, children: _jsx(Checkbox, { onChange: manager.start, checked: state.isHuman, inputProps: { 'aria-label': 'controlled' }, sx: {
|
|
98
|
+
'& .MuiSvgIcon-root': { fontSize: 32 },
|
|
99
|
+
} }) }), _jsx(Box, { sx: {
|
|
100
|
+
display: state.loading ? 'block' : 'none',
|
|
101
|
+
}, 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 } }) }) }) })] }) })] }));
|
|
102
|
+
};
|
|
103
|
+
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>';
|
|
104
|
+
//# sourceMappingURL=Procaptcha.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Procaptcha.js","sourceRoot":"","sources":["../../src/components/Procaptcha.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,0BAA0B,CAAA;AACjD,OAAO,GAAG,MAAM,mBAAmB,CAAA;AACnC,OAAO,QAAQ,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,IAAI,MAAM,oBAAoB,CAAA;AAQrC,OAAO,EAAE,OAAO,EAAsE,MAAM,qBAAqB,CAAA;AACjH,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACjE,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AAYjD;;;;GAIG;AACH,MAAM,aAAa,GAAG,CAAK,YAAe,EAA2B,EAAE;IACnE,MAAM,GAAG,GAAG,MAAM,CAAI,YAAY,CAAC,CAAA;IACnC,MAAM,MAAM,GAAG,CAAC,KAAQ,EAAE,EAAE;QACxB,GAAG,CAAC,OAAO,GAAG,KAAK,CAAA;IACvB,CAAC,CAAA;IACD,MAAM,KAAK,GAAM,GAAG,CAAC,OAAO,CAAA;IAC5B,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;AAC1B,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,GAA+C,EAAE;IACnE,6CAA6C;IAC7C,2CAA2C;IAC3C,oDAAoD;IAEpD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC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AAE,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 +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,cAAc,0BAA0B,CAAA;AACxC,cAAc,cAAc,CAAA"}
|
package/dist/components/index.js
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
//
|
|
14
14
|
// You should have received a copy of the GNU General Public License
|
|
15
15
|
// along with procaptcha-react. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
-
export * from './CaptchaManager';
|
|
17
16
|
export * from './CaptchaWidget';
|
|
18
17
|
export * from './CaptchaComponent';
|
|
19
18
|
export * from './ExtensionAccountSelect';
|
|
19
|
+
export * from './Procaptcha';
|
|
20
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,uFAAuF;AACvF,EAAE;AACF,2EAA2E;AAC3E,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,sEAAsE;AACtE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,4EAA4E;AAC5E,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,uFAAuF;AACvF,EAAE;AACF,2EAA2E;AAC3E,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,sEAAsE;AACtE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,4EAA4E;AAC5E,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/components/theme.ts"],"names":[],"mappings":";AAEA,wBAOE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../src/components/theme.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,kCAAkC,CAAA;AAE1D,eAAe,WAAW,CAAC;IACvB,OAAO,EAAE;QACL,OAAO,EAAE;YACL,IAAI,EAAE,SAAS;YACf,YAAY,EAAE,MAAM;SACvB;KACJ;CACJ,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,cAAc,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,cAAc,cAAc,CAAA;AAC5B,cAAc,QAAQ,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,5 @@
|
|
|
14
14
|
// You should have received a copy of the GNU General Public License
|
|
15
15
|
// along with procaptcha-react. If not, see <http://www.gnu.org/licenses/>.
|
|
16
16
|
export * from './components';
|
|
17
|
-
export * from './styles';
|
|
18
17
|
export * from './util';
|
|
19
18
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,uFAAuF;AACvF,EAAE;AACF,2EAA2E;AAC3E,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,sEAAsE;AACtE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,4EAA4E;AAC5E,cAAc,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,uFAAuF;AACvF,EAAE;AACF,2EAA2E;AAC3E,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,sEAAsE;AACtE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,4EAA4E;AAC5E,cAAc,cAAc,CAAA;AAC5B,cAAc,QAAQ,CAAA"}
|
package/dist/util/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EACxB,OAAO,EACP,GAAG,GACN,EAAE;IACC,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IACnC,GAAG,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;CAClC,MAKA"}
|
package/dist/util/index.js
CHANGED
|
@@ -9,9 +9,7 @@ function renameKeysForDataAttr(data = {}) {
|
|
|
9
9
|
export function addDataAttr({ general, dev, }) {
|
|
10
10
|
return {
|
|
11
11
|
...renameKeysForDataAttr(general),
|
|
12
|
-
...(process.env.NODE_ENV ===
|
|
13
|
-
? renameKeysForDataAttr(dev)
|
|
14
|
-
: {}),
|
|
12
|
+
...(process.env.NODE_ENV === 'development' ? renameKeysForDataAttr(dev) : {}),
|
|
15
13
|
};
|
|
16
14
|
}
|
|
17
15
|
//# sourceMappingURL=index.js.map
|
package/dist/util/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,SAAS,qBAAqB,CAAC,OAAkC,EAAE;IAC/D,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,SAAS,qBAAqB,CAAC,OAAkC,EAAE;IAC/D,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA;AACpG,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,EACxB,OAAO,EACP,GAAG,GAIN;IACG,OAAO;QACH,GAAG,qBAAqB,CAAC,OAAO,CAAC;QACjC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC,CAAC,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAChF,CAAA;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/procaptcha-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -13,10 +13,13 @@
|
|
|
13
13
|
"lint:fix": "npx eslint . --fix"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@
|
|
16
|
+
"@emotion/react": "^11.10.4",
|
|
17
|
+
"@emotion/styled": "^11.10.4",
|
|
18
|
+
"@mui/icons-material": "^5.10.9",
|
|
19
|
+
"@mui/material": "^5.10.11",
|
|
17
20
|
"@mui/styles": "^5.8.3",
|
|
18
|
-
"@prosopo/i18n": "0.
|
|
19
|
-
"@prosopo/procaptcha": "0.1.
|
|
21
|
+
"@prosopo/i18n": "^0.1.10",
|
|
22
|
+
"@prosopo/procaptcha": "^0.1.10",
|
|
20
23
|
"react": "^17.0.0",
|
|
21
24
|
"react-dom": "^17.0.0"
|
|
22
25
|
},
|
package/tsconfig.json
CHANGED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { ICaptchaContextState, ICaptchaContextReducer, ProsopoCaptchaClient, CaptchaEventCallbacks } from "@prosopo/procaptcha";
|
|
3
|
-
export declare function useCaptcha(defaultContext: ICaptchaContextState, callbacks?: CaptchaEventCallbacks): ProsopoCaptchaClient;
|
|
4
|
-
export declare const CaptchaContextManager: import("react").Context<ICaptchaContextReducer>;
|
|
5
|
-
//# sourceMappingURL=CaptchaManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CaptchaManager.d.ts","sourceRoot":"","sources":["../../src/components/CaptchaManager.ts"],"names":[],"mappings":";AAiBA,OAAO,EACH,oBAAoB,EAGpB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACxB,MAAM,qBAAqB,CAAC;AAG7B,wBAAgB,UAAU,CAAC,cAAc,EAAE,oBAAoB,EAAE,SAAS,CAAC,EAAE,qBAAqB,GAAG,oBAAoB,CAIxH;AAED,eAAO,MAAM,qBAAqB,iDAuBN,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
2
|
-
// This file is part of procaptcha-react <https://github.com/prosopo/procaptcha-react>.
|
|
3
|
-
//
|
|
4
|
-
// procaptcha-react is free software: you can redistribute it and/or modify
|
|
5
|
-
// it under the terms of the GNU General Public License as published by
|
|
6
|
-
// the Free Software Foundation, either version 3 of the License, or
|
|
7
|
-
// (at your option) any later version.
|
|
8
|
-
//
|
|
9
|
-
// procaptcha-react is distributed in the hope that it will be useful,
|
|
10
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
// GNU General Public License for more details.
|
|
13
|
-
//
|
|
14
|
-
// You should have received a copy of the GNU General Public License
|
|
15
|
-
// along with procaptcha-react. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
-
import { createContext, useReducer } from "react";
|
|
17
|
-
import { captchaContextReducer, captchaStatusReducer, ProsopoCaptchaClient, } from "@prosopo/procaptcha";
|
|
18
|
-
export function useCaptcha(defaultContext, callbacks) {
|
|
19
|
-
const [context, updateContext] = useReducer(captchaContextReducer, defaultContext);
|
|
20
|
-
const [status, updateStatus] = useReducer(captchaStatusReducer, {});
|
|
21
|
-
return new ProsopoCaptchaClient({ state: context, update: updateContext }, { state: status, update: updateStatus }, callbacks);
|
|
22
|
-
}
|
|
23
|
-
export const CaptchaContextManager = createContext({
|
|
24
|
-
state: {
|
|
25
|
-
config: {
|
|
26
|
-
"providerApi.baseURL": "",
|
|
27
|
-
"providerApi.prefix": "",
|
|
28
|
-
"dappAccount": "",
|
|
29
|
-
"dappUrl": "",
|
|
30
|
-
"solutionThreshold": 0,
|
|
31
|
-
"web2": false,
|
|
32
|
-
"prosopoContractAccount": "",
|
|
33
|
-
"accountCreator": {
|
|
34
|
-
"area": { width: 0, height: 0 },
|
|
35
|
-
"offsetParameter": 0,
|
|
36
|
-
"multiplier": 0,
|
|
37
|
-
"fontSizeFactor": 0,
|
|
38
|
-
"maxShadowBlur": 0,
|
|
39
|
-
"numberOfRounds": 0,
|
|
40
|
-
"seed": 0
|
|
41
|
-
},
|
|
42
|
-
"dappName": ""
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
update: () => { },
|
|
46
|
-
});
|
|
47
|
-
//# sourceMappingURL=CaptchaManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CaptchaManager.js","sourceRoot":"","sources":["../../src/components/CaptchaManager.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,uFAAuF;AACvF,EAAE;AACF,2EAA2E;AAC3E,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,sEAAsE;AACtE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC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.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles/withStyles").ClassNameMap<"root" | "dot" | "captchasContainer" | "captchasHeader" | "captchasBody" | "captchasFooter" | "captchaItem" | "captchaItemSelected" | "captchasHeaderLabel" | "dotsContainer" | "dotActive">;
|
|
2
|
-
//# sourceMappingURL=styles.d.ts.map
|
package/dist/styles.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,SAAS,6PAiEpB,CAAC"}
|
package/dist/styles.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
2
|
-
// This file is part of procaptcha-react <https://github.com/prosopo/procaptcha-react>.
|
|
3
|
-
//
|
|
4
|
-
// procaptcha-react is free software: you can redistribute it and/or modify
|
|
5
|
-
// it under the terms of the GNU General Public License as published by
|
|
6
|
-
// the Free Software Foundation, either version 3 of the License, or
|
|
7
|
-
// (at your option) any later version.
|
|
8
|
-
//
|
|
9
|
-
// procaptcha-react is distributed in the hope that it will be useful,
|
|
10
|
-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
-
// GNU General Public License for more details.
|
|
13
|
-
//
|
|
14
|
-
// You should have received a copy of the GNU General Public License
|
|
15
|
-
// along with procaptcha-react. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
-
import makeStyles from "@mui/styles/makeStyles";
|
|
17
|
-
const dot = {
|
|
18
|
-
width: 7,
|
|
19
|
-
height: 7,
|
|
20
|
-
borderRadius: 3.5,
|
|
21
|
-
marginRight: 5,
|
|
22
|
-
border: "1px solid #CFCFCF",
|
|
23
|
-
backgroundColor: "#FFFFFF",
|
|
24
|
-
};
|
|
25
|
-
export const useStyles = makeStyles({
|
|
26
|
-
root: {
|
|
27
|
-
display: "flex",
|
|
28
|
-
alignItems: "center",
|
|
29
|
-
justifyContent: "center",
|
|
30
|
-
width: "100%",
|
|
31
|
-
height: "100%"
|
|
32
|
-
},
|
|
33
|
-
captchasContainer: {
|
|
34
|
-
display: "flex",
|
|
35
|
-
flexDirection: "column",
|
|
36
|
-
background: "#FFFFFF",
|
|
37
|
-
border: "1px solid #CFCFCF",
|
|
38
|
-
boxShadow: "0px 2px 4px rgba(0, 0, 0, 0.2)"
|
|
39
|
-
},
|
|
40
|
-
captchasHeader: {
|
|
41
|
-
display: "flex",
|
|
42
|
-
alignItems: "center",
|
|
43
|
-
backgroundColor: "#bdbdbd",
|
|
44
|
-
height: 80,
|
|
45
|
-
paddingLeft: 20
|
|
46
|
-
},
|
|
47
|
-
captchasBody: {
|
|
48
|
-
display: "flex",
|
|
49
|
-
width: 460,
|
|
50
|
-
flexWrap: "wrap",
|
|
51
|
-
height: "max-content",
|
|
52
|
-
paddingTop: 10,
|
|
53
|
-
paddingLeft: 10,
|
|
54
|
-
borderBottom: "1px solid #CFCFCF"
|
|
55
|
-
},
|
|
56
|
-
captchasFooter: {
|
|
57
|
-
display: "flex",
|
|
58
|
-
alignItems: "center",
|
|
59
|
-
justifyContent: "space-between",
|
|
60
|
-
height: 80,
|
|
61
|
-
paddingLeft: 20,
|
|
62
|
-
paddingRight: 20
|
|
63
|
-
},
|
|
64
|
-
captchaItem: {
|
|
65
|
-
width: "140px !important",
|
|
66
|
-
borderRadius: 2,
|
|
67
|
-
height: "140px !important",
|
|
68
|
-
marginRight: 10,
|
|
69
|
-
marginBottom: 10
|
|
70
|
-
},
|
|
71
|
-
captchaItemSelected: {
|
|
72
|
-
border: "2px solid #1976d2"
|
|
73
|
-
},
|
|
74
|
-
captchasHeaderLabel: {
|
|
75
|
-
color: "#ffffff"
|
|
76
|
-
},
|
|
77
|
-
dotsContainer: {
|
|
78
|
-
display: "flex",
|
|
79
|
-
alignItems: "center",
|
|
80
|
-
justifyContent: "center",
|
|
81
|
-
width: "100%",
|
|
82
|
-
paddingBottom: 15,
|
|
83
|
-
paddingTop: 10
|
|
84
|
-
},
|
|
85
|
-
dot,
|
|
86
|
-
dotActive: {
|
|
87
|
-
...dot,
|
|
88
|
-
backgroundColor: "#CFCFCF"
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
//# sourceMappingURL=styles.js.map
|
package/dist/styles.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,uFAAuF;AACvF,EAAE;AACF,2EAA2E;AAC3E,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,sEAAsE;AACtE,iEAAiE;AACjE,gEAAgE;AAChE,+CAA+C;AAC/C,EAAE;AACF,oEAAoE;AACpE,4EAA4E;AAC5E,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAEhD,MAAM,GAAG,GAAG;IACR,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,YAAY,EAAE,GAAG;IACjB,WAAW,EAAE,CAAC;IACd,MAAM,EAAE,mBAAmB;IAC3B,eAAe,EAAE,SAAS;CAC7B,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC;IAChC,IAAI,EAAE;QACF,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;QACxB,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;KACjB;IACD,iBAAiB,EAAE;QACf,OAAO,EAAE,MAAM;QACf,aAAa,EAAE,QAAQ;QACvB,UAAU,EAAE,SAAS;QACrB,MAAM,EAAE,mBAAmB;QAC3B,SAAS,EAAE,gCAAgC;KAC9C;IACD,cAAc,EAAE;QACZ,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,QAAQ;QACpB,eAAe,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