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