@prosopo/procaptcha-bundle 2.2.2 → 2.3.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.
@@ -0,0 +1,79 @@
1
+ import { u as g, R as i } from "./index-43V4q4_w.js";
2
+ import { ah as m, j as l, ai as E, q as f } from "./hash-B8OCn-ev.js";
3
+ const h = "dev";
4
+ class y {
5
+ }
6
+ function x() {
7
+ return m().then(() => {
8
+ if (!l())
9
+ throw new Error("Unable to initialize @polkadot/util-crypto");
10
+ return !0;
11
+ }).catch(() => !1);
12
+ }
13
+ const b = async () => (await import("./fp.esm-C0kLYOiJ.js")).default, N = async () => (await (await (await b()).load()).get()).visitorId, T = async () => (await import("./Signer-DP9drQ55.js")).default, O = async () => (await import("./index-B2mmLfsC.js")).Keyring, A = async () => (await import("./bip39-CRbwrDSj.js").then((a) => a.c)).entropyToMnemonic;
14
+ class D extends y {
15
+ async getAccount(e) {
16
+ const t = await this.createAccount(e), n = await this.createExtension(t);
17
+ return {
18
+ account: t,
19
+ extension: n
20
+ };
21
+ }
22
+ async createExtension(e) {
23
+ const t = await T(), n = new t(async () => {
24
+ });
25
+ return n.signRaw = async (r) => {
26
+ const o = e.keypair.sign(r.data);
27
+ return {
28
+ id: 1,
29
+ signature: g(o)
30
+ };
31
+ }, {
32
+ accounts: {
33
+ get: async () => [e],
34
+ subscribe: () => () => {
35
+ }
36
+ },
37
+ name: "procaptcha-web2",
38
+ version: h,
39
+ signer: n
40
+ };
41
+ }
42
+ async createAccount(e) {
43
+ await x();
44
+ const t = await O(), n = await N(), r = E(n, 128).slice(2), o = f(r), u = (await A())(o), s = "sr25519", w = new t({
45
+ type: s
46
+ }).addFromMnemonic(u), p = w.address;
47
+ return {
48
+ address: p,
49
+ name: p,
50
+ keypair: w
51
+ };
52
+ }
53
+ }
54
+ const F = async () => (await import("./index-QVME9Prx.js")).web3Enable;
55
+ class I extends y {
56
+ async getAccount(e) {
57
+ const { dappName: t, userAccountAddress: n } = e;
58
+ if (!n)
59
+ throw new i("WIDGET.NO_ACCOUNTS_FOUND", {
60
+ context: { error: "No account address provided" }
61
+ });
62
+ const o = await (await F())(t);
63
+ if (o.length === 0)
64
+ throw new i("WIDGET.NO_EXTENSION_FOUND");
65
+ for (const c of o) {
66
+ const s = (await c.accounts.get()).find((d) => d.address === n);
67
+ if (s)
68
+ return { account: s, extension: c };
69
+ }
70
+ throw new i("WIDGET.ACCOUNT_NOT_FOUND", {
71
+ context: { error: `No account found matching ${n}` }
72
+ });
73
+ }
74
+ }
75
+ export {
76
+ y as Extension,
77
+ D as ExtensionWeb2,
78
+ I as ExtensionWeb3
79
+ };