@prosopo/procaptcha-react 0.1.0 → 0.1.4
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/README.md +36 -0
- package/dist/components/CaptchaComponent.d.ts +6 -0
- package/dist/components/CaptchaComponent.d.ts.map +1 -0
- package/{src/components/CaptchaComponent.tsx → dist/components/CaptchaComponent.js} +9 -63
- package/dist/components/CaptchaComponent.js.map +1 -0
- package/dist/components/CaptchaManager.d.ts +5 -0
- package/dist/components/CaptchaManager.d.ts.map +1 -0
- package/{src/components/CaptchaManager.ts → dist/components/CaptchaManager.js} +9 -17
- package/dist/components/CaptchaManager.js.map +1 -0
- package/dist/components/CaptchaWidget.d.ts +8 -0
- package/dist/components/CaptchaWidget.d.ts.map +1 -0
- package/{src/components/CaptchaWidget.tsx → dist/components/CaptchaWidget.js} +6 -21
- package/dist/components/CaptchaWidget.js.map +1 -0
- package/dist/components/ExtensionAccountSelect.d.ts +8 -0
- package/dist/components/ExtensionAccountSelect.d.ts.map +1 -0
- package/dist/components/ExtensionAccountSelect.js +8 -0
- package/dist/components/ExtensionAccountSelect.js.map +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.d.ts.map +1 -0
- package/{src/components/index.ts → dist/components/index.js} +1 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/{src/index.ts → dist/index.js} +1 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.d.ts +2 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +91 -0
- package/dist/styles.js.map +1 -0
- package/package.json +3 -3
- package/tsconfig.tsbuildinfo +1 -0
- package/src/components/ExtensionAccountSelect.tsx +0 -38
- package/src/styles.ts +0 -89
package/README.md
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# React Prosopo Procaptcha Component Library
|
|
2
|
+
|
|
3
|
+
React components for integrating the Prosopo [procaptcha](https://github.com/prosopo-io/procaptcha) into a React app.
|
|
4
|
+
|
|
5
|
+
Prosopo is a distributed human verification service that can be used to stop bots from interacting with smart contracts. Sign up to be a network [alpha tester](https://5b06hrhtlmh.typeform.com/to/vNpyOUfg).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
You can install this library with:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @prosopo/procaptcha-react --save
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Basic Usage
|
|
16
|
+
|
|
17
|
+
See the [client example](https://github.com/prosopo-io/client-example) for a minimal example of these components being used in a frontend app.
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
<Box className={"App"}>
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
<CaptchaContextManager.Provider value={manager}>
|
|
24
|
+
{showCaptchas &&
|
|
25
|
+
<CaptchaComponent {...{ clientInterface }} />}
|
|
26
|
+
</CaptchaContextManager.Provider>
|
|
27
|
+
|
|
28
|
+
{!showCaptchas &&
|
|
29
|
+
<Button onClick={showCaptchaClick} className={"iAmHumanButton"}>
|
|
30
|
+
<Typography className={"iAmHumanButtonLabel"}>
|
|
31
|
+
I am human
|
|
32
|
+
</Typography>
|
|
33
|
+
</Button>}
|
|
34
|
+
|
|
35
|
+
</Box>
|
|
36
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CaptchaComponent.d.ts","sourceRoot":"","sources":["../../src/components/CaptchaComponent.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAEH,oBAAoB,EAGvB,MAAM,qBAAqB,CAAC;AAQ7B,wBAAgB,gBAAgB,CAAC,EAAE,eAAe,EAAE,EAAE;IAAE,eAAe,EAAE,oBAAoB,CAAA;CAAE,eA+E9F;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
2
3
|
// This file is part of procaptcha-react <https://github.com/prosopo-io/procaptcha-react>.
|
|
3
4
|
//
|
|
@@ -15,38 +16,21 @@
|
|
|
15
16
|
// along with procaptcha-react. If not, see <http://www.gnu.org/licenses/>.
|
|
16
17
|
import { useEffect, useContext, useReducer } from "react";
|
|
17
18
|
import { Box, Button, Typography } from "@mui/material";
|
|
18
|
-
import {
|
|
19
|
-
ICaptchaContextReducer,
|
|
20
|
-
ProsopoCaptchaClient,
|
|
21
|
-
ProsopoCaptchaStateClient,
|
|
22
|
-
captchaStateReducer
|
|
23
|
-
} from "@prosopo/procaptcha";
|
|
24
|
-
|
|
19
|
+
import { ProsopoCaptchaStateClient, captchaStateReducer } from "@prosopo/procaptcha";
|
|
25
20
|
import { CaptchaContextManager } from "./CaptchaManager";
|
|
26
21
|
import { CaptchaWidget } from "./CaptchaWidget";
|
|
27
|
-
|
|
28
22
|
import { useStyles } from "../styles";
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export function CaptchaComponent({ clientInterface }: { clientInterface: ProsopoCaptchaClient }) {
|
|
32
|
-
|
|
23
|
+
export function CaptchaComponent({ clientInterface }) {
|
|
33
24
|
const classes = useStyles();
|
|
34
|
-
|
|
35
|
-
const manager: ICaptchaContextReducer = useContext(CaptchaContextManager);
|
|
25
|
+
const manager = useContext(CaptchaContextManager);
|
|
36
26
|
const [state, update] = useReducer(captchaStateReducer, { captchaIndex: 0, captchaSolution: [] });
|
|
37
|
-
|
|
38
27
|
const { account, contractAddress } = manager.state;
|
|
39
28
|
const { captchaChallenge, captchaIndex, captchaSolution } = state;
|
|
40
29
|
const totalCaptchas = captchaChallenge?.captchas.length ?? 0;
|
|
41
|
-
|
|
42
30
|
const stateClientInterface = new ProsopoCaptchaStateClient(clientInterface, { state, update });
|
|
43
|
-
|
|
44
31
|
useEffect(() => {
|
|
45
|
-
|
|
46
32
|
clientInterface.onLoad();
|
|
47
|
-
|
|
48
33
|
}, []);
|
|
49
|
-
|
|
50
34
|
useEffect(() => {
|
|
51
35
|
const extension = clientInterface.getExtension();
|
|
52
36
|
if (contractAddress && extension) {
|
|
@@ -57,56 +41,18 @@ export function CaptchaComponent({ clientInterface }: { clientInterface: Prosopo
|
|
|
57
41
|
}
|
|
58
42
|
}
|
|
59
43
|
}, [contractAddress]);
|
|
60
|
-
|
|
61
44
|
useEffect(() => {
|
|
62
45
|
if (account && !captchaChallenge) {
|
|
63
46
|
stateClientInterface.onLoadCaptcha()
|
|
64
47
|
.catch(error => {
|
|
65
|
-
|
|
66
|
-
|
|
48
|
+
clientInterface.status.update({ error });
|
|
49
|
+
});
|
|
67
50
|
}
|
|
68
51
|
}, [account]);
|
|
69
|
-
|
|
70
52
|
// TODO text strings
|
|
71
53
|
// https://www.npmjs.com/package/i18next
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
<Box className={classes.root}>
|
|
75
|
-
|
|
76
|
-
{account && captchaChallenge &&
|
|
77
|
-
<Box className={classes.captchasContainer}>
|
|
78
|
-
|
|
79
|
-
<Box className={classes.captchasHeader}>
|
|
80
|
-
<Typography className={classes.captchasHeaderLabel}>
|
|
81
|
-
Select all images with {captchaChallenge.captchas[captchaIndex].captcha.target}
|
|
82
|
-
</Typography>
|
|
83
|
-
</Box>
|
|
84
|
-
|
|
85
|
-
<Box className={classes.captchasBody}>
|
|
86
|
-
|
|
87
|
-
<CaptchaWidget challenge={captchaChallenge.captchas[captchaIndex]} solution={captchaSolution[captchaIndex] || []}
|
|
88
|
-
onChange={stateClientInterface.onChange.bind(stateClientInterface)} />
|
|
89
|
-
|
|
90
|
-
<Box className={classes.dotsContainer}>
|
|
91
|
-
{captchaChallenge?.captchas.map((_, index) =>
|
|
92
|
-
<Box key={index} className={captchaIndex === index ? classes.dot : classes.dotActive} />)}
|
|
93
|
-
</Box>
|
|
94
|
-
|
|
95
|
-
</Box>
|
|
96
|
-
|
|
97
|
-
<Box className={classes.captchasFooter}>
|
|
98
|
-
<Button onClick={() => stateClientInterface.onCancel()} variant="text">
|
|
99
|
-
Cancel
|
|
100
|
-
</Button>
|
|
101
|
-
<Button onClick={() => stateClientInterface.onSubmit()} variant="contained">
|
|
102
|
-
{captchaIndex + 1 < totalCaptchas ? "Next" : "Submit"}
|
|
103
|
-
</Button>
|
|
104
|
-
</Box>
|
|
105
|
-
|
|
106
|
-
</Box>
|
|
107
|
-
}
|
|
108
|
-
</Box>
|
|
109
|
-
);
|
|
54
|
+
return (_jsx(Box, { className: classes.root, children: account && captchaChallenge &&
|
|
55
|
+
_jsxs(Box, { className: classes.captchasContainer, children: [_jsx(Box, { className: classes.captchasHeader, children: _jsxs(Typography, { className: classes.captchasHeaderLabel, children: ["Select all images with ", captchaChallenge.captchas[captchaIndex].captcha.target] }) }), _jsxs(Box, { className: classes.captchasBody, children: [_jsx(CaptchaWidget, { challenge: captchaChallenge.captchas[captchaIndex], solution: captchaSolution[captchaIndex] || [], onChange: stateClientInterface.onChange.bind(stateClientInterface) }), _jsx(Box, { className: classes.dotsContainer, children: captchaChallenge?.captchas.map((_, index) => _jsx(Box, { className: captchaIndex === index ? classes.dot : classes.dotActive }, index)) })] }), _jsxs(Box, { className: classes.captchasFooter, children: [_jsx(Button, { onClick: () => stateClientInterface.onCancel(), variant: "text", children: "Cancel" }), _jsx(Button, { onClick: () => stateClientInterface.onSubmit(), variant: "contained", children: captchaIndex + 1 < totalCaptchas ? "Next" : "Submit" })] })] }) }));
|
|
110
56
|
}
|
|
111
|
-
|
|
112
57
|
export default CaptchaComponent;
|
|
58
|
+
//# sourceMappingURL=CaptchaComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CaptchaComponent.js","sourceRoot":"","sources":["../../src/components/CaptchaComponent.tsx"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,0FAA0F;AAC1F,EAAE;AACF,2EAA2E;AAC3E,uEAAuE;AACvE,oEAAoE;AACpE,sCAAsC;AACtC,EAAE;AACF,sEAAsE;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1E,KAAC,GAAG,IAAC,SAAS,EAAE,OAAO,CAAC,aAAa,YAChC,gBAAgB,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CACzC,KAAC,GAAG,IAAa,SAAS,EAAE,YAAY,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,IAA1E,KAAK,CAAyE,CAAC,GAC3F,IAEJ,EAEN,MAAC,GAAG,IAAC,SAAS,EAAE,OAAO,CAAC,cAAc,aAClC,KAAC,MAAM,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAC,MAAM,uBAE7D,EACT,KAAC,MAAM,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAC,WAAW,YACtE,YAAY,GAAG,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,GAChD,IACP,IAEJ,GAER,CACT,CAAC;AACN,CAAC;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,iDAWN,CAAC"}
|
|
@@ -13,31 +13,23 @@
|
|
|
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
|
-
|
|
17
16
|
import { createContext, useReducer } from "react";
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
captchaContextReducer,
|
|
21
|
-
captchaStatusReducer,
|
|
22
|
-
ICaptchaContextReducer,
|
|
23
|
-
ProsopoCaptchaClient,
|
|
24
|
-
CaptchaEventCallbacks,
|
|
25
|
-
} from "@prosopo/procaptcha";
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export function useCaptcha(defaultContext: ICaptchaContextState, callbacks?: CaptchaEventCallbacks): ProsopoCaptchaClient {
|
|
17
|
+
import { captchaContextReducer, captchaStatusReducer, ProsopoCaptchaClient, } from "@prosopo/procaptcha";
|
|
18
|
+
export function useCaptcha(defaultContext, callbacks) {
|
|
29
19
|
const [context, updateContext] = useReducer(captchaContextReducer, defaultContext);
|
|
30
20
|
const [status, updateStatus] = useReducer(captchaStatusReducer, {});
|
|
31
21
|
return new ProsopoCaptchaClient({ state: context, update: updateContext }, { state: status, update: updateStatus }, callbacks);
|
|
32
22
|
}
|
|
33
|
-
|
|
34
23
|
export const CaptchaContextManager = createContext({
|
|
35
24
|
state: {
|
|
36
25
|
config: {
|
|
37
26
|
"providerApi.baseURL": "",
|
|
38
27
|
"providerApi.prefix": "",
|
|
39
|
-
"dappAccount": ""
|
|
28
|
+
"dappAccount": "",
|
|
29
|
+
"dappUrl": "",
|
|
30
|
+
"solutionThreshold": 0
|
|
40
31
|
}
|
|
41
|
-
},
|
|
42
|
-
update: () => {},
|
|
43
|
-
}
|
|
32
|
+
},
|
|
33
|
+
update: () => { },
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=CaptchaManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CaptchaManager.js","sourceRoot":"","sources":["../../src/components/CaptchaManager.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,0FAA0F;AAC1F,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;AAE5E,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAClD,OAAO,EAEH,qBAAqB,EACrB,oBAAoB,EAEpB,oBAAoB,GAEvB,MAAM,qBAAqB,CAAC;AAG7B,MAAM,UAAU,UAAU,CAAC,cAAoC,EAAE,SAAiC;IAC9F,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,GAAG,UAAU,CAAC,qBAAqB,EAAE,cAAc,CAAC,CAAC;IACnF,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,UAAU,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;IACpE,OAAO,IAAI,oBAAoB,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,SAAS,CAAC,CAAC;AACnI,CAAC;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC;IAC/C,KAAK,EAAE;QACH,MAAM,EAAE;YACJ,qBAAqB,EAAE,EAAE;YACzB,oBAAoB,EAAE,EAAE;YACxB,aAAa,EAAE,EAAE;YACjB,SAAS,EAAE,EAAE;YACb,mBAAmB,EAAE,CAAC;SACzB;KACJ;IACD,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;CACO,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CaptchaResponseCaptcha } from "@prosopo/procaptcha";
|
|
2
|
+
export declare function CaptchaWidget({ challenge, solution, onChange }: {
|
|
3
|
+
challenge: CaptchaResponseCaptcha;
|
|
4
|
+
solution: number[];
|
|
5
|
+
onChange: (index: number) => void;
|
|
6
|
+
}): JSX.Element;
|
|
7
|
+
export default CaptchaWidget;
|
|
8
|
+
//# sourceMappingURL=CaptchaWidget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CaptchaWidget.d.ts","sourceRoot":"","sources":["../../src/components/CaptchaWidget.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAK7D,wBAAgB,aAAa,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAC3D;IAAC,SAAS,EAAE,sBAAsB,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;CAAC,eAkB3F;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
1
2
|
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
2
3
|
// This file is part of procaptcha-react <https://github.com/prosopo-io/procaptcha-react>.
|
|
3
4
|
//
|
|
@@ -14,30 +15,14 @@
|
|
|
14
15
|
// You should have received a copy of the GNU General Public License
|
|
15
16
|
// along with procaptcha-react. If not, see <http://www.gnu.org/licenses/>.
|
|
16
17
|
import { Avatar } from "@mui/material";
|
|
17
|
-
import { CaptchaResponseCaptcha } from "@prosopo/procaptcha";
|
|
18
|
-
|
|
19
18
|
import { useStyles } from "../styles";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export function CaptchaWidget({ challenge, solution, onChange }:
|
|
23
|
-
{challenge: CaptchaResponseCaptcha, solution: number[], onChange: (index: number) => void}) {
|
|
19
|
+
export function CaptchaWidget({ challenge, solution, onChange }) {
|
|
24
20
|
// TODO challenge.items
|
|
25
21
|
//const items = Array.from(Array(9).keys());
|
|
26
22
|
console.log("CHALLENGE", challenge);
|
|
27
23
|
const items = challenge.captcha.items;
|
|
28
24
|
const classes = useStyles();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
key={index}
|
|
34
|
-
src={item.path} // TODO challenge.items[].path...
|
|
35
|
-
variant="square"
|
|
36
|
-
className={classes.captchaItem + " " + (solution.includes(index) ? " selected" : "")}
|
|
37
|
-
onClick={() => onChange(index)} />
|
|
38
|
-
)}
|
|
39
|
-
</>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default CaptchaWidget;
|
|
25
|
+
return (_jsx(_Fragment, { children: items.map((item, index) => _jsx(Avatar, { src: item.path, variant: "square", className: classes.captchaItem + " " + (solution.includes(index) ? " " + classes.captchaItemSelected : ""), onClick: () => onChange(index) }, index)) }));
|
|
26
|
+
}
|
|
27
|
+
export default CaptchaWidget;
|
|
28
|
+
//# sourceMappingURL=CaptchaWidget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CaptchaWidget.js","sourceRoot":"","sources":["../../src/components/CaptchaWidget.tsx"],"names":[],"mappings":";AAAA,4CAA4C;AAC5C,0FAA0F;AAC1F,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,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,MAAM,UAAU,aAAa,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EACiC;IAC1F,uBAAuB;IACvB,4CAA4C;IAC5C,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC;IACtC,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC;IAE5B,OAAO,CACL,4BACG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAC,MAAM,IAEjC,GAAG,EAAE,IAAI,CAAC,IAAI,EACd,OAAO,EAAC,QAAQ,EAChB,SAAS,EAAE,OAAO,CAAC,WAAW,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAAC,EAC1G,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAJzB,KAAK,CAIwB,CACnC,GACA,CACJ,CAAC;AACJ,CAAC;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TExtensionAccount } from "@prosopo/procaptcha";
|
|
2
|
+
export declare const ExtensionAccountSelect: ({ value, options, onChange }: {
|
|
3
|
+
value?: import("@polkadot/extension-inject/types").InjectedAccountWithMeta | undefined;
|
|
4
|
+
options: TExtensionAccount[];
|
|
5
|
+
onChange: (value: TExtensionAccount | null) => void;
|
|
6
|
+
}) => JSX.Element;
|
|
7
|
+
export default ExtensionAccountSelect;
|
|
8
|
+
//# sourceMappingURL=ExtensionAccountSelect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtensionAccountSelect.d.ts","sourceRoot":"","sources":["../../src/components/ExtensionAccountSelect.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD,eAAO,MAAM,sBAAsB;;aACU,iBAAiB,EAAE;sBAAoB,iBAAiB,GAAG,IAAI,KAAK,IAAI;iBAcpH,CAAA;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Autocomplete, TextField } from "@mui/material";
|
|
3
|
+
export const ExtensionAccountSelect = ({ value, options, onChange }) => {
|
|
4
|
+
return (_jsx(Autocomplete, { disablePortal: true, id: "select-accounts" // TODO
|
|
5
|
+
, options: options, value: value, isOptionEqualToValue: (option, value) => option.address === value.address, onChange: (event, value) => onChange(value), sx: { width: 550 }, getOptionLabel: (option) => `${option.meta.name}\n${option.address}`, renderInput: (props) => _jsx(TextField, { ...props, label: "Select account" }) }));
|
|
6
|
+
};
|
|
7
|
+
export default ExtensionAccountSelect;
|
|
8
|
+
//# sourceMappingURL=ExtensionAccountSelect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtensionAccountSelect.js","sourceRoot":"","sources":["../../src/components/ExtensionAccountSelect.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAIxD,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EACsD,EAAE,EAAE;IACtH,OAAO,CACH,KAAC,YAAY,IACT,aAAa,QACb,EAAE,EAAC,iBAAiB,CAAC,OAAO;UAC5B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,oBAAoB,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,EACzE,QAAQ,EAAE,CAAC,KAAqC,EAAE,KAA+B,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,EACrG,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EAClB,cAAc,EAAE,CAAC,MAAW,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,OAAO,EAAE,EACzE,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAC,SAAS,OAAK,KAAK,EAAE,KAAK,EAAC,gBAAgB,GAAG,GACzE,CACL,CAAC;AACN,CAAC,CAAA;AAED,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAeA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,0FAA0F;AAC1F,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,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,0FAA0F;AAC1F,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,CAAC;AAC7B,cAAc,UAAU,CAAC"}
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"root" | "dot" | "captchasContainer" | "captchasHeader" | "captchasBody" | "captchasFooter" | "captchaItem" | "captchaItemSelected" | "captchasHeaderLabel" | "dotsContainer" | "dotActive">;
|
|
2
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,SAAS,kPAiEpB,CAAC"}
|
package/dist/styles.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Copyright (C) 2021-2022 Prosopo (UK) Ltd.
|
|
2
|
+
// This file is part of procaptcha-react <https://github.com/prosopo-io/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";
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,0FAA0F;AAC1F,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,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,GAAG,GAAG;IACV,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,YAAY,EAAE,GAAG;IACjB,WAAW,EAAE,CAAC;IACd,MAAM,EAAE,mBAAmB;IAC3B,eAAe,EAAE,SAAS;CAC3B,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC;IAClC,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM;QACf,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,QAAQ;QACxB,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;KACf;IACD,iBAA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-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -11,14 +11,14 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@mui/material": "^5.8.3",
|
|
13
13
|
"@mui/styles": "^5.8.3",
|
|
14
|
-
"@prosopo/procaptcha": "0.1.
|
|
14
|
+
"@prosopo/procaptcha": "0.1.4",
|
|
15
15
|
"react": "^17.0.0",
|
|
16
16
|
"react-dom": "^17.0.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@types/react": "^17.0.0",
|
|
20
20
|
"@types/react-dom": "^17.0.0",
|
|
21
|
-
"typescript": "^4.7.
|
|
21
|
+
"typescript": "^4.7.4"
|
|
22
22
|
},
|
|
23
23
|
"author": "",
|
|
24
24
|
"license": "ISC",
|