@prosopo/procaptcha-bundle 2.4.1 → 2.5.0
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/dist/bundle/{ProcaptchaWidget-DOETad4N.js → ProcaptchaWidget-CAyH6qD7.js} +33 -31
- package/dist/bundle/{ProcaptchaWidget-79FRw4Va.js → ProcaptchaWidget-CY3qomFu.js} +153 -149
- package/dist/bundle/{asU8a-2GgUBNjQ.js → asU8a-Br9wz334.js} +1 -1
- package/dist/bundle/{bip39-C01p7UHO.js → bip39-BtaWByKg.js} +7 -7
- package/dist/bundle/browser-ponyfill-Ck_bwPOY.js +339 -0
- package/dist/bundle/{hash-0yoKUuST.js → hash-KElfghPn.js} +7 -7
- package/dist/bundle/{index-Ckreqz7Q.js → index-B0trzdT2.js} +3 -3
- package/dist/bundle/index-Cb-XcaMX.js +4372 -0
- package/dist/bundle/index-VYSrdSle.js +11587 -0
- package/dist/bundle/{index-DlBTo0Xd.js → index-n-2hvBzo.js} +405 -405
- package/dist/bundle/locales/de/translation.json +405 -0
- package/dist/bundle/locales/en/translation.json +405 -0
- package/dist/bundle/locales/es/translation.json +405 -0
- package/dist/bundle/locales/fr/translation.json +405 -0
- package/dist/bundle/locales/it/translation.json +405 -0
- package/dist/bundle/locales/pt/translation.json +405 -0
- package/dist/bundle/locales/pt-BR/translation.json +405 -0
- package/dist/bundle/procaptcha.bundle.js +1 -1
- package/dist/bundle/useTranslation-CcYxvTxi.js +2435 -0
- package/package.json +11 -11
- package/stats.html +1 -1
- package/vite.cjs.config.ts +1 -1
- package/vite.config.ts +32 -1
- package/vite.test.config.ts +1 -1
- package/webpack.config.cjs +1 -1
- package/dist/bundle/index-C8sSamyh.js +0 -6521
- package/dist/bundle/index-DOFIggts.js +0 -17295
- package/dist/bundle/useTranslation-CgamIJ5S.js +0 -550
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { r as x, l as L, d as
|
|
2
|
-
import { u as
|
|
3
|
-
import { h as
|
|
4
|
-
import { r as
|
|
5
|
-
const
|
|
1
|
+
import { r as x, l as L, d as P, j as s, a as b, P as _, b as m, c as T, A as f, e as N, g as oe, p as B, f as re, h as ae, i as K, k as ie, E as se, R as ce, W as j, m as le, C as de, n as he, o as ue, q as pe, s as ge, t as fe, u as me, L as xe, v as Ce, w as be, x as we, y as ye } from "./index-VYSrdSle.js";
|
|
2
|
+
import { u as V, b as Ae, s as Te, a as Ee, c as Ie, l as ve } from "./useTranslation-CcYxvTxi.js";
|
|
3
|
+
import { h as U } from "./hash-KElfghPn.js";
|
|
4
|
+
import { r as Ne } from "./asU8a-Br9wz334.js";
|
|
5
|
+
const He = (t) => Array.isArray(t) && t !== null, G = new Array(256), X = new Array(256 * 256);
|
|
6
6
|
for (let t = 0; t < 256; t++)
|
|
7
7
|
G[t] = t.toString(16).padStart(2, "0");
|
|
8
8
|
for (let t = 0; t < 256; t++) {
|
|
9
9
|
const e = t << 8;
|
|
10
10
|
for (let o = 0; o < 256; o++)
|
|
11
|
-
|
|
11
|
+
X[e | o] = G[t] + G[o];
|
|
12
12
|
}
|
|
13
13
|
function W(t, e) {
|
|
14
14
|
const o = t.length % 2 | 0, i = t.length - o | 0;
|
|
15
15
|
for (let n = 0; n < i; n += 2)
|
|
16
|
-
e +=
|
|
16
|
+
e += X[t[n] << 8 | t[n + 1]];
|
|
17
17
|
return o && (e += G[t[i] | 0]), e;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function De(t, e = -1, o = !0) {
|
|
20
20
|
const i = o ? "0x" : "";
|
|
21
21
|
if (!(t != null && t.length))
|
|
22
22
|
return i;
|
|
@@ -27,7 +27,7 @@ function He(t, e = -1, o = !0) {
|
|
|
27
27
|
}
|
|
28
28
|
return W(t, i);
|
|
29
29
|
}
|
|
30
|
-
const
|
|
30
|
+
const ke = (t) => He(t) ? De(new Uint8Array(t)) : t.toString(), Re = {
|
|
31
31
|
border: "none",
|
|
32
32
|
paddingTop: "6px",
|
|
33
33
|
paddingBottom: "6px",
|
|
@@ -35,10 +35,10 @@ const De = (t) => Ne(t) ? He(new Uint8Array(t)) : t.toString(), ke = {
|
|
|
35
35
|
height: "39px",
|
|
36
36
|
width: "39px",
|
|
37
37
|
borderRadius: "50%"
|
|
38
|
-
},
|
|
39
|
-
const o = x.useMemo(() => t === "light" ? L :
|
|
38
|
+
}, _e = ({ themeColor: t, onReload: e }) => {
|
|
39
|
+
const o = x.useMemo(() => t === "light" ? L : P, [t]), [i, n] = x.useState(!1), a = x.useMemo(() => ({
|
|
40
40
|
...{
|
|
41
|
-
...
|
|
41
|
+
...Re,
|
|
42
42
|
backgroundColor: o.palette.background.default,
|
|
43
43
|
color: i ? o.palette.primary.contrastText : o.palette.background.contrastText
|
|
44
44
|
},
|
|
@@ -46,15 +46,15 @@ const De = (t) => Ne(t) ? He(new Uint8Array(t)) : t.toString(), ke = {
|
|
|
46
46
|
}), [i, o]);
|
|
47
47
|
return s("button", { className: "reload-button", "aria-label": "Reload", type: "button", style: a, onMouseEnter: () => n(!0), onMouseLeave: () => n(!1), onClick: (r) => {
|
|
48
48
|
r.preventDefault(), e();
|
|
49
|
-
}, children:
|
|
50
|
-
},
|
|
49
|
+
}, children: b("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: [s("title", { children: "reload" }), s("path", { fill: a.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" })] }) });
|
|
50
|
+
}, Le = (t) => {
|
|
51
51
|
if (!t.hash)
|
|
52
52
|
throw new _("CAPTCHA.MISSING_ITEM_HASH", {
|
|
53
53
|
context: { item: t }
|
|
54
54
|
});
|
|
55
55
|
return t.hash;
|
|
56
|
-
},
|
|
57
|
-
const n = t.items, a = x.useMemo(() => i === "light" ? L :
|
|
56
|
+
}, Pe = ({ challenge: t, solution: e, onClick: o, themeColor: i }) => {
|
|
57
|
+
const n = t.items, a = x.useMemo(() => i === "light" ? L : P, [i]), r = `${a.spacing.half}px`;
|
|
58
58
|
return s("div", { style: {
|
|
59
59
|
width: "100%",
|
|
60
60
|
height: "100%",
|
|
@@ -65,14 +65,14 @@ const De = (t) => Ne(t) ? He(new Uint8Array(t)) : t.toString(), ke = {
|
|
|
65
65
|
paddingBottom: r,
|
|
66
66
|
paddingRight: r
|
|
67
67
|
}, children: n.map((d, l) => {
|
|
68
|
-
const h =
|
|
68
|
+
const h = Le(d);
|
|
69
69
|
return s("div", { style: {
|
|
70
70
|
flexGrow: 1,
|
|
71
71
|
flexBasis: "33.3333%",
|
|
72
72
|
boxSizing: "border-box",
|
|
73
73
|
paddingLeft: r,
|
|
74
74
|
paddingTop: r
|
|
75
|
-
}, children:
|
|
75
|
+
}, children: b("div", { style: {
|
|
76
76
|
position: "relative",
|
|
77
77
|
cursor: "pointer",
|
|
78
78
|
height: "100%",
|
|
@@ -113,15 +113,15 @@ const De = (t) => Ne(t) ? He(new Uint8Array(t)) : t.toString(), ke = {
|
|
|
113
113
|
}, focusable: "false", color: "#fff", "aria-hidden": "true", viewBox: "0 0 24 24", "data-testid": "CheckIcon", "aria-label": "Check icon", children: s("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) }) })] }) }, d.hash);
|
|
114
114
|
}) });
|
|
115
115
|
};
|
|
116
|
-
function
|
|
116
|
+
function Me(t = {}) {
|
|
117
117
|
return Object.keys(t).reduce((e, o) => ({ ...e, [`data-${o}`]: t[o] }), {});
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function q({ general: t, dev: e }) {
|
|
120
120
|
return {
|
|
121
|
-
...
|
|
121
|
+
...Me(t)
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
-
const
|
|
124
|
+
const Se = {
|
|
125
125
|
display: "inline-flex",
|
|
126
126
|
alignItems: "center",
|
|
127
127
|
justifyContent: "center",
|
|
@@ -148,9 +148,9 @@ const Pe = {
|
|
|
148
148
|
backgroundColor: "#ffffff",
|
|
149
149
|
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"
|
|
150
150
|
}, $ = ({ themeColor: t, buttonType: e, text: o, onClick: i }) => {
|
|
151
|
-
const n = x.useMemo(() => t === "light" ? L :
|
|
151
|
+
const n = x.useMemo(() => t === "light" ? L : P, [t]), [a, r] = x.useState(!1), d = x.useMemo(() => {
|
|
152
152
|
const l = {
|
|
153
|
-
...
|
|
153
|
+
...Se,
|
|
154
154
|
color: a ? n.palette.primary.contrastText : n.palette.background.contrastText
|
|
155
155
|
};
|
|
156
156
|
return e === "cancel" ? {
|
|
@@ -161,11 +161,11 @@ const Pe = {
|
|
|
161
161
|
backgroundColor: a ? n.palette.primary.main : n.palette.background.default
|
|
162
162
|
};
|
|
163
163
|
}, [e, a, n]);
|
|
164
|
-
return s("button", { ...
|
|
164
|
+
return s("button", { ...q({ dev: {} }), onMouseEnter: () => r(!0), onMouseLeave: () => r(!1), style: d, onClick: (l) => {
|
|
165
165
|
l.preventDefault(), i();
|
|
166
166
|
}, "aria-label": o, children: o });
|
|
167
|
-
},
|
|
168
|
-
const { t: h } =
|
|
167
|
+
}, Ge = ({ challenge: t, index: e, solutions: o, onSubmit: i, onCancel: n, onClick: a, onNext: r, onReload: d, themeColor: l }) => {
|
|
168
|
+
const { t: h } = V(), C = t.captchas ? m(t.captchas, e) : null, w = o ? m(o, e) : [], y = x.useMemo(() => l === "light" ? L : P, [l]), H = `${y.spacing.unit}px`, I = `${y.spacing.half}px`;
|
|
169
169
|
return s(x.Suspense, { fallback: s("div", { children: "Loading..." }), children: s("div", { style: {
|
|
170
170
|
overflowX: "auto",
|
|
171
171
|
overflowY: "auto",
|
|
@@ -177,12 +177,12 @@ const Pe = {
|
|
|
177
177
|
border: "1px solid #dddddd",
|
|
178
178
|
boxShadow: "rgba(255, 255, 255, 0.2) 0px 0px 4px",
|
|
179
179
|
borderRadius: "4px",
|
|
180
|
-
backgroundColor:
|
|
180
|
+
backgroundColor: y.palette.background.default,
|
|
181
181
|
userSelect: "none",
|
|
182
182
|
touchAction: "none",
|
|
183
183
|
overscrollBehavior: "none"
|
|
184
|
-
}, children:
|
|
185
|
-
backgroundColor:
|
|
184
|
+
}, children: b("div", { style: {
|
|
185
|
+
backgroundColor: y.palette.background.default,
|
|
186
186
|
display: "flex",
|
|
187
187
|
flexDirection: "column",
|
|
188
188
|
minWidth: "300px"
|
|
@@ -191,15 +191,15 @@ const Pe = {
|
|
|
191
191
|
alignItems: "center",
|
|
192
192
|
width: "100%"
|
|
193
193
|
}, children: s("div", { style: {
|
|
194
|
-
backgroundColor:
|
|
194
|
+
backgroundColor: y.palette.primary.main,
|
|
195
195
|
width: "100%",
|
|
196
|
-
marginTop:
|
|
197
|
-
marginLeft:
|
|
198
|
-
marginRight:
|
|
199
|
-
}, children:
|
|
200
|
-
paddingLeft: `${
|
|
201
|
-
paddingRight: `${
|
|
202
|
-
}, children: [
|
|
196
|
+
marginTop: H,
|
|
197
|
+
marginLeft: H,
|
|
198
|
+
marginRight: H
|
|
199
|
+
}, children: b("div", { style: {
|
|
200
|
+
paddingLeft: `${y.spacing.half}px`,
|
|
201
|
+
paddingRight: `${y.spacing.half}px`
|
|
202
|
+
}, children: [b("p", { style: {
|
|
203
203
|
color: "#ffffff",
|
|
204
204
|
fontWeight: 700,
|
|
205
205
|
lineHeight: 1.5
|
|
@@ -208,26 +208,26 @@ const Pe = {
|
|
|
208
208
|
fontWeight: 500,
|
|
209
209
|
lineHeight: 0.8,
|
|
210
210
|
fontSize: "0.8rem"
|
|
211
|
-
}, children: h("WIDGET.IF_NONE_CLICK_NEXT") })] }) }) }), s("div", { ...
|
|
212
|
-
paddingRight:
|
|
213
|
-
paddingLeft:
|
|
214
|
-
}, children:
|
|
211
|
+
}, children: h("WIDGET.IF_NONE_CLICK_NEXT") })] }) }) }), s("div", { ...q({ dev: {} }), style: {
|
|
212
|
+
paddingRight: I,
|
|
213
|
+
paddingLeft: I
|
|
214
|
+
}, children: C && s(Pe, { challenge: C, solution: w, onClick: a, themeColor: l }) }), s("div", { style: {
|
|
215
215
|
display: "flex",
|
|
216
216
|
alignItems: "center",
|
|
217
217
|
justifyContent: "space-between",
|
|
218
218
|
lineHeight: 1.75,
|
|
219
|
-
padding:
|
|
220
|
-
paddingBottom:
|
|
221
|
-
paddingTop:
|
|
222
|
-
}, children:
|
|
219
|
+
padding: H,
|
|
220
|
+
paddingBottom: I,
|
|
221
|
+
paddingTop: I
|
|
222
|
+
}, children: b("div", { style: {
|
|
223
223
|
display: "grid",
|
|
224
224
|
gridAutoFlow: "column",
|
|
225
225
|
gridTemplateColumns: "repeat(3, minmax(0, 1fr)",
|
|
226
226
|
width: "100%"
|
|
227
|
-
}, children: [s("div", { style: { justifySelf: "left" }, children: s($, { themeColor: l, buttonType: "cancel", onClick: n, text: h("WIDGET.CANCEL"), "aria-label": h("WIDGET.CANCEL") }) }), s("div", { style: { justifySelf: "center" }, children: s(
|
|
227
|
+
}, children: [s("div", { style: { justifySelf: "left" }, children: s($, { themeColor: l, buttonType: "cancel", onClick: n, text: h("WIDGET.CANCEL"), "aria-label": h("WIDGET.CANCEL") }) }), s("div", { style: { justifySelf: "center" }, children: s(_e, { themeColor: l, onReload: d }) }), s("div", { style: { justifySelf: "right" }, children: s($, { themeColor: l, buttonType: "next", text: e < t.captchas.length - 1 ? h("WIDGET.NEXT") : h("WIDGET.SUBMIT"), onClick: e < t.captchas.length - 1 ? r : i, "aria-label": e < t.captchas.length - 1 ? h("WIDGET.NEXT") : h("WIDGET.SUBMIT"), "data-cy": "button-next" }) })] }) })] }) }) });
|
|
228
228
|
};
|
|
229
|
-
function
|
|
230
|
-
return
|
|
229
|
+
function Oe(t) {
|
|
230
|
+
return U([
|
|
231
231
|
t.captchaId,
|
|
232
232
|
t.captchaContentId,
|
|
233
233
|
[...t.solution].sort(),
|
|
@@ -239,13 +239,13 @@ class z {
|
|
|
239
239
|
this.hash = e, this.parent = null;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
class
|
|
242
|
+
class We {
|
|
243
243
|
constructor() {
|
|
244
244
|
this.leaves = [], this.layers = [];
|
|
245
245
|
}
|
|
246
246
|
getRoot() {
|
|
247
247
|
if (this.root === void 0)
|
|
248
|
-
throw new
|
|
248
|
+
throw new T("DATASET.MERKLE_ERROR", {
|
|
249
249
|
context: {
|
|
250
250
|
error: "root undefined",
|
|
251
251
|
failedFuncName: this.getRoot.name
|
|
@@ -272,7 +272,7 @@ class Oe {
|
|
|
272
272
|
for (; n < o; ) {
|
|
273
273
|
const r = e[n];
|
|
274
274
|
if (r === void 0)
|
|
275
|
-
throw new
|
|
275
|
+
throw new T("DEVELOPER.GENERAL", {
|
|
276
276
|
context: { error: "leftChild undefined" }
|
|
277
277
|
});
|
|
278
278
|
const d = n + 1 < o ? m(e, n + 1) : r, l = this.createParent(r, d);
|
|
@@ -281,7 +281,7 @@ class Oe {
|
|
|
281
281
|
return this.layers.push(a), this.buildMerkleTree(i);
|
|
282
282
|
}
|
|
283
283
|
createParent(e, o) {
|
|
284
|
-
const i = new z(
|
|
284
|
+
const i = new z(U([e.hash, o.hash]));
|
|
285
285
|
return e.parent = i.hash, o.parent = i.hash, i;
|
|
286
286
|
}
|
|
287
287
|
proof(e) {
|
|
@@ -290,7 +290,7 @@ class Oe {
|
|
|
290
290
|
for (; i < this.layers.length - 1; ) {
|
|
291
291
|
const a = this.layers[i];
|
|
292
292
|
if (a === void 0)
|
|
293
|
-
throw new
|
|
293
|
+
throw new T("DATASET.MERKLE_ERROR", {
|
|
294
294
|
context: {
|
|
295
295
|
error: "layer undefined",
|
|
296
296
|
failedFuncName: this.proof.name,
|
|
@@ -301,13 +301,13 @@ class Oe {
|
|
|
301
301
|
let d = r % 2 && r > 0 ? r - 1 : r + 1;
|
|
302
302
|
d > a.length - 1 && (d = r);
|
|
303
303
|
const l = [e], h = m(a, d);
|
|
304
|
-
d > r ? l.push(h) : l.unshift(h), o.push([m(l, 0), m(l, 1)]), i += 1, e =
|
|
304
|
+
d > r ? l.push(h) : l.unshift(h), o.push([m(l, 0), m(l, 1)]), i += 1, e = U(l);
|
|
305
305
|
}
|
|
306
306
|
const n = m(this.layers, this.layers.length - 1);
|
|
307
307
|
return [...o, [m(n, 0)]];
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
|
-
class
|
|
310
|
+
class F {
|
|
311
311
|
constructor(e, o, i, n, a) {
|
|
312
312
|
this.userAccount = e, this.provider = o, this.providerApi = i, this._web2 = n, this.dappAccount = a;
|
|
313
313
|
}
|
|
@@ -319,36 +319,35 @@ class We {
|
|
|
319
319
|
const o = await this.providerApi.getCaptchaChallenge(this.userAccount, this.provider, e);
|
|
320
320
|
if (o[f.error])
|
|
321
321
|
return o;
|
|
322
|
-
|
|
323
|
-
for (const
|
|
324
|
-
|
|
325
|
-
n.data && (n.data = n.data.replace(/^http(s)*:\/\//, "//"));
|
|
322
|
+
for (const i of o.captchas)
|
|
323
|
+
for (const n of i.items)
|
|
324
|
+
n.data && (n.data = `https://${n.data.replace(/^http(s)*:\/\//, "")}`);
|
|
326
325
|
return o;
|
|
327
326
|
} catch (o) {
|
|
328
|
-
throw new
|
|
327
|
+
throw new N("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
|
|
329
328
|
context: { error: o }
|
|
330
329
|
});
|
|
331
330
|
}
|
|
332
331
|
}
|
|
333
332
|
async submitCaptchaSolution(e, o, i, n, a) {
|
|
334
|
-
const r = new
|
|
333
|
+
const r = new We(), d = i.map((w) => Oe(w));
|
|
335
334
|
if (r.build(d), !r.root)
|
|
336
335
|
throw new _("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
|
|
337
336
|
context: { error: "Merkle tree root is undefined" }
|
|
338
337
|
});
|
|
339
338
|
const l = r.root.hash, h = void 0;
|
|
340
|
-
let
|
|
339
|
+
let C;
|
|
341
340
|
try {
|
|
342
|
-
|
|
343
|
-
} catch (
|
|
341
|
+
C = await this.providerApi.submitCaptchaSolution(i, o, this.userAccount, n, a, e);
|
|
342
|
+
} catch (w) {
|
|
344
343
|
throw new _("CAPTCHA.INVALID_CAPTCHA_CHALLENGE", {
|
|
345
|
-
context: { error:
|
|
344
|
+
context: { error: w }
|
|
346
345
|
});
|
|
347
346
|
}
|
|
348
|
-
return [
|
|
347
|
+
return [C, l, h];
|
|
349
348
|
}
|
|
350
349
|
}
|
|
351
|
-
const
|
|
350
|
+
const Ue = () => ({
|
|
352
351
|
showModal: !1,
|
|
353
352
|
loading: !1,
|
|
354
353
|
index: 0,
|
|
@@ -358,16 +357,16 @@ const Be = () => ({
|
|
|
358
357
|
captchaApi: void 0,
|
|
359
358
|
account: void 0
|
|
360
359
|
});
|
|
361
|
-
function
|
|
362
|
-
const a =
|
|
360
|
+
function Be(t, e, o, i, n) {
|
|
361
|
+
const a = oe(i), r = Ae(e, o), d = () => {
|
|
363
362
|
const c = {
|
|
364
363
|
userAccountAddress: "",
|
|
365
364
|
...t
|
|
366
365
|
};
|
|
367
|
-
return e.account && (c.userAccountAddress = e.account.account.address),
|
|
366
|
+
return e.account && (c.userAccountAddress = e.account.account.address), K.parse(c);
|
|
368
367
|
}, l = async () => {
|
|
369
|
-
a.onOpen(), await
|
|
370
|
-
var
|
|
368
|
+
a.onOpen(), await B(async () => {
|
|
369
|
+
var D;
|
|
371
370
|
if (e.loading || e.isHuman)
|
|
372
371
|
return;
|
|
373
372
|
r({ loading: !0 }), r({
|
|
@@ -376,177 +375,180 @@ function Ue(t, e, o, i, n) {
|
|
|
376
375
|
sessionId: n == null ? void 0 : n.sessionId
|
|
377
376
|
});
|
|
378
377
|
const c = d();
|
|
379
|
-
r({ dappAccount: c.account.address }), await
|
|
380
|
-
const p = await
|
|
378
|
+
r({ dappAccount: c.account.address }), await Ee(100);
|
|
379
|
+
const p = await Z();
|
|
381
380
|
let g = e.captchaApi;
|
|
382
|
-
if (
|
|
383
|
-
const
|
|
384
|
-
g = new
|
|
381
|
+
if (n != null && n.provider) {
|
|
382
|
+
const v = n.provider.provider.url, A = await I(v);
|
|
383
|
+
g = new F(p.account.address, n.provider, A, c.web2, c.account.address || ""), r({ captchaApi: g });
|
|
384
|
+
} else {
|
|
385
|
+
const v = await ae(d()), A = v.provider.url, E = await I(A);
|
|
386
|
+
g = new F(p.account.address, v, E, c.web2, c.account.address || ""), r({ captchaApi: g });
|
|
385
387
|
}
|
|
386
388
|
const u = await (g == null ? void 0 : g.getCaptchaChallenge(e.sessionId));
|
|
387
389
|
if (u.error)
|
|
388
390
|
r({
|
|
389
391
|
loading: !1,
|
|
390
392
|
error: u.error.message
|
|
391
|
-
}), a.onError(new Error((
|
|
393
|
+
}), a.onError(new Error((D = u.error) == null ? void 0 : D.message));
|
|
392
394
|
else {
|
|
393
395
|
if (u.captchas.length <= 0)
|
|
394
396
|
throw new _("DEVELOPER.PROVIDER_NO_CAPTCHA");
|
|
395
|
-
const
|
|
397
|
+
const v = u.captchas.map((E) => E.timeLimitMs || c.captchas.image.challengeTimeout).reduce((E, R) => E + R), A = setTimeout(() => {
|
|
396
398
|
a.onChallengeExpired(), r({ isHuman: !1, showModal: !1, loading: !1 });
|
|
397
|
-
},
|
|
399
|
+
}, v);
|
|
398
400
|
r({
|
|
399
401
|
index: 0,
|
|
400
402
|
solutions: u.captchas.map(() => []),
|
|
401
403
|
challenge: u,
|
|
402
404
|
showModal: !0,
|
|
403
|
-
timeout:
|
|
405
|
+
timeout: A,
|
|
404
406
|
loading: !1
|
|
405
407
|
});
|
|
406
408
|
}
|
|
407
|
-
}, l,
|
|
409
|
+
}, l, k, e.attemptCount, 10);
|
|
408
410
|
}, h = async () => {
|
|
409
|
-
await
|
|
410
|
-
if (
|
|
411
|
-
throw new
|
|
411
|
+
await B(async () => {
|
|
412
|
+
if (M(), !e.challenge)
|
|
413
|
+
throw new T("CAPTCHA.NO_CAPTCHA", {
|
|
412
414
|
context: { error: "Cannot submit, no Captcha found in state" }
|
|
413
415
|
});
|
|
414
416
|
r({ showModal: !1 });
|
|
415
|
-
const c = e.challenge, p =
|
|
416
|
-
const
|
|
417
|
+
const c = e.challenge, p = Ne(), g = e.challenge.captchas.map((S, te) => {
|
|
418
|
+
const ne = m(e.solutions, te);
|
|
417
419
|
return {
|
|
418
|
-
captchaId:
|
|
419
|
-
captchaContentId:
|
|
420
|
+
captchaId: S.captchaId,
|
|
421
|
+
captchaContentId: S.captchaContentId,
|
|
420
422
|
salt: p,
|
|
421
|
-
solution:
|
|
423
|
+
solution: ne
|
|
422
424
|
};
|
|
423
|
-
}), u = O(),
|
|
425
|
+
}), u = O(), D = Q(u).signer;
|
|
424
426
|
if (!m(c.captchas, 0).datasetId)
|
|
425
427
|
throw new _("CAPTCHA.INVALID_CAPTCHA_ID", {
|
|
426
428
|
context: { error: "No datasetId set for challenge" }
|
|
427
429
|
});
|
|
428
|
-
const
|
|
429
|
-
if (!
|
|
430
|
-
throw new
|
|
430
|
+
const A = e.captchaApi;
|
|
431
|
+
if (!A)
|
|
432
|
+
throw new T("CAPTCHA.INVALID_TOKEN", {
|
|
431
433
|
context: { error: "No Captcha API found in state" }
|
|
432
434
|
});
|
|
433
|
-
if (!
|
|
434
|
-
throw new
|
|
435
|
+
if (!D || !D.signRaw)
|
|
436
|
+
throw new N("GENERAL.CANT_FIND_KEYRINGPAIR", {
|
|
435
437
|
context: {
|
|
436
438
|
error: "Signer is not defined, cannot sign message to prove account ownership"
|
|
437
439
|
}
|
|
438
440
|
});
|
|
439
|
-
const
|
|
441
|
+
const E = await D.signRaw({
|
|
440
442
|
address: u.account.address,
|
|
441
443
|
data: Te(c[f.timestamp]),
|
|
442
444
|
type: "bytes"
|
|
443
|
-
}), R = await
|
|
445
|
+
}), R = await A.submitCaptchaSolution(E.signature, c.requestHash, g, c.timestamp, c.signature.provider.requestHash), ee = R[0].verified;
|
|
444
446
|
if (r({
|
|
445
447
|
submission: R,
|
|
446
|
-
isHuman:
|
|
448
|
+
isHuman: ee,
|
|
447
449
|
loading: !1
|
|
448
450
|
}), e.isHuman) {
|
|
449
|
-
const
|
|
450
|
-
a.onHuman(
|
|
451
|
-
[f.providerUrl]:
|
|
451
|
+
const S = A.provider.provider.url;
|
|
452
|
+
a.onHuman(re({
|
|
453
|
+
[f.providerUrl]: S,
|
|
452
454
|
[f.user]: u.account.address,
|
|
453
|
-
[f.dapp]:
|
|
454
|
-
[f.commitmentId]:
|
|
455
|
+
[f.dapp]: J(),
|
|
456
|
+
[f.commitmentId]: ke(R[1]),
|
|
455
457
|
[f.timestamp]: c.timestamp,
|
|
456
458
|
[f.signature]: {
|
|
457
459
|
[f.provider]: {
|
|
458
460
|
[f.requestHash]: c.signature.provider.requestHash
|
|
459
461
|
},
|
|
460
462
|
[f.user]: {
|
|
461
|
-
[f.timestamp]:
|
|
463
|
+
[f.timestamp]: E.signature
|
|
462
464
|
}
|
|
463
465
|
}
|
|
464
|
-
})),
|
|
466
|
+
})), Y();
|
|
465
467
|
} else
|
|
466
|
-
a.onFailed(),
|
|
467
|
-
}, l,
|
|
468
|
-
},
|
|
469
|
-
|
|
470
|
-
},
|
|
471
|
-
|
|
472
|
-
},
|
|
468
|
+
a.onFailed(), k(n == null ? void 0 : n.restart);
|
|
469
|
+
}, l, k, e.attemptCount, 10);
|
|
470
|
+
}, C = async () => {
|
|
471
|
+
M(), k(n == null ? void 0 : n.restart), a.onClose();
|
|
472
|
+
}, w = async () => {
|
|
473
|
+
M(), a.onReload(), k(n == null ? void 0 : n.restart), n != null && n.restart || await l();
|
|
474
|
+
}, y = (c) => {
|
|
473
475
|
if (!e.challenge)
|
|
474
|
-
throw new
|
|
476
|
+
throw new T("CAPTCHA.NO_CAPTCHA", {
|
|
475
477
|
context: { error: "Cannot select, no Captcha found in state" }
|
|
476
478
|
});
|
|
477
479
|
if (e.index >= e.challenge.captchas.length || e.index < 0)
|
|
478
|
-
throw new
|
|
480
|
+
throw new T("CAPTCHA.NO_CAPTCHA", {
|
|
479
481
|
context: {
|
|
480
482
|
error: "Cannot select, index is out of range for this Captcha"
|
|
481
483
|
}
|
|
482
484
|
});
|
|
483
485
|
const p = e.index, g = e.solutions, u = m(g, p);
|
|
484
486
|
u.includes(c) ? u.splice(u.indexOf(c), 1) : u.push(c), r({ solutions: g });
|
|
485
|
-
},
|
|
487
|
+
}, H = () => {
|
|
486
488
|
if (!e.challenge)
|
|
487
|
-
throw new
|
|
489
|
+
throw new T("CAPTCHA.NO_CAPTCHA", {
|
|
488
490
|
context: { error: "Cannot select, no Captcha found in state" }
|
|
489
491
|
});
|
|
490
492
|
if (e.index + 1 >= e.challenge.captchas.length)
|
|
491
|
-
throw new
|
|
493
|
+
throw new T("CAPTCHA.NO_CAPTCHA", {
|
|
492
494
|
context: {
|
|
493
495
|
error: "Cannot select, index is out of range for this Captcha"
|
|
494
496
|
}
|
|
495
497
|
});
|
|
496
498
|
r({ index: e.index + 1 });
|
|
497
|
-
},
|
|
499
|
+
}, I = async (c) => {
|
|
498
500
|
const p = d();
|
|
499
501
|
if (!p.account.address)
|
|
500
|
-
throw new
|
|
501
|
-
return new
|
|
502
|
-
},
|
|
502
|
+
throw new N("GENERAL.SITE_KEY_MISSING");
|
|
503
|
+
return new ie(c, p.account.address);
|
|
504
|
+
}, M = () => {
|
|
503
505
|
window.clearTimeout(Number(e.timeout)), r({ timeout: void 0 });
|
|
504
|
-
},
|
|
506
|
+
}, Y = () => {
|
|
505
507
|
const c = t.captchas.image.solutionTimeout, p = setTimeout(() => {
|
|
506
508
|
r({ isHuman: !1 }), a.onExpired();
|
|
507
509
|
}, c);
|
|
508
510
|
r({ successfullChallengeTimeout: p });
|
|
509
|
-
},
|
|
510
|
-
|
|
511
|
-
},
|
|
511
|
+
}, k = (c) => {
|
|
512
|
+
M(), r(Ue()), a.onReset(), c && c();
|
|
513
|
+
}, Z = async () => {
|
|
512
514
|
const c = d();
|
|
513
515
|
if (!c.web2 && !c.userAccountAddress)
|
|
514
|
-
throw new
|
|
516
|
+
throw new N("GENERAL.ACCOUNT_NOT_FOUND", {
|
|
515
517
|
context: { error: "Account address has not been set for web3 mode" }
|
|
516
518
|
});
|
|
517
519
|
const g = await (async () => {
|
|
518
|
-
const u = new (await
|
|
520
|
+
const u = new (await se(c.web2))();
|
|
519
521
|
return n ? n.userAccount : await u.getAccount(c);
|
|
520
522
|
})();
|
|
521
523
|
return r({ account: g }), O();
|
|
522
524
|
}, O = () => {
|
|
523
525
|
if (!e.account)
|
|
524
|
-
throw new
|
|
526
|
+
throw new N("GENERAL.ACCOUNT_NOT_FOUND", {
|
|
525
527
|
context: { error: "Account not loaded" }
|
|
526
528
|
});
|
|
527
529
|
return e.account;
|
|
528
|
-
},
|
|
530
|
+
}, J = () => {
|
|
529
531
|
if (!e.dappAccount)
|
|
530
|
-
throw new
|
|
532
|
+
throw new N("GENERAL.SITE_KEY_MISSING");
|
|
531
533
|
return e.dappAccount;
|
|
532
|
-
},
|
|
534
|
+
}, Q = (c) => {
|
|
533
535
|
const p = c || O();
|
|
534
536
|
if (!p.extension)
|
|
535
|
-
throw new
|
|
537
|
+
throw new N("ACCOUNT.NO_POLKADOT_EXTENSION", {
|
|
536
538
|
context: { error: "Extension not loaded" }
|
|
537
539
|
});
|
|
538
540
|
return p.extension;
|
|
539
541
|
};
|
|
540
542
|
return {
|
|
541
543
|
start: l,
|
|
542
|
-
cancel:
|
|
544
|
+
cancel: C,
|
|
543
545
|
submit: h,
|
|
544
|
-
select:
|
|
545
|
-
nextRound:
|
|
546
|
-
reload:
|
|
546
|
+
select: y,
|
|
547
|
+
nextRound: H,
|
|
548
|
+
reload: w
|
|
547
549
|
};
|
|
548
550
|
}
|
|
549
|
-
const je =
|
|
551
|
+
const je = ce.memo((t, e) => {
|
|
550
552
|
const { show: o, children: i } = t, a = {
|
|
551
553
|
position: "fixed",
|
|
552
554
|
zIndex: 2147483646,
|
|
@@ -573,29 +575,31 @@ const je = se.memo((t, e) => {
|
|
|
573
575
|
border: "none",
|
|
574
576
|
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,"
|
|
575
577
|
};
|
|
576
|
-
return
|
|
578
|
+
return b("div", { className: "prosopo-modalOuter", style: a, children: [s("div", { className: "prosopo-modalBackground", style: r }), s("div", { className: "prosopo-modalInner", style: d, children: i })] });
|
|
577
579
|
}), Ve = (t) => {
|
|
578
|
-
const { t: e } =
|
|
580
|
+
const { t: e } = V(), o = K.parse(t.config), i = t.frictionlessState, n = t.callbacks || {}, [a, r] = Ie(x.useState, x.useRef), d = Be(o, a, r, n, i), l = t.config.theme === "light" ? "light" : "dark", h = t.config.theme === "light" ? L : P;
|
|
579
581
|
return x.useEffect(() => {
|
|
580
|
-
o.language &&
|
|
581
|
-
|
|
582
|
+
o.language && ve().then((C) => {
|
|
583
|
+
C.changeLanguage(o.language).then((w) => w);
|
|
584
|
+
});
|
|
585
|
+
}, [o.language]), s("div", { style: { width: "100%", minHeight: j }, children: b("div", { style: {
|
|
582
586
|
maxWidth: le,
|
|
583
587
|
minHeight: j,
|
|
584
588
|
maxHeight: "100%",
|
|
585
589
|
overflowX: "auto",
|
|
586
590
|
width: "100%",
|
|
587
591
|
...h.font
|
|
588
|
-
}, children: [s(je, { show: a.showModal, children: a.challenge ? s(
|
|
589
|
-
padding:
|
|
590
|
-
border:
|
|
592
|
+
}, children: [s(je, { show: a.showModal, children: a.challenge ? s(Ge, { challenge: a.challenge, index: a.index, solutions: a.solutions, onSubmit: d.submit, onCancel: d.cancel, onClick: d.select, onNext: d.nextRound, onReload: d.reload, themeColor: o.theme ?? "light" }) : s("div", { children: "No challenge set." }) }), s(de, { children: s(he, { children: b("div", { style: ue, "data-cy": "button-human", children: [" ", b("div", { style: {
|
|
593
|
+
padding: me,
|
|
594
|
+
border: fe,
|
|
591
595
|
backgroundColor: h.palette.background.default,
|
|
592
596
|
borderColor: h.palette.grey[300],
|
|
593
|
-
borderRadius:
|
|
597
|
+
borderRadius: ge,
|
|
594
598
|
display: "flex",
|
|
595
599
|
alignItems: "center",
|
|
596
600
|
flexWrap: "wrap",
|
|
597
601
|
justifyContent: "space-between",
|
|
598
|
-
minHeight: `${
|
|
602
|
+
minHeight: `${pe}px`,
|
|
599
603
|
overflow: "hidden"
|
|
600
604
|
}, children: [s("div", { style: { display: "inline-flex", flexDirection: "column" }, children: s("div", { style: {
|
|
601
605
|
alignItems: "center",
|
|
@@ -608,7 +612,7 @@ const je = se.memo((t, e) => {
|
|
|
608
612
|
verticalAlign: "middle"
|
|
609
613
|
}, children: s("div", { style: {
|
|
610
614
|
display: "flex"
|
|
611
|
-
}, children: a.loading ? s(xe, { themeColor: l, "aria-label": "Loading spinner" }) : s(Ce, { themeColor: l, onChange: d.start, checked: a.isHuman, labelText: e("WIDGET.I_AM_HUMAN"), error: a.error, "aria-label": "human checkbox" }) }) }) }) }), s("div", { style: { display: "inline-flex", flexDirection: "column" }, children: s("a", { href:
|
|
615
|
+
}, children: a.loading ? s(xe, { themeColor: l, "aria-label": "Loading spinner" }) : s(Ce, { themeColor: l, onChange: d.start, checked: a.isHuman, labelText: e("WIDGET.I_AM_HUMAN"), error: a.error, "aria-label": "human checkbox" }) }) }) }) }), s("div", { style: { display: "inline-flex", flexDirection: "column" }, children: s("a", { href: we, target: "_blank", "aria-label": be, children: s("div", { style: { flex: 1 }, children: s(ye, { themeColor: l, "aria-label": "Prosopo logo" }) }) }) })] })] }) }) })] }) });
|
|
612
616
|
};
|
|
613
617
|
export {
|
|
614
618
|
Ve as default
|