@prosopo/procaptcha-bundle 0.3.5 → 0.3.37
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-Cv4jnpZb.js} +23 -22
- package/dist/bundle/{ProcaptchaWidget-DDAodo6R.js → ProcaptchaWidget-O71j1WKI.js} +353 -356
- package/dist/bundle/{index-HgeMtpKw.js → index-ChKfVXCq.js} +161 -157
- package/dist/bundle/procaptcha.bundle.js +1 -1
- package/dist/bundle/{utils-CfklpKIj.js → utils-C0DFj2UN.js} +11703 -11641
- package/dist/cjs/account/dist/extension/ExtensionWeb2.cjs +1 -1
- package/dist/cjs/procaptcha-pow/dist/Services/Manager.cjs +3 -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 I, 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-ChKfVXCq.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 O, f as ae, h as A, 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-C0DFj2UN.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 w = e.services.backendConnector.state["".concat(l, "|").concat(
|
|
39
|
+
var o = function(l, d) {
|
|
40
|
+
var w = e.services.backendConnector.state["".concat(l, "|").concat(d)];
|
|
36
41
|
return w === -1 || w === 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
69
|
} catch (w) {
|
|
65
|
-
|
|
70
|
+
d = !0, a = w;
|
|
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
|
-
return Array.isArray(
|
|
114
|
-
}, l = [
|
|
115
|
-
return l.t =
|
|
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(v) {
|
|
118
|
+
return Array.isArray(v) ? v[v.length - 1] : v;
|
|
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
|
|
119
|
-
|
|
120
|
-
var
|
|
121
|
-
return
|
|
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), w = d.useSuspense, N = d.keyPrefix, b = t || s || o.options && o.options.defaultNS;
|
|
124
|
+
b = typeof b == "string" ? [b] : b || ["translation"], o.reportNamespaces.addUsedNamespaces && o.reportNamespaces.addUsedNamespaces(b);
|
|
125
|
+
var x = (o.isInitialized || o.initializedStoreOnce) && b.every(function(E) {
|
|
126
|
+
return gt(E, o, d);
|
|
122
127
|
});
|
|
123
|
-
function
|
|
124
|
-
return o.getFixedT(null,
|
|
128
|
+
function H() {
|
|
129
|
+
return o.getFixedT(null, d.nsMode === "fallback" ? b : b[0], N);
|
|
125
130
|
}
|
|
126
|
-
var
|
|
131
|
+
var W = f.useState(H), U = wt(W, 2), j = U[0], _ = U[1], G = b.join(), Y = bt(G), y = f.useRef(!0);
|
|
127
132
|
f.useEffect(function() {
|
|
128
|
-
var
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}),
|
|
133
|
+
var E = d.bindI18n, v = d.bindI18nStore;
|
|
134
|
+
y.current = !0, !x && !w && fe(o, b, function() {
|
|
135
|
+
y.current && _(H);
|
|
136
|
+
}), x && Y && Y !== G && y.current && _(H);
|
|
132
137
|
function B() {
|
|
133
|
-
|
|
138
|
+
y.current && _(H);
|
|
134
139
|
}
|
|
135
|
-
return
|
|
136
|
-
|
|
137
|
-
return o.off(
|
|
138
|
-
}),
|
|
139
|
-
return o.store.off(
|
|
140
|
+
return E && o && o.on(E, B), v && o && o.store.on(v, B), function() {
|
|
141
|
+
y.current = !1, E && o && E.split(" ").forEach(function(c) {
|
|
142
|
+
return o.off(c, B);
|
|
143
|
+
}), v && o && v.split(" ").forEach(function(c) {
|
|
144
|
+
return o.store.off(c, B);
|
|
140
145
|
});
|
|
141
146
|
};
|
|
142
|
-
}, [o,
|
|
143
|
-
var
|
|
147
|
+
}, [o, G]);
|
|
148
|
+
var S = f.useRef(!0);
|
|
144
149
|
f.useEffect(function() {
|
|
145
|
-
|
|
146
|
-
}, [o,
|
|
147
|
-
var
|
|
148
|
-
if (
|
|
149
|
-
return
|
|
150
|
-
throw new Promise(function(
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
y.current && !S.current && _(H), S.current = !1;
|
|
151
|
+
}, [o, N]);
|
|
152
|
+
var R = [j, o, x];
|
|
153
|
+
if (R.t = j, R.i18n = o, R.ready = x, x || !x && !w)
|
|
154
|
+
return R;
|
|
155
|
+
throw new Promise(function(E) {
|
|
156
|
+
fe(o, b, function() {
|
|
157
|
+
E();
|
|
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:
|
|
186
|
+
}, children: I("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, w = n ? g(n, e) : [], N = 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%",
|
|
@@ -278,43 +283,43 @@ const vt = {
|
|
|
278
283
|
maxHeight: "100%",
|
|
279
284
|
display: "flex",
|
|
280
285
|
flexDirection: "column"
|
|
281
|
-
}, children:
|
|
282
|
-
backgroundColor:
|
|
286
|
+
}, children: I("div", { style: {
|
|
287
|
+
backgroundColor: N.palette.background.default,
|
|
283
288
|
display: "flex",
|
|
284
289
|
flexDirection: "column",
|
|
285
290
|
minWidth: "300px"
|
|
286
|
-
}, children: [
|
|
291
|
+
}, children: [I("div", { style: {
|
|
287
292
|
display: "flex",
|
|
288
293
|
alignItems: "center",
|
|
289
294
|
width: "100%",
|
|
290
|
-
backgroundColor:
|
|
295
|
+
backgroundColor: N.palette.primary.main,
|
|
291
296
|
padding: "24px 16px"
|
|
292
|
-
}, children: [
|
|
297
|
+
}, children: [I("p", { style: {
|
|
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: w, 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%"
|
|
310
|
-
} }),
|
|
315
|
+
} }), I("div", { style: {
|
|
311
316
|
padding: "0 16px 16px",
|
|
312
317
|
display: "flex",
|
|
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,99 +327,99 @@ 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 O("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 O("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 O("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();
|
|
371
376
|
return new Uint8Array(n);
|
|
372
377
|
} catch (e) {
|
|
373
|
-
throw new
|
|
378
|
+
throw new A("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 O("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 O("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;
|
|
@@ -498,70 +503,68 @@ class Ut {
|
|
|
498
503
|
});
|
|
499
504
|
}), e;
|
|
500
505
|
} catch (e) {
|
|
501
|
-
throw new
|
|
506
|
+
throw new A("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", { context: { error: e } });
|
|
502
507
|
}
|
|
503
508
|
}
|
|
504
509
|
verifyCaptchaChallengeContent(e, n) {
|
|
505
510
|
const r = g(n.captchas, 0), a = r.proof.length, s = g(r.proof, a - 1);
|
|
506
511
|
if (e.provider.datasetIdContent.toString() !== g(s, 0))
|
|
507
|
-
throw new
|
|
512
|
+
throw new A("CAPTCHA.INVALID_DATASET_CONTENT_ID");
|
|
508
513
|
for (const o of n.captchas) {
|
|
509
|
-
if (!
|
|
510
|
-
throw new
|
|
511
|
-
if (!
|
|
512
|
-
throw new
|
|
514
|
+
if (!jt(o))
|
|
515
|
+
throw new A("CAPTCHA.INVALID_CAPTCHA_CHALLENGE");
|
|
516
|
+
if (!Wt(o.captcha.captchaContentId, o.proof))
|
|
517
|
+
throw new A("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,
|
|
521
|
+
const o = new Mt(), i = a.map((x) => Rt(x));
|
|
522
|
+
o.build(i);
|
|
523
|
+
const l = o.root.hash, d = void 0;
|
|
519
524
|
let w;
|
|
520
|
-
if (
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
}
|
|
531
|
-
let I;
|
|
525
|
+
if (!e || !e.signRaw)
|
|
526
|
+
throw new A("GENERAL.CANT_FIND_KEYRINGPAIR", {
|
|
527
|
+
context: { error: "Signer is not defined, cannot sign message to prove account ownership" }
|
|
528
|
+
});
|
|
529
|
+
let N;
|
|
530
|
+
w = (await e.signRaw({
|
|
531
|
+
address: this.userAccount,
|
|
532
|
+
data: xe(n),
|
|
533
|
+
type: "bytes"
|
|
534
|
+
})).signature;
|
|
532
535
|
try {
|
|
533
|
-
|
|
534
|
-
} catch (
|
|
535
|
-
throw new
|
|
536
|
+
N = await this.providerApi.submitCaptchaSolution(a, n, this.contract.pair.address, s, w);
|
|
537
|
+
} catch (x) {
|
|
538
|
+
throw new F("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", { context: { error: x } });
|
|
536
539
|
}
|
|
537
|
-
return [
|
|
540
|
+
return [N, l, d];
|
|
538
541
|
}
|
|
539
542
|
}
|
|
540
|
-
async function
|
|
543
|
+
async function jt(t) {
|
|
541
544
|
const e = t.captcha, n = t.proof;
|
|
542
|
-
if (!(await Promise.all(e.items.map(async (a) => (await
|
|
545
|
+
if (!(await Promise.all(e.items.map(async (a) => (await _t(a)).hash === a.hash))).every((a) => a === !0))
|
|
543
546
|
return !1;
|
|
544
|
-
const r =
|
|
547
|
+
const r = Ee(e, !1, !1, !1);
|
|
545
548
|
return r !== e.captchaContentId ? !1 : g(n, 0).indexOf(r) !== -1;
|
|
546
549
|
}
|
|
547
|
-
const
|
|
548
|
-
function
|
|
549
|
-
localStorage.
|
|
550
|
+
const Gt = Ut, Ie = "@prosopo/procaptcha";
|
|
551
|
+
function ie() {
|
|
552
|
+
return ve.parse(JSON.parse(Qe(localStorage.getItem(Ie) || "0x7b7d")));
|
|
550
553
|
}
|
|
551
|
-
function
|
|
552
|
-
|
|
554
|
+
function Ne(t) {
|
|
555
|
+
localStorage.setItem(Ie, xe(JSON.stringify(ve.parse(t))));
|
|
553
556
|
}
|
|
554
|
-
function
|
|
555
|
-
|
|
557
|
+
function zt(t) {
|
|
558
|
+
Ne({ ...ie(), account: t });
|
|
556
559
|
}
|
|
557
|
-
function
|
|
558
|
-
return
|
|
560
|
+
function Ft() {
|
|
561
|
+
return ie().account || null;
|
|
559
562
|
}
|
|
560
|
-
const
|
|
561
|
-
setAccount:
|
|
562
|
-
getAccount:
|
|
563
|
-
|
|
564
|
-
|
|
563
|
+
const z = {
|
|
564
|
+
setAccount: zt,
|
|
565
|
+
getAccount: Ft,
|
|
566
|
+
setProcaptchaStorage: Ne,
|
|
567
|
+
getProcaptchaStorage: ie
|
|
565
568
|
}, Bt = () => ({
|
|
566
569
|
showModal: !1,
|
|
567
570
|
loading: !1,
|
|
@@ -571,236 +574,230 @@ const K = {
|
|
|
571
574
|
isHuman: !1,
|
|
572
575
|
captchaApi: void 0,
|
|
573
576
|
account: void 0
|
|
574
|
-
}),
|
|
577
|
+
}), ye = (t) => {
|
|
575
578
|
const e = t.networks[t.defaultNetwork];
|
|
576
579
|
if (!e)
|
|
577
|
-
throw new
|
|
580
|
+
throw new A("DEVELOPER.NETWORK_NOT_FOUND", {
|
|
578
581
|
context: { error: `No network found for environment ${t.defaultEnvironment}` }
|
|
579
582
|
});
|
|
580
583
|
return e;
|
|
581
584
|
};
|
|
582
585
|
function $t(t, e, n, r) {
|
|
583
|
-
const a =
|
|
584
|
-
const
|
|
585
|
-
a.onError(
|
|
586
|
-
}, o =
|
|
587
|
-
const
|
|
586
|
+
const a = Ze(n, e, r), s = (c) => {
|
|
587
|
+
const p = c instanceof Error ? c : new Error(String(c));
|
|
588
|
+
a.onError(p);
|
|
589
|
+
}, o = et(e, n), i = () => {
|
|
590
|
+
const c = {
|
|
588
591
|
userAccountAddress: "",
|
|
589
592
|
...t
|
|
590
593
|
};
|
|
591
|
-
return e.account && (
|
|
592
|
-
}, l = async (
|
|
594
|
+
return e.account && (c.userAccountAddress = e.account.account.address), Te.parse(c);
|
|
595
|
+
}, l = async (c) => {
|
|
593
596
|
try {
|
|
594
|
-
await
|
|
595
|
-
} catch (
|
|
596
|
-
console.error(
|
|
597
|
+
await c();
|
|
598
|
+
} catch (p) {
|
|
599
|
+
console.error(p), s(p), o({ isHuman: !1, showModal: !1, loading: !1 });
|
|
597
600
|
}
|
|
598
|
-
},
|
|
601
|
+
}, d = async () => {
|
|
599
602
|
a.onOpen(), await l(async () => {
|
|
600
603
|
if (e.loading || e.isHuman)
|
|
601
604
|
return;
|
|
602
|
-
|
|
603
|
-
const
|
|
604
|
-
o({ dappAccount:
|
|
605
|
-
const
|
|
606
|
-
let
|
|
605
|
+
_(), o({ loading: !0 });
|
|
606
|
+
const c = i();
|
|
607
|
+
o({ dappAccount: c.account.address }), await tt(100);
|
|
608
|
+
const p = await Y(), h = await v();
|
|
609
|
+
let m = !1;
|
|
607
610
|
try {
|
|
608
|
-
|
|
609
|
-
} catch (
|
|
611
|
+
m = (await h.query.dappOperatorIsHumanUser(p.account.address, c.solutionThreshold)).value.unwrap().unwrap();
|
|
612
|
+
} catch (P) {
|
|
610
613
|
}
|
|
611
|
-
if (
|
|
614
|
+
if (m) {
|
|
612
615
|
o({ isHuman: !0, loading: !1 }), a.onHuman({
|
|
613
|
-
user:
|
|
614
|
-
dapp:
|
|
615
|
-
}),
|
|
616
|
+
user: p.account.address,
|
|
617
|
+
dapp: S()
|
|
618
|
+
}), j();
|
|
616
619
|
return;
|
|
617
620
|
}
|
|
618
|
-
const C =
|
|
619
|
-
let
|
|
620
|
-
if (C) {
|
|
621
|
-
|
|
621
|
+
const C = z.getProcaptchaStorage();
|
|
622
|
+
let D;
|
|
623
|
+
if (C.providerUrl && C.blockNumber) {
|
|
624
|
+
D = await W(C.providerUrl);
|
|
622
625
|
try {
|
|
623
|
-
const
|
|
624
|
-
if (
|
|
626
|
+
const P = await D.verifyDappUser(S(), p.account.address, C.blockNumber, void 0, t.challengeValidLength);
|
|
627
|
+
if (P.verified) {
|
|
625
628
|
o({ isHuman: !0, loading: !1 });
|
|
626
|
-
const
|
|
627
|
-
[
|
|
628
|
-
[
|
|
629
|
-
[
|
|
630
|
-
[
|
|
631
|
-
[
|
|
629
|
+
const ne = {
|
|
630
|
+
[K.providerUrl]: C.providerUrl,
|
|
631
|
+
[K.user]: p.account.address,
|
|
632
|
+
[K.dapp]: S(),
|
|
633
|
+
[K.commitmentId]: ue(P.commitmentId),
|
|
634
|
+
[K.blockNumber]: P.blockNumber
|
|
632
635
|
};
|
|
633
|
-
a.onHuman(
|
|
636
|
+
a.onHuman(ne), j();
|
|
634
637
|
return;
|
|
635
638
|
}
|
|
636
639
|
} catch {
|
|
637
|
-
console.error("Error contacting provider from storage", C);
|
|
640
|
+
console.error("Error contacting provider from storage", C.providerUrl);
|
|
638
641
|
}
|
|
639
642
|
}
|
|
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(() => {
|
|
643
|
+
const k = await pe(h.query.getRandomActiveProvider, h.query)(p.account.address, S()), L = parseInt(k.blockNumber.toString()), M = re(k.provider.url.toString());
|
|
644
|
+
D = await W(M);
|
|
645
|
+
const T = await (await H(h, k, D)).getCaptchaChallenge();
|
|
646
|
+
if (T.captchas.length <= 0)
|
|
647
|
+
throw new ae("DEVELOPER.PROVIDER_NO_CAPTCHA");
|
|
648
|
+
const ee = T.captchas.map((P) => P.captcha.timeLimitMs || 30 * 1e3).reduce((P, ne) => P + ne), te = setTimeout(() => {
|
|
652
649
|
a.onChallengeExpired(), o({ isHuman: !1, showModal: !1, loading: !1 });
|
|
653
650
|
}, ee);
|
|
654
651
|
o({
|
|
655
652
|
index: 0,
|
|
656
|
-
solutions:
|
|
657
|
-
challenge:
|
|
653
|
+
solutions: T.captchas.map(() => []),
|
|
654
|
+
challenge: T,
|
|
658
655
|
showModal: !0,
|
|
659
|
-
timeout:
|
|
660
|
-
blockNumber:
|
|
656
|
+
timeout: te,
|
|
657
|
+
blockNumber: L
|
|
661
658
|
});
|
|
662
659
|
});
|
|
663
660
|
}, w = async () => {
|
|
664
661
|
await l(async () => {
|
|
665
|
-
if (
|
|
666
|
-
throw new
|
|
662
|
+
if (U(), !e.challenge)
|
|
663
|
+
throw new O("CAPTCHA.NO_CAPTCHA", {
|
|
667
664
|
context: { error: "Cannot submit, no Captcha found in state" }
|
|
668
665
|
});
|
|
669
666
|
o({ showModal: !1 });
|
|
670
|
-
const
|
|
671
|
-
const
|
|
667
|
+
const c = e.challenge, p = nt(), h = e.challenge.captchas.map((T, ee) => {
|
|
668
|
+
const te = g(e.solutions, ee);
|
|
672
669
|
return {
|
|
673
|
-
captchaId:
|
|
674
|
-
captchaContentId:
|
|
675
|
-
salt:
|
|
676
|
-
solution:
|
|
670
|
+
captchaId: T.captcha.captchaId,
|
|
671
|
+
captchaContentId: T.captcha.captchaContentId,
|
|
672
|
+
salt: p,
|
|
673
|
+
solution: te
|
|
677
674
|
};
|
|
678
|
-
}),
|
|
679
|
-
if (!
|
|
680
|
-
throw new
|
|
675
|
+
}), m = y(), C = R(), D = E(m).signer, k = g(c.captchas, 0);
|
|
676
|
+
if (!k.captcha.datasetId)
|
|
677
|
+
throw new F("CAPTCHA.INVALID_CAPTCHA_ID", {
|
|
681
678
|
context: { error: "No datasetId set for challenge" }
|
|
682
679
|
});
|
|
683
|
-
const
|
|
684
|
-
if (
|
|
685
|
-
submission:
|
|
686
|
-
isHuman:
|
|
680
|
+
const L = G(), M = await L.submitCaptchaSolution(D, c.requestHash, k.captcha.datasetId, h, p), $ = M[0].verified;
|
|
681
|
+
if ($ || a.onFailed(), o({
|
|
682
|
+
submission: M,
|
|
683
|
+
isHuman: $,
|
|
687
684
|
loading: !1
|
|
688
685
|
}), e.isHuman) {
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
providerUrl:
|
|
692
|
-
user:
|
|
693
|
-
dapp:
|
|
694
|
-
commitmentId:
|
|
686
|
+
const T = re(L.provider.provider.url.toString());
|
|
687
|
+
z.setProcaptchaStorage({ ...z.getProcaptchaStorage(), providerUrl: T, blockNumber: C }), a.onHuman({
|
|
688
|
+
providerUrl: T,
|
|
689
|
+
user: m.account.address,
|
|
690
|
+
dapp: S(),
|
|
691
|
+
commitmentId: ue(M[1]),
|
|
695
692
|
blockNumber: C
|
|
696
|
-
}),
|
|
693
|
+
}), j();
|
|
697
694
|
}
|
|
698
695
|
});
|
|
699
|
-
},
|
|
700
|
-
|
|
701
|
-
},
|
|
696
|
+
}, N = async () => {
|
|
697
|
+
U(), _(), a.onClose();
|
|
698
|
+
}, b = (c) => {
|
|
702
699
|
if (!e.challenge)
|
|
703
|
-
throw new
|
|
700
|
+
throw new O("CAPTCHA.NO_CAPTCHA", {
|
|
704
701
|
context: { error: "Cannot select, no Captcha found in state" }
|
|
705
702
|
});
|
|
706
703
|
if (e.index >= e.challenge.captchas.length || e.index < 0)
|
|
707
|
-
throw new
|
|
704
|
+
throw new O("CAPTCHA.NO_CAPTCHA", {
|
|
708
705
|
context: { error: "Cannot select, index is out of range for this Captcha" }
|
|
709
706
|
});
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
},
|
|
707
|
+
const p = e.index, h = e.solutions, m = g(h, p);
|
|
708
|
+
m.includes(c) ? m.splice(m.indexOf(c), 1) : m.push(c), o({ solutions: h });
|
|
709
|
+
}, x = () => {
|
|
713
710
|
if (!e.challenge)
|
|
714
|
-
throw new
|
|
711
|
+
throw new O("CAPTCHA.NO_CAPTCHA", {
|
|
715
712
|
context: { error: "Cannot select, no Captcha found in state" }
|
|
716
713
|
});
|
|
717
714
|
if (e.index + 1 >= e.challenge.captchas.length)
|
|
718
|
-
throw new
|
|
715
|
+
throw new O("CAPTCHA.NO_CAPTCHA", {
|
|
719
716
|
context: { error: "Cannot select, index is out of range for this Captcha" }
|
|
720
717
|
});
|
|
721
718
|
o({ index: e.index + 1 });
|
|
722
|
-
},
|
|
723
|
-
const
|
|
724
|
-
return o({ captchaApi: C }),
|
|
725
|
-
},
|
|
726
|
-
const
|
|
727
|
-
if (!
|
|
728
|
-
throw new
|
|
729
|
-
return new
|
|
730
|
-
},
|
|
719
|
+
}, H = async (c, p, h) => {
|
|
720
|
+
const m = i(), C = new Gt(y().account.address, c, p, h, m.web2, S());
|
|
721
|
+
return o({ captchaApi: C }), G();
|
|
722
|
+
}, W = async (c) => {
|
|
723
|
+
const p = i(), h = ye(p);
|
|
724
|
+
if (!p.account.address)
|
|
725
|
+
throw new A("GENERAL.SITE_KEY_MISSING");
|
|
726
|
+
return new rt(h, c, p.account.address);
|
|
727
|
+
}, U = () => {
|
|
731
728
|
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
729
|
}, j = () => {
|
|
730
|
+
const c = t.challengeValidLength || 12e4, p = setTimeout(() => {
|
|
731
|
+
o({ isHuman: !1 }), a.onExpired();
|
|
732
|
+
}, c);
|
|
733
|
+
o({ successfullChallengeTimeout: p });
|
|
734
|
+
}, _ = () => {
|
|
735
|
+
U(), o(Bt());
|
|
736
|
+
}, G = () => {
|
|
740
737
|
if (!e.captchaApi)
|
|
741
|
-
throw new
|
|
738
|
+
throw new ae("API.UNKNOWN", { context: { error: "Captcha api not set", state: e } });
|
|
742
739
|
return e.captchaApi;
|
|
743
740
|
}, Y = async () => {
|
|
744
|
-
const
|
|
745
|
-
if (!
|
|
746
|
-
throw new
|
|
741
|
+
const c = i();
|
|
742
|
+
if (!c.web2 && !c.userAccountAddress)
|
|
743
|
+
throw new A("GENERAL.ACCOUNT_NOT_FOUND", {
|
|
747
744
|
context: { error: "Account address has not been set for web3 mode" }
|
|
748
745
|
});
|
|
749
|
-
const h = await (
|
|
750
|
-
return
|
|
751
|
-
},
|
|
746
|
+
const h = await (c.web2 ? new ot() : new Dt()).getAccount(c);
|
|
747
|
+
return z.setAccount(h.account.address), o({ account: h }), y();
|
|
748
|
+
}, y = () => {
|
|
752
749
|
if (!e.account)
|
|
753
|
-
throw new
|
|
750
|
+
throw new A("GENERAL.ACCOUNT_NOT_FOUND", { context: { error: "Account not loaded" } });
|
|
754
751
|
return e.account;
|
|
755
|
-
},
|
|
752
|
+
}, S = () => {
|
|
756
753
|
if (!e.dappAccount)
|
|
757
|
-
throw new
|
|
754
|
+
throw new A("GENERAL.SITE_KEY_MISSING");
|
|
758
755
|
return e.dappAccount;
|
|
759
|
-
},
|
|
756
|
+
}, R = () => {
|
|
760
757
|
if (!e.blockNumber)
|
|
761
|
-
throw new
|
|
758
|
+
throw new at("CAPTCHA.INVALID_BLOCK_NO", { context: { error: "Block number not found" } });
|
|
762
759
|
return e.blockNumber;
|
|
763
|
-
},
|
|
764
|
-
if (
|
|
765
|
-
throw new
|
|
766
|
-
return
|
|
767
|
-
},
|
|
768
|
-
const
|
|
769
|
-
provider: new
|
|
760
|
+
}, E = (c) => {
|
|
761
|
+
if (c = c || y(), !c.extension)
|
|
762
|
+
throw new A("ACCOUNT.NO_POLKADOT_EXTENSION", { context: { error: "Extension not loaded" } });
|
|
763
|
+
return c.extension;
|
|
764
|
+
}, v = async () => {
|
|
765
|
+
const c = i(), p = ye(c), h = await st.create({
|
|
766
|
+
provider: new ct(p.endpoint),
|
|
770
767
|
initWasm: !1,
|
|
771
768
|
noInitWarn: !0
|
|
772
|
-
}),
|
|
773
|
-
return new
|
|
769
|
+
}), m = "sr25519", C = new it({ type: m, ss58Format: h.registry.chainSS58 });
|
|
770
|
+
return new lt(h, JSON.parse(ut), p.contract.address, "prosopo", 0, C.addFromAddress(y().account.address));
|
|
774
771
|
};
|
|
775
772
|
return {
|
|
776
|
-
start:
|
|
777
|
-
cancel:
|
|
773
|
+
start: d,
|
|
774
|
+
cancel: N,
|
|
778
775
|
submit: w,
|
|
779
|
-
select:
|
|
780
|
-
nextRound:
|
|
781
|
-
exportData: async (
|
|
782
|
-
var
|
|
783
|
-
const
|
|
784
|
-
let
|
|
785
|
-
if (
|
|
786
|
-
|
|
776
|
+
select: b,
|
|
777
|
+
nextRound: x,
|
|
778
|
+
exportData: async (c) => {
|
|
779
|
+
var k;
|
|
780
|
+
const h = z.getProcaptchaStorage().providerUrl;
|
|
781
|
+
let m;
|
|
782
|
+
if (h)
|
|
783
|
+
m = await W(h);
|
|
787
784
|
else {
|
|
788
|
-
const
|
|
789
|
-
|
|
785
|
+
const L = await v(), M = await pe(L.query.getRandomActiveProvider, L.query)(y().account.address, S()), $ = re(M.provider.url.toString());
|
|
786
|
+
m = await W($);
|
|
790
787
|
}
|
|
791
|
-
if (!(
|
|
788
|
+
if (!(z.getProcaptchaStorage().providerUrl || ((k = e.captchaApi) == null ? void 0 : k.provider.provider.url.toString())))
|
|
792
789
|
return;
|
|
793
|
-
let
|
|
790
|
+
let D = "";
|
|
794
791
|
try {
|
|
795
|
-
|
|
796
|
-
} catch (
|
|
797
|
-
console.error(
|
|
792
|
+
D = y().account.address;
|
|
793
|
+
} catch (L) {
|
|
794
|
+
console.error(L);
|
|
798
795
|
}
|
|
799
|
-
await
|
|
796
|
+
await m.submitUserEvents(c, D);
|
|
800
797
|
}
|
|
801
798
|
};
|
|
802
799
|
}
|
|
803
|
-
const Kt = 1e4,
|
|
800
|
+
const Kt = 1e4, le = (t, e) => {
|
|
804
801
|
e((n) => {
|
|
805
802
|
let r = [...n, t];
|
|
806
803
|
return r.length > Kt && (r = r.slice(1)), r;
|
|
@@ -811,33 +808,33 @@ const Kt = 1e4, ie = (t, e) => {
|
|
|
811
808
|
y: t.y,
|
|
812
809
|
timestamp: t.timeStamp
|
|
813
810
|
};
|
|
814
|
-
|
|
815
|
-
},
|
|
811
|
+
le(n, e);
|
|
812
|
+
}, Ce = (t, e) => {
|
|
816
813
|
const n = {
|
|
817
814
|
key: t.key,
|
|
818
815
|
timestamp: t.timeStamp,
|
|
819
816
|
isShiftKey: t.shiftKey,
|
|
820
817
|
isCtrlKey: t.ctrlKey
|
|
821
818
|
};
|
|
822
|
-
|
|
819
|
+
le(n, e);
|
|
823
820
|
}, q = (t, e) => {
|
|
824
821
|
for (const n of Array.from(t.touches))
|
|
825
|
-
|
|
822
|
+
le({ x: n.clientX, y: n.clientY, timestamp: t.timeStamp }, e);
|
|
826
823
|
}, 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([]), [
|
|
824
|
+
const a = Se(r);
|
|
825
|
+
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)));
|
|
826
|
+
}, Se = (t) => t.tagName === "FORM" ? t : t.parentElement ? Se(t.parentElement) : null, Xt = ({ onProcessData: t, sendData: e, account: n }) => {
|
|
827
|
+
const [r, a] = f.useState([]), [s, o] = f.useState([]), [i, l] = f.useState([]), d = f.useRef(null);
|
|
831
828
|
return f.useEffect(() => {
|
|
832
|
-
|
|
829
|
+
d && d.current && Yt(a, o, l, d.current);
|
|
833
830
|
}, []), f.useEffect(() => {
|
|
834
831
|
n && t({
|
|
835
832
|
mouseEvents: r,
|
|
836
833
|
touchEvents: s,
|
|
837
|
-
keyboardEvents:
|
|
834
|
+
keyboardEvents: i
|
|
838
835
|
});
|
|
839
|
-
}, [e, n]),
|
|
840
|
-
}, qt = Xt, Jt =
|
|
836
|
+
}, [e, n]), u("div", { ref: d });
|
|
837
|
+
}, qt = Xt, Jt = Pe.memo((t, e) => {
|
|
841
838
|
const { show: n, children: r } = t, s = {
|
|
842
839
|
position: "fixed",
|
|
843
840
|
zIndex: 2147483646,
|
|
@@ -854,7 +851,7 @@ const Kt = 1e4, ie = (t, e) => {
|
|
|
854
851
|
left: 0,
|
|
855
852
|
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
856
853
|
zIndex: -1
|
|
857
|
-
},
|
|
854
|
+
}, i = {
|
|
858
855
|
position: "absolute",
|
|
859
856
|
top: "50%",
|
|
860
857
|
left: "50%",
|
|
@@ -864,35 +861,35 @@ const Kt = 1e4, ie = (t, e) => {
|
|
|
864
861
|
border: "none",
|
|
865
862
|
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
863
|
};
|
|
867
|
-
return
|
|
864
|
+
return I("div", { className: "modalOuter", style: s, children: [u("div", { className: "modalBackground", style: o }), u("div", { className: "modalInner", style: i, children: r })] });
|
|
868
865
|
}), Qt = Jt, tn = (t) => {
|
|
869
|
-
const e = t.config, n = t.callbacks || {}, [r, a] =
|
|
870
|
-
return
|
|
871
|
-
padding:
|
|
872
|
-
border:
|
|
873
|
-
backgroundColor:
|
|
874
|
-
borderColor:
|
|
866
|
+
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;
|
|
867
|
+
return u("div", { children: I("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." }) }), I(Oe, { children: [u(De, { children: I("div", { style: ke, "data-cy": "button-human", children: [" ", I("div", { style: {
|
|
868
|
+
padding: Le,
|
|
869
|
+
border: He,
|
|
870
|
+
backgroundColor: i.palette.background.default,
|
|
871
|
+
borderColor: i.palette.grey[300],
|
|
875
872
|
borderRadius: _e,
|
|
876
873
|
display: "flex",
|
|
877
874
|
alignItems: "center",
|
|
878
875
|
flexWrap: "wrap",
|
|
879
876
|
justifyContent: "space-between",
|
|
880
|
-
minHeight: `${
|
|
877
|
+
minHeight: `${Re}px`,
|
|
881
878
|
overflow: "hidden"
|
|
882
|
-
}, children: [
|
|
879
|
+
}, children: [u("div", { style: { display: "inline-flex", flexDirection: "column" }, children: u("div", { style: {
|
|
883
880
|
alignItems: "center",
|
|
884
881
|
flex: 1
|
|
885
|
-
}, children:
|
|
882
|
+
}, children: I("div", { style: {
|
|
886
883
|
display: "flex",
|
|
887
884
|
alignItems: "center",
|
|
888
885
|
justifyContent: "center",
|
|
889
886
|
flexDirection: "column",
|
|
890
887
|
verticalAlign: "middle"
|
|
891
|
-
}, children: [
|
|
888
|
+
}, children: [u("div", { style: {
|
|
892
889
|
display: r.loading ? "none" : "flex"
|
|
893
|
-
}, children:
|
|
890
|
+
}, children: u(pt, { themeColor: o, onChange: s.start, checked: r.isHuman, labelText: "I am human" }) }), u("div", { style: {
|
|
894
891
|
display: r.loading ? "flex" : "none"
|
|
895
|
-
}, children:
|
|
892
|
+
}, 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
893
|
};
|
|
897
894
|
export {
|
|
898
895
|
tn as default
|