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