@prosopo/procaptcha-bundle 0.3.36 → 0.3.38

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,16 +1,16 @@
1
- import { A as p, P as I, j as n, C as W, W as _, a as C, c as k, e as P, f as R, g as O, i as G, L as H, k as U, m as L, n as j, l as F, d as B, r as b } from "./index-D8kIYYhv.js";
2
- import { B as K, u as M, p as q, h as w, m as X, w as $, t as z, q as J, A as Q, W as V, K as Y, x as Z, C as ee, n as D, y as te, z as ne } from "./utils-D1z4XROV.js";
1
+ import { A as p, P as I, j as n, C as W, W as _, a as C, c as k, e as P, f as R, g as O, i as G, L as H, k as U, m as L, n as j, l as F, d as B, r as b } from "./index-qPfd64Wv.js";
2
+ import { B as K, u as M, p as q, h as w, m as X, w as $, t as z, q as J, A as Q, W as V, K as Y, x as Z, C as ee, n as D, y as te, z as ne } from "./utils-DFW70WZi.js";
3
3
  const oe = (a, e) => {
4
4
  let o = 0;
5
5
  const c = "0".repeat(e);
6
6
  for (; ; ) {
7
- const d = new TextEncoder().encode(o + a);
8
- if (ae(K(d)).startsWith(c))
7
+ const l = new TextEncoder().encode(o + a);
8
+ if (ae(K(l)).startsWith(c))
9
9
  return o;
10
10
  o += 1;
11
11
  }
12
12
  }, ae = (a) => Array.from(a).map((e) => e.toString(16).padStart(2, "0")).join(""), re = (a, e, o, c) => {
13
- const d = () => ({
13
+ const l = () => ({
14
14
  showModal: !1,
15
15
  loading: !1,
16
16
  index: 0,
@@ -20,7 +20,7 @@ const oe = (a, e) => {
20
20
  captchaApi: void 0,
21
21
  account: void 0
22
22
  }), r = () => {
23
- window.clearTimeout(e.timeout), u({ timeout: void 0 });
23
+ window.clearTimeout(e.timeout), d({ timeout: void 0 });
24
24
  }, i = () => {
25
25
  const t = {
26
26
  userAccountAddress: "",
@@ -45,41 +45,42 @@ const oe = (a, e) => {
45
45
  if (!e.account)
46
46
  throw new w("GENERAL.ACCOUNT_NOT_FOUND", { context: { error: "Account not loaded" } });
47
47
  return e.account;
48
- }, l = () => {
48
+ }, u = () => {
49
49
  if (!e.dappAccount)
50
50
  throw new w("GENERAL.SITE_KEY_MISSING");
51
51
  return e.dappAccount;
52
- }, u = D(e, o), N = () => {
53
- r(), u(d());
52
+ }, d = D(e, o), N = () => {
53
+ r(), d(l());
54
54
  };
55
55
  return {
56
56
  start: async () => {
57
57
  if (e.loading || e.isHuman)
58
58
  return;
59
- N();
59
+ N(), d({
60
+ loading: !0
61
+ });
60
62
  const t = i(), s = new M(), h = t.userAccountAddress || (await s.getAccount(t)).account.address;
61
- if (u({
62
- loading: !0,
63
+ if (d({
63
64
  account: { account: { address: h } }
64
- }), u({ dappAccount: t.account.address }), await q(100), !t.web2 && !t.userAccountAddress)
65
+ }), d({ dappAccount: t.account.address }), await q(100), !t.web2 && !t.userAccountAddress)
65
66
  throw new w("GENERAL.ACCOUNT_NOT_FOUND", {
66
67
  context: { error: "Account address has not been set for web3 mode" }
67
68
  });
68
- const m = await A(), S = X(o, e, c), v = await $(m.query.getRandomActiveProvider, m.query)(h, l()), y = z(v.provider.url.toString()), E = new J(f(i()), y, l()), g = await E.getPowCaptchaChallenge(h, l()), T = oe(g.challenge, g.difficulty);
69
- (await E.submitPowCaptchaSolution(g, x().account.address, l(), v, T))[p.verified] && (u({
69
+ const m = await A(), S = X(o, e, c), v = await $(m.query.getRandomActiveProvider, m.query)(h, u()), y = z(v.provider.url.toString()), E = new J(f(i()), y, u()), g = await E.getPowCaptchaChallenge(h, u()), T = oe(g.challenge, g.difficulty);
70
+ (await E.submitPowCaptchaSolution(g, x().account.address, u(), v, T))[p.verified] && (d({
70
71
  isHuman: !0,
71
72
  loading: !1
72
73
  }), S.onHuman({
73
74
  providerUrl: y,
74
75
  [p.user]: x().account.address,
75
- [p.dapp]: l(),
76
+ [p.dapp]: u(),
76
77
  [p.challenge]: g.challenge,
77
78
  [p.blockNumber]: v.blockNumber
78
79
  }));
79
80
  }
80
81
  };
81
82
  }, le = (a) => {
82
- const e = a.config, o = e.theme === "light" ? "light" : "dark", c = a.config.theme === "light" ? F : B, d = a.callbacks || {}, [r, i] = te(b.useState, b.useRef), f = D(r, i), A = re(e, r, f, d);
83
+ const e = a.config, o = e.theme === "light" ? "light" : "dark", c = a.config.theme === "light" ? F : B, l = a.callbacks || {}, [r, i] = te(b.useState, b.useRef), f = D(r, i), A = re(e, r, f, l);
83
84
  return n("div", { children: n("div", { style: { maxWidth: "100%", maxHeight: "100%", overflowX: "auto" }, children: n(W, { children: n(_, { children: C("div", { style: k, "data-cy": "button-human", children: [" ", C("div", { style: {
84
85
  padding: P,
85
86
  border: R,
@@ -1,5 +1,5 @@
1
- import { z as X, r as f, l as Q, d as Z, j as u, a as E, b as g, A as K, h as ue, P as Te, R as Pe, C as Oe, W as De, c as ke, e as Le, f as He, g as _e, i as Re, L as Me, k as We, m as Ue, n as je } from "./index-D8kIYYhv.js";
2
- import { _ as Ge, a as ze, b as Fe, I as Be, R as $e, g as Ke, c as Ve, d as Ye, i as Xe, P as F, o as qe, E as Je, e as P, f as ae, h as v, j as V, k as de, s as xe, l as Qe, m as Ze, w as pe, t as re, n as et, p as tt, r as nt, q as rt, u as ot, v as at, A as st, W as ct, K as it, x as lt, C as ut, y as dt, z as pt } from "./utils-D1z4XROV.js";
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-qPfd64Wv.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-DFW70WZi.js";
3
3
  const ve = X.object({
4
4
  account: X.string().optional(),
5
5
  blockNumber: X.number().optional(),
@@ -37,8 +37,8 @@ function ft(t, e) {
37
37
  if (r.toLowerCase() === "cimode")
38
38
  return !0;
39
39
  var o = function(l, d) {
40
- var b = e.services.backendConnector.state["".concat(l, "|").concat(d)];
41
- return b === -1 || b === 2;
40
+ var w = e.services.backendConnector.state["".concat(l, "|").concat(d)];
41
+ return w === -1 || w === 2;
42
42
  };
43
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)));
44
44
  }
@@ -66,8 +66,8 @@ function mt(t, e) {
66
66
  } else
67
67
  for (; !(l = (r = s.call(n)).done) && (i.push(r.value), i.length !== e); l = !0)
68
68
  ;
69
- } catch (b) {
70
- d = !0, a = b;
69
+ } catch (w) {
70
+ d = !0, a = w;
71
71
  } finally {
72
72
  try {
73
73
  if (!l && n.return != null && (o = n.return(), Object(o) !== o))
@@ -114,47 +114,47 @@ function yt(t) {
114
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
115
  if (o && !o.reportNamespaces && (o.reportNamespaces = new $e()), !o) {
116
116
  se("You will need to pass in an i18next instance by using initReactI18next");
117
- var i = function(x) {
118
- return Array.isArray(x) ? x[x.length - 1] : x;
117
+ var i = function(v) {
118
+ return Array.isArray(v) ? v[v.length - 1] : v;
119
119
  }, l = [i, {}, !1];
120
120
  return l.t = i, l.i18n = {}, l.ready = !1, l;
121
121
  }
122
122
  o.options.react && o.options.react.wait !== void 0 && se("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");
123
- var d = oe(oe(oe({}, Ke()), o.options.react), e), b = d.useSuspense, I = d.keyPrefix, m = t || s || o.options && o.options.defaultNS;
124
- m = typeof m == "string" ? [m] : m || ["translation"], o.reportNamespaces.addUsedNamespaces && o.reportNamespaces.addUsedNamespaces(m);
125
- var L = (o.isInitialized || o.initializedStoreOnce) && m.every(function(A) {
126
- return gt(A, o, d);
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);
127
127
  });
128
128
  function H() {
129
- return o.getFixedT(null, d.nsMode === "fallback" ? m : m[0], I);
129
+ return o.getFixedT(null, d.nsMode === "fallback" ? b : b[0], N);
130
130
  }
131
- var W = f.useState(H), U = wt(W, 2), j = U[0], _ = U[1], G = m.join(), Y = bt(G), y = f.useRef(!0);
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);
132
132
  f.useEffect(function() {
133
- var A = d.bindI18n, x = d.bindI18nStore;
134
- y.current = !0, !L && !b && fe(o, m, function() {
133
+ var E = d.bindI18n, v = d.bindI18nStore;
134
+ y.current = !0, !x && !w && fe(o, b, function() {
135
135
  y.current && _(H);
136
- }), L && Y && Y !== G && y.current && _(H);
136
+ }), x && Y && Y !== G && y.current && _(H);
137
137
  function B() {
138
138
  y.current && _(H);
139
139
  }
140
- return A && o && o.on(A, B), x && o && o.store.on(x, B), function() {
141
- y.current = !1, A && o && A.split(" ").forEach(function(c) {
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
142
  return o.off(c, B);
143
- }), x && o && x.split(" ").forEach(function(c) {
143
+ }), v && o && v.split(" ").forEach(function(c) {
144
144
  return o.store.off(c, B);
145
145
  });
146
146
  };
147
147
  }, [o, G]);
148
- var N = f.useRef(!0);
148
+ var S = f.useRef(!0);
149
149
  f.useEffect(function() {
150
- y.current && !N.current && _(H), N.current = !1;
151
- }, [o, I]);
152
- var R = [j, o, L];
153
- if (R.t = j, R.i18n = o, R.ready = L, L || !L && !b)
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
154
  return R;
155
- throw new Promise(function(A) {
156
- fe(o, m, function() {
157
- A();
155
+ throw new Promise(function(E) {
156
+ fe(o, b, function() {
157
+ E();
158
158
  });
159
159
  });
160
160
  }
@@ -183,7 +183,7 @@ const xt = (t) => {
183
183
  flexGrow: 1,
184
184
  flexBasis: "33.3333%",
185
185
  boxSizing: "border-box"
186
- }, children: E("div", { style: { cursor: "pointer", height: "100%", width: "100%" }, onClick: o ? void 0 : () => n(d), onTouchStart: o ? () => n(d) : void 0, children: [u("div", { style: { border: 1, borderColor: s.palette.grey[300] }, children: u("img", { style: {
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: {
187
187
  width: "100%",
188
188
  backgroundColor: s.palette.grey[300],
189
189
  opacity: e.includes(d) && o ? "50%" : "100%",
@@ -274,7 +274,7 @@ const Et = {
274
274
  l.preventDefault(), r();
275
275
  }, children: n });
276
276
  }, me = It, Nt = ({ challenge: t, index: e, solutions: n, onSubmit: r, onCancel: a, onClick: s, onNext: o, themeColor: i }) => {
277
- const { t: l } = Ct(), d = t.captchas ? g(t.captchas, e) : null, b = n ? g(n, e) : [], I = f.useMemo(() => i === "light" ? Q : Z, [i]);
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
278
  return u(f.Suspense, { fallback: u("div", { children: "Loading..." }), children: u("div", { style: {
279
279
  overflowX: "auto",
280
280
  overflowY: "auto",
@@ -283,18 +283,18 @@ const Et = {
283
283
  maxHeight: "100%",
284
284
  display: "flex",
285
285
  flexDirection: "column"
286
- }, children: E("div", { style: {
287
- backgroundColor: I.palette.background.default,
286
+ }, children: I("div", { style: {
287
+ backgroundColor: N.palette.background.default,
288
288
  display: "flex",
289
289
  flexDirection: "column",
290
290
  minWidth: "300px"
291
- }, children: [E("div", { style: {
291
+ }, children: [I("div", { style: {
292
292
  display: "flex",
293
293
  alignItems: "center",
294
294
  width: "100%",
295
- backgroundColor: I.palette.primary.main,
295
+ backgroundColor: N.palette.primary.main,
296
296
  padding: "24px 16px"
297
- }, children: [E("p", { style: {
297
+ }, children: [I("p", { style: {
298
298
  color: "#ffffff",
299
299
  fontWeight: 700,
300
300
  lineHeight: 1.5
@@ -303,7 +303,7 @@ const Et = {
303
303
  fontWeight: 700,
304
304
  textTransform: "capitalize",
305
305
  lineHeight: 1.5
306
- }, children: `${g(t.captchas, e).captcha.target}` })] }), u("div", { ...ce({ dev: { cy: "captcha-" + e } }), children: d && u(vt, { challenge: d, solution: b, onClick: s, themeColor: i }) }), u("div", { style: {
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: {
307
307
  display: "flex",
308
308
  alignItems: "center",
309
309
  justifyContent: "center",
@@ -312,7 +312,7 @@ const Et = {
312
312
  padding: "8px 16px",
313
313
  display: "flex",
314
314
  width: "100%"
315
- } }), E("div", { style: {
315
+ } }), I("div", { style: {
316
316
  padding: "0 16px 16px",
317
317
  display: "flex",
318
318
  alignItems: "center",
@@ -351,16 +351,16 @@ class Dt extends Je {
351
351
  async getAccount(e) {
352
352
  const { dappName: n, userAccountAddress: r } = e;
353
353
  if (!r)
354
- throw new P("WIDGET.NO_ACCOUNTS_FOUND", { context: { error: "No account address provided" } });
354
+ throw new O("WIDGET.NO_ACCOUNTS_FOUND", { context: { error: "No account address provided" } });
355
355
  const a = await Ot(n);
356
356
  if (a.length === 0)
357
- throw new P("WIDGET.NO_EXTENSION_FOUND");
357
+ throw new O("WIDGET.NO_EXTENSION_FOUND");
358
358
  for (const s of a) {
359
359
  const i = (await s.accounts.get()).find((l) => l.address === r);
360
360
  if (i)
361
361
  return { account: i, extension: s };
362
362
  }
363
- throw new P("WIDGET.ACCOUNT_NOT_FOUND", {
363
+ throw new O("WIDGET.ACCOUNT_NOT_FOUND", {
364
364
  context: { error: `No account found matching ${r}` }
365
365
  });
366
366
  }
@@ -375,7 +375,7 @@ async function kt(t) {
375
375
  const n = await e.arrayBuffer();
376
376
  return new Uint8Array(n);
377
377
  } catch (e) {
378
- throw new v("DATABASE.IMAGE_GET_FAILED", { context: { error: e } });
378
+ throw new A("DATABASE.IMAGE_GET_FAILED", { context: { error: e } });
379
379
  }
380
380
  }
381
381
  const Lt = "NO_SOLUTION";
@@ -442,7 +442,7 @@ class Mt {
442
442
  for (; a < n; ) {
443
443
  const o = e[a];
444
444
  if (o === void 0)
445
- throw new P("DEVELOPER.GENERAL", { context: { error: "leftChild undefined" } });
445
+ throw new O("DEVELOPER.GENERAL", { context: { error: "leftChild undefined" } });
446
446
  const i = a + 1 < n ? g(e, a + 1) : o, l = this.createParent(o, i);
447
447
  s.push(l.hash), r.push(l), a += 2;
448
448
  }
@@ -458,7 +458,7 @@ class Mt {
458
458
  for (; r < this.layers.length - 1; ) {
459
459
  const s = this.layers[r];
460
460
  if (s === void 0)
461
- throw new P("DATASET.MERKLE_ERROR", {
461
+ throw new O("DATASET.MERKLE_ERROR", {
462
462
  context: { error: "layer undefined", failedFuncName: this.proof.name, layerNum: r }
463
463
  });
464
464
  const o = s.indexOf(e);
@@ -503,43 +503,41 @@ class Ut {
503
503
  });
504
504
  }), e;
505
505
  } catch (e) {
506
- throw new v("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", { context: { error: e } });
506
+ throw new A("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", { context: { error: e } });
507
507
  }
508
508
  }
509
509
  verifyCaptchaChallengeContent(e, n) {
510
510
  const r = g(n.captchas, 0), a = r.proof.length, s = g(r.proof, a - 1);
511
511
  if (e.provider.datasetIdContent.toString() !== g(s, 0))
512
- throw new v("CAPTCHA.INVALID_DATASET_CONTENT_ID");
512
+ throw new A("CAPTCHA.INVALID_DATASET_CONTENT_ID");
513
513
  for (const o of n.captchas) {
514
514
  if (!jt(o))
515
- throw new v("CAPTCHA.INVALID_CAPTCHA_CHALLENGE");
515
+ throw new A("CAPTCHA.INVALID_CAPTCHA_CHALLENGE");
516
516
  if (!Wt(o.captcha.captchaContentId, o.proof))
517
- throw new v("CAPTCHA.INVALID_CAPTCHA_CHALLENGE");
517
+ throw new A("CAPTCHA.INVALID_CAPTCHA_CHALLENGE");
518
518
  }
519
519
  }
520
520
  async submitCaptchaSolution(e, n, r, a, s) {
521
- const o = new Mt(), i = a.map((m) => Rt(m));
521
+ const o = new Mt(), i = a.map((x) => Rt(x));
522
522
  o.build(i);
523
523
  const l = o.root.hash, d = void 0;
524
- let b;
525
- if (this.web2) {
526
- if (!e || !e.signRaw)
527
- throw new v("GENERAL.CANT_FIND_KEYRINGPAIR", {
528
- context: { error: "Signer is not defined, cannot sign message to prove account ownership" }
529
- });
530
- b = (await e.signRaw({
531
- address: this.userAccount,
532
- data: xe(n),
533
- type: "bytes"
534
- })).signature;
535
- }
536
- let I;
524
+ let w;
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;
537
535
  try {
538
- I = await this.providerApi.submitCaptchaSolution(a, n, this.contract.pair.address, s, b);
539
- } catch (m) {
540
- throw new F("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 } });
541
539
  }
542
- return [I, l, d];
540
+ return [N, l, d];
543
541
  }
544
542
  }
545
543
  async function jt(t) {
@@ -579,7 +577,7 @@ const z = {
579
577
  }), ye = (t) => {
580
578
  const e = t.networks[t.defaultNetwork];
581
579
  if (!e)
582
- throw new v("DEVELOPER.NETWORK_NOT_FOUND", {
580
+ throw new A("DEVELOPER.NETWORK_NOT_FOUND", {
583
581
  context: { error: `No network found for environment ${t.defaultEnvironment}` }
584
582
  });
585
583
  return e;
@@ -607,33 +605,33 @@ function $t(t, e, n, r) {
607
605
  _(), o({ loading: !0 });
608
606
  const c = i();
609
607
  o({ dappAccount: c.account.address }), await tt(100);
610
- const p = await Y(), h = await x();
611
- let w = !1;
608
+ const p = await Y(), h = await v();
609
+ let m = !1;
612
610
  try {
613
- w = (await h.query.dappOperatorIsHumanUser(p.account.address, c.solutionThreshold)).value.unwrap().unwrap();
614
- } catch (T) {
611
+ m = (await h.query.dappOperatorIsHumanUser(p.account.address, c.solutionThreshold)).value.unwrap().unwrap();
612
+ } catch (P) {
615
613
  }
616
- if (w) {
614
+ if (m) {
617
615
  o({ isHuman: !0, loading: !1 }), a.onHuman({
618
616
  user: p.account.address,
619
- dapp: N()
617
+ dapp: S()
620
618
  }), j();
621
619
  return;
622
620
  }
623
621
  const C = z.getProcaptchaStorage();
624
- let O;
622
+ let D;
625
623
  if (C.providerUrl && C.blockNumber) {
626
- O = await W(C.providerUrl);
624
+ D = await W(C.providerUrl);
627
625
  try {
628
- const T = await O.verifyDappUser(N(), p.account.address, C.blockNumber, void 0, t.challengeValidLength);
629
- if (T.verified) {
626
+ const P = await D.verifyDappUser(S(), p.account.address, C.blockNumber, void 0, t.challengeValidLength);
627
+ if (P.verified) {
630
628
  o({ isHuman: !0, loading: !1 });
631
629
  const ne = {
632
630
  [K.providerUrl]: C.providerUrl,
633
631
  [K.user]: p.account.address,
634
- [K.dapp]: N(),
635
- [K.commitmentId]: ue(T.commitmentId),
636
- [K.blockNumber]: T.blockNumber
632
+ [K.dapp]: S(),
633
+ [K.commitmentId]: ue(P.commitmentId),
634
+ [K.blockNumber]: P.blockNumber
637
635
  };
638
636
  a.onHuman(ne), j();
639
637
  return;
@@ -642,89 +640,89 @@ function $t(t, e, n, r) {
642
640
  console.error("Error contacting provider from storage", C.providerUrl);
643
641
  }
644
642
  }
645
- const D = await pe(h.query.getRandomActiveProvider, h.query)(p.account.address, N()), k = parseInt(D.blockNumber.toString()), M = re(D.provider.url.toString());
646
- O = await W(M);
647
- const S = await (await H(h, D, O)).getCaptchaChallenge();
648
- if (S.captchas.length <= 0)
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)
649
647
  throw new ae("DEVELOPER.PROVIDER_NO_CAPTCHA");
650
- const ee = S.captchas.map((T) => T.captcha.timeLimitMs || 30 * 1e3).reduce((T, ne) => T + ne), te = setTimeout(() => {
648
+ const ee = T.captchas.map((P) => P.captcha.timeLimitMs || 30 * 1e3).reduce((P, ne) => P + ne), te = setTimeout(() => {
651
649
  a.onChallengeExpired(), o({ isHuman: !1, showModal: !1, loading: !1 });
652
650
  }, ee);
653
651
  o({
654
652
  index: 0,
655
- solutions: S.captchas.map(() => []),
656
- challenge: S,
653
+ solutions: T.captchas.map(() => []),
654
+ challenge: T,
657
655
  showModal: !0,
658
656
  timeout: te,
659
- blockNumber: k
657
+ blockNumber: L
660
658
  });
661
659
  });
662
- }, b = async () => {
660
+ }, w = async () => {
663
661
  await l(async () => {
664
662
  if (U(), !e.challenge)
665
- throw new P("CAPTCHA.NO_CAPTCHA", {
663
+ throw new O("CAPTCHA.NO_CAPTCHA", {
666
664
  context: { error: "Cannot submit, no Captcha found in state" }
667
665
  });
668
666
  o({ showModal: !1 });
669
- const c = e.challenge, p = nt(), h = e.challenge.captchas.map((S, ee) => {
667
+ const c = e.challenge, p = nt(), h = e.challenge.captchas.map((T, ee) => {
670
668
  const te = g(e.solutions, ee);
671
669
  return {
672
- captchaId: S.captcha.captchaId,
673
- captchaContentId: S.captcha.captchaContentId,
670
+ captchaId: T.captcha.captchaId,
671
+ captchaContentId: T.captcha.captchaContentId,
674
672
  salt: p,
675
673
  solution: te
676
674
  };
677
- }), w = y(), C = R(), O = A(w).signer, D = g(c.captchas, 0);
678
- if (!D.captcha.datasetId)
675
+ }), m = y(), C = R(), D = E(m).signer, k = g(c.captchas, 0);
676
+ if (!k.captcha.datasetId)
679
677
  throw new F("CAPTCHA.INVALID_CAPTCHA_ID", {
680
678
  context: { error: "No datasetId set for challenge" }
681
679
  });
682
- const k = G(), M = await k.submitCaptchaSolution(O, c.requestHash, D.captcha.datasetId, h, p), $ = M[0].verified;
680
+ const L = G(), M = await L.submitCaptchaSolution(D, c.requestHash, k.captcha.datasetId, h, p), $ = M[0].verified;
683
681
  if ($ || a.onFailed(), o({
684
682
  submission: M,
685
683
  isHuman: $,
686
684
  loading: !1
687
685
  }), e.isHuman) {
688
- const S = re(k.provider.provider.url.toString());
689
- z.setProcaptchaStorage({ ...z.getProcaptchaStorage(), providerUrl: S, blockNumber: C }), a.onHuman({
690
- providerUrl: S,
691
- user: w.account.address,
692
- dapp: N(),
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(),
693
691
  commitmentId: ue(M[1]),
694
692
  blockNumber: C
695
693
  }), j();
696
694
  }
697
695
  });
698
- }, I = async () => {
696
+ }, N = async () => {
699
697
  U(), _(), a.onClose();
700
- }, m = (c) => {
698
+ }, b = (c) => {
701
699
  if (!e.challenge)
702
- throw new P("CAPTCHA.NO_CAPTCHA", {
700
+ throw new O("CAPTCHA.NO_CAPTCHA", {
703
701
  context: { error: "Cannot select, no Captcha found in state" }
704
702
  });
705
703
  if (e.index >= e.challenge.captchas.length || e.index < 0)
706
- throw new P("CAPTCHA.NO_CAPTCHA", {
704
+ throw new O("CAPTCHA.NO_CAPTCHA", {
707
705
  context: { error: "Cannot select, index is out of range for this Captcha" }
708
706
  });
709
- const p = e.index, h = e.solutions, w = g(h, p);
710
- w.includes(c) ? w.splice(w.indexOf(c), 1) : w.push(c), o({ solutions: h });
711
- }, L = () => {
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 = () => {
712
710
  if (!e.challenge)
713
- throw new P("CAPTCHA.NO_CAPTCHA", {
711
+ throw new O("CAPTCHA.NO_CAPTCHA", {
714
712
  context: { error: "Cannot select, no Captcha found in state" }
715
713
  });
716
714
  if (e.index + 1 >= e.challenge.captchas.length)
717
- throw new P("CAPTCHA.NO_CAPTCHA", {
715
+ throw new O("CAPTCHA.NO_CAPTCHA", {
718
716
  context: { error: "Cannot select, index is out of range for this Captcha" }
719
717
  });
720
718
  o({ index: e.index + 1 });
721
719
  }, H = async (c, p, h) => {
722
- const w = i(), C = new Gt(y().account.address, c, p, h, w.web2, N());
720
+ const m = i(), C = new Gt(y().account.address, c, p, h, m.web2, S());
723
721
  return o({ captchaApi: C }), G();
724
722
  }, W = async (c) => {
725
723
  const p = i(), h = ye(p);
726
724
  if (!p.account.address)
727
- throw new v("GENERAL.SITE_KEY_MISSING");
725
+ throw new A("GENERAL.SITE_KEY_MISSING");
728
726
  return new rt(h, c, p.account.address);
729
727
  }, U = () => {
730
728
  window.clearTimeout(e.timeout), o({ timeout: void 0 });
@@ -742,60 +740,60 @@ function $t(t, e, n, r) {
742
740
  }, Y = async () => {
743
741
  const c = i();
744
742
  if (!c.web2 && !c.userAccountAddress)
745
- throw new v("GENERAL.ACCOUNT_NOT_FOUND", {
743
+ throw new A("GENERAL.ACCOUNT_NOT_FOUND", {
746
744
  context: { error: "Account address has not been set for web3 mode" }
747
745
  });
748
746
  const h = await (c.web2 ? new ot() : new Dt()).getAccount(c);
749
747
  return z.setAccount(h.account.address), o({ account: h }), y();
750
748
  }, y = () => {
751
749
  if (!e.account)
752
- 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" } });
753
751
  return e.account;
754
- }, N = () => {
752
+ }, S = () => {
755
753
  if (!e.dappAccount)
756
- throw new v("GENERAL.SITE_KEY_MISSING");
754
+ throw new A("GENERAL.SITE_KEY_MISSING");
757
755
  return e.dappAccount;
758
756
  }, R = () => {
759
757
  if (!e.blockNumber)
760
758
  throw new at("CAPTCHA.INVALID_BLOCK_NO", { context: { error: "Block number not found" } });
761
759
  return e.blockNumber;
762
- }, A = (c) => {
760
+ }, E = (c) => {
763
761
  if (c = c || y(), !c.extension)
764
- throw new v("ACCOUNT.NO_POLKADOT_EXTENSION", { context: { error: "Extension not loaded" } });
762
+ throw new A("ACCOUNT.NO_POLKADOT_EXTENSION", { context: { error: "Extension not loaded" } });
765
763
  return c.extension;
766
- }, x = async () => {
764
+ }, v = async () => {
767
765
  const c = i(), p = ye(c), h = await st.create({
768
766
  provider: new ct(p.endpoint),
769
767
  initWasm: !1,
770
768
  noInitWarn: !0
771
- }), w = "sr25519", C = new it({ type: w, ss58Format: h.registry.chainSS58 });
769
+ }), m = "sr25519", C = new it({ type: m, ss58Format: h.registry.chainSS58 });
772
770
  return new lt(h, JSON.parse(ut), p.contract.address, "prosopo", 0, C.addFromAddress(y().account.address));
773
771
  };
774
772
  return {
775
773
  start: d,
776
- cancel: I,
777
- submit: b,
778
- select: m,
779
- nextRound: L,
774
+ cancel: N,
775
+ submit: w,
776
+ select: b,
777
+ nextRound: x,
780
778
  exportData: async (c) => {
781
- var D;
779
+ var k;
782
780
  const h = z.getProcaptchaStorage().providerUrl;
783
- let w;
781
+ let m;
784
782
  if (h)
785
- w = await W(h);
783
+ m = await W(h);
786
784
  else {
787
- const k = await x(), M = await pe(k.query.getRandomActiveProvider, k.query)(y().account.address, N()), $ = re(M.provider.url.toString());
788
- w = await W($);
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($);
789
787
  }
790
- if (!(z.getProcaptchaStorage().providerUrl || ((D = e.captchaApi) == null ? void 0 : D.provider.provider.url.toString())))
788
+ if (!(z.getProcaptchaStorage().providerUrl || ((k = e.captchaApi) == null ? void 0 : k.provider.provider.url.toString())))
791
789
  return;
792
- let O = "";
790
+ let D = "";
793
791
  try {
794
- O = y().account.address;
795
- } catch (k) {
796
- console.error(k);
792
+ D = y().account.address;
793
+ } catch (L) {
794
+ console.error(L);
797
795
  }
798
- await w.submitUserEvents(c, O);
796
+ await m.submitUserEvents(c, D);
799
797
  }
800
798
  };
801
799
  }
@@ -863,10 +861,10 @@ const Kt = 1e4, le = (t, e) => {
863
861
  border: "none",
864
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,"
865
863
  };
866
- return E("div", { className: "modalOuter", style: s, children: [u("div", { className: "modalBackground", style: o }), u("div", { className: "modalInner", style: i, 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 })] });
867
865
  }), Qt = Jt, tn = (t) => {
868
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;
869
- return u("div", { children: E("div", { style: { maxWidth: "100%", maxHeight: "100%", overflowX: "auto" }, children: [u(Qt, { show: r.showModal, children: r.challenge ? u(St, { challenge: r.challenge, index: r.index, solutions: r.solutions, onSubmit: s.submit, onCancel: s.cancel, onClick: s.select, onNext: s.nextRound, themeColor: e.theme ?? "light" }) : u("div", { children: "No challenge set." }) }), E(Oe, { children: [u(De, { children: E("div", { style: ke, "data-cy": "button-human", children: [" ", E("div", { style: {
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: {
870
868
  padding: Le,
871
869
  border: He,
872
870
  backgroundColor: i.palette.background.default,
@@ -881,7 +879,7 @@ const Kt = 1e4, le = (t, e) => {
881
879
  }, children: [u("div", { style: { display: "inline-flex", flexDirection: "column" }, children: u("div", { style: {
882
880
  alignItems: "center",
883
881
  flex: 1
884
- }, children: E("div", { style: {
882
+ }, children: I("div", { style: {
885
883
  display: "flex",
886
884
  alignItems: "center",
887
885
  justifyContent: "center",