@prosopo/procaptcha-bundle 0.3.4 → 0.3.36
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/bundle/Captcha-1upZQDQF.js +112 -0
- package/dist/bundle/{ProcaptchaWidget-Boodb_xG.js → ProcaptchaWidget-wUItdOkp.js} +323 -320
- package/dist/bundle/{index-DNBOJlnJ.js → index-D8kIYYhv.js} +129 -128
- package/dist/bundle/procaptcha.bundle.js +1 -1
- package/dist/bundle/{utils-wnaO-SHm.js → utils-D1z4XROV.js} +1368 -1369
- package/dist/cjs/account/dist/extension/ExtensionWeb2.cjs +2 -2
- package/dist/cjs/procaptcha-pow/dist/Services/Manager.cjs +9 -6
- package/package.json +8 -7
- package/stats.html +1 -1
- package/dist/bundle/Captcha-CX9JR4o1.js +0 -108
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { A as h, P as I, j as n, C as _, W as k, a as S, c as P, e as R, f as G, g as O, i as H, L as U, k as j, m as L, n as M, l as F, d as q, r as b } from "./index-DNBOJlnJ.js";
|
|
2
|
-
import { B, n as K, h as g, u as z, l as X, w as J, t as V, q as $, A as Q, W as Y, K as Z, x as ee, C as te, m as D, y as ne, z as oe } from "./utils-wnaO-SHm.js";
|
|
3
|
-
const ae = (a, e) => {
|
|
4
|
-
let o = 0;
|
|
5
|
-
const c = "0".repeat(e);
|
|
6
|
-
for (; ; ) {
|
|
7
|
-
const d = new TextEncoder().encode(o + a);
|
|
8
|
-
if (re(B(d)).startsWith(c))
|
|
9
|
-
return o;
|
|
10
|
-
o += 1;
|
|
11
|
-
}
|
|
12
|
-
}, re = (a) => Array.from(a).map((e) => e.toString(16).padStart(2, "0")).join(""), se = (a, e, o, c) => {
|
|
13
|
-
const d = () => ({
|
|
14
|
-
showModal: !1,
|
|
15
|
-
loading: !1,
|
|
16
|
-
index: 0,
|
|
17
|
-
challenge: void 0,
|
|
18
|
-
solutions: void 0,
|
|
19
|
-
isHuman: !1,
|
|
20
|
-
captchaApi: void 0,
|
|
21
|
-
account: void 0
|
|
22
|
-
}), r = () => {
|
|
23
|
-
window.clearTimeout(e.timeout), u({ timeout: void 0 });
|
|
24
|
-
}, i = () => {
|
|
25
|
-
const t = {
|
|
26
|
-
userAccountAddress: "",
|
|
27
|
-
...a
|
|
28
|
-
};
|
|
29
|
-
return I.parse(t);
|
|
30
|
-
}, f = (t) => {
|
|
31
|
-
const s = t.networks[t.defaultNetwork];
|
|
32
|
-
if (!s)
|
|
33
|
-
throw new g("DEVELOPER.NETWORK_NOT_FOUND", {
|
|
34
|
-
context: { error: `No network found for environment ${t.defaultEnvironment}` }
|
|
35
|
-
});
|
|
36
|
-
return s;
|
|
37
|
-
}, w = async () => {
|
|
38
|
-
const t = f(i()), s = await Q.create({ provider: new Y(t.endpoint), initWasm: !1 }), x = "sr25519", p = new Z({ type: x, ss58Format: s.registry.chainSS58 });
|
|
39
|
-
return new ee(s, JSON.parse(te), t.contract.address, "prosopo", 0, p.addFromAddress(i().account.address || ""));
|
|
40
|
-
}, v = () => {
|
|
41
|
-
if (!e.account)
|
|
42
|
-
throw new g("GENERAL.ACCOUNT_NOT_FOUND", { context: { error: "Account not loaded" } });
|
|
43
|
-
return e.account;
|
|
44
|
-
}, l = () => {
|
|
45
|
-
if (!e.dappAccount)
|
|
46
|
-
throw new g("GENERAL.SITE_KEY_MISSING");
|
|
47
|
-
return e.dappAccount;
|
|
48
|
-
}, u = D(e, o), T = () => {
|
|
49
|
-
r(), u(d());
|
|
50
|
-
};
|
|
51
|
-
return {
|
|
52
|
-
start: async () => {
|
|
53
|
-
if (e.loading || e.isHuman)
|
|
54
|
-
return;
|
|
55
|
-
T();
|
|
56
|
-
const t = i(), s = t.userAccountAddress || "5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM";
|
|
57
|
-
if (u({
|
|
58
|
-
loading: !0,
|
|
59
|
-
account: { account: { address: s } }
|
|
60
|
-
}), u({ dappAccount: t.account.address }), await K(100), !t.web2 && !t.userAccountAddress)
|
|
61
|
-
throw new g("GENERAL.ACCOUNT_NOT_FOUND", {
|
|
62
|
-
context: { error: "Account address has not been set for web3 mode" }
|
|
63
|
-
});
|
|
64
|
-
const p = await new z().getAccount(t), y = await w(), N = X(o, e, c), A = await J(y.query.getRandomActiveProvider, y.query)(p.account.address, l()), E = V(A.provider.url.toString()), C = new $(f(i()), E, l()), m = await C.getPowCaptchaChallenge(p.account.address, l()), W = ae(m.challenge, m.difficulty);
|
|
65
|
-
(await C.submitPowCaptchaSolution(m, v().account.address, l(), A, W))[h.verified] && (u({
|
|
66
|
-
isHuman: !0,
|
|
67
|
-
loading: !1
|
|
68
|
-
}), N.onHuman({
|
|
69
|
-
providerUrl: E,
|
|
70
|
-
[h.user]: v().account.address,
|
|
71
|
-
[h.dapp]: l(),
|
|
72
|
-
[h.challenge]: m.challenge,
|
|
73
|
-
[h.blockNumber]: A.blockNumber
|
|
74
|
-
}));
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}, ue = (a) => {
|
|
78
|
-
const e = a.config, o = e.theme === "light" ? "light" : "dark", c = a.config.theme === "light" ? F : q, d = a.callbacks || {}, [r, i] = ne(b.useState, b.useRef), f = D(r, i), w = se(e, r, f, d);
|
|
79
|
-
return n("div", { children: n("div", { style: { maxWidth: "100%", maxHeight: "100%", overflowX: "auto" }, children: n(_, { children: n(k, { children: S("div", { style: P, "data-cy": "button-human", children: [" ", S("div", { style: {
|
|
80
|
-
padding: R,
|
|
81
|
-
border: G,
|
|
82
|
-
backgroundColor: c.palette.background.default,
|
|
83
|
-
borderColor: c.palette.grey[300],
|
|
84
|
-
borderRadius: O,
|
|
85
|
-
display: "flex",
|
|
86
|
-
alignItems: "center",
|
|
87
|
-
flexWrap: "wrap",
|
|
88
|
-
justifyContent: "space-between",
|
|
89
|
-
minHeight: `${H}px`,
|
|
90
|
-
overflow: "hidden"
|
|
91
|
-
}, children: [n("div", { style: { display: "inline-flex", flexDirection: "column" }, children: n("div", { style: {
|
|
92
|
-
display: "flex",
|
|
93
|
-
justifyContent: "flex-start",
|
|
94
|
-
alignItems: "center",
|
|
95
|
-
flexWrap: "wrap"
|
|
96
|
-
}, children: n("div", { style: {
|
|
97
|
-
display: "flex",
|
|
98
|
-
alignItems: "center",
|
|
99
|
-
justifyContent: "center",
|
|
100
|
-
flexDirection: "column",
|
|
101
|
-
verticalAlign: "middle"
|
|
102
|
-
}, children: n("div", { style: {
|
|
103
|
-
display: "flex"
|
|
104
|
-
}, children: n("div", { style: { flex: 1 }, children: r.loading ? n(U, { themeColor: o }) : n(oe, { checked: r.isHuman, onChange: w.start, themeColor: o, labelText: "I am human" }) }) }) }) }) }), n("div", { style: { display: "inline-flex", flexDirection: "column" }, children: n("a", { href: j, target: "_blank", "aria-label": L, children: n("div", { style: { flex: 1 }, children: n(M, { themeColor: o }) }) }) })] })] }) }) }) }) });
|
|
105
|
-
};
|
|
106
|
-
export {
|
|
107
|
-
ue as default
|
|
108
|
-
};
|