@prosopo/procaptcha-bundle 2.3.2 → 2.4.2

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 (160) hide show
  1. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/components.d.ts +5 -0
  2. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/components.d.ts.map +1 -0
  3. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/components.js +5 -0
  4. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/components.js.map +1 -0
  5. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/index.d.ts.map +1 -1
  6. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/index.js +1 -1
  7. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/index.js.map +1 -1
  8. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/tests/util/captchaType.test.js +4 -4
  9. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/tests/util/captchaType.test.js.map +1 -1
  10. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/captchaType.d.ts.map +1 -1
  11. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/captchaType.js +2 -2
  12. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/captchaType.js.map +1 -1
  13. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/captcha.d.ts +4 -8
  14. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/captcha.d.ts.map +1 -1
  15. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/captcha.js +1 -4
  16. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/captcha.js.map +1 -1
  17. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/captchaRenderer.d.ts +2 -2
  18. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/captchaRenderer.d.ts.map +1 -1
  19. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/captchaRenderer.js.map +1 -1
  20. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/frictionlessCaptcha.d.ts +2 -4
  21. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/frictionlessCaptcha.d.ts.map +1 -1
  22. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/frictionlessCaptcha.js +10 -7
  23. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/frictionlessCaptcha.js.map +1 -1
  24. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/imageCaptcha.d.ts +2 -4
  25. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/imageCaptcha.d.ts.map +1 -1
  26. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/imageCaptcha.js +5 -7
  27. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/imageCaptcha.js.map +1 -1
  28. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/powCaptcha.d.ts +2 -4
  29. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/powCaptcha.d.ts.map +1 -1
  30. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/powCaptcha.js +5 -7
  31. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/components/powCaptcha.js.map +1 -1
  32. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/componentsList.d.ts +2 -2
  33. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/componentsList.d.ts.map +1 -1
  34. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/componentsList.js +4 -4
  35. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/captcha/componentsList.js.map +1 -1
  36. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/webComponent.d.ts.map +1 -1
  37. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/webComponent.js +6 -1
  38. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/webComponent.js.map +1 -1
  39. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/widgetRenderer.d.ts +3 -4
  40. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/widgetRenderer.d.ts.map +1 -1
  41. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/widgetRenderer.js +1 -1
  42. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic/widgetRenderer.js.map +1 -1
  43. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic.js +2 -2
  44. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/renderLogic.js.map +1 -1
  45. package/dist/bundle/ProcaptchaWidget-CWr3QJxQ.js +161 -0
  46. package/dist/bundle/ProcaptchaWidget-DNDHo0wy.js +619 -0
  47. package/dist/bundle/{asU8a-BcA17eDA.js → asU8a-CzXEWKM2.js} +3 -3
  48. package/dist/bundle/{bip39-_F7Z5vIE.js → bip39-BY0qXKlh.js} +28 -27
  49. package/dist/bundle/browser-ponyfill-QubLHHEB.js +339 -0
  50. package/dist/bundle/components.d.ts +5 -0
  51. package/dist/bundle/components.d.ts.map +1 -0
  52. package/dist/bundle/{hash-C7-gVTqE.js → hash-BtiXKZG7.js} +460 -588
  53. package/dist/bundle/index-5BQn0RdY.js +11576 -0
  54. package/dist/bundle/{index-BH5dKH-o.js → index-CUmhpcqe.js} +17 -16
  55. package/dist/bundle/{index-DlBTo0Xd.js → index-n-2hvBzo.js} +405 -405
  56. package/dist/bundle/index-vKa71Rut.js +4372 -0
  57. package/dist/bundle/index.d.ts.map +1 -1
  58. package/dist/bundle/locales/de/translation.json +405 -0
  59. package/dist/bundle/locales/en/translation.json +405 -0
  60. package/dist/bundle/locales/es/translation.json +405 -0
  61. package/dist/bundle/locales/fr/translation.json +405 -0
  62. package/dist/bundle/locales/it/translation.json +405 -0
  63. package/dist/bundle/locales/pt/translation.json +405 -0
  64. package/dist/bundle/locales/pt-BR/translation.json +405 -0
  65. package/dist/bundle/procaptcha.bundle.js +1 -1
  66. package/dist/bundle/{sha256-Bcj1GDss.js → sha256-Cxc9Hrlx.js} +1 -1
  67. package/dist/bundle/toU8a-BWKf-2UU.js +133 -0
  68. package/dist/bundle/useTranslation-2VGhZyNk.js +2435 -0
  69. package/dist/bundle/util/captchaType.d.ts.map +1 -1
  70. package/dist/bundle/util/renderLogic/captcha/captcha.d.ts +4 -8
  71. package/dist/bundle/util/renderLogic/captcha/captcha.d.ts.map +1 -1
  72. package/dist/bundle/util/renderLogic/captcha/captchaRenderer.d.ts +2 -2
  73. package/dist/bundle/util/renderLogic/captcha/captchaRenderer.d.ts.map +1 -1
  74. package/dist/bundle/util/renderLogic/captcha/components/frictionlessCaptcha.d.ts +2 -4
  75. package/dist/bundle/util/renderLogic/captcha/components/frictionlessCaptcha.d.ts.map +1 -1
  76. package/dist/bundle/util/renderLogic/captcha/components/imageCaptcha.d.ts +2 -4
  77. package/dist/bundle/util/renderLogic/captcha/components/imageCaptcha.d.ts.map +1 -1
  78. package/dist/bundle/util/renderLogic/captcha/components/powCaptcha.d.ts +2 -4
  79. package/dist/bundle/util/renderLogic/captcha/components/powCaptcha.d.ts.map +1 -1
  80. package/dist/bundle/util/renderLogic/captcha/componentsList.d.ts +2 -2
  81. package/dist/bundle/util/renderLogic/captcha/componentsList.d.ts.map +1 -1
  82. package/dist/bundle/util/renderLogic/webComponent.d.ts.map +1 -1
  83. package/dist/bundle/util/renderLogic/widgetRenderer.d.ts +3 -4
  84. package/dist/bundle/util/renderLogic/widgetRenderer.d.ts.map +1 -1
  85. package/dist/components.d.ts +5 -0
  86. package/dist/components.d.ts.map +1 -0
  87. package/dist/components.js +5 -0
  88. package/dist/components.js.map +1 -0
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +1 -1
  91. package/dist/index.js.map +1 -1
  92. package/dist/tests/util/captchaType.test.js +4 -4
  93. package/dist/tests/util/captchaType.test.js.map +1 -1
  94. package/dist/util/captchaType.d.ts +2 -2
  95. package/dist/util/captchaType.d.ts.map +1 -1
  96. package/dist/util/captchaType.js +2 -2
  97. package/dist/util/captchaType.js.map +1 -1
  98. package/dist/util/renderLogic/captcha/captcha.d.ts +4 -8
  99. package/dist/util/renderLogic/captcha/captcha.d.ts.map +1 -1
  100. package/dist/util/renderLogic/captcha/captcha.js +1 -4
  101. package/dist/util/renderLogic/captcha/captcha.js.map +1 -1
  102. package/dist/util/renderLogic/captcha/captchaRenderer.d.ts +2 -2
  103. package/dist/util/renderLogic/captcha/captchaRenderer.d.ts.map +1 -1
  104. package/dist/util/renderLogic/captcha/captchaRenderer.js.map +1 -1
  105. package/dist/util/renderLogic/captcha/components/frictionlessCaptcha.d.ts +2 -4
  106. package/dist/util/renderLogic/captcha/components/frictionlessCaptcha.d.ts.map +1 -1
  107. package/dist/util/renderLogic/captcha/components/frictionlessCaptcha.js +10 -7
  108. package/dist/util/renderLogic/captcha/components/frictionlessCaptcha.js.map +1 -1
  109. package/dist/util/renderLogic/captcha/components/imageCaptcha.d.ts +2 -4
  110. package/dist/util/renderLogic/captcha/components/imageCaptcha.d.ts.map +1 -1
  111. package/dist/util/renderLogic/captcha/components/imageCaptcha.js +5 -7
  112. package/dist/util/renderLogic/captcha/components/imageCaptcha.js.map +1 -1
  113. package/dist/util/renderLogic/captcha/components/powCaptcha.d.ts +2 -4
  114. package/dist/util/renderLogic/captcha/components/powCaptcha.d.ts.map +1 -1
  115. package/dist/util/renderLogic/captcha/components/powCaptcha.js +5 -7
  116. package/dist/util/renderLogic/captcha/components/powCaptcha.js.map +1 -1
  117. package/dist/util/renderLogic/captcha/componentsList.d.ts +2 -2
  118. package/dist/util/renderLogic/captcha/componentsList.d.ts.map +1 -1
  119. package/dist/util/renderLogic/captcha/componentsList.js +4 -4
  120. package/dist/util/renderLogic/captcha/componentsList.js.map +1 -1
  121. package/dist/util/renderLogic/webComponent.d.ts.map +1 -1
  122. package/dist/util/renderLogic/webComponent.js +6 -1
  123. package/dist/util/renderLogic/webComponent.js.map +1 -1
  124. package/dist/util/renderLogic/widgetRenderer.d.ts +3 -4
  125. package/dist/util/renderLogic/widgetRenderer.d.ts.map +1 -1
  126. package/dist/util/renderLogic/widgetRenderer.js +1 -1
  127. package/dist/util/renderLogic/widgetRenderer.js.map +1 -1
  128. package/dist/util/renderLogic.js +2 -2
  129. package/dist/util/renderLogic.js.map +1 -1
  130. package/package.json +14 -10
  131. package/stats.html +1 -1
  132. package/vite.cjs.config.ts +1 -1
  133. package/vite.config.ts +32 -1
  134. package/vite.test.config.ts +1 -1
  135. package/webpack.config.cjs +1 -1
  136. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/defaultCallbacks.d.ts +0 -15
  137. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/defaultCallbacks.d.ts.map +0 -1
  138. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/defaultCallbacks.js +0 -178
  139. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/defaultCallbacks.js.map +0 -1
  140. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/form.d.ts +0 -2
  141. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/form.d.ts.map +0 -1
  142. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/form.js +0 -2
  143. package/.rollup.cache/home/runner/work/captcha-private/captcha-private/captcha/packages/procaptcha-bundle/dist/bundle/util/form.js.map +0 -1
  144. package/dist/bundle/Checkbox-gp52EwUq.js +0 -631
  145. package/dist/bundle/ProcaptchaWidget-BvScmKhX.js +0 -631
  146. package/dist/bundle/ProcaptchaWidget-D2i13eeY.js +0 -154
  147. package/dist/bundle/index-BYd5PSRY.js +0 -17233
  148. package/dist/bundle/index-BdsUZjbH.js +0 -6520
  149. package/dist/bundle/util/defaultCallbacks.d.ts +0 -15
  150. package/dist/bundle/util/defaultCallbacks.d.ts.map +0 -1
  151. package/dist/bundle/util/form.d.ts +0 -2
  152. package/dist/bundle/util/form.d.ts.map +0 -1
  153. package/dist/util/defaultCallbacks.d.ts +0 -15
  154. package/dist/util/defaultCallbacks.d.ts.map +0 -1
  155. package/dist/util/defaultCallbacks.js +0 -178
  156. package/dist/util/defaultCallbacks.js.map +0 -1
  157. package/dist/util/form.d.ts +0 -2
  158. package/dist/util/form.d.ts.map +0 -1
  159. package/dist/util/form.js +0 -2
  160. package/dist/util/form.js.map +0 -1
