@prosopo/procaptcha 1.0.2 → 2.0.1
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 +21 -28
- package/dist/cjs/account/dist/extension/ExtensionWeb3.cjs +5 -3
- package/dist/cjs/detector/src/index.cjs +4586 -0
- package/dist/cjs/modules/Manager.cjs +83 -168
- package/dist/cjs/modules/ProsopoCaptchaApi.cjs +34 -49
- package/dist/cjs/modules/collector.cjs +32 -8
- package/dist/cjs/modules/storage.cjs +8 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/modules/Manager.d.ts +1 -2
- package/dist/modules/Manager.d.ts.map +1 -1
- package/dist/modules/Manager.js +92 -168
- package/dist/modules/Manager.js.map +1 -1
- package/dist/modules/ProsopoCaptchaApi.d.ts +7 -10
- package/dist/modules/ProsopoCaptchaApi.d.ts.map +1 -1
- package/dist/modules/ProsopoCaptchaApi.js +28 -48
- package/dist/modules/ProsopoCaptchaApi.js.map +1 -1
- package/dist/modules/collector.d.ts +1 -1
- package/dist/modules/collector.d.ts.map +1 -1
- package/dist/modules/collector.js +8 -8
- package/dist/modules/collector.js.map +1 -1
- package/dist/modules/index.d.ts +3 -3
- package/dist/modules/index.d.ts.map +1 -1
- package/dist/modules/index.js +3 -3
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/storage.d.ts +1 -1
- package/dist/modules/storage.d.ts.map +1 -1
- package/dist/modules/storage.js +5 -5
- package/dist/modules/storage.js.map +1 -1
- package/dist/tests/modules/storage.test.js +15 -11
- package/dist/tests/modules/storage.test.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js.map +1 -1
- package/package.json +77 -85
- package/vite.cjs.config.ts +3 -3
- package/vite.test.config.ts +15 -15
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const Api = require("@polkadot/api/promise/Api");
|
|
4
|
-
const Extension = require("./Extension.cjs");
|
|
5
|
-
const keyring = require("@polkadot/keyring");
|
|
6
|
-
const common = require("@prosopo/common");
|
|
7
3
|
const Signer = require("@polkadot/extension-base/page/Signer");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
4
|
+
const keyring = require("@polkadot/keyring");
|
|
5
|
+
const utilCrypto = require("@polkadot/util-crypto");
|
|
10
6
|
const bip39 = require("@polkadot/util-crypto/mnemonic/bip39");
|
|
11
|
-
const fingerprintjs = require("@fingerprintjs/fingerprintjs");
|
|
12
|
-
const util = require("@prosopo/util");
|
|
13
7
|
const string = require("@polkadot/util/string");
|
|
14
8
|
const u8a = require("@polkadot/util/u8a");
|
|
9
|
+
const common = require("@prosopo/common");
|
|
10
|
+
const index = require("../../../detector/src/index.cjs");
|
|
11
|
+
const util = require("@prosopo/util");
|
|
12
|
+
const Extension = require("./Extension.cjs");
|
|
15
13
|
class ExtensionWeb2 extends Extension.Extension {
|
|
16
14
|
constructor() {
|
|
17
15
|
super(...arguments);
|
|
@@ -19,16 +17,16 @@ class ExtensionWeb2 extends Extension.Extension {
|
|
|
19
17
|
const network = config.networks[config.defaultNetwork];
|
|
20
18
|
if (!network) {
|
|
21
19
|
throw new common.ProsopoEnvError("DEVELOPER.NETWORK_NOT_FOUND", {
|
|
22
|
-
context: {
|
|
20
|
+
context: {
|
|
21
|
+
error: `No network found for environment ${config.defaultEnvironment}`
|
|
22
|
+
}
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
return network;
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
async getAccount(config) {
|
|
29
|
-
const
|
|
30
|
-
const wsProvider = new ws.WsProvider(network.endpoint);
|
|
31
|
-
const account = await this.createAccount(wsProvider);
|
|
29
|
+
const account = await this.createAccount(config);
|
|
32
30
|
const extension = await this.createExtension(account);
|
|
33
31
|
return {
|
|
34
32
|
account,
|
|
@@ -62,7 +60,8 @@ class ExtensionWeb2 extends Extension.Extension {
|
|
|
62
60
|
signer
|
|
63
61
|
};
|
|
64
62
|
}
|
|
65
|
-
async createAccount(
|
|
63
|
+
async createAccount(config) {
|
|
64
|
+
await utilCrypto.cryptoWaitReady();
|
|
66
65
|
const params = {
|
|
67
66
|
area: { width: 300, height: 300 },
|
|
68
67
|
offsetParameter: 2001000001,
|
|
@@ -72,29 +71,23 @@ class ExtensionWeb2 extends Extension.Extension {
|
|
|
72
71
|
numberOfRounds: 5,
|
|
73
72
|
seed: 42
|
|
74
73
|
};
|
|
75
|
-
const browserEntropy = await
|
|
74
|
+
const browserEntropy = await index.getFingerprint();
|
|
76
75
|
const canvasEntropy = util.picassoCanvas(params.numberOfRounds, params.seed, params);
|
|
77
76
|
const entropy = common.hexHash([canvasEntropy, browserEntropy].join(""), 128).slice(2);
|
|
78
77
|
const u8Entropy = string.stringToU8a(entropy);
|
|
79
78
|
const mnemonic = bip39.entropyToMnemonic(u8Entropy);
|
|
80
|
-
const
|
|
81
|
-
const
|
|
82
|
-
|
|
79
|
+
const type = "sr25519";
|
|
80
|
+
const keyring$1 = new keyring.Keyring({
|
|
81
|
+
type,
|
|
82
|
+
ss58Format: config.networks[config.defaultNetwork].ss58Format
|
|
83
|
+
});
|
|
83
84
|
const keypair = keyring$1.addFromMnemonic(mnemonic);
|
|
84
|
-
const address
|
|
85
|
+
const address = keypair.address;
|
|
85
86
|
return {
|
|
86
|
-
address
|
|
87
|
-
|
|
88
|
-
name: address$1,
|
|
87
|
+
address,
|
|
88
|
+
name: address,
|
|
89
89
|
keypair
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
async getFingerprint() {
|
|
93
|
-
const fpPromise = fingerprintjs.load();
|
|
94
|
-
const fp = await fpPromise;
|
|
95
|
-
const result = await fp.get();
|
|
96
|
-
const { screenFrame, ...componentsReduced } = result.components;
|
|
97
|
-
return fingerprintjs.hashComponents(componentsReduced);
|
|
98
|
-
}
|
|
99
92
|
}
|
|
100
93
|
exports.ExtensionWeb2 = ExtensionWeb2;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const Extension = require("./Extension.cjs");
|
|
4
|
-
const common = require("@prosopo/common");
|
|
5
3
|
const extensionDapp = require("@polkadot/extension-dapp");
|
|
4
|
+
const common = require("@prosopo/common");
|
|
5
|
+
const Extension = require("./Extension.cjs");
|
|
6
6
|
class ExtensionWeb3 extends Extension.Extension {
|
|
7
7
|
async getAccount(config) {
|
|
8
8
|
const { dappName, userAccountAddress: address } = config;
|
|
9
9
|
if (!address) {
|
|
10
|
-
throw new common.ProsopoError("WIDGET.NO_ACCOUNTS_FOUND", {
|
|
10
|
+
throw new common.ProsopoError("WIDGET.NO_ACCOUNTS_FOUND", {
|
|
11
|
+
context: { error: "No account address provided" }
|
|
12
|
+
});
|
|
11
13
|
}
|
|
12
14
|
const extensions = await extensionDapp.web3Enable(dappName);
|
|
13
15
|
if (extensions.length === 0) {
|