@prosopo/procaptcha-frictionless 2.0.1 → 2.0.3
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.
|
@@ -11,20 +11,6 @@ const index = require("../../../detector/src/index.cjs");
|
|
|
11
11
|
const util = require("@prosopo/util");
|
|
12
12
|
const Extension = require("./Extension.cjs");
|
|
13
13
|
class ExtensionWeb2 extends Extension.Extension {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(...arguments);
|
|
16
|
-
this.getNetwork = (config) => {
|
|
17
|
-
const network = config.networks[config.defaultNetwork];
|
|
18
|
-
if (!network) {
|
|
19
|
-
throw new common.ProsopoEnvError("DEVELOPER.NETWORK_NOT_FOUND", {
|
|
20
|
-
context: {
|
|
21
|
-
error: `No network found for environment ${config.defaultEnvironment}`
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return network;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
14
|
async getAccount(config) {
|
|
29
15
|
const account = await this.createAccount(config);
|
|
30
16
|
const extension = await this.createExtension(account);
|
|
@@ -78,8 +64,7 @@ class ExtensionWeb2 extends Extension.Extension {
|
|
|
78
64
|
const mnemonic = bip39.entropyToMnemonic(u8Entropy);
|
|
79
65
|
const type = "sr25519";
|
|
80
66
|
const keyring$1 = new keyring.Keyring({
|
|
81
|
-
type
|
|
82
|
-
ss58Format: config.networks[config.defaultNetwork].ss58Format
|
|
67
|
+
type
|
|
83
68
|
});
|
|
84
69
|
const keypair = keyring$1.addFromMnemonic(mnemonic);
|
|
85
70
|
const address = keypair.address;
|
|
@@ -3,7 +3,7 @@ const jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
|
3
3
|
const procaptchaCommon = require("@prosopo/procaptcha-common");
|
|
4
4
|
const webComponents = require("@prosopo/web-components");
|
|
5
5
|
const react = require("react");
|
|
6
|
-
const Manager = require("../
|
|
6
|
+
const Manager = require("../services/Manager.cjs");
|
|
7
7
|
const Procaptcha = (props) => {
|
|
8
8
|
const config = props.config;
|
|
9
9
|
const themeColor = config.theme === "light" ? "light" : "dark";
|
|
@@ -43,17 +43,6 @@ const Manager = (configInput, state, onStateUpdate, callbacks) => {
|
|
|
43
43
|
}
|
|
44
44
|
return types.ProcaptchaConfigSchema.parse(config);
|
|
45
45
|
};
|
|
46
|
-
const getNetwork = (config) => {
|
|
47
|
-
const network = config.networks[config.defaultNetwork];
|
|
48
|
-
if (!network) {
|
|
49
|
-
throw new common.ProsopoEnvError("DEVELOPER.NETWORK_NOT_FOUND", {
|
|
50
|
-
context: {
|
|
51
|
-
error: `No network found for environment ${config.defaultEnvironment}`
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
return network;
|
|
56
|
-
};
|
|
57
46
|
const getAccount = () => {
|
|
58
47
|
if (!state.account) {
|
|
59
48
|
throw new common.ProsopoEnvError("GENERAL.ACCOUNT_NOT_FOUND", {
|
|
@@ -111,7 +100,7 @@ const Manager = (configInput, state, onStateUpdate, callbacks) => {
|
|
|
111
100
|
const getRandomProviderResponse = getRandomActiveProvider();
|
|
112
101
|
const events2 = procaptchaCommon.getDefaultEvents(onStateUpdate, state, callbacks);
|
|
113
102
|
const providerUrl = getRandomProviderResponse.provider.url;
|
|
114
|
-
const providerApi = new api.ProviderApi(
|
|
103
|
+
const providerApi = new api.ProviderApi(providerUrl, getDappAccount());
|
|
115
104
|
const challenge = await providerApi.getPowCaptchaChallenge(userAccount, getDappAccount());
|
|
116
105
|
const solution = util.solvePoW(challenge.challenge, challenge.difficulty);
|
|
117
106
|
const user = await ext.getAccount(getConfig());
|
|
@@ -139,7 +128,6 @@ const Manager = (configInput, state, onStateUpdate, callbacks) => {
|
|
|
139
128
|
[types.ApiParams.user]: getAccount().account.account.address,
|
|
140
129
|
[types.ApiParams.dapp]: getDappAccount(),
|
|
141
130
|
[types.ApiParams.challenge]: challenge.challenge,
|
|
142
|
-
[types.ApiParams.blockNumber]: getRandomProviderResponse.blockNumber,
|
|
143
131
|
[types.ApiParams.nonce]: solution,
|
|
144
132
|
[types.ApiParams.timestamp]: challenge.timestamp,
|
|
145
133
|
[types.ApiParams.signature]: {
|
|
@@ -163,8 +151,7 @@ const Manager = (configInput, state, onStateUpdate, callbacks) => {
|
|
|
163
151
|
url: randomProvderObj.url,
|
|
164
152
|
datasetId: randomProvderObj.datasetId,
|
|
165
153
|
datasetIdContent: randomProvderObj.datasetIdContent
|
|
166
|
-
}
|
|
167
|
-
blockNumber: 0
|
|
154
|
+
}
|
|
168
155
|
};
|
|
169
156
|
};
|
|
170
157
|
return {
|
package/package.json
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
2
|
+
"name": "@prosopo/procaptcha-frictionless",
|
|
3
|
+
"version": "2.0.3",
|
|
4
|
+
"author": "PROSOPO LIMITED <info@prosopo.io>",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=20",
|
|
11
|
+
"npm": ">=9"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/index.js",
|
|
16
|
+
"require": "./dist/cjs/index.cjs"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"source": "./src/index.ts",
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "echo \"No test specified\"",
|
|
23
|
+
"clean": "tsc --build --clean",
|
|
24
|
+
"build": "tsc --build --verbose",
|
|
25
|
+
"build:cjs": "npx vite --config vite.cjs.config.ts build"
|
|
26
|
+
},
|
|
27
|
+
"browserslist": [
|
|
28
|
+
"> 0.5%, last 2 versions, not dead"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@prosopo/detector": "2.0.3",
|
|
32
|
+
"@prosopo/procaptcha-pow": "2.0.3",
|
|
33
|
+
"@prosopo/procaptcha-react": "2.0.3",
|
|
34
|
+
"@prosopo/types": "2.0.3",
|
|
35
|
+
"@prosopo/web-components": "2.0.3",
|
|
36
|
+
"react": "^18.3.1"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@prosopo/config": "2.0.3",
|
|
40
|
+
"tslib": "2.6.2",
|
|
41
|
+
"typescript": "5.1.6"
|
|
42
|
+
},
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/prosopo/captcha.git"
|
|
46
|
+
},
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/prosopo/captcha/issues"
|
|
49
|
+
},
|
|
50
|
+
"homepage": "https://github.com/prosopo/captcha#readme",
|
|
51
|
+
"description": "",
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"registry": "https://registry.npmjs.org"
|
|
54
|
+
}
|
|
55
55
|
}
|