@prosopo/procaptcha-frictionless 0.3.4 → 0.3.36
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.
|
@@ -58,7 +58,7 @@ class ExtensionWeb2 extends Extension.Extension {
|
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
name: "procaptcha-web2",
|
|
61
|
-
version:
|
|
61
|
+
version: util.version,
|
|
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 || ""));
|
|
@@ -88,7 +92,8 @@ const Manager = (configInput, state, onStateUpdate, callbacks) => {
|
|
|
88
92
|
}
|
|
89
93
|
resetState();
|
|
90
94
|
const config = getConfig();
|
|
91
|
-
const
|
|
95
|
+
const ext = new ExtensionWeb2.ExtensionWeb2();
|
|
96
|
+
const userAccount = config.userAccountAddress || (await ext.getAccount(config)).account.address;
|
|
92
97
|
updateState({
|
|
93
98
|
loading: true,
|
|
94
99
|
account: { account: { address: userAccount } }
|
|
@@ -100,14 +105,12 @@ const Manager = (configInput, state, onStateUpdate, callbacks) => {
|
|
|
100
105
|
context: { error: "Account address has not been set for web3 mode" }
|
|
101
106
|
});
|
|
102
107
|
}
|
|
103
|
-
const ext = new ExtensionWeb2.ExtensionWeb2();
|
|
104
|
-
const account = await ext.getAccount(config);
|
|
105
108
|
const contract$1 = await loadContract();
|
|
106
109
|
const events = procaptchaCommon.getDefaultEvents(onStateUpdate, state, callbacks);
|
|
107
|
-
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());
|
|
108
111
|
const providerUrl = common.trimProviderUrl(getRandomProviderResponse.provider.url.toString());
|
|
109
112
|
const providerApi = new api.ProviderApi(getNetwork(getConfig()), providerUrl, getDappAccount());
|
|
110
|
-
const challenge = await providerApi.getPowCaptchaChallenge(
|
|
113
|
+
const challenge = await providerApi.getPowCaptchaChallenge(userAccount, getDappAccount());
|
|
111
114
|
const solution = SolverService.solvePoW(challenge.challenge, challenge.difficulty);
|
|
112
115
|
const verifiedSolution = await providerApi.submitPowCaptchaSolution(challenge, getAccount().account.address, getDappAccount(), getRandomProviderResponse, solution);
|
|
113
116
|
if (verifiedSolution[types.ApiParams.verified]) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/procaptcha-frictionless",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.36",
|
|
4
4
|
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"source": "./src/index.ts",
|
|
21
21
|
"scripts": {
|
|
22
|
+
"test": "echo \"No test specified\"",
|
|
22
23
|
"clean": "tsc --build --clean",
|
|
23
24
|
"build": "tsc --build --verbose tsconfig.json",
|
|
24
25
|
"build:cjs": "npx vite --config vite.cjs.config.ts build",
|
|
@@ -34,9 +35,9 @@
|
|
|
34
35
|
],
|
|
35
36
|
"dependencies": {
|
|
36
37
|
"@fingerprintjs/botd": "^1.9.0",
|
|
37
|
-
"@prosopo/procaptcha-pow": "0.3.
|
|
38
|
-
"@prosopo/procaptcha-react": "0.3.
|
|
39
|
-
"@prosopo/web-components": "0.3.
|
|
38
|
+
"@prosopo/procaptcha-pow": "0.3.36",
|
|
39
|
+
"@prosopo/procaptcha-react": "0.3.36",
|
|
40
|
+
"@prosopo/web-components": "0.3.36",
|
|
40
41
|
"react": "^18.2.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|