@prosopo/client-bundle-example 2.8.2 → 2.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +3 -2
  3. package/dist/assets/{captcha-BhkVCEXM.css → captcha-DAWM1slf.css} +1 -1
  4. package/dist/assets/{frictionless-explicit-CNjy6JJ4.js → frictionless-explicit-CtnTw8dK.js} +1 -1
  5. package/dist/assets/{frictionless-implicit-Dq_sNGRK.js → frictionless-implicit-BH7anfOq.js} +1 -1
  6. package/dist/assets/{image-explicit-DQvfVB7-.js → image-explicit-Dm_JoW0N.js} +1 -1
  7. package/dist/assets/image-implicit-M0Y7U93R.js +1 -0
  8. package/dist/assets/{index-Dpt_5E72.js → index-Ck5HfpfQ.js} +1 -1
  9. package/dist/assets/{invisible-frictionless-explicit-DugBtRe4.js → invisible-frictionless-explicit-CSPYfcNr.js} +1 -1
  10. package/dist/assets/{invisible-frictionless-implicit-DYYos8W9.js → invisible-frictionless-implicit-D0saDt4U.js} +1 -1
  11. package/dist/assets/{invisible-image-explicit-C5Z4gSb1.js → invisible-image-explicit-erOMAo-F.js} +1 -1
  12. package/dist/assets/{invisible-image-implicit-DfNFNlFj.js → invisible-image-implicit-c0sMfk2s.js} +1 -1
  13. package/dist/assets/{invisible-pow-explicit-DjqGWFUb.js → invisible-pow-explicit-BgMt7lhN.js} +1 -1
  14. package/dist/assets/{invisible-pow-implicit-BRXL14FH.js → invisible-pow-implicit-CnxS8gw2.js} +1 -1
  15. package/dist/assets/{pow-explicit-BexxbnHM.js → pow-explicit-BgDWNJK9.js} +1 -1
  16. package/dist/assets/{pow-implicit-Dpt_5E72.js → pow-implicit-Ck5HfpfQ.js} +1 -1
  17. package/dist/cjs/index.cjs +1 -0
  18. package/dist/frictionless-explicit.html +8 -8
  19. package/dist/frictionless-implicit.html +7 -7
  20. package/dist/image-explicit.html +4 -4
  21. package/dist/index.html +4 -4
  22. package/dist/invisible-frictionless-explicit.html +4 -4
  23. package/dist/invisible-frictionless-implicit.html +4 -4
  24. package/dist/invisible-image-explicit.html +4 -4
  25. package/dist/invisible-image-implicit.html +4 -4
  26. package/dist/invisible-pow-explicit.html +4 -4
  27. package/dist/invisible-pow-implicit.html +4 -4
  28. package/dist/plugins/navigation-injector.ts +1 -1
  29. package/dist/pow-explicit.html +4 -4
  30. package/dist/pow-implicit.html +4 -4
  31. package/env.staging +6 -0
  32. package/package.json +29 -16
  33. package/vite.cjs.config.ts +22 -0
  34. package/vite.config.ts +21 -2
  35. package/vite.esm.config.ts +20 -0
  36. package/dist/assets/ProcaptchaWidget-DrBDhP6X.js +0 -636
  37. package/dist/assets/ProcaptchaWidget-rAM-9Rap.js +0 -360
  38. package/dist/assets/Signer-DP9drQ55.js +0 -23
  39. package/dist/assets/_commonjsHelpers-DaMA6jEr.js +0 -8
  40. package/dist/assets/asU8a-CJdNkNEq.js +0 -9
  41. package/dist/assets/bip39-Du2cANEV.js +0 -365
  42. package/dist/assets/browser-ponyfill-Dy1JBTMg.js +0 -339
  43. package/dist/assets/captchaComponentProvider-DmV1WTrT.js +0 -1242
  44. package/dist/assets/captchaRenderer-RIsSZXCC.js +0 -70
  45. package/dist/assets/components.d.ts +0 -5
  46. package/dist/assets/components.d.ts.map +0 -1
  47. package/dist/assets/emotion-element-5486c51c.browser.esm-C3u8NMUC.js +0 -1807
  48. package/dist/assets/fp.esm-DYWeNGcH.js +0 -1654
  49. package/dist/assets/hash-_rWungeW.js +0 -1268
  50. package/dist/assets/i18nFrontend-CsPT71ro.js +0 -2273
  51. package/dist/assets/image-implicit-Bwa9QJO5.js +0 -1
  52. package/dist/assets/index-BVr9fC_3.js +0 -4386
  53. package/dist/assets/index-BjRdPnnE.js +0 -1198
  54. package/dist/assets/index-Cu5oL_7b.js +0 -81
  55. package/dist/assets/index-DxIFpl6U.js +0 -5416
  56. package/dist/assets/index-QVME9Prx.js +0 -32
  57. package/dist/assets/index-Wgw2GQWq.js +0 -596
  58. package/dist/assets/index.d.ts +0 -16
  59. package/dist/assets/index.d.ts.map +0 -1
  60. package/dist/assets/locales/ar/translation.json +0 -56
  61. package/dist/assets/locales/az/translation.json +0 -56
  62. package/dist/assets/locales/cs/translation.json +0 -56
  63. package/dist/assets/locales/de/translation.json +0 -56
  64. package/dist/assets/locales/el/translation.json +0 -56
  65. package/dist/assets/locales/en/translation.json +0 -56
  66. package/dist/assets/locales/es/translation.json +0 -56
  67. package/dist/assets/locales/fi/translation.json +0 -56
  68. package/dist/assets/locales/fr/translation.json +0 -56
  69. package/dist/assets/locales/hi/translation.json +0 -56
  70. package/dist/assets/locales/hu/translation.json +0 -56
  71. package/dist/assets/locales/id/translation.json +0 -56
  72. package/dist/assets/locales/it/translation.json +0 -56
  73. package/dist/assets/locales/ja/translation.json +0 -56
  74. package/dist/assets/locales/jv/translation.json +0 -56
  75. package/dist/assets/locales/ko/translation.json +0 -56
  76. package/dist/assets/locales/ml/translation.json +0 -56
  77. package/dist/assets/locales/ms/translation.json +0 -56
  78. package/dist/assets/locales/nl/translation.json +0 -56
  79. package/dist/assets/locales/no/translation.json +0 -56
  80. package/dist/assets/locales/pl/translation.json +0 -56
  81. package/dist/assets/locales/pt/translation.json +0 -56
  82. package/dist/assets/locales/pt-br/translation.json +0 -56
  83. package/dist/assets/locales/ro/translation.json +0 -56
  84. package/dist/assets/locales/ru/translation.json +0 -56
  85. package/dist/assets/locales/sr/translation.json +0 -56
  86. package/dist/assets/locales/sv/translation.json +0 -56
  87. package/dist/assets/locales/th/translation.json +0 -56
  88. package/dist/assets/locales/tr/translation.json +0 -56
  89. package/dist/assets/locales/uk/translation.json +0 -56
  90. package/dist/assets/locales/vi/translation.json +0 -56
  91. package/dist/assets/locales/zh-cn/translation.json +0 -56
  92. package/dist/assets/procaptcha.bundle.js +0 -7
  93. package/dist/assets/spread-DEmVz7RJ.js +0 -15
  94. package/dist/assets/tests/util/captchaType.test.d.ts +0 -2
  95. package/dist/assets/tests/util/captchaType.test.d.ts.map +0 -1
  96. package/dist/assets/tests/util/config.test.d.ts +0 -2
  97. package/dist/assets/tests/util/config.test.d.ts.map +0 -1
  98. package/dist/assets/tests/util/renderLogic.test.d.ts +0 -2
  99. package/dist/assets/tests/util/renderLogic.test.d.ts.map +0 -1
  100. package/dist/assets/toU8a-C68WUzs_.js +0 -24
  101. package/dist/assets/translations-DEL070wJ.js +0 -2918
  102. package/dist/assets/useTranslation-CJplXtqb.js +0 -158
  103. package/dist/assets/util/captcha/captchaComponentProvider.d.ts +0 -8
  104. package/dist/assets/util/captcha/captchaComponentProvider.d.ts.map +0 -1
  105. package/dist/assets/util/captcha/captchaComponentsList.d.ts +0 -6
  106. package/dist/assets/util/captcha/captchaComponentsList.d.ts.map +0 -1
  107. package/dist/assets/util/captcha/captchaProps.d.ts +0 -9
  108. package/dist/assets/util/captcha/captchaProps.d.ts.map +0 -1
  109. package/dist/assets/util/captcha/captchaRenderer.d.ts +0 -24
  110. package/dist/assets/util/captcha/captchaRenderer.d.ts.map +0 -1
  111. package/dist/assets/util/captcha/captchaType.d.ts +0 -2
  112. package/dist/assets/util/captcha/captchaType.d.ts.map +0 -1
  113. package/dist/assets/util/captcha/components/frictionlessCaptcha.d.ts +0 -4
  114. package/dist/assets/util/captcha/components/frictionlessCaptcha.d.ts.map +0 -1
  115. package/dist/assets/util/captcha/components/imageCaptcha.d.ts +0 -4
  116. package/dist/assets/util/captcha/components/imageCaptcha.d.ts.map +0 -1
  117. package/dist/assets/util/captcha/components/powCaptcha.d.ts +0 -4
  118. package/dist/assets/util/captcha/components/powCaptcha.d.ts.map +0 -1
  119. package/dist/assets/util/config.d.ts +0 -6
  120. package/dist/assets/util/config.d.ts.map +0 -1
  121. package/dist/assets/util/configCreator.d.ts +0 -5
  122. package/dist/assets/util/configCreator.d.ts.map +0 -1
  123. package/dist/assets/util/language.d.ts +0 -3
  124. package/dist/assets/util/language.d.ts.map +0 -1
  125. package/dist/assets/util/timeout.d.ts +0 -3
  126. package/dist/assets/util/timeout.d.ts.map +0 -1
  127. package/dist/assets/util/widgetFactory.d.ts +0 -18
  128. package/dist/assets/util/widgetFactory.d.ts.map +0 -1
  129. package/dist/assets/util/widgetThemeResolver.d.ts +0 -9
  130. package/dist/assets/util/widgetThemeResolver.d.ts.map +0 -1
  131. /package/dist/assets/{captcha-ByKnSsbG.js → captcha-BaCo3bEP.js} +0 -0
