@prosopo/procaptcha-bundle 2.1.0 → 2.1.1

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.
Files changed (60) hide show
  1. package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/language.d.ts +1 -1
  2. package/.rollup.cache/home/chris/dev/prosopo/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/language.d.ts.map +1 -0
  3. package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/language.js +1 -1
  4. package/.rollup.cache/home/chris/dev/prosopo/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/language.js.map +1 -0
  5. package/dist/bundle/ProcaptchaWidget-BJTWbWXX.js +157 -0
  6. package/dist/bundle/{ProcaptchaWidget-BZq2OhjK.js → ProcaptchaWidget-CyCdGVAQ.js} +94 -85
  7. package/dist/bundle/{index-Ck7UqzKB.js → index-DkYajG2c.js} +13127 -13934
  8. package/dist/bundle/procaptcha.bundle.js +1 -1
  9. package/dist/bundle/util/language.d.ts +1 -1
  10. package/dist/bundle/util/language.d.ts.map +1 -1
  11. package/dist/bundle/{utils-9IQXYrRR.js → utils-CAk_TqSc.js} +5065 -3278
  12. package/dist/cjs/index.cjs +16 -4
  13. package/dist/cjs/util/language.cjs +3 -3
  14. package/dist/util/language.d.ts +1 -1
  15. package/dist/util/language.d.ts.map +1 -1
  16. package/dist/util/language.js +1 -1
  17. package/dist/util/language.js.map +1 -1
  18. package/package.json +9 -8
  19. package/stats.html +1 -1
  20. package/vite.config.ts.timestamp-1717674816132-b375b28e04de9.mjs +56 -0
  21. package/vite.config.ts.timestamp-1723148478701-50a086cc53355.mjs +56 -0
  22. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/language.d.ts.map +0 -1
  23. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/language.js.map +0 -1
  24. package/dist/bundle/ProcaptchaWidget-b_oUhvT9.js +0 -149
  25. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/index.d.ts +0 -0
  26. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/index.d.ts.map +0 -0
  27. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/index.js +0 -0
  28. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/index.js.map +0 -0
  29. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/tests/captchaType.test.d.ts +0 -0
  30. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/tests/captchaType.test.d.ts.map +0 -0
  31. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/tests/captchaType.test.js +0 -0
  32. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/tests/captchaType.test.js.map +0 -0
  33. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/tests/config.test.d.ts +0 -0
  34. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/tests/config.test.d.ts.map +0 -0
  35. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/tests/config.test.js +0 -0
  36. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/tests/config.test.js.map +0 -0
  37. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/captchaType.d.ts +0 -0
  38. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/captchaType.d.ts.map +0 -0
  39. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/captchaType.js +0 -0
  40. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/captchaType.js.map +0 -0
  41. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/config.d.ts +0 -0
  42. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/config.d.ts.map +0 -0
  43. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/config.js +0 -0
  44. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/config.js.map +0 -0
  45. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/defaultCallbacks.d.ts +0 -0
  46. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/defaultCallbacks.d.ts.map +0 -0
  47. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/defaultCallbacks.js +0 -0
  48. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/defaultCallbacks.js.map +0 -0
  49. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/form.d.ts +0 -0
  50. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/form.d.ts.map +0 -0
  51. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/form.js +0 -0
  52. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/form.js.map +0 -0
  53. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/theme.d.ts +0 -0
  54. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/theme.d.ts.map +0 -0
  55. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/theme.js +0 -0
  56. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/theme.js.map +0 -0
  57. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/timeout.d.ts +0 -0
  58. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/timeout.d.ts.map +0 -0
  59. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/timeout.js +0 -0
  60. /package/.rollup.cache/home/{runner/work/captcha → chris/dev/prosopo/captcha-private}/captcha/packages/procaptcha-bundle/dist/bundle/util/timeout.js.map +0 -0
@@ -1,3 +1,3 @@
1
- import { type ProcaptchaClientConfigInput, type ProcaptchaRenderOptions } from "@prosopo/types";
1
+ import type { ProcaptchaClientConfigInput, ProcaptchaRenderOptions } from "@prosopo/types";
2
2
  export declare const setLanguage: (renderOptions: ProcaptchaRenderOptions | undefined, element: Element, config: ProcaptchaClientConfigInput) => void;
3
3
  //# sourceMappingURL=language.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language.d.ts","sourceRoot":"","sources":["../../../src/util/language.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EACX,2BAA2B,EAC3B,uBAAuB,EACvB,MAAM,gBAAgB,CAAC;AAcxB,eAAO,MAAM,WAAW,kBACR,uBAAuB,GAAG,SAAS,WACzC,OAAO,UACR,2BAA2B,SAQnC,CAAC"}
