@prosopo/account 2.1.7 → 2.1.9
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/extension/Extension.d.ts +5 -0
- package/dist/extension/Extension.d.ts.map +1 -0
- package/dist/extension/Extension.js +3 -0
- package/dist/extension/Extension.js.map +1 -0
- package/dist/extension/ExtensionWeb2.d.ts +8 -0
- package/dist/extension/ExtensionWeb2.d.ts.map +1 -0
- package/dist/extension/ExtensionWeb2.js +77 -0
- package/dist/extension/ExtensionWeb2.js.map +1 -0
- package/dist/extension/ExtensionWeb3.d.ts +6 -0
- package/dist/extension/ExtensionWeb3.d.ts.map +1 -0
- package/dist/extension/ExtensionWeb3.js +28 -0
- package/dist/extension/ExtensionWeb3.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/package.json +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Extension.d.ts","sourceRoot":"","sources":["../../src/extension/Extension.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAK5E,8BAAsB,SAAS;aAOd,UAAU,CACzB,MAAM,EAAE,4BAA4B,GAClC,OAAO,CAAC,OAAO,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Extension.js","sourceRoot":"","sources":["../../src/extension/Extension.ts"],"names":[],"mappings":"AAkBA,MAAM,OAAgB,SAAS;CAU9B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Account, ProcaptchaClientConfigOutput } from "@prosopo/types";
|
|
2
|
+
import { Extension } from "./Extension.js";
|
|
3
|
+
export declare class ExtensionWeb2 extends Extension {
|
|
4
|
+
getAccount(config: ProcaptchaClientConfigOutput): Promise<Account>;
|
|
5
|
+
private createExtension;
|
|
6
|
+
private createAccount;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=ExtensionWeb2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtensionWeb2.d.ts","sourceRoot":"","sources":["../../src/extension/ExtensionWeb2.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAG5E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAO3C,qBAAa,aAAc,SAAQ,SAAS;IAC9B,UAAU,CACtB,MAAM,EAAE,4BAA4B,GAClC,OAAO,CAAC,OAAO,CAAC;YAUL,eAAe;YAmCf,aAAa;CAsC3B"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { default as Signer } from "@polkadot/extension-base/page/Signer";
|
|
2
|
+
import { Keyring } from "@polkadot/keyring";
|
|
3
|
+
import { cryptoWaitReady } from "@polkadot/util-crypto";
|
|
4
|
+
import { entropyToMnemonic } from "@polkadot/util-crypto/mnemonic/bip39";
|
|
5
|
+
import { stringToU8a } from "@polkadot/util/string";
|
|
6
|
+
import { u8aToHex } from "@polkadot/util/u8a";
|
|
7
|
+
import { hexHash } from "@prosopo/common";
|
|
8
|
+
import { getFingerprint } from "@prosopo/fingerprint";
|
|
9
|
+
import { picassoCanvas } from "@prosopo/util";
|
|
10
|
+
import { version } from "@prosopo/util";
|
|
11
|
+
import { Extension } from "./Extension.js";
|
|
12
|
+
export class ExtensionWeb2 extends Extension {
|
|
13
|
+
async getAccount(config) {
|
|
14
|
+
const account = await this.createAccount(config);
|
|
15
|
+
const extension = await this.createExtension(account);
|
|
16
|
+
return {
|
|
17
|
+
account,
|
|
18
|
+
extension,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
async createExtension(account) {
|
|
22
|
+
const signer = new Signer(async () => {
|
|
23
|
+
return;
|
|
24
|
+
});
|
|
25
|
+
signer.signRaw = async (payload) => {
|
|
26
|
+
const signature = account.keypair.sign(payload.data);
|
|
27
|
+
return {
|
|
28
|
+
id: 1,
|
|
29
|
+
signature: u8aToHex(signature),
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
accounts: {
|
|
34
|
+
get: async () => {
|
|
35
|
+
return [account];
|
|
36
|
+
},
|
|
37
|
+
subscribe: () => {
|
|
38
|
+
return () => {
|
|
39
|
+
return;
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
name: "procaptcha-web2",
|
|
44
|
+
version,
|
|
45
|
+
signer,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
async createAccount(config) {
|
|
49
|
+
await cryptoWaitReady();
|
|
50
|
+
const params = {
|
|
51
|
+
area: { width: 300, height: 300 },
|
|
52
|
+
offsetParameter: 2001000001,
|
|
53
|
+
multiplier: 15000,
|
|
54
|
+
fontSizeFactor: 1.5,
|
|
55
|
+
maxShadowBlur: 50,
|
|
56
|
+
numberOfRounds: 5,
|
|
57
|
+
seed: 42,
|
|
58
|
+
};
|
|
59
|
+
const browserEntropy = await getFingerprint();
|
|
60
|
+
const canvasEntropy = picassoCanvas(params.numberOfRounds, params.seed, params);
|
|
61
|
+
const entropy = hexHash([canvasEntropy, browserEntropy].join(""), 128).slice(2);
|
|
62
|
+
const u8Entropy = stringToU8a(entropy);
|
|
63
|
+
const mnemonic = entropyToMnemonic(u8Entropy);
|
|
64
|
+
const type = "sr25519";
|
|
65
|
+
const keyring = new Keyring({
|
|
66
|
+
type,
|
|
67
|
+
});
|
|
68
|
+
const keypair = keyring.addFromMnemonic(mnemonic);
|
|
69
|
+
const address = keypair.address;
|
|
70
|
+
return {
|
|
71
|
+
address,
|
|
72
|
+
name: address,
|
|
73
|
+
keypair,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=ExtensionWeb2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtensionWeb2.js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AAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QAClD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAChC,OAAO;YACN,OAAO;YACP,IAAI,EAAE,OAAO;YACb,OAAO;SACP,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Account, ProcaptchaClientConfigOutput } from "@prosopo/types";
|
|
2
|
+
import { Extension } from "./Extension.js";
|
|
3
|
+
export declare class ExtensionWeb3 extends Extension {
|
|
4
|
+
getAccount(config: ProcaptchaClientConfigOutput): Promise<Account>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=ExtensionWeb3.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtensionWeb3.d.ts","sourceRoot":"","sources":["../../src/extension/ExtensionWeb3.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK3C,qBAAa,aAAc,SAAQ,SAAS;IAC9B,UAAU,CACtB,MAAM,EAAE,4BAA4B,GAClC,OAAO,CAAC,OAAO,CAAC;CA4BnB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { web3Enable } from "@polkadot/extension-dapp";
|
|
2
|
+
import { ProsopoError } from "@prosopo/common";
|
|
3
|
+
import { Extension } from "./Extension.js";
|
|
4
|
+
export class ExtensionWeb3 extends Extension {
|
|
5
|
+
async getAccount(config) {
|
|
6
|
+
const { dappName, userAccountAddress: address } = config;
|
|
7
|
+
if (!address) {
|
|
8
|
+
throw new ProsopoError("WIDGET.NO_ACCOUNTS_FOUND", {
|
|
9
|
+
context: { error: "No account address provided" },
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
const extensions = await web3Enable(dappName);
|
|
13
|
+
if (extensions.length === 0) {
|
|
14
|
+
throw new ProsopoError("WIDGET.NO_EXTENSION_FOUND");
|
|
15
|
+
}
|
|
16
|
+
for (const extension of extensions) {
|
|
17
|
+
const accounts = await extension.accounts.get();
|
|
18
|
+
const account = accounts.find((account) => account.address === address);
|
|
19
|
+
if (account) {
|
|
20
|
+
return { account, extension };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
throw new ProsopoError("WIDGET.ACCOUNT_NOT_FOUND", {
|
|
24
|
+
context: { error: `No account found matching ${address}` },
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=ExtensionWeb3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtensionWeb3.js","sourceRoot":"","sources":["../../src/extension/ExtensionWeb3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAe/C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK3C,MAAM,OAAO,aAAc,SAAQ,SAAS;IACpC,KAAK,CAAC,UAAU,CACtB,MAAoC;QAEpC,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QAEzD,IAAI,CAAC,OAAO,EAAE,CAAC;YACd,MAAM,IAAI,YAAY,CAAC,0BAA0B,EAAE;gBAClD,OAAO,EAAE,EAAE,KAAK,EAAE,6BAA6B,EAAE;aACjD,CAAC,CAAC;QACJ,CAAC;QAGD,MAAM,UAAU,GAAwB,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC;QACnE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,YAAY,CAAC,2BAA2B,CAAC,CAAC;QACrD,CAAC;QAGD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACpC,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;YAChD,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;YACxE,IAAI,OAAO,EAAE,CAAC;gBACb,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;YAC/B,CAAC;QACF,CAAC;QAED,MAAM,IAAI,YAAY,CAAC,0BAA0B,EAAE;YAClD,OAAO,EAAE,EAAE,KAAK,EAAE,6BAA6B,OAAO,EAAE,EAAE;SAC1D,CAAC,CAAC;IACJ,CAAC;CACD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prosopo/account",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.9",
|
|
4
4
|
"description": "Services and Utils for Prosopo account gen and management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"@polkadot/keyring": "12.6.2",
|
|
38
38
|
"@polkadot/util": "12.6.2",
|
|
39
39
|
"@polkadot/util-crypto": "12.6.2",
|
|
40
|
-
"@prosopo/fingerprint": "2.1.
|
|
41
|
-
"@prosopo/common": "2.1.
|
|
42
|
-
"@prosopo/types": "2.1.
|
|
43
|
-
"@prosopo/util": "2.1.
|
|
40
|
+
"@prosopo/fingerprint": "2.1.9",
|
|
41
|
+
"@prosopo/common": "2.1.9",
|
|
42
|
+
"@prosopo/types": "2.1.9",
|
|
43
|
+
"@prosopo/util": "2.1.9",
|
|
44
44
|
"react": "18.3.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@prosopo/config": "2.1.
|
|
47
|
+
"@prosopo/config": "2.1.9",
|
|
48
48
|
"@vitest/coverage-v8": "2.1.1",
|
|
49
49
|
"concurrently": "9.0.1",
|
|
50
50
|
"npm-run-all": "4.1.5",
|