@@ -1,636 +0,0 @@
1
- import { j as c, a as H, P as _, b as T, c as N, g as ae, p as $, d as se, e as ie, E as ce, f as le, C as de } from "./captchaComponentProvider-DmV1WTrT.js";
2
- import { r as f, l as ue, P as X, R as he } from "./emotion-element-5486c51c.browser.esm-C3u8NMUC.js";
3
- import { b as M, d as D, a as w, A as C, l as pe } from "./index-Wgw2GQWq.js";
4
- import { u as q, b as ge, s as fe, a as me, c as xe } from "./useTranslation-CJplXtqb.js";
5
- import { r as Ce } from "./index-DxIFpl6U.js";
6
- import { h as U } from "./hash-_rWungeW.js";
7
- import { r as we } from "./asU8a-CJdNkNEq.js";
8
- const be = (t) => Array.isArray(t) && t !== null, S = new Array(256), Y = new Array(256 * 256);
9
- for (let t = 0; t < 256; t++)
10
- S[t] = t.toString(16).padStart(2, "0");
11
- for (let t = 0; t < 256; t++) {
12
- const e = t << 8;
13
- for (let o = 0; o < 256; o++)
14
- Y[e | o] = S[t] + S[o];
15
- }
16
- function W(t, e) {
17
- const o = t.length % 2 | 0, a = t.length - o | 0;
18
- for (let n = 0; n < a; n += 2)
19
- e += Y[t[n] << 8 | t[n + 1]];
20
- return o && (e += S[t[a] | 0]), e;
21
- }
22
- function Ae(t, e = -1, o = !0) {
23
- const a = o ? "0x" : "";
24
- if (!(t != null && t.length))
25
- return a;
26
- if (e > 0) {
27
- const n = Math.ceil(e / 8);
28
- if (t.length > n)
29
- return `${W(t.subarray(0, n / 2), a)}…${W(t.subarray(t.length - n / 2), "")}`;
30
- }
31
- return W(t, a);
32
- }
33
- const ye = (t) => be(t) ? Ae(new Uint8Array(t)) : t.toString(), Ee = {
34
- border: "none",
35
- paddingTop: "6px",
36
- paddingBottom: "6px",
37
- cursor: "pointer",
38
- height: "39px",
39
- width: "39px",
40
- borderRadius: "50%",
41
- display: "flex"
42
- }, Te = ({ themeColor: t, onReload: e }) => {
43
- const o = f.useMemo(() => t === "light" ? M : D, [t]), [a, n] = f.useState(!1), i = f.useMemo(() => ({
44
- ...{
45
- ...Ee,
46
- backgroundColor: o.palette.background.default,
47
- color: a ? o.palette.primary.contrastText : o.palette.background.contrastText,
48
- border: `1px solid ${o.palette.grey[500]}`,
49
- borderRadius: "50%",
50
- transition: "background-color 0.3s",
51
- boxShadow: `0px 1px 3px 0px ${o.palette.grey[500]}`,
52
- justifyContent: "center",
53
- alignItems: "center",
54
- margin: "0 auto"
55
- },
56
- backgroundColor: a ? o.palette.grey[700] : o.palette.background.default
57
- }), [a, o]);
58
- return c("button", { className: "reload-button", "aria-label": "Reload", type: "button", style: i, onMouseEnter: () => n(!0), onMouseLeave: () => n(!1), onClick: (r) => {
59
- r.preventDefault(), e();
60
- }, children: H("svg", { width: "16px", height: "16px", viewBox: "0 0 16 16", version: "1.1", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", style: { display: "flex" }, children: [c("title", { children: "reload" }), c("path", { shapeRendering: "optimizeQuality", fill: a ? o.palette.primary.contrastText : o.palette.grey[700], transform: "scale(0.0416)", 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" })] }) });
61
- }, ve = (t) => {
62
- if (!t.hash)
63
- throw new _("CAPTCHA.MISSING_ITEM_HASH", {
64
- context: { item: t }
65
- });
66
- return t.hash;
67
- }, Ie = ({ challenge: t, solution: e, onClick: o, themeColor: a }) => {
68
- const n = t.items, i = f.useMemo(() => a === "light" ? M : D, [a]), r = `${i.spacing.unit}px`;
69
- return c("div", { style: {
70
- width: "100%",
71
- height: "100%",
72
- display: "flex",
73
- flexDirection: "row",
74
- flexWrap: "wrap",
75
- justifyContent: "space-between",
76
- paddingBottom: r,
77
- paddingTop: r,
78
- gap: "10px"
79
- }, children: n.map((d, l) => {
80
- const h = ve(d);
81
- return c("div", { style: {
82
- flexGrow: 1,
83
- flexBasis: "calc(33.333% - 10px)",
84
- boxSizing: "border-box"
85
- }, children: H("div", { style: {
86
- position: "relative",
87
- cursor: "pointer",
88
- height: "100%",
89
- width: "100%",
90
- padding: 0,
91
- margin: 0
92
- }, onClick: () => o(h), children: [c("img", { style: {
93
- width: "100%",
94
- display: "block",
95
- objectFit: "cover",
96
- aspectRatio: "1/1",
97
- height: "auto",
98
- overflow: "hidden",
99
- borderStyle: "solid",
100
- borderWidth: "1px",
101
- borderColor: i.palette.grey[300]
102
- }, src: d.data, alt: `Captcha image ${l + 1}` }), c("div", { style: {
103
- position: "absolute",
104
- top: 0,
105
- left: 0,
106
- bottom: 0,
107
- right: 0,
108
- height: "100%",
109
- width: "100%",
110
- display: "flex",
111
- alignItems: "center",
112
- justifyContent: "center",
113
- backgroundColor: "rgba(0,0,0,0.5)",
114
- visibility: e.includes(h) ? "visible" : "hidden"
115
- }, children: c("svg", { style: {
116
- backgroundColor: "transparent",
117
- display: "block",
118
- width: "35%",
119
- height: "35%",
120
- transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
121
- userSelect: "none",
122
- fill: "currentcolor"
123
- }, focusable: "false", color: "#fff", "aria-hidden": "true", viewBox: "0 0 24 24", "data-testid": "CheckIcon", "aria-label": "Check icon", children: c("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) }) })] }) }, d.hash);
124
- }) });
125
- };
126
- function Ne(t = {}) {
127
- return Object.keys(t).reduce((e, o) => ({ ...e, [`data-${o}`]: t[o] }), {});
128
- }
129
- function Z({ general: t, dev: e }) {
130
- return {
131
- ...Ne(t)
132
- };
133
- }
134
- const He = {
135
- display: "inline-flex",
136
- alignItems: "center",
137
- justifyContent: "center",
138
- position: "relative",
139
- boxSizing: "border-box",
140
- outline: "0px",
141
- margin: "0px",
142
- cursor: "pointer",
143
- userSelect: "none",
144
- verticalAlign: "middle",
145
- appearance: void 0,
146
- textDecoration: "none",
147
- fontWeight: "500",
148
- fontSize: "0.875rem",
149
- lineHeight: "1.75",
150
- letterSpacing: "0.02857em",
151
- textTransform: "uppercase",
152
- minWidth: "64px",
153
- padding: "6px 16px",
154
- borderRadius: "4px",
155
- 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",
156
- backgroundColor: "#ffffff"
157
- }, B = ({ themeColor: t, buttonType: e, text: o, onClick: a }) => {
158
- const n = f.useMemo(() => t === "light" ? M : D, [t]), [i, r] = f.useState(!1), d = f.useMemo(() => {
159
- const l = {
160
- ...He,
161
- border: `1px solid ${n.palette.grey[500]}`,
162
- boxShadow: `0px 1px 3px 0px ${n.palette.grey[500]}`,
163
- fontFamily: n.font.fontFamily,
164
- width: "100%",
165
- color: i ? n.palette.primary.contrastText : n.palette.background.contrastText
166
- };
167
- return e === "cancel" ? {
168
- ...l,
169
- backgroundColor: i ? n.palette.grey[600] : "transparent"
170
- } : {
171
- ...l,
172
- backgroundColor: i ? n.palette.primary.main : n.palette.background.default
173
- };
174
- }, [e, i, n]);
175
- return c("button", { ...Z({ dev: {} }), onMouseEnter: () => r(!0), onMouseLeave: () => r(!1), style: d, onClick: (l) => {
176
- l.preventDefault(), a();
177
- }, "aria-label": o, children: o });
178
- }, j = ({ challenge: t, index: e, solutions: o, onSubmit: a, onCancel: n, onClick: i, onNext: r, onReload: d, themeColor: l }) => {
179
- const { t: h } = q(), u = t.captchas ? w(t.captchas, e) : null, y = o ? w(o, e) : [], x = f.useMemo(() => l === "light" ? M : D, [l]), b = `${x.spacing.unit * 2}px`, A = `${x.spacing.unit}px`;
180
- return c(f.Suspense, { fallback: c("div", { children: "Loading..." }), children: c("div", { style: {
181
- overflowX: "auto",
182
- overflowY: "auto",
183
- maxWidth: "500px",
184
- maxHeight: "100%",
185
- display: "flex",
186
- flexDirection: "column",
187
- border: "1px solid #dddddd",
188
- boxShadow: "rgba(255, 255, 255, 0.2) 0px 0px 4px",
189
- borderRadius: "4px",
190
- backgroundColor: x.palette.background.default,
191
- userSelect: "none",
192
- touchAction: "none",
193
- overscrollBehavior: "none"
194
- }, children: H("div", { style: {
195
- backgroundColor: x.palette.background.default,
196
- display: "flex",
197
- flexDirection: "column",
198
- minWidth: "300px",
199
- marginLeft: A,
200
- marginRight: A,
201
- justifyContent: "center"
202
- }, children: [c("div", { style: {
203
- display: "flex",
204
- alignItems: "center",
205
- width: "100%"
206
- }, children: c("div", { style: {
207
- backgroundColor: x.palette.primary.main,
208
- width: "100%",
209
- marginTop: A
210
- }, children: H("div", { style: {
211
- padding: `${x.spacing.half}px`,
212
- fontFamily: x.font.fontFamily
213
- }, children: [H("p", { style: {
214
- color: "#ffffff",
215
- fontWeight: 700,
216
- lineHeight: 1.5
217
- }, children: [h("WIDGET.SELECT_ALL"), ":", " ", c("span", { children: `${w(t.captchas, e).target} ` })] }), c("p", { style: {
218
- color: "#ffffff",
219
- fontWeight: 500,
220
- lineHeight: 0.8,
221
- fontSize: "0.8rem"
222
- }, children: h("WIDGET.IF_NONE_CLICK_NEXT") })] }) }) }), c("div", { ...Z({ dev: {} }), style: { overflow: "hidden" }, children: u && c(Ie, { challenge: u, solution: y, onClick: i, themeColor: l }) }), c("div", { style: {
223
- display: "flex",
224
- alignItems: "center",
225
- justifyContent: "space-between",
226
- lineHeight: 1.75,
227
- padding: `${A} 0 ${b} 0`
228
- }, children: H("div", { style: {
229
- width: "100%",
230
- height: "100%",
231
- display: "flex",
232
- flexDirection: "row",
233
- flexWrap: "wrap",
234
- justifyContent: "space-between",
235
- gap: "10px"
236
- }, children: [c("div", { style: {
237
- position: "relative",
238
- flexGrow: 1,
239
- flexBasis: "calc(33.333% - 10px)"
240
- }, children: c(B, { themeColor: l, buttonType: "cancel", onClick: n, text: h("WIDGET.CANCEL"), "aria-label": h("WIDGET.CANCEL") }) }), c("div", { style: {
241
- position: "relative",
242
- flexGrow: 1,
243
- flexBasis: "calc(33.333% - 10px)"
244
- }, children: c(Te, { themeColor: l, onReload: d }) }), c("div", { style: {
245
- position: "relative",
246
- flexGrow: 1,
247
- flexBasis: "calc(33.333% - 10px)"
248
- }, children: c(B, { themeColor: l, buttonType: "next", text: e < t.captchas.length - 1 ? h("WIDGET.NEXT") : h("WIDGET.SUBMIT"), onClick: e < t.captchas.length - 1 ? r : a, "aria-label": e < t.captchas.length - 1 ? h("WIDGET.NEXT") : h("WIDGET.SUBMIT"), "data-cy": "button-next" }) })] }) })] }) }) });
249
- };
250
- function ke(t) {
251
- return U([
252
- t.captchaId,
253
- t.captchaContentId,
254
- [...t.solution].sort(),
255
- t.salt
256
- ]);
257
- }
258
- class z {
259
- constructor(e) {
260
- this.hash = e, this.parent = null;
261
- }
262
- }
263
- class Re {
264
- constructor() {
265
- this.leaves = [], this.layers = [];
266
- }
267
- getRoot() {
268
- if (this.root === void 0)
269
- throw new T("DATASET.MERKLE_ERROR", {
270
- context: {
271
- error: "root undefined",
272
- failedFuncName: this.getRoot.name
273
- }
274
- });
275
- return this.root;
276
- }
277
- build(e) {
278
- this.layers.length && (this.layers = []);
279
- const o = [];
280
- for (const a of e) {
281
- const n = new z(a);
282
- this.leaves.push(n), o.push(n.hash);
283
- }
284
- this.layers.push(o), this.root = this.buildMerkleTree(this.leaves)[0];
285
- }
286
- buildMerkleTree(e) {
287
- const o = e.length;
288
- if (o === 1)
289
- return e;
290
- const a = [];
291
- let n = 0;
292
- const i = [];
293
- for (; n < o; ) {
294
- const r = e[n];
295
- if (r === void 0)
296
- throw new T("DEVELOPER.GENERAL", {
297
- context: { error: "leftChild undefined" }
298
- });
299
- const d = n + 1 < o ? w(e, n + 1) : r, l = this.createParent(r, d);
300
- i.push(l.hash), a.push(l), n += 2;
301
- }
302
- return this.layers.push(i), this.buildMerkleTree(a);
303
- }
304
- createParent(e, o) {
305
- const a = new z(U([e.hash, o.hash]));
306
- return e.parent = a.hash, o.parent = a.hash, a;
307
- }
308
- proof(e) {
309
- const o = [];
310
- let a = 0;
311
- for (; a < this.layers.length - 1; ) {
312
- const i = this.layers[a];
313
- if (i === void 0)
314
- throw new T("DATASET.MERKLE_ERROR", {
315
- context: {
316
- error: "layer undefined",
317
- failedFuncName: this.proof.name,
318
- layerNum: a
319
- }
320
- });
321
- const r = i.indexOf(e);
322
- let d = r % 2 && r > 0 ? r - 1 : r + 1;
323
- d > i.length - 1 && (d = r);
324
- const l = [e], h = w(i, d);
325
- d > r ? l.push(h) : l.unshift(h), o.push([w(l, 0), w(l, 1)]), a += 1, e = U(l);
326
- }
327
- const n = w(this.layers, this.layers.length - 1);
328
- return [...o, [w(n, 0)]];
329
- }
330
- }
331
- class F {
332
- constructor(e, o, a, n, i) {
333
- this.userAccount = e, this.provider = o, this.providerApi = a, this._web2 = n, this.dappAccount = i;
334
- }
335
- get web2() {
336
- return this._web2;
337
- }
338
- async getCaptchaChallenge(e) {
339
- try {
340
- const o = await this.providerApi.getCaptchaChallenge(this.userAccount, this.provider, e);
341
- if (o[C.error])
342
- return o;
343
- for (const a of o.captchas)
344
- for (const n of a.items)
345
- n.data && (n.data = `https://${n.data.replace(/^http(s)*:\/\//, "")}`);
346
- return o;
347
- } catch (o) {
348
- throw new N("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
349
- context: { error: o }
350
- });
351
- }
352
- }
353
- async submitCaptchaSolution(e, o, a, n, i) {
354
- const r = new Re(), d = a.map((y) => ke(y));
355
- if (r.build(d), !r.root)
356
- throw new _("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
357
- context: { error: "Merkle tree root is undefined" }
358
- });
359
- const l = r.root.hash, h = void 0;
360
- let u;
361
- try {
362
- u = await this.providerApi.submitCaptchaSolution(a, o, this.userAccount, n, i, e);
363
- } catch (y) {
364
- throw new _("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
365
- context: { error: y }
366
- });
367
- }
368
- return [u, l, h];
369
- }
370
- }
371
- const Pe = () => ({
372
- showModal: !1,
373
- loading: !1,
374
- index: 0,
375
- challenge: void 0,
376
- solutions: void 0,
377
- isHuman: !1,
378
- captchaApi: void 0,
379
- account: void 0
380
- });
381
- function Le(t, e, o, a, n) {
382
- const i = ae(a), r = ge(e, o), d = () => {
383
- const s = {
384
- userAccountAddress: "",
385
- ...t
386
- };
387
- return e.account && (s.userAccountAddress = e.account.account.address), X.parse(s);
388
- }, l = async () => {
389
- i.onOpen(), await $(async () => {
390
- var R;
391
- if (e.loading || e.isHuman)
392
- return;
393
- r({ loading: !0 }), r({
394
- attemptCount: e.attemptCount ? e.attemptCount + 1 : 1
395
- }), r({
396
- sessionId: n == null ? void 0 : n.sessionId
397
- });
398
- const s = d();
399
- r({ dappAccount: s.account.address }), await me(100);
400
- const g = await J();
401
- let m = e.captchaApi;
402
- if (n != null && n.provider) {
403
- const I = n.provider.provider.url, E = await A(I);
404
- m = new F(g.account.address, n.provider, E, s.web2, s.account.address || ""), r({ captchaApi: m });
405
- } else {
406
- const I = await se(d()), E = I.provider.url, v = await A(E);
407
- m = new F(g.account.address, I, v, s.web2, s.account.address || ""), r({ captchaApi: m });
408
- }
409
- const p = await (m == null ? void 0 : m.getCaptchaChallenge(e.sessionId));
410
- if (p.error)
411
- r({
412
- loading: !1,
413
- error: {
414
- message: p.error.message,
415
- key: p.error.key || "API.UNKNOWN_ERROR"
416
- }
417
- }), i.onError(new Error((R = p.error) == null ? void 0 : R.message));
418
- else {
419
- if (p.captchas.length <= 0)
420
- throw new _("DEVELOPER.PROVIDER_NO_CAPTCHA");
421
- const I = p.captchas.map((v) => v.timeLimitMs || s.captchas.image.challengeTimeout).reduce((v, L) => v + L), E = setTimeout(() => {
422
- i.onChallengeExpired(), r({ isHuman: !1, showModal: !1, loading: !1 });
423
- }, I);
424
- r({
425
- index: 0,
426
- solutions: p.captchas.map(() => []),
427
- challenge: p,
428
- showModal: !0,
429
- timeout: E,
430
- loading: !1
431
- });
432
- }
433
- }, l, P, e.attemptCount, 10);
434
- }, h = async () => {
435
- await $(async () => {
436
- if (k(), !e.challenge)
437
- throw new T("CAPTCHA.NO_CAPTCHA", {
438
- context: { error: "Cannot submit, no Captcha found in state" }
439
- });
440
- r({ showModal: !1 });
441
- const s = e.challenge, g = we(), m = e.challenge.captchas.map((O, oe) => {
442
- const re = w(e.solutions, oe);
443
- return {
444
- captchaId: O.captchaId,
445
- captchaContentId: O.captchaContentId,
446
- salt: g,
447
- solution: re
448
- };
449
- }), p = G(), R = te(p).signer;
450
- if (!w(s.captchas, 0).datasetId)
451
- throw new _("CAPTCHA.INVALID_CAPTCHA_ID", {
452
- context: { error: "No datasetId set for challenge" }
453
- });
454
- const E = e.captchaApi;
455
- if (!E)
456
- throw new T("CAPTCHA.INVALID_TOKEN", {
457
- context: { error: "No Captcha API found in state" }
458
- });
459
- if (!R || !R.signRaw)
460
- throw new N("GENERAL.CANT_FIND_KEYRINGPAIR", {
461
- context: {
462
- error: "Signer is not defined, cannot sign message to prove account ownership"
463
- }
464
- });
465
- const v = await R.signRaw({
466
- address: p.account.address,
467
- data: fe(s[C.timestamp]),
468
- type: "bytes"
469
- }), L = await E.submitCaptchaSolution(v.signature, s.requestHash, m, s.timestamp, s.signature.provider.requestHash), ne = L[0].verified;
470
- if (r({
471
- submission: L,
472
- isHuman: ne,
473
- loading: !1
474
- }), e.isHuman) {
475
- const O = E.provider.provider.url;
476
- i.onHuman(ue({
477
- [C.providerUrl]: O,
478
- [C.user]: p.account.address,
479
- [C.dapp]: ee(),
480
- [C.commitmentId]: ye(L[1]),
481
- [C.timestamp]: s.timestamp,
482
- [C.signature]: {
483
- [C.provider]: {
484
- [C.requestHash]: s.signature.provider.requestHash
485
- },
486
- [C.user]: {
487
- [C.timestamp]: v.signature
488
- }
489
- }
490
- })), Q();
491
- } else
492
- i.onFailed(), P(n == null ? void 0 : n.restart);
493
- }, l, P, e.attemptCount, 10);
494
- }, u = async () => {
495
- k(), P(n == null ? void 0 : n.restart), i.onClose();
496
- }, y = async () => {
497
- k(), i.onReload(), P(n == null ? void 0 : n.restart), n != null && n.restart || await l();
498
- }, x = (s) => {
499
- if (!e.challenge)
500
- throw new T("CAPTCHA.NO_CAPTCHA", {
501
- context: { error: "Cannot select, no Captcha found in state" }
502
- });
503
- if (e.index >= e.challenge.captchas.length || e.index < 0)
504
- throw new T("CAPTCHA.NO_CAPTCHA", {
505
- context: {
506
- error: "Cannot select, index is out of range for this Captcha"
507
- }
508
- });
509
- const g = e.index, m = e.solutions, p = w(m, g);
510
- p.includes(s) ? p.splice(p.indexOf(s), 1) : p.push(s), r({ solutions: m });
511
- }, b = () => {
512
- if (!e.challenge)
513
- throw new T("CAPTCHA.NO_CAPTCHA", {
514
- context: { error: "Cannot select, no Captcha found in state" }
515
- });
516
- if (e.index + 1 >= e.challenge.captchas.length)
517
- throw new T("CAPTCHA.NO_CAPTCHA", {
518
- context: {
519
- error: "Cannot select, index is out of range for this Captcha"
520
- }
521
- });
522
- r({ index: e.index + 1 });
523
- }, A = async (s) => {
524
- const g = d();
525
- if (!g.account.address)
526
- throw new N("GENERAL.SITE_KEY_MISSING");
527
- return new ie(s, g.account.address);
528
- }, k = () => {
529
- window.clearTimeout(Number(e.timeout)), r({ timeout: void 0 });
530
- }, Q = () => {
531
- const s = t.captchas.image.solutionTimeout, g = setTimeout(() => {
532
- r({ isHuman: !1 }), i.onExpired();
533
- }, s);
534
- r({ successfullChallengeTimeout: g });
535
- }, P = (s) => {
536
- k(), r(Pe()), i.onReset(), s && s();
537
- }, J = async () => {
538
- const s = d();
539
- if (!s.web2 && !s.userAccountAddress)
540
- throw new N("GENERAL.ACCOUNT_NOT_FOUND", {
541
- context: { error: "Account address has not been set for web3 mode" }
542
- });
543
- const m = await (async () => {
544
- const p = new (await ce(s.web2))();
545
- return n ? n.userAccount : await p.getAccount(s);
546
- })();
547
- return r({ account: m }), G();
548
- }, G = () => {
549
- if (!e.account)
550
- throw new N("GENERAL.ACCOUNT_NOT_FOUND", {
551
- context: { error: "Account not loaded" }
552
- });
553
- return e.account;
554
- }, ee = () => {
555
- if (!e.dappAccount)
556
- throw new N("GENERAL.SITE_KEY_MISSING");
557
- return e.dappAccount;
558
- }, te = (s) => {
559
- const g = s || G();
560
- if (!g.extension)
561
- throw new N("ACCOUNT.NO_POLKADOT_EXTENSION", {
562
- context: { error: "Extension not loaded" }
563
- });
564
- return g.extension;
565
- };
566
- return {
567
- start: l,
568
- cancel: u,
569
- submit: h,
570
- select: x,
571
- nextRound: b,
572
- reload: y
573
- };
574
- }
575
- const _e = le`
576
- position: absolute;
577
- top: 50%;
578
- left: 50%;
579
- transform: translate(-50%, -50%);
580
- max-width: 500px;
581
- background-color: transparent;
582
- border: none;
583
- border-radius: 4px;
584
- z-index: 2147483647;
585
- align-self: center;
586
- box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px,
587
- rgba(0, 0, 0, 0.14) 0px 24px 38px 3px,
588
- rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;
589
- box-sizing: border-box; /* Ensures border is part of width */
590
- /* iOS only */
591
- @supports (-webkit-touch-callout: none) {
592
- transform: translate(-50%, -100%);
593
- }
594
- `, K = he.memo((t) => {
595
- const { show: e, children: o } = t, n = {
596
- position: "fixed",
597
- zIndex: 2147483646,
598
- inset: 0,
599
- display: e ? "flex" : "none",
600
- alignItems: "center",
601
- justifyContent: "center",
602
- minHeight: "100vh"
603
- };
604
- return Ce.createPortal(c("div", { className: "prosopo-modalOuter", style: n, children: c("div", { className: "prosopo-modalInner", css: _e, children: o }) }), document.body);
605
- }), V = "procaptcha:execute", $e = (t) => {
606
- var x;
607
- const { t: e } = q(), o = X.parse(t.config), a = t.frictionlessState, n = t.i18n, i = t.callbacks || {}, [r, d] = xe(f.useState, f.useRef), [l, h] = f.useState(!1), u = Le(o, r, d, i, a), y = t.config.theme === "light" ? M : D;
608
- return f.useEffect(() => {
609
- o.language && (n ? n.language !== o.language && n.changeLanguage(o.language).then((b) => b) : pe().then((b) => {
610
- b.language !== o.language && b.changeLanguage(o.language).then((A) => A);
611
- }));
612
- }, [n, o.language]), f.useEffect(() => {
613
- r.error && (h(!1), r.error.key === "CAPTCHA.NO_SESSION_FOUND" && a && setTimeout(() => {
614
- a.restart();
615
- }, 3e3));
616
- }, [r.error, a]), f.useEffect(() => {
617
- const b = (A) => {
618
- if (d({
619
- showModal: !0
620
- }), !r.challenge && u.start)
621
- try {
622
- u.start();
623
- } catch (k) {
624
- console.error("Error starting verification:", k);
625
- }
626
- };
627
- return document.addEventListener(V, b), () => {
628
- document.removeEventListener(V, b);
629
- };
630
- }, [u, r.challenge, d]), o.mode === "invisible" ? c(K, { show: r.showModal, children: r.challenge ? c(j, { challenge: r.challenge, index: r.index, solutions: r.solutions, onSubmit: u.submit, onCancel: u.cancel, onClick: u.select, onNext: u.nextRound, onReload: u.reload, themeColor: o.theme ?? "light" }) : null }) : H("div", { className: "image-captcha", children: [c(K, { show: r.showModal, children: r.challenge ? c(j, { challenge: r.challenge, index: r.index, solutions: r.solutions, onSubmit: u.submit, onCancel: u.cancel, onClick: u.select, onNext: u.nextRound, onReload: u.reload, themeColor: o.theme ?? "light" }) : c("div", { children: "No challenge set." }) }), c(de, { theme: y, onChange: async () => {
631
- l || (h(!0), await u.start(), h(!1));
632
- }, checked: r.isHuman, labelText: e("WIDGET.I_AM_HUMAN"), error: (x = r.error) == null ? void 0 : x.message, "aria-label": "human checkbox", loading: l })] });
633
- };
634
- export {
635
- $e as default
636
- };