@prosopo/procaptcha-bundle 0.3.5 → 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-Cx0ArXYl.js → Captcha-1upZQDQF.js} +11 -11
- package/dist/bundle/{ProcaptchaWidget-DDAodo6R.js → ProcaptchaWidget-wUItdOkp.js} +321 -322
- package/dist/bundle/{index-HgeMtpKw.js → index-D8kIYYhv.js} +129 -128
- package/dist/bundle/procaptcha.bundle.js +1 -1
- package/dist/bundle/{utils-CfklpKIj.js → utils-D1z4XROV.js} +1368 -1367
- package/dist/cjs/account/dist/extension/ExtensionWeb2.cjs +1 -1
- package/package.json +8 -7
- package/stats.html +1 -1
|
@@ -1,19 +1,24 @@
|
|
|
1
|
-
import { r as f, l as Q, d as Z, j as
|
|
2
|
-
import { _ as
|
|
3
|
-
|
|
1
|
+
import { z as X, r as f, l as Q, d as Z, j as u, a as E, b as g, A as K, h as ue, P as Te, R as Pe, C as Oe, W as De, c as ke, e as Le, f as He, g as _e, i as Re, L as Me, k as We, m as Ue, n as je } from "./index-D8kIYYhv.js";
|
|
2
|
+
import { _ as Ge, a as ze, b as Fe, I as Be, R as $e, g as Ke, c as Ve, d as Ye, i as Xe, P as F, o as qe, E as Je, e as P, f as ae, h as v, j as V, k as de, s as xe, l as Qe, m as Ze, w as pe, t as re, n as et, p as tt, r as nt, q as rt, u as ot, v as at, A as st, W as ct, K as it, x as lt, C as ut, y as dt, z as pt } from "./utils-D1z4XROV.js";
|
|
3
|
+
const ve = X.object({
|
|
4
|
+
account: X.string().optional(),
|
|
5
|
+
blockNumber: X.number().optional(),
|
|
6
|
+
providerUrl: X.string().optional()
|
|
7
|
+
});
|
|
8
|
+
function ht() {
|
|
4
9
|
if (console && console.warn) {
|
|
5
10
|
for (var t, e = arguments.length, n = new Array(e), r = 0; r < e; r++)
|
|
6
11
|
n[r] = arguments[r];
|
|
7
12
|
typeof n[0] == "string" && (n[0] = "react-i18next:: ".concat(n[0])), (t = console).warn.apply(t, n);
|
|
8
13
|
}
|
|
9
14
|
}
|
|
10
|
-
var
|
|
11
|
-
function
|
|
15
|
+
var he = {};
|
|
16
|
+
function se() {
|
|
12
17
|
for (var t = arguments.length, e = new Array(t), n = 0; n < t; n++)
|
|
13
18
|
e[n] = arguments[n];
|
|
14
|
-
typeof e[0] == "string" &&
|
|
19
|
+
typeof e[0] == "string" && he[e[0]] || (typeof e[0] == "string" && (he[e[0]] = /* @__PURE__ */ new Date()), ht.apply(void 0, e));
|
|
15
20
|
}
|
|
16
|
-
function
|
|
21
|
+
function fe(t, e, n) {
|
|
17
22
|
t.loadNamespaces(e, function() {
|
|
18
23
|
if (t.isInitialized)
|
|
19
24
|
n();
|
|
@@ -27,58 +32,58 @@ function pe(t, e, n) {
|
|
|
27
32
|
}
|
|
28
33
|
});
|
|
29
34
|
}
|
|
30
|
-
function
|
|
35
|
+
function ft(t, e) {
|
|
31
36
|
var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, r = e.languages[0], a = e.options ? e.options.fallbackLng : !1, s = e.languages[e.languages.length - 1];
|
|
32
37
|
if (r.toLowerCase() === "cimode")
|
|
33
38
|
return !0;
|
|
34
|
-
var o = function(l,
|
|
35
|
-
var
|
|
36
|
-
return
|
|
39
|
+
var o = function(l, d) {
|
|
40
|
+
var b = e.services.backendConnector.state["".concat(l, "|").concat(d)];
|
|
41
|
+
return b === -1 || b === 2;
|
|
37
42
|
};
|
|
38
43
|
return n.bindI18n && n.bindI18n.indexOf("languageChanging") > -1 && e.services.backendConnector.backend && e.isLanguageChangingTo && !o(e.isLanguageChangingTo, t) ? !1 : !!(e.hasResourceBundle(r, t) || !e.services.backendConnector.backend || e.options.resources && !e.options.partialBundledLanguages || o(r, t) && (!a || o(s, t)));
|
|
39
44
|
}
|
|
40
|
-
function
|
|
45
|
+
function gt(t, e) {
|
|
41
46
|
var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
42
47
|
if (!e.languages || !e.languages.length)
|
|
43
|
-
return
|
|
48
|
+
return se("i18n.languages were undefined or empty", e.languages), !0;
|
|
44
49
|
var r = e.options.ignoreJSONStructure !== void 0;
|
|
45
50
|
return r ? e.hasLoadedNamespace(t, {
|
|
46
51
|
precheck: function(s, o) {
|
|
47
52
|
if (n.bindI18n && n.bindI18n.indexOf("languageChanging") > -1 && s.services.backendConnector.backend && s.isLanguageChangingTo && !o(s.isLanguageChangingTo, t))
|
|
48
53
|
return !1;
|
|
49
54
|
}
|
|
50
|
-
}) :
|
|
55
|
+
}) : ft(t, e, n);
|
|
51
56
|
}
|
|
52
|
-
function
|
|
57
|
+
function mt(t, e) {
|
|
53
58
|
var n = t == null ? null : typeof Symbol < "u" && t[Symbol.iterator] || t["@@iterator"];
|
|
54
59
|
if (n != null) {
|
|
55
|
-
var r, a, s, o,
|
|
60
|
+
var r, a, s, o, i = [], l = !0, d = !1;
|
|
56
61
|
try {
|
|
57
62
|
if (s = (n = n.call(t)).next, e === 0) {
|
|
58
63
|
if (Object(n) !== n)
|
|
59
64
|
return;
|
|
60
65
|
l = !1;
|
|
61
66
|
} else
|
|
62
|
-
for (; !(l = (r = s.call(n)).done) && (
|
|
67
|
+
for (; !(l = (r = s.call(n)).done) && (i.push(r.value), i.length !== e); l = !0)
|
|
63
68
|
;
|
|
64
|
-
} catch (
|
|
65
|
-
|
|
69
|
+
} catch (b) {
|
|
70
|
+
d = !0, a = b;
|
|
66
71
|
} finally {
|
|
67
72
|
try {
|
|
68
73
|
if (!l && n.return != null && (o = n.return(), Object(o) !== o))
|
|
69
74
|
return;
|
|
70
75
|
} finally {
|
|
71
|
-
if (
|
|
76
|
+
if (d)
|
|
72
77
|
throw a;
|
|
73
78
|
}
|
|
74
79
|
}
|
|
75
|
-
return
|
|
80
|
+
return i;
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
|
-
function
|
|
79
|
-
return
|
|
83
|
+
function wt(t, e) {
|
|
84
|
+
return Ge(t) || mt(t, e) || ze(t, e) || Fe();
|
|
80
85
|
}
|
|
81
|
-
function
|
|
86
|
+
function ge(t, e) {
|
|
82
87
|
var n = Object.keys(t);
|
|
83
88
|
if (Object.getOwnPropertySymbols) {
|
|
84
89
|
var r = Object.getOwnPropertySymbols(t);
|
|
@@ -88,81 +93,81 @@ function he(t, e) {
|
|
|
88
93
|
}
|
|
89
94
|
return n;
|
|
90
95
|
}
|
|
91
|
-
function
|
|
96
|
+
function oe(t) {
|
|
92
97
|
for (var e = 1; e < arguments.length; e++) {
|
|
93
98
|
var n = arguments[e] != null ? arguments[e] : {};
|
|
94
|
-
e % 2 ?
|
|
95
|
-
|
|
96
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) :
|
|
99
|
+
e % 2 ? ge(Object(n), !0).forEach(function(r) {
|
|
100
|
+
Ve(t, r, n[r]);
|
|
101
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : ge(Object(n)).forEach(function(r) {
|
|
97
102
|
Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(n, r));
|
|
98
103
|
});
|
|
99
104
|
}
|
|
100
105
|
return t;
|
|
101
106
|
}
|
|
102
|
-
var
|
|
107
|
+
var bt = function(e, n) {
|
|
103
108
|
var r = f.useRef();
|
|
104
109
|
return f.useEffect(function() {
|
|
105
110
|
r.current = n ? r.current : e;
|
|
106
111
|
}, [e, n]), r.current;
|
|
107
112
|
};
|
|
108
|
-
function
|
|
109
|
-
var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = e.i18n, r = f.useContext(
|
|
110
|
-
if (o && !o.reportNamespaces && (o.reportNamespaces = new
|
|
111
|
-
|
|
112
|
-
var
|
|
113
|
+
function yt(t) {
|
|
114
|
+
var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = e.i18n, r = f.useContext(Be) || {}, a = r.i18n, s = r.defaultNS, o = n || a || Ye();
|
|
115
|
+
if (o && !o.reportNamespaces && (o.reportNamespaces = new $e()), !o) {
|
|
116
|
+
se("You will need to pass in an i18next instance by using initReactI18next");
|
|
117
|
+
var i = function(x) {
|
|
113
118
|
return Array.isArray(x) ? x[x.length - 1] : x;
|
|
114
|
-
}, l = [
|
|
115
|
-
return l.t =
|
|
119
|
+
}, l = [i, {}, !1];
|
|
120
|
+
return l.t = i, l.i18n = {}, l.ready = !1, l;
|
|
116
121
|
}
|
|
117
|
-
o.options.react && o.options.react.wait !== void 0 &&
|
|
118
|
-
var
|
|
122
|
+
o.options.react && o.options.react.wait !== void 0 && se("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");
|
|
123
|
+
var d = oe(oe(oe({}, Ke()), o.options.react), e), b = d.useSuspense, I = d.keyPrefix, m = t || s || o.options && o.options.defaultNS;
|
|
119
124
|
m = typeof m == "string" ? [m] : m || ["translation"], o.reportNamespaces.addUsedNamespaces && o.reportNamespaces.addUsedNamespaces(m);
|
|
120
|
-
var
|
|
121
|
-
return
|
|
125
|
+
var L = (o.isInitialized || o.initializedStoreOnce) && m.every(function(A) {
|
|
126
|
+
return gt(A, o, d);
|
|
122
127
|
});
|
|
123
|
-
function
|
|
124
|
-
return o.getFixedT(null,
|
|
128
|
+
function H() {
|
|
129
|
+
return o.getFixedT(null, d.nsMode === "fallback" ? m : m[0], I);
|
|
125
130
|
}
|
|
126
|
-
var
|
|
131
|
+
var W = f.useState(H), U = wt(W, 2), j = U[0], _ = U[1], G = m.join(), Y = bt(G), y = f.useRef(!0);
|
|
127
132
|
f.useEffect(function() {
|
|
128
|
-
var A =
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}),
|
|
133
|
+
var A = d.bindI18n, x = d.bindI18nStore;
|
|
134
|
+
y.current = !0, !L && !b && fe(o, m, function() {
|
|
135
|
+
y.current && _(H);
|
|
136
|
+
}), L && Y && Y !== G && y.current && _(H);
|
|
132
137
|
function B() {
|
|
133
|
-
|
|
138
|
+
y.current && _(H);
|
|
134
139
|
}
|
|
135
140
|
return A && o && o.on(A, B), x && o && o.store.on(x, B), function() {
|
|
136
|
-
|
|
137
|
-
return o.off(
|
|
138
|
-
}), x && o && x.split(" ").forEach(function(
|
|
139
|
-
return o.store.off(
|
|
141
|
+
y.current = !1, A && o && A.split(" ").forEach(function(c) {
|
|
142
|
+
return o.off(c, B);
|
|
143
|
+
}), x && o && x.split(" ").forEach(function(c) {
|
|
144
|
+
return o.store.off(c, B);
|
|
140
145
|
});
|
|
141
146
|
};
|
|
142
|
-
}, [o,
|
|
143
|
-
var
|
|
147
|
+
}, [o, G]);
|
|
148
|
+
var N = f.useRef(!0);
|
|
144
149
|
f.useEffect(function() {
|
|
145
|
-
|
|
150
|
+
y.current && !N.current && _(H), N.current = !1;
|
|
146
151
|
}, [o, I]);
|
|
147
|
-
var
|
|
148
|
-
if (
|
|
149
|
-
return
|
|
152
|
+
var R = [j, o, L];
|
|
153
|
+
if (R.t = j, R.i18n = o, R.ready = L, L || !L && !b)
|
|
154
|
+
return R;
|
|
150
155
|
throw new Promise(function(A) {
|
|
151
|
-
|
|
156
|
+
fe(o, m, function() {
|
|
152
157
|
A();
|
|
153
158
|
});
|
|
154
159
|
});
|
|
155
160
|
}
|
|
156
|
-
function
|
|
157
|
-
return
|
|
161
|
+
function Ct(t) {
|
|
162
|
+
return yt("translation", { i18n: Xe, ...t });
|
|
158
163
|
}
|
|
159
|
-
const
|
|
164
|
+
const xt = (t) => {
|
|
160
165
|
if (!t.hash)
|
|
161
|
-
throw new
|
|
166
|
+
throw new F("CAPTCHA.MISSING_ITEM_HASH", { context: { item: t } });
|
|
162
167
|
return t.hash;
|
|
163
|
-
},
|
|
168
|
+
}, vt = ({ challenge: t, solution: e, onClick: n, themeColor: r }) => {
|
|
164
169
|
const a = t.captcha.items, s = f.useMemo(() => r === "light" ? Q : Z, [r]), o = "ontouchstart" in window;
|
|
165
|
-
return
|
|
170
|
+
return u("div", { style: {
|
|
166
171
|
paddingRight: 0.5,
|
|
167
172
|
paddingBottom: 0.5,
|
|
168
173
|
width: "100%",
|
|
@@ -170,31 +175,31 @@ const bt = (t) => {
|
|
|
170
175
|
display: "flex",
|
|
171
176
|
flexDirection: "row",
|
|
172
177
|
flexWrap: "wrap"
|
|
173
|
-
}, children: a.map((
|
|
174
|
-
const
|
|
175
|
-
return
|
|
178
|
+
}, children: a.map((i, l) => {
|
|
179
|
+
const d = xt(i);
|
|
180
|
+
return u("div", { style: {
|
|
176
181
|
paddingTop: "4px",
|
|
177
182
|
paddingLeft: "4px",
|
|
178
183
|
flexGrow: 1,
|
|
179
184
|
flexBasis: "33.3333%",
|
|
180
185
|
boxSizing: "border-box"
|
|
181
|
-
}, children: E("div", { style: { cursor: "pointer", height: "100%", width: "100%" }, onClick: o ? void 0 : () => n(
|
|
186
|
+
}, children: E("div", { style: { cursor: "pointer", height: "100%", width: "100%" }, onClick: o ? void 0 : () => n(d), onTouchStart: o ? () => n(d) : void 0, children: [u("div", { style: { border: 1, borderColor: s.palette.grey[300] }, children: u("img", { style: {
|
|
182
187
|
width: "100%",
|
|
183
188
|
backgroundColor: s.palette.grey[300],
|
|
184
|
-
opacity: e.includes(
|
|
189
|
+
opacity: e.includes(d) && o ? "50%" : "100%",
|
|
185
190
|
display: "block",
|
|
186
191
|
objectFit: "contain",
|
|
187
192
|
aspectRatio: "1/1",
|
|
188
193
|
height: "auto"
|
|
189
|
-
}, src:
|
|
194
|
+
}, src: i.data, alt: `Captcha image ${l + 1}` }) }), u("div", { style: {
|
|
190
195
|
position: "relative",
|
|
191
196
|
width: "100%",
|
|
192
197
|
height: "100%",
|
|
193
198
|
top: "-100%",
|
|
194
|
-
visibility: e.includes(
|
|
199
|
+
visibility: e.includes(d) ? "visible" : "hidden",
|
|
195
200
|
transition: "opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
|
|
196
201
|
opacity: 1
|
|
197
|
-
}, children:
|
|
202
|
+
}, children: u("div", { style: {
|
|
198
203
|
position: "absolute",
|
|
199
204
|
top: 0,
|
|
200
205
|
left: 0,
|
|
@@ -206,7 +211,7 @@ const bt = (t) => {
|
|
|
206
211
|
alignItems: "center",
|
|
207
212
|
justifyContent: "center",
|
|
208
213
|
backgroundColor: "rgba(0,0,0,0.5)"
|
|
209
|
-
}, children:
|
|
214
|
+
}, children: u("svg", { style: {
|
|
210
215
|
backgroundColor: "transparent",
|
|
211
216
|
display: "block",
|
|
212
217
|
width: "35%",
|
|
@@ -214,18 +219,18 @@ const bt = (t) => {
|
|
|
214
219
|
transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
|
|
215
220
|
userSelect: "none",
|
|
216
221
|
fill: "currentcolor"
|
|
217
|
-
}, focusable: "false", color: "#fff", "aria-hidden": "true", viewBox: "0 0 24 24", "data-testid": "CheckIcon", children:
|
|
222
|
+
}, focusable: "false", color: "#fff", "aria-hidden": "true", viewBox: "0 0 24 24", "data-testid": "CheckIcon", children: u("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) }) }) })] }) }, l);
|
|
218
223
|
}) });
|
|
219
224
|
};
|
|
220
|
-
function
|
|
225
|
+
function At(t = {}) {
|
|
221
226
|
return Object.keys(t).reduce((e, n) => ({ ...e, [`data-${n}`]: t[n] }), {});
|
|
222
227
|
}
|
|
223
|
-
function
|
|
228
|
+
function ce({ general: t, dev: e }) {
|
|
224
229
|
return {
|
|
225
|
-
...
|
|
230
|
+
...At(t)
|
|
226
231
|
};
|
|
227
232
|
}
|
|
228
|
-
const
|
|
233
|
+
const Et = {
|
|
229
234
|
display: "inline-flex",
|
|
230
235
|
alignItems: "center",
|
|
231
236
|
justifyContent: "center",
|
|
@@ -251,10 +256,10 @@ const vt = {
|
|
|
251
256
|
color: "rgb(0, 0, 0)",
|
|
252
257
|
backgroundColor: "#ffffff",
|
|
253
258
|
boxShadow: "rgba(0, 0, 0, 0.2) 0px 3px 1px -2px, rgba(0, 0, 0, 0.14) 0px 2px 2px 0px, rgba(0, 0, 0, 0.12) 0px 1px 5px 0px"
|
|
254
|
-
},
|
|
255
|
-
const a = f.useMemo(() => t === "light" ? Q : Z, [t]), [s, o] = f.useState(!1),
|
|
259
|
+
}, It = ({ themeColor: t, buttonType: e, text: n, onClick: r }) => {
|
|
260
|
+
const a = f.useMemo(() => t === "light" ? Q : Z, [t]), [s, o] = f.useState(!1), i = f.useMemo(() => {
|
|
256
261
|
const l = {
|
|
257
|
-
...
|
|
262
|
+
...Et,
|
|
258
263
|
color: s ? a.palette.primary.contrastText : a.palette.background.contrastText
|
|
259
264
|
};
|
|
260
265
|
return e === "cancel" ? {
|
|
@@ -265,12 +270,12 @@ const vt = {
|
|
|
265
270
|
backgroundColor: s ? a.palette.primary.main : a.palette.background.default
|
|
266
271
|
};
|
|
267
272
|
}, [e, s, a]);
|
|
268
|
-
return
|
|
273
|
+
return u("button", { ...ce({ dev: { cy: `button-${e}` } }), onMouseEnter: () => o(!0), onMouseLeave: () => o(!1), style: i, onClick: (l) => {
|
|
269
274
|
l.preventDefault(), r();
|
|
270
275
|
}, children: n });
|
|
271
|
-
},
|
|
272
|
-
const { t: l } =
|
|
273
|
-
return
|
|
276
|
+
}, me = It, Nt = ({ challenge: t, index: e, solutions: n, onSubmit: r, onCancel: a, onClick: s, onNext: o, themeColor: i }) => {
|
|
277
|
+
const { t: l } = Ct(), d = t.captchas ? g(t.captchas, e) : null, b = n ? g(n, e) : [], I = f.useMemo(() => i === "light" ? Q : Z, [i]);
|
|
278
|
+
return u(f.Suspense, { fallback: u("div", { children: "Loading..." }), children: u("div", { style: {
|
|
274
279
|
overflowX: "auto",
|
|
275
280
|
overflowY: "auto",
|
|
276
281
|
width: "100%",
|
|
@@ -293,17 +298,17 @@ const vt = {
|
|
|
293
298
|
color: "#ffffff",
|
|
294
299
|
fontWeight: 700,
|
|
295
300
|
lineHeight: 1.5
|
|
296
|
-
}, children: [l("WIDGET.SELECT_ALL"), ": "] }),
|
|
301
|
+
}, children: [l("WIDGET.SELECT_ALL"), ": "] }), u("p", { style: {
|
|
297
302
|
color: "#ffffff",
|
|
298
303
|
fontWeight: 700,
|
|
299
304
|
textTransform: "capitalize",
|
|
300
305
|
lineHeight: 1.5
|
|
301
|
-
}, children: `${g(t.captchas, e).captcha.target}` })] }),
|
|
306
|
+
}, children: `${g(t.captchas, e).captcha.target}` })] }), u("div", { ...ce({ dev: { cy: "captcha-" + e } }), children: d && u(vt, { challenge: d, solution: b, onClick: s, themeColor: i }) }), u("div", { style: {
|
|
302
307
|
display: "flex",
|
|
303
308
|
alignItems: "center",
|
|
304
309
|
justifyContent: "center",
|
|
305
310
|
width: "100%"
|
|
306
|
-
}, ...
|
|
311
|
+
}, ...ce({ dev: { cy: "dots-captcha" } }) }), u("div", { style: {
|
|
307
312
|
padding: "8px 16px",
|
|
308
313
|
display: "flex",
|
|
309
314
|
width: "100%"
|
|
@@ -313,8 +318,8 @@ const vt = {
|
|
|
313
318
|
alignItems: "center",
|
|
314
319
|
justifyContent: "space-between",
|
|
315
320
|
lineHeight: 1.75
|
|
316
|
-
}, children: [
|
|
317
|
-
},
|
|
321
|
+
}, children: [u(me, { themeColor: i, buttonType: "cancel", onClick: a, text: l("WIDGET.CANCEL") }), u(me, { themeColor: i, buttonType: "next", text: e < t.captchas.length - 1 ? l("WIDGET.NEXT") : l("WIDGET.SUBMIT"), onClick: e < t.captchas.length - 1 ? o : r })] })] }) }) });
|
|
322
|
+
}, St = Nt;
|
|
318
323
|
function Tt(t) {
|
|
319
324
|
return new Promise((e) => {
|
|
320
325
|
document.readyState === "complete" ? e(t()) : window.addEventListener("load", () => e(t()));
|
|
@@ -322,49 +327,49 @@ function Tt(t) {
|
|
|
322
327
|
}
|
|
323
328
|
const J = window;
|
|
324
329
|
J.injectedWeb3 = J.injectedWeb3 || {};
|
|
325
|
-
|
|
326
|
-
let
|
|
327
|
-
function
|
|
330
|
+
Ae();
|
|
331
|
+
let we = null;
|
|
332
|
+
function Ae() {
|
|
328
333
|
return Object.values(J.injectedWeb3).filter(({ connect: t, enable: e }) => !!(t || e)).length !== 0;
|
|
329
334
|
}
|
|
330
|
-
function
|
|
331
|
-
return Promise.all(Object.entries(J.injectedWeb3).map(([e, { connect: n, enable: r, version: a }]) => Promise.resolve().then(() => n ? n(t) : r ? r(t).then((s) =>
|
|
335
|
+
function Pt(t) {
|
|
336
|
+
return Promise.all(Object.entries(J.injectedWeb3).map(([e, { connect: n, enable: r, version: a }]) => Promise.resolve().then(() => n ? n(t) : r ? r(t).then((s) => qe({ name: e, version: a || "unknown" }, s)) : Promise.reject(new Error("No connect(..) or enable(...) hook found"))).catch(({ message: s }) => {
|
|
332
337
|
console.error(`Error initializing ${e}: ${s}`);
|
|
333
338
|
}))).then((e) => e.filter((n) => !!n));
|
|
334
339
|
}
|
|
335
|
-
function
|
|
340
|
+
function Ot(t, e = []) {
|
|
336
341
|
if (!t)
|
|
337
342
|
throw new Error("You must pass a name for your app to the web3Enable function");
|
|
338
343
|
const n = e.length ? Promise.all(e.map((r) => r().catch(() => !1))) : Promise.resolve([!0]);
|
|
339
|
-
return
|
|
344
|
+
return we = Tt(() => n.then(() => Pt(t).then((r) => r.map((a) => (a.accounts.subscribe || (a.accounts.subscribe = (s) => (a.accounts.get().then(s).catch(console.error), () => {
|
|
340
345
|
})), a))).catch(() => []).then((r) => {
|
|
341
346
|
const a = r.map(({ name: s, version: o }) => `${s}/${o}`);
|
|
342
|
-
return
|
|
343
|
-
}))),
|
|
347
|
+
return Ae(), `${r.length}`, r.length, `${a.join(", ")}`, r;
|
|
348
|
+
}))), we;
|
|
344
349
|
}
|
|
345
|
-
class
|
|
350
|
+
class Dt extends Je {
|
|
346
351
|
async getAccount(e) {
|
|
347
352
|
const { dappName: n, userAccountAddress: r } = e;
|
|
348
353
|
if (!r)
|
|
349
|
-
throw new
|
|
350
|
-
const a = await
|
|
354
|
+
throw new P("WIDGET.NO_ACCOUNTS_FOUND", { context: { error: "No account address provided" } });
|
|
355
|
+
const a = await Ot(n);
|
|
351
356
|
if (a.length === 0)
|
|
352
|
-
throw new
|
|
357
|
+
throw new P("WIDGET.NO_EXTENSION_FOUND");
|
|
353
358
|
for (const s of a) {
|
|
354
|
-
const
|
|
355
|
-
if (
|
|
356
|
-
return { account:
|
|
359
|
+
const i = (await s.accounts.get()).find((l) => l.address === r);
|
|
360
|
+
if (i)
|
|
361
|
+
return { account: i, extension: s };
|
|
357
362
|
}
|
|
358
|
-
throw new
|
|
363
|
+
throw new P("WIDGET.ACCOUNT_NOT_FOUND", {
|
|
359
364
|
context: { error: `No account found matching ${r}` }
|
|
360
365
|
});
|
|
361
366
|
}
|
|
362
367
|
}
|
|
363
|
-
async function
|
|
368
|
+
async function kt(t) {
|
|
364
369
|
try {
|
|
365
370
|
const e = await fetch(t);
|
|
366
371
|
if (!e.ok)
|
|
367
|
-
throw new
|
|
372
|
+
throw new ae("API.BAD_REQUEST", {
|
|
368
373
|
context: { error: `Network response was not ok, status: ${e.status}`, url: t }
|
|
369
374
|
});
|
|
370
375
|
const n = await e.arrayBuffer();
|
|
@@ -373,48 +378,48 @@ async function Ot(t) {
|
|
|
373
378
|
throw new v("DATABASE.IMAGE_GET_FAILED", { context: { error: e } });
|
|
374
379
|
}
|
|
375
380
|
}
|
|
376
|
-
const
|
|
377
|
-
function
|
|
381
|
+
const Lt = "NO_SOLUTION";
|
|
382
|
+
function Ee(t, e = !1, n = !1, r) {
|
|
378
383
|
try {
|
|
379
384
|
const a = t.items.map((s, o) => {
|
|
380
385
|
if (s.hash)
|
|
381
386
|
return s.hash;
|
|
382
|
-
throw new
|
|
387
|
+
throw new F("CAPTCHA.MISSING_ITEM_HASH", {
|
|
383
388
|
context: {
|
|
384
|
-
computeCaptchaHashName:
|
|
389
|
+
computeCaptchaHashName: Ee.name,
|
|
385
390
|
index: o
|
|
386
391
|
}
|
|
387
392
|
});
|
|
388
393
|
});
|
|
389
394
|
return V([
|
|
390
395
|
t.target,
|
|
391
|
-
...e ?
|
|
396
|
+
...e ? Ht(t.solution) : [],
|
|
392
397
|
n ? t.salt : "",
|
|
393
398
|
r ? a.sort() : a
|
|
394
399
|
]);
|
|
395
400
|
} catch (a) {
|
|
396
|
-
throw new
|
|
401
|
+
throw new F("DATASET.HASH_ERROR", { context: { error: a } });
|
|
397
402
|
}
|
|
398
403
|
}
|
|
399
|
-
function
|
|
400
|
-
return t !== void 0 ? t.sort() : [
|
|
404
|
+
function Ht(t) {
|
|
405
|
+
return t !== void 0 ? t.sort() : [Lt];
|
|
401
406
|
}
|
|
402
|
-
async function
|
|
407
|
+
async function _t(t) {
|
|
403
408
|
if (t.type === "text")
|
|
404
|
-
return { ...t, hash:
|
|
409
|
+
return { ...t, hash: de(t.data) };
|
|
405
410
|
if (t.type === "image")
|
|
406
|
-
return { ...t, hash:
|
|
407
|
-
throw new
|
|
411
|
+
return { ...t, hash: de(await kt(t.data)) };
|
|
412
|
+
throw new F("CAPTCHA.INVALID_ITEM_FORMAT");
|
|
408
413
|
}
|
|
409
|
-
function
|
|
414
|
+
function Rt(t) {
|
|
410
415
|
return V([t.captchaId, t.captchaContentId, [...t.solution].sort(), t.salt]);
|
|
411
416
|
}
|
|
412
|
-
class
|
|
417
|
+
class be {
|
|
413
418
|
constructor(e) {
|
|
414
419
|
this.hash = e, this.parent = null;
|
|
415
420
|
}
|
|
416
421
|
}
|
|
417
|
-
class
|
|
422
|
+
class Mt {
|
|
418
423
|
constructor() {
|
|
419
424
|
this.leaves = [], this.layers = [];
|
|
420
425
|
}
|
|
@@ -422,7 +427,7 @@ class Ht {
|
|
|
422
427
|
this.layers.length && (this.layers = []);
|
|
423
428
|
const n = [];
|
|
424
429
|
for (const r of e) {
|
|
425
|
-
const a = new
|
|
430
|
+
const a = new be(r);
|
|
426
431
|
this.leaves.push(a), n.push(a.hash);
|
|
427
432
|
}
|
|
428
433
|
this.layers.push(n), this.root = this.buildMerkleTree(this.leaves)[0];
|
|
@@ -437,14 +442,14 @@ class Ht {
|
|
|
437
442
|
for (; a < n; ) {
|
|
438
443
|
const o = e[a];
|
|
439
444
|
if (o === void 0)
|
|
440
|
-
throw new
|
|
441
|
-
const
|
|
445
|
+
throw new P("DEVELOPER.GENERAL", { context: { error: "leftChild undefined" } });
|
|
446
|
+
const i = a + 1 < n ? g(e, a + 1) : o, l = this.createParent(o, i);
|
|
442
447
|
s.push(l.hash), r.push(l), a += 2;
|
|
443
448
|
}
|
|
444
449
|
return this.layers.push(s), this.buildMerkleTree(r);
|
|
445
450
|
}
|
|
446
451
|
createParent(e, n) {
|
|
447
|
-
const r = new
|
|
452
|
+
const r = new be(V([e.hash, n.hash]));
|
|
448
453
|
return e.parent = r.hash, n.parent = r.hash, r;
|
|
449
454
|
}
|
|
450
455
|
proof(e) {
|
|
@@ -453,20 +458,20 @@ class Ht {
|
|
|
453
458
|
for (; r < this.layers.length - 1; ) {
|
|
454
459
|
const s = this.layers[r];
|
|
455
460
|
if (s === void 0)
|
|
456
|
-
throw new
|
|
461
|
+
throw new P("DATASET.MERKLE_ERROR", {
|
|
457
462
|
context: { error: "layer undefined", failedFuncName: this.proof.name, layerNum: r }
|
|
458
463
|
});
|
|
459
464
|
const o = s.indexOf(e);
|
|
460
|
-
let
|
|
461
|
-
|
|
462
|
-
const l = [e],
|
|
463
|
-
|
|
465
|
+
let i = o % 2 && o > 0 ? o - 1 : o + 1;
|
|
466
|
+
i > s.length - 1 && (i = o);
|
|
467
|
+
const l = [e], d = g(s, i);
|
|
468
|
+
i > o ? l.push(d) : l.unshift(d), n.push([g(l, 0), g(l, 1)]), r += 1, e = V(l);
|
|
464
469
|
}
|
|
465
470
|
const a = g(this.layers, this.layers.length - 1);
|
|
466
471
|
return [...n, [g(a, 0)]];
|
|
467
472
|
}
|
|
468
473
|
}
|
|
469
|
-
function
|
|
474
|
+
function Wt(t, e) {
|
|
470
475
|
try {
|
|
471
476
|
if (g(e, 0).indexOf(t) === -1)
|
|
472
477
|
return !1;
|
|
@@ -506,62 +511,62 @@ class Ut {
|
|
|
506
511
|
if (e.provider.datasetIdContent.toString() !== g(s, 0))
|
|
507
512
|
throw new v("CAPTCHA.INVALID_DATASET_CONTENT_ID");
|
|
508
513
|
for (const o of n.captchas) {
|
|
509
|
-
if (!
|
|
514
|
+
if (!jt(o))
|
|
510
515
|
throw new v("CAPTCHA.INVALID_CAPTCHA_CHALLENGE");
|
|
511
|
-
if (!
|
|
516
|
+
if (!Wt(o.captcha.captchaContentId, o.proof))
|
|
512
517
|
throw new v("CAPTCHA.INVALID_CAPTCHA_CHALLENGE");
|
|
513
518
|
}
|
|
514
519
|
}
|
|
515
520
|
async submitCaptchaSolution(e, n, r, a, s) {
|
|
516
|
-
const o = new
|
|
517
|
-
o.build(
|
|
518
|
-
const l = o.root.hash,
|
|
519
|
-
let
|
|
521
|
+
const o = new Mt(), i = a.map((m) => Rt(m));
|
|
522
|
+
o.build(i);
|
|
523
|
+
const l = o.root.hash, d = void 0;
|
|
524
|
+
let b;
|
|
520
525
|
if (this.web2) {
|
|
521
526
|
if (!e || !e.signRaw)
|
|
522
527
|
throw new v("GENERAL.CANT_FIND_KEYRINGPAIR", {
|
|
523
528
|
context: { error: "Signer is not defined, cannot sign message to prove account ownership" }
|
|
524
529
|
});
|
|
525
|
-
|
|
530
|
+
b = (await e.signRaw({
|
|
526
531
|
address: this.userAccount,
|
|
527
|
-
data:
|
|
532
|
+
data: xe(n),
|
|
528
533
|
type: "bytes"
|
|
529
534
|
})).signature;
|
|
530
535
|
}
|
|
531
536
|
let I;
|
|
532
537
|
try {
|
|
533
|
-
I = await this.providerApi.submitCaptchaSolution(a, n, this.contract.pair.address, s,
|
|
538
|
+
I = await this.providerApi.submitCaptchaSolution(a, n, this.contract.pair.address, s, b);
|
|
534
539
|
} catch (m) {
|
|
535
|
-
throw new
|
|
540
|
+
throw new F("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", { context: { error: m } });
|
|
536
541
|
}
|
|
537
|
-
return [I, l,
|
|
542
|
+
return [I, l, d];
|
|
538
543
|
}
|
|
539
544
|
}
|
|
540
|
-
async function
|
|
545
|
+
async function jt(t) {
|
|
541
546
|
const e = t.captcha, n = t.proof;
|
|
542
|
-
if (!(await Promise.all(e.items.map(async (a) => (await
|
|
547
|
+
if (!(await Promise.all(e.items.map(async (a) => (await _t(a)).hash === a.hash))).every((a) => a === !0))
|
|
543
548
|
return !1;
|
|
544
|
-
const r =
|
|
549
|
+
const r = Ee(e, !1, !1, !1);
|
|
545
550
|
return r !== e.captchaContentId ? !1 : g(n, 0).indexOf(r) !== -1;
|
|
546
551
|
}
|
|
547
|
-
const
|
|
548
|
-
function
|
|
549
|
-
localStorage.
|
|
552
|
+
const Gt = Ut, Ie = "@prosopo/procaptcha";
|
|
553
|
+
function ie() {
|
|
554
|
+
return ve.parse(JSON.parse(Qe(localStorage.getItem(Ie) || "0x7b7d")));
|
|
550
555
|
}
|
|
551
|
-
function
|
|
552
|
-
|
|
556
|
+
function Ne(t) {
|
|
557
|
+
localStorage.setItem(Ie, xe(JSON.stringify(ve.parse(t))));
|
|
553
558
|
}
|
|
554
|
-
function
|
|
555
|
-
|
|
559
|
+
function zt(t) {
|
|
560
|
+
Ne({ ...ie(), account: t });
|
|
556
561
|
}
|
|
557
|
-
function
|
|
558
|
-
return
|
|
562
|
+
function Ft() {
|
|
563
|
+
return ie().account || null;
|
|
559
564
|
}
|
|
560
|
-
const
|
|
561
|
-
setAccount:
|
|
562
|
-
getAccount:
|
|
563
|
-
|
|
564
|
-
|
|
565
|
+
const z = {
|
|
566
|
+
setAccount: zt,
|
|
567
|
+
getAccount: Ft,
|
|
568
|
+
setProcaptchaStorage: Ne,
|
|
569
|
+
getProcaptchaStorage: ie
|
|
565
570
|
}, Bt = () => ({
|
|
566
571
|
showModal: !1,
|
|
567
572
|
loading: !1,
|
|
@@ -571,7 +576,7 @@ const K = {
|
|
|
571
576
|
isHuman: !1,
|
|
572
577
|
captchaApi: void 0,
|
|
573
578
|
account: void 0
|
|
574
|
-
}),
|
|
579
|
+
}), ye = (t) => {
|
|
575
580
|
const e = t.networks[t.defaultNetwork];
|
|
576
581
|
if (!e)
|
|
577
582
|
throw new v("DEVELOPER.NETWORK_NOT_FOUND", {
|
|
@@ -580,227 +585,221 @@ const K = {
|
|
|
580
585
|
return e;
|
|
581
586
|
};
|
|
582
587
|
function $t(t, e, n, r) {
|
|
583
|
-
const a =
|
|
584
|
-
const
|
|
585
|
-
a.onError(
|
|
586
|
-
}, o =
|
|
587
|
-
const
|
|
588
|
+
const a = Ze(n, e, r), s = (c) => {
|
|
589
|
+
const p = c instanceof Error ? c : new Error(String(c));
|
|
590
|
+
a.onError(p);
|
|
591
|
+
}, o = et(e, n), i = () => {
|
|
592
|
+
const c = {
|
|
588
593
|
userAccountAddress: "",
|
|
589
594
|
...t
|
|
590
595
|
};
|
|
591
|
-
return e.account && (
|
|
592
|
-
}, l = async (
|
|
596
|
+
return e.account && (c.userAccountAddress = e.account.account.address), Te.parse(c);
|
|
597
|
+
}, l = async (c) => {
|
|
593
598
|
try {
|
|
594
|
-
await
|
|
595
|
-
} catch (
|
|
596
|
-
console.error(
|
|
599
|
+
await c();
|
|
600
|
+
} catch (p) {
|
|
601
|
+
console.error(p), s(p), o({ isHuman: !1, showModal: !1, loading: !1 });
|
|
597
602
|
}
|
|
598
|
-
},
|
|
603
|
+
}, d = async () => {
|
|
599
604
|
a.onOpen(), await l(async () => {
|
|
600
605
|
if (e.loading || e.isHuman)
|
|
601
606
|
return;
|
|
602
|
-
|
|
603
|
-
const
|
|
604
|
-
o({ dappAccount:
|
|
605
|
-
const
|
|
606
|
-
let
|
|
607
|
+
_(), o({ loading: !0 });
|
|
608
|
+
const c = i();
|
|
609
|
+
o({ dappAccount: c.account.address }), await tt(100);
|
|
610
|
+
const p = await Y(), h = await x();
|
|
611
|
+
let w = !1;
|
|
607
612
|
try {
|
|
608
|
-
|
|
609
|
-
} catch (
|
|
613
|
+
w = (await h.query.dappOperatorIsHumanUser(p.account.address, c.solutionThreshold)).value.unwrap().unwrap();
|
|
614
|
+
} catch (T) {
|
|
610
615
|
}
|
|
611
|
-
if (
|
|
616
|
+
if (w) {
|
|
612
617
|
o({ isHuman: !0, loading: !1 }), a.onHuman({
|
|
613
|
-
user:
|
|
614
|
-
dapp:
|
|
615
|
-
}),
|
|
618
|
+
user: p.account.address,
|
|
619
|
+
dapp: N()
|
|
620
|
+
}), j();
|
|
616
621
|
return;
|
|
617
622
|
}
|
|
618
|
-
const C =
|
|
619
|
-
let
|
|
620
|
-
if (C) {
|
|
621
|
-
|
|
623
|
+
const C = z.getProcaptchaStorage();
|
|
624
|
+
let O;
|
|
625
|
+
if (C.providerUrl && C.blockNumber) {
|
|
626
|
+
O = await W(C.providerUrl);
|
|
622
627
|
try {
|
|
623
|
-
const
|
|
624
|
-
if (
|
|
628
|
+
const T = await O.verifyDappUser(N(), p.account.address, C.blockNumber, void 0, t.challengeValidLength);
|
|
629
|
+
if (T.verified) {
|
|
625
630
|
o({ isHuman: !0, loading: !1 });
|
|
626
|
-
const
|
|
627
|
-
[
|
|
628
|
-
[
|
|
629
|
-
[
|
|
630
|
-
[
|
|
631
|
-
[
|
|
631
|
+
const ne = {
|
|
632
|
+
[K.providerUrl]: C.providerUrl,
|
|
633
|
+
[K.user]: p.account.address,
|
|
634
|
+
[K.dapp]: N(),
|
|
635
|
+
[K.commitmentId]: ue(T.commitmentId),
|
|
636
|
+
[K.blockNumber]: T.blockNumber
|
|
632
637
|
};
|
|
633
|
-
a.onHuman(
|
|
638
|
+
a.onHuman(ne), j();
|
|
634
639
|
return;
|
|
635
640
|
}
|
|
636
641
|
} catch {
|
|
637
|
-
console.error("Error contacting provider from storage", C);
|
|
642
|
+
console.error("Error contacting provider from storage", C.providerUrl);
|
|
638
643
|
}
|
|
639
644
|
}
|
|
640
|
-
const
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
const _ = await de(h.query.getRandomActiveProvider, h.query)(u.account.address, T()), R = parseInt(_.blockNumber.toString()), X = ne(_.provider.url.toString());
|
|
647
|
-
P = await U(X);
|
|
648
|
-
const F = await (await k(h, _, P)).getCaptchaChallenge();
|
|
649
|
-
if (F.captchas.length <= 0)
|
|
650
|
-
throw new oe("DEVELOPER.PROVIDER_NO_CAPTCHA");
|
|
651
|
-
const ee = F.captchas.map((N) => N.captcha.timeLimitMs || 30 * 1e3).reduce((N, te) => N + te), Ee = setTimeout(() => {
|
|
645
|
+
const D = await pe(h.query.getRandomActiveProvider, h.query)(p.account.address, N()), k = parseInt(D.blockNumber.toString()), M = re(D.provider.url.toString());
|
|
646
|
+
O = await W(M);
|
|
647
|
+
const S = await (await H(h, D, O)).getCaptchaChallenge();
|
|
648
|
+
if (S.captchas.length <= 0)
|
|
649
|
+
throw new ae("DEVELOPER.PROVIDER_NO_CAPTCHA");
|
|
650
|
+
const ee = S.captchas.map((T) => T.captcha.timeLimitMs || 30 * 1e3).reduce((T, ne) => T + ne), te = setTimeout(() => {
|
|
652
651
|
a.onChallengeExpired(), o({ isHuman: !1, showModal: !1, loading: !1 });
|
|
653
652
|
}, ee);
|
|
654
653
|
o({
|
|
655
654
|
index: 0,
|
|
656
|
-
solutions:
|
|
657
|
-
challenge:
|
|
655
|
+
solutions: S.captchas.map(() => []),
|
|
656
|
+
challenge: S,
|
|
658
657
|
showModal: !0,
|
|
659
|
-
timeout:
|
|
660
|
-
blockNumber:
|
|
658
|
+
timeout: te,
|
|
659
|
+
blockNumber: k
|
|
661
660
|
});
|
|
662
661
|
});
|
|
663
|
-
},
|
|
662
|
+
}, b = async () => {
|
|
664
663
|
await l(async () => {
|
|
665
|
-
if (
|
|
666
|
-
throw new
|
|
664
|
+
if (U(), !e.challenge)
|
|
665
|
+
throw new P("CAPTCHA.NO_CAPTCHA", {
|
|
667
666
|
context: { error: "Cannot submit, no Captcha found in state" }
|
|
668
667
|
});
|
|
669
668
|
o({ showModal: !1 });
|
|
670
|
-
const
|
|
671
|
-
const
|
|
669
|
+
const c = e.challenge, p = nt(), h = e.challenge.captchas.map((S, ee) => {
|
|
670
|
+
const te = g(e.solutions, ee);
|
|
672
671
|
return {
|
|
673
|
-
captchaId:
|
|
674
|
-
captchaContentId:
|
|
675
|
-
salt:
|
|
676
|
-
solution:
|
|
672
|
+
captchaId: S.captcha.captchaId,
|
|
673
|
+
captchaContentId: S.captcha.captchaContentId,
|
|
674
|
+
salt: p,
|
|
675
|
+
solution: te
|
|
677
676
|
};
|
|
678
|
-
}),
|
|
679
|
-
if (!
|
|
680
|
-
throw new
|
|
677
|
+
}), w = y(), C = R(), O = A(w).signer, D = g(c.captchas, 0);
|
|
678
|
+
if (!D.captcha.datasetId)
|
|
679
|
+
throw new F("CAPTCHA.INVALID_CAPTCHA_ID", {
|
|
681
680
|
context: { error: "No datasetId set for challenge" }
|
|
682
681
|
});
|
|
683
|
-
const
|
|
684
|
-
if (
|
|
685
|
-
submission:
|
|
686
|
-
isHuman:
|
|
682
|
+
const k = G(), M = await k.submitCaptchaSolution(O, c.requestHash, D.captcha.datasetId, h, p), $ = M[0].verified;
|
|
683
|
+
if ($ || a.onFailed(), o({
|
|
684
|
+
submission: M,
|
|
685
|
+
isHuman: $,
|
|
687
686
|
loading: !1
|
|
688
687
|
}), e.isHuman) {
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
providerUrl:
|
|
692
|
-
user:
|
|
693
|
-
dapp:
|
|
694
|
-
commitmentId:
|
|
688
|
+
const S = re(k.provider.provider.url.toString());
|
|
689
|
+
z.setProcaptchaStorage({ ...z.getProcaptchaStorage(), providerUrl: S, blockNumber: C }), a.onHuman({
|
|
690
|
+
providerUrl: S,
|
|
691
|
+
user: w.account.address,
|
|
692
|
+
dapp: N(),
|
|
693
|
+
commitmentId: ue(M[1]),
|
|
695
694
|
blockNumber: C
|
|
696
|
-
}),
|
|
695
|
+
}), j();
|
|
697
696
|
}
|
|
698
697
|
});
|
|
699
698
|
}, I = async () => {
|
|
700
|
-
|
|
701
|
-
}, m = (
|
|
699
|
+
U(), _(), a.onClose();
|
|
700
|
+
}, m = (c) => {
|
|
702
701
|
if (!e.challenge)
|
|
703
|
-
throw new
|
|
702
|
+
throw new P("CAPTCHA.NO_CAPTCHA", {
|
|
704
703
|
context: { error: "Cannot select, no Captcha found in state" }
|
|
705
704
|
});
|
|
706
705
|
if (e.index >= e.challenge.captchas.length || e.index < 0)
|
|
707
|
-
throw new
|
|
706
|
+
throw new P("CAPTCHA.NO_CAPTCHA", {
|
|
708
707
|
context: { error: "Cannot select, index is out of range for this Captcha" }
|
|
709
708
|
});
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
},
|
|
709
|
+
const p = e.index, h = e.solutions, w = g(h, p);
|
|
710
|
+
w.includes(c) ? w.splice(w.indexOf(c), 1) : w.push(c), o({ solutions: h });
|
|
711
|
+
}, L = () => {
|
|
713
712
|
if (!e.challenge)
|
|
714
|
-
throw new
|
|
713
|
+
throw new P("CAPTCHA.NO_CAPTCHA", {
|
|
715
714
|
context: { error: "Cannot select, no Captcha found in state" }
|
|
716
715
|
});
|
|
717
716
|
if (e.index + 1 >= e.challenge.captchas.length)
|
|
718
|
-
throw new
|
|
717
|
+
throw new P("CAPTCHA.NO_CAPTCHA", {
|
|
719
718
|
context: { error: "Cannot select, index is out of range for this Captcha" }
|
|
720
719
|
});
|
|
721
720
|
o({ index: e.index + 1 });
|
|
722
|
-
},
|
|
723
|
-
const
|
|
724
|
-
return o({ captchaApi: C }),
|
|
725
|
-
},
|
|
726
|
-
const
|
|
727
|
-
if (!
|
|
721
|
+
}, H = async (c, p, h) => {
|
|
722
|
+
const w = i(), C = new Gt(y().account.address, c, p, h, w.web2, N());
|
|
723
|
+
return o({ captchaApi: C }), G();
|
|
724
|
+
}, W = async (c) => {
|
|
725
|
+
const p = i(), h = ye(p);
|
|
726
|
+
if (!p.account.address)
|
|
728
727
|
throw new v("GENERAL.SITE_KEY_MISSING");
|
|
729
|
-
return new
|
|
730
|
-
},
|
|
728
|
+
return new rt(h, c, p.account.address);
|
|
729
|
+
}, U = () => {
|
|
731
730
|
window.clearTimeout(e.timeout), o({ timeout: void 0 });
|
|
732
|
-
}, W = () => {
|
|
733
|
-
const i = t.challengeValidLength || 12e4, u = setTimeout(() => {
|
|
734
|
-
o({ isHuman: !1 }), a.onExpired();
|
|
735
|
-
}, i);
|
|
736
|
-
o({ successfullChallengeTimeout: u });
|
|
737
|
-
}, L = () => {
|
|
738
|
-
M(), o(Bt());
|
|
739
731
|
}, j = () => {
|
|
732
|
+
const c = t.challengeValidLength || 12e4, p = setTimeout(() => {
|
|
733
|
+
o({ isHuman: !1 }), a.onExpired();
|
|
734
|
+
}, c);
|
|
735
|
+
o({ successfullChallengeTimeout: p });
|
|
736
|
+
}, _ = () => {
|
|
737
|
+
U(), o(Bt());
|
|
738
|
+
}, G = () => {
|
|
740
739
|
if (!e.captchaApi)
|
|
741
|
-
throw new
|
|
740
|
+
throw new ae("API.UNKNOWN", { context: { error: "Captcha api not set", state: e } });
|
|
742
741
|
return e.captchaApi;
|
|
743
742
|
}, Y = async () => {
|
|
744
|
-
const
|
|
745
|
-
if (!
|
|
743
|
+
const c = i();
|
|
744
|
+
if (!c.web2 && !c.userAccountAddress)
|
|
746
745
|
throw new v("GENERAL.ACCOUNT_NOT_FOUND", {
|
|
747
746
|
context: { error: "Account address has not been set for web3 mode" }
|
|
748
747
|
});
|
|
749
|
-
const h = await (
|
|
750
|
-
return
|
|
751
|
-
},
|
|
748
|
+
const h = await (c.web2 ? new ot() : new Dt()).getAccount(c);
|
|
749
|
+
return z.setAccount(h.account.address), o({ account: h }), y();
|
|
750
|
+
}, y = () => {
|
|
752
751
|
if (!e.account)
|
|
753
752
|
throw new v("GENERAL.ACCOUNT_NOT_FOUND", { context: { error: "Account not loaded" } });
|
|
754
753
|
return e.account;
|
|
755
|
-
},
|
|
754
|
+
}, N = () => {
|
|
756
755
|
if (!e.dappAccount)
|
|
757
756
|
throw new v("GENERAL.SITE_KEY_MISSING");
|
|
758
757
|
return e.dappAccount;
|
|
759
|
-
},
|
|
758
|
+
}, R = () => {
|
|
760
759
|
if (!e.blockNumber)
|
|
761
|
-
throw new
|
|
760
|
+
throw new at("CAPTCHA.INVALID_BLOCK_NO", { context: { error: "Block number not found" } });
|
|
762
761
|
return e.blockNumber;
|
|
763
|
-
}, A = (
|
|
764
|
-
if (
|
|
762
|
+
}, A = (c) => {
|
|
763
|
+
if (c = c || y(), !c.extension)
|
|
765
764
|
throw new v("ACCOUNT.NO_POLKADOT_EXTENSION", { context: { error: "Extension not loaded" } });
|
|
766
|
-
return
|
|
765
|
+
return c.extension;
|
|
767
766
|
}, x = async () => {
|
|
768
|
-
const
|
|
769
|
-
provider: new
|
|
767
|
+
const c = i(), p = ye(c), h = await st.create({
|
|
768
|
+
provider: new ct(p.endpoint),
|
|
770
769
|
initWasm: !1,
|
|
771
770
|
noInitWarn: !0
|
|
772
|
-
}),
|
|
773
|
-
return new
|
|
771
|
+
}), w = "sr25519", C = new it({ type: w, ss58Format: h.registry.chainSS58 });
|
|
772
|
+
return new lt(h, JSON.parse(ut), p.contract.address, "prosopo", 0, C.addFromAddress(y().account.address));
|
|
774
773
|
};
|
|
775
774
|
return {
|
|
776
|
-
start:
|
|
775
|
+
start: d,
|
|
777
776
|
cancel: I,
|
|
778
|
-
submit:
|
|
777
|
+
submit: b,
|
|
779
778
|
select: m,
|
|
780
|
-
nextRound:
|
|
781
|
-
exportData: async (
|
|
782
|
-
var
|
|
783
|
-
const
|
|
784
|
-
let
|
|
785
|
-
if (
|
|
786
|
-
|
|
779
|
+
nextRound: L,
|
|
780
|
+
exportData: async (c) => {
|
|
781
|
+
var D;
|
|
782
|
+
const h = z.getProcaptchaStorage().providerUrl;
|
|
783
|
+
let w;
|
|
784
|
+
if (h)
|
|
785
|
+
w = await W(h);
|
|
787
786
|
else {
|
|
788
|
-
const
|
|
789
|
-
|
|
787
|
+
const k = await x(), M = await pe(k.query.getRandomActiveProvider, k.query)(y().account.address, N()), $ = re(M.provider.url.toString());
|
|
788
|
+
w = await W($);
|
|
790
789
|
}
|
|
791
|
-
if (!(
|
|
790
|
+
if (!(z.getProcaptchaStorage().providerUrl || ((D = e.captchaApi) == null ? void 0 : D.provider.provider.url.toString())))
|
|
792
791
|
return;
|
|
793
|
-
let
|
|
792
|
+
let O = "";
|
|
794
793
|
try {
|
|
795
|
-
|
|
796
|
-
} catch (
|
|
797
|
-
console.error(
|
|
794
|
+
O = y().account.address;
|
|
795
|
+
} catch (k) {
|
|
796
|
+
console.error(k);
|
|
798
797
|
}
|
|
799
|
-
await
|
|
798
|
+
await w.submitUserEvents(c, O);
|
|
800
799
|
}
|
|
801
800
|
};
|
|
802
801
|
}
|
|
803
|
-
const Kt = 1e4,
|
|
802
|
+
const Kt = 1e4, le = (t, e) => {
|
|
804
803
|
e((n) => {
|
|
805
804
|
let r = [...n, t];
|
|
806
805
|
return r.length > Kt && (r = r.slice(1)), r;
|
|
@@ -811,33 +810,33 @@ const Kt = 1e4, ie = (t, e) => {
|
|
|
811
810
|
y: t.y,
|
|
812
811
|
timestamp: t.timeStamp
|
|
813
812
|
};
|
|
814
|
-
|
|
815
|
-
},
|
|
813
|
+
le(n, e);
|
|
814
|
+
}, Ce = (t, e) => {
|
|
816
815
|
const n = {
|
|
817
816
|
key: t.key,
|
|
818
817
|
timestamp: t.timeStamp,
|
|
819
818
|
isShiftKey: t.shiftKey,
|
|
820
819
|
isCtrlKey: t.ctrlKey
|
|
821
820
|
};
|
|
822
|
-
|
|
821
|
+
le(n, e);
|
|
823
822
|
}, q = (t, e) => {
|
|
824
823
|
for (const n of Array.from(t.touches))
|
|
825
|
-
|
|
824
|
+
le({ x: n.clientX, y: n.clientY, timestamp: t.timeStamp }, e);
|
|
826
825
|
}, Yt = (t, e, n, r) => {
|
|
827
|
-
const a =
|
|
828
|
-
a && (a.addEventListener("mousemove", (s) => Vt(s, t)), a.addEventListener("keydown", (s) =>
|
|
829
|
-
},
|
|
830
|
-
const [r, a] = f.useState([]), [s, o] = f.useState([]), [
|
|
826
|
+
const a = Se(r);
|
|
827
|
+
a && (a.addEventListener("mousemove", (s) => Vt(s, t)), a.addEventListener("keydown", (s) => Ce(s, n)), a.addEventListener("keyup", (s) => Ce(s, n)), a.addEventListener("touchstart", (s) => q(s, e)), a.addEventListener("touchend", (s) => q(s, e)), a.addEventListener("touchcancel", (s) => q(s, e)), a.addEventListener("touchmove", (s) => q(s, e)));
|
|
828
|
+
}, Se = (t) => t.tagName === "FORM" ? t : t.parentElement ? Se(t.parentElement) : null, Xt = ({ onProcessData: t, sendData: e, account: n }) => {
|
|
829
|
+
const [r, a] = f.useState([]), [s, o] = f.useState([]), [i, l] = f.useState([]), d = f.useRef(null);
|
|
831
830
|
return f.useEffect(() => {
|
|
832
|
-
|
|
831
|
+
d && d.current && Yt(a, o, l, d.current);
|
|
833
832
|
}, []), f.useEffect(() => {
|
|
834
833
|
n && t({
|
|
835
834
|
mouseEvents: r,
|
|
836
835
|
touchEvents: s,
|
|
837
|
-
keyboardEvents:
|
|
836
|
+
keyboardEvents: i
|
|
838
837
|
});
|
|
839
|
-
}, [e, n]),
|
|
840
|
-
}, qt = Xt, Jt =
|
|
838
|
+
}, [e, n]), u("div", { ref: d });
|
|
839
|
+
}, qt = Xt, Jt = Pe.memo((t, e) => {
|
|
841
840
|
const { show: n, children: r } = t, s = {
|
|
842
841
|
position: "fixed",
|
|
843
842
|
zIndex: 2147483646,
|
|
@@ -854,7 +853,7 @@ const Kt = 1e4, ie = (t, e) => {
|
|
|
854
853
|
left: 0,
|
|
855
854
|
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
856
855
|
zIndex: -1
|
|
857
|
-
},
|
|
856
|
+
}, i = {
|
|
858
857
|
position: "absolute",
|
|
859
858
|
top: "50%",
|
|
860
859
|
left: "50%",
|
|
@@ -864,22 +863,22 @@ const Kt = 1e4, ie = (t, e) => {
|
|
|
864
863
|
border: "none",
|
|
865
864
|
boxShadow: "rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px,"
|
|
866
865
|
};
|
|
867
|
-
return E("div", { className: "modalOuter", style: s, children: [
|
|
866
|
+
return E("div", { className: "modalOuter", style: s, children: [u("div", { className: "modalBackground", style: o }), u("div", { className: "modalInner", style: i, children: r })] });
|
|
868
867
|
}), Qt = Jt, tn = (t) => {
|
|
869
|
-
const e = t.config, n = t.callbacks || {}, [r, a] =
|
|
870
|
-
return
|
|
871
|
-
padding:
|
|
872
|
-
border:
|
|
873
|
-
backgroundColor:
|
|
874
|
-
borderColor:
|
|
868
|
+
const e = t.config, n = t.callbacks || {}, [r, a] = dt(f.useState, f.useRef), s = $t(e, r, a, n), o = t.config.theme === "light" ? "light" : "dark", i = t.config.theme === "light" ? Q : Z;
|
|
869
|
+
return u("div", { children: E("div", { style: { maxWidth: "100%", maxHeight: "100%", overflowX: "auto" }, children: [u(Qt, { show: r.showModal, children: r.challenge ? u(St, { challenge: r.challenge, index: r.index, solutions: r.solutions, onSubmit: s.submit, onCancel: s.cancel, onClick: s.select, onNext: s.nextRound, themeColor: e.theme ?? "light" }) : u("div", { children: "No challenge set." }) }), E(Oe, { children: [u(De, { children: E("div", { style: ke, "data-cy": "button-human", children: [" ", E("div", { style: {
|
|
870
|
+
padding: Le,
|
|
871
|
+
border: He,
|
|
872
|
+
backgroundColor: i.palette.background.default,
|
|
873
|
+
borderColor: i.palette.grey[300],
|
|
875
874
|
borderRadius: _e,
|
|
876
875
|
display: "flex",
|
|
877
876
|
alignItems: "center",
|
|
878
877
|
flexWrap: "wrap",
|
|
879
878
|
justifyContent: "space-between",
|
|
880
|
-
minHeight: `${
|
|
879
|
+
minHeight: `${Re}px`,
|
|
881
880
|
overflow: "hidden"
|
|
882
|
-
}, children: [
|
|
881
|
+
}, children: [u("div", { style: { display: "inline-flex", flexDirection: "column" }, children: u("div", { style: {
|
|
883
882
|
alignItems: "center",
|
|
884
883
|
flex: 1
|
|
885
884
|
}, children: E("div", { style: {
|
|
@@ -888,11 +887,11 @@ const Kt = 1e4, ie = (t, e) => {
|
|
|
888
887
|
justifyContent: "center",
|
|
889
888
|
flexDirection: "column",
|
|
890
889
|
verticalAlign: "middle"
|
|
891
|
-
}, children: [
|
|
890
|
+
}, children: [u("div", { style: {
|
|
892
891
|
display: r.loading ? "none" : "flex"
|
|
893
|
-
}, children:
|
|
892
|
+
}, children: u(pt, { themeColor: o, onChange: s.start, checked: r.isHuman, labelText: "I am human" }) }), u("div", { style: {
|
|
894
893
|
display: r.loading ? "flex" : "none"
|
|
895
|
-
}, children:
|
|
894
|
+
}, children: u("div", { style: { display: "inline-flex" }, children: u(Me, { themeColor: o }) }) })] }) }) }), u("div", { style: { display: "inline-flex", flexDirection: "column" }, children: u("a", { href: We, target: "_blank", "aria-label": Ue, children: u("div", { style: { flex: 1 }, children: u(je, { themeColor: o }) }) }) })] })] }) }), e.devOnlyWatchEvents && u(qt, { onProcessData: s.exportData, sendData: r.sendData, account: r.account })] })] }) });
|
|
896
895
|
};
|
|
897
896
|
export {
|
|
898
897
|
tn as default
|