@prosopo/account 2.5.5 → 2.6.2
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/CHANGELOG.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# @prosopo/account
|
|
2
|
+
|
|
3
|
+
## 2.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [6ff193a]
|
|
8
|
+
- @prosopo/types@2.6.2
|
|
9
|
+
|
|
10
|
+
## 2.6.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [52feffc]
|
|
15
|
+
- @prosopo/types@2.6.1
|
|
16
|
+
|
|
17
|
+
## 2.6.0
|
|
18
|
+
|
|
19
|
+
### Minor Changes
|
|
20
|
+
|
|
21
|
+
- a0bfc8a: bump all pkg versions since independent versioning applied
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [a0bfc8a]
|
|
26
|
+
- @prosopo/common@2.6.0
|
|
27
|
+
- @prosopo/fingerprint@2.6.0
|
|
28
|
+
- @prosopo/types@2.6.0
|
|
29
|
+
- @prosopo/util@2.6.0
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
25
|
+
const utilCrypto = require("@polkadot/util-crypto");
|
|
26
|
+
const string = require("@polkadot/util/string");
|
|
27
|
+
const u8a = require("@polkadot/util/u8a");
|
|
28
|
+
const common = require("@prosopo/common");
|
|
29
|
+
const fingerprint = require("@prosopo/fingerprint");
|
|
30
|
+
const util = require("@prosopo/util");
|
|
31
|
+
const Extension = require("./Extension.cjs");
|
|
32
|
+
const SignerLoader = async () => (await import("@polkadot/extension-base/page/Signer")).default;
|
|
33
|
+
const KeyringLoader = async () => (await import("@polkadot/keyring")).Keyring;
|
|
34
|
+
const EntropyToMnemonicLoader = async () => (await import("@polkadot/util-crypto/mnemonic/bip39")).entropyToMnemonic;
|
|
35
|
+
class ExtensionWeb2 extends Extension.Extension {
|
|
36
|
+
async getAccount(config) {
|
|
37
|
+
const account = await this.createAccount(config);
|
|
38
|
+
const extension = await this.createExtension(account);
|
|
39
|
+
return {
|
|
40
|
+
account,
|
|
41
|
+
extension
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async createExtension(account) {
|
|
45
|
+
const Signer = await SignerLoader();
|
|
46
|
+
const signer = new Signer(async () => {
|
|
47
|
+
return;
|
|
48
|
+
});
|
|
49
|
+
signer.signRaw = async (payload) => {
|
|
50
|
+
const signature = account.keypair.sign(payload.data);
|
|
51
|
+
return {
|
|
52
|
+
id: 1,
|
|
53
|
+
// the id of the request to sign. This should be incremented each time and adjust the signature, but we're hacking around this. Hence the signature will always be the same given the same payload.
|
|
54
|
+
signature: u8a.u8aToHex(signature)
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
return {
|
|
58
|
+
accounts: {
|
|
59
|
+
get: async () => {
|
|
60
|
+
return [account];
|
|
61
|
+
},
|
|
62
|
+
subscribe: () => {
|
|
63
|
+
return () => {
|
|
64
|
+
return;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
name: "procaptcha-web2",
|
|
69
|
+
version: util.version,
|
|
70
|
+
signer
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
async createAccount(config) {
|
|
74
|
+
await utilCrypto.cryptoWaitReady();
|
|
75
|
+
const Keyring = await KeyringLoader();
|
|
76
|
+
const browserEntropy = await fingerprint.getFingerprint();
|
|
77
|
+
const entropy = common.hexHash(browserEntropy, 128).slice(2);
|
|
78
|
+
const u8Entropy = string.stringToU8a(entropy);
|
|
79
|
+
const entropyToMnemonic = await EntropyToMnemonicLoader();
|
|
80
|
+
const mnemonic = entropyToMnemonic(u8Entropy);
|
|
81
|
+
const type = "sr25519";
|
|
82
|
+
const keyring = new Keyring({
|
|
83
|
+
type
|
|
84
|
+
});
|
|
85
|
+
const keypair = keyring.addFromMnemonic(mnemonic);
|
|
86
|
+
const address = keypair.address;
|
|
87
|
+
return {
|
|
88
|
+
address,
|
|
89
|
+
name: address,
|
|
90
|
+
keypair
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.ExtensionWeb2 = ExtensionWeb2;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
25
|
+
const common = require("@prosopo/common");
|
|
26
|
+
const Extension = require("./Extension.cjs");
|
|
27
|
+
const web3Loader = async () => (await import("@polkadot/extension-dapp")).web3Enable;
|
|
28
|
+
class ExtensionWeb3 extends Extension.Extension {
|
|
29
|
+
async getAccount(config) {
|
|
30
|
+
const { dappName, userAccountAddress: address } = config;
|
|
31
|
+
if (!address) {
|
|
32
|
+
throw new common.ProsopoError("WIDGET.NO_ACCOUNTS_FOUND", {
|
|
33
|
+
context: { error: "No account address provided" }
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const web3Enable = await web3Loader();
|
|
37
|
+
const extensions = await web3Enable(dappName);
|
|
38
|
+
if (extensions.length === 0) {
|
|
39
|
+
throw new common.ProsopoError("WIDGET.NO_EXTENSION_FOUND");
|
|
40
|
+
}
|
|
41
|
+
for (const extension of extensions) {
|
|
42
|
+
const accounts = await extension.accounts.get();
|
|
43
|
+
const account = accounts.find((account2) => account2.address === address);
|
|
44
|
+
if (account) {
|
|
45
|
+
return { account, extension };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
throw new common.ProsopoError("WIDGET.ACCOUNT_NOT_FOUND", {
|
|
49
|
+
context: { error: `No account found matching ${address}` }
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.ExtensionWeb3 = ExtensionWeb3;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const Extension = require("./extension/Extension.cjs");
|
|
4
|
+
const ExtensionWeb2 = require("./extension/ExtensionWeb2.cjs");
|
|
5
|
+
const ExtensionWeb3 = require("./extension/ExtensionWeb3.cjs");
|
|
6
|
+
exports.Extension = Extension.Extension;
|
|
7
|
+
exports.ExtensionWeb2 = ExtensionWeb2.ExtensionWeb2;
|
|
8
|
+
exports.ExtensionWeb3 = ExtensionWeb3.ExtensionWeb3;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/account",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.2",
|
|
4
4
|
"description": "Services and Utils for Prosopo account gen and management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
|
-
"url": "git+
|
|
25
|
+
"url": "git+https://github.com/prosopo/captcha.git",
|
|
26
|
+
"directory": "packages/account"
|
|
26
27
|
},
|
|
27
28
|
"author": "Prosopo Limited",
|
|
28
29
|
"license": "Apache-2.0",
|
|
@@ -37,15 +38,15 @@
|
|
|
37
38
|
"@polkadot/keyring": "12.6.2",
|
|
38
39
|
"@polkadot/util": "12.6.2",
|
|
39
40
|
"@polkadot/util-crypto": "12.6.2",
|
|
40
|
-
"@prosopo/common": "2.
|
|
41
|
-
"@prosopo/fingerprint": "2.
|
|
42
|
-
"@prosopo/types": "2.
|
|
43
|
-
"@prosopo/util": "2.
|
|
41
|
+
"@prosopo/common": "2.6.0",
|
|
42
|
+
"@prosopo/fingerprint": "2.6.0",
|
|
43
|
+
"@prosopo/types": "2.6.2",
|
|
44
|
+
"@prosopo/util": "2.6.0",
|
|
44
45
|
"express": "4.21.2",
|
|
45
46
|
"react": "18.3.1"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
|
-
"@prosopo/config": "2.
|
|
49
|
+
"@prosopo/config": "2.6.0",
|
|
49
50
|
"@vitest/coverage-v8": "3.0.9",
|
|
50
51
|
"concurrently": "9.0.1",
|
|
51
52
|
"del-cli": "6.0.0",
|