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