@@ -1,631 +0,0 @@
1
- import { N as W, r as m, s as L, t as P, j as i, d as C, O as _, Q as f, R as A, A as g, P as I, p as F, g as ce, e as le, a as de, b as X, S as ue, i as he, W as pe, C as ge, c as fe, f as me, h as xe, k as Ce, l as be, m as ye, L as Ae, n as we, o as Te, q as Ee } from "./index-BYd5PSRY.js";
2
- import { u as q, a as Y, g as Se, b as Ie, s as ve, c as Ne, C as He } from "./Checkbox-gp52EwUq.js";
3
- import { v as ke, x as De, y as $ } from "./hash-C7-gVTqE.js";
4
- import { a as Re } from "./asU8a-BcA17eDA.js";
5
- const _e = (t) => Array.isArray(t) && t !== null, G = new Array(256), J = new Array(256 * 256);
6
- for (let t = 0; t < 256; t++)
7
- G[t] = t.toString(16).padStart(2, "0");
8
- for (let t = 0; t < 256; t++) {
9
- const e = t << 8;
10
- for (let n = 0; n < 256; n++)
11
- J[e | n] = G[t] + G[n];
12
- }
13
- function B(t, e) {
14
- const n = t.length % 2 | 0, r = t.length - n | 0;
15
- for (let a = 0; a < r; a += 2)
16
- e += J[t[a] << 8 | t[a + 1]];
17
- return n && (e += G[t[r] | 0]), e;
18
- }
19
- function Le(t, e = -1, n = !0) {
20
- const r = n ? "0x" : "";
21
- if (!(t != null && t.length))
22
- return r;
23
- if (e > 0) {
24
- const a = Math.ceil(e / 8);
25
- if (t.length > a)
26
- return `${B(t.subarray(0, a / 2), r)}…${B(t.subarray(t.length - a / 2), "")}`;
27
- }
28
- return B(t, r);
29
- }
30
- const Pe = (t) => _e(t) ? Le(new Uint8Array(t)) : t.toString();
31
- function Me(t) {
32
- return ke(De(t));
33
- }
34
- const Z = W.object({
35
- account: W.string().optional(),
36
- blockNumber: W.number().optional(),
37
- providerUrl: W.string().optional()
38
- }), Oe = {
39
- border: "none",
40
- paddingTop: "6px",
41
- paddingBottom: "6px",
42
- cursor: "pointer",
43
- height: "39px",
44
- width: "39px",
45
- borderRadius: "50%"
46
- }, We = ({ themeColor: t, onReload: e }) => {
47
- const n = m.useMemo(() => t === "light" ? L : P, [t]), [r, a] = m.useState(!1), s = m.useMemo(() => ({
48
- ...{
49
- ...Oe,
50
- backgroundColor: n.palette.background.default,
51
- color: r ? n.palette.primary.contrastText : n.palette.background.contrastText
52
- },
53
- backgroundColor: r ? n.palette.grey[700] : n.palette.background.default
54
- }), [r, n]);
55
- return i("button", { className: "reload-button", "aria-label": "Reload", type: "button", style: s, onMouseEnter: () => a(!0), onMouseLeave: () => a(!1), onClick: (o) => {
56
- o.preventDefault(), e();
57
- }, children: C("svg", { width: "27px", height: "27px", viewBox: "0 0 27 27", version: "1.1", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", children: [i("title", { children: "reload" }), i("path", { fill: s.color, transform: "scale(0.0703125)", d: "M234.666667,149.333333 L234.666667,106.666667 L314.564847,106.664112 C287.579138,67.9778918 242.745446,42.6666667 192,42.6666667 C109.525477,42.6666667 42.6666667,109.525477 42.6666667,192 C42.6666667,274.474523 109.525477,341.333333 192,341.333333 C268.201293,341.333333 331.072074,284.258623 340.195444,210.526102 L382.537159,215.817985 C370.807686,310.617565 289.973536,384 192,384 C85.961328,384 1.42108547e-14,298.038672 1.42108547e-14,192 C1.42108547e-14,85.961328 85.961328,1.42108547e-14 192,1.42108547e-14 C252.316171,1.42108547e-14 306.136355,27.8126321 341.335366,71.3127128 L341.333333,1.42108547e-14 L384,1.42108547e-14 L384,149.333333 L234.666667,149.333333 Z" })] }) });
58
- }, Ge = (t) => {
59
- if (!t.hash)
60
- throw new _("CAPTCHA.MISSING_ITEM_HASH", {
61
- context: { item: t }
62
- });
63
- return t.hash;
64
- }, Ue = ({ challenge: t, solution: e, onClick: n, themeColor: r }) => {
65
- const a = t.items, s = m.useMemo(() => r === "light" ? L : P, [r]), o = `${s.spacing.half}px`;
66
- return i("div", { style: {
67
- width: "100%",
68
- height: "100%",
69
- display: "flex",
70
- flexDirection: "row",
71
- flexWrap: "wrap",
72
- justifyContent: "space-between",
73
- paddingBottom: o,
74
- paddingRight: o
75
- }, children: a.map((d, c) => {
76
- const u = Ge(d);
77
- return i("div", { style: {
78
- flexGrow: 1,
79
- flexBasis: "33.3333%",
80
- boxSizing: "border-box",
81
- paddingLeft: o,
82
- paddingTop: o
83
- }, children: C("div", { style: {
84
- position: "relative",
85
- cursor: "pointer",
86
- height: "100%",
87
- width: "100%",
88
- border: 1,
89
- padding: 0,
90
- margin: 0,
91
- borderStyle: "solid",
92
- borderColor: s.palette.grey[300]
93
- }, onClick: () => n(u), children: [i("img", { style: {
94
- width: "100%",
95
- backgroundColor: s.palette.grey[300],
96
- display: "block",
97
- objectFit: "contain",
98
- aspectRatio: "1/1",
99
- height: "auto"
100
- }, src: d.data, alt: `Captcha image ${c + 1}` }), i("div", { style: {
101
- position: "absolute",
102
- top: 0,
103
- left: 0,
104
- bottom: 0,
105
- right: 0,
106
- height: "100%",
107
- width: "100%",
108
- display: "flex",
109
- alignItems: "center",
110
- justifyContent: "center",
111
- backgroundColor: "rgba(0,0,0,0.5)",
112
- visibility: e.includes(u) ? "visible" : "hidden"
113
- }, children: i("svg", { style: {
114
- backgroundColor: "transparent",
115
- display: "block",
116
- width: "35%",
117
- height: "35%",
118
- transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
119
- userSelect: "none",
120
- fill: "currentcolor"
121
- }, focusable: "false", color: "#fff", "aria-hidden": "true", viewBox: "0 0 24 24", "data-testid": "CheckIcon", "aria-label": "Check icon", children: i("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) }) })] }) }, d.hash);
122
- }) });
123
- };
124
- function Be(t = {}) {
125
- return Object.keys(t).reduce((e, n) => ({ ...e, [`data-${n}`]: t[n] }), {});
126
- }
127
- function Q({ general: t, dev: e }) {
128
- return {
129
- ...Be(t)
130
- };
131
- }
132
- const je = {
133
- display: "inline-flex",
134
- alignItems: "center",
135
- justifyContent: "center",
136
- position: "relative",
137
- boxSizing: "border-box",
138
- outline: "0px",
139
- border: "0px",
140
- margin: "0px",
141
- cursor: "pointer",
142
- userSelect: "none",
143
- verticalAlign: "middle",
144
- appearance: void 0,
145
- textDecoration: "none",
146
- fontWeight: "500",
147
- fontSize: "0.875rem",
148
- lineHeight: "1.75",
149
- letterSpacing: "0.02857em",
150
- textTransform: "uppercase",
151
- minWidth: "64px",
152
- padding: "6px 16px",
153
- borderRadius: "4px",
154
- transition: "background-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, box-shadow 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, border-color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, color 250ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
155
- color: "rgb(0, 0, 0)",
156
- backgroundColor: "#ffffff",
157
- 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"
158
- }, K = ({ themeColor: t, buttonType: e, text: n, onClick: r }) => {
159
- const a = m.useMemo(() => t === "light" ? L : P, [t]), [s, o] = m.useState(!1), d = m.useMemo(() => {
160
- const c = {
161
- ...je,
162
- color: s ? a.palette.primary.contrastText : a.palette.background.contrastText
163
- };
164
- return e === "cancel" ? {
165
- ...c,
166
- backgroundColor: s ? a.palette.grey[600] : "transparent"
167
- } : {
168
- ...c,
169
- backgroundColor: s ? a.palette.primary.main : a.palette.background.default
170
- };
171
- }, [e, s, a]);
172
- return i("button", { ...Q({ dev: { cy: `button-${e}` } }), onMouseEnter: () => o(!0), onMouseLeave: () => o(!1), style: d, onClick: (c) => {
173
- c.preventDefault(), r();
174
- }, "aria-label": n, children: n });
175
- }, $e = ({ challenge: t, index: e, solutions: n, onSubmit: r, onCancel: a, onClick: s, onNext: o, onReload: d, themeColor: c }) => {
176
- const { t: u } = q(), w = t.captchas ? f(t.captchas, e) : null, E = n ? f(n, e) : [], b = m.useMemo(() => c === "light" ? L : P, [c]), v = `${b.spacing.unit}px`, N = `${b.spacing.half}px`;
177
- return i(m.Suspense, { fallback: i("div", { children: "Loading..." }), children: i("div", { style: {
178
- overflowX: "auto",
179
- overflowY: "auto",
180
- width: "100%",
181
- maxWidth: "500px",
182
- maxHeight: "100%",
183
- display: "flex",
184
- flexDirection: "column",
185
- border: "1px solid #dddddd",
186
- boxShadow: "rgba(255, 255, 255, 0.2) 0px 0px 4px",
187
- borderRadius: "4px",
188
- backgroundColor: b.palette.background.default,
189
- userSelect: "none",
190
- touchAction: "none",
191
- overscrollBehavior: "none"
192
- }, children: C("div", { style: {
193
- backgroundColor: b.palette.background.default,
194
- display: "flex",
195
- flexDirection: "column",
196
- minWidth: "300px"
197
- }, children: [i("div", { style: {
198
- display: "flex",
199
- alignItems: "center",
200
- width: "100%"
201
- }, children: i("div", { style: {
202
- backgroundColor: b.palette.primary.main,
203
- width: "100%",
204
- marginTop: v,
205
- marginLeft: v,
206
- marginRight: v
207
- }, children: C("div", { style: {
208
- paddingLeft: `${b.spacing.half}px`,
209
- paddingRight: `${b.spacing.half}px`
210
- }, children: [C("p", { style: {
211
- color: "#ffffff",
212
- fontWeight: 700,
213
- lineHeight: 1.5
214
- }, children: [u("WIDGET.SELECT_ALL"), ":", " ", i("span", { children: `${u(f(t.captchas, e).target)} ` })] }), i("p", { style: {
215
- color: "#ffffff",
216
- fontWeight: 500,
217
- lineHeight: 0.8,
218
- fontSize: "0.8rem"
219
- }, children: u("WIDGET.IF_NONE_CLICK_NEXT") })] }) }) }), i("div", { ...Q({ dev: { cy: `captcha-${e}` } }), style: {
220
- paddingRight: N,
221
- paddingLeft: N
222
- }, children: w && i(Ue, { challenge: w, solution: E, onClick: s, themeColor: c }) }), i("div", { style: {
223
- display: "flex",
224
- alignItems: "center",
225
- justifyContent: "space-between",
226
- lineHeight: 1.75,
227
- padding: v,
228
- paddingBottom: N,
229
- paddingTop: N
230
- }, children: C("div", { style: {
231
- display: "grid",
232
- gridAutoFlow: "column",
233
- gridTemplateColumns: "repeat(3, minmax(0, 1fr)",
234
- width: "100%"
235
- }, children: [i("div", { style: { justifySelf: "left" }, children: i(K, { themeColor: c, buttonType: "cancel", onClick: a, text: u("WIDGET.CANCEL"), "aria-label": u("WIDGET.CANCEL") }) }), i("div", { style: { justifySelf: "center" }, children: i(We, { themeColor: c, onReload: d }) }), i("div", { style: { justifySelf: "right" }, children: i(K, { themeColor: c, buttonType: "next", text: e < t.captchas.length - 1 ? u("WIDGET.NEXT") : u("WIDGET.SUBMIT"), onClick: e < t.captchas.length - 1 ? o : r, "aria-label": e < t.captchas.length - 1 ? u("WIDGET.NEXT") : u("WIDGET.SUBMIT"), "data-cy": "button-next" }) })] }) })] }) }) });
236
- };
237
- function ze(t) {
238
- return $([
239
- t.captchaId,
240
- t.captchaContentId,
241
- [...t.solution].sort(),
242
- t.salt
243
- ]);
244
- }
245
- class V {
246
- constructor(e) {
247
- this.hash = e, this.parent = null;
248
- }
249
- }
250
- class Fe {
251
- constructor() {
252
- this.leaves = [], this.layers = [];
253
- }
254
- getRoot() {
255
- if (this.root === void 0)
256
- throw new A("DATASET.MERKLE_ERROR", {
257
- context: {
258
- error: "root undefined",
259
- failedFuncName: this.getRoot.name
260
- }
261
- });
262
- return this.root;
263
- }
264
- build(e) {
265
- this.layers.length && (this.layers = []);
266
- const n = [];
267
- for (const r of e) {
268
- const a = new V(r);
269
- this.leaves.push(a), n.push(a.hash);
270
- }
271
- this.layers.push(n), this.root = this.buildMerkleTree(this.leaves)[0];
272
- }
273
- buildMerkleTree(e) {
274
- const n = e.length;
275
- if (n === 1)
276
- return e;
277
- const r = [];
278
- let a = 0;
279
- const s = [];
280
- for (; a < n; ) {
281
- const o = e[a];
282
- if (o === void 0)
283
- throw new A("DEVELOPER.GENERAL", {
284
- context: { error: "leftChild undefined" }
285
- });
286
- const d = a + 1 < n ? f(e, a + 1) : o, c = this.createParent(o, d);
287
- s.push(c.hash), r.push(c), a += 2;
288
- }
289
- return this.layers.push(s), this.buildMerkleTree(r);
290
- }
291
- createParent(e, n) {
292
- const r = new V($([e.hash, n.hash]));
293
- return e.parent = r.hash, n.parent = r.hash, r;
294
- }
295
- proof(e) {
296
- const n = [];
297
- let r = 0;
298
- for (; r < this.layers.length - 1; ) {
299
- const s = this.layers[r];
300
- if (s === void 0)
301
- throw new A("DATASET.MERKLE_ERROR", {
302
- context: {
303
- error: "layer undefined",
304
- failedFuncName: this.proof.name,
305
- layerNum: r
306
- }
307
- });
308
- const o = s.indexOf(e);
309
- let d = o % 2 && o > 0 ? o - 1 : o + 1;
310
- d > s.length - 1 && (d = o);
311
- const c = [e], u = f(s, d);
312
- d > o ? c.push(u) : c.unshift(u), n.push([f(c, 0), f(c, 1)]), r += 1, e = $(c);
313
- }
314
- const a = f(this.layers, this.layers.length - 1);
315
- return [...n, [f(a, 0)]];
316
- }
317
- }
318
- class Ke {
319
- constructor(e, n, r, a, s) {
320
- this.userAccount = e, this.provider = n, this.providerApi = r, this._web2 = a, this.dappAccount = s;
321
- }
322
- get web2() {
323
- return this._web2;
324
- }
325
- async getCaptchaChallenge() {
326
- try {
327
- const e = await this.providerApi.getCaptchaChallenge(this.userAccount, this.provider);
328
- if (e[g.error])
329
- return e;
330
- if (window.location.protocol === "https:" || window.location.protocol === "http:")
331
- for (const n of e.captchas)
332
- for (const r of n.items)
333
- r.data && (r.data = r.data.replace(/^http(s)*:\/\//, "//"));
334
- return e;
335
- } catch (e) {
336
- throw new I("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
337
- context: { error: e }
338
- });
339
- }
340
- }
341
- async submitCaptchaSolution(e, n, r, a, s) {
342
- const o = new Fe(), d = r.map((E) => ze(E));
343
- if (o.build(d), !o.root)
344
- throw new _("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
345
- context: { error: "Merkle tree root is undefined" }
346
- });
347
- const c = o.root.hash, u = void 0;
348
- let w;
349
- try {
350
- w = await this.providerApi.submitCaptchaSolution(r, n, this.userAccount, a, s, e);
351
- } catch (E) {
352
- throw new _("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
353
- context: { error: E }
354
- });
355
- }
356
- return [w, c, u];
357
- }
358
- }
359
- const ee = "@prosopo/procaptcha";
360
- function z() {
361
- return Z.parse(JSON.parse(Me(localStorage.getItem(ee) || "0x7b7d")));
362
- }
363
- function te(t) {
364
- localStorage.setItem(ee, Y(JSON.stringify(Z.parse(t))));
365
- }
366
- function Ve(t) {
367
- te({ ...z(), account: t });
368
- }
369
- function Xe() {
370
- return z().account || null;
371
- }
372
- const j = {
373
- setAccount: Ve,
374
- getAccount: Xe,
375
- setProcaptchaStorage: te,
376
- getProcaptchaStorage: z
377
- }, qe = () => ({
378
- showModal: !1,
379
- loading: !1,
380
- index: 0,
381
- challenge: void 0,
382
- solutions: void 0,
383
- isHuman: !1,
384
- captchaApi: void 0,
385
- account: void 0
386
- });
387
- function Ye(t, e, n, r, a) {
388
- const s = Se(n, e, r), o = Ie(e, n), d = () => {
389
- const l = {
390
- userAccountAddress: "",
391
- ...t
392
- };
393
- return e.account && (l.userAccountAddress = e.account.account.address), X.parse(l);
394
- }, c = async () => {
395
- s.onOpen(), await F(async () => {
396
- if (e.loading || e.isHuman)
397
- return;
398
- H(), o({ loading: !0 }), o({
399
- attemptCount: e.attemptCount ? e.attemptCount + 1 : 1
400
- });
401
- const l = d();
402
- o({ dappAccount: l.account.address }), await ve(100);
403
- const h = await oe(), y = await ce(d()), p = y.provider.url, T = await N(p), k = new Ke(h.account.address, y, T, l.web2, l.account.address || "");
404
- o({ captchaApi: k });
405
- const x = await k.getCaptchaChallenge();
406
- if (x.error)
407
- o({
408
- loading: !1,
409
- error: x.error.message
410
- });
411
- else {
412
- if (x.captchas.length <= 0)
413
- throw new _("DEVELOPER.PROVIDER_NO_CAPTCHA");
414
- const O = x.captchas.map((R) => R.timeLimitMs || l.captchas.image.challengeTimeout).reduce((R, S) => R + S), D = setTimeout(() => {
415
- s.onChallengeExpired(), o({ isHuman: !1, showModal: !1, loading: !1 });
416
- }, O);
417
- o({
418
- index: 0,
419
- solutions: x.captchas.map(() => []),
420
- challenge: x,
421
- showModal: !0,
422
- timeout: D
423
- });
424
- }
425
- }, c, H, e.attemptCount, 10);
426
- }, u = async () => {
427
- await F(async () => {
428
- if (M(), !e.challenge)
429
- throw new A("CAPTCHA.NO_CAPTCHA", {
430
- context: { error: "Cannot submit, no Captcha found in state" }
431
- });
432
- o({ showModal: !1 });
433
- const l = e.challenge, h = Re(), y = e.challenge.captchas.map((S, ie) => {
434
- const se = f(e.solutions, ie);
435
- return {
436
- captchaId: S.captchaId,
437
- captchaContentId: S.captchaContentId,
438
- salt: h,
439
- solution: se
440
- };
441
- }), p = U(), T = re(p).signer;
442
- if (!f(l.captchas, 0).datasetId)
443
- throw new _("CAPTCHA.INVALID_CAPTCHA_ID", {
444
- context: { error: "No datasetId set for challenge" }
445
- });
446
- const x = e.captchaApi;
447
- if (!x)
448
- throw new A("CAPTCHA.INVALID_TOKEN", {
449
- context: { error: "No Captcha API found in state" }
450
- });
451
- if (!T || !T.signRaw)
452
- throw new I("GENERAL.CANT_FIND_KEYRINGPAIR", {
453
- context: {
454
- error: "Signer is not defined, cannot sign message to prove account ownership"
455
- }
456
- });
457
- const O = await T.signRaw({
458
- address: p.account.address,
459
- data: Y(l[g.timestamp]),
460
- type: "bytes"
461
- }), D = await x.submitCaptchaSolution(O.signature, l.requestHash, y, l.timestamp, l.signature.provider.requestHash), R = D[0].verified;
462
- if (o({
463
- submission: D,
464
- isHuman: R,
465
- loading: !1
466
- }), e.isHuman) {
467
- const S = x.provider.provider.url;
468
- j.setProcaptchaStorage({
469
- ...j.getProcaptchaStorage(),
470
- providerUrl: S
471
- }), s.onHuman(le({
472
- [g.providerUrl]: S,
473
- [g.user]: p.account.address,
474
- [g.dapp]: ae(),
475
- [g.commitmentId]: Pe(D[1]),
476
- [g.timestamp]: l.timestamp,
477
- [g.signature]: {
478
- [g.provider]: {
479
- [g.requestHash]: l.signature.provider.requestHash
480
- },
481
- [g.user]: {
482
- [g.timestamp]: O.signature
483
- }
484
- }
485
- })), ne();
486
- } else
487
- s.onFailed();
488
- }, c, H, e.attemptCount, 10);
489
- }, w = async () => {
490
- M(), H(), s.onClose();
491
- }, E = async () => {
492
- M(), H(), s.onClose(), await c();
493
- }, b = (l) => {
494
- if (!e.challenge)
495
- throw new A("CAPTCHA.NO_CAPTCHA", {
496
- context: { error: "Cannot select, no Captcha found in state" }
497
- });
498
- if (e.index >= e.challenge.captchas.length || e.index < 0)
499
- throw new A("CAPTCHA.NO_CAPTCHA", {
500
- context: {
501
- error: "Cannot select, index is out of range for this Captcha"
502
- }
503
- });
504
- const h = e.index, y = e.solutions, p = f(y, h);
505
- p.includes(l) ? p.splice(p.indexOf(l), 1) : p.push(l), o({ solutions: y });
506
- }, v = () => {
507
- if (!e.challenge)
508
- throw new A("CAPTCHA.NO_CAPTCHA", {
509
- context: { error: "Cannot select, no Captcha found in state" }
510
- });
511
- if (e.index + 1 >= e.challenge.captchas.length)
512
- throw new A("CAPTCHA.NO_CAPTCHA", {
513
- context: {
514
- error: "Cannot select, index is out of range for this Captcha"
515
- }
516
- });
517
- o({ index: e.index + 1 });
518
- }, N = async (l) => {
519
- const h = d();
520
- if (!h.account.address)
521
- throw new I("GENERAL.SITE_KEY_MISSING");
522
- return new de(l, h.account.address);
523
- }, M = () => {
524
- window.clearTimeout(Number(e.timeout)), o({ timeout: void 0 });
525
- }, ne = () => {
526
- const l = t.captchas.image.solutionTimeout, h = setTimeout(() => {
527
- o({ isHuman: !1 }), s.onExpired();
528
- }, l);
529
- o({ successfullChallengeTimeout: h });
530
- }, H = () => {
531
- M(), o(qe()), s.onReset();
532
- }, oe = async () => {
533
- const l = d();
534
- if (!l.web2 && !l.userAccountAddress)
535
- throw new I("GENERAL.ACCOUNT_NOT_FOUND", {
536
- context: { error: "Account address has not been set for web3 mode" }
537
- });
538
- const h = async (k) => await new (await k())().getAccount(l), y = async () => (await import("./index-BH5dKH-o.js")).ExtensionWeb3, p = async () => (await import("./index-BH5dKH-o.js")).ExtensionWeb2, T = await h(l.web2 ? p : y);
539
- return j.setAccount(T.account.address), o({ account: T }), U();
540
- }, U = () => {
541
- if (!e.account)
542
- throw new I("GENERAL.ACCOUNT_NOT_FOUND", {
543
- context: { error: "Account not loaded" }
544
- });
545
- return e.account;
546
- }, ae = () => {
547
- if (!e.dappAccount)
548
- throw new I("GENERAL.SITE_KEY_MISSING");
549
- return e.dappAccount;
550
- }, re = (l) => {
551
- const h = l || U();
552
- if (!h.extension)
553
- throw new I("ACCOUNT.NO_POLKADOT_EXTENSION", {
554
- context: { error: "Extension not loaded" }
555
- });
556
- return h.extension;
557
- };
558
- return {
559
- start: c,
560
- cancel: w,
561
- submit: u,
562
- select: b,
563
- nextRound: v,
564
- reload: E
565
- };
566
- }
567
- const Je = ue.memo((t, e) => {
568
- const { show: n, children: r } = t, s = {
569
- position: "fixed",
570
- zIndex: 2147483646,
571
- inset: 0,
572
- display: n ? "block" : "none"
573
- }, o = {
574
- position: "fixed",
575
- display: "flex",
576
- alignItems: "center",
577
- justifyContent: "center",
578
- right: 0,
579
- bottom: 0,
580
- top: 0,
581
- left: 0,
582
- backgroundColor: "rgba(0, 0, 0, 0.5)",
583
- zIndex: -1
584
- }, d = {
585
- position: "absolute",
586
- top: "50%",
587
- left: "50%",
588
- transform: "translate(-50%, -50%)",
589
- width: "inherit",
590
- backgroundColor: "transparent",
591
- border: "none",
592
- 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,"
593
- };
594
- return C("div", { className: "prosopo-modalOuter", style: s, children: [i("div", { className: "prosopo-modalBackground", style: o }), i("div", { className: "prosopo-modalInner", style: d, children: r })] });
595
- }), nt = (t) => {
596
- const { t: e } = q(), n = X.parse(t.config), r = t.callbacks || {}, [a, s] = Ne(m.useState, m.useRef), o = Ye(n, a, s, r), d = t.config.theme === "light" ? "light" : "dark", c = t.config.theme === "light" ? L : P;
597
- return m.useEffect(() => {
598
- n.language && he.changeLanguage(n.language);
599
- }, [n.language]), i("div", { children: C("div", { style: {
600
- maxWidth: pe,
601
- maxHeight: "100%",
602
- overflowX: "auto",
603
- ...c.font
604
- }, children: [i(Je, { show: a.showModal, children: a.challenge ? i($e, { challenge: a.challenge, index: a.index, solutions: a.solutions, onSubmit: o.submit, onCancel: o.cancel, onClick: o.select, onNext: o.nextRound, onReload: o.reload, themeColor: n.theme ?? "light" }) : i("div", { children: "No challenge set." }) }), i(ge, { children: i(fe, { children: C("div", { style: me, "data-cy": "button-human", children: [" ", C("div", { style: {
605
- padding: xe,
606
- border: Ce,
607
- backgroundColor: c.palette.background.default,
608
- borderColor: c.palette.grey[300],
609
- borderRadius: be,
610
- display: "flex",
611
- alignItems: "center",
612
- flexWrap: "wrap",
613
- justifyContent: "space-between",
614
- minHeight: `${ye}px`,
615
- overflow: "hidden"
616
- }, children: [i("div", { style: { display: "inline-flex", flexDirection: "column" }, children: i("div", { style: {
617
- alignItems: "center",
618
- flex: 1
619
- }, children: i("div", { style: {
620
- display: "flex",
621
- alignItems: "center",
622
- justifyContent: "center",
623
- flexDirection: "column",
624
- verticalAlign: "middle"
625
- }, children: i("div", { style: {
626
- display: "flex"
627
- }, children: a.loading ? i(Ae, { themeColor: d, "aria-label": "Loading spinner" }) : i(He, { themeColor: d, onChange: o.start, checked: a.isHuman, labelText: e("WIDGET.I_AM_HUMAN"), error: a.error, "aria-label": "human checkbox" }) }) }) }) }), i("div", { style: { display: "inline-flex", flexDirection: "column" }, children: i("a", { href: we, target: "_blank", "aria-label": Te, children: i("div", { style: { flex: 1 }, children: i(Ee, { themeColor: d, "aria-label": "Prosopo logo" }) }) }) })] })] }) }) })] }) });
628
- };
629
- export {
630
- nt as default
631
- };