@prosopo/procaptcha-frictionless 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/account/dist/extension/ExtensionWeb2.cjs +2 -2
- package/dist/cjs/procaptcha-pow/dist/Services/Manager.cjs +21 -10
- package/dist/cjs/procaptcha-pow/dist/components/Captcha.cjs +3 -3
- package/dist/cjs/web-components/dist/CaptchaPlaceholder.cjs +3 -3
- package/dist/cjs/web-components/dist/WidgetConstants.cjs +6 -0
- package/dist/cjs/web-components/dist/index.cjs +3 -0
- package/package.json +4 -4
|
@@ -58,7 +58,7 @@ class ExtensionWeb2 extends Extension.Extension {
|
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
name: "procaptcha-web2",
|
|
61
|
-
version: "0.
|
|
61
|
+
version: "0.3.x",
|
|
62
62
|
signer
|
|
63
63
|
};
|
|
64
64
|
}
|
|
@@ -77,7 +77,7 @@ class ExtensionWeb2 extends Extension.Extension {
|
|
|
77
77
|
const entropy = common.hexHash([canvasEntropy, browserEntropy].join(""), 128).slice(2);
|
|
78
78
|
const u8Entropy = string.stringToU8a(entropy);
|
|
79
79
|
const mnemonic = bip39.entropyToMnemonic(u8Entropy);
|
|
80
|
-
const api = await Api.ApiPromise.create({ provider: wsProvider, initWasm: false });
|
|
80
|
+
const api = await Api.ApiPromise.create({ provider: wsProvider, initWasm: false, noInitWarn: true });
|
|
81
81
|
const type = "ed25519";
|
|
82
82
|
const keyring$1 = new keyring.Keyring({ type, ss58Format: api.registry.chainSS58 });
|
|
83
83
|
const keypair = keyring$1.addFromMnemonic(mnemonic);
|
|
@@ -48,7 +48,11 @@ const Manager = (configInput, state, onStateUpdate, callbacks) => {
|
|
|
48
48
|
};
|
|
49
49
|
const loadContract = async () => {
|
|
50
50
|
const network = getNetwork(getConfig());
|
|
51
|
-
const api2 = await Api.ApiPromise.create({
|
|
51
|
+
const api2 = await Api.ApiPromise.create({
|
|
52
|
+
provider: new ws.WsProvider(network.endpoint),
|
|
53
|
+
initWasm: false,
|
|
54
|
+
noInitWarn: true
|
|
55
|
+
});
|
|
52
56
|
const type = "sr25519";
|
|
53
57
|
const keyring$1 = new keyring.Keyring({ type, ss58Format: api2.registry.chainSS58 });
|
|
54
58
|
return new contract.ProsopoCaptchaContract(api2, JSON.parse(contractInfo.ContractAbi), network.contract.address, "prosopo", 0, keyring$1.addFromAddress(getConfig().account.address || ""));
|
|
@@ -87,8 +91,13 @@ const Manager = (configInput, state, onStateUpdate, callbacks) => {
|
|
|
87
91
|
return;
|
|
88
92
|
}
|
|
89
93
|
resetState();
|
|
90
|
-
updateState({ loading: true });
|
|
91
94
|
const config = getConfig();
|
|
95
|
+
const ext = new ExtensionWeb2.ExtensionWeb2();
|
|
96
|
+
const userAccount = config.userAccountAddress || (await ext.getAccount(config)).account.address;
|
|
97
|
+
updateState({
|
|
98
|
+
loading: true,
|
|
99
|
+
account: { account: { address: userAccount } }
|
|
100
|
+
});
|
|
92
101
|
updateState({ dappAccount: config.account.address });
|
|
93
102
|
await procaptcha.sleep(100);
|
|
94
103
|
if (!config.web2 && !config.userAccountAddress) {
|
|
@@ -96,23 +105,25 @@ const Manager = (configInput, state, onStateUpdate, callbacks) => {
|
|
|
96
105
|
context: { error: "Account address has not been set for web3 mode" }
|
|
97
106
|
});
|
|
98
107
|
}
|
|
99
|
-
const ext = new ExtensionWeb2.ExtensionWeb2();
|
|
100
|
-
const account = await ext.getAccount(config);
|
|
101
108
|
const contract$1 = await loadContract();
|
|
102
109
|
const events = procaptchaCommon.getDefaultEvents(onStateUpdate, state, callbacks);
|
|
103
|
-
const getRandomProviderResponse = await contract.wrapQuery(contract$1.query.getRandomActiveProvider, contract$1.query)(
|
|
110
|
+
const getRandomProviderResponse = await contract.wrapQuery(contract$1.query.getRandomActiveProvider, contract$1.query)(userAccount, getDappAccount());
|
|
104
111
|
const providerUrl = common.trimProviderUrl(getRandomProviderResponse.provider.url.toString());
|
|
105
112
|
const providerApi = new api.ProviderApi(getNetwork(getConfig()), providerUrl, getDappAccount());
|
|
106
|
-
const challenge = await providerApi.getPowCaptchaChallenge(
|
|
113
|
+
const challenge = await providerApi.getPowCaptchaChallenge(userAccount, getDappAccount());
|
|
107
114
|
const solution = SolverService.solvePoW(challenge.challenge, challenge.difficulty);
|
|
108
|
-
await providerApi.submitPowCaptchaSolution(challenge, getAccount().account.address, getDappAccount(), getRandomProviderResponse, solution);
|
|
109
|
-
if (
|
|
115
|
+
const verifiedSolution = await providerApi.submitPowCaptchaSolution(challenge, getAccount().account.address, getDappAccount(), getRandomProviderResponse, solution);
|
|
116
|
+
if (verifiedSolution[types.ApiParams.verified]) {
|
|
117
|
+
updateState({
|
|
118
|
+
isHuman: true,
|
|
119
|
+
loading: false
|
|
120
|
+
});
|
|
110
121
|
events.onHuman({
|
|
111
122
|
providerUrl,
|
|
112
123
|
[types.ApiParams.user]: getAccount().account.address,
|
|
113
124
|
[types.ApiParams.dapp]: getDappAccount(),
|
|
114
|
-
[types.ApiParams.
|
|
115
|
-
[types.ApiParams.blockNumber]:
|
|
125
|
+
[types.ApiParams.challenge]: challenge.challenge,
|
|
126
|
+
[types.ApiParams.blockNumber]: getRandomProviderResponse.blockNumber
|
|
116
127
|
});
|
|
117
128
|
}
|
|
118
129
|
};
|
|
@@ -19,11 +19,11 @@ const Procaptcha = (props) => {
|
|
|
19
19
|
const updateState = procaptchaCommon.buildUpdateState(state, _updateState);
|
|
20
20
|
const manager = Manager.Manager(config, state, updateState, callbacks);
|
|
21
21
|
return jsxRuntime.jsx("div", { children: jsxRuntime.jsx("div", { style: { maxWidth: "100%", maxHeight: "100%", overflowX: "auto" }, children: jsxRuntime.jsx(Containers.ContainerDiv, { children: jsxRuntime.jsx(Containers.WidthBasedStylesDiv, { children: jsxRuntime.jsxs("div", { style: WidgetConstants.WIDGET_DIMENSIONS, "data-cy": "button-human", children: [" ", jsxRuntime.jsxs("div", { style: {
|
|
22
|
-
padding:
|
|
23
|
-
border:
|
|
22
|
+
padding: WidgetConstants.WIDGET_PADDING,
|
|
23
|
+
border: WidgetConstants.WIDGET_BORDER,
|
|
24
24
|
backgroundColor: theme$1.palette.background.default,
|
|
25
25
|
borderColor: theme$1.palette.grey[300],
|
|
26
|
-
borderRadius:
|
|
26
|
+
borderRadius: WidgetConstants.WIDGET_BORDER_RADIUS,
|
|
27
27
|
display: "flex",
|
|
28
28
|
alignItems: "center",
|
|
29
29
|
flexWrap: "wrap",
|
|
@@ -10,11 +10,11 @@ const ProcaptchaPlaceholder = (props) => {
|
|
|
10
10
|
const themeColor = props.darkMode === "light" ? "light" : "dark";
|
|
11
11
|
const theme$1 = props.darkMode === "light" ? theme.lightTheme : theme.darkTheme;
|
|
12
12
|
return jsxRuntime.jsx("div", { children: jsxRuntime.jsx("div", { style: { maxWidth: "100%", maxHeight: "100%", overflowX: "auto" }, children: jsxRuntime.jsx(Containers.ContainerDiv, { children: jsxRuntime.jsx(Containers.WidthBasedStylesDiv, { children: jsxRuntime.jsxs("div", { style: WidgetConstants.WIDGET_DIMENSIONS, "data-cy": "button-human", children: [" ", jsxRuntime.jsxs("div", { style: {
|
|
13
|
-
padding:
|
|
14
|
-
border:
|
|
13
|
+
padding: WidgetConstants.WIDGET_PADDING,
|
|
14
|
+
border: WidgetConstants.WIDGET_BORDER,
|
|
15
15
|
backgroundColor: theme$1.palette.background.default,
|
|
16
16
|
borderColor: theme$1.palette.grey[300],
|
|
17
|
-
borderRadius:
|
|
17
|
+
borderRadius: WidgetConstants.WIDGET_BORDER_RADIUS,
|
|
18
18
|
display: "flex",
|
|
19
19
|
alignItems: "center",
|
|
20
20
|
flexWrap: "wrap",
|
|
@@ -5,8 +5,14 @@ const WIDGET_URL_TEXT = "Visit prosopo.io to learn more about the service and it
|
|
|
5
5
|
const WIDGET_INNER_HEIGHT = 74;
|
|
6
6
|
const WIDGET_OUTER_HEIGHT = 80;
|
|
7
7
|
const WIDGET_DIMENSIONS = { maxWidth: "400px", minWidth: "200px", minHeight: `${WIDGET_OUTER_HEIGHT}px` };
|
|
8
|
+
const WIDGET_BORDER_RADIUS = "8px";
|
|
9
|
+
const WIDGET_PADDING = "2px";
|
|
10
|
+
const WIDGET_BORDER = "1px solid";
|
|
11
|
+
exports.WIDGET_BORDER = WIDGET_BORDER;
|
|
12
|
+
exports.WIDGET_BORDER_RADIUS = WIDGET_BORDER_RADIUS;
|
|
8
13
|
exports.WIDGET_DIMENSIONS = WIDGET_DIMENSIONS;
|
|
9
14
|
exports.WIDGET_INNER_HEIGHT = WIDGET_INNER_HEIGHT;
|
|
10
15
|
exports.WIDGET_OUTER_HEIGHT = WIDGET_OUTER_HEIGHT;
|
|
16
|
+
exports.WIDGET_PADDING = WIDGET_PADDING;
|
|
11
17
|
exports.WIDGET_URL = WIDGET_URL;
|
|
12
18
|
exports.WIDGET_URL_TEXT = WIDGET_URL_TEXT;
|
|
@@ -15,8 +15,11 @@ exports.Checkbox = Checkbox.Checkbox;
|
|
|
15
15
|
exports.Logo = Logo;
|
|
16
16
|
exports.ContainerDiv = Containers.ContainerDiv;
|
|
17
17
|
exports.WidthBasedStylesDiv = Containers.WidthBasedStylesDiv;
|
|
18
|
+
exports.WIDGET_BORDER = WidgetConstants.WIDGET_BORDER;
|
|
19
|
+
exports.WIDGET_BORDER_RADIUS = WidgetConstants.WIDGET_BORDER_RADIUS;
|
|
18
20
|
exports.WIDGET_DIMENSIONS = WidgetConstants.WIDGET_DIMENSIONS;
|
|
19
21
|
exports.WIDGET_INNER_HEIGHT = WidgetConstants.WIDGET_INNER_HEIGHT;
|
|
20
22
|
exports.WIDGET_OUTER_HEIGHT = WidgetConstants.WIDGET_OUTER_HEIGHT;
|
|
23
|
+
exports.WIDGET_PADDING = WidgetConstants.WIDGET_PADDING;
|
|
21
24
|
exports.WIDGET_URL = WidgetConstants.WIDGET_URL;
|
|
22
25
|
exports.WIDGET_URL_TEXT = WidgetConstants.WIDGET_URL_TEXT;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/procaptcha-frictionless",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@fingerprintjs/botd": "^1.9.0",
|
|
37
|
-
"@prosopo/procaptcha-pow": "0.3.
|
|
38
|
-
"@prosopo/procaptcha-react": "0.3.
|
|
39
|
-
"@prosopo/web-components": "0.3.
|
|
37
|
+
"@prosopo/procaptcha-pow": "0.3.5",
|
|
38
|
+
"@prosopo/procaptcha-react": "0.3.5",
|
|
39
|
+
"@prosopo/web-components": "0.3.5",
|
|
40
40
|
"react": "^18.2.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|