@prosopo/procaptcha-bundle 2.0.1 → 2.0.3
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/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/index.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/index.js +1 -4
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/index.js.map +1 -1
- package/dist/bundle/{ProcaptchaWidget-Bk0Iiawd.js → ProcaptchaWidget-BzBkw8-_.js} +285 -297
- package/dist/bundle/ProcaptchaWidget-nO3NsM0R.js +155 -0
- package/dist/bundle/{index-DvT5XLGE.js → index-DsnIPyZG.js} +3222 -3273
- package/dist/bundle/index.d.ts.map +1 -1
- package/dist/bundle/procaptcha.bundle.js +1 -1
- package/dist/bundle/{utils-nH-g73b2.js → utils-Cpz4o_0n.js} +4290 -3878
- package/dist/cjs/index.cjs +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -4
- package/dist/index.js.map +1 -1
- package/package.json +59 -59
- package/stats.html +1 -1
- package/vite.config.ts +26 -24
- package/dist/bundle/ProcaptchaWidget-CtdNKhRb.js +0 -166
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { A as a, e as H, a as L, P as O, r as w, j as n, W as k, C as j, c as M, b as R, f as U, g as B, h as F, i as X, k as K, L as V, m as Y, n as q, o as $, l as z, d as J } from "./index-DsnIPyZG.js";
|
|
2
|
+
import { v as Q, k as _, n as Z, f as E, o as ee, s as te, p as ne, l as N, E as oe, q as ae, t as se, C as re } from "./utils-Cpz4o_0n.js";
|
|
3
|
+
const ce = (r, e) => {
|
|
4
|
+
let s = 0;
|
|
5
|
+
const c = "0".repeat(e);
|
|
6
|
+
for (; ; ) {
|
|
7
|
+
const p = new TextEncoder().encode(s + r);
|
|
8
|
+
if (ie(Q(p)).startsWith(c))
|
|
9
|
+
return s;
|
|
10
|
+
s += 1;
|
|
11
|
+
}
|
|
12
|
+
}, ie = (r) => Array.from(r).map((e) => e.toString(16).padStart(2, "0")).join(""), le = (r, e, s, c) => {
|
|
13
|
+
const p = _(s, e, c), i = () => ({
|
|
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
|
+
}), T = () => {
|
|
23
|
+
window.clearTimeout(e.timeout), o({ timeout: void 0 });
|
|
24
|
+
}, b = () => {
|
|
25
|
+
window.clearTimeout(e.successfullChallengeTimeout), o({ successfullChallengeTimeout: void 0 });
|
|
26
|
+
}, l = () => {
|
|
27
|
+
const t = {
|
|
28
|
+
userAccountAddress: "",
|
|
29
|
+
...r
|
|
30
|
+
};
|
|
31
|
+
return e.account && (t.userAccountAddress = e.account.account.address), O.parse(t);
|
|
32
|
+
}, g = () => {
|
|
33
|
+
if (!e.account)
|
|
34
|
+
throw new E("GENERAL.ACCOUNT_NOT_FOUND", {
|
|
35
|
+
context: { error: "Account not loaded" }
|
|
36
|
+
});
|
|
37
|
+
return { account: e.account };
|
|
38
|
+
}, d = () => {
|
|
39
|
+
if (!e.dappAccount)
|
|
40
|
+
throw new E("GENERAL.SITE_KEY_MISSING");
|
|
41
|
+
return e.dappAccount;
|
|
42
|
+
}, o = N(e, s), v = () => {
|
|
43
|
+
T(), b(), o(i());
|
|
44
|
+
}, P = () => {
|
|
45
|
+
const t = l().captchas.pow.solutionTimeout, f = setTimeout(() => {
|
|
46
|
+
o({ isHuman: !1 }), p.onExpired();
|
|
47
|
+
}, t);
|
|
48
|
+
o({ successfullChallengeTimeout: f });
|
|
49
|
+
}, W = async () => {
|
|
50
|
+
var D;
|
|
51
|
+
if (e.loading || e.isHuman)
|
|
52
|
+
return;
|
|
53
|
+
v(), o({
|
|
54
|
+
loading: !0
|
|
55
|
+
});
|
|
56
|
+
const t = l(), f = t.web2 ? new oe() : new ae(), h = t.userAccountAddress || (await f.getAccount(t)).account.address;
|
|
57
|
+
if (o({
|
|
58
|
+
account: { account: { address: h } }
|
|
59
|
+
}), o({ dappAccount: t.account.address }), await Z(100), !t.web2 && !t.userAccountAddress)
|
|
60
|
+
throw new E("GENERAL.ACCOUNT_NOT_FOUND", {
|
|
61
|
+
context: { error: "Account address has not been set for web3 mode" }
|
|
62
|
+
});
|
|
63
|
+
const m = G(), A = _(s, e, c), x = m.provider.url, I = new ee(x, d()), u = await I.getPowCaptchaChallenge(h, d()), S = ce(u.challenge, u.difficulty), C = (D = (await f.getAccount(l())).extension) == null ? void 0 : D.signer;
|
|
64
|
+
if (!C || !C.signRaw)
|
|
65
|
+
throw new E("GENERAL.CANT_FIND_KEYRINGPAIR", {
|
|
66
|
+
context: {
|
|
67
|
+
error: "Signer is not defined, cannot sign message to prove account ownership"
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
const y = await C.signRaw({
|
|
71
|
+
address: h,
|
|
72
|
+
data: te(u[a.timestamp].toString()),
|
|
73
|
+
type: "bytes"
|
|
74
|
+
});
|
|
75
|
+
(await I.submitPowCaptchaSolution(u, g().account.account.address, d(), S, y.signature.toString(), t.captchas.pow.verifiedTimeout))[a.verified] && (o({
|
|
76
|
+
isHuman: !0,
|
|
77
|
+
loading: !1
|
|
78
|
+
}), A.onHuman(H({
|
|
79
|
+
[a.providerUrl]: x,
|
|
80
|
+
[a.user]: g().account.account.address,
|
|
81
|
+
[a.dapp]: d(),
|
|
82
|
+
[a.challenge]: u.challenge,
|
|
83
|
+
[a.nonce]: S,
|
|
84
|
+
[a.timestamp]: u.timestamp,
|
|
85
|
+
[a.signature]: {
|
|
86
|
+
[a.provider]: u.signature.provider,
|
|
87
|
+
[a.user]: {
|
|
88
|
+
[a.timestamp]: y.signature.toString()
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
})), P());
|
|
92
|
+
}, G = () => {
|
|
93
|
+
const t = (A, x) => Math.floor(Math.random() * (x - A + 1) + A), f = l().defaultEnvironment, h = ne(f), m = L(h, t(0, h.length - 1));
|
|
94
|
+
return {
|
|
95
|
+
providerAccount: m.address,
|
|
96
|
+
provider: {
|
|
97
|
+
url: m.url,
|
|
98
|
+
datasetId: m.datasetId,
|
|
99
|
+
datasetIdContent: m.datasetIdContent
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
return {
|
|
104
|
+
start: W,
|
|
105
|
+
resetState: v
|
|
106
|
+
};
|
|
107
|
+
}, me = (r) => {
|
|
108
|
+
const e = r.config, s = e.theme === "light" ? "light" : "dark", c = r.config.theme === "light" ? z : J, p = r.callbacks || {}, [i, T] = se(w.useState, w.useRef), b = N(i, T), l = w.useRef(le(e, i, b, p)), g = w.useRef(null);
|
|
109
|
+
return w.useEffect(() => {
|
|
110
|
+
const d = g.current;
|
|
111
|
+
if (!d)
|
|
112
|
+
return;
|
|
113
|
+
const o = d.closest("form");
|
|
114
|
+
if (!o)
|
|
115
|
+
return;
|
|
116
|
+
const v = () => {
|
|
117
|
+
l.current.resetState();
|
|
118
|
+
};
|
|
119
|
+
return o.addEventListener("submit", v), () => {
|
|
120
|
+
o.removeEventListener("submit", v);
|
|
121
|
+
};
|
|
122
|
+
}, []), n("div", { ref: g, children: n("div", { style: {
|
|
123
|
+
maxWidth: k,
|
|
124
|
+
maxHeight: "100%",
|
|
125
|
+
overflowX: "auto"
|
|
126
|
+
}, children: n(j, { children: n(M, { children: R("div", { style: U, "data-cy": "button-human", children: [" ", R("div", { style: {
|
|
127
|
+
padding: B,
|
|
128
|
+
border: F,
|
|
129
|
+
backgroundColor: c.palette.background.default,
|
|
130
|
+
borderColor: c.palette.grey[300],
|
|
131
|
+
borderRadius: X,
|
|
132
|
+
display: "flex",
|
|
133
|
+
alignItems: "center",
|
|
134
|
+
flexWrap: "wrap",
|
|
135
|
+
justifyContent: "space-between",
|
|
136
|
+
minHeight: `${K}px`,
|
|
137
|
+
overflow: "hidden"
|
|
138
|
+
}, children: [n("div", { style: { display: "inline-flex", flexDirection: "column" }, children: n("div", { style: {
|
|
139
|
+
display: "flex",
|
|
140
|
+
justifyContent: "flex-start",
|
|
141
|
+
alignItems: "center",
|
|
142
|
+
flexWrap: "wrap"
|
|
143
|
+
}, children: n("div", { style: {
|
|
144
|
+
display: "flex",
|
|
145
|
+
alignItems: "center",
|
|
146
|
+
justifyContent: "center",
|
|
147
|
+
flexDirection: "column",
|
|
148
|
+
verticalAlign: "middle"
|
|
149
|
+
}, children: n("div", { style: {
|
|
150
|
+
display: "flex"
|
|
151
|
+
}, children: n("div", { style: { flex: 1 }, children: i.loading ? n(V, { themeColor: s, "aria-label": "Loading spinner" }) : n(re, { checked: i.isHuman, onChange: l.current.start, themeColor: s, labelText: "I am human", "aria-label": "human checkbox" }) }) }) }) }) }), n("div", { style: { display: "inline-flex", flexDirection: "column" }, children: n("a", { href: Y, target: "_blank", "aria-label": q, rel: "noreferrer", children: n("div", { style: { flex: 1 }, children: n($, { themeColor: s, "aria-label": "Prosopo logo" }) }) }) })] })] }) }) }) }) });
|
|
152
|
+
};
|
|
153
|
+
export {
|
|
154
|
+
me as default
|
|
155
|
+
};
|