@prosopo/procaptcha-bundle 3.0.8 → 3.0.10
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.
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentProvider.d.ts +1 -0
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentProvider.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentsList.d.ts +1 -0
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentsList.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaRenderer.d.ts +1 -0
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaRenderer.d.ts.map +1 -1
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaType.d.ts +2 -1
- package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaType.d.ts.map +1 -1
- package/CHANGELOG.md +38 -0
- package/dist/bundle/ProcaptchaWidget-48FxVPQd.js +187 -0
- package/dist/bundle/ProcaptchaWidget-B2BzhXLv.js +992 -0
- package/dist/bundle/builder-DNHtDoNG.js +44 -0
- package/dist/bundle/{captchaComponentProvider-Dw6ydLe3.js → captchaComponentProvider-B7Vxx339.js} +266 -100
- package/dist/bundle/{captchaRenderer-CY8KuZK-.js → captchaRenderer-DdOlOCKw.js} +3 -3
- package/dist/bundle/{commonChunk-24zMb_mF.js → commonChunk-HCVkoCqn.js} +9 -12
- package/dist/bundle/{emotion-element-5486c51c.browser.esm-PRDDgd_k.js → emotion-element-5486c51c.browser.esm-D7qvHZDV.js} +1 -1
- package/dist/bundle/{fp.esm-BADUiinQ.js → fp.esm-DYWeNGcH.js} +648 -548
- package/dist/bundle/index-7Xh-Mf8v.js +1318 -0
- package/dist/bundle/{index-DqwVRCwA.js → index-C00_J7av.js} +48 -12
- package/dist/bundle/{index-BzOMq-ud.js → index-DyYmvHVN.js} +1 -1
- package/dist/bundle/locales/ar/translation.json +12 -11
- package/dist/bundle/locales/az/translation.json +12 -11
- package/dist/bundle/locales/cs/translation.json +12 -11
- package/dist/bundle/locales/de/translation.json +12 -11
- package/dist/bundle/locales/el/translation.json +12 -11
- package/dist/bundle/locales/en/translation.json +4 -3
- package/dist/bundle/locales/es/translation.json +12 -11
- package/dist/bundle/locales/fi/translation.json +29 -28
- package/dist/bundle/locales/fr/translation.json +12 -11
- package/dist/bundle/locales/hi/translation.json +41 -40
- package/dist/bundle/locales/hu/translation.json +12 -11
- package/dist/bundle/locales/id/translation.json +12 -11
- package/dist/bundle/locales/it/translation.json +12 -11
- package/dist/bundle/locales/ja/translation.json +12 -11
- package/dist/bundle/locales/jv/translation.json +12 -11
- package/dist/bundle/locales/ko/translation.json +7 -6
- package/dist/bundle/locales/ml/translation.json +12 -11
- package/dist/bundle/locales/ms/translation.json +12 -11
- package/dist/bundle/locales/nl/translation.json +12 -11
- package/dist/bundle/locales/no/translation.json +12 -11
- package/dist/bundle/locales/pl/translation.json +12 -11
- package/dist/bundle/locales/pt/translation.json +12 -11
- package/dist/bundle/locales/pt-BR/translation.json +12 -11
- package/dist/bundle/locales/ro/translation.json +12 -11
- package/dist/bundle/locales/ru/translation.json +12 -11
- package/dist/bundle/locales/sr/translation.json +12 -11
- package/dist/bundle/locales/sv/translation.json +12 -11
- package/dist/bundle/locales/th/translation.json +12 -11
- package/dist/bundle/locales/tr/translation.json +7 -6
- package/dist/bundle/locales/uk/translation.json +12 -11
- package/dist/bundle/locales/vi/translation.json +12 -11
- package/dist/bundle/locales/zh-CN/translation.json +12 -11
- package/dist/bundle/nobleChunk-Qozzkbsq.js +3648 -0
- package/dist/bundle/procaptcha.bundle.js +2 -2
- package/dist/bundle/util/captcha/captchaComponentProvider.d.ts +1 -0
- package/dist/bundle/util/captcha/captchaComponentProvider.d.ts.map +1 -1
- package/dist/bundle/util/captcha/captchaComponentsList.d.ts +1 -0
- package/dist/bundle/util/captcha/captchaComponentsList.d.ts.map +1 -1
- package/dist/bundle/util/captcha/captchaRenderer.d.ts +1 -0
- package/dist/bundle/util/captcha/captchaRenderer.d.ts.map +1 -1
- package/dist/bundle/util/captcha/captchaType.d.ts +2 -1
- package/dist/bundle/util/captcha/captchaType.d.ts.map +1 -1
- package/dist/bundle/{utilCryptoChunk-CIPUtfoO.js → utilCryptoChunk-qm-BM2eT.js} +618 -647
- package/dist/bundle/{web2Chunk-7Vd8yt2r.js → web2Chunk-DCsWA5PR.js} +1150 -994
- package/dist/bundle/{web3Chunk-DrUvbVNW.js → web3Chunk-B8txCqUJ.js} +3 -3
- package/dist/index.js +142 -108
- package/dist/util/captcha/captchaComponentProvider.js +18 -10
- package/dist/util/captcha/captchaComponentsList.js +6 -5
- package/dist/util/captcha/captchaRenderer.js +58 -40
- package/dist/util/captcha/captchaType.js +9 -5
- package/dist/util/captcha/components/frictionlessCaptcha.js +19 -9
- package/dist/util/captcha/components/imageCaptcha.js +13 -5
- package/dist/util/captcha/components/powCaptcha.js +13 -5
- package/dist/util/config.js +15 -12
- package/dist/util/configCreator.js +21 -22
- package/dist/util/language.js +14 -13
- package/dist/util/timeout.js +13 -8
- package/dist/util/widgetFactory.js +77 -55
- package/dist/util/widgetThemeResolver.js +14 -17
- package/package.json +23 -20
- package/stats.html +1 -1
- package/vite.cjs.config.ts +2 -3
- package/vite.esm.config.ts +20 -0
- package/vite.test.config.ts +9 -5
- package/dist/bundle/ProcaptchaWidget-BpzncYOb.js +0 -612
- package/dist/bundle/ProcaptchaWidget-D961oZ27.js +0 -148
- package/dist/bundle/builder-CQlqPNRd.js +0 -37
- package/dist/bundle/index-BRg_gWPo.js +0 -1328
- package/dist/bundle/nobleChunk-Xl5XLrx3.js +0 -3635
- package/dist/components.d.ts +0 -5
- package/dist/components.d.ts.map +0 -1
- package/dist/components.js +0 -5
- package/dist/components.js.map +0 -1
- package/dist/index.d.ts +0 -16
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/tests/util/captchaType.test.d.ts +0 -2
- package/dist/tests/util/captchaType.test.d.ts.map +0 -1
- package/dist/tests/util/captchaType.test.js +0 -36
- package/dist/tests/util/captchaType.test.js.map +0 -1
- package/dist/tests/util/config.test.d.ts +0 -2
- package/dist/tests/util/config.test.d.ts.map +0 -1
- package/dist/tests/util/config.test.js +0 -69
- package/dist/tests/util/config.test.js.map +0 -1
- package/dist/tests/util/renderLogic.test.d.ts +0 -2
- package/dist/tests/util/renderLogic.test.d.ts.map +0 -1
- package/dist/tests/util/renderLogic.test.js +0 -126
- package/dist/tests/util/renderLogic.test.js.map +0 -1
- package/dist/util/captcha/captchaComponentProvider.d.ts +0 -8
- package/dist/util/captcha/captchaComponentProvider.d.ts.map +0 -1
- package/dist/util/captcha/captchaComponentProvider.js.map +0 -1
- package/dist/util/captcha/captchaComponentsList.d.ts +0 -6
- package/dist/util/captcha/captchaComponentsList.d.ts.map +0 -1
- package/dist/util/captcha/captchaComponentsList.js.map +0 -1
- package/dist/util/captcha/captchaProps.d.ts +0 -9
- package/dist/util/captcha/captchaProps.d.ts.map +0 -1
- package/dist/util/captcha/captchaProps.js +0 -2
- package/dist/util/captcha/captchaProps.js.map +0 -1
- package/dist/util/captcha/captchaRenderer.d.ts +0 -24
- package/dist/util/captcha/captchaRenderer.d.ts.map +0 -1
- package/dist/util/captcha/captchaRenderer.js.map +0 -1
- package/dist/util/captcha/captchaType.d.ts +0 -3
- package/dist/util/captcha/captchaType.d.ts.map +0 -1
- package/dist/util/captcha/captchaType.js.map +0 -1
- package/dist/util/captcha/components/frictionlessCaptcha.d.ts +0 -4
- package/dist/util/captcha/components/frictionlessCaptcha.d.ts.map +0 -1
- package/dist/util/captcha/components/frictionlessCaptcha.js.map +0 -1
- package/dist/util/captcha/components/imageCaptcha.d.ts +0 -4
- package/dist/util/captcha/components/imageCaptcha.d.ts.map +0 -1
- package/dist/util/captcha/components/imageCaptcha.js.map +0 -1
- package/dist/util/captcha/components/powCaptcha.d.ts +0 -4
- package/dist/util/captcha/components/powCaptcha.d.ts.map +0 -1
- package/dist/util/captcha/components/powCaptcha.js.map +0 -1
- package/dist/util/config.d.ts +0 -6
- package/dist/util/config.d.ts.map +0 -1
- package/dist/util/config.js.map +0 -1
- package/dist/util/configCreator.d.ts +0 -5
- package/dist/util/configCreator.d.ts.map +0 -1
- package/dist/util/configCreator.js.map +0 -1
- package/dist/util/language.d.ts +0 -3
- package/dist/util/language.d.ts.map +0 -1
- package/dist/util/language.js.map +0 -1
- package/dist/util/timeout.d.ts +0 -3
- package/dist/util/timeout.d.ts.map +0 -1
- package/dist/util/timeout.js.map +0 -1
- package/dist/util/widgetFactory.d.ts +0 -18
- package/dist/util/widgetFactory.d.ts.map +0 -1
- package/dist/util/widgetFactory.js.map +0 -1
- package/dist/util/widgetThemeResolver.d.ts +0 -9
- package/dist/util/widgetThemeResolver.d.ts.map +0 -1
- package/dist/util/widgetThemeResolver.js.map +0 -1
|
@@ -0,0 +1,992 @@
|
|
|
1
|
+
import { j as l, a as H, g as oe, p as U, b as ne, P as ae, E as re, c as se, C as ie } from "./captchaComponentProvider-B7Vxx339.js";
|
|
2
|
+
import { r as m, u as V, a as b, A as w, f as ce, h as le, s as de, P as X, g as ue, l as pe } from "./web2Chunk-DCsWA5PR.js";
|
|
3
|
+
import { b as _, c as W, P as v, a as N } from "./commonChunk-HCVkoCqn.js";
|
|
4
|
+
import { b as he, u as ge } from "./builder-DNHtDoNG.js";
|
|
5
|
+
import { u as fe } from "./utilCryptoChunk-qm-BM2eT.js";
|
|
6
|
+
import { w as me } from "./utilChunk-sqstc6C5.js";
|
|
7
|
+
import { l as M, d as D } from "./index-C00_J7av.js";
|
|
8
|
+
import { r as xe } from "./index-DyYmvHVN.js";
|
|
9
|
+
const Ce = {
|
|
10
|
+
border: "none",
|
|
11
|
+
paddingTop: "6px",
|
|
12
|
+
paddingBottom: "6px",
|
|
13
|
+
cursor: "pointer",
|
|
14
|
+
height: "39px",
|
|
15
|
+
width: "39px",
|
|
16
|
+
borderRadius: "50%",
|
|
17
|
+
display: "flex"
|
|
18
|
+
}, we = ({
|
|
19
|
+
themeColor: r,
|
|
20
|
+
onReload: e
|
|
21
|
+
}) => {
|
|
22
|
+
const o = m.useMemo(
|
|
23
|
+
() => r === "light" ? M : D,
|
|
24
|
+
[r]
|
|
25
|
+
), [n, t] = m.useState(!1), i = m.useMemo(() => ({
|
|
26
|
+
...{
|
|
27
|
+
...Ce,
|
|
28
|
+
backgroundColor: o.palette.background.default,
|
|
29
|
+
color: n ? o.palette.primary.contrastText : o.palette.background.contrastText,
|
|
30
|
+
border: `1px solid ${o.palette.grey[500]}`,
|
|
31
|
+
borderRadius: "50%",
|
|
32
|
+
transition: "background-color 0.3s",
|
|
33
|
+
boxShadow: `0px 1px 3px 0px ${o.palette.grey[500]}`,
|
|
34
|
+
justifyContent: "center",
|
|
35
|
+
alignItems: "center",
|
|
36
|
+
margin: "0 auto"
|
|
37
|
+
},
|
|
38
|
+
backgroundColor: n ? o.palette.grey[700] : o.palette.background.default
|
|
39
|
+
}), [n, o]);
|
|
40
|
+
return /* @__PURE__ */ l(
|
|
41
|
+
"button",
|
|
42
|
+
{
|
|
43
|
+
className: "reload-button",
|
|
44
|
+
"aria-label": "Reload",
|
|
45
|
+
type: "button",
|
|
46
|
+
style: i,
|
|
47
|
+
onMouseEnter: () => t(!0),
|
|
48
|
+
onMouseLeave: () => t(!1),
|
|
49
|
+
onClick: (a) => {
|
|
50
|
+
a.preventDefault(), e();
|
|
51
|
+
},
|
|
52
|
+
children: /* @__PURE__ */ H(
|
|
53
|
+
"svg",
|
|
54
|
+
{
|
|
55
|
+
width: "16px",
|
|
56
|
+
height: "16px",
|
|
57
|
+
viewBox: "0 0 16 16",
|
|
58
|
+
version: "1.1",
|
|
59
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
60
|
+
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
61
|
+
style: { display: "flex" },
|
|
62
|
+
children: [
|
|
63
|
+
/* @__PURE__ */ l("title", { children: "reload" }),
|
|
64
|
+
/* @__PURE__ */ l(
|
|
65
|
+
"path",
|
|
66
|
+
{
|
|
67
|
+
shapeRendering: "optimizeQuality",
|
|
68
|
+
fill: n ? o.palette.primary.contrastText : o.palette.grey[700],
|
|
69
|
+
transform: "scale(0.0416)",
|
|
70
|
+
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"
|
|
71
|
+
}
|
|
72
|
+
)
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}, be = (r) => {
|
|
79
|
+
if (!r.hash)
|
|
80
|
+
throw new _("CAPTCHA.MISSING_ITEM_HASH", {
|
|
81
|
+
context: { item: r }
|
|
82
|
+
});
|
|
83
|
+
return r.hash;
|
|
84
|
+
}, Ae = ({
|
|
85
|
+
challenge: r,
|
|
86
|
+
solution: e,
|
|
87
|
+
onClick: o,
|
|
88
|
+
themeColor: n
|
|
89
|
+
}) => {
|
|
90
|
+
const t = r.items, i = m.useMemo(
|
|
91
|
+
() => n === "light" ? M : D,
|
|
92
|
+
[n]
|
|
93
|
+
), a = `${i.spacing.unit}px`;
|
|
94
|
+
return /* @__PURE__ */ l(
|
|
95
|
+
"div",
|
|
96
|
+
{
|
|
97
|
+
style: {
|
|
98
|
+
// expand to full height / width of parent
|
|
99
|
+
width: "100%",
|
|
100
|
+
height: "100%",
|
|
101
|
+
// display children in flex, spreading them evenly and wrapping when row length exceeded
|
|
102
|
+
display: "flex",
|
|
103
|
+
flexDirection: "row",
|
|
104
|
+
flexWrap: "wrap",
|
|
105
|
+
justifyContent: "space-between",
|
|
106
|
+
paddingBottom: a,
|
|
107
|
+
paddingTop: a,
|
|
108
|
+
gap: "10px"
|
|
109
|
+
},
|
|
110
|
+
children: t.map((s, d) => {
|
|
111
|
+
const u = be(s);
|
|
112
|
+
return /* @__PURE__ */ l("div", { style: {
|
|
113
|
+
// enable the items in the grid to grow in width to use up excess space
|
|
114
|
+
flexGrow: 1,
|
|
115
|
+
// make the width of each item 1/3rd of the width overall, i.e. 3 columns
|
|
116
|
+
flexBasis: "calc(33.333% - 10px)",
|
|
117
|
+
// include the padding / margin / border in the width
|
|
118
|
+
boxSizing: "border-box"
|
|
119
|
+
}, children: /* @__PURE__ */ H(
|
|
120
|
+
"div",
|
|
121
|
+
{
|
|
122
|
+
style: {
|
|
123
|
+
position: "relative",
|
|
124
|
+
cursor: "pointer",
|
|
125
|
+
height: "100%",
|
|
126
|
+
width: "100%",
|
|
127
|
+
padding: 0,
|
|
128
|
+
margin: 0
|
|
129
|
+
},
|
|
130
|
+
onClick: () => o(u),
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ l(
|
|
133
|
+
"img",
|
|
134
|
+
{
|
|
135
|
+
style: {
|
|
136
|
+
width: "100%",
|
|
137
|
+
// image should be full width / height of the item
|
|
138
|
+
display: "block",
|
|
139
|
+
// removes whitespace below imgs
|
|
140
|
+
objectFit: "cover",
|
|
141
|
+
// contain the entire image in the img tag
|
|
142
|
+
aspectRatio: "1/1",
|
|
143
|
+
// force AR to be 1, letterboxing images with different aspect ratios
|
|
144
|
+
height: "auto",
|
|
145
|
+
// make the img tag responsive to its container
|
|
146
|
+
overflow: "hidden",
|
|
147
|
+
borderStyle: "solid",
|
|
148
|
+
borderWidth: "1px",
|
|
149
|
+
borderColor: i.palette.grey[300]
|
|
150
|
+
},
|
|
151
|
+
src: s.data,
|
|
152
|
+
alt: `Captcha image ${d + 1}`
|
|
153
|
+
}
|
|
154
|
+
),
|
|
155
|
+
/* @__PURE__ */ l(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
style: {
|
|
159
|
+
position: "absolute",
|
|
160
|
+
top: 0,
|
|
161
|
+
left: 0,
|
|
162
|
+
bottom: 0,
|
|
163
|
+
right: 0,
|
|
164
|
+
height: "100%",
|
|
165
|
+
width: "100%",
|
|
166
|
+
// display overlays in center
|
|
167
|
+
display: "flex",
|
|
168
|
+
alignItems: "center",
|
|
169
|
+
justifyContent: "center",
|
|
170
|
+
// make bg half opacity, i.e. shadowing the item's img
|
|
171
|
+
backgroundColor: "rgba(0,0,0,0.5)",
|
|
172
|
+
visibility: e.includes(u) ? "visible" : "hidden"
|
|
173
|
+
},
|
|
174
|
+
children: /* @__PURE__ */ l(
|
|
175
|
+
"svg",
|
|
176
|
+
{
|
|
177
|
+
style: {
|
|
178
|
+
backgroundColor: "transparent",
|
|
179
|
+
// img must be displayed as block otherwise gets a bottom whitespace border
|
|
180
|
+
display: "block",
|
|
181
|
+
// how big the overlay icon is
|
|
182
|
+
width: "35%",
|
|
183
|
+
height: "35%",
|
|
184
|
+
transition: "fill 200ms cubic-bezier(0.4, 0, 0.2, 1) 0ms",
|
|
185
|
+
userSelect: "none",
|
|
186
|
+
fill: "currentcolor"
|
|
187
|
+
},
|
|
188
|
+
focusable: "false",
|
|
189
|
+
color: "#fff",
|
|
190
|
+
"aria-hidden": "true",
|
|
191
|
+
viewBox: "0 0 24 24",
|
|
192
|
+
"data-testid": "CheckIcon",
|
|
193
|
+
"aria-label": "Check icon",
|
|
194
|
+
children: /* @__PURE__ */ l("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" })
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
)
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
) }, s.hash);
|
|
202
|
+
})
|
|
203
|
+
}
|
|
204
|
+
);
|
|
205
|
+
};
|
|
206
|
+
function ye(r = {}) {
|
|
207
|
+
return Object.keys(r).reduce(
|
|
208
|
+
// biome-ignore lint/performance/noAccumulatingSpread: TODO fix
|
|
209
|
+
(e, o) => ({ ...e, [`data-${o}`]: r[o] }),
|
|
210
|
+
{}
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
function q({
|
|
214
|
+
general: r,
|
|
215
|
+
dev: e
|
|
216
|
+
}) {
|
|
217
|
+
return {
|
|
218
|
+
...ye(r)
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
const ve = {
|
|
222
|
+
display: "inline-flex",
|
|
223
|
+
alignItems: "center",
|
|
224
|
+
justifyContent: "center",
|
|
225
|
+
position: "relative",
|
|
226
|
+
boxSizing: "border-box",
|
|
227
|
+
outline: "0px",
|
|
228
|
+
margin: "0px",
|
|
229
|
+
cursor: "pointer",
|
|
230
|
+
userSelect: "none",
|
|
231
|
+
verticalAlign: "middle",
|
|
232
|
+
appearance: void 0,
|
|
233
|
+
textDecoration: "none",
|
|
234
|
+
fontWeight: "500",
|
|
235
|
+
fontSize: "0.875rem",
|
|
236
|
+
lineHeight: "1.75",
|
|
237
|
+
letterSpacing: "0.02857em",
|
|
238
|
+
textTransform: "uppercase",
|
|
239
|
+
minWidth: "64px",
|
|
240
|
+
padding: "6px 16px",
|
|
241
|
+
borderRadius: "4px",
|
|
242
|
+
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",
|
|
243
|
+
backgroundColor: "#ffffff"
|
|
244
|
+
}, B = ({
|
|
245
|
+
themeColor: r,
|
|
246
|
+
buttonType: e,
|
|
247
|
+
text: o,
|
|
248
|
+
onClick: n
|
|
249
|
+
}) => {
|
|
250
|
+
const t = m.useMemo(
|
|
251
|
+
() => r === "light" ? M : D,
|
|
252
|
+
[r]
|
|
253
|
+
), [i, a] = m.useState(!1), s = m.useMemo(() => {
|
|
254
|
+
const d = {
|
|
255
|
+
...ve,
|
|
256
|
+
border: `1px solid ${t.palette.grey[500]}`,
|
|
257
|
+
boxShadow: `0px 1px 3px 0px ${t.palette.grey[500]}`,
|
|
258
|
+
fontFamily: t.font.fontFamily,
|
|
259
|
+
width: "100%",
|
|
260
|
+
color: i ? t.palette.primary.contrastText : t.palette.background.contrastText
|
|
261
|
+
};
|
|
262
|
+
return e === "cancel" ? {
|
|
263
|
+
...d,
|
|
264
|
+
backgroundColor: i ? t.palette.grey[600] : "transparent"
|
|
265
|
+
} : {
|
|
266
|
+
...d,
|
|
267
|
+
backgroundColor: i ? t.palette.primary.main : t.palette.background.default
|
|
268
|
+
};
|
|
269
|
+
}, [e, i, t]);
|
|
270
|
+
return /* @__PURE__ */ l(
|
|
271
|
+
"button",
|
|
272
|
+
{
|
|
273
|
+
...q({ dev: {} }),
|
|
274
|
+
onMouseEnter: () => a(!0),
|
|
275
|
+
onMouseLeave: () => a(!1),
|
|
276
|
+
style: s,
|
|
277
|
+
onClick: (d) => {
|
|
278
|
+
d.preventDefault(), n();
|
|
279
|
+
},
|
|
280
|
+
"aria-label": o,
|
|
281
|
+
children: o
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
}, $ = ({
|
|
285
|
+
challenge: r,
|
|
286
|
+
index: e,
|
|
287
|
+
solutions: o,
|
|
288
|
+
onSubmit: n,
|
|
289
|
+
onCancel: t,
|
|
290
|
+
onClick: i,
|
|
291
|
+
onNext: a,
|
|
292
|
+
onReload: s,
|
|
293
|
+
themeColor: d
|
|
294
|
+
}) => {
|
|
295
|
+
const { t: u } = V(), C = r.captchas ? b(r.captchas, e) : null, h = o ? b(o, e) : [], A = m.useMemo(
|
|
296
|
+
() => d === "light" ? M : D,
|
|
297
|
+
[d]
|
|
298
|
+
), k = `${A.spacing.unit * 2}px`, g = `${A.spacing.unit}px`;
|
|
299
|
+
return /* @__PURE__ */ l(m.Suspense, { fallback: /* @__PURE__ */ l("div", { children: "Loading..." }), children: /* @__PURE__ */ l(
|
|
300
|
+
"div",
|
|
301
|
+
{
|
|
302
|
+
style: {
|
|
303
|
+
// introduce scroll bars when screen < minWidth of children
|
|
304
|
+
overflowX: "auto",
|
|
305
|
+
overflowY: "auto",
|
|
306
|
+
maxWidth: "500px",
|
|
307
|
+
maxHeight: "100%",
|
|
308
|
+
display: "flex",
|
|
309
|
+
flexDirection: "column",
|
|
310
|
+
border: "1px solid #dddddd",
|
|
311
|
+
boxShadow: "rgba(255, 255, 255, 0.2) 0px 0px 4px",
|
|
312
|
+
borderRadius: "4px",
|
|
313
|
+
backgroundColor: A.palette.background.default,
|
|
314
|
+
userSelect: "none",
|
|
315
|
+
touchAction: "none",
|
|
316
|
+
overscrollBehavior: "none"
|
|
317
|
+
},
|
|
318
|
+
children: /* @__PURE__ */ H(
|
|
319
|
+
"div",
|
|
320
|
+
{
|
|
321
|
+
style: {
|
|
322
|
+
backgroundColor: A.palette.background.default,
|
|
323
|
+
display: "flex",
|
|
324
|
+
flexDirection: "column",
|
|
325
|
+
minWidth: "300px",
|
|
326
|
+
marginLeft: g,
|
|
327
|
+
marginRight: g,
|
|
328
|
+
justifyContent: "center"
|
|
329
|
+
},
|
|
330
|
+
children: [
|
|
331
|
+
/* @__PURE__ */ l(
|
|
332
|
+
"div",
|
|
333
|
+
{
|
|
334
|
+
style: {
|
|
335
|
+
display: "flex",
|
|
336
|
+
alignItems: "center",
|
|
337
|
+
width: "100%"
|
|
338
|
+
},
|
|
339
|
+
children: /* @__PURE__ */ l(
|
|
340
|
+
"div",
|
|
341
|
+
{
|
|
342
|
+
style: {
|
|
343
|
+
backgroundColor: A.palette.primary.main,
|
|
344
|
+
width: "100%",
|
|
345
|
+
marginTop: g
|
|
346
|
+
},
|
|
347
|
+
children: /* @__PURE__ */ H(
|
|
348
|
+
"div",
|
|
349
|
+
{
|
|
350
|
+
style: {
|
|
351
|
+
padding: `${A.spacing.half}px`,
|
|
352
|
+
fontFamily: A.font.fontFamily
|
|
353
|
+
},
|
|
354
|
+
children: [
|
|
355
|
+
/* @__PURE__ */ H(
|
|
356
|
+
"p",
|
|
357
|
+
{
|
|
358
|
+
style: {
|
|
359
|
+
color: "#ffffff",
|
|
360
|
+
fontWeight: 700,
|
|
361
|
+
lineHeight: 1.5
|
|
362
|
+
},
|
|
363
|
+
children: [
|
|
364
|
+
u("WIDGET.SELECT_ALL"),
|
|
365
|
+
":",
|
|
366
|
+
" ",
|
|
367
|
+
/* @__PURE__ */ l("span", { children: `${b(r.captchas, e).target} ` })
|
|
368
|
+
]
|
|
369
|
+
}
|
|
370
|
+
),
|
|
371
|
+
/* @__PURE__ */ l(
|
|
372
|
+
"p",
|
|
373
|
+
{
|
|
374
|
+
style: {
|
|
375
|
+
color: "#ffffff",
|
|
376
|
+
fontWeight: 500,
|
|
377
|
+
lineHeight: 0.8,
|
|
378
|
+
fontSize: "0.8rem"
|
|
379
|
+
},
|
|
380
|
+
children: u("WIDGET.IF_NONE_CLICK_NEXT")
|
|
381
|
+
}
|
|
382
|
+
)
|
|
383
|
+
]
|
|
384
|
+
}
|
|
385
|
+
)
|
|
386
|
+
}
|
|
387
|
+
)
|
|
388
|
+
}
|
|
389
|
+
),
|
|
390
|
+
/* @__PURE__ */ l(
|
|
391
|
+
"div",
|
|
392
|
+
{
|
|
393
|
+
...q({ dev: {} }),
|
|
394
|
+
style: { overflow: "hidden" },
|
|
395
|
+
children: C && /* @__PURE__ */ l(
|
|
396
|
+
Ae,
|
|
397
|
+
{
|
|
398
|
+
challenge: C,
|
|
399
|
+
solution: h,
|
|
400
|
+
onClick: i,
|
|
401
|
+
themeColor: d
|
|
402
|
+
}
|
|
403
|
+
)
|
|
404
|
+
}
|
|
405
|
+
),
|
|
406
|
+
/* @__PURE__ */ l(
|
|
407
|
+
"div",
|
|
408
|
+
{
|
|
409
|
+
style: {
|
|
410
|
+
display: "flex",
|
|
411
|
+
alignItems: "center",
|
|
412
|
+
justifyContent: "space-between",
|
|
413
|
+
lineHeight: 1.75,
|
|
414
|
+
padding: `${g} 0 ${k} 0`
|
|
415
|
+
},
|
|
416
|
+
children: /* @__PURE__ */ H(
|
|
417
|
+
"div",
|
|
418
|
+
{
|
|
419
|
+
style: {
|
|
420
|
+
// expand to full height / width of parent
|
|
421
|
+
width: "100%",
|
|
422
|
+
height: "100%",
|
|
423
|
+
// display children in flex, spreading them evenly and wrapping when row length exceeded
|
|
424
|
+
display: "flex",
|
|
425
|
+
flexDirection: "row",
|
|
426
|
+
flexWrap: "wrap",
|
|
427
|
+
justifyContent: "space-between",
|
|
428
|
+
gap: "10px"
|
|
429
|
+
},
|
|
430
|
+
children: [
|
|
431
|
+
/* @__PURE__ */ l(
|
|
432
|
+
"div",
|
|
433
|
+
{
|
|
434
|
+
style: {
|
|
435
|
+
position: "relative",
|
|
436
|
+
flexGrow: 1,
|
|
437
|
+
// make the width of each item 1/3rd of the width overall, i.e. 3 columns
|
|
438
|
+
flexBasis: "calc(33.333% - 10px)"
|
|
439
|
+
},
|
|
440
|
+
children: /* @__PURE__ */ l(
|
|
441
|
+
B,
|
|
442
|
+
{
|
|
443
|
+
themeColor: d,
|
|
444
|
+
buttonType: "cancel",
|
|
445
|
+
onClick: t,
|
|
446
|
+
text: u("WIDGET.CANCEL"),
|
|
447
|
+
"aria-label": u("WIDGET.CANCEL")
|
|
448
|
+
}
|
|
449
|
+
)
|
|
450
|
+
}
|
|
451
|
+
),
|
|
452
|
+
/* @__PURE__ */ l(
|
|
453
|
+
"div",
|
|
454
|
+
{
|
|
455
|
+
style: {
|
|
456
|
+
position: "relative",
|
|
457
|
+
flexGrow: 1,
|
|
458
|
+
// make the width of each item 1/3rd of the width overall, i.e. 3 columns
|
|
459
|
+
flexBasis: "calc(33.333% - 10px)"
|
|
460
|
+
},
|
|
461
|
+
children: /* @__PURE__ */ l(we, { themeColor: d, onReload: s })
|
|
462
|
+
}
|
|
463
|
+
),
|
|
464
|
+
/* @__PURE__ */ l(
|
|
465
|
+
"div",
|
|
466
|
+
{
|
|
467
|
+
style: {
|
|
468
|
+
position: "relative",
|
|
469
|
+
flexGrow: 1,
|
|
470
|
+
// make the width of each item 1/3rd of the width overall, i.e. 3 columns
|
|
471
|
+
flexBasis: "calc(33.333% - 10px)"
|
|
472
|
+
},
|
|
473
|
+
children: /* @__PURE__ */ l(
|
|
474
|
+
B,
|
|
475
|
+
{
|
|
476
|
+
themeColor: d,
|
|
477
|
+
buttonType: "next",
|
|
478
|
+
text: e < r.captchas.length - 1 ? u("WIDGET.NEXT") : u("WIDGET.SUBMIT"),
|
|
479
|
+
onClick: e < r.captchas.length - 1 ? a : n,
|
|
480
|
+
"aria-label": e < r.captchas.length - 1 ? u("WIDGET.NEXT") : u("WIDGET.SUBMIT"),
|
|
481
|
+
"data-cy": "button-next"
|
|
482
|
+
}
|
|
483
|
+
)
|
|
484
|
+
}
|
|
485
|
+
)
|
|
486
|
+
]
|
|
487
|
+
}
|
|
488
|
+
)
|
|
489
|
+
}
|
|
490
|
+
)
|
|
491
|
+
]
|
|
492
|
+
}
|
|
493
|
+
)
|
|
494
|
+
}
|
|
495
|
+
) });
|
|
496
|
+
};
|
|
497
|
+
function Ee(r) {
|
|
498
|
+
return W([
|
|
499
|
+
r.captchaId,
|
|
500
|
+
r.captchaContentId,
|
|
501
|
+
[...r.solution].sort(),
|
|
502
|
+
r.salt
|
|
503
|
+
]);
|
|
504
|
+
}
|
|
505
|
+
class z {
|
|
506
|
+
constructor(e) {
|
|
507
|
+
this.hash = e, this.parent = null;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
class Te {
|
|
511
|
+
constructor() {
|
|
512
|
+
this.leaves = [], this.layers = [];
|
|
513
|
+
}
|
|
514
|
+
getRoot() {
|
|
515
|
+
if (this.root === void 0)
|
|
516
|
+
throw new v("DATASET.MERKLE_ERROR", {
|
|
517
|
+
context: {
|
|
518
|
+
error: "root undefined",
|
|
519
|
+
failedFuncName: this.getRoot.name
|
|
520
|
+
}
|
|
521
|
+
});
|
|
522
|
+
return this.root;
|
|
523
|
+
}
|
|
524
|
+
build(e) {
|
|
525
|
+
this.layers.length && (this.layers = []);
|
|
526
|
+
const o = [];
|
|
527
|
+
for (const n of e) {
|
|
528
|
+
const t = new z(n);
|
|
529
|
+
this.leaves.push(t), o.push(t.hash);
|
|
530
|
+
}
|
|
531
|
+
this.layers.push(o), this.root = this.buildMerkleTree(this.leaves)[0];
|
|
532
|
+
}
|
|
533
|
+
buildMerkleTree(e) {
|
|
534
|
+
const o = e.length;
|
|
535
|
+
if (o === 1)
|
|
536
|
+
return e;
|
|
537
|
+
const n = [];
|
|
538
|
+
let t = 0;
|
|
539
|
+
const i = [];
|
|
540
|
+
for (; t < o; ) {
|
|
541
|
+
const a = e[t];
|
|
542
|
+
if (a === void 0)
|
|
543
|
+
throw new v("DEVELOPER.GENERAL", {
|
|
544
|
+
context: { error: "leftChild undefined" }
|
|
545
|
+
});
|
|
546
|
+
const s = t + 1 < o ? b(e, t + 1) : a, d = this.createParent(a, s);
|
|
547
|
+
i.push(d.hash), n.push(d), t += 2;
|
|
548
|
+
}
|
|
549
|
+
return this.layers.push(i), this.buildMerkleTree(n);
|
|
550
|
+
}
|
|
551
|
+
createParent(e, o) {
|
|
552
|
+
const n = new z(
|
|
553
|
+
W([e.hash, o.hash])
|
|
554
|
+
);
|
|
555
|
+
return e.parent = n.hash, o.parent = n.hash, n;
|
|
556
|
+
}
|
|
557
|
+
proof(e) {
|
|
558
|
+
const o = [];
|
|
559
|
+
let n = 0;
|
|
560
|
+
for (; n < this.layers.length - 1; ) {
|
|
561
|
+
const i = this.layers[n];
|
|
562
|
+
if (i === void 0)
|
|
563
|
+
throw new v("DATASET.MERKLE_ERROR", {
|
|
564
|
+
context: {
|
|
565
|
+
error: "layer undefined",
|
|
566
|
+
failedFuncName: this.proof.name,
|
|
567
|
+
layerNum: n
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
const a = i.indexOf(e);
|
|
571
|
+
let s = a % 2 && a > 0 ? a - 1 : a + 1;
|
|
572
|
+
s > i.length - 1 && (s = a);
|
|
573
|
+
const d = [e], u = b(i, s);
|
|
574
|
+
s > a ? d.push(u) : d.unshift(u), o.push([b(d, 0), b(d, 1)]), n += 1, e = W(d);
|
|
575
|
+
}
|
|
576
|
+
const t = b(this.layers, this.layers.length - 1);
|
|
577
|
+
return [...o, [b(t, 0)]];
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
class F {
|
|
581
|
+
constructor(e, o, n, t, i) {
|
|
582
|
+
this.userAccount = e, this.provider = o, this.providerApi = n, this._web2 = t, this.dappAccount = i;
|
|
583
|
+
}
|
|
584
|
+
get web2() {
|
|
585
|
+
return this._web2;
|
|
586
|
+
}
|
|
587
|
+
async getCaptchaChallenge(e) {
|
|
588
|
+
try {
|
|
589
|
+
const o = await this.providerApi.getCaptchaChallenge(
|
|
590
|
+
this.userAccount,
|
|
591
|
+
this.provider,
|
|
592
|
+
e
|
|
593
|
+
);
|
|
594
|
+
if (o[w.error])
|
|
595
|
+
return o;
|
|
596
|
+
for (const n of o.captchas)
|
|
597
|
+
for (const t of n.items)
|
|
598
|
+
t.data && (t.data = `https://${t.data.replace(/^http(s)*:\/\//, "")}`);
|
|
599
|
+
return o;
|
|
600
|
+
} catch (o) {
|
|
601
|
+
throw new N("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
|
|
602
|
+
context: { error: o }
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
async submitCaptchaSolution(e, o, n, t, i) {
|
|
607
|
+
const a = new Te(), s = n.map(
|
|
608
|
+
(C) => Ee(C)
|
|
609
|
+
);
|
|
610
|
+
if (a.build(s), !a.root)
|
|
611
|
+
throw new _("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
|
|
612
|
+
context: { error: "Merkle tree root is undefined" }
|
|
613
|
+
});
|
|
614
|
+
const d = a.root.hash;
|
|
615
|
+
let u;
|
|
616
|
+
try {
|
|
617
|
+
u = await this.providerApi.submitCaptchaSolution(
|
|
618
|
+
n,
|
|
619
|
+
o,
|
|
620
|
+
this.userAccount,
|
|
621
|
+
t,
|
|
622
|
+
i,
|
|
623
|
+
e
|
|
624
|
+
);
|
|
625
|
+
} catch (C) {
|
|
626
|
+
throw new _("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
|
|
627
|
+
context: { error: C }
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
return [u, d];
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
const Ie = () => ({
|
|
634
|
+
// note order matters! see buildUpdateState. These fields are set in order, so disable modal first, then set loading to false, etc.
|
|
635
|
+
showModal: !1,
|
|
636
|
+
loading: !1,
|
|
637
|
+
index: 0,
|
|
638
|
+
challenge: void 0,
|
|
639
|
+
solutions: void 0,
|
|
640
|
+
isHuman: !1,
|
|
641
|
+
captchaApi: void 0,
|
|
642
|
+
account: void 0
|
|
643
|
+
// don't handle timeout here, this should be handled by the state management
|
|
644
|
+
});
|
|
645
|
+
function Ne(r, e, o, n, t) {
|
|
646
|
+
const i = oe(n), a = he(e, o), s = () => {
|
|
647
|
+
const c = {
|
|
648
|
+
userAccountAddress: "",
|
|
649
|
+
...r
|
|
650
|
+
};
|
|
651
|
+
return e.account && (c.userAccountAddress = e.account.account.address), X.parse(c);
|
|
652
|
+
}, d = async () => {
|
|
653
|
+
i.onOpen(), await U(
|
|
654
|
+
async () => {
|
|
655
|
+
var P;
|
|
656
|
+
if (e.loading || e.isHuman)
|
|
657
|
+
return;
|
|
658
|
+
a({ loading: !0 }), a({
|
|
659
|
+
attemptCount: e.attemptCount ? e.attemptCount + 1 : 1
|
|
660
|
+
}), a({
|
|
661
|
+
sessionId: t == null ? void 0 : t.sessionId
|
|
662
|
+
});
|
|
663
|
+
const c = s();
|
|
664
|
+
a({ dappAccount: c.account.address }), await de(100);
|
|
665
|
+
const f = await Y();
|
|
666
|
+
let x = e.captchaApi;
|
|
667
|
+
if (t != null && t.provider) {
|
|
668
|
+
const I = t.provider.provider.url, y = await g(I);
|
|
669
|
+
x = new F(
|
|
670
|
+
f.account.address,
|
|
671
|
+
t.provider,
|
|
672
|
+
y,
|
|
673
|
+
c.web2,
|
|
674
|
+
c.account.address || ""
|
|
675
|
+
), a({ captchaApi: x });
|
|
676
|
+
} else {
|
|
677
|
+
const I = await ne(
|
|
678
|
+
s()
|
|
679
|
+
), y = I.provider.url, E = await g(y);
|
|
680
|
+
x = new F(
|
|
681
|
+
f.account.address,
|
|
682
|
+
I,
|
|
683
|
+
E,
|
|
684
|
+
c.web2,
|
|
685
|
+
c.account.address || ""
|
|
686
|
+
), a({ captchaApi: x });
|
|
687
|
+
}
|
|
688
|
+
const p = await (x == null ? void 0 : x.getCaptchaChallenge(
|
|
689
|
+
e.sessionId
|
|
690
|
+
));
|
|
691
|
+
if (p.error)
|
|
692
|
+
a({
|
|
693
|
+
loading: !1,
|
|
694
|
+
error: {
|
|
695
|
+
message: p.error.message,
|
|
696
|
+
key: p.error.key || "API.UNKNOWN_ERROR"
|
|
697
|
+
}
|
|
698
|
+
}), i.onError(new Error((P = p.error) == null ? void 0 : P.message));
|
|
699
|
+
else {
|
|
700
|
+
if (p.captchas.length <= 0)
|
|
701
|
+
throw new _("DEVELOPER.PROVIDER_NO_CAPTCHA");
|
|
702
|
+
const I = p.captchas.map(
|
|
703
|
+
(E) => E.timeLimitMs || c.captchas.image.challengeTimeout
|
|
704
|
+
).reduce((E, L) => E + L), y = setTimeout(() => {
|
|
705
|
+
i.onChallengeExpired(), a({ isHuman: !1, showModal: !1, loading: !1 });
|
|
706
|
+
}, I);
|
|
707
|
+
a({
|
|
708
|
+
index: 0,
|
|
709
|
+
solutions: p.captchas.map(() => []),
|
|
710
|
+
challenge: p,
|
|
711
|
+
showModal: !0,
|
|
712
|
+
timeout: y,
|
|
713
|
+
loading: !1
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
},
|
|
717
|
+
d,
|
|
718
|
+
R,
|
|
719
|
+
e.attemptCount,
|
|
720
|
+
10
|
|
721
|
+
);
|
|
722
|
+
}, u = async () => {
|
|
723
|
+
await U(
|
|
724
|
+
async () => {
|
|
725
|
+
if (T(), !e.challenge)
|
|
726
|
+
throw new v("CAPTCHA.NO_CAPTCHA", {
|
|
727
|
+
context: { error: "Cannot submit, no Captcha found in state" }
|
|
728
|
+
});
|
|
729
|
+
a({ showModal: !1 });
|
|
730
|
+
const c = e.challenge, f = fe(), x = e.challenge.captchas.map(
|
|
731
|
+
(O, ee) => {
|
|
732
|
+
const te = b(e.solutions, ee);
|
|
733
|
+
return {
|
|
734
|
+
captchaId: O.captchaId,
|
|
735
|
+
captchaContentId: O.captchaContentId,
|
|
736
|
+
salt: f,
|
|
737
|
+
solution: te
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
), p = G(), P = Q(p).signer;
|
|
741
|
+
if (!b(c.captchas, 0).datasetId)
|
|
742
|
+
throw new _("CAPTCHA.INVALID_CAPTCHA_ID", {
|
|
743
|
+
context: { error: "No datasetId set for challenge" }
|
|
744
|
+
});
|
|
745
|
+
const y = e.captchaApi;
|
|
746
|
+
if (!y)
|
|
747
|
+
throw new v("CAPTCHA.INVALID_TOKEN", {
|
|
748
|
+
context: { error: "No Captcha API found in state" }
|
|
749
|
+
});
|
|
750
|
+
if (!P || !P.signRaw)
|
|
751
|
+
throw new N("GENERAL.CANT_FIND_KEYRINGPAIR", {
|
|
752
|
+
context: {
|
|
753
|
+
error: "Signer is not defined, cannot sign message to prove account ownership"
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
const E = await P.signRaw({
|
|
757
|
+
address: p.account.address,
|
|
758
|
+
data: me(c[w.timestamp]),
|
|
759
|
+
type: "bytes"
|
|
760
|
+
}), L = await y.submitCaptchaSolution(
|
|
761
|
+
E.signature,
|
|
762
|
+
c.requestHash,
|
|
763
|
+
x,
|
|
764
|
+
c.timestamp,
|
|
765
|
+
c.signature.provider.requestHash
|
|
766
|
+
), J = L[0].verified;
|
|
767
|
+
if (a({
|
|
768
|
+
submission: L,
|
|
769
|
+
isHuman: J,
|
|
770
|
+
loading: !1
|
|
771
|
+
}), e.isHuman) {
|
|
772
|
+
const O = y.provider.provider.url;
|
|
773
|
+
i.onHuman(
|
|
774
|
+
ce({
|
|
775
|
+
[w.providerUrl]: O,
|
|
776
|
+
[w.user]: p.account.address,
|
|
777
|
+
[w.dapp]: Z(),
|
|
778
|
+
[w.commitmentId]: le(L[1]),
|
|
779
|
+
[w.timestamp]: c.timestamp,
|
|
780
|
+
[w.signature]: {
|
|
781
|
+
[w.provider]: {
|
|
782
|
+
[w.requestHash]: c.signature.provider.requestHash
|
|
783
|
+
},
|
|
784
|
+
[w.user]: {
|
|
785
|
+
[w.timestamp]: E.signature
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
})
|
|
789
|
+
), S();
|
|
790
|
+
} else
|
|
791
|
+
i.onFailed(), R(t == null ? void 0 : t.restart);
|
|
792
|
+
},
|
|
793
|
+
d,
|
|
794
|
+
R,
|
|
795
|
+
e.attemptCount,
|
|
796
|
+
10
|
|
797
|
+
);
|
|
798
|
+
}, C = async () => {
|
|
799
|
+
T(), R(t == null ? void 0 : t.restart), i.onClose();
|
|
800
|
+
}, h = async () => {
|
|
801
|
+
T(), i.onReload(), R(t == null ? void 0 : t.restart), t != null && t.restart || await d();
|
|
802
|
+
}, A = (c) => {
|
|
803
|
+
if (!e.challenge)
|
|
804
|
+
throw new v("CAPTCHA.NO_CAPTCHA", {
|
|
805
|
+
context: { error: "Cannot select, no Captcha found in state" }
|
|
806
|
+
});
|
|
807
|
+
if (e.index >= e.challenge.captchas.length || e.index < 0)
|
|
808
|
+
throw new v("CAPTCHA.NO_CAPTCHA", {
|
|
809
|
+
context: {
|
|
810
|
+
error: "Cannot select, index is out of range for this Captcha"
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
const f = e.index, x = e.solutions, p = b(x, f);
|
|
814
|
+
p.includes(c) ? p.splice(p.indexOf(c), 1) : p.push(c), a({ solutions: x });
|
|
815
|
+
}, k = () => {
|
|
816
|
+
if (!e.challenge)
|
|
817
|
+
throw new v("CAPTCHA.NO_CAPTCHA", {
|
|
818
|
+
context: { error: "Cannot select, no Captcha found in state" }
|
|
819
|
+
});
|
|
820
|
+
if (e.index + 1 >= e.challenge.captchas.length)
|
|
821
|
+
throw new v("CAPTCHA.NO_CAPTCHA", {
|
|
822
|
+
context: {
|
|
823
|
+
error: "Cannot select, index is out of range for this Captcha"
|
|
824
|
+
}
|
|
825
|
+
});
|
|
826
|
+
a({ index: e.index + 1 });
|
|
827
|
+
}, g = async (c) => {
|
|
828
|
+
const f = s();
|
|
829
|
+
if (!f.account.address)
|
|
830
|
+
throw new N("GENERAL.SITE_KEY_MISSING");
|
|
831
|
+
return new ae(c, f.account.address);
|
|
832
|
+
}, T = () => {
|
|
833
|
+
window.clearTimeout(Number(e.timeout)), a({ timeout: void 0 });
|
|
834
|
+
}, S = () => {
|
|
835
|
+
const c = r.captchas.image.solutionTimeout, f = setTimeout(() => {
|
|
836
|
+
a({ isHuman: !1 }), i.onExpired();
|
|
837
|
+
}, c);
|
|
838
|
+
a({ successfullChallengeTimeout: f });
|
|
839
|
+
}, R = (c) => {
|
|
840
|
+
T(), a(Ie()), i.onReset(), c && c();
|
|
841
|
+
}, Y = async () => {
|
|
842
|
+
const c = s();
|
|
843
|
+
if (!c.web2 && !c.userAccountAddress)
|
|
844
|
+
throw new N("GENERAL.ACCOUNT_NOT_FOUND", {
|
|
845
|
+
context: { error: "Account address has not been set for web3 mode" }
|
|
846
|
+
});
|
|
847
|
+
const x = await (async () => {
|
|
848
|
+
const p = new (await re(c.web2))();
|
|
849
|
+
return t ? t.userAccount : await p.getAccount(c);
|
|
850
|
+
})();
|
|
851
|
+
return a({ account: x }), G();
|
|
852
|
+
}, G = () => {
|
|
853
|
+
if (!e.account)
|
|
854
|
+
throw new N("GENERAL.ACCOUNT_NOT_FOUND", {
|
|
855
|
+
context: { error: "Account not loaded" }
|
|
856
|
+
});
|
|
857
|
+
return e.account;
|
|
858
|
+
}, Z = () => {
|
|
859
|
+
if (!e.dappAccount)
|
|
860
|
+
throw new N("GENERAL.SITE_KEY_MISSING");
|
|
861
|
+
return e.dappAccount;
|
|
862
|
+
}, Q = (c) => {
|
|
863
|
+
const f = c || G();
|
|
864
|
+
if (!f.extension)
|
|
865
|
+
throw new N("ACCOUNT.NO_POLKADOT_EXTENSION", {
|
|
866
|
+
context: { error: "Extension not loaded" }
|
|
867
|
+
});
|
|
868
|
+
return f.extension;
|
|
869
|
+
};
|
|
870
|
+
return {
|
|
871
|
+
start: d,
|
|
872
|
+
cancel: C,
|
|
873
|
+
submit: u,
|
|
874
|
+
select: A,
|
|
875
|
+
nextRound: k,
|
|
876
|
+
reload: h
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
const He = se`
|
|
880
|
+
position: absolute;
|
|
881
|
+
top: 50%;
|
|
882
|
+
left: 50%;
|
|
883
|
+
transform: translate(-50%, -50%);
|
|
884
|
+
max-width: 500px;
|
|
885
|
+
background-color: transparent;
|
|
886
|
+
border: none;
|
|
887
|
+
border-radius: 4px;
|
|
888
|
+
z-index: 2147483647;
|
|
889
|
+
align-self: center;
|
|
890
|
+
box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px,
|
|
891
|
+
rgba(0, 0, 0, 0.14) 0px 24px 38px 3px,
|
|
892
|
+
rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;
|
|
893
|
+
box-sizing: border-box; /* Ensures border is part of width */
|
|
894
|
+
/* iOS only */
|
|
895
|
+
@supports (-webkit-touch-callout: none) {
|
|
896
|
+
transform: translate(-50%, -100%);
|
|
897
|
+
}
|
|
898
|
+
`, j = ue.memo((r) => {
|
|
899
|
+
const { show: e, children: o } = r, t = {
|
|
900
|
+
position: "fixed",
|
|
901
|
+
zIndex: 2147483646,
|
|
902
|
+
inset: 0,
|
|
903
|
+
display: e ? "flex" : "none",
|
|
904
|
+
alignItems: "center",
|
|
905
|
+
justifyContent: "center",
|
|
906
|
+
minHeight: "100vh"
|
|
907
|
+
};
|
|
908
|
+
return xe.createPortal(
|
|
909
|
+
/* @__PURE__ */ l("div", { className: "prosopo-modalOuter", style: t, children: /* @__PURE__ */ l("div", { className: "prosopo-modalInner", css: He, children: o }) }),
|
|
910
|
+
document.body
|
|
911
|
+
);
|
|
912
|
+
}), K = "procaptcha:execute", Se = (r) => {
|
|
913
|
+
var k;
|
|
914
|
+
const { t: e, ready: o } = V(), n = X.parse(r.config), t = r.frictionlessState, i = r.i18n, a = r.callbacks || {}, [s, d] = ge(m.useState, m.useRef), [u, C] = m.useState(!1), h = Ne(
|
|
915
|
+
n,
|
|
916
|
+
s,
|
|
917
|
+
d,
|
|
918
|
+
a,
|
|
919
|
+
t
|
|
920
|
+
), A = r.config.theme === "light" ? M : D;
|
|
921
|
+
return m.useEffect(() => {
|
|
922
|
+
n.language && (i ? i.language !== n.language && i.changeLanguage(n.language).then((g) => g) : pe().then((g) => {
|
|
923
|
+
g.language !== n.language && g.changeLanguage(n.language).then((T) => T);
|
|
924
|
+
}));
|
|
925
|
+
}, [i, n.language]), m.useEffect(() => {
|
|
926
|
+
s.error && (C(!1), s.error.key === "CAPTCHA.NO_SESSION_FOUND" && t && setTimeout(() => {
|
|
927
|
+
t.restart();
|
|
928
|
+
}, 3e3));
|
|
929
|
+
}, [s.error, t]), m.useEffect(() => {
|
|
930
|
+
const g = (T) => {
|
|
931
|
+
if (d({
|
|
932
|
+
showModal: !0
|
|
933
|
+
}), !s.challenge && h.start)
|
|
934
|
+
try {
|
|
935
|
+
h.start();
|
|
936
|
+
} catch (S) {
|
|
937
|
+
console.error("Error starting verification:", S);
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
return document.addEventListener(K, g), () => {
|
|
941
|
+
document.removeEventListener(
|
|
942
|
+
K,
|
|
943
|
+
g
|
|
944
|
+
);
|
|
945
|
+
};
|
|
946
|
+
}, [h, s.challenge, d]), n.mode === "invisible" ? /* @__PURE__ */ l(j, { show: s.showModal, children: s.challenge ? /* @__PURE__ */ l(
|
|
947
|
+
$,
|
|
948
|
+
{
|
|
949
|
+
challenge: s.challenge,
|
|
950
|
+
index: s.index,
|
|
951
|
+
solutions: s.solutions,
|
|
952
|
+
onSubmit: h.submit,
|
|
953
|
+
onCancel: h.cancel,
|
|
954
|
+
onClick: h.select,
|
|
955
|
+
onNext: h.nextRound,
|
|
956
|
+
onReload: h.reload,
|
|
957
|
+
themeColor: n.theme ?? "light"
|
|
958
|
+
}
|
|
959
|
+
) : null }) : /* @__PURE__ */ H("div", { className: "image-captcha", children: [
|
|
960
|
+
/* @__PURE__ */ l(j, { show: s.showModal, children: s.challenge ? /* @__PURE__ */ l(
|
|
961
|
+
$,
|
|
962
|
+
{
|
|
963
|
+
challenge: s.challenge,
|
|
964
|
+
index: s.index,
|
|
965
|
+
solutions: s.solutions,
|
|
966
|
+
onSubmit: h.submit,
|
|
967
|
+
onCancel: h.cancel,
|
|
968
|
+
onClick: h.select,
|
|
969
|
+
onNext: h.nextRound,
|
|
970
|
+
onReload: h.reload,
|
|
971
|
+
themeColor: n.theme ?? "light"
|
|
972
|
+
}
|
|
973
|
+
) : /* @__PURE__ */ l("div", { children: "No challenge set." }) }),
|
|
974
|
+
/* @__PURE__ */ l(
|
|
975
|
+
ie,
|
|
976
|
+
{
|
|
977
|
+
theme: A,
|
|
978
|
+
onChange: async () => {
|
|
979
|
+
u || (C(!0), await h.start(), C(!1));
|
|
980
|
+
},
|
|
981
|
+
checked: s.isHuman,
|
|
982
|
+
labelText: o ? e("WIDGET.I_AM_HUMAN") : "",
|
|
983
|
+
error: (k = s.error) == null ? void 0 : k.message,
|
|
984
|
+
"aria-label": "human checkbox",
|
|
985
|
+
loading: u
|
|
986
|
+
}
|
|
987
|
+
)
|
|
988
|
+
] });
|
|
989
|
+
};
|
|
990
|
+
export {
|
|
991
|
+
Se as default
|
|
992
|
+
};
|