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