@@ -1,4 +1,4 @@
1
- import { LanguageSchema, } from "@prosopo/types";
1
+ import { LanguageSchema } from "@prosopo/locale";
2
2
  export const setLanguage = (renderOptions, element, config) => {
3
3
  const languageAttribute = renderOptions?.language || element.getAttribute("data-language");
4
4
  if (languageAttribute) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"language.js","sourceRoot":"","sources":["../../../src/util/language.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAkBjD,MAAM,CAAC,MAAM,WAAW,GAAG,CAC1B,aAAkD,EAClD,OAAgB,EAChB,MAAmC,EAClC,EAAE;IACH,MAAM,iBAAiB,GACtB,aAAa,EAAE,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;IAElE,IAAI,iBAAiB,EAAE,CAAC;QACvB,MAAM,CAAC,QAAQ,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,CAAC;IACvD,CAAC;AACF,CAAC,CAAC;AAEF,MAAM,gBAAgB,GAAG,CACxB,iBAAiD,EAChD,EAAE;IACH,IAAI,CAAC;QACJ,OAAO,cAAc,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,CAAC,+BAA+B,iBAAiB,EAAE,CAAC,CAAC;QAClE,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;AACF,CAAC,CAAC"}
@@ -0,0 +1,157 @@
1
+ import { A as s, e as H, P, r as h, i as L, j as t, W as k, C as O, c as U, b as R, f as j, g as M, h as B, k as F, m as X, L as K, n as Y, o as V, p as $, l as q, d as z } from "./index-DkYajG2c.js";
2
+ import { n as J, g as _, p as Q, d as N, f as Z, b as v, i as ee, j as te, s as ne, E as ae, k as oe, l as se, m as re, C as ie } from "./utils-CAk_TqSc.js";
3
+ const ce = (r, e) => {
4
+ let o = 0;
5
+ const c = "0".repeat(e);
6
+ for (; ; ) {
7
+ const f = new TextEncoder().encode(o + r);
8
+ if (le(J(f)).startsWith(c))
9
+ return o;
10
+ o += 1;
11
+ }
12
+ }, le = (r) => Array.from(r).map((e) => e.toString(16).padStart(2, "0")).join(""), ue = (r, e, o, c) => {
13
+ const f = _(o, e, c), m = () => ({
14
+ showModal: !1,
15
+ loading: !1,
16
+ index: 0,
17
+ challenge: void 0,
18
+ solutions: void 0,
19
+ isHuman: !1,
20
+ captchaApi: void 0,
21
+ account: void 0
22
+ }), l = () => {
23
+ window.clearTimeout(e.timeout), n({ timeout: void 0 });
24
+ }, x = () => {
25
+ window.clearTimeout(e.successfullChallengeTimeout), n({ successfullChallengeTimeout: void 0 });
26
+ }, g = () => {
27
+ const a = {
28
+ userAccountAddress: "",
29
+ ...r
30
+ };
31
+ return e.account && (a.userAccountAddress = e.account.account.address), P.parse(a);
32
+ }, p = () => {
33
+ if (!e.account)
34
+ throw new v("GENERAL.ACCOUNT_NOT_FOUND", {
35
+ context: { error: "Account not loaded" }
36
+ });
37
+ return { account: e.account };
38
+ }, u = () => {
39
+ if (!e.dappAccount)
40
+ throw new v("GENERAL.SITE_KEY_MISSING");
41
+ return e.dappAccount;
42
+ }, n = N(e, o), d = () => {
43
+ l(), x(), n(m());
44
+ }, w = () => {
45
+ const a = g().captchas.pow.solutionTimeout, A = setTimeout(() => {
46
+ n({ isHuman: !1 }), f.onExpired();
47
+ }, a);
48
+ n({ successfullChallengeTimeout: A });
49
+ }, C = async () => {
50
+ await Q(async () => {
51
+ var S;
52
+ if (e.loading || e.isHuman)
53
+ return;
54
+ d(), n({
55
+ loading: !0
56
+ }), n({ attemptCount: e.attemptCount + 1 });
57
+ const a = g(), A = a.web2 ? new ae() : new oe(), E = a.userAccountAddress || (await A.getAccount(a)).account.address;
58
+ if (n({
59
+ account: { account: { address: E } }
60
+ }), n({ dappAccount: a.account.address }), await Z(100), !a.web2 && !a.userAccountAddress)
61
+ throw new v("GENERAL.ACCOUNT_NOT_FOUND", {
62
+ context: {
63
+ error: "Account address has not been set for web3 mode"
64
+ }
65
+ });
66
+ const W = await ee(g()), G = _(o, e, c), b = W.provider.url, y = new te(b, u()), i = await y.getPowCaptchaChallenge(E, u());
67
+ if (i.error)
68
+ n({
69
+ error: i.error,
70
+ loading: !1
71
+ });
72
+ else {
73
+ const D = ce(i.challenge, i.difficulty), T = (S = (await A.getAccount(g())).extension) == null ? void 0 : S.signer;
74
+ if (!T || !T.signRaw)
75
+ throw new v("GENERAL.CANT_FIND_KEYRINGPAIR", {
76
+ context: {
77
+ error: "Signer is not defined, cannot sign message to prove account ownership"
78
+ }
79
+ });
80
+ const I = await T.signRaw({
81
+ address: E,
82
+ data: ne(i[s.timestamp].toString()),
83
+ type: "bytes"
84
+ });
85
+ (await y.submitPowCaptchaSolution(i, p().account.account.address, u(), D, I.signature.toString(), a.captchas.pow.verifiedTimeout))[s.verified] && (n({
86
+ isHuman: !0,
87
+ loading: !1
88
+ }), G.onHuman(H({
89
+ [s.providerUrl]: b,
90
+ [s.user]: p().account.account.address,
91
+ [s.dapp]: u(),
92
+ [s.challenge]: i.challenge,
93
+ [s.nonce]: D,
94
+ [s.timestamp]: i.timestamp,
95
+ [s.signature]: {
96
+ [s.provider]: i.signature.provider,
97
+ [s.user]: {
98
+ [s.timestamp]: I.signature.toString()
99
+ }
100
+ }
101
+ })), w());
102
+ }
103
+ }, C, d, e.attemptCount, 10);
104
+ };
105
+ return {
106
+ start: C,
107
+ resetState: d
108
+ };
109
+ }, he = (r) => {
110
+ const { t: e } = se(), o = r.config, c = o.theme === "light" ? "light" : "dark", f = r.config.theme === "light" ? q : z, m = r.callbacks || {}, [l, x] = re(h.useState, h.useRef), g = N(l, x), p = h.useRef(ue(o, l, g, m)), u = h.useRef(null);
111
+ return h.useEffect(() => {
112
+ const n = u.current;
113
+ if (!n)
114
+ return;
115
+ const d = n.closest("form");
116
+ if (!d)
117
+ return;
118
+ const w = () => {
119
+ p.current.resetState();
120
+ };
121
+ return d.addEventListener("submit", w), o.language && L.changeLanguage(o.language), () => {
122
+ d.removeEventListener("submit", w);
123
+ };
124
+ }, [o.language]), t("div", { ref: u, children: t("div", { style: {
125
+ maxWidth: k,
126
+ maxHeight: "100%",
127
+ overflowX: "auto"
128
+ }, children: t(O, { children: t(U, { children: R("div", { style: j, "data-cy": "button-human", children: [" ", R("div", { style: {
129
+ padding: M,
130
+ border: B,
131
+ backgroundColor: f.palette.background.default,
132
+ borderColor: f.palette.grey[300],
133
+ borderRadius: F,
134
+ display: "flex",
135
+ alignItems: "center",
136
+ flexWrap: "wrap",
137
+ justifyContent: "space-between",
138
+ minHeight: `${X}px`,
139
+ overflow: "hidden"
140
+ }, children: [t("div", { style: { display: "inline-flex", flexDirection: "column" }, children: t("div", { style: {
141
+ display: "flex",
142
+ justifyContent: "flex-start",
143
+ alignItems: "center",
144
+ flexWrap: "wrap"
145
+ }, children: t("div", { style: {
146
+ display: "flex",
147
+ alignItems: "center",
148
+ justifyContent: "center",
149
+ flexDirection: "column",
150
+ verticalAlign: "middle"
151
+ }, children: t("div", { style: {
152
+ display: "flex"
153
+ }, children: t("div", { style: { flex: 1 }, children: l.loading ? t(K, { themeColor: c, "aria-label": "Loading spinner" }) : t(ie, { checked: l.isHuman, onChange: p.current.start, themeColor: c, labelText: e("WIDGET.I_AM_HUMAN"), error: l.error, "aria-label": "human checkbox" }) }) }) }) }) }), t("div", { style: { display: "inline-flex", flexDirection: "column" }, children: t("a", { href: Y, target: "_blank", "aria-label": V, rel: "noreferrer", children: t("div", { style: { flex: 1 }, children: t($, { themeColor: c, "aria-label": "Prosopo logo" }) }) }) })] })] }) }) }) }) });
154
+ };
155
+ export {
156
+ he as default
157
+ };
@@ -1,5 +1,5 @@
1
- import { z as P, P as b, a as u, b as I, c as D, e as ie, A as x, d as q, r as A, l as L, f as M, j as s, g as C, R as se, i as ce, W as le, C as de, h as he, k as pe, m as ue, n as ge, o as fe, p as me, L as xe, q as Ce, s as be, t as Ae } from "./index-Ck7UqzKB.js";
2
- import { u as ye, h as we, a as j, s as X, g as Te, p as F, b as Ee, c as Ie, d as Se, e as ve, r as Ne, P as He, E as De, f as Re, i as Y, j as _e, C as Pe } from "./utils-9IQXYrRR.js";
1
+ import { z as P, a as u, A as f, e as ie, P as X, r as y, l as L, d as M, j as s, b, R as se, i as ce, W as le, C as de, c as he, f as pe, g as ue, h as ge, k as fe, m as me, L as xe, n as Ce, o as be, p as Ae } from "./index-DkYajG2c.js";
2
+ import { u as ye, h as we, a as j, P as A, b as I, c as D, s as q, g as Te, p as F, d as Ee, e as Ie, f as Se, i as ve, r as Ne, j as He, E as De, k as Re, l as Y, m as _e, C as Pe } from "./utils-CAk_TqSc.js";
3
3
  function ke(t) {
4
4
  return ye(we(t));
5
5
  }
@@ -52,7 +52,7 @@ class We {
52
52
  }
53
53
  getRoot() {
54
54
  if (this.root === void 0)
55
- throw new b("DATASET.MERKLE_ERROR", {
55
+ throw new A("DATASET.MERKLE_ERROR", {
56
56
  context: {
57
57
  error: "root undefined",
58
58
  failedFuncName: this.getRoot.name
@@ -79,7 +79,7 @@ class We {
79
79
  for (; n < o; ) {
80
80
  const c = e[n];
81
81
  if (c === void 0)
82
- throw new b("DEVELOPER.GENERAL", {
82
+ throw new A("DEVELOPER.GENERAL", {
83
83
  context: { error: "leftChild undefined" }
84
84
  });
85
85
  const d = n + 1 < o ? u(e, n + 1) : c, i = this.createParent(c, d);
@@ -97,7 +97,7 @@ class We {
97
97
  for (; r < this.layers.length - 1; ) {
98
98
  const a = this.layers[r];
99
99
  if (a === void 0)
100
- throw new b("DATASET.MERKLE_ERROR", {
100
+ throw new A("DATASET.MERKLE_ERROR", {
101
101
  context: {
102
102
  error: "layer undefined",
103
103
  failedFuncName: this.proof.name,
@@ -124,6 +124,8 @@ class Ue {
124
124
  async getCaptchaChallenge() {
125
125
  try {
126
126
  const e = await this.providerApi.getCaptchaChallenge(this.userAccount, this.provider);
127
+ if (e[f.error])
128
+ return e;
127
129
  for (const o of e.captchas)
128
130
  for (const r of o.items)
129
131
  r.data && (r.data = r.data.replace(/^http(s)*:\/\//, "//"));
@@ -141,15 +143,15 @@ class Ue {
141
143
  context: { error: "Merkle tree root is undefined" }
142
144
  });
143
145
  const i = c.root.hash, g = void 0;
144
- let y;
146
+ let w;
145
147
  try {
146
- y = await this.providerApi.submitCaptchaSolution(r, o, this.userAccount, n, a, e);
148
+ w = await this.providerApi.submitCaptchaSolution(r, o, this.userAccount, n, a, e);
147
149
  } catch (h) {
148
150
  throw new D("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
149
151
  context: { error: h }
150
152
  });
151
153
  }
152
- return [y, i, g];
154
+ return [w, i, g];
153
155
  }
154
156
  }
155
157
  const Q = "@prosopo/procaptcha";
@@ -157,7 +159,7 @@ function z() {
157
159
  return Z.parse(JSON.parse(ke(localStorage.getItem(Q) || "0x7b7d")));
158
160
  }
159
161
  function ee(t) {
160
- localStorage.setItem(Q, X(JSON.stringify(Z.parse(t))));
162
+ localStorage.setItem(Q, q(JSON.stringify(Z.parse(t))));
161
163
  }
162
164
  function Be(t) {
163
165
  ee({ ...z(), account: t });
@@ -186,7 +188,7 @@ function ze(t, e, o, r) {
186
188
  userAccountAddress: "",
187
189
  ...t
188
190
  };
189
- return e.account && (l.userAccountAddress = e.account.account.address), q.parse(l);
191
+ return e.account && (l.userAccountAddress = e.account.account.address), X.parse(l);
190
192
  }, d = async () => {
191
193
  n.onOpen(), await F(async () => {
192
194
  if (e.loading || e.isHuman)
@@ -196,30 +198,37 @@ function ze(t, e, o, r) {
196
198
  });
197
199
  const l = c();
198
200
  a({ dappAccount: l.account.address }), await Se(100);
199
- const p = await te(), f = await ve(c()), m = f.provider.url, N = await v(m), W = new Ue(p.account.address, f, N, l.web2, l.account.address || "");
201
+ const p = await te(), m = await ve(c()), x = m.provider.url, N = await v(x), W = new Ue(p.account.address, m, N, l.web2, l.account.address || "");
200
202
  a({ captchaApi: W });
201
- const T = await W.getCaptchaChallenge();
202
- if (T.captchas.length <= 0)
203
- throw new D("DEVELOPER.PROVIDER_NO_CAPTCHA");
204
- const _ = T.captchas.map((S) => S.timeLimitMs || l.captchas.image.challengeTimeout).reduce((S, E) => S + E), H = setTimeout(() => {
205
- n.onChallengeExpired(), a({ isHuman: !1, showModal: !1, loading: !1 });
206
- }, _);
207
- a({
208
- index: 0,
209
- solutions: T.captchas.map(() => []),
210
- challenge: T,
211
- showModal: !0,
212
- timeout: H
213
- });
203
+ const C = await W.getCaptchaChallenge();
204
+ if (C.error)
205
+ a({
206
+ loading: !1,
207
+ error: C.error
208
+ });
209
+ else {
210
+ if (C.captchas.length <= 0)
211
+ throw new D("DEVELOPER.PROVIDER_NO_CAPTCHA");
212
+ const _ = C.captchas.map((S) => S.timeLimitMs || l.captchas.image.challengeTimeout).reduce((S, E) => S + E), H = setTimeout(() => {
213
+ n.onChallengeExpired(), a({ isHuman: !1, showModal: !1, loading: !1 });
214
+ }, _);
215
+ a({
216
+ index: 0,
217
+ solutions: C.captchas.map(() => []),
218
+ challenge: C,
219
+ showModal: !0,
220
+ timeout: H
221
+ });
222
+ }
214
223
  }, d, R, e.attemptCount, 10);
215
224
  }, i = async () => {
216
225
  await F(async () => {
217
- if (w(), !e.challenge)
218
- throw new b("CAPTCHA.NO_CAPTCHA", {
226
+ if (T(), !e.challenge)
227
+ throw new A("CAPTCHA.NO_CAPTCHA", {
219
228
  context: { error: "Cannot submit, no Captcha found in state" }
220
229
  });
221
230
  a({ showModal: !1 });
222
- const l = e.challenge, p = Ne(), f = e.challenge.captchas.map((E, ae) => {
231
+ const l = e.challenge, p = Ne(), m = e.challenge.captchas.map((E, ae) => {
223
232
  const re = u(e.solutions, ae);
224
233
  return {
225
234
  captchaId: E.captchaId,
@@ -227,14 +236,14 @@ function ze(t, e, o, r) {
227
236
  salt: p,
228
237
  solution: re
229
238
  };
230
- }), m = G(), N = oe(m).signer;
239
+ }), x = G(), N = oe(x).signer;
231
240
  if (!u(l.captchas, 0).datasetId)
232
241
  throw new D("CAPTCHA.INVALID_CAPTCHA_ID", {
233
242
  context: { error: "No datasetId set for challenge" }
234
243
  });
235
- const T = e.captchaApi;
236
- if (!T)
237
- throw new b("CAPTCHA.INVALID_TOKEN", {
244
+ const C = e.captchaApi;
245
+ if (!C)
246
+ throw new A("CAPTCHA.INVALID_TOKEN", {
238
247
  context: { error: "No Captcha API found in state" }
239
248
  });
240
249
  if (!N || !N.signRaw)
@@ -244,58 +253,58 @@ function ze(t, e, o, r) {
244
253
  }
245
254
  });
246
255
  const _ = await N.signRaw({
247
- address: m.account.address,
248
- data: X(l.requestHash),
256
+ address: x.account.address,
257
+ data: q(l.requestHash),
249
258
  type: "bytes"
250
- }), H = await T.submitCaptchaSolution(_.signature, l.requestHash, f, l.timestamp, l.signature.provider.requestHash), S = H[0].verified;
259
+ }), H = await C.submitCaptchaSolution(_.signature, l.requestHash, m, l.timestamp, l.signature.provider.requestHash), S = H[0].verified;
251
260
  if (S || n.onFailed(), a({
252
261
  submission: H,
253
262
  isHuman: S,
254
263
  loading: !1
255
264
  }), e.isHuman) {
256
- const E = T.provider.provider.url;
265
+ const E = C.provider.provider.url;
257
266
  B.setProcaptchaStorage({
258
267
  ...B.getProcaptchaStorage(),
259
268
  providerUrl: E
260
269
  }), n.onHuman(ie({
261
- [x.providerUrl]: E,
262
- [x.user]: m.account.address,
263
- [x.dapp]: ne(),
264
- [x.commitmentId]: Oe(H[1]),
265
- [x.timestamp]: l.timestamp,
266
- [x.signature]: {
267
- [x.provider]: {
268
- [x.requestHash]: l.signature.provider.requestHash
270
+ [f.providerUrl]: E,
271
+ [f.user]: x.account.address,
272
+ [f.dapp]: ne(),
273
+ [f.commitmentId]: Oe(H[1]),
274
+ [f.timestamp]: l.timestamp,
275
+ [f.signature]: {
276
+ [f.provider]: {
277
+ [f.requestHash]: l.signature.provider.requestHash
269
278
  },
270
- [x.user]: {
271
- [x.requestHash]: _.signature
279
+ [f.user]: {
280
+ [f.requestHash]: _.signature
272
281
  }
273
282
  }
274
283
  })), O();
275
284
  }
276
285
  }, d, R, e.attemptCount, 10);
277
286
  }, g = async () => {
278
- w(), R(), n.onClose();
279
- }, y = (l) => {
287
+ T(), R(), n.onClose();
288
+ }, w = (l) => {
280
289
  if (!e.challenge)
281
- throw new b("CAPTCHA.NO_CAPTCHA", {
290
+ throw new A("CAPTCHA.NO_CAPTCHA", {
282
291
  context: { error: "Cannot select, no Captcha found in state" }
283
292
  });
284
293
  if (e.index >= e.challenge.captchas.length || e.index < 0)
285
- throw new b("CAPTCHA.NO_CAPTCHA", {
294
+ throw new A("CAPTCHA.NO_CAPTCHA", {
286
295
  context: {
287
296
  error: "Cannot select, index is out of range for this Captcha"
288
297
  }
289
298
  });
290
- const p = e.index, f = e.solutions, m = u(f, p);
291
- m.includes(l) ? m.splice(m.indexOf(l), 1) : m.push(l), a({ solutions: f });
299
+ const p = e.index, m = e.solutions, x = u(m, p);
300
+ x.includes(l) ? x.splice(x.indexOf(l), 1) : x.push(l), a({ solutions: m });
292
301
  }, h = () => {
293
302
  if (!e.challenge)
294
- throw new b("CAPTCHA.NO_CAPTCHA", {
303
+ throw new A("CAPTCHA.NO_CAPTCHA", {
295
304
  context: { error: "Cannot select, no Captcha found in state" }
296
305
  });
297
306
  if (e.index + 1 >= e.challenge.captchas.length)
298
- throw new b("CAPTCHA.NO_CAPTCHA", {
307
+ throw new A("CAPTCHA.NO_CAPTCHA", {
299
308
  context: {
300
309
  error: "Cannot select, index is out of range for this Captcha"
301
310
  }
@@ -306,7 +315,7 @@ function ze(t, e, o, r) {
306
315
  if (!p.account.address)
307
316
  throw new I("GENERAL.SITE_KEY_MISSING");
308
317
  return new He(l, p.account.address);
309
- }, w = () => {
318
+ }, T = () => {
310
319
  window.clearTimeout(e.timeout), a({ timeout: void 0 });
311
320
  }, O = () => {
312
321
  const l = t.captchas.image.solutionTimeout, p = setTimeout(() => {
@@ -314,15 +323,15 @@ function ze(t, e, o, r) {
314
323
  }, l);
315
324
  a({ successfullChallengeTimeout: p });
316
325
  }, R = () => {
317
- w(), a($e());
326
+ T(), a($e());
318
327
  }, te = async () => {
319
328
  const l = c();
320
329
  if (!l.web2 && !l.userAccountAddress)
321
330
  throw new I("GENERAL.ACCOUNT_NOT_FOUND", {
322
331
  context: { error: "Account address has not been set for web3 mode" }
323
332
  });
324
- const f = await (l.web2 ? new De() : new Re()).getAccount(l);
325
- return B.setAccount(f.account.address), a({ account: f }), G();
333
+ const m = await (l.web2 ? new De() : new Re()).getAccount(l);
334
+ return B.setAccount(m.account.address), a({ account: m }), G();
326
335
  }, G = () => {
327
336
  if (!e.account)
328
337
  throw new I("GENERAL.ACCOUNT_NOT_FOUND", {
@@ -345,7 +354,7 @@ function ze(t, e, o, r) {
345
354
  start: d,
346
355
  cancel: g,
347
356
  submit: i,
348
- select: y,
357
+ select: w,
349
358
  nextRound: h
350
359
  };
351
360
  }
@@ -356,7 +365,7 @@ const Fe = (t) => {
356
365
  });
357
366
  return t.hash;
358
367
  }, Ke = ({ challenge: t, solution: e, onClick: o, themeColor: r }) => {
359
- const n = t.items, a = A.useMemo(() => r === "light" ? L : M, [r]), c = "ontouchstart" in window, d = `${a.spacing.unit}px`, i = `${a.spacing.half}px`, g = {
368
+ const n = t.items, a = y.useMemo(() => r === "light" ? L : M, [r]), c = "ontouchstart" in window, d = `${a.spacing.unit}px`, i = `${a.spacing.half}px`, g = {
360
369
  0: {
361
370
  paddingLeft: 0,
362
371
  paddingRight: i,
@@ -375,7 +384,7 @@ const Fe = (t) => {
375
384
  paddingTop: i,
376
385
  paddingBottom: i
377
386
  }
378
- }, y = {
387
+ }, w = {
379
388
  0: { paddingTop: d },
380
389
  2: { paddingBottom: d }
381
390
  };
@@ -388,24 +397,24 @@ const Fe = (t) => {
388
397
  flexDirection: "row",
389
398
  flexWrap: "wrap"
390
399
  }, children: n.map((h, v) => {
391
- const w = Fe(h), O = {
400
+ const T = Fe(h), O = {
392
401
  ...g[v % 3],
393
- ...y[Math.floor(v / 3)],
402
+ ...w[Math.floor(v / 3)],
394
403
  flexGrow: 1,
395
404
  flexBasis: "33.3333%",
396
405
  boxSizing: "border-box"
397
406
  };
398
- return s("div", { style: O, children: C("div", { style: {
407
+ return s("div", { style: O, children: b("div", { style: {
399
408
  cursor: "pointer",
400
409
  height: "100%",
401
410
  width: "100%",
402
411
  border: 1,
403
412
  borderStyle: "solid",
404
413
  borderColor: a.palette.grey[300]
405
- }, onClick: c ? void 0 : () => o(w), onTouchStart: c ? () => o(w) : void 0, children: [s("div", { children: s("img", { style: {
414
+ }, onClick: c ? void 0 : () => o(T), onTouchStart: c ? () => o(T) : void 0, children: [s("div", { children: s("img", { style: {
406
415
  width: "100%",
407
416
  backgroundColor: a.palette.grey[300],
408
- opacity: e.includes(w) && c ? "50%" : "100%",
417
+ opacity: e.includes(T) && c ? "50%" : "100%",
409
418
  display: "block",
410
419
  objectFit: "contain",
411
420
  aspectRatio: "1/1",
@@ -415,7 +424,7 @@ const Fe = (t) => {
415
424
  width: "100%",
416
425
  height: "100%",
417
426
  top: "-100%",
418
- visibility: e.includes(w) ? "visible" : "hidden",
427
+ visibility: e.includes(T) ? "visible" : "hidden",
419
428
  transition: "opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
420
429
  opacity: 1
421
430
  }, children: s("div", { style: {
@@ -449,7 +458,7 @@ function $({ general: t, dev: e }) {
449
458
  ...Ve(t)
450
459
  };
451
460
  }
452
- const qe = {
461
+ const Xe = {
453
462
  display: "inline-flex",
454
463
  alignItems: "center",
455
464
  justifyContent: "center",
@@ -476,9 +485,9 @@ const qe = {
476
485
  backgroundColor: "#ffffff",
477
486
  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"
478
487
  }, V = ({ themeColor: t, buttonType: e, text: o, onClick: r }) => {
479
- const n = A.useMemo(() => t === "light" ? L : M, [t]), [a, c] = A.useState(!1), d = A.useMemo(() => {
488
+ const n = y.useMemo(() => t === "light" ? L : M, [t]), [a, c] = y.useState(!1), d = y.useMemo(() => {
480
489
  const i = {
481
- ...qe,
490
+ ...Xe,
482
491
  color: a ? n.palette.primary.contrastText : n.palette.background.contrastText
483
492
  };
484
493
  return e === "cancel" ? {
@@ -492,9 +501,9 @@ const qe = {
492
501
  return s("button", { ...$({ dev: { cy: `button-${e}` } }), onMouseEnter: () => c(!0), onMouseLeave: () => c(!1), style: d, onClick: (i) => {
493
502
  i.preventDefault(), r();
494
503
  }, "aria-label": o, children: o });
495
- }, Xe = ({ challenge: t, index: e, solutions: o, onSubmit: r, onCancel: n, onClick: a, onNext: c, themeColor: d }) => {
496
- const { t: i } = Y(), g = t.captchas ? u(t.captchas, e) : null, y = o ? u(o, e) : [], h = A.useMemo(() => d === "light" ? L : M, [d]);
497
- return s(A.Suspense, { fallback: s("div", { children: "Loading..." }), children: s("div", { style: {
504
+ }, qe = ({ challenge: t, index: e, solutions: o, onSubmit: r, onCancel: n, onClick: a, onNext: c, themeColor: d }) => {
505
+ const { t: i } = Y(), g = t.captchas ? u(t.captchas, e) : null, w = o ? u(o, e) : [], h = y.useMemo(() => d === "light" ? L : M, [d]);
506
+ return s(y.Suspense, { fallback: s("div", { children: "Loading..." }), children: s("div", { style: {
498
507
  overflowX: "auto",
499
508
  overflowY: "auto",
500
509
  width: "100%",
@@ -507,7 +516,7 @@ const qe = {
507
516
  borderRadius: "4px",
508
517
  padding: `${h.spacing.unit}px`,
509
518
  backgroundColor: h.palette.background.default
510
- }, children: C("div", { style: {
519
+ }, children: b("div", { style: {
511
520
  backgroundColor: h.palette.background.default,
512
521
  display: "flex",
513
522
  flexDirection: "column",
@@ -519,10 +528,10 @@ const qe = {
519
528
  }, children: s("div", { style: {
520
529
  backgroundColor: h.palette.primary.main,
521
530
  width: "100%"
522
- }, children: C("div", { style: {
531
+ }, children: b("div", { style: {
523
532
  paddingLeft: `${h.spacing.half}px`,
524
533
  paddingRight: `${h.spacing.half}px`
525
- }, children: [C("p", { style: {
534
+ }, children: [b("p", { style: {
526
535
  color: "#ffffff",
527
536
  fontWeight: 700,
528
537
  lineHeight: 1.5
@@ -531,7 +540,7 @@ const qe = {
531
540
  fontWeight: 500,
532
541
  lineHeight: 0.8,
533
542
  fontSize: "0.8rem"
534
- }, children: i("WIDGET.IF_NONE_CLICK_NEXT") })] }) }) }), s("div", { ...$({ dev: { cy: `captcha-${e}` } }), children: g && s(Ke, { challenge: g, solution: y, onClick: a, themeColor: d }) }), s("div", { style: {
543
+ }, children: i("WIDGET.IF_NONE_CLICK_NEXT") })] }) }) }), s("div", { ...$({ dev: { cy: `captcha-${e}` } }), children: g && s(Ke, { challenge: g, solution: w, onClick: a, themeColor: d }) }), s("div", { style: {
535
544
  display: "flex",
536
545
  alignItems: "center",
537
546
  justifyContent: "center",
@@ -540,7 +549,7 @@ const qe = {
540
549
  padding: `0 ${h.spacing}px`,
541
550
  display: "flex",
542
551
  width: "100%"
543
- } }), C("div", { style: {
552
+ } }), b("div", { style: {
544
553
  padding: `0 ${h.spacing}px`,
545
554
  display: "flex",
546
555
  alignItems: "center",
@@ -574,16 +583,16 @@ const qe = {
574
583
  border: "none",
575
584
  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,"
576
585
  };
577
- return C("div", { className: "prosopo-modalOuter", style: a, children: [s("div", { className: "prosopo-modalBackground", style: c }), s("div", { className: "prosopo-modalInner", style: d, children: r })] });
586
+ return b("div", { className: "prosopo-modalOuter", style: a, children: [s("div", { className: "prosopo-modalBackground", style: c }), s("div", { className: "prosopo-modalInner", style: d, children: r })] });
578
587
  }), Qe = (t) => {
579
- const { t: e } = Y(), o = q.parse(t.config), r = t.callbacks || {}, [n, a] = _e(A.useState, A.useRef), c = ze(o, n, a, r), d = t.config.theme === "light" ? "light" : "dark", i = t.config.theme === "light" ? L : M;
580
- return A.useEffect(() => {
588
+ const { t: e } = Y(), o = X.parse(t.config), r = t.callbacks || {}, [n, a] = _e(y.useState, y.useRef), c = ze(o, n, a, r), d = t.config.theme === "light" ? "light" : "dark", i = t.config.theme === "light" ? L : M;
589
+ return y.useEffect(() => {
581
590
  o.language && ce.changeLanguage(o.language);
582
- }, [o.language]), s("div", { children: C("div", { style: {
591
+ }, [o.language]), s("div", { children: b("div", { style: {
583
592
  maxWidth: le,
584
593
  maxHeight: "100%",
585
594
  overflowX: "auto"
586
- }, children: [s(Ye, { show: n.showModal, children: n.challenge ? s(Xe, { challenge: n.challenge, index: n.index, solutions: n.solutions, onSubmit: c.submit, onCancel: c.cancel, onClick: c.select, onNext: c.nextRound, themeColor: o.theme ?? "light" }) : s("div", { children: "No challenge set." }) }), s(de, { children: s(he, { children: C("div", { style: pe, "data-cy": "button-human", children: [" ", C("div", { style: {
595
+ }, children: [s(Ye, { show: n.showModal, children: n.challenge ? s(qe, { challenge: n.challenge, index: n.index, solutions: n.solutions, onSubmit: c.submit, onCancel: c.cancel, onClick: c.select, onNext: c.nextRound, themeColor: o.theme ?? "light" }) : s("div", { children: "No challenge set." }) }), s(de, { children: s(he, { children: b("div", { style: pe, "data-cy": "button-human", children: [" ", b("div", { style: {
587
596
  padding: ue,
588
597
  border: ge,
589
598
  backgroundColor: i.palette.background.default,
@@ -598,15 +607,15 @@ const qe = {
598
607
  }, children: [s("div", { style: { display: "inline-flex", flexDirection: "column" }, children: s("div", { style: {
599
608
  alignItems: "center",
600
609
  flex: 1
601
- }, children: C("div", { style: {
610
+ }, children: b("div", { style: {
602
611
  display: "flex",
603
612
  alignItems: "center",
604
613
  justifyContent: "center",
605
614
  flexDirection: "column",
606
615
  verticalAlign: "middle"
607
616
  }, children: [s("div", { style: {
608
- display: n.loading ? "none" : "flex"
609
- }, children: s(Pe, { themeColor: d, onChange: c.start, checked: n.isHuman, labelText: e("WIDGET.I_AM_HUMAN"), "aria-label": "human checkbox" }) }), s("div", { style: {
617
+ display: !n.loading && !n.error ? "flex" : "none"
618
+ }, children: s(Pe, { themeColor: d, onChange: c.start, checked: n.isHuman, labelText: e("WIDGET.I_AM_HUMAN"), error: n.error, "aria-label": "human checkbox" }) }), s("div", { style: {
610
619
  display: n.loading ? "flex" : "none"
611
620
  }, children: s("div", { style: { display: "inline-flex" }, children: s(xe, { themeColor: d, "aria-label": "Loading spinner" }) }) })] }) }) }), s("div", { style: { display: "inline-flex", flexDirection: "column" }, children: s("a", { href: Ce, target: "_blank", "aria-label": be, rel: "noreferrer", children: s("div", { style: { flex: 1 }, children: s(Ae, { themeColor: d, "aria-label": "Prosopo logo" }) }) }) })] })] }) }) })] }) });
612
621
  };