@prosopo/procaptcha-bundle 0.3.5 → 0.3.37

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